1b8021494Sopenharmony_ci// Copyright 2016, VIXL authors
2b8021494Sopenharmony_ci// All rights reserved.
3b8021494Sopenharmony_ci//
4b8021494Sopenharmony_ci// Redistribution and use in source and binary forms, with or without
5b8021494Sopenharmony_ci// modification, are permitted provided that the following conditions are met:
6b8021494Sopenharmony_ci//
7b8021494Sopenharmony_ci//   * Redistributions of source code must retain the above copyright notice,
8b8021494Sopenharmony_ci//     this list of conditions and the following disclaimer.
9b8021494Sopenharmony_ci//   * Redistributions in binary form must reproduce the above copyright notice,
10b8021494Sopenharmony_ci//     this list of conditions and the following disclaimer in the documentation
11b8021494Sopenharmony_ci//     and/or other materials provided with the distribution.
12b8021494Sopenharmony_ci//   * Neither the name of ARM Limited nor the names of its contributors may be
13b8021494Sopenharmony_ci//     used to endorse or promote products derived from this software without
14b8021494Sopenharmony_ci//     specific prior written permission.
15b8021494Sopenharmony_ci//
16b8021494Sopenharmony_ci// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
17b8021494Sopenharmony_ci// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18b8021494Sopenharmony_ci// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19b8021494Sopenharmony_ci// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20b8021494Sopenharmony_ci// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21b8021494Sopenharmony_ci// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22b8021494Sopenharmony_ci// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23b8021494Sopenharmony_ci// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24b8021494Sopenharmony_ci// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25b8021494Sopenharmony_ci// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26b8021494Sopenharmony_ci
27b8021494Sopenharmony_ci
28b8021494Sopenharmony_ci// -----------------------------------------------------------------------------
29b8021494Sopenharmony_ci// This file is auto generated from the
30b8021494Sopenharmony_ci// test/aarch32/config/template-simulator-aarch32.cc.in template file using
31b8021494Sopenharmony_ci// tools/generate_tests.py.
32b8021494Sopenharmony_ci//
33b8021494Sopenharmony_ci// PLEASE DO NOT EDIT.
34b8021494Sopenharmony_ci// -----------------------------------------------------------------------------
35b8021494Sopenharmony_ci
36b8021494Sopenharmony_ci
37b8021494Sopenharmony_ci#include "test-runner.h"
38b8021494Sopenharmony_ci
39b8021494Sopenharmony_ci#include "test-utils.h"
40b8021494Sopenharmony_ci#include "test-utils-aarch32.h"
41b8021494Sopenharmony_ci
42b8021494Sopenharmony_ci#include "aarch32/assembler-aarch32.h"
43b8021494Sopenharmony_ci#include "aarch32/disasm-aarch32.h"
44b8021494Sopenharmony_ci#include "aarch32/macro-assembler-aarch32.h"
45b8021494Sopenharmony_ci
46b8021494Sopenharmony_ci#define __ masm.
47b8021494Sopenharmony_ci#define BUF_SIZE (4096)
48b8021494Sopenharmony_ci
49b8021494Sopenharmony_ci#ifdef VIXL_INCLUDE_SIMULATOR_AARCH32
50b8021494Sopenharmony_ci// Run tests with the simulator.
51b8021494Sopenharmony_ci
52b8021494Sopenharmony_ci#define SETUP() MacroAssembler masm(BUF_SIZE)
53b8021494Sopenharmony_ci
54b8021494Sopenharmony_ci#define START() masm.GetBuffer()->Reset()
55b8021494Sopenharmony_ci
56b8021494Sopenharmony_ci#define END() \
57b8021494Sopenharmony_ci  __ Hlt(0);  \
58b8021494Sopenharmony_ci  __ FinalizeCode();
59b8021494Sopenharmony_ci
60b8021494Sopenharmony_ci// TODO: Run the tests in the simulator.
61b8021494Sopenharmony_ci#define RUN()
62b8021494Sopenharmony_ci
63b8021494Sopenharmony_ci#else  // ifdef VIXL_INCLUDE_SIMULATOR_AARCH32.
64b8021494Sopenharmony_ci
65b8021494Sopenharmony_ci#define SETUP()                  \
66b8021494Sopenharmony_ci  MacroAssembler masm(BUF_SIZE); \
67b8021494Sopenharmony_ci  UseScratchRegisterScope harness_scratch;
68b8021494Sopenharmony_ci
69b8021494Sopenharmony_ci#define START()                 \
70b8021494Sopenharmony_ci  harness_scratch.Open(&masm);  \
71b8021494Sopenharmony_ci  harness_scratch.ExcludeAll(); \
72b8021494Sopenharmony_ci  masm.GetBuffer()->Reset();    \
73b8021494Sopenharmony_ci  __ Push(r4);                  \
74b8021494Sopenharmony_ci  __ Push(r5);                  \
75b8021494Sopenharmony_ci  __ Push(r6);                  \
76b8021494Sopenharmony_ci  __ Push(r7);                  \
77b8021494Sopenharmony_ci  __ Push(r8);                  \
78b8021494Sopenharmony_ci  __ Push(r9);                  \
79b8021494Sopenharmony_ci  __ Push(r10);                 \
80b8021494Sopenharmony_ci  __ Push(r11);                 \
81b8021494Sopenharmony_ci  __ Push(lr);                  \
82b8021494Sopenharmony_ci  harness_scratch.Include(ip);
83b8021494Sopenharmony_ci
84b8021494Sopenharmony_ci#define END()                  \
85b8021494Sopenharmony_ci  harness_scratch.Exclude(ip); \
86b8021494Sopenharmony_ci  __ Pop(lr);                  \
87b8021494Sopenharmony_ci  __ Pop(r11);                 \
88b8021494Sopenharmony_ci  __ Pop(r10);                 \
89b8021494Sopenharmony_ci  __ Pop(r9);                  \
90b8021494Sopenharmony_ci  __ Pop(r8);                  \
91b8021494Sopenharmony_ci  __ Pop(r7);                  \
92b8021494Sopenharmony_ci  __ Pop(r6);                  \
93b8021494Sopenharmony_ci  __ Pop(r5);                  \
94b8021494Sopenharmony_ci  __ Pop(r4);                  \
95b8021494Sopenharmony_ci  __ Bx(lr);                   \
96b8021494Sopenharmony_ci  __ FinalizeCode();           \
97b8021494Sopenharmony_ci  harness_scratch.Close();
98b8021494Sopenharmony_ci
99b8021494Sopenharmony_ci#define RUN()                                                 \
100b8021494Sopenharmony_ci  {                                                           \
101b8021494Sopenharmony_ci    int pcs_offset = masm.IsUsingT32() ? 1 : 0;               \
102b8021494Sopenharmony_ci    masm.GetBuffer()->SetExecutable();                        \
103b8021494Sopenharmony_ci    ExecuteMemory(masm.GetBuffer()->GetStartAddress<byte*>(), \
104b8021494Sopenharmony_ci                  masm.GetSizeOfCodeGenerated(),              \
105b8021494Sopenharmony_ci                  pcs_offset);                                \
106b8021494Sopenharmony_ci    masm.GetBuffer()->SetWritable();                          \
107b8021494Sopenharmony_ci  }
108b8021494Sopenharmony_ci
109b8021494Sopenharmony_ci#endif  // ifdef VIXL_INCLUDE_SIMULATOR_AARCH32
110b8021494Sopenharmony_ci
111b8021494Sopenharmony_cinamespace vixl {
112b8021494Sopenharmony_cinamespace aarch32 {
113b8021494Sopenharmony_ci
114b8021494Sopenharmony_ci// List of instruction encodings:
115b8021494Sopenharmony_ci#define FOREACH_INSTRUCTION(M) \
116b8021494Sopenharmony_ci  M(Crc32b)                    \
117b8021494Sopenharmony_ci  M(Crc32cb)                   \
118b8021494Sopenharmony_ci  M(Crc32ch)                   \
119b8021494Sopenharmony_ci  M(Crc32cw)                   \
120b8021494Sopenharmony_ci  M(Crc32h)                    \
121b8021494Sopenharmony_ci  M(Crc32w)
122b8021494Sopenharmony_ci
123b8021494Sopenharmony_ci
124b8021494Sopenharmony_ci// The following definitions are defined again in each generated test, therefore
125b8021494Sopenharmony_ci// we need to place them in an anonymous namespace. It expresses that they are
126b8021494Sopenharmony_ci// local to this file only, and the compiler is not allowed to share these types
127b8021494Sopenharmony_ci// across test files during template instantiation. Specifically, `Operands` and
128b8021494Sopenharmony_ci// `Inputs` have various layouts across generated tests so they absolutely
129b8021494Sopenharmony_ci// cannot be shared.
130b8021494Sopenharmony_ci
131b8021494Sopenharmony_ci#ifdef VIXL_INCLUDE_TARGET_A32
132b8021494Sopenharmony_cinamespace {
133b8021494Sopenharmony_ci
134b8021494Sopenharmony_ci// Values to be passed to the assembler to produce the instruction under test.
135b8021494Sopenharmony_cistruct Operands {
136b8021494Sopenharmony_ci  Register rd;
137b8021494Sopenharmony_ci  Register rn;
138b8021494Sopenharmony_ci  Register rm;
139b8021494Sopenharmony_ci};
140b8021494Sopenharmony_ci
141b8021494Sopenharmony_ci// Input data to feed to the instruction.
142b8021494Sopenharmony_cistruct Inputs {
143b8021494Sopenharmony_ci  uint32_t rd;
144b8021494Sopenharmony_ci  uint32_t rn;
145b8021494Sopenharmony_ci  uint32_t rm;
146b8021494Sopenharmony_ci};
147b8021494Sopenharmony_ci
148b8021494Sopenharmony_ci// This structure contains all input data needed to test one specific encoding.
149b8021494Sopenharmony_ci// It used to generate a loop over an instruction.
150b8021494Sopenharmony_cistruct TestLoopData {
151b8021494Sopenharmony_ci  // The `operands` fields represents the values to pass to the assembler to
152b8021494Sopenharmony_ci  // produce the instruction.
153b8021494Sopenharmony_ci  Operands operands;
154b8021494Sopenharmony_ci  // Description of the operands, used for error reporting.
155b8021494Sopenharmony_ci  const char* operands_description;
156b8021494Sopenharmony_ci  // Unique identifier, used for generating traces.
157b8021494Sopenharmony_ci  const char* identifier;
158b8021494Sopenharmony_ci  // Array of values to be fed to the instruction.
159b8021494Sopenharmony_ci  size_t input_size;
160b8021494Sopenharmony_ci  const Inputs* inputs;
161b8021494Sopenharmony_ci};
162b8021494Sopenharmony_ci
163b8021494Sopenharmony_cistatic const Inputs kRnIsRm[] = {
164b8021494Sopenharmony_ci    {0xffffffe0, 0x00007fff, 0x00007fff}, {0xaaaaaaaa, 0x00007fff, 0x00007fff},
165b8021494Sopenharmony_ci    {0xffffff82, 0x7ffffffe, 0x7ffffffe}, {0x7ffffffd, 0x33333333, 0x33333333},
166b8021494Sopenharmony_ci    {0x00007ffd, 0x00000002, 0x00000002}, {0xffffff80, 0xfffffffd, 0xfffffffd},
167b8021494Sopenharmony_ci    {0xffffff82, 0x33333333, 0x33333333}, {0xcccccccc, 0xffff8002, 0xffff8002},
168b8021494Sopenharmony_ci    {0x55555555, 0xffffffe0, 0xffffffe0}, {0x00007fff, 0xffffffff, 0xffffffff},
169b8021494Sopenharmony_ci    {0x55555555, 0x33333333, 0x33333333}, {0x7ffffffd, 0xffff8002, 0xffff8002},
170b8021494Sopenharmony_ci    {0x00000020, 0xffffff83, 0xffffff83}, {0x0000007e, 0x00007fff, 0x00007fff},
171b8021494Sopenharmony_ci    {0xfffffffe, 0xffffff82, 0xffffff82}, {0xffffff82, 0x00007fff, 0x00007fff},
172b8021494Sopenharmony_ci    {0xffffff82, 0xfffffffd, 0xfffffffd}, {0x80000000, 0x7fffffff, 0x7fffffff},
173b8021494Sopenharmony_ci    {0x55555555, 0x00000002, 0x00000002}, {0xfffffffe, 0xffffff80, 0xffffff80},
174b8021494Sopenharmony_ci    {0xfffffffe, 0x00000002, 0x00000002}, {0xfffffffe, 0x00000020, 0x00000020},
175b8021494Sopenharmony_ci    {0xfffffffe, 0x00007ffd, 0x00007ffd}, {0x0000007f, 0x33333333, 0x33333333},
176b8021494Sopenharmony_ci    {0xfffffffd, 0xfffffffe, 0xfffffffe}, {0x80000001, 0x7ffffffd, 0x7ffffffd},
177b8021494Sopenharmony_ci    {0x7ffffffe, 0xffffff83, 0xffffff83}, {0xffffffe0, 0x00000002, 0x00000002},
178b8021494Sopenharmony_ci    {0x00007ffe, 0xffffff83, 0xffffff83}, {0xffffff82, 0xffffff80, 0xffffff80},
179b8021494Sopenharmony_ci    {0x0000007e, 0x33333333, 0x33333333}, {0xffff8001, 0xfffffffe, 0xfffffffe},
180b8021494Sopenharmony_ci    {0xfffffffe, 0xffffff81, 0xffffff81}, {0x00000001, 0xffffff83, 0xffffff83},
181b8021494Sopenharmony_ci    {0xfffffffe, 0xaaaaaaaa, 0xaaaaaaaa}, {0xcccccccc, 0xffffff80, 0xffffff80},
182b8021494Sopenharmony_ci    {0xffffff83, 0x0000007f, 0x0000007f}, {0x00007ffd, 0x00000020, 0x00000020},
183b8021494Sopenharmony_ci    {0x0000007d, 0xfffffffd, 0xfffffffd}, {0x7ffffffe, 0xaaaaaaaa, 0xaaaaaaaa},
184b8021494Sopenharmony_ci    {0xffffff83, 0x00000001, 0x00000001}, {0x0000007d, 0xffff8000, 0xffff8000},
185b8021494Sopenharmony_ci    {0xffffffe0, 0x00000020, 0x00000020}, {0xffff8003, 0xffffff80, 0xffffff80},
186b8021494Sopenharmony_ci    {0x00000000, 0xaaaaaaaa, 0xaaaaaaaa}, {0x00007fff, 0x00000020, 0x00000020},
187b8021494Sopenharmony_ci    {0x80000000, 0x0000007d, 0x0000007d}, {0xffffff81, 0x0000007e, 0x0000007e},
188b8021494Sopenharmony_ci    {0xcccccccc, 0x00000020, 0x00000020}, {0xffffff81, 0x33333333, 0x33333333},
189b8021494Sopenharmony_ci    {0xffff8002, 0xffffffe0, 0xffffffe0}, {0xffffffe0, 0x00007ffe, 0x00007ffe},
190b8021494Sopenharmony_ci    {0xffff8002, 0xaaaaaaaa, 0xaaaaaaaa}, {0xffff8001, 0x00007ffe, 0x00007ffe},
191b8021494Sopenharmony_ci    {0x80000000, 0xcccccccc, 0xcccccccc}, {0x7ffffffd, 0x00000002, 0x00000002},
192b8021494Sopenharmony_ci    {0xcccccccc, 0x0000007f, 0x0000007f}, {0x7ffffffe, 0xffffff82, 0xffffff82},
193b8021494Sopenharmony_ci    {0x00000001, 0x0000007e, 0x0000007e}, {0x00007ffd, 0x00007ffe, 0x00007ffe},
194b8021494Sopenharmony_ci    {0x7ffffffd, 0xfffffffe, 0xfffffffe}, {0x00000001, 0x80000001, 0x80000001},
195b8021494Sopenharmony_ci    {0x00007ffe, 0x7fffffff, 0x7fffffff}, {0xffff8001, 0xffff8002, 0xffff8002},
196b8021494Sopenharmony_ci    {0x00000001, 0xffff8003, 0xffff8003}, {0x00000002, 0xfffffffe, 0xfffffffe},
197b8021494Sopenharmony_ci    {0x00000002, 0x00007ffd, 0x00007ffd}, {0x7ffffffe, 0xfffffffd, 0xfffffffd},
198b8021494Sopenharmony_ci    {0xffff8001, 0x7ffffffd, 0x7ffffffd}, {0x7ffffffd, 0x55555555, 0x55555555},
199b8021494Sopenharmony_ci    {0x80000000, 0xffffff80, 0xffffff80}, {0xffff8002, 0xffff8003, 0xffff8003},
200b8021494Sopenharmony_ci    {0xffffffff, 0x00000020, 0x00000020}, {0xfffffffe, 0x00000001, 0x00000001},
201b8021494Sopenharmony_ci    {0x00007fff, 0x00007fff, 0x00007fff}, {0x00000000, 0xffffff83, 0xffffff83},
202b8021494Sopenharmony_ci    {0x33333333, 0xaaaaaaaa, 0xaaaaaaaa}, {0x0000007d, 0x7ffffffe, 0x7ffffffe},
203b8021494Sopenharmony_ci    {0xffff8003, 0xffff8001, 0xffff8001}, {0xfffffffd, 0xcccccccc, 0xcccccccc},
204b8021494Sopenharmony_ci    {0x80000000, 0x80000001, 0x80000001}, {0xffff8002, 0x00000002, 0x00000002},
205b8021494Sopenharmony_ci    {0xfffffffd, 0xffffffe0, 0xffffffe0}, {0xffffffe0, 0xffffff82, 0xffffff82},
206b8021494Sopenharmony_ci    {0x33333333, 0x00007ffe, 0x00007ffe}, {0xffff8002, 0xffffff80, 0xffffff80},
207b8021494Sopenharmony_ci    {0xffffff81, 0x80000000, 0x80000000}, {0x00000000, 0x80000000, 0x80000000},
208b8021494Sopenharmony_ci    {0x00000000, 0xcccccccc, 0xcccccccc}, {0x00000020, 0xffffffe0, 0xffffffe0},
209b8021494Sopenharmony_ci    {0x00007ffe, 0xffffffe0, 0xffffffe0}, {0xffffff81, 0xfffffffe, 0xfffffffe},
210b8021494Sopenharmony_ci    {0x00000002, 0x00007ffe, 0x00007ffe}, {0xffff8000, 0x7fffffff, 0x7fffffff},
211b8021494Sopenharmony_ci    {0x00000002, 0x55555555, 0x55555555}, {0xffff8000, 0x55555555, 0x55555555},
212b8021494Sopenharmony_ci    {0xffff8001, 0x00000020, 0x00000020}, {0xffffffff, 0x55555555, 0x55555555},
213b8021494Sopenharmony_ci    {0x33333333, 0x00000020, 0x00000020}, {0xfffffffd, 0x7fffffff, 0x7fffffff},
214b8021494Sopenharmony_ci    {0x7ffffffd, 0x7fffffff, 0x7fffffff}, {0xaaaaaaaa, 0xffffff81, 0xffffff81},
215b8021494Sopenharmony_ci    {0x00007ffd, 0x80000001, 0x80000001}, {0x7ffffffe, 0xffffffff, 0xffffffff},
216b8021494Sopenharmony_ci    {0x00007ffe, 0x7ffffffe, 0x7ffffffe}, {0xffff8001, 0x55555555, 0x55555555},
217b8021494Sopenharmony_ci    {0xffffff80, 0xfffffffe, 0xfffffffe}, {0x0000007e, 0x7ffffffd, 0x7ffffffd},
218b8021494Sopenharmony_ci    {0x00000000, 0x00007ffd, 0x00007ffd}, {0x00000020, 0x80000001, 0x80000001},
219b8021494Sopenharmony_ci    {0xffffff83, 0xffffffe0, 0xffffffe0}, {0x55555555, 0xffff8000, 0xffff8000},
220b8021494Sopenharmony_ci    {0x33333333, 0xffff8002, 0xffff8002}, {0x7ffffffd, 0x0000007f, 0x0000007f},
221b8021494Sopenharmony_ci    {0x00000002, 0xffffff82, 0xffffff82}, {0xfffffffe, 0xcccccccc, 0xcccccccc},
222b8021494Sopenharmony_ci    {0x33333333, 0xffffff82, 0xffffff82}, {0x7ffffffd, 0x00007ffd, 0x00007ffd},
223b8021494Sopenharmony_ci    {0x00000002, 0xffffff80, 0xffffff80}, {0xffff8001, 0x00000000, 0x00000000},
224b8021494Sopenharmony_ci    {0x7ffffffe, 0x0000007d, 0x0000007d}, {0x00000001, 0x00000020, 0x00000020},
225b8021494Sopenharmony_ci    {0xaaaaaaaa, 0xffffff82, 0xffffff82}, {0x00000001, 0xfffffffd, 0xfffffffd},
226b8021494Sopenharmony_ci    {0x80000001, 0xfffffffe, 0xfffffffe}, {0xffffff80, 0x80000000, 0x80000000},
227b8021494Sopenharmony_ci    {0x80000000, 0xffffffff, 0xffffffff}, {0x00000001, 0x00000001, 0x00000001},
228b8021494Sopenharmony_ci    {0x80000001, 0xffff8003, 0xffff8003}, {0xffffffff, 0xffffff83, 0xffffff83},
229b8021494Sopenharmony_ci    {0x00007ffe, 0x00007ffe, 0x00007ffe}, {0x7ffffffd, 0xcccccccc, 0xcccccccc},
230b8021494Sopenharmony_ci    {0xffff8003, 0xcccccccc, 0xcccccccc}, {0xcccccccc, 0x00007fff, 0x00007fff},
231b8021494Sopenharmony_ci    {0x00000002, 0x7ffffffd, 0x7ffffffd}, {0x00000002, 0xffff8002, 0xffff8002},
232b8021494Sopenharmony_ci    {0xffffff80, 0x33333333, 0x33333333}, {0x55555555, 0xffffff82, 0xffffff82},
233b8021494Sopenharmony_ci    {0x7fffffff, 0x00007fff, 0x00007fff}, {0x33333333, 0x00000001, 0x00000001},
234b8021494Sopenharmony_ci    {0x33333333, 0xffffffe0, 0xffffffe0}, {0xffffff83, 0x0000007e, 0x0000007e},
235b8021494Sopenharmony_ci    {0x00000002, 0xffff8001, 0xffff8001}, {0xcccccccc, 0xffffffe0, 0xffffffe0},
236b8021494Sopenharmony_ci    {0xffff8000, 0x7ffffffe, 0x7ffffffe}, {0x00007ffe, 0xffffff81, 0xffffff81},
237b8021494Sopenharmony_ci    {0x7ffffffd, 0xffffffe0, 0xffffffe0}, {0x00007fff, 0xffffff81, 0xffffff81},
238b8021494Sopenharmony_ci    {0xffffffff, 0x00007ffd, 0x00007ffd}, {0x00007fff, 0x80000001, 0x80000001},
239b8021494Sopenharmony_ci    {0xffffffff, 0xcccccccc, 0xcccccccc}, {0x00007ffd, 0x0000007d, 0x0000007d},
240b8021494Sopenharmony_ci    {0x0000007e, 0x00000000, 0x00000000}, {0x0000007f, 0x7ffffffe, 0x7ffffffe},
241b8021494Sopenharmony_ci    {0x00000020, 0xffffff82, 0xffffff82}, {0xcccccccc, 0x80000001, 0x80000001},
242b8021494Sopenharmony_ci    {0xffff8002, 0x00007ffd, 0x00007ffd}, {0xffff8000, 0x00000001, 0x00000001},
243b8021494Sopenharmony_ci    {0xffffff83, 0xffffff83, 0xffffff83}, {0x00000002, 0xffffffe0, 0xffffffe0},
244b8021494Sopenharmony_ci    {0xfffffffe, 0xffff8000, 0xffff8000}, {0x7ffffffe, 0xffffff80, 0xffffff80},
245b8021494Sopenharmony_ci    {0x0000007f, 0xffffff81, 0xffffff81}, {0xffffffff, 0x0000007f, 0x0000007f},
246b8021494Sopenharmony_ci    {0x7ffffffe, 0x0000007e, 0x0000007e}, {0x80000000, 0xfffffffd, 0xfffffffd},
247b8021494Sopenharmony_ci    {0x33333333, 0x0000007d, 0x0000007d}, {0x80000001, 0xcccccccc, 0xcccccccc},
248b8021494Sopenharmony_ci    {0xaaaaaaaa, 0x7ffffffd, 0x7ffffffd}, {0x7fffffff, 0x0000007f, 0x0000007f},
249b8021494Sopenharmony_ci    {0x0000007e, 0xffff8001, 0xffff8001}, {0x0000007d, 0xaaaaaaaa, 0xaaaaaaaa},
250b8021494Sopenharmony_ci    {0xffffff82, 0x55555555, 0x55555555}, {0x55555555, 0xffffff81, 0xffffff81},
251b8021494Sopenharmony_ci    {0xcccccccc, 0xffffff82, 0xffffff82}, {0x0000007d, 0x0000007d, 0x0000007d},
252b8021494Sopenharmony_ci    {0xfffffffd, 0xfffffffd, 0xfffffffd}, {0xffffff82, 0xffff8002, 0xffff8002},
253b8021494Sopenharmony_ci    {0xffffffe0, 0x00000001, 0x00000001}, {0x0000007d, 0x00007ffe, 0x00007ffe},
254b8021494Sopenharmony_ci    {0xfffffffe, 0xffff8003, 0xffff8003}, {0x00000001, 0xffff8001, 0xffff8001},
255b8021494Sopenharmony_ci    {0xffff8003, 0x00007ffe, 0x00007ffe}, {0x7ffffffd, 0x00000020, 0x00000020},
256b8021494Sopenharmony_ci    {0xfffffffd, 0x00007ffe, 0x00007ffe}, {0x7fffffff, 0xfffffffd, 0xfffffffd},
257b8021494Sopenharmony_ci    {0x7fffffff, 0xffff8001, 0xffff8001}, {0xffff8003, 0xffffffff, 0xffffffff},
258b8021494Sopenharmony_ci    {0x0000007d, 0x33333333, 0x33333333}, {0xffffffff, 0x00000000, 0x00000000},
259b8021494Sopenharmony_ci    {0xffffffe0, 0xffffff81, 0xffffff81}, {0xffffffe0, 0xffffffff, 0xffffffff},
260b8021494Sopenharmony_ci    {0x00007ffd, 0x00007ffd, 0x00007ffd}, {0x00000002, 0x33333333, 0x33333333},
261b8021494Sopenharmony_ci    {0x0000007f, 0x00000002, 0x00000002}, {0xffff8000, 0x0000007e, 0x0000007e},
262b8021494Sopenharmony_ci    {0x80000000, 0x00007fff, 0x00007fff}, {0xffff8000, 0xfffffffd, 0xfffffffd},
263b8021494Sopenharmony_ci    {0xffff8002, 0xcccccccc, 0xcccccccc}, {0xffff8003, 0xffffff82, 0xffffff82}};
264b8021494Sopenharmony_ci
265b8021494Sopenharmony_cistatic const Inputs kRnIsNotRm[] = {
266b8021494Sopenharmony_ci    {0x00007ffe, 0x00007ffe, 0x80000000}, {0x80000001, 0xcccccccc, 0x00000001},
267b8021494Sopenharmony_ci    {0x0000007d, 0x00000020, 0xcccccccc}, {0x7ffffffd, 0x55555555, 0x0000007f},
268b8021494Sopenharmony_ci    {0x00000020, 0xffff8001, 0x80000001}, {0xffffffe0, 0xffffff81, 0xffffff83},
269b8021494Sopenharmony_ci    {0x00000002, 0xffffff80, 0xaaaaaaaa}, {0x00000002, 0x00000001, 0x0000007d},
270b8021494Sopenharmony_ci    {0xffffff83, 0x00007ffd, 0x00000002}, {0xffff8000, 0x00000020, 0x55555555},
271b8021494Sopenharmony_ci    {0x00007ffd, 0x0000007f, 0x7ffffffd}, {0xfffffffd, 0x80000000, 0x00000000},
272b8021494Sopenharmony_ci    {0x0000007f, 0x33333333, 0x7fffffff}, {0x00000000, 0x33333333, 0x55555555},
273b8021494Sopenharmony_ci    {0xffffff81, 0x00007fff, 0xaaaaaaaa}, {0x33333333, 0x00000000, 0x7ffffffe},
274b8021494Sopenharmony_ci    {0xfffffffe, 0x00000001, 0xffffffff}, {0xaaaaaaaa, 0xffffffe0, 0xffffff80},
275b8021494Sopenharmony_ci    {0x33333333, 0xffffffe0, 0x7fffffff}, {0x55555555, 0x7ffffffd, 0xffffff81},
276b8021494Sopenharmony_ci    {0xaaaaaaaa, 0xffffffe0, 0x0000007f}, {0x00007fff, 0xfffffffd, 0xcccccccc},
277b8021494Sopenharmony_ci    {0x7fffffff, 0xffff8002, 0x00000001}, {0x0000007d, 0x00000002, 0x7fffffff},
278b8021494Sopenharmony_ci    {0x00000002, 0x55555555, 0x00007ffe}, {0x00007ffd, 0x0000007d, 0xfffffffe},
279b8021494Sopenharmony_ci    {0x7ffffffd, 0x55555555, 0xffffff83}, {0x7ffffffe, 0x80000001, 0x00000001},
280b8021494Sopenharmony_ci    {0xfffffffd, 0x80000001, 0x80000000}, {0xffff8002, 0x00000000, 0x80000001},
281b8021494Sopenharmony_ci    {0x0000007d, 0x00000020, 0x0000007e}, {0x00000020, 0x0000007f, 0x80000001},
282b8021494Sopenharmony_ci    {0x7ffffffe, 0x80000001, 0xffff8002}, {0xffffff81, 0xffffff80, 0xffffff81},
283b8021494Sopenharmony_ci    {0x7ffffffe, 0xffffff80, 0x0000007d}, {0x00007ffd, 0x00000000, 0x55555555},
284b8021494Sopenharmony_ci    {0xcccccccc, 0xcccccccc, 0x7ffffffe}, {0xffff8002, 0x00000001, 0xffff8000},
285b8021494Sopenharmony_ci    {0x00007ffe, 0x0000007d, 0xffffffe0}, {0x00007ffd, 0x7ffffffe, 0xffffffe0},
286b8021494Sopenharmony_ci    {0x80000001, 0x7ffffffe, 0xffff8001}, {0x55555555, 0xffffff80, 0xffff8003},
287b8021494Sopenharmony_ci    {0xfffffffd, 0xffff8002, 0x55555555}, {0x33333333, 0xffff8000, 0xffff8003},
288b8021494Sopenharmony_ci    {0x7ffffffd, 0xffff8002, 0x0000007e}, {0x7fffffff, 0xffffff80, 0xfffffffd},
289b8021494Sopenharmony_ci    {0xffff8002, 0x00000001, 0xaaaaaaaa}, {0xffffff83, 0xffff8001, 0x33333333},
290b8021494Sopenharmony_ci    {0x00000000, 0xfffffffe, 0x0000007e}, {0x80000000, 0xffffffe0, 0x0000007d},
291b8021494Sopenharmony_ci    {0xffff8000, 0x33333333, 0x00000002}, {0xfffffffe, 0x00000002, 0xffffffe0},
292b8021494Sopenharmony_ci    {0x00007ffd, 0x0000007e, 0x7ffffffe}, {0xffffff81, 0xffffffff, 0x00000000},
293b8021494Sopenharmony_ci    {0x0000007e, 0x7ffffffe, 0x33333333}, {0x00000002, 0x80000001, 0xffffff80},
294b8021494Sopenharmony_ci    {0x7ffffffd, 0xffffff82, 0x7ffffffe}, {0xffffff81, 0x0000007e, 0xffffff81},
295b8021494Sopenharmony_ci    {0xffff8002, 0x00007fff, 0x0000007f}, {0xcccccccc, 0xcccccccc, 0x0000007d},
296b8021494Sopenharmony_ci    {0x7ffffffd, 0xffffff80, 0x00007ffe}, {0x55555555, 0x55555555, 0xfffffffe},
297b8021494Sopenharmony_ci    {0x00000001, 0x00000020, 0x00000001}, {0x0000007f, 0x7ffffffd, 0x80000001},
298b8021494Sopenharmony_ci    {0x55555555, 0xaaaaaaaa, 0xfffffffd}, {0x00000020, 0x00007fff, 0xffffff81},
299b8021494Sopenharmony_ci    {0xffffff80, 0x33333333, 0xffffff81}, {0x00000000, 0xffff8001, 0xffffff83},
300b8021494Sopenharmony_ci    {0x0000007e, 0x33333333, 0x7ffffffd}, {0xaaaaaaaa, 0x55555555, 0xffffffff},
301b8021494Sopenharmony_ci    {0xfffffffd, 0xffff8000, 0x00000000}, {0xffff8000, 0xfffffffe, 0x7fffffff},
302b8021494Sopenharmony_ci    {0xffff8001, 0xcccccccc, 0x33333333}, {0x00007ffd, 0xffff8001, 0x0000007f},
303b8021494Sopenharmony_ci    {0xffffff83, 0x7ffffffd, 0x7fffffff}, {0xffffff81, 0xffffffe0, 0x00007fff},
304b8021494Sopenharmony_ci    {0xffffffff, 0x00000002, 0xffffff82}, {0xffff8001, 0xffffff81, 0x55555555},
305b8021494Sopenharmony_ci    {0x00007fff, 0xffffff83, 0x00007ffe}, {0x00007fff, 0xcccccccc, 0x00000020},
306b8021494Sopenharmony_ci    {0x7fffffff, 0x7ffffffd, 0xffff8000}, {0x0000007f, 0x80000000, 0x7ffffffd},
307b8021494Sopenharmony_ci    {0x0000007e, 0x0000007e, 0x0000007d}, {0xfffffffe, 0x00000020, 0xffffff80},
308b8021494Sopenharmony_ci    {0x00007ffd, 0x00007ffe, 0xffffff82}, {0x00000020, 0x80000000, 0x0000007e},
309b8021494Sopenharmony_ci    {0x00000020, 0x00000002, 0xffffffff}, {0x00007fff, 0xffff8000, 0x00007fff},
310b8021494Sopenharmony_ci    {0xcccccccc, 0x7ffffffd, 0x80000000}, {0xffffff80, 0x00000002, 0xffffff81},
311b8021494Sopenharmony_ci    {0xfffffffe, 0xffffff83, 0x33333333}, {0xffff8000, 0x7ffffffe, 0x55555555},
312b8021494Sopenharmony_ci    {0x00007fff, 0x0000007e, 0xffffff81}, {0xaaaaaaaa, 0xcccccccc, 0xffffffe0},
313b8021494Sopenharmony_ci    {0x7ffffffd, 0xffffffff, 0xffff8003}, {0xffffff81, 0xffff8002, 0xffffff82},
314b8021494Sopenharmony_ci    {0x00000002, 0xffffffe0, 0x80000001}, {0x7ffffffe, 0x33333333, 0xaaaaaaaa},
315b8021494Sopenharmony_ci    {0x00007fff, 0x00000020, 0xfffffffe}, {0xcccccccc, 0xfffffffe, 0x00000000},
316b8021494Sopenharmony_ci    {0x7ffffffe, 0x80000001, 0xfffffffd}, {0xffffffe0, 0x00000000, 0xaaaaaaaa},
317b8021494Sopenharmony_ci    {0x80000000, 0xffffff83, 0xffff8000}, {0xffffff81, 0xfffffffe, 0xffffff83},
318b8021494Sopenharmony_ci    {0x80000000, 0x0000007e, 0xffff8002}, {0x80000001, 0x00000020, 0x00007ffe},
319b8021494Sopenharmony_ci    {0x00000000, 0x00000020, 0x0000007e}, {0x80000001, 0xffffffff, 0x7ffffffe},
320b8021494Sopenharmony_ci    {0xffffff83, 0x33333333, 0x00000001}, {0x00000020, 0xffffff80, 0xffffff81},
321b8021494Sopenharmony_ci    {0xcccccccc, 0xffff8000, 0x00007ffd}, {0xffff8003, 0x00000000, 0x0000007f},
322b8021494Sopenharmony_ci    {0xffff8003, 0x00000001, 0x0000007d}, {0x0000007e, 0x00000020, 0x55555555},
323b8021494Sopenharmony_ci    {0xffffffff, 0xfffffffe, 0xffffff83}, {0xffffff80, 0x80000000, 0xfffffffe},
324b8021494Sopenharmony_ci    {0x0000007e, 0x0000007e, 0x00000000}, {0xaaaaaaaa, 0x00000002, 0xffffffe0},
325b8021494Sopenharmony_ci    {0xffff8001, 0x00007ffe, 0x00000020}, {0x7ffffffe, 0xffff8000, 0x00007ffe},
326b8021494Sopenharmony_ci    {0xffffff80, 0x33333333, 0x00007fff}, {0x33333333, 0xffffff81, 0x00000001},
327b8021494Sopenharmony_ci    {0x00000000, 0x33333333, 0x00000020}, {0x00007fff, 0x00000020, 0x0000007e},
328b8021494Sopenharmony_ci    {0xcccccccc, 0x55555555, 0xffffffe0}, {0xffffff80, 0x0000007e, 0x33333333},
329b8021494Sopenharmony_ci    {0x0000007e, 0xffff8002, 0x00000000}, {0xffffff83, 0xffffffe0, 0xfffffffd},
330b8021494Sopenharmony_ci    {0x00000001, 0x0000007f, 0xffff8001}, {0xffffffff, 0x00000020, 0xcccccccc},
331b8021494Sopenharmony_ci    {0x7ffffffd, 0xfffffffd, 0xffff8000}, {0xffffffff, 0x80000000, 0x00007fff},
332b8021494Sopenharmony_ci    {0x00000020, 0xffffffe0, 0xfffffffd}, {0x55555555, 0xffff8002, 0x0000007f},
333b8021494Sopenharmony_ci    {0xffff8002, 0x55555555, 0x0000007f}, {0xffff8003, 0xffff8000, 0x0000007d},
334b8021494Sopenharmony_ci    {0x00007fff, 0x00007ffe, 0x00000000}, {0xcccccccc, 0xffffff81, 0x00007fff},
335b8021494Sopenharmony_ci    {0x7ffffffd, 0xcccccccc, 0xffff8000}, {0x7ffffffe, 0xffff8001, 0x80000000},
336b8021494Sopenharmony_ci    {0x0000007f, 0xffffffe0, 0x80000001}, {0xffff8000, 0x00007ffd, 0xffff8003},
337b8021494Sopenharmony_ci    {0xffff8001, 0xffffff80, 0x00000001}, {0x33333333, 0x00000000, 0x80000000},
338b8021494Sopenharmony_ci    {0xfffffffe, 0x7ffffffd, 0x80000001}, {0x00000000, 0xffffffe0, 0x80000001},
339b8021494Sopenharmony_ci    {0xffff8002, 0x7ffffffe, 0x33333333}, {0xffffffe0, 0x0000007e, 0x00000001},
340b8021494Sopenharmony_ci    {0xffffff80, 0xffffffe0, 0x00007ffe}, {0xffff8000, 0x0000007f, 0x80000001},
341b8021494Sopenharmony_ci    {0xffffff80, 0xffffff80, 0xffff8002}, {0x7fffffff, 0x0000007f, 0xfffffffd},
342b8021494Sopenharmony_ci    {0x00000001, 0xffffffe0, 0xffffffff}, {0x55555555, 0x0000007f, 0xffff8002},
343b8021494Sopenharmony_ci    {0xffff8001, 0xfffffffd, 0x00000020}, {0x00007ffd, 0xfffffffd, 0x0000007e},
344b8021494Sopenharmony_ci    {0xfffffffd, 0xffff8003, 0x55555555}, {0xfffffffe, 0xffffff80, 0x0000007f},
345b8021494Sopenharmony_ci    {0x0000007f, 0x0000007f, 0xfffffffe}, {0x33333333, 0x55555555, 0xffff8003},
346b8021494Sopenharmony_ci    {0x0000007d, 0x00000020, 0x55555555}, {0xffff8003, 0x33333333, 0xffffff83},
347b8021494Sopenharmony_ci    {0xffffffe0, 0x00007fff, 0xffffff80}, {0x00000020, 0x00000001, 0x0000007d},
348b8021494Sopenharmony_ci    {0xffffff83, 0x00007fff, 0xaaaaaaaa}, {0xfffffffd, 0xffffff83, 0x55555555},
349b8021494Sopenharmony_ci    {0xffff8002, 0x00007fff, 0xffffffe0}, {0x80000001, 0xffffff82, 0x00007ffd},
350b8021494Sopenharmony_ci    {0xffff8000, 0x00000002, 0xffffffe0}, {0xfffffffd, 0xffffff80, 0x7ffffffe},
351b8021494Sopenharmony_ci    {0xffffffff, 0xaaaaaaaa, 0xffff8000}, {0x7ffffffd, 0x00000002, 0xffff8002},
352b8021494Sopenharmony_ci    {0xffff8001, 0x00007ffe, 0xffffffff}, {0xffff8001, 0x00000001, 0x00000000},
353b8021494Sopenharmony_ci    {0x80000001, 0xffffff80, 0x7ffffffd}, {0xffffff80, 0x0000007d, 0xffffff81},
354b8021494Sopenharmony_ci    {0xffffff81, 0xcccccccc, 0xffffff81}, {0xaaaaaaaa, 0x00000000, 0xffffff81},
355b8021494Sopenharmony_ci    {0x00000002, 0x00000020, 0xffffff81}, {0x7ffffffd, 0x7ffffffe, 0xffffff83},
356b8021494Sopenharmony_ci    {0x7fffffff, 0x55555555, 0x0000007f}, {0xfffffffd, 0xffffff82, 0xfffffffd},
357b8021494Sopenharmony_ci    {0x00000020, 0x00007ffd, 0xffffff81}, {0x0000007e, 0xffffff83, 0x33333333},
358b8021494Sopenharmony_ci    {0xffffff83, 0x00007fff, 0x00000002}, {0xffffffe0, 0xffffff80, 0xffff8001},
359b8021494Sopenharmony_ci    {0x00000000, 0x00000000, 0x00000002}, {0xfffffffd, 0x7ffffffe, 0x00000001},
360b8021494Sopenharmony_ci    {0xfffffffd, 0xfffffffd, 0xffffff80}, {0xffffff83, 0x00000000, 0x00007ffe},
361b8021494Sopenharmony_ci    {0xffff8002, 0xcccccccc, 0x33333333}, {0xffffff80, 0xffffff81, 0x0000007d},
362b8021494Sopenharmony_ci    {0x0000007e, 0xffff8000, 0x00007ffe}, {0x0000007e, 0x80000000, 0x80000001},
363b8021494Sopenharmony_ci    {0xffffff83, 0x00007fff, 0xffffffe0}, {0xcccccccc, 0x00007fff, 0xffffff80},
364b8021494Sopenharmony_ci    {0x0000007f, 0x0000007e, 0xfffffffd}, {0xcccccccc, 0xffffffff, 0x00000001},
365b8021494Sopenharmony_ci    {0xffffffff, 0xffff8000, 0xffffff82}, {0xfffffffe, 0x00000002, 0xffffffff}};
366b8021494Sopenharmony_ci
367b8021494Sopenharmony_ci
368b8021494Sopenharmony_ci// A loop will be generated for each element of this array.
369b8021494Sopenharmony_ciconst TestLoopData kTests[] = {
370b8021494Sopenharmony_ci    {{r9, r8, r8}, "r9 r8 r8", "RnIsRm_r9_r8_r8", ARRAY_SIZE(kRnIsRm), kRnIsRm},
371b8021494Sopenharmony_ci    {{r6, r11, r11},
372b8021494Sopenharmony_ci     "r6 r11 r11",
373b8021494Sopenharmony_ci     "RnIsRm_r6_r11_r11",
374b8021494Sopenharmony_ci     ARRAY_SIZE(kRnIsRm),
375b8021494Sopenharmony_ci     kRnIsRm},
376b8021494Sopenharmony_ci    {{r3, r12, r12},
377b8021494Sopenharmony_ci     "r3 r12 r12",
378b8021494Sopenharmony_ci     "RnIsRm_r3_r12_r12",
379b8021494Sopenharmony_ci     ARRAY_SIZE(kRnIsRm),
380b8021494Sopenharmony_ci     kRnIsRm},
381b8021494Sopenharmony_ci    {{r14, r3, r3},
382b8021494Sopenharmony_ci     "r14 r3 r3",
383b8021494Sopenharmony_ci     "RnIsRm_r14_r3_r3",
384b8021494Sopenharmony_ci     ARRAY_SIZE(kRnIsRm),
385b8021494Sopenharmony_ci     kRnIsRm},
386b8021494Sopenharmony_ci    {{r10, r4, r4},
387b8021494Sopenharmony_ci     "r10 r4 r4",
388b8021494Sopenharmony_ci     "RnIsRm_r10_r4_r4",
389b8021494Sopenharmony_ci     ARRAY_SIZE(kRnIsRm),
390b8021494Sopenharmony_ci     kRnIsRm},
391b8021494Sopenharmony_ci    {{r6, r8, r8}, "r6 r8 r8", "RnIsRm_r6_r8_r8", ARRAY_SIZE(kRnIsRm), kRnIsRm},
392b8021494Sopenharmony_ci    {{r5, r7, r7}, "r5 r7 r7", "RnIsRm_r5_r7_r7", ARRAY_SIZE(kRnIsRm), kRnIsRm},
393b8021494Sopenharmony_ci    {{r6, r3, r3}, "r6 r3 r3", "RnIsRm_r6_r3_r3", ARRAY_SIZE(kRnIsRm), kRnIsRm},
394b8021494Sopenharmony_ci    {{r7, r0, r0}, "r7 r0 r0", "RnIsRm_r7_r0_r0", ARRAY_SIZE(kRnIsRm), kRnIsRm},
395b8021494Sopenharmony_ci    {{r2, r1, r1}, "r2 r1 r1", "RnIsRm_r2_r1_r1", ARRAY_SIZE(kRnIsRm), kRnIsRm},
396b8021494Sopenharmony_ci    {{r5, r3, r14},
397b8021494Sopenharmony_ci     "r5 r3 r14",
398b8021494Sopenharmony_ci     "RnIsNotRm_r5_r3_r14",
399b8021494Sopenharmony_ci     ARRAY_SIZE(kRnIsNotRm),
400b8021494Sopenharmony_ci     kRnIsNotRm},
401b8021494Sopenharmony_ci    {{r10, r8, r3},
402b8021494Sopenharmony_ci     "r10 r8 r3",
403b8021494Sopenharmony_ci     "RnIsNotRm_r10_r8_r3",
404b8021494Sopenharmony_ci     ARRAY_SIZE(kRnIsNotRm),
405b8021494Sopenharmony_ci     kRnIsNotRm},
406b8021494Sopenharmony_ci    {{r2, r8, r11},
407b8021494Sopenharmony_ci     "r2 r8 r11",
408b8021494Sopenharmony_ci     "RnIsNotRm_r2_r8_r11",
409b8021494Sopenharmony_ci     ARRAY_SIZE(kRnIsNotRm),
410b8021494Sopenharmony_ci     kRnIsNotRm},
411b8021494Sopenharmony_ci    {{r7, r12, r7},
412b8021494Sopenharmony_ci     "r7 r12 r7",
413b8021494Sopenharmony_ci     "RnIsNotRm_r7_r12_r7",
414b8021494Sopenharmony_ci     ARRAY_SIZE(kRnIsNotRm),
415b8021494Sopenharmony_ci     kRnIsNotRm},
416b8021494Sopenharmony_ci    {{r2, r4, r10},
417b8021494Sopenharmony_ci     "r2 r4 r10",
418b8021494Sopenharmony_ci     "RnIsNotRm_r2_r4_r10",
419b8021494Sopenharmony_ci     ARRAY_SIZE(kRnIsNotRm),
420b8021494Sopenharmony_ci     kRnIsNotRm},
421b8021494Sopenharmony_ci    {{r1, r10, r8},
422b8021494Sopenharmony_ci     "r1 r10 r8",
423b8021494Sopenharmony_ci     "RnIsNotRm_r1_r10_r8",
424b8021494Sopenharmony_ci     ARRAY_SIZE(kRnIsNotRm),
425b8021494Sopenharmony_ci     kRnIsNotRm},
426b8021494Sopenharmony_ci    {{r1, r4, r2},
427b8021494Sopenharmony_ci     "r1 r4 r2",
428b8021494Sopenharmony_ci     "RnIsNotRm_r1_r4_r2",
429b8021494Sopenharmony_ci     ARRAY_SIZE(kRnIsNotRm),
430b8021494Sopenharmony_ci     kRnIsNotRm},
431b8021494Sopenharmony_ci    {{r12, r2, r12},
432b8021494Sopenharmony_ci     "r12 r2 r12",
433b8021494Sopenharmony_ci     "RnIsNotRm_r12_r2_r12",
434b8021494Sopenharmony_ci     ARRAY_SIZE(kRnIsNotRm),
435b8021494Sopenharmony_ci     kRnIsNotRm},
436b8021494Sopenharmony_ci    {{r4, r8, r5},
437b8021494Sopenharmony_ci     "r4 r8 r5",
438b8021494Sopenharmony_ci     "RnIsNotRm_r4_r8_r5",
439b8021494Sopenharmony_ci     ARRAY_SIZE(kRnIsNotRm),
440b8021494Sopenharmony_ci     kRnIsNotRm},
441b8021494Sopenharmony_ci    {{r4, r0, r9},
442b8021494Sopenharmony_ci     "r4 r0 r9",
443b8021494Sopenharmony_ci     "RnIsNotRm_r4_r0_r9",
444b8021494Sopenharmony_ci     ARRAY_SIZE(kRnIsNotRm),
445b8021494Sopenharmony_ci     kRnIsNotRm}};
446b8021494Sopenharmony_ci
447b8021494Sopenharmony_ci// We record all inputs to the instructions as outputs. This way, we also check
448b8021494Sopenharmony_ci// that what shouldn't change didn't change.
449b8021494Sopenharmony_cistruct TestResult {
450b8021494Sopenharmony_ci  size_t output_size;
451b8021494Sopenharmony_ci  const Inputs* outputs;
452b8021494Sopenharmony_ci};
453b8021494Sopenharmony_ci
454b8021494Sopenharmony_ci// These headers each contain an array of `TestResult` with the reference output
455b8021494Sopenharmony_ci// values. The reference arrays are names `kReference{mnemonic}`.
456b8021494Sopenharmony_ci#include "aarch32/traces/simulator-rd-rn-rm-crc32b-a32.h"
457b8021494Sopenharmony_ci#include "aarch32/traces/simulator-rd-rn-rm-crc32cb-a32.h"
458b8021494Sopenharmony_ci#include "aarch32/traces/simulator-rd-rn-rm-crc32ch-a32.h"
459b8021494Sopenharmony_ci#include "aarch32/traces/simulator-rd-rn-rm-crc32cw-a32.h"
460b8021494Sopenharmony_ci#include "aarch32/traces/simulator-rd-rn-rm-crc32h-a32.h"
461b8021494Sopenharmony_ci#include "aarch32/traces/simulator-rd-rn-rm-crc32w-a32.h"
462b8021494Sopenharmony_ci
463b8021494Sopenharmony_ci
464b8021494Sopenharmony_ci// The maximum number of errors to report in detail for each test.
465b8021494Sopenharmony_ciconst unsigned kErrorReportLimit = 8;
466b8021494Sopenharmony_ci
467b8021494Sopenharmony_citypedef void (MacroAssembler::*Fn)(Register rd, Register rn, Register rm);
468b8021494Sopenharmony_ci
469b8021494Sopenharmony_civoid TestHelper(Fn instruction,
470b8021494Sopenharmony_ci                const char* mnemonic,
471b8021494Sopenharmony_ci                const TestResult reference[]) {
472b8021494Sopenharmony_ci  SETUP();
473b8021494Sopenharmony_ci  masm.UseA32();
474b8021494Sopenharmony_ci  START();
475b8021494Sopenharmony_ci
476b8021494Sopenharmony_ci  // Data to compare to `reference`.
477b8021494Sopenharmony_ci  TestResult* results[ARRAY_SIZE(kTests)];
478b8021494Sopenharmony_ci
479b8021494Sopenharmony_ci  // Test cases for memory bound instructions may allocate a buffer and save its
480b8021494Sopenharmony_ci  // address in this array.
481b8021494Sopenharmony_ci  byte* scratch_memory_buffers[ARRAY_SIZE(kTests)];
482b8021494Sopenharmony_ci
483b8021494Sopenharmony_ci  // Generate a loop for each element in `kTests`. Each loop tests one specific
484b8021494Sopenharmony_ci  // instruction.
485b8021494Sopenharmony_ci  for (unsigned i = 0; i < ARRAY_SIZE(kTests); i++) {
486b8021494Sopenharmony_ci    // Allocate results on the heap for this test.
487b8021494Sopenharmony_ci    results[i] = new TestResult;
488b8021494Sopenharmony_ci    results[i]->outputs = new Inputs[kTests[i].input_size];
489b8021494Sopenharmony_ci    results[i]->output_size = kTests[i].input_size;
490b8021494Sopenharmony_ci
491b8021494Sopenharmony_ci    size_t input_stride = sizeof(kTests[i].inputs[0]) * kTests[i].input_size;
492b8021494Sopenharmony_ci    VIXL_ASSERT(IsUint32(input_stride));
493b8021494Sopenharmony_ci
494b8021494Sopenharmony_ci    scratch_memory_buffers[i] = NULL;
495b8021494Sopenharmony_ci
496b8021494Sopenharmony_ci    Label loop;
497b8021494Sopenharmony_ci    UseScratchRegisterScope scratch_registers(&masm);
498b8021494Sopenharmony_ci    // Include all registers from r0 ro r12.
499b8021494Sopenharmony_ci    scratch_registers.Include(RegisterList(0x1fff));
500b8021494Sopenharmony_ci
501b8021494Sopenharmony_ci    // Values to pass to the macro-assembler.
502b8021494Sopenharmony_ci    Register rd = kTests[i].operands.rd;
503b8021494Sopenharmony_ci    Register rn = kTests[i].operands.rn;
504b8021494Sopenharmony_ci    Register rm = kTests[i].operands.rm;
505b8021494Sopenharmony_ci    scratch_registers.Exclude(rd);
506b8021494Sopenharmony_ci    scratch_registers.Exclude(rn);
507b8021494Sopenharmony_ci    scratch_registers.Exclude(rm);
508b8021494Sopenharmony_ci
509b8021494Sopenharmony_ci    // Allocate reserved registers for our own use.
510b8021494Sopenharmony_ci    Register input_ptr = scratch_registers.Acquire();
511b8021494Sopenharmony_ci    Register input_end = scratch_registers.Acquire();
512b8021494Sopenharmony_ci    Register result_ptr = scratch_registers.Acquire();
513b8021494Sopenharmony_ci
514b8021494Sopenharmony_ci    // Initialize `input_ptr` to the first element and `input_end` the address
515b8021494Sopenharmony_ci    // after the array.
516b8021494Sopenharmony_ci    __ Mov(input_ptr, Operand::From(kTests[i].inputs));
517b8021494Sopenharmony_ci    __ Add(input_end, input_ptr, static_cast<uint32_t>(input_stride));
518b8021494Sopenharmony_ci    __ Mov(result_ptr, Operand::From(results[i]->outputs));
519b8021494Sopenharmony_ci    __ Bind(&loop);
520b8021494Sopenharmony_ci
521b8021494Sopenharmony_ci    __ Ldr(rd, MemOperand(input_ptr, offsetof(Inputs, rd)));
522b8021494Sopenharmony_ci    __ Ldr(rn, MemOperand(input_ptr, offsetof(Inputs, rn)));
523b8021494Sopenharmony_ci    __ Ldr(rm, MemOperand(input_ptr, offsetof(Inputs, rm)));
524b8021494Sopenharmony_ci
525b8021494Sopenharmony_ci    (masm.*instruction)(rd, rn, rm);
526b8021494Sopenharmony_ci
527b8021494Sopenharmony_ci    __ Str(rd, MemOperand(result_ptr, offsetof(Inputs, rd)));
528b8021494Sopenharmony_ci    __ Str(rn, MemOperand(result_ptr, offsetof(Inputs, rn)));
529b8021494Sopenharmony_ci    __ Str(rm, MemOperand(result_ptr, offsetof(Inputs, rm)));
530b8021494Sopenharmony_ci
531b8021494Sopenharmony_ci    // Advance the result pointer.
532b8021494Sopenharmony_ci    __ Add(result_ptr, result_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
533b8021494Sopenharmony_ci    // Loop back until `input_ptr` is lower than `input_base`.
534b8021494Sopenharmony_ci    __ Add(input_ptr, input_ptr, Operand::From(sizeof(kTests[i].inputs[0])));
535b8021494Sopenharmony_ci    __ Cmp(input_ptr, input_end);
536b8021494Sopenharmony_ci    __ B(ne, &loop);
537b8021494Sopenharmony_ci  }
538b8021494Sopenharmony_ci
539b8021494Sopenharmony_ci  END();
540b8021494Sopenharmony_ci
541b8021494Sopenharmony_ci  RUN();
542b8021494Sopenharmony_ci
543b8021494Sopenharmony_ci  if (Test::generate_test_trace()) {
544b8021494Sopenharmony_ci    // Print the results.
545b8021494Sopenharmony_ci    for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
546b8021494Sopenharmony_ci      printf("const Inputs kOutputs_%s_%s[] = {\n",
547b8021494Sopenharmony_ci             mnemonic,
548b8021494Sopenharmony_ci             kTests[i].identifier);
549b8021494Sopenharmony_ci      for (size_t j = 0; j < results[i]->output_size; j++) {
550b8021494Sopenharmony_ci        printf("  { ");
551b8021494Sopenharmony_ci        printf("0x%08" PRIx32, results[i]->outputs[j].rd);
552b8021494Sopenharmony_ci        printf(", ");
553b8021494Sopenharmony_ci        printf("0x%08" PRIx32, results[i]->outputs[j].rn);
554b8021494Sopenharmony_ci        printf(", ");
555b8021494Sopenharmony_ci        printf("0x%08" PRIx32, results[i]->outputs[j].rm);
556b8021494Sopenharmony_ci        printf(" },\n");
557b8021494Sopenharmony_ci      }
558b8021494Sopenharmony_ci      printf("};\n");
559b8021494Sopenharmony_ci    }
560b8021494Sopenharmony_ci    printf("const TestResult kReference%s[] = {\n", mnemonic);
561b8021494Sopenharmony_ci    for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
562b8021494Sopenharmony_ci      printf("  {\n");
563b8021494Sopenharmony_ci      printf("    ARRAY_SIZE(kOutputs_%s_%s),\n",
564b8021494Sopenharmony_ci             mnemonic,
565b8021494Sopenharmony_ci             kTests[i].identifier);
566b8021494Sopenharmony_ci      printf("    kOutputs_%s_%s,\n", mnemonic, kTests[i].identifier);
567b8021494Sopenharmony_ci      printf("  },\n");
568b8021494Sopenharmony_ci    }
569b8021494Sopenharmony_ci    printf("};\n");
570b8021494Sopenharmony_ci  } else if (kCheckSimulatorTestResults) {
571b8021494Sopenharmony_ci    // Check the results.
572b8021494Sopenharmony_ci    unsigned total_error_count = 0;
573b8021494Sopenharmony_ci    for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
574b8021494Sopenharmony_ci      bool instruction_has_errors = false;
575b8021494Sopenharmony_ci      for (size_t j = 0; j < kTests[i].input_size; j++) {
576b8021494Sopenharmony_ci        uint32_t rd = results[i]->outputs[j].rd;
577b8021494Sopenharmony_ci        uint32_t rn = results[i]->outputs[j].rn;
578b8021494Sopenharmony_ci        uint32_t rm = results[i]->outputs[j].rm;
579b8021494Sopenharmony_ci        uint32_t rd_input = kTests[i].inputs[j].rd;
580b8021494Sopenharmony_ci        uint32_t rn_input = kTests[i].inputs[j].rn;
581b8021494Sopenharmony_ci        uint32_t rm_input = kTests[i].inputs[j].rm;
582b8021494Sopenharmony_ci        uint32_t rd_ref = reference[i].outputs[j].rd;
583b8021494Sopenharmony_ci        uint32_t rn_ref = reference[i].outputs[j].rn;
584b8021494Sopenharmony_ci        uint32_t rm_ref = reference[i].outputs[j].rm;
585b8021494Sopenharmony_ci
586b8021494Sopenharmony_ci        if (((rd != rd_ref) || (rn != rn_ref) || (rm != rm_ref)) &&
587b8021494Sopenharmony_ci            (++total_error_count <= kErrorReportLimit)) {
588b8021494Sopenharmony_ci          // Print the instruction once even if it triggered multiple failures.
589b8021494Sopenharmony_ci          if (!instruction_has_errors) {
590b8021494Sopenharmony_ci            printf("Error(s) when testing \"%s %s\":\n",
591b8021494Sopenharmony_ci                   mnemonic,
592b8021494Sopenharmony_ci                   kTests[i].operands_description);
593b8021494Sopenharmony_ci            instruction_has_errors = true;
594b8021494Sopenharmony_ci          }
595b8021494Sopenharmony_ci          // Print subsequent errors.
596b8021494Sopenharmony_ci          printf("  Input:    ");
597b8021494Sopenharmony_ci          printf("0x%08" PRIx32, rd_input);
598b8021494Sopenharmony_ci          printf(", ");
599b8021494Sopenharmony_ci          printf("0x%08" PRIx32, rn_input);
600b8021494Sopenharmony_ci          printf(", ");
601b8021494Sopenharmony_ci          printf("0x%08" PRIx32, rm_input);
602b8021494Sopenharmony_ci          printf("\n");
603b8021494Sopenharmony_ci          printf("  Expected: ");
604b8021494Sopenharmony_ci          printf("0x%08" PRIx32, rd_ref);
605b8021494Sopenharmony_ci          printf(", ");
606b8021494Sopenharmony_ci          printf("0x%08" PRIx32, rn_ref);
607b8021494Sopenharmony_ci          printf(", ");
608b8021494Sopenharmony_ci          printf("0x%08" PRIx32, rm_ref);
609b8021494Sopenharmony_ci          printf("\n");
610b8021494Sopenharmony_ci          printf("  Found:    ");
611b8021494Sopenharmony_ci          printf("0x%08" PRIx32, rd);
612b8021494Sopenharmony_ci          printf(", ");
613b8021494Sopenharmony_ci          printf("0x%08" PRIx32, rn);
614b8021494Sopenharmony_ci          printf(", ");
615b8021494Sopenharmony_ci          printf("0x%08" PRIx32, rm);
616b8021494Sopenharmony_ci          printf("\n\n");
617b8021494Sopenharmony_ci        }
618b8021494Sopenharmony_ci      }
619b8021494Sopenharmony_ci    }
620b8021494Sopenharmony_ci
621b8021494Sopenharmony_ci    if (total_error_count > kErrorReportLimit) {
622b8021494Sopenharmony_ci      printf("%u other errors follow.\n",
623b8021494Sopenharmony_ci             total_error_count - kErrorReportLimit);
624b8021494Sopenharmony_ci    }
625b8021494Sopenharmony_ci    VIXL_CHECK(total_error_count == 0);
626b8021494Sopenharmony_ci  } else {
627b8021494Sopenharmony_ci    VIXL_WARNING("Assembled the code, but did not run anything.\n");
628b8021494Sopenharmony_ci  }
629b8021494Sopenharmony_ci
630b8021494Sopenharmony_ci  for (size_t i = 0; i < ARRAY_SIZE(kTests); i++) {
631b8021494Sopenharmony_ci    delete[] results[i]->outputs;
632b8021494Sopenharmony_ci    delete results[i];
633b8021494Sopenharmony_ci    delete[] scratch_memory_buffers[i];
634b8021494Sopenharmony_ci  }
635b8021494Sopenharmony_ci}
636b8021494Sopenharmony_ci
637b8021494Sopenharmony_ci// Instantiate tests for each instruction in the list.
638b8021494Sopenharmony_ci// TODO: Remove this limitation by having a sandboxing mechanism.
639b8021494Sopenharmony_ci#if defined(VIXL_HOST_POINTER_32)
640b8021494Sopenharmony_ci#define TEST(mnemonic)                                                      \
641b8021494Sopenharmony_ci  void Test_##mnemonic() {                                                  \
642b8021494Sopenharmony_ci    TestHelper(&MacroAssembler::mnemonic, #mnemonic, kReference##mnemonic); \
643b8021494Sopenharmony_ci  }                                                                         \
644b8021494Sopenharmony_ci  Test test_##mnemonic("AARCH32_SIMULATOR_RD_RN_RM_" #mnemonic "_A32",      \
645b8021494Sopenharmony_ci                       &Test_##mnemonic);
646b8021494Sopenharmony_ci#else
647b8021494Sopenharmony_ci#define TEST(mnemonic)                                                 \
648b8021494Sopenharmony_ci  void Test_##mnemonic() {                                             \
649b8021494Sopenharmony_ci    VIXL_WARNING("This test can only run on a 32-bit host.\n");        \
650b8021494Sopenharmony_ci    USE(TestHelper);                                                   \
651b8021494Sopenharmony_ci  }                                                                    \
652b8021494Sopenharmony_ci  Test test_##mnemonic("AARCH32_SIMULATOR_RD_RN_RM_" #mnemonic "_A32", \
653b8021494Sopenharmony_ci                       &Test_##mnemonic);
654b8021494Sopenharmony_ci#endif
655b8021494Sopenharmony_ci
656b8021494Sopenharmony_ciFOREACH_INSTRUCTION(TEST)
657b8021494Sopenharmony_ci#undef TEST
658b8021494Sopenharmony_ci
659b8021494Sopenharmony_ci}  // namespace
660b8021494Sopenharmony_ci#endif
661b8021494Sopenharmony_ci
662b8021494Sopenharmony_ci}  // namespace aarch32
663b8021494Sopenharmony_ci}  // namespace vixl
664