1 // Copyright 2016, VIXL authors
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
6 //
7 // * Redistributions of source code must retain the above copyright notice,
8 // this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above copyright notice,
10 // this list of conditions and the following disclaimer in the documentation
11 // and/or other materials provided with the distribution.
12 // * Neither the name of ARM Limited nor the names of its contributors may be
13 // used to endorse or promote products derived from this software without
14 // specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
17 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27
28 // -----------------------------------------------------------------------------
29 // This file is auto generated from the
30 // test/aarch32/config/template-simulator-aarch32.cc.in template file using
31 // tools/generate_tests.py.
32 //
33 // PLEASE DO NOT EDIT.
34 // -----------------------------------------------------------------------------
35
36
37 #include "test-runner.h"
38
39 #include "test-utils.h"
40 #include "test-utils-aarch32.h"
41
42 #include "aarch32/assembler-aarch32.h"
43 #include "aarch32/disasm-aarch32.h"
44 #include "aarch32/macro-assembler-aarch32.h"
45
46 #define __ masm.
47 #define BUF_SIZE (4096)
48
49 #ifdef VIXL_INCLUDE_SIMULATOR_AARCH32
50 // Run tests with the simulator.
51
52 #define SETUP() MacroAssembler masm(BUF_SIZE)
53
54 #define START() masm.GetBuffer()->Reset()
55
56 #define END() \
57 __ Hlt(0); \
58 __ FinalizeCode();
59
60 // TODO: Run the tests in the simulator.
61 #define RUN()
62
63 #else // ifdef VIXL_INCLUDE_SIMULATOR_AARCH32.
64
65 #define SETUP() \
66 MacroAssembler masm(BUF_SIZE); \
67 UseScratchRegisterScope harness_scratch;
68
69 #define START() \
70 harness_scratch.Open(&masm); \
71 harness_scratch.ExcludeAll(); \
72 masm.GetBuffer()->Reset(); \
73 __ Push(r4); \
74 __ Push(r5); \
75 __ Push(r6); \
76 __ Push(r7); \
77 __ Push(r8); \
78 __ Push(r9); \
79 __ Push(r10); \
80 __ Push(r11); \
81 __ Push(lr); \
82 harness_scratch.Include(ip);
83
84 #define END() \
85 harness_scratch.Exclude(ip); \
86 __ Pop(lr); \
87 __ Pop(r11); \
88 __ Pop(r10); \
89 __ Pop(r9); \
90 __ Pop(r8); \
91 __ Pop(r7); \
92 __ Pop(r6); \
93 __ Pop(r5); \
94 __ Pop(r4); \
95 __ Bx(lr); \
96 __ FinalizeCode(); \
97 harness_scratch.Close();
98
99 #define RUN() \
100 { \
101 int pcs_offset = masm.IsUsingT32() ? 1 : 0; \
102 masm.GetBuffer()->SetExecutable(); \
103 ExecuteMemory(masm.GetBuffer()->GetStartAddress<byte*>(), \
104 masm.GetSizeOfCodeGenerated(), \
105 pcs_offset); \
106 masm.GetBuffer()->SetWritable(); \
107 }
108
109 #endif // ifdef VIXL_INCLUDE_SIMULATOR_AARCH32
110
111 namespace vixl {
112 namespace aarch32 {
113
114 // List of instruction encodings:
115 #define FOREACH_INSTRUCTION(M) \
116 M(Adc) \
117 M(Adcs) \
118 M(Add) \
119 M(Adds) \
120 M(And) \
121 M(Ands) \
122 M(Bic) \
123 M(Bics) \
124 M(Eor) \
125 M(Eors) \
126 M(Orn) \
127 M(Orns) \
128 M(Orr) \
129 M(Orrs) \
130 M(Rsb) \
131 M(Rsbs) \
132 M(Sbc) \
133 M(Sbcs) \
134 M(Sub) \
135 M(Subs) \
136 M(Sxtab) \
137 M(Sxtab16) \
138 M(Sxtah) \
139 M(Uxtab) \
140 M(Uxtab16) \
141 M(Uxtah) \
142 M(Asr) \
143 M(Asrs) \
144 M(Lsl) \
145 M(Lsls) \
146 M(Lsr) \
147 M(Lsrs) \
148 M(Ror) \
149 M(Rors)
150
151
152 // The following definitions are defined again in each generated test, therefore
153 // we need to place them in an anomymous namespace. It expresses that they are
154 // local to this file only, and the compiler is not allowed to share these types
155 // across test files during template instantiation. Specifically, `Operands` and
156 // `Inputs` have various layouts across generated tests so they absolutely
157 // cannot be shared.
158
159 #ifdef VIXL_INCLUDE_TARGET_T32
160 namespace {
161
162 // Values to be passed to the assembler to produce the instruction under test.
163 struct Operands {
164 Condition cond;
165 Register rd;
166 Register rn;
167 Register rm;
168 };
169
170 // Input data to feed to the instruction.
171 struct Inputs {
172 uint32_t apsr;
173 uint32_t rd;
174 uint32_t rn;
175 uint32_t rm;
176 };
177
178 // This structure contains all input data needed to test one specific encoding.
179 // It used to generate a loop over an instruction.
180 struct TestLoopData {
181 // The `operands` fields represents the values to pass to the assembler to
182 // produce the instruction.
183 Operands operands;
184 // Description of the operands, used for error reporting.
185 const char* operands_description;
186 // Unique identifier, used for generating traces.
187 const char* identifier;
188 // Array of values to be fed to the instruction.
189 size_t input_size;
190 const Inputs* inputs;
191 };
192
193 static const Inputs kCondition[] =
194 {{NFlag, 0xabababab, 0xabababab, 0xabababab},
195 {ZFlag, 0xabababab, 0xabababab, 0xabababab},
196 {CFlag, 0xabababab, 0xabababab, 0xabababab},
197 {VFlag, 0xabababab, 0xabababab, 0xabababab},
198 {NZFlag, 0xabababab, 0xabababab, 0xabababab},
199 {NCFlag, 0xabababab, 0xabababab, 0xabababab},
200 {NVFlag, 0xabababab, 0xabababab, 0xabababab},
201 {ZCFlag, 0xabababab, 0xabababab, 0xabababab},
202 {ZVFlag, 0xabababab, 0xabababab, 0xabababab},
203 {CVFlag, 0xabababab, 0xabababab, 0xabababab},
204 {NZCFlag, 0xabababab, 0xabababab, 0xabababab},
205 {NZVFlag, 0xabababab, 0xabababab, 0xabababab},
206 {NCVFlag, 0xabababab, 0xabababab, 0xabababab},
207 {ZCVFlag, 0xabababab, 0xabababab, 0xabababab},
208 {NZCVFlag, 0xabababab, 0xabababab, 0xabababab}};
209
210 static const Inputs kRdIsRn[] = {{ZCFlag, 0x00000000, 0x00000000, 0xffffff80},
211 {NZCFlag, 0x00007ffe, 0x00007ffe, 0x7ffffffe},
212 {NVFlag, 0x00000001, 0x00000001, 0x0000007d},
213 {NZFlag, 0xffffff80, 0xffffff80, 0xaaaaaaaa},
214 {NZFlag, 0x55555555, 0x55555555, 0x00000020},
215 {NCVFlag, 0x00000001, 0x00000001, 0x00000002},
216 {NCVFlag, 0xffffffff, 0xffffffff, 0x55555555},
217 {NVFlag, 0x80000001, 0x80000001, 0x00007ffd},
218 {NZCFlag, 0x00007fff, 0x00007fff, 0x80000000},
219 {ZFlag, 0x00000001, 0x00000001, 0x00000001},
220 {CVFlag, 0xffff8001, 0xffff8001, 0x00000002},
221 {NCVFlag, 0xffffffff, 0xffffffff, 0xffffff82},
222 {ZCFlag, 0x00000001, 0x00000001, 0x00000001},
223 {ZCFlag, 0xffffff81, 0xffffff81, 0x80000000},
224 {NZCVFlag, 0x00007ffe, 0x00007ffe, 0xfffffffe},
225 {NZFlag, 0x00000002, 0x00000002, 0x00007fff},
226 {VFlag, 0x00007fff, 0x00007fff, 0x7ffffffe},
227 {NZCVFlag, 0x00000002, 0x00000002, 0xfffffffd},
228 {CFlag, 0xffffff80, 0xffffff80, 0xffff8003},
229 {NZCVFlag, 0xfffffffd, 0xfffffffd, 0x00007ffe},
230 {NCVFlag, 0xffffff83, 0xffffff83, 0xffffffff},
231 {NFlag, 0x0000007f, 0x0000007f, 0x00000002},
232 {NZFlag, 0xffff8002, 0xffff8002, 0x00000001},
233 {NZCVFlag, 0x00007fff, 0x00007fff, 0x00007ffd},
234 {NZCVFlag, 0x55555555, 0x55555555, 0xffffff82},
235 {NCFlag, 0xffff8003, 0xffff8003, 0x7ffffffe},
236 {NCFlag, 0xffffff80, 0xffffff80, 0x7fffffff},
237 {ZVFlag, 0xfffffffd, 0xfffffffd, 0xffffffe0},
238 {NVFlag, 0x55555555, 0x55555555, 0x80000001},
239 {CVFlag, 0xffffff82, 0xffffff82, 0x00007ffe},
240 {NVFlag, 0xffffffff, 0xffffffff, 0x0000007f},
241 {ZFlag, 0x00007fff, 0x00007fff, 0x55555555},
242 {VFlag, 0x00000001, 0x00000001, 0x7ffffffe},
243 {NFlag, 0xffff8000, 0xffff8000, 0xffff8003},
244 {ZVFlag, 0x00007ffd, 0x00007ffd, 0xffffff80},
245 {NZFlag, 0xffffff83, 0xffffff83, 0xfffffffe},
246 {NCVFlag, 0xffffffe0, 0xffffffe0, 0x00000000},
247 {ZCFlag, 0x0000007d, 0x0000007d, 0x00000000},
248 {ZFlag, 0x00000020, 0x00000020, 0xffff8002},
249 {ZFlag, 0xfffffffe, 0xfffffffe, 0x00000001},
250 {CFlag, 0xffffffff, 0xffffffff, 0x0000007f},
251 {NZFlag, 0xcccccccc, 0xcccccccc, 0x00000001},
252 {ZFlag, 0x00000001, 0x00000001, 0x7ffffffe},
253 {NFlag, 0xffffffe0, 0xffffffe0, 0xffffffff},
254 {NCFlag, 0xffffffff, 0xffffffff, 0x00000002},
255 {NVFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0xffff8000},
256 {NZFlag, 0xffffffe0, 0xffffffe0, 0xffffffe0},
257 {NZFlag, 0x00000000, 0x00000000, 0x00007fff},
258 {ZFlag, 0x33333333, 0x33333333, 0xffff8000},
259 {VFlag, 0x55555555, 0x55555555, 0x00000001},
260 {NCVFlag, 0x00000001, 0x00000001, 0x00000020},
261 {NZCFlag, 0xfffffffd, 0xfffffffd, 0x00000001},
262 {NFlag, 0xffff8002, 0xffff8002, 0x00000001},
263 {NZCFlag, 0x0000007d, 0x0000007d, 0xffffff81},
264 {NZFlag, 0x55555555, 0x55555555, 0x00000000},
265 {NZVFlag, 0xffffffff, 0xffffffff, 0xfffffffe},
266 {NZFlag, 0x00000000, 0x00000000, 0xfffffffd},
267 {NCVFlag, 0x00007ffd, 0x00007ffd, 0xffff8001},
268 {NCFlag, 0x0000007d, 0x0000007d, 0x00007ffe},
269 {NFlag, 0xffff8003, 0xffff8003, 0x00000020},
270 {NZCVFlag, 0x0000007e, 0x0000007e, 0x33333333},
271 {ZCFlag, 0x00000000, 0x00000000, 0x80000000},
272 {VFlag, 0x80000001, 0x80000001, 0x80000000},
273 {NZVFlag, 0x00000002, 0x00000002, 0x80000001},
274 {NZFlag, 0x0000007f, 0x0000007f, 0xffffff80},
275 {NCFlag, 0xcccccccc, 0xcccccccc, 0x00007ffe},
276 {NZVFlag, 0x7ffffffd, 0x7ffffffd, 0xffffff80},
277 {CVFlag, 0x0000007d, 0x0000007d, 0xffff8003},
278 {ZFlag, 0x7ffffffd, 0x7ffffffd, 0x80000001},
279 {NZCFlag, 0xffff8003, 0xffff8003, 0xffffff81},
280 {CFlag, 0x00000000, 0x00000000, 0x80000001},
281 {VFlag, 0x80000001, 0x80000001, 0x00000000},
282 {NZVFlag, 0xffffff82, 0xffffff82, 0x00007ffd},
283 {NZCFlag, 0xffffff80, 0xffffff80, 0xfffffffd},
284 {ZVFlag, 0x7ffffffe, 0x7ffffffe, 0xfffffffd},
285 {NCFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0xffff8003},
286 {CFlag, 0xffffff81, 0xffffff81, 0x00007ffd},
287 {NZVFlag, 0xffff8002, 0xffff8002, 0x80000000},
288 {NZCVFlag, 0x7ffffffd, 0x7ffffffd, 0x0000007e},
289 {CVFlag, 0xffffffff, 0xffffffff, 0x7ffffffd},
290 {NCFlag, 0x00000001, 0x00000001, 0x00007fff},
291 {NZVFlag, 0xffffff83, 0xffffff83, 0x00000020},
292 {NZFlag, 0x00000001, 0x00000001, 0x00007ffd},
293 {NZVFlag, 0xcccccccc, 0xcccccccc, 0x00000020},
294 {NCFlag, 0xffffff80, 0xffffff80, 0xaaaaaaaa},
295 {VFlag, 0x7ffffffe, 0x7ffffffe, 0x80000001},
296 {NZCVFlag, 0x00000002, 0x00000002, 0x33333333},
297 {NCFlag, 0xffffff81, 0xffffff81, 0xffff8000},
298 {ZVFlag, 0xffffffe0, 0xffffffe0, 0x55555555},
299 {NCVFlag, 0xfffffffd, 0xfffffffd, 0x7ffffffe},
300 {NVFlag, 0xffffff83, 0xffffff83, 0x0000007f},
301 {ZVFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0xfffffffd},
302 {NFlag, 0xffff8001, 0xffff8001, 0x00000000},
303 {NCFlag, 0x0000007d, 0x0000007d, 0x00007fff},
304 {NVFlag, 0x0000007f, 0x0000007f, 0x80000000},
305 {ZCFlag, 0xffffff80, 0xffffff80, 0x7ffffffe},
306 {ZFlag, 0xffff8002, 0xffff8002, 0xffffff80},
307 {NVFlag, 0xffff8001, 0xffff8001, 0x33333333},
308 {NCVFlag, 0xffff8002, 0xffff8002, 0x00007ffd},
309 {NCFlag, 0x00000020, 0x00000020, 0xffff8002},
310 {NCVFlag, 0x33333333, 0x33333333, 0x0000007d},
311 {VFlag, 0x55555555, 0x55555555, 0x00007ffd},
312 {NZFlag, 0xffff8000, 0xffff8000, 0x33333333},
313 {NFlag, 0xffffffff, 0xffffffff, 0x80000001},
314 {ZFlag, 0x7ffffffe, 0x7ffffffe, 0x00000020},
315 {ZVFlag, 0x0000007e, 0x0000007e, 0x0000007f},
316 {ZCFlag, 0xffffff80, 0xffffff80, 0xffffffff},
317 {ZCVFlag, 0x00000020, 0x00000020, 0xaaaaaaaa},
318 {NZCVFlag, 0x00007ffd, 0x00007ffd, 0x00000000},
319 {NZVFlag, 0xffff8002, 0xffff8002, 0x0000007f},
320 {NZFlag, 0x7ffffffd, 0x7ffffffd, 0xffffffe0},
321 {NZCVFlag, 0x00000002, 0x00000002, 0xffff8001},
322 {ZCFlag, 0xffffff81, 0xffffff81, 0x33333333},
323 {ZCVFlag, 0x00000001, 0x00000001, 0x7ffffffd},
324 {ZCVFlag, 0x0000007d, 0x0000007d, 0xaaaaaaaa},
325 {NFlag, 0xffffff83, 0xffffff83, 0x33333333},
326 {ZFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x00000000},
327 {ZVFlag, 0xffff8001, 0xffff8001, 0x00007ffe},
328 {NZFlag, 0x55555555, 0x55555555, 0x7fffffff},
329 {ZCVFlag, 0x00007ffd, 0x00007ffd, 0xffffffff},
330 {VFlag, 0x00007ffe, 0x00007ffe, 0xffff8002},
331 {CVFlag, 0x0000007e, 0x0000007e, 0xffff8002},
332 {CFlag, 0xffffff82, 0xffffff82, 0xffff8002},
333 {NCFlag, 0x00007ffd, 0x00007ffd, 0x00000000},
334 {NCFlag, 0x00007ffe, 0x00007ffe, 0x7fffffff},
335 {ZCFlag, 0xfffffffd, 0xfffffffd, 0x0000007d},
336 {NZVFlag, 0x0000007e, 0x0000007e, 0x33333333},
337 {NZVFlag, 0x55555555, 0x55555555, 0x00007fff},
338 {ZVFlag, 0xffff8002, 0xffff8002, 0xaaaaaaaa},
339 {NZFlag, 0xfffffffe, 0xfffffffe, 0x7fffffff},
340 {ZCFlag, 0x80000001, 0x80000001, 0x80000001},
341 {ZCFlag, 0x7fffffff, 0x7fffffff, 0x80000001},
342 {NZCVFlag, 0xffff8002, 0xffff8002, 0xffffff83},
343 {NZCVFlag, 0x00000000, 0x00000000, 0x80000000},
344 {ZCVFlag, 0x55555555, 0x55555555, 0xfffffffe},
345 {NZVFlag, 0x00007ffe, 0x00007ffe, 0x00007fff},
346 {ZCFlag, 0x7ffffffe, 0x7ffffffe, 0xffffff81},
347 {ZFlag, 0x00000020, 0x00000020, 0xfffffffd},
348 {NZCFlag, 0x00007fff, 0x00007fff, 0x7fffffff},
349 {NZCVFlag, 0x7ffffffd, 0x7ffffffd, 0xaaaaaaaa},
350 {NCFlag, 0xffffff82, 0xffffff82, 0x00000001},
351 {CFlag, 0xffffff81, 0xffffff81, 0xfffffffd},
352 {NCVFlag, 0xffffff82, 0xffffff82, 0xffff8001},
353 {NZCFlag, 0xcccccccc, 0xcccccccc, 0xffffff82},
354 {NCFlag, 0x55555555, 0x55555555, 0xffffffff},
355 {CFlag, 0x7ffffffe, 0x7ffffffe, 0x00000001},
356 {ZFlag, 0x00007fff, 0x00007fff, 0x0000007e},
357 {NVFlag, 0xfffffffe, 0xfffffffe, 0xffff8002},
358 {NVFlag, 0x0000007d, 0x0000007d, 0xfffffffd},
359 {CFlag, 0x55555555, 0x55555555, 0xffffffe0},
360 {ZCFlag, 0xcccccccc, 0xcccccccc, 0x0000007d},
361 {NCVFlag, 0xffff8001, 0xffff8001, 0x0000007f},
362 {NFlag, 0xffff8001, 0xffff8001, 0x0000007f},
363 {CFlag, 0x80000001, 0x80000001, 0xffff8003},
364 {NCVFlag, 0x00000000, 0x00000000, 0x0000007f},
365 {NZCVFlag, 0xffff8000, 0xffff8000, 0xfffffffd},
366 {NCFlag, 0x0000007d, 0x0000007d, 0x55555555},
367 {NZFlag, 0xffffff80, 0xffffff80, 0xffffff83},
368 {NCFlag, 0x7ffffffe, 0x7ffffffe, 0xffffff80},
369 {NVFlag, 0xffff8002, 0xffff8002, 0xcccccccc},
370 {NZFlag, 0xfffffffd, 0xfffffffd, 0x00007fff},
371 {NZCVFlag, 0x0000007f, 0x0000007f, 0xffffffff},
372 {NZCFlag, 0x00000020, 0x00000020, 0x55555555},
373 {NVFlag, 0x7ffffffe, 0x7ffffffe, 0x00007ffe},
374 {NZCFlag, 0x00007ffd, 0x00007ffd, 0xcccccccc},
375 {CVFlag, 0x00000001, 0x00000001, 0xffff8003},
376 {NCFlag, 0x55555555, 0x55555555, 0xffffff80},
377 {NCVFlag, 0x00007ffe, 0x00007ffe, 0xffffff83},
378 {ZCFlag, 0xffffffff, 0xffffffff, 0x00000002},
379 {NZFlag, 0xffffff81, 0xffffff81, 0xffffff83},
380 {CVFlag, 0x00007fff, 0x00007fff, 0xffffffe0},
381 {NZFlag, 0xfffffffd, 0xfffffffd, 0x00000002},
382 {NCFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x80000000},
383 {NZCVFlag, 0x00007fff, 0x00007fff, 0xffffff82},
384 {NFlag, 0xffffffff, 0xffffffff, 0x00007ffe},
385 {CVFlag, 0x00007ffd, 0x00007ffd, 0x00000001},
386 {NZCFlag, 0xffff8003, 0xffff8003, 0xffffff82},
387 {CVFlag, 0x00000020, 0x00000020, 0x00007ffd},
388 {VFlag, 0x00000000, 0x00000000, 0x00007ffd},
389 {CVFlag, 0x80000000, 0x80000000, 0xffffff82},
390 {ZCVFlag, 0xffffffe0, 0xffffffe0, 0x00000001},
391 {NZFlag, 0x7ffffffe, 0x7ffffffe, 0x55555555},
392 {ZCVFlag, 0x7fffffff, 0x7fffffff, 0x55555555},
393 {CVFlag, 0x00000001, 0x00000001, 0x80000001},
394 {NZFlag, 0xffff8000, 0xffff8000, 0xffff8001},
395 {NZFlag, 0x7ffffffd, 0x7ffffffd, 0x00007ffe},
396 {ZCVFlag, 0xffffff82, 0xffffff82, 0x7ffffffd},
397 {CFlag, 0xffffff82, 0xffffff82, 0x00007fff},
398 {NCVFlag, 0xcccccccc, 0xcccccccc, 0x80000000},
399 {NCVFlag, 0x80000000, 0x80000000, 0xaaaaaaaa},
400 {NZFlag, 0xffff8002, 0xffff8002, 0xffffff80},
401 {NCFlag, 0x7fffffff, 0x7fffffff, 0x00000001},
402 {ZVFlag, 0xfffffffd, 0xfffffffd, 0xffffff83},
403 {NZCFlag, 0x00007ffe, 0x00007ffe, 0xaaaaaaaa},
404 {NFlag, 0xffffff83, 0xffffff83, 0xffffff81},
405 {NCFlag, 0xffffff83, 0xffffff83, 0x0000007f},
406 {ZFlag, 0xffffffe0, 0xffffffe0, 0x0000007f},
407 {ZCFlag, 0x33333333, 0x33333333, 0x00007ffe},
408 {ZCFlag, 0x7ffffffe, 0x7ffffffe, 0xffff8002},
409 {NCFlag, 0x0000007d, 0x0000007d, 0x00007ffd}};
410
411 static const Inputs kRdIsRm[] = {{NZVFlag, 0xffff8002, 0x00000020, 0xffff8002},
412 {NVFlag, 0x00000002, 0xfffffffd, 0x00000002},
413 {ZCVFlag, 0x00000000, 0x00007ffd, 0x00000000},
414 {NCVFlag, 0x0000007f, 0xffff8000, 0x0000007f},
415 {NFlag, 0x00007fff, 0xffffff83, 0x00007fff},
416 {CVFlag, 0xffffff80, 0x7ffffffd, 0xffffff80},
417 {ZVFlag, 0xffffff82, 0x0000007d, 0xffffff82},
418 {ZFlag, 0xfffffffd, 0x80000001, 0xfffffffd},
419 {ZVFlag, 0xffffff82, 0x7fffffff, 0xffffff82},
420 {CFlag, 0xffff8000, 0x00007ffe, 0xffff8000},
421 {NZFlag, 0x0000007e, 0xffffff80, 0x0000007e},
422 {NVFlag, 0xffffff83, 0xffff8000, 0xffffff83},
423 {NVFlag, 0xcccccccc, 0x80000001, 0xcccccccc},
424 {CFlag, 0xffffff81, 0xffff8003, 0xffffff81},
425 {NZCVFlag, 0x0000007e, 0xfffffffe, 0x0000007e},
426 {VFlag, 0x0000007f, 0xfffffffd, 0x0000007f},
427 {NVFlag, 0xcccccccc, 0xffff8001, 0xcccccccc},
428 {CFlag, 0x80000000, 0x00000000, 0x80000000},
429 {NVFlag, 0x80000000, 0xffff8002, 0x80000000},
430 {ZVFlag, 0x00000001, 0x7ffffffd, 0x00000001},
431 {ZVFlag, 0xffff8001, 0x00000020, 0xffff8001},
432 {CFlag, 0xffffff81, 0x0000007e, 0xffffff81},
433 {NVFlag, 0xffff8000, 0x00000002, 0xffff8000},
434 {NCVFlag, 0xffff8000, 0xffff8002, 0xffff8000},
435 {NZVFlag, 0xcccccccc, 0x00000020, 0xcccccccc},
436 {ZFlag, 0x7ffffffd, 0xffff8002, 0x7ffffffd},
437 {NFlag, 0xffffff81, 0x00000020, 0xffffff81},
438 {NFlag, 0x80000000, 0xfffffffe, 0x80000000},
439 {NZVFlag, 0xaaaaaaaa, 0xffffff82, 0xaaaaaaaa},
440 {NZVFlag, 0x0000007f, 0x00007ffe, 0x0000007f},
441 {NVFlag, 0x80000001, 0x00007ffe, 0x80000001},
442 {NZVFlag, 0xffff8003, 0x00000020, 0xffff8003},
443 {NZVFlag, 0xffffff81, 0xfffffffe, 0xffffff81},
444 {ZVFlag, 0x00000001, 0xffffff83, 0x00000001},
445 {ZCVFlag, 0x0000007d, 0x7fffffff, 0x0000007d},
446 {ZFlag, 0x80000001, 0x33333333, 0x80000001},
447 {NCFlag, 0x7ffffffd, 0xffff8003, 0x7ffffffd},
448 {NZCFlag, 0xcccccccc, 0xaaaaaaaa, 0xcccccccc},
449 {NVFlag, 0x7ffffffe, 0xffffffe0, 0x7ffffffe},
450 {NCFlag, 0xffffff82, 0x7ffffffe, 0xffffff82},
451 {NZFlag, 0x7fffffff, 0xffffff81, 0x7fffffff},
452 {CFlag, 0xffffff81, 0xfffffffd, 0xffffff81},
453 {NZCVFlag, 0x00000020, 0xaaaaaaaa, 0x00000020},
454 {ZCFlag, 0x80000000, 0xffff8001, 0x80000000},
455 {NZCVFlag, 0x00000000, 0xffff8000, 0x00000000},
456 {ZVFlag, 0x00000002, 0x0000007d, 0x00000002},
457 {ZCVFlag, 0x7fffffff, 0xffff8003, 0x7fffffff},
458 {NZFlag, 0x80000000, 0xffffffe0, 0x80000000},
459 {CVFlag, 0xffffff81, 0x33333333, 0xffffff81},
460 {ZVFlag, 0x55555555, 0x0000007f, 0x55555555},
461 {NVFlag, 0xffff8000, 0x33333333, 0xffff8000},
462 {VFlag, 0x00007ffd, 0xffffffff, 0x00007ffd},
463 {NCVFlag, 0x7ffffffe, 0xffffffff, 0x7ffffffe},
464 {ZCFlag, 0xffff8000, 0x7ffffffd, 0xffff8000},
465 {NZCVFlag, 0xfffffffd, 0x33333333, 0xfffffffd},
466 {NCFlag, 0xffffff81, 0x00007ffe, 0xffffff81},
467 {CFlag, 0xffff8003, 0x00000020, 0xffff8003},
468 {NCVFlag, 0xaaaaaaaa, 0x80000001, 0xaaaaaaaa},
469 {NCFlag, 0xffffff82, 0x7fffffff, 0xffffff82},
470 {NZVFlag, 0x7ffffffe, 0xffff8001, 0x7ffffffe},
471 {NZVFlag, 0x00000001, 0x00000000, 0x00000001},
472 {NZVFlag, 0x00000020, 0x33333333, 0x00000020},
473 {NCVFlag, 0x00000002, 0x00000002, 0x00000002},
474 {CFlag, 0x55555555, 0x0000007e, 0x55555555},
475 {ZFlag, 0x00000000, 0x80000001, 0x00000000},
476 {NZFlag, 0x33333333, 0xffffff81, 0x33333333},
477 {CFlag, 0x0000007e, 0x0000007f, 0x0000007e},
478 {NCFlag, 0xffffff82, 0x0000007f, 0xffffff82},
479 {CFlag, 0x00007ffe, 0x00007ffe, 0x00007ffe},
480 {ZFlag, 0x7ffffffe, 0x0000007d, 0x7ffffffe},
481 {ZCVFlag, 0xaaaaaaaa, 0xffffff82, 0xaaaaaaaa},
482 {NCVFlag, 0xfffffffd, 0x0000007e, 0xfffffffd},
483 {NVFlag, 0xcccccccc, 0x7ffffffe, 0xcccccccc},
484 {NCFlag, 0xffff8001, 0x7ffffffe, 0xffff8001},
485 {NCFlag, 0x7ffffffe, 0x0000007e, 0x7ffffffe},
486 {CVFlag, 0x0000007f, 0x0000007f, 0x0000007f},
487 {NZVFlag, 0x00000020, 0x0000007f, 0x00000020},
488 {ZCFlag, 0xffffff80, 0x00000001, 0xffffff80},
489 {ZCVFlag, 0x00000020, 0xffffffff, 0x00000020},
490 {NFlag, 0xffffffe0, 0x7fffffff, 0xffffffe0},
491 {NZCFlag, 0x00007fff, 0xffffffff, 0x00007fff},
492 {CVFlag, 0xffff8003, 0x7ffffffe, 0xffff8003},
493 {CVFlag, 0x00000020, 0x7fffffff, 0x00000020},
494 {NFlag, 0xffffff82, 0x80000001, 0xffffff82},
495 {NFlag, 0xffffff83, 0xffffff81, 0xffffff83},
496 {NZCVFlag, 0xffffffe0, 0xffffff80, 0xffffffe0},
497 {ZCVFlag, 0x7fffffff, 0x00007ffe, 0x7fffffff},
498 {ZCVFlag, 0x0000007d, 0x00000002, 0x0000007d},
499 {NVFlag, 0xffffff80, 0xcccccccc, 0xffffff80},
500 {ZCFlag, 0xffffff83, 0xfffffffe, 0xffffff83},
501 {ZVFlag, 0x7ffffffd, 0x7ffffffe, 0x7ffffffd},
502 {NZVFlag, 0x00007ffd, 0xffff8001, 0x00007ffd},
503 {NCVFlag, 0x0000007e, 0x80000000, 0x0000007e},
504 {NZVFlag, 0x7fffffff, 0xcccccccc, 0x7fffffff},
505 {VFlag, 0x00007ffd, 0xfffffffe, 0x00007ffd},
506 {ZFlag, 0xaaaaaaaa, 0xffffff81, 0xaaaaaaaa},
507 {ZCVFlag, 0x80000001, 0x00000000, 0x80000001},
508 {VFlag, 0xffffffe0, 0x00000000, 0xffffffe0},
509 {NZVFlag, 0x0000007f, 0x80000000, 0x0000007f},
510 {ZFlag, 0x80000001, 0x00007fff, 0x80000001},
511 {ZCFlag, 0x00007ffd, 0x0000007e, 0x00007ffd},
512 {NCVFlag, 0x0000007f, 0xffff8003, 0x0000007f},
513 {NFlag, 0xfffffffd, 0xffff8000, 0xfffffffd},
514 {NZVFlag, 0xffffff80, 0x80000000, 0xffffff80},
515 {NFlag, 0x33333333, 0xffffff80, 0x33333333},
516 {NZFlag, 0x0000007f, 0x7ffffffe, 0x0000007f},
517 {ZVFlag, 0x00007ffd, 0x00000002, 0x00007ffd},
518 {ZCFlag, 0x00000020, 0xffff8003, 0x00000020},
519 {NZFlag, 0x0000007e, 0x00000002, 0x0000007e},
520 {NCVFlag, 0x00000000, 0xffffff80, 0x00000000},
521 {NCVFlag, 0xffff8002, 0x00007ffe, 0xffff8002},
522 {NZCVFlag, 0xffffff80, 0xffff8003, 0xffffff80},
523 {NZFlag, 0xffff8003, 0x00007ffe, 0xffff8003},
524 {NFlag, 0x00000000, 0xffff8003, 0x00000000},
525 {NCFlag, 0x00000020, 0xaaaaaaaa, 0x00000020},
526 {NFlag, 0xffffff83, 0x80000000, 0xffffff83},
527 {ZFlag, 0xcccccccc, 0x0000007f, 0xcccccccc},
528 {NZVFlag, 0xffffffe0, 0x00000002, 0xffffffe0},
529 {NZVFlag, 0x33333333, 0xffffff81, 0x33333333},
530 {NZFlag, 0x7ffffffe, 0x00007ffd, 0x7ffffffe},
531 {VFlag, 0x0000007f, 0x80000001, 0x0000007f},
532 {NVFlag, 0xffff8001, 0x00000000, 0xffff8001},
533 {NFlag, 0x0000007d, 0xcccccccc, 0x0000007d},
534 {ZVFlag, 0xffffff82, 0x55555555, 0xffffff82},
535 {NZVFlag, 0x00007ffe, 0x0000007d, 0x00007ffe},
536 {NCFlag, 0xaaaaaaaa, 0x80000001, 0xaaaaaaaa},
537 {ZVFlag, 0x33333333, 0x00000020, 0x33333333},
538 {NZCFlag, 0x0000007f, 0xffffffe0, 0x0000007f},
539 {NCVFlag, 0x80000001, 0xffffff83, 0x80000001},
540 {ZVFlag, 0x00000001, 0xffffffe0, 0x00000001},
541 {NZFlag, 0xffffff82, 0xffffff80, 0xffffff82},
542 {NCVFlag, 0xffffff80, 0x00007ffd, 0xffffff80},
543 {VFlag, 0x0000007e, 0x0000007e, 0x0000007e},
544 {CVFlag, 0x7fffffff, 0x7fffffff, 0x7fffffff},
545 {CVFlag, 0x00007ffd, 0xffffff83, 0x00007ffd},
546 {VFlag, 0xffff8000, 0x80000001, 0xffff8000},
547 {ZFlag, 0x0000007f, 0x00000020, 0x0000007f},
548 {NZFlag, 0xffff8003, 0x33333333, 0xffff8003},
549 {ZFlag, 0x00000020, 0xfffffffd, 0x00000020},
550 {ZCVFlag, 0xffffff81, 0xffff8000, 0xffffff81},
551 {NFlag, 0xffffffe0, 0xffffff83, 0xffffffe0},
552 {ZCVFlag, 0x80000001, 0x55555555, 0x80000001},
553 {ZCVFlag, 0x7fffffff, 0x00000020, 0x7fffffff},
554 {NCFlag, 0x80000001, 0xcccccccc, 0x80000001},
555 {ZVFlag, 0x55555555, 0x7ffffffd, 0x55555555},
556 {CVFlag, 0xffffffff, 0xffff8001, 0xffffffff},
557 {CFlag, 0xfffffffe, 0xffff8000, 0xfffffffe},
558 {NZFlag, 0xcccccccc, 0xffffff82, 0xcccccccc},
559 {NZVFlag, 0x55555555, 0xffffff81, 0x55555555},
560 {NFlag, 0xfffffffd, 0xffffffe0, 0xfffffffd},
561 {NCVFlag, 0xfffffffd, 0xffff8003, 0xfffffffd},
562 {NFlag, 0xfffffffe, 0xffffff80, 0xfffffffe},
563 {ZFlag, 0xffff8002, 0x00007ffd, 0xffff8002},
564 {CFlag, 0xffffff81, 0xffff8002, 0xffffff81},
565 {ZVFlag, 0xffffff81, 0x0000007f, 0xffffff81},
566 {NFlag, 0x00000020, 0xffffff83, 0x00000020},
567 {NZFlag, 0xfffffffd, 0x0000007e, 0xfffffffd},
568 {NZVFlag, 0xfffffffd, 0x0000007e, 0xfffffffd},
569 {NCVFlag, 0xffffffe0, 0x80000000, 0xffffffe0},
570 {NFlag, 0xffffff80, 0x55555555, 0xffffff80},
571 {ZFlag, 0xffffff80, 0x00007ffd, 0xffffff80},
572 {ZCVFlag, 0x00007ffe, 0xffff8003, 0x00007ffe},
573 {VFlag, 0x7fffffff, 0x80000000, 0x7fffffff},
574 {NVFlag, 0xcccccccc, 0xffffff80, 0xcccccccc},
575 {NZCVFlag, 0xcccccccc, 0x7ffffffd, 0xcccccccc},
576 {NZCFlag, 0x33333333, 0xffff8001, 0x33333333},
577 {ZFlag, 0xffffff81, 0xffff8000, 0xffffff81},
578 {NZCVFlag, 0x0000007f, 0xffff8003, 0x0000007f},
579 {NFlag, 0x0000007d, 0x00007ffd, 0x0000007d},
580 {ZFlag, 0x00007ffd, 0x00000020, 0x00007ffd},
581 {NFlag, 0xffffff81, 0xfffffffd, 0xffffff81},
582 {NZFlag, 0xffffff83, 0xffffff80, 0xffffff83},
583 {NCFlag, 0x00007ffd, 0x00000001, 0x00007ffd},
584 {NVFlag, 0x7fffffff, 0xffffff82, 0x7fffffff},
585 {NZVFlag, 0xffff8000, 0x7ffffffd, 0xffff8000},
586 {NZCFlag, 0xaaaaaaaa, 0x0000007f, 0xaaaaaaaa},
587 {NZFlag, 0x7ffffffe, 0xffffffff, 0x7ffffffe},
588 {NZFlag, 0x00000000, 0x00007ffd, 0x00000000},
589 {NZFlag, 0x55555555, 0x0000007f, 0x55555555},
590 {CFlag, 0xcccccccc, 0x0000007f, 0xcccccccc},
591 {NZCVFlag, 0x00007fff, 0x33333333, 0x00007fff},
592 {NCFlag, 0xffff8000, 0xffffff81, 0xffff8000},
593 {ZCVFlag, 0xffffff82, 0xffffff83, 0xffffff82},
594 {NVFlag, 0xffffffe0, 0x0000007e, 0xffffffe0},
595 {NCFlag, 0x7ffffffe, 0x00007fff, 0x7ffffffe},
596 {VFlag, 0x7ffffffd, 0x00000020, 0x7ffffffd},
597 {ZCVFlag, 0xffffff81, 0xffffff81, 0xffffff81},
598 {NVFlag, 0xaaaaaaaa, 0x00000000, 0xaaaaaaaa},
599 {CFlag, 0x33333333, 0x00000002, 0x33333333},
600 {CVFlag, 0x55555555, 0xfffffffd, 0x55555555},
601 {ZCFlag, 0x00000000, 0xffffff80, 0x00000000},
602 {NZCFlag, 0x00007fff, 0x80000000, 0x00007fff},
603 {NCVFlag, 0xffffff80, 0xffffffe0, 0xffffff80},
604 {NZCVFlag, 0x00000001, 0x80000001, 0x00000001},
605 {NZCFlag, 0x55555555, 0x0000007d, 0x55555555},
606 {NCFlag, 0x80000001, 0xffff8001, 0x80000001},
607 {NCVFlag, 0x7fffffff, 0xffffff82, 0x7fffffff},
608 {NCFlag, 0x00000000, 0x00007ffd, 0x00000000},
609 {NZFlag, 0x0000007e, 0xffffffff, 0x0000007e},
610 {NVFlag, 0xffffff81, 0x00007ffd, 0xffffff81}};
611
612 static const Inputs kRdIsNotRnIsNotRm[] =
613 {{ZCVFlag, 0x0000007d, 0x7ffffffe, 0x00000000},
614 {NZCVFlag, 0x00007ffe, 0x00007ffe, 0xaaaaaaaa},
615 {CFlag, 0xfffffffd, 0xffff8001, 0x55555555},
616 {NVFlag, 0x7fffffff, 0x00007ffd, 0xffff8002},
617 {NZVFlag, 0x0000007f, 0xffff8003, 0x00007fff},
618 {CFlag, 0x00000000, 0xaaaaaaaa, 0x7ffffffe},
619 {NFlag, 0xffffffe0, 0xcccccccc, 0x80000001},
620 {NFlag, 0x7fffffff, 0xffffff80, 0xcccccccc},
621 {NFlag, 0xffff8001, 0x00000002, 0x00000001},
622 {ZVFlag, 0xcccccccc, 0xaaaaaaaa, 0x00000001},
623 {NCFlag, 0xffff8001, 0xffff8001, 0xffff8003},
624 {VFlag, 0x33333333, 0x7ffffffe, 0xfffffffd},
625 {CFlag, 0x00000002, 0xffffffe0, 0x00007ffd},
626 {CFlag, 0xffffff82, 0x00000002, 0xfffffffd},
627 {ZCVFlag, 0x80000001, 0xffffffe0, 0x00000020},
628 {ZFlag, 0xffff8001, 0x80000000, 0x80000001},
629 {ZVFlag, 0x00000020, 0xcccccccc, 0xffffff80},
630 {VFlag, 0x00007fff, 0x00000002, 0x55555555},
631 {NVFlag, 0x0000007f, 0xffff8000, 0xaaaaaaaa},
632 {NFlag, 0xffffff81, 0x0000007f, 0x00000002},
633 {CVFlag, 0x00000020, 0x0000007f, 0x00000000},
634 {NZCFlag, 0x00007ffd, 0xffff8002, 0xaaaaaaaa},
635 {ZCVFlag, 0x00007ffe, 0xffffffff, 0x80000000},
636 {NZCFlag, 0x00000020, 0xffffff81, 0x0000007d},
637 {NZCVFlag, 0x00000020, 0x0000007d, 0xffff8001},
638 {NZCFlag, 0xffffff80, 0xfffffffe, 0xffffffe0},
639 {ZCVFlag, 0xffff8001, 0xfffffffd, 0x00000002},
640 {NCFlag, 0xffff8001, 0x00007ffe, 0xffffff80},
641 {NZVFlag, 0xfffffffd, 0xcccccccc, 0x7ffffffe},
642 {ZCVFlag, 0x00007ffe, 0xffff8003, 0x00007ffd},
643 {VFlag, 0x00007ffe, 0x0000007d, 0x00007ffd},
644 {NCFlag, 0x00000002, 0xffff8002, 0xfffffffd},
645 {NZFlag, 0x00000002, 0x0000007f, 0x0000007d},
646 {VFlag, 0x80000000, 0xffffff83, 0x00000000},
647 {NZVFlag, 0xfffffffd, 0x0000007e, 0xfffffffd},
648 {NFlag, 0x80000000, 0x00000020, 0x00007ffe},
649 {NVFlag, 0xffffff81, 0x00000002, 0x00000000},
650 {NZCVFlag, 0x33333333, 0x00007ffd, 0xaaaaaaaa},
651 {NVFlag, 0xffff8003, 0xcccccccc, 0x0000007d},
652 {NZVFlag, 0xfffffffd, 0xffffff80, 0xffffffe0},
653 {NCFlag, 0x0000007d, 0xffffffff, 0x0000007d},
654 {ZCFlag, 0x0000007d, 0xffffff83, 0x00000001},
655 {NFlag, 0xffff8000, 0x80000000, 0x00000002},
656 {CFlag, 0x33333333, 0xffff8001, 0x0000007f},
657 {NCFlag, 0xfffffffd, 0x33333333, 0x0000007d},
658 {CVFlag, 0x0000007f, 0x7ffffffd, 0xffff8003},
659 {CVFlag, 0x80000000, 0xffff8000, 0xffffffe0},
660 {ZFlag, 0x00007ffe, 0xcccccccc, 0x33333333},
661 {NZCVFlag, 0xfffffffe, 0x0000007e, 0x0000007d},
662 {CVFlag, 0xffffff82, 0x80000001, 0xffffff80},
663 {CFlag, 0xffff8002, 0x7fffffff, 0xffff8001},
664 {ZVFlag, 0x7fffffff, 0xffffff83, 0x00007fff},
665 {CVFlag, 0xffffffe0, 0x7ffffffe, 0x7fffffff},
666 {ZCVFlag, 0xffffffe0, 0x00007ffd, 0xffffff82},
667 {ZFlag, 0x00000020, 0xffff8001, 0x00000020},
668 {NFlag, 0x00007ffd, 0xfffffffe, 0x00000000},
669 {NFlag, 0xfffffffe, 0x80000001, 0xffffff80},
670 {CVFlag, 0x00000002, 0xcccccccc, 0x00007ffd},
671 {ZCFlag, 0x80000001, 0x00000020, 0xaaaaaaaa},
672 {NZVFlag, 0x00007ffe, 0x00000000, 0x0000007d},
673 {ZFlag, 0x00000000, 0xffff8003, 0xffff8003},
674 {NCVFlag, 0xffffff83, 0xffffff81, 0xffffff83},
675 {NVFlag, 0xffffffff, 0xffffff81, 0x33333333},
676 {CVFlag, 0x00007ffd, 0xcccccccc, 0x55555555},
677 {ZCVFlag, 0xffffffff, 0x80000001, 0x55555555},
678 {NZVFlag, 0x7ffffffd, 0x0000007e, 0xcccccccc},
679 {NZCFlag, 0xfffffffe, 0xfffffffd, 0x7fffffff},
680 {ZCVFlag, 0x0000007f, 0x80000001, 0xffffffff},
681 {NZCVFlag, 0xffffff83, 0x00007ffd, 0x55555555},
682 {NVFlag, 0xffffffff, 0xffffff82, 0x00000002},
683 {NCVFlag, 0x00000001, 0x00000002, 0xffff8002},
684 {NVFlag, 0x0000007d, 0x80000000, 0xffff8000},
685 {ZFlag, 0x00000000, 0x0000007f, 0xffffff81},
686 {CVFlag, 0x00000000, 0x33333333, 0x00000000},
687 {ZFlag, 0x80000001, 0x0000007d, 0xcccccccc},
688 {ZFlag, 0x80000000, 0x0000007f, 0x00000000},
689 {ZFlag, 0x7ffffffe, 0xfffffffe, 0x0000007e},
690 {NZVFlag, 0xcccccccc, 0x80000000, 0xcccccccc},
691 {VFlag, 0x80000001, 0xffff8000, 0x7fffffff},
692 {NFlag, 0x55555555, 0x0000007e, 0x7ffffffd},
693 {NFlag, 0x00007fff, 0x00007ffe, 0xffffff80},
694 {ZFlag, 0x7fffffff, 0xffffff83, 0xffffff80},
695 {VFlag, 0x7fffffff, 0x7fffffff, 0x0000007d},
696 {ZVFlag, 0xfffffffe, 0xffffff80, 0x33333333},
697 {NZFlag, 0x55555555, 0x0000007e, 0x7ffffffd},
698 {VFlag, 0x55555555, 0xcccccccc, 0x0000007e},
699 {NVFlag, 0x00007ffd, 0x7ffffffd, 0xffffff80},
700 {NZCFlag, 0x00007ffe, 0xfffffffd, 0x00000002},
701 {NZCVFlag, 0x7ffffffd, 0x7fffffff, 0xffffff81},
702 {NZCFlag, 0x7ffffffd, 0x80000000, 0x7ffffffe},
703 {CFlag, 0x7ffffffd, 0x00007fff, 0x0000007f},
704 {CVFlag, 0xffff8001, 0xcccccccc, 0xffffffff},
705 {ZFlag, 0x00007fff, 0xffffffff, 0xffffff82},
706 {ZCVFlag, 0x80000000, 0x00000001, 0x80000001},
707 {ZVFlag, 0xffffff82, 0xfffffffe, 0x0000007e},
708 {NZCFlag, 0xffffffe0, 0x55555555, 0x00000000},
709 {NZFlag, 0xffff8001, 0xffff8003, 0xffffff82},
710 {ZFlag, 0x7fffffff, 0x00000002, 0xffffffe0},
711 {ZCFlag, 0x00000001, 0xffffff81, 0xffffff81},
712 {ZFlag, 0x7ffffffe, 0xffffff81, 0xfffffffe},
713 {CFlag, 0x00007ffe, 0x7ffffffd, 0x80000000},
714 {NZVFlag, 0x00000000, 0xaaaaaaaa, 0x0000007d},
715 {NZVFlag, 0x7ffffffd, 0xffff8001, 0x00007fff},
716 {NZCFlag, 0x55555555, 0x7fffffff, 0x80000001},
717 {ZCFlag, 0xfffffffe, 0x0000007e, 0xcccccccc},
718 {NVFlag, 0x80000000, 0xfffffffe, 0x0000007e},
719 {NVFlag, 0xffffff83, 0xffffff82, 0x00000000},
720 {NVFlag, 0xfffffffe, 0x33333333, 0x80000000},
721 {ZVFlag, 0x80000000, 0xffff8002, 0xffffff82},
722 {CFlag, 0xcccccccc, 0x00007fff, 0x00000000},
723 {ZVFlag, 0xfffffffe, 0x7ffffffe, 0x00007ffe},
724 {NZCVFlag, 0x00007fff, 0xffff8002, 0xffff8001},
725 {NZVFlag, 0x00000002, 0xffffff81, 0xfffffffe},
726 {NCVFlag, 0xffffff83, 0xffff8001, 0x00007ffe},
727 {ZFlag, 0x0000007d, 0x00007ffe, 0xffff8000},
728 {NCVFlag, 0x55555555, 0xaaaaaaaa, 0x7fffffff},
729 {ZVFlag, 0x0000007e, 0xfffffffd, 0x7ffffffe},
730 {ZCVFlag, 0xffffff83, 0x33333333, 0xffffff82},
731 {ZFlag, 0xffff8001, 0x00000020, 0xffff8003},
732 {NCFlag, 0xfffffffe, 0xaaaaaaaa, 0x80000001},
733 {NZFlag, 0x80000000, 0xaaaaaaaa, 0xffffffff},
734 {NZCFlag, 0xffffffe0, 0x00007ffe, 0x0000007e},
735 {NFlag, 0x0000007f, 0x80000000, 0x33333333},
736 {NZFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x80000000},
737 {ZVFlag, 0x7ffffffd, 0xffffff83, 0x0000007e},
738 {NZVFlag, 0x0000007d, 0x00000002, 0x80000000},
739 {ZFlag, 0xffffff83, 0xfffffffe, 0xffffffe0},
740 {CVFlag, 0x0000007e, 0x00000020, 0x0000007f},
741 {CFlag, 0xffffffe0, 0x00007ffd, 0x80000000},
742 {NZCVFlag, 0x00007ffd, 0xffff8001, 0xffff8001},
743 {NZFlag, 0x33333333, 0x0000007d, 0xffffffe0},
744 {NCVFlag, 0x55555555, 0x7ffffffe, 0x00000000},
745 {NZFlag, 0x0000007e, 0xffffffff, 0xffffffff},
746 {NZCFlag, 0x00007ffd, 0xfffffffd, 0xffff8002},
747 {NZCVFlag, 0x33333333, 0xffff8003, 0xffff8002},
748 {NCVFlag, 0x0000007f, 0x33333333, 0x0000007d},
749 {NFlag, 0x7ffffffe, 0xffffff81, 0xffffffe0},
750 {ZCFlag, 0xaaaaaaaa, 0xffffff83, 0xffff8002},
751 {NFlag, 0x00000000, 0x00000002, 0x0000007e},
752 {CVFlag, 0x0000007e, 0x0000007f, 0x80000001},
753 {NZCFlag, 0x7ffffffd, 0xffffff81, 0xffff8003},
754 {NCVFlag, 0xffffff83, 0x00000020, 0x00000002},
755 {NCFlag, 0xffffff82, 0x7fffffff, 0xffff8003},
756 {NZVFlag, 0x0000007f, 0xffffffff, 0xffffff82},
757 {ZCFlag, 0xffffff80, 0x00007ffd, 0x33333333},
758 {NZVFlag, 0xfffffffe, 0xcccccccc, 0xffff8002},
759 {ZVFlag, 0x80000001, 0xfffffffe, 0x0000007d},
760 {ZCFlag, 0x0000007f, 0xfffffffd, 0x80000000},
761 {CFlag, 0xfffffffe, 0xffff8001, 0x33333333},
762 {NFlag, 0x80000001, 0x80000001, 0xcccccccc},
763 {NCVFlag, 0xffffff81, 0x80000000, 0x00007ffe},
764 {NCFlag, 0xffffffff, 0xfffffffd, 0xffffff80},
765 {NCFlag, 0x00000020, 0x00000002, 0x80000001},
766 {NZVFlag, 0xcccccccc, 0xffff8000, 0xffff8003},
767 {NZCFlag, 0x80000000, 0xaaaaaaaa, 0xffffff83},
768 {ZCFlag, 0xffff8000, 0x00000002, 0xffff8002},
769 {ZCVFlag, 0x00000001, 0xffff8001, 0x00007ffe},
770 {NVFlag, 0xfffffffd, 0xffff8003, 0xffffff82},
771 {NZCVFlag, 0x80000000, 0x7ffffffd, 0xffffff80},
772 {ZCFlag, 0x33333333, 0x0000007e, 0xfffffffd},
773 {NZCFlag, 0x0000007d, 0xffffffe0, 0x00000001},
774 {NZCVFlag, 0xcccccccc, 0xaaaaaaaa, 0x7fffffff},
775 {ZVFlag, 0x00007ffe, 0x00000000, 0x55555555},
776 {NZFlag, 0x80000001, 0x7ffffffe, 0x7ffffffe},
777 {ZFlag, 0x33333333, 0x0000007e, 0xcccccccc},
778 {NZCFlag, 0x0000007e, 0xffffffe0, 0x33333333},
779 {NCVFlag, 0xffffff83, 0xffff8002, 0x80000001},
780 {CFlag, 0x7fffffff, 0xffffff81, 0x33333333},
781 {NCFlag, 0xcccccccc, 0x33333333, 0xffff8003},
782 {NVFlag, 0x0000007e, 0xffffff80, 0x00007fff},
783 {NCFlag, 0xffff8003, 0x0000007d, 0xffffff82},
784 {ZCVFlag, 0xaaaaaaaa, 0x7fffffff, 0xffff8001},
785 {ZCVFlag, 0x00007ffe, 0x55555555, 0x00000020},
786 {ZVFlag, 0x00000001, 0x80000001, 0x80000001},
787 {CVFlag, 0x00000001, 0xffffff80, 0x0000007f},
788 {NZCVFlag, 0xfffffffd, 0xffffff81, 0x00000020},
789 {NZCVFlag, 0x00000020, 0x80000000, 0xffffff81},
790 {NZCVFlag, 0xffffff81, 0x7fffffff, 0xffff8002},
791 {NZVFlag, 0xfffffffe, 0x00000000, 0xffff8000},
792 {ZCVFlag, 0xffff8000, 0xffffff83, 0xffffff81},
793 {NZCVFlag, 0x00007ffd, 0xaaaaaaaa, 0x00007ffe},
794 {NZCFlag, 0x0000007e, 0xcccccccc, 0x80000000},
795 {ZVFlag, 0xffff8002, 0x7ffffffd, 0xffffffe0},
796 {ZCFlag, 0xaaaaaaaa, 0x7ffffffe, 0x0000007e},
797 {VFlag, 0xffffffff, 0x7fffffff, 0xcccccccc},
798 {NZCFlag, 0xfffffffe, 0xffff8001, 0x80000001},
799 {VFlag, 0xfffffffd, 0xffff8000, 0xffff8003},
800 {CVFlag, 0x80000001, 0x80000001, 0x00007ffd},
801 {NVFlag, 0x55555555, 0x0000007e, 0xffffff82},
802 {NCFlag, 0x0000007f, 0x7ffffffe, 0x00000001},
803 {NVFlag, 0x00000001, 0xffffff83, 0xffffff82},
804 {CFlag, 0xffffff81, 0xffff8002, 0xffff8000},
805 {CFlag, 0xfffffffe, 0x00000020, 0x0000007d},
806 {CVFlag, 0x00007ffd, 0xffffff80, 0x00000002},
807 {NVFlag, 0x7ffffffe, 0x00007ffd, 0x00000001},
808 {CFlag, 0x80000001, 0x7fffffff, 0xffff8003},
809 {ZVFlag, 0x00007ffe, 0xffff8000, 0xffffffff},
810 {ZFlag, 0x00000001, 0xffff8002, 0x0000007e},
811 {NZCVFlag, 0xffffffff, 0x33333333, 0x0000007f},
812 {NZFlag, 0x7ffffffd, 0x00007ffe, 0x00000020}};
813
814
815 // A loop will be generated for each element of this array.
816 const TestLoopData kTests[] = {{{eq, r0, r0, r0},
817 "eq r0 r0 r0",
818 "Condition_eq_r0_r0_r0",
819 ARRAY_SIZE(kCondition),
820 kCondition},
821 {{ne, r0, r0, r0},
822 "ne r0 r0 r0",
823 "Condition_ne_r0_r0_r0",
824 ARRAY_SIZE(kCondition),
825 kCondition},
826 {{cs, r0, r0, r0},
827 "cs r0 r0 r0",
828 "Condition_cs_r0_r0_r0",
829 ARRAY_SIZE(kCondition),
830 kCondition},
831 {{cc, r0, r0, r0},
832 "cc r0 r0 r0",
833 "Condition_cc_r0_r0_r0",
834 ARRAY_SIZE(kCondition),
835 kCondition},
836 {{mi, r0, r0, r0},
837 "mi r0 r0 r0",
838 "Condition_mi_r0_r0_r0",
839 ARRAY_SIZE(kCondition),
840 kCondition},
841 {{pl, r0, r0, r0},
842 "pl r0 r0 r0",
843 "Condition_pl_r0_r0_r0",
844 ARRAY_SIZE(kCondition),
845 kCondition},
846 {{vs, r0, r0, r0},
847 "vs r0 r0 r0",
848 "Condition_vs_r0_r0_r0",
849 ARRAY_SIZE(kCondition),
850 kCondition},
851 {{vc, r0, r0, r0},
852 "vc r0 r0 r0",
853 "Condition_vc_r0_r0_r0",
854 ARRAY_SIZE(kCondition),
855 kCondition},
856 {{hi, r0, r0, r0},
857 "hi r0 r0 r0",
858 "Condition_hi_r0_r0_r0",
859 ARRAY_SIZE(kCondition),
860 kCondition},
861 {{ls, r0, r0, r0},
862 "ls r0 r0 r0",
863 "Condition_ls_r0_r0_r0",
864 ARRAY_SIZE(kCondition),
865 kCondition},
866 {{ge, r0, r0, r0},
867 "ge r0 r0 r0",
868 "Condition_ge_r0_r0_r0",
869 ARRAY_SIZE(kCondition),
870 kCondition},
871 {{lt, r0, r0, r0},
872 "lt r0 r0 r0",
873 "Condition_lt_r0_r0_r0",
874 ARRAY_SIZE(kCondition),
875 kCondition},
876 {{gt, r0, r0, r0},
877 "gt r0 r0 r0",
878 "Condition_gt_r0_r0_r0",
879 ARRAY_SIZE(kCondition),
880 kCondition},
881 {{le, r0, r0, r0},
882 "le r0 r0 r0",
883 "Condition_le_r0_r0_r0",
884 ARRAY_SIZE(kCondition),
885 kCondition},
886 {{al, r0, r0, r0},
887 "al r0 r0 r0",
888 "Condition_al_r0_r0_r0",
889 ARRAY_SIZE(kCondition),
890 kCondition},
891 {{ls, r3, r3, r11},
892 "ls r3 r3 r11",
893 "RdIsRn_ls_r3_r3_r11",
894 ARRAY_SIZE(kRdIsRn),
895 kRdIsRn},
896 {{le, r7, r7, r11},
897 "le r7 r7 r11",
898 "RdIsRn_le_r7_r7_r11",
899 ARRAY_SIZE(kRdIsRn),
900 kRdIsRn},
901 {{vc, r14, r14, r7},
902 "vc r14 r14 r7",
903 "RdIsRn_vc_r14_r14_r7",
904 ARRAY_SIZE(kRdIsRn),
905 kRdIsRn},
906 {{vs, r3, r3, r14},
907 "vs r3 r3 r14",
908 "RdIsRn_vs_r3_r3_r14",
909 ARRAY_SIZE(kRdIsRn),
910 kRdIsRn},
911 {{pl, r10, r10, r7},
912 "pl r10 r10 r7",
913 "RdIsRn_pl_r10_r10_r7",
914 ARRAY_SIZE(kRdIsRn),
915 kRdIsRn},
916 {{hi, r8, r8, r7},
917 "hi r8 r8 r7",
918 "RdIsRn_hi_r8_r8_r7",
919 ARRAY_SIZE(kRdIsRn),
920 kRdIsRn},
921 {{le, r8, r8, r6},
922 "le r8 r8 r6",
923 "RdIsRn_le_r8_r8_r6",
924 ARRAY_SIZE(kRdIsRn),
925 kRdIsRn},
926 {{ne, r5, r5, r1},
927 "ne r5 r5 r1",
928 "RdIsRn_ne_r5_r5_r1",
929 ARRAY_SIZE(kRdIsRn),
930 kRdIsRn},
931 {{gt, r10, r10, r3},
932 "gt r10 r10 r3",
933 "RdIsRn_gt_r10_r10_r3",
934 ARRAY_SIZE(kRdIsRn),
935 kRdIsRn},
936 {{ls, r3, r3, r14},
937 "ls r3 r3 r14",
938 "RdIsRn_ls_r3_r3_r14",
939 ARRAY_SIZE(kRdIsRn),
940 kRdIsRn},
941 {{hi, r0, r9, r0},
942 "hi r0 r9 r0",
943 "RdIsRm_hi_r0_r9_r0",
944 ARRAY_SIZE(kRdIsRm),
945 kRdIsRm},
946 {{eq, r5, r12, r5},
947 "eq r5 r12 r5",
948 "RdIsRm_eq_r5_r12_r5",
949 ARRAY_SIZE(kRdIsRm),
950 kRdIsRm},
951 {{gt, r12, r3, r12},
952 "gt r12 r3 r12",
953 "RdIsRm_gt_r12_r3_r12",
954 ARRAY_SIZE(kRdIsRm),
955 kRdIsRm},
956 {{lt, r8, r11, r8},
957 "lt r8 r11 r8",
958 "RdIsRm_lt_r8_r11_r8",
959 ARRAY_SIZE(kRdIsRm),
960 kRdIsRm},
961 {{cs, r7, r6, r7},
962 "cs r7 r6 r7",
963 "RdIsRm_cs_r7_r6_r7",
964 ARRAY_SIZE(kRdIsRm),
965 kRdIsRm},
966 {{lt, r9, r0, r9},
967 "lt r9 r0 r9",
968 "RdIsRm_lt_r9_r0_r9",
969 ARRAY_SIZE(kRdIsRm),
970 kRdIsRm},
971 {{cc, r6, r5, r6},
972 "cc r6 r5 r6",
973 "RdIsRm_cc_r6_r5_r6",
974 ARRAY_SIZE(kRdIsRm),
975 kRdIsRm},
976 {{pl, r7, r4, r7},
977 "pl r7 r4 r7",
978 "RdIsRm_pl_r7_r4_r7",
979 ARRAY_SIZE(kRdIsRm),
980 kRdIsRm},
981 {{ls, r0, r10, r0},
982 "ls r0 r10 r0",
983 "RdIsRm_ls_r0_r10_r0",
984 ARRAY_SIZE(kRdIsRm),
985 kRdIsRm},
986 {{hi, r9, r14, r9},
987 "hi r9 r14 r9",
988 "RdIsRm_hi_r9_r14_r9",
989 ARRAY_SIZE(kRdIsRm),
990 kRdIsRm},
991 {{mi, r8, r5, r10},
992 "mi r8 r5 r10",
993 "RdIsNotRnIsNotRm_mi_r8_r5_r10",
994 ARRAY_SIZE(kRdIsNotRnIsNotRm),
995 kRdIsNotRnIsNotRm},
996 {{ge, r2, r5, r4},
997 "ge r2 r5 r4",
998 "RdIsNotRnIsNotRm_ge_r2_r5_r4",
999 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1000 kRdIsNotRnIsNotRm},
1001 {{cc, r2, r7, r1},
1002 "cc r2 r7 r1",
1003 "RdIsNotRnIsNotRm_cc_r2_r7_r1",
1004 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1005 kRdIsNotRnIsNotRm},
1006 {{ne, r5, r9, r0},
1007 "ne r5 r9 r0",
1008 "RdIsNotRnIsNotRm_ne_r5_r9_r0",
1009 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1010 kRdIsNotRnIsNotRm},
1011 {{eq, r10, r6, r5},
1012 "eq r10 r6 r5",
1013 "RdIsNotRnIsNotRm_eq_r10_r6_r5",
1014 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1015 kRdIsNotRnIsNotRm},
1016 {{ne, r0, r4, r6},
1017 "ne r0 r4 r6",
1018 "RdIsNotRnIsNotRm_ne_r0_r4_r6",
1019 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1020 kRdIsNotRnIsNotRm},
1021 {{le, r7, r6, r0},
1022 "le r7 r6 r0",
1023 "RdIsNotRnIsNotRm_le_r7_r6_r0",
1024 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1025 kRdIsNotRnIsNotRm},
1026 {{hi, r12, r11, r3},
1027 "hi r12 r11 r3",
1028 "RdIsNotRnIsNotRm_hi_r12_r11_r3",
1029 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1030 kRdIsNotRnIsNotRm},
1031 {{pl, r3, r7, r12},
1032 "pl r3 r7 r12",
1033 "RdIsNotRnIsNotRm_pl_r3_r7_r12",
1034 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1035 kRdIsNotRnIsNotRm},
1036 {{cc, r4, r1, r7},
1037 "cc r4 r1 r7",
1038 "RdIsNotRnIsNotRm_cc_r4_r1_r7",
1039 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1040 kRdIsNotRnIsNotRm}};
1041
1042 // We record all inputs to the instructions as outputs. This way, we also check
1043 // that what shouldn't change didn't change.
1044 struct TestResult {
1045 size_t output_size;
1046 const Inputs* outputs;
1047 };
1048
1049 // These headers each contain an array of `TestResult` with the reference output
1050 // values. The reference arrays are names `kReference{mnemonic}`.
1051 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-adc-t32.h"
1052 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-adcs-t32.h"
1053 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-add-t32.h"
1054 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-adds-t32.h"
1055 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-and-t32.h"
1056 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-ands-t32.h"
1057 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-asr-t32.h"
1058 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-asrs-t32.h"
1059 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-bic-t32.h"
1060 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-bics-t32.h"
1061 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-eor-t32.h"
1062 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-eors-t32.h"
1063 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-lsl-t32.h"
1064 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-lsls-t32.h"
1065 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-lsr-t32.h"
1066 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-lsrs-t32.h"
1067 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-orn-t32.h"
1068 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-orns-t32.h"
1069 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-orr-t32.h"
1070 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-orrs-t32.h"
1071 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-ror-t32.h"
1072 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-rors-t32.h"
1073 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-rsb-t32.h"
1074 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-rsbs-t32.h"
1075 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-sbc-t32.h"
1076 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-sbcs-t32.h"
1077 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-sub-t32.h"
1078 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-subs-t32.h"
1079 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-sxtab-t32.h"
1080 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-sxtab16-t32.h"
1081 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-sxtah-t32.h"
1082 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-uxtab-t32.h"
1083 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-uxtab16-t32.h"
1084 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-uxtah-t32.h"
1085
1086
1087 // The maximum number of errors to report in detail for each test.
1088 const unsigned kErrorReportLimit = 8;
1089
1090 typedef void (MacroAssembler::*Fn)(Condition cond,
1091 Register rd,
1092 Register rn,
1093 const Operand& op);
1094
TestHelper(Fn instruction,const char * mnemonic,const TestResult reference[])1095 void TestHelper(Fn instruction,
1096 const char* mnemonic,
1097 const TestResult reference[]) {
1098 SETUP();
1099 masm.UseT32();
1100 START();
1101
1102 // Data to compare to `reference`.
1103 TestResult* results[ARRAY_SIZE(kTests)];
1104
1105 // Test cases for memory bound instructions may allocate a buffer and save its
1106 // address in this array.
1107 byte* scratch_memory_buffers[ARRAY_SIZE(kTests)];
1108
1109 // Generate a loop for each element in `kTests`. Each loop tests one specific
1110 // instruction.
1111 for (unsigned i = 0; i < ARRAY_SIZE(kTests); i++) {
1112 // Allocate results on the heap for this test.
1113 results[i] = new TestResult;
1114 results[i]->outputs = new Inputs[kTests[i].input_size];
1115 results[i]->output_size = kTests[i].input_size;
1116
1117 size_t input_stride = sizeof(kTests[i].inputs[0]) * kTests[i].input_size;
1118 VIXL_ASSERT(IsUint32(input_stride));
1119
1120 scratch_memory_buffers[i] = NULL;
1121
1122 Label loop;
1123 UseScratchRegisterScope scratch_registers(&masm);
1124 // Include all registers from r0 ro r12.
1125 scratch_registers.Include(RegisterList(0x1fff));
1126
1127 // Values to pass to the macro-assembler.
1128 Condition cond = kTests[i].operands.cond;
1129 Register rd = kTests[i].operands.rd;
1130 Register rn = kTests[i].operands.rn;
1131 Register rm = kTests[i].operands.rm;
1132 Operand op(rm);
1133 scratch_registers.Exclude(rd);
1134 scratch_registers.Exclude(rn);
1135 scratch_registers.Exclude(rm);
1136
1137 // Allocate reserved registers for our own use.
1138 Register input_ptr = scratch_registers.Acquire();
1139 Register input_end = scratch_registers.Acquire();
1140 Register result_ptr = scratch_registers.Acquire();
1141
1142 // Initialize `input_ptr` to the first element and `input_end` the address
1143 // after the array.
1144 __ Mov(input_ptr, Operand::From(kTests[i].inputs));
1145 __ Add(input_end, input_ptr, static_cast<uint32_t>(input_stride));
1146 __ Mov(result_ptr, Operand::From(results[i]->outputs));
1147 __ Bind(&loop);
1148
1149 {
1150 UseScratchRegisterScope temp_registers(&masm);
1151 Register nzcv_bits = temp_registers.Acquire();
1152 Register saved_q_bit = temp_registers.Acquire();
1153 // Save the `Q` bit flag.
1154 __ Mrs(saved_q_bit, APSR);
1155 __ And(saved_q_bit, saved_q_bit, QFlag);
1156 // Set the `NZCV` and `Q` flags together.
1157 __ Ldr(nzcv_bits, MemOperand(input_ptr, offsetof(Inputs, apsr)));
1158 __ Orr(nzcv_bits, nzcv_bits, saved_q_bit);
1159 __ Msr(APSR_nzcvq, nzcv_bits);
1160 }
1161 __ Ldr(rd, MemOperand(input_ptr, offsetof(Inputs, rd)));
1162 __ Ldr(rn, MemOperand(input_ptr, offsetof(Inputs, rn)));
1163 __ Ldr(rm, MemOperand(input_ptr, offsetof(Inputs, rm)));
1164
1165 (masm.*instruction)(cond, rd, rn, op);
1166
1167 {
1168 UseScratchRegisterScope temp_registers(&masm);
1169 Register nzcv_bits = temp_registers.Acquire();
1170 __ Mrs(nzcv_bits, APSR);
1171 // Only record the NZCV bits.
1172 __ And(nzcv_bits, nzcv_bits, NZCVFlag);
1173 __ Str(nzcv_bits, MemOperand(result_ptr, offsetof(Inputs, apsr)));
1174 }
1175 __ Str(rd, MemOperand(result_ptr, offsetof(Inputs, rd)));
1176 __ Str(rn, MemOperand(result_ptr, offsetof(Inputs, rn)));
1177 __ Str(rm, MemOperand(result_ptr, offsetof(Inputs, rm)));
1178
1179 // Advance the result pointer.
1180 __ Add(result_ptr, result_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
1181 // Loop back until `input_ptr` is lower than `input_base`.
1182 __ Add(input_ptr, input_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
1183 __ Cmp(input_ptr, input_end);
1184 __ B(ne, &loop);
1185 }
1186
1187 END();
1188
1189 RUN();
1190
1191 if (Test::generate_test_trace()) {
1192 // Print the results.
1193 for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
1194 printf("const Inputs kOutputs_%s_%s[] = {\n",
1195 mnemonic,
1196 kTests[i].identifier);
1197 for (size_t j = 0; j < results[i]->output_size; j++) {
1198 printf(" { ");
1199 printf("0x%08" PRIx32, results[i]->outputs[j].apsr);
1200 printf(", ");
1201 printf("0x%08" PRIx32, results[i]->outputs[j].rd);
1202 printf(", ");
1203 printf("0x%08" PRIx32, results[i]->outputs[j].rn);
1204 printf(", ");
1205 printf("0x%08" PRIx32, results[i]->outputs[j].rm);
1206 printf(" },\n");
1207 }
1208 printf("};\n");
1209 }
1210 printf("const TestResult kReference%s[] = {\n", mnemonic);
1211 for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
1212 printf(" {\n");
1213 printf(" ARRAY_SIZE(kOutputs_%s_%s),\n",
1214 mnemonic,
1215 kTests[i].identifier);
1216 printf(" kOutputs_%s_%s,\n", mnemonic, kTests[i].identifier);
1217 printf(" },\n");
1218 }
1219 printf("};\n");
1220 } else if (kCheckSimulatorTestResults) {
1221 // Check the results.
1222 unsigned total_error_count = 0;
1223 for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
1224 bool instruction_has_errors = false;
1225 for (size_t j = 0; j < kTests[i].input_size; j++) {
1226 uint32_t apsr = results[i]->outputs[j].apsr;
1227 uint32_t rd = results[i]->outputs[j].rd;
1228 uint32_t rn = results[i]->outputs[j].rn;
1229 uint32_t rm = results[i]->outputs[j].rm;
1230 uint32_t apsr_input = kTests[i].inputs[j].apsr;
1231 uint32_t rd_input = kTests[i].inputs[j].rd;
1232 uint32_t rn_input = kTests[i].inputs[j].rn;
1233 uint32_t rm_input = kTests[i].inputs[j].rm;
1234 uint32_t apsr_ref = reference[i].outputs[j].apsr;
1235 uint32_t rd_ref = reference[i].outputs[j].rd;
1236 uint32_t rn_ref = reference[i].outputs[j].rn;
1237 uint32_t rm_ref = reference[i].outputs[j].rm;
1238
1239 if (((apsr != apsr_ref) || (rd != rd_ref) || (rn != rn_ref) ||
1240 (rm != rm_ref)) &&
1241 (++total_error_count <= kErrorReportLimit)) {
1242 // Print the instruction once even if it triggered multiple failures.
1243 if (!instruction_has_errors) {
1244 printf("Error(s) when testing \"%s %s\":\n",
1245 mnemonic,
1246 kTests[i].operands_description);
1247 instruction_has_errors = true;
1248 }
1249 // Print subsequent errors.
1250 printf(" Input: ");
1251 printf("0x%08" PRIx32, apsr_input);
1252 printf(", ");
1253 printf("0x%08" PRIx32, rd_input);
1254 printf(", ");
1255 printf("0x%08" PRIx32, rn_input);
1256 printf(", ");
1257 printf("0x%08" PRIx32, rm_input);
1258 printf("\n");
1259 printf(" Expected: ");
1260 printf("0x%08" PRIx32, apsr_ref);
1261 printf(", ");
1262 printf("0x%08" PRIx32, rd_ref);
1263 printf(", ");
1264 printf("0x%08" PRIx32, rn_ref);
1265 printf(", ");
1266 printf("0x%08" PRIx32, rm_ref);
1267 printf("\n");
1268 printf(" Found: ");
1269 printf("0x%08" PRIx32, apsr);
1270 printf(", ");
1271 printf("0x%08" PRIx32, rd);
1272 printf(", ");
1273 printf("0x%08" PRIx32, rn);
1274 printf(", ");
1275 printf("0x%08" PRIx32, rm);
1276 printf("\n\n");
1277 }
1278 }
1279 }
1280
1281 if (total_error_count > kErrorReportLimit) {
1282 printf("%u other errors follow.\n",
1283 total_error_count - kErrorReportLimit);
1284 }
1285 VIXL_CHECK(total_error_count == 0);
1286 } else {
1287 VIXL_WARNING("Assembled the code, but did not run anything.\n");
1288 }
1289
1290 for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
1291 delete[] results[i]->outputs;
1292 delete results[i];
1293 delete[] scratch_memory_buffers[i];
1294 }
1295 }
1296
1297 // Instantiate tests for each instruction in the list.
1298 // TODO: Remove this limitation by having a sandboxing mechanism.
1299 #if defined(VIXL_HOST_POINTER_32)
1300 #define TEST(mnemonic) \
1301 void Test_##mnemonic() { \
1302 TestHelper(&MacroAssembler::mnemonic, #mnemonic, kReference##mnemonic); \
1303 } \
1304 Test test_##mnemonic("AARCH32_SIMULATOR_COND_RD_RN_OPERAND_RM_" #mnemonic \
1305 "_T32", \
1306 &Test_##mnemonic);
1307 #else
1308 #define TEST(mnemonic) \
1309 void Test_##mnemonic() { \
1310 VIXL_WARNING("This test can only run on a 32-bit host.\n"); \
1311 USE(TestHelper); \
1312 } \
1313 Test test_##mnemonic("AARCH32_SIMULATOR_COND_RD_RN_OPERAND_RM_" #mnemonic \
1314 "_T32", \
1315 &Test_##mnemonic);
1316 #endif
1317
1318 FOREACH_INSTRUCTION(TEST)
1319 #undef TEST
1320
1321 } // namespace
1322 #endif
1323
1324 } // namespace aarch32
1325 } // namespace vixl
1326