1 // Copyright 2016, VIXL authors
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
6 //
7 //   * Redistributions of source code must retain the above copyright notice,
8 //     this list of conditions and the following disclaimer.
9 //   * Redistributions in binary form must reproduce the above copyright notice,
10 //     this list of conditions and the following disclaimer in the documentation
11 //     and/or other materials provided with the distribution.
12 //   * Neither the name of ARM Limited nor the names of its contributors may be
13 //     used to endorse or promote products derived from this software without
14 //     specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
17 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 
27 
28 // -----------------------------------------------------------------------------
29 // This file is auto generated from the
30 // test/aarch32/config/template-simulator-aarch32.cc.in template file using
31 // tools/generate_tests.py.
32 //
33 // PLEASE DO NOT EDIT.
34 // -----------------------------------------------------------------------------
35 
36 
37 #include "test-runner.h"
38 
39 #include "test-utils.h"
40 #include "test-utils-aarch32.h"
41 
42 #include "aarch32/assembler-aarch32.h"
43 #include "aarch32/disasm-aarch32.h"
44 #include "aarch32/macro-assembler-aarch32.h"
45 
46 #define __ masm.
47 #define BUF_SIZE (4096)
48 
49 #ifdef VIXL_INCLUDE_SIMULATOR_AARCH32
50 // Run tests with the simulator.
51 
52 #define SETUP() MacroAssembler masm(BUF_SIZE)
53 
54 #define START() masm.GetBuffer()->Reset()
55 
56 #define END() \
57   __ Hlt(0);  \
58   __ FinalizeCode();
59 
60 // TODO: Run the tests in the simulator.
61 #define RUN()
62 
63 #else  // ifdef VIXL_INCLUDE_SIMULATOR_AARCH32.
64 
65 #define SETUP()                  \
66   MacroAssembler masm(BUF_SIZE); \
67   UseScratchRegisterScope harness_scratch;
68 
69 #define START()                 \
70   harness_scratch.Open(&masm);  \
71   harness_scratch.ExcludeAll(); \
72   masm.GetBuffer()->Reset();    \
73   __ Push(r4);                  \
74   __ Push(r5);                  \
75   __ Push(r6);                  \
76   __ Push(r7);                  \
77   __ Push(r8);                  \
78   __ Push(r9);                  \
79   __ Push(r10);                 \
80   __ Push(r11);                 \
81   __ Push(lr);                  \
82   harness_scratch.Include(ip);
83 
84 #define END()                  \
85   harness_scratch.Exclude(ip); \
86   __ Pop(lr);                  \
87   __ Pop(r11);                 \
88   __ Pop(r10);                 \
89   __ Pop(r9);                  \
90   __ Pop(r8);                  \
91   __ Pop(r7);                  \
92   __ Pop(r6);                  \
93   __ Pop(r5);                  \
94   __ Pop(r4);                  \
95   __ Bx(lr);                   \
96   __ FinalizeCode();           \
97   harness_scratch.Close();
98 
99 #define RUN()                                                 \
100   {                                                           \
101     int pcs_offset = masm.IsUsingT32() ? 1 : 0;               \
102     masm.GetBuffer()->SetExecutable();                        \
103     ExecuteMemory(masm.GetBuffer()->GetStartAddress<byte*>(), \
104                   masm.GetSizeOfCodeGenerated(),              \
105                   pcs_offset);                                \
106     masm.GetBuffer()->SetWritable();                          \
107   }
108 
109 #endif  // ifdef VIXL_INCLUDE_SIMULATOR_AARCH32
110 
111 namespace vixl {
112 namespace aarch32 {
113 
114 // List of instruction encodings:
115 #define FOREACH_INSTRUCTION(M) \
116   M(Adc)                       \
117   M(Adcs)                      \
118   M(Add)                       \
119   M(Adds)                      \
120   M(And)                       \
121   M(Ands)                      \
122   M(Bic)                       \
123   M(Bics)                      \
124   M(Eor)                       \
125   M(Eors)                      \
126   M(Orn)                       \
127   M(Orns)                      \
128   M(Orr)                       \
129   M(Orrs)                      \
130   M(Rsb)                       \
131   M(Rsbs)                      \
132   M(Sbc)                       \
133   M(Sbcs)                      \
134   M(Sub)                       \
135   M(Subs)
136 
137 
138 // The following definitions are defined again in each generated test, therefore
139 // we need to place them in an anomymous namespace. It expresses that they are
140 // local to this file only, and the compiler is not allowed to share these types
141 // across test files during template instantiation. Specifically, `Operands` and
142 // `Inputs` have various layouts across generated tests so they absolutely
143 // cannot be shared.
144 
145 #ifdef VIXL_INCLUDE_TARGET_T32
146 namespace {
147 
148 // Values to be passed to the assembler to produce the instruction under test.
149 struct Operands {
150   Condition cond;
151   Register rd;
152   Register rn;
153   Register rm;
154   ShiftType shift;
155   uint32_t amount;
156 };
157 
158 // Input data to feed to the instruction.
159 struct Inputs {
160   uint32_t apsr;
161   uint32_t rd;
162   uint32_t rn;
163   uint32_t rm;
164 };
165 
166 // This structure contains all input data needed to test one specific encoding.
167 // It used to generate a loop over an instruction.
168 struct TestLoopData {
169   // The `operands` fields represents the values to pass to the assembler to
170   // produce the instruction.
171   Operands operands;
172   // Description of the operands, used for error reporting.
173   const char* operands_description;
174   // Unique identifier, used for generating traces.
175   const char* identifier;
176   // Array of values to be fed to the instruction.
177   size_t input_size;
178   const Inputs* inputs;
179 };
180 
181 static const Inputs kCondition[] =
182     {{NFlag, 0xabababab, 0xabababab, 0xabababab},
183      {ZFlag, 0xabababab, 0xabababab, 0xabababab},
184      {CFlag, 0xabababab, 0xabababab, 0xabababab},
185      {VFlag, 0xabababab, 0xabababab, 0xabababab},
186      {NZFlag, 0xabababab, 0xabababab, 0xabababab},
187      {NCFlag, 0xabababab, 0xabababab, 0xabababab},
188      {NVFlag, 0xabababab, 0xabababab, 0xabababab},
189      {ZCFlag, 0xabababab, 0xabababab, 0xabababab},
190      {ZVFlag, 0xabababab, 0xabababab, 0xabababab},
191      {CVFlag, 0xabababab, 0xabababab, 0xabababab},
192      {NZCFlag, 0xabababab, 0xabababab, 0xabababab},
193      {NZVFlag, 0xabababab, 0xabababab, 0xabababab},
194      {NCVFlag, 0xabababab, 0xabababab, 0xabababab},
195      {ZCVFlag, 0xabababab, 0xabababab, 0xabababab},
196      {NZCVFlag, 0xabababab, 0xabababab, 0xabababab}};
197 
198 static const Inputs kRdIsRn[] = {{NoFlag, 0xffffff83, 0xffffff83, 0xffff8002},
199                                  {NoFlag, 0x0000007e, 0x0000007e, 0x7fffffff},
200                                  {NoFlag, 0x0000007d, 0x0000007d, 0xffffffe0},
201                                  {NoFlag, 0x7fffffff, 0x7fffffff, 0x00000002},
202                                  {NoFlag, 0xffff8002, 0xffff8002, 0xfffffffd},
203                                  {NoFlag, 0xffffffe0, 0xffffffe0, 0x00007fff},
204                                  {NoFlag, 0xffff8000, 0xffff8000, 0xffffff83},
205                                  {NoFlag, 0xffff8002, 0xffff8002, 0x80000001},
206                                  {NoFlag, 0x00007ffd, 0x00007ffd, 0xffff8003},
207                                  {NoFlag, 0x00007fff, 0x00007fff, 0xffffffff},
208                                  {NoFlag, 0x00000000, 0x00000000, 0xffffff80},
209                                  {NoFlag, 0xffff8001, 0xffff8001, 0x33333333},
210                                  {NoFlag, 0xffffff80, 0xffffff80, 0x0000007e},
211                                  {NoFlag, 0x0000007e, 0x0000007e, 0x7ffffffd},
212                                  {NoFlag, 0xffffff80, 0xffffff80, 0xfffffffd},
213                                  {NoFlag, 0x00000020, 0x00000020, 0xffff8002},
214                                  {NoFlag, 0xffffff80, 0xffffff80, 0xfffffffe},
215                                  {NoFlag, 0x00000002, 0x00000002, 0x00000000},
216                                  {NoFlag, 0x0000007e, 0x0000007e, 0x00000001},
217                                  {NoFlag, 0x00000002, 0x00000002, 0x0000007f},
218                                  {NoFlag, 0x80000000, 0x80000000, 0x80000000},
219                                  {NoFlag, 0x7fffffff, 0x7fffffff, 0xffffff80},
220                                  {NoFlag, 0x00000001, 0x00000001, 0xfffffffe},
221                                  {NoFlag, 0x33333333, 0x33333333, 0x0000007d},
222                                  {NoFlag, 0x00000001, 0x00000001, 0x7ffffffe},
223                                  {NoFlag, 0x00007ffe, 0x00007ffe, 0x7fffffff},
224                                  {NoFlag, 0x80000000, 0x80000000, 0xffffff83},
225                                  {NoFlag, 0x00000000, 0x00000000, 0x7ffffffe},
226                                  {NoFlag, 0x00000000, 0x00000000, 0x0000007f},
227                                  {NoFlag, 0x7fffffff, 0x7fffffff, 0xcccccccc},
228                                  {NoFlag, 0xffffff82, 0xffffff82, 0x00000002},
229                                  {NoFlag, 0x7ffffffd, 0x7ffffffd, 0xaaaaaaaa},
230                                  {NoFlag, 0xcccccccc, 0xcccccccc, 0xffff8001},
231                                  {NoFlag, 0xfffffffe, 0xfffffffe, 0xffff8001},
232                                  {NoFlag, 0x7fffffff, 0x7fffffff, 0x00000020},
233                                  {NoFlag, 0xffffffe0, 0xffffffe0, 0x00007ffe},
234                                  {NoFlag, 0x80000001, 0x80000001, 0xffff8000},
235                                  {NoFlag, 0xffffff82, 0xffffff82, 0x0000007d},
236                                  {NoFlag, 0x0000007e, 0x0000007e, 0x7ffffffe},
237                                  {NoFlag, 0x00007ffd, 0x00007ffd, 0xffffff80},
238                                  {NoFlag, 0x0000007d, 0x0000007d, 0x0000007e},
239                                  {NoFlag, 0xffff8002, 0xffff8002, 0x7fffffff},
240                                  {NoFlag, 0xffffffe0, 0xffffffe0, 0x0000007f},
241                                  {NoFlag, 0x00007ffe, 0x00007ffe, 0xffffff81},
242                                  {NoFlag, 0x80000000, 0x80000000, 0x0000007e},
243                                  {NoFlag, 0xffffffff, 0xffffffff, 0xaaaaaaaa},
244                                  {NoFlag, 0xfffffffe, 0xfffffffe, 0x00000020},
245                                  {NoFlag, 0xffffff82, 0xffffff82, 0xffff8003},
246                                  {NoFlag, 0x7ffffffd, 0x7ffffffd, 0xffff8002},
247                                  {NoFlag, 0x7ffffffe, 0x7ffffffe, 0x00000000},
248                                  {NoFlag, 0xfffffffd, 0xfffffffd, 0xffffffe0},
249                                  {NoFlag, 0xffff8000, 0xffff8000, 0xffff8002},
250                                  {NoFlag, 0xffffff82, 0xffffff82, 0x7ffffffd},
251                                  {NoFlag, 0xcccccccc, 0xcccccccc, 0x80000000},
252                                  {NoFlag, 0x80000001, 0x80000001, 0x33333333},
253                                  {NoFlag, 0x00000001, 0x00000001, 0x00000002},
254                                  {NoFlag, 0x55555555, 0x55555555, 0x0000007f},
255                                  {NoFlag, 0xffffffff, 0xffffffff, 0xfffffffd},
256                                  {NoFlag, 0xffffff80, 0xffffff80, 0x80000000},
257                                  {NoFlag, 0x00000000, 0x00000000, 0x00000020},
258                                  {NoFlag, 0xfffffffe, 0xfffffffe, 0xffff8003},
259                                  {NoFlag, 0xffff8001, 0xffff8001, 0xffff8000},
260                                  {NoFlag, 0x55555555, 0x55555555, 0x55555555},
261                                  {NoFlag, 0x00007fff, 0x00007fff, 0xffff8000},
262                                  {NoFlag, 0x7fffffff, 0x7fffffff, 0xffffffe0},
263                                  {NoFlag, 0x00000001, 0x00000001, 0x55555555},
264                                  {NoFlag, 0x33333333, 0x33333333, 0x7ffffffe},
265                                  {NoFlag, 0x80000000, 0x80000000, 0xffffffe0},
266                                  {NoFlag, 0xffffff83, 0xffffff83, 0x0000007d},
267                                  {NoFlag, 0xffff8003, 0xffff8003, 0x00000002},
268                                  {NoFlag, 0x7ffffffe, 0x7ffffffe, 0xffffff81},
269                                  {NoFlag, 0xfffffffe, 0xfffffffe, 0xffffff80},
270                                  {NoFlag, 0x00007ffe, 0x00007ffe, 0xffff8002},
271                                  {NoFlag, 0x80000001, 0x80000001, 0xfffffffe},
272                                  {NoFlag, 0x7ffffffd, 0x7ffffffd, 0xfffffffd},
273                                  {NoFlag, 0x7ffffffd, 0x7ffffffd, 0xfffffffe},
274                                  {NoFlag, 0x7ffffffe, 0x7ffffffe, 0xffffff83},
275                                  {NoFlag, 0xfffffffd, 0xfffffffd, 0x00007ffe},
276                                  {NoFlag, 0x7fffffff, 0x7fffffff, 0x80000000},
277                                  {NoFlag, 0xffffff82, 0xffffff82, 0x7fffffff},
278                                  {NoFlag, 0xffffffe0, 0xffffffe0, 0xffffff83},
279                                  {NoFlag, 0xffff8000, 0xffff8000, 0xffff8000},
280                                  {NoFlag, 0x00000001, 0x00000001, 0x7fffffff},
281                                  {NoFlag, 0xfffffffe, 0xfffffffe, 0xffffffff},
282                                  {NoFlag, 0xffffff82, 0xffffff82, 0xffffffff},
283                                  {NoFlag, 0xffffffff, 0xffffffff, 0xfffffffe},
284                                  {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x0000007d},
285                                  {NoFlag, 0xffff8001, 0xffff8001, 0xfffffffe},
286                                  {NoFlag, 0x00007ffe, 0x00007ffe, 0x0000007d},
287                                  {NoFlag, 0xffffff82, 0xffffff82, 0xfffffffe},
288                                  {NoFlag, 0x00000000, 0x00000000, 0x00007ffd},
289                                  {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0xffff8002},
290                                  {NoFlag, 0x0000007f, 0x0000007f, 0xffffff82},
291                                  {NoFlag, 0x00007fff, 0x00007fff, 0x33333333},
292                                  {NoFlag, 0xfffffffd, 0xfffffffd, 0x80000000},
293                                  {NoFlag, 0x00000000, 0x00000000, 0xfffffffd},
294                                  {NoFlag, 0x0000007d, 0x0000007d, 0x0000007f},
295                                  {NoFlag, 0xfffffffd, 0xfffffffd, 0x0000007e},
296                                  {NoFlag, 0xffffffe0, 0xffffffe0, 0x55555555},
297                                  {NoFlag, 0xffffffff, 0xffffffff, 0x80000000},
298                                  {NoFlag, 0xffffffe0, 0xffffffe0, 0x0000007e},
299                                  {NoFlag, 0xffffff81, 0xffffff81, 0x00007ffd},
300                                  {NoFlag, 0x00000020, 0x00000020, 0xffff8001},
301                                  {NoFlag, 0x00007fff, 0x00007fff, 0xffffff83},
302                                  {NoFlag, 0x33333333, 0x33333333, 0x00000000},
303                                  {NoFlag, 0xffff8000, 0xffff8000, 0xffffff82},
304                                  {NoFlag, 0xffff8001, 0xffff8001, 0x0000007e},
305                                  {NoFlag, 0xffffff80, 0xffffff80, 0x00000001},
306                                  {NoFlag, 0x80000000, 0x80000000, 0xcccccccc},
307                                  {NoFlag, 0x00000002, 0x00000002, 0x00007ffd},
308                                  {NoFlag, 0x7ffffffe, 0x7ffffffe, 0x80000001},
309                                  {NoFlag, 0x00000020, 0x00000020, 0x00007ffe},
310                                  {NoFlag, 0xffff8000, 0xffff8000, 0xfffffffd},
311                                  {NoFlag, 0x7fffffff, 0x7fffffff, 0xffff8001},
312                                  {NoFlag, 0x00000000, 0x00000000, 0xffffff83},
313                                  {NoFlag, 0x0000007f, 0x0000007f, 0x00000020},
314                                  {NoFlag, 0x80000001, 0x80000001, 0xffff8003},
315                                  {NoFlag, 0xffff8001, 0xffff8001, 0x0000007f},
316                                  {NoFlag, 0x0000007f, 0x0000007f, 0x80000001},
317                                  {NoFlag, 0x00000002, 0x00000002, 0x7ffffffe},
318                                  {NoFlag, 0xffffff82, 0xffffff82, 0xffffff83},
319                                  {NoFlag, 0x00007ffd, 0x00007ffd, 0x7fffffff},
320                                  {NoFlag, 0x7ffffffe, 0x7ffffffe, 0xfffffffe},
321                                  {NoFlag, 0xffffff82, 0xffffff82, 0xffff8000},
322                                  {NoFlag, 0xfffffffe, 0xfffffffe, 0xffff8000},
323                                  {NoFlag, 0xffff8002, 0xffff8002, 0xffffff81},
324                                  {NoFlag, 0x33333333, 0x33333333, 0x7fffffff},
325                                  {NoFlag, 0x80000001, 0x80000001, 0x00007fff},
326                                  {NoFlag, 0xffff8002, 0xffff8002, 0xcccccccc},
327                                  {NoFlag, 0xffffffff, 0xffffffff, 0x00000002},
328                                  {NoFlag, 0x33333333, 0x33333333, 0xffffff81},
329                                  {NoFlag, 0xfffffffd, 0xfffffffd, 0xffffff80},
330                                  {NoFlag, 0x55555555, 0x55555555, 0xaaaaaaaa},
331                                  {NoFlag, 0x33333333, 0x33333333, 0xffffff82},
332                                  {NoFlag, 0xffffff80, 0xffffff80, 0xaaaaaaaa},
333                                  {NoFlag, 0x0000007e, 0x0000007e, 0x00000020},
334                                  {NoFlag, 0xffffff83, 0xffffff83, 0x00007ffd},
335                                  {NoFlag, 0xffffff82, 0xffffff82, 0xaaaaaaaa},
336                                  {NoFlag, 0xffff8003, 0xffff8003, 0xffffffff},
337                                  {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0xfffffffe},
338                                  {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x00000000},
339                                  {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x0000007f},
340                                  {NoFlag, 0x0000007f, 0x0000007f, 0x0000007d},
341                                  {NoFlag, 0xfffffffd, 0xfffffffd, 0x55555555},
342                                  {NoFlag, 0xffffffff, 0xffffffff, 0x00000020},
343                                  {NoFlag, 0x00007ffe, 0x00007ffe, 0xffffff83},
344                                  {NoFlag, 0x7fffffff, 0x7fffffff, 0x55555555},
345                                  {NoFlag, 0x55555555, 0x55555555, 0xcccccccc},
346                                  {NoFlag, 0xffffffe0, 0xffffffe0, 0xffff8003},
347                                  {NoFlag, 0x7ffffffe, 0x7ffffffe, 0x00007ffe},
348                                  {NoFlag, 0x00007ffd, 0x00007ffd, 0xffff8002},
349                                  {NoFlag, 0x00007ffd, 0x00007ffd, 0x00000001},
350                                  {NoFlag, 0x00000000, 0x00000000, 0x00007ffe},
351                                  {NoFlag, 0xffffff80, 0xffffff80, 0x00000020},
352                                  {NoFlag, 0xffff8000, 0xffff8000, 0x0000007d},
353                                  {NoFlag, 0xffff8003, 0xffff8003, 0x00000000},
354                                  {NoFlag, 0x0000007e, 0x0000007e, 0x80000000},
355                                  {NoFlag, 0xfffffffd, 0xfffffffd, 0x00000000},
356                                  {NoFlag, 0xffffff80, 0xffffff80, 0xffffffff},
357                                  {NoFlag, 0xcccccccc, 0xcccccccc, 0x0000007f},
358                                  {NoFlag, 0x7ffffffd, 0x7ffffffd, 0x00000000},
359                                  {NoFlag, 0x00007fff, 0x00007fff, 0x00000000},
360                                  {NoFlag, 0x0000007f, 0x0000007f, 0x00000001},
361                                  {NoFlag, 0xffffffff, 0xffffffff, 0xffffff82},
362                                  {NoFlag, 0x00007ffe, 0x00007ffe, 0x00007ffd},
363                                  {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x33333333},
364                                  {NoFlag, 0xffffff82, 0xffffff82, 0x55555555},
365                                  {NoFlag, 0xffff8003, 0xffff8003, 0x0000007e},
366                                  {NoFlag, 0xffffff83, 0xffffff83, 0x00000002},
367                                  {NoFlag, 0xffffff82, 0xffffff82, 0x33333333},
368                                  {NoFlag, 0x55555555, 0x55555555, 0xffffffff},
369                                  {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x80000001},
370                                  {NoFlag, 0xffffff83, 0xffffff83, 0xffffffe0},
371                                  {NoFlag, 0x00000001, 0x00000001, 0xffffffe0},
372                                  {NoFlag, 0x33333333, 0x33333333, 0x33333333},
373                                  {NoFlag, 0x55555555, 0x55555555, 0x00000001},
374                                  {NoFlag, 0xffffff83, 0xffffff83, 0x00007fff},
375                                  {NoFlag, 0x00000002, 0x00000002, 0xfffffffd},
376                                  {NoFlag, 0xffffffe0, 0xffffffe0, 0xffff8002},
377                                  {NoFlag, 0x80000000, 0x80000000, 0x00007ffd},
378                                  {NoFlag, 0xffffff83, 0xffffff83, 0xfffffffe},
379                                  {NoFlag, 0x80000001, 0x80000001, 0xffffffff},
380                                  {NoFlag, 0xffff8003, 0xffff8003, 0x00000020},
381                                  {NoFlag, 0xffffff82, 0xffffff82, 0xcccccccc},
382                                  {NoFlag, 0x00000020, 0x00000020, 0x7fffffff},
383                                  {NoFlag, 0xffffff80, 0xffffff80, 0x55555555},
384                                  {NoFlag, 0x00000001, 0x00000001, 0x00000020},
385                                  {NoFlag, 0xffff8001, 0xffff8001, 0x00007fff},
386                                  {NoFlag, 0x00000020, 0x00000020, 0xaaaaaaaa},
387                                  {NoFlag, 0x55555555, 0x55555555, 0x7fffffff},
388                                  {NoFlag, 0xfffffffe, 0xfffffffe, 0x7fffffff},
389                                  {NoFlag, 0x00007fff, 0x00007fff, 0x55555555},
390                                  {NoFlag, 0x55555555, 0x55555555, 0x0000007d},
391                                  {NoFlag, 0xcccccccc, 0xcccccccc, 0x7ffffffe},
392                                  {NoFlag, 0xffff8002, 0xffff8002, 0x00007ffe},
393                                  {NoFlag, 0xfffffffe, 0xfffffffe, 0xffffff81},
394                                  {NoFlag, 0xffffff81, 0xffffff81, 0x0000007d},
395                                  {NoFlag, 0x00000020, 0x00000020, 0x0000007e},
396                                  {NoFlag, 0xffffffff, 0xffffffff, 0x00007ffe},
397                                  {NoFlag, 0xffff8002, 0xffff8002, 0x0000007e}};
398 
399 static const Inputs kRdIsRm[] = {{NoFlag, 0x55555555, 0x7ffffffe, 0x55555555},
400                                  {NoFlag, 0xfffffffe, 0x00000001, 0xfffffffe},
401                                  {NoFlag, 0xffffff82, 0xffffff82, 0xffffff82},
402                                  {NoFlag, 0xffff8000, 0xffff8003, 0xffff8000},
403                                  {NoFlag, 0x00000001, 0x00000000, 0x00000001},
404                                  {NoFlag, 0xffffff81, 0x00007fff, 0xffffff81},
405                                  {NoFlag, 0x0000007d, 0xffff8002, 0x0000007d},
406                                  {NoFlag, 0x80000000, 0xffff8000, 0x80000000},
407                                  {NoFlag, 0xffffff80, 0x00000020, 0xffffff80},
408                                  {NoFlag, 0x55555555, 0xffffff81, 0x55555555},
409                                  {NoFlag, 0x00007ffd, 0xffffff82, 0x00007ffd},
410                                  {NoFlag, 0x55555555, 0x00007fff, 0x55555555},
411                                  {NoFlag, 0x7ffffffd, 0xffff8000, 0x7ffffffd},
412                                  {NoFlag, 0xffffffff, 0xffffff83, 0xffffffff},
413                                  {NoFlag, 0x00000000, 0xffffffff, 0x00000000},
414                                  {NoFlag, 0xffff8002, 0x33333333, 0xffff8002},
415                                  {NoFlag, 0x00007ffd, 0xaaaaaaaa, 0x00007ffd},
416                                  {NoFlag, 0x55555555, 0xffff8000, 0x55555555},
417                                  {NoFlag, 0x80000001, 0xffffffff, 0x80000001},
418                                  {NoFlag, 0x0000007d, 0xffffff83, 0x0000007d},
419                                  {NoFlag, 0x0000007e, 0xffffff82, 0x0000007e},
420                                  {NoFlag, 0xcccccccc, 0x0000007d, 0xcccccccc},
421                                  {NoFlag, 0xffff8002, 0xffffffff, 0xffff8002},
422                                  {NoFlag, 0xffffff81, 0x0000007f, 0xffffff81},
423                                  {NoFlag, 0xffff8000, 0xffffff83, 0xffff8000},
424                                  {NoFlag, 0xffffffff, 0xffffffe0, 0xffffffff},
425                                  {NoFlag, 0xfffffffd, 0x80000001, 0xfffffffd},
426                                  {NoFlag, 0x55555555, 0x80000000, 0x55555555},
427                                  {NoFlag, 0xffff8000, 0x0000007d, 0xffff8000},
428                                  {NoFlag, 0xaaaaaaaa, 0xffff8003, 0xaaaaaaaa},
429                                  {NoFlag, 0x00000001, 0x00007ffd, 0x00000001},
430                                  {NoFlag, 0x0000007e, 0x7ffffffe, 0x0000007e},
431                                  {NoFlag, 0x00000020, 0x00007ffd, 0x00000020},
432                                  {NoFlag, 0xffffff81, 0x7ffffffd, 0xffffff81},
433                                  {NoFlag, 0xffffff83, 0x0000007f, 0xffffff83},
434                                  {NoFlag, 0x00000001, 0x0000007e, 0x00000001},
435                                  {NoFlag, 0xffffff82, 0xfffffffd, 0xffffff82},
436                                  {NoFlag, 0xffff8003, 0x7ffffffe, 0xffff8003},
437                                  {NoFlag, 0x00000002, 0x00000002, 0x00000002},
438                                  {NoFlag, 0xffffff83, 0xffff8001, 0xffffff83},
439                                  {NoFlag, 0xffff8002, 0xfffffffe, 0xffff8002},
440                                  {NoFlag, 0xffffff80, 0xffffff81, 0xffffff80},
441                                  {NoFlag, 0x7fffffff, 0xffffff81, 0x7fffffff},
442                                  {NoFlag, 0x00000020, 0xffffff81, 0x00000020},
443                                  {NoFlag, 0x0000007f, 0xffffffff, 0x0000007f},
444                                  {NoFlag, 0x0000007d, 0xcccccccc, 0x0000007d},
445                                  {NoFlag, 0x00007fff, 0x55555555, 0x00007fff},
446                                  {NoFlag, 0xffff8003, 0x00007ffd, 0xffff8003},
447                                  {NoFlag, 0x80000001, 0x80000001, 0x80000001},
448                                  {NoFlag, 0xffffffff, 0xfffffffd, 0xffffffff},
449                                  {NoFlag, 0xffff8000, 0xfffffffe, 0xffff8000},
450                                  {NoFlag, 0xcccccccc, 0x0000007f, 0xcccccccc},
451                                  {NoFlag, 0x00000001, 0x00000002, 0x00000001},
452                                  {NoFlag, 0xffffff82, 0xffffff81, 0xffffff82},
453                                  {NoFlag, 0xfffffffd, 0x00007ffd, 0xfffffffd},
454                                  {NoFlag, 0x80000001, 0x33333333, 0x80000001},
455                                  {NoFlag, 0xffffff82, 0xffff8002, 0xffffff82},
456                                  {NoFlag, 0xffff8003, 0xfffffffd, 0xffff8003},
457                                  {NoFlag, 0xffffff81, 0x00000020, 0xffffff81},
458                                  {NoFlag, 0xffff8001, 0xffff8003, 0xffff8001},
459                                  {NoFlag, 0x00000001, 0x80000001, 0x00000001},
460                                  {NoFlag, 0xfffffffd, 0x00000002, 0xfffffffd},
461                                  {NoFlag, 0xffff8003, 0x7ffffffd, 0xffff8003},
462                                  {NoFlag, 0x0000007e, 0xaaaaaaaa, 0x0000007e},
463                                  {NoFlag, 0x7ffffffe, 0x7fffffff, 0x7ffffffe},
464                                  {NoFlag, 0x00007ffd, 0x00007ffe, 0x00007ffd},
465                                  {NoFlag, 0x00007fff, 0x80000001, 0x00007fff},
466                                  {NoFlag, 0x00007fff, 0xfffffffe, 0x00007fff},
467                                  {NoFlag, 0x00000001, 0xffffff80, 0x00000001},
468                                  {NoFlag, 0x55555555, 0xcccccccc, 0x55555555},
469                                  {NoFlag, 0x7ffffffd, 0xffffffe0, 0x7ffffffd},
470                                  {NoFlag, 0xffffff81, 0xfffffffe, 0xffffff81},
471                                  {NoFlag, 0xffffff82, 0x00007ffe, 0xffffff82},
472                                  {NoFlag, 0xffffff82, 0x80000001, 0xffffff82},
473                                  {NoFlag, 0x0000007f, 0xffff8001, 0x0000007f},
474                                  {NoFlag, 0x7ffffffd, 0xffffff83, 0x7ffffffd},
475                                  {NoFlag, 0xffffff82, 0xcccccccc, 0xffffff82},
476                                  {NoFlag, 0x00000020, 0xffffff83, 0x00000020},
477                                  {NoFlag, 0x00007ffe, 0x80000000, 0x00007ffe},
478                                  {NoFlag, 0x0000007f, 0xffff8000, 0x0000007f},
479                                  {NoFlag, 0xffffff82, 0x33333333, 0xffffff82},
480                                  {NoFlag, 0x7ffffffd, 0x7ffffffd, 0x7ffffffd},
481                                  {NoFlag, 0xffffff80, 0xffff8001, 0xffffff80},
482                                  {NoFlag, 0x00000002, 0xaaaaaaaa, 0x00000002},
483                                  {NoFlag, 0xffffffff, 0x7fffffff, 0xffffffff},
484                                  {NoFlag, 0xfffffffd, 0xfffffffe, 0xfffffffd},
485                                  {NoFlag, 0x00000020, 0x00000001, 0x00000020},
486                                  {NoFlag, 0x55555555, 0x00000001, 0x55555555},
487                                  {NoFlag, 0x55555555, 0xffffff80, 0x55555555},
488                                  {NoFlag, 0xffffffff, 0x00007fff, 0xffffffff},
489                                  {NoFlag, 0x00000020, 0xaaaaaaaa, 0x00000020},
490                                  {NoFlag, 0x00000002, 0x00007ffe, 0x00000002},
491                                  {NoFlag, 0x00000001, 0xcccccccc, 0x00000001},
492                                  {NoFlag, 0xffff8001, 0x00000000, 0xffff8001},
493                                  {NoFlag, 0x00000001, 0xffff8000, 0x00000001},
494                                  {NoFlag, 0xffffffe0, 0x00007fff, 0xffffffe0},
495                                  {NoFlag, 0xfffffffe, 0x00007fff, 0xfffffffe},
496                                  {NoFlag, 0xffffff83, 0x00000001, 0xffffff83},
497                                  {NoFlag, 0x00007fff, 0xffff8002, 0x00007fff},
498                                  {NoFlag, 0x7ffffffd, 0x7ffffffe, 0x7ffffffd},
499                                  {NoFlag, 0x80000001, 0xaaaaaaaa, 0x80000001},
500                                  {NoFlag, 0x80000001, 0xcccccccc, 0x80000001},
501                                  {NoFlag, 0x00007ffe, 0xffffffe0, 0x00007ffe},
502                                  {NoFlag, 0x00007ffe, 0xfffffffd, 0x00007ffe},
503                                  {NoFlag, 0x55555555, 0xaaaaaaaa, 0x55555555},
504                                  {NoFlag, 0xffffffe0, 0x00000001, 0xffffffe0},
505                                  {NoFlag, 0x0000007e, 0x00007fff, 0x0000007e},
506                                  {NoFlag, 0xfffffffe, 0xfffffffd, 0xfffffffe},
507                                  {NoFlag, 0x33333333, 0x0000007d, 0x33333333},
508                                  {NoFlag, 0xffffff81, 0x7fffffff, 0xffffff81},
509                                  {NoFlag, 0x0000007e, 0x0000007d, 0x0000007e},
510                                  {NoFlag, 0x00000001, 0xffffff81, 0x00000001},
511                                  {NoFlag, 0x80000000, 0x00000002, 0x80000000},
512                                  {NoFlag, 0x0000007d, 0xffff8003, 0x0000007d},
513                                  {NoFlag, 0x7ffffffe, 0x00007ffd, 0x7ffffffe},
514                                  {NoFlag, 0x7ffffffe, 0xaaaaaaaa, 0x7ffffffe},
515                                  {NoFlag, 0x00000000, 0xffff8000, 0x00000000},
516                                  {NoFlag, 0x33333333, 0x00000002, 0x33333333},
517                                  {NoFlag, 0xffffff81, 0xffffff83, 0xffffff81},
518                                  {NoFlag, 0x7ffffffe, 0x00007ffe, 0x7ffffffe},
519                                  {NoFlag, 0x80000000, 0x0000007d, 0x80000000},
520                                  {NoFlag, 0x00000020, 0x00000002, 0x00000020},
521                                  {NoFlag, 0x33333333, 0x80000001, 0x33333333},
522                                  {NoFlag, 0xffffff83, 0x00007ffd, 0xffffff83},
523                                  {NoFlag, 0x00007ffd, 0xffffff83, 0x00007ffd},
524                                  {NoFlag, 0xffff8001, 0x80000000, 0xffff8001},
525                                  {NoFlag, 0x00000000, 0x80000000, 0x00000000},
526                                  {NoFlag, 0xffffffe0, 0xffffffff, 0xffffffe0},
527                                  {NoFlag, 0x80000000, 0xffffff83, 0x80000000},
528                                  {NoFlag, 0x00000020, 0xffffff80, 0x00000020},
529                                  {NoFlag, 0x7ffffffd, 0xffff8001, 0x7ffffffd},
530                                  {NoFlag, 0x80000001, 0xffff8003, 0x80000001},
531                                  {NoFlag, 0x00007ffe, 0x7fffffff, 0x00007ffe},
532                                  {NoFlag, 0x7fffffff, 0x00000002, 0x7fffffff},
533                                  {NoFlag, 0xffffff83, 0xffff8003, 0xffffff83},
534                                  {NoFlag, 0xaaaaaaaa, 0xcccccccc, 0xaaaaaaaa},
535                                  {NoFlag, 0x0000007f, 0xffffff80, 0x0000007f},
536                                  {NoFlag, 0x80000001, 0x00007ffd, 0x80000001},
537                                  {NoFlag, 0xffff8000, 0x80000001, 0xffff8000},
538                                  {NoFlag, 0x00007fff, 0x00007ffd, 0x00007fff},
539                                  {NoFlag, 0x0000007e, 0x0000007f, 0x0000007e},
540                                  {NoFlag, 0x00000002, 0x0000007d, 0x00000002},
541                                  {NoFlag, 0x80000001, 0x7fffffff, 0x80000001},
542                                  {NoFlag, 0x0000007e, 0xffffff81, 0x0000007e},
543                                  {NoFlag, 0x7ffffffe, 0xffff8001, 0x7ffffffe},
544                                  {NoFlag, 0x7fffffff, 0x80000001, 0x7fffffff},
545                                  {NoFlag, 0x7ffffffd, 0x0000007f, 0x7ffffffd},
546                                  {NoFlag, 0xffffff81, 0xffffff81, 0xffffff81},
547                                  {NoFlag, 0x00000001, 0xfffffffd, 0x00000001},
548                                  {NoFlag, 0x00000001, 0xffffffff, 0x00000001},
549                                  {NoFlag, 0x7ffffffd, 0x55555555, 0x7ffffffd},
550                                  {NoFlag, 0x55555555, 0x0000007f, 0x55555555},
551                                  {NoFlag, 0x55555555, 0xffff8003, 0x55555555},
552                                  {NoFlag, 0xaaaaaaaa, 0x00007ffd, 0xaaaaaaaa},
553                                  {NoFlag, 0x0000007e, 0x33333333, 0x0000007e},
554                                  {NoFlag, 0xfffffffe, 0x80000001, 0xfffffffe},
555                                  {NoFlag, 0xfffffffe, 0xffff8000, 0xfffffffe},
556                                  {NoFlag, 0xffffffe0, 0xffffff81, 0xffffffe0},
557                                  {NoFlag, 0x7fffffff, 0x0000007f, 0x7fffffff},
558                                  {NoFlag, 0xffff8003, 0x0000007f, 0xffff8003},
559                                  {NoFlag, 0xffffff82, 0x00007ffd, 0xffffff82},
560                                  {NoFlag, 0x33333333, 0xffffffff, 0x33333333},
561                                  {NoFlag, 0xffffffe0, 0xcccccccc, 0xffffffe0},
562                                  {NoFlag, 0xffffff83, 0x7ffffffd, 0xffffff83},
563                                  {NoFlag, 0x0000007e, 0xcccccccc, 0x0000007e},
564                                  {NoFlag, 0x00000002, 0xfffffffd, 0x00000002},
565                                  {NoFlag, 0x00007fff, 0xcccccccc, 0x00007fff},
566                                  {NoFlag, 0x7fffffff, 0x00007fff, 0x7fffffff},
567                                  {NoFlag, 0xffffffe0, 0x33333333, 0xffffffe0},
568                                  {NoFlag, 0x0000007f, 0x0000007d, 0x0000007f},
569                                  {NoFlag, 0x0000007f, 0xffffffe0, 0x0000007f},
570                                  {NoFlag, 0x00007fff, 0xffff8000, 0x00007fff},
571                                  {NoFlag, 0x7fffffff, 0xffffffff, 0x7fffffff},
572                                  {NoFlag, 0xffff8000, 0x7ffffffd, 0xffff8000},
573                                  {NoFlag, 0xcccccccc, 0x0000007e, 0xcccccccc},
574                                  {NoFlag, 0x33333333, 0xffff8003, 0x33333333},
575                                  {NoFlag, 0x55555555, 0x00000002, 0x55555555},
576                                  {NoFlag, 0x00000001, 0x00000001, 0x00000001},
577                                  {NoFlag, 0xaaaaaaaa, 0x33333333, 0xaaaaaaaa},
578                                  {NoFlag, 0x7ffffffd, 0x00000001, 0x7ffffffd},
579                                  {NoFlag, 0xffffff82, 0xffff8000, 0xffffff82},
580                                  {NoFlag, 0x0000007d, 0x55555555, 0x0000007d},
581                                  {NoFlag, 0xffff8000, 0x7ffffffe, 0xffff8000},
582                                  {NoFlag, 0x7fffffff, 0xffffffe0, 0x7fffffff},
583                                  {NoFlag, 0x7fffffff, 0xffff8003, 0x7fffffff},
584                                  {NoFlag, 0xffffff82, 0xaaaaaaaa, 0xffffff82},
585                                  {NoFlag, 0xfffffffd, 0xffffff80, 0xfffffffd},
586                                  {NoFlag, 0x7ffffffd, 0x80000001, 0x7ffffffd},
587                                  {NoFlag, 0x00000000, 0x00007ffd, 0x00000000},
588                                  {NoFlag, 0xffffffff, 0xffffff80, 0xffffffff},
589                                  {NoFlag, 0xffffff80, 0xcccccccc, 0xffffff80},
590                                  {NoFlag, 0x00007ffe, 0x55555555, 0x00007ffe},
591                                  {NoFlag, 0xffff8000, 0xffff8000, 0xffff8000},
592                                  {NoFlag, 0xffffffff, 0xffff8000, 0xffffffff},
593                                  {NoFlag, 0x80000001, 0x0000007d, 0x80000001},
594                                  {NoFlag, 0xffffffe0, 0xffff8002, 0xffffffe0},
595                                  {NoFlag, 0xfffffffe, 0xffffffe0, 0xfffffffe},
596                                  {NoFlag, 0x80000000, 0xffff8003, 0x80000000},
597                                  {NoFlag, 0x80000001, 0xffffff81, 0x80000001},
598                                  {NoFlag, 0xffffffe0, 0x00007ffe, 0xffffffe0}};
599 
600 static const Inputs kRdIsNotRnIsNotRm[] =
601     {{NoFlag, 0x0000007e, 0x0000007e, 0x0000007d},
602      {NoFlag, 0x55555555, 0x00000002, 0xffff8002},
603      {NoFlag, 0xffffffe0, 0x80000001, 0x00000000},
604      {NoFlag, 0x55555555, 0xffffff83, 0x00000002},
605      {NoFlag, 0xffffffe0, 0xffffffe0, 0x00000002},
606      {NoFlag, 0x00000000, 0x80000001, 0xffffff82},
607      {NoFlag, 0x80000001, 0x00007fff, 0x0000007f},
608      {NoFlag, 0xffffff80, 0x0000007d, 0x7ffffffe},
609      {NoFlag, 0xaaaaaaaa, 0x00000020, 0xffff8002},
610      {NoFlag, 0x33333333, 0x55555555, 0x00000001},
611      {NoFlag, 0x7ffffffe, 0x33333333, 0x00000000},
612      {NoFlag, 0x80000000, 0x7ffffffd, 0x55555555},
613      {NoFlag, 0xcccccccc, 0xffff8001, 0x7ffffffe},
614      {NoFlag, 0x00000020, 0xffffff83, 0xffff8003},
615      {NoFlag, 0x00007fff, 0xffffffe0, 0xffffff81},
616      {NoFlag, 0xffff8000, 0xffff8001, 0x0000007e},
617      {NoFlag, 0x33333333, 0x0000007e, 0x00000020},
618      {NoFlag, 0x0000007f, 0xfffffffd, 0xaaaaaaaa},
619      {NoFlag, 0xffffff83, 0xffffff82, 0x7ffffffd},
620      {NoFlag, 0x0000007e, 0xcccccccc, 0x7fffffff},
621      {NoFlag, 0xffff8001, 0x80000001, 0xffffffff},
622      {NoFlag, 0xffffff81, 0x00000020, 0x7ffffffe},
623      {NoFlag, 0xffffff83, 0xffffff81, 0xffffffe0},
624      {NoFlag, 0xffffffe0, 0xffffff81, 0xfffffffd},
625      {NoFlag, 0x80000001, 0xffffffff, 0xffffffff},
626      {NoFlag, 0x7ffffffe, 0xffff8000, 0xcccccccc},
627      {NoFlag, 0xffffff80, 0x00007ffe, 0xffffff82},
628      {NoFlag, 0x0000007e, 0x0000007d, 0xffff8003},
629      {NoFlag, 0xffff8002, 0xffffff81, 0x0000007e},
630      {NoFlag, 0x00007fff, 0x7ffffffd, 0xfffffffe},
631      {NoFlag, 0x00007ffe, 0x80000001, 0xffffff81},
632      {NoFlag, 0xffffff81, 0x00007ffd, 0xfffffffd},
633      {NoFlag, 0x00000020, 0x7fffffff, 0xffff8003},
634      {NoFlag, 0x0000007e, 0x0000007d, 0x33333333},
635      {NoFlag, 0xcccccccc, 0xffff8000, 0x00007ffe},
636      {NoFlag, 0x00007fff, 0xffff8000, 0x00000020},
637      {NoFlag, 0x00007ffd, 0x00007fff, 0xffffffe0},
638      {NoFlag, 0x7ffffffd, 0x00000000, 0x00007ffe},
639      {NoFlag, 0xffffff82, 0x33333333, 0x00000001},
640      {NoFlag, 0x7ffffffe, 0xffffff80, 0x00000020},
641      {NoFlag, 0x00007fff, 0xffffff83, 0x00007ffd},
642      {NoFlag, 0xffff8001, 0xffffffff, 0x80000001},
643      {NoFlag, 0x00000002, 0xffffff81, 0xcccccccc},
644      {NoFlag, 0x55555555, 0x0000007f, 0xffff8001},
645      {NoFlag, 0x80000000, 0x00000020, 0x80000000},
646      {NoFlag, 0xffffff83, 0x00007fff, 0xffffff80},
647      {NoFlag, 0x33333333, 0x7ffffffe, 0x7ffffffd},
648      {NoFlag, 0xffffff80, 0xffffffff, 0x00000001},
649      {NoFlag, 0x00007ffd, 0x7ffffffd, 0xffffff83},
650      {NoFlag, 0x33333333, 0xffff8001, 0xffffffe0},
651      {NoFlag, 0xffff8001, 0xffffff80, 0x00007ffd},
652      {NoFlag, 0xffffffe0, 0x00007fff, 0x00007ffe},
653      {NoFlag, 0x0000007d, 0x00000000, 0xffff8000},
654      {NoFlag, 0x7ffffffe, 0xaaaaaaaa, 0x7ffffffe},
655      {NoFlag, 0x0000007e, 0x00007ffd, 0xffffffe0},
656      {NoFlag, 0xfffffffd, 0xffffffe0, 0xffffff83},
657      {NoFlag, 0x00000001, 0xffffffe0, 0x7ffffffd},
658      {NoFlag, 0xfffffffd, 0xffff8002, 0x80000000},
659      {NoFlag, 0x00000020, 0xffffffff, 0x80000000},
660      {NoFlag, 0x00000001, 0x80000001, 0xffff8003},
661      {NoFlag, 0xffff8003, 0xaaaaaaaa, 0xffffff81},
662      {NoFlag, 0x0000007f, 0xfffffffd, 0xffffffe0},
663      {NoFlag, 0x00007ffe, 0xffffff80, 0x00007ffe},
664      {NoFlag, 0xffff8002, 0xffff8003, 0xffffffff},
665      {NoFlag, 0x7ffffffe, 0xffffff82, 0xffff8000},
666      {NoFlag, 0xffff8000, 0x00000002, 0x80000000},
667      {NoFlag, 0xffffff80, 0xffffff82, 0xffffff81},
668      {NoFlag, 0x00000000, 0xcccccccc, 0x00007ffd},
669      {NoFlag, 0x55555555, 0x00007ffe, 0x7fffffff},
670      {NoFlag, 0x00000002, 0xffffff81, 0xaaaaaaaa},
671      {NoFlag, 0x00007ffd, 0x0000007e, 0x00000002},
672      {NoFlag, 0xffffff83, 0x0000007e, 0xffffff80},
673      {NoFlag, 0xcccccccc, 0x00007ffe, 0xaaaaaaaa},
674      {NoFlag, 0x7ffffffe, 0x55555555, 0xffff8003},
675      {NoFlag, 0xfffffffd, 0x00000001, 0xffffff80},
676      {NoFlag, 0x00007ffd, 0x55555555, 0x80000001},
677      {NoFlag, 0x0000007f, 0x00000000, 0x0000007e},
678      {NoFlag, 0x7fffffff, 0xaaaaaaaa, 0x00000000},
679      {NoFlag, 0x7ffffffd, 0xffffff81, 0xcccccccc},
680      {NoFlag, 0xffffffe0, 0xcccccccc, 0xfffffffd},
681      {NoFlag, 0x00000002, 0xffff8000, 0x7ffffffd},
682      {NoFlag, 0xffffffe0, 0xffff8000, 0x80000001},
683      {NoFlag, 0x7ffffffd, 0xffff8003, 0xffff8001},
684      {NoFlag, 0x33333333, 0x00007ffd, 0x80000000},
685      {NoFlag, 0x7ffffffd, 0x00007fff, 0xcccccccc},
686      {NoFlag, 0xffffffff, 0xffffff80, 0x00007ffe},
687      {NoFlag, 0xffffff83, 0x7ffffffd, 0xaaaaaaaa},
688      {NoFlag, 0xfffffffd, 0xffff8003, 0x0000007f},
689      {NoFlag, 0xfffffffe, 0xfffffffe, 0xfffffffd},
690      {NoFlag, 0x00007fff, 0xfffffffe, 0x55555555},
691      {NoFlag, 0x7ffffffd, 0xfffffffe, 0xfffffffe},
692      {NoFlag, 0xfffffffe, 0xffffffff, 0x00007fff},
693      {NoFlag, 0x7ffffffd, 0x0000007e, 0x00007ffd},
694      {NoFlag, 0x7ffffffd, 0xffffffe0, 0x00000002},
695      {NoFlag, 0xffffffff, 0x00007ffd, 0xffffff81},
696      {NoFlag, 0xffff8001, 0x00000020, 0xfffffffd},
697      {NoFlag, 0x00007fff, 0x0000007d, 0xffffff83},
698      {NoFlag, 0x00000002, 0x55555555, 0x7ffffffe},
699      {NoFlag, 0x00007fff, 0x00007ffe, 0x00000002},
700      {NoFlag, 0x80000001, 0x7fffffff, 0x00007ffd},
701      {NoFlag, 0x0000007f, 0xffffffff, 0x00000001},
702      {NoFlag, 0xffff8001, 0x33333333, 0xffffff83},
703      {NoFlag, 0x00007fff, 0xcccccccc, 0x33333333},
704      {NoFlag, 0x33333333, 0xffffff80, 0x00000001},
705      {NoFlag, 0x00007fff, 0xcccccccc, 0x00007ffd},
706      {NoFlag, 0xffff8002, 0xfffffffd, 0x7ffffffe},
707      {NoFlag, 0x00007ffe, 0x7ffffffe, 0xffffff83},
708      {NoFlag, 0xffffffe0, 0x0000007f, 0xffff8001},
709      {NoFlag, 0x80000000, 0x00007fff, 0xffffff80},
710      {NoFlag, 0x7fffffff, 0x00007fff, 0x7ffffffe},
711      {NoFlag, 0xffff8002, 0x55555555, 0xffff8001},
712      {NoFlag, 0xffffff80, 0x00000000, 0xffffff80},
713      {NoFlag, 0x00007ffd, 0x00007fff, 0x00000002},
714      {NoFlag, 0x00000000, 0x55555555, 0xffff8003},
715      {NoFlag, 0x0000007f, 0xffff8003, 0x00000020},
716      {NoFlag, 0x00000000, 0xffff8002, 0x7fffffff},
717      {NoFlag, 0x00007fff, 0x55555555, 0x00000000},
718      {NoFlag, 0x7fffffff, 0x00007ffe, 0xffffff81},
719      {NoFlag, 0x0000007e, 0x80000001, 0x00007ffe},
720      {NoFlag, 0x7ffffffd, 0xaaaaaaaa, 0x00000020},
721      {NoFlag, 0xfffffffd, 0xfffffffe, 0x00000002},
722      {NoFlag, 0xffffff80, 0xffff8000, 0xffff8002},
723      {NoFlag, 0x0000007d, 0x00007fff, 0xaaaaaaaa},
724      {NoFlag, 0xfffffffd, 0xffffff80, 0x00007ffd},
725      {NoFlag, 0xffffff82, 0x80000000, 0xffffff80},
726      {NoFlag, 0xffffffe0, 0x55555555, 0xfffffffd},
727      {NoFlag, 0xffffffff, 0xffffffff, 0x00007ffd},
728      {NoFlag, 0x0000007e, 0xfffffffe, 0xffffff80},
729      {NoFlag, 0xffff8000, 0xffffff82, 0xffff8002},
730      {NoFlag, 0xaaaaaaaa, 0x7ffffffe, 0xffff8000},
731      {NoFlag, 0x55555555, 0xffff8003, 0xffffff80},
732      {NoFlag, 0x7ffffffe, 0x00000020, 0xffffffe0},
733      {NoFlag, 0x00000001, 0xffff8001, 0xffffffe0},
734      {NoFlag, 0xcccccccc, 0xffff8000, 0xffff8002},
735      {NoFlag, 0x80000000, 0x00000002, 0x7ffffffe},
736      {NoFlag, 0x00000002, 0x0000007f, 0xffffff81},
737      {NoFlag, 0xffffffff, 0x00000001, 0x7fffffff},
738      {NoFlag, 0xffffff83, 0x00000000, 0x33333333},
739      {NoFlag, 0xffff8000, 0xffffff83, 0xcccccccc},
740      {NoFlag, 0x80000000, 0x00000020, 0x00007ffd},
741      {NoFlag, 0xffffff81, 0xcccccccc, 0x00000000},
742      {NoFlag, 0xffffffff, 0xffff8000, 0x00007fff},
743      {NoFlag, 0xffff8003, 0xcccccccc, 0x00007ffe},
744      {NoFlag, 0xffffffff, 0xfffffffd, 0x7ffffffe},
745      {NoFlag, 0xffff8003, 0xaaaaaaaa, 0x55555555},
746      {NoFlag, 0x00000000, 0xaaaaaaaa, 0xffffff81},
747      {NoFlag, 0x0000007f, 0xfffffffe, 0xffff8000},
748      {NoFlag, 0x00000001, 0xffffffe0, 0xfffffffd},
749      {NoFlag, 0x33333333, 0x33333333, 0xfffffffd},
750      {NoFlag, 0xffffff82, 0xffff8002, 0x80000001},
751      {NoFlag, 0x55555555, 0xffffff83, 0xffffff83},
752      {NoFlag, 0xffffff83, 0xffff8002, 0x00000020},
753      {NoFlag, 0x0000007d, 0x7fffffff, 0x0000007f},
754      {NoFlag, 0x00000000, 0xcccccccc, 0xffff8000},
755      {NoFlag, 0x00000002, 0x7ffffffe, 0x00007fff},
756      {NoFlag, 0xffffff82, 0x7ffffffd, 0x7ffffffd},
757      {NoFlag, 0xaaaaaaaa, 0xfffffffd, 0xffff8002},
758      {NoFlag, 0xfffffffd, 0x00000002, 0x7fffffff},
759      {NoFlag, 0xfffffffe, 0xfffffffe, 0x00000020},
760      {NoFlag, 0x80000001, 0x0000007e, 0x00007ffe},
761      {NoFlag, 0x00007ffd, 0x00007ffd, 0xfffffffd},
762      {NoFlag, 0xffff8000, 0x0000007f, 0x00000002},
763      {NoFlag, 0x7ffffffd, 0x80000000, 0x7ffffffd},
764      {NoFlag, 0x0000007d, 0x00007fff, 0x80000001},
765      {NoFlag, 0xffffffff, 0x80000000, 0xaaaaaaaa},
766      {NoFlag, 0x00000000, 0xaaaaaaaa, 0xffff8001},
767      {NoFlag, 0xaaaaaaaa, 0xffffffe0, 0xffff8003},
768      {NoFlag, 0xffffff82, 0xffffffff, 0x00007ffd},
769      {NoFlag, 0x00000001, 0xffffff81, 0x00000001},
770      {NoFlag, 0x7fffffff, 0xaaaaaaaa, 0x80000001},
771      {NoFlag, 0x7fffffff, 0xffff8000, 0xffff8000},
772      {NoFlag, 0xaaaaaaaa, 0x00007ffd, 0xaaaaaaaa},
773      {NoFlag, 0x0000007f, 0x7ffffffe, 0x80000000},
774      {NoFlag, 0x00007ffd, 0x00007ffe, 0xffffff81},
775      {NoFlag, 0x0000007d, 0x0000007d, 0xffff8002},
776      {NoFlag, 0x80000001, 0x00000002, 0xffffff81},
777      {NoFlag, 0xffff8000, 0xfffffffd, 0x7ffffffd},
778      {NoFlag, 0xfffffffe, 0x00000020, 0xffffff80},
779      {NoFlag, 0x00000020, 0x7fffffff, 0xffffffe0},
780      {NoFlag, 0xffff8002, 0xffff8002, 0x0000007f},
781      {NoFlag, 0xffff8003, 0x7fffffff, 0xffff8002},
782      {NoFlag, 0x00000020, 0xfffffffd, 0x00000020},
783      {NoFlag, 0x7ffffffd, 0xffffffe0, 0x0000007e},
784      {NoFlag, 0x00000020, 0x00000020, 0x7ffffffe},
785      {NoFlag, 0xfffffffe, 0x0000007f, 0xffff8000},
786      {NoFlag, 0x80000001, 0x80000001, 0x0000007d},
787      {NoFlag, 0x55555555, 0x0000007f, 0x00007ffd},
788      {NoFlag, 0x55555555, 0xffffffe0, 0xffffff82},
789      {NoFlag, 0xffff8001, 0x0000007e, 0xffff8002},
790      {NoFlag, 0xffffffe0, 0x55555555, 0x0000007f},
791      {NoFlag, 0xffff8000, 0x7fffffff, 0x7ffffffe},
792      {NoFlag, 0xffffffff, 0xfffffffe, 0xffffff80},
793      {NoFlag, 0xffff8001, 0xffff8002, 0x33333333},
794      {NoFlag, 0x7ffffffd, 0xfffffffd, 0xaaaaaaaa},
795      {NoFlag, 0xaaaaaaaa, 0xfffffffd, 0x00000020},
796      {NoFlag, 0x0000007f, 0x00007ffe, 0x55555555},
797      {NoFlag, 0x00000020, 0x00000020, 0x00000002},
798      {NoFlag, 0x80000001, 0xffff8002, 0xfffffffe},
799      {NoFlag, 0x7fffffff, 0x80000001, 0xffff8002},
800      {NoFlag, 0x00000020, 0x0000007e, 0x33333333}};
801 
802 static const Inputs kShiftTypes[] =
803     {{NoFlag, 0xabababab, 0xabababab, 0x00000000},
804      {NoFlag, 0xabababab, 0xabababab, 0x00000001},
805      {NoFlag, 0xabababab, 0xabababab, 0x00000002},
806      {NoFlag, 0xabababab, 0xabababab, 0x00000020},
807      {NoFlag, 0xabababab, 0xabababab, 0x0000007d},
808      {NoFlag, 0xabababab, 0xabababab, 0x0000007e},
809      {NoFlag, 0xabababab, 0xabababab, 0x0000007f},
810      {NoFlag, 0xabababab, 0xabababab, 0x00007ffd},
811      {NoFlag, 0xabababab, 0xabababab, 0x00007ffe},
812      {NoFlag, 0xabababab, 0xabababab, 0x00007fff},
813      {NoFlag, 0xabababab, 0xabababab, 0x33333333},
814      {NoFlag, 0xabababab, 0xabababab, 0x55555555},
815      {NoFlag, 0xabababab, 0xabababab, 0x7ffffffd},
816      {NoFlag, 0xabababab, 0xabababab, 0x7ffffffe},
817      {NoFlag, 0xabababab, 0xabababab, 0x7fffffff},
818      {NoFlag, 0xabababab, 0xabababab, 0x80000000},
819      {NoFlag, 0xabababab, 0xabababab, 0x80000001},
820      {NoFlag, 0xabababab, 0xabababab, 0xaaaaaaaa},
821      {NoFlag, 0xabababab, 0xabababab, 0xcccccccc},
822      {NoFlag, 0xabababab, 0xabababab, 0xffff8000},
823      {NoFlag, 0xabababab, 0xabababab, 0xffff8001},
824      {NoFlag, 0xabababab, 0xabababab, 0xffff8002},
825      {NoFlag, 0xabababab, 0xabababab, 0xffff8003},
826      {NoFlag, 0xabababab, 0xabababab, 0xffffff80},
827      {NoFlag, 0xabababab, 0xabababab, 0xffffff81},
828      {NoFlag, 0xabababab, 0xabababab, 0xffffff82},
829      {NoFlag, 0xabababab, 0xabababab, 0xffffff83},
830      {NoFlag, 0xabababab, 0xabababab, 0xffffffe0},
831      {NoFlag, 0xabababab, 0xabababab, 0xfffffffd},
832      {NoFlag, 0xabababab, 0xabababab, 0xfffffffe},
833      {NoFlag, 0xabababab, 0xabababab, 0xffffffff}};
834 
835 
836 // A loop will be generated for each element of this array.
837 const TestLoopData kTests[] = {{{eq, r0, r0, r0, LSL, 1},
838                                 "eq r0 r0 r0 LSL 1",
839                                 "Condition_eq_r0_r0_r0_LSL_1",
840                                 ARRAY_SIZE(kCondition),
841                                 kCondition},
842                                {{ne, r0, r0, r0, LSL, 1},
843                                 "ne r0 r0 r0 LSL 1",
844                                 "Condition_ne_r0_r0_r0_LSL_1",
845                                 ARRAY_SIZE(kCondition),
846                                 kCondition},
847                                {{cs, r0, r0, r0, LSL, 1},
848                                 "cs r0 r0 r0 LSL 1",
849                                 "Condition_cs_r0_r0_r0_LSL_1",
850                                 ARRAY_SIZE(kCondition),
851                                 kCondition},
852                                {{cc, r0, r0, r0, LSL, 1},
853                                 "cc r0 r0 r0 LSL 1",
854                                 "Condition_cc_r0_r0_r0_LSL_1",
855                                 ARRAY_SIZE(kCondition),
856                                 kCondition},
857                                {{mi, r0, r0, r0, LSL, 1},
858                                 "mi r0 r0 r0 LSL 1",
859                                 "Condition_mi_r0_r0_r0_LSL_1",
860                                 ARRAY_SIZE(kCondition),
861                                 kCondition},
862                                {{pl, r0, r0, r0, LSL, 1},
863                                 "pl r0 r0 r0 LSL 1",
864                                 "Condition_pl_r0_r0_r0_LSL_1",
865                                 ARRAY_SIZE(kCondition),
866                                 kCondition},
867                                {{vs, r0, r0, r0, LSL, 1},
868                                 "vs r0 r0 r0 LSL 1",
869                                 "Condition_vs_r0_r0_r0_LSL_1",
870                                 ARRAY_SIZE(kCondition),
871                                 kCondition},
872                                {{vc, r0, r0, r0, LSL, 1},
873                                 "vc r0 r0 r0 LSL 1",
874                                 "Condition_vc_r0_r0_r0_LSL_1",
875                                 ARRAY_SIZE(kCondition),
876                                 kCondition},
877                                {{hi, r0, r0, r0, LSL, 1},
878                                 "hi r0 r0 r0 LSL 1",
879                                 "Condition_hi_r0_r0_r0_LSL_1",
880                                 ARRAY_SIZE(kCondition),
881                                 kCondition},
882                                {{ls, r0, r0, r0, LSL, 1},
883                                 "ls r0 r0 r0 LSL 1",
884                                 "Condition_ls_r0_r0_r0_LSL_1",
885                                 ARRAY_SIZE(kCondition),
886                                 kCondition},
887                                {{ge, r0, r0, r0, LSL, 1},
888                                 "ge r0 r0 r0 LSL 1",
889                                 "Condition_ge_r0_r0_r0_LSL_1",
890                                 ARRAY_SIZE(kCondition),
891                                 kCondition},
892                                {{lt, r0, r0, r0, LSL, 1},
893                                 "lt r0 r0 r0 LSL 1",
894                                 "Condition_lt_r0_r0_r0_LSL_1",
895                                 ARRAY_SIZE(kCondition),
896                                 kCondition},
897                                {{gt, r0, r0, r0, LSL, 1},
898                                 "gt r0 r0 r0 LSL 1",
899                                 "Condition_gt_r0_r0_r0_LSL_1",
900                                 ARRAY_SIZE(kCondition),
901                                 kCondition},
902                                {{le, r0, r0, r0, LSL, 1},
903                                 "le r0 r0 r0 LSL 1",
904                                 "Condition_le_r0_r0_r0_LSL_1",
905                                 ARRAY_SIZE(kCondition),
906                                 kCondition},
907                                {{al, r0, r0, r0, LSL, 1},
908                                 "al r0 r0 r0 LSL 1",
909                                 "Condition_al_r0_r0_r0_LSL_1",
910                                 ARRAY_SIZE(kCondition),
911                                 kCondition},
912                                {{al, r3, r3, r4, LSL, 1},
913                                 "al r3 r3 r4 LSL 1",
914                                 "RdIsRn_al_r3_r3_r4_LSL_1",
915                                 ARRAY_SIZE(kRdIsRn),
916                                 kRdIsRn},
917                                {{al, r2, r2, r12, LSL, 1},
918                                 "al r2 r2 r12 LSL 1",
919                                 "RdIsRn_al_r2_r2_r12_LSL_1",
920                                 ARRAY_SIZE(kRdIsRn),
921                                 kRdIsRn},
922                                {{al, r8, r8, r5, LSL, 1},
923                                 "al r8 r8 r5 LSL 1",
924                                 "RdIsRn_al_r8_r8_r5_LSL_1",
925                                 ARRAY_SIZE(kRdIsRn),
926                                 kRdIsRn},
927                                {{al, r14, r14, r0, LSL, 1},
928                                 "al r14 r14 r0 LSL 1",
929                                 "RdIsRn_al_r14_r14_r0_LSL_1",
930                                 ARRAY_SIZE(kRdIsRn),
931                                 kRdIsRn},
932                                {{al, r11, r11, r10, LSL, 1},
933                                 "al r11 r11 r10 LSL 1",
934                                 "RdIsRn_al_r11_r11_r10_LSL_1",
935                                 ARRAY_SIZE(kRdIsRn),
936                                 kRdIsRn},
937                                {{al, r12, r12, r10, LSL, 1},
938                                 "al r12 r12 r10 LSL 1",
939                                 "RdIsRn_al_r12_r12_r10_LSL_1",
940                                 ARRAY_SIZE(kRdIsRn),
941                                 kRdIsRn},
942                                {{al, r4, r4, r8, LSL, 1},
943                                 "al r4 r4 r8 LSL 1",
944                                 "RdIsRn_al_r4_r4_r8_LSL_1",
945                                 ARRAY_SIZE(kRdIsRn),
946                                 kRdIsRn},
947                                {{al, r5, r5, r14, LSL, 1},
948                                 "al r5 r5 r14 LSL 1",
949                                 "RdIsRn_al_r5_r5_r14_LSL_1",
950                                 ARRAY_SIZE(kRdIsRn),
951                                 kRdIsRn},
952                                {{al, r0, r0, r6, LSL, 1},
953                                 "al r0 r0 r6 LSL 1",
954                                 "RdIsRn_al_r0_r0_r6_LSL_1",
955                                 ARRAY_SIZE(kRdIsRn),
956                                 kRdIsRn},
957                                {{al, r12, r12, r1, LSL, 1},
958                                 "al r12 r12 r1 LSL 1",
959                                 "RdIsRn_al_r12_r12_r1_LSL_1",
960                                 ARRAY_SIZE(kRdIsRn),
961                                 kRdIsRn},
962                                {{al, r6, r11, r6, LSL, 1},
963                                 "al r6 r11 r6 LSL 1",
964                                 "RdIsRm_al_r6_r11_r6_LSL_1",
965                                 ARRAY_SIZE(kRdIsRm),
966                                 kRdIsRm},
967                                {{al, r11, r9, r11, LSL, 1},
968                                 "al r11 r9 r11 LSL 1",
969                                 "RdIsRm_al_r11_r9_r11_LSL_1",
970                                 ARRAY_SIZE(kRdIsRm),
971                                 kRdIsRm},
972                                {{al, r0, r8, r0, LSL, 1},
973                                 "al r0 r8 r0 LSL 1",
974                                 "RdIsRm_al_r0_r8_r0_LSL_1",
975                                 ARRAY_SIZE(kRdIsRm),
976                                 kRdIsRm},
977                                {{al, r2, r11, r2, LSL, 1},
978                                 "al r2 r11 r2 LSL 1",
979                                 "RdIsRm_al_r2_r11_r2_LSL_1",
980                                 ARRAY_SIZE(kRdIsRm),
981                                 kRdIsRm},
982                                {{al, r9, r4, r9, LSL, 1},
983                                 "al r9 r4 r9 LSL 1",
984                                 "RdIsRm_al_r9_r4_r9_LSL_1",
985                                 ARRAY_SIZE(kRdIsRm),
986                                 kRdIsRm},
987                                {{al, r14, r10, r14, LSL, 1},
988                                 "al r14 r10 r14 LSL 1",
989                                 "RdIsRm_al_r14_r10_r14_LSL_1",
990                                 ARRAY_SIZE(kRdIsRm),
991                                 kRdIsRm},
992                                {{al, r7, r0, r7, LSL, 1},
993                                 "al r7 r0 r7 LSL 1",
994                                 "RdIsRm_al_r7_r0_r7_LSL_1",
995                                 ARRAY_SIZE(kRdIsRm),
996                                 kRdIsRm},
997                                {{al, r4, r9, r4, LSL, 1},
998                                 "al r4 r9 r4 LSL 1",
999                                 "RdIsRm_al_r4_r9_r4_LSL_1",
1000                                 ARRAY_SIZE(kRdIsRm),
1001                                 kRdIsRm},
1002                                {{al, r6, r10, r6, LSL, 1},
1003                                 "al r6 r10 r6 LSL 1",
1004                                 "RdIsRm_al_r6_r10_r6_LSL_1",
1005                                 ARRAY_SIZE(kRdIsRm),
1006                                 kRdIsRm},
1007                                {{al, r7, r6, r7, LSL, 1},
1008                                 "al r7 r6 r7 LSL 1",
1009                                 "RdIsRm_al_r7_r6_r7_LSL_1",
1010                                 ARRAY_SIZE(kRdIsRm),
1011                                 kRdIsRm},
1012                                {{al, r3, r9, r10, LSL, 1},
1013                                 "al r3 r9 r10 LSL 1",
1014                                 "RdIsNotRnIsNotRm_al_r3_r9_r10_LSL_1",
1015                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1016                                 kRdIsNotRnIsNotRm},
1017                                {{al, r7, r12, r5, LSL, 1},
1018                                 "al r7 r12 r5 LSL 1",
1019                                 "RdIsNotRnIsNotRm_al_r7_r12_r5_LSL_1",
1020                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1021                                 kRdIsNotRnIsNotRm},
1022                                {{al, r8, r5, r6, LSL, 1},
1023                                 "al r8 r5 r6 LSL 1",
1024                                 "RdIsNotRnIsNotRm_al_r8_r5_r6_LSL_1",
1025                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1026                                 kRdIsNotRnIsNotRm},
1027                                {{al, r0, r6, r0, LSL, 1},
1028                                 "al r0 r6 r0 LSL 1",
1029                                 "RdIsNotRnIsNotRm_al_r0_r6_r0_LSL_1",
1030                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1031                                 kRdIsNotRnIsNotRm},
1032                                {{al, r11, r7, r8, LSL, 1},
1033                                 "al r11 r7 r8 LSL 1",
1034                                 "RdIsNotRnIsNotRm_al_r11_r7_r8_LSL_1",
1035                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1036                                 kRdIsNotRnIsNotRm},
1037                                {{al, r12, r2, r3, LSL, 1},
1038                                 "al r12 r2 r3 LSL 1",
1039                                 "RdIsNotRnIsNotRm_al_r12_r2_r3_LSL_1",
1040                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1041                                 kRdIsNotRnIsNotRm},
1042                                {{al, r7, r4, r10, LSL, 1},
1043                                 "al r7 r4 r10 LSL 1",
1044                                 "RdIsNotRnIsNotRm_al_r7_r4_r10_LSL_1",
1045                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1046                                 kRdIsNotRnIsNotRm},
1047                                {{al, r9, r6, r1, LSL, 1},
1048                                 "al r9 r6 r1 LSL 1",
1049                                 "RdIsNotRnIsNotRm_al_r9_r6_r1_LSL_1",
1050                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1051                                 kRdIsNotRnIsNotRm},
1052                                {{al, r10, r14, r3, LSL, 1},
1053                                 "al r10 r14 r3 LSL 1",
1054                                 "RdIsNotRnIsNotRm_al_r10_r14_r3_LSL_1",
1055                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1056                                 kRdIsNotRnIsNotRm},
1057                                {{al, r14, r3, r6, LSL, 1},
1058                                 "al r14 r3 r6 LSL 1",
1059                                 "RdIsNotRnIsNotRm_al_r14_r3_r6_LSL_1",
1060                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1061                                 kRdIsNotRnIsNotRm},
1062                                {{al, r0, r1, r2, LSL, 1},
1063                                 "al r0 r1 r2 LSL 1",
1064                                 "ShiftTypes_al_r0_r1_r2_LSL_1",
1065                                 ARRAY_SIZE(kShiftTypes),
1066                                 kShiftTypes},
1067                                {{al, r0, r1, r2, LSL, 2},
1068                                 "al r0 r1 r2 LSL 2",
1069                                 "ShiftTypes_al_r0_r1_r2_LSL_2",
1070                                 ARRAY_SIZE(kShiftTypes),
1071                                 kShiftTypes},
1072                                {{al, r0, r1, r2, LSL, 3},
1073                                 "al r0 r1 r2 LSL 3",
1074                                 "ShiftTypes_al_r0_r1_r2_LSL_3",
1075                                 ARRAY_SIZE(kShiftTypes),
1076                                 kShiftTypes},
1077                                {{al, r0, r1, r2, LSL, 4},
1078                                 "al r0 r1 r2 LSL 4",
1079                                 "ShiftTypes_al_r0_r1_r2_LSL_4",
1080                                 ARRAY_SIZE(kShiftTypes),
1081                                 kShiftTypes},
1082                                {{al, r0, r1, r2, LSL, 5},
1083                                 "al r0 r1 r2 LSL 5",
1084                                 "ShiftTypes_al_r0_r1_r2_LSL_5",
1085                                 ARRAY_SIZE(kShiftTypes),
1086                                 kShiftTypes},
1087                                {{al, r0, r1, r2, LSL, 6},
1088                                 "al r0 r1 r2 LSL 6",
1089                                 "ShiftTypes_al_r0_r1_r2_LSL_6",
1090                                 ARRAY_SIZE(kShiftTypes),
1091                                 kShiftTypes},
1092                                {{al, r0, r1, r2, LSL, 7},
1093                                 "al r0 r1 r2 LSL 7",
1094                                 "ShiftTypes_al_r0_r1_r2_LSL_7",
1095                                 ARRAY_SIZE(kShiftTypes),
1096                                 kShiftTypes},
1097                                {{al, r0, r1, r2, LSL, 8},
1098                                 "al r0 r1 r2 LSL 8",
1099                                 "ShiftTypes_al_r0_r1_r2_LSL_8",
1100                                 ARRAY_SIZE(kShiftTypes),
1101                                 kShiftTypes},
1102                                {{al, r0, r1, r2, LSL, 9},
1103                                 "al r0 r1 r2 LSL 9",
1104                                 "ShiftTypes_al_r0_r1_r2_LSL_9",
1105                                 ARRAY_SIZE(kShiftTypes),
1106                                 kShiftTypes},
1107                                {{al, r0, r1, r2, LSL, 10},
1108                                 "al r0 r1 r2 LSL 10",
1109                                 "ShiftTypes_al_r0_r1_r2_LSL_10",
1110                                 ARRAY_SIZE(kShiftTypes),
1111                                 kShiftTypes},
1112                                {{al, r0, r1, r2, LSL, 11},
1113                                 "al r0 r1 r2 LSL 11",
1114                                 "ShiftTypes_al_r0_r1_r2_LSL_11",
1115                                 ARRAY_SIZE(kShiftTypes),
1116                                 kShiftTypes},
1117                                {{al, r0, r1, r2, LSL, 12},
1118                                 "al r0 r1 r2 LSL 12",
1119                                 "ShiftTypes_al_r0_r1_r2_LSL_12",
1120                                 ARRAY_SIZE(kShiftTypes),
1121                                 kShiftTypes},
1122                                {{al, r0, r1, r2, LSL, 13},
1123                                 "al r0 r1 r2 LSL 13",
1124                                 "ShiftTypes_al_r0_r1_r2_LSL_13",
1125                                 ARRAY_SIZE(kShiftTypes),
1126                                 kShiftTypes},
1127                                {{al, r0, r1, r2, LSL, 14},
1128                                 "al r0 r1 r2 LSL 14",
1129                                 "ShiftTypes_al_r0_r1_r2_LSL_14",
1130                                 ARRAY_SIZE(kShiftTypes),
1131                                 kShiftTypes},
1132                                {{al, r0, r1, r2, LSL, 15},
1133                                 "al r0 r1 r2 LSL 15",
1134                                 "ShiftTypes_al_r0_r1_r2_LSL_15",
1135                                 ARRAY_SIZE(kShiftTypes),
1136                                 kShiftTypes},
1137                                {{al, r0, r1, r2, LSL, 16},
1138                                 "al r0 r1 r2 LSL 16",
1139                                 "ShiftTypes_al_r0_r1_r2_LSL_16",
1140                                 ARRAY_SIZE(kShiftTypes),
1141                                 kShiftTypes},
1142                                {{al, r0, r1, r2, LSL, 17},
1143                                 "al r0 r1 r2 LSL 17",
1144                                 "ShiftTypes_al_r0_r1_r2_LSL_17",
1145                                 ARRAY_SIZE(kShiftTypes),
1146                                 kShiftTypes},
1147                                {{al, r0, r1, r2, LSL, 18},
1148                                 "al r0 r1 r2 LSL 18",
1149                                 "ShiftTypes_al_r0_r1_r2_LSL_18",
1150                                 ARRAY_SIZE(kShiftTypes),
1151                                 kShiftTypes},
1152                                {{al, r0, r1, r2, LSL, 19},
1153                                 "al r0 r1 r2 LSL 19",
1154                                 "ShiftTypes_al_r0_r1_r2_LSL_19",
1155                                 ARRAY_SIZE(kShiftTypes),
1156                                 kShiftTypes},
1157                                {{al, r0, r1, r2, LSL, 20},
1158                                 "al r0 r1 r2 LSL 20",
1159                                 "ShiftTypes_al_r0_r1_r2_LSL_20",
1160                                 ARRAY_SIZE(kShiftTypes),
1161                                 kShiftTypes},
1162                                {{al, r0, r1, r2, LSL, 21},
1163                                 "al r0 r1 r2 LSL 21",
1164                                 "ShiftTypes_al_r0_r1_r2_LSL_21",
1165                                 ARRAY_SIZE(kShiftTypes),
1166                                 kShiftTypes},
1167                                {{al, r0, r1, r2, LSL, 22},
1168                                 "al r0 r1 r2 LSL 22",
1169                                 "ShiftTypes_al_r0_r1_r2_LSL_22",
1170                                 ARRAY_SIZE(kShiftTypes),
1171                                 kShiftTypes},
1172                                {{al, r0, r1, r2, LSL, 23},
1173                                 "al r0 r1 r2 LSL 23",
1174                                 "ShiftTypes_al_r0_r1_r2_LSL_23",
1175                                 ARRAY_SIZE(kShiftTypes),
1176                                 kShiftTypes},
1177                                {{al, r0, r1, r2, LSL, 24},
1178                                 "al r0 r1 r2 LSL 24",
1179                                 "ShiftTypes_al_r0_r1_r2_LSL_24",
1180                                 ARRAY_SIZE(kShiftTypes),
1181                                 kShiftTypes},
1182                                {{al, r0, r1, r2, LSL, 25},
1183                                 "al r0 r1 r2 LSL 25",
1184                                 "ShiftTypes_al_r0_r1_r2_LSL_25",
1185                                 ARRAY_SIZE(kShiftTypes),
1186                                 kShiftTypes},
1187                                {{al, r0, r1, r2, LSL, 26},
1188                                 "al r0 r1 r2 LSL 26",
1189                                 "ShiftTypes_al_r0_r1_r2_LSL_26",
1190                                 ARRAY_SIZE(kShiftTypes),
1191                                 kShiftTypes},
1192                                {{al, r0, r1, r2, LSL, 27},
1193                                 "al r0 r1 r2 LSL 27",
1194                                 "ShiftTypes_al_r0_r1_r2_LSL_27",
1195                                 ARRAY_SIZE(kShiftTypes),
1196                                 kShiftTypes},
1197                                {{al, r0, r1, r2, LSL, 28},
1198                                 "al r0 r1 r2 LSL 28",
1199                                 "ShiftTypes_al_r0_r1_r2_LSL_28",
1200                                 ARRAY_SIZE(kShiftTypes),
1201                                 kShiftTypes},
1202                                {{al, r0, r1, r2, LSL, 29},
1203                                 "al r0 r1 r2 LSL 29",
1204                                 "ShiftTypes_al_r0_r1_r2_LSL_29",
1205                                 ARRAY_SIZE(kShiftTypes),
1206                                 kShiftTypes},
1207                                {{al, r0, r1, r2, LSL, 30},
1208                                 "al r0 r1 r2 LSL 30",
1209                                 "ShiftTypes_al_r0_r1_r2_LSL_30",
1210                                 ARRAY_SIZE(kShiftTypes),
1211                                 kShiftTypes},
1212                                {{al, r0, r1, r2, LSL, 31},
1213                                 "al r0 r1 r2 LSL 31",
1214                                 "ShiftTypes_al_r0_r1_r2_LSL_31",
1215                                 ARRAY_SIZE(kShiftTypes),
1216                                 kShiftTypes},
1217                                {{al, r0, r1, r2, ROR, 1},
1218                                 "al r0 r1 r2 ROR 1",
1219                                 "ShiftTypes_al_r0_r1_r2_ROR_1",
1220                                 ARRAY_SIZE(kShiftTypes),
1221                                 kShiftTypes},
1222                                {{al, r0, r1, r2, ROR, 2},
1223                                 "al r0 r1 r2 ROR 2",
1224                                 "ShiftTypes_al_r0_r1_r2_ROR_2",
1225                                 ARRAY_SIZE(kShiftTypes),
1226                                 kShiftTypes},
1227                                {{al, r0, r1, r2, ROR, 3},
1228                                 "al r0 r1 r2 ROR 3",
1229                                 "ShiftTypes_al_r0_r1_r2_ROR_3",
1230                                 ARRAY_SIZE(kShiftTypes),
1231                                 kShiftTypes},
1232                                {{al, r0, r1, r2, ROR, 4},
1233                                 "al r0 r1 r2 ROR 4",
1234                                 "ShiftTypes_al_r0_r1_r2_ROR_4",
1235                                 ARRAY_SIZE(kShiftTypes),
1236                                 kShiftTypes},
1237                                {{al, r0, r1, r2, ROR, 5},
1238                                 "al r0 r1 r2 ROR 5",
1239                                 "ShiftTypes_al_r0_r1_r2_ROR_5",
1240                                 ARRAY_SIZE(kShiftTypes),
1241                                 kShiftTypes},
1242                                {{al, r0, r1, r2, ROR, 6},
1243                                 "al r0 r1 r2 ROR 6",
1244                                 "ShiftTypes_al_r0_r1_r2_ROR_6",
1245                                 ARRAY_SIZE(kShiftTypes),
1246                                 kShiftTypes},
1247                                {{al, r0, r1, r2, ROR, 7},
1248                                 "al r0 r1 r2 ROR 7",
1249                                 "ShiftTypes_al_r0_r1_r2_ROR_7",
1250                                 ARRAY_SIZE(kShiftTypes),
1251                                 kShiftTypes},
1252                                {{al, r0, r1, r2, ROR, 8},
1253                                 "al r0 r1 r2 ROR 8",
1254                                 "ShiftTypes_al_r0_r1_r2_ROR_8",
1255                                 ARRAY_SIZE(kShiftTypes),
1256                                 kShiftTypes},
1257                                {{al, r0, r1, r2, ROR, 9},
1258                                 "al r0 r1 r2 ROR 9",
1259                                 "ShiftTypes_al_r0_r1_r2_ROR_9",
1260                                 ARRAY_SIZE(kShiftTypes),
1261                                 kShiftTypes},
1262                                {{al, r0, r1, r2, ROR, 10},
1263                                 "al r0 r1 r2 ROR 10",
1264                                 "ShiftTypes_al_r0_r1_r2_ROR_10",
1265                                 ARRAY_SIZE(kShiftTypes),
1266                                 kShiftTypes},
1267                                {{al, r0, r1, r2, ROR, 11},
1268                                 "al r0 r1 r2 ROR 11",
1269                                 "ShiftTypes_al_r0_r1_r2_ROR_11",
1270                                 ARRAY_SIZE(kShiftTypes),
1271                                 kShiftTypes},
1272                                {{al, r0, r1, r2, ROR, 12},
1273                                 "al r0 r1 r2 ROR 12",
1274                                 "ShiftTypes_al_r0_r1_r2_ROR_12",
1275                                 ARRAY_SIZE(kShiftTypes),
1276                                 kShiftTypes},
1277                                {{al, r0, r1, r2, ROR, 13},
1278                                 "al r0 r1 r2 ROR 13",
1279                                 "ShiftTypes_al_r0_r1_r2_ROR_13",
1280                                 ARRAY_SIZE(kShiftTypes),
1281                                 kShiftTypes},
1282                                {{al, r0, r1, r2, ROR, 14},
1283                                 "al r0 r1 r2 ROR 14",
1284                                 "ShiftTypes_al_r0_r1_r2_ROR_14",
1285                                 ARRAY_SIZE(kShiftTypes),
1286                                 kShiftTypes},
1287                                {{al, r0, r1, r2, ROR, 15},
1288                                 "al r0 r1 r2 ROR 15",
1289                                 "ShiftTypes_al_r0_r1_r2_ROR_15",
1290                                 ARRAY_SIZE(kShiftTypes),
1291                                 kShiftTypes},
1292                                {{al, r0, r1, r2, ROR, 16},
1293                                 "al r0 r1 r2 ROR 16",
1294                                 "ShiftTypes_al_r0_r1_r2_ROR_16",
1295                                 ARRAY_SIZE(kShiftTypes),
1296                                 kShiftTypes},
1297                                {{al, r0, r1, r2, ROR, 17},
1298                                 "al r0 r1 r2 ROR 17",
1299                                 "ShiftTypes_al_r0_r1_r2_ROR_17",
1300                                 ARRAY_SIZE(kShiftTypes),
1301                                 kShiftTypes},
1302                                {{al, r0, r1, r2, ROR, 18},
1303                                 "al r0 r1 r2 ROR 18",
1304                                 "ShiftTypes_al_r0_r1_r2_ROR_18",
1305                                 ARRAY_SIZE(kShiftTypes),
1306                                 kShiftTypes},
1307                                {{al, r0, r1, r2, ROR, 19},
1308                                 "al r0 r1 r2 ROR 19",
1309                                 "ShiftTypes_al_r0_r1_r2_ROR_19",
1310                                 ARRAY_SIZE(kShiftTypes),
1311                                 kShiftTypes},
1312                                {{al, r0, r1, r2, ROR, 20},
1313                                 "al r0 r1 r2 ROR 20",
1314                                 "ShiftTypes_al_r0_r1_r2_ROR_20",
1315                                 ARRAY_SIZE(kShiftTypes),
1316                                 kShiftTypes},
1317                                {{al, r0, r1, r2, ROR, 21},
1318                                 "al r0 r1 r2 ROR 21",
1319                                 "ShiftTypes_al_r0_r1_r2_ROR_21",
1320                                 ARRAY_SIZE(kShiftTypes),
1321                                 kShiftTypes},
1322                                {{al, r0, r1, r2, ROR, 22},
1323                                 "al r0 r1 r2 ROR 22",
1324                                 "ShiftTypes_al_r0_r1_r2_ROR_22",
1325                                 ARRAY_SIZE(kShiftTypes),
1326                                 kShiftTypes},
1327                                {{al, r0, r1, r2, ROR, 23},
1328                                 "al r0 r1 r2 ROR 23",
1329                                 "ShiftTypes_al_r0_r1_r2_ROR_23",
1330                                 ARRAY_SIZE(kShiftTypes),
1331                                 kShiftTypes},
1332                                {{al, r0, r1, r2, ROR, 24},
1333                                 "al r0 r1 r2 ROR 24",
1334                                 "ShiftTypes_al_r0_r1_r2_ROR_24",
1335                                 ARRAY_SIZE(kShiftTypes),
1336                                 kShiftTypes},
1337                                {{al, r0, r1, r2, ROR, 25},
1338                                 "al r0 r1 r2 ROR 25",
1339                                 "ShiftTypes_al_r0_r1_r2_ROR_25",
1340                                 ARRAY_SIZE(kShiftTypes),
1341                                 kShiftTypes},
1342                                {{al, r0, r1, r2, ROR, 26},
1343                                 "al r0 r1 r2 ROR 26",
1344                                 "ShiftTypes_al_r0_r1_r2_ROR_26",
1345                                 ARRAY_SIZE(kShiftTypes),
1346                                 kShiftTypes},
1347                                {{al, r0, r1, r2, ROR, 27},
1348                                 "al r0 r1 r2 ROR 27",
1349                                 "ShiftTypes_al_r0_r1_r2_ROR_27",
1350                                 ARRAY_SIZE(kShiftTypes),
1351                                 kShiftTypes},
1352                                {{al, r0, r1, r2, ROR, 28},
1353                                 "al r0 r1 r2 ROR 28",
1354                                 "ShiftTypes_al_r0_r1_r2_ROR_28",
1355                                 ARRAY_SIZE(kShiftTypes),
1356                                 kShiftTypes},
1357                                {{al, r0, r1, r2, ROR, 29},
1358                                 "al r0 r1 r2 ROR 29",
1359                                 "ShiftTypes_al_r0_r1_r2_ROR_29",
1360                                 ARRAY_SIZE(kShiftTypes),
1361                                 kShiftTypes},
1362                                {{al, r0, r1, r2, ROR, 30},
1363                                 "al r0 r1 r2 ROR 30",
1364                                 "ShiftTypes_al_r0_r1_r2_ROR_30",
1365                                 ARRAY_SIZE(kShiftTypes),
1366                                 kShiftTypes},
1367                                {{al, r0, r1, r2, ROR, 31},
1368                                 "al r0 r1 r2 ROR 31",
1369                                 "ShiftTypes_al_r0_r1_r2_ROR_31",
1370                                 ARRAY_SIZE(kShiftTypes),
1371                                 kShiftTypes}};
1372 
1373 // We record all inputs to the instructions as outputs. This way, we also check
1374 // that what shouldn't change didn't change.
1375 struct TestResult {
1376   size_t output_size;
1377   const Inputs* outputs;
1378 };
1379 
1380 // These headers each contain an array of `TestResult` with the reference output
1381 // values. The reference arrays are names `kReference{mnemonic}`.
1382 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-adc-t32.h"
1383 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-adcs-t32.h"
1384 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-add-t32.h"
1385 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-adds-t32.h"
1386 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-and-t32.h"
1387 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-ands-t32.h"
1388 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-bic-t32.h"
1389 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-bics-t32.h"
1390 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-eor-t32.h"
1391 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-eors-t32.h"
1392 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-orn-t32.h"
1393 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-orns-t32.h"
1394 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-orr-t32.h"
1395 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-orrs-t32.h"
1396 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-rsb-t32.h"
1397 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-rsbs-t32.h"
1398 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-sbc-t32.h"
1399 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-sbcs-t32.h"
1400 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-sub-t32.h"
1401 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to31-subs-t32.h"
1402 
1403 
1404 // The maximum number of errors to report in detail for each test.
1405 const unsigned kErrorReportLimit = 8;
1406 
1407 typedef void (MacroAssembler::*Fn)(Condition cond,
1408                                    Register rd,
1409                                    Register rn,
1410                                    const Operand& op);
1411 
TestHelper(Fn instruction,const char * mnemonic,const TestResult reference[])1412 void TestHelper(Fn instruction,
1413                 const char* mnemonic,
1414                 const TestResult reference[]) {
1415   SETUP();
1416   masm.UseT32();
1417   START();
1418 
1419   // Data to compare to `reference`.
1420   TestResult* results[ARRAY_SIZE(kTests)];
1421 
1422   // Test cases for memory bound instructions may allocate a buffer and save its
1423   // address in this array.
1424   byte* scratch_memory_buffers[ARRAY_SIZE(kTests)];
1425 
1426   // Generate a loop for each element in `kTests`. Each loop tests one specific
1427   // instruction.
1428   for (unsigned i = 0; i < ARRAY_SIZE(kTests); i++) {
1429     // Allocate results on the heap for this test.
1430     results[i] = new TestResult;
1431     results[i]->outputs = new Inputs[kTests[i].input_size];
1432     results[i]->output_size = kTests[i].input_size;
1433 
1434     size_t input_stride = sizeof(kTests[i].inputs[0]) * kTests[i].input_size;
1435     VIXL_ASSERT(IsUint32(input_stride));
1436 
1437     scratch_memory_buffers[i] = NULL;
1438 
1439     Label loop;
1440     UseScratchRegisterScope scratch_registers(&masm);
1441     // Include all registers from r0 ro r12.
1442     scratch_registers.Include(RegisterList(0x1fff));
1443 
1444     // Values to pass to the macro-assembler.
1445     Condition cond = kTests[i].operands.cond;
1446     Register rd = kTests[i].operands.rd;
1447     Register rn = kTests[i].operands.rn;
1448     Register rm = kTests[i].operands.rm;
1449     ShiftType shift = kTests[i].operands.shift;
1450     uint32_t amount = kTests[i].operands.amount;
1451     Operand op(rm, shift, amount);
1452     scratch_registers.Exclude(rd);
1453     scratch_registers.Exclude(rn);
1454     scratch_registers.Exclude(rm);
1455 
1456     // Allocate reserved registers for our own use.
1457     Register input_ptr = scratch_registers.Acquire();
1458     Register input_end = scratch_registers.Acquire();
1459     Register result_ptr = scratch_registers.Acquire();
1460 
1461     // Initialize `input_ptr` to the first element and `input_end` the address
1462     // after the array.
1463     __ Mov(input_ptr, Operand::From(kTests[i].inputs));
1464     __ Add(input_end, input_ptr, static_cast<uint32_t>(input_stride));
1465     __ Mov(result_ptr, Operand::From(results[i]->outputs));
1466     __ Bind(&loop);
1467 
1468     {
1469       UseScratchRegisterScope temp_registers(&masm);
1470       Register nzcv_bits = temp_registers.Acquire();
1471       Register saved_q_bit = temp_registers.Acquire();
1472       // Save the `Q` bit flag.
1473       __ Mrs(saved_q_bit, APSR);
1474       __ And(saved_q_bit, saved_q_bit, QFlag);
1475       // Set the `NZCV` and `Q` flags together.
1476       __ Ldr(nzcv_bits, MemOperand(input_ptr, offsetof(Inputs, apsr)));
1477       __ Orr(nzcv_bits, nzcv_bits, saved_q_bit);
1478       __ Msr(APSR_nzcvq, nzcv_bits);
1479     }
1480     __ Ldr(rd, MemOperand(input_ptr, offsetof(Inputs, rd)));
1481     __ Ldr(rn, MemOperand(input_ptr, offsetof(Inputs, rn)));
1482     __ Ldr(rm, MemOperand(input_ptr, offsetof(Inputs, rm)));
1483 
1484     (masm.*instruction)(cond, rd, rn, op);
1485 
1486     {
1487       UseScratchRegisterScope temp_registers(&masm);
1488       Register nzcv_bits = temp_registers.Acquire();
1489       __ Mrs(nzcv_bits, APSR);
1490       // Only record the NZCV bits.
1491       __ And(nzcv_bits, nzcv_bits, NZCVFlag);
1492       __ Str(nzcv_bits, MemOperand(result_ptr, offsetof(Inputs, apsr)));
1493     }
1494     __ Str(rd, MemOperand(result_ptr, offsetof(Inputs, rd)));
1495     __ Str(rn, MemOperand(result_ptr, offsetof(Inputs, rn)));
1496     __ Str(rm, MemOperand(result_ptr, offsetof(Inputs, rm)));
1497 
1498     // Advance the result pointer.
1499     __ Add(result_ptr, result_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
1500     // Loop back until `input_ptr` is lower than `input_base`.
1501     __ Add(input_ptr, input_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
1502     __ Cmp(input_ptr, input_end);
1503     __ B(ne, &loop);
1504   }
1505 
1506   END();
1507 
1508   RUN();
1509 
1510   if (Test::generate_test_trace()) {
1511     // Print the results.
1512     for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
1513       printf("const Inputs kOutputs_%s_%s[] = {\n",
1514              mnemonic,
1515              kTests[i].identifier);
1516       for (size_t j = 0; j < results[i]->output_size; j++) {
1517         printf("  { ");
1518         printf("0x%08" PRIx32, results[i]->outputs[j].apsr);
1519         printf(", ");
1520         printf("0x%08" PRIx32, results[i]->outputs[j].rd);
1521         printf(", ");
1522         printf("0x%08" PRIx32, results[i]->outputs[j].rn);
1523         printf(", ");
1524         printf("0x%08" PRIx32, results[i]->outputs[j].rm);
1525         printf(" },\n");
1526       }
1527       printf("};\n");
1528     }
1529     printf("const TestResult kReference%s[] = {\n", mnemonic);
1530     for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
1531       printf("  {\n");
1532       printf("    ARRAY_SIZE(kOutputs_%s_%s),\n",
1533              mnemonic,
1534              kTests[i].identifier);
1535       printf("    kOutputs_%s_%s,\n", mnemonic, kTests[i].identifier);
1536       printf("  },\n");
1537     }
1538     printf("};\n");
1539   } else if (kCheckSimulatorTestResults) {
1540     // Check the results.
1541     unsigned total_error_count = 0;
1542     for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
1543       bool instruction_has_errors = false;
1544       for (size_t j = 0; j < kTests[i].input_size; j++) {
1545         uint32_t apsr = results[i]->outputs[j].apsr;
1546         uint32_t rd = results[i]->outputs[j].rd;
1547         uint32_t rn = results[i]->outputs[j].rn;
1548         uint32_t rm = results[i]->outputs[j].rm;
1549         uint32_t apsr_input = kTests[i].inputs[j].apsr;
1550         uint32_t rd_input = kTests[i].inputs[j].rd;
1551         uint32_t rn_input = kTests[i].inputs[j].rn;
1552         uint32_t rm_input = kTests[i].inputs[j].rm;
1553         uint32_t apsr_ref = reference[i].outputs[j].apsr;
1554         uint32_t rd_ref = reference[i].outputs[j].rd;
1555         uint32_t rn_ref = reference[i].outputs[j].rn;
1556         uint32_t rm_ref = reference[i].outputs[j].rm;
1557 
1558         if (((apsr != apsr_ref) || (rd != rd_ref) || (rn != rn_ref) ||
1559              (rm != rm_ref)) &&
1560             (++total_error_count <= kErrorReportLimit)) {
1561           // Print the instruction once even if it triggered multiple failures.
1562           if (!instruction_has_errors) {
1563             printf("Error(s) when testing \"%s %s\":\n",
1564                    mnemonic,
1565                    kTests[i].operands_description);
1566             instruction_has_errors = true;
1567           }
1568           // Print subsequent errors.
1569           printf("  Input:    ");
1570           printf("0x%08" PRIx32, apsr_input);
1571           printf(", ");
1572           printf("0x%08" PRIx32, rd_input);
1573           printf(", ");
1574           printf("0x%08" PRIx32, rn_input);
1575           printf(", ");
1576           printf("0x%08" PRIx32, rm_input);
1577           printf("\n");
1578           printf("  Expected: ");
1579           printf("0x%08" PRIx32, apsr_ref);
1580           printf(", ");
1581           printf("0x%08" PRIx32, rd_ref);
1582           printf(", ");
1583           printf("0x%08" PRIx32, rn_ref);
1584           printf(", ");
1585           printf("0x%08" PRIx32, rm_ref);
1586           printf("\n");
1587           printf("  Found:    ");
1588           printf("0x%08" PRIx32, apsr);
1589           printf(", ");
1590           printf("0x%08" PRIx32, rd);
1591           printf(", ");
1592           printf("0x%08" PRIx32, rn);
1593           printf(", ");
1594           printf("0x%08" PRIx32, rm);
1595           printf("\n\n");
1596         }
1597       }
1598     }
1599 
1600     if (total_error_count > kErrorReportLimit) {
1601       printf("%u other errors follow.\n",
1602              total_error_count - kErrorReportLimit);
1603     }
1604     VIXL_CHECK(total_error_count == 0);
1605   } else {
1606     VIXL_WARNING("Assembled the code, but did not run anything.\n");
1607   }
1608 
1609   for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
1610     delete[] results[i]->outputs;
1611     delete results[i];
1612     delete[] scratch_memory_buffers[i];
1613   }
1614 }
1615 
1616 // Instantiate tests for each instruction in the list.
1617 // TODO: Remove this limitation by having a sandboxing mechanism.
1618 #if defined(VIXL_HOST_POINTER_32)
1619 #define TEST(mnemonic)                                                        \
1620   void Test_##mnemonic() {                                                    \
1621     TestHelper(&MacroAssembler::mnemonic, #mnemonic, kReference##mnemonic);   \
1622   }                                                                           \
1623   Test test_##mnemonic(                                                       \
1624       "AARCH32_SIMULATOR_COND_RD_RN_OPERAND_RM_SHIFT_AMOUNT_1TO31_" #mnemonic \
1625       "_T32",                                                                 \
1626       &Test_##mnemonic);
1627 #else
1628 #define TEST(mnemonic)                                                        \
1629   void Test_##mnemonic() {                                                    \
1630     VIXL_WARNING("This test can only run on a 32-bit host.\n");               \
1631     USE(TestHelper);                                                          \
1632   }                                                                           \
1633   Test test_##mnemonic(                                                       \
1634       "AARCH32_SIMULATOR_COND_RD_RN_OPERAND_RM_SHIFT_AMOUNT_1TO31_" #mnemonic \
1635       "_T32",                                                                 \
1636       &Test_##mnemonic);
1637 #endif
1638 
1639 FOREACH_INSTRUCTION(TEST)
1640 #undef TEST
1641 
1642 }  // namespace
1643 #endif
1644 
1645 }  // namespace aarch32
1646 }  // namespace vixl
1647