]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/testsuite/gdb.arch/i386-sse.c
* gdb.arch/i386-sse.exp, gdb.arch/i386-sse.c: New tests.
[thirdparty/binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-sse.c
CommitLineData
83ecb59f
JB
1/* Test program for SSE registers.
2
3 Copyright 2004 Free Software Foundation, Inc.
4
5 This file is part of GDB.
6
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22#include <stdio.h>
23#include "i386-cpuid.h"
24
25typedef struct {
26 float f[4];
27} v4sf_t;
28
29
30v4sf_t data[8] =
31 {
32 { { 0.0, 0.25, 0.50, 0.75 } },
33 { { 1.0, 1.25, 1.50, 1.75 } },
34 { { 2.0, 2.25, 2.50, 2.75 } },
35 { { 3.0, 3.25, 3.50, 3.75 } },
36 { { 4.0, 4.25, 4.50, 4.75 } },
37 { { 5.0, 5.25, 5.50, 5.75 } },
38 { { 6.0, 6.25, 6.50, 6.75 } },
39 { { 7.0, 7.25, 7.50, 7.75 } },
40 };
41
42
43int
44have_sse (void)
45{
46 int edx = i386_cpuid ();
47
48 if (edx & bit_SSE)
49 return 1;
50 else
51 return 0;
52}
53
54int
55main (int argc, char **argv)
56{
57 if (have_sse ())
58 {
59 asm ("movaps 0(%0), %%xmm0\n\t"
60 "movaps 16(%0), %%xmm1\n\t"
61 "movaps 32(%0), %%xmm2\n\t"
62 "movaps 48(%0), %%xmm3\n\t"
63 "movaps 64(%0), %%xmm4\n\t"
64 "movaps 80(%0), %%xmm5\n\t"
65 "movaps 96(%0), %%xmm6\n\t"
66 "movaps 112(%0), %%xmm7\n\t"
67 : /* no output operands */
68 : "r" (data)
69 : "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7");
70
71 puts ("Hi!"); /* first breakpoint here */
72
73 asm (
74 "movaps %%xmm0, 0(%0)\n\t"
75 "movaps %%xmm1, 16(%0)\n\t"
76 "movaps %%xmm2, 32(%0)\n\t"
77 "movaps %%xmm3, 48(%0)\n\t"
78 "movaps %%xmm4, 64(%0)\n\t"
79 "movaps %%xmm5, 80(%0)\n\t"
80 "movaps %%xmm6, 96(%0)\n\t"
81 "movaps %%xmm7, 112(%0)\n\t"
82 : /* no output operands */
83 : "r" (data)
84 : "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7");
85
86 puts ("Bye!"); /* second breakpoint here */
87 }
88
89 return 0;
90}