Automatic Copyright Year update after running gdb/copyright.py
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-sse.c
CommitLineData
83ecb59f
JB
1/* Test program for SSE registers.
2
88b9d363 3 Copyright 2004-2022 Free Software Foundation, Inc.
83ecb59f
JB
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
a9762ec7 9 the Free Software Foundation; either version 3 of the License, or
83ecb59f 10 (at your option) any later version.
a9762ec7 11
83ecb59f
JB
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.
a9762ec7 16
83ecb59f 17 You should have received a copy of the GNU General Public License
a9762ec7 18 along with this program. If not, see <http://www.gnu.org/licenses/>. */
83ecb59f
JB
19
20#include <stdio.h>
df7e5265 21#include "nat/x86-cpuid.h"
83ecb59f
JB
22
23typedef struct {
24 float f[4];
25} v4sf_t;
26
27
701e355d 28v4sf_t data[] =
83ecb59f 29 {
701e355d
DE
30 { { 0.0, 0.25, 0.50, 0.75 } },
31 { { 1.0, 1.25, 1.50, 1.75 } },
32 { { 2.0, 2.25, 2.50, 2.75 } },
33 { { 3.0, 3.25, 3.50, 3.75 } },
34 { { 4.0, 4.25, 4.50, 4.75 } },
35 { { 5.0, 5.25, 5.50, 5.75 } },
36 { { 6.0, 6.25, 6.50, 6.75 } },
37 { { 7.0, 7.25, 7.50, 7.75 } },
38#ifdef __x86_64__
39 { { 8.0, 8.25, 8.50, 8.75 } },
40 { { 9.0, 9.25, 9.50, 9.75 } },
41 { { 10.0, 10.25, 10.50, 10.75 } },
42 { { 11.0, 11.25, 11.50, 11.75 } },
43 { { 12.0, 12.25, 12.50, 12.75 } },
44 { { 13.0, 13.25, 13.50, 13.75 } },
45 { { 14.0, 14.25, 14.50, 14.75 } },
46 { { 15.0, 15.25, 15.50, 15.75 } },
47#endif
83ecb59f
JB
48 };
49
50
51int
52have_sse (void)
53{
915771bb 54 unsigned int edx;
4d157a3d 55
df7e5265 56 if (!x86_cpuid (1, NULL, NULL, NULL, &edx))
4d157a3d 57 return 0;
83ecb59f
JB
58
59 if (edx & bit_SSE)
60 return 1;
61 else
62 return 0;
63}
64
65int
66main (int argc, char **argv)
67{
68 if (have_sse ())
69 {
70 asm ("movaps 0(%0), %%xmm0\n\t"
71 "movaps 16(%0), %%xmm1\n\t"
72 "movaps 32(%0), %%xmm2\n\t"
73 "movaps 48(%0), %%xmm3\n\t"
74 "movaps 64(%0), %%xmm4\n\t"
75 "movaps 80(%0), %%xmm5\n\t"
76 "movaps 96(%0), %%xmm6\n\t"
77 "movaps 112(%0), %%xmm7\n\t"
78 : /* no output operands */
79 : "r" (data)
80 : "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7");
701e355d
DE
81#ifdef __x86_64__
82 asm ("movaps 128(%0), %%xmm8\n\t"
83 "movaps 144(%0), %%xmm9\n\t"
84 "movaps 160(%0), %%xmm10\n\t"
85 "movaps 176(%0), %%xmm11\n\t"
86 "movaps 192(%0), %%xmm12\n\t"
87 "movaps 208(%0), %%xmm13\n\t"
88 "movaps 224(%0), %%xmm14\n\t"
89 "movaps 240(%0), %%xmm15\n\t"
90 : /* no output operands */
91 : "r" (data)
92 : "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15");
93#endif
83ecb59f 94
ff4ab08d 95 asm ("nop"); /* first breakpoint here */
83ecb59f
JB
96
97 asm (
98 "movaps %%xmm0, 0(%0)\n\t"
99 "movaps %%xmm1, 16(%0)\n\t"
100 "movaps %%xmm2, 32(%0)\n\t"
101 "movaps %%xmm3, 48(%0)\n\t"
102 "movaps %%xmm4, 64(%0)\n\t"
103 "movaps %%xmm5, 80(%0)\n\t"
104 "movaps %%xmm6, 96(%0)\n\t"
105 "movaps %%xmm7, 112(%0)\n\t"
106 : /* no output operands */
107 : "r" (data)
108 : "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7");
701e355d
DE
109#ifdef __x86_64__
110 asm (
111 "movaps %%xmm8, 128(%0)\n\t"
112 "movaps %%xmm9, 144(%0)\n\t"
113 "movaps %%xmm10, 160(%0)\n\t"
114 "movaps %%xmm11, 176(%0)\n\t"
115 "movaps %%xmm12, 192(%0)\n\t"
116 "movaps %%xmm13, 208(%0)\n\t"
117 "movaps %%xmm14, 224(%0)\n\t"
118 "movaps %%xmm15, 240(%0)\n\t"
119 : /* no output operands */
120 : "r" (data)
121 : "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15");
122#endif
83ecb59f
JB
123
124 puts ("Bye!"); /* second breakpoint here */
125 }
126
127 return 0;
128}
This page took 2.328143 seconds and 4 git commands to generate.