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