[gdb/testsuite] Require c++11 where necessary
[deliverable/binutils-gdb.git] / gdb / testsuite / gdb.arch / i386-avx.c
1 /* Test program for AVX registers.
2
3 Copyright 2010-2019 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 3 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, see <http://www.gnu.org/licenses/>. */
19
20 #include <stdio.h>
21 #include "nat/x86-cpuid.h"
22
23 typedef struct {
24 float f[8];
25 } v8sf_t;
26
27
28 v8sf_t data[] =
29 {
30 { { 0.0, 0.125, 0.25, 0.375, 0.50, 0.625, 0.75, 0.875 } },
31 { { 1.0, 1.125, 1.25, 1.375, 1.50, 1.625, 1.75, 1.875 } },
32 { { 2.0, 2.125, 2.25, 2.375, 2.50, 2.625, 2.75, 2.875 } },
33 { { 3.0, 3.125, 3.25, 3.375, 3.50, 3.625, 3.75, 3.875 } },
34 { { 4.0, 4.125, 4.25, 4.375, 4.50, 4.625, 4.75, 4.875 } },
35 { { 5.0, 5.125, 5.25, 5.375, 5.50, 5.625, 5.75, 5.875 } },
36 { { 6.0, 6.125, 6.25, 6.375, 6.50, 6.625, 6.75, 6.875 } },
37 { { 7.0, 7.125, 7.25, 7.375, 7.50, 7.625, 7.75, 7.875 } },
38 #ifdef __x86_64__
39 { { 8.0, 8.125, 8.25, 8.375, 8.50, 8.625, 8.75, 8.875 } },
40 { { 9.0, 9.125, 9.25, 9.375, 9.50, 9.625, 9.75, 9.875 } },
41 { { 10.0, 10.125, 10.25, 10.375, 10.50, 10.625, 10.75, 10.875 } },
42 { { 11.0, 11.125, 11.25, 11.375, 11.50, 11.625, 11.75, 11.875 } },
43 { { 12.0, 12.125, 12.25, 12.375, 12.50, 12.625, 12.75, 12.875 } },
44 { { 13.0, 13.125, 13.25, 13.375, 13.50, 13.625, 13.75, 13.875 } },
45 { { 14.0, 14.125, 14.25, 14.375, 14.50, 14.625, 14.75, 14.875 } },
46 { { 15.0, 15.125, 15.25, 15.375, 15.50, 15.625, 15.75, 15.875 } },
47 #endif
48 };
49
50
51 int
52 have_avx (void)
53 {
54 unsigned int eax, ebx, ecx, edx;
55
56 if (!x86_cpuid (1, &eax, &ebx, &ecx, &edx))
57 return 0;
58
59 if ((ecx & (bit_AVX | bit_OSXSAVE)) == (bit_AVX | bit_OSXSAVE))
60 return 1;
61 else
62 return 0;
63 }
64
65 int
66 main (int argc, char **argv)
67 {
68 if (have_avx ())
69 {
70 asm ("vmovaps 0(%0), %%ymm0\n\t"
71 "vmovaps 32(%0), %%ymm1\n\t"
72 "vmovaps 64(%0), %%ymm2\n\t"
73 "vmovaps 96(%0), %%ymm3\n\t"
74 "vmovaps 128(%0), %%ymm4\n\t"
75 "vmovaps 160(%0), %%ymm5\n\t"
76 "vmovaps 192(%0), %%ymm6\n\t"
77 "vmovaps 224(%0), %%ymm7\n\t"
78 : /* no output operands */
79 : "r" (data)
80 : "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7");
81 #ifdef __x86_64__
82 asm ("vmovaps 256(%0), %%ymm8\n\t"
83 "vmovaps 288(%0), %%ymm9\n\t"
84 "vmovaps 320(%0), %%ymm10\n\t"
85 "vmovaps 352(%0), %%ymm11\n\t"
86 "vmovaps 384(%0), %%ymm12\n\t"
87 "vmovaps 416(%0), %%ymm13\n\t"
88 "vmovaps 448(%0), %%ymm14\n\t"
89 "vmovaps 480(%0), %%ymm15\n\t"
90 : /* no output operands */
91 : "r" (data)
92 : "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15");
93 #endif
94
95 asm ("nop"); /* first breakpoint here */
96
97 asm (
98 "vmovaps %%ymm0, 0(%0)\n\t"
99 "vmovaps %%ymm1, 32(%0)\n\t"
100 "vmovaps %%ymm2, 64(%0)\n\t"
101 "vmovaps %%ymm3, 96(%0)\n\t"
102 "vmovaps %%ymm4, 128(%0)\n\t"
103 "vmovaps %%ymm5, 160(%0)\n\t"
104 "vmovaps %%ymm6, 192(%0)\n\t"
105 "vmovaps %%ymm7, 224(%0)\n\t"
106 : /* no output operands */
107 : "r" (data)
108 : "xmm0", "xmm1", "xmm2", "xmm3", "xmm4", "xmm5", "xmm6", "xmm7");
109 #ifdef __x86_64__
110 asm (
111 "vmovaps %%ymm8, 256(%0)\n\t"
112 "vmovaps %%ymm9, 288(%0)\n\t"
113 "vmovaps %%ymm10, 320(%0)\n\t"
114 "vmovaps %%ymm11, 352(%0)\n\t"
115 "vmovaps %%ymm12, 384(%0)\n\t"
116 "vmovaps %%ymm13, 416(%0)\n\t"
117 "vmovaps %%ymm14, 448(%0)\n\t"
118 "vmovaps %%ymm15, 480(%0)\n\t"
119 : /* no output operands */
120 : "r" (data)
121 : "xmm8", "xmm9", "xmm10", "xmm11", "xmm12", "xmm13", "xmm14", "xmm15");
122 #endif
123
124 puts ("Bye!"); /* second breakpoint here */
125 }
126
127 return 0;
128 }
This page took 0.034867 seconds and 4 git commands to generate.