1// Copyright 2016, VIXL authors
2// All rights reserved.
3//
4// Redistribution and use in source and binary forms, with or without
5// modification, are permitted provided that the following conditions are met:
6//
7//   * Redistributions of source code must retain the above copyright notice,
8//     this list of conditions and the following disclaimer.
9//   * Redistributions in binary form must reproduce the above copyright notice,
10//     this list of conditions and the following disclaimer in the documentation
11//     and/or other materials provided with the distribution.
12//   * Neither the name of ARM Limited nor the names of its contributors may be
13//     used to endorse or promote products derived from this software without
14//     specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
17// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27
28// -----------------------------------------------------------------------------
29// This file is auto generated from the
30// test/aarch32/config/template-simulator-aarch32.cc.in template file using
31// tools/generate_tests.py.
32//
33// PLEASE DO NOT EDIT.
34// -----------------------------------------------------------------------------
35
36
37#include "test-runner.h"
38
39#include "test-utils.h"
40#include "test-utils-aarch32.h"
41
42#include "aarch32/assembler-aarch32.h"
43#include "aarch32/disasm-aarch32.h"
44#include "aarch32/macro-assembler-aarch32.h"
45
46#define __ masm.
47#define BUF_SIZE (4096)
48
49#ifdef VIXL_INCLUDE_SIMULATOR_AARCH32
50// Run tests with the simulator.
51
52#define SETUP() MacroAssembler masm(BUF_SIZE)
53
54#define START() masm.GetBuffer()->Reset()
55
56#define END() \
57  __ Hlt(0);  \
58  __ FinalizeCode();
59
60// TODO: Run the tests in the simulator.
61#define RUN()
62
63#else  // ifdef VIXL_INCLUDE_SIMULATOR_AARCH32.
64
65#define SETUP()                  \
66  MacroAssembler masm(BUF_SIZE); \
67  UseScratchRegisterScope harness_scratch;
68
69#define START()                 \
70  harness_scratch.Open(&masm);  \
71  harness_scratch.ExcludeAll(); \
72  masm.GetBuffer()->Reset();    \
73  __ Push(r4);                  \
74  __ Push(r5);                  \
75  __ Push(r6);                  \
76  __ Push(r7);                  \
77  __ Push(r8);                  \
78  __ Push(r9);                  \
79  __ Push(r10);                 \
80  __ Push(r11);                 \
81  __ Push(lr);                  \
82  harness_scratch.Include(ip);
83
84#define END()                  \
85  harness_scratch.Exclude(ip); \
86  __ Pop(lr);                  \
87  __ Pop(r11);                 \
88  __ Pop(r10);                 \
89  __ Pop(r9);                  \
90  __ Pop(r8);                  \
91  __ Pop(r7);                  \
92  __ Pop(r6);                  \
93  __ Pop(r5);                  \
94  __ Pop(r4);                  \
95  __ Bx(lr);                   \
96  __ FinalizeCode();           \
97  harness_scratch.Close();
98
99#define RUN()                                                 \
100  {                                                           \
101    int pcs_offset = masm.IsUsingT32() ? 1 : 0;               \
102    masm.GetBuffer()->SetExecutable();                        \
103    ExecuteMemory(masm.GetBuffer()->GetStartAddress<byte*>(), \
104                  masm.GetSizeOfCodeGenerated(),              \
105                  pcs_offset);                                \
106    masm.GetBuffer()->SetWritable();                          \
107  }
108
109#endif  // ifdef VIXL_INCLUDE_SIMULATOR_AARCH32
110
111namespace vixl {
112namespace aarch32 {
113
114// List of instruction encodings:
115#define FOREACH_INSTRUCTION(M) \
116  M(Add)                       \
117  M(Sub)
118
119
120// The following definitions are defined again in each generated test, therefore
121// we need to place them in an anomymous namespace. It expresses that they are
122// local to this file only, and the compiler is not allowed to share these types
123// across test files during template instantiation. Specifically, `Operands` and
124// `Inputs` have various layouts across generated tests so they absolutely
125// cannot be shared.
126
127#ifdef VIXL_INCLUDE_TARGET_T32
128namespace {
129
130// Values to be passed to the assembler to produce the instruction under test.
131struct Operands {
132  Condition cond;
133  Register rd;
134  Register rn;
135  int32_t immediate;
136};
137
138// Input data to feed to the instruction.
139struct Inputs {
140  uint32_t rd;
141  uint32_t rn;
142};
143
144// This structure contains all input data needed to test one specific encoding.
145// It used to generate a loop over an instruction.
146struct TestLoopData {
147  // The `operands` fields represents the values to pass to the assembler to
148  // produce the instruction.
149  Operands operands;
150  // Description of the operands, used for error reporting.
151  const char* operands_description;
152  // Unique identifier, used for generating traces.
153  const char* identifier;
154  // Array of values to be fed to the instruction.
155  size_t input_size;
156  const Inputs* inputs;
157};
158
159static const Inputs kRdIsRn[] =
160    {{0x00000000, 0x00000000}, {0x00000001, 0x00000001},
161     {0x00000002, 0x00000002}, {0x00000020, 0x00000020},
162     {0x0000007d, 0x0000007d}, {0x0000007e, 0x0000007e},
163     {0x0000007f, 0x0000007f}, {0x00007ffd, 0x00007ffd},
164     {0x00007ffe, 0x00007ffe}, {0x00007fff, 0x00007fff},
165     {0x33333333, 0x33333333}, {0x55555555, 0x55555555},
166     {0x7ffffffd, 0x7ffffffd}, {0x7ffffffe, 0x7ffffffe},
167     {0x7fffffff, 0x7fffffff}, {0x80000000, 0x80000000},
168     {0x80000001, 0x80000001}, {0xaaaaaaaa, 0xaaaaaaaa},
169     {0xcccccccc, 0xcccccccc}, {0xffff8000, 0xffff8000},
170     {0xffff8001, 0xffff8001}, {0xffff8002, 0xffff8002},
171     {0xffff8003, 0xffff8003}, {0xffffff80, 0xffffff80},
172     {0xffffff81, 0xffffff81}, {0xffffff82, 0xffffff82},
173     {0xffffff83, 0xffffff83}, {0xffffffe0, 0xffffffe0},
174     {0xfffffffd, 0xfffffffd}, {0xfffffffe, 0xfffffffe},
175     {0xffffffff, 0xffffffff}};
176
177static const Inputs kRdIsNotRn[] =
178    {{0x00000000, 0x00000000}, {0x00000000, 0x00000001},
179     {0x00000000, 0x00000002}, {0x00000000, 0x00000020},
180     {0x00000000, 0x0000007d}, {0x00000000, 0x0000007e},
181     {0x00000000, 0x0000007f}, {0x00000000, 0x00007ffd},
182     {0x00000000, 0x00007ffe}, {0x00000000, 0x00007fff},
183     {0x00000000, 0x33333333}, {0x00000000, 0x55555555},
184     {0x00000000, 0x7ffffffd}, {0x00000000, 0x7ffffffe},
185     {0x00000000, 0x7fffffff}, {0x00000000, 0x80000000},
186     {0x00000000, 0x80000001}, {0x00000000, 0xaaaaaaaa},
187     {0x00000000, 0xcccccccc}, {0x00000000, 0xffff8000},
188     {0x00000000, 0xffff8001}, {0x00000000, 0xffff8002},
189     {0x00000000, 0xffff8003}, {0x00000000, 0xffffff80},
190     {0x00000000, 0xffffff81}, {0x00000000, 0xffffff82},
191     {0x00000000, 0xffffff83}, {0x00000000, 0xffffffe0},
192     {0x00000000, 0xfffffffd}, {0x00000000, 0xfffffffe},
193     {0x00000000, 0xffffffff}, {0x00000001, 0x00000000},
194     {0x00000001, 0x00000001}, {0x00000001, 0x00000002},
195     {0x00000001, 0x00000020}, {0x00000001, 0x0000007d},
196     {0x00000001, 0x0000007e}, {0x00000001, 0x0000007f},
197     {0x00000001, 0x00007ffd}, {0x00000001, 0x00007ffe},
198     {0x00000001, 0x00007fff}, {0x00000001, 0x33333333},
199     {0x00000001, 0x55555555}, {0x00000001, 0x7ffffffd},
200     {0x00000001, 0x7ffffffe}, {0x00000001, 0x7fffffff},
201     {0x00000001, 0x80000000}, {0x00000001, 0x80000001},
202     {0x00000001, 0xaaaaaaaa}, {0x00000001, 0xcccccccc},
203     {0x00000001, 0xffff8000}, {0x00000001, 0xffff8001},
204     {0x00000001, 0xffff8002}, {0x00000001, 0xffff8003},
205     {0x00000001, 0xffffff80}, {0x00000001, 0xffffff81},
206     {0x00000001, 0xffffff82}, {0x00000001, 0xffffff83},
207     {0x00000001, 0xffffffe0}, {0x00000001, 0xfffffffd},
208     {0x00000001, 0xfffffffe}, {0x00000001, 0xffffffff},
209     {0x00000002, 0x00000000}, {0x00000002, 0x00000001},
210     {0x00000002, 0x00000002}, {0x00000002, 0x00000020},
211     {0x00000002, 0x0000007d}, {0x00000002, 0x0000007e},
212     {0x00000002, 0x0000007f}, {0x00000002, 0x00007ffd},
213     {0x00000002, 0x00007ffe}, {0x00000002, 0x00007fff},
214     {0x00000002, 0x33333333}, {0x00000002, 0x55555555},
215     {0x00000002, 0x7ffffffd}, {0x00000002, 0x7ffffffe},
216     {0x00000002, 0x7fffffff}, {0x00000002, 0x80000000},
217     {0x00000002, 0x80000001}, {0x00000002, 0xaaaaaaaa},
218     {0x00000002, 0xcccccccc}, {0x00000002, 0xffff8000},
219     {0x00000002, 0xffff8001}, {0x00000002, 0xffff8002},
220     {0x00000002, 0xffff8003}, {0x00000002, 0xffffff80},
221     {0x00000002, 0xffffff81}, {0x00000002, 0xffffff82},
222     {0x00000002, 0xffffff83}, {0x00000002, 0xffffffe0},
223     {0x00000002, 0xfffffffd}, {0x00000002, 0xfffffffe},
224     {0x00000002, 0xffffffff}, {0x00000020, 0x00000000},
225     {0x00000020, 0x00000001}, {0x00000020, 0x00000002},
226     {0x00000020, 0x00000020}, {0x00000020, 0x0000007d},
227     {0x00000020, 0x0000007e}, {0x00000020, 0x0000007f},
228     {0x00000020, 0x00007ffd}, {0x00000020, 0x00007ffe},
229     {0x00000020, 0x00007fff}, {0x00000020, 0x33333333},
230     {0x00000020, 0x55555555}, {0x00000020, 0x7ffffffd},
231     {0x00000020, 0x7ffffffe}, {0x00000020, 0x7fffffff},
232     {0x00000020, 0x80000000}, {0x00000020, 0x80000001},
233     {0x00000020, 0xaaaaaaaa}, {0x00000020, 0xcccccccc},
234     {0x00000020, 0xffff8000}, {0x00000020, 0xffff8001},
235     {0x00000020, 0xffff8002}, {0x00000020, 0xffff8003},
236     {0x00000020, 0xffffff80}, {0x00000020, 0xffffff81},
237     {0x00000020, 0xffffff82}, {0x00000020, 0xffffff83},
238     {0x00000020, 0xffffffe0}, {0x00000020, 0xfffffffd},
239     {0x00000020, 0xfffffffe}, {0x00000020, 0xffffffff},
240     {0x0000007d, 0x00000000}, {0x0000007d, 0x00000001},
241     {0x0000007d, 0x00000002}, {0x0000007d, 0x00000020},
242     {0x0000007d, 0x0000007d}, {0x0000007d, 0x0000007e},
243     {0x0000007d, 0x0000007f}, {0x0000007d, 0x00007ffd},
244     {0x0000007d, 0x00007ffe}, {0x0000007d, 0x00007fff},
245     {0x0000007d, 0x33333333}, {0x0000007d, 0x55555555},
246     {0x0000007d, 0x7ffffffd}, {0x0000007d, 0x7ffffffe},
247     {0x0000007d, 0x7fffffff}, {0x0000007d, 0x80000000},
248     {0x0000007d, 0x80000001}, {0x0000007d, 0xaaaaaaaa},
249     {0x0000007d, 0xcccccccc}, {0x0000007d, 0xffff8000},
250     {0x0000007d, 0xffff8001}, {0x0000007d, 0xffff8002},
251     {0x0000007d, 0xffff8003}, {0x0000007d, 0xffffff80},
252     {0x0000007d, 0xffffff81}, {0x0000007d, 0xffffff82},
253     {0x0000007d, 0xffffff83}, {0x0000007d, 0xffffffe0},
254     {0x0000007d, 0xfffffffd}, {0x0000007d, 0xfffffffe},
255     {0x0000007d, 0xffffffff}, {0x0000007e, 0x00000000},
256     {0x0000007e, 0x00000001}, {0x0000007e, 0x00000002},
257     {0x0000007e, 0x00000020}, {0x0000007e, 0x0000007d},
258     {0x0000007e, 0x0000007e}, {0x0000007e, 0x0000007f},
259     {0x0000007e, 0x00007ffd}, {0x0000007e, 0x00007ffe},
260     {0x0000007e, 0x00007fff}, {0x0000007e, 0x33333333},
261     {0x0000007e, 0x55555555}, {0x0000007e, 0x7ffffffd},
262     {0x0000007e, 0x7ffffffe}, {0x0000007e, 0x7fffffff},
263     {0x0000007e, 0x80000000}, {0x0000007e, 0x80000001},
264     {0x0000007e, 0xaaaaaaaa}, {0x0000007e, 0xcccccccc},
265     {0x0000007e, 0xffff8000}, {0x0000007e, 0xffff8001},
266     {0x0000007e, 0xffff8002}, {0x0000007e, 0xffff8003},
267     {0x0000007e, 0xffffff80}, {0x0000007e, 0xffffff81},
268     {0x0000007e, 0xffffff82}, {0x0000007e, 0xffffff83},
269     {0x0000007e, 0xffffffe0}, {0x0000007e, 0xfffffffd},
270     {0x0000007e, 0xfffffffe}, {0x0000007e, 0xffffffff},
271     {0x0000007f, 0x00000000}, {0x0000007f, 0x00000001},
272     {0x0000007f, 0x00000002}, {0x0000007f, 0x00000020},
273     {0x0000007f, 0x0000007d}, {0x0000007f, 0x0000007e},
274     {0x0000007f, 0x0000007f}, {0x0000007f, 0x00007ffd},
275     {0x0000007f, 0x00007ffe}, {0x0000007f, 0x00007fff},
276     {0x0000007f, 0x33333333}, {0x0000007f, 0x55555555},
277     {0x0000007f, 0x7ffffffd}, {0x0000007f, 0x7ffffffe},
278     {0x0000007f, 0x7fffffff}, {0x0000007f, 0x80000000},
279     {0x0000007f, 0x80000001}, {0x0000007f, 0xaaaaaaaa},
280     {0x0000007f, 0xcccccccc}, {0x0000007f, 0xffff8000},
281     {0x0000007f, 0xffff8001}, {0x0000007f, 0xffff8002},
282     {0x0000007f, 0xffff8003}, {0x0000007f, 0xffffff80},
283     {0x0000007f, 0xffffff81}, {0x0000007f, 0xffffff82},
284     {0x0000007f, 0xffffff83}, {0x0000007f, 0xffffffe0},
285     {0x0000007f, 0xfffffffd}, {0x0000007f, 0xfffffffe},
286     {0x0000007f, 0xffffffff}, {0x00007ffd, 0x00000000},
287     {0x00007ffd, 0x00000001}, {0x00007ffd, 0x00000002},
288     {0x00007ffd, 0x00000020}, {0x00007ffd, 0x0000007d},
289     {0x00007ffd, 0x0000007e}, {0x00007ffd, 0x0000007f},
290     {0x00007ffd, 0x00007ffd}, {0x00007ffd, 0x00007ffe},
291     {0x00007ffd, 0x00007fff}, {0x00007ffd, 0x33333333},
292     {0x00007ffd, 0x55555555}, {0x00007ffd, 0x7ffffffd},
293     {0x00007ffd, 0x7ffffffe}, {0x00007ffd, 0x7fffffff},
294     {0x00007ffd, 0x80000000}, {0x00007ffd, 0x80000001},
295     {0x00007ffd, 0xaaaaaaaa}, {0x00007ffd, 0xcccccccc},
296     {0x00007ffd, 0xffff8000}, {0x00007ffd, 0xffff8001},
297     {0x00007ffd, 0xffff8002}, {0x00007ffd, 0xffff8003},
298     {0x00007ffd, 0xffffff80}, {0x00007ffd, 0xffffff81},
299     {0x00007ffd, 0xffffff82}, {0x00007ffd, 0xffffff83},
300     {0x00007ffd, 0xffffffe0}, {0x00007ffd, 0xfffffffd},
301     {0x00007ffd, 0xfffffffe}, {0x00007ffd, 0xffffffff},
302     {0x00007ffe, 0x00000000}, {0x00007ffe, 0x00000001},
303     {0x00007ffe, 0x00000002}, {0x00007ffe, 0x00000020},
304     {0x00007ffe, 0x0000007d}, {0x00007ffe, 0x0000007e},
305     {0x00007ffe, 0x0000007f}, {0x00007ffe, 0x00007ffd},
306     {0x00007ffe, 0x00007ffe}, {0x00007ffe, 0x00007fff},
307     {0x00007ffe, 0x33333333}, {0x00007ffe, 0x55555555},
308     {0x00007ffe, 0x7ffffffd}, {0x00007ffe, 0x7ffffffe},
309     {0x00007ffe, 0x7fffffff}, {0x00007ffe, 0x80000000},
310     {0x00007ffe, 0x80000001}, {0x00007ffe, 0xaaaaaaaa},
311     {0x00007ffe, 0xcccccccc}, {0x00007ffe, 0xffff8000},
312     {0x00007ffe, 0xffff8001}, {0x00007ffe, 0xffff8002},
313     {0x00007ffe, 0xffff8003}, {0x00007ffe, 0xffffff80},
314     {0x00007ffe, 0xffffff81}, {0x00007ffe, 0xffffff82},
315     {0x00007ffe, 0xffffff83}, {0x00007ffe, 0xffffffe0},
316     {0x00007ffe, 0xfffffffd}, {0x00007ffe, 0xfffffffe},
317     {0x00007ffe, 0xffffffff}, {0x00007fff, 0x00000000},
318     {0x00007fff, 0x00000001}, {0x00007fff, 0x00000002},
319     {0x00007fff, 0x00000020}, {0x00007fff, 0x0000007d},
320     {0x00007fff, 0x0000007e}, {0x00007fff, 0x0000007f},
321     {0x00007fff, 0x00007ffd}, {0x00007fff, 0x00007ffe},
322     {0x00007fff, 0x00007fff}, {0x00007fff, 0x33333333},
323     {0x00007fff, 0x55555555}, {0x00007fff, 0x7ffffffd},
324     {0x00007fff, 0x7ffffffe}, {0x00007fff, 0x7fffffff},
325     {0x00007fff, 0x80000000}, {0x00007fff, 0x80000001},
326     {0x00007fff, 0xaaaaaaaa}, {0x00007fff, 0xcccccccc},
327     {0x00007fff, 0xffff8000}, {0x00007fff, 0xffff8001},
328     {0x00007fff, 0xffff8002}, {0x00007fff, 0xffff8003},
329     {0x00007fff, 0xffffff80}, {0x00007fff, 0xffffff81},
330     {0x00007fff, 0xffffff82}, {0x00007fff, 0xffffff83},
331     {0x00007fff, 0xffffffe0}, {0x00007fff, 0xfffffffd},
332     {0x00007fff, 0xfffffffe}, {0x00007fff, 0xffffffff},
333     {0x33333333, 0x00000000}, {0x33333333, 0x00000001},
334     {0x33333333, 0x00000002}, {0x33333333, 0x00000020},
335     {0x33333333, 0x0000007d}, {0x33333333, 0x0000007e},
336     {0x33333333, 0x0000007f}, {0x33333333, 0x00007ffd},
337     {0x33333333, 0x00007ffe}, {0x33333333, 0x00007fff},
338     {0x33333333, 0x33333333}, {0x33333333, 0x55555555},
339     {0x33333333, 0x7ffffffd}, {0x33333333, 0x7ffffffe},
340     {0x33333333, 0x7fffffff}, {0x33333333, 0x80000000},
341     {0x33333333, 0x80000001}, {0x33333333, 0xaaaaaaaa},
342     {0x33333333, 0xcccccccc}, {0x33333333, 0xffff8000},
343     {0x33333333, 0xffff8001}, {0x33333333, 0xffff8002},
344     {0x33333333, 0xffff8003}, {0x33333333, 0xffffff80},
345     {0x33333333, 0xffffff81}, {0x33333333, 0xffffff82},
346     {0x33333333, 0xffffff83}, {0x33333333, 0xffffffe0},
347     {0x33333333, 0xfffffffd}, {0x33333333, 0xfffffffe},
348     {0x33333333, 0xffffffff}, {0x55555555, 0x00000000},
349     {0x55555555, 0x00000001}, {0x55555555, 0x00000002},
350     {0x55555555, 0x00000020}, {0x55555555, 0x0000007d},
351     {0x55555555, 0x0000007e}, {0x55555555, 0x0000007f},
352     {0x55555555, 0x00007ffd}, {0x55555555, 0x00007ffe},
353     {0x55555555, 0x00007fff}, {0x55555555, 0x33333333},
354     {0x55555555, 0x55555555}, {0x55555555, 0x7ffffffd},
355     {0x55555555, 0x7ffffffe}, {0x55555555, 0x7fffffff},
356     {0x55555555, 0x80000000}, {0x55555555, 0x80000001},
357     {0x55555555, 0xaaaaaaaa}, {0x55555555, 0xcccccccc},
358     {0x55555555, 0xffff8000}, {0x55555555, 0xffff8001},
359     {0x55555555, 0xffff8002}, {0x55555555, 0xffff8003},
360     {0x55555555, 0xffffff80}, {0x55555555, 0xffffff81},
361     {0x55555555, 0xffffff82}, {0x55555555, 0xffffff83},
362     {0x55555555, 0xffffffe0}, {0x55555555, 0xfffffffd},
363     {0x55555555, 0xfffffffe}, {0x55555555, 0xffffffff},
364     {0x7ffffffd, 0x00000000}, {0x7ffffffd, 0x00000001},
365     {0x7ffffffd, 0x00000002}, {0x7ffffffd, 0x00000020},
366     {0x7ffffffd, 0x0000007d}, {0x7ffffffd, 0x0000007e},
367     {0x7ffffffd, 0x0000007f}, {0x7ffffffd, 0x00007ffd},
368     {0x7ffffffd, 0x00007ffe}, {0x7ffffffd, 0x00007fff},
369     {0x7ffffffd, 0x33333333}, {0x7ffffffd, 0x55555555},
370     {0x7ffffffd, 0x7ffffffd}, {0x7ffffffd, 0x7ffffffe},
371     {0x7ffffffd, 0x7fffffff}, {0x7ffffffd, 0x80000000},
372     {0x7ffffffd, 0x80000001}, {0x7ffffffd, 0xaaaaaaaa},
373     {0x7ffffffd, 0xcccccccc}, {0x7ffffffd, 0xffff8000},
374     {0x7ffffffd, 0xffff8001}, {0x7ffffffd, 0xffff8002},
375     {0x7ffffffd, 0xffff8003}, {0x7ffffffd, 0xffffff80},
376     {0x7ffffffd, 0xffffff81}, {0x7ffffffd, 0xffffff82},
377     {0x7ffffffd, 0xffffff83}, {0x7ffffffd, 0xffffffe0},
378     {0x7ffffffd, 0xfffffffd}, {0x7ffffffd, 0xfffffffe},
379     {0x7ffffffd, 0xffffffff}, {0x7ffffffe, 0x00000000},
380     {0x7ffffffe, 0x00000001}, {0x7ffffffe, 0x00000002},
381     {0x7ffffffe, 0x00000020}, {0x7ffffffe, 0x0000007d},
382     {0x7ffffffe, 0x0000007e}, {0x7ffffffe, 0x0000007f},
383     {0x7ffffffe, 0x00007ffd}, {0x7ffffffe, 0x00007ffe},
384     {0x7ffffffe, 0x00007fff}, {0x7ffffffe, 0x33333333},
385     {0x7ffffffe, 0x55555555}, {0x7ffffffe, 0x7ffffffd},
386     {0x7ffffffe, 0x7ffffffe}, {0x7ffffffe, 0x7fffffff},
387     {0x7ffffffe, 0x80000000}, {0x7ffffffe, 0x80000001},
388     {0x7ffffffe, 0xaaaaaaaa}, {0x7ffffffe, 0xcccccccc},
389     {0x7ffffffe, 0xffff8000}, {0x7ffffffe, 0xffff8001},
390     {0x7ffffffe, 0xffff8002}, {0x7ffffffe, 0xffff8003},
391     {0x7ffffffe, 0xffffff80}, {0x7ffffffe, 0xffffff81},
392     {0x7ffffffe, 0xffffff82}, {0x7ffffffe, 0xffffff83},
393     {0x7ffffffe, 0xffffffe0}, {0x7ffffffe, 0xfffffffd},
394     {0x7ffffffe, 0xfffffffe}, {0x7ffffffe, 0xffffffff},
395     {0x7fffffff, 0x00000000}, {0x7fffffff, 0x00000001},
396     {0x7fffffff, 0x00000002}, {0x7fffffff, 0x00000020},
397     {0x7fffffff, 0x0000007d}, {0x7fffffff, 0x0000007e},
398     {0x7fffffff, 0x0000007f}, {0x7fffffff, 0x00007ffd},
399     {0x7fffffff, 0x00007ffe}, {0x7fffffff, 0x00007fff},
400     {0x7fffffff, 0x33333333}, {0x7fffffff, 0x55555555},
401     {0x7fffffff, 0x7ffffffd}, {0x7fffffff, 0x7ffffffe},
402     {0x7fffffff, 0x7fffffff}, {0x7fffffff, 0x80000000},
403     {0x7fffffff, 0x80000001}, {0x7fffffff, 0xaaaaaaaa},
404     {0x7fffffff, 0xcccccccc}, {0x7fffffff, 0xffff8000},
405     {0x7fffffff, 0xffff8001}, {0x7fffffff, 0xffff8002},
406     {0x7fffffff, 0xffff8003}, {0x7fffffff, 0xffffff80},
407     {0x7fffffff, 0xffffff81}, {0x7fffffff, 0xffffff82},
408     {0x7fffffff, 0xffffff83}, {0x7fffffff, 0xffffffe0},
409     {0x7fffffff, 0xfffffffd}, {0x7fffffff, 0xfffffffe},
410     {0x7fffffff, 0xffffffff}, {0x80000000, 0x00000000},
411     {0x80000000, 0x00000001}, {0x80000000, 0x00000002},
412     {0x80000000, 0x00000020}, {0x80000000, 0x0000007d},
413     {0x80000000, 0x0000007e}, {0x80000000, 0x0000007f},
414     {0x80000000, 0x00007ffd}, {0x80000000, 0x00007ffe},
415     {0x80000000, 0x00007fff}, {0x80000000, 0x33333333},
416     {0x80000000, 0x55555555}, {0x80000000, 0x7ffffffd},
417     {0x80000000, 0x7ffffffe}, {0x80000000, 0x7fffffff},
418     {0x80000000, 0x80000000}, {0x80000000, 0x80000001},
419     {0x80000000, 0xaaaaaaaa}, {0x80000000, 0xcccccccc},
420     {0x80000000, 0xffff8000}, {0x80000000, 0xffff8001},
421     {0x80000000, 0xffff8002}, {0x80000000, 0xffff8003},
422     {0x80000000, 0xffffff80}, {0x80000000, 0xffffff81},
423     {0x80000000, 0xffffff82}, {0x80000000, 0xffffff83},
424     {0x80000000, 0xffffffe0}, {0x80000000, 0xfffffffd},
425     {0x80000000, 0xfffffffe}, {0x80000000, 0xffffffff},
426     {0x80000001, 0x00000000}, {0x80000001, 0x00000001},
427     {0x80000001, 0x00000002}, {0x80000001, 0x00000020},
428     {0x80000001, 0x0000007d}, {0x80000001, 0x0000007e},
429     {0x80000001, 0x0000007f}, {0x80000001, 0x00007ffd},
430     {0x80000001, 0x00007ffe}, {0x80000001, 0x00007fff},
431     {0x80000001, 0x33333333}, {0x80000001, 0x55555555},
432     {0x80000001, 0x7ffffffd}, {0x80000001, 0x7ffffffe},
433     {0x80000001, 0x7fffffff}, {0x80000001, 0x80000000},
434     {0x80000001, 0x80000001}, {0x80000001, 0xaaaaaaaa},
435     {0x80000001, 0xcccccccc}, {0x80000001, 0xffff8000},
436     {0x80000001, 0xffff8001}, {0x80000001, 0xffff8002},
437     {0x80000001, 0xffff8003}, {0x80000001, 0xffffff80},
438     {0x80000001, 0xffffff81}, {0x80000001, 0xffffff82},
439     {0x80000001, 0xffffff83}, {0x80000001, 0xffffffe0},
440     {0x80000001, 0xfffffffd}, {0x80000001, 0xfffffffe},
441     {0x80000001, 0xffffffff}, {0xaaaaaaaa, 0x00000000},
442     {0xaaaaaaaa, 0x00000001}, {0xaaaaaaaa, 0x00000002},
443     {0xaaaaaaaa, 0x00000020}, {0xaaaaaaaa, 0x0000007d},
444     {0xaaaaaaaa, 0x0000007e}, {0xaaaaaaaa, 0x0000007f},
445     {0xaaaaaaaa, 0x00007ffd}, {0xaaaaaaaa, 0x00007ffe},
446     {0xaaaaaaaa, 0x00007fff}, {0xaaaaaaaa, 0x33333333},
447     {0xaaaaaaaa, 0x55555555}, {0xaaaaaaaa, 0x7ffffffd},
448     {0xaaaaaaaa, 0x7ffffffe}, {0xaaaaaaaa, 0x7fffffff},
449     {0xaaaaaaaa, 0x80000000}, {0xaaaaaaaa, 0x80000001},
450     {0xaaaaaaaa, 0xaaaaaaaa}, {0xaaaaaaaa, 0xcccccccc},
451     {0xaaaaaaaa, 0xffff8000}, {0xaaaaaaaa, 0xffff8001},
452     {0xaaaaaaaa, 0xffff8002}, {0xaaaaaaaa, 0xffff8003},
453     {0xaaaaaaaa, 0xffffff80}, {0xaaaaaaaa, 0xffffff81},
454     {0xaaaaaaaa, 0xffffff82}, {0xaaaaaaaa, 0xffffff83},
455     {0xaaaaaaaa, 0xffffffe0}, {0xaaaaaaaa, 0xfffffffd},
456     {0xaaaaaaaa, 0xfffffffe}, {0xaaaaaaaa, 0xffffffff},
457     {0xcccccccc, 0x00000000}, {0xcccccccc, 0x00000001},
458     {0xcccccccc, 0x00000002}, {0xcccccccc, 0x00000020},
459     {0xcccccccc, 0x0000007d}, {0xcccccccc, 0x0000007e},
460     {0xcccccccc, 0x0000007f}, {0xcccccccc, 0x00007ffd},
461     {0xcccccccc, 0x00007ffe}, {0xcccccccc, 0x00007fff},
462     {0xcccccccc, 0x33333333}, {0xcccccccc, 0x55555555},
463     {0xcccccccc, 0x7ffffffd}, {0xcccccccc, 0x7ffffffe},
464     {0xcccccccc, 0x7fffffff}, {0xcccccccc, 0x80000000},
465     {0xcccccccc, 0x80000001}, {0xcccccccc, 0xaaaaaaaa},
466     {0xcccccccc, 0xcccccccc}, {0xcccccccc, 0xffff8000},
467     {0xcccccccc, 0xffff8001}, {0xcccccccc, 0xffff8002},
468     {0xcccccccc, 0xffff8003}, {0xcccccccc, 0xffffff80},
469     {0xcccccccc, 0xffffff81}, {0xcccccccc, 0xffffff82},
470     {0xcccccccc, 0xffffff83}, {0xcccccccc, 0xffffffe0},
471     {0xcccccccc, 0xfffffffd}, {0xcccccccc, 0xfffffffe},
472     {0xcccccccc, 0xffffffff}, {0xffff8000, 0x00000000},
473     {0xffff8000, 0x00000001}, {0xffff8000, 0x00000002},
474     {0xffff8000, 0x00000020}, {0xffff8000, 0x0000007d},
475     {0xffff8000, 0x0000007e}, {0xffff8000, 0x0000007f},
476     {0xffff8000, 0x00007ffd}, {0xffff8000, 0x00007ffe},
477     {0xffff8000, 0x00007fff}, {0xffff8000, 0x33333333},
478     {0xffff8000, 0x55555555}, {0xffff8000, 0x7ffffffd},
479     {0xffff8000, 0x7ffffffe}, {0xffff8000, 0x7fffffff},
480     {0xffff8000, 0x80000000}, {0xffff8000, 0x80000001},
481     {0xffff8000, 0xaaaaaaaa}, {0xffff8000, 0xcccccccc},
482     {0xffff8000, 0xffff8000}, {0xffff8000, 0xffff8001},
483     {0xffff8000, 0xffff8002}, {0xffff8000, 0xffff8003},
484     {0xffff8000, 0xffffff80}, {0xffff8000, 0xffffff81},
485     {0xffff8000, 0xffffff82}, {0xffff8000, 0xffffff83},
486     {0xffff8000, 0xffffffe0}, {0xffff8000, 0xfffffffd},
487     {0xffff8000, 0xfffffffe}, {0xffff8000, 0xffffffff},
488     {0xffff8001, 0x00000000}, {0xffff8001, 0x00000001},
489     {0xffff8001, 0x00000002}, {0xffff8001, 0x00000020},
490     {0xffff8001, 0x0000007d}, {0xffff8001, 0x0000007e},
491     {0xffff8001, 0x0000007f}, {0xffff8001, 0x00007ffd},
492     {0xffff8001, 0x00007ffe}, {0xffff8001, 0x00007fff},
493     {0xffff8001, 0x33333333}, {0xffff8001, 0x55555555},
494     {0xffff8001, 0x7ffffffd}, {0xffff8001, 0x7ffffffe},
495     {0xffff8001, 0x7fffffff}, {0xffff8001, 0x80000000},
496     {0xffff8001, 0x80000001}, {0xffff8001, 0xaaaaaaaa},
497     {0xffff8001, 0xcccccccc}, {0xffff8001, 0xffff8000},
498     {0xffff8001, 0xffff8001}, {0xffff8001, 0xffff8002},
499     {0xffff8001, 0xffff8003}, {0xffff8001, 0xffffff80},
500     {0xffff8001, 0xffffff81}, {0xffff8001, 0xffffff82},
501     {0xffff8001, 0xffffff83}, {0xffff8001, 0xffffffe0},
502     {0xffff8001, 0xfffffffd}, {0xffff8001, 0xfffffffe},
503     {0xffff8001, 0xffffffff}, {0xffff8002, 0x00000000},
504     {0xffff8002, 0x00000001}, {0xffff8002, 0x00000002},
505     {0xffff8002, 0x00000020}, {0xffff8002, 0x0000007d},
506     {0xffff8002, 0x0000007e}, {0xffff8002, 0x0000007f},
507     {0xffff8002, 0x00007ffd}, {0xffff8002, 0x00007ffe},
508     {0xffff8002, 0x00007fff}, {0xffff8002, 0x33333333},
509     {0xffff8002, 0x55555555}, {0xffff8002, 0x7ffffffd},
510     {0xffff8002, 0x7ffffffe}, {0xffff8002, 0x7fffffff},
511     {0xffff8002, 0x80000000}, {0xffff8002, 0x80000001},
512     {0xffff8002, 0xaaaaaaaa}, {0xffff8002, 0xcccccccc},
513     {0xffff8002, 0xffff8000}, {0xffff8002, 0xffff8001},
514     {0xffff8002, 0xffff8002}, {0xffff8002, 0xffff8003},
515     {0xffff8002, 0xffffff80}, {0xffff8002, 0xffffff81},
516     {0xffff8002, 0xffffff82}, {0xffff8002, 0xffffff83},
517     {0xffff8002, 0xffffffe0}, {0xffff8002, 0xfffffffd},
518     {0xffff8002, 0xfffffffe}, {0xffff8002, 0xffffffff},
519     {0xffff8003, 0x00000000}, {0xffff8003, 0x00000001},
520     {0xffff8003, 0x00000002}, {0xffff8003, 0x00000020},
521     {0xffff8003, 0x0000007d}, {0xffff8003, 0x0000007e},
522     {0xffff8003, 0x0000007f}, {0xffff8003, 0x00007ffd},
523     {0xffff8003, 0x00007ffe}, {0xffff8003, 0x00007fff},
524     {0xffff8003, 0x33333333}, {0xffff8003, 0x55555555},
525     {0xffff8003, 0x7ffffffd}, {0xffff8003, 0x7ffffffe},
526     {0xffff8003, 0x7fffffff}, {0xffff8003, 0x80000000},
527     {0xffff8003, 0x80000001}, {0xffff8003, 0xaaaaaaaa},
528     {0xffff8003, 0xcccccccc}, {0xffff8003, 0xffff8000},
529     {0xffff8003, 0xffff8001}, {0xffff8003, 0xffff8002},
530     {0xffff8003, 0xffff8003}, {0xffff8003, 0xffffff80},
531     {0xffff8003, 0xffffff81}, {0xffff8003, 0xffffff82},
532     {0xffff8003, 0xffffff83}, {0xffff8003, 0xffffffe0},
533     {0xffff8003, 0xfffffffd}, {0xffff8003, 0xfffffffe},
534     {0xffff8003, 0xffffffff}, {0xffffff80, 0x00000000},
535     {0xffffff80, 0x00000001}, {0xffffff80, 0x00000002},
536     {0xffffff80, 0x00000020}, {0xffffff80, 0x0000007d},
537     {0xffffff80, 0x0000007e}, {0xffffff80, 0x0000007f},
538     {0xffffff80, 0x00007ffd}, {0xffffff80, 0x00007ffe},
539     {0xffffff80, 0x00007fff}, {0xffffff80, 0x33333333},
540     {0xffffff80, 0x55555555}, {0xffffff80, 0x7ffffffd},
541     {0xffffff80, 0x7ffffffe}, {0xffffff80, 0x7fffffff},
542     {0xffffff80, 0x80000000}, {0xffffff80, 0x80000001},
543     {0xffffff80, 0xaaaaaaaa}, {0xffffff80, 0xcccccccc},
544     {0xffffff80, 0xffff8000}, {0xffffff80, 0xffff8001},
545     {0xffffff80, 0xffff8002}, {0xffffff80, 0xffff8003},
546     {0xffffff80, 0xffffff80}, {0xffffff80, 0xffffff81},
547     {0xffffff80, 0xffffff82}, {0xffffff80, 0xffffff83},
548     {0xffffff80, 0xffffffe0}, {0xffffff80, 0xfffffffd},
549     {0xffffff80, 0xfffffffe}, {0xffffff80, 0xffffffff},
550     {0xffffff81, 0x00000000}, {0xffffff81, 0x00000001},
551     {0xffffff81, 0x00000002}, {0xffffff81, 0x00000020},
552     {0xffffff81, 0x0000007d}, {0xffffff81, 0x0000007e},
553     {0xffffff81, 0x0000007f}, {0xffffff81, 0x00007ffd},
554     {0xffffff81, 0x00007ffe}, {0xffffff81, 0x00007fff},
555     {0xffffff81, 0x33333333}, {0xffffff81, 0x55555555},
556     {0xffffff81, 0x7ffffffd}, {0xffffff81, 0x7ffffffe},
557     {0xffffff81, 0x7fffffff}, {0xffffff81, 0x80000000},
558     {0xffffff81, 0x80000001}, {0xffffff81, 0xaaaaaaaa},
559     {0xffffff81, 0xcccccccc}, {0xffffff81, 0xffff8000},
560     {0xffffff81, 0xffff8001}, {0xffffff81, 0xffff8002},
561     {0xffffff81, 0xffff8003}, {0xffffff81, 0xffffff80},
562     {0xffffff81, 0xffffff81}, {0xffffff81, 0xffffff82},
563     {0xffffff81, 0xffffff83}, {0xffffff81, 0xffffffe0},
564     {0xffffff81, 0xfffffffd}, {0xffffff81, 0xfffffffe},
565     {0xffffff81, 0xffffffff}, {0xffffff82, 0x00000000},
566     {0xffffff82, 0x00000001}, {0xffffff82, 0x00000002},
567     {0xffffff82, 0x00000020}, {0xffffff82, 0x0000007d},
568     {0xffffff82, 0x0000007e}, {0xffffff82, 0x0000007f},
569     {0xffffff82, 0x00007ffd}, {0xffffff82, 0x00007ffe},
570     {0xffffff82, 0x00007fff}, {0xffffff82, 0x33333333},
571     {0xffffff82, 0x55555555}, {0xffffff82, 0x7ffffffd},
572     {0xffffff82, 0x7ffffffe}, {0xffffff82, 0x7fffffff},
573     {0xffffff82, 0x80000000}, {0xffffff82, 0x80000001},
574     {0xffffff82, 0xaaaaaaaa}, {0xffffff82, 0xcccccccc},
575     {0xffffff82, 0xffff8000}, {0xffffff82, 0xffff8001},
576     {0xffffff82, 0xffff8002}, {0xffffff82, 0xffff8003},
577     {0xffffff82, 0xffffff80}, {0xffffff82, 0xffffff81},
578     {0xffffff82, 0xffffff82}, {0xffffff82, 0xffffff83},
579     {0xffffff82, 0xffffffe0}, {0xffffff82, 0xfffffffd},
580     {0xffffff82, 0xfffffffe}, {0xffffff82, 0xffffffff},
581     {0xffffff83, 0x00000000}, {0xffffff83, 0x00000001},
582     {0xffffff83, 0x00000002}, {0xffffff83, 0x00000020},
583     {0xffffff83, 0x0000007d}, {0xffffff83, 0x0000007e},
584     {0xffffff83, 0x0000007f}, {0xffffff83, 0x00007ffd},
585     {0xffffff83, 0x00007ffe}, {0xffffff83, 0x00007fff},
586     {0xffffff83, 0x33333333}, {0xffffff83, 0x55555555},
587     {0xffffff83, 0x7ffffffd}, {0xffffff83, 0x7ffffffe},
588     {0xffffff83, 0x7fffffff}, {0xffffff83, 0x80000000},
589     {0xffffff83, 0x80000001}, {0xffffff83, 0xaaaaaaaa},
590     {0xffffff83, 0xcccccccc}, {0xffffff83, 0xffff8000},
591     {0xffffff83, 0xffff8001}, {0xffffff83, 0xffff8002},
592     {0xffffff83, 0xffff8003}, {0xffffff83, 0xffffff80},
593     {0xffffff83, 0xffffff81}, {0xffffff83, 0xffffff82},
594     {0xffffff83, 0xffffff83}, {0xffffff83, 0xffffffe0},
595     {0xffffff83, 0xfffffffd}, {0xffffff83, 0xfffffffe},
596     {0xffffff83, 0xffffffff}, {0xffffffe0, 0x00000000},
597     {0xffffffe0, 0x00000001}, {0xffffffe0, 0x00000002},
598     {0xffffffe0, 0x00000020}, {0xffffffe0, 0x0000007d},
599     {0xffffffe0, 0x0000007e}, {0xffffffe0, 0x0000007f},
600     {0xffffffe0, 0x00007ffd}, {0xffffffe0, 0x00007ffe},
601     {0xffffffe0, 0x00007fff}, {0xffffffe0, 0x33333333},
602     {0xffffffe0, 0x55555555}, {0xffffffe0, 0x7ffffffd},
603     {0xffffffe0, 0x7ffffffe}, {0xffffffe0, 0x7fffffff},
604     {0xffffffe0, 0x80000000}, {0xffffffe0, 0x80000001},
605     {0xffffffe0, 0xaaaaaaaa}, {0xffffffe0, 0xcccccccc},
606     {0xffffffe0, 0xffff8000}, {0xffffffe0, 0xffff8001},
607     {0xffffffe0, 0xffff8002}, {0xffffffe0, 0xffff8003},
608     {0xffffffe0, 0xffffff80}, {0xffffffe0, 0xffffff81},
609     {0xffffffe0, 0xffffff82}, {0xffffffe0, 0xffffff83},
610     {0xffffffe0, 0xffffffe0}, {0xffffffe0, 0xfffffffd},
611     {0xffffffe0, 0xfffffffe}, {0xffffffe0, 0xffffffff},
612     {0xfffffffd, 0x00000000}, {0xfffffffd, 0x00000001},
613     {0xfffffffd, 0x00000002}, {0xfffffffd, 0x00000020},
614     {0xfffffffd, 0x0000007d}, {0xfffffffd, 0x0000007e},
615     {0xfffffffd, 0x0000007f}, {0xfffffffd, 0x00007ffd},
616     {0xfffffffd, 0x00007ffe}, {0xfffffffd, 0x00007fff},
617     {0xfffffffd, 0x33333333}, {0xfffffffd, 0x55555555},
618     {0xfffffffd, 0x7ffffffd}, {0xfffffffd, 0x7ffffffe},
619     {0xfffffffd, 0x7fffffff}, {0xfffffffd, 0x80000000},
620     {0xfffffffd, 0x80000001}, {0xfffffffd, 0xaaaaaaaa},
621     {0xfffffffd, 0xcccccccc}, {0xfffffffd, 0xffff8000},
622     {0xfffffffd, 0xffff8001}, {0xfffffffd, 0xffff8002},
623     {0xfffffffd, 0xffff8003}, {0xfffffffd, 0xffffff80},
624     {0xfffffffd, 0xffffff81}, {0xfffffffd, 0xffffff82},
625     {0xfffffffd, 0xffffff83}, {0xfffffffd, 0xffffffe0},
626     {0xfffffffd, 0xfffffffd}, {0xfffffffd, 0xfffffffe},
627     {0xfffffffd, 0xffffffff}, {0xfffffffe, 0x00000000},
628     {0xfffffffe, 0x00000001}, {0xfffffffe, 0x00000002},
629     {0xfffffffe, 0x00000020}, {0xfffffffe, 0x0000007d},
630     {0xfffffffe, 0x0000007e}, {0xfffffffe, 0x0000007f},
631     {0xfffffffe, 0x00007ffd}, {0xfffffffe, 0x00007ffe},
632     {0xfffffffe, 0x00007fff}, {0xfffffffe, 0x33333333},
633     {0xfffffffe, 0x55555555}, {0xfffffffe, 0x7ffffffd},
634     {0xfffffffe, 0x7ffffffe}, {0xfffffffe, 0x7fffffff},
635     {0xfffffffe, 0x80000000}, {0xfffffffe, 0x80000001},
636     {0xfffffffe, 0xaaaaaaaa}, {0xfffffffe, 0xcccccccc},
637     {0xfffffffe, 0xffff8000}, {0xfffffffe, 0xffff8001},
638     {0xfffffffe, 0xffff8002}, {0xfffffffe, 0xffff8003},
639     {0xfffffffe, 0xffffff80}, {0xfffffffe, 0xffffff81},
640     {0xfffffffe, 0xffffff82}, {0xfffffffe, 0xffffff83},
641     {0xfffffffe, 0xffffffe0}, {0xfffffffe, 0xfffffffd},
642     {0xfffffffe, 0xfffffffe}, {0xfffffffe, 0xffffffff},
643     {0xffffffff, 0x00000000}, {0xffffffff, 0x00000001},
644     {0xffffffff, 0x00000002}, {0xffffffff, 0x00000020},
645     {0xffffffff, 0x0000007d}, {0xffffffff, 0x0000007e},
646     {0xffffffff, 0x0000007f}, {0xffffffff, 0x00007ffd},
647     {0xffffffff, 0x00007ffe}, {0xffffffff, 0x00007fff},
648     {0xffffffff, 0x33333333}, {0xffffffff, 0x55555555},
649     {0xffffffff, 0x7ffffffd}, {0xffffffff, 0x7ffffffe},
650     {0xffffffff, 0x7fffffff}, {0xffffffff, 0x80000000},
651     {0xffffffff, 0x80000001}, {0xffffffff, 0xaaaaaaaa},
652     {0xffffffff, 0xcccccccc}, {0xffffffff, 0xffff8000},
653     {0xffffffff, 0xffff8001}, {0xffffffff, 0xffff8002},
654     {0xffffffff, 0xffff8003}, {0xffffffff, 0xffffff80},
655     {0xffffffff, 0xffffff81}, {0xffffffff, 0xffffff82},
656     {0xffffffff, 0xffffff83}, {0xffffffff, 0xffffffe0},
657     {0xffffffff, 0xfffffffd}, {0xffffffff, 0xfffffffe},
658     {0xffffffff, 0xffffffff}};
659
660static const Inputs kImmediate[] =
661    {{0xabababab, 0x00000000}, {0xabababab, 0x00000001},
662     {0xabababab, 0x00000002}, {0xabababab, 0x00000020},
663     {0xabababab, 0x0000007d}, {0xabababab, 0x0000007e},
664     {0xabababab, 0x0000007f}, {0xabababab, 0x00007ffd},
665     {0xabababab, 0x00007ffe}, {0xabababab, 0x00007fff},
666     {0xabababab, 0x33333333}, {0xabababab, 0x55555555},
667     {0xabababab, 0x7ffffffd}, {0xabababab, 0x7ffffffe},
668     {0xabababab, 0x7fffffff}, {0xabababab, 0x80000000},
669     {0xabababab, 0x80000001}, {0xabababab, 0xaaaaaaaa},
670     {0xabababab, 0xcccccccc}, {0xabababab, 0xffff8000},
671     {0xabababab, 0xffff8001}, {0xabababab, 0xffff8002},
672     {0xabababab, 0xffff8003}, {0xabababab, 0xffffff80},
673     {0xabababab, 0xffffff81}, {0xabababab, 0xffffff82},
674     {0xabababab, 0xffffff83}, {0xabababab, 0xffffffe0},
675     {0xabababab, 0xfffffffd}, {0xabababab, 0xfffffffe},
676     {0xabababab, 0xffffffff}};
677
678
679// A loop will be generated for each element of this array.
680const TestLoopData kTests[] = {{{al, r4, r4, 4018},
681                                "al r4 r4 4018",
682                                "RdIsRn_al_r4_r4_4018",
683                                ARRAY_SIZE(kRdIsRn),
684                                kRdIsRn},
685                               {{al, r0, r0, 490},
686                                "al r0 r0 490",
687                                "RdIsRn_al_r0_r0_490",
688                                ARRAY_SIZE(kRdIsRn),
689                                kRdIsRn},
690                               {{al, r1, r1, 2365},
691                                "al r1 r1 2365",
692                                "RdIsRn_al_r1_r1_2365",
693                                ARRAY_SIZE(kRdIsRn),
694                                kRdIsRn},
695                               {{al, r9, r9, 2945},
696                                "al r9 r9 2945",
697                                "RdIsRn_al_r9_r9_2945",
698                                ARRAY_SIZE(kRdIsRn),
699                                kRdIsRn},
700                               {{al, r14, r14, 3287},
701                                "al r14 r14 3287",
702                                "RdIsRn_al_r14_r14_3287",
703                                ARRAY_SIZE(kRdIsRn),
704                                kRdIsRn},
705                               {{al, r1, r1, 3529},
706                                "al r1 r1 3529",
707                                "RdIsRn_al_r1_r1_3529",
708                                ARRAY_SIZE(kRdIsRn),
709                                kRdIsRn},
710                               {{al, r11, r11, 2072},
711                                "al r11 r11 2072",
712                                "RdIsRn_al_r11_r11_2072",
713                                ARRAY_SIZE(kRdIsRn),
714                                kRdIsRn},
715                               {{al, r7, r7, 850},
716                                "al r7 r7 850",
717                                "RdIsRn_al_r7_r7_850",
718                                ARRAY_SIZE(kRdIsRn),
719                                kRdIsRn},
720                               {{al, r3, r3, 3384},
721                                "al r3 r3 3384",
722                                "RdIsRn_al_r3_r3_3384",
723                                ARRAY_SIZE(kRdIsRn),
724                                kRdIsRn},
725                               {{al, r7, r7, 1374},
726                                "al r7 r7 1374",
727                                "RdIsRn_al_r7_r7_1374",
728                                ARRAY_SIZE(kRdIsRn),
729                                kRdIsRn},
730                               {{al, r4, r14, 3391},
731                                "al r4 r14 3391",
732                                "RdIsNotRn_al_r4_r14_3391",
733                                ARRAY_SIZE(kRdIsNotRn),
734                                kRdIsNotRn},
735                               {{al, r0, r4, 960},
736                                "al r0 r4 960",
737                                "RdIsNotRn_al_r0_r4_960",
738                                ARRAY_SIZE(kRdIsNotRn),
739                                kRdIsNotRn},
740                               {{al, r8, r5, 2021},
741                                "al r8 r5 2021",
742                                "RdIsNotRn_al_r8_r5_2021",
743                                ARRAY_SIZE(kRdIsNotRn),
744                                kRdIsNotRn},
745                               {{al, r5, r4, 783},
746                                "al r5 r4 783",
747                                "RdIsNotRn_al_r5_r4_783",
748                                ARRAY_SIZE(kRdIsNotRn),
749                                kRdIsNotRn},
750                               {{al, r9, r5, 3566},
751                                "al r9 r5 3566",
752                                "RdIsNotRn_al_r9_r5_3566",
753                                ARRAY_SIZE(kRdIsNotRn),
754                                kRdIsNotRn},
755                               {{al, r2, r14, 3195},
756                                "al r2 r14 3195",
757                                "RdIsNotRn_al_r2_r14_3195",
758                                ARRAY_SIZE(kRdIsNotRn),
759                                kRdIsNotRn},
760                               {{al, r1, r2, 484},
761                                "al r1 r2 484",
762                                "RdIsNotRn_al_r1_r2_484",
763                                ARRAY_SIZE(kRdIsNotRn),
764                                kRdIsNotRn},
765                               {{al, r1, r8, 1374},
766                                "al r1 r8 1374",
767                                "RdIsNotRn_al_r1_r8_1374",
768                                ARRAY_SIZE(kRdIsNotRn),
769                                kRdIsNotRn},
770                               {{al, r12, r3, 2366},
771                                "al r12 r3 2366",
772                                "RdIsNotRn_al_r12_r3_2366",
773                                ARRAY_SIZE(kRdIsNotRn),
774                                kRdIsNotRn},
775                               {{al, r7, r2, 1505},
776                                "al r7 r2 1505",
777                                "RdIsNotRn_al_r7_r2_1505",
778                                ARRAY_SIZE(kRdIsNotRn),
779                                kRdIsNotRn},
780                               {{al, r0, r0, 3570},
781                                "al r0 r0 3570",
782                                "Immediate_al_r0_r0_3570",
783                                ARRAY_SIZE(kImmediate),
784                                kImmediate},
785                               {{al, r0, r0, 2535},
786                                "al r0 r0 2535",
787                                "Immediate_al_r0_r0_2535",
788                                ARRAY_SIZE(kImmediate),
789                                kImmediate},
790                               {{al, r0, r0, 3239},
791                                "al r0 r0 3239",
792                                "Immediate_al_r0_r0_3239",
793                                ARRAY_SIZE(kImmediate),
794                                kImmediate},
795                               {{al, r0, r0, 2403},
796                                "al r0 r0 2403",
797                                "Immediate_al_r0_r0_2403",
798                                ARRAY_SIZE(kImmediate),
799                                kImmediate},
800                               {{al, r0, r0, 2290},
801                                "al r0 r0 2290",
802                                "Immediate_al_r0_r0_2290",
803                                ARRAY_SIZE(kImmediate),
804                                kImmediate},
805                               {{al, r0, r0, 606},
806                                "al r0 r0 606",
807                                "Immediate_al_r0_r0_606",
808                                ARRAY_SIZE(kImmediate),
809                                kImmediate},
810                               {{al, r0, r0, 2323},
811                                "al r0 r0 2323",
812                                "Immediate_al_r0_r0_2323",
813                                ARRAY_SIZE(kImmediate),
814                                kImmediate},
815                               {{al, r0, r0, 1759},
816                                "al r0 r0 1759",
817                                "Immediate_al_r0_r0_1759",
818                                ARRAY_SIZE(kImmediate),
819                                kImmediate},
820                               {{al, r0, r0, 47},
821                                "al r0 r0 47",
822                                "Immediate_al_r0_r0_47",
823                                ARRAY_SIZE(kImmediate),
824                                kImmediate},
825                               {{al, r0, r0, 3063},
826                                "al r0 r0 3063",
827                                "Immediate_al_r0_r0_3063",
828                                ARRAY_SIZE(kImmediate),
829                                kImmediate},
830                               {{al, r0, r0, 3256},
831                                "al r0 r0 3256",
832                                "Immediate_al_r0_r0_3256",
833                                ARRAY_SIZE(kImmediate),
834                                kImmediate},
835                               {{al, r0, r0, 3626},
836                                "al r0 r0 3626",
837                                "Immediate_al_r0_r0_3626",
838                                ARRAY_SIZE(kImmediate),
839                                kImmediate},
840                               {{al, r0, r0, 525},
841                                "al r0 r0 525",
842                                "Immediate_al_r0_r0_525",
843                                ARRAY_SIZE(kImmediate),
844                                kImmediate},
845                               {{al, r0, r0, 3659},
846                                "al r0 r0 3659",
847                                "Immediate_al_r0_r0_3659",
848                                ARRAY_SIZE(kImmediate),
849                                kImmediate},
850                               {{al, r0, r0, 3195},
851                                "al r0 r0 3195",
852                                "Immediate_al_r0_r0_3195",
853                                ARRAY_SIZE(kImmediate),
854                                kImmediate},
855                               {{al, r0, r0, 2507},
856                                "al r0 r0 2507",
857                                "Immediate_al_r0_r0_2507",
858                                ARRAY_SIZE(kImmediate),
859                                kImmediate},
860                               {{al, r0, r0, 3076},
861                                "al r0 r0 3076",
862                                "Immediate_al_r0_r0_3076",
863                                ARRAY_SIZE(kImmediate),
864                                kImmediate},
865                               {{al, r0, r0, 2338},
866                                "al r0 r0 2338",
867                                "Immediate_al_r0_r0_2338",
868                                ARRAY_SIZE(kImmediate),
869                                kImmediate},
870                               {{al, r0, r0, 3282},
871                                "al r0 r0 3282",
872                                "Immediate_al_r0_r0_3282",
873                                ARRAY_SIZE(kImmediate),
874                                kImmediate},
875                               {{al, r0, r0, 2374},
876                                "al r0 r0 2374",
877                                "Immediate_al_r0_r0_2374",
878                                ARRAY_SIZE(kImmediate),
879                                kImmediate}};
880
881// We record all inputs to the instructions as outputs. This way, we also check
882// that what shouldn't change didn't change.
883struct TestResult {
884  size_t output_size;
885  const Inputs* outputs;
886};
887
888// These headers each contain an array of `TestResult` with the reference output
889// values. The reference arrays are names `kReference{mnemonic}`.
890#include "aarch32/traces/simulator-cond-rd-rn-operand-imm12-add-t32.h"
891#include "aarch32/traces/simulator-cond-rd-rn-operand-imm12-sub-t32.h"
892
893
894// The maximum number of errors to report in detail for each test.
895const unsigned kErrorReportLimit = 8;
896
897typedef void (MacroAssembler::*Fn)(Condition cond,
898                                   Register rd,
899                                   Register rn,
900                                   const Operand& op);
901
902void TestHelper(Fn instruction,
903                const char* mnemonic,
904                const TestResult reference[]) {
905  SETUP();
906  masm.UseT32();
907  START();
908
909  // Data to compare to `reference`.
910  TestResult* results[ARRAY_SIZE(kTests)];
911
912  // Test cases for memory bound instructions may allocate a buffer and save its
913  // address in this array.
914  byte* scratch_memory_buffers[ARRAY_SIZE(kTests)];
915
916  // Generate a loop for each element in `kTests`. Each loop tests one specific
917  // instruction.
918  for (unsigned i = 0; i < ARRAY_SIZE(kTests); i++) {
919    // Allocate results on the heap for this test.
920    results[i] = new TestResult;
921    results[i]->outputs = new Inputs[kTests[i].input_size];
922    results[i]->output_size = kTests[i].input_size;
923
924    size_t input_stride = sizeof(kTests[i].inputs[0]) * kTests[i].input_size;
925    VIXL_ASSERT(IsUint32(input_stride));
926
927    scratch_memory_buffers[i] = NULL;
928
929    Label loop;
930    UseScratchRegisterScope scratch_registers(&masm);
931    // Include all registers from r0 ro r12.
932    scratch_registers.Include(RegisterList(0x1fff));
933
934    // Values to pass to the macro-assembler.
935    Condition cond = kTests[i].operands.cond;
936    Register rd = kTests[i].operands.rd;
937    Register rn = kTests[i].operands.rn;
938    int32_t immediate = kTests[i].operands.immediate;
939    Operand op(immediate);
940    scratch_registers.Exclude(rd);
941    scratch_registers.Exclude(rn);
942
943    // Allocate reserved registers for our own use.
944    Register input_ptr = scratch_registers.Acquire();
945    Register input_end = scratch_registers.Acquire();
946    Register result_ptr = scratch_registers.Acquire();
947
948    // Initialize `input_ptr` to the first element and `input_end` the address
949    // after the array.
950    __ Mov(input_ptr, Operand::From(kTests[i].inputs));
951    __ Add(input_end, input_ptr, static_cast<uint32_t>(input_stride));
952    __ Mov(result_ptr, Operand::From(results[i]->outputs));
953    __ Bind(&loop);
954
955    __ Ldr(rd, MemOperand(input_ptr, offsetof(Inputs, rd)));
956    __ Ldr(rn, MemOperand(input_ptr, offsetof(Inputs, rn)));
957
958    (masm.*instruction)(cond, rd, rn, op);
959
960    __ Str(rd, MemOperand(result_ptr, offsetof(Inputs, rd)));
961    __ Str(rn, MemOperand(result_ptr, offsetof(Inputs, rn)));
962
963    // Advance the result pointer.
964    __ Add(result_ptr, result_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
965    // Loop back until `input_ptr` is lower than `input_base`.
966    __ Add(input_ptr, input_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
967    __ Cmp(input_ptr, input_end);
968    __ B(ne, &loop);
969  }
970
971  END();
972
973  RUN();
974
975  if (Test::generate_test_trace()) {
976    // Print the results.
977    for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
978      printf("const Inputs kOutputs_%s_%s[] = {\n",
979             mnemonic,
980             kTests[i].identifier);
981      for (size_t j = 0; j < results[i]->output_size; j++) {
982        printf("  { ");
983        printf("0x%08" PRIx32, results[i]->outputs[j].rd);
984        printf(", ");
985        printf("0x%08" PRIx32, results[i]->outputs[j].rn);
986        printf(" },\n");
987      }
988      printf("};\n");
989    }
990    printf("const TestResult kReference%s[] = {\n", mnemonic);
991    for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
992      printf("  {\n");
993      printf("    ARRAY_SIZE(kOutputs_%s_%s),\n",
994             mnemonic,
995             kTests[i].identifier);
996      printf("    kOutputs_%s_%s,\n", mnemonic, kTests[i].identifier);
997      printf("  },\n");
998    }
999    printf("};\n");
1000  } else if (kCheckSimulatorTestResults) {
1001    // Check the results.
1002    unsigned total_error_count = 0;
1003    for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
1004      bool instruction_has_errors = false;
1005      for (size_t j = 0; j < kTests[i].input_size; j++) {
1006        uint32_t rd = results[i]->outputs[j].rd;
1007        uint32_t rn = results[i]->outputs[j].rn;
1008        uint32_t rd_input = kTests[i].inputs[j].rd;
1009        uint32_t rn_input = kTests[i].inputs[j].rn;
1010        uint32_t rd_ref = reference[i].outputs[j].rd;
1011        uint32_t rn_ref = reference[i].outputs[j].rn;
1012
1013        if (((rd != rd_ref) || (rn != rn_ref)) &&
1014            (++total_error_count <= kErrorReportLimit)) {
1015          // Print the instruction once even if it triggered multiple failures.
1016          if (!instruction_has_errors) {
1017            printf("Error(s) when testing \"%s %s\":\n",
1018                   mnemonic,
1019                   kTests[i].operands_description);
1020            instruction_has_errors = true;
1021          }
1022          // Print subsequent errors.
1023          printf("  Input:    ");
1024          printf("0x%08" PRIx32, rd_input);
1025          printf(", ");
1026          printf("0x%08" PRIx32, rn_input);
1027          printf("\n");
1028          printf("  Expected: ");
1029          printf("0x%08" PRIx32, rd_ref);
1030          printf(", ");
1031          printf("0x%08" PRIx32, rn_ref);
1032          printf("\n");
1033          printf("  Found:    ");
1034          printf("0x%08" PRIx32, rd);
1035          printf(", ");
1036          printf("0x%08" PRIx32, rn);
1037          printf("\n\n");
1038        }
1039      }
1040    }
1041
1042    if (total_error_count > kErrorReportLimit) {
1043      printf("%u other errors follow.\n",
1044             total_error_count - kErrorReportLimit);
1045    }
1046    VIXL_CHECK(total_error_count == 0);
1047  } else {
1048    VIXL_WARNING("Assembled the code, but did not run anything.\n");
1049  }
1050
1051  for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
1052    delete[] results[i]->outputs;
1053    delete results[i];
1054    delete[] scratch_memory_buffers[i];
1055  }
1056}
1057
1058// Instantiate tests for each instruction in the list.
1059// TODO: Remove this limitation by having a sandboxing mechanism.
1060#if defined(VIXL_HOST_POINTER_32)
1061#define TEST(mnemonic)                                                         \
1062  void Test_##mnemonic() {                                                     \
1063    TestHelper(&MacroAssembler::mnemonic, #mnemonic, kReference##mnemonic);    \
1064  }                                                                            \
1065  Test test_##mnemonic("AARCH32_SIMULATOR_COND_RD_RN_OPERAND_IMM12_" #mnemonic \
1066                       "_T32",                                                 \
1067                       &Test_##mnemonic);
1068#else
1069#define TEST(mnemonic)                                                         \
1070  void Test_##mnemonic() {                                                     \
1071    VIXL_WARNING("This test can only run on a 32-bit host.\n");                \
1072    USE(TestHelper);                                                           \
1073  }                                                                            \
1074  Test test_##mnemonic("AARCH32_SIMULATOR_COND_RD_RN_OPERAND_IMM12_" #mnemonic \
1075                       "_T32",                                                 \
1076                       &Test_##mnemonic);
1077#endif
1078
1079FOREACH_INSTRUCTION(TEST)
1080#undef TEST
1081
1082}  // namespace
1083#endif
1084
1085}  // namespace aarch32
1086}  // namespace vixl
1087