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(Orr) \
127 M(Orrs) \
128 M(Rsb) \
129 M(Rsbs) \
130 M(Rsc) \
131 M(Rscs) \
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_A32
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[] = {{NoFlag, 0xffffff83, 0xffffff83, 0xffff8002},
211 {NoFlag, 0x0000007e, 0x0000007e, 0x7fffffff},
212 {NoFlag, 0x0000007d, 0x0000007d, 0xffffffe0},
213 {NoFlag, 0x7fffffff, 0x7fffffff, 0x00000002},
214 {NoFlag, 0xffff8002, 0xffff8002, 0xfffffffd},
215 {NoFlag, 0xffffffe0, 0xffffffe0, 0x00007fff},
216 {NoFlag, 0xffff8000, 0xffff8000, 0xffffff83},
217 {NoFlag, 0xffff8002, 0xffff8002, 0x80000001},
218 {NoFlag, 0x00007ffd, 0x00007ffd, 0xffff8003},
219 {NoFlag, 0x00007fff, 0x00007fff, 0xffffffff},
220 {NoFlag, 0x00000000, 0x00000000, 0xffffff80},
221 {NoFlag, 0xffff8001, 0xffff8001, 0x33333333},
222 {NoFlag, 0xffffff80, 0xffffff80, 0x0000007e},
223 {NoFlag, 0x0000007e, 0x0000007e, 0x7ffffffd},
224 {NoFlag, 0xffffff80, 0xffffff80, 0xfffffffd},
225 {NoFlag, 0x00000020, 0x00000020, 0xffff8002},
226 {NoFlag, 0xffffff80, 0xffffff80, 0xfffffffe},
227 {NoFlag, 0x00000002, 0x00000002, 0x00000000},
228 {NoFlag, 0x0000007e, 0x0000007e, 0x00000001},
229 {NoFlag, 0x00000002, 0x00000002, 0x0000007f},
230 {NoFlag, 0x80000000, 0x80000000, 0x80000000},
231 {NoFlag, 0x7fffffff, 0x7fffffff, 0xffffff80},
232 {NoFlag, 0x00000001, 0x00000001, 0xfffffffe},
233 {NoFlag, 0x33333333, 0x33333333, 0x0000007d},
234 {NoFlag, 0x00000001, 0x00000001, 0x7ffffffe},
235 {NoFlag, 0x00007ffe, 0x00007ffe, 0x7fffffff},
236 {NoFlag, 0x80000000, 0x80000000, 0xffffff83},
237 {NoFlag, 0x00000000, 0x00000000, 0x7ffffffe},
238 {NoFlag, 0x00000000, 0x00000000, 0x0000007f},
239 {NoFlag, 0x7fffffff, 0x7fffffff, 0xcccccccc},
240 {NoFlag, 0xffffff82, 0xffffff82, 0x00000002},
241 {NoFlag, 0x7ffffffd, 0x7ffffffd, 0xaaaaaaaa},
242 {NoFlag, 0xcccccccc, 0xcccccccc, 0xffff8001},
243 {NoFlag, 0xfffffffe, 0xfffffffe, 0xffff8001},
244 {NoFlag, 0x7fffffff, 0x7fffffff, 0x00000020},
245 {NoFlag, 0xffffffe0, 0xffffffe0, 0x00007ffe},
246 {NoFlag, 0x80000001, 0x80000001, 0xffff8000},
247 {NoFlag, 0xffffff82, 0xffffff82, 0x0000007d},
248 {NoFlag, 0x0000007e, 0x0000007e, 0x7ffffffe},
249 {NoFlag, 0x00007ffd, 0x00007ffd, 0xffffff80},
250 {NoFlag, 0x0000007d, 0x0000007d, 0x0000007e},
251 {NoFlag, 0xffff8002, 0xffff8002, 0x7fffffff},
252 {NoFlag, 0xffffffe0, 0xffffffe0, 0x0000007f},
253 {NoFlag, 0x00007ffe, 0x00007ffe, 0xffffff81},
254 {NoFlag, 0x80000000, 0x80000000, 0x0000007e},
255 {NoFlag, 0xffffffff, 0xffffffff, 0xaaaaaaaa},
256 {NoFlag, 0xfffffffe, 0xfffffffe, 0x00000020},
257 {NoFlag, 0xffffff82, 0xffffff82, 0xffff8003},
258 {NoFlag, 0x7ffffffd, 0x7ffffffd, 0xffff8002},
259 {NoFlag, 0x7ffffffe, 0x7ffffffe, 0x00000000},
260 {NoFlag, 0xfffffffd, 0xfffffffd, 0xffffffe0},
261 {NoFlag, 0xffff8000, 0xffff8000, 0xffff8002},
262 {NoFlag, 0xffffff82, 0xffffff82, 0x7ffffffd},
263 {NoFlag, 0xcccccccc, 0xcccccccc, 0x80000000},
264 {NoFlag, 0x80000001, 0x80000001, 0x33333333},
265 {NoFlag, 0x00000001, 0x00000001, 0x00000002},
266 {NoFlag, 0x55555555, 0x55555555, 0x0000007f},
267 {NoFlag, 0xffffffff, 0xffffffff, 0xfffffffd},
268 {NoFlag, 0xffffff80, 0xffffff80, 0x80000000},
269 {NoFlag, 0x00000000, 0x00000000, 0x00000020},
270 {NoFlag, 0xfffffffe, 0xfffffffe, 0xffff8003},
271 {NoFlag, 0xffff8001, 0xffff8001, 0xffff8000},
272 {NoFlag, 0x55555555, 0x55555555, 0x55555555},
273 {NoFlag, 0x00007fff, 0x00007fff, 0xffff8000},
274 {NoFlag, 0x7fffffff, 0x7fffffff, 0xffffffe0},
275 {NoFlag, 0x00000001, 0x00000001, 0x55555555},
276 {NoFlag, 0x33333333, 0x33333333, 0x7ffffffe},
277 {NoFlag, 0x80000000, 0x80000000, 0xffffffe0},
278 {NoFlag, 0xffffff83, 0xffffff83, 0x0000007d},
279 {NoFlag, 0xffff8003, 0xffff8003, 0x00000002},
280 {NoFlag, 0x7ffffffe, 0x7ffffffe, 0xffffff81},
281 {NoFlag, 0xfffffffe, 0xfffffffe, 0xffffff80},
282 {NoFlag, 0x00007ffe, 0x00007ffe, 0xffff8002},
283 {NoFlag, 0x80000001, 0x80000001, 0xfffffffe},
284 {NoFlag, 0x7ffffffd, 0x7ffffffd, 0xfffffffd},
285 {NoFlag, 0x7ffffffd, 0x7ffffffd, 0xfffffffe},
286 {NoFlag, 0x7ffffffe, 0x7ffffffe, 0xffffff83},
287 {NoFlag, 0xfffffffd, 0xfffffffd, 0x00007ffe},
288 {NoFlag, 0x7fffffff, 0x7fffffff, 0x80000000},
289 {NoFlag, 0xffffff82, 0xffffff82, 0x7fffffff},
290 {NoFlag, 0xffffffe0, 0xffffffe0, 0xffffff83},
291 {NoFlag, 0xffff8000, 0xffff8000, 0xffff8000},
292 {NoFlag, 0x00000001, 0x00000001, 0x7fffffff},
293 {NoFlag, 0xfffffffe, 0xfffffffe, 0xffffffff},
294 {NoFlag, 0xffffff82, 0xffffff82, 0xffffffff},
295 {NoFlag, 0xffffffff, 0xffffffff, 0xfffffffe},
296 {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x0000007d},
297 {NoFlag, 0xffff8001, 0xffff8001, 0xfffffffe},
298 {NoFlag, 0x00007ffe, 0x00007ffe, 0x0000007d},
299 {NoFlag, 0xffffff82, 0xffffff82, 0xfffffffe},
300 {NoFlag, 0x00000000, 0x00000000, 0x00007ffd},
301 {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0xffff8002},
302 {NoFlag, 0x0000007f, 0x0000007f, 0xffffff82},
303 {NoFlag, 0x00007fff, 0x00007fff, 0x33333333},
304 {NoFlag, 0xfffffffd, 0xfffffffd, 0x80000000},
305 {NoFlag, 0x00000000, 0x00000000, 0xfffffffd},
306 {NoFlag, 0x0000007d, 0x0000007d, 0x0000007f},
307 {NoFlag, 0xfffffffd, 0xfffffffd, 0x0000007e},
308 {NoFlag, 0xffffffe0, 0xffffffe0, 0x55555555},
309 {NoFlag, 0xffffffff, 0xffffffff, 0x80000000},
310 {NoFlag, 0xffffffe0, 0xffffffe0, 0x0000007e},
311 {NoFlag, 0xffffff81, 0xffffff81, 0x00007ffd},
312 {NoFlag, 0x00000020, 0x00000020, 0xffff8001},
313 {NoFlag, 0x00007fff, 0x00007fff, 0xffffff83},
314 {NoFlag, 0x33333333, 0x33333333, 0x00000000},
315 {NoFlag, 0xffff8000, 0xffff8000, 0xffffff82},
316 {NoFlag, 0xffff8001, 0xffff8001, 0x0000007e},
317 {NoFlag, 0xffffff80, 0xffffff80, 0x00000001},
318 {NoFlag, 0x80000000, 0x80000000, 0xcccccccc},
319 {NoFlag, 0x00000002, 0x00000002, 0x00007ffd},
320 {NoFlag, 0x7ffffffe, 0x7ffffffe, 0x80000001},
321 {NoFlag, 0x00000020, 0x00000020, 0x00007ffe},
322 {NoFlag, 0xffff8000, 0xffff8000, 0xfffffffd},
323 {NoFlag, 0x7fffffff, 0x7fffffff, 0xffff8001},
324 {NoFlag, 0x00000000, 0x00000000, 0xffffff83},
325 {NoFlag, 0x0000007f, 0x0000007f, 0x00000020},
326 {NoFlag, 0x80000001, 0x80000001, 0xffff8003},
327 {NoFlag, 0xffff8001, 0xffff8001, 0x0000007f},
328 {NoFlag, 0x0000007f, 0x0000007f, 0x80000001},
329 {NoFlag, 0x00000002, 0x00000002, 0x7ffffffe},
330 {NoFlag, 0xffffff82, 0xffffff82, 0xffffff83},
331 {NoFlag, 0x00007ffd, 0x00007ffd, 0x7fffffff},
332 {NoFlag, 0x7ffffffe, 0x7ffffffe, 0xfffffffe},
333 {NoFlag, 0xffffff82, 0xffffff82, 0xffff8000},
334 {NoFlag, 0xfffffffe, 0xfffffffe, 0xffff8000},
335 {NoFlag, 0xffff8002, 0xffff8002, 0xffffff81},
336 {NoFlag, 0x33333333, 0x33333333, 0x7fffffff},
337 {NoFlag, 0x80000001, 0x80000001, 0x00007fff},
338 {NoFlag, 0xffff8002, 0xffff8002, 0xcccccccc},
339 {NoFlag, 0xffffffff, 0xffffffff, 0x00000002},
340 {NoFlag, 0x33333333, 0x33333333, 0xffffff81},
341 {NoFlag, 0xfffffffd, 0xfffffffd, 0xffffff80},
342 {NoFlag, 0x55555555, 0x55555555, 0xaaaaaaaa},
343 {NoFlag, 0x33333333, 0x33333333, 0xffffff82},
344 {NoFlag, 0xffffff80, 0xffffff80, 0xaaaaaaaa},
345 {NoFlag, 0x0000007e, 0x0000007e, 0x00000020},
346 {NoFlag, 0xffffff83, 0xffffff83, 0x00007ffd},
347 {NoFlag, 0xffffff82, 0xffffff82, 0xaaaaaaaa},
348 {NoFlag, 0xffff8003, 0xffff8003, 0xffffffff},
349 {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0xfffffffe},
350 {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x00000000},
351 {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x0000007f},
352 {NoFlag, 0x0000007f, 0x0000007f, 0x0000007d},
353 {NoFlag, 0xfffffffd, 0xfffffffd, 0x55555555},
354 {NoFlag, 0xffffffff, 0xffffffff, 0x00000020},
355 {NoFlag, 0x00007ffe, 0x00007ffe, 0xffffff83},
356 {NoFlag, 0x7fffffff, 0x7fffffff, 0x55555555},
357 {NoFlag, 0x55555555, 0x55555555, 0xcccccccc},
358 {NoFlag, 0xffffffe0, 0xffffffe0, 0xffff8003},
359 {NoFlag, 0x7ffffffe, 0x7ffffffe, 0x00007ffe},
360 {NoFlag, 0x00007ffd, 0x00007ffd, 0xffff8002},
361 {NoFlag, 0x00007ffd, 0x00007ffd, 0x00000001},
362 {NoFlag, 0x00000000, 0x00000000, 0x00007ffe},
363 {NoFlag, 0xffffff80, 0xffffff80, 0x00000020},
364 {NoFlag, 0xffff8000, 0xffff8000, 0x0000007d},
365 {NoFlag, 0xffff8003, 0xffff8003, 0x00000000},
366 {NoFlag, 0x0000007e, 0x0000007e, 0x80000000},
367 {NoFlag, 0xfffffffd, 0xfffffffd, 0x00000000},
368 {NoFlag, 0xffffff80, 0xffffff80, 0xffffffff},
369 {NoFlag, 0xcccccccc, 0xcccccccc, 0x0000007f},
370 {NoFlag, 0x7ffffffd, 0x7ffffffd, 0x00000000},
371 {NoFlag, 0x00007fff, 0x00007fff, 0x00000000},
372 {NoFlag, 0x0000007f, 0x0000007f, 0x00000001},
373 {NoFlag, 0xffffffff, 0xffffffff, 0xffffff82},
374 {NoFlag, 0x00007ffe, 0x00007ffe, 0x00007ffd},
375 {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x33333333},
376 {NoFlag, 0xffffff82, 0xffffff82, 0x55555555},
377 {NoFlag, 0xffff8003, 0xffff8003, 0x0000007e},
378 {NoFlag, 0xffffff83, 0xffffff83, 0x00000002},
379 {NoFlag, 0xffffff82, 0xffffff82, 0x33333333},
380 {NoFlag, 0x55555555, 0x55555555, 0xffffffff},
381 {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x80000001},
382 {NoFlag, 0xffffff83, 0xffffff83, 0xffffffe0},
383 {NoFlag, 0x00000001, 0x00000001, 0xffffffe0},
384 {NoFlag, 0x33333333, 0x33333333, 0x33333333},
385 {NoFlag, 0x55555555, 0x55555555, 0x00000001},
386 {NoFlag, 0xffffff83, 0xffffff83, 0x00007fff},
387 {NoFlag, 0x00000002, 0x00000002, 0xfffffffd},
388 {NoFlag, 0xffffffe0, 0xffffffe0, 0xffff8002},
389 {NoFlag, 0x80000000, 0x80000000, 0x00007ffd},
390 {NoFlag, 0xffffff83, 0xffffff83, 0xfffffffe},
391 {NoFlag, 0x80000001, 0x80000001, 0xffffffff},
392 {NoFlag, 0xffff8003, 0xffff8003, 0x00000020},
393 {NoFlag, 0xffffff82, 0xffffff82, 0xcccccccc},
394 {NoFlag, 0x00000020, 0x00000020, 0x7fffffff},
395 {NoFlag, 0xffffff80, 0xffffff80, 0x55555555},
396 {NoFlag, 0x00000001, 0x00000001, 0x00000020},
397 {NoFlag, 0xffff8001, 0xffff8001, 0x00007fff},
398 {NoFlag, 0x00000020, 0x00000020, 0xaaaaaaaa},
399 {NoFlag, 0x55555555, 0x55555555, 0x7fffffff},
400 {NoFlag, 0xfffffffe, 0xfffffffe, 0x7fffffff},
401 {NoFlag, 0x00007fff, 0x00007fff, 0x55555555},
402 {NoFlag, 0x55555555, 0x55555555, 0x0000007d},
403 {NoFlag, 0xcccccccc, 0xcccccccc, 0x7ffffffe},
404 {NoFlag, 0xffff8002, 0xffff8002, 0x00007ffe},
405 {NoFlag, 0xfffffffe, 0xfffffffe, 0xffffff81},
406 {NoFlag, 0xffffff81, 0xffffff81, 0x0000007d},
407 {NoFlag, 0x00000020, 0x00000020, 0x0000007e},
408 {NoFlag, 0xffffffff, 0xffffffff, 0x00007ffe},
409 {NoFlag, 0xffff8002, 0xffff8002, 0x0000007e}};
410
411 static const Inputs kRdIsRm[] = {{NoFlag, 0x55555555, 0x7ffffffe, 0x55555555},
412 {NoFlag, 0xfffffffe, 0x00000001, 0xfffffffe},
413 {NoFlag, 0xffffff82, 0xffffff82, 0xffffff82},
414 {NoFlag, 0xffff8000, 0xffff8003, 0xffff8000},
415 {NoFlag, 0x00000001, 0x00000000, 0x00000001},
416 {NoFlag, 0xffffff81, 0x00007fff, 0xffffff81},
417 {NoFlag, 0x0000007d, 0xffff8002, 0x0000007d},
418 {NoFlag, 0x80000000, 0xffff8000, 0x80000000},
419 {NoFlag, 0xffffff80, 0x00000020, 0xffffff80},
420 {NoFlag, 0x55555555, 0xffffff81, 0x55555555},
421 {NoFlag, 0x00007ffd, 0xffffff82, 0x00007ffd},
422 {NoFlag, 0x55555555, 0x00007fff, 0x55555555},
423 {NoFlag, 0x7ffffffd, 0xffff8000, 0x7ffffffd},
424 {NoFlag, 0xffffffff, 0xffffff83, 0xffffffff},
425 {NoFlag, 0x00000000, 0xffffffff, 0x00000000},
426 {NoFlag, 0xffff8002, 0x33333333, 0xffff8002},
427 {NoFlag, 0x00007ffd, 0xaaaaaaaa, 0x00007ffd},
428 {NoFlag, 0x55555555, 0xffff8000, 0x55555555},
429 {NoFlag, 0x80000001, 0xffffffff, 0x80000001},
430 {NoFlag, 0x0000007d, 0xffffff83, 0x0000007d},
431 {NoFlag, 0x0000007e, 0xffffff82, 0x0000007e},
432 {NoFlag, 0xcccccccc, 0x0000007d, 0xcccccccc},
433 {NoFlag, 0xffff8002, 0xffffffff, 0xffff8002},
434 {NoFlag, 0xffffff81, 0x0000007f, 0xffffff81},
435 {NoFlag, 0xffff8000, 0xffffff83, 0xffff8000},
436 {NoFlag, 0xffffffff, 0xffffffe0, 0xffffffff},
437 {NoFlag, 0xfffffffd, 0x80000001, 0xfffffffd},
438 {NoFlag, 0x55555555, 0x80000000, 0x55555555},
439 {NoFlag, 0xffff8000, 0x0000007d, 0xffff8000},
440 {NoFlag, 0xaaaaaaaa, 0xffff8003, 0xaaaaaaaa},
441 {NoFlag, 0x00000001, 0x00007ffd, 0x00000001},
442 {NoFlag, 0x0000007e, 0x7ffffffe, 0x0000007e},
443 {NoFlag, 0x00000020, 0x00007ffd, 0x00000020},
444 {NoFlag, 0xffffff81, 0x7ffffffd, 0xffffff81},
445 {NoFlag, 0xffffff83, 0x0000007f, 0xffffff83},
446 {NoFlag, 0x00000001, 0x0000007e, 0x00000001},
447 {NoFlag, 0xffffff82, 0xfffffffd, 0xffffff82},
448 {NoFlag, 0xffff8003, 0x7ffffffe, 0xffff8003},
449 {NoFlag, 0x00000002, 0x00000002, 0x00000002},
450 {NoFlag, 0xffffff83, 0xffff8001, 0xffffff83},
451 {NoFlag, 0xffff8002, 0xfffffffe, 0xffff8002},
452 {NoFlag, 0xffffff80, 0xffffff81, 0xffffff80},
453 {NoFlag, 0x7fffffff, 0xffffff81, 0x7fffffff},
454 {NoFlag, 0x00000020, 0xffffff81, 0x00000020},
455 {NoFlag, 0x0000007f, 0xffffffff, 0x0000007f},
456 {NoFlag, 0x0000007d, 0xcccccccc, 0x0000007d},
457 {NoFlag, 0x00007fff, 0x55555555, 0x00007fff},
458 {NoFlag, 0xffff8003, 0x00007ffd, 0xffff8003},
459 {NoFlag, 0x80000001, 0x80000001, 0x80000001},
460 {NoFlag, 0xffffffff, 0xfffffffd, 0xffffffff},
461 {NoFlag, 0xffff8000, 0xfffffffe, 0xffff8000},
462 {NoFlag, 0xcccccccc, 0x0000007f, 0xcccccccc},
463 {NoFlag, 0x00000001, 0x00000002, 0x00000001},
464 {NoFlag, 0xffffff82, 0xffffff81, 0xffffff82},
465 {NoFlag, 0xfffffffd, 0x00007ffd, 0xfffffffd},
466 {NoFlag, 0x80000001, 0x33333333, 0x80000001},
467 {NoFlag, 0xffffff82, 0xffff8002, 0xffffff82},
468 {NoFlag, 0xffff8003, 0xfffffffd, 0xffff8003},
469 {NoFlag, 0xffffff81, 0x00000020, 0xffffff81},
470 {NoFlag, 0xffff8001, 0xffff8003, 0xffff8001},
471 {NoFlag, 0x00000001, 0x80000001, 0x00000001},
472 {NoFlag, 0xfffffffd, 0x00000002, 0xfffffffd},
473 {NoFlag, 0xffff8003, 0x7ffffffd, 0xffff8003},
474 {NoFlag, 0x0000007e, 0xaaaaaaaa, 0x0000007e},
475 {NoFlag, 0x7ffffffe, 0x7fffffff, 0x7ffffffe},
476 {NoFlag, 0x00007ffd, 0x00007ffe, 0x00007ffd},
477 {NoFlag, 0x00007fff, 0x80000001, 0x00007fff},
478 {NoFlag, 0x00007fff, 0xfffffffe, 0x00007fff},
479 {NoFlag, 0x00000001, 0xffffff80, 0x00000001},
480 {NoFlag, 0x55555555, 0xcccccccc, 0x55555555},
481 {NoFlag, 0x7ffffffd, 0xffffffe0, 0x7ffffffd},
482 {NoFlag, 0xffffff81, 0xfffffffe, 0xffffff81},
483 {NoFlag, 0xffffff82, 0x00007ffe, 0xffffff82},
484 {NoFlag, 0xffffff82, 0x80000001, 0xffffff82},
485 {NoFlag, 0x0000007f, 0xffff8001, 0x0000007f},
486 {NoFlag, 0x7ffffffd, 0xffffff83, 0x7ffffffd},
487 {NoFlag, 0xffffff82, 0xcccccccc, 0xffffff82},
488 {NoFlag, 0x00000020, 0xffffff83, 0x00000020},
489 {NoFlag, 0x00007ffe, 0x80000000, 0x00007ffe},
490 {NoFlag, 0x0000007f, 0xffff8000, 0x0000007f},
491 {NoFlag, 0xffffff82, 0x33333333, 0xffffff82},
492 {NoFlag, 0x7ffffffd, 0x7ffffffd, 0x7ffffffd},
493 {NoFlag, 0xffffff80, 0xffff8001, 0xffffff80},
494 {NoFlag, 0x00000002, 0xaaaaaaaa, 0x00000002},
495 {NoFlag, 0xffffffff, 0x7fffffff, 0xffffffff},
496 {NoFlag, 0xfffffffd, 0xfffffffe, 0xfffffffd},
497 {NoFlag, 0x00000020, 0x00000001, 0x00000020},
498 {NoFlag, 0x55555555, 0x00000001, 0x55555555},
499 {NoFlag, 0x55555555, 0xffffff80, 0x55555555},
500 {NoFlag, 0xffffffff, 0x00007fff, 0xffffffff},
501 {NoFlag, 0x00000020, 0xaaaaaaaa, 0x00000020},
502 {NoFlag, 0x00000002, 0x00007ffe, 0x00000002},
503 {NoFlag, 0x00000001, 0xcccccccc, 0x00000001},
504 {NoFlag, 0xffff8001, 0x00000000, 0xffff8001},
505 {NoFlag, 0x00000001, 0xffff8000, 0x00000001},
506 {NoFlag, 0xffffffe0, 0x00007fff, 0xffffffe0},
507 {NoFlag, 0xfffffffe, 0x00007fff, 0xfffffffe},
508 {NoFlag, 0xffffff83, 0x00000001, 0xffffff83},
509 {NoFlag, 0x00007fff, 0xffff8002, 0x00007fff},
510 {NoFlag, 0x7ffffffd, 0x7ffffffe, 0x7ffffffd},
511 {NoFlag, 0x80000001, 0xaaaaaaaa, 0x80000001},
512 {NoFlag, 0x80000001, 0xcccccccc, 0x80000001},
513 {NoFlag, 0x00007ffe, 0xffffffe0, 0x00007ffe},
514 {NoFlag, 0x00007ffe, 0xfffffffd, 0x00007ffe},
515 {NoFlag, 0x55555555, 0xaaaaaaaa, 0x55555555},
516 {NoFlag, 0xffffffe0, 0x00000001, 0xffffffe0},
517 {NoFlag, 0x0000007e, 0x00007fff, 0x0000007e},
518 {NoFlag, 0xfffffffe, 0xfffffffd, 0xfffffffe},
519 {NoFlag, 0x33333333, 0x0000007d, 0x33333333},
520 {NoFlag, 0xffffff81, 0x7fffffff, 0xffffff81},
521 {NoFlag, 0x0000007e, 0x0000007d, 0x0000007e},
522 {NoFlag, 0x00000001, 0xffffff81, 0x00000001},
523 {NoFlag, 0x80000000, 0x00000002, 0x80000000},
524 {NoFlag, 0x0000007d, 0xffff8003, 0x0000007d},
525 {NoFlag, 0x7ffffffe, 0x00007ffd, 0x7ffffffe},
526 {NoFlag, 0x7ffffffe, 0xaaaaaaaa, 0x7ffffffe},
527 {NoFlag, 0x00000000, 0xffff8000, 0x00000000},
528 {NoFlag, 0x33333333, 0x00000002, 0x33333333},
529 {NoFlag, 0xffffff81, 0xffffff83, 0xffffff81},
530 {NoFlag, 0x7ffffffe, 0x00007ffe, 0x7ffffffe},
531 {NoFlag, 0x80000000, 0x0000007d, 0x80000000},
532 {NoFlag, 0x00000020, 0x00000002, 0x00000020},
533 {NoFlag, 0x33333333, 0x80000001, 0x33333333},
534 {NoFlag, 0xffffff83, 0x00007ffd, 0xffffff83},
535 {NoFlag, 0x00007ffd, 0xffffff83, 0x00007ffd},
536 {NoFlag, 0xffff8001, 0x80000000, 0xffff8001},
537 {NoFlag, 0x00000000, 0x80000000, 0x00000000},
538 {NoFlag, 0xffffffe0, 0xffffffff, 0xffffffe0},
539 {NoFlag, 0x80000000, 0xffffff83, 0x80000000},
540 {NoFlag, 0x00000020, 0xffffff80, 0x00000020},
541 {NoFlag, 0x7ffffffd, 0xffff8001, 0x7ffffffd},
542 {NoFlag, 0x80000001, 0xffff8003, 0x80000001},
543 {NoFlag, 0x00007ffe, 0x7fffffff, 0x00007ffe},
544 {NoFlag, 0x7fffffff, 0x00000002, 0x7fffffff},
545 {NoFlag, 0xffffff83, 0xffff8003, 0xffffff83},
546 {NoFlag, 0xaaaaaaaa, 0xcccccccc, 0xaaaaaaaa},
547 {NoFlag, 0x0000007f, 0xffffff80, 0x0000007f},
548 {NoFlag, 0x80000001, 0x00007ffd, 0x80000001},
549 {NoFlag, 0xffff8000, 0x80000001, 0xffff8000},
550 {NoFlag, 0x00007fff, 0x00007ffd, 0x00007fff},
551 {NoFlag, 0x0000007e, 0x0000007f, 0x0000007e},
552 {NoFlag, 0x00000002, 0x0000007d, 0x00000002},
553 {NoFlag, 0x80000001, 0x7fffffff, 0x80000001},
554 {NoFlag, 0x0000007e, 0xffffff81, 0x0000007e},
555 {NoFlag, 0x7ffffffe, 0xffff8001, 0x7ffffffe},
556 {NoFlag, 0x7fffffff, 0x80000001, 0x7fffffff},
557 {NoFlag, 0x7ffffffd, 0x0000007f, 0x7ffffffd},
558 {NoFlag, 0xffffff81, 0xffffff81, 0xffffff81},
559 {NoFlag, 0x00000001, 0xfffffffd, 0x00000001},
560 {NoFlag, 0x00000001, 0xffffffff, 0x00000001},
561 {NoFlag, 0x7ffffffd, 0x55555555, 0x7ffffffd},
562 {NoFlag, 0x55555555, 0x0000007f, 0x55555555},
563 {NoFlag, 0x55555555, 0xffff8003, 0x55555555},
564 {NoFlag, 0xaaaaaaaa, 0x00007ffd, 0xaaaaaaaa},
565 {NoFlag, 0x0000007e, 0x33333333, 0x0000007e},
566 {NoFlag, 0xfffffffe, 0x80000001, 0xfffffffe},
567 {NoFlag, 0xfffffffe, 0xffff8000, 0xfffffffe},
568 {NoFlag, 0xffffffe0, 0xffffff81, 0xffffffe0},
569 {NoFlag, 0x7fffffff, 0x0000007f, 0x7fffffff},
570 {NoFlag, 0xffff8003, 0x0000007f, 0xffff8003},
571 {NoFlag, 0xffffff82, 0x00007ffd, 0xffffff82},
572 {NoFlag, 0x33333333, 0xffffffff, 0x33333333},
573 {NoFlag, 0xffffffe0, 0xcccccccc, 0xffffffe0},
574 {NoFlag, 0xffffff83, 0x7ffffffd, 0xffffff83},
575 {NoFlag, 0x0000007e, 0xcccccccc, 0x0000007e},
576 {NoFlag, 0x00000002, 0xfffffffd, 0x00000002},
577 {NoFlag, 0x00007fff, 0xcccccccc, 0x00007fff},
578 {NoFlag, 0x7fffffff, 0x00007fff, 0x7fffffff},
579 {NoFlag, 0xffffffe0, 0x33333333, 0xffffffe0},
580 {NoFlag, 0x0000007f, 0x0000007d, 0x0000007f},
581 {NoFlag, 0x0000007f, 0xffffffe0, 0x0000007f},
582 {NoFlag, 0x00007fff, 0xffff8000, 0x00007fff},
583 {NoFlag, 0x7fffffff, 0xffffffff, 0x7fffffff},
584 {NoFlag, 0xffff8000, 0x7ffffffd, 0xffff8000},
585 {NoFlag, 0xcccccccc, 0x0000007e, 0xcccccccc},
586 {NoFlag, 0x33333333, 0xffff8003, 0x33333333},
587 {NoFlag, 0x55555555, 0x00000002, 0x55555555},
588 {NoFlag, 0x00000001, 0x00000001, 0x00000001},
589 {NoFlag, 0xaaaaaaaa, 0x33333333, 0xaaaaaaaa},
590 {NoFlag, 0x7ffffffd, 0x00000001, 0x7ffffffd},
591 {NoFlag, 0xffffff82, 0xffff8000, 0xffffff82},
592 {NoFlag, 0x0000007d, 0x55555555, 0x0000007d},
593 {NoFlag, 0xffff8000, 0x7ffffffe, 0xffff8000},
594 {NoFlag, 0x7fffffff, 0xffffffe0, 0x7fffffff},
595 {NoFlag, 0x7fffffff, 0xffff8003, 0x7fffffff},
596 {NoFlag, 0xffffff82, 0xaaaaaaaa, 0xffffff82},
597 {NoFlag, 0xfffffffd, 0xffffff80, 0xfffffffd},
598 {NoFlag, 0x7ffffffd, 0x80000001, 0x7ffffffd},
599 {NoFlag, 0x00000000, 0x00007ffd, 0x00000000},
600 {NoFlag, 0xffffffff, 0xffffff80, 0xffffffff},
601 {NoFlag, 0xffffff80, 0xcccccccc, 0xffffff80},
602 {NoFlag, 0x00007ffe, 0x55555555, 0x00007ffe},
603 {NoFlag, 0xffff8000, 0xffff8000, 0xffff8000},
604 {NoFlag, 0xffffffff, 0xffff8000, 0xffffffff},
605 {NoFlag, 0x80000001, 0x0000007d, 0x80000001},
606 {NoFlag, 0xffffffe0, 0xffff8002, 0xffffffe0},
607 {NoFlag, 0xfffffffe, 0xffffffe0, 0xfffffffe},
608 {NoFlag, 0x80000000, 0xffff8003, 0x80000000},
609 {NoFlag, 0x80000001, 0xffffff81, 0x80000001},
610 {NoFlag, 0xffffffe0, 0x00007ffe, 0xffffffe0}};
611
612 static const Inputs kRdIsNotRnIsNotRm[] =
613 {{NoFlag, 0x0000007e, 0x0000007e, 0x0000007d},
614 {NoFlag, 0x55555555, 0x00000002, 0xffff8002},
615 {NoFlag, 0xffffffe0, 0x80000001, 0x00000000},
616 {NoFlag, 0x55555555, 0xffffff83, 0x00000002},
617 {NoFlag, 0xffffffe0, 0xffffffe0, 0x00000002},
618 {NoFlag, 0x00000000, 0x80000001, 0xffffff82},
619 {NoFlag, 0x80000001, 0x00007fff, 0x0000007f},
620 {NoFlag, 0xffffff80, 0x0000007d, 0x7ffffffe},
621 {NoFlag, 0xaaaaaaaa, 0x00000020, 0xffff8002},
622 {NoFlag, 0x33333333, 0x55555555, 0x00000001},
623 {NoFlag, 0x7ffffffe, 0x33333333, 0x00000000},
624 {NoFlag, 0x80000000, 0x7ffffffd, 0x55555555},
625 {NoFlag, 0xcccccccc, 0xffff8001, 0x7ffffffe},
626 {NoFlag, 0x00000020, 0xffffff83, 0xffff8003},
627 {NoFlag, 0x00007fff, 0xffffffe0, 0xffffff81},
628 {NoFlag, 0xffff8000, 0xffff8001, 0x0000007e},
629 {NoFlag, 0x33333333, 0x0000007e, 0x00000020},
630 {NoFlag, 0x0000007f, 0xfffffffd, 0xaaaaaaaa},
631 {NoFlag, 0xffffff83, 0xffffff82, 0x7ffffffd},
632 {NoFlag, 0x0000007e, 0xcccccccc, 0x7fffffff},
633 {NoFlag, 0xffff8001, 0x80000001, 0xffffffff},
634 {NoFlag, 0xffffff81, 0x00000020, 0x7ffffffe},
635 {NoFlag, 0xffffff83, 0xffffff81, 0xffffffe0},
636 {NoFlag, 0xffffffe0, 0xffffff81, 0xfffffffd},
637 {NoFlag, 0x80000001, 0xffffffff, 0xffffffff},
638 {NoFlag, 0x7ffffffe, 0xffff8000, 0xcccccccc},
639 {NoFlag, 0xffffff80, 0x00007ffe, 0xffffff82},
640 {NoFlag, 0x0000007e, 0x0000007d, 0xffff8003},
641 {NoFlag, 0xffff8002, 0xffffff81, 0x0000007e},
642 {NoFlag, 0x00007fff, 0x7ffffffd, 0xfffffffe},
643 {NoFlag, 0x00007ffe, 0x80000001, 0xffffff81},
644 {NoFlag, 0xffffff81, 0x00007ffd, 0xfffffffd},
645 {NoFlag, 0x00000020, 0x7fffffff, 0xffff8003},
646 {NoFlag, 0x0000007e, 0x0000007d, 0x33333333},
647 {NoFlag, 0xcccccccc, 0xffff8000, 0x00007ffe},
648 {NoFlag, 0x00007fff, 0xffff8000, 0x00000020},
649 {NoFlag, 0x00007ffd, 0x00007fff, 0xffffffe0},
650 {NoFlag, 0x7ffffffd, 0x00000000, 0x00007ffe},
651 {NoFlag, 0xffffff82, 0x33333333, 0x00000001},
652 {NoFlag, 0x7ffffffe, 0xffffff80, 0x00000020},
653 {NoFlag, 0x00007fff, 0xffffff83, 0x00007ffd},
654 {NoFlag, 0xffff8001, 0xffffffff, 0x80000001},
655 {NoFlag, 0x00000002, 0xffffff81, 0xcccccccc},
656 {NoFlag, 0x55555555, 0x0000007f, 0xffff8001},
657 {NoFlag, 0x80000000, 0x00000020, 0x80000000},
658 {NoFlag, 0xffffff83, 0x00007fff, 0xffffff80},
659 {NoFlag, 0x33333333, 0x7ffffffe, 0x7ffffffd},
660 {NoFlag, 0xffffff80, 0xffffffff, 0x00000001},
661 {NoFlag, 0x00007ffd, 0x7ffffffd, 0xffffff83},
662 {NoFlag, 0x33333333, 0xffff8001, 0xffffffe0},
663 {NoFlag, 0xffff8001, 0xffffff80, 0x00007ffd},
664 {NoFlag, 0xffffffe0, 0x00007fff, 0x00007ffe},
665 {NoFlag, 0x0000007d, 0x00000000, 0xffff8000},
666 {NoFlag, 0x7ffffffe, 0xaaaaaaaa, 0x7ffffffe},
667 {NoFlag, 0x0000007e, 0x00007ffd, 0xffffffe0},
668 {NoFlag, 0xfffffffd, 0xffffffe0, 0xffffff83},
669 {NoFlag, 0x00000001, 0xffffffe0, 0x7ffffffd},
670 {NoFlag, 0xfffffffd, 0xffff8002, 0x80000000},
671 {NoFlag, 0x00000020, 0xffffffff, 0x80000000},
672 {NoFlag, 0x00000001, 0x80000001, 0xffff8003},
673 {NoFlag, 0xffff8003, 0xaaaaaaaa, 0xffffff81},
674 {NoFlag, 0x0000007f, 0xfffffffd, 0xffffffe0},
675 {NoFlag, 0x00007ffe, 0xffffff80, 0x00007ffe},
676 {NoFlag, 0xffff8002, 0xffff8003, 0xffffffff},
677 {NoFlag, 0x7ffffffe, 0xffffff82, 0xffff8000},
678 {NoFlag, 0xffff8000, 0x00000002, 0x80000000},
679 {NoFlag, 0xffffff80, 0xffffff82, 0xffffff81},
680 {NoFlag, 0x00000000, 0xcccccccc, 0x00007ffd},
681 {NoFlag, 0x55555555, 0x00007ffe, 0x7fffffff},
682 {NoFlag, 0x00000002, 0xffffff81, 0xaaaaaaaa},
683 {NoFlag, 0x00007ffd, 0x0000007e, 0x00000002},
684 {NoFlag, 0xffffff83, 0x0000007e, 0xffffff80},
685 {NoFlag, 0xcccccccc, 0x00007ffe, 0xaaaaaaaa},
686 {NoFlag, 0x7ffffffe, 0x55555555, 0xffff8003},
687 {NoFlag, 0xfffffffd, 0x00000001, 0xffffff80},
688 {NoFlag, 0x00007ffd, 0x55555555, 0x80000001},
689 {NoFlag, 0x0000007f, 0x00000000, 0x0000007e},
690 {NoFlag, 0x7fffffff, 0xaaaaaaaa, 0x00000000},
691 {NoFlag, 0x7ffffffd, 0xffffff81, 0xcccccccc},
692 {NoFlag, 0xffffffe0, 0xcccccccc, 0xfffffffd},
693 {NoFlag, 0x00000002, 0xffff8000, 0x7ffffffd},
694 {NoFlag, 0xffffffe0, 0xffff8000, 0x80000001},
695 {NoFlag, 0x7ffffffd, 0xffff8003, 0xffff8001},
696 {NoFlag, 0x33333333, 0x00007ffd, 0x80000000},
697 {NoFlag, 0x7ffffffd, 0x00007fff, 0xcccccccc},
698 {NoFlag, 0xffffffff, 0xffffff80, 0x00007ffe},
699 {NoFlag, 0xffffff83, 0x7ffffffd, 0xaaaaaaaa},
700 {NoFlag, 0xfffffffd, 0xffff8003, 0x0000007f},
701 {NoFlag, 0xfffffffe, 0xfffffffe, 0xfffffffd},
702 {NoFlag, 0x00007fff, 0xfffffffe, 0x55555555},
703 {NoFlag, 0x7ffffffd, 0xfffffffe, 0xfffffffe},
704 {NoFlag, 0xfffffffe, 0xffffffff, 0x00007fff},
705 {NoFlag, 0x7ffffffd, 0x0000007e, 0x00007ffd},
706 {NoFlag, 0x7ffffffd, 0xffffffe0, 0x00000002},
707 {NoFlag, 0xffffffff, 0x00007ffd, 0xffffff81},
708 {NoFlag, 0xffff8001, 0x00000020, 0xfffffffd},
709 {NoFlag, 0x00007fff, 0x0000007d, 0xffffff83},
710 {NoFlag, 0x00000002, 0x55555555, 0x7ffffffe},
711 {NoFlag, 0x00007fff, 0x00007ffe, 0x00000002},
712 {NoFlag, 0x80000001, 0x7fffffff, 0x00007ffd},
713 {NoFlag, 0x0000007f, 0xffffffff, 0x00000001},
714 {NoFlag, 0xffff8001, 0x33333333, 0xffffff83},
715 {NoFlag, 0x00007fff, 0xcccccccc, 0x33333333},
716 {NoFlag, 0x33333333, 0xffffff80, 0x00000001},
717 {NoFlag, 0x00007fff, 0xcccccccc, 0x00007ffd},
718 {NoFlag, 0xffff8002, 0xfffffffd, 0x7ffffffe},
719 {NoFlag, 0x00007ffe, 0x7ffffffe, 0xffffff83},
720 {NoFlag, 0xffffffe0, 0x0000007f, 0xffff8001},
721 {NoFlag, 0x80000000, 0x00007fff, 0xffffff80},
722 {NoFlag, 0x7fffffff, 0x00007fff, 0x7ffffffe},
723 {NoFlag, 0xffff8002, 0x55555555, 0xffff8001},
724 {NoFlag, 0xffffff80, 0x00000000, 0xffffff80},
725 {NoFlag, 0x00007ffd, 0x00007fff, 0x00000002},
726 {NoFlag, 0x00000000, 0x55555555, 0xffff8003},
727 {NoFlag, 0x0000007f, 0xffff8003, 0x00000020},
728 {NoFlag, 0x00000000, 0xffff8002, 0x7fffffff},
729 {NoFlag, 0x00007fff, 0x55555555, 0x00000000},
730 {NoFlag, 0x7fffffff, 0x00007ffe, 0xffffff81},
731 {NoFlag, 0x0000007e, 0x80000001, 0x00007ffe},
732 {NoFlag, 0x7ffffffd, 0xaaaaaaaa, 0x00000020},
733 {NoFlag, 0xfffffffd, 0xfffffffe, 0x00000002},
734 {NoFlag, 0xffffff80, 0xffff8000, 0xffff8002},
735 {NoFlag, 0x0000007d, 0x00007fff, 0xaaaaaaaa},
736 {NoFlag, 0xfffffffd, 0xffffff80, 0x00007ffd},
737 {NoFlag, 0xffffff82, 0x80000000, 0xffffff80},
738 {NoFlag, 0xffffffe0, 0x55555555, 0xfffffffd},
739 {NoFlag, 0xffffffff, 0xffffffff, 0x00007ffd},
740 {NoFlag, 0x0000007e, 0xfffffffe, 0xffffff80},
741 {NoFlag, 0xffff8000, 0xffffff82, 0xffff8002},
742 {NoFlag, 0xaaaaaaaa, 0x7ffffffe, 0xffff8000},
743 {NoFlag, 0x55555555, 0xffff8003, 0xffffff80},
744 {NoFlag, 0x7ffffffe, 0x00000020, 0xffffffe0},
745 {NoFlag, 0x00000001, 0xffff8001, 0xffffffe0},
746 {NoFlag, 0xcccccccc, 0xffff8000, 0xffff8002},
747 {NoFlag, 0x80000000, 0x00000002, 0x7ffffffe},
748 {NoFlag, 0x00000002, 0x0000007f, 0xffffff81},
749 {NoFlag, 0xffffffff, 0x00000001, 0x7fffffff},
750 {NoFlag, 0xffffff83, 0x00000000, 0x33333333},
751 {NoFlag, 0xffff8000, 0xffffff83, 0xcccccccc},
752 {NoFlag, 0x80000000, 0x00000020, 0x00007ffd},
753 {NoFlag, 0xffffff81, 0xcccccccc, 0x00000000},
754 {NoFlag, 0xffffffff, 0xffff8000, 0x00007fff},
755 {NoFlag, 0xffff8003, 0xcccccccc, 0x00007ffe},
756 {NoFlag, 0xffffffff, 0xfffffffd, 0x7ffffffe},
757 {NoFlag, 0xffff8003, 0xaaaaaaaa, 0x55555555},
758 {NoFlag, 0x00000000, 0xaaaaaaaa, 0xffffff81},
759 {NoFlag, 0x0000007f, 0xfffffffe, 0xffff8000},
760 {NoFlag, 0x00000001, 0xffffffe0, 0xfffffffd},
761 {NoFlag, 0x33333333, 0x33333333, 0xfffffffd},
762 {NoFlag, 0xffffff82, 0xffff8002, 0x80000001},
763 {NoFlag, 0x55555555, 0xffffff83, 0xffffff83},
764 {NoFlag, 0xffffff83, 0xffff8002, 0x00000020},
765 {NoFlag, 0x0000007d, 0x7fffffff, 0x0000007f},
766 {NoFlag, 0x00000000, 0xcccccccc, 0xffff8000},
767 {NoFlag, 0x00000002, 0x7ffffffe, 0x00007fff},
768 {NoFlag, 0xffffff82, 0x7ffffffd, 0x7ffffffd},
769 {NoFlag, 0xaaaaaaaa, 0xfffffffd, 0xffff8002},
770 {NoFlag, 0xfffffffd, 0x00000002, 0x7fffffff},
771 {NoFlag, 0xfffffffe, 0xfffffffe, 0x00000020},
772 {NoFlag, 0x80000001, 0x0000007e, 0x00007ffe},
773 {NoFlag, 0x00007ffd, 0x00007ffd, 0xfffffffd},
774 {NoFlag, 0xffff8000, 0x0000007f, 0x00000002},
775 {NoFlag, 0x7ffffffd, 0x80000000, 0x7ffffffd},
776 {NoFlag, 0x0000007d, 0x00007fff, 0x80000001},
777 {NoFlag, 0xffffffff, 0x80000000, 0xaaaaaaaa},
778 {NoFlag, 0x00000000, 0xaaaaaaaa, 0xffff8001},
779 {NoFlag, 0xaaaaaaaa, 0xffffffe0, 0xffff8003},
780 {NoFlag, 0xffffff82, 0xffffffff, 0x00007ffd},
781 {NoFlag, 0x00000001, 0xffffff81, 0x00000001},
782 {NoFlag, 0x7fffffff, 0xaaaaaaaa, 0x80000001},
783 {NoFlag, 0x7fffffff, 0xffff8000, 0xffff8000},
784 {NoFlag, 0xaaaaaaaa, 0x00007ffd, 0xaaaaaaaa},
785 {NoFlag, 0x0000007f, 0x7ffffffe, 0x80000000},
786 {NoFlag, 0x00007ffd, 0x00007ffe, 0xffffff81},
787 {NoFlag, 0x0000007d, 0x0000007d, 0xffff8002},
788 {NoFlag, 0x80000001, 0x00000002, 0xffffff81},
789 {NoFlag, 0xffff8000, 0xfffffffd, 0x7ffffffd},
790 {NoFlag, 0xfffffffe, 0x00000020, 0xffffff80},
791 {NoFlag, 0x00000020, 0x7fffffff, 0xffffffe0},
792 {NoFlag, 0xffff8002, 0xffff8002, 0x0000007f},
793 {NoFlag, 0xffff8003, 0x7fffffff, 0xffff8002},
794 {NoFlag, 0x00000020, 0xfffffffd, 0x00000020},
795 {NoFlag, 0x7ffffffd, 0xffffffe0, 0x0000007e},
796 {NoFlag, 0x00000020, 0x00000020, 0x7ffffffe},
797 {NoFlag, 0xfffffffe, 0x0000007f, 0xffff8000},
798 {NoFlag, 0x80000001, 0x80000001, 0x0000007d},
799 {NoFlag, 0x55555555, 0x0000007f, 0x00007ffd},
800 {NoFlag, 0x55555555, 0xffffffe0, 0xffffff82},
801 {NoFlag, 0xffff8001, 0x0000007e, 0xffff8002},
802 {NoFlag, 0xffffffe0, 0x55555555, 0x0000007f},
803 {NoFlag, 0xffff8000, 0x7fffffff, 0x7ffffffe},
804 {NoFlag, 0xffffffff, 0xfffffffe, 0xffffff80},
805 {NoFlag, 0xffff8001, 0xffff8002, 0x33333333},
806 {NoFlag, 0x7ffffffd, 0xfffffffd, 0xaaaaaaaa},
807 {NoFlag, 0xaaaaaaaa, 0xfffffffd, 0x00000020},
808 {NoFlag, 0x0000007f, 0x00007ffe, 0x55555555},
809 {NoFlag, 0x00000020, 0x00000020, 0x00000002},
810 {NoFlag, 0x80000001, 0xffff8002, 0xfffffffe},
811 {NoFlag, 0x7fffffff, 0x80000001, 0xffff8002},
812 {NoFlag, 0x00000020, 0x0000007e, 0x33333333}};
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 {{al, r3, r3, r4},
892 "al r3 r3 r4",
893 "RdIsRn_al_r3_r3_r4",
894 ARRAY_SIZE(kRdIsRn),
895 kRdIsRn},
896 {{al, r2, r2, r12},
897 "al r2 r2 r12",
898 "RdIsRn_al_r2_r2_r12",
899 ARRAY_SIZE(kRdIsRn),
900 kRdIsRn},
901 {{al, r8, r8, r5},
902 "al r8 r8 r5",
903 "RdIsRn_al_r8_r8_r5",
904 ARRAY_SIZE(kRdIsRn),
905 kRdIsRn},
906 {{al, r14, r14, r0},
907 "al r14 r14 r0",
908 "RdIsRn_al_r14_r14_r0",
909 ARRAY_SIZE(kRdIsRn),
910 kRdIsRn},
911 {{al, r11, r11, r10},
912 "al r11 r11 r10",
913 "RdIsRn_al_r11_r11_r10",
914 ARRAY_SIZE(kRdIsRn),
915 kRdIsRn},
916 {{al, r12, r12, r10},
917 "al r12 r12 r10",
918 "RdIsRn_al_r12_r12_r10",
919 ARRAY_SIZE(kRdIsRn),
920 kRdIsRn},
921 {{al, r4, r4, r8},
922 "al r4 r4 r8",
923 "RdIsRn_al_r4_r4_r8",
924 ARRAY_SIZE(kRdIsRn),
925 kRdIsRn},
926 {{al, r5, r5, r14},
927 "al r5 r5 r14",
928 "RdIsRn_al_r5_r5_r14",
929 ARRAY_SIZE(kRdIsRn),
930 kRdIsRn},
931 {{al, r0, r0, r6},
932 "al r0 r0 r6",
933 "RdIsRn_al_r0_r0_r6",
934 ARRAY_SIZE(kRdIsRn),
935 kRdIsRn},
936 {{al, r12, r12, r1},
937 "al r12 r12 r1",
938 "RdIsRn_al_r12_r12_r1",
939 ARRAY_SIZE(kRdIsRn),
940 kRdIsRn},
941 {{al, r6, r11, r6},
942 "al r6 r11 r6",
943 "RdIsRm_al_r6_r11_r6",
944 ARRAY_SIZE(kRdIsRm),
945 kRdIsRm},
946 {{al, r11, r9, r11},
947 "al r11 r9 r11",
948 "RdIsRm_al_r11_r9_r11",
949 ARRAY_SIZE(kRdIsRm),
950 kRdIsRm},
951 {{al, r0, r8, r0},
952 "al r0 r8 r0",
953 "RdIsRm_al_r0_r8_r0",
954 ARRAY_SIZE(kRdIsRm),
955 kRdIsRm},
956 {{al, r2, r11, r2},
957 "al r2 r11 r2",
958 "RdIsRm_al_r2_r11_r2",
959 ARRAY_SIZE(kRdIsRm),
960 kRdIsRm},
961 {{al, r9, r4, r9},
962 "al r9 r4 r9",
963 "RdIsRm_al_r9_r4_r9",
964 ARRAY_SIZE(kRdIsRm),
965 kRdIsRm},
966 {{al, r14, r10, r14},
967 "al r14 r10 r14",
968 "RdIsRm_al_r14_r10_r14",
969 ARRAY_SIZE(kRdIsRm),
970 kRdIsRm},
971 {{al, r7, r0, r7},
972 "al r7 r0 r7",
973 "RdIsRm_al_r7_r0_r7",
974 ARRAY_SIZE(kRdIsRm),
975 kRdIsRm},
976 {{al, r4, r9, r4},
977 "al r4 r9 r4",
978 "RdIsRm_al_r4_r9_r4",
979 ARRAY_SIZE(kRdIsRm),
980 kRdIsRm},
981 {{al, r6, r10, r6},
982 "al r6 r10 r6",
983 "RdIsRm_al_r6_r10_r6",
984 ARRAY_SIZE(kRdIsRm),
985 kRdIsRm},
986 {{al, r7, r6, r7},
987 "al r7 r6 r7",
988 "RdIsRm_al_r7_r6_r7",
989 ARRAY_SIZE(kRdIsRm),
990 kRdIsRm},
991 {{al, r3, r9, r10},
992 "al r3 r9 r10",
993 "RdIsNotRnIsNotRm_al_r3_r9_r10",
994 ARRAY_SIZE(kRdIsNotRnIsNotRm),
995 kRdIsNotRnIsNotRm},
996 {{al, r7, r12, r5},
997 "al r7 r12 r5",
998 "RdIsNotRnIsNotRm_al_r7_r12_r5",
999 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1000 kRdIsNotRnIsNotRm},
1001 {{al, r8, r5, r6},
1002 "al r8 r5 r6",
1003 "RdIsNotRnIsNotRm_al_r8_r5_r6",
1004 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1005 kRdIsNotRnIsNotRm},
1006 {{al, r0, r6, r0},
1007 "al r0 r6 r0",
1008 "RdIsNotRnIsNotRm_al_r0_r6_r0",
1009 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1010 kRdIsNotRnIsNotRm},
1011 {{al, r11, r7, r8},
1012 "al r11 r7 r8",
1013 "RdIsNotRnIsNotRm_al_r11_r7_r8",
1014 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1015 kRdIsNotRnIsNotRm},
1016 {{al, r12, r2, r3},
1017 "al r12 r2 r3",
1018 "RdIsNotRnIsNotRm_al_r12_r2_r3",
1019 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1020 kRdIsNotRnIsNotRm},
1021 {{al, r7, r4, r10},
1022 "al r7 r4 r10",
1023 "RdIsNotRnIsNotRm_al_r7_r4_r10",
1024 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1025 kRdIsNotRnIsNotRm},
1026 {{al, r9, r6, r1},
1027 "al r9 r6 r1",
1028 "RdIsNotRnIsNotRm_al_r9_r6_r1",
1029 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1030 kRdIsNotRnIsNotRm},
1031 {{al, r10, r14, r3},
1032 "al r10 r14 r3",
1033 "RdIsNotRnIsNotRm_al_r10_r14_r3",
1034 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1035 kRdIsNotRnIsNotRm},
1036 {{al, r14, r3, r6},
1037 "al r14 r3 r6",
1038 "RdIsNotRnIsNotRm_al_r14_r3_r6",
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-a32.h"
1052 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-adcs-a32.h"
1053 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-add-a32.h"
1054 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-adds-a32.h"
1055 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-and-a32.h"
1056 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-ands-a32.h"
1057 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-asr-a32.h"
1058 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-asrs-a32.h"
1059 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-bic-a32.h"
1060 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-bics-a32.h"
1061 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-eor-a32.h"
1062 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-eors-a32.h"
1063 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-lsl-a32.h"
1064 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-lsls-a32.h"
1065 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-lsr-a32.h"
1066 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-lsrs-a32.h"
1067 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-orr-a32.h"
1068 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-orrs-a32.h"
1069 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-ror-a32.h"
1070 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-rors-a32.h"
1071 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-rsb-a32.h"
1072 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-rsbs-a32.h"
1073 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-rsc-a32.h"
1074 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-rscs-a32.h"
1075 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-sbc-a32.h"
1076 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-sbcs-a32.h"
1077 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-sub-a32.h"
1078 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-subs-a32.h"
1079 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-sxtab-a32.h"
1080 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-sxtab16-a32.h"
1081 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-sxtah-a32.h"
1082 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-uxtab-a32.h"
1083 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-uxtab16-a32.h"
1084 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-uxtah-a32.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.UseA32();
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 "_A32", \
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 "_A32", \
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