| 1 |
// |
| 2 |
// arch/x86_64/rsp/gcc/vabs.s |
| 3 |
// |
| 4 |
// CEN64: Cycle-Accurate Nintendo 64 Emulator. |
| 5 |
// Copyright (C) 2015, Tyler J. Stachecki. |
| 6 |
// |
| 7 |
// This file is subject to the terms and conditions defined in |
| 8 |
// 'LICENSE', which is part of this source code package. |
| 9 |
// |
| 10 |
|
| 11 |
.include "rsp/gcc/defs.h" |
| 12 |
|
| 13 |
.text |
| 14 |
|
| 15 |
.ifdef __MINGW__ |
| 16 |
.globl RSP_VABS |
| 17 |
.def RSP_VABS; .scl 2; .type 32; .endef |
| 18 |
.seh_proc RSP_VABS |
| 19 |
.ifndef __VECTORCALL__ |
| 20 |
RSP_VABS: |
| 21 |
movdqa (%r8), %xmm0 |
| 22 |
movdqa (%r9), %xmm1 |
| 23 |
pxor %xmm2, %xmm2 |
| 24 |
.endif |
| 25 |
.else |
| 26 |
.global RSP_VABS |
| 27 |
.type RSP_VABS, @function |
| 28 |
RSP_VABS: |
| 29 |
.endif |
| 30 |
|
| 31 |
.ifdef __AVX__ |
| 32 |
vpsraw $0xf, %xmm1, %xmm3 |
| 33 |
vpsignw %xmm1, %xmm0, acc_lo |
| 34 |
vpaddw %xmm3, acc_lo, %xmm2 |
| 35 |
vpsubsw %xmm3, %xmm2, %xmm0 |
| 36 |
retq |
| 37 |
|
| 38 |
.elseif __SSSE3__ == 1 |
| 39 |
psignw %xmm1, %xmm0 |
| 40 |
psraw $0xF, %xmm1 |
| 41 |
movdqa %xmm0, acc_lo |
| 42 |
paddw %xmm1, %xmm0 |
| 43 |
psubsw %xmm1, %xmm0 |
| 44 |
retq |
| 45 |
|
| 46 |
.else |
| 47 |
pcmpeqw %xmm1, %xmm2 |
| 48 |
psraw $0xF, %xmm1 |
| 49 |
pandn %xmm0, %xmm2 |
| 50 |
pxor %xmm1, %xmm2 |
| 51 |
movdqa %xmm2, acc_lo |
| 52 |
psubsw %xmm1, %xmm2 |
| 53 |
psubw %xmm1, acc_lo |
| 54 |
movdqa %xmm2, %xmm0 |
| 55 |
retq |
| 56 |
.endif |
| 57 |
|
| 58 |
.ifdef __MINGW__ |
| 59 |
.seh_endproc |
| 60 |
.else |
| 61 |
.size RSP_VABS,.-RSP_VABS |
| 62 |
.endif |
| 63 |
|