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