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/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(Add)                       \
    119   M(Adds)                      \
    120   M(Rsb)                       \
    121   M(Rsbs)                      \
    122   M(Sub)                       \
    123   M(Subs)
    124 
    125 
    126 // The following definitions are defined again in each generated test, therefore
    127 // we need to place them in an anomymous namespace. It expresses that they are
    128 // local to this file only, and the compiler is not allowed to share these types
    129 // across test files during template instantiation. Specifically, `Operands` and
    130 // `Inputs` have various layouts across generated tests so they absolutely
    131 // cannot be shared.
    132 
    133 #ifdef VIXL_INCLUDE_TARGET_T32
    134 namespace {
    135 
    136 // Values to be passed to the assembler to produce the instruction under test.
    137 struct Operands {
    138   Condition cond;
    139   Register rd;
    140   Register rn;
    141   int32_t immediate;
    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 };
    150 
    151 // This structure contains all input data needed to test one specific encoding.
    152 // It used to generate a loop over an instruction.
    153 struct TestLoopData {
    154   // The `operands` fields represents the values to pass to the assembler to
    155   // produce the instruction.
    156   Operands operands;
    157   // Description of the operands, used for error reporting.
    158   const char* operands_description;
    159   // Unique identifier, used for generating traces.
    160   const char* identifier;
    161   // Array of values to be fed to the instruction.
    162   size_t input_size;
    163   const Inputs* inputs;
    164 };
    165 
    166 static const Inputs kRdIsRn[] = {{ZFlag, 0x00007fff, 0x00007fff},
    167                                  {CFlag, 0xffffff83, 0xffffff83},
    168                                  {NCFlag, 0x00000000, 0x00000000},
    169                                  {NCVFlag, 0x00000000, 0x00000000},
    170                                  {NZFlag, 0x00000000, 0x00000000},
    171                                  {VFlag, 0x00000002, 0x00000002},
    172                                  {NCFlag, 0xfffffffe, 0xfffffffe},
    173                                  {NCVFlag, 0x00007ffd, 0x00007ffd},
    174                                  {NZCVFlag, 0xffffffff, 0xffffffff},
    175                                  {ZVFlag, 0xffffffff, 0xffffffff},
    176                                  {CFlag, 0x00000002, 0x00000002},
    177                                  {ZFlag, 0x80000001, 0x80000001},
    178                                  {ZCFlag, 0x00007ffe, 0x00007ffe},
    179                                  {ZVFlag, 0xffff8000, 0xffff8000},
    180                                  {CFlag, 0x0000007e, 0x0000007e},
    181                                  {ZFlag, 0xcccccccc, 0xcccccccc},
    182                                  {NVFlag, 0xffff8000, 0xffff8000},
    183                                  {CFlag, 0x00000001, 0x00000001},
    184                                  {NFlag, 0x00000001, 0x00000001},
    185                                  {NZFlag, 0xffffffe0, 0xffffffe0},
    186                                  {CVFlag, 0xfffffffd, 0xfffffffd},
    187                                  {ZVFlag, 0x00007ffe, 0x00007ffe},
    188                                  {ZCVFlag, 0x55555555, 0x55555555},
    189                                  {NCFlag, 0x00000020, 0x00000020},
    190                                  {ZCFlag, 0xffffff81, 0xffffff81},
    191                                  {ZCFlag, 0xcccccccc, 0xcccccccc},
    192                                  {ZCFlag, 0x00000020, 0x00000020},
    193                                  {NCVFlag, 0xffff8000, 0xffff8000},
    194                                  {NZVFlag, 0xffff8001, 0xffff8001},
    195                                  {ZVFlag, 0xffffff81, 0xffffff81},
    196                                  {NZVFlag, 0xffffff81, 0xffffff81},
    197                                  {NZVFlag, 0x00000000, 0x00000000},
    198                                  {NVFlag, 0x00000001, 0x00000001},
    199                                  {NCVFlag, 0x33333333, 0x33333333},
    200                                  {NZCVFlag, 0xffff8001, 0xffff8001},
    201                                  {NZCFlag, 0xffffffff, 0xffffffff},
    202                                  {NCVFlag, 0x80000000, 0x80000000},
    203                                  {ZCFlag, 0x00000001, 0x00000001},
    204                                  {CVFlag, 0x00000020, 0x00000020},
    205                                  {NCFlag, 0xffff8003, 0xffff8003},
    206                                  {CVFlag, 0x00000002, 0x00000002},
    207                                  {NZCFlag, 0x80000000, 0x80000000},
    208                                  {VFlag, 0xffffff83, 0xffffff83},
    209                                  {NZFlag, 0x33333333, 0x33333333},
    210                                  {NCVFlag, 0x00007ffe, 0x00007ffe},
    211                                  {NFlag, 0xffffff81, 0xffffff81},
    212                                  {NZVFlag, 0x00000020, 0x00000020},
    213                                  {CVFlag, 0x00007fff, 0x00007fff},
    214                                  {NZCFlag, 0xffff8003, 0xffff8003},
    215                                  {ZCFlag, 0xfffffffd, 0xfffffffd},
    216                                  {NZFlag, 0xcccccccc, 0xcccccccc},
    217                                  {ZCFlag, 0xffffffff, 0xffffffff},
    218                                  {ZVFlag, 0xffffffe0, 0xffffffe0},
    219                                  {ZCFlag, 0x55555555, 0x55555555},
    220                                  {NVFlag, 0x00000020, 0x00000020},
    221                                  {NFlag, 0xffff8000, 0xffff8000},
    222                                  {ZFlag, 0x00000000, 0x00000000},
    223                                  {VFlag, 0xffffffe0, 0xffffffe0},
    224                                  {CFlag, 0xffff8001, 0xffff8001},
    225                                  {NZCVFlag, 0xfffffffd, 0xfffffffd},
    226                                  {NCVFlag, 0x0000007d, 0x0000007d},
    227                                  {NCVFlag, 0x0000007f, 0x0000007f},
    228                                  {NZFlag, 0xffff8003, 0xffff8003},
    229                                  {ZCFlag, 0xffffff82, 0xffffff82},
    230                                  {ZFlag, 0xffff8001, 0xffff8001},
    231                                  {NZFlag, 0xffff8002, 0xffff8002},
    232                                  {NZFlag, 0x00000020, 0x00000020},
    233                                  {NCFlag, 0x33333333, 0x33333333},
    234                                  {ZCVFlag, 0x80000000, 0x80000000},
    235                                  {NZCFlag, 0xffffffe0, 0xffffffe0},
    236                                  {NZFlag, 0x00007fff, 0x00007fff},
    237                                  {NZVFlag, 0x00000002, 0x00000002},
    238                                  {NFlag, 0x55555555, 0x55555555},
    239                                  {NVFlag, 0xffffffff, 0xffffffff},
    240                                  {NCFlag, 0x00007fff, 0x00007fff},
    241                                  {NZCVFlag, 0xffffff81, 0xffffff81},
    242                                  {ZCVFlag, 0x00007fff, 0x00007fff},
    243                                  {NZFlag, 0x0000007d, 0x0000007d},
    244                                  {VFlag, 0x00007ffe, 0x00007ffe},
    245                                  {CVFlag, 0xffffff83, 0xffffff83},
    246                                  {NZFlag, 0x80000000, 0x80000000},
    247                                  {ZCFlag, 0xaaaaaaaa, 0xaaaaaaaa},
    248                                  {NCFlag, 0x0000007f, 0x0000007f},
    249                                  {CFlag, 0x00000020, 0x00000020},
    250                                  {NZCFlag, 0x00000001, 0x00000001},
    251                                  {NZCFlag, 0xcccccccc, 0xcccccccc},
    252                                  {NZCFlag, 0xffffff80, 0xffffff80},
    253                                  {NCVFlag, 0xffff8003, 0xffff8003},
    254                                  {NFlag, 0x0000007d, 0x0000007d},
    255                                  {NZVFlag, 0x55555555, 0x55555555},
    256                                  {NZCVFlag, 0xfffffffe, 0xfffffffe},
    257                                  {NCFlag, 0xffff8000, 0xffff8000},
    258                                  {CFlag, 0x80000001, 0x80000001},
    259                                  {NVFlag, 0xffffffe0, 0xffffffe0},
    260                                  {CFlag, 0xffffff82, 0xffffff82},
    261                                  {NZCVFlag, 0x00007ffd, 0x00007ffd},
    262                                  {CFlag, 0xaaaaaaaa, 0xaaaaaaaa},
    263                                  {NZCFlag, 0xffffff81, 0xffffff81},
    264                                  {ZFlag, 0x00007ffd, 0x00007ffd},
    265                                  {NZVFlag, 0xffffffe0, 0xffffffe0},
    266                                  {NZVFlag, 0x00007ffe, 0x00007ffe},
    267                                  {NZFlag, 0x7ffffffd, 0x7ffffffd},
    268                                  {NZCFlag, 0xfffffffe, 0xfffffffe},
    269                                  {NZCVFlag, 0x7ffffffd, 0x7ffffffd},
    270                                  {ZVFlag, 0xaaaaaaaa, 0xaaaaaaaa},
    271                                  {CFlag, 0x00000000, 0x00000000},
    272                                  {ZCVFlag, 0xaaaaaaaa, 0xaaaaaaaa},
    273                                  {NZFlag, 0x00007ffd, 0x00007ffd},
    274                                  {VFlag, 0xffff8000, 0xffff8000},
    275                                  {CVFlag, 0xcccccccc, 0xcccccccc},
    276                                  {NZCVFlag, 0xffff8003, 0xffff8003},
    277                                  {NVFlag, 0x00007ffe, 0x00007ffe},
    278                                  {ZVFlag, 0xfffffffd, 0xfffffffd},
    279                                  {NZCFlag, 0x0000007e, 0x0000007e},
    280                                  {VFlag, 0x00000000, 0x00000000},
    281                                  {NZFlag, 0x00000002, 0x00000002},
    282                                  {ZCFlag, 0x7fffffff, 0x7fffffff},
    283                                  {ZFlag, 0x0000007e, 0x0000007e},
    284                                  {NZCFlag, 0x7fffffff, 0x7fffffff},
    285                                  {ZVFlag, 0xffff8002, 0xffff8002},
    286                                  {ZFlag, 0x00000020, 0x00000020},
    287                                  {NZFlag, 0xffffff81, 0xffffff81},
    288                                  {ZCVFlag, 0x00000000, 0x00000000},
    289                                  {CFlag, 0xffffff81, 0xffffff81},
    290                                  {NVFlag, 0x0000007e, 0x0000007e},
    291                                  {NZFlag, 0x55555555, 0x55555555},
    292                                  {CFlag, 0x0000007d, 0x0000007d},
    293                                  {NCFlag, 0x7fffffff, 0x7fffffff},
    294                                  {NCFlag, 0xffff8001, 0xffff8001},
    295                                  {CFlag, 0xffffffe0, 0xffffffe0},
    296                                  {ZVFlag, 0x7ffffffe, 0x7ffffffe},
    297                                  {VFlag, 0x7ffffffd, 0x7ffffffd},
    298                                  {CFlag, 0xffffffff, 0xffffffff},
    299                                  {ZCFlag, 0xffff8000, 0xffff8000},
    300                                  {NZVFlag, 0xffff8003, 0xffff8003},
    301                                  {NCFlag, 0x0000007d, 0x0000007d},
    302                                  {NZVFlag, 0x0000007f, 0x0000007f},
    303                                  {CFlag, 0xcccccccc, 0xcccccccc},
    304                                  {CVFlag, 0x00000001, 0x00000001},
    305                                  {NZCFlag, 0xffff8001, 0xffff8001},
    306                                  {NCVFlag, 0x00000020, 0x00000020},
    307                                  {NZVFlag, 0xffffff82, 0xffffff82},
    308                                  {NCFlag, 0x00007ffd, 0x00007ffd},
    309                                  {ZVFlag, 0x0000007e, 0x0000007e},
    310                                  {NZFlag, 0x80000001, 0x80000001},
    311                                  {NVFlag, 0x7ffffffe, 0x7ffffffe},
    312                                  {NZCVFlag, 0x00000000, 0x00000000},
    313                                  {CVFlag, 0x55555555, 0x55555555},
    314                                  {ZVFlag, 0x00000020, 0x00000020},
    315                                  {VFlag, 0x00000020, 0x00000020},
    316                                  {NFlag, 0xcccccccc, 0xcccccccc},
    317                                  {NVFlag, 0x0000007d, 0x0000007d},
    318                                  {CVFlag, 0x0000007f, 0x0000007f},
    319                                  {NZCFlag, 0x00000002, 0x00000002},
    320                                  {NZCFlag, 0x00007fff, 0x00007fff},
    321                                  {NZVFlag, 0x0000007d, 0x0000007d},
    322                                  {NZVFlag, 0xfffffffd, 0xfffffffd},
    323                                  {NFlag, 0x00000002, 0x00000002},
    324                                  {NZCVFlag, 0x0000007d, 0x0000007d},
    325                                  {NVFlag, 0xffffff82, 0xffffff82},
    326                                  {VFlag, 0x00007fff, 0x00007fff},
    327                                  {NZCVFlag, 0x00000001, 0x00000001},
    328                                  {ZFlag, 0xaaaaaaaa, 0xaaaaaaaa},
    329                                  {CVFlag, 0xffff8002, 0xffff8002},
    330                                  {NFlag, 0x7fffffff, 0x7fffffff},
    331                                  {NCVFlag, 0xffffff80, 0xffffff80},
    332                                  {ZFlag, 0x33333333, 0x33333333},
    333                                  {NZFlag, 0x00000001, 0x00000001},
    334                                  {NCVFlag, 0x7ffffffe, 0x7ffffffe},
    335                                  {VFlag, 0x00000001, 0x00000001},
    336                                  {ZCFlag, 0x0000007f, 0x0000007f},
    337                                  {ZVFlag, 0x80000001, 0x80000001},
    338                                  {ZVFlag, 0xffff8003, 0xffff8003},
    339                                  {NCVFlag, 0xaaaaaaaa, 0xaaaaaaaa},
    340                                  {NZCVFlag, 0xffffffe0, 0xffffffe0},
    341                                  {VFlag, 0x33333333, 0x33333333},
    342                                  {NCFlag, 0xffffff80, 0xffffff80},
    343                                  {ZFlag, 0x00007ffe, 0x00007ffe},
    344                                  {NVFlag, 0x00000000, 0x00000000},
    345                                  {NZCFlag, 0x00007ffd, 0x00007ffd},
    346                                  {NZFlag, 0xfffffffd, 0xfffffffd},
    347                                  {VFlag, 0xffffffff, 0xffffffff},
    348                                  {NZCFlag, 0xffffff83, 0xffffff83},
    349                                  {NZVFlag, 0xffff8002, 0xffff8002},
    350                                  {NZCVFlag, 0x33333333, 0x33333333},
    351                                  {ZCVFlag, 0xfffffffd, 0xfffffffd},
    352                                  {ZCFlag, 0x80000001, 0x80000001},
    353                                  {NCFlag, 0x00007ffe, 0x00007ffe},
    354                                  {NFlag, 0xfffffffd, 0xfffffffd},
    355                                  {NZCVFlag, 0x7fffffff, 0x7fffffff},
    356                                  {VFlag, 0xffff8001, 0xffff8001},
    357                                  {NZVFlag, 0xffff8000, 0xffff8000},
    358                                  {ZCVFlag, 0xcccccccc, 0xcccccccc},
    359                                  {VFlag, 0x7ffffffe, 0x7ffffffe},
    360                                  {ZFlag, 0xffff8002, 0xffff8002},
    361                                  {ZCFlag, 0x0000007d, 0x0000007d},
    362                                  {NZCVFlag, 0xffffff83, 0xffffff83},
    363                                  {ZVFlag, 0x00000001, 0x00000001},
    364                                  {NZCVFlag, 0xffff8002, 0xffff8002},
    365                                  {ZCFlag, 0xffffff83, 0xffffff83},
    366                                  {CFlag, 0xffff8003, 0xffff8003},
    367                                  {NCVFlag, 0xffffffff, 0xffffffff},
    368                                  {CFlag, 0xfffffffe, 0xfffffffe},
    369                                  {NZFlag, 0xffffff80, 0xffffff80},
    370                                  {CVFlag, 0x00007ffd, 0x00007ffd},
    371                                  {ZCVFlag, 0x0000007d, 0x0000007d},
    372                                  {ZVFlag, 0xcccccccc, 0xcccccccc},
    373                                  {NVFlag, 0x00007ffd, 0x00007ffd},
    374                                  {NZFlag, 0xaaaaaaaa, 0xaaaaaaaa},
    375                                  {ZFlag, 0x0000007f, 0x0000007f},
    376                                  {CVFlag, 0xffff8003, 0xffff8003},
    377                                  {ZFlag, 0xffffffe0, 0xffffffe0},
    378                                  {NZVFlag, 0xcccccccc, 0xcccccccc},
    379                                  {NFlag, 0x00007ffe, 0x00007ffe},
    380                                  {NFlag, 0xffff8003, 0xffff8003},
    381                                  {NZVFlag, 0xffffffff, 0xffffffff},
    382                                  {CFlag, 0x00007fff, 0x00007fff},
    383                                  {NCVFlag, 0x7fffffff, 0x7fffffff},
    384                                  {CFlag, 0x33333333, 0x33333333},
    385                                  {ZCFlag, 0x80000000, 0x80000000},
    386                                  {ZCFlag, 0x0000007e, 0x0000007e},
    387                                  {NVFlag, 0x7fffffff, 0x7fffffff},
    388                                  {NZFlag, 0x7ffffffe, 0x7ffffffe},
    389                                  {CFlag, 0xffff8002, 0xffff8002},
    390                                  {NCFlag, 0x80000000, 0x80000000},
    391                                  {VFlag, 0x7fffffff, 0x7fffffff},
    392                                  {NZFlag, 0xffffffff, 0xffffffff},
    393                                  {NFlag, 0x7ffffffd, 0x7ffffffd},
    394                                  {ZFlag, 0x00000002, 0x00000002},
    395                                  {ZCVFlag, 0xffff8003, 0xffff8003},
    396                                  {CFlag, 0x7fffffff, 0x7fffffff},
    397                                  {CFlag, 0x0000007f, 0x0000007f},
    398                                  {VFlag, 0x80000001, 0x80000001},
    399                                  {ZCFlag, 0x00007fff, 0x00007fff},
    400                                  {CFlag, 0xfffffffd, 0xfffffffd},
    401                                  {NZFlag, 0x7fffffff, 0x7fffffff},
    402                                  {CVFlag, 0xffff8001, 0xffff8001},
    403                                  {NZVFlag, 0x00007fff, 0x00007fff},
    404                                  {NZVFlag, 0x7ffffffe, 0x7ffffffe},
    405                                  {ZCVFlag, 0x0000007e, 0x0000007e},
    406                                  {NZVFlag, 0x00000001, 0x00000001},
    407                                  {ZFlag, 0xffffffff, 0xffffffff},
    408                                  {NZFlag, 0xfffffffe, 0xfffffffe},
    409                                  {NZCVFlag, 0x0000007f, 0x0000007f},
    410                                  {NZCVFlag, 0x80000000, 0x80000000},
    411                                  {VFlag, 0x55555555, 0x55555555},
    412                                  {NVFlag, 0xffff8001, 0xffff8001},
    413                                  {NFlag, 0xffffff83, 0xffffff83},
    414                                  {NZVFlag, 0x7ffffffd, 0x7ffffffd},
    415                                  {ZVFlag, 0x00000000, 0x00000000},
    416                                  {NCVFlag, 0xfffffffd, 0xfffffffd},
    417                                  {CFlag, 0x00007ffe, 0x00007ffe},
    418                                  {NVFlag, 0xffffff83, 0xffffff83},
    419                                  {NZFlag, 0x0000007e, 0x0000007e},
    420                                  {VFlag, 0x80000000, 0x80000000},
    421                                  {NZCFlag, 0xffff8000, 0xffff8000},
    422                                  {ZCFlag, 0xffff8001, 0xffff8001},
    423                                  {NVFlag, 0x00007fff, 0x00007fff},
    424                                  {ZCVFlag, 0xffffff81, 0xffffff81},
    425                                  {NZVFlag, 0x0000007e, 0x0000007e},
    426                                  {CVFlag, 0xffff8000, 0xffff8000},
    427                                  {VFlag, 0xffffff82, 0xffffff82},
    428                                  {VFlag, 0xaaaaaaaa, 0xaaaaaaaa},
    429                                  {NZCVFlag, 0xcccccccc, 0xcccccccc},
    430                                  {CVFlag, 0x33333333, 0x33333333},
    431                                  {NCFlag, 0xffffffff, 0xffffffff},
    432                                  {VFlag, 0xffffff80, 0xffffff80},
    433                                  {NVFlag, 0xffff8002, 0xffff8002},
    434                                  {ZCFlag, 0x00000000, 0x00000000},
    435                                  {ZCVFlag, 0x80000001, 0x80000001},
    436                                  {NZCVFlag, 0x80000001, 0x80000001},
    437                                  {NCFlag, 0x55555555, 0x55555555},
    438                                  {CVFlag, 0x7ffffffe, 0x7ffffffe},
    439                                  {ZVFlag, 0x7ffffffd, 0x7ffffffd},
    440                                  {ZCVFlag, 0xffff8000, 0xffff8000},
    441                                  {ZCFlag, 0xffff8002, 0xffff8002},
    442                                  {NFlag, 0xfffffffe, 0xfffffffe},
    443                                  {ZCVFlag, 0x0000007f, 0x0000007f},
    444                                  {NCVFlag, 0xfffffffe, 0xfffffffe},
    445                                  {ZCVFlag, 0x7fffffff, 0x7fffffff},
    446                                  {CVFlag, 0x0000007e, 0x0000007e},
    447                                  {NZCVFlag, 0x7ffffffe, 0x7ffffffe},
    448                                  {CFlag, 0xffffff80, 0xffffff80},
    449                                  {VFlag, 0x00007ffd, 0x00007ffd},
    450                                  {CVFlag, 0xffffffe0, 0xffffffe0},
    451                                  {CFlag, 0x7ffffffe, 0x7ffffffe},
    452                                  {CFlag, 0x80000000, 0x80000000},
    453                                  {CVFlag, 0xfffffffe, 0xfffffffe},
    454                                  {NCVFlag, 0xffff8002, 0xffff8002},
    455                                  {ZCVFlag, 0x33333333, 0x33333333},
    456                                  {NZCFlag, 0xaaaaaaaa, 0xaaaaaaaa},
    457                                  {NVFlag, 0x55555555, 0x55555555},
    458                                  {NVFlag, 0x80000000, 0x80000000},
    459                                  {NZCVFlag, 0x00007ffe, 0x00007ffe},
    460                                  {ZFlag, 0xffffff83, 0xffffff83},
    461                                  {NCFlag, 0xaaaaaaaa, 0xaaaaaaaa},
    462                                  {NZVFlag, 0xfffffffe, 0xfffffffe},
    463                                  {CVFlag, 0xaaaaaaaa, 0xaaaaaaaa},
    464                                  {NZCFlag, 0xffff8002, 0xffff8002},
    465                                  {VFlag, 0x0000007d, 0x0000007d}};
    466 
    467 static const Inputs kRdIsNotRn[] = {{NZCVFlag, 0xffff8000, 0xffffffff},
    468                                     {CVFlag, 0xcccccccc, 0xffffff80},
    469                                     {NCFlag, 0xfffffffe, 0xfffffffd},
    470                                     {NCFlag, 0xcccccccc, 0xcccccccc},
    471                                     {ZFlag, 0x80000001, 0xffffffff},
    472                                     {NCFlag, 0xffffff82, 0x0000007d},
    473                                     {NCVFlag, 0x0000007d, 0xffff8001},
    474                                     {NVFlag, 0x00007fff, 0x7fffffff},
    475                                     {NVFlag, 0x80000001, 0xffffff82},
    476                                     {ZCVFlag, 0xffffffff, 0x0000007e},
    477                                     {ZCVFlag, 0xffffff80, 0x0000007d},
    478                                     {ZCVFlag, 0x00000020, 0xaaaaaaaa},
    479                                     {CVFlag, 0x00007fff, 0x00000020},
    480                                     {NVFlag, 0xffff8000, 0xffffff82},
    481                                     {NZFlag, 0xffffff82, 0x7ffffffe},
    482                                     {NZVFlag, 0xffff8003, 0x33333333},
    483                                     {ZCVFlag, 0x00007ffe, 0x7ffffffe},
    484                                     {NFlag, 0x0000007f, 0xffffffff},
    485                                     {NZCFlag, 0x33333333, 0x80000000},
    486                                     {ZCFlag, 0x80000001, 0xffffffff},
    487                                     {VFlag, 0x00007ffd, 0x00000001},
    488                                     {ZVFlag, 0xffffffff, 0x0000007e},
    489                                     {NZFlag, 0x00000001, 0xcccccccc},
    490                                     {NZVFlag, 0x00000020, 0xffff8001},
    491                                     {NCVFlag, 0x7ffffffe, 0xffffff80},
    492                                     {ZCFlag, 0x33333333, 0x00007fff},
    493                                     {CFlag, 0xffffff82, 0x0000007e},
    494                                     {ZCFlag, 0x55555555, 0xffff8003},
    495                                     {NFlag, 0x0000007f, 0x00000001},
    496                                     {ZCVFlag, 0x00000020, 0xfffffffd},
    497                                     {ZVFlag, 0x0000007e, 0xffff8003},
    498                                     {ZCVFlag, 0x00000020, 0x80000001},
    499                                     {ZCFlag, 0xfffffffe, 0x55555555},
    500                                     {NFlag, 0xfffffffd, 0xfffffffe},
    501                                     {VFlag, 0xffffff82, 0x7ffffffe},
    502                                     {CVFlag, 0xffffff80, 0x0000007f},
    503                                     {NVFlag, 0x00000020, 0xffff8001},
    504                                     {NCFlag, 0x0000007d, 0x80000000},
    505                                     {CVFlag, 0x00000020, 0xffffff83},
    506                                     {NZCVFlag, 0x0000007f, 0x00000000},
    507                                     {ZVFlag, 0xffffff82, 0x7ffffffd},
    508                                     {ZVFlag, 0xffff8000, 0x80000001},
    509                                     {NFlag, 0xcccccccc, 0x0000007e},
    510                                     {NFlag, 0x55555555, 0xffffff80},
    511                                     {NCFlag, 0x80000000, 0x00007ffd},
    512                                     {ZVFlag, 0x00007ffd, 0x00007ffe},
    513                                     {ZCVFlag, 0x00000000, 0x7ffffffe},
    514                                     {ZFlag, 0xffff8001, 0xffffffff},
    515                                     {NCFlag, 0xfffffffe, 0x55555555},
    516                                     {VFlag, 0x7ffffffd, 0x80000001},
    517                                     {VFlag, 0x80000000, 0xffffffff},
    518                                     {CFlag, 0xffffff82, 0xffffff80},
    519                                     {NZCFlag, 0xffff8003, 0xfffffffd},
    520                                     {CFlag, 0x00000020, 0x00007fff},
    521                                     {NZVFlag, 0xffff8002, 0xfffffffe},
    522                                     {NVFlag, 0xffffff80, 0x0000007e},
    523                                     {NVFlag, 0xcccccccc, 0x0000007d},
    524                                     {CFlag, 0x0000007f, 0x00000001},
    525                                     {ZVFlag, 0xffff8002, 0xffffff81},
    526                                     {NZVFlag, 0x80000000, 0x00007ffe},
    527                                     {NZCVFlag, 0x80000000, 0x7ffffffe},
    528                                     {ZVFlag, 0x7ffffffe, 0x80000000},
    529                                     {ZFlag, 0xffff8000, 0xffffff80},
    530                                     {VFlag, 0x00007ffd, 0x00007ffd},
    531                                     {ZCFlag, 0x0000007d, 0x0000007e},
    532                                     {NCFlag, 0x00000000, 0x7ffffffe},
    533                                     {NVFlag, 0x00000020, 0xaaaaaaaa},
    534                                     {NVFlag, 0xffffff83, 0x0000007e},
    535                                     {NZFlag, 0xffff8002, 0x7ffffffd},
    536                                     {CVFlag, 0xcccccccc, 0x00000001},
    537                                     {NZFlag, 0x33333333, 0x0000007e},
    538                                     {NZCFlag, 0x00000002, 0x7ffffffd},
    539                                     {NZFlag, 0x00007ffd, 0xffffff80},
    540                                     {ZVFlag, 0x00007ffd, 0xfffffffe},
    541                                     {NZCVFlag, 0xffff8000, 0x80000000},
    542                                     {NZFlag, 0xffff8002, 0xffffffff},
    543                                     {CFlag, 0x00000002, 0xffff8000},
    544                                     {NZCFlag, 0x0000007d, 0xffffff80},
    545                                     {ZVFlag, 0x0000007d, 0xffff8003},
    546                                     {VFlag, 0x55555555, 0xffff8000},
    547                                     {CFlag, 0x00007fff, 0x00000001},
    548                                     {VFlag, 0x80000001, 0x33333333},
    549                                     {ZCFlag, 0xaaaaaaaa, 0xffffff82},
    550                                     {VFlag, 0x00000002, 0x00007ffd},
    551                                     {ZVFlag, 0x7ffffffe, 0xffff8001},
    552                                     {ZCFlag, 0x7fffffff, 0x00000000},
    553                                     {CVFlag, 0x55555555, 0x0000007e},
    554                                     {VFlag, 0x55555555, 0x0000007e},
    555                                     {NZCVFlag, 0x80000000, 0x7ffffffd},
    556                                     {ZFlag, 0x0000007d, 0x00000000},
    557                                     {NZVFlag, 0xffffff80, 0x00000002},
    558                                     {NVFlag, 0xfffffffd, 0x00000001},
    559                                     {ZVFlag, 0x7ffffffd, 0xfffffffd},
    560                                     {VFlag, 0xffff8002, 0x55555555},
    561                                     {ZCVFlag, 0x00000001, 0xffff8002},
    562                                     {NVFlag, 0xffff8002, 0x00000020},
    563                                     {ZFlag, 0x33333333, 0xffff8002},
    564                                     {ZCVFlag, 0x55555555, 0xffffff82},
    565                                     {CVFlag, 0x7ffffffe, 0xffffffe0},
    566                                     {NVFlag, 0xcccccccc, 0x00007ffd},
    567                                     {NZFlag, 0x00000001, 0x0000007f},
    568                                     {ZFlag, 0xfffffffe, 0x00007fff},
    569                                     {NCVFlag, 0x80000001, 0xffffff83},
    570                                     {NCVFlag, 0xaaaaaaaa, 0xffff8002},
    571                                     {ZVFlag, 0x00007fff, 0xffff8000},
    572                                     {ZFlag, 0xffff8001, 0xfffffffd},
    573                                     {CFlag, 0x55555555, 0x80000000},
    574                                     {ZCVFlag, 0xcccccccc, 0xfffffffe},
    575                                     {NZCVFlag, 0xffff8003, 0x7fffffff},
    576                                     {NZCVFlag, 0x00007ffe, 0xffffff81},
    577                                     {NZCFlag, 0xfffffffd, 0xaaaaaaaa},
    578                                     {NVFlag, 0x00000002, 0x00000020},
    579                                     {ZCVFlag, 0xffff8003, 0xfffffffd},
    580                                     {NFlag, 0xffff8001, 0x00007ffe},
    581                                     {ZCFlag, 0xaaaaaaaa, 0x00000002},
    582                                     {NCVFlag, 0xffff8000, 0xfffffffe},
    583                                     {CFlag, 0x00000020, 0x00000000},
    584                                     {NZVFlag, 0x00007ffd, 0xffffff81},
    585                                     {NVFlag, 0x00007fff, 0x00000020},
    586                                     {ZFlag, 0x0000007e, 0x80000001},
    587                                     {CVFlag, 0x0000007d, 0xaaaaaaaa},
    588                                     {NZVFlag, 0x7fffffff, 0x55555555},
    589                                     {VFlag, 0xffffffff, 0x00007ffd},
    590                                     {NFlag, 0x80000000, 0xffffffe0},
    591                                     {ZVFlag, 0xffffff82, 0xfffffffe},
    592                                     {CVFlag, 0x0000007d, 0x00007fff},
    593                                     {CFlag, 0x7ffffffe, 0x55555555},
    594                                     {ZFlag, 0xffffff82, 0x7fffffff},
    595                                     {NZCFlag, 0xfffffffd, 0xffffff83},
    596                                     {CVFlag, 0x80000001, 0x80000000},
    597                                     {ZVFlag, 0x00000001, 0xfffffffe},
    598                                     {CVFlag, 0x00000001, 0x33333333},
    599                                     {NZFlag, 0x7ffffffd, 0x80000000},
    600                                     {NZVFlag, 0x00007ffd, 0xaaaaaaaa},
    601                                     {CVFlag, 0x0000007e, 0xffffff82},
    602                                     {CVFlag, 0x7ffffffe, 0xffff8002},
    603                                     {NVFlag, 0xfffffffe, 0xffff8003},
    604                                     {NFlag, 0x7fffffff, 0x80000001},
    605                                     {CFlag, 0xffffff82, 0x00000002},
    606                                     {CVFlag, 0xcccccccc, 0x0000007e},
    607                                     {NZCVFlag, 0x00000001, 0x7ffffffe},
    608                                     {NFlag, 0x00000000, 0x55555555},
    609                                     {NZFlag, 0xffffff81, 0x00000000},
    610                                     {NZVFlag, 0xffffffe0, 0x0000007e},
    611                                     {ZCFlag, 0xffff8002, 0xaaaaaaaa},
    612                                     {NZVFlag, 0x7fffffff, 0x0000007d},
    613                                     {ZVFlag, 0x0000007e, 0xffff8001},
    614                                     {NCVFlag, 0xffffff83, 0xaaaaaaaa},
    615                                     {ZFlag, 0xffffff82, 0xffffff83},
    616                                     {VFlag, 0x00000001, 0x55555555},
    617                                     {NFlag, 0x00000020, 0x80000000},
    618                                     {NZFlag, 0x00000000, 0xfffffffe},
    619                                     {VFlag, 0xffffff83, 0xaaaaaaaa},
    620                                     {ZFlag, 0xffff8002, 0xffffff83},
    621                                     {NZVFlag, 0xcccccccc, 0x7ffffffe},
    622                                     {ZVFlag, 0x00000000, 0x55555555},
    623                                     {NCFlag, 0x33333333, 0xffff8003},
    624                                     {NZCVFlag, 0xfffffffd, 0x00000000},
    625                                     {NZCVFlag, 0x00000020, 0xffff8000},
    626                                     {CVFlag, 0xffff8001, 0xffffff83},
    627                                     {CFlag, 0xffffff83, 0x33333333},
    628                                     {CVFlag, 0x7ffffffd, 0x00000020},
    629                                     {NCVFlag, 0xffffffe0, 0x80000000},
    630                                     {NCVFlag, 0xffffff82, 0xcccccccc},
    631                                     {NZCVFlag, 0xaaaaaaaa, 0x00007fff},
    632                                     {VFlag, 0xcccccccc, 0xffff8003},
    633                                     {ZCVFlag, 0x55555555, 0xffffffe0},
    634                                     {NZCFlag, 0xffffff83, 0xffff8000},
    635                                     {ZVFlag, 0xffff8001, 0x0000007d},
    636                                     {CVFlag, 0xffffff83, 0x00000002},
    637                                     {NVFlag, 0x7fffffff, 0x0000007d},
    638                                     {VFlag, 0x55555555, 0x33333333},
    639                                     {NCVFlag, 0x00000002, 0xffffff80},
    640                                     {ZFlag, 0xfffffffd, 0x00007fff},
    641                                     {ZCFlag, 0xffff8003, 0x0000007d},
    642                                     {NZCFlag, 0xffff8002, 0xffff8000},
    643                                     {NCVFlag, 0x00000020, 0xffff8002},
    644                                     {ZVFlag, 0xffff8000, 0x00000020},
    645                                     {ZCVFlag, 0x0000007f, 0xffffffe0},
    646                                     {NZCFlag, 0xffffff80, 0x33333333},
    647                                     {NCVFlag, 0x00007fff, 0xaaaaaaaa},
    648                                     {ZCVFlag, 0x00000020, 0xffffff82},
    649                                     {NFlag, 0x00000000, 0x0000007d},
    650                                     {NCVFlag, 0x00000001, 0x00007ffe},
    651                                     {ZFlag, 0x80000001, 0x00000002},
    652                                     {NZVFlag, 0xffff8000, 0x00000020},
    653                                     {CVFlag, 0xffff8002, 0xcccccccc},
    654                                     {NVFlag, 0xffffff83, 0x80000000},
    655                                     {ZCFlag, 0x0000007f, 0xffffff80},
    656                                     {NZFlag, 0xcccccccc, 0xffffffff},
    657                                     {NZFlag, 0x00007fff, 0x0000007f},
    658                                     {NZFlag, 0xfffffffd, 0xffff8001},
    659                                     {CFlag, 0x0000007d, 0x7ffffffd},
    660                                     {ZCFlag, 0xffff8000, 0xffff8003},
    661                                     {ZVFlag, 0xffffffff, 0xffffffe0},
    662                                     {NZCFlag, 0x00007ffd, 0xcccccccc},
    663                                     {NCVFlag, 0x0000007d, 0x00000020},
    664                                     {ZCFlag, 0xaaaaaaaa, 0x80000000},
    665                                     {ZCVFlag, 0xfffffffd, 0x0000007d},
    666                                     {ZFlag, 0xffffffe0, 0xfffffffe},
    667                                     {VFlag, 0xffff8003, 0x80000000},
    668                                     {NZCFlag, 0x00007fff, 0xffffff82},
    669                                     {NCVFlag, 0x00000002, 0x33333333},
    670                                     {NZCVFlag, 0x00000000, 0xffffff82},
    671                                     {VFlag, 0x80000000, 0x80000000},
    672                                     {ZVFlag, 0x80000001, 0x33333333},
    673                                     {ZFlag, 0x7ffffffe, 0x00007fff},
    674                                     {NZCVFlag, 0x7fffffff, 0x00007fff},
    675                                     {ZCFlag, 0xffffff83, 0xaaaaaaaa},
    676                                     {NZVFlag, 0xffff8002, 0xffffffe0},
    677                                     {VFlag, 0xfffffffd, 0xffffff81},
    678                                     {NZFlag, 0x7fffffff, 0x7ffffffd},
    679                                     {NZCVFlag, 0x0000007f, 0xcccccccc},
    680                                     {NZCFlag, 0xffff8001, 0x00000020},
    681                                     {ZFlag, 0x00000020, 0xffff8002},
    682                                     {ZVFlag, 0x55555555, 0x00007ffd},
    683                                     {NZVFlag, 0xcccccccc, 0x33333333},
    684                                     {CFlag, 0x80000000, 0x80000000},
    685                                     {ZCVFlag, 0xcccccccc, 0x00007ffd},
    686                                     {ZFlag, 0xffff8002, 0xffffff80},
    687                                     {CVFlag, 0x7ffffffd, 0xffffff80},
    688                                     {NZCVFlag, 0x00000001, 0x00000001},
    689                                     {NFlag, 0xfffffffe, 0xffffffe0},
    690                                     {ZVFlag, 0x0000007e, 0x0000007f},
    691                                     {NCVFlag, 0xffff8002, 0xffff8002},
    692                                     {ZCVFlag, 0xffffff82, 0x80000001},
    693                                     {CVFlag, 0x0000007d, 0x0000007d},
    694                                     {NZVFlag, 0xcccccccc, 0xffffff83},
    695                                     {VFlag, 0xffffff82, 0xfffffffd},
    696                                     {CFlag, 0x0000007d, 0x0000007f},
    697                                     {NFlag, 0x0000007d, 0x00000001},
    698                                     {NVFlag, 0x00007ffd, 0xfffffffe},
    699                                     {NZVFlag, 0x33333333, 0xffffff80},
    700                                     {NVFlag, 0x0000007e, 0x00007ffe},
    701                                     {ZFlag, 0xffff8001, 0x0000007e},
    702                                     {VFlag, 0x80000000, 0x00000002},
    703                                     {NVFlag, 0x00000020, 0x00007ffe},
    704                                     {CFlag, 0x00007ffe, 0x0000007f},
    705                                     {ZCFlag, 0xffff8002, 0x00000020},
    706                                     {NCVFlag, 0x00000001, 0xffff8000},
    707                                     {NZCVFlag, 0x0000007e, 0xffff8001},
    708                                     {ZCFlag, 0x0000007f, 0xffffff81},
    709                                     {ZVFlag, 0xfffffffd, 0x00007ffd},
    710                                     {NCFlag, 0x0000007d, 0xcccccccc},
    711                                     {NZFlag, 0xfffffffd, 0xfffffffe},
    712                                     {ZCFlag, 0xffff8003, 0x80000000},
    713                                     {CFlag, 0x0000007d, 0xffff8002},
    714                                     {ZVFlag, 0x0000007f, 0x00007ffe},
    715                                     {NCVFlag, 0xffff8002, 0x00000001},
    716                                     {ZCFlag, 0x80000001, 0x0000007e},
    717                                     {NCFlag, 0x00000000, 0xaaaaaaaa},
    718                                     {ZCVFlag, 0x33333333, 0x80000001},
    719                                     {CFlag, 0x80000000, 0x0000007d},
    720                                     {NCVFlag, 0x80000001, 0x80000000},
    721                                     {ZCVFlag, 0x7ffffffe, 0xffffff82},
    722                                     {ZCFlag, 0xfffffffd, 0xffff8000},
    723                                     {ZFlag, 0x80000000, 0x55555555},
    724                                     {ZVFlag, 0x0000007d, 0xffff8000},
    725                                     {ZCFlag, 0x80000001, 0xffff8001},
    726                                     {NVFlag, 0xffff8002, 0x00007ffe},
    727                                     {ZCFlag, 0x00000000, 0xffff8000},
    728                                     {CFlag, 0xffffff81, 0xffffffff},
    729                                     {CFlag, 0xffffffff, 0x80000001},
    730                                     {CFlag, 0x80000001, 0x7ffffffd},
    731                                     {ZFlag, 0x80000001, 0x00007fff},
    732                                     {ZVFlag, 0xffff8002, 0xffff8001},
    733                                     {NZFlag, 0x80000000, 0x00007ffd},
    734                                     {NZCFlag, 0x33333333, 0xcccccccc},
    735                                     {ZCFlag, 0xffffffff, 0x33333333},
    736                                     {VFlag, 0x80000001, 0x55555555},
    737                                     {CFlag, 0xffffff82, 0x00000001},
    738                                     {ZVFlag, 0xffff8003, 0xffff8001},
    739                                     {NCVFlag, 0xffff8003, 0xffffffe0},
    740                                     {ZCVFlag, 0xffffffe0, 0x7ffffffd},
    741                                     {NFlag, 0xffff8003, 0x7ffffffe},
    742                                     {VFlag, 0xffffffff, 0x00000001},
    743                                     {CVFlag, 0xcccccccc, 0xfffffffe},
    744                                     {NZVFlag, 0xffff8003, 0x0000007f},
    745                                     {NZVFlag, 0x0000007d, 0x00000002},
    746                                     {NVFlag, 0x0000007d, 0x00000000},
    747                                     {NVFlag, 0x00000002, 0xffff8002},
    748                                     {ZCVFlag, 0xffff8001, 0xfffffffd},
    749                                     {CVFlag, 0x00007fff, 0x0000007d},
    750                                     {NCFlag, 0x33333333, 0x00000002},
    751                                     {NCVFlag, 0xcccccccc, 0xaaaaaaaa},
    752                                     {CVFlag, 0x80000000, 0x00007ffd},
    753                                     {NZFlag, 0xffffff81, 0x55555555},
    754                                     {CFlag, 0xffff8003, 0x33333333},
    755                                     {NZCVFlag, 0xffffffe0, 0xffffff82},
    756                                     {NVFlag, 0x80000001, 0xfffffffd},
    757                                     {CFlag, 0xffff8000, 0x33333333},
    758                                     {NCVFlag, 0xffff8003, 0x0000007f},
    759                                     {CFlag, 0x00000000, 0x0000007d},
    760                                     {NVFlag, 0x0000007e, 0xcccccccc},
    761                                     {NZFlag, 0x7ffffffe, 0xffffffe0},
    762                                     {ZVFlag, 0xffffffe0, 0xffffff82},
    763                                     {ZCVFlag, 0x80000001, 0x55555555},
    764                                     {NZFlag, 0xcccccccc, 0xffff8001},
    765                                     {NFlag, 0x55555555, 0x00000020},
    766                                     {ZVFlag, 0x00007ffd, 0xffffff83}};
    767 
    768 static const Inputs kImmediate[] = {{CFlag, 0xabababab, 0xffffff82},
    769                                     {CVFlag, 0xabababab, 0x0000007f},
    770                                     {NFlag, 0xabababab, 0x80000001},
    771                                     {NZFlag, 0xabababab, 0xfffffffd},
    772                                     {VFlag, 0xabababab, 0x7ffffffd},
    773                                     {CFlag, 0xabababab, 0x7ffffffe},
    774                                     {ZFlag, 0xabababab, 0xaaaaaaaa},
    775                                     {NZVFlag, 0xabababab, 0x0000007e},
    776                                     {NZVFlag, 0xabababab, 0x80000001},
    777                                     {CFlag, 0xabababab, 0xffffff81},
    778                                     {NZVFlag, 0xabababab, 0xfffffffd},
    779                                     {NZFlag, 0xabababab, 0x00007fff},
    780                                     {VFlag, 0xabababab, 0x00000001},
    781                                     {CVFlag, 0xabababab, 0xffffffff},
    782                                     {NZCVFlag, 0xabababab, 0xffffffff},
    783                                     {CFlag, 0xabababab, 0x00000000},
    784                                     {NZFlag, 0xabababab, 0xffffff83},
    785                                     {NCFlag, 0xabababab, 0x0000007e},
    786                                     {NZCVFlag, 0xabababab, 0x7fffffff},
    787                                     {ZCVFlag, 0xabababab, 0x00000002},
    788                                     {CFlag, 0xabababab, 0x80000000},
    789                                     {NZCFlag, 0xabababab, 0x7ffffffd},
    790                                     {ZFlag, 0xabababab, 0xffff8000},
    791                                     {CFlag, 0xabababab, 0x7ffffffd},
    792                                     {NVFlag, 0xabababab, 0x55555555},
    793                                     {NZCFlag, 0xabababab, 0xfffffffd},
    794                                     {CVFlag, 0xabababab, 0xaaaaaaaa},
    795                                     {NZCVFlag, 0xabababab, 0xffff8003},
    796                                     {NZFlag, 0xabababab, 0xffffffe0},
    797                                     {NZCFlag, 0xabababab, 0x00007ffd},
    798                                     {ZCVFlag, 0xabababab, 0xffffff80},
    799                                     {NZFlag, 0xabababab, 0x7ffffffd},
    800                                     {ZCFlag, 0xabababab, 0x7fffffff},
    801                                     {ZVFlag, 0xabababab, 0xffffff81},
    802                                     {VFlag, 0xabababab, 0x7fffffff},
    803                                     {NCVFlag, 0xabababab, 0xcccccccc},
    804                                     {ZVFlag, 0xabababab, 0x00007fff},
    805                                     {NZFlag, 0xabababab, 0x00000002},
    806                                     {NVFlag, 0xabababab, 0x00000002},
    807                                     {ZVFlag, 0xabababab, 0xffff8002},
    808                                     {NZVFlag, 0xabababab, 0x00000020},
    809                                     {ZCVFlag, 0xabababab, 0xaaaaaaaa},
    810                                     {ZCFlag, 0xabababab, 0x00000000},
    811                                     {NZCVFlag, 0xabababab, 0xaaaaaaaa},
    812                                     {NZFlag, 0xabababab, 0xfffffffe},
    813                                     {NZCFlag, 0xabababab, 0xffffffe0},
    814                                     {NFlag, 0xabababab, 0xaaaaaaaa},
    815                                     {ZVFlag, 0xabababab, 0xffffff80},
    816                                     {VFlag, 0xabababab, 0x0000007f},
    817                                     {ZVFlag, 0xabababab, 0x33333333},
    818                                     {NZFlag, 0xabababab, 0x00007ffd},
    819                                     {NCFlag, 0xabababab, 0x00000002},
    820                                     {NVFlag, 0xabababab, 0x00007ffd},
    821                                     {ZFlag, 0xabababab, 0x00000001},
    822                                     {CVFlag, 0xabababab, 0x7fffffff},
    823                                     {CFlag, 0xabababab, 0xaaaaaaaa},
    824                                     {NZCVFlag, 0xabababab, 0x80000001},
    825                                     {CVFlag, 0xabababab, 0x00000002},
    826                                     {ZVFlag, 0xabababab, 0x0000007e},
    827                                     {VFlag, 0xabababab, 0xffffffff},
    828                                     {NCFlag, 0xabababab, 0x00000001},
    829                                     {NZCFlag, 0xabababab, 0xcccccccc},
    830                                     {CVFlag, 0xabababab, 0x80000001},
    831                                     {NVFlag, 0xabababab, 0xffffff82},
    832                                     {NZCVFlag, 0xabababab, 0x0000007e},
    833                                     {CFlag, 0xabababab, 0xffffffe0},
    834                                     {ZCFlag, 0xabababab, 0xffff8002},
    835                                     {NZVFlag, 0xabababab, 0x7fffffff},
    836                                     {NZVFlag, 0xabababab, 0x33333333},
    837                                     {NZCFlag, 0xabababab, 0x0000007d},
    838                                     {NFlag, 0xabababab, 0x7ffffffe},
    839                                     {ZCVFlag, 0xabababab, 0xcccccccc},
    840                                     {ZCFlag, 0xabababab, 0xfffffffe},
    841                                     {NVFlag, 0xabababab, 0x00007ffe},
    842                                     {NZFlag, 0xabababab, 0x00007ffe},
    843                                     {NCVFlag, 0xabababab, 0xffffff82},
    844                                     {NZVFlag, 0xabababab, 0x00000002},
    845                                     {ZVFlag, 0xabababab, 0x7fffffff},
    846                                     {NZCFlag, 0xabababab, 0xffff8001},
    847                                     {VFlag, 0xabababab, 0xffffff83},
    848                                     {ZCVFlag, 0xabababab, 0x0000007e},
    849                                     {NZCFlag, 0xabababab, 0xffffff83},
    850                                     {NCFlag, 0xabababab, 0x00007fff},
    851                                     {NCVFlag, 0xabababab, 0x7ffffffe},
    852                                     {CFlag, 0xabababab, 0x00000020},
    853                                     {NFlag, 0xabababab, 0x00007ffd},
    854                                     {NZFlag, 0xabababab, 0x7fffffff},
    855                                     {NZCFlag, 0xabababab, 0xffff8002},
    856                                     {ZVFlag, 0xabababab, 0x0000007f},
    857                                     {NZVFlag, 0xabababab, 0xffffff83},
    858                                     {NZVFlag, 0xabababab, 0xffffffff},
    859                                     {ZFlag, 0xabababab, 0x80000000},
    860                                     {ZVFlag, 0xabababab, 0xffffff82},
    861                                     {ZVFlag, 0xabababab, 0x80000000},
    862                                     {NZFlag, 0xabababab, 0xaaaaaaaa},
    863                                     {CFlag, 0xabababab, 0xfffffffe},
    864                                     {NZCVFlag, 0xabababab, 0x00000000},
    865                                     {VFlag, 0xabababab, 0x80000001},
    866                                     {ZCVFlag, 0xabababab, 0xfffffffd},
    867                                     {NFlag, 0xabababab, 0xffffffff},
    868                                     {VFlag, 0xabababab, 0xcccccccc},
    869                                     {NFlag, 0xabababab, 0xffff8003},
    870                                     {NZVFlag, 0xabababab, 0xfffffffe},
    871                                     {CVFlag, 0xabababab, 0xffff8001},
    872                                     {NZVFlag, 0xabababab, 0x00007fff},
    873                                     {VFlag, 0xabababab, 0x33333333},
    874                                     {ZCVFlag, 0xabababab, 0x00007ffd},
    875                                     {NCFlag, 0xabababab, 0xfffffffe},
    876                                     {ZVFlag, 0xabababab, 0xffffff83},
    877                                     {NFlag, 0xabababab, 0x00007fff},
    878                                     {NVFlag, 0xabababab, 0x80000000},
    879                                     {NCVFlag, 0xabababab, 0xffffff80},
    880                                     {ZFlag, 0xabababab, 0x7fffffff},
    881                                     {NFlag, 0xabababab, 0x00000020},
    882                                     {NFlag, 0xabababab, 0x7ffffffd},
    883                                     {NFlag, 0xabababab, 0x0000007f},
    884                                     {NZCVFlag, 0xabababab, 0x00000020},
    885                                     {NCVFlag, 0xabababab, 0xfffffffe},
    886                                     {ZVFlag, 0xabababab, 0xcccccccc},
    887                                     {NCFlag, 0xabababab, 0xffffffe0},
    888                                     {CVFlag, 0xabababab, 0xffffff82},
    889                                     {NCFlag, 0xabababab, 0x00000000},
    890                                     {VFlag, 0xabababab, 0xffff8000},
    891                                     {VFlag, 0xabababab, 0xffff8003},
    892                                     {NCFlag, 0xabababab, 0xffffffff},
    893                                     {NZCFlag, 0xabababab, 0x55555555},
    894                                     {ZVFlag, 0xabababab, 0xfffffffe},
    895                                     {NZFlag, 0xabababab, 0x7ffffffe},
    896                                     {ZCVFlag, 0xabababab, 0x7ffffffe},
    897                                     {ZVFlag, 0xabababab, 0xffffffe0},
    898                                     {NZCFlag, 0xabababab, 0x0000007e},
    899                                     {CFlag, 0xabababab, 0x7fffffff},
    900                                     {NZVFlag, 0xabababab, 0x55555555},
    901                                     {NZCVFlag, 0xabababab, 0xcccccccc},
    902                                     {ZCVFlag, 0xabababab, 0x80000000},
    903                                     {NFlag, 0xabababab, 0x55555555},
    904                                     {ZCVFlag, 0xabababab, 0xffffffe0},
    905                                     {NCFlag, 0xabababab, 0xffff8000},
    906                                     {NCFlag, 0xabababab, 0xffff8001},
    907                                     {NVFlag, 0xabababab, 0x7ffffffe},
    908                                     {ZVFlag, 0xabababab, 0x00007ffe},
    909                                     {NVFlag, 0xabababab, 0x00000020},
    910                                     {NFlag, 0xabababab, 0x7fffffff},
    911                                     {NZFlag, 0xabababab, 0x33333333},
    912                                     {ZCFlag, 0xabababab, 0xffff8001},
    913                                     {ZFlag, 0xabababab, 0xffffffe0},
    914                                     {VFlag, 0xabababab, 0xffffffe0},
    915                                     {VFlag, 0xabababab, 0xffffff80},
    916                                     {NCVFlag, 0xabababab, 0x80000000},
    917                                     {ZCFlag, 0xabababab, 0x55555555},
    918                                     {CFlag, 0xabababab, 0xffff8001},
    919                                     {CFlag, 0xabababab, 0xffff8002},
    920                                     {ZVFlag, 0xabababab, 0xffff8000},
    921                                     {CFlag, 0xabababab, 0x80000001},
    922                                     {NZCVFlag, 0xabababab, 0x0000007d},
    923                                     {NZCVFlag, 0xabababab, 0xfffffffd},
    924                                     {CVFlag, 0xabababab, 0xffffff81},
    925                                     {NVFlag, 0xabababab, 0xffff8002},
    926                                     {ZCFlag, 0xabababab, 0x7ffffffe},
    927                                     {ZCVFlag, 0xabababab, 0xffffff82},
    928                                     {ZCVFlag, 0xabababab, 0x33333333},
    929                                     {NCFlag, 0xabababab, 0x33333333},
    930                                     {NZCVFlag, 0xabababab, 0x00000002},
    931                                     {NFlag, 0xabababab, 0x00000001},
    932                                     {NVFlag, 0xabababab, 0xffff8003},
    933                                     {NZCVFlag, 0xabababab, 0x00000001},
    934                                     {CFlag, 0xabababab, 0xffff8003},
    935                                     {NVFlag, 0xabababab, 0x0000007e},
    936                                     {CVFlag, 0xabababab, 0x80000000},
    937                                     {ZFlag, 0xabababab, 0xffffffff},
    938                                     {NFlag, 0xabababab, 0xfffffffd},
    939                                     {NVFlag, 0xabababab, 0x00007fff},
    940                                     {NZCVFlag, 0xabababab, 0x7ffffffd},
    941                                     {NZVFlag, 0xabababab, 0x00000000},
    942                                     {NZCFlag, 0xabababab, 0xfffffffe},
    943                                     {ZVFlag, 0xabababab, 0x7ffffffe},
    944                                     {CFlag, 0xabababab, 0xffffffff},
    945                                     {ZCFlag, 0xabababab, 0xffffff82},
    946                                     {ZCFlag, 0xabababab, 0xffffff83},
    947                                     {ZCFlag, 0xabababab, 0x00000002},
    948                                     {NZFlag, 0xabababab, 0x0000007e},
    949                                     {NZCVFlag, 0xabababab, 0xffffffe0},
    950                                     {NZFlag, 0xabababab, 0x00000001},
    951                                     {ZVFlag, 0xabababab, 0x55555555},
    952                                     {ZCVFlag, 0xabababab, 0x00007fff},
    953                                     {NFlag, 0xabababab, 0x33333333},
    954                                     {ZFlag, 0xabababab, 0x00000000},
    955                                     {NVFlag, 0xabababab, 0x7fffffff},
    956                                     {ZVFlag, 0xabababab, 0xfffffffd},
    957                                     {ZFlag, 0xabababab, 0x00000020},
    958                                     {NCVFlag, 0xabababab, 0xfffffffd},
    959                                     {NZCFlag, 0xabababab, 0x80000000},
    960                                     {NVFlag, 0xabababab, 0x80000001},
    961                                     {ZFlag, 0xabababab, 0xffff8002},
    962                                     {NZCVFlag, 0xabababab, 0xffff8001},
    963                                     {NFlag, 0xabababab, 0xfffffffe},
    964                                     {ZVFlag, 0xabababab, 0x0000007d},
    965                                     {NCFlag, 0xabababab, 0x00007ffd},
    966                                     {NFlag, 0xabababab, 0xffff8001},
    967                                     {NZCFlag, 0xabababab, 0xaaaaaaaa},
    968                                     {NZCFlag, 0xabababab, 0x00000020},
    969                                     {ZCVFlag, 0xabababab, 0x7fffffff},
    970                                     {ZCVFlag, 0xabababab, 0x00000001},
    971                                     {NVFlag, 0xabababab, 0xcccccccc},
    972                                     {NFlag, 0xabababab, 0x80000000},
    973                                     {NFlag, 0xabababab, 0xffffffe0},
    974                                     {ZCFlag, 0xabababab, 0xffffffff},
    975                                     {CVFlag, 0xabababab, 0x00000000},
    976                                     {ZCFlag, 0xabababab, 0xffff8000},
    977                                     {ZCFlag, 0xabababab, 0x00007ffd},
    978                                     {NCFlag, 0xabababab, 0x0000007f},
    979                                     {ZVFlag, 0xabababab, 0x00000020},
    980                                     {VFlag, 0xabababab, 0xffff8002},
    981                                     {ZFlag, 0xabababab, 0xffffff81},
    982                                     {CVFlag, 0xabababab, 0xffff8003},
    983                                     {NFlag, 0xabababab, 0xffffff80},
    984                                     {NVFlag, 0xabababab, 0xaaaaaaaa},
    985                                     {CFlag, 0xabababab, 0x00000001},
    986                                     {ZCVFlag, 0xabababab, 0xffff8003},
    987                                     {NCFlag, 0xabababab, 0xfffffffd},
    988                                     {CVFlag, 0xabababab, 0xffffff83},
    989                                     {ZCFlag, 0xabababab, 0xfffffffd},
    990                                     {CVFlag, 0xabababab, 0x0000007d},
    991                                     {ZCVFlag, 0xabababab, 0xffffff83},
    992                                     {NCFlag, 0xabababab, 0xffffff81},
    993                                     {NFlag, 0xabababab, 0xffff8000},
    994                                     {NZFlag, 0xabababab, 0x80000001},
    995                                     {NCFlag, 0xabababab, 0x55555555},
    996                                     {NCVFlag, 0xabababab, 0xaaaaaaaa},
    997                                     {NZCFlag, 0xabababab, 0xffffffff},
    998                                     {ZFlag, 0xabababab, 0x33333333},
    999                                     {NCFlag, 0xabababab, 0xffffff82},
   1000                                     {NZFlag, 0xabababab, 0xffff8001},
   1001                                     {VFlag, 0xabababab, 0x7ffffffe},
   1002                                     {NZCVFlag, 0xabababab, 0x7ffffffe},
   1003                                     {ZFlag, 0xabababab, 0x80000001},
   1004                                     {NVFlag, 0xabababab, 0xffffff80},
   1005                                     {NFlag, 0xabababab, 0x0000007e},
   1006                                     {NCVFlag, 0xabababab, 0x00007ffd},
   1007                                     {CFlag, 0xabababab, 0x0000007e},
   1008                                     {NZVFlag, 0xabababab, 0xcccccccc},
   1009                                     {NZVFlag, 0xabababab, 0x0000007f},
   1010                                     {ZFlag, 0xabababab, 0xffffff83},
   1011                                     {VFlag, 0xabababab, 0xaaaaaaaa},
   1012                                     {ZVFlag, 0xabababab, 0x7ffffffd},
   1013                                     {ZVFlag, 0xabababab, 0xffffffff},
   1014                                     {NZCVFlag, 0xabababab, 0x0000007f},
   1015                                     {NCVFlag, 0xabababab, 0x0000007e},
   1016                                     {NZVFlag, 0xabababab, 0xffffff82},
   1017                                     {CFlag, 0xabababab, 0xffffff80},
   1018                                     {NZCVFlag, 0xabababab, 0x80000000},
   1019                                     {NZVFlag, 0xabababab, 0x7ffffffe},
   1020                                     {NZFlag, 0xabababab, 0xffffff80},
   1021                                     {NZFlag, 0xabababab, 0xffff8000},
   1022                                     {NCFlag, 0xabababab, 0xaaaaaaaa},
   1023                                     {NFlag, 0xabababab, 0x00000000},
   1024                                     {NZFlag, 0xabababab, 0xcccccccc},
   1025                                     {ZCFlag, 0xabababab, 0xffffffe0},
   1026                                     {CVFlag, 0xabababab, 0xcccccccc},
   1027                                     {VFlag, 0xabababab, 0xfffffffd},
   1028                                     {CVFlag, 0xabababab, 0x7ffffffd},
   1029                                     {ZCFlag, 0xabababab, 0x00000020},
   1030                                     {CVFlag, 0xabababab, 0x00007ffe},
   1031                                     {ZCFlag, 0xabababab, 0xffffff80},
   1032                                     {NVFlag, 0xabababab, 0xfffffffd},
   1033                                     {NZCFlag, 0xabababab, 0x00000001},
   1034                                     {CVFlag, 0xabababab, 0x00000001},
   1035                                     {NVFlag, 0xabababab, 0xffffff83},
   1036                                     {ZCVFlag, 0xabababab, 0x7ffffffd},
   1037                                     {NZVFlag, 0xabababab, 0xffff8000},
   1038                                     {CVFlag, 0xabababab, 0xffffffe0},
   1039                                     {NCFlag, 0xabababab, 0x0000007d},
   1040                                     {VFlag, 0xabababab, 0x00007ffd},
   1041                                     {NZCFlag, 0xabababab, 0xffffff81},
   1042                                     {NCVFlag, 0xabababab, 0x00007fff},
   1043                                     {NVFlag, 0xabababab, 0x0000007f},
   1044                                     {CFlag, 0xabababab, 0xcccccccc},
   1045                                     {ZFlag, 0xabababab, 0xcccccccc},
   1046                                     {ZCFlag, 0xabababab, 0x80000000},
   1047                                     {VFlag, 0xabababab, 0x0000007d},
   1048                                     {NFlag, 0xabababab, 0xcccccccc},
   1049                                     {NCFlag, 0xabababab, 0x7fffffff},
   1050                                     {VFlag, 0xabababab, 0xffffff81},
   1051                                     {NCVFlag, 0xabababab, 0xffffffff},
   1052                                     {NZFlag, 0xabababab, 0xffff8002},
   1053                                     {NZVFlag, 0xabababab, 0x80000000},
   1054                                     {ZCVFlag, 0xabababab, 0x0000007f},
   1055                                     {ZFlag, 0xabababab, 0x0000007f},
   1056                                     {VFlag, 0xabababab, 0xffff8001},
   1057                                     {NVFlag, 0xabababab, 0x00000000},
   1058                                     {ZFlag, 0xabababab, 0x00007ffd},
   1059                                     {NCVFlag, 0xabababab, 0x80000001},
   1060                                     {NCVFlag, 0xabababab, 0xffff8002},
   1061                                     {NCFlag, 0xabababab, 0x7ffffffe},
   1062                                     {ZCFlag, 0xabababab, 0x7ffffffd},
   1063                                     {NZCFlag, 0xabababab, 0x80000001},
   1064                                     {ZCFlag, 0xabababab, 0x0000007f},
   1065                                     {VFlag, 0xabababab, 0x80000000},
   1066                                     {NCFlag, 0xabababab, 0x80000001},
   1067                                     {NVFlag, 0xabababab, 0xffffff81}};
   1068 
   1069 
   1070 // A loop will be generated for each element of this array.
   1071 const TestLoopData kTests[] = {{{ne, r2, r2, 45},
   1072                                 "ne r2 r2 45",
   1073                                 "RdIsRn_ne_r2_r2_45",
   1074                                 ARRAY_SIZE(kRdIsRn),
   1075                                 kRdIsRn},
   1076                                {{cs, r6, r6, 59},
   1077                                 "cs r6 r6 59",
   1078                                 "RdIsRn_cs_r6_r6_59",
   1079                                 ARRAY_SIZE(kRdIsRn),
   1080                                 kRdIsRn},
   1081                                {{mi, r6, r6, 211},
   1082                                 "mi r6 r6 211",
   1083                                 "RdIsRn_mi_r6_r6_211",
   1084                                 ARRAY_SIZE(kRdIsRn),
   1085                                 kRdIsRn},
   1086                                {{lt, r5, r5, 36},
   1087                                 "lt r5 r5 36",
   1088                                 "RdIsRn_lt_r5_r5_36",
   1089                                 ARRAY_SIZE(kRdIsRn),
   1090                                 kRdIsRn},
   1091                                {{cc, r7, r7, 7},
   1092                                 "cc r7 r7 7",
   1093                                 "RdIsRn_cc_r7_r7_7",
   1094                                 ARRAY_SIZE(kRdIsRn),
   1095                                 kRdIsRn},
   1096                                {{cs, r7, r7, 215},
   1097                                 "cs r7 r7 215",
   1098                                 "RdIsRn_cs_r7_r7_215",
   1099                                 ARRAY_SIZE(kRdIsRn),
   1100                                 kRdIsRn},
   1101                                {{pl, r6, r6, 54},
   1102                                 "pl r6 r6 54",
   1103                                 "RdIsRn_pl_r6_r6_54",
   1104                                 ARRAY_SIZE(kRdIsRn),
   1105                                 kRdIsRn},
   1106                                {{lt, r6, r6, 221},
   1107                                 "lt r6 r6 221",
   1108                                 "RdIsRn_lt_r6_r6_221",
   1109                                 ARRAY_SIZE(kRdIsRn),
   1110                                 kRdIsRn},
   1111                                {{ne, r2, r2, 40},
   1112                                 "ne r2 r2 40",
   1113                                 "RdIsRn_ne_r2_r2_40",
   1114                                 ARRAY_SIZE(kRdIsRn),
   1115                                 kRdIsRn},
   1116                                {{hi, r5, r5, 158},
   1117                                 "hi r5 r5 158",
   1118                                 "RdIsRn_hi_r5_r5_158",
   1119                                 ARRAY_SIZE(kRdIsRn),
   1120                                 kRdIsRn},
   1121                                {{cs, r0, r0, 18},
   1122                                 "cs r0 r0 18",
   1123                                 "RdIsRn_cs_r0_r0_18",
   1124                                 ARRAY_SIZE(kRdIsRn),
   1125                                 kRdIsRn},
   1126                                {{ne, r3, r3, 205},
   1127                                 "ne r3 r3 205",
   1128                                 "RdIsRn_ne_r3_r3_205",
   1129                                 ARRAY_SIZE(kRdIsRn),
   1130                                 kRdIsRn},
   1131                                {{vc, r0, r0, 97},
   1132                                 "vc r0 r0 97",
   1133                                 "RdIsRn_vc_r0_r0_97",
   1134                                 ARRAY_SIZE(kRdIsRn),
   1135                                 kRdIsRn},
   1136                                {{hi, r2, r2, 197},
   1137                                 "hi r2 r2 197",
   1138                                 "RdIsRn_hi_r2_r2_197",
   1139                                 ARRAY_SIZE(kRdIsRn),
   1140                                 kRdIsRn},
   1141                                {{cs, r0, r0, 248},
   1142                                 "cs r0 r0 248",
   1143                                 "RdIsRn_cs_r0_r0_248",
   1144                                 ARRAY_SIZE(kRdIsRn),
   1145                                 kRdIsRn},
   1146                                {{ne, r4, r4, 108},
   1147                                 "ne r4 r4 108",
   1148                                 "RdIsRn_ne_r4_r4_108",
   1149                                 ARRAY_SIZE(kRdIsRn),
   1150                                 kRdIsRn},
   1151                                {{vs, r3, r3, 73},
   1152                                 "vs r3 r3 73",
   1153                                 "RdIsRn_vs_r3_r3_73",
   1154                                 ARRAY_SIZE(kRdIsRn),
   1155                                 kRdIsRn},
   1156                                {{ne, r7, r7, 230},
   1157                                 "ne r7 r7 230",
   1158                                 "RdIsRn_ne_r7_r7_230",
   1159                                 ARRAY_SIZE(kRdIsRn),
   1160                                 kRdIsRn},
   1161                                {{eq, r0, r0, 100},
   1162                                 "eq r0 r0 100",
   1163                                 "RdIsRn_eq_r0_r0_100",
   1164                                 ARRAY_SIZE(kRdIsRn),
   1165                                 kRdIsRn},
   1166                                {{mi, r5, r5, 211},
   1167                                 "mi r5 r5 211",
   1168                                 "RdIsRn_mi_r5_r5_211",
   1169                                 ARRAY_SIZE(kRdIsRn),
   1170                                 kRdIsRn},
   1171                                {{ge, r2, r3, 225},
   1172                                 "ge r2 r3 225",
   1173                                 "RdIsNotRn_ge_r2_r3_225",
   1174                                 ARRAY_SIZE(kRdIsNotRn),
   1175                                 kRdIsNotRn},
   1176                                {{vs, r3, r1, 64},
   1177                                 "vs r3 r1 64",
   1178                                 "RdIsNotRn_vs_r3_r1_64",
   1179                                 ARRAY_SIZE(kRdIsNotRn),
   1180                                 kRdIsNotRn},
   1181                                {{vs, r0, r1, 93},
   1182                                 "vs r0 r1 93",
   1183                                 "RdIsNotRn_vs_r0_r1_93",
   1184                                 ARRAY_SIZE(kRdIsNotRn),
   1185                                 kRdIsNotRn},
   1186                                {{ne, r5, r1, 247},
   1187                                 "ne r5 r1 247",
   1188                                 "RdIsNotRn_ne_r5_r1_247",
   1189                                 ARRAY_SIZE(kRdIsNotRn),
   1190                                 kRdIsNotRn},
   1191                                {{vs, r1, r7, 9},
   1192                                 "vs r1 r7 9",
   1193                                 "RdIsNotRn_vs_r1_r7_9",
   1194                                 ARRAY_SIZE(kRdIsNotRn),
   1195                                 kRdIsNotRn},
   1196                                {{le, r0, r2, 201},
   1197                                 "le r0 r2 201",
   1198                                 "RdIsNotRn_le_r0_r2_201",
   1199                                 ARRAY_SIZE(kRdIsNotRn),
   1200                                 kRdIsNotRn},
   1201                                {{vs, r6, r0, 176},
   1202                                 "vs r6 r0 176",
   1203                                 "RdIsNotRn_vs_r6_r0_176",
   1204                                 ARRAY_SIZE(kRdIsNotRn),
   1205                                 kRdIsNotRn},
   1206                                {{vc, r0, r1, 248},
   1207                                 "vc r0 r1 248",
   1208                                 "RdIsNotRn_vc_r0_r1_248",
   1209                                 ARRAY_SIZE(kRdIsNotRn),
   1210                                 kRdIsNotRn},
   1211                                {{al, r7, r6, 64},
   1212                                 "al r7 r6 64",
   1213                                 "RdIsNotRn_al_r7_r6_64",
   1214                                 ARRAY_SIZE(kRdIsNotRn),
   1215                                 kRdIsNotRn},
   1216                                {{al, r5, r7, 175},
   1217                                 "al r5 r7 175",
   1218                                 "RdIsNotRn_al_r5_r7_175",
   1219                                 ARRAY_SIZE(kRdIsNotRn),
   1220                                 kRdIsNotRn},
   1221                                {{al, r0, r4, 182},
   1222                                 "al r0 r4 182",
   1223                                 "RdIsNotRn_al_r0_r4_182",
   1224                                 ARRAY_SIZE(kRdIsNotRn),
   1225                                 kRdIsNotRn},
   1226                                {{ls, r7, r5, 58},
   1227                                 "ls r7 r5 58",
   1228                                 "RdIsNotRn_ls_r7_r5_58",
   1229                                 ARRAY_SIZE(kRdIsNotRn),
   1230                                 kRdIsNotRn},
   1231                                {{vc, r0, r7, 205},
   1232                                 "vc r0 r7 205",
   1233                                 "RdIsNotRn_vc_r0_r7_205",
   1234                                 ARRAY_SIZE(kRdIsNotRn),
   1235                                 kRdIsNotRn},
   1236                                {{pl, r1, r3, 135},
   1237                                 "pl r1 r3 135",
   1238                                 "RdIsNotRn_pl_r1_r3_135",
   1239                                 ARRAY_SIZE(kRdIsNotRn),
   1240                                 kRdIsNotRn},
   1241                                {{gt, r4, r3, 253},
   1242                                 "gt r4 r3 253",
   1243                                 "RdIsNotRn_gt_r4_r3_253",
   1244                                 ARRAY_SIZE(kRdIsNotRn),
   1245                                 kRdIsNotRn},
   1246                                {{al, r1, r7, 32},
   1247                                 "al r1 r7 32",
   1248                                 "RdIsNotRn_al_r1_r7_32",
   1249                                 ARRAY_SIZE(kRdIsNotRn),
   1250                                 kRdIsNotRn},
   1251                                {{eq, r1, r7, 139},
   1252                                 "eq r1 r7 139",
   1253                                 "RdIsNotRn_eq_r1_r7_139",
   1254                                 ARRAY_SIZE(kRdIsNotRn),
   1255                                 kRdIsNotRn},
   1256                                {{lt, r0, r5, 248},
   1257                                 "lt r0 r5 248",
   1258                                 "RdIsNotRn_lt_r0_r5_248",
   1259                                 ARRAY_SIZE(kRdIsNotRn),
   1260                                 kRdIsNotRn},
   1261                                {{hi, r0, r6, 89},
   1262                                 "hi r0 r6 89",
   1263                                 "RdIsNotRn_hi_r0_r6_89",
   1264                                 ARRAY_SIZE(kRdIsNotRn),
   1265                                 kRdIsNotRn},
   1266                                {{cc, r3, r5, 210},
   1267                                 "cc r3 r5 210",
   1268                                 "RdIsNotRn_cc_r3_r5_210",
   1269                                 ARRAY_SIZE(kRdIsNotRn),
   1270                                 kRdIsNotRn},
   1271                                {{cs, r0, r0, 187},
   1272                                 "cs r0 r0 187",
   1273                                 "Immediate_cs_r0_r0_187",
   1274                                 ARRAY_SIZE(kImmediate),
   1275                                 kImmediate},
   1276                                {{hi, r0, r0, 236},
   1277                                 "hi r0 r0 236",
   1278                                 "Immediate_hi_r0_r0_236",
   1279                                 ARRAY_SIZE(kImmediate),
   1280                                 kImmediate},
   1281                                {{eq, r0, r0, 133},
   1282                                 "eq r0 r0 133",
   1283                                 "Immediate_eq_r0_r0_133",
   1284                                 ARRAY_SIZE(kImmediate),
   1285                                 kImmediate},
   1286                                {{mi, r0, r0, 193},
   1287                                 "mi r0 r0 193",
   1288                                 "Immediate_mi_r0_r0_193",
   1289                                 ARRAY_SIZE(kImmediate),
   1290                                 kImmediate},
   1291                                {{cc, r0, r0, 73},
   1292                                 "cc r0 r0 73",
   1293                                 "Immediate_cc_r0_r0_73",
   1294                                 ARRAY_SIZE(kImmediate),
   1295                                 kImmediate},
   1296                                {{cs, r0, r0, 93},
   1297                                 "cs r0 r0 93",
   1298                                 "Immediate_cs_r0_r0_93",
   1299                                 ARRAY_SIZE(kImmediate),
   1300                                 kImmediate},
   1301                                {{ne, r0, r0, 130},
   1302                                 "ne r0 r0 130",
   1303                                 "Immediate_ne_r0_r0_130",
   1304                                 ARRAY_SIZE(kImmediate),
   1305                                 kImmediate},
   1306                                {{ge, r0, r0, 209},
   1307                                 "ge r0 r0 209",
   1308                                 "Immediate_ge_r0_r0_209",
   1309                                 ARRAY_SIZE(kImmediate),
   1310                                 kImmediate},
   1311                                {{lt, r0, r0, 42},
   1312                                 "lt r0 r0 42",
   1313                                 "Immediate_lt_r0_r0_42",
   1314                                 ARRAY_SIZE(kImmediate),
   1315                                 kImmediate},
   1316                                {{cs, r0, r0, 177},
   1317                                 "cs r0 r0 177",
   1318                                 "Immediate_cs_r0_r0_177",
   1319                                 ARRAY_SIZE(kImmediate),
   1320                                 kImmediate},
   1321                                {{lt, r0, r0, 139},
   1322                                 "lt r0 r0 139",
   1323                                 "Immediate_lt_r0_r0_139",
   1324                                 ARRAY_SIZE(kImmediate),
   1325                                 kImmediate},
   1326                                {{mi, r0, r0, 43},
   1327                                 "mi r0 r0 43",
   1328                                 "Immediate_mi_r0_r0_43",
   1329                                 ARRAY_SIZE(kImmediate),
   1330                                 kImmediate},
   1331                                {{cs, r0, r0, 247},
   1332                                 "cs r0 r0 247",
   1333                                 "Immediate_cs_r0_r0_247",
   1334                                 ARRAY_SIZE(kImmediate),
   1335                                 kImmediate},
   1336                                {{ls, r0, r0, 170},
   1337                                 "ls r0 r0 170",
   1338                                 "Immediate_ls_r0_r0_170",
   1339                                 ARRAY_SIZE(kImmediate),
   1340                                 kImmediate},
   1341                                {{cs, r0, r0, 185},
   1342                                 "cs r0 r0 185",
   1343                                 "Immediate_cs_r0_r0_185",
   1344                                 ARRAY_SIZE(kImmediate),
   1345                                 kImmediate},
   1346                                {{ne, r0, r0, 246},
   1347                                 "ne r0 r0 246",
   1348                                 "Immediate_ne_r0_r0_246",
   1349                                 ARRAY_SIZE(kImmediate),
   1350                                 kImmediate},
   1351                                {{mi, r0, r0, 179},
   1352                                 "mi r0 r0 179",
   1353                                 "Immediate_mi_r0_r0_179",
   1354                                 ARRAY_SIZE(kImmediate),
   1355                                 kImmediate},
   1356                                {{pl, r0, r0, 7},
   1357                                 "pl r0 r0 7",
   1358                                 "Immediate_pl_r0_r0_7",
   1359                                 ARRAY_SIZE(kImmediate),
   1360                                 kImmediate},
   1361                                {{mi, r0, r0, 177},
   1362                                 "mi r0 r0 177",
   1363                                 "Immediate_mi_r0_r0_177",
   1364                                 ARRAY_SIZE(kImmediate),
   1365                                 kImmediate},
   1366                                {{gt, r0, r0, 175},
   1367                                 "gt r0 r0 175",
   1368                                 "Immediate_gt_r0_r0_175",
   1369                                 ARRAY_SIZE(kImmediate),
   1370                                 kImmediate}};
   1371 
   1372 // We record all inputs to the instructions as outputs. This way, we also check
   1373 // that what shouldn't change didn't change.
   1374 struct TestResult {
   1375   size_t output_size;
   1376   const Inputs* outputs;
   1377 };
   1378 
   1379 // These headers each contain an array of `TestResult` with the reference output
   1380 // values. The reference arrays are names `kReference{mnemonic}`.
   1381 #include "aarch32/traces/simulator-cond-rdlow-rnlow-operand-immediate-t32-add.h"
   1382 #include "aarch32/traces/simulator-cond-rdlow-rnlow-operand-immediate-t32-adds.h"
   1383 #include "aarch32/traces/simulator-cond-rdlow-rnlow-operand-immediate-t32-rsb.h"
   1384 #include "aarch32/traces/simulator-cond-rdlow-rnlow-operand-immediate-t32-rsbs.h"
   1385 #include "aarch32/traces/simulator-cond-rdlow-rnlow-operand-immediate-t32-sub.h"
   1386 #include "aarch32/traces/simulator-cond-rdlow-rnlow-operand-immediate-t32-subs.h"
   1387 
   1388 
   1389 // The maximum number of errors to report in detail for each test.
   1390 const unsigned kErrorReportLimit = 8;
   1391 
   1392 typedef void (MacroAssembler::*Fn)(Condition cond,
   1393                                    Register rd,
   1394                                    Register rn,
   1395                                    const Operand& op);
   1396 
   1397 void TestHelper(Fn instruction,
   1398                 const char* mnemonic,
   1399                 const TestResult reference[]) {
   1400   SETUP();
   1401   masm.UseT32();
   1402   START();
   1403 
   1404   // Data to compare to `reference`.
   1405   TestResult* results[ARRAY_SIZE(kTests)];
   1406 
   1407   // Test cases for memory bound instructions may allocate a buffer and save its
   1408   // address in this array.
   1409   byte* scratch_memory_buffers[ARRAY_SIZE(kTests)];
   1410 
   1411   // Generate a loop for each element in `kTests`. Each loop tests one specific
   1412   // instruction.
   1413   for (unsigned i = 0; i < ARRAY_SIZE(kTests); i++) {
   1414     // Allocate results on the heap for this test.
   1415     results[i] = new TestResult;
   1416     results[i]->outputs = new Inputs[kTests[i].input_size];
   1417     results[i]->output_size = kTests[i].input_size;
   1418 
   1419     size_t input_stride = sizeof(kTests[i].inputs[0]) * kTests[i].input_size;
   1420     VIXL_ASSERT(IsUint32(input_stride));
   1421 
   1422     scratch_memory_buffers[i] = NULL;
   1423 
   1424     Label loop;
   1425     UseScratchRegisterScope scratch_registers(&masm);
   1426     // Include all registers from r0 ro r12.
   1427     scratch_registers.Include(RegisterList(0x1fff));
   1428 
   1429     // Values to pass to the macro-assembler.
   1430     Condition cond = kTests[i].operands.cond;
   1431     Register rd = kTests[i].operands.rd;
   1432     Register rn = kTests[i].operands.rn;
   1433     int32_t immediate = kTests[i].operands.immediate;
   1434     Operand op(immediate);
   1435     scratch_registers.Exclude(rd);
   1436     scratch_registers.Exclude(rn);
   1437 
   1438     // Allocate reserved registers for our own use.
   1439     Register input_ptr = scratch_registers.Acquire();
   1440     Register input_end = scratch_registers.Acquire();
   1441     Register result_ptr = scratch_registers.Acquire();
   1442 
   1443     // Initialize `input_ptr` to the first element and `input_end` the address
   1444     // after the array.
   1445     __ Mov(input_ptr, Operand::From(kTests[i].inputs));
   1446     __ Add(input_end, input_ptr, static_cast<uint32_t>(input_stride));
   1447     __ Mov(result_ptr, Operand::From(results[i]->outputs));
   1448     __ Bind(&loop);
   1449 
   1450     {
   1451       UseScratchRegisterScope temp_registers(&masm);
   1452       Register nzcv_bits = temp_registers.Acquire();
   1453       Register saved_q_bit = temp_registers.Acquire();
   1454       // Save the `Q` bit flag.
   1455       __ Mrs(saved_q_bit, APSR);
   1456       __ And(saved_q_bit, saved_q_bit, QFlag);
   1457       // Set the `NZCV` and `Q` flags together.
   1458       __ Ldr(nzcv_bits, MemOperand(input_ptr, offsetof(Inputs, apsr)));
   1459       __ Orr(nzcv_bits, nzcv_bits, saved_q_bit);
   1460       __ Msr(APSR_nzcvq, nzcv_bits);
   1461     }
   1462     __ Ldr(rd, MemOperand(input_ptr, offsetof(Inputs, rd)));
   1463     __ Ldr(rn, MemOperand(input_ptr, offsetof(Inputs, rn)));
   1464 
   1465     (masm.*instruction)(cond, rd, rn, op);
   1466 
   1467     {
   1468       UseScratchRegisterScope temp_registers(&masm);
   1469       Register nzcv_bits = temp_registers.Acquire();
   1470       __ Mrs(nzcv_bits, APSR);
   1471       // Only record the NZCV bits.
   1472       __ And(nzcv_bits, nzcv_bits, NZCVFlag);
   1473       __ Str(nzcv_bits, MemOperand(result_ptr, offsetof(Inputs, apsr)));
   1474     }
   1475     __ Str(rd, MemOperand(result_ptr, offsetof(Inputs, rd)));
   1476     __ Str(rn, MemOperand(result_ptr, offsetof(Inputs, rn)));
   1477 
   1478     // Advance the result pointer.
   1479     __ Add(result_ptr, result_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
   1480     // Loop back until `input_ptr` is lower than `input_base`.
   1481     __ Add(input_ptr, input_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
   1482     __ Cmp(input_ptr, input_end);
   1483     __ B(ne, &loop);
   1484   }
   1485 
   1486   END();
   1487 
   1488   RUN();
   1489 
   1490   if (Test::generate_test_trace()) {
   1491     // Print the results.
   1492     for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
   1493       printf("const Inputs kOutputs_%s_%s[] = {\n",
   1494              mnemonic,
   1495              kTests[i].identifier);
   1496       for (size_t j = 0; j < results[i]->output_size; j++) {
   1497         printf("  { ");
   1498         printf("0x%08" PRIx32, results[i]->outputs[j].apsr);
   1499         printf(", ");
   1500         printf("0x%08" PRIx32, results[i]->outputs[j].rd);
   1501         printf(", ");
   1502         printf("0x%08" PRIx32, results[i]->outputs[j].rn);
   1503         printf(" },\n");
   1504       }
   1505       printf("};\n");
   1506     }
   1507     printf("const TestResult kReference%s[] = {\n", mnemonic);
   1508     for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
   1509       printf("  {\n");
   1510       printf("    ARRAY_SIZE(kOutputs_%s_%s),\n",
   1511              mnemonic,
   1512              kTests[i].identifier);
   1513       printf("    kOutputs_%s_%s,\n", mnemonic, kTests[i].identifier);
   1514       printf("  },\n");
   1515     }
   1516     printf("};\n");
   1517   } else if (kCheckSimulatorTestResults) {
   1518     // Check the results.
   1519     unsigned total_error_count = 0;
   1520     for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
   1521       bool instruction_has_errors = false;
   1522       for (size_t j = 0; j < kTests[i].input_size; j++) {
   1523         uint32_t apsr = results[i]->outputs[j].apsr;
   1524         uint32_t rd = results[i]->outputs[j].rd;
   1525         uint32_t rn = results[i]->outputs[j].rn;
   1526         uint32_t apsr_input = kTests[i].inputs[j].apsr;
   1527         uint32_t rd_input = kTests[i].inputs[j].rd;
   1528         uint32_t rn_input = kTests[i].inputs[j].rn;
   1529         uint32_t apsr_ref = reference[i].outputs[j].apsr;
   1530         uint32_t rd_ref = reference[i].outputs[j].rd;
   1531         uint32_t rn_ref = reference[i].outputs[j].rn;
   1532 
   1533         if (((apsr != apsr_ref) || (rd != rd_ref) || (rn != rn_ref)) &&
   1534             (++total_error_count <= kErrorReportLimit)) {
   1535           // Print the instruction once even if it triggered multiple failures.
   1536           if (!instruction_has_errors) {
   1537             printf("Error(s) when testing \"%s %s\":\n",
   1538                    mnemonic,
   1539                    kTests[i].operands_description);
   1540             instruction_has_errors = true;
   1541           }
   1542           // Print subsequent errors.
   1543           printf("  Input:    ");
   1544           printf("0x%08" PRIx32, apsr_input);
   1545           printf(", ");
   1546           printf("0x%08" PRIx32, rd_input);
   1547           printf(", ");
   1548           printf("0x%08" PRIx32, rn_input);
   1549           printf("\n");
   1550           printf("  Expected: ");
   1551           printf("0x%08" PRIx32, apsr_ref);
   1552           printf(", ");
   1553           printf("0x%08" PRIx32, rd_ref);
   1554           printf(", ");
   1555           printf("0x%08" PRIx32, rn_ref);
   1556           printf("\n");
   1557           printf("  Found:    ");
   1558           printf("0x%08" PRIx32, apsr);
   1559           printf(", ");
   1560           printf("0x%08" PRIx32, rd);
   1561           printf(", ");
   1562           printf("0x%08" PRIx32, rn);
   1563           printf("\n\n");
   1564         }
   1565       }
   1566     }
   1567 
   1568     if (total_error_count > kErrorReportLimit) {
   1569       printf("%u other errors follow.\n",
   1570              total_error_count - kErrorReportLimit);
   1571     }
   1572     VIXL_CHECK(total_error_count == 0);
   1573   } else {
   1574     VIXL_WARNING("Assembled the code, but did not run anything.\n");
   1575   }
   1576 
   1577   for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
   1578     delete[] results[i]->outputs;
   1579     delete results[i];
   1580     delete[] scratch_memory_buffers[i];
   1581   }
   1582 
   1583   TEARDOWN();
   1584 }
   1585 
   1586 // Instantiate tests for each instruction in the list.
   1587 // TODO: Remove this limitation by having a sandboxing mechanism.
   1588 #if defined(VIXL_HOST_POINTER_32)
   1589 #define TEST(mnemonic)                                                       \
   1590   void Test_##mnemonic() {                                                   \
   1591     TestHelper(&MacroAssembler::mnemonic, #mnemonic, kReference##mnemonic);  \
   1592   }                                                                          \
   1593   Test test_##mnemonic(                                                      \
   1594       "AARCH32_SIMULATOR_COND_RDLOW_RNLOW_OPERAND_IMMEDIATE_T32_" #mnemonic, \
   1595       &Test_##mnemonic);
   1596 #else
   1597 #define TEST(mnemonic)                                                       \
   1598   void Test_##mnemonic() {                                                   \
   1599     VIXL_WARNING("This test can only run on a 32-bit host.\n");              \
   1600     USE(TestHelper);                                                         \
   1601   }                                                                          \
   1602   Test test_##mnemonic(                                                      \
   1603       "AARCH32_SIMULATOR_COND_RDLOW_RNLOW_OPERAND_IMMEDIATE_T32_" #mnemonic, \
   1604       &Test_##mnemonic);
   1605 #endif
   1606 
   1607 FOREACH_INSTRUCTION(TEST)
   1608 #undef TEST
   1609 
   1610 }  // namespace
   1611 #endif
   1612 
   1613 }  // namespace aarch32
   1614 }  // namespace vixl
   1615