2004-06-07 15:38:52 +00:00
|
|
|
/* Test program for SSE registers.
|
|
|
|
|
2014-01-01 03:54:24 +00:00
|
|
|
Copyright 2004-2014 Free Software Foundation, Inc.
|
2004-06-07 15:38:52 +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
|
2007-08-23 18:08:50 +00:00
|
|
|
the Free Software Foundation; either version 3 of the License, or
|
2004-06-07 15:38:52 +00:00
|
|
|
(at your option) any later version.
|
2007-08-23 18:08:50 +00:00
|
|
|
|
2004-06-07 15:38:52 +00:00
|
|
|
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.
|
2007-08-23 18:08:50 +00:00
|
|
|
|
2004-06-07 15:38:52 +00:00
|
|
|
You should have received a copy of the GNU General Public License
|
2007-08-23 18:08:50 +00:00
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
2004-06-07 15:38:52 +00:00
|
|
|
|
|
|
|
#include <stdio.h>
|
Rename 32- and 64-bit Intel files from "i386" to "x86"
This commit renames nine files that contain code used by both 32- and
64-bit Intel ports such that their names are prefixed with "x86"
rather than "i386". All types, functions and variables within these
files are likewise renamed such that their names are prefixed with
"x86" rather than "i386". This makes GDB follow the convention used
by gdbserver such that 32-bit Intel code lives in files called
"i386-*", 64-bit Intel code lives in files called "amd64-*", and code
for both 32- and 64-bit Intel lives in files called "x86-*".
This commit only renames OS-independent files. The Linux ports of
both GDB and gdbserver now follow the i386/amd64/x86 convention fully.
Some ports still use the old convention where "i386" in file/function/
type/variable names can mean "32-bit only" or "32- and 64-bit" but I
don't want to touch ports I can't fully test except where absolutely
necessary.
gdb/ChangeLog:
* i386-nat.h: Renamed as...
* x86-nat.h: New file. All type, function and variable name
prefixes changed from "i386_" to "x86_". All references updated.
* i386-nat.c: Renamed as...
* x86-nat.c: New file. All type, function and variable name
prefixes changed from "i386_" to "x86_". All references updated.
* common/i386-xstate.h: Renamed as...
* common/x86-xstate.h: New file. All type, function and variable
name prefixes changed from "i386_" to "x86_". All references
updated.
* nat/i386-cpuid.h: Renamed as...
* nat/x86-cpuid.h: New file. All type, function and variable name
prefixes changed from "i386_" to "x86_". All references updated.
* nat/i386-gcc-cpuid.h: Renamed as...
* nat/x86-gcc-cpuid.h: New file. All type, function and variable
name prefixes changed from "i386_" to "x86_". All references
updated.
* nat/i386-dregs.h: Renamed as...
* nat/x86-dregs.h: New file. All type, function and variable name
prefixes changed from "i386_" to "x86_". All references updated.
* nat/i386-dregs.c: Renamed as...
* nat/x86-dregs.c: New file. All type, function and variable name
prefixes changed from "i386_" to "x86_". All references updated.
gdb/gdbserver/ChangeLog:
* i386-low.h: Renamed as...
* x86-low.h: New file. All type, function and variable name
prefixes changed from "i386_" to "x86_". All references updated.
* i386-low.c: Renamed as...
* x86-low.c: New file. All type, function and variable name
prefixes changed from "i386_" to "x86_". All references updated.
2014-08-19 14:16:11 +00:00
|
|
|
#include "nat/x86-cpuid.h"
|
2004-06-07 15:38:52 +00:00
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
float f[4];
|
|
|
|
} v4sf_t;
|
|
|
|
|
|
|
|
|
2009-06-03 16:46:06 +00:00
|
|
|
v4sf_t data[] =
|
2004-06-07 15:38:52 +00:00
|
|
|
{
|
2009-06-03 16:46:06 +00:00
|
|
|
{ { 0.0, 0.25, 0.50, 0.75 } },
|
|
|
|
{ { 1.0, 1.25, 1.50, 1.75 } },
|
|
|
|
{ { 2.0, 2.25, 2.50, 2.75 } },
|
|
|
|
{ { 3.0, 3.25, 3.50, 3.75 } },
|
|
|
|
{ { 4.0, 4.25, 4.50, 4.75 } },
|
|
|
|
{ { 5.0, 5.25, 5.50, 5.75 } },
|
|
|
|
{ { 6.0, 6.25, 6.50, 6.75 } },
|
|
|
|
{ { 7.0, 7.25, 7.50, 7.75 } },
|
|
|
|
#ifdef __x86_64__
|
|
|
|
{ { 8.0, 8.25, 8.50, 8.75 } },
|
|
|
|
{ { 9.0, 9.25, 9.50, 9.75 } },
|
|
|
|
{ { 10.0, 10.25, 10.50, 10.75 } },
|
|
|
|
{ { 11.0, 11.25, 11.50, 11.75 } },
|
|
|
|
{ { 12.0, 12.25, 12.50, 12.75 } },
|
|
|
|
{ { 13.0, 13.25, 13.50, 13.75 } },
|
|
|
|
{ { 14.0, 14.25, 14.50, 14.75 } },
|
|
|
|
{ { 15.0, 15.25, 15.50, 15.75 } },
|
|
|
|
#endif
|
2004-06-07 15:38:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
have_sse (void)
|
|
|
|
{
|
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
|
|
|
int edx;
|
|
|
|
|
Rename 32- and 64-bit Intel files from "i386" to "x86"
This commit renames nine files that contain code used by both 32- and
64-bit Intel ports such that their names are prefixed with "x86"
rather than "i386". All types, functions and variables within these
files are likewise renamed such that their names are prefixed with
"x86" rather than "i386". This makes GDB follow the convention used
by gdbserver such that 32-bit Intel code lives in files called
"i386-*", 64-bit Intel code lives in files called "amd64-*", and code
for both 32- and 64-bit Intel lives in files called "x86-*".
This commit only renames OS-independent files. The Linux ports of
both GDB and gdbserver now follow the i386/amd64/x86 convention fully.
Some ports still use the old convention where "i386" in file/function/
type/variable names can mean "32-bit only" or "32- and 64-bit" but I
don't want to touch ports I can't fully test except where absolutely
necessary.
gdb/ChangeLog:
* i386-nat.h: Renamed as...
* x86-nat.h: New file. All type, function and variable name
prefixes changed from "i386_" to "x86_". All references updated.
* i386-nat.c: Renamed as...
* x86-nat.c: New file. All type, function and variable name
prefixes changed from "i386_" to "x86_". All references updated.
* common/i386-xstate.h: Renamed as...
* common/x86-xstate.h: New file. All type, function and variable
name prefixes changed from "i386_" to "x86_". All references
updated.
* nat/i386-cpuid.h: Renamed as...
* nat/x86-cpuid.h: New file. All type, function and variable name
prefixes changed from "i386_" to "x86_". All references updated.
* nat/i386-gcc-cpuid.h: Renamed as...
* nat/x86-gcc-cpuid.h: New file. All type, function and variable
name prefixes changed from "i386_" to "x86_". All references
updated.
* nat/i386-dregs.h: Renamed as...
* nat/x86-dregs.h: New file. All type, function and variable name
prefixes changed from "i386_" to "x86_". All references updated.
* nat/i386-dregs.c: Renamed as...
* nat/x86-dregs.c: New file. All type, function and variable name
prefixes changed from "i386_" to "x86_". All references updated.
gdb/gdbserver/ChangeLog:
* i386-low.h: Renamed as...
* x86-low.h: New file. All type, function and variable name
prefixes changed from "i386_" to "x86_". All references updated.
* i386-low.c: Renamed as...
* x86-low.c: New file. All type, function and variable name
prefixes changed from "i386_" to "x86_". All references updated.
2014-08-19 14:16:11 +00:00
|
|
|
if (!x86_cpuid (1, NULL, NULL, NULL, &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
|
|
|
return 0;
|
2004-06-07 15:38:52 +00:00
|
|
|
|
|
|
|
if (edx & bit_SSE)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
if (have_sse ())
|
|
|
|
{
|
|
|
|
asm ("movaps 0(%0), %%xmm0\n\t"
|
|
|
|
"movaps 16(%0), %%xmm1\n\t"
|
|
|
|
"movaps 32(%0), %%xmm2\n\t"
|
|
|
|
"movaps 48(%0), %%xmm3\n\t"
|
|
|
|
"movaps 64(%0), %%xmm4\n\t"
|
|
|
|
"movaps 80(%0), %%xmm5\n\t"
|
|
|
|
"movaps 96(%0), %%xmm6\n\t"
|
|
|
|
"movaps 112(%0), %%xmm7\n\t"
|
|
|
|
: /* no output operands */
|
|
|
|
: "r" (data)
|
|
|
|
: "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7");
|
2009-06-03 16:46:06 +00:00
|
|
|
#ifdef __x86_64__
|
|
|
|
asm ("movaps 128(%0), %%xmm8\n\t"
|
|
|
|
"movaps 144(%0), %%xmm9\n\t"
|
|
|
|
"movaps 160(%0), %%xmm10\n\t"
|
|
|
|
"movaps 176(%0), %%xmm11\n\t"
|
|
|
|
"movaps 192(%0), %%xmm12\n\t"
|
|
|
|
"movaps 208(%0), %%xmm13\n\t"
|
|
|
|
"movaps 224(%0), %%xmm14\n\t"
|
|
|
|
"movaps 240(%0), %%xmm15\n\t"
|
|
|
|
: /* no output operands */
|
|
|
|
: "r" (data)
|
|
|
|
: "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15");
|
|
|
|
#endif
|
2004-06-07 15:38:52 +00:00
|
|
|
|
2009-02-06 08:48:29 +00:00
|
|
|
asm ("nop"); /* first breakpoint here */
|
2004-06-07 15:38:52 +00:00
|
|
|
|
|
|
|
asm (
|
|
|
|
"movaps %%xmm0, 0(%0)\n\t"
|
|
|
|
"movaps %%xmm1, 16(%0)\n\t"
|
|
|
|
"movaps %%xmm2, 32(%0)\n\t"
|
|
|
|
"movaps %%xmm3, 48(%0)\n\t"
|
|
|
|
"movaps %%xmm4, 64(%0)\n\t"
|
|
|
|
"movaps %%xmm5, 80(%0)\n\t"
|
|
|
|
"movaps %%xmm6, 96(%0)\n\t"
|
|
|
|
"movaps %%xmm7, 112(%0)\n\t"
|
|
|
|
: /* no output operands */
|
|
|
|
: "r" (data)
|
|
|
|
: "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7");
|
2009-06-03 16:46:06 +00:00
|
|
|
#ifdef __x86_64__
|
|
|
|
asm (
|
|
|
|
"movaps %%xmm8, 128(%0)\n\t"
|
|
|
|
"movaps %%xmm9, 144(%0)\n\t"
|
|
|
|
"movaps %%xmm10, 160(%0)\n\t"
|
|
|
|
"movaps %%xmm11, 176(%0)\n\t"
|
|
|
|
"movaps %%xmm12, 192(%0)\n\t"
|
|
|
|
"movaps %%xmm13, 208(%0)\n\t"
|
|
|
|
"movaps %%xmm14, 224(%0)\n\t"
|
|
|
|
"movaps %%xmm15, 240(%0)\n\t"
|
|
|
|
: /* no output operands */
|
|
|
|
: "r" (data)
|
|
|
|
: "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15");
|
|
|
|
#endif
|
2004-06-07 15:38:52 +00:00
|
|
|
|
|
|
|
puts ("Bye!"); /* second breakpoint here */
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|