Home | History | Annotate | Download | only in aarch32
      1 // Copyright 2016, VIXL authors
      2 // All rights reserved.
      3 //
      4 // Redistribution and use in source and binary forms, with or without
      5 // modification, are permitted provided that the following conditions are met:
      6 //
      7 //   * Redistributions of source code must retain the above copyright notice,
      8 //     this list of conditions and the following disclaimer.
      9 //   * Redistributions in binary form must reproduce the above copyright notice,
     10 //     this list of conditions and the following disclaimer in the documentation
     11 //     and/or other materials provided with the distribution.
     12 //   * Neither the name of ARM Limited nor the names of its contributors may be
     13 //     used to endorse or promote products derived from this software without
     14 //     specific prior written permission.
     15 //
     16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
     17 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
     18 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
     19 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
     20 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     21 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
     22 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
     23 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     26 
     27 
     28 // -----------------------------------------------------------------------------
     29 // This file is auto generated from the
     30 // test/aarch32/config/template-simulator-aarch32.cc.in template file using
     31 // tools/generate_tests.py.
     32 //
     33 // PLEASE DO NOT EDIT.
     34 // -----------------------------------------------------------------------------
     35 
     36 
     37 #include "test-runner.h"
     38 
     39 #include "test-utils.h"
     40 #include "test-utils-aarch32.h"
     41 
     42 #include "aarch32/assembler-aarch32.h"
     43 #include "aarch32/disasm-aarch32.h"
     44 #include "aarch32/macro-assembler-aarch32.h"
     45 
     46 #define __ masm.
     47 #define BUF_SIZE (4096)
     48 
     49 #ifdef VIXL_INCLUDE_SIMULATOR_AARCH32
     50 // Run tests with the simulator.
     51 
     52 #define SETUP() MacroAssembler masm(BUF_SIZE)
     53 
     54 #define START() masm.GetBuffer()->Reset()
     55 
     56 #define END() \
     57   __ Hlt(0);  \
     58   __ FinalizeCode();
     59 
     60 // TODO: Run the tests in the simulator.
     61 #define RUN()
     62 
     63 #else  // ifdef VIXL_INCLUDE_SIMULATOR_AARCH32.
     64 
     65 #define SETUP()                  \
     66   MacroAssembler masm(BUF_SIZE); \
     67   UseScratchRegisterScope harness_scratch;
     68 
     69 #define START()                 \
     70   harness_scratch.Open(&masm);  \
     71   harness_scratch.ExcludeAll(); \
     72   masm.GetBuffer()->Reset();    \
     73   __ Push(r4);                  \
     74   __ Push(r5);                  \
     75   __ Push(r6);                  \
     76   __ Push(r7);                  \
     77   __ Push(r8);                  \
     78   __ Push(r9);                  \
     79   __ Push(r10);                 \
     80   __ Push(r11);                 \
     81   __ Push(lr);                  \
     82   harness_scratch.Include(ip);
     83 
     84 #define END()                  \
     85   harness_scratch.Exclude(ip); \
     86   __ Pop(lr);                  \
     87   __ Pop(r11);                 \
     88   __ Pop(r10);                 \
     89   __ Pop(r9);                  \
     90   __ Pop(r8);                  \
     91   __ Pop(r7);                  \
     92   __ Pop(r6);                  \
     93   __ Pop(r5);                  \
     94   __ Pop(r4);                  \
     95   __ Bx(lr);                   \
     96   __ FinalizeCode();           \
     97   harness_scratch.Close();
     98 
     99 #define RUN()                                                 \
    100   {                                                           \
    101     int pcs_offset = masm.IsUsingT32() ? 1 : 0;               \
    102     masm.GetBuffer()->SetExecutable();                        \
    103     ExecuteMemory(masm.GetBuffer()->GetStartAddress<byte*>(), \
    104                   masm.GetSizeOfCodeGenerated(),              \
    105                   pcs_offset);                                \
    106     masm.GetBuffer()->SetWritable();                          \
    107   }
    108 
    109 #endif  // ifdef VIXL_INCLUDE_SIMULATOR_AARCH32
    110 
    111 namespace vixl {
    112 namespace aarch32 {
    113 
    114 // List of instruction encodings:
    115 #define FOREACH_INSTRUCTION(M) \
    116   M(Sxtab)                     \
    117   M(Sxtab16)                   \
    118   M(Sxtah)                     \
    119   M(Uxtab)                     \
    120   M(Uxtab16)                   \
    121   M(Uxtah)
    122 
    123 
    124 // The following definitions are defined again in each generated test, therefore
    125 // we need to place them in an anomymous namespace. It expresses that they are
    126 // local to this file only, and the compiler is not allowed to share these types
    127 // across test files during template instantiation. Specifically, `Operands` and
    128 // `Inputs` have various layouts across generated tests so they absolutely
    129 // cannot be shared.
    130 
    131 #ifdef VIXL_INCLUDE_TARGET_T32
    132 namespace {
    133 
    134 // Values to be passed to the assembler to produce the instruction under test.
    135 struct Operands {
    136   Condition cond;
    137   Register rd;
    138   Register rn;
    139   Register rm;
    140   ShiftType ror;
    141   uint32_t amount;
    142 };
    143 
    144 // Input data to feed to the instruction.
    145 struct Inputs {
    146   uint32_t apsr;
    147   uint32_t rd;
    148   uint32_t rn;
    149   uint32_t rm;
    150 };
    151 
    152 // This structure contains all input data needed to test one specific encoding.
    153 // It used to generate a loop over an instruction.
    154 struct TestLoopData {
    155   // The `operands` fields represents the values to pass to the assembler to
    156   // produce the instruction.
    157   Operands operands;
    158   // Description of the operands, used for error reporting.
    159   const char* operands_description;
    160   // Unique identifier, used for generating traces.
    161   const char* identifier;
    162   // Array of values to be fed to the instruction.
    163   size_t input_size;
    164   const Inputs* inputs;
    165 };
    166 
    167 static const Inputs kCondition[] =
    168     {{NFlag, 0xabababab, 0xabababab, 0xabababab},
    169      {ZFlag, 0xabababab, 0xabababab, 0xabababab},
    170      {CFlag, 0xabababab, 0xabababab, 0xabababab},
    171      {VFlag, 0xabababab, 0xabababab, 0xabababab},
    172      {NZFlag, 0xabababab, 0xabababab, 0xabababab},
    173      {NCFlag, 0xabababab, 0xabababab, 0xabababab},
    174      {NVFlag, 0xabababab, 0xabababab, 0xabababab},
    175      {ZCFlag, 0xabababab, 0xabababab, 0xabababab},
    176      {ZVFlag, 0xabababab, 0xabababab, 0xabababab},
    177      {CVFlag, 0xabababab, 0xabababab, 0xabababab},
    178      {NZCFlag, 0xabababab, 0xabababab, 0xabababab},
    179      {NZVFlag, 0xabababab, 0xabababab, 0xabababab},
    180      {NCVFlag, 0xabababab, 0xabababab, 0xabababab},
    181      {ZCVFlag, 0xabababab, 0xabababab, 0xabababab},
    182      {NZCVFlag, 0xabababab, 0xabababab, 0xabababab}};
    183 
    184 static const Inputs kRdIsRn[] = {{NoFlag, 0xffffff83, 0xffffff83, 0xffff8002},
    185                                  {NoFlag, 0x0000007e, 0x0000007e, 0x7fffffff},
    186                                  {NoFlag, 0x0000007d, 0x0000007d, 0xffffffe0},
    187                                  {NoFlag, 0x7fffffff, 0x7fffffff, 0x00000002},
    188                                  {NoFlag, 0xffff8002, 0xffff8002, 0xfffffffd},
    189                                  {NoFlag, 0xffffffe0, 0xffffffe0, 0x00007fff},
    190                                  {NoFlag, 0xffff8000, 0xffff8000, 0xffffff83},
    191                                  {NoFlag, 0xffff8002, 0xffff8002, 0x80000001},
    192                                  {NoFlag, 0x00007ffd, 0x00007ffd, 0xffff8003},
    193                                  {NoFlag, 0x00007fff, 0x00007fff, 0xffffffff},
    194                                  {NoFlag, 0x00000000, 0x00000000, 0xffffff80},
    195                                  {NoFlag, 0xffff8001, 0xffff8001, 0x33333333},
    196                                  {NoFlag, 0xffffff80, 0xffffff80, 0x0000007e},
    197                                  {NoFlag, 0x0000007e, 0x0000007e, 0x7ffffffd},
    198                                  {NoFlag, 0xffffff80, 0xffffff80, 0xfffffffd},
    199                                  {NoFlag, 0x00000020, 0x00000020, 0xffff8002},
    200                                  {NoFlag, 0xffffff80, 0xffffff80, 0xfffffffe},
    201                                  {NoFlag, 0x00000002, 0x00000002, 0x00000000},
    202                                  {NoFlag, 0x0000007e, 0x0000007e, 0x00000001},
    203                                  {NoFlag, 0x00000002, 0x00000002, 0x0000007f},
    204                                  {NoFlag, 0x80000000, 0x80000000, 0x80000000},
    205                                  {NoFlag, 0x7fffffff, 0x7fffffff, 0xffffff80},
    206                                  {NoFlag, 0x00000001, 0x00000001, 0xfffffffe},
    207                                  {NoFlag, 0x33333333, 0x33333333, 0x0000007d},
    208                                  {NoFlag, 0x00000001, 0x00000001, 0x7ffffffe},
    209                                  {NoFlag, 0x00007ffe, 0x00007ffe, 0x7fffffff},
    210                                  {NoFlag, 0x80000000, 0x80000000, 0xffffff83},
    211                                  {NoFlag, 0x00000000, 0x00000000, 0x7ffffffe},
    212                                  {NoFlag, 0x00000000, 0x00000000, 0x0000007f},
    213                                  {NoFlag, 0x7fffffff, 0x7fffffff, 0xcccccccc},
    214                                  {NoFlag, 0xffffff82, 0xffffff82, 0x00000002},
    215                                  {NoFlag, 0x7ffffffd, 0x7ffffffd, 0xaaaaaaaa},
    216                                  {NoFlag, 0xcccccccc, 0xcccccccc, 0xffff8001},
    217                                  {NoFlag, 0xfffffffe, 0xfffffffe, 0xffff8001},
    218                                  {NoFlag, 0x7fffffff, 0x7fffffff, 0x00000020},
    219                                  {NoFlag, 0xffffffe0, 0xffffffe0, 0x00007ffe},
    220                                  {NoFlag, 0x80000001, 0x80000001, 0xffff8000},
    221                                  {NoFlag, 0xffffff82, 0xffffff82, 0x0000007d},
    222                                  {NoFlag, 0x0000007e, 0x0000007e, 0x7ffffffe},
    223                                  {NoFlag, 0x00007ffd, 0x00007ffd, 0xffffff80},
    224                                  {NoFlag, 0x0000007d, 0x0000007d, 0x0000007e},
    225                                  {NoFlag, 0xffff8002, 0xffff8002, 0x7fffffff},
    226                                  {NoFlag, 0xffffffe0, 0xffffffe0, 0x0000007f},
    227                                  {NoFlag, 0x00007ffe, 0x00007ffe, 0xffffff81},
    228                                  {NoFlag, 0x80000000, 0x80000000, 0x0000007e},
    229                                  {NoFlag, 0xffffffff, 0xffffffff, 0xaaaaaaaa},
    230                                  {NoFlag, 0xfffffffe, 0xfffffffe, 0x00000020},
    231                                  {NoFlag, 0xffffff82, 0xffffff82, 0xffff8003},
    232                                  {NoFlag, 0x7ffffffd, 0x7ffffffd, 0xffff8002},
    233                                  {NoFlag, 0x7ffffffe, 0x7ffffffe, 0x00000000},
    234                                  {NoFlag, 0xfffffffd, 0xfffffffd, 0xffffffe0},
    235                                  {NoFlag, 0xffff8000, 0xffff8000, 0xffff8002},
    236                                  {NoFlag, 0xffffff82, 0xffffff82, 0x7ffffffd},
    237                                  {NoFlag, 0xcccccccc, 0xcccccccc, 0x80000000},
    238                                  {NoFlag, 0x80000001, 0x80000001, 0x33333333},
    239                                  {NoFlag, 0x00000001, 0x00000001, 0x00000002},
    240                                  {NoFlag, 0x55555555, 0x55555555, 0x0000007f},
    241                                  {NoFlag, 0xffffffff, 0xffffffff, 0xfffffffd},
    242                                  {NoFlag, 0xffffff80, 0xffffff80, 0x80000000},
    243                                  {NoFlag, 0x00000000, 0x00000000, 0x00000020},
    244                                  {NoFlag, 0xfffffffe, 0xfffffffe, 0xffff8003},
    245                                  {NoFlag, 0xffff8001, 0xffff8001, 0xffff8000},
    246                                  {NoFlag, 0x55555555, 0x55555555, 0x55555555},
    247                                  {NoFlag, 0x00007fff, 0x00007fff, 0xffff8000},
    248                                  {NoFlag, 0x7fffffff, 0x7fffffff, 0xffffffe0},
    249                                  {NoFlag, 0x00000001, 0x00000001, 0x55555555},
    250                                  {NoFlag, 0x33333333, 0x33333333, 0x7ffffffe},
    251                                  {NoFlag, 0x80000000, 0x80000000, 0xffffffe0},
    252                                  {NoFlag, 0xffffff83, 0xffffff83, 0x0000007d},
    253                                  {NoFlag, 0xffff8003, 0xffff8003, 0x00000002},
    254                                  {NoFlag, 0x7ffffffe, 0x7ffffffe, 0xffffff81},
    255                                  {NoFlag, 0xfffffffe, 0xfffffffe, 0xffffff80},
    256                                  {NoFlag, 0x00007ffe, 0x00007ffe, 0xffff8002},
    257                                  {NoFlag, 0x80000001, 0x80000001, 0xfffffffe},
    258                                  {NoFlag, 0x7ffffffd, 0x7ffffffd, 0xfffffffd},
    259                                  {NoFlag, 0x7ffffffd, 0x7ffffffd, 0xfffffffe},
    260                                  {NoFlag, 0x7ffffffe, 0x7ffffffe, 0xffffff83},
    261                                  {NoFlag, 0xfffffffd, 0xfffffffd, 0x00007ffe},
    262                                  {NoFlag, 0x7fffffff, 0x7fffffff, 0x80000000},
    263                                  {NoFlag, 0xffffff82, 0xffffff82, 0x7fffffff},
    264                                  {NoFlag, 0xffffffe0, 0xffffffe0, 0xffffff83},
    265                                  {NoFlag, 0xffff8000, 0xffff8000, 0xffff8000},
    266                                  {NoFlag, 0x00000001, 0x00000001, 0x7fffffff},
    267                                  {NoFlag, 0xfffffffe, 0xfffffffe, 0xffffffff},
    268                                  {NoFlag, 0xffffff82, 0xffffff82, 0xffffffff},
    269                                  {NoFlag, 0xffffffff, 0xffffffff, 0xfffffffe},
    270                                  {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x0000007d},
    271                                  {NoFlag, 0xffff8001, 0xffff8001, 0xfffffffe},
    272                                  {NoFlag, 0x00007ffe, 0x00007ffe, 0x0000007d},
    273                                  {NoFlag, 0xffffff82, 0xffffff82, 0xfffffffe},
    274                                  {NoFlag, 0x00000000, 0x00000000, 0x00007ffd},
    275                                  {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0xffff8002},
    276                                  {NoFlag, 0x0000007f, 0x0000007f, 0xffffff82},
    277                                  {NoFlag, 0x00007fff, 0x00007fff, 0x33333333},
    278                                  {NoFlag, 0xfffffffd, 0xfffffffd, 0x80000000},
    279                                  {NoFlag, 0x00000000, 0x00000000, 0xfffffffd},
    280                                  {NoFlag, 0x0000007d, 0x0000007d, 0x0000007f},
    281                                  {NoFlag, 0xfffffffd, 0xfffffffd, 0x0000007e},
    282                                  {NoFlag, 0xffffffe0, 0xffffffe0, 0x55555555},
    283                                  {NoFlag, 0xffffffff, 0xffffffff, 0x80000000},
    284                                  {NoFlag, 0xffffffe0, 0xffffffe0, 0x0000007e},
    285                                  {NoFlag, 0xffffff81, 0xffffff81, 0x00007ffd},
    286                                  {NoFlag, 0x00000020, 0x00000020, 0xffff8001},
    287                                  {NoFlag, 0x00007fff, 0x00007fff, 0xffffff83},
    288                                  {NoFlag, 0x33333333, 0x33333333, 0x00000000},
    289                                  {NoFlag, 0xffff8000, 0xffff8000, 0xffffff82},
    290                                  {NoFlag, 0xffff8001, 0xffff8001, 0x0000007e},
    291                                  {NoFlag, 0xffffff80, 0xffffff80, 0x00000001},
    292                                  {NoFlag, 0x80000000, 0x80000000, 0xcccccccc},
    293                                  {NoFlag, 0x00000002, 0x00000002, 0x00007ffd},
    294                                  {NoFlag, 0x7ffffffe, 0x7ffffffe, 0x80000001},
    295                                  {NoFlag, 0x00000020, 0x00000020, 0x00007ffe},
    296                                  {NoFlag, 0xffff8000, 0xffff8000, 0xfffffffd},
    297                                  {NoFlag, 0x7fffffff, 0x7fffffff, 0xffff8001},
    298                                  {NoFlag, 0x00000000, 0x00000000, 0xffffff83},
    299                                  {NoFlag, 0x0000007f, 0x0000007f, 0x00000020},
    300                                  {NoFlag, 0x80000001, 0x80000001, 0xffff8003},
    301                                  {NoFlag, 0xffff8001, 0xffff8001, 0x0000007f},
    302                                  {NoFlag, 0x0000007f, 0x0000007f, 0x80000001},
    303                                  {NoFlag, 0x00000002, 0x00000002, 0x7ffffffe},
    304                                  {NoFlag, 0xffffff82, 0xffffff82, 0xffffff83},
    305                                  {NoFlag, 0x00007ffd, 0x00007ffd, 0x7fffffff},
    306                                  {NoFlag, 0x7ffffffe, 0x7ffffffe, 0xfffffffe},
    307                                  {NoFlag, 0xffffff82, 0xffffff82, 0xffff8000},
    308                                  {NoFlag, 0xfffffffe, 0xfffffffe, 0xffff8000},
    309                                  {NoFlag, 0xffff8002, 0xffff8002, 0xffffff81},
    310                                  {NoFlag, 0x33333333, 0x33333333, 0x7fffffff},
    311                                  {NoFlag, 0x80000001, 0x80000001, 0x00007fff},
    312                                  {NoFlag, 0xffff8002, 0xffff8002, 0xcccccccc},
    313                                  {NoFlag, 0xffffffff, 0xffffffff, 0x00000002},
    314                                  {NoFlag, 0x33333333, 0x33333333, 0xffffff81},
    315                                  {NoFlag, 0xfffffffd, 0xfffffffd, 0xffffff80},
    316                                  {NoFlag, 0x55555555, 0x55555555, 0xaaaaaaaa},
    317                                  {NoFlag, 0x33333333, 0x33333333, 0xffffff82},
    318                                  {NoFlag, 0xffffff80, 0xffffff80, 0xaaaaaaaa},
    319                                  {NoFlag, 0x0000007e, 0x0000007e, 0x00000020},
    320                                  {NoFlag, 0xffffff83, 0xffffff83, 0x00007ffd},
    321                                  {NoFlag, 0xffffff82, 0xffffff82, 0xaaaaaaaa},
    322                                  {NoFlag, 0xffff8003, 0xffff8003, 0xffffffff},
    323                                  {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0xfffffffe},
    324                                  {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x00000000},
    325                                  {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x0000007f},
    326                                  {NoFlag, 0x0000007f, 0x0000007f, 0x0000007d},
    327                                  {NoFlag, 0xfffffffd, 0xfffffffd, 0x55555555},
    328                                  {NoFlag, 0xffffffff, 0xffffffff, 0x00000020},
    329                                  {NoFlag, 0x00007ffe, 0x00007ffe, 0xffffff83},
    330                                  {NoFlag, 0x7fffffff, 0x7fffffff, 0x55555555},
    331                                  {NoFlag, 0x55555555, 0x55555555, 0xcccccccc},
    332                                  {NoFlag, 0xffffffe0, 0xffffffe0, 0xffff8003},
    333                                  {NoFlag, 0x7ffffffe, 0x7ffffffe, 0x00007ffe},
    334                                  {NoFlag, 0x00007ffd, 0x00007ffd, 0xffff8002},
    335                                  {NoFlag, 0x00007ffd, 0x00007ffd, 0x00000001},
    336                                  {NoFlag, 0x00000000, 0x00000000, 0x00007ffe},
    337                                  {NoFlag, 0xffffff80, 0xffffff80, 0x00000020},
    338                                  {NoFlag, 0xffff8000, 0xffff8000, 0x0000007d},
    339                                  {NoFlag, 0xffff8003, 0xffff8003, 0x00000000},
    340                                  {NoFlag, 0x0000007e, 0x0000007e, 0x80000000},
    341                                  {NoFlag, 0xfffffffd, 0xfffffffd, 0x00000000},
    342                                  {NoFlag, 0xffffff80, 0xffffff80, 0xffffffff},
    343                                  {NoFlag, 0xcccccccc, 0xcccccccc, 0x0000007f},
    344                                  {NoFlag, 0x7ffffffd, 0x7ffffffd, 0x00000000},
    345                                  {NoFlag, 0x00007fff, 0x00007fff, 0x00000000},
    346                                  {NoFlag, 0x0000007f, 0x0000007f, 0x00000001},
    347                                  {NoFlag, 0xffffffff, 0xffffffff, 0xffffff82},
    348                                  {NoFlag, 0x00007ffe, 0x00007ffe, 0x00007ffd},
    349                                  {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x33333333},
    350                                  {NoFlag, 0xffffff82, 0xffffff82, 0x55555555},
    351                                  {NoFlag, 0xffff8003, 0xffff8003, 0x0000007e},
    352                                  {NoFlag, 0xffffff83, 0xffffff83, 0x00000002},
    353                                  {NoFlag, 0xffffff82, 0xffffff82, 0x33333333},
    354                                  {NoFlag, 0x55555555, 0x55555555, 0xffffffff},
    355                                  {NoFlag, 0xaaaaaaaa, 0xaaaaaaaa, 0x80000001},
    356                                  {NoFlag, 0xffffff83, 0xffffff83, 0xffffffe0},
    357                                  {NoFlag, 0x00000001, 0x00000001, 0xffffffe0},
    358                                  {NoFlag, 0x33333333, 0x33333333, 0x33333333},
    359                                  {NoFlag, 0x55555555, 0x55555555, 0x00000001},
    360                                  {NoFlag, 0xffffff83, 0xffffff83, 0x00007fff},
    361                                  {NoFlag, 0x00000002, 0x00000002, 0xfffffffd},
    362                                  {NoFlag, 0xffffffe0, 0xffffffe0, 0xffff8002},
    363                                  {NoFlag, 0x80000000, 0x80000000, 0x00007ffd},
    364                                  {NoFlag, 0xffffff83, 0xffffff83, 0xfffffffe},
    365                                  {NoFlag, 0x80000001, 0x80000001, 0xffffffff},
    366                                  {NoFlag, 0xffff8003, 0xffff8003, 0x00000020},
    367                                  {NoFlag, 0xffffff82, 0xffffff82, 0xcccccccc},
    368                                  {NoFlag, 0x00000020, 0x00000020, 0x7fffffff},
    369                                  {NoFlag, 0xffffff80, 0xffffff80, 0x55555555},
    370                                  {NoFlag, 0x00000001, 0x00000001, 0x00000020},
    371                                  {NoFlag, 0xffff8001, 0xffff8001, 0x00007fff},
    372                                  {NoFlag, 0x00000020, 0x00000020, 0xaaaaaaaa},
    373                                  {NoFlag, 0x55555555, 0x55555555, 0x7fffffff},
    374                                  {NoFlag, 0xfffffffe, 0xfffffffe, 0x7fffffff},
    375                                  {NoFlag, 0x00007fff, 0x00007fff, 0x55555555},
    376                                  {NoFlag, 0x55555555, 0x55555555, 0x0000007d},
    377                                  {NoFlag, 0xcccccccc, 0xcccccccc, 0x7ffffffe},
    378                                  {NoFlag, 0xffff8002, 0xffff8002, 0x00007ffe},
    379                                  {NoFlag, 0xfffffffe, 0xfffffffe, 0xffffff81},
    380                                  {NoFlag, 0xffffff81, 0xffffff81, 0x0000007d},
    381                                  {NoFlag, 0x00000020, 0x00000020, 0x0000007e},
    382                                  {NoFlag, 0xffffffff, 0xffffffff, 0x00007ffe},
    383                                  {NoFlag, 0xffff8002, 0xffff8002, 0x0000007e}};
    384 
    385 static const Inputs kRdIsRm[] = {{NoFlag, 0x55555555, 0x7ffffffe, 0x55555555},
    386                                  {NoFlag, 0xfffffffe, 0x00000001, 0xfffffffe},
    387                                  {NoFlag, 0xffffff82, 0xffffff82, 0xffffff82},
    388                                  {NoFlag, 0xffff8000, 0xffff8003, 0xffff8000},
    389                                  {NoFlag, 0x00000001, 0x00000000, 0x00000001},
    390                                  {NoFlag, 0xffffff81, 0x00007fff, 0xffffff81},
    391                                  {NoFlag, 0x0000007d, 0xffff8002, 0x0000007d},
    392                                  {NoFlag, 0x80000000, 0xffff8000, 0x80000000},
    393                                  {NoFlag, 0xffffff80, 0x00000020, 0xffffff80},
    394                                  {NoFlag, 0x55555555, 0xffffff81, 0x55555555},
    395                                  {NoFlag, 0x00007ffd, 0xffffff82, 0x00007ffd},
    396                                  {NoFlag, 0x55555555, 0x00007fff, 0x55555555},
    397                                  {NoFlag, 0x7ffffffd, 0xffff8000, 0x7ffffffd},
    398                                  {NoFlag, 0xffffffff, 0xffffff83, 0xffffffff},
    399                                  {NoFlag, 0x00000000, 0xffffffff, 0x00000000},
    400                                  {NoFlag, 0xffff8002, 0x33333333, 0xffff8002},
    401                                  {NoFlag, 0x00007ffd, 0xaaaaaaaa, 0x00007ffd},
    402                                  {NoFlag, 0x55555555, 0xffff8000, 0x55555555},
    403                                  {NoFlag, 0x80000001, 0xffffffff, 0x80000001},
    404                                  {NoFlag, 0x0000007d, 0xffffff83, 0x0000007d},
    405                                  {NoFlag, 0x0000007e, 0xffffff82, 0x0000007e},
    406                                  {NoFlag, 0xcccccccc, 0x0000007d, 0xcccccccc},
    407                                  {NoFlag, 0xffff8002, 0xffffffff, 0xffff8002},
    408                                  {NoFlag, 0xffffff81, 0x0000007f, 0xffffff81},
    409                                  {NoFlag, 0xffff8000, 0xffffff83, 0xffff8000},
    410                                  {NoFlag, 0xffffffff, 0xffffffe0, 0xffffffff},
    411                                  {NoFlag, 0xfffffffd, 0x80000001, 0xfffffffd},
    412                                  {NoFlag, 0x55555555, 0x80000000, 0x55555555},
    413                                  {NoFlag, 0xffff8000, 0x0000007d, 0xffff8000},
    414                                  {NoFlag, 0xaaaaaaaa, 0xffff8003, 0xaaaaaaaa},
    415                                  {NoFlag, 0x00000001, 0x00007ffd, 0x00000001},
    416                                  {NoFlag, 0x0000007e, 0x7ffffffe, 0x0000007e},
    417                                  {NoFlag, 0x00000020, 0x00007ffd, 0x00000020},
    418                                  {NoFlag, 0xffffff81, 0x7ffffffd, 0xffffff81},
    419                                  {NoFlag, 0xffffff83, 0x0000007f, 0xffffff83},
    420                                  {NoFlag, 0x00000001, 0x0000007e, 0x00000001},
    421                                  {NoFlag, 0xffffff82, 0xfffffffd, 0xffffff82},
    422                                  {NoFlag, 0xffff8003, 0x7ffffffe, 0xffff8003},
    423                                  {NoFlag, 0x00000002, 0x00000002, 0x00000002},
    424                                  {NoFlag, 0xffffff83, 0xffff8001, 0xffffff83},
    425                                  {NoFlag, 0xffff8002, 0xfffffffe, 0xffff8002},
    426                                  {NoFlag, 0xffffff80, 0xffffff81, 0xffffff80},
    427                                  {NoFlag, 0x7fffffff, 0xffffff81, 0x7fffffff},
    428                                  {NoFlag, 0x00000020, 0xffffff81, 0x00000020},
    429                                  {NoFlag, 0x0000007f, 0xffffffff, 0x0000007f},
    430                                  {NoFlag, 0x0000007d, 0xcccccccc, 0x0000007d},
    431                                  {NoFlag, 0x00007fff, 0x55555555, 0x00007fff},
    432                                  {NoFlag, 0xffff8003, 0x00007ffd, 0xffff8003},
    433                                  {NoFlag, 0x80000001, 0x80000001, 0x80000001},
    434                                  {NoFlag, 0xffffffff, 0xfffffffd, 0xffffffff},
    435                                  {NoFlag, 0xffff8000, 0xfffffffe, 0xffff8000},
    436                                  {NoFlag, 0xcccccccc, 0x0000007f, 0xcccccccc},
    437                                  {NoFlag, 0x00000001, 0x00000002, 0x00000001},
    438                                  {NoFlag, 0xffffff82, 0xffffff81, 0xffffff82},
    439                                  {NoFlag, 0xfffffffd, 0x00007ffd, 0xfffffffd},
    440                                  {NoFlag, 0x80000001, 0x33333333, 0x80000001},
    441                                  {NoFlag, 0xffffff82, 0xffff8002, 0xffffff82},
    442                                  {NoFlag, 0xffff8003, 0xfffffffd, 0xffff8003},
    443                                  {NoFlag, 0xffffff81, 0x00000020, 0xffffff81},
    444                                  {NoFlag, 0xffff8001, 0xffff8003, 0xffff8001},
    445                                  {NoFlag, 0x00000001, 0x80000001, 0x00000001},
    446                                  {NoFlag, 0xfffffffd, 0x00000002, 0xfffffffd},
    447                                  {NoFlag, 0xffff8003, 0x7ffffffd, 0xffff8003},
    448                                  {NoFlag, 0x0000007e, 0xaaaaaaaa, 0x0000007e},
    449                                  {NoFlag, 0x7ffffffe, 0x7fffffff, 0x7ffffffe},
    450                                  {NoFlag, 0x00007ffd, 0x00007ffe, 0x00007ffd},
    451                                  {NoFlag, 0x00007fff, 0x80000001, 0x00007fff},
    452                                  {NoFlag, 0x00007fff, 0xfffffffe, 0x00007fff},
    453                                  {NoFlag, 0x00000001, 0xffffff80, 0x00000001},
    454                                  {NoFlag, 0x55555555, 0xcccccccc, 0x55555555},
    455                                  {NoFlag, 0x7ffffffd, 0xffffffe0, 0x7ffffffd},
    456                                  {NoFlag, 0xffffff81, 0xfffffffe, 0xffffff81},
    457                                  {NoFlag, 0xffffff82, 0x00007ffe, 0xffffff82},
    458                                  {NoFlag, 0xffffff82, 0x80000001, 0xffffff82},
    459                                  {NoFlag, 0x0000007f, 0xffff8001, 0x0000007f},
    460                                  {NoFlag, 0x7ffffffd, 0xffffff83, 0x7ffffffd},
    461                                  {NoFlag, 0xffffff82, 0xcccccccc, 0xffffff82},
    462                                  {NoFlag, 0x00000020, 0xffffff83, 0x00000020},
    463                                  {NoFlag, 0x00007ffe, 0x80000000, 0x00007ffe},
    464                                  {NoFlag, 0x0000007f, 0xffff8000, 0x0000007f},
    465                                  {NoFlag, 0xffffff82, 0x33333333, 0xffffff82},
    466                                  {NoFlag, 0x7ffffffd, 0x7ffffffd, 0x7ffffffd},
    467                                  {NoFlag, 0xffffff80, 0xffff8001, 0xffffff80},
    468                                  {NoFlag, 0x00000002, 0xaaaaaaaa, 0x00000002},
    469                                  {NoFlag, 0xffffffff, 0x7fffffff, 0xffffffff},
    470                                  {NoFlag, 0xfffffffd, 0xfffffffe, 0xfffffffd},
    471                                  {NoFlag, 0x00000020, 0x00000001, 0x00000020},
    472                                  {NoFlag, 0x55555555, 0x00000001, 0x55555555},
    473                                  {NoFlag, 0x55555555, 0xffffff80, 0x55555555},
    474                                  {NoFlag, 0xffffffff, 0x00007fff, 0xffffffff},
    475                                  {NoFlag, 0x00000020, 0xaaaaaaaa, 0x00000020},
    476                                  {NoFlag, 0x00000002, 0x00007ffe, 0x00000002},
    477                                  {NoFlag, 0x00000001, 0xcccccccc, 0x00000001},
    478                                  {NoFlag, 0xffff8001, 0x00000000, 0xffff8001},
    479                                  {NoFlag, 0x00000001, 0xffff8000, 0x00000001},
    480                                  {NoFlag, 0xffffffe0, 0x00007fff, 0xffffffe0},
    481                                  {NoFlag, 0xfffffffe, 0x00007fff, 0xfffffffe},
    482                                  {NoFlag, 0xffffff83, 0x00000001, 0xffffff83},
    483                                  {NoFlag, 0x00007fff, 0xffff8002, 0x00007fff},
    484                                  {NoFlag, 0x7ffffffd, 0x7ffffffe, 0x7ffffffd},
    485                                  {NoFlag, 0x80000001, 0xaaaaaaaa, 0x80000001},
    486                                  {NoFlag, 0x80000001, 0xcccccccc, 0x80000001},
    487                                  {NoFlag, 0x00007ffe, 0xffffffe0, 0x00007ffe},
    488                                  {NoFlag, 0x00007ffe, 0xfffffffd, 0x00007ffe},
    489                                  {NoFlag, 0x55555555, 0xaaaaaaaa, 0x55555555},
    490                                  {NoFlag, 0xffffffe0, 0x00000001, 0xffffffe0},
    491                                  {NoFlag, 0x0000007e, 0x00007fff, 0x0000007e},
    492                                  {NoFlag, 0xfffffffe, 0xfffffffd, 0xfffffffe},
    493                                  {NoFlag, 0x33333333, 0x0000007d, 0x33333333},
    494                                  {NoFlag, 0xffffff81, 0x7fffffff, 0xffffff81},
    495                                  {NoFlag, 0x0000007e, 0x0000007d, 0x0000007e},
    496                                  {NoFlag, 0x00000001, 0xffffff81, 0x00000001},
    497                                  {NoFlag, 0x80000000, 0x00000002, 0x80000000},
    498                                  {NoFlag, 0x0000007d, 0xffff8003, 0x0000007d},
    499                                  {NoFlag, 0x7ffffffe, 0x00007ffd, 0x7ffffffe},
    500                                  {NoFlag, 0x7ffffffe, 0xaaaaaaaa, 0x7ffffffe},
    501                                  {NoFlag, 0x00000000, 0xffff8000, 0x00000000},
    502                                  {NoFlag, 0x33333333, 0x00000002, 0x33333333},
    503                                  {NoFlag, 0xffffff81, 0xffffff83, 0xffffff81},
    504                                  {NoFlag, 0x7ffffffe, 0x00007ffe, 0x7ffffffe},
    505                                  {NoFlag, 0x80000000, 0x0000007d, 0x80000000},
    506                                  {NoFlag, 0x00000020, 0x00000002, 0x00000020},
    507                                  {NoFlag, 0x33333333, 0x80000001, 0x33333333},
    508                                  {NoFlag, 0xffffff83, 0x00007ffd, 0xffffff83},
    509                                  {NoFlag, 0x00007ffd, 0xffffff83, 0x00007ffd},
    510                                  {NoFlag, 0xffff8001, 0x80000000, 0xffff8001},
    511                                  {NoFlag, 0x00000000, 0x80000000, 0x00000000},
    512                                  {NoFlag, 0xffffffe0, 0xffffffff, 0xffffffe0},
    513                                  {NoFlag, 0x80000000, 0xffffff83, 0x80000000},
    514                                  {NoFlag, 0x00000020, 0xffffff80, 0x00000020},
    515                                  {NoFlag, 0x7ffffffd, 0xffff8001, 0x7ffffffd},
    516                                  {NoFlag, 0x80000001, 0xffff8003, 0x80000001},
    517                                  {NoFlag, 0x00007ffe, 0x7fffffff, 0x00007ffe},
    518                                  {NoFlag, 0x7fffffff, 0x00000002, 0x7fffffff},
    519                                  {NoFlag, 0xffffff83, 0xffff8003, 0xffffff83},
    520                                  {NoFlag, 0xaaaaaaaa, 0xcccccccc, 0xaaaaaaaa},
    521                                  {NoFlag, 0x0000007f, 0xffffff80, 0x0000007f},
    522                                  {NoFlag, 0x80000001, 0x00007ffd, 0x80000001},
    523                                  {NoFlag, 0xffff8000, 0x80000001, 0xffff8000},
    524                                  {NoFlag, 0x00007fff, 0x00007ffd, 0x00007fff},
    525                                  {NoFlag, 0x0000007e, 0x0000007f, 0x0000007e},
    526                                  {NoFlag, 0x00000002, 0x0000007d, 0x00000002},
    527                                  {NoFlag, 0x80000001, 0x7fffffff, 0x80000001},
    528                                  {NoFlag, 0x0000007e, 0xffffff81, 0x0000007e},
    529                                  {NoFlag, 0x7ffffffe, 0xffff8001, 0x7ffffffe},
    530                                  {NoFlag, 0x7fffffff, 0x80000001, 0x7fffffff},
    531                                  {NoFlag, 0x7ffffffd, 0x0000007f, 0x7ffffffd},
    532                                  {NoFlag, 0xffffff81, 0xffffff81, 0xffffff81},
    533                                  {NoFlag, 0x00000001, 0xfffffffd, 0x00000001},
    534                                  {NoFlag, 0x00000001, 0xffffffff, 0x00000001},
    535                                  {NoFlag, 0x7ffffffd, 0x55555555, 0x7ffffffd},
    536                                  {NoFlag, 0x55555555, 0x0000007f, 0x55555555},
    537                                  {NoFlag, 0x55555555, 0xffff8003, 0x55555555},
    538                                  {NoFlag, 0xaaaaaaaa, 0x00007ffd, 0xaaaaaaaa},
    539                                  {NoFlag, 0x0000007e, 0x33333333, 0x0000007e},
    540                                  {NoFlag, 0xfffffffe, 0x80000001, 0xfffffffe},
    541                                  {NoFlag, 0xfffffffe, 0xffff8000, 0xfffffffe},
    542                                  {NoFlag, 0xffffffe0, 0xffffff81, 0xffffffe0},
    543                                  {NoFlag, 0x7fffffff, 0x0000007f, 0x7fffffff},
    544                                  {NoFlag, 0xffff8003, 0x0000007f, 0xffff8003},
    545                                  {NoFlag, 0xffffff82, 0x00007ffd, 0xffffff82},
    546                                  {NoFlag, 0x33333333, 0xffffffff, 0x33333333},
    547                                  {NoFlag, 0xffffffe0, 0xcccccccc, 0xffffffe0},
    548                                  {NoFlag, 0xffffff83, 0x7ffffffd, 0xffffff83},
    549                                  {NoFlag, 0x0000007e, 0xcccccccc, 0x0000007e},
    550                                  {NoFlag, 0x00000002, 0xfffffffd, 0x00000002},
    551                                  {NoFlag, 0x00007fff, 0xcccccccc, 0x00007fff},
    552                                  {NoFlag, 0x7fffffff, 0x00007fff, 0x7fffffff},
    553                                  {NoFlag, 0xffffffe0, 0x33333333, 0xffffffe0},
    554                                  {NoFlag, 0x0000007f, 0x0000007d, 0x0000007f},
    555                                  {NoFlag, 0x0000007f, 0xffffffe0, 0x0000007f},
    556                                  {NoFlag, 0x00007fff, 0xffff8000, 0x00007fff},
    557                                  {NoFlag, 0x7fffffff, 0xffffffff, 0x7fffffff},
    558                                  {NoFlag, 0xffff8000, 0x7ffffffd, 0xffff8000},
    559                                  {NoFlag, 0xcccccccc, 0x0000007e, 0xcccccccc},
    560                                  {NoFlag, 0x33333333, 0xffff8003, 0x33333333},
    561                                  {NoFlag, 0x55555555, 0x00000002, 0x55555555},
    562                                  {NoFlag, 0x00000001, 0x00000001, 0x00000001},
    563                                  {NoFlag, 0xaaaaaaaa, 0x33333333, 0xaaaaaaaa},
    564                                  {NoFlag, 0x7ffffffd, 0x00000001, 0x7ffffffd},
    565                                  {NoFlag, 0xffffff82, 0xffff8000, 0xffffff82},
    566                                  {NoFlag, 0x0000007d, 0x55555555, 0x0000007d},
    567                                  {NoFlag, 0xffff8000, 0x7ffffffe, 0xffff8000},
    568                                  {NoFlag, 0x7fffffff, 0xffffffe0, 0x7fffffff},
    569                                  {NoFlag, 0x7fffffff, 0xffff8003, 0x7fffffff},
    570                                  {NoFlag, 0xffffff82, 0xaaaaaaaa, 0xffffff82},
    571                                  {NoFlag, 0xfffffffd, 0xffffff80, 0xfffffffd},
    572                                  {NoFlag, 0x7ffffffd, 0x80000001, 0x7ffffffd},
    573                                  {NoFlag, 0x00000000, 0x00007ffd, 0x00000000},
    574                                  {NoFlag, 0xffffffff, 0xffffff80, 0xffffffff},
    575                                  {NoFlag, 0xffffff80, 0xcccccccc, 0xffffff80},
    576                                  {NoFlag, 0x00007ffe, 0x55555555, 0x00007ffe},
    577                                  {NoFlag, 0xffff8000, 0xffff8000, 0xffff8000},
    578                                  {NoFlag, 0xffffffff, 0xffff8000, 0xffffffff},
    579                                  {NoFlag, 0x80000001, 0x0000007d, 0x80000001},
    580                                  {NoFlag, 0xffffffe0, 0xffff8002, 0xffffffe0},
    581                                  {NoFlag, 0xfffffffe, 0xffffffe0, 0xfffffffe},
    582                                  {NoFlag, 0x80000000, 0xffff8003, 0x80000000},
    583                                  {NoFlag, 0x80000001, 0xffffff81, 0x80000001},
    584                                  {NoFlag, 0xffffffe0, 0x00007ffe, 0xffffffe0}};
    585 
    586 static const Inputs kRdIsNotRnIsNotRm[] =
    587     {{NoFlag, 0x0000007e, 0x0000007e, 0x0000007d},
    588      {NoFlag, 0x55555555, 0x00000002, 0xffff8002},
    589      {NoFlag, 0xffffffe0, 0x80000001, 0x00000000},
    590      {NoFlag, 0x55555555, 0xffffff83, 0x00000002},
    591      {NoFlag, 0xffffffe0, 0xffffffe0, 0x00000002},
    592      {NoFlag, 0x00000000, 0x80000001, 0xffffff82},
    593      {NoFlag, 0x80000001, 0x00007fff, 0x0000007f},
    594      {NoFlag, 0xffffff80, 0x0000007d, 0x7ffffffe},
    595      {NoFlag, 0xaaaaaaaa, 0x00000020, 0xffff8002},
    596      {NoFlag, 0x33333333, 0x55555555, 0x00000001},
    597      {NoFlag, 0x7ffffffe, 0x33333333, 0x00000000},
    598      {NoFlag, 0x80000000, 0x7ffffffd, 0x55555555},
    599      {NoFlag, 0xcccccccc, 0xffff8001, 0x7ffffffe},
    600      {NoFlag, 0x00000020, 0xffffff83, 0xffff8003},
    601      {NoFlag, 0x00007fff, 0xffffffe0, 0xffffff81},
    602      {NoFlag, 0xffff8000, 0xffff8001, 0x0000007e},
    603      {NoFlag, 0x33333333, 0x0000007e, 0x00000020},
    604      {NoFlag, 0x0000007f, 0xfffffffd, 0xaaaaaaaa},
    605      {NoFlag, 0xffffff83, 0xffffff82, 0x7ffffffd},
    606      {NoFlag, 0x0000007e, 0xcccccccc, 0x7fffffff},
    607      {NoFlag, 0xffff8001, 0x80000001, 0xffffffff},
    608      {NoFlag, 0xffffff81, 0x00000020, 0x7ffffffe},
    609      {NoFlag, 0xffffff83, 0xffffff81, 0xffffffe0},
    610      {NoFlag, 0xffffffe0, 0xffffff81, 0xfffffffd},
    611      {NoFlag, 0x80000001, 0xffffffff, 0xffffffff},
    612      {NoFlag, 0x7ffffffe, 0xffff8000, 0xcccccccc},
    613      {NoFlag, 0xffffff80, 0x00007ffe, 0xffffff82},
    614      {NoFlag, 0x0000007e, 0x0000007d, 0xffff8003},
    615      {NoFlag, 0xffff8002, 0xffffff81, 0x0000007e},
    616      {NoFlag, 0x00007fff, 0x7ffffffd, 0xfffffffe},
    617      {NoFlag, 0x00007ffe, 0x80000001, 0xffffff81},
    618      {NoFlag, 0xffffff81, 0x00007ffd, 0xfffffffd},
    619      {NoFlag, 0x00000020, 0x7fffffff, 0xffff8003},
    620      {NoFlag, 0x0000007e, 0x0000007d, 0x33333333},
    621      {NoFlag, 0xcccccccc, 0xffff8000, 0x00007ffe},
    622      {NoFlag, 0x00007fff, 0xffff8000, 0x00000020},
    623      {NoFlag, 0x00007ffd, 0x00007fff, 0xffffffe0},
    624      {NoFlag, 0x7ffffffd, 0x00000000, 0x00007ffe},
    625      {NoFlag, 0xffffff82, 0x33333333, 0x00000001},
    626      {NoFlag, 0x7ffffffe, 0xffffff80, 0x00000020},
    627      {NoFlag, 0x00007fff, 0xffffff83, 0x00007ffd},
    628      {NoFlag, 0xffff8001, 0xffffffff, 0x80000001},
    629      {NoFlag, 0x00000002, 0xffffff81, 0xcccccccc},
    630      {NoFlag, 0x55555555, 0x0000007f, 0xffff8001},
    631      {NoFlag, 0x80000000, 0x00000020, 0x80000000},
    632      {NoFlag, 0xffffff83, 0x00007fff, 0xffffff80},
    633      {NoFlag, 0x33333333, 0x7ffffffe, 0x7ffffffd},
    634      {NoFlag, 0xffffff80, 0xffffffff, 0x00000001},
    635      {NoFlag, 0x00007ffd, 0x7ffffffd, 0xffffff83},
    636      {NoFlag, 0x33333333, 0xffff8001, 0xffffffe0},
    637      {NoFlag, 0xffff8001, 0xffffff80, 0x00007ffd},
    638      {NoFlag, 0xffffffe0, 0x00007fff, 0x00007ffe},
    639      {NoFlag, 0x0000007d, 0x00000000, 0xffff8000},
    640      {NoFlag, 0x7ffffffe, 0xaaaaaaaa, 0x7ffffffe},
    641      {NoFlag, 0x0000007e, 0x00007ffd, 0xffffffe0},
    642      {NoFlag, 0xfffffffd, 0xffffffe0, 0xffffff83},
    643      {NoFlag, 0x00000001, 0xffffffe0, 0x7ffffffd},
    644      {NoFlag, 0xfffffffd, 0xffff8002, 0x80000000},
    645      {NoFlag, 0x00000020, 0xffffffff, 0x80000000},
    646      {NoFlag, 0x00000001, 0x80000001, 0xffff8003},
    647      {NoFlag, 0xffff8003, 0xaaaaaaaa, 0xffffff81},
    648      {NoFlag, 0x0000007f, 0xfffffffd, 0xffffffe0},
    649      {NoFlag, 0x00007ffe, 0xffffff80, 0x00007ffe},
    650      {NoFlag, 0xffff8002, 0xffff8003, 0xffffffff},
    651      {NoFlag, 0x7ffffffe, 0xffffff82, 0xffff8000},
    652      {NoFlag, 0xffff8000, 0x00000002, 0x80000000},
    653      {NoFlag, 0xffffff80, 0xffffff82, 0xffffff81},
    654      {NoFlag, 0x00000000, 0xcccccccc, 0x00007ffd},
    655      {NoFlag, 0x55555555, 0x00007ffe, 0x7fffffff},
    656      {NoFlag, 0x00000002, 0xffffff81, 0xaaaaaaaa},
    657      {NoFlag, 0x00007ffd, 0x0000007e, 0x00000002},
    658      {NoFlag, 0xffffff83, 0x0000007e, 0xffffff80},
    659      {NoFlag, 0xcccccccc, 0x00007ffe, 0xaaaaaaaa},
    660      {NoFlag, 0x7ffffffe, 0x55555555, 0xffff8003},
    661      {NoFlag, 0xfffffffd, 0x00000001, 0xffffff80},
    662      {NoFlag, 0x00007ffd, 0x55555555, 0x80000001},
    663      {NoFlag, 0x0000007f, 0x00000000, 0x0000007e},
    664      {NoFlag, 0x7fffffff, 0xaaaaaaaa, 0x00000000},
    665      {NoFlag, 0x7ffffffd, 0xffffff81, 0xcccccccc},
    666      {NoFlag, 0xffffffe0, 0xcccccccc, 0xfffffffd},
    667      {NoFlag, 0x00000002, 0xffff8000, 0x7ffffffd},
    668      {NoFlag, 0xffffffe0, 0xffff8000, 0x80000001},
    669      {NoFlag, 0x7ffffffd, 0xffff8003, 0xffff8001},
    670      {NoFlag, 0x33333333, 0x00007ffd, 0x80000000},
    671      {NoFlag, 0x7ffffffd, 0x00007fff, 0xcccccccc},
    672      {NoFlag, 0xffffffff, 0xffffff80, 0x00007ffe},
    673      {NoFlag, 0xffffff83, 0x7ffffffd, 0xaaaaaaaa},
    674      {NoFlag, 0xfffffffd, 0xffff8003, 0x0000007f},
    675      {NoFlag, 0xfffffffe, 0xfffffffe, 0xfffffffd},
    676      {NoFlag, 0x00007fff, 0xfffffffe, 0x55555555},
    677      {NoFlag, 0x7ffffffd, 0xfffffffe, 0xfffffffe},
    678      {NoFlag, 0xfffffffe, 0xffffffff, 0x00007fff},
    679      {NoFlag, 0x7ffffffd, 0x0000007e, 0x00007ffd},
    680      {NoFlag, 0x7ffffffd, 0xffffffe0, 0x00000002},
    681      {NoFlag, 0xffffffff, 0x00007ffd, 0xffffff81},
    682      {NoFlag, 0xffff8001, 0x00000020, 0xfffffffd},
    683      {NoFlag, 0x00007fff, 0x0000007d, 0xffffff83},
    684      {NoFlag, 0x00000002, 0x55555555, 0x7ffffffe},
    685      {NoFlag, 0x00007fff, 0x00007ffe, 0x00000002},
    686      {NoFlag, 0x80000001, 0x7fffffff, 0x00007ffd},
    687      {NoFlag, 0x0000007f, 0xffffffff, 0x00000001},
    688      {NoFlag, 0xffff8001, 0x33333333, 0xffffff83},
    689      {NoFlag, 0x00007fff, 0xcccccccc, 0x33333333},
    690      {NoFlag, 0x33333333, 0xffffff80, 0x00000001},
    691      {NoFlag, 0x00007fff, 0xcccccccc, 0x00007ffd},
    692      {NoFlag, 0xffff8002, 0xfffffffd, 0x7ffffffe},
    693      {NoFlag, 0x00007ffe, 0x7ffffffe, 0xffffff83},
    694      {NoFlag, 0xffffffe0, 0x0000007f, 0xffff8001},
    695      {NoFlag, 0x80000000, 0x00007fff, 0xffffff80},
    696      {NoFlag, 0x7fffffff, 0x00007fff, 0x7ffffffe},
    697      {NoFlag, 0xffff8002, 0x55555555, 0xffff8001},
    698      {NoFlag, 0xffffff80, 0x00000000, 0xffffff80},
    699      {NoFlag, 0x00007ffd, 0x00007fff, 0x00000002},
    700      {NoFlag, 0x00000000, 0x55555555, 0xffff8003},
    701      {NoFlag, 0x0000007f, 0xffff8003, 0x00000020},
    702      {NoFlag, 0x00000000, 0xffff8002, 0x7fffffff},
    703      {NoFlag, 0x00007fff, 0x55555555, 0x00000000},
    704      {NoFlag, 0x7fffffff, 0x00007ffe, 0xffffff81},
    705      {NoFlag, 0x0000007e, 0x80000001, 0x00007ffe},
    706      {NoFlag, 0x7ffffffd, 0xaaaaaaaa, 0x00000020},
    707      {NoFlag, 0xfffffffd, 0xfffffffe, 0x00000002},
    708      {NoFlag, 0xffffff80, 0xffff8000, 0xffff8002},
    709      {NoFlag, 0x0000007d, 0x00007fff, 0xaaaaaaaa},
    710      {NoFlag, 0xfffffffd, 0xffffff80, 0x00007ffd},
    711      {NoFlag, 0xffffff82, 0x80000000, 0xffffff80},
    712      {NoFlag, 0xffffffe0, 0x55555555, 0xfffffffd},
    713      {NoFlag, 0xffffffff, 0xffffffff, 0x00007ffd},
    714      {NoFlag, 0x0000007e, 0xfffffffe, 0xffffff80},
    715      {NoFlag, 0xffff8000, 0xffffff82, 0xffff8002},
    716      {NoFlag, 0xaaaaaaaa, 0x7ffffffe, 0xffff8000},
    717      {NoFlag, 0x55555555, 0xffff8003, 0xffffff80},
    718      {NoFlag, 0x7ffffffe, 0x00000020, 0xffffffe0},
    719      {NoFlag, 0x00000001, 0xffff8001, 0xffffffe0},
    720      {NoFlag, 0xcccccccc, 0xffff8000, 0xffff8002},
    721      {NoFlag, 0x80000000, 0x00000002, 0x7ffffffe},
    722      {NoFlag, 0x00000002, 0x0000007f, 0xffffff81},
    723      {NoFlag, 0xffffffff, 0x00000001, 0x7fffffff},
    724      {NoFlag, 0xffffff83, 0x00000000, 0x33333333},
    725      {NoFlag, 0xffff8000, 0xffffff83, 0xcccccccc},
    726      {NoFlag, 0x80000000, 0x00000020, 0x00007ffd},
    727      {NoFlag, 0xffffff81, 0xcccccccc, 0x00000000},
    728      {NoFlag, 0xffffffff, 0xffff8000, 0x00007fff},
    729      {NoFlag, 0xffff8003, 0xcccccccc, 0x00007ffe},
    730      {NoFlag, 0xffffffff, 0xfffffffd, 0x7ffffffe},
    731      {NoFlag, 0xffff8003, 0xaaaaaaaa, 0x55555555},
    732      {NoFlag, 0x00000000, 0xaaaaaaaa, 0xffffff81},
    733      {NoFlag, 0x0000007f, 0xfffffffe, 0xffff8000},
    734      {NoFlag, 0x00000001, 0xffffffe0, 0xfffffffd},
    735      {NoFlag, 0x33333333, 0x33333333, 0xfffffffd},
    736      {NoFlag, 0xffffff82, 0xffff8002, 0x80000001},
    737      {NoFlag, 0x55555555, 0xffffff83, 0xffffff83},
    738      {NoFlag, 0xffffff83, 0xffff8002, 0x00000020},
    739      {NoFlag, 0x0000007d, 0x7fffffff, 0x0000007f},
    740      {NoFlag, 0x00000000, 0xcccccccc, 0xffff8000},
    741      {NoFlag, 0x00000002, 0x7ffffffe, 0x00007fff},
    742      {NoFlag, 0xffffff82, 0x7ffffffd, 0x7ffffffd},
    743      {NoFlag, 0xaaaaaaaa, 0xfffffffd, 0xffff8002},
    744      {NoFlag, 0xfffffffd, 0x00000002, 0x7fffffff},
    745      {NoFlag, 0xfffffffe, 0xfffffffe, 0x00000020},
    746      {NoFlag, 0x80000001, 0x0000007e, 0x00007ffe},
    747      {NoFlag, 0x00007ffd, 0x00007ffd, 0xfffffffd},
    748      {NoFlag, 0xffff8000, 0x0000007f, 0x00000002},
    749      {NoFlag, 0x7ffffffd, 0x80000000, 0x7ffffffd},
    750      {NoFlag, 0x0000007d, 0x00007fff, 0x80000001},
    751      {NoFlag, 0xffffffff, 0x80000000, 0xaaaaaaaa},
    752      {NoFlag, 0x00000000, 0xaaaaaaaa, 0xffff8001},
    753      {NoFlag, 0xaaaaaaaa, 0xffffffe0, 0xffff8003},
    754      {NoFlag, 0xffffff82, 0xffffffff, 0x00007ffd},
    755      {NoFlag, 0x00000001, 0xffffff81, 0x00000001},
    756      {NoFlag, 0x7fffffff, 0xaaaaaaaa, 0x80000001},
    757      {NoFlag, 0x7fffffff, 0xffff8000, 0xffff8000},
    758      {NoFlag, 0xaaaaaaaa, 0x00007ffd, 0xaaaaaaaa},
    759      {NoFlag, 0x0000007f, 0x7ffffffe, 0x80000000},
    760      {NoFlag, 0x00007ffd, 0x00007ffe, 0xffffff81},
    761      {NoFlag, 0x0000007d, 0x0000007d, 0xffff8002},
    762      {NoFlag, 0x80000001, 0x00000002, 0xffffff81},
    763      {NoFlag, 0xffff8000, 0xfffffffd, 0x7ffffffd},
    764      {NoFlag, 0xfffffffe, 0x00000020, 0xffffff80},
    765      {NoFlag, 0x00000020, 0x7fffffff, 0xffffffe0},
    766      {NoFlag, 0xffff8002, 0xffff8002, 0x0000007f},
    767      {NoFlag, 0xffff8003, 0x7fffffff, 0xffff8002},
    768      {NoFlag, 0x00000020, 0xfffffffd, 0x00000020},
    769      {NoFlag, 0x7ffffffd, 0xffffffe0, 0x0000007e},
    770      {NoFlag, 0x00000020, 0x00000020, 0x7ffffffe},
    771      {NoFlag, 0xfffffffe, 0x0000007f, 0xffff8000},
    772      {NoFlag, 0x80000001, 0x80000001, 0x0000007d},
    773      {NoFlag, 0x55555555, 0x0000007f, 0x00007ffd},
    774      {NoFlag, 0x55555555, 0xffffffe0, 0xffffff82},
    775      {NoFlag, 0xffff8001, 0x0000007e, 0xffff8002},
    776      {NoFlag, 0xffffffe0, 0x55555555, 0x0000007f},
    777      {NoFlag, 0xffff8000, 0x7fffffff, 0x7ffffffe},
    778      {NoFlag, 0xffffffff, 0xfffffffe, 0xffffff80},
    779      {NoFlag, 0xffff8001, 0xffff8002, 0x33333333},
    780      {NoFlag, 0x7ffffffd, 0xfffffffd, 0xaaaaaaaa},
    781      {NoFlag, 0xaaaaaaaa, 0xfffffffd, 0x00000020},
    782      {NoFlag, 0x0000007f, 0x00007ffe, 0x55555555},
    783      {NoFlag, 0x00000020, 0x00000020, 0x00000002},
    784      {NoFlag, 0x80000001, 0xffff8002, 0xfffffffe},
    785      {NoFlag, 0x7fffffff, 0x80000001, 0xffff8002},
    786      {NoFlag, 0x00000020, 0x0000007e, 0x33333333}};
    787 
    788 static const Inputs kRotations[] =
    789     {{NoFlag, 0xabababab, 0xabababab, 0x00000000},
    790      {NoFlag, 0xabababab, 0xabababab, 0x00000001},
    791      {NoFlag, 0xabababab, 0xabababab, 0x00000002},
    792      {NoFlag, 0xabababab, 0xabababab, 0x00000020},
    793      {NoFlag, 0xabababab, 0xabababab, 0x0000007d},
    794      {NoFlag, 0xabababab, 0xabababab, 0x0000007e},
    795      {NoFlag, 0xabababab, 0xabababab, 0x0000007f},
    796      {NoFlag, 0xabababab, 0xabababab, 0x00007ffd},
    797      {NoFlag, 0xabababab, 0xabababab, 0x00007ffe},
    798      {NoFlag, 0xabababab, 0xabababab, 0x00007fff},
    799      {NoFlag, 0xabababab, 0xabababab, 0x33333333},
    800      {NoFlag, 0xabababab, 0xabababab, 0x55555555},
    801      {NoFlag, 0xabababab, 0xabababab, 0x7ffffffd},
    802      {NoFlag, 0xabababab, 0xabababab, 0x7ffffffe},
    803      {NoFlag, 0xabababab, 0xabababab, 0x7fffffff},
    804      {NoFlag, 0xabababab, 0xabababab, 0x80000000},
    805      {NoFlag, 0xabababab, 0xabababab, 0x80000001},
    806      {NoFlag, 0xabababab, 0xabababab, 0xaaaaaaaa},
    807      {NoFlag, 0xabababab, 0xabababab, 0xcccccccc},
    808      {NoFlag, 0xabababab, 0xabababab, 0xffff8000},
    809      {NoFlag, 0xabababab, 0xabababab, 0xffff8001},
    810      {NoFlag, 0xabababab, 0xabababab, 0xffff8002},
    811      {NoFlag, 0xabababab, 0xabababab, 0xffff8003},
    812      {NoFlag, 0xabababab, 0xabababab, 0xffffff80},
    813      {NoFlag, 0xabababab, 0xabababab, 0xffffff81},
    814      {NoFlag, 0xabababab, 0xabababab, 0xffffff82},
    815      {NoFlag, 0xabababab, 0xabababab, 0xffffff83},
    816      {NoFlag, 0xabababab, 0xabababab, 0xffffffe0},
    817      {NoFlag, 0xabababab, 0xabababab, 0xfffffffd},
    818      {NoFlag, 0xabababab, 0xabababab, 0xfffffffe},
    819      {NoFlag, 0xabababab, 0xabababab, 0xffffffff}};
    820 
    821 
    822 // A loop will be generated for each element of this array.
    823 const TestLoopData kTests[] = {{{eq, r0, r0, r0, ROR, 0},
    824                                 "eq r0 r0 r0 ROR 0",
    825                                 "Condition_eq_r0_r0_r0_ROR_0",
    826                                 ARRAY_SIZE(kCondition),
    827                                 kCondition},
    828                                {{ne, r0, r0, r0, ROR, 0},
    829                                 "ne r0 r0 r0 ROR 0",
    830                                 "Condition_ne_r0_r0_r0_ROR_0",
    831                                 ARRAY_SIZE(kCondition),
    832                                 kCondition},
    833                                {{cs, r0, r0, r0, ROR, 0},
    834                                 "cs r0 r0 r0 ROR 0",
    835                                 "Condition_cs_r0_r0_r0_ROR_0",
    836                                 ARRAY_SIZE(kCondition),
    837                                 kCondition},
    838                                {{cc, r0, r0, r0, ROR, 0},
    839                                 "cc r0 r0 r0 ROR 0",
    840                                 "Condition_cc_r0_r0_r0_ROR_0",
    841                                 ARRAY_SIZE(kCondition),
    842                                 kCondition},
    843                                {{mi, r0, r0, r0, ROR, 0},
    844                                 "mi r0 r0 r0 ROR 0",
    845                                 "Condition_mi_r0_r0_r0_ROR_0",
    846                                 ARRAY_SIZE(kCondition),
    847                                 kCondition},
    848                                {{pl, r0, r0, r0, ROR, 0},
    849                                 "pl r0 r0 r0 ROR 0",
    850                                 "Condition_pl_r0_r0_r0_ROR_0",
    851                                 ARRAY_SIZE(kCondition),
    852                                 kCondition},
    853                                {{vs, r0, r0, r0, ROR, 0},
    854                                 "vs r0 r0 r0 ROR 0",
    855                                 "Condition_vs_r0_r0_r0_ROR_0",
    856                                 ARRAY_SIZE(kCondition),
    857                                 kCondition},
    858                                {{vc, r0, r0, r0, ROR, 0},
    859                                 "vc r0 r0 r0 ROR 0",
    860                                 "Condition_vc_r0_r0_r0_ROR_0",
    861                                 ARRAY_SIZE(kCondition),
    862                                 kCondition},
    863                                {{hi, r0, r0, r0, ROR, 0},
    864                                 "hi r0 r0 r0 ROR 0",
    865                                 "Condition_hi_r0_r0_r0_ROR_0",
    866                                 ARRAY_SIZE(kCondition),
    867                                 kCondition},
    868                                {{ls, r0, r0, r0, ROR, 0},
    869                                 "ls r0 r0 r0 ROR 0",
    870                                 "Condition_ls_r0_r0_r0_ROR_0",
    871                                 ARRAY_SIZE(kCondition),
    872                                 kCondition},
    873                                {{ge, r0, r0, r0, ROR, 0},
    874                                 "ge r0 r0 r0 ROR 0",
    875                                 "Condition_ge_r0_r0_r0_ROR_0",
    876                                 ARRAY_SIZE(kCondition),
    877                                 kCondition},
    878                                {{lt, r0, r0, r0, ROR, 0},
    879                                 "lt r0 r0 r0 ROR 0",
    880                                 "Condition_lt_r0_r0_r0_ROR_0",
    881                                 ARRAY_SIZE(kCondition),
    882                                 kCondition},
    883                                {{gt, r0, r0, r0, ROR, 0},
    884                                 "gt r0 r0 r0 ROR 0",
    885                                 "Condition_gt_r0_r0_r0_ROR_0",
    886                                 ARRAY_SIZE(kCondition),
    887                                 kCondition},
    888                                {{le, r0, r0, r0, ROR, 0},
    889                                 "le r0 r0 r0 ROR 0",
    890                                 "Condition_le_r0_r0_r0_ROR_0",
    891                                 ARRAY_SIZE(kCondition),
    892                                 kCondition},
    893                                {{al, r0, r0, r0, ROR, 0},
    894                                 "al r0 r0 r0 ROR 0",
    895                                 "Condition_al_r0_r0_r0_ROR_0",
    896                                 ARRAY_SIZE(kCondition),
    897                                 kCondition},
    898                                {{al, r3, r3, r4, ROR, 0},
    899                                 "al r3 r3 r4 ROR 0",
    900                                 "RdIsRn_al_r3_r3_r4_ROR_0",
    901                                 ARRAY_SIZE(kRdIsRn),
    902                                 kRdIsRn},
    903                                {{al, r2, r2, r12, ROR, 0},
    904                                 "al r2 r2 r12 ROR 0",
    905                                 "RdIsRn_al_r2_r2_r12_ROR_0",
    906                                 ARRAY_SIZE(kRdIsRn),
    907                                 kRdIsRn},
    908                                {{al, r8, r8, r5, ROR, 0},
    909                                 "al r8 r8 r5 ROR 0",
    910                                 "RdIsRn_al_r8_r8_r5_ROR_0",
    911                                 ARRAY_SIZE(kRdIsRn),
    912                                 kRdIsRn},
    913                                {{al, r14, r14, r0, ROR, 0},
    914                                 "al r14 r14 r0 ROR 0",
    915                                 "RdIsRn_al_r14_r14_r0_ROR_0",
    916                                 ARRAY_SIZE(kRdIsRn),
    917                                 kRdIsRn},
    918                                {{al, r11, r11, r10, ROR, 0},
    919                                 "al r11 r11 r10 ROR 0",
    920                                 "RdIsRn_al_r11_r11_r10_ROR_0",
    921                                 ARRAY_SIZE(kRdIsRn),
    922                                 kRdIsRn},
    923                                {{al, r12, r12, r10, ROR, 0},
    924                                 "al r12 r12 r10 ROR 0",
    925                                 "RdIsRn_al_r12_r12_r10_ROR_0",
    926                                 ARRAY_SIZE(kRdIsRn),
    927                                 kRdIsRn},
    928                                {{al, r4, r4, r8, ROR, 0},
    929                                 "al r4 r4 r8 ROR 0",
    930                                 "RdIsRn_al_r4_r4_r8_ROR_0",
    931                                 ARRAY_SIZE(kRdIsRn),
    932                                 kRdIsRn},
    933                                {{al, r5, r5, r14, ROR, 0},
    934                                 "al r5 r5 r14 ROR 0",
    935                                 "RdIsRn_al_r5_r5_r14_ROR_0",
    936                                 ARRAY_SIZE(kRdIsRn),
    937                                 kRdIsRn},
    938                                {{al, r0, r0, r6, ROR, 0},
    939                                 "al r0 r0 r6 ROR 0",
    940                                 "RdIsRn_al_r0_r0_r6_ROR_0",
    941                                 ARRAY_SIZE(kRdIsRn),
    942                                 kRdIsRn},
    943                                {{al, r12, r12, r1, ROR, 0},
    944                                 "al r12 r12 r1 ROR 0",
    945                                 "RdIsRn_al_r12_r12_r1_ROR_0",
    946                                 ARRAY_SIZE(kRdIsRn),
    947                                 kRdIsRn},
    948                                {{al, r6, r11, r6, ROR, 0},
    949                                 "al r6 r11 r6 ROR 0",
    950                                 "RdIsRm_al_r6_r11_r6_ROR_0",
    951                                 ARRAY_SIZE(kRdIsRm),
    952                                 kRdIsRm},
    953                                {{al, r11, r9, r11, ROR, 0},
    954                                 "al r11 r9 r11 ROR 0",
    955                                 "RdIsRm_al_r11_r9_r11_ROR_0",
    956                                 ARRAY_SIZE(kRdIsRm),
    957                                 kRdIsRm},
    958                                {{al, r0, r8, r0, ROR, 0},
    959                                 "al r0 r8 r0 ROR 0",
    960                                 "RdIsRm_al_r0_r8_r0_ROR_0",
    961                                 ARRAY_SIZE(kRdIsRm),
    962                                 kRdIsRm},
    963                                {{al, r2, r11, r2, ROR, 0},
    964                                 "al r2 r11 r2 ROR 0",
    965                                 "RdIsRm_al_r2_r11_r2_ROR_0",
    966                                 ARRAY_SIZE(kRdIsRm),
    967                                 kRdIsRm},
    968                                {{al, r9, r4, r9, ROR, 0},
    969                                 "al r9 r4 r9 ROR 0",
    970                                 "RdIsRm_al_r9_r4_r9_ROR_0",
    971                                 ARRAY_SIZE(kRdIsRm),
    972                                 kRdIsRm},
    973                                {{al, r14, r10, r14, ROR, 0},
    974                                 "al r14 r10 r14 ROR 0",
    975                                 "RdIsRm_al_r14_r10_r14_ROR_0",
    976                                 ARRAY_SIZE(kRdIsRm),
    977                                 kRdIsRm},
    978                                {{al, r7, r0, r7, ROR, 0},
    979                                 "al r7 r0 r7 ROR 0",
    980                                 "RdIsRm_al_r7_r0_r7_ROR_0",
    981                                 ARRAY_SIZE(kRdIsRm),
    982                                 kRdIsRm},
    983                                {{al, r4, r9, r4, ROR, 0},
    984                                 "al r4 r9 r4 ROR 0",
    985                                 "RdIsRm_al_r4_r9_r4_ROR_0",
    986                                 ARRAY_SIZE(kRdIsRm),
    987                                 kRdIsRm},
    988                                {{al, r6, r10, r6, ROR, 0},
    989                                 "al r6 r10 r6 ROR 0",
    990                                 "RdIsRm_al_r6_r10_r6_ROR_0",
    991                                 ARRAY_SIZE(kRdIsRm),
    992                                 kRdIsRm},
    993                                {{al, r7, r6, r7, ROR, 0},
    994                                 "al r7 r6 r7 ROR 0",
    995                                 "RdIsRm_al_r7_r6_r7_ROR_0",
    996                                 ARRAY_SIZE(kRdIsRm),
    997                                 kRdIsRm},
    998                                {{al, r3, r9, r10, ROR, 0},
    999                                 "al r3 r9 r10 ROR 0",
   1000                                 "RdIsNotRnIsNotRm_al_r3_r9_r10_ROR_0",
   1001                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
   1002                                 kRdIsNotRnIsNotRm},
   1003                                {{al, r7, r12, r5, ROR, 0},
   1004                                 "al r7 r12 r5 ROR 0",
   1005                                 "RdIsNotRnIsNotRm_al_r7_r12_r5_ROR_0",
   1006                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
   1007                                 kRdIsNotRnIsNotRm},
   1008                                {{al, r8, r5, r6, ROR, 0},
   1009                                 "al r8 r5 r6 ROR 0",
   1010                                 "RdIsNotRnIsNotRm_al_r8_r5_r6_ROR_0",
   1011                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
   1012                                 kRdIsNotRnIsNotRm},
   1013                                {{al, r0, r6, r0, ROR, 0},
   1014                                 "al r0 r6 r0 ROR 0",
   1015                                 "RdIsNotRnIsNotRm_al_r0_r6_r0_ROR_0",
   1016                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
   1017                                 kRdIsNotRnIsNotRm},
   1018                                {{al, r11, r7, r8, ROR, 0},
   1019                                 "al r11 r7 r8 ROR 0",
   1020                                 "RdIsNotRnIsNotRm_al_r11_r7_r8_ROR_0",
   1021                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
   1022                                 kRdIsNotRnIsNotRm},
   1023                                {{al, r12, r2, r3, ROR, 0},
   1024                                 "al r12 r2 r3 ROR 0",
   1025                                 "RdIsNotRnIsNotRm_al_r12_r2_r3_ROR_0",
   1026                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
   1027                                 kRdIsNotRnIsNotRm},
   1028                                {{al, r7, r4, r10, ROR, 0},
   1029                                 "al r7 r4 r10 ROR 0",
   1030                                 "RdIsNotRnIsNotRm_al_r7_r4_r10_ROR_0",
   1031                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
   1032                                 kRdIsNotRnIsNotRm},
   1033                                {{al, r9, r6, r1, ROR, 0},
   1034                                 "al r9 r6 r1 ROR 0",
   1035                                 "RdIsNotRnIsNotRm_al_r9_r6_r1_ROR_0",
   1036                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
   1037                                 kRdIsNotRnIsNotRm},
   1038                                {{al, r10, r14, r3, ROR, 0},
   1039                                 "al r10 r14 r3 ROR 0",
   1040                                 "RdIsNotRnIsNotRm_al_r10_r14_r3_ROR_0",
   1041                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
   1042                                 kRdIsNotRnIsNotRm},
   1043                                {{al, r14, r3, r6, ROR, 0},
   1044                                 "al r14 r3 r6 ROR 0",
   1045                                 "RdIsNotRnIsNotRm_al_r14_r3_r6_ROR_0",
   1046                                 ARRAY_SIZE(kRdIsNotRnIsNotRm),
   1047                                 kRdIsNotRnIsNotRm},
   1048                                {{al, r0, r1, r2, ROR, 0},
   1049                                 "al r0 r1 r2 ROR 0",
   1050                                 "Rotations_al_r0_r1_r2_ROR_0",
   1051                                 ARRAY_SIZE(kRotations),
   1052                                 kRotations},
   1053                                {{al, r0, r1, r2, ROR, 8},
   1054                                 "al r0 r1 r2 ROR 8",
   1055                                 "Rotations_al_r0_r1_r2_ROR_8",
   1056                                 ARRAY_SIZE(kRotations),
   1057                                 kRotations},
   1058                                {{al, r0, r1, r2, ROR, 16},
   1059                                 "al r0 r1 r2 ROR 16",
   1060                                 "Rotations_al_r0_r1_r2_ROR_16",
   1061                                 ARRAY_SIZE(kRotations),
   1062                                 kRotations},
   1063                                {{al, r0, r1, r2, ROR, 24},
   1064                                 "al r0 r1 r2 ROR 24",
   1065                                 "Rotations_al_r0_r1_r2_ROR_24",
   1066                                 ARRAY_SIZE(kRotations),
   1067                                 kRotations}};
   1068 
   1069 // We record all inputs to the instructions as outputs. This way, we also check
   1070 // that what shouldn't change didn't change.
   1071 struct TestResult {
   1072   size_t output_size;
   1073   const Inputs* outputs;
   1074 };
   1075 
   1076 // These headers each contain an array of `TestResult` with the reference output
   1077 // values. The reference arrays are names `kReference{mnemonic}`.
   1078 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-ror-amount-sxtab-t32.h"
   1079 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-ror-amount-sxtab16-t32.h"
   1080 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-ror-amount-sxtah-t32.h"
   1081 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-ror-amount-uxtab-t32.h"
   1082 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-ror-amount-uxtab16-t32.h"
   1083 #include "aarch32/traces/simulator-cond-rd-rn-operand-rm-ror-amount-uxtah-t32.h"
   1084 
   1085 
   1086 // The maximum number of errors to report in detail for each test.
   1087 const unsigned kErrorReportLimit = 8;
   1088 
   1089 typedef void (MacroAssembler::*Fn)(Condition cond,
   1090                                    Register rd,
   1091                                    Register rn,
   1092                                    const Operand& op);
   1093 
   1094 void TestHelper(Fn instruction,
   1095                 const char* mnemonic,
   1096                 const TestResult reference[]) {
   1097   SETUP();
   1098   masm.UseT32();
   1099   START();
   1100 
   1101   // Data to compare to `reference`.
   1102   TestResult* results[ARRAY_SIZE(kTests)];
   1103 
   1104   // Test cases for memory bound instructions may allocate a buffer and save its
   1105   // address in this array.
   1106   byte* scratch_memory_buffers[ARRAY_SIZE(kTests)];
   1107 
   1108   // Generate a loop for each element in `kTests`. Each loop tests one specific
   1109   // instruction.
   1110   for (unsigned i = 0; i < ARRAY_SIZE(kTests); i++) {
   1111     // Allocate results on the heap for this test.
   1112     results[i] = new TestResult;
   1113     results[i]->outputs = new Inputs[kTests[i].input_size];
   1114     results[i]->output_size = kTests[i].input_size;
   1115 
   1116     size_t input_stride = sizeof(kTests[i].inputs[0]) * kTests[i].input_size;
   1117     VIXL_ASSERT(IsUint32(input_stride));
   1118 
   1119     scratch_memory_buffers[i] = NULL;
   1120 
   1121     Label loop;
   1122     UseScratchRegisterScope scratch_registers(&masm);
   1123     // Include all registers from r0 ro r12.
   1124     scratch_registers.Include(RegisterList(0x1fff));
   1125 
   1126     // Values to pass to the macro-assembler.
   1127     Condition cond = kTests[i].operands.cond;
   1128     Register rd = kTests[i].operands.rd;
   1129     Register rn = kTests[i].operands.rn;
   1130     Register rm = kTests[i].operands.rm;
   1131     ShiftType ror = kTests[i].operands.ror;
   1132     uint32_t amount = kTests[i].operands.amount;
   1133     Operand op(rm, ror, amount);
   1134     scratch_registers.Exclude(rd);
   1135     scratch_registers.Exclude(rn);
   1136     scratch_registers.Exclude(rm);
   1137 
   1138     // Allocate reserved registers for our own use.
   1139     Register input_ptr = scratch_registers.Acquire();
   1140     Register input_end = scratch_registers.Acquire();
   1141     Register result_ptr = scratch_registers.Acquire();
   1142 
   1143     // Initialize `input_ptr` to the first element and `input_end` the address
   1144     // after the array.
   1145     __ Mov(input_ptr, Operand::From(kTests[i].inputs));
   1146     __ Add(input_end, input_ptr, static_cast<uint32_t>(input_stride));
   1147     __ Mov(result_ptr, Operand::From(results[i]->outputs));
   1148     __ Bind(&loop);
   1149 
   1150     {
   1151       UseScratchRegisterScope temp_registers(&masm);
   1152       Register nzcv_bits = temp_registers.Acquire();
   1153       Register saved_q_bit = temp_registers.Acquire();
   1154       // Save the `Q` bit flag.
   1155       __ Mrs(saved_q_bit, APSR);
   1156       __ And(saved_q_bit, saved_q_bit, QFlag);
   1157       // Set the `NZCV` and `Q` flags together.
   1158       __ Ldr(nzcv_bits, MemOperand(input_ptr, offsetof(Inputs, apsr)));
   1159       __ Orr(nzcv_bits, nzcv_bits, saved_q_bit);
   1160       __ Msr(APSR_nzcvq, nzcv_bits);
   1161     }
   1162     __ Ldr(rd, MemOperand(input_ptr, offsetof(Inputs, rd)));
   1163     __ Ldr(rn, MemOperand(input_ptr, offsetof(Inputs, rn)));
   1164     __ Ldr(rm, MemOperand(input_ptr, offsetof(Inputs, rm)));
   1165 
   1166     (masm.*instruction)(cond, rd, rn, op);
   1167 
   1168     {
   1169       UseScratchRegisterScope temp_registers(&masm);
   1170       Register nzcv_bits = temp_registers.Acquire();
   1171       __ Mrs(nzcv_bits, APSR);
   1172       // Only record the NZCV bits.
   1173       __ And(nzcv_bits, nzcv_bits, NZCVFlag);
   1174       __ Str(nzcv_bits, MemOperand(result_ptr, offsetof(Inputs, apsr)));
   1175     }
   1176     __ Str(rd, MemOperand(result_ptr, offsetof(Inputs, rd)));
   1177     __ Str(rn, MemOperand(result_ptr, offsetof(Inputs, rn)));
   1178     __ Str(rm, MemOperand(result_ptr, offsetof(Inputs, rm)));
   1179 
   1180     // Advance the result pointer.
   1181     __ Add(result_ptr, result_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
   1182     // Loop back until `input_ptr` is lower than `input_base`.
   1183     __ Add(input_ptr, input_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
   1184     __ Cmp(input_ptr, input_end);
   1185     __ B(ne, &loop);
   1186   }
   1187 
   1188   END();
   1189 
   1190   RUN();
   1191 
   1192   if (Test::generate_test_trace()) {
   1193     // Print the results.
   1194     for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
   1195       printf("const Inputs kOutputs_%s_%s[] = {\n",
   1196              mnemonic,
   1197              kTests[i].identifier);
   1198       for (size_t j = 0; j < results[i]->output_size; j++) {
   1199         printf("  { ");
   1200         printf("0x%08" PRIx32, results[i]->outputs[j].apsr);
   1201         printf(", ");
   1202         printf("0x%08" PRIx32, results[i]->outputs[j].rd);
   1203         printf(", ");
   1204         printf("0x%08" PRIx32, results[i]->outputs[j].rn);
   1205         printf(", ");
   1206         printf("0x%08" PRIx32, results[i]->outputs[j].rm);
   1207         printf(" },\n");
   1208       }
   1209       printf("};\n");
   1210     }
   1211     printf("const TestResult kReference%s[] = {\n", mnemonic);
   1212     for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
   1213       printf("  {\n");
   1214       printf("    ARRAY_SIZE(kOutputs_%s_%s),\n",
   1215              mnemonic,
   1216              kTests[i].identifier);
   1217       printf("    kOutputs_%s_%s,\n", mnemonic, kTests[i].identifier);
   1218       printf("  },\n");
   1219     }
   1220     printf("};\n");
   1221   } else if (kCheckSimulatorTestResults) {
   1222     // Check the results.
   1223     unsigned total_error_count = 0;
   1224     for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
   1225       bool instruction_has_errors = false;
   1226       for (size_t j = 0; j < kTests[i].input_size; j++) {
   1227         uint32_t apsr = results[i]->outputs[j].apsr;
   1228         uint32_t rd = results[i]->outputs[j].rd;
   1229         uint32_t rn = results[i]->outputs[j].rn;
   1230         uint32_t rm = results[i]->outputs[j].rm;
   1231         uint32_t apsr_input = kTests[i].inputs[j].apsr;
   1232         uint32_t rd_input = kTests[i].inputs[j].rd;
   1233         uint32_t rn_input = kTests[i].inputs[j].rn;
   1234         uint32_t rm_input = kTests[i].inputs[j].rm;
   1235         uint32_t apsr_ref = reference[i].outputs[j].apsr;
   1236         uint32_t rd_ref = reference[i].outputs[j].rd;
   1237         uint32_t rn_ref = reference[i].outputs[j].rn;
   1238         uint32_t rm_ref = reference[i].outputs[j].rm;
   1239 
   1240         if (((apsr != apsr_ref) || (rd != rd_ref) || (rn != rn_ref) ||
   1241              (rm != rm_ref)) &&
   1242             (++total_error_count <= kErrorReportLimit)) {
   1243           // Print the instruction once even if it triggered multiple failures.
   1244           if (!instruction_has_errors) {
   1245             printf("Error(s) when testing \"%s %s\":\n",
   1246                    mnemonic,
   1247                    kTests[i].operands_description);
   1248             instruction_has_errors = true;
   1249           }
   1250           // Print subsequent errors.
   1251           printf("  Input:    ");
   1252           printf("0x%08" PRIx32, apsr_input);
   1253           printf(", ");
   1254           printf("0x%08" PRIx32, rd_input);
   1255           printf(", ");
   1256           printf("0x%08" PRIx32, rn_input);
   1257           printf(", ");
   1258           printf("0x%08" PRIx32, rm_input);
   1259           printf("\n");
   1260           printf("  Expected: ");
   1261           printf("0x%08" PRIx32, apsr_ref);
   1262           printf(", ");
   1263           printf("0x%08" PRIx32, rd_ref);
   1264           printf(", ");
   1265           printf("0x%08" PRIx32, rn_ref);
   1266           printf(", ");
   1267           printf("0x%08" PRIx32, rm_ref);
   1268           printf("\n");
   1269           printf("  Found:    ");
   1270           printf("0x%08" PRIx32, apsr);
   1271           printf(", ");
   1272           printf("0x%08" PRIx32, rd);
   1273           printf(", ");
   1274           printf("0x%08" PRIx32, rn);
   1275           printf(", ");
   1276           printf("0x%08" PRIx32, rm);
   1277           printf("\n\n");
   1278         }
   1279       }
   1280     }
   1281 
   1282     if (total_error_count > kErrorReportLimit) {
   1283       printf("%u other errors follow.\n",
   1284              total_error_count - kErrorReportLimit);
   1285     }
   1286     VIXL_CHECK(total_error_count == 0);
   1287   } else {
   1288     VIXL_WARNING("Assembled the code, but did not run anything.\n");
   1289   }
   1290 
   1291   for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
   1292     delete[] results[i]->outputs;
   1293     delete results[i];
   1294     delete[] scratch_memory_buffers[i];
   1295   }
   1296 }
   1297 
   1298 // Instantiate tests for each instruction in the list.
   1299 // TODO: Remove this limitation by having a sandboxing mechanism.
   1300 #if defined(VIXL_HOST_POINTER_32)
   1301 #define TEST(mnemonic)                                                        \
   1302   void Test_##mnemonic() {                                                    \
   1303     TestHelper(&MacroAssembler::mnemonic, #mnemonic, kReference##mnemonic);   \
   1304   }                                                                           \
   1305   Test test_##mnemonic(                                                       \
   1306       "AARCH32_SIMULATOR_COND_RD_RN_OPERAND_RM_ROR_AMOUNT_" #mnemonic "_T32", \
   1307       &Test_##mnemonic);
   1308 #else
   1309 #define TEST(mnemonic)                                                        \
   1310   void Test_##mnemonic() {                                                    \
   1311     VIXL_WARNING("This test can only run on a 32-bit host.\n");               \
   1312     USE(TestHelper);                                                          \
   1313   }                                                                           \
   1314   Test test_##mnemonic(                                                       \
   1315       "AARCH32_SIMULATOR_COND_RD_RN_OPERAND_RM_ROR_AMOUNT_" #mnemonic "_T32", \
   1316       &Test_##mnemonic);
   1317 #endif
   1318 
   1319 FOREACH_INSTRUCTION(TEST)
   1320 #undef TEST
   1321 
   1322 }  // namespace
   1323 #endif
   1324 
   1325 }  // namespace aarch32
   1326 }  // namespace vixl
   1327