2015-06-09 15:29:47 +00:00
|
|
|
/* Wrapper implementations of vector math functions.
|
2022-01-01 18:54:23 +00:00
|
|
|
Copyright (C) 2014-2022 Free Software Foundation, Inc.
|
2015-06-09 15:29:47 +00:00
|
|
|
This file is part of the GNU C Library.
|
|
|
|
|
|
|
|
The GNU C Library is free software; you can redistribute it and/or
|
|
|
|
modify it under the terms of the GNU Lesser General Public
|
|
|
|
License as published by the Free Software Foundation; either
|
|
|
|
version 2.1 of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
The GNU C Library is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public
|
|
|
|
License along with the GNU C Library; if not, see
|
Prefer https to http for gnu.org and fsf.org URLs
Also, change sources.redhat.com to sourceware.org.
This patch was automatically generated by running the following shell
script, which uses GNU sed, and which avoids modifying files imported
from upstream:
sed -ri '
s,(http|ftp)(://(.*\.)?(gnu|fsf|sourceware)\.org($|[^.]|\.[^a-z])),https\2,g
s,(http|ftp)(://(.*\.)?)sources\.redhat\.com($|[^.]|\.[^a-z]),https\2sourceware.org\4,g
' \
$(find $(git ls-files) -prune -type f \
! -name '*.po' \
! -name 'ChangeLog*' \
! -path COPYING ! -path COPYING.LIB \
! -path manual/fdl-1.3.texi ! -path manual/lgpl-2.1.texi \
! -path manual/texinfo.tex ! -path scripts/config.guess \
! -path scripts/config.sub ! -path scripts/install-sh \
! -path scripts/mkinstalldirs ! -path scripts/move-if-change \
! -path INSTALL ! -path locale/programs/charmap-kw.h \
! -path po/libc.pot ! -path sysdeps/gnu/errlist.c \
! '(' -name configure \
-execdir test -f configure.ac -o -f configure.in ';' ')' \
! '(' -name preconfigure \
-execdir test -f preconfigure.ac ';' ')' \
-print)
and then by running 'make dist-prepare' to regenerate files built
from the altered files, and then executing the following to cleanup:
chmod a+x sysdeps/unix/sysv/linux/riscv/configure
# Omit irrelevant whitespace and comment-only changes,
# perhaps from a slightly-different Autoconf version.
git checkout -f \
sysdeps/csky/configure \
sysdeps/hppa/configure \
sysdeps/riscv/configure \
sysdeps/unix/sysv/linux/csky/configure
# Omit changes that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/powerpc/powerpc64/ppc-mcount.S: trailing lines
git checkout -f \
sysdeps/powerpc/powerpc64/ppc-mcount.S \
sysdeps/unix/sysv/linux/s390/s390-64/syscall.S
# Omit change that caused a pre-commit check to fail like this:
# remote: *** error: sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S: last line does not end in newline
git checkout -f sysdeps/sparc/sparc64/multiarch/memcpy-ultra3.S
2019-09-07 05:40:42 +00:00
|
|
|
<https://www.gnu.org/licenses/>. */
|
2015-06-09 15:29:47 +00:00
|
|
|
|
|
|
|
/* SSE2 ISA version as wrapper to scalar. */
|
|
|
|
.macro WRAPPER_IMPL_SSE2 callee
|
2022-11-19 00:13:31 +00:00
|
|
|
push %rbx
|
|
|
|
cfi_adjust_cfa_offset (8)
|
|
|
|
cfi_rel_offset (%rbx, 0)
|
|
|
|
subq $16, %rsp
|
|
|
|
cfi_adjust_cfa_offset (16)
|
2022-11-19 00:13:30 +00:00
|
|
|
movaps %xmm0, (%rsp)
|
|
|
|
call JUMPTARGET(\callee)
|
2022-11-19 00:13:31 +00:00
|
|
|
movss %xmm0, (%rsp)
|
2022-11-19 00:13:30 +00:00
|
|
|
movss 4(%rsp), %xmm0
|
|
|
|
call JUMPTARGET(\callee)
|
2022-11-19 00:13:31 +00:00
|
|
|
movss %xmm0, 4(%rsp)
|
2022-11-19 00:13:30 +00:00
|
|
|
movss 8(%rsp), %xmm0
|
|
|
|
call JUMPTARGET(\callee)
|
2022-11-19 00:13:31 +00:00
|
|
|
movd %xmm0, %ebx
|
2022-11-19 00:13:30 +00:00
|
|
|
movss 12(%rsp), %xmm0
|
|
|
|
call JUMPTARGET(\callee)
|
2022-11-19 00:13:31 +00:00
|
|
|
movd %ebx, %xmm1
|
|
|
|
unpcklps %xmm0, %xmm1
|
|
|
|
movsd (%rsp), %xmm0
|
|
|
|
unpcklpd %xmm1, %xmm0
|
|
|
|
addq $16, %rsp
|
|
|
|
cfi_adjust_cfa_offset (-16)
|
|
|
|
popq %rbx
|
|
|
|
cfi_adjust_cfa_offset (-8)
|
|
|
|
cfi_restore (%rbx)
|
2022-11-19 00:13:30 +00:00
|
|
|
ret
|
2015-06-09 15:29:47 +00:00
|
|
|
.endm
|
|
|
|
|
2015-06-18 14:04:07 +00:00
|
|
|
/* 2 argument SSE2 ISA version as wrapper to scalar. */
|
|
|
|
.macro WRAPPER_IMPL_SSE2_ff callee
|
2022-11-19 00:13:31 +00:00
|
|
|
push %rbx
|
|
|
|
cfi_adjust_cfa_offset (8)
|
|
|
|
cfi_rel_offset (%rbx, 0)
|
|
|
|
subq $32, %rsp
|
|
|
|
cfi_adjust_cfa_offset (40)
|
2022-11-19 00:13:30 +00:00
|
|
|
movaps %xmm0, (%rsp)
|
|
|
|
movaps %xmm1, 16(%rsp)
|
|
|
|
call JUMPTARGET(\callee)
|
|
|
|
movss 20(%rsp), %xmm1
|
2022-11-19 00:13:31 +00:00
|
|
|
movss %xmm0, 0(%rsp)
|
|
|
|
movss 4(%rsp), %xmm0
|
2022-11-19 00:13:30 +00:00
|
|
|
call JUMPTARGET(\callee)
|
|
|
|
movss 24(%rsp), %xmm1
|
2022-11-19 00:13:31 +00:00
|
|
|
movss %xmm0, 4(%rsp)
|
|
|
|
movss 8(%rsp), %xmm0
|
2022-11-19 00:13:30 +00:00
|
|
|
call JUMPTARGET(\callee)
|
|
|
|
movss 28(%rsp), %xmm1
|
2022-11-19 00:13:31 +00:00
|
|
|
movd %xmm0, %ebx
|
|
|
|
movss 12(%rsp), %xmm0
|
2022-11-19 00:13:30 +00:00
|
|
|
call JUMPTARGET(\callee)
|
2022-11-19 00:13:31 +00:00
|
|
|
/* merge 4x results into xmm0. */
|
|
|
|
movd %ebx, %xmm1
|
|
|
|
unpcklps %xmm0, %xmm1
|
|
|
|
movsd (%rsp), %xmm0
|
|
|
|
unpcklpd %xmm1, %xmm0
|
|
|
|
addq $32, %rsp
|
|
|
|
cfi_adjust_cfa_offset (-32)
|
|
|
|
popq %rbx
|
|
|
|
cfi_adjust_cfa_offset (-8)
|
|
|
|
cfi_restore (%rbx)
|
2022-11-19 00:13:30 +00:00
|
|
|
ret
|
2015-06-18 14:04:07 +00:00
|
|
|
.endm
|
|
|
|
|
2015-06-18 17:11:27 +00:00
|
|
|
/* 3 argument SSE2 ISA version as wrapper to scalar. */
|
|
|
|
.macro WRAPPER_IMPL_SSE2_fFF callee
|
2022-11-19 00:13:30 +00:00
|
|
|
pushq %rbp
|
|
|
|
cfi_adjust_cfa_offset (8)
|
|
|
|
cfi_rel_offset (%rbp, 0)
|
|
|
|
pushq %rbx
|
|
|
|
cfi_adjust_cfa_offset (8)
|
|
|
|
cfi_rel_offset (%rbx, 0)
|
|
|
|
movq %rdi, %rbp
|
|
|
|
movq %rsi, %rbx
|
2022-11-19 00:13:31 +00:00
|
|
|
subq $24, %rsp
|
|
|
|
cfi_adjust_cfa_offset (24)
|
2022-11-19 00:13:30 +00:00
|
|
|
movaps %xmm0, (%rsp)
|
|
|
|
call JUMPTARGET(\callee)
|
2022-11-19 00:13:31 +00:00
|
|
|
movss 4(%rsp), %xmm0
|
|
|
|
leaq 4(%rbp), %rdi
|
|
|
|
leaq 4(%rbx), %rsi
|
2022-11-19 00:13:30 +00:00
|
|
|
call JUMPTARGET(\callee)
|
2022-11-19 00:13:31 +00:00
|
|
|
movss 8(%rsp), %xmm0
|
|
|
|
leaq 8(%rbp), %rdi
|
|
|
|
leaq 8(%rbx), %rsi
|
2022-11-19 00:13:30 +00:00
|
|
|
call JUMPTARGET(\callee)
|
2022-11-19 00:13:31 +00:00
|
|
|
movss 12(%rsp), %xmm0
|
|
|
|
leaq 12(%rbp), %rdi
|
|
|
|
leaq 12(%rbx), %rsi
|
2022-11-19 00:13:30 +00:00
|
|
|
call JUMPTARGET(\callee)
|
2022-11-19 00:13:31 +00:00
|
|
|
addq $24, %rsp
|
|
|
|
cfi_adjust_cfa_offset (-24)
|
2022-11-19 00:13:30 +00:00
|
|
|
popq %rbx
|
|
|
|
cfi_adjust_cfa_offset (-8)
|
|
|
|
cfi_restore (%rbx)
|
|
|
|
popq %rbp
|
|
|
|
cfi_adjust_cfa_offset (-8)
|
|
|
|
cfi_restore (%rbp)
|
|
|
|
ret
|
2015-06-18 17:11:27 +00:00
|
|
|
.endm
|
|
|
|
|
2015-06-09 15:29:47 +00:00
|
|
|
/* AVX/AVX2 ISA version as wrapper to SSE ISA version. */
|
|
|
|
.macro WRAPPER_IMPL_AVX callee
|
2022-11-19 00:13:30 +00:00
|
|
|
pushq %rbp
|
|
|
|
cfi_adjust_cfa_offset (8)
|
|
|
|
cfi_rel_offset (%rbp, 0)
|
|
|
|
movq %rsp, %rbp
|
|
|
|
cfi_def_cfa_register (%rbp)
|
|
|
|
andq $-32, %rsp
|
|
|
|
subq $32, %rsp
|
2022-11-19 00:13:31 +00:00
|
|
|
vmovaps %ymm0, (%rsp)
|
2022-11-19 00:13:30 +00:00
|
|
|
vzeroupper
|
|
|
|
call HIDDEN_JUMPTARGET(\callee)
|
2022-11-19 00:13:31 +00:00
|
|
|
vmovaps %xmm0, (%rsp)
|
2022-11-19 00:13:30 +00:00
|
|
|
vmovaps 16(%rsp), %xmm0
|
2022-11-19 00:13:31 +00:00
|
|
|
call HIDDEN_JUMPTARGET(\callee)
|
|
|
|
/* combine xmm0 (return of second call) with result of first
|
|
|
|
call (saved on stack). Might be worth exploring logic that
|
|
|
|
uses `vpblend` and reads in ymm1 using -16(rsp). */
|
|
|
|
vmovaps (%rsp), %xmm1
|
|
|
|
vinsertf128 $1, %xmm0, %ymm1, %ymm0
|
2022-11-19 00:13:30 +00:00
|
|
|
movq %rbp, %rsp
|
|
|
|
cfi_def_cfa_register (%rsp)
|
|
|
|
popq %rbp
|
|
|
|
cfi_adjust_cfa_offset (-8)
|
|
|
|
cfi_restore (%rbp)
|
|
|
|
ret
|
2015-06-09 15:29:47 +00:00
|
|
|
.endm
|
|
|
|
|
2015-06-18 14:04:07 +00:00
|
|
|
/* 2 argument AVX/AVX2 ISA version as wrapper to SSE ISA version. */
|
|
|
|
.macro WRAPPER_IMPL_AVX_ff callee
|
2022-11-19 00:13:30 +00:00
|
|
|
pushq %rbp
|
|
|
|
cfi_adjust_cfa_offset (8)
|
|
|
|
cfi_rel_offset (%rbp, 0)
|
|
|
|
movq %rsp, %rbp
|
|
|
|
cfi_def_cfa_register (%rbp)
|
|
|
|
andq $-32, %rsp
|
|
|
|
subq $64, %rsp
|
2022-11-19 00:13:31 +00:00
|
|
|
vmovaps %ymm0, (%rsp)
|
|
|
|
vmovaps %ymm1, 32(%rsp)
|
2022-11-19 00:13:30 +00:00
|
|
|
vzeroupper
|
|
|
|
call HIDDEN_JUMPTARGET(\callee)
|
2022-11-19 00:13:31 +00:00
|
|
|
vmovaps 48(%rsp), %xmm1
|
|
|
|
vmovaps %xmm0, (%rsp)
|
2022-11-19 00:13:30 +00:00
|
|
|
vmovaps 16(%rsp), %xmm0
|
|
|
|
call HIDDEN_JUMPTARGET(\callee)
|
2022-11-19 00:13:31 +00:00
|
|
|
/* combine xmm0 (return of second call) with result of first
|
|
|
|
call (saved on stack). Might be worth exploring logic that
|
|
|
|
uses `vpblend` and reads in ymm1 using -16(rsp). */
|
|
|
|
vmovaps (%rsp), %xmm1
|
|
|
|
vinsertf128 $1, %xmm0, %ymm1, %ymm0
|
2022-11-19 00:13:30 +00:00
|
|
|
movq %rbp, %rsp
|
|
|
|
cfi_def_cfa_register (%rsp)
|
|
|
|
popq %rbp
|
|
|
|
cfi_adjust_cfa_offset (-8)
|
|
|
|
cfi_restore (%rbp)
|
|
|
|
ret
|
2015-06-18 14:04:07 +00:00
|
|
|
.endm
|
|
|
|
|
2015-06-18 17:11:27 +00:00
|
|
|
/* 3 argument AVX/AVX2 ISA version as wrapper to SSE ISA version. */
|
|
|
|
.macro WRAPPER_IMPL_AVX_fFF callee
|
2022-11-19 00:13:30 +00:00
|
|
|
pushq %rbp
|
|
|
|
cfi_adjust_cfa_offset (8)
|
|
|
|
cfi_rel_offset (%rbp, 0)
|
|
|
|
movq %rsp, %rbp
|
|
|
|
andq $-32, %rsp
|
2022-11-19 00:13:31 +00:00
|
|
|
subq $32, %rsp
|
|
|
|
vmovaps %ymm0, (%rsp)
|
|
|
|
pushq %rbx
|
2022-11-19 00:13:30 +00:00
|
|
|
pushq %r14
|
2022-11-19 00:13:31 +00:00
|
|
|
movq %rdi, %rbx
|
2022-11-19 00:13:30 +00:00
|
|
|
movq %rsi, %r14
|
|
|
|
vzeroupper
|
|
|
|
call HIDDEN_JUMPTARGET(\callee)
|
|
|
|
vmovaps 32(%rsp), %xmm0
|
2022-11-19 00:13:31 +00:00
|
|
|
leaq 16(%rbx), %rdi
|
|
|
|
leaq 16(%r14), %rsi
|
2022-11-19 00:13:30 +00:00
|
|
|
call HIDDEN_JUMPTARGET(\callee)
|
|
|
|
popq %r14
|
2022-11-19 00:13:31 +00:00
|
|
|
popq %rbx
|
2022-11-19 00:13:30 +00:00
|
|
|
movq %rbp, %rsp
|
|
|
|
cfi_def_cfa_register (%rsp)
|
|
|
|
popq %rbp
|
|
|
|
cfi_adjust_cfa_offset (-8)
|
|
|
|
cfi_restore (%rbp)
|
|
|
|
ret
|
2015-06-18 17:11:27 +00:00
|
|
|
.endm
|
|
|
|
|
2015-06-09 15:29:47 +00:00
|
|
|
/* AVX512 ISA version as wrapper to AVX2 ISA version. */
|
|
|
|
.macro WRAPPER_IMPL_AVX512 callee
|
2022-11-19 00:13:30 +00:00
|
|
|
pushq %rbp
|
|
|
|
cfi_adjust_cfa_offset (8)
|
|
|
|
cfi_rel_offset (%rbp, 0)
|
|
|
|
movq %rsp, %rbp
|
|
|
|
cfi_def_cfa_register (%rbp)
|
|
|
|
andq $-64, %rsp
|
2022-11-19 00:13:31 +00:00
|
|
|
subq $64, %rsp
|
2022-11-19 00:13:30 +00:00
|
|
|
vmovups %zmm0, (%rsp)
|
|
|
|
call HIDDEN_JUMPTARGET(\callee)
|
2022-11-19 00:13:31 +00:00
|
|
|
vmovupd %ymm0, (%rsp)
|
2022-11-19 00:13:30 +00:00
|
|
|
vmovupd 32(%rsp), %ymm0
|
|
|
|
call HIDDEN_JUMPTARGET(\callee)
|
2022-11-19 00:13:31 +00:00
|
|
|
/* combine ymm0 (return of second call) with result of first
|
|
|
|
call (saved on stack). */
|
|
|
|
vmovaps (%rsp), %ymm1
|
|
|
|
vinserti64x4 $0x1, %ymm0, %zmm1, %zmm0
|
2022-11-19 00:13:30 +00:00
|
|
|
movq %rbp, %rsp
|
|
|
|
cfi_def_cfa_register (%rsp)
|
|
|
|
popq %rbp
|
|
|
|
cfi_adjust_cfa_offset (-8)
|
|
|
|
cfi_restore (%rbp)
|
|
|
|
ret
|
2015-06-09 15:29:47 +00:00
|
|
|
.endm
|
2015-06-18 14:04:07 +00:00
|
|
|
|
|
|
|
/* 2 argument AVX512 ISA version as wrapper to AVX2 ISA version. */
|
|
|
|
.macro WRAPPER_IMPL_AVX512_ff callee
|
2022-11-19 00:13:30 +00:00
|
|
|
pushq %rbp
|
|
|
|
cfi_adjust_cfa_offset (8)
|
|
|
|
cfi_rel_offset (%rbp, 0)
|
|
|
|
movq %rsp, %rbp
|
|
|
|
cfi_def_cfa_register (%rbp)
|
|
|
|
andq $-64, %rsp
|
2022-11-19 00:13:31 +00:00
|
|
|
addq $-128, %rsp
|
2022-11-19 00:13:30 +00:00
|
|
|
vmovups %zmm0, (%rsp)
|
|
|
|
vmovups %zmm1, 64(%rsp)
|
2022-11-19 00:13:31 +00:00
|
|
|
/* ymm0 and ymm1 are already set. */
|
2022-11-19 00:13:30 +00:00
|
|
|
call HIDDEN_JUMPTARGET(\callee)
|
|
|
|
vmovups 96(%rsp), %ymm1
|
2022-11-19 00:13:31 +00:00
|
|
|
vmovaps %ymm0, (%rsp)
|
|
|
|
vmovups 32(%rsp), %ymm0
|
2022-11-19 00:13:30 +00:00
|
|
|
call HIDDEN_JUMPTARGET(\callee)
|
2022-11-19 00:13:31 +00:00
|
|
|
/* combine ymm0 (return of second call) with result of first
|
|
|
|
call (saved on stack). */
|
|
|
|
vmovaps (%rsp), %ymm1
|
|
|
|
vinserti64x4 $0x1, %ymm0, %zmm1, %zmm0
|
2022-11-19 00:13:30 +00:00
|
|
|
movq %rbp, %rsp
|
|
|
|
cfi_def_cfa_register (%rsp)
|
|
|
|
popq %rbp
|
|
|
|
cfi_adjust_cfa_offset (-8)
|
|
|
|
cfi_restore (%rbp)
|
|
|
|
ret
|
2015-06-18 17:11:27 +00:00
|
|
|
.endm
|
|
|
|
|
|
|
|
/* 3 argument AVX512 ISA version as wrapper to AVX2 ISA version. */
|
|
|
|
.macro WRAPPER_IMPL_AVX512_fFF callee
|
2022-11-19 00:13:30 +00:00
|
|
|
pushq %rbp
|
|
|
|
cfi_adjust_cfa_offset (8)
|
|
|
|
cfi_rel_offset (%rbp, 0)
|
|
|
|
movq %rsp, %rbp
|
|
|
|
cfi_def_cfa_register (%rbp)
|
|
|
|
andq $-64, %rsp
|
2022-11-19 00:13:31 +00:00
|
|
|
subq $64, %rsp
|
2022-11-19 00:13:30 +00:00
|
|
|
vmovaps %zmm0, (%rsp)
|
2022-11-19 00:13:31 +00:00
|
|
|
pushq %rbx
|
|
|
|
pushq %r14
|
|
|
|
movq %rdi, %rbx
|
|
|
|
movq %rsi, %r14
|
|
|
|
/* ymm0 is already set. */
|
2022-11-19 00:13:30 +00:00
|
|
|
call HIDDEN_JUMPTARGET(\callee)
|
2022-11-19 00:13:31 +00:00
|
|
|
vmovaps 48(%rsp), %ymm0
|
|
|
|
leaq 32(%rbx), %rdi
|
|
|
|
leaq 32(%r14), %rsi
|
2022-11-19 00:13:30 +00:00
|
|
|
call HIDDEN_JUMPTARGET(\callee)
|
2022-11-19 00:13:31 +00:00
|
|
|
popq %r14
|
|
|
|
popq %rbx
|
2022-11-19 00:13:30 +00:00
|
|
|
movq %rbp, %rsp
|
|
|
|
cfi_def_cfa_register (%rsp)
|
|
|
|
popq %rbp
|
|
|
|
cfi_adjust_cfa_offset (-8)
|
|
|
|
cfi_restore (%rbp)
|
|
|
|
ret
|
2015-06-18 14:04:07 +00:00
|
|
|
.endm
|