1b8021494Sopenharmony_ci// Copyright 2016, VIXL authors
2b8021494Sopenharmony_ci// All rights reserved.
3b8021494Sopenharmony_ci//
4b8021494Sopenharmony_ci// Redistribution and use in source and binary forms, with or without
5b8021494Sopenharmony_ci// modification, are permitted provided that the following conditions are met:
6b8021494Sopenharmony_ci//
7b8021494Sopenharmony_ci//   * Redistributions of source code must retain the above copyright notice,
8b8021494Sopenharmony_ci//     this list of conditions and the following disclaimer.
9b8021494Sopenharmony_ci//   * Redistributions in binary form must reproduce the above copyright notice,
10b8021494Sopenharmony_ci//     this list of conditions and the following disclaimer in the documentation
11b8021494Sopenharmony_ci//     and/or other materials provided with the distribution.
12b8021494Sopenharmony_ci//   * Neither the name of ARM Limited nor the names of its contributors may be
13b8021494Sopenharmony_ci//     used to endorse or promote products derived from this software without
14b8021494Sopenharmony_ci//     specific prior written permission.
15b8021494Sopenharmony_ci//
16b8021494Sopenharmony_ci// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
17b8021494Sopenharmony_ci// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18b8021494Sopenharmony_ci// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19b8021494Sopenharmony_ci// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20b8021494Sopenharmony_ci// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21b8021494Sopenharmony_ci// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22b8021494Sopenharmony_ci// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23b8021494Sopenharmony_ci// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24b8021494Sopenharmony_ci// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25b8021494Sopenharmony_ci// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26b8021494Sopenharmony_ci
27b8021494Sopenharmony_ci
28b8021494Sopenharmony_ci// -----------------------------------------------------------------------------
29b8021494Sopenharmony_ci// This file is auto generated from the
30b8021494Sopenharmony_ci// test/aarch32/config/template-simulator-aarch32.cc.in template file using
31b8021494Sopenharmony_ci// tools/generate_tests.py.
32b8021494Sopenharmony_ci//
33b8021494Sopenharmony_ci// PLEASE DO NOT EDIT.
34b8021494Sopenharmony_ci// -----------------------------------------------------------------------------
35b8021494Sopenharmony_ci
36b8021494Sopenharmony_ci
37b8021494Sopenharmony_ci#include "test-runner.h"
38b8021494Sopenharmony_ci
39b8021494Sopenharmony_ci#include "test-utils.h"
40b8021494Sopenharmony_ci#include "test-utils-aarch32.h"
41b8021494Sopenharmony_ci
42b8021494Sopenharmony_ci#include "aarch32/assembler-aarch32.h"
43b8021494Sopenharmony_ci#include "aarch32/disasm-aarch32.h"
44b8021494Sopenharmony_ci#include "aarch32/macro-assembler-aarch32.h"
45b8021494Sopenharmony_ci
46b8021494Sopenharmony_ci#define __ masm.
47b8021494Sopenharmony_ci#define BUF_SIZE (4096)
48b8021494Sopenharmony_ci
49b8021494Sopenharmony_ci#ifdef VIXL_INCLUDE_SIMULATOR_AARCH32
50b8021494Sopenharmony_ci// Run tests with the simulator.
51b8021494Sopenharmony_ci
52b8021494Sopenharmony_ci#define SETUP() MacroAssembler masm(BUF_SIZE)
53b8021494Sopenharmony_ci
54b8021494Sopenharmony_ci#define START() masm.GetBuffer()->Reset()
55b8021494Sopenharmony_ci
56b8021494Sopenharmony_ci#define END() \
57b8021494Sopenharmony_ci  __ Hlt(0);  \
58b8021494Sopenharmony_ci  __ FinalizeCode();
59b8021494Sopenharmony_ci
60b8021494Sopenharmony_ci// TODO: Run the tests in the simulator.
61b8021494Sopenharmony_ci#define RUN()
62b8021494Sopenharmony_ci
63b8021494Sopenharmony_ci#else  // ifdef VIXL_INCLUDE_SIMULATOR_AARCH32.
64b8021494Sopenharmony_ci
65b8021494Sopenharmony_ci#define SETUP()                  \
66b8021494Sopenharmony_ci  MacroAssembler masm(BUF_SIZE); \
67b8021494Sopenharmony_ci  UseScratchRegisterScope harness_scratch;
68b8021494Sopenharmony_ci
69b8021494Sopenharmony_ci#define START()                 \
70b8021494Sopenharmony_ci  harness_scratch.Open(&masm);  \
71b8021494Sopenharmony_ci  harness_scratch.ExcludeAll(); \
72b8021494Sopenharmony_ci  masm.GetBuffer()->Reset();    \
73b8021494Sopenharmony_ci  __ Push(r4);                  \
74b8021494Sopenharmony_ci  __ Push(r5);                  \
75b8021494Sopenharmony_ci  __ Push(r6);                  \
76b8021494Sopenharmony_ci  __ Push(r7);                  \
77b8021494Sopenharmony_ci  __ Push(r8);                  \
78b8021494Sopenharmony_ci  __ Push(r9);                  \
79b8021494Sopenharmony_ci  __ Push(r10);                 \
80b8021494Sopenharmony_ci  __ Push(r11);                 \
81b8021494Sopenharmony_ci  __ Push(lr);                  \
82b8021494Sopenharmony_ci  harness_scratch.Include(ip);
83b8021494Sopenharmony_ci
84b8021494Sopenharmony_ci#define END()                  \
85b8021494Sopenharmony_ci  harness_scratch.Exclude(ip); \
86b8021494Sopenharmony_ci  __ Pop(lr);                  \
87b8021494Sopenharmony_ci  __ Pop(r11);                 \
88b8021494Sopenharmony_ci  __ Pop(r10);                 \
89b8021494Sopenharmony_ci  __ Pop(r9);                  \
90b8021494Sopenharmony_ci  __ Pop(r8);                  \
91b8021494Sopenharmony_ci  __ Pop(r7);                  \
92b8021494Sopenharmony_ci  __ Pop(r6);                  \
93b8021494Sopenharmony_ci  __ Pop(r5);                  \
94b8021494Sopenharmony_ci  __ Pop(r4);                  \
95b8021494Sopenharmony_ci  __ Bx(lr);                   \
96b8021494Sopenharmony_ci  __ FinalizeCode();           \
97b8021494Sopenharmony_ci  harness_scratch.Close();
98b8021494Sopenharmony_ci
99b8021494Sopenharmony_ci#define RUN()                                                 \
100b8021494Sopenharmony_ci  {                                                           \
101b8021494Sopenharmony_ci    int pcs_offset = masm.IsUsingT32() ? 1 : 0;               \
102b8021494Sopenharmony_ci    masm.GetBuffer()->SetExecutable();                        \
103b8021494Sopenharmony_ci    ExecuteMemory(masm.GetBuffer()->GetStartAddress<byte*>(), \
104b8021494Sopenharmony_ci                  masm.GetSizeOfCodeGenerated(),              \
105b8021494Sopenharmony_ci                  pcs_offset);                                \
106b8021494Sopenharmony_ci    masm.GetBuffer()->SetWritable();                          \
107b8021494Sopenharmony_ci  }
108b8021494Sopenharmony_ci
109b8021494Sopenharmony_ci#endif  // ifdef VIXL_INCLUDE_SIMULATOR_AARCH32
110b8021494Sopenharmony_ci
111b8021494Sopenharmony_cinamespace vixl {
112b8021494Sopenharmony_cinamespace aarch32 {
113b8021494Sopenharmony_ci
114b8021494Sopenharmony_ci// List of instruction encodings:
115b8021494Sopenharmony_ci#define FOREACH_INSTRUCTION(M) \
116b8021494Sopenharmony_ci  M(Cmn)                       \
117b8021494Sopenharmony_ci  M(Cmp)                       \
118b8021494Sopenharmony_ci  M(Mov)                       \
119b8021494Sopenharmony_ci  M(Movs)                      \
120b8021494Sopenharmony_ci  M(Mvn)                       \
121b8021494Sopenharmony_ci  M(Mvns)                      \
122b8021494Sopenharmony_ci  M(Teq)                       \
123b8021494Sopenharmony_ci  M(Tst)
124b8021494Sopenharmony_ci
125b8021494Sopenharmony_ci
126b8021494Sopenharmony_ci// The following definitions are defined again in each generated test, therefore
127b8021494Sopenharmony_ci// we need to place them in an anonymous namespace. It expresses that they are
128b8021494Sopenharmony_ci// local to this file only, and the compiler is not allowed to share these types
129b8021494Sopenharmony_ci// across test files during template instantiation. Specifically, `Operands` and
130b8021494Sopenharmony_ci// `Inputs` have various layouts across generated tests so they absolutely
131b8021494Sopenharmony_ci// cannot be shared.
132b8021494Sopenharmony_ci
133b8021494Sopenharmony_ci#ifdef VIXL_INCLUDE_TARGET_A32
134b8021494Sopenharmony_cinamespace {
135b8021494Sopenharmony_ci
136b8021494Sopenharmony_ci// Values to be passed to the assembler to produce the instruction under test.
137b8021494Sopenharmony_cistruct Operands {
138b8021494Sopenharmony_ci  Condition cond;
139b8021494Sopenharmony_ci  Register rd;
140b8021494Sopenharmony_ci  uint32_t immediate;
141b8021494Sopenharmony_ci};
142b8021494Sopenharmony_ci
143b8021494Sopenharmony_ci// Input data to feed to the instruction.
144b8021494Sopenharmony_cistruct Inputs {
145b8021494Sopenharmony_ci  uint32_t apsr;
146b8021494Sopenharmony_ci  uint32_t rd;
147b8021494Sopenharmony_ci};
148b8021494Sopenharmony_ci
149b8021494Sopenharmony_ci// This structure contains all input data needed to test one specific encoding.
150b8021494Sopenharmony_ci// It used to generate a loop over an instruction.
151b8021494Sopenharmony_cistruct TestLoopData {
152b8021494Sopenharmony_ci  // The `operands` fields represents the values to pass to the assembler to
153b8021494Sopenharmony_ci  // produce the instruction.
154b8021494Sopenharmony_ci  Operands operands;
155b8021494Sopenharmony_ci  // Description of the operands, used for error reporting.
156b8021494Sopenharmony_ci  const char* operands_description;
157b8021494Sopenharmony_ci  // Unique identifier, used for generating traces.
158b8021494Sopenharmony_ci  const char* identifier;
159b8021494Sopenharmony_ci  // Array of values to be fed to the instruction.
160b8021494Sopenharmony_ci  size_t input_size;
161b8021494Sopenharmony_ci  const Inputs* inputs;
162b8021494Sopenharmony_ci};
163b8021494Sopenharmony_ci
164b8021494Sopenharmony_cistatic const Inputs kCondition[] = {{NFlag, 0xabababab},
165b8021494Sopenharmony_ci                                    {ZFlag, 0xabababab},
166b8021494Sopenharmony_ci                                    {CFlag, 0xabababab},
167b8021494Sopenharmony_ci                                    {VFlag, 0xabababab},
168b8021494Sopenharmony_ci                                    {NZFlag, 0xabababab},
169b8021494Sopenharmony_ci                                    {NCFlag, 0xabababab},
170b8021494Sopenharmony_ci                                    {NVFlag, 0xabababab},
171b8021494Sopenharmony_ci                                    {ZCFlag, 0xabababab},
172b8021494Sopenharmony_ci                                    {ZVFlag, 0xabababab},
173b8021494Sopenharmony_ci                                    {CVFlag, 0xabababab},
174b8021494Sopenharmony_ci                                    {NZCFlag, 0xabababab},
175b8021494Sopenharmony_ci                                    {NZVFlag, 0xabababab},
176b8021494Sopenharmony_ci                                    {NCVFlag, 0xabababab},
177b8021494Sopenharmony_ci                                    {ZCVFlag, 0xabababab},
178b8021494Sopenharmony_ci                                    {NZCVFlag, 0xabababab}};
179b8021494Sopenharmony_ci
180b8021494Sopenharmony_cistatic const Inputs kModifiedImmediate[] =
181b8021494Sopenharmony_ci    {{NoFlag, 0x00000000}, {NoFlag, 0x00000001}, {NoFlag, 0x00000002},
182b8021494Sopenharmony_ci     {NoFlag, 0x00000020}, {NoFlag, 0x0000007d}, {NoFlag, 0x0000007e},
183b8021494Sopenharmony_ci     {NoFlag, 0x0000007f}, {NoFlag, 0x00007ffd}, {NoFlag, 0x00007ffe},
184b8021494Sopenharmony_ci     {NoFlag, 0x00007fff}, {NoFlag, 0x33333333}, {NoFlag, 0x55555555},
185b8021494Sopenharmony_ci     {NoFlag, 0x7ffffffd}, {NoFlag, 0x7ffffffe}, {NoFlag, 0x7fffffff},
186b8021494Sopenharmony_ci     {NoFlag, 0x80000000}, {NoFlag, 0x80000001}, {NoFlag, 0xaaaaaaaa},
187b8021494Sopenharmony_ci     {NoFlag, 0xcccccccc}, {NoFlag, 0xffff8000}, {NoFlag, 0xffff8001},
188b8021494Sopenharmony_ci     {NoFlag, 0xffff8002}, {NoFlag, 0xffff8003}, {NoFlag, 0xffffff80},
189b8021494Sopenharmony_ci     {NoFlag, 0xffffff81}, {NoFlag, 0xffffff82}, {NoFlag, 0xffffff83},
190b8021494Sopenharmony_ci     {NoFlag, 0xffffffe0}, {NoFlag, 0xfffffffd}, {NoFlag, 0xfffffffe},
191b8021494Sopenharmony_ci     {NoFlag, 0xffffffff}};
192b8021494Sopenharmony_ci
193b8021494Sopenharmony_ci
194b8021494Sopenharmony_ci// A loop will be generated for each element of this array.
195b8021494Sopenharmony_ciconst TestLoopData kTests[] = {{{eq, r0, 0x000000ab},
196b8021494Sopenharmony_ci                                "eq r0 0x000000ab",
197b8021494Sopenharmony_ci                                "Condition_eq_r0_0x000000ab",
198b8021494Sopenharmony_ci                                ARRAY_SIZE(kCondition),
199b8021494Sopenharmony_ci                                kCondition},
200b8021494Sopenharmony_ci                               {{ne, r0, 0x000000ab},
201b8021494Sopenharmony_ci                                "ne r0 0x000000ab",
202b8021494Sopenharmony_ci                                "Condition_ne_r0_0x000000ab",
203b8021494Sopenharmony_ci                                ARRAY_SIZE(kCondition),
204b8021494Sopenharmony_ci                                kCondition},
205b8021494Sopenharmony_ci                               {{cs, r0, 0x000000ab},
206b8021494Sopenharmony_ci                                "cs r0 0x000000ab",
207b8021494Sopenharmony_ci                                "Condition_cs_r0_0x000000ab",
208b8021494Sopenharmony_ci                                ARRAY_SIZE(kCondition),
209b8021494Sopenharmony_ci                                kCondition},
210b8021494Sopenharmony_ci                               {{cc, r0, 0x000000ab},
211b8021494Sopenharmony_ci                                "cc r0 0x000000ab",
212b8021494Sopenharmony_ci                                "Condition_cc_r0_0x000000ab",
213b8021494Sopenharmony_ci                                ARRAY_SIZE(kCondition),
214b8021494Sopenharmony_ci                                kCondition},
215b8021494Sopenharmony_ci                               {{mi, r0, 0x000000ab},
216b8021494Sopenharmony_ci                                "mi r0 0x000000ab",
217b8021494Sopenharmony_ci                                "Condition_mi_r0_0x000000ab",
218b8021494Sopenharmony_ci                                ARRAY_SIZE(kCondition),
219b8021494Sopenharmony_ci                                kCondition},
220b8021494Sopenharmony_ci                               {{pl, r0, 0x000000ab},
221b8021494Sopenharmony_ci                                "pl r0 0x000000ab",
222b8021494Sopenharmony_ci                                "Condition_pl_r0_0x000000ab",
223b8021494Sopenharmony_ci                                ARRAY_SIZE(kCondition),
224b8021494Sopenharmony_ci                                kCondition},
225b8021494Sopenharmony_ci                               {{vs, r0, 0x000000ab},
226b8021494Sopenharmony_ci                                "vs r0 0x000000ab",
227b8021494Sopenharmony_ci                                "Condition_vs_r0_0x000000ab",
228b8021494Sopenharmony_ci                                ARRAY_SIZE(kCondition),
229b8021494Sopenharmony_ci                                kCondition},
230b8021494Sopenharmony_ci                               {{vc, r0, 0x000000ab},
231b8021494Sopenharmony_ci                                "vc r0 0x000000ab",
232b8021494Sopenharmony_ci                                "Condition_vc_r0_0x000000ab",
233b8021494Sopenharmony_ci                                ARRAY_SIZE(kCondition),
234b8021494Sopenharmony_ci                                kCondition},
235b8021494Sopenharmony_ci                               {{hi, r0, 0x000000ab},
236b8021494Sopenharmony_ci                                "hi r0 0x000000ab",
237b8021494Sopenharmony_ci                                "Condition_hi_r0_0x000000ab",
238b8021494Sopenharmony_ci                                ARRAY_SIZE(kCondition),
239b8021494Sopenharmony_ci                                kCondition},
240b8021494Sopenharmony_ci                               {{ls, r0, 0x000000ab},
241b8021494Sopenharmony_ci                                "ls r0 0x000000ab",
242b8021494Sopenharmony_ci                                "Condition_ls_r0_0x000000ab",
243b8021494Sopenharmony_ci                                ARRAY_SIZE(kCondition),
244b8021494Sopenharmony_ci                                kCondition},
245b8021494Sopenharmony_ci                               {{ge, r0, 0x000000ab},
246b8021494Sopenharmony_ci                                "ge r0 0x000000ab",
247b8021494Sopenharmony_ci                                "Condition_ge_r0_0x000000ab",
248b8021494Sopenharmony_ci                                ARRAY_SIZE(kCondition),
249b8021494Sopenharmony_ci                                kCondition},
250b8021494Sopenharmony_ci                               {{lt, r0, 0x000000ab},
251b8021494Sopenharmony_ci                                "lt r0 0x000000ab",
252b8021494Sopenharmony_ci                                "Condition_lt_r0_0x000000ab",
253b8021494Sopenharmony_ci                                ARRAY_SIZE(kCondition),
254b8021494Sopenharmony_ci                                kCondition},
255b8021494Sopenharmony_ci                               {{gt, r0, 0x000000ab},
256b8021494Sopenharmony_ci                                "gt r0 0x000000ab",
257b8021494Sopenharmony_ci                                "Condition_gt_r0_0x000000ab",
258b8021494Sopenharmony_ci                                ARRAY_SIZE(kCondition),
259b8021494Sopenharmony_ci                                kCondition},
260b8021494Sopenharmony_ci                               {{le, r0, 0x000000ab},
261b8021494Sopenharmony_ci                                "le r0 0x000000ab",
262b8021494Sopenharmony_ci                                "Condition_le_r0_0x000000ab",
263b8021494Sopenharmony_ci                                ARRAY_SIZE(kCondition),
264b8021494Sopenharmony_ci                                kCondition},
265b8021494Sopenharmony_ci                               {{al, r0, 0x000000ab},
266b8021494Sopenharmony_ci                                "al r0 0x000000ab",
267b8021494Sopenharmony_ci                                "Condition_al_r0_0x000000ab",
268b8021494Sopenharmony_ci                                ARRAY_SIZE(kCondition),
269b8021494Sopenharmony_ci                                kCondition},
270b8021494Sopenharmony_ci                               {{al, r0, 0x00000000},
271b8021494Sopenharmony_ci                                "al r0 0x00000000",
272b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x00000000",
273b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
274b8021494Sopenharmony_ci                                kModifiedImmediate},
275b8021494Sopenharmony_ci                               {{al, r0, 0x000000ff},
276b8021494Sopenharmony_ci                                "al r0 0x000000ff",
277b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x000000ff",
278b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
279b8021494Sopenharmony_ci                                kModifiedImmediate},
280b8021494Sopenharmony_ci                               {{al, r0, 0xc000003f},
281b8021494Sopenharmony_ci                                "al r0 0xc000003f",
282b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0xc000003f",
283b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
284b8021494Sopenharmony_ci                                kModifiedImmediate},
285b8021494Sopenharmony_ci                               {{al, r0, 0xf000000f},
286b8021494Sopenharmony_ci                                "al r0 0xf000000f",
287b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0xf000000f",
288b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
289b8021494Sopenharmony_ci                                kModifiedImmediate},
290b8021494Sopenharmony_ci                               {{al, r0, 0xfc000003},
291b8021494Sopenharmony_ci                                "al r0 0xfc000003",
292b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0xfc000003",
293b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
294b8021494Sopenharmony_ci                                kModifiedImmediate},
295b8021494Sopenharmony_ci                               {{al, r0, 0xff000000},
296b8021494Sopenharmony_ci                                "al r0 0xff000000",
297b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0xff000000",
298b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
299b8021494Sopenharmony_ci                                kModifiedImmediate},
300b8021494Sopenharmony_ci                               {{al, r0, 0x3fc00000},
301b8021494Sopenharmony_ci                                "al r0 0x3fc00000",
302b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x3fc00000",
303b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
304b8021494Sopenharmony_ci                                kModifiedImmediate},
305b8021494Sopenharmony_ci                               {{al, r0, 0x0ff00000},
306b8021494Sopenharmony_ci                                "al r0 0x0ff00000",
307b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x0ff00000",
308b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
309b8021494Sopenharmony_ci                                kModifiedImmediate},
310b8021494Sopenharmony_ci                               {{al, r0, 0x03fc0000},
311b8021494Sopenharmony_ci                                "al r0 0x03fc0000",
312b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x03fc0000",
313b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
314b8021494Sopenharmony_ci                                kModifiedImmediate},
315b8021494Sopenharmony_ci                               {{al, r0, 0x00ff0000},
316b8021494Sopenharmony_ci                                "al r0 0x00ff0000",
317b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x00ff0000",
318b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
319b8021494Sopenharmony_ci                                kModifiedImmediate},
320b8021494Sopenharmony_ci                               {{al, r0, 0x003fc000},
321b8021494Sopenharmony_ci                                "al r0 0x003fc000",
322b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x003fc000",
323b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
324b8021494Sopenharmony_ci                                kModifiedImmediate},
325b8021494Sopenharmony_ci                               {{al, r0, 0x000ff000},
326b8021494Sopenharmony_ci                                "al r0 0x000ff000",
327b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x000ff000",
328b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
329b8021494Sopenharmony_ci                                kModifiedImmediate},
330b8021494Sopenharmony_ci                               {{al, r0, 0x0003fc00},
331b8021494Sopenharmony_ci                                "al r0 0x0003fc00",
332b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x0003fc00",
333b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
334b8021494Sopenharmony_ci                                kModifiedImmediate},
335b8021494Sopenharmony_ci                               {{al, r0, 0x0000ff00},
336b8021494Sopenharmony_ci                                "al r0 0x0000ff00",
337b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x0000ff00",
338b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
339b8021494Sopenharmony_ci                                kModifiedImmediate},
340b8021494Sopenharmony_ci                               {{al, r0, 0x00003fc0},
341b8021494Sopenharmony_ci                                "al r0 0x00003fc0",
342b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x00003fc0",
343b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
344b8021494Sopenharmony_ci                                kModifiedImmediate},
345b8021494Sopenharmony_ci                               {{al, r0, 0x00000ff0},
346b8021494Sopenharmony_ci                                "al r0 0x00000ff0",
347b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x00000ff0",
348b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
349b8021494Sopenharmony_ci                                kModifiedImmediate},
350b8021494Sopenharmony_ci                               {{al, r0, 0x000003fc},
351b8021494Sopenharmony_ci                                "al r0 0x000003fc",
352b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x000003fc",
353b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
354b8021494Sopenharmony_ci                                kModifiedImmediate},
355b8021494Sopenharmony_ci                               {{al, r0, 0x000000ab},
356b8021494Sopenharmony_ci                                "al r0 0x000000ab",
357b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x000000ab",
358b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
359b8021494Sopenharmony_ci                                kModifiedImmediate},
360b8021494Sopenharmony_ci                               {{al, r0, 0xc000002a},
361b8021494Sopenharmony_ci                                "al r0 0xc000002a",
362b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0xc000002a",
363b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
364b8021494Sopenharmony_ci                                kModifiedImmediate},
365b8021494Sopenharmony_ci                               {{al, r0, 0xb000000a},
366b8021494Sopenharmony_ci                                "al r0 0xb000000a",
367b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0xb000000a",
368b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
369b8021494Sopenharmony_ci                                kModifiedImmediate},
370b8021494Sopenharmony_ci                               {{al, r0, 0xac000002},
371b8021494Sopenharmony_ci                                "al r0 0xac000002",
372b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0xac000002",
373b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
374b8021494Sopenharmony_ci                                kModifiedImmediate},
375b8021494Sopenharmony_ci                               {{al, r0, 0xab000000},
376b8021494Sopenharmony_ci                                "al r0 0xab000000",
377b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0xab000000",
378b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
379b8021494Sopenharmony_ci                                kModifiedImmediate},
380b8021494Sopenharmony_ci                               {{al, r0, 0x2ac00000},
381b8021494Sopenharmony_ci                                "al r0 0x2ac00000",
382b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x2ac00000",
383b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
384b8021494Sopenharmony_ci                                kModifiedImmediate},
385b8021494Sopenharmony_ci                               {{al, r0, 0x0ab00000},
386b8021494Sopenharmony_ci                                "al r0 0x0ab00000",
387b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x0ab00000",
388b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
389b8021494Sopenharmony_ci                                kModifiedImmediate},
390b8021494Sopenharmony_ci                               {{al, r0, 0x02ac0000},
391b8021494Sopenharmony_ci                                "al r0 0x02ac0000",
392b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x02ac0000",
393b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
394b8021494Sopenharmony_ci                                kModifiedImmediate},
395b8021494Sopenharmony_ci                               {{al, r0, 0x00ab0000},
396b8021494Sopenharmony_ci                                "al r0 0x00ab0000",
397b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x00ab0000",
398b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
399b8021494Sopenharmony_ci                                kModifiedImmediate},
400b8021494Sopenharmony_ci                               {{al, r0, 0x002ac000},
401b8021494Sopenharmony_ci                                "al r0 0x002ac000",
402b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x002ac000",
403b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
404b8021494Sopenharmony_ci                                kModifiedImmediate},
405b8021494Sopenharmony_ci                               {{al, r0, 0x000ab000},
406b8021494Sopenharmony_ci                                "al r0 0x000ab000",
407b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x000ab000",
408b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
409b8021494Sopenharmony_ci                                kModifiedImmediate},
410b8021494Sopenharmony_ci                               {{al, r0, 0x0002ac00},
411b8021494Sopenharmony_ci                                "al r0 0x0002ac00",
412b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x0002ac00",
413b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
414b8021494Sopenharmony_ci                                kModifiedImmediate},
415b8021494Sopenharmony_ci                               {{al, r0, 0x0000ab00},
416b8021494Sopenharmony_ci                                "al r0 0x0000ab00",
417b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x0000ab00",
418b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
419b8021494Sopenharmony_ci                                kModifiedImmediate},
420b8021494Sopenharmony_ci                               {{al, r0, 0x00002ac0},
421b8021494Sopenharmony_ci                                "al r0 0x00002ac0",
422b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x00002ac0",
423b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
424b8021494Sopenharmony_ci                                kModifiedImmediate},
425b8021494Sopenharmony_ci                               {{al, r0, 0x00000ab0},
426b8021494Sopenharmony_ci                                "al r0 0x00000ab0",
427b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x00000ab0",
428b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
429b8021494Sopenharmony_ci                                kModifiedImmediate},
430b8021494Sopenharmony_ci                               {{al, r0, 0x000002ac},
431b8021494Sopenharmony_ci                                "al r0 0x000002ac",
432b8021494Sopenharmony_ci                                "ModifiedImmediate_al_r0_0x000002ac",
433b8021494Sopenharmony_ci                                ARRAY_SIZE(kModifiedImmediate),
434b8021494Sopenharmony_ci                                kModifiedImmediate}};
435b8021494Sopenharmony_ci
436b8021494Sopenharmony_ci// We record all inputs to the instructions as outputs. This way, we also check
437b8021494Sopenharmony_ci// that what shouldn't change didn't change.
438b8021494Sopenharmony_cistruct TestResult {
439b8021494Sopenharmony_ci  size_t output_size;
440b8021494Sopenharmony_ci  const Inputs* outputs;
441b8021494Sopenharmony_ci};
442b8021494Sopenharmony_ci
443b8021494Sopenharmony_ci// These headers each contain an array of `TestResult` with the reference output
444b8021494Sopenharmony_ci// values. The reference arrays are names `kReference{mnemonic}`.
445b8021494Sopenharmony_ci#include "aarch32/traces/simulator-cond-rd-operand-const-cmn-a32.h"
446b8021494Sopenharmony_ci#include "aarch32/traces/simulator-cond-rd-operand-const-cmp-a32.h"
447b8021494Sopenharmony_ci#include "aarch32/traces/simulator-cond-rd-operand-const-mov-a32.h"
448b8021494Sopenharmony_ci#include "aarch32/traces/simulator-cond-rd-operand-const-movs-a32.h"
449b8021494Sopenharmony_ci#include "aarch32/traces/simulator-cond-rd-operand-const-mvn-a32.h"
450b8021494Sopenharmony_ci#include "aarch32/traces/simulator-cond-rd-operand-const-mvns-a32.h"
451b8021494Sopenharmony_ci#include "aarch32/traces/simulator-cond-rd-operand-const-teq-a32.h"
452b8021494Sopenharmony_ci#include "aarch32/traces/simulator-cond-rd-operand-const-tst-a32.h"
453b8021494Sopenharmony_ci
454b8021494Sopenharmony_ci
455b8021494Sopenharmony_ci// The maximum number of errors to report in detail for each test.
456b8021494Sopenharmony_ciconst unsigned kErrorReportLimit = 8;
457b8021494Sopenharmony_ci
458b8021494Sopenharmony_citypedef void (MacroAssembler::*Fn)(Condition cond,
459b8021494Sopenharmony_ci                                   Register rd,
460b8021494Sopenharmony_ci                                   const Operand& op);
461b8021494Sopenharmony_ci
462b8021494Sopenharmony_civoid TestHelper(Fn instruction,
463b8021494Sopenharmony_ci                const char* mnemonic,
464b8021494Sopenharmony_ci                const TestResult reference[]) {
465b8021494Sopenharmony_ci  SETUP();
466b8021494Sopenharmony_ci  masm.UseA32();
467b8021494Sopenharmony_ci  START();
468b8021494Sopenharmony_ci
469b8021494Sopenharmony_ci  // Data to compare to `reference`.
470b8021494Sopenharmony_ci  TestResult* results[ARRAY_SIZE(kTests)];
471b8021494Sopenharmony_ci
472b8021494Sopenharmony_ci  // Test cases for memory bound instructions may allocate a buffer and save its
473b8021494Sopenharmony_ci  // address in this array.
474b8021494Sopenharmony_ci  byte* scratch_memory_buffers[ARRAY_SIZE(kTests)];
475b8021494Sopenharmony_ci
476b8021494Sopenharmony_ci  // Generate a loop for each element in `kTests`. Each loop tests one specific
477b8021494Sopenharmony_ci  // instruction.
478b8021494Sopenharmony_ci  for (unsigned i = 0; i < ARRAY_SIZE(kTests); i++) {
479b8021494Sopenharmony_ci    // Allocate results on the heap for this test.
480b8021494Sopenharmony_ci    results[i] = new TestResult;
481b8021494Sopenharmony_ci    results[i]->outputs = new Inputs[kTests[i].input_size];
482b8021494Sopenharmony_ci    results[i]->output_size = kTests[i].input_size;
483b8021494Sopenharmony_ci
484b8021494Sopenharmony_ci    size_t input_stride = sizeof(kTests[i].inputs[0]) * kTests[i].input_size;
485b8021494Sopenharmony_ci    VIXL_ASSERT(IsUint32(input_stride));
486b8021494Sopenharmony_ci
487b8021494Sopenharmony_ci    scratch_memory_buffers[i] = NULL;
488b8021494Sopenharmony_ci
489b8021494Sopenharmony_ci    Label loop;
490b8021494Sopenharmony_ci    UseScratchRegisterScope scratch_registers(&masm);
491b8021494Sopenharmony_ci    // Include all registers from r0 ro r12.
492b8021494Sopenharmony_ci    scratch_registers.Include(RegisterList(0x1fff));
493b8021494Sopenharmony_ci
494b8021494Sopenharmony_ci    // Values to pass to the macro-assembler.
495b8021494Sopenharmony_ci    Condition cond = kTests[i].operands.cond;
496b8021494Sopenharmony_ci    Register rd = kTests[i].operands.rd;
497b8021494Sopenharmony_ci    uint32_t immediate = kTests[i].operands.immediate;
498b8021494Sopenharmony_ci    Operand op(immediate);
499b8021494Sopenharmony_ci    scratch_registers.Exclude(rd);
500b8021494Sopenharmony_ci
501b8021494Sopenharmony_ci    // Allocate reserved registers for our own use.
502b8021494Sopenharmony_ci    Register input_ptr = scratch_registers.Acquire();
503b8021494Sopenharmony_ci    Register input_end = scratch_registers.Acquire();
504b8021494Sopenharmony_ci    Register result_ptr = scratch_registers.Acquire();
505b8021494Sopenharmony_ci
506b8021494Sopenharmony_ci    // Initialize `input_ptr` to the first element and `input_end` the address
507b8021494Sopenharmony_ci    // after the array.
508b8021494Sopenharmony_ci    __ Mov(input_ptr, Operand::From(kTests[i].inputs));
509b8021494Sopenharmony_ci    __ Add(input_end, input_ptr, static_cast<uint32_t>(input_stride));
510b8021494Sopenharmony_ci    __ Mov(result_ptr, Operand::From(results[i]->outputs));
511b8021494Sopenharmony_ci    __ Bind(&loop);
512b8021494Sopenharmony_ci
513b8021494Sopenharmony_ci    {
514b8021494Sopenharmony_ci      UseScratchRegisterScope temp_registers(&masm);
515b8021494Sopenharmony_ci      Register nzcv_bits = temp_registers.Acquire();
516b8021494Sopenharmony_ci      Register saved_q_bit = temp_registers.Acquire();
517b8021494Sopenharmony_ci      // Save the `Q` bit flag.
518b8021494Sopenharmony_ci      __ Mrs(saved_q_bit, APSR);
519b8021494Sopenharmony_ci      __ And(saved_q_bit, saved_q_bit, QFlag);
520b8021494Sopenharmony_ci      // Set the `NZCV` and `Q` flags together.
521b8021494Sopenharmony_ci      __ Ldr(nzcv_bits, MemOperand(input_ptr, offsetof(Inputs, apsr)));
522b8021494Sopenharmony_ci      __ Orr(nzcv_bits, nzcv_bits, saved_q_bit);
523b8021494Sopenharmony_ci      __ Msr(APSR_nzcvq, nzcv_bits);
524b8021494Sopenharmony_ci    }
525b8021494Sopenharmony_ci    __ Ldr(rd, MemOperand(input_ptr, offsetof(Inputs, rd)));
526b8021494Sopenharmony_ci
527b8021494Sopenharmony_ci    (masm.*instruction)(cond, rd, op);
528b8021494Sopenharmony_ci
529b8021494Sopenharmony_ci    {
530b8021494Sopenharmony_ci      UseScratchRegisterScope temp_registers(&masm);
531b8021494Sopenharmony_ci      Register nzcv_bits = temp_registers.Acquire();
532b8021494Sopenharmony_ci      __ Mrs(nzcv_bits, APSR);
533b8021494Sopenharmony_ci      // Only record the NZCV bits.
534b8021494Sopenharmony_ci      __ And(nzcv_bits, nzcv_bits, NZCVFlag);
535b8021494Sopenharmony_ci      __ Str(nzcv_bits, MemOperand(result_ptr, offsetof(Inputs, apsr)));
536b8021494Sopenharmony_ci    }
537b8021494Sopenharmony_ci    __ Str(rd, MemOperand(result_ptr, offsetof(Inputs, rd)));
538b8021494Sopenharmony_ci
539b8021494Sopenharmony_ci    // Advance the result pointer.
540b8021494Sopenharmony_ci    __ Add(result_ptr, result_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
541b8021494Sopenharmony_ci    // Loop back until `input_ptr` is lower than `input_base`.
542b8021494Sopenharmony_ci    __ Add(input_ptr, input_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
543b8021494Sopenharmony_ci    __ Cmp(input_ptr, input_end);
544b8021494Sopenharmony_ci    __ B(ne, &loop);
545b8021494Sopenharmony_ci  }
546b8021494Sopenharmony_ci
547b8021494Sopenharmony_ci  END();
548b8021494Sopenharmony_ci
549b8021494Sopenharmony_ci  RUN();
550b8021494Sopenharmony_ci
551b8021494Sopenharmony_ci  if (Test::generate_test_trace()) {
552b8021494Sopenharmony_ci    // Print the results.
553b8021494Sopenharmony_ci    for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
554b8021494Sopenharmony_ci      printf("const Inputs kOutputs_%s_%s[] = {\n",
555b8021494Sopenharmony_ci             mnemonic,
556b8021494Sopenharmony_ci             kTests[i].identifier);
557b8021494Sopenharmony_ci      for (size_t j = 0; j < results[i]->output_size; j++) {
558b8021494Sopenharmony_ci        printf("  { ");
559b8021494Sopenharmony_ci        printf("0x%08" PRIx32, results[i]->outputs[j].apsr);
560b8021494Sopenharmony_ci        printf(", ");
561b8021494Sopenharmony_ci        printf("0x%08" PRIx32, results[i]->outputs[j].rd);
562b8021494Sopenharmony_ci        printf(" },\n");
563b8021494Sopenharmony_ci      }
564b8021494Sopenharmony_ci      printf("};\n");
565b8021494Sopenharmony_ci    }
566b8021494Sopenharmony_ci    printf("const TestResult kReference%s[] = {\n", mnemonic);
567b8021494Sopenharmony_ci    for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
568b8021494Sopenharmony_ci      printf("  {\n");
569b8021494Sopenharmony_ci      printf("    ARRAY_SIZE(kOutputs_%s_%s),\n",
570b8021494Sopenharmony_ci             mnemonic,
571b8021494Sopenharmony_ci             kTests[i].identifier);
572b8021494Sopenharmony_ci      printf("    kOutputs_%s_%s,\n", mnemonic, kTests[i].identifier);
573b8021494Sopenharmony_ci      printf("  },\n");
574b8021494Sopenharmony_ci    }
575b8021494Sopenharmony_ci    printf("};\n");
576b8021494Sopenharmony_ci  } else if (kCheckSimulatorTestResults) {
577b8021494Sopenharmony_ci    // Check the results.
578b8021494Sopenharmony_ci    unsigned total_error_count = 0;
579b8021494Sopenharmony_ci    for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
580b8021494Sopenharmony_ci      bool instruction_has_errors = false;
581b8021494Sopenharmony_ci      for (size_t j = 0; j < kTests[i].input_size; j++) {
582b8021494Sopenharmony_ci        uint32_t apsr = results[i]->outputs[j].apsr;
583b8021494Sopenharmony_ci        uint32_t rd = results[i]->outputs[j].rd;
584b8021494Sopenharmony_ci        uint32_t apsr_input = kTests[i].inputs[j].apsr;
585b8021494Sopenharmony_ci        uint32_t rd_input = kTests[i].inputs[j].rd;
586b8021494Sopenharmony_ci        uint32_t apsr_ref = reference[i].outputs[j].apsr;
587b8021494Sopenharmony_ci        uint32_t rd_ref = reference[i].outputs[j].rd;
588b8021494Sopenharmony_ci
589b8021494Sopenharmony_ci        if (((apsr != apsr_ref) || (rd != rd_ref)) &&
590b8021494Sopenharmony_ci            (++total_error_count <= kErrorReportLimit)) {
591b8021494Sopenharmony_ci          // Print the instruction once even if it triggered multiple failures.
592b8021494Sopenharmony_ci          if (!instruction_has_errors) {
593b8021494Sopenharmony_ci            printf("Error(s) when testing \"%s %s\":\n",
594b8021494Sopenharmony_ci                   mnemonic,
595b8021494Sopenharmony_ci                   kTests[i].operands_description);
596b8021494Sopenharmony_ci            instruction_has_errors = true;
597b8021494Sopenharmony_ci          }
598b8021494Sopenharmony_ci          // Print subsequent errors.
599b8021494Sopenharmony_ci          printf("  Input:    ");
600b8021494Sopenharmony_ci          printf("0x%08" PRIx32, apsr_input);
601b8021494Sopenharmony_ci          printf(", ");
602b8021494Sopenharmony_ci          printf("0x%08" PRIx32, rd_input);
603b8021494Sopenharmony_ci          printf("\n");
604b8021494Sopenharmony_ci          printf("  Expected: ");
605b8021494Sopenharmony_ci          printf("0x%08" PRIx32, apsr_ref);
606b8021494Sopenharmony_ci          printf(", ");
607b8021494Sopenharmony_ci          printf("0x%08" PRIx32, rd_ref);
608b8021494Sopenharmony_ci          printf("\n");
609b8021494Sopenharmony_ci          printf("  Found:    ");
610b8021494Sopenharmony_ci          printf("0x%08" PRIx32, apsr);
611b8021494Sopenharmony_ci          printf(", ");
612b8021494Sopenharmony_ci          printf("0x%08" PRIx32, rd);
613b8021494Sopenharmony_ci          printf("\n\n");
614b8021494Sopenharmony_ci        }
615b8021494Sopenharmony_ci      }
616b8021494Sopenharmony_ci    }
617b8021494Sopenharmony_ci
618b8021494Sopenharmony_ci    if (total_error_count > kErrorReportLimit) {
619b8021494Sopenharmony_ci      printf("%u other errors follow.\n",
620b8021494Sopenharmony_ci             total_error_count - kErrorReportLimit);
621b8021494Sopenharmony_ci    }
622b8021494Sopenharmony_ci    VIXL_CHECK(total_error_count == 0);
623b8021494Sopenharmony_ci  } else {
624b8021494Sopenharmony_ci    VIXL_WARNING("Assembled the code, but did not run anything.\n");
625b8021494Sopenharmony_ci  }
626b8021494Sopenharmony_ci
627b8021494Sopenharmony_ci  for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
628b8021494Sopenharmony_ci    delete[] results[i]->outputs;
629b8021494Sopenharmony_ci    delete results[i];
630b8021494Sopenharmony_ci    delete[] scratch_memory_buffers[i];
631b8021494Sopenharmony_ci  }
632b8021494Sopenharmony_ci}
633b8021494Sopenharmony_ci
634b8021494Sopenharmony_ci// Instantiate tests for each instruction in the list.
635b8021494Sopenharmony_ci// TODO: Remove this limitation by having a sandboxing mechanism.
636b8021494Sopenharmony_ci#if defined(VIXL_HOST_POINTER_32)
637b8021494Sopenharmony_ci#define TEST(mnemonic)                                                      \
638b8021494Sopenharmony_ci  void Test_##mnemonic() {                                                  \
639b8021494Sopenharmony_ci    TestHelper(&MacroAssembler::mnemonic, #mnemonic, kReference##mnemonic); \
640b8021494Sopenharmony_ci  }                                                                         \
641b8021494Sopenharmony_ci  Test test_##mnemonic("AARCH32_SIMULATOR_COND_RD_OPERAND_CONST_" #mnemonic \
642b8021494Sopenharmony_ci                       "_A32",                                              \
643b8021494Sopenharmony_ci                       &Test_##mnemonic);
644b8021494Sopenharmony_ci#else
645b8021494Sopenharmony_ci#define TEST(mnemonic)                                                      \
646b8021494Sopenharmony_ci  void Test_##mnemonic() {                                                  \
647b8021494Sopenharmony_ci    VIXL_WARNING("This test can only run on a 32-bit host.\n");             \
648b8021494Sopenharmony_ci    USE(TestHelper);                                                        \
649b8021494Sopenharmony_ci  }                                                                         \
650b8021494Sopenharmony_ci  Test test_##mnemonic("AARCH32_SIMULATOR_COND_RD_OPERAND_CONST_" #mnemonic \
651b8021494Sopenharmony_ci                       "_A32",                                              \
652b8021494Sopenharmony_ci                       &Test_##mnemonic);
653b8021494Sopenharmony_ci#endif
654b8021494Sopenharmony_ci
655b8021494Sopenharmony_ciFOREACH_INSTRUCTION(TEST)
656b8021494Sopenharmony_ci#undef TEST
657b8021494Sopenharmony_ci
658b8021494Sopenharmony_ci}  // namespace
659b8021494Sopenharmony_ci#endif
660b8021494Sopenharmony_ci
661b8021494Sopenharmony_ci}  // namespace aarch32
662b8021494Sopenharmony_ci}  // namespace vixl
663