1 /* Copyright (C) 2017-2018 Free Software Foundation, Inc.
3 This file is part of GDB.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #include "linux-x86-tdesc.h"
21 #include "common/selftest.h"
22 #include "x86-xstate.h"
24 /* Defined in auto-generated file i386-linux.c. */
25 void init_registers_i386_linux (void);
26 extern const struct target_desc *tdesc_i386_linux;
28 /* Defined in auto-generated file i386-mmx-linux.c. */
29 void init_registers_i386_mmx_linux (void);
30 extern const struct target_desc *tdesc_i386_mmx_linux;
32 /* Defined in auto-generated file i386-avx-linux.c. */
33 void init_registers_i386_avx_linux (void);
34 extern const struct target_desc *tdesc_i386_avx_linux;
36 /* Defined in auto-generated file i386-avx-mpx-linux.c. */
37 void init_registers_i386_avx_mpx_linux (void);
38 extern const struct target_desc *tdesc_i386_avx_mpx_linux;
40 /* Defined in auto-generated file i386-avx-avx512-linux.c. */
41 void init_registers_i386_avx_avx512_linux (void);
42 extern const struct target_desc *tdesc_i386_avx_avx512_linux;
44 /* Defined in auto-generated file i386-avx-mpx-avx512-linux.c. */
45 void init_registers_i386_avx_mpx_avx512_pku_linux (void);
46 extern const struct target_desc *tdesc_i386_avx_mpx_avx512_pku_linux;
48 /* Defined in auto-generated file i386-mpx-linux.c. */
49 void init_registers_i386_mpx_linux (void);
50 extern const struct target_desc *tdesc_i386_mpx_linux;
54 /* Defined in auto-generated file amd64-linux.c. */
55 void init_registers_amd64_linux (void);
56 extern const struct target_desc *tdesc_amd64_linux;
58 /* Defined in auto-generated file amd64-avx-linux.c. */
59 void init_registers_amd64_avx_linux (void);
60 extern const struct target_desc *tdesc_amd64_avx_linux;
62 /* Defined in auto-generated file amd64-avx-avx512-linux.c. */
63 void init_registers_amd64_avx_avx512_linux (void);
64 extern const struct target_desc *tdesc_amd64_avx_avx512_linux;
66 /* Defined in auto-generated file amd64-avx-mpx-avx512-pku-linux.c. */
67 void init_registers_amd64_avx_mpx_avx512_pku_linux (void);
68 extern const struct target_desc *tdesc_amd64_avx_mpx_avx512_pku_linux;
70 /* Defined in auto-generated file amd64-avx-mpx-linux.c. */
71 void init_registers_amd64_avx_mpx_linux (void);
72 extern const struct target_desc *tdesc_amd64_avx_mpx_linux;
74 /* Defined in auto-generated file amd64-mpx-linux.c. */
75 void init_registers_amd64_mpx_linux (void);
76 extern const struct target_desc *tdesc_amd64_mpx_linux;
78 /* Defined in auto-generated file x32-linux.c. */
79 void init_registers_x32_linux (void);
80 extern const struct target_desc *tdesc_x32_linux;
82 /* Defined in auto-generated file x32-avx-linux.c. */
83 void init_registers_x32_avx_linux (void);
84 extern const struct target_desc *tdesc_x32_avx_linux;
86 /* Defined in auto-generated file x32-avx-avx512-linux.c. */
87 void init_registers_x32_avx_avx512_linux (void);
88 extern const struct target_desc *tdesc_x32_avx_avx512_linux;
100 const target_desc *tdesc;
102 { X86_XSTATE_X87, tdesc_i386_mmx_linux },
103 { X86_XSTATE_SSE_MASK, tdesc_i386_linux },
104 { X86_XSTATE_AVX_MASK, tdesc_i386_avx_linux },
105 { X86_XSTATE_MPX_MASK, tdesc_i386_mpx_linux },
106 { X86_XSTATE_AVX_MPX_MASK, tdesc_i386_avx_mpx_linux },
107 { X86_XSTATE_AVX_AVX512_MASK, tdesc_i386_avx_avx512_linux },
108 { X86_XSTATE_AVX_MPX_AVX512_PKU_MASK, tdesc_i386_avx_mpx_avx512_pku_linux }
111 for (auto &elem : tdesc_tests)
113 const target_desc *tdesc = i386_linux_read_description (elem.mask);
115 SELF_CHECK (*tdesc == *elem.tdesc);
127 const target_desc *tdesc[2];
129 { X86_XSTATE_SSE_MASK, { tdesc_amd64_linux, tdesc_x32_linux } },
130 { X86_XSTATE_AVX_MASK, { tdesc_amd64_avx_linux, tdesc_x32_avx_linux } },
131 { X86_XSTATE_MPX_MASK, { tdesc_amd64_mpx_linux, tdesc_x32_avx_linux } },
132 { X86_XSTATE_AVX_MPX_MASK, { tdesc_amd64_avx_mpx_linux,
133 tdesc_x32_avx_linux } },
134 { X86_XSTATE_AVX_AVX512_MASK, { tdesc_amd64_avx_avx512_linux,
135 tdesc_x32_avx_avx512_linux } },
136 { X86_XSTATE_AVX_MPX_AVX512_PKU_MASK,
137 { tdesc_amd64_avx_mpx_avx512_pku_linux, tdesc_x32_avx_avx512_linux } },
140 for (auto &elem : tdesc_tests)
142 for (int i = 0; i < 2; i++)
144 const target_desc *tdesc = amd64_linux_read_description (elem.mask,
147 SELF_CHECK (*tdesc == *elem.tdesc[i]);
154 } // namespace selftests
157 initialize_low_tdesc ()
159 init_registers_i386_linux ();
160 init_registers_i386_mmx_linux ();
161 init_registers_i386_avx_linux ();
162 init_registers_i386_mpx_linux ();
163 init_registers_i386_avx_mpx_linux ();
164 init_registers_i386_avx_avx512_linux ();
165 init_registers_i386_avx_mpx_avx512_pku_linux ();
167 selftests::register_test ("i386-tdesc", selftests::tdesc::i386_tdesc_test);
170 init_registers_x32_linux ();
171 init_registers_x32_avx_linux ();
172 init_registers_x32_avx_avx512_linux ();
174 init_registers_amd64_linux ();
175 init_registers_amd64_avx_linux ();
176 init_registers_amd64_mpx_linux ();
177 init_registers_amd64_avx_mpx_linux ();
178 init_registers_amd64_avx_avx512_linux ();
179 init_registers_amd64_avx_mpx_avx512_pku_linux ();
181 selftests::register_test ("amd64-tdesc", selftests::tdesc::amd64_tdesc_test);