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