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