old-cross-binutils/gdb/testsuite/gdb.arch/i386-avx.c

129 lines
4.3 KiB
C
Raw Normal View History

Support amd64 AVX. gdb/ 2010-04-07 H.J. Lu <hongjiu.lu@intel.com> * amd64-linux-nat.c: Include "regset.h", "elf/common.h", <sys/uio.h> and "i386-xstate.h". (PTRACE_GETREGSET): New. (PTRACE_SETREGSET): Likewise. (have_ptrace_getregset): Likewise. (amd64_linux_gregset64_reg_offset): Include 16 upper YMM registers. (amd64_linux_gregset32_reg_offset): Include 8 upper YMM registers. (amd64_linux_fetch_inferior_registers): Support PTRACE_GETFPREGS. (amd64_linux_store_inferior_registers): Likewise. (amd64_linux_read_description): Check and enable AVX target descriptions. * amd64-linux-tdep.c: Include "regset.h", "i386-linux-tdep.h" and "features/i386/amd64-avx-linux.c". (amd64_linux_regset_sections): New. (amd64_linux_core_read_description): Check and enable AVX target description. (amd64_linux_init_abi): Set xsave_xcr0_offset. Call set_gdbarch_core_regset_sections. (_initialize_amd64_linux_tdep): Call initialize_tdesc_amd64_avx_linux. * amd64-linux-tdep.h (AMD64_LINUX_ORIG_RAX_REGNUM): Replace AMD64_MXCSR_REGNUM with AMD64_YMM15H_REGNUM. (tdesc_amd64_avx_linux): New. (amd64_linux_update_xstateregset): Likewise. * amd64-tdep.c: Include "features/i386/amd64-avx.c". (amd64_ymm_names): New. (amd64_ymmh_names): Likewise. (amd64_register_name): Likewise. (amd64_supply_xstateregset): Likewise. (amd64_collect_xstateregset): Likewise. (amd64_supply_xsave): Likewise. (amd64_collect_xsave): Likewise. (AMD64_NUM_REGS): Removed. (amd64_dwarf_reg_to_regnum): Return %ymmN register number for %xmmN if AVX is available. (amd64_pseudo_register_name): Support pseudo YMM registers. (amd64_regset_from_core_section): Support .reg-xstate section. (amd64_init_abi): Set ymmh_register_names, num_ymm_regs and ymm0h_regnum. Call set_gdbarch_register_name. (amd64_init_abi): Call initialize_tdesc_amd64_avx. * amd64-tdep.h (amd64_regnum): Add AMD64_YMM0H_REGNUM and AMD64_YMM15H_REGNUM. (AMD64_NUM_REGS): New. (amd64_supply_xsave): Likewise. (amd64_collect_xsave): Likewise. (amd64_register_name): Removed. (amd64_register_type): Likewise. gdb/testsuite/ 2010-04-07 H.J. Lu <hongjiu.lu@intel.com> * gdb.arch/i386-avx.c: New. * gdb.arch/i386-avx.exp: Likewise. * gdb.arch/i386-cpuid.h: Updated from gcc 4.4.
2010-04-07 18:46:50 +00:00
/* Test program for AVX registers.
Copyright 2010-2014 Free Software Foundation, Inc.
Support amd64 AVX. gdb/ 2010-04-07 H.J. Lu <hongjiu.lu@intel.com> * amd64-linux-nat.c: Include "regset.h", "elf/common.h", <sys/uio.h> and "i386-xstate.h". (PTRACE_GETREGSET): New. (PTRACE_SETREGSET): Likewise. (have_ptrace_getregset): Likewise. (amd64_linux_gregset64_reg_offset): Include 16 upper YMM registers. (amd64_linux_gregset32_reg_offset): Include 8 upper YMM registers. (amd64_linux_fetch_inferior_registers): Support PTRACE_GETFPREGS. (amd64_linux_store_inferior_registers): Likewise. (amd64_linux_read_description): Check and enable AVX target descriptions. * amd64-linux-tdep.c: Include "regset.h", "i386-linux-tdep.h" and "features/i386/amd64-avx-linux.c". (amd64_linux_regset_sections): New. (amd64_linux_core_read_description): Check and enable AVX target description. (amd64_linux_init_abi): Set xsave_xcr0_offset. Call set_gdbarch_core_regset_sections. (_initialize_amd64_linux_tdep): Call initialize_tdesc_amd64_avx_linux. * amd64-linux-tdep.h (AMD64_LINUX_ORIG_RAX_REGNUM): Replace AMD64_MXCSR_REGNUM with AMD64_YMM15H_REGNUM. (tdesc_amd64_avx_linux): New. (amd64_linux_update_xstateregset): Likewise. * amd64-tdep.c: Include "features/i386/amd64-avx.c". (amd64_ymm_names): New. (amd64_ymmh_names): Likewise. (amd64_register_name): Likewise. (amd64_supply_xstateregset): Likewise. (amd64_collect_xstateregset): Likewise. (amd64_supply_xsave): Likewise. (amd64_collect_xsave): Likewise. (AMD64_NUM_REGS): Removed. (amd64_dwarf_reg_to_regnum): Return %ymmN register number for %xmmN if AVX is available. (amd64_pseudo_register_name): Support pseudo YMM registers. (amd64_regset_from_core_section): Support .reg-xstate section. (amd64_init_abi): Set ymmh_register_names, num_ymm_regs and ymm0h_regnum. Call set_gdbarch_register_name. (amd64_init_abi): Call initialize_tdesc_amd64_avx. * amd64-tdep.h (amd64_regnum): Add AMD64_YMM0H_REGNUM and AMD64_YMM15H_REGNUM. (AMD64_NUM_REGS): New. (amd64_supply_xsave): Likewise. (amd64_collect_xsave): Likewise. (amd64_register_name): Removed. (amd64_register_type): Likewise. gdb/testsuite/ 2010-04-07 H.J. Lu <hongjiu.lu@intel.com> * gdb.arch/i386-avx.c: New. * gdb.arch/i386-avx.exp: Likewise. * gdb.arch/i386-cpuid.h: Updated from gcc 4.4.
2010-04-07 18:46:50 +00:00
This file is part of GDB.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program 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 General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <stdio.h>
#include "i386-cpuid.h"
typedef struct {
float f[8];
} v8sf_t;
v8sf_t data[] =
{
{ { 0.0, 0.125, 0.25, 0.375, 0.50, 0.625, 0.75, 0.875 } },
{ { 1.0, 1.125, 1.25, 1.375, 1.50, 1.625, 1.75, 1.875 } },
{ { 2.0, 2.125, 2.25, 2.375, 2.50, 2.625, 2.75, 2.875 } },
{ { 3.0, 3.125, 3.25, 3.375, 3.50, 3.625, 3.75, 3.875 } },
{ { 4.0, 4.125, 4.25, 4.375, 4.50, 4.625, 4.75, 4.875 } },
{ { 5.0, 5.125, 5.25, 5.375, 5.50, 5.625, 5.75, 5.875 } },
{ { 6.0, 6.125, 6.25, 6.375, 6.50, 6.625, 6.75, 6.875 } },
{ { 7.0, 7.125, 7.25, 7.375, 7.50, 7.625, 7.75, 7.875 } },
#ifdef __x86_64__
{ { 8.0, 8.125, 8.25, 8.375, 8.50, 8.625, 8.75, 8.875 } },
{ { 9.0, 9.125, 9.25, 9.375, 9.50, 9.625, 9.75, 9.875 } },
{ { 10.0, 10.125, 10.25, 10.375, 10.50, 10.625, 10.75, 10.875 } },
{ { 11.0, 11.125, 11.25, 11.375, 11.50, 11.625, 11.75, 11.875 } },
{ { 12.0, 12.125, 12.25, 12.375, 12.50, 12.625, 12.75, 12.875 } },
{ { 13.0, 13.125, 13.25, 13.375, 13.50, 13.625, 13.75, 13.875 } },
{ { 14.0, 14.125, 14.25, 14.375, 14.50, 14.625, 14.75, 14.875 } },
{ { 15.0, 15.125, 15.25, 15.375, 15.50, 15.625, 15.75, 15.875 } },
#endif
};
int
have_avx (void)
{
unsigned int eax, ebx, ecx, edx;
gdb: clean up x86 cpuid implementations We've currently got 3 files doing open coded implementations of cpuid. Each has its own set of workarounds and varying levels of how well they're written and are generally hardcoded to specific cpuid functions. If you try to build the latest gdb as a PIE on an i386 system, the build will fail because one of them lacks PIC workarounds (wrt ebx). Specifically, we have: common/linux-btrace.c: two copies of cpuid asm w/specific args, one has no workarounds while the other implicitly does to avoid memcpy go32-nat.c: two copies of cpuid asm w/specific args, one has workarounds to avoid memcpy gdb/testsuite/gdb.arch/i386-cpuid.h: one general cpuid asm w/many workarounds copied from older gcc Fortunately, that last header there is pretty damn good -- it handles lots of edge cases, the code is nice & tight (uses gcc asm operands rather than manual movs), and is already almost a general library type header. It's also the basis of what is now the public cpuid.h that is shipped with gcc-4.3+. So what I've done is pull that test header out and into gdb/common/ (not sure if there's a better place), synced to the version found in gcc-4.8.0, put a wrapper API around it, and then cut over all the existing call points to this new header. Since the func already has support for "is cpuid supported on this proc", it makes it trivial to push the i386/x86_64 ifdefs down into this wrapper API too. Now it can be safely used for all targets and gcc will elide the unused code for us. I've verified the gdb.arch testsuite still passes, and this code compiles for an armv7a host as well as x86_64. The go32-nat code has been left ifdef-ed out until someone can test & verify the new stuff works (and if it doesn't, figure out how to make the new code work). URL: https://bugs.gentoo.org/467806 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2013-06-19 22:29:36 +00:00
if (!i386_cpuid (1, &eax, &ebx, &ecx, &edx))
Support amd64 AVX. gdb/ 2010-04-07 H.J. Lu <hongjiu.lu@intel.com> * amd64-linux-nat.c: Include "regset.h", "elf/common.h", <sys/uio.h> and "i386-xstate.h". (PTRACE_GETREGSET): New. (PTRACE_SETREGSET): Likewise. (have_ptrace_getregset): Likewise. (amd64_linux_gregset64_reg_offset): Include 16 upper YMM registers. (amd64_linux_gregset32_reg_offset): Include 8 upper YMM registers. (amd64_linux_fetch_inferior_registers): Support PTRACE_GETFPREGS. (amd64_linux_store_inferior_registers): Likewise. (amd64_linux_read_description): Check and enable AVX target descriptions. * amd64-linux-tdep.c: Include "regset.h", "i386-linux-tdep.h" and "features/i386/amd64-avx-linux.c". (amd64_linux_regset_sections): New. (amd64_linux_core_read_description): Check and enable AVX target description. (amd64_linux_init_abi): Set xsave_xcr0_offset. Call set_gdbarch_core_regset_sections. (_initialize_amd64_linux_tdep): Call initialize_tdesc_amd64_avx_linux. * amd64-linux-tdep.h (AMD64_LINUX_ORIG_RAX_REGNUM): Replace AMD64_MXCSR_REGNUM with AMD64_YMM15H_REGNUM. (tdesc_amd64_avx_linux): New. (amd64_linux_update_xstateregset): Likewise. * amd64-tdep.c: Include "features/i386/amd64-avx.c". (amd64_ymm_names): New. (amd64_ymmh_names): Likewise. (amd64_register_name): Likewise. (amd64_supply_xstateregset): Likewise. (amd64_collect_xstateregset): Likewise. (amd64_supply_xsave): Likewise. (amd64_collect_xsave): Likewise. (AMD64_NUM_REGS): Removed. (amd64_dwarf_reg_to_regnum): Return %ymmN register number for %xmmN if AVX is available. (amd64_pseudo_register_name): Support pseudo YMM registers. (amd64_regset_from_core_section): Support .reg-xstate section. (amd64_init_abi): Set ymmh_register_names, num_ymm_regs and ymm0h_regnum. Call set_gdbarch_register_name. (amd64_init_abi): Call initialize_tdesc_amd64_avx. * amd64-tdep.h (amd64_regnum): Add AMD64_YMM0H_REGNUM and AMD64_YMM15H_REGNUM. (AMD64_NUM_REGS): New. (amd64_supply_xsave): Likewise. (amd64_collect_xsave): Likewise. (amd64_register_name): Removed. (amd64_register_type): Likewise. gdb/testsuite/ 2010-04-07 H.J. Lu <hongjiu.lu@intel.com> * gdb.arch/i386-avx.c: New. * gdb.arch/i386-avx.exp: Likewise. * gdb.arch/i386-cpuid.h: Updated from gcc 4.4.
2010-04-07 18:46:50 +00:00
return 0;
if ((ecx & (bit_AVX | bit_OSXSAVE)) == (bit_AVX | bit_OSXSAVE))
return 1;
else
return 0;
}
int
main (int argc, char **argv)
{
if (have_avx ())
{
asm ("vmovaps 0(%0), %%ymm0\n\t"
"vmovaps 32(%0), %%ymm1\n\t"
"vmovaps 64(%0), %%ymm2\n\t"
"vmovaps 96(%0), %%ymm3\n\t"
"vmovaps 128(%0), %%ymm4\n\t"
"vmovaps 160(%0), %%ymm5\n\t"
"vmovaps 192(%0), %%ymm6\n\t"
"vmovaps 224(%0), %%ymm7\n\t"
: /* no output operands */
: "r" (data)
: "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7");
#ifdef __x86_64__
asm ("vmovaps 256(%0), %%ymm8\n\t"
"vmovaps 288(%0), %%ymm9\n\t"
"vmovaps 320(%0), %%ymm10\n\t"
"vmovaps 352(%0), %%ymm11\n\t"
"vmovaps 384(%0), %%ymm12\n\t"
"vmovaps 416(%0), %%ymm13\n\t"
"vmovaps 448(%0), %%ymm14\n\t"
"vmovaps 480(%0), %%ymm15\n\t"
: /* no output operands */
: "r" (data)
: "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15");
#endif
asm ("nop"); /* first breakpoint here */
asm (
"vmovaps %%ymm0, 0(%0)\n\t"
"vmovaps %%ymm1, 32(%0)\n\t"
"vmovaps %%ymm2, 64(%0)\n\t"
"vmovaps %%ymm3, 96(%0)\n\t"
"vmovaps %%ymm4, 128(%0)\n\t"
"vmovaps %%ymm5, 160(%0)\n\t"
"vmovaps %%ymm6, 192(%0)\n\t"
"vmovaps %%ymm7, 224(%0)\n\t"
: /* no output operands */
: "r" (data)
: "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7");
#ifdef __x86_64__
asm (
"vmovaps %%ymm8, 256(%0)\n\t"
"vmovaps %%ymm9, 288(%0)\n\t"
"vmovaps %%ymm10, 320(%0)\n\t"
"vmovaps %%ymm11, 352(%0)\n\t"
"vmovaps %%ymm12, 384(%0)\n\t"
"vmovaps %%ymm13, 416(%0)\n\t"
"vmovaps %%ymm14, 448(%0)\n\t"
"vmovaps %%ymm15, 480(%0)\n\t"
: /* no output operands */
: "r" (data)
: "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15");
#endif
puts ("Bye!"); /* second breakpoint here */
}
return 0;
}