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(Mul)                       \
119   M(Muls)
120 
121 
122 // The following definitions are defined again in each generated test, therefore
123 // we need to place them in an anomymous namespace. It expresses that they are
124 // local to this file only, and the compiler is not allowed to share these types
125 // across test files during template instantiation. Specifically, `Operands` and
126 // `Inputs` have various layouts across generated tests so they absolutely
127 // cannot be shared.
128 
129 #ifdef VIXL_INCLUDE_TARGET_T32
130 namespace {
131 
132 // Values to be passed to the assembler to produce the instruction under test.
133 struct Operands {
134   Condition cond;
135   Register rd;
136   Register rn;
137   Register rm;
138 };
139 
140 // Input data to feed to the instruction.
141 struct Inputs {
142   uint32_t apsr;
143   uint32_t rd;
144   uint32_t rn;
145   uint32_t rm;
146 };
147 
148 // This structure contains all input data needed to test one specific encoding.
149 // It used to generate a loop over an instruction.
150 struct TestLoopData {
151   // The `operands` fields represents the values to pass to the assembler to
152   // produce the instruction.
153   Operands operands;
154   // Description of the operands, used for error reporting.
155   const char* operands_description;
156   // Unique identifier, used for generating traces.
157   const char* identifier;
158   // Array of values to be fed to the instruction.
159   size_t input_size;
160   const Inputs* inputs;
161 };
162 
163 static const Inputs kCondition[] =
164     {{NFlag, 0xabababab, 0xabababab, 0xabababab},
165      {ZFlag, 0xabababab, 0xabababab, 0xabababab},
166      {CFlag, 0xabababab, 0xabababab, 0xabababab},
167      {VFlag, 0xabababab, 0xabababab, 0xabababab},
168      {NZFlag, 0xabababab, 0xabababab, 0xabababab},
169      {NCFlag, 0xabababab, 0xabababab, 0xabababab},
170      {NVFlag, 0xabababab, 0xabababab, 0xabababab},
171      {ZCFlag, 0xabababab, 0xabababab, 0xabababab},
172      {ZVFlag, 0xabababab, 0xabababab, 0xabababab},
173      {CVFlag, 0xabababab, 0xabababab, 0xabababab},
174      {NZCFlag, 0xabababab, 0xabababab, 0xabababab},
175      {NZVFlag, 0xabababab, 0xabababab, 0xabababab},
176      {NCVFlag, 0xabababab, 0xabababab, 0xabababab},
177      {ZCVFlag, 0xabababab, 0xabababab, 0xabababab},
178      {NZCVFlag, 0xabababab, 0xabababab, 0xabababab}};
179 
180 static const Inputs kUnconditional[] =
181     {{NoFlag, 0x7ffffffe, 0xffffff81, 0x7ffffffe},
182      {NoFlag, 0xfffffffd, 0x00000000, 0xfffffffd},
183      {NoFlag, 0xfffffffe, 0x33333333, 0xfffffffe},
184      {NoFlag, 0x0000007e, 0x7fffffff, 0x0000007e},
185      {NoFlag, 0xffffffff, 0x7fffffff, 0xffffffff},
186      {NoFlag, 0x00000020, 0x7ffffffe, 0x00000020},
187      {NoFlag, 0x00000020, 0xffffff83, 0x00000020},
188      {NoFlag, 0x0000007e, 0xffffff80, 0x0000007e},
189      {NoFlag, 0x0000007f, 0xffff8003, 0x0000007f},
190      {NoFlag, 0xffffffe0, 0xffff8000, 0xffffffe0},
191      {NoFlag, 0xfffffffe, 0x00000020, 0xfffffffe},
192      {NoFlag, 0x00000001, 0xffff8003, 0x00000001},
193      {NoFlag, 0x55555555, 0x0000007d, 0x55555555},
194      {NoFlag, 0x00000001, 0x0000007f, 0x00000001},
195      {NoFlag, 0x0000007f, 0xffffffff, 0x0000007f},
196      {NoFlag, 0x00007ffe, 0xffffff80, 0x00007ffe},
197      {NoFlag, 0xfffffffd, 0x00007ffe, 0xfffffffd},
198      {NoFlag, 0xfffffffe, 0xffffffe0, 0xfffffffe},
199      {NoFlag, 0x00000020, 0x00007fff, 0x00000020},
200      {NoFlag, 0x80000000, 0xffffff83, 0x80000000},
201      {NoFlag, 0xfffffffe, 0xffffff83, 0xfffffffe},
202      {NoFlag, 0x80000000, 0x00007ffe, 0x80000000},
203      {NoFlag, 0x55555555, 0x00000020, 0x55555555},
204      {NoFlag, 0x00000001, 0x33333333, 0x00000001},
205      {NoFlag, 0xffff8001, 0x7ffffffe, 0xffff8001},
206      {NoFlag, 0xffffffff, 0xffff8000, 0xffffffff},
207      {NoFlag, 0xaaaaaaaa, 0x7ffffffe, 0xaaaaaaaa},
208      {NoFlag, 0x00000000, 0x7ffffffd, 0x00000000},
209      {NoFlag, 0x55555555, 0x00000002, 0x55555555},
210      {NoFlag, 0xffff8002, 0xffffff82, 0xffff8002},
211      {NoFlag, 0xcccccccc, 0x33333333, 0xcccccccc},
212      {NoFlag, 0x7ffffffd, 0xffffff83, 0x7ffffffd},
213      {NoFlag, 0x00000002, 0xaaaaaaaa, 0x00000002},
214      {NoFlag, 0xffffffe0, 0xcccccccc, 0xffffffe0},
215      {NoFlag, 0x00000000, 0x33333333, 0x00000000},
216      {NoFlag, 0xfffffffe, 0xffff8000, 0xfffffffe},
217      {NoFlag, 0x00000020, 0x7ffffffd, 0x00000020},
218      {NoFlag, 0x80000001, 0xffffffff, 0x80000001},
219      {NoFlag, 0x00000020, 0x0000007e, 0x00000020},
220      {NoFlag, 0x0000007f, 0x55555555, 0x0000007f},
221      {NoFlag, 0x00000020, 0x00000020, 0x00000020},
222      {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0xaaaaaaaa},
223      {NoFlag, 0x0000007d, 0xffffff81, 0x0000007d},
224      {NoFlag, 0x80000001, 0x7fffffff, 0x80000001},
225      {NoFlag, 0xffffff82, 0xaaaaaaaa, 0xffffff82},
226      {NoFlag, 0x80000001, 0xffffff81, 0x80000001},
227      {NoFlag, 0xffff8000, 0xffffff81, 0xffff8000},
228      {NoFlag, 0xffff8003, 0xffffffe0, 0xffff8003},
229      {NoFlag, 0x7fffffff, 0x7fffffff, 0x7fffffff},
230      {NoFlag, 0x0000007d, 0xffff8003, 0x0000007d},
231      {NoFlag, 0xffffff81, 0xffffff81, 0xffffff81},
232      {NoFlag, 0xffffffff, 0x80000001, 0xffffffff},
233      {NoFlag, 0x33333333, 0x00000020, 0x33333333},
234      {NoFlag, 0x00000001, 0xfffffffd, 0x00000001},
235      {NoFlag, 0xffff8001, 0xffffff81, 0xffff8001},
236      {NoFlag, 0xffffff83, 0xffff8002, 0xffffff83},
237      {NoFlag, 0xffff8001, 0xfffffffd, 0xffff8001},
238      {NoFlag, 0x0000007f, 0x00007ffd, 0x0000007f},
239      {NoFlag, 0x0000007e, 0x7ffffffe, 0x0000007e},
240      {NoFlag, 0xffff8002, 0x33333333, 0xffff8002},
241      {NoFlag, 0xffff8001, 0x00000020, 0xffff8001},
242      {NoFlag, 0xffffffe0, 0x80000000, 0xffffffe0},
243      {NoFlag, 0xffffff80, 0xfffffffe, 0xffffff80},
244      {NoFlag, 0xaaaaaaaa, 0x00000002, 0xaaaaaaaa},
245      {NoFlag, 0x00007ffd, 0xffff8001, 0x00007ffd},
246      {NoFlag, 0xffffff83, 0x7ffffffd, 0xffffff83},
247      {NoFlag, 0x0000007d, 0x7ffffffe, 0x0000007d},
248      {NoFlag, 0xfffffffe, 0x7fffffff, 0xfffffffe},
249      {NoFlag, 0x0000007f, 0xffffff82, 0x0000007f},
250      {NoFlag, 0xcccccccc, 0x0000007f, 0xcccccccc},
251      {NoFlag, 0xffffff81, 0xcccccccc, 0xffffff81},
252      {NoFlag, 0xffffff81, 0x7ffffffd, 0xffffff81},
253      {NoFlag, 0x0000007e, 0xcccccccc, 0x0000007e},
254      {NoFlag, 0xcccccccc, 0x00000000, 0xcccccccc},
255      {NoFlag, 0xffffffe0, 0x00000001, 0xffffffe0},
256      {NoFlag, 0x00007ffd, 0xffffff82, 0x00007ffd},
257      {NoFlag, 0x00000020, 0x00000002, 0x00000020},
258      {NoFlag, 0xffff8000, 0xffffffe0, 0xffff8000},
259      {NoFlag, 0x7fffffff, 0xaaaaaaaa, 0x7fffffff},
260      {NoFlag, 0x7fffffff, 0xfffffffd, 0x7fffffff},
261      {NoFlag, 0x0000007d, 0x0000007e, 0x0000007d},
262      {NoFlag, 0xcccccccc, 0xffff8001, 0xcccccccc},
263      {NoFlag, 0xffffffff, 0xffff8001, 0xffffffff},
264      {NoFlag, 0x33333333, 0x0000007f, 0x33333333},
265      {NoFlag, 0x0000007d, 0x00000020, 0x0000007d},
266      {NoFlag, 0x7ffffffd, 0x00007ffd, 0x7ffffffd},
267      {NoFlag, 0x7ffffffd, 0xfffffffe, 0x7ffffffd},
268      {NoFlag, 0xffffffe0, 0x33333333, 0xffffffe0},
269      {NoFlag, 0x00007ffe, 0xffffff83, 0x00007ffe},
270      {NoFlag, 0x7fffffff, 0xffffff80, 0x7fffffff},
271      {NoFlag, 0xffffff81, 0x80000000, 0xffffff81},
272      {NoFlag, 0x0000007f, 0xaaaaaaaa, 0x0000007f},
273      {NoFlag, 0xcccccccc, 0x55555555, 0xcccccccc},
274      {NoFlag, 0x00000000, 0xfffffffd, 0x00000000},
275      {NoFlag, 0xffffff81, 0xffffffe0, 0xffffff81},
276      {NoFlag, 0x7ffffffd, 0xffffff80, 0x7ffffffd},
277      {NoFlag, 0x80000001, 0xffffff83, 0x80000001},
278      {NoFlag, 0x00000002, 0xffffff81, 0x00000002},
279      {NoFlag, 0xffffff80, 0xffffff80, 0xffffff80},
280      {NoFlag, 0x0000007f, 0x00007ffe, 0x0000007f},
281      {NoFlag, 0x80000000, 0xffffff81, 0x80000000},
282      {NoFlag, 0xffff8003, 0xfffffffe, 0xffff8003},
283      {NoFlag, 0xffffff80, 0xffff8002, 0xffffff80},
284      {NoFlag, 0x0000007f, 0x00000002, 0x0000007f},
285      {NoFlag, 0x7ffffffd, 0xffff8000, 0x7ffffffd},
286      {NoFlag, 0x00007ffd, 0x55555555, 0x00007ffd},
287      {NoFlag, 0xffffffff, 0x7ffffffd, 0xffffffff},
288      {NoFlag, 0xffff8001, 0x00000002, 0xffff8001},
289      {NoFlag, 0x7fffffff, 0x0000007f, 0x7fffffff},
290      {NoFlag, 0xffffffe0, 0x7fffffff, 0xffffffe0},
291      {NoFlag, 0xffffff80, 0x0000007d, 0xffffff80},
292      {NoFlag, 0xffffffff, 0xffffff80, 0xffffffff},
293      {NoFlag, 0x55555555, 0xffffffe0, 0x55555555},
294      {NoFlag, 0x00000020, 0xfffffffe, 0x00000020},
295      {NoFlag, 0x00007ffe, 0x00000020, 0x00007ffe},
296      {NoFlag, 0x55555555, 0x00007ffd, 0x55555555},
297      {NoFlag, 0xffffff81, 0xffff8002, 0xffffff81},
298      {NoFlag, 0x80000000, 0xffffffe0, 0x80000000},
299      {NoFlag, 0x0000007f, 0xffffff83, 0x0000007f},
300      {NoFlag, 0xffff8000, 0x00000000, 0xffff8000},
301      {NoFlag, 0x00000002, 0xffffff80, 0x00000002},
302      {NoFlag, 0x7fffffff, 0xffff8001, 0x7fffffff},
303      {NoFlag, 0xffffff82, 0x00000000, 0xffffff82},
304      {NoFlag, 0x55555555, 0xfffffffe, 0x55555555},
305      {NoFlag, 0x00007fff, 0xffffff83, 0x00007fff},
306      {NoFlag, 0x00007fff, 0xffffff82, 0x00007fff},
307      {NoFlag, 0x0000007e, 0x00007ffe, 0x0000007e},
308      {NoFlag, 0x00000001, 0xffffff81, 0x00000001},
309      {NoFlag, 0xffff8003, 0xfffffffd, 0xffff8003},
310      {NoFlag, 0xaaaaaaaa, 0x00007fff, 0xaaaaaaaa},
311      {NoFlag, 0x00000020, 0xfffffffd, 0x00000020},
312      {NoFlag, 0xffffff83, 0x00007ffd, 0xffffff83},
313      {NoFlag, 0x00007ffd, 0x00007ffd, 0x00007ffd},
314      {NoFlag, 0xfffffffd, 0x00000020, 0xfffffffd},
315      {NoFlag, 0xffffff81, 0x33333333, 0xffffff81},
316      {NoFlag, 0x00007ffe, 0x0000007e, 0x00007ffe},
317      {NoFlag, 0xffffffff, 0x00007ffe, 0xffffffff},
318      {NoFlag, 0xffffff82, 0x00000002, 0xffffff82},
319      {NoFlag, 0x0000007f, 0xffff8002, 0x0000007f},
320      {NoFlag, 0xfffffffe, 0x00007ffd, 0xfffffffe},
321      {NoFlag, 0xffff8001, 0xffff8000, 0xffff8001},
322      {NoFlag, 0x55555555, 0xffffffff, 0x55555555},
323      {NoFlag, 0xffff8002, 0x00000020, 0xffff8002},
324      {NoFlag, 0xffffff81, 0xffffff80, 0xffffff81},
325      {NoFlag, 0x80000000, 0x7fffffff, 0x80000000},
326      {NoFlag, 0x0000007e, 0x33333333, 0x0000007e},
327      {NoFlag, 0x0000007d, 0x00007ffe, 0x0000007d},
328      {NoFlag, 0x00000020, 0xffff8003, 0x00000020},
329      {NoFlag, 0xffffff81, 0x00000020, 0xffffff81},
330      {NoFlag, 0x00007ffd, 0x00007fff, 0x00007ffd},
331      {NoFlag, 0xfffffffd, 0x0000007f, 0xfffffffd},
332      {NoFlag, 0xffff8000, 0xffff8001, 0xffff8000},
333      {NoFlag, 0xffff8003, 0x55555555, 0xffff8003},
334      {NoFlag, 0x00000020, 0x00000001, 0x00000020},
335      {NoFlag, 0x00000002, 0x7ffffffe, 0x00000002},
336      {NoFlag, 0xffff8001, 0xffffffff, 0xffff8001},
337      {NoFlag, 0xfffffffd, 0xcccccccc, 0xfffffffd},
338      {NoFlag, 0xffff8001, 0xffff8001, 0xffff8001},
339      {NoFlag, 0x80000001, 0x80000000, 0x80000001},
340      {NoFlag, 0x80000000, 0x80000001, 0x80000000},
341      {NoFlag, 0xfffffffe, 0x0000007d, 0xfffffffe},
342      {NoFlag, 0x7ffffffd, 0x55555555, 0x7ffffffd},
343      {NoFlag, 0xffff8002, 0x00007ffd, 0xffff8002},
344      {NoFlag, 0xffff8002, 0xfffffffe, 0xffff8002},
345      {NoFlag, 0xfffffffd, 0xffff8000, 0xfffffffd},
346      {NoFlag, 0x33333333, 0xcccccccc, 0x33333333},
347      {NoFlag, 0x0000007e, 0x00000000, 0x0000007e},
348      {NoFlag, 0xaaaaaaaa, 0xcccccccc, 0xaaaaaaaa},
349      {NoFlag, 0x00000001, 0x80000000, 0x00000001},
350      {NoFlag, 0x00000001, 0x7ffffffd, 0x00000001},
351      {NoFlag, 0x7ffffffd, 0xcccccccc, 0x7ffffffd},
352      {NoFlag, 0x80000000, 0x00000000, 0x80000000},
353      {NoFlag, 0xaaaaaaaa, 0x00000020, 0xaaaaaaaa},
354      {NoFlag, 0x0000007e, 0xffff8001, 0x0000007e},
355      {NoFlag, 0x80000000, 0x00000020, 0x80000000},
356      {NoFlag, 0x7ffffffd, 0x7ffffffd, 0x7ffffffd},
357      {NoFlag, 0x00000002, 0x00000020, 0x00000002},
358      {NoFlag, 0x7ffffffe, 0xffff8003, 0x7ffffffe},
359      {NoFlag, 0x55555555, 0xaaaaaaaa, 0x55555555},
360      {NoFlag, 0xfffffffe, 0xfffffffe, 0xfffffffe},
361      {NoFlag, 0x7ffffffd, 0x00007fff, 0x7ffffffd},
362      {NoFlag, 0xffffff81, 0x0000007f, 0xffffff81},
363      {NoFlag, 0xffff8003, 0x00000002, 0xffff8003},
364      {NoFlag, 0xcccccccc, 0xfffffffe, 0xcccccccc},
365      {NoFlag, 0xcccccccc, 0xaaaaaaaa, 0xcccccccc},
366      {NoFlag, 0xffffff81, 0x00000002, 0xffffff81},
367      {NoFlag, 0xffffff81, 0xfffffffd, 0xffffff81},
368      {NoFlag, 0x00007fff, 0xffffffe0, 0x00007fff},
369      {NoFlag, 0x55555555, 0x80000000, 0x55555555},
370      {NoFlag, 0x00007fff, 0x80000000, 0x00007fff},
371      {NoFlag, 0xffffff80, 0x7fffffff, 0xffffff80},
372      {NoFlag, 0xffffffff, 0xffffff82, 0xffffffff},
373      {NoFlag, 0xcccccccc, 0xcccccccc, 0xcccccccc},
374      {NoFlag, 0xffff8003, 0xffff8001, 0xffff8003},
375      {NoFlag, 0x00007ffe, 0x00007ffd, 0x00007ffe},
376      {NoFlag, 0x00000000, 0x00007ffd, 0x00000000},
377      {NoFlag, 0x7fffffff, 0x00000002, 0x7fffffff},
378      {NoFlag, 0x33333333, 0xffff8003, 0x33333333},
379      {NoFlag, 0xffffff81, 0x00000001, 0xffffff81},
380      {NoFlag, 0xffff8002, 0x80000001, 0xffff8002},
381      {NoFlag, 0x00007ffe, 0xffffffff, 0x00007ffe},
382      {NoFlag, 0xffffff82, 0x80000001, 0xffffff82},
383      {NoFlag, 0x80000000, 0x55555555, 0x80000000},
384      {NoFlag, 0x00007ffd, 0xffff8000, 0x00007ffd},
385      {NoFlag, 0x00000000, 0x0000007d, 0x00000000},
386      {NoFlag, 0x00000001, 0xffffff83, 0x00000001},
387      {NoFlag, 0x0000007f, 0x0000007f, 0x0000007f},
388      {NoFlag, 0x0000007f, 0x00000020, 0x0000007f},
389      {NoFlag, 0x7ffffffd, 0x00000020, 0x7ffffffd},
390      {NoFlag, 0x00007ffe, 0x00000001, 0x00007ffe},
391      {NoFlag, 0x80000001, 0x55555555, 0x80000001},
392      {NoFlag, 0xaaaaaaaa, 0x7ffffffd, 0xaaaaaaaa},
393      {NoFlag, 0xffffff81, 0x0000007e, 0xffffff81},
394      {NoFlag, 0xffffffff, 0xffff8002, 0xffffffff},
395      {NoFlag, 0x00007fff, 0xffff8000, 0x00007fff},
396      {NoFlag, 0x80000000, 0x00007fff, 0x80000000},
397      {NoFlag, 0xcccccccc, 0x7ffffffe, 0xcccccccc},
398      {NoFlag, 0x7ffffffe, 0xffffff80, 0x7ffffffe},
399      {NoFlag, 0x00007ffe, 0xffff8000, 0x00007ffe},
400      {NoFlag, 0x33333333, 0x80000001, 0x33333333},
401      {NoFlag, 0x00007fff, 0x7ffffffe, 0x00007fff},
402      {NoFlag, 0x7fffffff, 0xffffffff, 0x7fffffff},
403      {NoFlag, 0xffffffe0, 0x00000020, 0xffffffe0},
404      {NoFlag, 0xffff8000, 0x80000000, 0xffff8000},
405      {NoFlag, 0x7fffffff, 0xffffff81, 0x7fffffff},
406      {NoFlag, 0x00007ffd, 0xffffffe0, 0x00007ffd},
407      {NoFlag, 0x00000001, 0xaaaaaaaa, 0x00000001},
408      {NoFlag, 0x80000001, 0x7ffffffe, 0x80000001},
409      {NoFlag, 0x00000020, 0x00007ffd, 0x00000020},
410      {NoFlag, 0xaaaaaaaa, 0xffffff82, 0xaaaaaaaa},
411      {NoFlag, 0xffffff81, 0x55555555, 0xffffff81},
412      {NoFlag, 0x7ffffffe, 0xffff8000, 0x7ffffffe},
413      {NoFlag, 0xffffff82, 0x0000007f, 0xffffff82},
414      {NoFlag, 0xffff8002, 0xcccccccc, 0xffff8002},
415      {NoFlag, 0xaaaaaaaa, 0xffff8002, 0xaaaaaaaa},
416      {NoFlag, 0x7ffffffe, 0x55555555, 0x7ffffffe},
417      {NoFlag, 0x7ffffffe, 0x80000001, 0x7ffffffe},
418      {NoFlag, 0xaaaaaaaa, 0xffff8000, 0xaaaaaaaa},
419      {NoFlag, 0xffffff82, 0xffff8002, 0xffffff82},
420      {NoFlag, 0xffffffe0, 0xffffff80, 0xffffffe0},
421      {NoFlag, 0x80000000, 0x00000001, 0x80000000},
422      {NoFlag, 0x0000007f, 0x00000001, 0x0000007f},
423      {NoFlag, 0xffff8000, 0xffff8002, 0xffff8000},
424      {NoFlag, 0x00000001, 0x0000007e, 0x00000001},
425      {NoFlag, 0xffffff83, 0x7fffffff, 0xffffff83},
426      {NoFlag, 0xffffffff, 0xcccccccc, 0xffffffff},
427      {NoFlag, 0xffff8003, 0x00000001, 0xffff8003},
428      {NoFlag, 0x0000007f, 0xcccccccc, 0x0000007f},
429      {NoFlag, 0x00000001, 0xffff8000, 0x00000001},
430      {NoFlag, 0x00007fff, 0xffffff80, 0x00007fff},
431      {NoFlag, 0xffffffff, 0x7ffffffe, 0xffffffff},
432      {NoFlag, 0xffffff83, 0x0000007e, 0xffffff83},
433      {NoFlag, 0xffffff81, 0xffff8001, 0xffffff81},
434      {NoFlag, 0x00007fff, 0xffffffff, 0x00007fff},
435      {NoFlag, 0x00007ffd, 0xffffffff, 0x00007ffd},
436      {NoFlag, 0xffff8003, 0x0000007e, 0xffff8003},
437      {NoFlag, 0xffffffe0, 0xfffffffe, 0xffffffe0},
438      {NoFlag, 0xffffff81, 0xffff8003, 0xffffff81},
439      {NoFlag, 0xfffffffd, 0x7fffffff, 0xfffffffd},
440      {NoFlag, 0x00000002, 0x00000002, 0x00000002},
441      {NoFlag, 0x00007fff, 0x00000001, 0x00007fff},
442      {NoFlag, 0x7ffffffd, 0x80000000, 0x7ffffffd},
443      {NoFlag, 0xffff8002, 0x00000001, 0xffff8002},
444      {NoFlag, 0x00000002, 0xffff8000, 0x00000002},
445      {NoFlag, 0xffff8001, 0x55555555, 0xffff8001},
446      {NoFlag, 0xffff8001, 0xfffffffe, 0xffff8001},
447      {NoFlag, 0x7ffffffd, 0x00000001, 0x7ffffffd},
448      {NoFlag, 0x7ffffffd, 0x00000000, 0x7ffffffd},
449      {NoFlag, 0xffff8003, 0x00000000, 0xffff8003},
450      {NoFlag, 0xffffff80, 0x00000020, 0xffffff80},
451      {NoFlag, 0xffff8000, 0x7fffffff, 0xffff8000},
452      {NoFlag, 0xffffff80, 0xffff8003, 0xffffff80},
453      {NoFlag, 0x55555555, 0xffff8001, 0x55555555},
454      {NoFlag, 0x00007ffd, 0x00000000, 0x00007ffd},
455      {NoFlag, 0xcccccccc, 0xffffff83, 0xcccccccc},
456      {NoFlag, 0x7ffffffd, 0x0000007f, 0x7ffffffd},
457      {NoFlag, 0x33333333, 0x00007fff, 0x33333333},
458      {NoFlag, 0xffffff83, 0xcccccccc, 0xffffff83},
459      {NoFlag, 0xffff8002, 0x00000000, 0xffff8002},
460      {NoFlag, 0x33333333, 0xffffffff, 0x33333333},
461      {NoFlag, 0xfffffffd, 0x80000001, 0xfffffffd},
462      {NoFlag, 0xffffff81, 0x00007fff, 0xffffff81},
463      {NoFlag, 0x7ffffffe, 0x0000007f, 0x7ffffffe},
464      {NoFlag, 0x7fffffff, 0xcccccccc, 0x7fffffff},
465      {NoFlag, 0x0000007f, 0x80000001, 0x0000007f},
466      {NoFlag, 0x00007fff, 0x00000020, 0x00007fff},
467      {NoFlag, 0xffffff81, 0x7ffffffe, 0xffffff81},
468      {NoFlag, 0xffffff83, 0x80000000, 0xffffff83},
469      {NoFlag, 0x0000007e, 0xaaaaaaaa, 0x0000007e},
470      {NoFlag, 0xffffff80, 0xffffff82, 0xffffff80},
471      {NoFlag, 0xffffff81, 0xfffffffe, 0xffffff81},
472      {NoFlag, 0x0000007e, 0x00000020, 0x0000007e},
473      {NoFlag, 0x7ffffffd, 0x00007ffe, 0x7ffffffd},
474      {NoFlag, 0x7ffffffe, 0x80000000, 0x7ffffffe},
475      {NoFlag, 0xfffffffd, 0x0000007e, 0xfffffffd},
476      {NoFlag, 0x00000000, 0x0000007f, 0x00000000},
477      {NoFlag, 0xffff8000, 0x0000007e, 0xffff8000},
478      {NoFlag, 0x7ffffffe, 0x00000000, 0x7ffffffe},
479      {NoFlag, 0xffffff80, 0x80000000, 0xffffff80},
480      {NoFlag, 0x7fffffff, 0x0000007e, 0x7fffffff},
481      {NoFlag, 0x80000001, 0x80000001, 0x80000001},
482      {NoFlag, 0xfffffffd, 0x0000007d, 0xfffffffd},
483      {NoFlag, 0xffff8003, 0x00007ffe, 0xffff8003},
484      {NoFlag, 0xcccccccc, 0x00007ffd, 0xcccccccc},
485      {NoFlag, 0x33333333, 0x55555555, 0x33333333},
486      {NoFlag, 0x7fffffff, 0x00000001, 0x7fffffff},
487      {NoFlag, 0xfffffffe, 0xffffff80, 0xfffffffe},
488      {NoFlag, 0xffffff83, 0xffffffff, 0xffffff83},
489      {NoFlag, 0x00007ffe, 0x7ffffffe, 0x00007ffe},
490      {NoFlag, 0xffff8001, 0x7fffffff, 0xffff8001},
491      {NoFlag, 0x00000001, 0x00000002, 0x00000001},
492      {NoFlag, 0xffffff80, 0x55555555, 0xffffff80},
493      {NoFlag, 0xffffff81, 0x00000000, 0xffffff81},
494      {NoFlag, 0xffff8003, 0xffffff81, 0xffff8003},
495      {NoFlag, 0x00000002, 0x7fffffff, 0x00000002},
496      {NoFlag, 0xffff8000, 0x7ffffffd, 0xffff8000},
497      {NoFlag, 0x80000001, 0xfffffffd, 0x80000001},
498      {NoFlag, 0x00000001, 0x7ffffffe, 0x00000001},
499      {NoFlag, 0x0000007e, 0x7ffffffd, 0x0000007e},
500      {NoFlag, 0x7ffffffe, 0x7ffffffe, 0x7ffffffe},
501      {NoFlag, 0xffffffff, 0xfffffffd, 0xffffffff},
502      {NoFlag, 0x0000007e, 0x00000002, 0x0000007e},
503      {NoFlag, 0x00000000, 0xffff8001, 0x00000000},
504      {NoFlag, 0xffffff82, 0x7ffffffd, 0xffffff82},
505      {NoFlag, 0x00000002, 0xffffff83, 0x00000002},
506      {NoFlag, 0x00000001, 0xcccccccc, 0x00000001},
507      {NoFlag, 0xfffffffd, 0xffffffff, 0xfffffffd},
508      {NoFlag, 0x0000007e, 0xffff8003, 0x0000007e},
509      {NoFlag, 0x55555555, 0x80000001, 0x55555555},
510      {NoFlag, 0xffffff83, 0x00007ffe, 0xffffff83},
511      {NoFlag, 0x00000020, 0xffffff80, 0x00000020},
512      {NoFlag, 0x7ffffffe, 0xfffffffe, 0x7ffffffe},
513      {NoFlag, 0x00000020, 0xffffff81, 0x00000020},
514      {NoFlag, 0x7ffffffe, 0x7ffffffd, 0x7ffffffe},
515      {NoFlag, 0x7ffffffd, 0xffff8002, 0x7ffffffd},
516      {NoFlag, 0x80000000, 0xaaaaaaaa, 0x80000000},
517      {NoFlag, 0xfffffffe, 0x80000001, 0xfffffffe},
518      {NoFlag, 0xcccccccc, 0x7fffffff, 0xcccccccc},
519      {NoFlag, 0xffff8003, 0xffff8000, 0xffff8003},
520      {NoFlag, 0xffffff83, 0xffff8003, 0xffffff83},
521      {NoFlag, 0x00007ffd, 0x33333333, 0x00007ffd},
522      {NoFlag, 0xffff8002, 0xaaaaaaaa, 0xffff8002},
523      {NoFlag, 0x00007ffd, 0x00007ffe, 0x00007ffd},
524      {NoFlag, 0x7fffffff, 0x00007ffe, 0x7fffffff},
525      {NoFlag, 0xffff8003, 0x80000000, 0xffff8003},
526      {NoFlag, 0xffffffff, 0xffffff83, 0xffffffff},
527      {NoFlag, 0xffff8003, 0x0000007f, 0xffff8003},
528      {NoFlag, 0xaaaaaaaa, 0x00000001, 0xaaaaaaaa},
529      {NoFlag, 0x00000020, 0x7fffffff, 0x00000020},
530      {NoFlag, 0xcccccccc, 0x00007fff, 0xcccccccc},
531      {NoFlag, 0x00000002, 0x00000000, 0x00000002},
532      {NoFlag, 0x33333333, 0x00007ffd, 0x33333333},
533      {NoFlag, 0x7fffffff, 0x33333333, 0x7fffffff},
534      {NoFlag, 0x00000000, 0xffffff81, 0x00000000},
535      {NoFlag, 0x00007ffd, 0xffffff83, 0x00007ffd},
536      {NoFlag, 0x80000000, 0xffffffff, 0x80000000},
537      {NoFlag, 0x00000002, 0x80000001, 0x00000002},
538      {NoFlag, 0x80000000, 0x7ffffffd, 0x80000000},
539      {NoFlag, 0x00007ffd, 0x80000001, 0x00007ffd},
540      {NoFlag, 0xaaaaaaaa, 0x7fffffff, 0xaaaaaaaa},
541      {NoFlag, 0xffff8003, 0xffff8003, 0xffff8003},
542      {NoFlag, 0x00007fff, 0x7ffffffd, 0x00007fff},
543      {NoFlag, 0xffffff80, 0xaaaaaaaa, 0xffffff80},
544      {NoFlag, 0xfffffffe, 0xffff8003, 0xfffffffe},
545      {NoFlag, 0x0000007e, 0xffffff82, 0x0000007e},
546      {NoFlag, 0xffffffe0, 0x00007ffd, 0xffffffe0},
547      {NoFlag, 0x55555555, 0x00000000, 0x55555555},
548      {NoFlag, 0xfffffffe, 0x00007fff, 0xfffffffe},
549      {NoFlag, 0x00007fff, 0x33333333, 0x00007fff},
550      {NoFlag, 0xffffff82, 0xffffff80, 0xffffff82},
551      {NoFlag, 0x80000001, 0x0000007e, 0x80000001},
552      {NoFlag, 0xffff8002, 0xffff8002, 0xffff8002},
553      {NoFlag, 0xffffff81, 0x0000007d, 0xffffff81},
554      {NoFlag, 0xaaaaaaaa, 0xffff8003, 0xaaaaaaaa},
555      {NoFlag, 0xffff8002, 0x00007ffe, 0xffff8002},
556      {NoFlag, 0xffff8001, 0x00007ffd, 0xffff8001},
557      {NoFlag, 0xffff8002, 0xffffff81, 0xffff8002},
558      {NoFlag, 0x00000001, 0x00000020, 0x00000001},
559      {NoFlag, 0xffffff81, 0xffffff82, 0xffffff81},
560      {NoFlag, 0x7ffffffe, 0xffffff82, 0x7ffffffe},
561      {NoFlag, 0xffffff83, 0xffffff83, 0xffffff83},
562      {NoFlag, 0x55555555, 0xffffff83, 0x55555555},
563      {NoFlag, 0xfffffffe, 0xffffff81, 0xfffffffe},
564      {NoFlag, 0x00007ffe, 0x00007fff, 0x00007ffe},
565      {NoFlag, 0xffff8000, 0xffffffff, 0xffff8000},
566      {NoFlag, 0x33333333, 0xfffffffe, 0x33333333},
567      {NoFlag, 0xfffffffd, 0x7ffffffd, 0xfffffffd},
568      {NoFlag, 0xfffffffd, 0xffffff83, 0xfffffffd},
569      {NoFlag, 0xfffffffe, 0xaaaaaaaa, 0xfffffffe},
570      {NoFlag, 0x00000002, 0xfffffffe, 0x00000002},
571      {NoFlag, 0x00000020, 0xffff8002, 0x00000020},
572      {NoFlag, 0x00000001, 0xffffffe0, 0x00000001},
573      {NoFlag, 0x0000007d, 0x55555555, 0x0000007d},
574      {NoFlag, 0x0000007d, 0x7ffffffd, 0x0000007d},
575      {NoFlag, 0x33333333, 0xffffff82, 0x33333333},
576      {NoFlag, 0xfffffffe, 0xcccccccc, 0xfffffffe},
577      {NoFlag, 0x55555555, 0x55555555, 0x55555555},
578      {NoFlag, 0xffffffe0, 0xfffffffd, 0xffffffe0},
579      {NoFlag, 0x7fffffff, 0xfffffffe, 0x7fffffff},
580      {NoFlag, 0x0000007e, 0xffff8000, 0x0000007e},
581      {NoFlag, 0x55555555, 0x00007fff, 0x55555555},
582      {NoFlag, 0xffff8000, 0xfffffffd, 0xffff8000},
583      {NoFlag, 0xffffff80, 0x0000007e, 0xffffff80},
584      {NoFlag, 0x00000000, 0xffffffe0, 0x00000000},
585      {NoFlag, 0x55555555, 0x0000007e, 0x55555555},
586      {NoFlag, 0x0000007f, 0x7ffffffd, 0x0000007f},
587      {NoFlag, 0xffffff81, 0x00007ffe, 0xffffff81},
588      {NoFlag, 0xffffff80, 0xffff8001, 0xffffff80},
589      {NoFlag, 0x7ffffffd, 0xffffffff, 0x7ffffffd},
590      {NoFlag, 0xffff8001, 0xffff8002, 0xffff8001},
591      {NoFlag, 0x7ffffffd, 0x80000001, 0x7ffffffd},
592      {NoFlag, 0x0000007e, 0xfffffffe, 0x0000007e},
593      {NoFlag, 0x7ffffffe, 0x00007fff, 0x7ffffffe},
594      {NoFlag, 0x00007fff, 0x00007ffe, 0x00007fff},
595      {NoFlag, 0xffffff83, 0x00000001, 0xffffff83},
596      {NoFlag, 0xffffffff, 0x0000007f, 0xffffffff},
597      {NoFlag, 0xffffff83, 0x0000007f, 0xffffff83},
598      {NoFlag, 0xffff8000, 0xaaaaaaaa, 0xffff8000},
599      {NoFlag, 0xfffffffe, 0xffffffff, 0xfffffffe},
600      {NoFlag, 0x80000001, 0x7ffffffd, 0x80000001},
601      {NoFlag, 0xffffff80, 0xffffff83, 0xffffff80},
602      {NoFlag, 0x0000007e, 0xfffffffd, 0x0000007e},
603      {NoFlag, 0x00000001, 0x80000001, 0x00000001},
604      {NoFlag, 0x80000001, 0x00007fff, 0x80000001},
605      {NoFlag, 0xffff8003, 0xffffff82, 0xffff8003},
606      {NoFlag, 0x7ffffffd, 0x7ffffffe, 0x7ffffffd},
607      {NoFlag, 0xffff8003, 0x00000020, 0xffff8003},
608      {NoFlag, 0x33333333, 0xffff8000, 0x33333333},
609      {NoFlag, 0xcccccccc, 0xffffff82, 0xcccccccc},
610      {NoFlag, 0xffff8000, 0x7ffffffe, 0xffff8000},
611      {NoFlag, 0xffffffff, 0x55555555, 0xffffffff},
612      {NoFlag, 0x0000007f, 0x00000000, 0x0000007f},
613      {NoFlag, 0x00000000, 0xffffffff, 0x00000000},
614      {NoFlag, 0xffffffe0, 0x7ffffffe, 0xffffffe0},
615      {NoFlag, 0x7fffffff, 0x7ffffffe, 0x7fffffff},
616      {NoFlag, 0x00000001, 0xffffffff, 0x00000001},
617      {NoFlag, 0xffff8000, 0x33333333, 0xffff8000},
618      {NoFlag, 0x00007fff, 0xfffffffe, 0x00007fff},
619      {NoFlag, 0x00007fff, 0x80000001, 0x00007fff},
620      {NoFlag, 0xffffff83, 0xfffffffd, 0xffffff83},
621      {NoFlag, 0x0000007d, 0xaaaaaaaa, 0x0000007d},
622      {NoFlag, 0x00000000, 0x00000020, 0x00000000},
623      {NoFlag, 0x00007ffe, 0xffff8003, 0x00007ffe},
624      {NoFlag, 0x0000007d, 0xffffff82, 0x0000007d},
625      {NoFlag, 0xffffff80, 0x00000000, 0xffffff80},
626      {NoFlag, 0x00000020, 0xcccccccc, 0x00000020},
627      {NoFlag, 0xfffffffe, 0x00000002, 0xfffffffe},
628      {NoFlag, 0x0000007d, 0xfffffffe, 0x0000007d},
629      {NoFlag, 0x33333333, 0xaaaaaaaa, 0x33333333},
630      {NoFlag, 0xffff8001, 0x00000001, 0xffff8001},
631      {NoFlag, 0x0000007f, 0x00007fff, 0x0000007f},
632      {NoFlag, 0x55555555, 0xffffff81, 0x55555555},
633      {NoFlag, 0xfffffffd, 0xffffff81, 0xfffffffd},
634      {NoFlag, 0xffffffe0, 0x55555555, 0xffffffe0},
635      {NoFlag, 0x55555555, 0x7fffffff, 0x55555555},
636      {NoFlag, 0x00000002, 0x80000000, 0x00000002},
637      {NoFlag, 0xaaaaaaaa, 0x00007ffe, 0xaaaaaaaa},
638      {NoFlag, 0x00000002, 0x0000007e, 0x00000002},
639      {NoFlag, 0xffffff83, 0x00000000, 0xffffff83},
640      {NoFlag, 0x7ffffffe, 0xffffffe0, 0x7ffffffe},
641      {NoFlag, 0x00007ffe, 0xfffffffe, 0x00007ffe},
642      {NoFlag, 0x00000001, 0x0000007d, 0x00000001},
643      {NoFlag, 0x0000007d, 0x80000000, 0x0000007d},
644      {NoFlag, 0xffffffff, 0x00000002, 0xffffffff},
645      {NoFlag, 0x00007ffd, 0x00000002, 0x00007ffd},
646      {NoFlag, 0x0000007d, 0x33333333, 0x0000007d},
647      {NoFlag, 0x00000000, 0xffff8003, 0x00000000},
648      {NoFlag, 0x33333333, 0x00000001, 0x33333333},
649      {NoFlag, 0x55555555, 0x7ffffffd, 0x55555555},
650      {NoFlag, 0x00000000, 0x80000001, 0x00000000},
651      {NoFlag, 0x7ffffffe, 0xffff8002, 0x7ffffffe},
652      {NoFlag, 0x00007ffd, 0xfffffffe, 0x00007ffd},
653      {NoFlag, 0xffffff82, 0xfffffffd, 0xffffff82},
654      {NoFlag, 0x00000002, 0x7ffffffd, 0x00000002},
655      {NoFlag, 0xfffffffe, 0x0000007e, 0xfffffffe},
656      {NoFlag, 0x0000007d, 0xfffffffd, 0x0000007d},
657      {NoFlag, 0xffff8003, 0x33333333, 0xffff8003},
658      {NoFlag, 0x00000002, 0xfffffffd, 0x00000002},
659      {NoFlag, 0xfffffffd, 0x00007ffd, 0xfffffffd},
660      {NoFlag, 0x00007ffe, 0xffffff81, 0x00007ffe},
661      {NoFlag, 0xffff8000, 0xffff8000, 0xffff8000},
662      {NoFlag, 0x00007ffd, 0x00000001, 0x00007ffd},
663      {NoFlag, 0x00007ffd, 0xaaaaaaaa, 0x00007ffd},
664      {NoFlag, 0xcccccccc, 0x00000001, 0xcccccccc},
665      {NoFlag, 0xffffff82, 0xfffffffe, 0xffffff82},
666      {NoFlag, 0x00000001, 0xffffff82, 0x00000001},
667      {NoFlag, 0xffffffff, 0x0000007d, 0xffffffff},
668      {NoFlag, 0xfffffffd, 0xffff8002, 0xfffffffd},
669      {NoFlag, 0x7ffffffe, 0x7fffffff, 0x7ffffffe},
670      {NoFlag, 0x80000001, 0xffff8001, 0x80000001},
671      {NoFlag, 0x7ffffffe, 0xffffffff, 0x7ffffffe},
672      {NoFlag, 0xffffff80, 0xffffffe0, 0xffffff80},
673      {NoFlag, 0x33333333, 0xffffff81, 0x33333333},
674      {NoFlag, 0xffff8001, 0x0000007f, 0xffff8001},
675      {NoFlag, 0x33333333, 0x7ffffffd, 0x33333333},
676      {NoFlag, 0x0000007d, 0x00007ffd, 0x0000007d},
677      {NoFlag, 0xfffffffe, 0x7ffffffd, 0xfffffffe},
678      {NoFlag, 0x0000007f, 0x7fffffff, 0x0000007f},
679      {NoFlag, 0xaaaaaaaa, 0xffffff80, 0xaaaaaaaa},
680      {NoFlag, 0x0000007e, 0xffffffe0, 0x0000007e}};
681 
682 
683 // A loop will be generated for each element of this array.
684 const TestLoopData kTests[] = {{{eq, r0, r0, r0},
685                                 "eq r0 r0 r0",
686                                 "Condition_eq_r0_r0_r0",
687                                 ARRAY_SIZE(kCondition),
688                                 kCondition},
689                                {{ne, r0, r0, r0},
690                                 "ne r0 r0 r0",
691                                 "Condition_ne_r0_r0_r0",
692                                 ARRAY_SIZE(kCondition),
693                                 kCondition},
694                                {{cs, r0, r0, r0},
695                                 "cs r0 r0 r0",
696                                 "Condition_cs_r0_r0_r0",
697                                 ARRAY_SIZE(kCondition),
698                                 kCondition},
699                                {{cc, r0, r0, r0},
700                                 "cc r0 r0 r0",
701                                 "Condition_cc_r0_r0_r0",
702                                 ARRAY_SIZE(kCondition),
703                                 kCondition},
704                                {{mi, r0, r0, r0},
705                                 "mi r0 r0 r0",
706                                 "Condition_mi_r0_r0_r0",
707                                 ARRAY_SIZE(kCondition),
708                                 kCondition},
709                                {{pl, r0, r0, r0},
710                                 "pl r0 r0 r0",
711                                 "Condition_pl_r0_r0_r0",
712                                 ARRAY_SIZE(kCondition),
713                                 kCondition},
714                                {{vs, r0, r0, r0},
715                                 "vs r0 r0 r0",
716                                 "Condition_vs_r0_r0_r0",
717                                 ARRAY_SIZE(kCondition),
718                                 kCondition},
719                                {{vc, r0, r0, r0},
720                                 "vc r0 r0 r0",
721                                 "Condition_vc_r0_r0_r0",
722                                 ARRAY_SIZE(kCondition),
723                                 kCondition},
724                                {{hi, r0, r0, r0},
725                                 "hi r0 r0 r0",
726                                 "Condition_hi_r0_r0_r0",
727                                 ARRAY_SIZE(kCondition),
728                                 kCondition},
729                                {{ls, r0, r0, r0},
730                                 "ls r0 r0 r0",
731                                 "Condition_ls_r0_r0_r0",
732                                 ARRAY_SIZE(kCondition),
733                                 kCondition},
734                                {{ge, r0, r0, r0},
735                                 "ge r0 r0 r0",
736                                 "Condition_ge_r0_r0_r0",
737                                 ARRAY_SIZE(kCondition),
738                                 kCondition},
739                                {{lt, r0, r0, r0},
740                                 "lt r0 r0 r0",
741                                 "Condition_lt_r0_r0_r0",
742                                 ARRAY_SIZE(kCondition),
743                                 kCondition},
744                                {{gt, r0, r0, r0},
745                                 "gt r0 r0 r0",
746                                 "Condition_gt_r0_r0_r0",
747                                 ARRAY_SIZE(kCondition),
748                                 kCondition},
749                                {{le, r0, r0, r0},
750                                 "le r0 r0 r0",
751                                 "Condition_le_r0_r0_r0",
752                                 ARRAY_SIZE(kCondition),
753                                 kCondition},
754                                {{al, r0, r0, r0},
755                                 "al r0 r0 r0",
756                                 "Condition_al_r0_r0_r0",
757                                 ARRAY_SIZE(kCondition),
758                                 kCondition},
759                                {{al, r6, r5, r6},
760                                 "al r6 r5 r6",
761                                 "Unconditional_al_r6_r5_r6",
762                                 ARRAY_SIZE(kUnconditional),
763                                 kUnconditional},
764                                {{al, r6, r6, r6},
765                                 "al r6 r6 r6",
766                                 "Unconditional_al_r6_r6_r6",
767                                 ARRAY_SIZE(kUnconditional),
768                                 kUnconditional},
769                                {{al, r7, r4, r7},
770                                 "al r7 r4 r7",
771                                 "Unconditional_al_r7_r4_r7",
772                                 ARRAY_SIZE(kUnconditional),
773                                 kUnconditional},
774                                {{al, r7, r0, r7},
775                                 "al r7 r0 r7",
776                                 "Unconditional_al_r7_r0_r7",
777                                 ARRAY_SIZE(kUnconditional),
778                                 kUnconditional},
779                                {{al, r1, r2, r1},
780                                 "al r1 r2 r1",
781                                 "Unconditional_al_r1_r2_r1",
782                                 ARRAY_SIZE(kUnconditional),
783                                 kUnconditional},
784                                {{al, r0, r6, r0},
785                                 "al r0 r6 r0",
786                                 "Unconditional_al_r0_r6_r0",
787                                 ARRAY_SIZE(kUnconditional),
788                                 kUnconditional},
789                                {{al, r0, r7, r0},
790                                 "al r0 r7 r0",
791                                 "Unconditional_al_r0_r7_r0",
792                                 ARRAY_SIZE(kUnconditional),
793                                 kUnconditional},
794                                {{al, r1, r3, r1},
795                                 "al r1 r3 r1",
796                                 "Unconditional_al_r1_r3_r1",
797                                 ARRAY_SIZE(kUnconditional),
798                                 kUnconditional},
799                                {{al, r1, r5, r1},
800                                 "al r1 r5 r1",
801                                 "Unconditional_al_r1_r5_r1",
802                                 ARRAY_SIZE(kUnconditional),
803                                 kUnconditional},
804                                {{al, r7, r7, r7},
805                                 "al r7 r7 r7",
806                                 "Unconditional_al_r7_r7_r7",
807                                 ARRAY_SIZE(kUnconditional),
808                                 kUnconditional},
809                                {{al, r0, r3, r0},
810                                 "al r0 r3 r0",
811                                 "Unconditional_al_r0_r3_r0",
812                                 ARRAY_SIZE(kUnconditional),
813                                 kUnconditional},
814                                {{al, r2, r5, r2},
815                                 "al r2 r5 r2",
816                                 "Unconditional_al_r2_r5_r2",
817                                 ARRAY_SIZE(kUnconditional),
818                                 kUnconditional},
819                                {{al, r0, r2, r0},
820                                 "al r0 r2 r0",
821                                 "Unconditional_al_r0_r2_r0",
822                                 ARRAY_SIZE(kUnconditional),
823                                 kUnconditional},
824                                {{al, r6, r7, r6},
825                                 "al r6 r7 r6",
826                                 "Unconditional_al_r6_r7_r6",
827                                 ARRAY_SIZE(kUnconditional),
828                                 kUnconditional},
829                                {{al, r2, r0, r2},
830                                 "al r2 r0 r2",
831                                 "Unconditional_al_r2_r0_r2",
832                                 ARRAY_SIZE(kUnconditional),
833                                 kUnconditional},
834                                {{al, r7, r2, r7},
835                                 "al r7 r2 r7",
836                                 "Unconditional_al_r7_r2_r7",
837                                 ARRAY_SIZE(kUnconditional),
838                                 kUnconditional},
839                                {{al, r3, r6, r3},
840                                 "al r3 r6 r3",
841                                 "Unconditional_al_r3_r6_r3",
842                                 ARRAY_SIZE(kUnconditional),
843                                 kUnconditional},
844                                {{al, r3, r5, r3},
845                                 "al r3 r5 r3",
846                                 "Unconditional_al_r3_r5_r3",
847                                 ARRAY_SIZE(kUnconditional),
848                                 kUnconditional},
849                                {{al, r6, r4, r6},
850                                 "al r6 r4 r6",
851                                 "Unconditional_al_r6_r4_r6",
852                                 ARRAY_SIZE(kUnconditional),
853                                 kUnconditional},
854                                {{al, r6, r3, r6},
855                                 "al r6 r3 r6",
856                                 "Unconditional_al_r6_r3_r6",
857                                 ARRAY_SIZE(kUnconditional),
858                                 kUnconditional}};
859 
860 // We record all inputs to the instructions as outputs. This way, we also check
861 // that what shouldn't change didn't change.
862 struct TestResult {
863   size_t output_size;
864   const Inputs* outputs;
865 };
866 
867 // These headers each contain an array of `TestResult` with the reference output
868 // values. The reference arrays are names `kReference{mnemonic}`.
869 #include "aarch32/traces/simulator-cond-rdlow-rnlow-rmlow-t32-mul.h"
870 #include "aarch32/traces/simulator-cond-rdlow-rnlow-rmlow-t32-muls.h"
871 
872 
873 // The maximum number of errors to report in detail for each test.
874 const unsigned kErrorReportLimit = 8;
875 
876 typedef void (MacroAssembler::*Fn)(Condition cond,
877                                    Register rd,
878                                    Register rn,
879                                    Register rm);
880 
TestHelper(Fn instruction,const char * mnemonic,const TestResult reference[])881 void TestHelper(Fn instruction,
882                 const char* mnemonic,
883                 const TestResult reference[]) {
884   SETUP();
885   masm.UseT32();
886   START();
887 
888   // Data to compare to `reference`.
889   TestResult* results[ARRAY_SIZE(kTests)];
890 
891   // Test cases for memory bound instructions may allocate a buffer and save its
892   // address in this array.
893   byte* scratch_memory_buffers[ARRAY_SIZE(kTests)];
894 
895   // Generate a loop for each element in `kTests`. Each loop tests one specific
896   // instruction.
897   for (unsigned i = 0; i < ARRAY_SIZE(kTests); i++) {
898     // Allocate results on the heap for this test.
899     results[i] = new TestResult;
900     results[i]->outputs = new Inputs[kTests[i].input_size];
901     results[i]->output_size = kTests[i].input_size;
902 
903     size_t input_stride = sizeof(kTests[i].inputs[0]) * kTests[i].input_size;
904     VIXL_ASSERT(IsUint32(input_stride));
905 
906     scratch_memory_buffers[i] = NULL;
907 
908     Label loop;
909     UseScratchRegisterScope scratch_registers(&masm);
910     // Include all registers from r0 ro r12.
911     scratch_registers.Include(RegisterList(0x1fff));
912 
913     // Values to pass to the macro-assembler.
914     Condition cond = kTests[i].operands.cond;
915     Register rd = kTests[i].operands.rd;
916     Register rn = kTests[i].operands.rn;
917     Register rm = kTests[i].operands.rm;
918     scratch_registers.Exclude(rd);
919     scratch_registers.Exclude(rn);
920     scratch_registers.Exclude(rm);
921 
922     // Allocate reserved registers for our own use.
923     Register input_ptr = scratch_registers.Acquire();
924     Register input_end = scratch_registers.Acquire();
925     Register result_ptr = scratch_registers.Acquire();
926 
927     // Initialize `input_ptr` to the first element and `input_end` the address
928     // after the array.
929     __ Mov(input_ptr, Operand::From(kTests[i].inputs));
930     __ Add(input_end, input_ptr, static_cast<uint32_t>(input_stride));
931     __ Mov(result_ptr, Operand::From(results[i]->outputs));
932     __ Bind(&loop);
933 
934     {
935       UseScratchRegisterScope temp_registers(&masm);
936       Register nzcv_bits = temp_registers.Acquire();
937       Register saved_q_bit = temp_registers.Acquire();
938       // Save the `Q` bit flag.
939       __ Mrs(saved_q_bit, APSR);
940       __ And(saved_q_bit, saved_q_bit, QFlag);
941       // Set the `NZCV` and `Q` flags together.
942       __ Ldr(nzcv_bits, MemOperand(input_ptr, offsetof(Inputs, apsr)));
943       __ Orr(nzcv_bits, nzcv_bits, saved_q_bit);
944       __ Msr(APSR_nzcvq, nzcv_bits);
945     }
946     __ Ldr(rd, MemOperand(input_ptr, offsetof(Inputs, rd)));
947     __ Ldr(rn, MemOperand(input_ptr, offsetof(Inputs, rn)));
948     __ Ldr(rm, MemOperand(input_ptr, offsetof(Inputs, rm)));
949 
950     (masm.*instruction)(cond, rd, rn, rm);
951 
952     {
953       UseScratchRegisterScope temp_registers(&masm);
954       Register nzcv_bits = temp_registers.Acquire();
955       __ Mrs(nzcv_bits, APSR);
956       // Only record the NZCV bits.
957       __ And(nzcv_bits, nzcv_bits, NZCVFlag);
958       __ Str(nzcv_bits, MemOperand(result_ptr, offsetof(Inputs, apsr)));
959     }
960     __ Str(rd, MemOperand(result_ptr, offsetof(Inputs, rd)));
961     __ Str(rn, MemOperand(result_ptr, offsetof(Inputs, rn)));
962     __ Str(rm, MemOperand(result_ptr, offsetof(Inputs, rm)));
963 
964     // Advance the result pointer.
965     __ Add(result_ptr, result_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
966     // Loop back until `input_ptr` is lower than `input_base`.
967     __ Add(input_ptr, input_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
968     __ Cmp(input_ptr, input_end);
969     __ B(ne, &loop);
970   }
971 
972   END();
973 
974   RUN();
975 
976   if (Test::generate_test_trace()) {
977     // Print the results.
978     for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
979       printf("const Inputs kOutputs_%s_%s[] = {\n",
980              mnemonic,
981              kTests[i].identifier);
982       for (size_t j = 0; j < results[i]->output_size; j++) {
983         printf("  { ");
984         printf("0x%08" PRIx32, results[i]->outputs[j].apsr);
985         printf(", ");
986         printf("0x%08" PRIx32, results[i]->outputs[j].rd);
987         printf(", ");
988         printf("0x%08" PRIx32, results[i]->outputs[j].rn);
989         printf(", ");
990         printf("0x%08" PRIx32, results[i]->outputs[j].rm);
991         printf(" },\n");
992       }
993       printf("};\n");
994     }
995     printf("const TestResult kReference%s[] = {\n", mnemonic);
996     for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
997       printf("  {\n");
998       printf("    ARRAY_SIZE(kOutputs_%s_%s),\n",
999              mnemonic,
1000              kTests[i].identifier);
1001       printf("    kOutputs_%s_%s,\n", mnemonic, kTests[i].identifier);
1002       printf("  },\n");
1003     }
1004     printf("};\n");
1005   } else if (kCheckSimulatorTestResults) {
1006     // Check the results.
1007     unsigned total_error_count = 0;
1008     for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
1009       bool instruction_has_errors = false;
1010       for (size_t j = 0; j < kTests[i].input_size; j++) {
1011         uint32_t apsr = results[i]->outputs[j].apsr;
1012         uint32_t rd = results[i]->outputs[j].rd;
1013         uint32_t rn = results[i]->outputs[j].rn;
1014         uint32_t rm = results[i]->outputs[j].rm;
1015         uint32_t apsr_input = kTests[i].inputs[j].apsr;
1016         uint32_t rd_input = kTests[i].inputs[j].rd;
1017         uint32_t rn_input = kTests[i].inputs[j].rn;
1018         uint32_t rm_input = kTests[i].inputs[j].rm;
1019         uint32_t apsr_ref = reference[i].outputs[j].apsr;
1020         uint32_t rd_ref = reference[i].outputs[j].rd;
1021         uint32_t rn_ref = reference[i].outputs[j].rn;
1022         uint32_t rm_ref = reference[i].outputs[j].rm;
1023 
1024         if (((apsr != apsr_ref) || (rd != rd_ref) || (rn != rn_ref) ||
1025              (rm != rm_ref)) &&
1026             (++total_error_count <= kErrorReportLimit)) {
1027           // Print the instruction once even if it triggered multiple failures.
1028           if (!instruction_has_errors) {
1029             printf("Error(s) when testing \"%s %s\":\n",
1030                    mnemonic,
1031                    kTests[i].operands_description);
1032             instruction_has_errors = true;
1033           }
1034           // Print subsequent errors.
1035           printf("  Input:    ");
1036           printf("0x%08" PRIx32, apsr_input);
1037           printf(", ");
1038           printf("0x%08" PRIx32, rd_input);
1039           printf(", ");
1040           printf("0x%08" PRIx32, rn_input);
1041           printf(", ");
1042           printf("0x%08" PRIx32, rm_input);
1043           printf("\n");
1044           printf("  Expected: ");
1045           printf("0x%08" PRIx32, apsr_ref);
1046           printf(", ");
1047           printf("0x%08" PRIx32, rd_ref);
1048           printf(", ");
1049           printf("0x%08" PRIx32, rn_ref);
1050           printf(", ");
1051           printf("0x%08" PRIx32, rm_ref);
1052           printf("\n");
1053           printf("  Found:    ");
1054           printf("0x%08" PRIx32, apsr);
1055           printf(", ");
1056           printf("0x%08" PRIx32, rd);
1057           printf(", ");
1058           printf("0x%08" PRIx32, rn);
1059           printf(", ");
1060           printf("0x%08" PRIx32, rm);
1061           printf("\n\n");
1062         }
1063       }
1064     }
1065 
1066     if (total_error_count > kErrorReportLimit) {
1067       printf("%u other errors follow.\n",
1068              total_error_count - kErrorReportLimit);
1069     }
1070     VIXL_CHECK(total_error_count == 0);
1071   } else {
1072     VIXL_WARNING("Assembled the code, but did not run anything.\n");
1073   }
1074 
1075   for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
1076     delete[] results[i]->outputs;
1077     delete results[i];
1078     delete[] scratch_memory_buffers[i];
1079   }
1080 
1081   TEARDOWN();
1082 }
1083 
1084 // Instantiate tests for each instruction in the list.
1085 // TODO: Remove this limitation by having a sandboxing mechanism.
1086 #if defined(VIXL_HOST_POINTER_32)
1087 #define TEST(mnemonic)                                                      \
1088   void Test_##mnemonic() {                                                  \
1089     TestHelper(&MacroAssembler::mnemonic, #mnemonic, kReference##mnemonic); \
1090   }                                                                         \
1091   Test test_##mnemonic(                                                     \
1092       "AARCH32_SIMULATOR_COND_RDLOW_RNLOW_RMLOW_T32_" #mnemonic,            \
1093       &Test_##mnemonic);
1094 #else
1095 #define TEST(mnemonic)                                           \
1096   void Test_##mnemonic() {                                       \
1097     VIXL_WARNING("This test can only run on a 32-bit host.\n");  \
1098     USE(TestHelper);                                             \
1099   }                                                              \
1100   Test test_##mnemonic(                                          \
1101       "AARCH32_SIMULATOR_COND_RDLOW_RNLOW_RMLOW_T32_" #mnemonic, \
1102       &Test_##mnemonic);
1103 #endif
1104 
1105 FOREACH_INSTRUCTION(TEST)
1106 #undef TEST
1107 
1108 }  // namespace
1109 #endif
1110 
1111 }  // namespace aarch32
1112 }  // namespace vixl
1113