media/libvpx/vp8/encoder/x86/fwalsh_sse2.asm

Thu, 15 Jan 2015 15:59:08 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 15 Jan 2015 15:59:08 +0100
branch
TOR_BUG_9701
changeset 10
ac0c01689b40
permissions
-rw-r--r--

Implement a real Private Browsing Mode condition by changing the API/ABI;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 ;
michael@0 2 ; Copyright (c) 2010 The WebM project authors. All Rights Reserved.
michael@0 3 ;
michael@0 4 ; Use of this source code is governed by a BSD-style license
michael@0 5 ; that can be found in the LICENSE file in the root of the source
michael@0 6 ; tree. An additional intellectual property rights grant can be found
michael@0 7 ; in the file PATENTS. All contributing project authors may
michael@0 8 ; be found in the AUTHORS file in the root of the source tree.
michael@0 9 ;
michael@0 10
michael@0 11
michael@0 12 %include "vpx_ports/x86_abi_support.asm"
michael@0 13
michael@0 14 ;void vp8_short_walsh4x4_sse2(short *input, short *output, int pitch)
michael@0 15 global sym(vp8_short_walsh4x4_sse2) PRIVATE
michael@0 16 sym(vp8_short_walsh4x4_sse2):
michael@0 17 push rbp
michael@0 18 mov rbp, rsp
michael@0 19 SHADOW_ARGS_TO_STACK 3
michael@0 20 SAVE_XMM 7
michael@0 21 GET_GOT rbx
michael@0 22 push rsi
michael@0 23 push rdi
michael@0 24 ; end prolog
michael@0 25
michael@0 26 mov rsi, arg(0) ; input
michael@0 27 mov rdi, arg(1) ; output
michael@0 28 movsxd rdx, dword ptr arg(2) ; pitch
michael@0 29
michael@0 30 ; first for loop
michael@0 31 movq xmm0, MMWORD PTR [rsi] ; load input
michael@0 32 movq xmm1, MMWORD PTR [rsi + rdx]
michael@0 33 lea rsi, [rsi + rdx*2]
michael@0 34 movq xmm2, MMWORD PTR [rsi]
michael@0 35 movq xmm3, MMWORD PTR [rsi + rdx]
michael@0 36
michael@0 37 punpcklwd xmm0, xmm1
michael@0 38 punpcklwd xmm2, xmm3
michael@0 39
michael@0 40 movdqa xmm1, xmm0
michael@0 41 punpckldq xmm0, xmm2 ; ip[1] ip[0]
michael@0 42 punpckhdq xmm1, xmm2 ; ip[3] ip[2]
michael@0 43
michael@0 44 movdqa xmm2, xmm0
michael@0 45 paddw xmm0, xmm1
michael@0 46 psubw xmm2, xmm1
michael@0 47
michael@0 48 psllw xmm0, 2 ; d1 a1
michael@0 49 psllw xmm2, 2 ; c1 b1
michael@0 50
michael@0 51 movdqa xmm1, xmm0
michael@0 52 punpcklqdq xmm0, xmm2 ; b1 a1
michael@0 53 punpckhqdq xmm1, xmm2 ; c1 d1
michael@0 54
michael@0 55 pxor xmm6, xmm6
michael@0 56 movq xmm6, xmm0
michael@0 57 pxor xmm7, xmm7
michael@0 58 pcmpeqw xmm7, xmm6
michael@0 59 paddw xmm7, [GLOBAL(c1)]
michael@0 60
michael@0 61 movdqa xmm2, xmm0
michael@0 62 paddw xmm0, xmm1 ; b1+c1 a1+d1
michael@0 63 psubw xmm2, xmm1 ; b1-c1 a1-d1
michael@0 64 paddw xmm0, xmm7 ; b1+c1 a1+d1+(a1!=0)
michael@0 65
michael@0 66 ; second for loop
michael@0 67 ; input: 13 9 5 1 12 8 4 0 (xmm0)
michael@0 68 ; 14 10 6 2 15 11 7 3 (xmm2)
michael@0 69 ; after shuffle:
michael@0 70 ; 13 5 9 1 12 4 8 0 (xmm0)
michael@0 71 ; 14 6 10 2 15 7 11 3 (xmm1)
michael@0 72 pshuflw xmm3, xmm0, 0xd8
michael@0 73 pshufhw xmm0, xmm3, 0xd8
michael@0 74 pshuflw xmm3, xmm2, 0xd8
michael@0 75 pshufhw xmm1, xmm3, 0xd8
michael@0 76
michael@0 77 movdqa xmm2, xmm0
michael@0 78 pmaddwd xmm0, [GLOBAL(c1)] ; d11 a11 d10 a10
michael@0 79 pmaddwd xmm2, [GLOBAL(cn1)] ; c11 b11 c10 b10
michael@0 80 movdqa xmm3, xmm1
michael@0 81 pmaddwd xmm1, [GLOBAL(c1)] ; d12 a12 d13 a13
michael@0 82 pmaddwd xmm3, [GLOBAL(cn1)] ; c12 b12 c13 b13
michael@0 83
michael@0 84 pshufd xmm4, xmm0, 0xd8 ; d11 d10 a11 a10
michael@0 85 pshufd xmm5, xmm2, 0xd8 ; c11 c10 b11 b10
michael@0 86 pshufd xmm6, xmm1, 0x72 ; d13 d12 a13 a12
michael@0 87 pshufd xmm7, xmm3, 0x72 ; c13 c12 b13 b12
michael@0 88
michael@0 89 movdqa xmm0, xmm4
michael@0 90 punpcklqdq xmm0, xmm5 ; b11 b10 a11 a10
michael@0 91 punpckhqdq xmm4, xmm5 ; c11 c10 d11 d10
michael@0 92 movdqa xmm1, xmm6
michael@0 93 punpcklqdq xmm1, xmm7 ; b13 b12 a13 a12
michael@0 94 punpckhqdq xmm6, xmm7 ; c13 c12 d13 d12
michael@0 95
michael@0 96 movdqa xmm2, xmm0
michael@0 97 paddd xmm0, xmm4 ; b21 b20 a21 a20
michael@0 98 psubd xmm2, xmm4 ; c21 c20 d21 d20
michael@0 99 movdqa xmm3, xmm1
michael@0 100 paddd xmm1, xmm6 ; b23 b22 a23 a22
michael@0 101 psubd xmm3, xmm6 ; c23 c22 d23 d22
michael@0 102
michael@0 103 pxor xmm4, xmm4
michael@0 104 movdqa xmm5, xmm4
michael@0 105 pcmpgtd xmm4, xmm0
michael@0 106 pcmpgtd xmm5, xmm2
michael@0 107 pand xmm4, [GLOBAL(cd1)]
michael@0 108 pand xmm5, [GLOBAL(cd1)]
michael@0 109
michael@0 110 pxor xmm6, xmm6
michael@0 111 movdqa xmm7, xmm6
michael@0 112 pcmpgtd xmm6, xmm1
michael@0 113 pcmpgtd xmm7, xmm3
michael@0 114 pand xmm6, [GLOBAL(cd1)]
michael@0 115 pand xmm7, [GLOBAL(cd1)]
michael@0 116
michael@0 117 paddd xmm0, xmm4
michael@0 118 paddd xmm2, xmm5
michael@0 119 paddd xmm0, [GLOBAL(cd3)]
michael@0 120 paddd xmm2, [GLOBAL(cd3)]
michael@0 121 paddd xmm1, xmm6
michael@0 122 paddd xmm3, xmm7
michael@0 123 paddd xmm1, [GLOBAL(cd3)]
michael@0 124 paddd xmm3, [GLOBAL(cd3)]
michael@0 125
michael@0 126 psrad xmm0, 3
michael@0 127 psrad xmm1, 3
michael@0 128 psrad xmm2, 3
michael@0 129 psrad xmm3, 3
michael@0 130 movdqa xmm4, xmm0
michael@0 131 punpcklqdq xmm0, xmm1 ; a23 a22 a21 a20
michael@0 132 punpckhqdq xmm4, xmm1 ; b23 b22 b21 b20
michael@0 133 movdqa xmm5, xmm2
michael@0 134 punpckhqdq xmm2, xmm3 ; c23 c22 c21 c20
michael@0 135 punpcklqdq xmm5, xmm3 ; d23 d22 d21 d20
michael@0 136
michael@0 137 packssdw xmm0, xmm4 ; b23 b22 b21 b20 a23 a22 a21 a20
michael@0 138 packssdw xmm2, xmm5 ; d23 d22 d21 d20 c23 c22 c21 c20
michael@0 139
michael@0 140 movdqa XMMWORD PTR [rdi], xmm0
michael@0 141 movdqa XMMWORD PTR [rdi + 16], xmm2
michael@0 142
michael@0 143 ; begin epilog
michael@0 144 pop rdi
michael@0 145 pop rsi
michael@0 146 RESTORE_GOT
michael@0 147 RESTORE_XMM
michael@0 148 UNSHADOW_ARGS
michael@0 149 pop rbp
michael@0 150 ret
michael@0 151
michael@0 152 SECTION_RODATA
michael@0 153 align 16
michael@0 154 c1:
michael@0 155 dw 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001, 0x0001
michael@0 156 align 16
michael@0 157 cn1:
michael@0 158 dw 0x0001, 0xffff, 0x0001, 0xffff, 0x0001, 0xffff, 0x0001, 0xffff
michael@0 159 align 16
michael@0 160 cd1:
michael@0 161 dd 0x00000001, 0x00000001, 0x00000001, 0x00000001
michael@0 162 align 16
michael@0 163 cd3:
michael@0 164 dd 0x00000003, 0x00000003, 0x00000003, 0x00000003

mercurial