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(Orn)                       \
129   M(Orns)                      \
130   M(Orr)                       \
131   M(Orrs)                      \
132   M(Rsb)                       \
133   M(Rsbs)                      \
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_T32
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, LSR, 1},
840                                 "eq r0 r0 r0 LSR 1",
841                                 "Condition_eq_r0_r0_r0_LSR_1",
842                                 ARRAY_SIZE(kCondition),
843                                 kCondition},
844                                {{ne, r0, r0, r0, LSR, 1},
845                                 "ne r0 r0 r0 LSR 1",
846                                 "Condition_ne_r0_r0_r0_LSR_1",
847                                 ARRAY_SIZE(kCondition),
848                                 kCondition},
849                                {{cs, r0, r0, r0, LSR, 1},
850                                 "cs r0 r0 r0 LSR 1",
851                                 "Condition_cs_r0_r0_r0_LSR_1",
852                                 ARRAY_SIZE(kCondition),
853                                 kCondition},
854                                {{cc, r0, r0, r0, LSR, 1},
855                                 "cc r0 r0 r0 LSR 1",
856                                 "Condition_cc_r0_r0_r0_LSR_1",
857                                 ARRAY_SIZE(kCondition),
858                                 kCondition},
859                                {{mi, r0, r0, r0, LSR, 1},
860                                 "mi r0 r0 r0 LSR 1",
861                                 "Condition_mi_r0_r0_r0_LSR_1",
862                                 ARRAY_SIZE(kCondition),
863                                 kCondition},
864                                {{pl, r0, r0, r0, LSR, 1},
865                                 "pl r0 r0 r0 LSR 1",
866                                 "Condition_pl_r0_r0_r0_LSR_1",
867                                 ARRAY_SIZE(kCondition),
868                                 kCondition},
869                                {{vs, r0, r0, r0, LSR, 1},
870                                 "vs r0 r0 r0 LSR 1",
871                                 "Condition_vs_r0_r0_r0_LSR_1",
872                                 ARRAY_SIZE(kCondition),
873                                 kCondition},
874                                {{vc, r0, r0, r0, LSR, 1},
875                                 "vc r0 r0 r0 LSR 1",
876                                 "Condition_vc_r0_r0_r0_LSR_1",
877                                 ARRAY_SIZE(kCondition),
878                                 kCondition},
879                                {{hi, r0, r0, r0, LSR, 1},
880                                 "hi r0 r0 r0 LSR 1",
881                                 "Condition_hi_r0_r0_r0_LSR_1",
882                                 ARRAY_SIZE(kCondition),
883                                 kCondition},
884                                {{ls, r0, r0, r0, LSR, 1},
885                                 "ls r0 r0 r0 LSR 1",
886                                 "Condition_ls_r0_r0_r0_LSR_1",
887                                 ARRAY_SIZE(kCondition),
888                                 kCondition},
889                                {{ge, r0, r0, r0, LSR, 1},
890                                 "ge r0 r0 r0 LSR 1",
891                                 "Condition_ge_r0_r0_r0_LSR_1",
892                                 ARRAY_SIZE(kCondition),
893                                 kCondition},
894                                {{lt, r0, r0, r0, LSR, 1},
895                                 "lt r0 r0 r0 LSR 1",
896                                 "Condition_lt_r0_r0_r0_LSR_1",
897                                 ARRAY_SIZE(kCondition),
898                                 kCondition},
899                                {{gt, r0, r0, r0, LSR, 1},
900                                 "gt r0 r0 r0 LSR 1",
901                                 "Condition_gt_r0_r0_r0_LSR_1",
902                                 ARRAY_SIZE(kCondition),
903                                 kCondition},
904                                {{le, r0, r0, r0, LSR, 1},
905                                 "le r0 r0 r0 LSR 1",
906                                 "Condition_le_r0_r0_r0_LSR_1",
907                                 ARRAY_SIZE(kCondition),
908                                 kCondition},
909                                {{al, r0, r0, r0, LSR, 1},
910                                 "al r0 r0 r0 LSR 1",
911                                 "Condition_al_r0_r0_r0_LSR_1",
912                                 ARRAY_SIZE(kCondition),
913                                 kCondition},
914                                {{al, r3, r3, r4, LSR, 1},
915                                 "al r3 r3 r4 LSR 1",
916                                 "RdIsRn_al_r3_r3_r4_LSR_1",
917                                 ARRAY_SIZE(kRdIsRn),
918                                 kRdIsRn},
919                                {{al, r2, r2, r12, LSR, 1},
920                                 "al r2 r2 r12 LSR 1",
921                                 "RdIsRn_al_r2_r2_r12_LSR_1",
922                                 ARRAY_SIZE(kRdIsRn),
923                                 kRdIsRn},
924                                {{al, r8, r8, r5, LSR, 1},
925                                 "al r8 r8 r5 LSR 1",
926                                 "RdIsRn_al_r8_r8_r5_LSR_1",
927                                 ARRAY_SIZE(kRdIsRn),
928                                 kRdIsRn},
929                                {{al, r14, r14, r0, LSR, 1},
930                                 "al r14 r14 r0 LSR 1",
931                                 "RdIsRn_al_r14_r14_r0_LSR_1",
932                                 ARRAY_SIZE(kRdIsRn),
933                                 kRdIsRn},
934                                {{al, r11, r11, r10, LSR, 1},
935                                 "al r11 r11 r10 LSR 1",
936                                 "RdIsRn_al_r11_r11_r10_LSR_1",
937                                 ARRAY_SIZE(kRdIsRn),
938                                 kRdIsRn},
939                                {{al, r12, r12, r10, LSR, 1},
940                                 "al r12 r12 r10 LSR 1",
941                                 "RdIsRn_al_r12_r12_r10_LSR_1",
942                                 ARRAY_SIZE(kRdIsRn),
943                                 kRdIsRn},
944                                {{al, r4, r4, r8, LSR, 1},
945                                 "al r4 r4 r8 LSR 1",
946                                 "RdIsRn_al_r4_r4_r8_LSR_1",
947                                 ARRAY_SIZE(kRdIsRn),
948                                 kRdIsRn},
949                                {{al, r5, r5, r14, LSR, 1},
950                                 "al r5 r5 r14 LSR 1",
951                                 "RdIsRn_al_r5_r5_r14_LSR_1",
952                                 ARRAY_SIZE(kRdIsRn),
953                                 kRdIsRn},
954                                {{al, r0, r0, r6, LSR, 1},
955                                 "al r0 r0 r6 LSR 1",
956                                 "RdIsRn_al_r0_r0_r6_LSR_1",
957                                 ARRAY_SIZE(kRdIsRn),
958                                 kRdIsRn},
959                                {{al, r12, r12, r1, LSR, 1},
960                                 "al r12 r12 r1 LSR 1",
961                                 "RdIsRn_al_r12_r12_r1_LSR_1",
962                                 ARRAY_SIZE(kRdIsRn),
963                                 kRdIsRn},
964                                {{al, r6, r11, r6, LSR, 1},
965                                 "al r6 r11 r6 LSR 1",
966                                 "RdIsRm_al_r6_r11_r6_LSR_1",
967                                 ARRAY_SIZE(kRdIsRm),
968                                 kRdIsRm},
969                                {{al, r11, r9, r11, LSR, 1},
970                                 "al r11 r9 r11 LSR 1",
971                                 "RdIsRm_al_r11_r9_r11_LSR_1",
972                                 ARRAY_SIZE(kRdIsRm),
973                                 kRdIsRm},
974                                {{al, r0, r8, r0, LSR, 1},
975                                 "al r0 r8 r0 LSR 1",
976                                 "RdIsRm_al_r0_r8_r0_LSR_1",
977                                 ARRAY_SIZE(kRdIsRm),
978                                 kRdIsRm},
979                                {{al, r2, r11, r2, LSR, 1},
980                                 "al r2 r11 r2 LSR 1",
981                                 "RdIsRm_al_r2_r11_r2_LSR_1",
982                                 ARRAY_SIZE(kRdIsRm),
983                                 kRdIsRm},
984                                {{al, r9, r4, r9, LSR, 1},
985                                 "al r9 r4 r9 LSR 1",
986                                 "RdIsRm_al_r9_r4_r9_LSR_1",
987                                 ARRAY_SIZE(kRdIsRm),
988                                 kRdIsRm},
989                                {{al, r14, r10, r14, LSR, 1},
990                                 "al r14 r10 r14 LSR 1",
991                                 "RdIsRm_al_r14_r10_r14_LSR_1",
992                                 ARRAY_SIZE(kRdIsRm),
993                                 kRdIsRm},
994                                {{al, r7, r0, r7, LSR, 1},
995                                 "al r7 r0 r7 LSR 1",
996                                 "RdIsRm_al_r7_r0_r7_LSR_1",
997                                 ARRAY_SIZE(kRdIsRm),
998                                 kRdIsRm},
999                                {{al, r4, r9, r4, LSR, 1},
1000                                 "al r4 r9 r4 LSR 1",
1001                                 "RdIsRm_al_r4_r9_r4_LSR_1",
1002                                 ARRAY_SIZE(kRdIsRm),
1003                                 kRdIsRm},
1004                                {{al, r6, r10, r6, LSR, 1},
1005                                 "al r6 r10 r6 LSR 1",
1006                                 "RdIsRm_al_r6_r10_r6_LSR_1",
1007                                 ARRAY_SIZE(kRdIsRm),
1008                                 kRdIsRm},
1009                                {{al, r7, r6, r7, LSR, 1},
1010                                 "al r7 r6 r7 LSR 1",
1011                                 "RdIsRm_al_r7_r6_r7_LSR_1",
1012                                 ARRAY_SIZE(kRdIsRm),
1013                                 kRdIsRm},
1014                                {{al, r3, r9, r10, LSR, 1},
1015                                 "al r3 r9 r10 LSR 1",
1016                                 "RdIsNotRnIsNotRm_al_r3_r9_r10_LSR_1",
1017                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1018                                 kRdIsNotRnIsNotRm},
1019                                {{al, r7, r12, r5, LSR, 1},
1020                                 "al r7 r12 r5 LSR 1",
1021                                 "RdIsNotRnIsNotRm_al_r7_r12_r5_LSR_1",
1022                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1023                                 kRdIsNotRnIsNotRm},
1024                                {{al, r8, r5, r6, LSR, 1},
1025                                 "al r8 r5 r6 LSR 1",
1026                                 "RdIsNotRnIsNotRm_al_r8_r5_r6_LSR_1",
1027                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1028                                 kRdIsNotRnIsNotRm},
1029                                {{al, r0, r6, r0, LSR, 1},
1030                                 "al r0 r6 r0 LSR 1",
1031                                 "RdIsNotRnIsNotRm_al_r0_r6_r0_LSR_1",
1032                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1033                                 kRdIsNotRnIsNotRm},
1034                                {{al, r11, r7, r8, LSR, 1},
1035                                 "al r11 r7 r8 LSR 1",
1036                                 "RdIsNotRnIsNotRm_al_r11_r7_r8_LSR_1",
1037                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1038                                 kRdIsNotRnIsNotRm},
1039                                {{al, r12, r2, r3, LSR, 1},
1040                                 "al r12 r2 r3 LSR 1",
1041                                 "RdIsNotRnIsNotRm_al_r12_r2_r3_LSR_1",
1042                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1043                                 kRdIsNotRnIsNotRm},
1044                                {{al, r7, r4, r10, LSR, 1},
1045                                 "al r7 r4 r10 LSR 1",
1046                                 "RdIsNotRnIsNotRm_al_r7_r4_r10_LSR_1",
1047                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1048                                 kRdIsNotRnIsNotRm},
1049                                {{al, r9, r6, r1, LSR, 1},
1050                                 "al r9 r6 r1 LSR 1",
1051                                 "RdIsNotRnIsNotRm_al_r9_r6_r1_LSR_1",
1052                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1053                                 kRdIsNotRnIsNotRm},
1054                                {{al, r10, r14, r3, LSR, 1},
1055                                 "al r10 r14 r3 LSR 1",
1056                                 "RdIsNotRnIsNotRm_al_r10_r14_r3_LSR_1",
1057                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1058                                 kRdIsNotRnIsNotRm},
1059                                {{al, r14, r3, r6, LSR, 1},
1060                                 "al r14 r3 r6 LSR 1",
1061                                 "RdIsNotRnIsNotRm_al_r14_r3_r6_LSR_1",
1062                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
1063                                 kRdIsNotRnIsNotRm},
1064                                {{al, r0, r1, r2, LSR, 1},
1065                                 "al r0 r1 r2 LSR 1",
1066                                 "ShiftTypes_al_r0_r1_r2_LSR_1",
1067                                 ARRAY_SIZE(kShiftTypes),
1068                                 kShiftTypes},
1069                                {{al, r0, r1, r2, LSR, 2},
1070                                 "al r0 r1 r2 LSR 2",
1071                                 "ShiftTypes_al_r0_r1_r2_LSR_2",
1072                                 ARRAY_SIZE(kShiftTypes),
1073                                 kShiftTypes},
1074                                {{al, r0, r1, r2, LSR, 3},
1075                                 "al r0 r1 r2 LSR 3",
1076                                 "ShiftTypes_al_r0_r1_r2_LSR_3",
1077                                 ARRAY_SIZE(kShiftTypes),
1078                                 kShiftTypes},
1079                                {{al, r0, r1, r2, LSR, 4},
1080                                 "al r0 r1 r2 LSR 4",
1081                                 "ShiftTypes_al_r0_r1_r2_LSR_4",
1082                                 ARRAY_SIZE(kShiftTypes),
1083                                 kShiftTypes},
1084                                {{al, r0, r1, r2, LSR, 5},
1085                                 "al r0 r1 r2 LSR 5",
1086                                 "ShiftTypes_al_r0_r1_r2_LSR_5",
1087                                 ARRAY_SIZE(kShiftTypes),
1088                                 kShiftTypes},
1089                                {{al, r0, r1, r2, LSR, 6},
1090                                 "al r0 r1 r2 LSR 6",
1091                                 "ShiftTypes_al_r0_r1_r2_LSR_6",
1092                                 ARRAY_SIZE(kShiftTypes),
1093                                 kShiftTypes},
1094                                {{al, r0, r1, r2, LSR, 7},
1095                                 "al r0 r1 r2 LSR 7",
1096                                 "ShiftTypes_al_r0_r1_r2_LSR_7",
1097                                 ARRAY_SIZE(kShiftTypes),
1098                                 kShiftTypes},
1099                                {{al, r0, r1, r2, LSR, 8},
1100                                 "al r0 r1 r2 LSR 8",
1101                                 "ShiftTypes_al_r0_r1_r2_LSR_8",
1102                                 ARRAY_SIZE(kShiftTypes),
1103                                 kShiftTypes},
1104                                {{al, r0, r1, r2, LSR, 9},
1105                                 "al r0 r1 r2 LSR 9",
1106                                 "ShiftTypes_al_r0_r1_r2_LSR_9",
1107                                 ARRAY_SIZE(kShiftTypes),
1108                                 kShiftTypes},
1109                                {{al, r0, r1, r2, LSR, 10},
1110                                 "al r0 r1 r2 LSR 10",
1111                                 "ShiftTypes_al_r0_r1_r2_LSR_10",
1112                                 ARRAY_SIZE(kShiftTypes),
1113                                 kShiftTypes},
1114                                {{al, r0, r1, r2, LSR, 11},
1115                                 "al r0 r1 r2 LSR 11",
1116                                 "ShiftTypes_al_r0_r1_r2_LSR_11",
1117                                 ARRAY_SIZE(kShiftTypes),
1118                                 kShiftTypes},
1119                                {{al, r0, r1, r2, LSR, 12},
1120                                 "al r0 r1 r2 LSR 12",
1121                                 "ShiftTypes_al_r0_r1_r2_LSR_12",
1122                                 ARRAY_SIZE(kShiftTypes),
1123                                 kShiftTypes},
1124                                {{al, r0, r1, r2, LSR, 13},
1125                                 "al r0 r1 r2 LSR 13",
1126                                 "ShiftTypes_al_r0_r1_r2_LSR_13",
1127                                 ARRAY_SIZE(kShiftTypes),
1128                                 kShiftTypes},
1129                                {{al, r0, r1, r2, LSR, 14},
1130                                 "al r0 r1 r2 LSR 14",
1131                                 "ShiftTypes_al_r0_r1_r2_LSR_14",
1132                                 ARRAY_SIZE(kShiftTypes),
1133                                 kShiftTypes},
1134                                {{al, r0, r1, r2, LSR, 15},
1135                                 "al r0 r1 r2 LSR 15",
1136                                 "ShiftTypes_al_r0_r1_r2_LSR_15",
1137                                 ARRAY_SIZE(kShiftTypes),
1138                                 kShiftTypes},
1139                                {{al, r0, r1, r2, LSR, 16},
1140                                 "al r0 r1 r2 LSR 16",
1141                                 "ShiftTypes_al_r0_r1_r2_LSR_16",
1142                                 ARRAY_SIZE(kShiftTypes),
1143                                 kShiftTypes},
1144                                {{al, r0, r1, r2, LSR, 17},
1145                                 "al r0 r1 r2 LSR 17",
1146                                 "ShiftTypes_al_r0_r1_r2_LSR_17",
1147                                 ARRAY_SIZE(kShiftTypes),
1148                                 kShiftTypes},
1149                                {{al, r0, r1, r2, LSR, 18},
1150                                 "al r0 r1 r2 LSR 18",
1151                                 "ShiftTypes_al_r0_r1_r2_LSR_18",
1152                                 ARRAY_SIZE(kShiftTypes),
1153                                 kShiftTypes},
1154                                {{al, r0, r1, r2, LSR, 19},
1155                                 "al r0 r1 r2 LSR 19",
1156                                 "ShiftTypes_al_r0_r1_r2_LSR_19",
1157                                 ARRAY_SIZE(kShiftTypes),
1158                                 kShiftTypes},
1159                                {{al, r0, r1, r2, LSR, 20},
1160                                 "al r0 r1 r2 LSR 20",
1161                                 "ShiftTypes_al_r0_r1_r2_LSR_20",
1162                                 ARRAY_SIZE(kShiftTypes),
1163                                 kShiftTypes},
1164                                {{al, r0, r1, r2, LSR, 21},
1165                                 "al r0 r1 r2 LSR 21",
1166                                 "ShiftTypes_al_r0_r1_r2_LSR_21",
1167                                 ARRAY_SIZE(kShiftTypes),
1168                                 kShiftTypes},
1169                                {{al, r0, r1, r2, LSR, 22},
1170                                 "al r0 r1 r2 LSR 22",
1171                                 "ShiftTypes_al_r0_r1_r2_LSR_22",
1172                                 ARRAY_SIZE(kShiftTypes),
1173                                 kShiftTypes},
1174                                {{al, r0, r1, r2, LSR, 23},
1175                                 "al r0 r1 r2 LSR 23",
1176                                 "ShiftTypes_al_r0_r1_r2_LSR_23",
1177                                 ARRAY_SIZE(kShiftTypes),
1178                                 kShiftTypes},
1179                                {{al, r0, r1, r2, LSR, 24},
1180                                 "al r0 r1 r2 LSR 24",
1181                                 "ShiftTypes_al_r0_r1_r2_LSR_24",
1182                                 ARRAY_SIZE(kShiftTypes),
1183                                 kShiftTypes},
1184                                {{al, r0, r1, r2, LSR, 25},
1185                                 "al r0 r1 r2 LSR 25",
1186                                 "ShiftTypes_al_r0_r1_r2_LSR_25",
1187                                 ARRAY_SIZE(kShiftTypes),
1188                                 kShiftTypes},
1189                                {{al, r0, r1, r2, LSR, 26},
1190                                 "al r0 r1 r2 LSR 26",
1191                                 "ShiftTypes_al_r0_r1_r2_LSR_26",
1192                                 ARRAY_SIZE(kShiftTypes),
1193                                 kShiftTypes},
1194                                {{al, r0, r1, r2, LSR, 27},
1195                                 "al r0 r1 r2 LSR 27",
1196                                 "ShiftTypes_al_r0_r1_r2_LSR_27",
1197                                 ARRAY_SIZE(kShiftTypes),
1198                                 kShiftTypes},
1199                                {{al, r0, r1, r2, LSR, 28},
1200                                 "al r0 r1 r2 LSR 28",
1201                                 "ShiftTypes_al_r0_r1_r2_LSR_28",
1202                                 ARRAY_SIZE(kShiftTypes),
1203                                 kShiftTypes},
1204                                {{al, r0, r1, r2, LSR, 29},
1205                                 "al r0 r1 r2 LSR 29",
1206                                 "ShiftTypes_al_r0_r1_r2_LSR_29",
1207                                 ARRAY_SIZE(kShiftTypes),
1208                                 kShiftTypes},
1209                                {{al, r0, r1, r2, LSR, 30},
1210                                 "al r0 r1 r2 LSR 30",
1211                                 "ShiftTypes_al_r0_r1_r2_LSR_30",
1212                                 ARRAY_SIZE(kShiftTypes),
1213                                 kShiftTypes},
1214                                {{al, r0, r1, r2, LSR, 31},
1215                                 "al r0 r1 r2 LSR 31",
1216                                 "ShiftTypes_al_r0_r1_r2_LSR_31",
1217                                 ARRAY_SIZE(kShiftTypes),
1218                                 kShiftTypes},
1219                                {{al, r0, r1, r2, LSR, 32},
1220                                 "al r0 r1 r2 LSR 32",
1221                                 "ShiftTypes_al_r0_r1_r2_LSR_32",
1222                                 ARRAY_SIZE(kShiftTypes),
1223                                 kShiftTypes},
1224                                {{al, r0, r1, r2, ASR, 1},
1225                                 "al r0 r1 r2 ASR 1",
1226                                 "ShiftTypes_al_r0_r1_r2_ASR_1",
1227                                 ARRAY_SIZE(kShiftTypes),
1228                                 kShiftTypes},
1229                                {{al, r0, r1, r2, ASR, 2},
1230                                 "al r0 r1 r2 ASR 2",
1231                                 "ShiftTypes_al_r0_r1_r2_ASR_2",
1232                                 ARRAY_SIZE(kShiftTypes),
1233                                 kShiftTypes},
1234                                {{al, r0, r1, r2, ASR, 3},
1235                                 "al r0 r1 r2 ASR 3",
1236                                 "ShiftTypes_al_r0_r1_r2_ASR_3",
1237                                 ARRAY_SIZE(kShiftTypes),
1238                                 kShiftTypes},
1239                                {{al, r0, r1, r2, ASR, 4},
1240                                 "al r0 r1 r2 ASR 4",
1241                                 "ShiftTypes_al_r0_r1_r2_ASR_4",
1242                                 ARRAY_SIZE(kShiftTypes),
1243                                 kShiftTypes},
1244                                {{al, r0, r1, r2, ASR, 5},
1245                                 "al r0 r1 r2 ASR 5",
1246                                 "ShiftTypes_al_r0_r1_r2_ASR_5",
1247                                 ARRAY_SIZE(kShiftTypes),
1248                                 kShiftTypes},
1249                                {{al, r0, r1, r2, ASR, 6},
1250                                 "al r0 r1 r2 ASR 6",
1251                                 "ShiftTypes_al_r0_r1_r2_ASR_6",
1252                                 ARRAY_SIZE(kShiftTypes),
1253                                 kShiftTypes},
1254                                {{al, r0, r1, r2, ASR, 7},
1255                                 "al r0 r1 r2 ASR 7",
1256                                 "ShiftTypes_al_r0_r1_r2_ASR_7",
1257                                 ARRAY_SIZE(kShiftTypes),
1258                                 kShiftTypes},
1259                                {{al, r0, r1, r2, ASR, 8},
1260                                 "al r0 r1 r2 ASR 8",
1261                                 "ShiftTypes_al_r0_r1_r2_ASR_8",
1262                                 ARRAY_SIZE(kShiftTypes),
1263                                 kShiftTypes},
1264                                {{al, r0, r1, r2, ASR, 9},
1265                                 "al r0 r1 r2 ASR 9",
1266                                 "ShiftTypes_al_r0_r1_r2_ASR_9",
1267                                 ARRAY_SIZE(kShiftTypes),
1268                                 kShiftTypes},
1269                                {{al, r0, r1, r2, ASR, 10},
1270                                 "al r0 r1 r2 ASR 10",
1271                                 "ShiftTypes_al_r0_r1_r2_ASR_10",
1272                                 ARRAY_SIZE(kShiftTypes),
1273                                 kShiftTypes},
1274                                {{al, r0, r1, r2, ASR, 11},
1275                                 "al r0 r1 r2 ASR 11",
1276                                 "ShiftTypes_al_r0_r1_r2_ASR_11",
1277                                 ARRAY_SIZE(kShiftTypes),
1278                                 kShiftTypes},
1279                                {{al, r0, r1, r2, ASR, 12},
1280                                 "al r0 r1 r2 ASR 12",
1281                                 "ShiftTypes_al_r0_r1_r2_ASR_12",
1282                                 ARRAY_SIZE(kShiftTypes),
1283                                 kShiftTypes},
1284                                {{al, r0, r1, r2, ASR, 13},
1285                                 "al r0 r1 r2 ASR 13",
1286                                 "ShiftTypes_al_r0_r1_r2_ASR_13",
1287                                 ARRAY_SIZE(kShiftTypes),
1288                                 kShiftTypes},
1289                                {{al, r0, r1, r2, ASR, 14},
1290                                 "al r0 r1 r2 ASR 14",
1291                                 "ShiftTypes_al_r0_r1_r2_ASR_14",
1292                                 ARRAY_SIZE(kShiftTypes),
1293                                 kShiftTypes},
1294                                {{al, r0, r1, r2, ASR, 15},
1295                                 "al r0 r1 r2 ASR 15",
1296                                 "ShiftTypes_al_r0_r1_r2_ASR_15",
1297                                 ARRAY_SIZE(kShiftTypes),
1298                                 kShiftTypes},
1299                                {{al, r0, r1, r2, ASR, 16},
1300                                 "al r0 r1 r2 ASR 16",
1301                                 "ShiftTypes_al_r0_r1_r2_ASR_16",
1302                                 ARRAY_SIZE(kShiftTypes),
1303                                 kShiftTypes},
1304                                {{al, r0, r1, r2, ASR, 17},
1305                                 "al r0 r1 r2 ASR 17",
1306                                 "ShiftTypes_al_r0_r1_r2_ASR_17",
1307                                 ARRAY_SIZE(kShiftTypes),
1308                                 kShiftTypes},
1309                                {{al, r0, r1, r2, ASR, 18},
1310                                 "al r0 r1 r2 ASR 18",
1311                                 "ShiftTypes_al_r0_r1_r2_ASR_18",
1312                                 ARRAY_SIZE(kShiftTypes),
1313                                 kShiftTypes},
1314                                {{al, r0, r1, r2, ASR, 19},
1315                                 "al r0 r1 r2 ASR 19",
1316                                 "ShiftTypes_al_r0_r1_r2_ASR_19",
1317                                 ARRAY_SIZE(kShiftTypes),
1318                                 kShiftTypes},
1319                                {{al, r0, r1, r2, ASR, 20},
1320                                 "al r0 r1 r2 ASR 20",
1321                                 "ShiftTypes_al_r0_r1_r2_ASR_20",
1322                                 ARRAY_SIZE(kShiftTypes),
1323                                 kShiftTypes},
1324                                {{al, r0, r1, r2, ASR, 21},
1325                                 "al r0 r1 r2 ASR 21",
1326                                 "ShiftTypes_al_r0_r1_r2_ASR_21",
1327                                 ARRAY_SIZE(kShiftTypes),
1328                                 kShiftTypes},
1329                                {{al, r0, r1, r2, ASR, 22},
1330                                 "al r0 r1 r2 ASR 22",
1331                                 "ShiftTypes_al_r0_r1_r2_ASR_22",
1332                                 ARRAY_SIZE(kShiftTypes),
1333                                 kShiftTypes},
1334                                {{al, r0, r1, r2, ASR, 23},
1335                                 "al r0 r1 r2 ASR 23",
1336                                 "ShiftTypes_al_r0_r1_r2_ASR_23",
1337                                 ARRAY_SIZE(kShiftTypes),
1338                                 kShiftTypes},
1339                                {{al, r0, r1, r2, ASR, 24},
1340                                 "al r0 r1 r2 ASR 24",
1341                                 "ShiftTypes_al_r0_r1_r2_ASR_24",
1342                                 ARRAY_SIZE(kShiftTypes),
1343                                 kShiftTypes},
1344                                {{al, r0, r1, r2, ASR, 25},
1345                                 "al r0 r1 r2 ASR 25",
1346                                 "ShiftTypes_al_r0_r1_r2_ASR_25",
1347                                 ARRAY_SIZE(kShiftTypes),
1348                                 kShiftTypes},
1349                                {{al, r0, r1, r2, ASR, 26},
1350                                 "al r0 r1 r2 ASR 26",
1351                                 "ShiftTypes_al_r0_r1_r2_ASR_26",
1352                                 ARRAY_SIZE(kShiftTypes),
1353                                 kShiftTypes},
1354                                {{al, r0, r1, r2, ASR, 27},
1355                                 "al r0 r1 r2 ASR 27",
1356                                 "ShiftTypes_al_r0_r1_r2_ASR_27",
1357                                 ARRAY_SIZE(kShiftTypes),
1358                                 kShiftTypes},
1359                                {{al, r0, r1, r2, ASR, 28},
1360                                 "al r0 r1 r2 ASR 28",
1361                                 "ShiftTypes_al_r0_r1_r2_ASR_28",
1362                                 ARRAY_SIZE(kShiftTypes),
1363                                 kShiftTypes},
1364                                {{al, r0, r1, r2, ASR, 29},
1365                                 "al r0 r1 r2 ASR 29",
1366                                 "ShiftTypes_al_r0_r1_r2_ASR_29",
1367                                 ARRAY_SIZE(kShiftTypes),
1368                                 kShiftTypes},
1369                                {{al, r0, r1, r2, ASR, 30},
1370                                 "al r0 r1 r2 ASR 30",
1371                                 "ShiftTypes_al_r0_r1_r2_ASR_30",
1372                                 ARRAY_SIZE(kShiftTypes),
1373                                 kShiftTypes},
1374                                {{al, r0, r1, r2, ASR, 31},
1375                                 "al r0 r1 r2 ASR 31",
1376                                 "ShiftTypes_al_r0_r1_r2_ASR_31",
1377                                 ARRAY_SIZE(kShiftTypes),
1378                                 kShiftTypes},
1379                                {{al, r0, r1, r2, ASR, 32},
1380                                 "al r0 r1 r2 ASR 32",
1381                                 "ShiftTypes_al_r0_r1_r2_ASR_32",
1382                                 ARRAY_SIZE(kShiftTypes),
1383                                 kShiftTypes}};
1384 
1385 // We record all inputs to the instructions as outputs. This way, we also check
1386 // that what shouldn't change didn't change.
1387 struct TestResult {
1388   size_t output_size;
1389   const Inputs* outputs;
1390 };
1391 
1392 // These headers each contain an array of `TestResult` with the reference output
1393 // values. The reference arrays are names `kReference{mnemonic}`.
1394 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-adc.h"
1395 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-adcs.h"
1396 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-add.h"
1397 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-adds.h"
1398 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-and.h"
1399 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-ands.h"
1400 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-bic.h"
1401 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-bics.h"
1402 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-eor.h"
1403 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-eors.h"
1404 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-orn.h"
1405 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-orns.h"
1406 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-orr.h"
1407 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-orrs.h"
1408 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-rsb.h"
1409 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-rsbs.h"
1410 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-sbc.h"
1411 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-sbcs.h"
1412 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-sub.h"
1413 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-shift-amount-1to32-t32-subs.h"
1414 
1415 
1416 // The maximum number of errors to report in detail for each test.
1417 const unsigned kErrorReportLimit = 8;
1418 
1419 typedef void (MacroAssembler::*Fn)(Condition cond,
1420                                    Register rd,
1421                                    Register rn,
1422                                    const Operand& op);
1423 
TestHelper(Fn instruction,const char * mnemonic,const TestResult reference[])1424 void TestHelper(Fn instruction,
1425                 const char* mnemonic,
1426                 const TestResult reference[]) {
1427   SETUP();
1428   masm.UseT32();
1429   START();
1430 
1431   // Data to compare to `reference`.
1432   TestResult* results[ARRAY_SIZE(kTests)];
1433 
1434   // Test cases for memory bound instructions may allocate a buffer and save its
1435   // address in this array.
1436   byte* scratch_memory_buffers[ARRAY_SIZE(kTests)];
1437 
1438   // Generate a loop for each element in `kTests`. Each loop tests one specific
1439   // instruction.
1440   for (unsigned i = 0; i < ARRAY_SIZE(kTests); i++) {
1441     // Allocate results on the heap for this test.
1442     results[i] = new TestResult;
1443     results[i]->outputs = new Inputs[kTests[i].input_size];
1444     results[i]->output_size = kTests[i].input_size;
1445 
1446     size_t input_stride = sizeof(kTests[i].inputs[0]) * kTests[i].input_size;
1447     VIXL_ASSERT(IsUint32(input_stride));
1448 
1449     scratch_memory_buffers[i] = NULL;
1450 
1451     Label loop;
1452     UseScratchRegisterScope scratch_registers(&masm);
1453     // Include all registers from r0 ro r12.
1454     scratch_registers.Include(RegisterList(0x1fff));
1455 
1456     // Values to pass to the macro-assembler.
1457     Condition cond = kTests[i].operands.cond;
1458     Register rd = kTests[i].operands.rd;
1459     Register rn = kTests[i].operands.rn;
1460     Register rm = kTests[i].operands.rm;
1461     ShiftType shift = kTests[i].operands.shift;
1462     uint32_t amount = kTests[i].operands.amount;
1463     Operand op(rm, shift, amount);
1464     scratch_registers.Exclude(rd);
1465     scratch_registers.Exclude(rn);
1466     scratch_registers.Exclude(rm);
1467 
1468     // Allocate reserved registers for our own use.
1469     Register input_ptr = scratch_registers.Acquire();
1470     Register input_end = scratch_registers.Acquire();
1471     Register result_ptr = scratch_registers.Acquire();
1472 
1473     // Initialize `input_ptr` to the first element and `input_end` the address
1474     // after the array.
1475     __ Mov(input_ptr, Operand::From(kTests[i].inputs));
1476     __ Add(input_end, input_ptr, static_cast<uint32_t>(input_stride));
1477     __ Mov(result_ptr, Operand::From(results[i]->outputs));
1478     __ Bind(&loop);
1479 
1480     {
1481       UseScratchRegisterScope temp_registers(&masm);
1482       Register nzcv_bits = temp_registers.Acquire();
1483       Register saved_q_bit = temp_registers.Acquire();
1484       // Save the `Q` bit flag.
1485       __ Mrs(saved_q_bit, APSR);
1486       __ And(saved_q_bit, saved_q_bit, QFlag);
1487       // Set the `NZCV` and `Q` flags together.
1488       __ Ldr(nzcv_bits, MemOperand(input_ptr, offsetof(Inputs, apsr)));
1489       __ Orr(nzcv_bits, nzcv_bits, saved_q_bit);
1490       __ Msr(APSR_nzcvq, nzcv_bits);
1491     }
1492     __ Ldr(rd, MemOperand(input_ptr, offsetof(Inputs, rd)));
1493     __ Ldr(rn, MemOperand(input_ptr, offsetof(Inputs, rn)));
1494     __ Ldr(rm, MemOperand(input_ptr, offsetof(Inputs, rm)));
1495 
1496     (masm.*instruction)(cond, rd, rn, op);
1497 
1498     {
1499       UseScratchRegisterScope temp_registers(&masm);
1500       Register nzcv_bits = temp_registers.Acquire();
1501       __ Mrs(nzcv_bits, APSR);
1502       // Only record the NZCV bits.
1503       __ And(nzcv_bits, nzcv_bits, NZCVFlag);
1504       __ Str(nzcv_bits, MemOperand(result_ptr, offsetof(Inputs, apsr)));
1505     }
1506     __ Str(rd, MemOperand(result_ptr, offsetof(Inputs, rd)));
1507     __ Str(rn, MemOperand(result_ptr, offsetof(Inputs, rn)));
1508     __ Str(rm, MemOperand(result_ptr, offsetof(Inputs, rm)));
1509 
1510     // Advance the result pointer.
1511     __ Add(result_ptr, result_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
1512     // Loop back until `input_ptr` is lower than `input_base`.
1513     __ Add(input_ptr, input_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
1514     __ Cmp(input_ptr, input_end);
1515     __ B(ne, &loop);
1516   }
1517 
1518   END();
1519 
1520   RUN();
1521 
1522   if (Test::generate_test_trace()) {
1523     // Print the results.
1524     for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
1525       printf("const Inputs kOutputs_%s_%s[] = {\n",
1526              mnemonic,
1527              kTests[i].identifier);
1528       for (size_t j = 0; j < results[i]->output_size; j++) {
1529         printf("  { ");
1530         printf("0x%08" PRIx32, results[i]->outputs[j].apsr);
1531         printf(", ");
1532         printf("0x%08" PRIx32, results[i]->outputs[j].rd);
1533         printf(", ");
1534         printf("0x%08" PRIx32, results[i]->outputs[j].rn);
1535         printf(", ");
1536         printf("0x%08" PRIx32, results[i]->outputs[j].rm);
1537         printf(" },\n");
1538       }
1539       printf("};\n");
1540     }
1541     printf("const TestResult kReference%s[] = {\n", mnemonic);
1542     for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
1543       printf("  {\n");
1544       printf("    ARRAY_SIZE(kOutputs_%s_%s),\n",
1545              mnemonic,
1546              kTests[i].identifier);
1547       printf("    kOutputs_%s_%s,\n", mnemonic, kTests[i].identifier);
1548       printf("  },\n");
1549     }
1550     printf("};\n");
1551   } else if (kCheckSimulatorTestResults) {
1552     // Check the results.
1553     unsigned total_error_count = 0;
1554     for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
1555       bool instruction_has_errors = false;
1556       for (size_t j = 0; j < kTests[i].input_size; j++) {
1557         uint32_t apsr = results[i]->outputs[j].apsr;
1558         uint32_t rd = results[i]->outputs[j].rd;
1559         uint32_t rn = results[i]->outputs[j].rn;
1560         uint32_t rm = results[i]->outputs[j].rm;
1561         uint32_t apsr_input = kTests[i].inputs[j].apsr;
1562         uint32_t rd_input = kTests[i].inputs[j].rd;
1563         uint32_t rn_input = kTests[i].inputs[j].rn;
1564         uint32_t rm_input = kTests[i].inputs[j].rm;
1565         uint32_t apsr_ref = reference[i].outputs[j].apsr;
1566         uint32_t rd_ref = reference[i].outputs[j].rd;
1567         uint32_t rn_ref = reference[i].outputs[j].rn;
1568         uint32_t rm_ref = reference[i].outputs[j].rm;
1569 
1570         if (((apsr != apsr_ref) || (rd != rd_ref) || (rn != rn_ref) ||
1571              (rm != rm_ref)) &&
1572             (++total_error_count <= kErrorReportLimit)) {
1573           // Print the instruction once even if it triggered multiple failures.
1574           if (!instruction_has_errors) {
1575             printf("Error(s) when testing \"%s %s\":\n",
1576                    mnemonic,
1577                    kTests[i].operands_description);
1578             instruction_has_errors = true;
1579           }
1580           // Print subsequent errors.
1581           printf("  Input:    ");
1582           printf("0x%08" PRIx32, apsr_input);
1583           printf(", ");
1584           printf("0x%08" PRIx32, rd_input);
1585           printf(", ");
1586           printf("0x%08" PRIx32, rn_input);
1587           printf(", ");
1588           printf("0x%08" PRIx32, rm_input);
1589           printf("\n");
1590           printf("  Expected: ");
1591           printf("0x%08" PRIx32, apsr_ref);
1592           printf(", ");
1593           printf("0x%08" PRIx32, rd_ref);
1594           printf(", ");
1595           printf("0x%08" PRIx32, rn_ref);
1596           printf(", ");
1597           printf("0x%08" PRIx32, rm_ref);
1598           printf("\n");
1599           printf("  Found:    ");
1600           printf("0x%08" PRIx32, apsr);
1601           printf(", ");
1602           printf("0x%08" PRIx32, rd);
1603           printf(", ");
1604           printf("0x%08" PRIx32, rn);
1605           printf(", ");
1606           printf("0x%08" PRIx32, rm);
1607           printf("\n\n");
1608         }
1609       }
1610     }
1611 
1612     if (total_error_count > kErrorReportLimit) {
1613       printf("%u other errors follow.\n",
1614              total_error_count - kErrorReportLimit);
1615     }
1616     VIXL_CHECK(total_error_count == 0);
1617   } else {
1618     VIXL_WARNING("Assembled the code, but did not run anything.\n");
1619   }
1620 
1621   for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
1622     delete[] results[i]->outputs;
1623     delete results[i];
1624     delete[] scratch_memory_buffers[i];
1625   }
1626 
1627   TEARDOWN();
1628 }
1629 
1630 // Instantiate tests for each instruction in the list.
1631 // TODO: Remove this limitation by having a sandboxing mechanism.
1632 #if defined(VIXL_HOST_POINTER_32)
1633 #define TEST(mnemonic)                                                      \
1634   void Test_##mnemonic() {                                                  \
1635     TestHelper(&MacroAssembler::mnemonic, #mnemonic, kReference##mnemonic); \
1636   }                                                                         \
1637   Test test_##mnemonic(                                                     \
1638       "AARCH32_SIMULATOR_COND_RD_RN_OPERAND_RM_SHIFT_AMOUNT_1TO32_"         \
1639       "T32_" #mnemonic,                                                     \
1640       &Test_##mnemonic);
1641 #else
1642 #define TEST(mnemonic)                                              \
1643   void Test_##mnemonic() {                                          \
1644     VIXL_WARNING("This test can only run on a 32-bit host.\n");     \
1645     USE(TestHelper);                                                \
1646   }                                                                 \
1647   Test test_##mnemonic(                                             \
1648       "AARCH32_SIMULATOR_COND_RD_RN_OPERAND_RM_SHIFT_AMOUNT_1TO32_" \
1649       "T32_" #mnemonic,                                             \
1650       &Test_##mnemonic);
1651 #endif
1652 
1653 FOREACH_INSTRUCTION(TEST)
1654 #undef TEST
1655 
1656 }  // namespace
1657 #endif
1658 
1659 }  // namespace aarch32
1660 }  // namespace vixl
1661