1 // Copyright 2015, 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 #include <cstdio>
29 #include <cstring>
30 #include <string>
31 
32 #include "test-runner.h"
33 
34 #include "aarch64/disasm-aarch64.h"
35 #include "aarch64/macro-assembler-aarch64.h"
36 
37 #define TEST(name) TEST_(AARCH64_DISASM_##name)
38 
39 #define SETUP_COMMON()   \
40   uint32_t encoding = 0; \
41   MacroAssembler masm;   \
42   Decoder decoder;       \
43   Disassembler disasm;   \
44   decoder.AppendVisitor(&disasm)
45 
46 #ifdef VIXL_INCLUDE_SIMULATOR_AARCH64
47 // Run tests with the simulator.
48 #define SETUP()   \
49   SETUP_COMMON(); \
50   masm.SetGenerateSimulatorCode(true)
51 
52 #else  // ifdef VIXL_INCLUDE_SIMULATOR_AARCH64.
53 #define SETUP()   \
54   SETUP_COMMON(); \
55   masm.SetGenerateSimulatorCode(false)
56 
57 #endif  // ifdef VIXL_INCLUDE_SIMULATOR_AARCH64.
58 
59 // A conservative limit for the size of the code that we generate in these
60 // tests.
61 #define MAX_SIZE_GENERATED 1024
62 
63 #define COMPARE(ASM, EXP)                                             \
64   masm.Reset();                                                       \
65   {                                                                   \
66     ExactAssemblyScope guard(&masm,                                   \
67                              MAX_SIZE_GENERATED,                      \
68                              ExactAssemblyScope::kMaximumSize);       \
69     masm.ASM;                                                         \
70   }                                                                   \
71   masm.FinalizeCode();                                                \
72   decoder.Decode(masm.GetBuffer()->GetStartAddress<Instruction*>());  \
73   encoding = *masm.GetBuffer()->GetStartAddress<uint32_t*>();         \
74   if (strcmp(disasm.GetOutput(), EXP) != 0) {                         \
75     printf("\nEncoding: %08" PRIx32 "\nExpected: %s\nFound:    %s\n", \
76            encoding,                                                  \
77            EXP,                                                       \
78            disasm.GetOutput());                                       \
79     abort();                                                          \
80   }                                                                   \
81   if (Test::disassemble()) {                                          \
82     printf("%08" PRIx32 "\t%s\n", encoding, disasm.GetOutput());      \
83   }
84 
85 #define COMPARE_PREFIX(ASM, EXP)                                      \
86   masm.Reset();                                                       \
87   {                                                                   \
88     ExactAssemblyScope guard(&masm,                                   \
89                              MAX_SIZE_GENERATED,                      \
90                              ExactAssemblyScope::kMaximumSize);       \
91     masm.ASM;                                                         \
92   }                                                                   \
93   masm.FinalizeCode();                                                \
94   decoder.Decode(masm.GetBuffer()->GetStartAddress<Instruction*>());  \
95   encoding = *masm.GetBuffer()->GetStartAddress<uint32_t*>();         \
96   if (strncmp(disasm.GetOutput(), EXP, strlen(EXP)) != 0) {           \
97     printf("\nEncoding: %08" PRIx32 "\nExpected: %s\nFound:    %s\n", \
98            encoding,                                                  \
99            EXP,                                                       \
100            disasm.GetOutput());                                       \
101     abort();                                                          \
102   }                                                                   \
103   if (Test::disassemble()) {                                          \
104     printf("%08" PRIx32 "\t%s\n", encoding, disasm.GetOutput());      \
105   }
106 
107 #define COMPARE_MACRO_BASE(ASM, EXP)                               \
108   masm.Reset();                                                    \
109   masm.ASM;                                                        \
110   masm.FinalizeCode();                                             \
111   std::string res;                                                 \
112                                                                    \
113   Instruction* instruction =                                       \
114       masm.GetBuffer()->GetStartAddress<Instruction*>();           \
115   Instruction* end = masm.GetCursorAddress<Instruction*>();        \
116   while (instruction != end) {                                     \
117     decoder.Decode(instruction);                                   \
118     res.append(disasm.GetOutput());                                \
119     if (Test::disassemble()) {                                     \
120       encoding = *reinterpret_cast<uint32_t*>(instruction);        \
121       printf("%08" PRIx32 "\t%s\n", encoding, disasm.GetOutput()); \
122     }                                                              \
123     instruction += kInstructionSize;                               \
124     if (instruction != end) {                                      \
125       res.append("\n");                                            \
126     }                                                              \
127   }
128 
129 #define COMPARE_MACRO(ASM, EXP)                                 \
130   {                                                             \
131     COMPARE_MACRO_BASE(ASM, EXP)                                \
132     if (strcmp(res.c_str(), EXP) != 0) {                        \
133       printf("Expected: %s\nFound:    %s\n", EXP, res.c_str()); \
134       abort();                                                  \
135     }                                                           \
136   }
137 
138 #define COMPARE_MACRO_PREFIX(ASM, EXP)                                   \
139   {                                                                      \
140     COMPARE_MACRO_BASE(ASM, EXP)                                         \
141     if (strncmp(res.c_str(), EXP, strlen(EXP)) != 0) {                   \
142       printf("Expected (prefix): %s\nFound:    %s\n", EXP, res.c_str()); \
143       abort();                                                           \
144     }                                                                    \
145   }
146 
147 #define CLEANUP()
148 
149 namespace vixl {
150 namespace aarch64 {
151 
TEST(bootstrap)152 TEST(bootstrap) {
153   SETUP();
154 
155   // Instructions generated by C compiler, disassembled by objdump, and
156   // reformatted to suit our disassembly style.
157   COMPARE(dci(0xa9ba7bfd), "stp x29, x30, [sp, #-96]!");
158   COMPARE(dci(0x910003fd), "mov x29, sp");
159   COMPARE(dci(0x9100e3a0), "add x0, x29, #0x38 (56)");
160   COMPARE(dci(0xb900001f), "str wzr, [x0]");
161   COMPARE(dci(0x528000e1), "mov w1, #0x7");
162   COMPARE(dci(0xb9001c01), "str w1, [x0, #28]");
163   COMPARE(dci(0x390043a0), "strb w0, [x29, #16]");
164   COMPARE(dci(0x790027a0), "strh w0, [x29, #18]");
165   COMPARE(dci(0xb9400400), "ldr w0, [x0, #4]");
166   COMPARE(dci(0x0b000021), "add w1, w1, w0");
167   COMPARE(dci(0x531b6800), "lsl w0, w0, #5");
168   COMPARE(dci(0x521e0400), "eor w0, w0, #0xc");
169   COMPARE(dci(0x72af0f00), "movk w0, #0x7878, lsl #16");
170   COMPARE(dci(0xd360fc00), "lsr x0, x0, #32");
171   COMPARE(dci(0x13037c01), "asr w1, w0, #3");
172   COMPARE(dci(0x4b000021), "sub w1, w1, w0");
173   COMPARE(dci(0x2a0103e0), "mov w0, w1");
174   COMPARE(dci(0x93407c00), "sxtw x0, w0");
175   COMPARE(dci(0x2a000020), "orr w0, w1, w0");
176   COMPARE(dci(0xa8c67bfd), "ldp x29, x30, [sp], #96");
177 
178   CLEANUP();
179 }
180 
181 
TEST(mov_mvn)182 TEST(mov_mvn) {
183   SETUP();
184 
185   COMPARE_MACRO(Mov(w0, Operand(0x1234)), "mov w0, #0x1234");
186   COMPARE_MACRO(Mov(x1, Operand(0x1234)), "mov x1, #0x1234");
187   COMPARE_MACRO(Mov(w2, Operand(w3)), "mov w2, w3");
188   COMPARE_MACRO(Mov(x4, Operand(x5)), "mov x4, x5");
189   COMPARE_MACRO(Mov(w6, Operand(w7, LSL, 5)), "lsl w6, w7, #5");
190   COMPARE_MACRO(Mov(x8, Operand(x9, ASR, 42)), "asr x8, x9, #42");
191   COMPARE_MACRO(Mov(w10, Operand(w11, UXTB)), "uxtb w10, w11");
192   COMPARE_MACRO(Mov(x12, Operand(x13, UXTB, 1)), "ubfiz x12, x13, #1, #8");
193   COMPARE_MACRO(Mov(w14, Operand(w15, SXTH, 2)), "sbfiz w14, w15, #2, #16");
194   COMPARE_MACRO(Mov(x16, Operand(x17, SXTW, 3)), "sbfiz x16, x17, #3, #32");
195 
196   COMPARE_MACRO(Mvn(w0, Operand(0x101)), "mov w0, #0xfffffefe");
197   COMPARE_MACRO(Mvn(x1, Operand(0xfff1)), "mov x1, #0xffffffffffff000e");
198   COMPARE_MACRO(Mvn(w2, Operand(w3)), "mvn w2, w3");
199   COMPARE_MACRO(Mvn(x4, Operand(x5)), "mvn x4, x5");
200   COMPARE_MACRO(Mvn(w6, Operand(w7, LSL, 12)), "mvn w6, w7, lsl #12");
201   COMPARE_MACRO(Mvn(x8, Operand(x9, ASR, 63)), "mvn x8, x9, asr #63");
202 
203   CLEANUP();
204 }
205 
206 
TEST(move_immediate)207 TEST(move_immediate) {
208   SETUP();
209 
210   COMPARE(movz(w0, 0x1234), "mov w0, #0x1234");
211   COMPARE(movz(x1, 0xabcd0000), "mov x1, #0xabcd0000");
212   COMPARE(movz(x2, 0x555500000000), "mov x2, #0x555500000000");
213   COMPARE(movz(x3, 0xaaaa000000000000), "mov x3, #0xaaaa000000000000");
214   COMPARE(movz(x4, 0xabcd, 16), "mov x4, #0xabcd0000");
215   COMPARE(movz(x5, 0x5555, 32), "mov x5, #0x555500000000");
216   COMPARE(movz(x6, 0xaaaa, 48), "mov x6, #0xaaaa000000000000");
217 
218   COMPARE(movk(w7, 0x1234), "movk w7, #0x1234");
219   COMPARE(movk(x8, 0xabcd0000), "movk x8, #0xabcd, lsl #16");
220   COMPARE(movk(x9, 0x555500000000), "movk x9, #0x5555, lsl #32");
221   COMPARE(movk(x10, 0xaaaa000000000000), "movk x10, #0xaaaa, lsl #48");
222   COMPARE(movk(w11, 0xabcd, 16), "movk w11, #0xabcd, lsl #16");
223   COMPARE(movk(x12, 0x5555, 32), "movk x12, #0x5555, lsl #32");
224   COMPARE(movk(x13, 0xaaaa, 48), "movk x13, #0xaaaa, lsl #48");
225 
226   COMPARE(movn(w14, 0x1234), "mov w14, #0xffffedcb");
227   COMPARE(movn(x15, 0xabcd0000), "mov x15, #0xffffffff5432ffff");
228   COMPARE(movn(x16, 0x555500000000), "mov x16, #0xffffaaaaffffffff");
229   COMPARE(movn(x17, 0xaaaa000000000000), "mov x17, #0x5555ffffffffffff");
230   COMPARE(movn(w18, 0xabcd, 16), "mov w18, #0x5432ffff");
231   COMPARE(movn(x19, 0x5555, 32), "mov x19, #0xffffaaaaffffffff");
232   COMPARE(movn(x20, 0xaaaa, 48), "mov x20, #0x5555ffffffffffff");
233 
234   COMPARE(movk(w21, 0), "movk w21, #0x0");
235   COMPARE(movk(x22, 0, 0), "movk x22, #0x0");
236   COMPARE(movk(w23, 0, 16), "movk w23, #0x0, lsl #16");
237   COMPARE(movk(x24, 0, 32), "movk x24, #0x0, lsl #32");
238   COMPARE(movk(x25, 0, 48), "movk x25, #0x0, lsl #48");
239 
240   COMPARE(movz(x26, 0, 48), "movz x26, #0x0");
241   COMPARE(movn(x27, 0, 48), "movn x27, #0x0");
242   COMPARE(movn(w28, 0xffff), "movn w28, #0xffff");
243 
244   CLEANUP();
245 }
246 
247 
TEST(move_immediate_2)248 TEST(move_immediate_2) {
249   SETUP();
250 
251   // Move instructions expected for certain immediates. This is really a macro
252   // assembler test, to ensure it generates immediates efficiently.
253   COMPARE_MACRO(Mov(w0, 0), "mov w0, #0x0");
254   COMPARE_MACRO(Mov(w0, 0x0000ffff), "mov w0, #0xffff");
255   COMPARE_MACRO(Mov(w0, 0x00010000), "mov w0, #0x10000");
256   COMPARE_MACRO(Mov(w0, 0xffff0000), "mov w0, #0xffff0000");
257   COMPARE_MACRO(Mov(w0, 0x0001ffff), "mov w0, #0x1ffff");
258   COMPARE_MACRO(Mov(w0, 0xffff8000), "mov w0, #0xffff8000");
259   COMPARE_MACRO(Mov(w0, 0xfffffffe), "mov w0, #0xfffffffe");
260   COMPARE_MACRO(Mov(w0, 0xffffffff), "mov w0, #0xffffffff");
261   COMPARE_MACRO(Mov(w0, 0x00ffff00), "mov w0, #0xffff00");
262   COMPARE_MACRO(Mov(w0, 0xfffe7fff), "mov w0, #0xfffe7fff");
263   COMPARE_MACRO(Mov(w0, 0xfffeffff), "mov w0, #0xfffeffff");
264   COMPARE_MACRO(Mov(w0, 0xffff7fff), "mov w0, #0xffff7fff");
265 
266   COMPARE_MACRO(Mov(x0, 0), "mov x0, #0x0");
267   COMPARE_MACRO(Mov(x0, 0x0000ffff), "mov x0, #0xffff");
268   COMPARE_MACRO(Mov(x0, 0x00010000), "mov x0, #0x10000");
269   COMPARE_MACRO(Mov(x0, 0xffff0000), "mov x0, #0xffff0000");
270   COMPARE_MACRO(Mov(x0, 0x0001ffff), "mov x0, #0x1ffff");
271   COMPARE_MACRO(Mov(x0, 0xffff8000), "mov x0, #0xffff8000");
272   COMPARE_MACRO(Mov(x0, 0xfffffffe), "mov x0, #0xfffffffe");
273   COMPARE_MACRO(Mov(x0, 0xffffffff), "mov x0, #0xffffffff");
274   COMPARE_MACRO(Mov(x0, 0x00ffff00), "mov x0, #0xffff00");
275   COMPARE_MACRO(Mov(x0, 0xffff000000000000), "mov x0, #0xffff000000000000");
276   COMPARE_MACRO(Mov(x0, 0x0000ffff00000000), "mov x0, #0xffff00000000");
277   COMPARE_MACRO(Mov(x0, 0x00000000ffff0000), "mov x0, #0xffff0000");
278   COMPARE_MACRO(Mov(x0, 0xffffffffffff0000), "mov x0, #0xffffffffffff0000");
279   COMPARE_MACRO(Mov(x0, 0xffffffff0000ffff), "mov x0, #0xffffffff0000ffff");
280   COMPARE_MACRO(Mov(x0, 0xffff0000ffffffff), "mov x0, #0xffff0000ffffffff");
281   COMPARE_MACRO(Mov(x0, 0x0000ffffffffffff), "mov x0, #0xffffffffffff");
282   COMPARE_MACRO(Mov(x0, 0xfffe7fffffffffff), "mov x0, #0xfffe7fffffffffff");
283   COMPARE_MACRO(Mov(x0, 0xfffeffffffffffff), "mov x0, #0xfffeffffffffffff");
284   COMPARE_MACRO(Mov(x0, 0xffff7fffffffffff), "mov x0, #0xffff7fffffffffff");
285   COMPARE_MACRO(Mov(x0, 0xfffffffe7fffffff), "mov x0, #0xfffffffe7fffffff");
286   COMPARE_MACRO(Mov(x0, 0xfffffffeffffffff), "mov x0, #0xfffffffeffffffff");
287   COMPARE_MACRO(Mov(x0, 0xffffffff7fffffff), "mov x0, #0xffffffff7fffffff");
288   COMPARE_MACRO(Mov(x0, 0xfffffffffffe7fff), "mov x0, #0xfffffffffffe7fff");
289   COMPARE_MACRO(Mov(x0, 0xfffffffffffeffff), "mov x0, #0xfffffffffffeffff");
290   COMPARE_MACRO(Mov(x0, 0xffffffffffff7fff), "mov x0, #0xffffffffffff7fff");
291   COMPARE_MACRO(Mov(x0, 0xffffffffffffffff), "mov x0, #0xffffffffffffffff");
292 
293   COMPARE_MACRO(Movk(w0, 0x1234, 0), "movk w0, #0x1234");
294   COMPARE_MACRO(Movk(x1, 0x2345, 0), "movk x1, #0x2345");
295   COMPARE_MACRO(Movk(w2, 0x3456, 16), "movk w2, #0x3456, lsl #16");
296   COMPARE_MACRO(Movk(x3, 0x4567, 16), "movk x3, #0x4567, lsl #16");
297   COMPARE_MACRO(Movk(x4, 0x5678, 32), "movk x4, #0x5678, lsl #32");
298   COMPARE_MACRO(Movk(x5, 0x6789, 48), "movk x5, #0x6789, lsl #48");
299 
300   CLEANUP();
301 }
302 
303 
TEST(add_immediate)304 TEST(add_immediate) {
305   SETUP();
306 
307   COMPARE(add(w0, w1, Operand(0xff)), "add w0, w1, #0xff (255)");
308   COMPARE(add(x2, x3, Operand(0x3ff)), "add x2, x3, #0x3ff (1023)");
309   COMPARE(add(w4, w5, Operand(0xfff)), "add w4, w5, #0xfff (4095)");
310   COMPARE(add(x6, x7, Operand(0x1000)), "add x6, x7, #0x1000 (4096)");
311   COMPARE(add(w8, w9, Operand(0xff000)), "add w8, w9, #0xff000 (1044480)");
312   COMPARE(add(x10, x11, Operand(0x3ff000)),
313           "add x10, x11, #0x3ff000 (4190208)");
314   COMPARE(add(w12, w13, Operand(0xfff000)),
315           "add w12, w13, #0xfff000 (16773120)");
316   COMPARE(adds(w14, w15, Operand(0xff)), "adds w14, w15, #0xff (255)");
317   COMPARE(adds(x16, x17, Operand(0xaa000)), "adds x16, x17, #0xaa000 (696320)");
318 
319   COMPARE(cmn(w18, Operand(0xff)), "cmn w18, #0xff (255)");
320   COMPARE(cmn(x19, Operand(0xff000)), "cmn x19, #0xff000 (1044480)");
321   COMPARE(add(w0, wsp, Operand(0)), "mov w0, wsp");
322   COMPARE(add(sp, x0, Operand(0)), "mov sp, x0");
323 
324   COMPARE(add(w1, wsp, Operand(8)), "add w1, wsp, #0x8 (8)");
325   COMPARE(add(x2, sp, Operand(16)), "add x2, sp, #0x10 (16)");
326   COMPARE(add(wsp, wsp, Operand(42)), "add wsp, wsp, #0x2a (42)");
327   COMPARE(cmn(sp, Operand(24)), "cmn sp, #0x18 (24)");
328   COMPARE(adds(wzr, wsp, Operand(9)), "cmn wsp, #0x9 (9)");
329 
330   // Instructions in the add/sub immediate space, but unallocated due to shift
331   // value out of range.
332   COMPARE(dci(0x11800400), "unallocated (Unallocated)");
333   COMPARE(dci(0x11c00400), "unallocated (Unallocated)");
334 
335   CLEANUP();
336 }
337 
338 
TEST(sub_immediate)339 TEST(sub_immediate) {
340   SETUP();
341 
342   COMPARE(sub(w0, w1, Operand(0xff)), "sub w0, w1, #0xff (255)");
343   COMPARE(sub(x2, x3, Operand(0x3ff)), "sub x2, x3, #0x3ff (1023)");
344   COMPARE(sub(w4, w5, Operand(0xfff)), "sub w4, w5, #0xfff (4095)");
345   COMPARE(sub(x6, x7, Operand(0x1000)), "sub x6, x7, #0x1000 (4096)");
346   COMPARE(sub(w8, w9, Operand(0xff000)), "sub w8, w9, #0xff000 (1044480)");
347   COMPARE(sub(x10, x11, Operand(0x3ff000)),
348           "sub x10, x11, #0x3ff000 (4190208)");
349   COMPARE(sub(w12, w13, Operand(0xfff000)),
350           "sub w12, w13, #0xfff000 (16773120)");
351   COMPARE(subs(w14, w15, Operand(0xff)), "subs w14, w15, #0xff (255)");
352   COMPARE(subs(x16, x17, Operand(0xaa000)), "subs x16, x17, #0xaa000 (696320)");
353   COMPARE(cmp(w18, Operand(0xff)), "cmp w18, #0xff (255)");
354   COMPARE(cmp(x19, Operand(0xff000)), "cmp x19, #0xff000 (1044480)");
355 
356   COMPARE(sub(w1, wsp, Operand(8)), "sub w1, wsp, #0x8 (8)");
357   COMPARE(sub(x2, sp, Operand(16)), "sub x2, sp, #0x10 (16)");
358   COMPARE(sub(wsp, wsp, Operand(42)), "sub wsp, wsp, #0x2a (42)");
359   COMPARE(cmp(sp, Operand(24)), "cmp sp, #0x18 (24)");
360   COMPARE(subs(wzr, wsp, Operand(9)), "cmp wsp, #0x9 (9)");
361 
362   CLEANUP();
363 }
364 
365 
TEST(add_shifted)366 TEST(add_shifted) {
367   SETUP();
368 
369   COMPARE(add(w0, w1, Operand(w2)), "add w0, w1, w2");
370   COMPARE(add(x3, x4, Operand(x5)), "add x3, x4, x5");
371   COMPARE(add(w6, w7, Operand(w8, LSL, 1)), "add w6, w7, w8, lsl #1");
372   COMPARE(add(x9, x10, Operand(x11, LSL, 2)), "add x9, x10, x11, lsl #2");
373   COMPARE(add(w12, w13, Operand(w14, LSR, 3)), "add w12, w13, w14, lsr #3");
374   COMPARE(add(x15, x16, Operand(x17, LSR, 4)), "add x15, x16, x17, lsr #4");
375   COMPARE(add(w18, w19, Operand(w20, ASR, 5)), "add w18, w19, w20, asr #5");
376   COMPARE(add(x21, x22, Operand(x23, ASR, 6)), "add x21, x22, x23, asr #6");
377   COMPARE(cmn(w24, Operand(w25)), "cmn w24, w25");
378   COMPARE(cmn(x26, Operand(x27, LSL, 63)), "cmn x26, x27, lsl #63");
379 
380   COMPARE(add(x0, sp, Operand(x1)), "add x0, sp, x1");
381   COMPARE(add(w2, wsp, Operand(w3)), "add w2, wsp, w3");
382   COMPARE(add(x4, sp, Operand(x5, LSL, 1)), "add x4, sp, x5, lsl #1");
383   COMPARE(add(x4, xzr, Operand(x5, LSL, 1)), "add x4, xzr, x5, lsl #1");
384   COMPARE(add(w6, wsp, Operand(w7, LSL, 3)), "add w6, wsp, w7, lsl #3");
385   COMPARE(adds(xzr, sp, Operand(x8, LSL, 4)), "cmn sp, x8, lsl #4");
386   COMPARE(adds(xzr, xzr, Operand(x8, LSL, 5)), "cmn xzr, x8, lsl #5");
387 
388   CLEANUP();
389 }
390 
391 
TEST(sub_shifted)392 TEST(sub_shifted) {
393   SETUP();
394 
395   COMPARE(sub(w0, w1, Operand(w2)), "sub w0, w1, w2");
396   COMPARE(sub(x3, x4, Operand(x5)), "sub x3, x4, x5");
397   COMPARE(sub(w6, w7, Operand(w8, LSL, 1)), "sub w6, w7, w8, lsl #1");
398   COMPARE(sub(x9, x10, Operand(x11, LSL, 2)), "sub x9, x10, x11, lsl #2");
399   COMPARE(sub(w12, w13, Operand(w14, LSR, 3)), "sub w12, w13, w14, lsr #3");
400   COMPARE(sub(x15, x16, Operand(x17, LSR, 4)), "sub x15, x16, x17, lsr #4");
401   COMPARE(sub(w18, w19, Operand(w20, ASR, 5)), "sub w18, w19, w20, asr #5");
402   COMPARE(sub(x21, x22, Operand(x23, ASR, 6)), "sub x21, x22, x23, asr #6");
403   COMPARE(cmp(w24, Operand(w25)), "cmp w24, w25");
404   COMPARE(cmp(x26, Operand(x27, LSL, 63)), "cmp x26, x27, lsl #63");
405   COMPARE(neg(w28, Operand(w29)), "neg w28, w29");
406   COMPARE(neg(x30, Operand(x0, LSR, 62)), "neg x30, x0, lsr #62");
407   COMPARE(negs(w1, Operand(w2)), "negs w1, w2");
408   COMPARE(negs(x3, Operand(x4, ASR, 61)), "negs x3, x4, asr #61");
409 
410   COMPARE(sub(x0, sp, Operand(x1)), "sub x0, sp, x1");
411   COMPARE(sub(w2, wsp, Operand(w3)), "sub w2, wsp, w3");
412   COMPARE(sub(x4, sp, Operand(x5, LSL, 1)), "sub x4, sp, x5, lsl #1");
413   COMPARE(sub(x4, xzr, Operand(x5, LSL, 1)), "neg x4, x5, lsl #1");
414   COMPARE(sub(w6, wsp, Operand(w7, LSL, 3)), "sub w6, wsp, w7, lsl #3");
415   COMPARE(subs(xzr, sp, Operand(x8, LSL, 4)), "cmp sp, x8, lsl #4");
416   COMPARE(subs(xzr, xzr, Operand(x8, LSL, 5)), "cmp xzr, x8, lsl #5");
417 
418   CLEANUP();
419 }
420 
421 
TEST(add_extended)422 TEST(add_extended) {
423   SETUP();
424 
425   COMPARE(add(w0, w1, Operand(w2, UXTB)), "add w0, w1, w2, uxtb");
426   COMPARE(adds(x3, x4, Operand(w5, UXTB, 1)), "adds x3, x4, w5, uxtb #1");
427   COMPARE(add(w6, w7, Operand(w8, UXTH, 2)), "add w6, w7, w8, uxth #2");
428   COMPARE(adds(x9, x10, Operand(x11, UXTW, 3)), "adds x9, x10, w11, uxtw #3");
429   COMPARE(add(x12, x13, Operand(x14, UXTX, 4)), "add x12, x13, x14, uxtx #4");
430   COMPARE(adds(w15, w16, Operand(w17, SXTB, 4)), "adds w15, w16, w17, sxtb #4");
431   COMPARE(add(x18, x19, Operand(x20, SXTB, 3)), "add x18, x19, w20, sxtb #3");
432   COMPARE(adds(w21, w22, Operand(w23, SXTH, 2)), "adds w21, w22, w23, sxth #2");
433   COMPARE(add(x24, x25, Operand(x26, SXTW, 1)), "add x24, x25, w26, sxtw #1");
434   COMPARE(adds(x27, x28, Operand(x29, SXTX)), "adds x27, x28, x29, sxtx");
435   COMPARE(cmn(w0, Operand(w1, UXTB, 2)), "cmn w0, w1, uxtb #2");
436   COMPARE(cmn(x2, Operand(x3, SXTH, 4)), "cmn x2, w3, sxth #4");
437 
438   COMPARE(add(w0, wsp, Operand(w1, UXTB)), "add w0, wsp, w1, uxtb");
439   COMPARE(add(x2, sp, Operand(x3, UXTH, 1)), "add x2, sp, w3, uxth #1");
440   COMPARE(add(wsp, wsp, Operand(w4, UXTW, 2)), "add wsp, wsp, w4, lsl #2");
441   COMPARE(cmn(sp, Operand(xzr, UXTX, 3)), "cmn sp, xzr, lsl #3");
442   COMPARE(cmn(sp, Operand(xzr, LSL, 4)), "cmn sp, xzr, lsl #4");
443 
444   CLEANUP();
445 }
446 
447 
TEST(sub_extended)448 TEST(sub_extended) {
449   SETUP();
450 
451   COMPARE(sub(w0, w1, Operand(w2, UXTB)), "sub w0, w1, w2, uxtb");
452   COMPARE(subs(x3, x4, Operand(w5, UXTB, 1)), "subs x3, x4, w5, uxtb #1");
453   COMPARE(sub(w6, w7, Operand(w8, UXTH, 2)), "sub w6, w7, w8, uxth #2");
454   COMPARE(subs(x9, x10, Operand(x11, UXTW, 3)), "subs x9, x10, w11, uxtw #3");
455   COMPARE(sub(x12, x13, Operand(x14, UXTX, 4)), "sub x12, x13, x14, uxtx #4");
456   COMPARE(subs(w15, w16, Operand(w17, SXTB, 4)), "subs w15, w16, w17, sxtb #4");
457   COMPARE(sub(x18, x19, Operand(x20, SXTB, 3)), "sub x18, x19, w20, sxtb #3");
458   COMPARE(subs(w21, w22, Operand(w23, SXTH, 2)), "subs w21, w22, w23, sxth #2");
459   COMPARE(sub(x24, x25, Operand(x26, SXTW, 1)), "sub x24, x25, w26, sxtw #1");
460   COMPARE(subs(x27, x28, Operand(x29, SXTX)), "subs x27, x28, x29, sxtx");
461   COMPARE(cmp(w0, Operand(w1, SXTB, 1)), "cmp w0, w1, sxtb #1");
462   COMPARE(cmp(x2, Operand(x3, UXTH, 3)), "cmp x2, w3, uxth #3");
463 
464   COMPARE(sub(w0, wsp, Operand(w1, UXTB)), "sub w0, wsp, w1, uxtb");
465   COMPARE(sub(x2, sp, Operand(x3, UXTH, 1)), "sub x2, sp, w3, uxth #1");
466   COMPARE(sub(wsp, wsp, Operand(w4, UXTW, 2)), "sub wsp, wsp, w4, lsl #2");
467   COMPARE(cmp(sp, Operand(xzr, UXTX, 3)), "cmp sp, xzr, lsl #3");
468   COMPARE(cmp(sp, Operand(xzr, LSL, 4)), "cmp sp, xzr, lsl #4");
469 
470   CLEANUP();
471 }
472 
473 
TEST(adc_subc_ngc)474 TEST(adc_subc_ngc) {
475   SETUP();
476 
477   COMPARE(adc(w0, w1, Operand(w2)), "adc w0, w1, w2");
478   COMPARE(adc(x3, x4, Operand(x5)), "adc x3, x4, x5");
479   COMPARE(adcs(w6, w7, Operand(w8)), "adcs w6, w7, w8");
480   COMPARE(adcs(x9, x10, Operand(x11)), "adcs x9, x10, x11");
481   COMPARE(sbc(w12, w13, Operand(w14)), "sbc w12, w13, w14");
482   COMPARE(sbc(x15, x16, Operand(x17)), "sbc x15, x16, x17");
483   COMPARE(sbcs(w18, w19, Operand(w20)), "sbcs w18, w19, w20");
484   COMPARE(sbcs(x21, x22, Operand(x23)), "sbcs x21, x22, x23");
485   COMPARE(ngc(w24, Operand(w25)), "ngc w24, w25");
486   COMPARE(ngc(x26, Operand(x27)), "ngc x26, x27");
487   COMPARE(ngcs(w28, Operand(w29)), "ngcs w28, w29");
488   COMPARE(ngcs(x30, Operand(x0)), "ngcs x30, x0");
489 
490   CLEANUP();
491 }
492 
493 
TEST(mul_and_div)494 TEST(mul_and_div) {
495   SETUP();
496 
497   COMPARE(mul(w0, w1, w2), "mul w0, w1, w2");
498   COMPARE(mul(x3, x4, x5), "mul x3, x4, x5");
499   COMPARE(mul(w30, w0, w1), "mul w30, w0, w1");
500   COMPARE(mul(x30, x0, x1), "mul x30, x0, x1");
501   COMPARE(mneg(w0, w1, w2), "mneg w0, w1, w2");
502   COMPARE(mneg(x3, x4, x5), "mneg x3, x4, x5");
503   COMPARE(mneg(w30, w0, w1), "mneg w30, w0, w1");
504   COMPARE(mneg(x30, x0, x1), "mneg x30, x0, x1");
505   COMPARE(smull(x0, w0, w1), "smull x0, w0, w1");
506   COMPARE(smull(x30, w30, w0), "smull x30, w30, w0");
507   COMPARE(smulh(x0, x1, x2), "smulh x0, x1, x2");
508   COMPARE(umulh(x0, x2, x1), "umulh x0, x2, x1");
509 
510   COMPARE(sdiv(w0, w1, w2), "sdiv w0, w1, w2");
511   COMPARE(sdiv(x3, x4, x5), "sdiv x3, x4, x5");
512   COMPARE(udiv(w6, w7, w8), "udiv w6, w7, w8");
513   COMPARE(udiv(x9, x10, x11), "udiv x9, x10, x11");
514 
515   CLEANUP();
516 }
517 
518 
TEST(madd)519 TEST(madd) {
520   SETUP();
521 
522   COMPARE(madd(w0, w1, w2, w3), "madd w0, w1, w2, w3");
523   COMPARE(madd(w30, w21, w22, w16), "madd w30, w21, w22, w16");
524   COMPARE(madd(x0, x1, x2, x3), "madd x0, x1, x2, x3");
525   COMPARE(madd(x30, x21, x22, x16), "madd x30, x21, x22, x16");
526 
527   COMPARE(smaddl(x0, w1, w2, x3), "smaddl x0, w1, w2, x3");
528   COMPARE(smaddl(x30, w21, w22, x16), "smaddl x30, w21, w22, x16");
529   COMPARE(umaddl(x0, w1, w2, x3), "umaddl x0, w1, w2, x3");
530   COMPARE(umaddl(x30, w21, w22, x16), "umaddl x30, w21, w22, x16");
531   COMPARE(umull(x0, w1, w2), "umull x0, w1, w2");
532   COMPARE(umull(x30, w21, w22), "umull x30, w21, w22");
533 
534   CLEANUP();
535 }
536 
537 
TEST(msub)538 TEST(msub) {
539   SETUP();
540 
541   COMPARE(msub(w0, w1, w2, w3), "msub w0, w1, w2, w3");
542   COMPARE(msub(w30, w21, w22, w16), "msub w30, w21, w22, w16");
543   COMPARE(msub(x0, x1, x2, x3), "msub x0, x1, x2, x3");
544   COMPARE(msub(x30, x21, x22, x16), "msub x30, x21, x22, x16");
545 
546   COMPARE(smsubl(x0, w1, w2, x3), "smsubl x0, w1, w2, x3");
547   COMPARE(smsubl(x30, w21, w22, x16), "smsubl x30, w21, w22, x16");
548   COMPARE(umsubl(x0, w1, w2, x3), "umsubl x0, w1, w2, x3");
549   COMPARE(umsubl(x30, w21, w22, x16), "umsubl x30, w21, w22, x16");
550 
551   CLEANUP();
552 }
553 
554 
TEST(dp_1_source)555 TEST(dp_1_source) {
556   SETUP();
557 
558   COMPARE(rbit(w0, w1), "rbit w0, w1");
559   COMPARE(rbit(x2, x3), "rbit x2, x3");
560   COMPARE(rev16(w4, w5), "rev16 w4, w5");
561   COMPARE(rev16(x6, x7), "rev16 x6, x7");
562   COMPARE(rev32(x8, x9), "rev32 x8, x9");
563   COMPARE(rev(w10, w11), "rev w10, w11");
564   COMPARE(rev(x12, x13), "rev x12, x13");
565   COMPARE(clz(w14, w15), "clz w14, w15");
566   COMPARE(clz(x16, x17), "clz x16, x17");
567   COMPARE(cls(w18, w19), "cls w18, w19");
568   COMPARE(cls(x20, x21), "cls x20, x21");
569 
570   CLEANUP();
571 }
572 
573 
TEST(bitfield)574 TEST(bitfield) {
575   SETUP();
576 
577   COMPARE(sxtb(w0, w1), "sxtb w0, w1");
578   COMPARE(sxtb(x2, x3), "sxtb x2, w3");
579   COMPARE(sxth(w4, w5), "sxth w4, w5");
580   COMPARE(sxth(x6, x7), "sxth x6, w7");
581   COMPARE(sxtw(x8, x9), "sxtw x8, w9");
582   COMPARE(sxtb(x0, w1), "sxtb x0, w1");
583   COMPARE(sxth(x2, w3), "sxth x2, w3");
584   COMPARE(sxtw(x4, w5), "sxtw x4, w5");
585 
586   COMPARE(uxtb(w10, w11), "uxtb w10, w11");
587   COMPARE(uxtb(x12, x13), "uxtb x12, w13");
588   COMPARE(uxth(w14, w15), "uxth w14, w15");
589   COMPARE(uxth(x16, x17), "uxth x16, w17");
590   COMPARE(uxtw(x18, x19), "ubfx x18, x19, #0, #32");
591 
592   COMPARE(asr(w20, w21, 10), "asr w20, w21, #10");
593   COMPARE(asr(x22, x23, 20), "asr x22, x23, #20");
594   COMPARE(lsr(w24, w25, 10), "lsr w24, w25, #10");
595   COMPARE(lsr(x26, x27, 20), "lsr x26, x27, #20");
596   COMPARE(lsl(w28, w29, 10), "lsl w28, w29, #10");
597   COMPARE(lsl(x30, x0, 20), "lsl x30, x0, #20");
598 
599   COMPARE(sbfiz(w1, w2, 1, 20), "sbfiz w1, w2, #1, #20");
600   COMPARE(sbfiz(x3, x4, 2, 19), "sbfiz x3, x4, #2, #19");
601   COMPARE(sbfx(w5, w6, 3, 18), "sbfx w5, w6, #3, #18");
602   COMPARE(sbfx(x7, x8, 4, 17), "sbfx x7, x8, #4, #17");
603   COMPARE(bfi(w9, w10, 5, 16), "bfi w9, w10, #5, #16");
604   COMPARE(bfi(x11, x12, 6, 15), "bfi x11, x12, #6, #15");
605   COMPARE(bfxil(w13, w14, 7, 14), "bfxil w13, w14, #7, #14");
606   COMPARE(bfxil(x15, x16, 8, 13), "bfxil x15, x16, #8, #13");
607   COMPARE(ubfiz(w17, w18, 9, 12), "ubfiz w17, w18, #9, #12");
608   COMPARE(ubfiz(x19, x20, 10, 11), "ubfiz x19, x20, #10, #11");
609   COMPARE(ubfx(w21, w22, 11, 10), "ubfx w21, w22, #11, #10");
610   COMPARE(ubfx(x23, x24, 12, 9), "ubfx x23, x24, #12, #9");
611 
612   CLEANUP();
613 }
614 
615 
TEST(crc32b)616 TEST(crc32b) {
617   SETUP();
618 
619   COMPARE(crc32b(w0, w1, w2), "crc32b w0, w1, w2");
620   COMPARE(crc32b(w0, w11, w22), "crc32b w0, w11, w22");
621   COMPARE(crc32b(w10, w20, w30), "crc32b w10, w20, w30");
622 
623   CLEANUP();
624 }
625 
626 
TEST(crc32h)627 TEST(crc32h) {
628   SETUP();
629 
630   COMPARE(crc32h(w1, w2, w3), "crc32h w1, w2, w3");
631   COMPARE(crc32h(w2, w13, w23), "crc32h w2, w13, w23");
632   COMPARE(crc32h(w11, w12, w15), "crc32h w11, w12, w15");
633 
634   CLEANUP();
635 }
636 
637 
TEST(crc32w)638 TEST(crc32w) {
639   SETUP();
640 
641   COMPARE(crc32w(w2, w3, w4), "crc32w w2, w3, w4");
642   COMPARE(crc32w(w3, w14, w24), "crc32w w3, w14, w24");
643   COMPARE(crc32w(w13, w13, w16), "crc32w w13, w13, w16");
644 
645   CLEANUP();
646 }
647 
648 
TEST(crc32x)649 TEST(crc32x) {
650   SETUP();
651 
652   COMPARE(crc32x(w3, w4, x5), "crc32x w3, w4, x5");
653   COMPARE(crc32x(w4, w15, x25), "crc32x w4, w15, x25");
654   COMPARE(crc32x(w14, w14, x30), "crc32x w14, w14, x30");
655 
656   CLEANUP();
657 }
658 
659 
TEST(crc32cb)660 TEST(crc32cb) {
661   SETUP();
662 
663   COMPARE(crc32cb(w4, w5, w6), "crc32cb w4, w5, w6");
664   COMPARE(crc32cb(w5, w16, w26), "crc32cb w5, w16, w26");
665   COMPARE(crc32cb(w15, w15, w5), "crc32cb w15, w15, w5");
666 
667   CLEANUP();
668 }
669 
670 
TEST(crc32ch)671 TEST(crc32ch) {
672   SETUP();
673 
674   COMPARE(crc32ch(w5, w6, w7), "crc32ch w5, w6, w7");
675   COMPARE(crc32ch(w6, w17, w27), "crc32ch w6, w17, w27");
676   COMPARE(crc32ch(w16, w16, w2), "crc32ch w16, w16, w2");
677 
678   CLEANUP();
679 }
680 
681 
TEST(crc32cw)682 TEST(crc32cw) {
683   SETUP();
684 
685   COMPARE(crc32cw(w6, w7, w8), "crc32cw w6, w7, w8");
686   COMPARE(crc32cw(w7, w18, w28), "crc32cw w7, w18, w28");
687   COMPARE(crc32cw(w17, w17, w3), "crc32cw w17, w17, w3");
688 
689   CLEANUP();
690 }
691 
692 
TEST(crc32cx)693 TEST(crc32cx) {
694   SETUP();
695 
696   COMPARE(crc32cx(w7, w8, x9), "crc32cx w7, w8, x9");
697   COMPARE(crc32cx(w8, w19, x29), "crc32cx w8, w19, x29");
698   COMPARE(crc32cx(w18, w18, x4), "crc32cx w18, w18, x4");
699 
700   CLEANUP();
701 }
702 
703 
TEST(extract)704 TEST(extract) {
705   SETUP();
706 
707   COMPARE(extr(w0, w1, w2, 0), "extr w0, w1, w2, #0");
708   COMPARE(extr(x3, x4, x5, 1), "extr x3, x4, x5, #1");
709   COMPARE(extr(w6, w7, w8, 31), "extr w6, w7, w8, #31");
710   COMPARE(extr(x9, x10, x11, 63), "extr x9, x10, x11, #63");
711   COMPARE(extr(w12, w13, w13, 10), "ror w12, w13, #10");
712   COMPARE(extr(x14, x15, x15, 42), "ror x14, x15, #42");
713 
714   CLEANUP();
715 }
716 
717 
TEST(logical_immediate)718 TEST(logical_immediate) {
719   SETUP();
720 #define RESULT_SIZE (256)
721 
722   char result[RESULT_SIZE];
723 
724   // Test immediate encoding - 64-bit destination.
725   // 64-bit patterns.
726   uint64_t value = 0x7fffffff;
727   for (int i = 0; i < 64; i++) {
728     snprintf(result, RESULT_SIZE, "and x0, x0, #0x%" PRIx64, value);
729     COMPARE(and_(x0, x0, Operand(value)), result);
730     value = ((value & 1) << 63) | (value >> 1);  // Rotate right 1 bit.
731   }
732 
733   // 32-bit patterns.
734   value = 0x00003fff00003fff;
735   for (int i = 0; i < 32; i++) {
736     snprintf(result, RESULT_SIZE, "and x0, x0, #0x%" PRIx64, value);
737     COMPARE(and_(x0, x0, Operand(value)), result);
738     value = ((value & 1) << 63) | (value >> 1);  // Rotate right 1 bit.
739   }
740 
741   // 16-bit patterns.
742   value = 0x001f001f001f001f;
743   for (int i = 0; i < 16; i++) {
744     snprintf(result, RESULT_SIZE, "and x0, x0, #0x%" PRIx64, value);
745     COMPARE(and_(x0, x0, Operand(value)), result);
746     value = ((value & 1) << 63) | (value >> 1);  // Rotate right 1 bit.
747   }
748 
749   // 8-bit patterns.
750   value = 0x0e0e0e0e0e0e0e0e;
751   for (int i = 0; i < 8; i++) {
752     snprintf(result, RESULT_SIZE, "and x0, x0, #0x%" PRIx64, value);
753     COMPARE(and_(x0, x0, Operand(value)), result);
754     value = ((value & 1) << 63) | (value >> 1);  // Rotate right 1 bit.
755   }
756 
757   // 4-bit patterns.
758   value = 0x6666666666666666;
759   for (int i = 0; i < 4; i++) {
760     snprintf(result, RESULT_SIZE, "and x0, x0, #0x%" PRIx64, value);
761     COMPARE(and_(x0, x0, Operand(value)), result);
762     value = ((value & 1) << 63) | (value >> 1);  // Rotate right 1 bit.
763   }
764 
765   // 2-bit patterns.
766   COMPARE(and_(x0, x0, Operand(0x5555555555555555)),
767           "and x0, x0, #0x5555555555555555");
768   COMPARE(and_(x0, x0, Operand(0xaaaaaaaaaaaaaaaa)),
769           "and x0, x0, #0xaaaaaaaaaaaaaaaa");
770 
771   // Test immediate encoding - 32-bit destination.
772   COMPARE(and_(w0, w0, Operand(0xff8007ff)),
773           "and w0, w0, #0xff8007ff");  // 32-bit pattern.
774   COMPARE(and_(w0, w0, Operand(0xf87ff87f)),
775           "and w0, w0, #0xf87ff87f");  // 16-bit pattern.
776   COMPARE(and_(w0, w0, Operand(0x87878787)),
777           "and w0, w0, #0x87878787");  // 8-bit pattern.
778   COMPARE(and_(w0, w0, Operand(0x66666666)),
779           "and w0, w0, #0x66666666");  // 4-bit pattern.
780   COMPARE(and_(w0, w0, Operand(0x55555555)),
781           "and w0, w0, #0x55555555");  // 2-bit pattern.
782 
783   // Test other instructions.
784   COMPARE(tst(w1, Operand(0x11111111)), "tst w1, #0x11111111");
785   COMPARE(tst(x2, Operand(0x8888888888888888)), "tst x2, #0x8888888888888888");
786   COMPARE(orr(w7, w8, Operand(0xaaaaaaaa)), "orr w7, w8, #0xaaaaaaaa");
787   COMPARE(orr(x9, x10, Operand(0x5555555555555555)),
788           "orr x9, x10, #0x5555555555555555");
789   COMPARE(eor(w15, w16, Operand(0x00000001)), "eor w15, w16, #0x1");
790   COMPARE(eor(x17, x18, Operand(0x0000000000000003)), "eor x17, x18, #0x3");
791   COMPARE(ands(w23, w24, Operand(0x0000000f)), "ands w23, w24, #0xf");
792   COMPARE(ands(x25, x26, Operand(0x800000000000000f)),
793           "ands x25, x26, #0x800000000000000f");
794 
795   // Test inverse.
796   COMPARE(bic(w3, w4, Operand(0x20202020)), "and w3, w4, #0xdfdfdfdf");
797   COMPARE(bic(x5, x6, Operand(0x4040404040404040)),
798           "and x5, x6, #0xbfbfbfbfbfbfbfbf");
799   COMPARE(orn(w11, w12, Operand(0x40004000)), "orr w11, w12, #0xbfffbfff");
800   COMPARE(orn(x13, x14, Operand(0x8181818181818181)),
801           "orr x13, x14, #0x7e7e7e7e7e7e7e7e");
802   COMPARE(eon(w19, w20, Operand(0x80000001)), "eor w19, w20, #0x7ffffffe");
803   COMPARE(eon(x21, x22, Operand(0xc000000000000003)),
804           "eor x21, x22, #0x3ffffffffffffffc");
805   COMPARE(bics(w27, w28, Operand(0xfffffff7)), "ands w27, w28, #0x8");
806   COMPARE(bics(x29, x0, Operand(0xfffffffeffffffff)),
807           "ands x29, x0, #0x100000000");
808 
809   // Test stack pointer.
810   COMPARE(and_(wsp, wzr, Operand(7)), "and wsp, wzr, #0x7");
811   COMPARE(ands(xzr, xzr, Operand(7)), "tst xzr, #0x7");
812   COMPARE(orr(sp, xzr, Operand(15)), "orr sp, xzr, #0xf");
813   COMPARE(eor(wsp, w0, Operand(31)), "eor wsp, w0, #0x1f");
814 
815   // Test move aliases.
816   COMPARE(orr(w0, wzr, Operand(0x00000780)), "orr w0, wzr, #0x780");
817   COMPARE(orr(w1, wzr, Operand(0x00007800)), "orr w1, wzr, #0x7800");
818   COMPARE(orr(w2, wzr, Operand(0x00078000)), "mov w2, #0x78000");
819   COMPARE(orr(w3, wzr, Operand(0x00780000)), "orr w3, wzr, #0x780000");
820   COMPARE(orr(w4, wzr, Operand(0x07800000)), "orr w4, wzr, #0x7800000");
821   COMPARE(orr(x5, xzr, Operand(0xffffffffffffc001)),
822           "orr x5, xzr, #0xffffffffffffc001");
823   COMPARE(orr(x6, xzr, Operand(0xfffffffffffc001f)),
824           "mov x6, #0xfffffffffffc001f");
825   COMPARE(orr(x7, xzr, Operand(0xffffffffffc001ff)),
826           "mov x7, #0xffffffffffc001ff");
827   COMPARE(orr(x8, xzr, Operand(0xfffffffffc001fff)),
828           "mov x8, #0xfffffffffc001fff");
829   COMPARE(orr(x9, xzr, Operand(0xffffffffc001ffff)),
830           "orr x9, xzr, #0xffffffffc001ffff");
831 
832   CLEANUP();
833 }
834 
835 
TEST(logical_shifted)836 TEST(logical_shifted) {
837   SETUP();
838 
839   COMPARE(and_(w0, w1, Operand(w2)), "and w0, w1, w2");
840   COMPARE(and_(x3, x4, Operand(x5, LSL, 1)), "and x3, x4, x5, lsl #1");
841   COMPARE(and_(w6, w7, Operand(w8, LSR, 2)), "and w6, w7, w8, lsr #2");
842   COMPARE(and_(x9, x10, Operand(x11, ASR, 3)), "and x9, x10, x11, asr #3");
843   COMPARE(and_(w12, w13, Operand(w14, ROR, 4)), "and w12, w13, w14, ror #4");
844 
845   COMPARE(bic(w15, w16, Operand(w17)), "bic w15, w16, w17");
846   COMPARE(bic(x18, x19, Operand(x20, LSL, 5)), "bic x18, x19, x20, lsl #5");
847   COMPARE(bic(w21, w22, Operand(w23, LSR, 6)), "bic w21, w22, w23, lsr #6");
848   COMPARE(bic(x24, x25, Operand(x26, ASR, 7)), "bic x24, x25, x26, asr #7");
849   COMPARE(bic(w27, w28, Operand(w29, ROR, 8)), "bic w27, w28, w29, ror #8");
850 
851   COMPARE(orr(w0, w1, Operand(w2)), "orr w0, w1, w2");
852   COMPARE(orr(x3, x4, Operand(x5, LSL, 9)), "orr x3, x4, x5, lsl #9");
853   COMPARE(orr(w6, w7, Operand(w8, LSR, 10)), "orr w6, w7, w8, lsr #10");
854   COMPARE(orr(x9, x10, Operand(x11, ASR, 11)), "orr x9, x10, x11, asr #11");
855   COMPARE(orr(w12, w13, Operand(w14, ROR, 12)), "orr w12, w13, w14, ror #12");
856 
857   COMPARE(orn(w15, w16, Operand(w17)), "orn w15, w16, w17");
858   COMPARE(orn(x18, x19, Operand(x20, LSL, 13)), "orn x18, x19, x20, lsl #13");
859   COMPARE(orn(w21, w22, Operand(w23, LSR, 14)), "orn w21, w22, w23, lsr #14");
860   COMPARE(orn(x24, x25, Operand(x26, ASR, 15)), "orn x24, x25, x26, asr #15");
861   COMPARE(orn(w27, w28, Operand(w29, ROR, 16)), "orn w27, w28, w29, ror #16");
862 
863   COMPARE(eor(w0, w1, Operand(w2)), "eor w0, w1, w2");
864   COMPARE(eor(x3, x4, Operand(x5, LSL, 17)), "eor x3, x4, x5, lsl #17");
865   COMPARE(eor(w6, w7, Operand(w8, LSR, 18)), "eor w6, w7, w8, lsr #18");
866   COMPARE(eor(x9, x10, Operand(x11, ASR, 19)), "eor x9, x10, x11, asr #19");
867   COMPARE(eor(w12, w13, Operand(w14, ROR, 20)), "eor w12, w13, w14, ror #20");
868 
869   COMPARE(eon(w15, w16, Operand(w17)), "eon w15, w16, w17");
870   COMPARE(eon(x18, x19, Operand(x20, LSL, 21)), "eon x18, x19, x20, lsl #21");
871   COMPARE(eon(w21, w22, Operand(w23, LSR, 22)), "eon w21, w22, w23, lsr #22");
872   COMPARE(eon(x24, x25, Operand(x26, ASR, 23)), "eon x24, x25, x26, asr #23");
873   COMPARE(eon(w27, w28, Operand(w29, ROR, 24)), "eon w27, w28, w29, ror #24");
874 
875   COMPARE(ands(w0, w1, Operand(w2)), "ands w0, w1, w2");
876   COMPARE(ands(x3, x4, Operand(x5, LSL, 1)), "ands x3, x4, x5, lsl #1");
877   COMPARE(ands(w6, w7, Operand(w8, LSR, 2)), "ands w6, w7, w8, lsr #2");
878   COMPARE(ands(x9, x10, Operand(x11, ASR, 3)), "ands x9, x10, x11, asr #3");
879   COMPARE(ands(w12, w13, Operand(w14, ROR, 4)), "ands w12, w13, w14, ror #4");
880 
881   COMPARE(bics(w15, w16, Operand(w17)), "bics w15, w16, w17");
882   COMPARE(bics(x18, x19, Operand(x20, LSL, 5)), "bics x18, x19, x20, lsl #5");
883   COMPARE(bics(w21, w22, Operand(w23, LSR, 6)), "bics w21, w22, w23, lsr #6");
884   COMPARE(bics(x24, x25, Operand(x26, ASR, 7)), "bics x24, x25, x26, asr #7");
885   COMPARE(bics(w27, w28, Operand(w29, ROR, 8)), "bics w27, w28, w29, ror #8");
886 
887   COMPARE(tst(w0, Operand(w1)), "tst w0, w1");
888   COMPARE(tst(w2, Operand(w3, ROR, 10)), "tst w2, w3, ror #10");
889   COMPARE(tst(x0, Operand(x1)), "tst x0, x1");
890   COMPARE(tst(x2, Operand(x3, ROR, 42)), "tst x2, x3, ror #42");
891 
892   COMPARE(orn(w0, wzr, Operand(w1)), "mvn w0, w1");
893   COMPARE(orn(w2, wzr, Operand(w3, ASR, 5)), "mvn w2, w3, asr #5");
894   COMPARE(orn(x0, xzr, Operand(x1)), "mvn x0, x1");
895   COMPARE(orn(x2, xzr, Operand(x3, ASR, 42)), "mvn x2, x3, asr #42");
896 
897   COMPARE(orr(w0, wzr, Operand(w1)), "mov w0, w1");
898   COMPARE(orr(x0, xzr, Operand(x1)), "mov x0, x1");
899   COMPARE(orr(w16, wzr, Operand(w17, LSL, 1)), "orr w16, wzr, w17, lsl #1");
900   COMPARE(orr(x16, xzr, Operand(x17, ASR, 2)), "orr x16, xzr, x17, asr #2");
901 
902   CLEANUP();
903 }
904 
905 
TEST(dp_2_source)906 TEST(dp_2_source) {
907   SETUP();
908 
909   COMPARE(lslv(w0, w1, w2), "lsl w0, w1, w2");
910   COMPARE(lslv(x3, x4, x5), "lsl x3, x4, x5");
911   COMPARE(lsrv(w6, w7, w8), "lsr w6, w7, w8");
912   COMPARE(lsrv(x9, x10, x11), "lsr x9, x10, x11");
913   COMPARE(asrv(w12, w13, w14), "asr w12, w13, w14");
914   COMPARE(asrv(x15, x16, x17), "asr x15, x16, x17");
915   COMPARE(rorv(w18, w19, w20), "ror w18, w19, w20");
916   COMPARE(rorv(x21, x22, x23), "ror x21, x22, x23");
917 
918   CLEANUP();
919 }
920 
921 
TEST(adr)922 TEST(adr) {
923   SETUP();
924 
925   COMPARE_PREFIX(adr(x0, INT64_C(0)), "adr x0, #+0x0");
926   COMPARE_PREFIX(adr(x1, 1), "adr x1, #+0x1");
927   COMPARE_PREFIX(adr(x2, -1), "adr x2, #-0x1");
928   COMPARE_PREFIX(adr(x3, 4), "adr x3, #+0x4");
929   COMPARE_PREFIX(adr(x4, -4), "adr x4, #-0x4");
930   COMPARE_PREFIX(adr(x5, 0x000fffff), "adr x5, #+0xfffff");
931   COMPARE_PREFIX(adr(x6, -0x00100000), "adr x6, #-0x100000");
932   COMPARE_PREFIX(adr(xzr, INT64_C(0)), "adr xzr, #+0x0");
933 
934   CLEANUP();
935 }
936 
937 
TEST(adrp)938 TEST(adrp) {
939   SETUP();
940 
941   COMPARE_PREFIX(adrp(x0, INT64_C(0)), "adrp x0, #+0x0");
942   COMPARE_PREFIX(adrp(x1, 1), "adrp x1, #+0x1000");
943   COMPARE_PREFIX(adrp(x2, -1), "adrp x2, #-0x1000");
944   COMPARE_PREFIX(adrp(x3, 4), "adrp x3, #+0x4000");
945   COMPARE_PREFIX(adrp(x4, -4), "adrp x4, #-0x4000");
946   COMPARE_PREFIX(adrp(x5, 0x000fffff), "adrp x5, #+0xfffff000");
947   COMPARE_PREFIX(adrp(x6, -0x00100000), "adrp x6, #-0x100000000");
948   COMPARE_PREFIX(adrp(xzr, INT64_C(0)), "adrp xzr, #+0x0");
949 
950   CLEANUP();
951 }
952 
953 
TEST(branch)954 TEST(branch) {
955   SETUP();
956 
957 #define INST_OFF(x) (INT64_C(x) >> kInstructionSizeLog2)
958   COMPARE_PREFIX(b(INST_OFF(0x4)), "b #+0x4");
959   COMPARE_PREFIX(b(INST_OFF(-0x4)), "b #-0x4");
960   COMPARE_PREFIX(b(INST_OFF(0x7fffffc)), "b #+0x7fffffc");
961   COMPARE_PREFIX(b(INST_OFF(-0x8000000)), "b #-0x8000000");
962   COMPARE_PREFIX(b(INST_OFF(0xffffc), eq), "b.eq #+0xffffc");
963   COMPARE_PREFIX(b(INST_OFF(-0x100000), mi), "b.mi #-0x100000");
964   COMPARE_PREFIX(b(INST_OFF(0xffffc), al), "b.al #+0xffffc");
965   COMPARE_PREFIX(b(INST_OFF(-0x100000), nv), "b.nv #-0x100000");
966   COMPARE_PREFIX(bl(INST_OFF(0x4)), "bl #+0x4");
967   COMPARE_PREFIX(bl(INST_OFF(-0x4)), "bl #-0x4");
968   COMPARE_PREFIX(bl(INST_OFF(0xffffc)), "bl #+0xffffc");
969   COMPARE_PREFIX(bl(INST_OFF(-0x100000)), "bl #-0x100000");
970   COMPARE_PREFIX(cbz(w0, INST_OFF(0xffffc)), "cbz w0, #+0xffffc");
971   COMPARE_PREFIX(cbz(x1, INST_OFF(-0x100000)), "cbz x1, #-0x100000");
972   COMPARE_PREFIX(cbnz(w2, INST_OFF(0xffffc)), "cbnz w2, #+0xffffc");
973   COMPARE_PREFIX(cbnz(x3, INST_OFF(-0x100000)), "cbnz x3, #-0x100000");
974   COMPARE_PREFIX(tbz(w4, 0, INST_OFF(0x7ffc)), "tbz w4, #0, #+0x7ffc");
975   COMPARE_PREFIX(tbz(x5, 63, INST_OFF(-0x8000)), "tbz x5, #63, #-0x8000");
976   COMPARE_PREFIX(tbz(w6, 31, INST_OFF(0)), "tbz w6, #31, #+0x0");
977   COMPARE_PREFIX(tbz(x7, 31, INST_OFF(0x4)), "tbz w7, #31, #+0x4");
978   COMPARE_PREFIX(tbz(x8, 32, INST_OFF(0x8)), "tbz x8, #32, #+0x8");
979   COMPARE_PREFIX(tbnz(w8, 0, INST_OFF(0x7ffc)), "tbnz w8, #0, #+0x7ffc");
980   COMPARE_PREFIX(tbnz(x9, 63, INST_OFF(-0x8000)), "tbnz x9, #63, #-0x8000");
981   COMPARE_PREFIX(tbnz(w10, 31, INST_OFF(0)), "tbnz w10, #31, #+0x0");
982   COMPARE_PREFIX(tbnz(x11, 31, INST_OFF(0x4)), "tbnz w11, #31, #+0x4");
983   COMPARE_PREFIX(tbnz(x12, 32, INST_OFF(0x8)), "tbnz x12, #32, #+0x8");
984   COMPARE(br(x0), "br x0");
985   COMPARE(blr(x1), "blr x1");
986   COMPARE(ret(x2), "ret x2");
987   COMPARE(ret(lr), "ret")
988 
989   CLEANUP();
990 }
991 
992 
TEST(load_store)993 TEST(load_store) {
994   SETUP();
995 
996   COMPARE(ldr(w0, MemOperand(x1)), "ldr w0, [x1]");
997   COMPARE(ldr(w2, MemOperand(x3, 4)), "ldr w2, [x3, #4]");
998   COMPARE(ldr(w4, MemOperand(x5, 16380)), "ldr w4, [x5, #16380]");
999   COMPARE(ldr(x6, MemOperand(x7)), "ldr x6, [x7]");
1000   COMPARE(ldr(x8, MemOperand(x9, 8)), "ldr x8, [x9, #8]");
1001   COMPARE(ldr(x10, MemOperand(x11, 32760)), "ldr x10, [x11, #32760]");
1002   COMPARE(str(w12, MemOperand(x13)), "str w12, [x13]");
1003   COMPARE(str(w14, MemOperand(x15, 4)), "str w14, [x15, #4]");
1004   COMPARE(str(w16, MemOperand(x17, 16380)), "str w16, [x17, #16380]");
1005   COMPARE(str(x18, MemOperand(x19)), "str x18, [x19]");
1006   COMPARE(str(x20, MemOperand(x21, 8)), "str x20, [x21, #8]");
1007   COMPARE(str(x22, MemOperand(x23, 32760)), "str x22, [x23, #32760]");
1008 
1009   COMPARE(ldr(w0, MemOperand(x1, 4, PreIndex)), "ldr w0, [x1, #4]!");
1010   COMPARE(ldr(w2, MemOperand(x3, 255, PreIndex)), "ldr w2, [x3, #255]!");
1011   COMPARE(ldr(w4, MemOperand(x5, -256, PreIndex)), "ldr w4, [x5, #-256]!");
1012   COMPARE(ldr(x6, MemOperand(x7, 8, PreIndex)), "ldr x6, [x7, #8]!");
1013   COMPARE(ldr(x8, MemOperand(x9, 255, PreIndex)), "ldr x8, [x9, #255]!");
1014   COMPARE(ldr(x10, MemOperand(x11, -256, PreIndex)), "ldr x10, [x11, #-256]!");
1015   COMPARE(str(w12, MemOperand(x13, 4, PreIndex)), "str w12, [x13, #4]!");
1016   COMPARE(str(w14, MemOperand(x15, 255, PreIndex)), "str w14, [x15, #255]!");
1017   COMPARE(str(w16, MemOperand(x17, -256, PreIndex)), "str w16, [x17, #-256]!");
1018   COMPARE(str(x18, MemOperand(x19, 8, PreIndex)), "str x18, [x19, #8]!");
1019   COMPARE(str(x20, MemOperand(x21, 255, PreIndex)), "str x20, [x21, #255]!");
1020   COMPARE(str(x22, MemOperand(x23, -256, PreIndex)), "str x22, [x23, #-256]!");
1021 
1022   COMPARE(ldr(w0, MemOperand(x1, 4, PostIndex)), "ldr w0, [x1], #4");
1023   COMPARE(ldr(w2, MemOperand(x3, 255, PostIndex)), "ldr w2, [x3], #255");
1024   COMPARE(ldr(w4, MemOperand(x5, -256, PostIndex)), "ldr w4, [x5], #-256");
1025   COMPARE(ldr(x6, MemOperand(x7, 8, PostIndex)), "ldr x6, [x7], #8");
1026   COMPARE(ldr(x8, MemOperand(x9, 255, PostIndex)), "ldr x8, [x9], #255");
1027   COMPARE(ldr(x10, MemOperand(x11, -256, PostIndex)), "ldr x10, [x11], #-256");
1028   COMPARE(str(w12, MemOperand(x13, 4, PostIndex)), "str w12, [x13], #4");
1029   COMPARE(str(w14, MemOperand(x15, 255, PostIndex)), "str w14, [x15], #255");
1030   COMPARE(str(w16, MemOperand(x17, -256, PostIndex)), "str w16, [x17], #-256");
1031   COMPARE(str(x18, MemOperand(x19, 8, PostIndex)), "str x18, [x19], #8");
1032   COMPARE(str(x20, MemOperand(x21, 255, PostIndex)), "str x20, [x21], #255");
1033   COMPARE(str(x22, MemOperand(x23, -256, PostIndex)), "str x22, [x23], #-256");
1034 
1035   COMPARE(ldr(w24, MemOperand(sp)), "ldr w24, [sp]");
1036   COMPARE(ldr(x25, MemOperand(sp, 8)), "ldr x25, [sp, #8]");
1037   COMPARE(str(w26, MemOperand(sp, 4, PreIndex)), "str w26, [sp, #4]!");
1038   COMPARE(str(x27, MemOperand(sp, -8, PostIndex)), "str x27, [sp], #-8");
1039 
1040   COMPARE(ldrsw(x0, MemOperand(x1)), "ldrsw x0, [x1]");
1041   COMPARE(ldrsw(x2, MemOperand(x3, 8)), "ldrsw x2, [x3, #8]");
1042   COMPARE(ldrsw(x4, MemOperand(x5, 42, PreIndex)), "ldrsw x4, [x5, #42]!");
1043   COMPARE(ldrsw(x6, MemOperand(x7, -11, PostIndex)), "ldrsw x6, [x7], #-11");
1044 
1045   CLEANUP();
1046 }
1047 
1048 
TEST(load_store_regoffset)1049 TEST(load_store_regoffset) {
1050   SETUP();
1051 
1052   COMPARE(ldr(w0, MemOperand(x1, w2, UXTW)), "ldr w0, [x1, w2, uxtw]");
1053   COMPARE(ldr(w3, MemOperand(x4, w5, UXTW, 2)), "ldr w3, [x4, w5, uxtw #2]");
1054   COMPARE(ldr(w6, MemOperand(x7, x8)), "ldr w6, [x7, x8]");
1055   COMPARE(ldr(w9, MemOperand(x10, x11, LSL, 2)), "ldr w9, [x10, x11, lsl #2]");
1056   COMPARE(ldr(w12, MemOperand(x13, w14, SXTW)), "ldr w12, [x13, w14, sxtw]");
1057   COMPARE(ldr(w15, MemOperand(x16, w17, SXTW, 2)),
1058           "ldr w15, [x16, w17, sxtw #2]");
1059   COMPARE(ldr(w18, MemOperand(x19, x20, SXTX)), "ldr w18, [x19, x20, sxtx]");
1060   COMPARE(ldr(w21, MemOperand(x22, x23, SXTX, 2)),
1061           "ldr w21, [x22, x23, sxtx #2]");
1062   COMPARE(ldr(x0, MemOperand(x1, w2, UXTW)), "ldr x0, [x1, w2, uxtw]");
1063   COMPARE(ldr(x3, MemOperand(x4, w5, UXTW, 3)), "ldr x3, [x4, w5, uxtw #3]");
1064   COMPARE(ldr(x6, MemOperand(x7, x8)), "ldr x6, [x7, x8]");
1065   COMPARE(ldr(x9, MemOperand(x10, x11, LSL, 3)), "ldr x9, [x10, x11, lsl #3]");
1066   COMPARE(ldr(x12, MemOperand(x13, w14, SXTW)), "ldr x12, [x13, w14, sxtw]");
1067   COMPARE(ldr(x15, MemOperand(x16, w17, SXTW, 3)),
1068           "ldr x15, [x16, w17, sxtw #3]");
1069   COMPARE(ldr(x18, MemOperand(x19, x20, SXTX)), "ldr x18, [x19, x20, sxtx]");
1070   COMPARE(ldr(x21, MemOperand(x22, x23, SXTX, 3)),
1071           "ldr x21, [x22, x23, sxtx #3]");
1072 
1073   COMPARE(str(w0, MemOperand(x1, w2, UXTW)), "str w0, [x1, w2, uxtw]");
1074   COMPARE(str(w3, MemOperand(x4, w5, UXTW, 2)), "str w3, [x4, w5, uxtw #2]");
1075   COMPARE(str(w6, MemOperand(x7, x8)), "str w6, [x7, x8]");
1076   COMPARE(str(w9, MemOperand(x10, x11, LSL, 2)), "str w9, [x10, x11, lsl #2]");
1077   COMPARE(str(w12, MemOperand(x13, w14, SXTW)), "str w12, [x13, w14, sxtw]");
1078   COMPARE(str(w15, MemOperand(x16, w17, SXTW, 2)),
1079           "str w15, [x16, w17, sxtw #2]");
1080   COMPARE(str(w18, MemOperand(x19, x20, SXTX)), "str w18, [x19, x20, sxtx]");
1081   COMPARE(str(w21, MemOperand(x22, x23, SXTX, 2)),
1082           "str w21, [x22, x23, sxtx #2]");
1083   COMPARE(str(x0, MemOperand(x1, w2, UXTW)), "str x0, [x1, w2, uxtw]");
1084   COMPARE(str(x3, MemOperand(x4, w5, UXTW, 3)), "str x3, [x4, w5, uxtw #3]");
1085   COMPARE(str(x6, MemOperand(x7, x8)), "str x6, [x7, x8]");
1086   COMPARE(str(x9, MemOperand(x10, x11, LSL, 3)), "str x9, [x10, x11, lsl #3]");
1087   COMPARE(str(x12, MemOperand(x13, w14, SXTW)), "str x12, [x13, w14, sxtw]");
1088   COMPARE(str(x15, MemOperand(x16, w17, SXTW, 3)),
1089           "str x15, [x16, w17, sxtw #3]");
1090   COMPARE(str(x18, MemOperand(x19, x20, SXTX)), "str x18, [x19, x20, sxtx]");
1091   COMPARE(str(x21, MemOperand(x22, x23, SXTX, 3)),
1092           "str x21, [x22, x23, sxtx #3]");
1093 
1094   COMPARE(ldrb(w0, MemOperand(x1, w2, UXTW)), "ldrb w0, [x1, w2, uxtw]");
1095   COMPARE(ldrb(w6, MemOperand(x7, x8)), "ldrb w6, [x7, x8]");
1096   COMPARE(ldrb(w12, MemOperand(x13, w14, SXTW)), "ldrb w12, [x13, w14, sxtw]");
1097   COMPARE(ldrb(w18, MemOperand(x19, x20, SXTX)), "ldrb w18, [x19, x20, sxtx]");
1098   COMPARE(strb(w0, MemOperand(x1, w2, UXTW)), "strb w0, [x1, w2, uxtw]");
1099   COMPARE(strb(w6, MemOperand(x7, x8)), "strb w6, [x7, x8]");
1100   COMPARE(strb(w12, MemOperand(x13, w14, SXTW)), "strb w12, [x13, w14, sxtw]");
1101   COMPARE(strb(w18, MemOperand(x19, x20, SXTX)), "strb w18, [x19, x20, sxtx]");
1102 
1103   COMPARE(ldrh(w0, MemOperand(x1, w2, UXTW)), "ldrh w0, [x1, w2, uxtw]");
1104   COMPARE(ldrh(w3, MemOperand(x4, w5, UXTW, 1)), "ldrh w3, [x4, w5, uxtw #1]");
1105   COMPARE(ldrh(w6, MemOperand(x7, x8)), "ldrh w6, [x7, x8]");
1106   COMPARE(ldrh(w9, MemOperand(x10, x11, LSL, 1)),
1107           "ldrh w9, [x10, x11, lsl #1]");
1108   COMPARE(ldrh(w12, MemOperand(x13, w14, SXTW)), "ldrh w12, [x13, w14, sxtw]");
1109   COMPARE(ldrh(w15, MemOperand(x16, w17, SXTW, 1)),
1110           "ldrh w15, [x16, w17, sxtw #1]");
1111   COMPARE(ldrh(w18, MemOperand(x19, x20, SXTX)), "ldrh w18, [x19, x20, sxtx]");
1112   COMPARE(ldrh(w21, MemOperand(x22, x23, SXTX, 1)),
1113           "ldrh w21, [x22, x23, sxtx #1]");
1114   COMPARE(strh(w0, MemOperand(x1, w2, UXTW)), "strh w0, [x1, w2, uxtw]");
1115   COMPARE(strh(w3, MemOperand(x4, w5, UXTW, 1)), "strh w3, [x4, w5, uxtw #1]");
1116   COMPARE(strh(w6, MemOperand(x7, x8)), "strh w6, [x7, x8]");
1117   COMPARE(strh(w9, MemOperand(x10, x11, LSL, 1)),
1118           "strh w9, [x10, x11, lsl #1]");
1119   COMPARE(strh(w12, MemOperand(x13, w14, SXTW)), "strh w12, [x13, w14, sxtw]");
1120   COMPARE(strh(w15, MemOperand(x16, w17, SXTW, 1)),
1121           "strh w15, [x16, w17, sxtw #1]");
1122   COMPARE(strh(w18, MemOperand(x19, x20, SXTX)), "strh w18, [x19, x20, sxtx]");
1123   COMPARE(strh(w21, MemOperand(x22, x23, SXTX, 1)),
1124           "strh w21, [x22, x23, sxtx #1]");
1125 
1126   COMPARE(ldr(x0, MemOperand(sp, wzr, SXTW)), "ldr x0, [sp, wzr, sxtw]");
1127   COMPARE(str(x1, MemOperand(sp, xzr)), "str x1, [sp, xzr]");
1128 
1129   CLEANUP();
1130 }
1131 
1132 
TEST(load_store_byte)1133 TEST(load_store_byte) {
1134   SETUP();
1135 
1136   COMPARE(ldrb(w0, MemOperand(x1)), "ldrb w0, [x1]");
1137   COMPARE(ldrb(x2, MemOperand(x3)), "ldrb w2, [x3]");
1138   COMPARE(ldrb(w4, MemOperand(x5, 4095)), "ldrb w4, [x5, #4095]");
1139   COMPARE(ldrb(w6, MemOperand(x7, 255, PreIndex)), "ldrb w6, [x7, #255]!");
1140   COMPARE(ldrb(w8, MemOperand(x9, -256, PreIndex)), "ldrb w8, [x9, #-256]!");
1141   COMPARE(ldrb(w10, MemOperand(x11, 255, PostIndex)), "ldrb w10, [x11], #255");
1142   COMPARE(ldrb(w12, MemOperand(x13, -256, PostIndex)),
1143           "ldrb w12, [x13], #-256");
1144   COMPARE(strb(w14, MemOperand(x15)), "strb w14, [x15]");
1145   COMPARE(strb(x16, MemOperand(x17)), "strb w16, [x17]");
1146   COMPARE(strb(w18, MemOperand(x19, 4095)), "strb w18, [x19, #4095]");
1147   COMPARE(strb(w20, MemOperand(x21, 255, PreIndex)), "strb w20, [x21, #255]!");
1148   COMPARE(strb(w22, MemOperand(x23, -256, PreIndex)),
1149           "strb w22, [x23, #-256]!");
1150   COMPARE(strb(w24, MemOperand(x25, 255, PostIndex)), "strb w24, [x25], #255");
1151   COMPARE(strb(w26, MemOperand(x27, -256, PostIndex)),
1152           "strb w26, [x27], #-256");
1153   COMPARE(ldrb(w28, MemOperand(sp, 3, PostIndex)), "ldrb w28, [sp], #3");
1154   COMPARE(strb(x29, MemOperand(sp, -42, PreIndex)), "strb w29, [sp, #-42]!");
1155   COMPARE(ldrsb(w0, MemOperand(x1)), "ldrsb w0, [x1]");
1156   COMPARE(ldrsb(x2, MemOperand(x3, 8)), "ldrsb x2, [x3, #8]");
1157   COMPARE(ldrsb(w4, MemOperand(x5, 42, PreIndex)), "ldrsb w4, [x5, #42]!");
1158   COMPARE(ldrsb(x6, MemOperand(x7, -11, PostIndex)), "ldrsb x6, [x7], #-11");
1159 
1160   CLEANUP();
1161 }
1162 
1163 
TEST(load_store_half)1164 TEST(load_store_half) {
1165   SETUP();
1166 
1167   COMPARE(ldrh(w0, MemOperand(x1)), "ldrh w0, [x1]");
1168   COMPARE(ldrh(x2, MemOperand(x3)), "ldrh w2, [x3]");
1169   COMPARE(ldrh(w4, MemOperand(x5, 8190)), "ldrh w4, [x5, #8190]");
1170   COMPARE(ldrh(w6, MemOperand(x7, 255, PreIndex)), "ldrh w6, [x7, #255]!");
1171   COMPARE(ldrh(w8, MemOperand(x9, -256, PreIndex)), "ldrh w8, [x9, #-256]!");
1172   COMPARE(ldrh(w10, MemOperand(x11, 255, PostIndex)), "ldrh w10, [x11], #255");
1173   COMPARE(ldrh(w12, MemOperand(x13, -256, PostIndex)),
1174           "ldrh w12, [x13], #-256");
1175   COMPARE(strh(w14, MemOperand(x15)), "strh w14, [x15]");
1176   COMPARE(strh(x16, MemOperand(x17)), "strh w16, [x17]");
1177   COMPARE(strh(w18, MemOperand(x19, 8190)), "strh w18, [x19, #8190]");
1178   COMPARE(strh(w20, MemOperand(x21, 255, PreIndex)), "strh w20, [x21, #255]!");
1179   COMPARE(strh(w22, MemOperand(x23, -256, PreIndex)),
1180           "strh w22, [x23, #-256]!");
1181   COMPARE(strh(w24, MemOperand(x25, 255, PostIndex)), "strh w24, [x25], #255");
1182   COMPARE(strh(w26, MemOperand(x27, -256, PostIndex)),
1183           "strh w26, [x27], #-256");
1184   COMPARE(ldrh(w28, MemOperand(sp, 3, PostIndex)), "ldrh w28, [sp], #3");
1185   COMPARE(strh(x29, MemOperand(sp, -42, PreIndex)), "strh w29, [sp, #-42]!");
1186   COMPARE(ldrh(w30, MemOperand(x0, 255)), "ldurh w30, [x0, #255]");
1187   COMPARE(ldrh(x1, MemOperand(x2, -256)), "ldurh w1, [x2, #-256]");
1188   COMPARE(strh(w3, MemOperand(x4, 255)), "sturh w3, [x4, #255]");
1189   COMPARE(strh(x5, MemOperand(x6, -256)), "sturh w5, [x6, #-256]");
1190   COMPARE(ldrsh(w0, MemOperand(x1)), "ldrsh w0, [x1]");
1191   COMPARE(ldrsh(w2, MemOperand(x3, 8)), "ldrsh w2, [x3, #8]");
1192   COMPARE(ldrsh(w4, MemOperand(x5, 42, PreIndex)), "ldrsh w4, [x5, #42]!");
1193   COMPARE(ldrsh(x6, MemOperand(x7, -11, PostIndex)), "ldrsh x6, [x7], #-11");
1194 
1195   CLEANUP();
1196 }
1197 
1198 
TEST(load_store_v_offset)1199 TEST(load_store_v_offset) {
1200   SETUP();
1201 
1202   COMPARE(ldr(s0, MemOperand(x1)), "ldr s0, [x1]");
1203   COMPARE(ldr(s2, MemOperand(x3, 4)), "ldr s2, [x3, #4]");
1204   COMPARE(ldr(s4, MemOperand(x5, 16380)), "ldr s4, [x5, #16380]");
1205   COMPARE(ldr(d6, MemOperand(x7)), "ldr d6, [x7]");
1206   COMPARE(ldr(d8, MemOperand(x9, 8)), "ldr d8, [x9, #8]");
1207   COMPARE(ldr(d10, MemOperand(x11, 32760)), "ldr d10, [x11, #32760]");
1208   COMPARE(str(s12, MemOperand(x13)), "str s12, [x13]");
1209   COMPARE(str(s14, MemOperand(x15, 4)), "str s14, [x15, #4]");
1210   COMPARE(str(s16, MemOperand(x17, 16380)), "str s16, [x17, #16380]");
1211   COMPARE(str(d18, MemOperand(x19)), "str d18, [x19]");
1212   COMPARE(str(d20, MemOperand(x21, 8)), "str d20, [x21, #8]");
1213   COMPARE(str(d22, MemOperand(x23, 32760)), "str d22, [x23, #32760]");
1214 
1215   COMPARE(ldr(b0, MemOperand(x1)), "ldr b0, [x1]");
1216   COMPARE(ldr(b2, MemOperand(x3, 1)), "ldr b2, [x3, #1]");
1217   COMPARE(ldr(b4, MemOperand(x5, 4095)), "ldr b4, [x5, #4095]");
1218   COMPARE(ldr(h6, MemOperand(x7)), "ldr h6, [x7]");
1219   COMPARE(ldr(h8, MemOperand(x9, 2)), "ldr h8, [x9, #2]");
1220   COMPARE(ldr(h10, MemOperand(x11, 8190)), "ldr h10, [x11, #8190]");
1221   COMPARE(ldr(q12, MemOperand(x13)), "ldr q12, [x13]");
1222   COMPARE(ldr(q14, MemOperand(x15, 16)), "ldr q14, [x15, #16]");
1223   COMPARE(ldr(q16, MemOperand(x17, 65520)), "ldr q16, [x17, #65520]");
1224   COMPARE(str(b18, MemOperand(x19)), "str b18, [x19]");
1225   COMPARE(str(b20, MemOperand(x21, 1)), "str b20, [x21, #1]");
1226   COMPARE(str(b22, MemOperand(x23, 4095)), "str b22, [x23, #4095]");
1227   COMPARE(str(h24, MemOperand(x25)), "str h24, [x25]");
1228   COMPARE(str(h26, MemOperand(x27, 2)), "str h26, [x27, #2]");
1229   COMPARE(str(h28, MemOperand(x29, 8190)), "str h28, [x29, #8190]");
1230   COMPARE(str(q30, MemOperand(x30)), "str q30, [x30]");
1231   COMPARE(str(q31, MemOperand(x1, 16)), "str q31, [x1, #16]");
1232   COMPARE(str(q0, MemOperand(x3, 65520)), "str q0, [x3, #65520]");
1233 
1234   COMPARE(ldr(s24, MemOperand(sp)), "ldr s24, [sp]");
1235   COMPARE(ldr(d25, MemOperand(sp, 8)), "ldr d25, [sp, #8]");
1236   COMPARE(ldr(b26, MemOperand(sp, 1)), "ldr b26, [sp, #1]");
1237   COMPARE(ldr(h27, MemOperand(sp, 2)), "ldr h27, [sp, #2]");
1238   COMPARE(ldr(q28, MemOperand(sp, 16)), "ldr q28, [sp, #16]");
1239 
1240   CLEANUP();
1241 }
1242 
1243 
TEST(load_store_v_pre)1244 TEST(load_store_v_pre) {
1245   SETUP();
1246 
1247   COMPARE(ldr(s0, MemOperand(x1, 4, PreIndex)), "ldr s0, [x1, #4]!");
1248   COMPARE(ldr(s2, MemOperand(x3, 255, PreIndex)), "ldr s2, [x3, #255]!");
1249   COMPARE(ldr(s4, MemOperand(x5, -256, PreIndex)), "ldr s4, [x5, #-256]!");
1250   COMPARE(ldr(d6, MemOperand(x7, 8, PreIndex)), "ldr d6, [x7, #8]!");
1251   COMPARE(ldr(d8, MemOperand(x9, 255, PreIndex)), "ldr d8, [x9, #255]!");
1252   COMPARE(ldr(d10, MemOperand(x11, -256, PreIndex)), "ldr d10, [x11, #-256]!");
1253 
1254   COMPARE(str(s12, MemOperand(x13, 4, PreIndex)), "str s12, [x13, #4]!");
1255   COMPARE(str(s14, MemOperand(x15, 255, PreIndex)), "str s14, [x15, #255]!");
1256   COMPARE(str(s16, MemOperand(x17, -256, PreIndex)), "str s16, [x17, #-256]!");
1257   COMPARE(str(d18, MemOperand(x19, 8, PreIndex)), "str d18, [x19, #8]!");
1258   COMPARE(str(d20, MemOperand(x21, 255, PreIndex)), "str d20, [x21, #255]!");
1259   COMPARE(str(d22, MemOperand(x23, -256, PreIndex)), "str d22, [x23, #-256]!");
1260 
1261   COMPARE(ldr(b0, MemOperand(x1, 1, PreIndex)), "ldr b0, [x1, #1]!");
1262   COMPARE(ldr(b2, MemOperand(x3, 255, PreIndex)), "ldr b2, [x3, #255]!");
1263   COMPARE(ldr(b4, MemOperand(x5, -256, PreIndex)), "ldr b4, [x5, #-256]!");
1264   COMPARE(ldr(h6, MemOperand(x7, 2, PreIndex)), "ldr h6, [x7, #2]!");
1265   COMPARE(ldr(h8, MemOperand(x9, 255, PreIndex)), "ldr h8, [x9, #255]!");
1266   COMPARE(ldr(h10, MemOperand(x11, -256, PreIndex)), "ldr h10, [x11, #-256]!");
1267   COMPARE(ldr(q12, MemOperand(x13, 16, PreIndex)), "ldr q12, [x13, #16]!");
1268   COMPARE(ldr(q14, MemOperand(x15, 255, PreIndex)), "ldr q14, [x15, #255]!");
1269   COMPARE(ldr(q16, MemOperand(x17, -256, PreIndex)), "ldr q16, [x17, #-256]!");
1270 
1271   COMPARE(str(b18, MemOperand(x19, 1, PreIndex)), "str b18, [x19, #1]!");
1272   COMPARE(str(b20, MemOperand(x21, 255, PreIndex)), "str b20, [x21, #255]!");
1273   COMPARE(str(b22, MemOperand(x23, -256, PreIndex)), "str b22, [x23, #-256]!");
1274   COMPARE(str(h24, MemOperand(x25, 2, PreIndex)), "str h24, [x25, #2]!");
1275   COMPARE(str(h26, MemOperand(x27, 255, PreIndex)), "str h26, [x27, #255]!");
1276   COMPARE(str(h28, MemOperand(x29, -256, PreIndex)), "str h28, [x29, #-256]!");
1277   COMPARE(str(q30, MemOperand(x1, 16, PreIndex)), "str q30, [x1, #16]!");
1278   COMPARE(str(q31, MemOperand(x3, 255, PreIndex)), "str q31, [x3, #255]!");
1279   COMPARE(str(q0, MemOperand(x5, -256, PreIndex)), "str q0, [x5, #-256]!");
1280 
1281   COMPARE(str(b24, MemOperand(sp, 1, PreIndex)), "str b24, [sp, #1]!");
1282   COMPARE(str(h25, MemOperand(sp, -2, PreIndex)), "str h25, [sp, #-2]!");
1283   COMPARE(str(s26, MemOperand(sp, 4, PreIndex)), "str s26, [sp, #4]!");
1284   COMPARE(str(d27, MemOperand(sp, -8, PreIndex)), "str d27, [sp, #-8]!");
1285   COMPARE(str(q28, MemOperand(sp, 16, PreIndex)), "str q28, [sp, #16]!");
1286 
1287   CLEANUP();
1288 }
1289 
1290 
TEST(load_store_v_post)1291 TEST(load_store_v_post) {
1292   SETUP();
1293 
1294   COMPARE(ldr(s0, MemOperand(x1, 4, PostIndex)), "ldr s0, [x1], #4");
1295   COMPARE(ldr(s2, MemOperand(x3, 255, PostIndex)), "ldr s2, [x3], #255");
1296   COMPARE(ldr(s4, MemOperand(x5, -256, PostIndex)), "ldr s4, [x5], #-256");
1297   COMPARE(ldr(d6, MemOperand(x7, 8, PostIndex)), "ldr d6, [x7], #8");
1298   COMPARE(ldr(d8, MemOperand(x9, 255, PostIndex)), "ldr d8, [x9], #255");
1299   COMPARE(ldr(d10, MemOperand(x11, -256, PostIndex)), "ldr d10, [x11], #-256");
1300 
1301   COMPARE(str(s12, MemOperand(x13, 4, PostIndex)), "str s12, [x13], #4");
1302   COMPARE(str(s14, MemOperand(x15, 255, PostIndex)), "str s14, [x15], #255");
1303   COMPARE(str(s16, MemOperand(x17, -256, PostIndex)), "str s16, [x17], #-256");
1304   COMPARE(str(d18, MemOperand(x19, 8, PostIndex)), "str d18, [x19], #8");
1305   COMPARE(str(d20, MemOperand(x21, 255, PostIndex)), "str d20, [x21], #255");
1306   COMPARE(str(d22, MemOperand(x23, -256, PostIndex)), "str d22, [x23], #-256");
1307 
1308   COMPARE(ldr(b0, MemOperand(x1, 4, PostIndex)), "ldr b0, [x1], #4");
1309   COMPARE(ldr(b2, MemOperand(x3, 255, PostIndex)), "ldr b2, [x3], #255");
1310   COMPARE(ldr(b4, MemOperand(x5, -256, PostIndex)), "ldr b4, [x5], #-256");
1311   COMPARE(ldr(h6, MemOperand(x7, 8, PostIndex)), "ldr h6, [x7], #8");
1312   COMPARE(ldr(h8, MemOperand(x9, 255, PostIndex)), "ldr h8, [x9], #255");
1313   COMPARE(ldr(h10, MemOperand(x11, -256, PostIndex)), "ldr h10, [x11], #-256");
1314   COMPARE(ldr(q12, MemOperand(x13, 8, PostIndex)), "ldr q12, [x13], #8");
1315   COMPARE(ldr(q14, MemOperand(x15, 255, PostIndex)), "ldr q14, [x15], #255");
1316   COMPARE(ldr(q16, MemOperand(x17, -256, PostIndex)), "ldr q16, [x17], #-256");
1317 
1318   COMPARE(str(b18, MemOperand(x19, 4, PostIndex)), "str b18, [x19], #4");
1319   COMPARE(str(b20, MemOperand(x21, 255, PostIndex)), "str b20, [x21], #255");
1320   COMPARE(str(b22, MemOperand(x23, -256, PostIndex)), "str b22, [x23], #-256");
1321   COMPARE(str(h24, MemOperand(x25, 8, PostIndex)), "str h24, [x25], #8");
1322   COMPARE(str(h26, MemOperand(x27, 255, PostIndex)), "str h26, [x27], #255");
1323   COMPARE(str(h28, MemOperand(x29, -256, PostIndex)), "str h28, [x29], #-256");
1324   COMPARE(str(q30, MemOperand(x1, 8, PostIndex)), "str q30, [x1], #8");
1325   COMPARE(str(q31, MemOperand(x3, 255, PostIndex)), "str q31, [x3], #255");
1326   COMPARE(str(q0, MemOperand(x5, -256, PostIndex)), "str q0, [x5], #-256");
1327 
1328   COMPARE(ldr(b24, MemOperand(sp, -1, PreIndex)), "ldr b24, [sp, #-1]!");
1329   COMPARE(ldr(h25, MemOperand(sp, 2, PreIndex)), "ldr h25, [sp, #2]!");
1330   COMPARE(ldr(s26, MemOperand(sp, -4, PreIndex)), "ldr s26, [sp, #-4]!");
1331   COMPARE(ldr(d27, MemOperand(sp, 8, PreIndex)), "ldr d27, [sp, #8]!");
1332   COMPARE(ldr(q28, MemOperand(sp, -16, PreIndex)), "ldr q28, [sp, #-16]!");
1333 
1334   CLEANUP();
1335 }
1336 
1337 
TEST(load_store_v_regoffset)1338 TEST(load_store_v_regoffset) {
1339   SETUP();
1340 
1341   COMPARE(ldr(b0, MemOperand(x1, x2)), "ldr b0, [x1, x2]");
1342   COMPARE(ldr(b1, MemOperand(x2, w3, UXTW)), "ldr b1, [x2, w3, uxtw]");
1343   COMPARE(ldr(b2, MemOperand(x3, w4, SXTW)), "ldr b2, [x3, w4, sxtw]");
1344   // We can't assemble this instruction, but we check it disassembles correctly.
1345   COMPARE(dci(0x3c657883), "ldr b3, [x4, x5, lsl #0]");
1346   COMPARE(ldr(b30, MemOperand(sp, xzr)), "ldr b30, [sp, xzr]");
1347   COMPARE(ldr(b31, MemOperand(sp, wzr, UXTW)), "ldr b31, [sp, wzr, uxtw]");
1348 
1349   COMPARE(ldr(h0, MemOperand(x1, x2)), "ldr h0, [x1, x2]");
1350   COMPARE(ldr(h1, MemOperand(x2, w3, UXTW)), "ldr h1, [x2, w3, uxtw]");
1351   COMPARE(ldr(h2, MemOperand(x3, w4, SXTW)), "ldr h2, [x3, w4, sxtw]");
1352   COMPARE(ldr(h3, MemOperand(x4, w5, UXTW, 1)), "ldr h3, [x4, w5, uxtw #1]");
1353   COMPARE(ldr(h4, MemOperand(x5, w5, SXTW, 1)), "ldr h4, [x5, w5, sxtw #1]");
1354   COMPARE(ldr(h30, MemOperand(sp, xzr)), "ldr h30, [sp, xzr]");
1355   COMPARE(ldr(h31, MemOperand(sp, wzr, SXTW, 1)),
1356           "ldr h31, [sp, wzr, sxtw #1]");
1357 
1358   COMPARE(ldr(s0, MemOperand(x1, x2)), "ldr s0, [x1, x2]");
1359   COMPARE(ldr(s1, MemOperand(x2, w3, UXTW)), "ldr s1, [x2, w3, uxtw]");
1360   COMPARE(ldr(s2, MemOperand(x3, w4, SXTW)), "ldr s2, [x3, w4, sxtw]");
1361   COMPARE(ldr(s3, MemOperand(x4, w5, UXTW, 2)), "ldr s3, [x4, w5, uxtw #2]");
1362   COMPARE(ldr(s4, MemOperand(x5, w5, SXTW, 2)), "ldr s4, [x5, w5, sxtw #2]");
1363   COMPARE(ldr(s30, MemOperand(sp, xzr)), "ldr s30, [sp, xzr]");
1364   COMPARE(ldr(s31, MemOperand(sp, wzr, SXTW, 2)),
1365           "ldr s31, [sp, wzr, sxtw #2]");
1366 
1367   COMPARE(ldr(d0, MemOperand(x1, x2)), "ldr d0, [x1, x2]");
1368   COMPARE(ldr(d1, MemOperand(x2, w3, UXTW)), "ldr d1, [x2, w3, uxtw]");
1369   COMPARE(ldr(d2, MemOperand(x3, w4, SXTW)), "ldr d2, [x3, w4, sxtw]");
1370   COMPARE(ldr(d3, MemOperand(x4, w5, UXTW, 3)), "ldr d3, [x4, w5, uxtw #3]");
1371   COMPARE(ldr(d4, MemOperand(x5, w5, SXTW, 3)), "ldr d4, [x5, w5, sxtw #3]");
1372   COMPARE(ldr(d30, MemOperand(sp, xzr)), "ldr d30, [sp, xzr]");
1373   COMPARE(ldr(d31, MemOperand(sp, wzr, SXTW, 3)),
1374           "ldr d31, [sp, wzr, sxtw #3]");
1375 
1376   COMPARE(ldr(q0, MemOperand(x1, x2)), "ldr q0, [x1, x2]");
1377   COMPARE(ldr(q1, MemOperand(x2, w3, UXTW)), "ldr q1, [x2, w3, uxtw]");
1378   COMPARE(ldr(q2, MemOperand(x3, w4, SXTW)), "ldr q2, [x3, w4, sxtw]");
1379   COMPARE(ldr(q3, MemOperand(x4, w5, UXTW, 4)), "ldr q3, [x4, w5, uxtw #4]");
1380   COMPARE(ldr(q4, MemOperand(x5, w5, SXTW, 4)), "ldr q4, [x5, w5, sxtw #4]");
1381   COMPARE(ldr(q30, MemOperand(sp, xzr)), "ldr q30, [sp, xzr]");
1382   COMPARE(ldr(q31, MemOperand(sp, wzr, SXTW, 4)),
1383           "ldr q31, [sp, wzr, sxtw #4]");
1384 
1385   COMPARE(str(b0, MemOperand(x1, x2)), "str b0, [x1, x2]");
1386   COMPARE(str(b1, MemOperand(x2, w3, UXTW)), "str b1, [x2, w3, uxtw]");
1387   COMPARE(str(b2, MemOperand(x3, w4, SXTW)), "str b2, [x3, w4, sxtw]");
1388   // We can't assemble this instruction, but we check it disassembles correctly.
1389   COMPARE(dci(0x3c257883), "str b3, [x4, x5, lsl #0]");
1390   COMPARE(str(b30, MemOperand(sp, xzr)), "str b30, [sp, xzr]");
1391   COMPARE(str(b31, MemOperand(sp, wzr, UXTW)), "str b31, [sp, wzr, uxtw]");
1392 
1393   COMPARE(str(h0, MemOperand(x1, x2)), "str h0, [x1, x2]");
1394   COMPARE(str(h1, MemOperand(x2, w3, UXTW)), "str h1, [x2, w3, uxtw]");
1395   COMPARE(str(h2, MemOperand(x3, w4, SXTW)), "str h2, [x3, w4, sxtw]");
1396   COMPARE(str(h3, MemOperand(x4, w5, UXTW, 1)), "str h3, [x4, w5, uxtw #1]");
1397   COMPARE(str(h4, MemOperand(x5, w5, SXTW, 1)), "str h4, [x5, w5, sxtw #1]");
1398   COMPARE(str(h30, MemOperand(sp, xzr)), "str h30, [sp, xzr]");
1399   COMPARE(str(h31, MemOperand(sp, wzr, SXTW, 1)),
1400           "str h31, [sp, wzr, sxtw #1]");
1401 
1402   COMPARE(str(s0, MemOperand(x1, x2)), "str s0, [x1, x2]");
1403   COMPARE(str(s1, MemOperand(x2, w3, UXTW)), "str s1, [x2, w3, uxtw]");
1404   COMPARE(str(s2, MemOperand(x3, w4, SXTW)), "str s2, [x3, w4, sxtw]");
1405   COMPARE(str(s3, MemOperand(x4, w5, UXTW, 2)), "str s3, [x4, w5, uxtw #2]");
1406   COMPARE(str(s4, MemOperand(x5, w5, SXTW, 2)), "str s4, [x5, w5, sxtw #2]");
1407   COMPARE(str(s30, MemOperand(sp, xzr)), "str s30, [sp, xzr]");
1408   COMPARE(str(s31, MemOperand(sp, wzr, SXTW, 2)),
1409           "str s31, [sp, wzr, sxtw #2]");
1410 
1411   COMPARE(str(d0, MemOperand(x1, x2)), "str d0, [x1, x2]");
1412   COMPARE(str(d1, MemOperand(x2, w3, UXTW)), "str d1, [x2, w3, uxtw]");
1413   COMPARE(str(d2, MemOperand(x3, w4, SXTW)), "str d2, [x3, w4, sxtw]");
1414   COMPARE(str(d3, MemOperand(x4, w5, UXTW, 3)), "str d3, [x4, w5, uxtw #3]");
1415   COMPARE(str(d4, MemOperand(x5, w5, SXTW, 3)), "str d4, [x5, w5, sxtw #3]");
1416   COMPARE(str(d30, MemOperand(sp, xzr)), "str d30, [sp, xzr]");
1417   COMPARE(str(d31, MemOperand(sp, wzr, SXTW, 3)),
1418           "str d31, [sp, wzr, sxtw #3]");
1419 
1420   COMPARE(str(q0, MemOperand(x1, x2)), "str q0, [x1, x2]");
1421   COMPARE(str(q1, MemOperand(x2, w3, UXTW)), "str q1, [x2, w3, uxtw]");
1422   COMPARE(str(q2, MemOperand(x3, w4, SXTW)), "str q2, [x3, w4, sxtw]");
1423   COMPARE(str(q3, MemOperand(x4, w5, UXTW, 4)), "str q3, [x4, w5, uxtw #4]");
1424   COMPARE(str(q4, MemOperand(x5, w5, SXTW, 4)), "str q4, [x5, w5, sxtw #4]");
1425   COMPARE(str(q30, MemOperand(sp, xzr)), "str q30, [sp, xzr]");
1426   COMPARE(str(q31, MemOperand(sp, wzr, SXTW, 4)),
1427           "str q31, [sp, wzr, sxtw #4]");
1428 
1429   CLEANUP();
1430 }
1431 
1432 
TEST(load_store_unscaled)1433 TEST(load_store_unscaled) {
1434   SETUP();
1435 
1436   // If an unscaled-offset instruction is requested, it is used, even if the
1437   // offset could be encoded in a scaled-offset instruction.
1438   COMPARE(ldurb(w0, MemOperand(x1)), "ldurb w0, [x1]");
1439   COMPARE(ldurb(x2, MemOperand(x3, 1)), "ldurb w2, [x3, #1]");
1440   COMPARE(ldurb(w4, MemOperand(x5, 255)), "ldurb w4, [x5, #255]");
1441   COMPARE(sturb(w14, MemOperand(x15)), "sturb w14, [x15]");
1442   COMPARE(sturb(x16, MemOperand(x17, 1)), "sturb w16, [x17, #1]");
1443   COMPARE(sturb(w18, MemOperand(x19, 255)), "sturb w18, [x19, #255]");
1444   COMPARE(ldursb(w0, MemOperand(x1)), "ldursb w0, [x1]");
1445   COMPARE(ldursb(w2, MemOperand(x3, 1)), "ldursb w2, [x3, #1]");
1446   COMPARE(ldursb(x2, MemOperand(x3, 255)), "ldursb x2, [x3, #255]");
1447 
1448   COMPARE(ldurh(w0, MemOperand(x1)), "ldurh w0, [x1]");
1449   COMPARE(ldurh(x2, MemOperand(x3, 2)), "ldurh w2, [x3, #2]");
1450   COMPARE(ldurh(w4, MemOperand(x5, 254)), "ldurh w4, [x5, #254]");
1451   COMPARE(sturh(w14, MemOperand(x15)), "sturh w14, [x15]");
1452   COMPARE(sturh(x16, MemOperand(x17, 2)), "sturh w16, [x17, #2]");
1453   COMPARE(sturh(w18, MemOperand(x19, 254)), "sturh w18, [x19, #254]");
1454   COMPARE(ldursh(w0, MemOperand(x1)), "ldursh w0, [x1]");
1455   COMPARE(ldursh(w2, MemOperand(x3, 2)), "ldursh w2, [x3, #2]");
1456   COMPARE(ldursh(x4, MemOperand(x5, 254)), "ldursh x4, [x5, #254]");
1457 
1458   COMPARE(ldur(w0, MemOperand(x1)), "ldur w0, [x1]");
1459   COMPARE(ldur(w2, MemOperand(x3, 4)), "ldur w2, [x3, #4]");
1460   COMPARE(ldur(w4, MemOperand(x5, 248)), "ldur w4, [x5, #248]");
1461   COMPARE(stur(w12, MemOperand(x13)), "stur w12, [x13]");
1462   COMPARE(stur(w14, MemOperand(x15, 4)), "stur w14, [x15, #4]");
1463   COMPARE(stur(w16, MemOperand(x17, 248)), "stur w16, [x17, #248]");
1464   COMPARE(ldursw(x0, MemOperand(x1)), "ldursw x0, [x1]");
1465   COMPARE(ldursw(x2, MemOperand(x3, 4)), "ldursw x2, [x3, #4]");
1466   COMPARE(ldursw(x4, MemOperand(x5, 248)), "ldursw x4, [x5, #248]");
1467 
1468   COMPARE(ldur(x6, MemOperand(x7)), "ldur x6, [x7]");
1469   COMPARE(ldur(x8, MemOperand(x9, 8)), "ldur x8, [x9, #8]");
1470   COMPARE(ldur(x10, MemOperand(x11, 248)), "ldur x10, [x11, #248]");
1471   COMPARE(stur(x18, MemOperand(x19)), "stur x18, [x19]");
1472   COMPARE(stur(x20, MemOperand(x21, 8)), "stur x20, [x21, #8]");
1473   COMPARE(stur(x22, MemOperand(x23, 248)), "stur x22, [x23, #248]");
1474 
1475   COMPARE(ldur(b0, MemOperand(x1)), "ldur b0, [x1]");
1476   COMPARE(ldur(h2, MemOperand(x3, -1)), "ldur h2, [x3, #-1]");
1477   COMPARE(ldur(s4, MemOperand(x5, 2)), "ldur s4, [x5, #2]");
1478   COMPARE(ldur(d6, MemOperand(x7, -3)), "ldur d6, [x7, #-3]");
1479   COMPARE(ldur(q8, MemOperand(x9, 4)), "ldur q8, [x9, #4]");
1480   COMPARE(stur(b10, MemOperand(x11)), "stur b10, [x11]");
1481   COMPARE(stur(h12, MemOperand(x13, -1)), "stur h12, [x13, #-1]");
1482   COMPARE(stur(s14, MemOperand(x15, 2)), "stur s14, [x15, #2]");
1483   COMPARE(stur(d16, MemOperand(x17, -3)), "stur d16, [x17, #-3]");
1484   COMPARE(stur(q18, MemOperand(x19, 4)), "stur q18, [x19, #4]");
1485 
1486   // Normal loads and stores are converted to unscaled loads and stores if the
1487   // offset requires it.
1488   COMPARE(ldr(w0, MemOperand(x1, 1)), "ldur w0, [x1, #1]");
1489   COMPARE(ldr(w2, MemOperand(x3, -1)), "ldur w2, [x3, #-1]");
1490   COMPARE(ldr(w4, MemOperand(x5, 255)), "ldur w4, [x5, #255]");
1491   COMPARE(ldr(w6, MemOperand(x7, -256)), "ldur w6, [x7, #-256]");
1492   COMPARE(ldr(x8, MemOperand(x9, 1)), "ldur x8, [x9, #1]");
1493   COMPARE(ldr(x10, MemOperand(x11, -1)), "ldur x10, [x11, #-1]");
1494   COMPARE(ldr(x12, MemOperand(x13, 255)), "ldur x12, [x13, #255]");
1495   COMPARE(ldr(x14, MemOperand(x15, -256)), "ldur x14, [x15, #-256]");
1496   COMPARE(str(w16, MemOperand(x17, 1)), "stur w16, [x17, #1]");
1497   COMPARE(str(w18, MemOperand(x19, -1)), "stur w18, [x19, #-1]");
1498   COMPARE(str(w20, MemOperand(x21, 255)), "stur w20, [x21, #255]");
1499   COMPARE(str(w22, MemOperand(x23, -256)), "stur w22, [x23, #-256]");
1500   COMPARE(str(x24, MemOperand(x25, 1)), "stur x24, [x25, #1]");
1501   COMPARE(str(x26, MemOperand(x27, -1)), "stur x26, [x27, #-1]");
1502   COMPARE(str(x28, MemOperand(x29, 255)), "stur x28, [x29, #255]");
1503   COMPARE(str(x30, MemOperand(x0, -256)), "stur x30, [x0, #-256]");
1504   COMPARE(ldr(w0, MemOperand(sp, 1)), "ldur w0, [sp, #1]");
1505   COMPARE(str(x1, MemOperand(sp, -1)), "stur x1, [sp, #-1]");
1506   COMPARE(ldrb(w2, MemOperand(x3, -2)), "ldurb w2, [x3, #-2]");
1507   COMPARE(ldrsb(w4, MemOperand(x5, -3)), "ldursb w4, [x5, #-3]");
1508   COMPARE(ldrsb(x6, MemOperand(x7, -4)), "ldursb x6, [x7, #-4]");
1509   COMPARE(ldrh(w8, MemOperand(x9, -5)), "ldurh w8, [x9, #-5]");
1510   COMPARE(ldrsh(w10, MemOperand(x11, -6)), "ldursh w10, [x11, #-6]");
1511   COMPARE(ldrsh(x12, MemOperand(x13, -7)), "ldursh x12, [x13, #-7]");
1512   COMPARE(ldrsw(x14, MemOperand(x15, -8)), "ldursw x14, [x15, #-8]");
1513 
1514   CLEANUP();
1515 }
1516 
1517 
TEST(load_store_unscaled_option)1518 TEST(load_store_unscaled_option) {
1519   SETUP();
1520 
1521   // Just like load_store_unscaled, but specify the scaling option explicitly.
1522   LoadStoreScalingOption options[] = {PreferUnscaledOffset,
1523                                       RequireUnscaledOffset};
1524 
1525   for (size_t i = 0; i < sizeof(options) / sizeof(options[0]); i++) {
1526     LoadStoreScalingOption option = options[i];
1527 
1528     // If an unscaled-offset instruction is requested, it is used, even if the
1529     // offset could be encoded in a scaled-offset instruction.
1530     COMPARE(ldurb(w0, MemOperand(x1), option), "ldurb w0, [x1]");
1531     COMPARE(ldurb(x2, MemOperand(x3, 1), option), "ldurb w2, [x3, #1]");
1532     COMPARE(ldurb(w4, MemOperand(x5, 255), option), "ldurb w4, [x5, #255]");
1533     COMPARE(sturb(w14, MemOperand(x15), option), "sturb w14, [x15]");
1534     COMPARE(sturb(x16, MemOperand(x17, 1), option), "sturb w16, [x17, #1]");
1535     COMPARE(sturb(w18, MemOperand(x19, 255), option), "sturb w18, [x19, #255]");
1536     COMPARE(ldursb(w0, MemOperand(x1), option), "ldursb w0, [x1]");
1537     COMPARE(ldursb(w2, MemOperand(x3, 1), option), "ldursb w2, [x3, #1]");
1538     COMPARE(ldursb(x2, MemOperand(x3, 255), option), "ldursb x2, [x3, #255]");
1539 
1540     COMPARE(ldurh(w0, MemOperand(x1), option), "ldurh w0, [x1]");
1541     COMPARE(ldurh(x2, MemOperand(x3, 2), option), "ldurh w2, [x3, #2]");
1542     COMPARE(ldurh(w4, MemOperand(x5, 254), option), "ldurh w4, [x5, #254]");
1543     COMPARE(sturh(w14, MemOperand(x15), option), "sturh w14, [x15]");
1544     COMPARE(sturh(x16, MemOperand(x17, 2), option), "sturh w16, [x17, #2]");
1545     COMPARE(sturh(w18, MemOperand(x19, 254), option), "sturh w18, [x19, #254]");
1546     COMPARE(ldursh(w0, MemOperand(x1), option), "ldursh w0, [x1]");
1547     COMPARE(ldursh(w2, MemOperand(x3, 2), option), "ldursh w2, [x3, #2]");
1548     COMPARE(ldursh(x4, MemOperand(x5, 254), option), "ldursh x4, [x5, #254]");
1549 
1550     COMPARE(ldur(w0, MemOperand(x1), option), "ldur w0, [x1]");
1551     COMPARE(ldur(w2, MemOperand(x3, 4), option), "ldur w2, [x3, #4]");
1552     COMPARE(ldur(w4, MemOperand(x5, 248), option), "ldur w4, [x5, #248]");
1553     COMPARE(stur(w12, MemOperand(x13), option), "stur w12, [x13]");
1554     COMPARE(stur(w14, MemOperand(x15, 4), option), "stur w14, [x15, #4]");
1555     COMPARE(stur(w16, MemOperand(x17, 248), option), "stur w16, [x17, #248]");
1556     COMPARE(ldursw(x0, MemOperand(x1), option), "ldursw x0, [x1]");
1557     COMPARE(ldursw(x2, MemOperand(x3, 4), option), "ldursw x2, [x3, #4]");
1558     COMPARE(ldursw(x4, MemOperand(x5, 248), option), "ldursw x4, [x5, #248]");
1559 
1560     COMPARE(ldur(x6, MemOperand(x7), option), "ldur x6, [x7]");
1561     COMPARE(ldur(x8, MemOperand(x9, 8), option), "ldur x8, [x9, #8]");
1562     COMPARE(ldur(x10, MemOperand(x11, 248), option), "ldur x10, [x11, #248]");
1563     COMPARE(stur(x18, MemOperand(x19), option), "stur x18, [x19]");
1564     COMPARE(stur(x20, MemOperand(x21, 8), option), "stur x20, [x21, #8]");
1565     COMPARE(stur(x22, MemOperand(x23, 248), option), "stur x22, [x23, #248]");
1566 
1567     COMPARE(ldur(b0, MemOperand(x1), option), "ldur b0, [x1]");
1568     COMPARE(ldur(h2, MemOperand(x3, 2), option), "ldur h2, [x3, #2]");
1569     COMPARE(ldur(s4, MemOperand(x5, 4), option), "ldur s4, [x5, #4]");
1570     COMPARE(ldur(d6, MemOperand(x7, 8), option), "ldur d6, [x7, #8]");
1571     COMPARE(ldur(q8, MemOperand(x9, 16), option), "ldur q8, [x9, #16]");
1572     COMPARE(stur(b10, MemOperand(x11), option), "stur b10, [x11]");
1573     COMPARE(stur(h12, MemOperand(x13, 2), option), "stur h12, [x13, #2]");
1574     COMPARE(stur(s14, MemOperand(x15, 4), option), "stur s14, [x15, #4]");
1575     COMPARE(stur(d16, MemOperand(x17, 8), option), "stur d16, [x17, #8]");
1576     COMPARE(stur(q18, MemOperand(x19, 16), option), "stur q18, [x19, #16]");
1577   }
1578 
1579   // Normal loads and stores are converted to unscaled loads and stores if the
1580   // offset requires it. PreferScaledOffset is the default for these cases, so
1581   // the behaviour here is the same when no option is specified.
1582   LoadStoreScalingOption option = PreferScaledOffset;
1583   COMPARE(ldr(w0, MemOperand(x1, 1), option), "ldur w0, [x1, #1]");
1584   COMPARE(ldr(w2, MemOperand(x3, -1), option), "ldur w2, [x3, #-1]");
1585   COMPARE(ldr(w4, MemOperand(x5, 255), option), "ldur w4, [x5, #255]");
1586   COMPARE(ldr(w6, MemOperand(x7, -256), option), "ldur w6, [x7, #-256]");
1587   COMPARE(ldr(x8, MemOperand(x9, 1), option), "ldur x8, [x9, #1]");
1588   COMPARE(ldr(x10, MemOperand(x11, -1), option), "ldur x10, [x11, #-1]");
1589   COMPARE(ldr(x12, MemOperand(x13, 255), option), "ldur x12, [x13, #255]");
1590   COMPARE(ldr(x14, MemOperand(x15, -256), option), "ldur x14, [x15, #-256]");
1591   COMPARE(str(w16, MemOperand(x17, 1), option), "stur w16, [x17, #1]");
1592   COMPARE(str(w18, MemOperand(x19, -1), option), "stur w18, [x19, #-1]");
1593   COMPARE(str(w20, MemOperand(x21, 255), option), "stur w20, [x21, #255]");
1594   COMPARE(str(w22, MemOperand(x23, -256), option), "stur w22, [x23, #-256]");
1595   COMPARE(str(x24, MemOperand(x25, 1), option), "stur x24, [x25, #1]");
1596   COMPARE(str(x26, MemOperand(x27, -1), option), "stur x26, [x27, #-1]");
1597   COMPARE(str(x28, MemOperand(x29, 255), option), "stur x28, [x29, #255]");
1598   COMPARE(str(x30, MemOperand(x0, -256), option), "stur x30, [x0, #-256]");
1599   COMPARE(ldr(w0, MemOperand(sp, 1), option), "ldur w0, [sp, #1]");
1600   COMPARE(str(x1, MemOperand(sp, -1), option), "stur x1, [sp, #-1]");
1601   COMPARE(ldrb(w2, MemOperand(x3, -2), option), "ldurb w2, [x3, #-2]");
1602   COMPARE(ldrsb(w4, MemOperand(x5, -3), option), "ldursb w4, [x5, #-3]");
1603   COMPARE(ldrsb(x6, MemOperand(x7, -4), option), "ldursb x6, [x7, #-4]");
1604   COMPARE(ldrh(w8, MemOperand(x9, -5), option), "ldurh w8, [x9, #-5]");
1605   COMPARE(ldrsh(w10, MemOperand(x11, -6), option), "ldursh w10, [x11, #-6]");
1606   COMPARE(ldrsh(x12, MemOperand(x13, -7), option), "ldursh x12, [x13, #-7]");
1607   COMPARE(ldrsw(x14, MemOperand(x15, -8), option), "ldursw x14, [x15, #-8]");
1608   COMPARE(ldr(b0, MemOperand(x1, 1), option), "ldr b0, [x1, #1]");
1609   COMPARE(ldr(h2, MemOperand(x3, 1), option), "ldur h2, [x3, #1]");
1610   COMPARE(ldr(s4, MemOperand(x5, 3), option), "ldur s4, [x5, #3]");
1611   COMPARE(ldr(d6, MemOperand(x7, 7), option), "ldur d6, [x7, #7]");
1612   COMPARE(ldr(q8, MemOperand(x9, 15), option), "ldur q8, [x9, #15]");
1613   COMPARE(str(b10, MemOperand(x11, 1), option), "str b10, [x11, #1]");
1614   COMPARE(str(h12, MemOperand(x13, 1), option), "stur h12, [x13, #1]");
1615   COMPARE(str(s14, MemOperand(x15, 3), option), "stur s14, [x15, #3]");
1616   COMPARE(str(d16, MemOperand(x17, 7), option), "stur d16, [x17, #7]");
1617   COMPARE(str(q18, MemOperand(x19, 15), option), "stur q18, [x19, #15]");
1618 
1619   CLEANUP();
1620 }
1621 
1622 
TEST(load_store_pair)1623 TEST(load_store_pair) {
1624   SETUP();
1625 
1626   COMPARE(ldp(w0, w1, MemOperand(x2)), "ldp w0, w1, [x2]");
1627   COMPARE(ldp(x3, x4, MemOperand(x5)), "ldp x3, x4, [x5]");
1628   COMPARE(ldp(w6, w7, MemOperand(x8, 4)), "ldp w6, w7, [x8, #4]");
1629   COMPARE(ldp(x9, x10, MemOperand(x11, 8)), "ldp x9, x10, [x11, #8]");
1630   COMPARE(ldp(w12, w13, MemOperand(x14, 252)), "ldp w12, w13, [x14, #252]");
1631   COMPARE(ldp(x15, x16, MemOperand(x17, 504)), "ldp x15, x16, [x17, #504]");
1632   COMPARE(ldp(w18, w19, MemOperand(x20, -256)), "ldp w18, w19, [x20, #-256]");
1633   COMPARE(ldp(x21, x22, MemOperand(x23, -512)), "ldp x21, x22, [x23, #-512]");
1634   COMPARE(ldp(w24, w25, MemOperand(x26, 252, PreIndex)),
1635           "ldp w24, w25, [x26, #252]!");
1636   COMPARE(ldp(x27, x28, MemOperand(x29, 504, PreIndex)),
1637           "ldp x27, x28, [x29, #504]!");
1638   COMPARE(ldp(w30, w0, MemOperand(x1, -256, PreIndex)),
1639           "ldp w30, w0, [x1, #-256]!");
1640   COMPARE(ldp(x2, x3, MemOperand(x4, -512, PreIndex)),
1641           "ldp x2, x3, [x4, #-512]!");
1642   COMPARE(ldp(w5, w6, MemOperand(x7, 252, PostIndex)),
1643           "ldp w5, w6, [x7], #252");
1644   COMPARE(ldp(x8, x9, MemOperand(x10, 504, PostIndex)),
1645           "ldp x8, x9, [x10], #504");
1646   COMPARE(ldp(w11, w12, MemOperand(x13, -256, PostIndex)),
1647           "ldp w11, w12, [x13], #-256");
1648   COMPARE(ldp(x14, x15, MemOperand(x16, -512, PostIndex)),
1649           "ldp x14, x15, [x16], #-512");
1650 
1651   COMPARE(ldp(s17, s18, MemOperand(x19)), "ldp s17, s18, [x19]");
1652   COMPARE(ldp(s20, s21, MemOperand(x22, 252)), "ldp s20, s21, [x22, #252]");
1653   COMPARE(ldp(s23, s24, MemOperand(x25, -256)), "ldp s23, s24, [x25, #-256]");
1654   COMPARE(ldp(s26, s27, MemOperand(x28, 252, PreIndex)),
1655           "ldp s26, s27, [x28, #252]!");
1656   COMPARE(ldp(s29, s30, MemOperand(x29, -256, PreIndex)),
1657           "ldp s29, s30, [x29, #-256]!");
1658   COMPARE(ldp(s31, s0, MemOperand(x1, 252, PostIndex)),
1659           "ldp s31, s0, [x1], #252");
1660   COMPARE(ldp(s2, s3, MemOperand(x4, -256, PostIndex)),
1661           "ldp s2, s3, [x4], #-256");
1662   COMPARE(ldp(d17, d18, MemOperand(x19)), "ldp d17, d18, [x19]");
1663   COMPARE(ldp(d20, d21, MemOperand(x22, 504)), "ldp d20, d21, [x22, #504]");
1664   COMPARE(ldp(d23, d24, MemOperand(x25, -512)), "ldp d23, d24, [x25, #-512]");
1665   COMPARE(ldp(d26, d27, MemOperand(x28, 504, PreIndex)),
1666           "ldp d26, d27, [x28, #504]!");
1667   COMPARE(ldp(d29, d30, MemOperand(x29, -512, PreIndex)),
1668           "ldp d29, d30, [x29, #-512]!");
1669   COMPARE(ldp(d31, d0, MemOperand(x1, 504, PostIndex)),
1670           "ldp d31, d0, [x1], #504");
1671   COMPARE(ldp(d2, d3, MemOperand(x4, -512, PostIndex)),
1672           "ldp d2, d3, [x4], #-512");
1673 
1674   COMPARE(ldp(q5, q6, MemOperand(x7)), "ldp q5, q6, [x7]");
1675   COMPARE(ldp(q8, q9, MemOperand(x10, 1008)), "ldp q8, q9, [x10, #1008]");
1676   COMPARE(ldp(q11, q12, MemOperand(x13, -1024)), "ldp q11, q12, [x13, #-1024]");
1677   COMPARE(ldp(q14, q15, MemOperand(x16, 1008, PreIndex)),
1678           "ldp q14, q15, [x16, #1008]!");
1679   COMPARE(ldp(q17, q18, MemOperand(x19, -1024, PreIndex)),
1680           "ldp q17, q18, [x19, #-1024]!");
1681   COMPARE(ldp(q20, q21, MemOperand(x22, 1008, PostIndex)),
1682           "ldp q20, q21, [x22], #1008");
1683   COMPARE(ldp(q23, q24, MemOperand(x25, -1024, PostIndex)),
1684           "ldp q23, q24, [x25], #-1024");
1685 
1686   COMPARE(stp(w0, w1, MemOperand(x2)), "stp w0, w1, [x2]");
1687   COMPARE(stp(x3, x4, MemOperand(x5)), "stp x3, x4, [x5]");
1688   COMPARE(stp(w6, w7, MemOperand(x8, 4)), "stp w6, w7, [x8, #4]");
1689   COMPARE(stp(x9, x10, MemOperand(x11, 8)), "stp x9, x10, [x11, #8]");
1690   COMPARE(stp(w12, w13, MemOperand(x14, 252)), "stp w12, w13, [x14, #252]");
1691   COMPARE(stp(x15, x16, MemOperand(x17, 504)), "stp x15, x16, [x17, #504]");
1692   COMPARE(stp(w18, w19, MemOperand(x20, -256)), "stp w18, w19, [x20, #-256]");
1693   COMPARE(stp(x21, x22, MemOperand(x23, -512)), "stp x21, x22, [x23, #-512]");
1694   COMPARE(stp(w24, w25, MemOperand(x26, 252, PreIndex)),
1695           "stp w24, w25, [x26, #252]!");
1696   COMPARE(stp(x27, x28, MemOperand(x29, 504, PreIndex)),
1697           "stp x27, x28, [x29, #504]!");
1698   COMPARE(stp(w30, w0, MemOperand(x1, -256, PreIndex)),
1699           "stp w30, w0, [x1, #-256]!");
1700   COMPARE(stp(x2, x3, MemOperand(x4, -512, PreIndex)),
1701           "stp x2, x3, [x4, #-512]!");
1702   COMPARE(stp(w5, w6, MemOperand(x7, 252, PostIndex)),
1703           "stp w5, w6, [x7], #252");
1704   COMPARE(stp(x8, x9, MemOperand(x10, 504, PostIndex)),
1705           "stp x8, x9, [x10], #504");
1706   COMPARE(stp(w11, w12, MemOperand(x13, -256, PostIndex)),
1707           "stp w11, w12, [x13], #-256");
1708   COMPARE(stp(x14, x15, MemOperand(x16, -512, PostIndex)),
1709           "stp x14, x15, [x16], #-512");
1710 
1711   COMPARE(stp(s17, s18, MemOperand(x19)), "stp s17, s18, [x19]");
1712   COMPARE(stp(s20, s21, MemOperand(x22, 252)), "stp s20, s21, [x22, #252]");
1713   COMPARE(stp(s23, s24, MemOperand(x25, -256)), "stp s23, s24, [x25, #-256]");
1714   COMPARE(stp(s26, s27, MemOperand(x28, 252, PreIndex)),
1715           "stp s26, s27, [x28, #252]!");
1716   COMPARE(stp(s29, s30, MemOperand(x29, -256, PreIndex)),
1717           "stp s29, s30, [x29, #-256]!");
1718   COMPARE(stp(s31, s0, MemOperand(x1, 252, PostIndex)),
1719           "stp s31, s0, [x1], #252");
1720   COMPARE(stp(s2, s3, MemOperand(x4, -256, PostIndex)),
1721           "stp s2, s3, [x4], #-256");
1722   COMPARE(stp(d17, d18, MemOperand(x19)), "stp d17, d18, [x19]");
1723   COMPARE(stp(d20, d21, MemOperand(x22, 504)), "stp d20, d21, [x22, #504]");
1724   COMPARE(stp(d23, d24, MemOperand(x25, -512)), "stp d23, d24, [x25, #-512]");
1725   COMPARE(stp(d26, d27, MemOperand(x28, 504, PreIndex)),
1726           "stp d26, d27, [x28, #504]!");
1727   COMPARE(stp(d29, d30, MemOperand(x29, -512, PreIndex)),
1728           "stp d29, d30, [x29, #-512]!");
1729   COMPARE(stp(d31, d0, MemOperand(x1, 504, PostIndex)),
1730           "stp d31, d0, [x1], #504");
1731   COMPARE(stp(d2, d3, MemOperand(x4, -512, PostIndex)),
1732           "stp d2, d3, [x4], #-512");
1733 
1734   COMPARE(stp(q5, q6, MemOperand(x7)), "stp q5, q6, [x7]");
1735   COMPARE(stp(q8, q9, MemOperand(x10, 1008)), "stp q8, q9, [x10, #1008]");
1736   COMPARE(stp(q11, q12, MemOperand(x13, -1024)), "stp q11, q12, [x13, #-1024]");
1737   COMPARE(stp(q14, q15, MemOperand(x16, 1008, PreIndex)),
1738           "stp q14, q15, [x16, #1008]!");
1739   COMPARE(stp(q17, q18, MemOperand(x19, -1024, PreIndex)),
1740           "stp q17, q18, [x19, #-1024]!");
1741   COMPARE(stp(q20, q21, MemOperand(x22, 1008, PostIndex)),
1742           "stp q20, q21, [x22], #1008");
1743   COMPARE(stp(q23, q24, MemOperand(x25, -1024, PostIndex)),
1744           "stp q23, q24, [x25], #-1024");
1745 
1746   COMPARE(ldp(w16, w17, MemOperand(sp, 4, PostIndex)),
1747           "ldp w16, w17, [sp], #4");
1748   COMPARE(stp(x18, x19, MemOperand(sp, -8, PreIndex)),
1749           "stp x18, x19, [sp, #-8]!");
1750   COMPARE(ldp(s30, s31, MemOperand(sp, 12, PostIndex)),
1751           "ldp s30, s31, [sp], #12");
1752   COMPARE(stp(d30, d31, MemOperand(sp, -16)), "stp d30, d31, [sp, #-16]");
1753   COMPARE(ldp(q30, q31, MemOperand(sp, 32, PostIndex)),
1754           "ldp q30, q31, [sp], #32");
1755 
1756   COMPARE(ldpsw(x0, x1, MemOperand(x2)), "ldpsw x0, x1, [x2]");
1757   COMPARE(ldpsw(x3, x4, MemOperand(x5, 16)), "ldpsw x3, x4, [x5, #16]");
1758   COMPARE(ldpsw(x6, x7, MemOperand(x8, -32, PreIndex)),
1759           "ldpsw x6, x7, [x8, #-32]!");
1760   COMPARE(ldpsw(x9, x10, MemOperand(x11, 128, PostIndex)),
1761           "ldpsw x9, x10, [x11], #128");
1762 
1763   CLEANUP();
1764 }
1765 
1766 
TEST(load_store_exclusive)1767 TEST(load_store_exclusive) {
1768   SETUP();
1769 
1770   COMPARE(stxrb(w0, w1, MemOperand(x2)), "stxrb w0, w1, [x2]");
1771   COMPARE(stxrb(x3, w4, MemOperand(sp)), "stxrb w3, w4, [sp]");
1772   COMPARE(stxrb(w5, x6, MemOperand(x7)), "stxrb w5, w6, [x7]");
1773   COMPARE(stxrb(x8, x9, MemOperand(sp)), "stxrb w8, w9, [sp]");
1774   COMPARE(stxrh(w10, w11, MemOperand(x12)), "stxrh w10, w11, [x12]");
1775   COMPARE(stxrh(x13, w14, MemOperand(sp)), "stxrh w13, w14, [sp]");
1776   COMPARE(stxrh(w15, x16, MemOperand(x17)), "stxrh w15, w16, [x17]");
1777   COMPARE(stxrh(x18, x19, MemOperand(sp)), "stxrh w18, w19, [sp]");
1778   COMPARE(stxr(w20, w21, MemOperand(x22)), "stxr w20, w21, [x22]");
1779   COMPARE(stxr(x23, w24, MemOperand(sp)), "stxr w23, w24, [sp]");
1780   COMPARE(stxr(w25, x26, MemOperand(x27)), "stxr w25, x26, [x27]");
1781   COMPARE(stxr(x28, x29, MemOperand(sp)), "stxr w28, x29, [sp]");
1782   COMPARE(ldxrb(w30, MemOperand(x0)), "ldxrb w30, [x0]");
1783   COMPARE(ldxrb(w1, MemOperand(sp)), "ldxrb w1, [sp]");
1784   COMPARE(ldxrb(x2, MemOperand(x3)), "ldxrb w2, [x3]");
1785   COMPARE(ldxrb(x4, MemOperand(sp)), "ldxrb w4, [sp]");
1786   COMPARE(ldxrh(w5, MemOperand(x6)), "ldxrh w5, [x6]");
1787   COMPARE(ldxrh(w7, MemOperand(sp)), "ldxrh w7, [sp]");
1788   COMPARE(ldxrh(x8, MemOperand(x9)), "ldxrh w8, [x9]");
1789   COMPARE(ldxrh(x10, MemOperand(sp)), "ldxrh w10, [sp]");
1790   COMPARE(ldxr(w11, MemOperand(x12)), "ldxr w11, [x12]");
1791   COMPARE(ldxr(w13, MemOperand(sp)), "ldxr w13, [sp]");
1792   COMPARE(ldxr(x14, MemOperand(x15)), "ldxr x14, [x15]");
1793   COMPARE(ldxr(x16, MemOperand(sp)), "ldxr x16, [sp]");
1794   COMPARE(stxp(w17, w18, w19, MemOperand(x20)), "stxp w17, w18, w19, [x20]");
1795   COMPARE(stxp(x21, w22, w23, MemOperand(sp)), "stxp w21, w22, w23, [sp]");
1796   COMPARE(stxp(w24, x25, x26, MemOperand(x27)), "stxp w24, x25, x26, [x27]");
1797   COMPARE(stxp(x28, x29, x30, MemOperand(sp)), "stxp w28, x29, x30, [sp]");
1798   COMPARE(ldxp(w0, w1, MemOperand(x2)), "ldxp w0, w1, [x2]");
1799   COMPARE(ldxp(w3, w4, MemOperand(sp)), "ldxp w3, w4, [sp]");
1800   COMPARE(ldxp(x5, x6, MemOperand(x7)), "ldxp x5, x6, [x7]");
1801   COMPARE(ldxp(x8, x9, MemOperand(sp)), "ldxp x8, x9, [sp]");
1802   COMPARE(stlxrb(w10, w11, MemOperand(x12)), "stlxrb w10, w11, [x12]");
1803   COMPARE(stlxrb(x13, w14, MemOperand(sp)), "stlxrb w13, w14, [sp]");
1804   COMPARE(stlxrb(w15, x16, MemOperand(x17)), "stlxrb w15, w16, [x17]");
1805   COMPARE(stlxrb(x18, x19, MemOperand(sp)), "stlxrb w18, w19, [sp]");
1806   COMPARE(stlxrh(w20, w21, MemOperand(x22)), "stlxrh w20, w21, [x22]");
1807   COMPARE(stlxrh(x23, w24, MemOperand(sp)), "stlxrh w23, w24, [sp]");
1808   COMPARE(stlxrh(w25, x26, MemOperand(x27)), "stlxrh w25, w26, [x27]");
1809   COMPARE(stlxrh(x28, x29, MemOperand(sp)), "stlxrh w28, w29, [sp]");
1810   COMPARE(stlxr(w30, w0, MemOperand(x1)), "stlxr w30, w0, [x1]");
1811   COMPARE(stlxr(x2, w3, MemOperand(sp)), "stlxr w2, w3, [sp]");
1812   COMPARE(stlxr(w4, x5, MemOperand(x6)), "stlxr w4, x5, [x6]");
1813   COMPARE(stlxr(x7, x8, MemOperand(sp)), "stlxr w7, x8, [sp]");
1814   COMPARE(ldaxrb(w9, MemOperand(x10)), "ldaxrb w9, [x10]");
1815   COMPARE(ldaxrb(w11, MemOperand(sp)), "ldaxrb w11, [sp]");
1816   COMPARE(ldaxrb(x12, MemOperand(x13)), "ldaxrb w12, [x13]");
1817   COMPARE(ldaxrb(x14, MemOperand(sp)), "ldaxrb w14, [sp]");
1818   COMPARE(ldaxrh(w15, MemOperand(x16)), "ldaxrh w15, [x16]");
1819   COMPARE(ldaxrh(w17, MemOperand(sp)), "ldaxrh w17, [sp]");
1820   COMPARE(ldaxrh(x18, MemOperand(x19)), "ldaxrh w18, [x19]");
1821   COMPARE(ldaxrh(x20, MemOperand(sp)), "ldaxrh w20, [sp]");
1822   COMPARE(ldaxr(w21, MemOperand(x22)), "ldaxr w21, [x22]");
1823   COMPARE(ldaxr(w23, MemOperand(sp)), "ldaxr w23, [sp]");
1824   COMPARE(ldaxr(x24, MemOperand(x25)), "ldaxr x24, [x25]");
1825   COMPARE(ldaxr(x26, MemOperand(sp)), "ldaxr x26, [sp]");
1826   COMPARE(stlxp(w27, w28, w29, MemOperand(x30)), "stlxp w27, w28, w29, [x30]");
1827   COMPARE(stlxp(x0, w1, w2, MemOperand(sp)), "stlxp w0, w1, w2, [sp]");
1828   COMPARE(stlxp(w3, x4, x5, MemOperand(x6)), "stlxp w3, x4, x5, [x6]");
1829   COMPARE(stlxp(x7, x8, x9, MemOperand(sp)), "stlxp w7, x8, x9, [sp]");
1830   COMPARE(ldaxp(w10, w11, MemOperand(x12)), "ldaxp w10, w11, [x12]");
1831   COMPARE(ldaxp(w13, w14, MemOperand(sp)), "ldaxp w13, w14, [sp]");
1832   COMPARE(ldaxp(x15, x16, MemOperand(x17)), "ldaxp x15, x16, [x17]");
1833   COMPARE(ldaxp(x18, x19, MemOperand(sp)), "ldaxp x18, x19, [sp]");
1834   COMPARE(stlrb(w20, MemOperand(x21)), "stlrb w20, [x21]");
1835   COMPARE(stlrb(w22, MemOperand(sp)), "stlrb w22, [sp]");
1836   COMPARE(stlrb(x23, MemOperand(x24)), "stlrb w23, [x24]");
1837   COMPARE(stlrb(x25, MemOperand(sp)), "stlrb w25, [sp]");
1838   COMPARE(stlrh(w26, MemOperand(x27)), "stlrh w26, [x27]");
1839   COMPARE(stlrh(w28, MemOperand(sp)), "stlrh w28, [sp]");
1840   COMPARE(stlrh(x29, MemOperand(x30)), "stlrh w29, [x30]");
1841   COMPARE(stlrh(x0, MemOperand(sp)), "stlrh w0, [sp]");
1842   COMPARE(stlr(w1, MemOperand(x2)), "stlr w1, [x2]");
1843   COMPARE(stlr(w3, MemOperand(sp)), "stlr w3, [sp]");
1844   COMPARE(stlr(x4, MemOperand(x5)), "stlr x4, [x5]");
1845   COMPARE(stlr(x6, MemOperand(sp)), "stlr x6, [sp]");
1846   COMPARE(ldarb(w7, MemOperand(x8)), "ldarb w7, [x8]");
1847   COMPARE(ldarb(w9, MemOperand(sp)), "ldarb w9, [sp]");
1848   COMPARE(ldarb(x10, MemOperand(x11)), "ldarb w10, [x11]");
1849   COMPARE(ldarb(x12, MemOperand(sp)), "ldarb w12, [sp]");
1850   COMPARE(ldarh(w13, MemOperand(x14)), "ldarh w13, [x14]");
1851   COMPARE(ldarh(w15, MemOperand(sp)), "ldarh w15, [sp]");
1852   COMPARE(ldarh(x16, MemOperand(x17)), "ldarh w16, [x17]");
1853   COMPARE(ldarh(x18, MemOperand(sp)), "ldarh w18, [sp]");
1854   COMPARE(ldar(w19, MemOperand(x20)), "ldar w19, [x20]");
1855   COMPARE(ldar(w21, MemOperand(sp)), "ldar w21, [sp]");
1856   COMPARE(ldar(x22, MemOperand(x23)), "ldar x22, [x23]");
1857   COMPARE(ldar(x24, MemOperand(sp)), "ldar x24, [sp]");
1858 
1859   CLEANUP();
1860 }
1861 
1862 
TEST(load_store_pair_nontemp)1863 TEST(load_store_pair_nontemp) {
1864   SETUP();
1865 
1866   COMPARE(ldnp(w0, w1, MemOperand(x2)), "ldnp w0, w1, [x2]");
1867   COMPARE(stnp(w3, w4, MemOperand(x5, 252)), "stnp w3, w4, [x5, #252]");
1868   COMPARE(ldnp(w6, w7, MemOperand(x8, -256)), "ldnp w6, w7, [x8, #-256]");
1869   COMPARE(stnp(x9, x10, MemOperand(x11)), "stnp x9, x10, [x11]");
1870   COMPARE(ldnp(x12, x13, MemOperand(x14, 504)), "ldnp x12, x13, [x14, #504]");
1871   COMPARE(stnp(x15, x16, MemOperand(x17, -512)), "stnp x15, x16, [x17, #-512]");
1872   COMPARE(ldnp(s18, s19, MemOperand(x20)), "ldnp s18, s19, [x20]");
1873   COMPARE(stnp(s21, s22, MemOperand(x23, 252)), "stnp s21, s22, [x23, #252]");
1874   COMPARE(ldnp(s24, s25, MemOperand(x26, -256)), "ldnp s24, s25, [x26, #-256]");
1875   COMPARE(stnp(d27, d28, MemOperand(x29)), "stnp d27, d28, [x29]");
1876   COMPARE(ldnp(d30, d31, MemOperand(x0, 504)), "ldnp d30, d31, [x0, #504]");
1877   COMPARE(stnp(d1, d2, MemOperand(x3, -512)), "stnp d1, d2, [x3, #-512]");
1878   COMPARE(ldnp(q4, q5, MemOperand(x6)), "ldnp q4, q5, [x6]");
1879   COMPARE(stnp(q7, q8, MemOperand(x9, 1008)), "stnp q7, q8, [x9, #1008]");
1880   COMPARE(ldnp(q10, q11, MemOperand(x12, -1024)),
1881           "ldnp q10, q11, [x12, #-1024]");
1882 
1883   CLEANUP();
1884 }
1885 
1886 
TEST(load_literal_macro)1887 TEST(load_literal_macro) {
1888   SETUP();
1889 
1890   // In each case, the literal will be placed at PC+8:
1891   //    ldr   x10, pc+8               // Test instruction.
1892   //    ldr   xzr, pc+12              // Pool marker.
1893   //    .word64 #0x1234567890abcdef   // Test literal.
1894 
1895   COMPARE_MACRO_PREFIX(Ldr(x10, 0x1234567890abcdef), "ldr x10, pc+8");
1896   COMPARE_MACRO_PREFIX(Ldr(w20, 0xfedcba09), "ldr w20, pc+8");
1897   COMPARE_MACRO_PREFIX(Ldr(d11, 1.234), "ldr d11, pc+8");
1898   COMPARE_MACRO_PREFIX(Ldr(s22, 2.5f), "ldr s22, pc+8");
1899   COMPARE_MACRO_PREFIX(Ldrsw(x21, 0x80000000), "ldrsw x21, pc+8");
1900 
1901   CLEANUP();
1902 }
1903 
1904 
TEST(load_literal)1905 TEST(load_literal) {
1906   SETUP();
1907 
1908   COMPARE_PREFIX(ldr(x20, INT64_C(0)), "ldr x20, pc+0");
1909   COMPARE_PREFIX(ldr(x20, 1), "ldr x20, pc+4");
1910   COMPARE_PREFIX(ldr(x20, -1), "ldr x20, pc-4");
1911   COMPARE_PREFIX(ldr(x20, 0x3ffff), "ldr x20, pc+1048572");
1912   COMPARE_PREFIX(ldr(x20, -0x40000), "ldr x20, pc-1048576");
1913   COMPARE_PREFIX(ldr(w21, INT64_C(0)), "ldr w21, pc+0");
1914   COMPARE_PREFIX(ldr(w21, 1), "ldr w21, pc+4");
1915   COMPARE_PREFIX(ldr(w21, -1), "ldr w21, pc-4");
1916   COMPARE_PREFIX(ldr(w21, 0x3ffff), "ldr w21, pc+1048572");
1917   COMPARE_PREFIX(ldr(w21, -0x40000), "ldr w21, pc-1048576");
1918   COMPARE_PREFIX(ldr(d22, INT64_C(0)), "ldr d22, pc+0");
1919   COMPARE_PREFIX(ldr(d22, 1), "ldr d22, pc+4");
1920   COMPARE_PREFIX(ldr(d22, -1), "ldr d22, pc-4");
1921   COMPARE_PREFIX(ldr(d22, 0x3ffff), "ldr d22, pc+1048572");
1922   COMPARE_PREFIX(ldr(d22, -0x40000), "ldr d22, pc-1048576");
1923   COMPARE_PREFIX(ldr(s23, INT64_C(0)), "ldr s23, pc+0");
1924   COMPARE_PREFIX(ldr(s23, 1), "ldr s23, pc+4");
1925   COMPARE_PREFIX(ldr(s23, -1), "ldr s23, pc-4");
1926   COMPARE_PREFIX(ldr(s23, 0x3ffff), "ldr s23, pc+1048572");
1927   COMPARE_PREFIX(ldr(s23, -0x40000), "ldr s23, pc-1048576");
1928   COMPARE_PREFIX(ldrsw(x24, INT64_C(0)), "ldrsw x24, pc+0");
1929   COMPARE_PREFIX(ldrsw(x24, 1), "ldrsw x24, pc+4");
1930   COMPARE_PREFIX(ldrsw(x24, -1), "ldrsw x24, pc-4");
1931   COMPARE_PREFIX(ldrsw(x24, 0x3ffff), "ldrsw x24, pc+1048572");
1932   COMPARE_PREFIX(ldrsw(x24, -0x40000), "ldrsw x24, pc-1048576");
1933 
1934   CLEANUP();
1935 }
1936 
1937 
TEST(prfm_operations)1938 TEST(prfm_operations) {
1939   SETUP();
1940 
1941   // Test every encodable prefetch operation.
1942   const char* expected[] = {
1943       "prfm pldl1keep, ", "prfm pldl1strm, ", "prfm pldl2keep, ",
1944       "prfm pldl2strm, ", "prfm pldl3keep, ", "prfm pldl3strm, ",
1945       "prfm #0b00110, ",  "prfm #0b00111, ",  "prfm plil1keep, ",
1946       "prfm plil1strm, ", "prfm plil2keep, ", "prfm plil2strm, ",
1947       "prfm plil3keep, ", "prfm plil3strm, ", "prfm #0b01110, ",
1948       "prfm #0b01111, ",  "prfm pstl1keep, ", "prfm pstl1strm, ",
1949       "prfm pstl2keep, ", "prfm pstl2strm, ", "prfm pstl3keep, ",
1950       "prfm pstl3strm, ", "prfm #0b10110, ",  "prfm #0b10111, ",
1951       "prfm #0b11000, ",  "prfm #0b11001, ",  "prfm #0b11010, ",
1952       "prfm #0b11011, ",  "prfm #0b11100, ",  "prfm #0b11101, ",
1953       "prfm #0b11110, ",  "prfm #0b11111, ",
1954   };
1955   const int expected_count = sizeof(expected) / sizeof(expected[0]);
1956   VIXL_STATIC_ASSERT((1 << ImmPrefetchOperation_width) == expected_count);
1957 
1958   for (int i = 0; i < (1 << ImmPrefetchOperation_width); i++) {
1959     PrefetchOperation op = static_cast<PrefetchOperation>(i);
1960     COMPARE_PREFIX(prfm(op, INT64_C(0)), expected[i]);
1961     COMPARE_PREFIX(prfm(op, MemOperand(x0, 0)), expected[i]);
1962     COMPARE_PREFIX(prfm(op, MemOperand(x0, x1)), expected[i]);
1963   }
1964 
1965   CLEANUP();
1966 }
1967 
1968 
TEST(prfum_operations)1969 TEST(prfum_operations) {
1970   SETUP();
1971 
1972   // Test every encodable prefetch operation.
1973   const char* expected[] = {
1974       "prfum pldl1keep, ", "prfum pldl1strm, ", "prfum pldl2keep, ",
1975       "prfum pldl2strm, ", "prfum pldl3keep, ", "prfum pldl3strm, ",
1976       "prfum #0b00110, ",  "prfum #0b00111, ",  "prfum plil1keep, ",
1977       "prfum plil1strm, ", "prfum plil2keep, ", "prfum plil2strm, ",
1978       "prfum plil3keep, ", "prfum plil3strm, ", "prfum #0b01110, ",
1979       "prfum #0b01111, ",  "prfum pstl1keep, ", "prfum pstl1strm, ",
1980       "prfum pstl2keep, ", "prfum pstl2strm, ", "prfum pstl3keep, ",
1981       "prfum pstl3strm, ", "prfum #0b10110, ",  "prfum #0b10111, ",
1982       "prfum #0b11000, ",  "prfum #0b11001, ",  "prfum #0b11010, ",
1983       "prfum #0b11011, ",  "prfum #0b11100, ",  "prfum #0b11101, ",
1984       "prfum #0b11110, ",  "prfum #0b11111, ",
1985   };
1986   const int expected_count = sizeof(expected) / sizeof(expected[0]);
1987   VIXL_STATIC_ASSERT((1 << ImmPrefetchOperation_width) == expected_count);
1988 
1989   for (int i = 0; i < (1 << ImmPrefetchOperation_width); i++) {
1990     PrefetchOperation op = static_cast<PrefetchOperation>(i);
1991     COMPARE_PREFIX(prfum(op, MemOperand(x0, 0)), expected[i]);
1992   }
1993 
1994   CLEANUP();
1995 }
1996 
1997 
TEST(prfm_offset)1998 TEST(prfm_offset) {
1999   SETUP();
2000 
2001   COMPARE(prfm(PLDL1KEEP, MemOperand(x1)), "prfm pldl1keep, [x1]");
2002   COMPARE(prfm(PLDL1STRM, MemOperand(x3, 8)), "prfm pldl1strm, [x3, #8]");
2003   COMPARE(prfm(PLDL2KEEP, MemOperand(x5, 32760)),
2004           "prfm pldl2keep, [x5, #32760]");
2005 
2006   COMPARE(prfm(PLDL2STRM, MemOperand(sp)), "prfm pldl2strm, [sp]");
2007   COMPARE(prfm(PLDL3KEEP, MemOperand(sp, 8)), "prfm pldl3keep, [sp, #8]");
2008   COMPARE(prfm(PLDL3STRM, MemOperand(sp, 32760)),
2009           "prfm pldl3strm, [sp, #32760]");
2010 
2011   CLEANUP();
2012 }
2013 
2014 
TEST(prfm_regoffset)2015 TEST(prfm_regoffset) {
2016   SETUP();
2017 
2018   COMPARE(prfm(PLIL1KEEP, MemOperand(x1, x2)), "prfm plil1keep, [x1, x2]");
2019   COMPARE(prfm(PLIL1STRM, MemOperand(x3, w4, SXTW)),
2020           "prfm plil1strm, [x3, w4, sxtw]");
2021   COMPARE(prfm(PLIL2KEEP, MemOperand(x5, x6, LSL, 3)),
2022           "prfm plil2keep, [x5, x6, lsl #3]");
2023 
2024   COMPARE(prfm(PLIL2STRM, MemOperand(sp, xzr)), "prfm plil2strm, [sp, xzr]");
2025   COMPARE(prfm(PLIL3KEEP, MemOperand(sp, wzr, SXTW)),
2026           "prfm plil3keep, [sp, wzr, sxtw]");
2027   COMPARE(prfm(PLIL3STRM, MemOperand(sp, xzr, LSL, 3)),
2028           "prfm plil3strm, [sp, xzr, lsl #3]");
2029 
2030   CLEANUP();
2031 }
2032 
2033 
TEST(prfm_literal)2034 TEST(prfm_literal) {
2035   SETUP();
2036 
2037   COMPARE_PREFIX(prfm(PSTL1KEEP, INT64_C(0)), "prfm pstl1keep, pc+0");
2038   COMPARE_PREFIX(prfm(PSTL1STRM, 1), "prfm pstl1strm, pc+4");
2039   COMPARE_PREFIX(prfm(PSTL2KEEP, -1), "prfm pstl2keep, pc-4");
2040   COMPARE_PREFIX(prfm(PSTL2STRM, 0x3ffff), "prfm pstl2strm, pc+1048572");
2041   COMPARE_PREFIX(prfm(PSTL3KEEP, -0x3ffff), "prfm pstl3keep, pc-1048572");
2042   COMPARE_PREFIX(prfm(PSTL3STRM, -0x40000), "prfm pstl3strm, pc-1048576");
2043 
2044   CLEANUP();
2045 }
2046 
2047 
TEST(prfm_unscaled)2048 TEST(prfm_unscaled) {
2049   SETUP();
2050 
2051   // If an unscaled-offset instruction is requested, it is used, even if the
2052   // offset could be encoded in a scaled-offset instruction.
2053   COMPARE(prfum(PLDL1KEEP, MemOperand(x1)), "prfum pldl1keep, [x1]");
2054   COMPARE(prfum(PLDL1STRM, MemOperand(x1, 8)), "prfum pldl1strm, [x1, #8]");
2055   COMPARE(prfum(PLDL2KEEP, MemOperand(x1, 248)), "prfum pldl2keep, [x1, #248]");
2056 
2057   // Normal offsets are converted to unscaled offsets if necssary.
2058   COMPARE(prfm(PLDL2STRM, MemOperand(x1, 1)), "prfum pldl2strm, [x1, #1]");
2059   COMPARE(prfm(PLDL3KEEP, MemOperand(x1, -1)), "prfum pldl3keep, [x1, #-1]");
2060   COMPARE(prfm(PLDL3STRM, MemOperand(x1, 255)), "prfum pldl3strm, [x1, #255]");
2061   COMPARE(prfm(PLDL3STRM, MemOperand(x1, -256)),
2062           "prfum pldl3strm, [x1, #-256]");
2063 
2064   CLEANUP();
2065 }
2066 
2067 
TEST(prfm_unscaled_option)2068 TEST(prfm_unscaled_option) {
2069   SETUP();
2070 
2071   // Just like prfm_unscaled, but specify the scaling option explicitly.
2072 
2073   // Require unscaled-offset forms.
2074   LoadStoreScalingOption option = RequireUnscaledOffset;
2075 
2076   COMPARE(prfum(PLDL1KEEP, MemOperand(x1), option), "prfum pldl1keep, [x1]");
2077   COMPARE(prfum(PLDL1STRM, MemOperand(x1, 8), option),
2078           "prfum pldl1strm, [x1, #8]");
2079   COMPARE(prfum(PLDL2KEEP, MemOperand(x1, 248), option),
2080           "prfum pldl2keep, [x1, #248]");
2081   COMPARE(prfum(PLDL2STRM, MemOperand(x1, 1), option),
2082           "prfum pldl2strm, [x1, #1]");
2083   COMPARE(prfum(PLDL3KEEP, MemOperand(x1, -1), option),
2084           "prfum pldl3keep, [x1, #-1]");
2085   COMPARE(prfum(PLDL3STRM, MemOperand(x1, 255), option),
2086           "prfum pldl3strm, [x1, #255]");
2087   COMPARE(prfum(PLIL1KEEP, MemOperand(x1, -256), option),
2088           "prfum plil1keep, [x1, #-256]");
2089 
2090   // Require scaled-offset forms..
2091   option = RequireScaledOffset;
2092 
2093   COMPARE(prfm(PLDL1KEEP, MemOperand(x1), option), "prfm pldl1keep, [x1]");
2094   COMPARE(prfm(PLDL1STRM, MemOperand(x1, 8), option),
2095           "prfm pldl1strm, [x1, #8]");
2096   COMPARE(prfm(PLDL2KEEP, MemOperand(x1, 248), option),
2097           "prfm pldl2keep, [x1, #248]");
2098   COMPARE(prfm(PLIL2STRM, MemOperand(x1, 256), option),
2099           "prfm plil2strm, [x1, #256]");
2100   COMPARE(prfm(PLIL3KEEP, MemOperand(x1, 32760), option),
2101           "prfm plil3keep, [x1, #32760]");
2102 
2103   // Prefer unscaled-offset forms, but allow scaled-offset forms if necessary.
2104   option = PreferUnscaledOffset;
2105 
2106   COMPARE(prfum(PLDL1KEEP, MemOperand(x1), option), "prfum pldl1keep, [x1]");
2107   COMPARE(prfum(PLDL1STRM, MemOperand(x1, 8), option),
2108           "prfum pldl1strm, [x1, #8]");
2109   COMPARE(prfum(PLDL2KEEP, MemOperand(x1, 248), option),
2110           "prfum pldl2keep, [x1, #248]");
2111   COMPARE(prfum(PLDL2STRM, MemOperand(x1, 1), option),
2112           "prfum pldl2strm, [x1, #1]");
2113   COMPARE(prfum(PLDL3KEEP, MemOperand(x1, -1), option),
2114           "prfum pldl3keep, [x1, #-1]");
2115   COMPARE(prfum(PLDL3STRM, MemOperand(x1, 255), option),
2116           "prfum pldl3strm, [x1, #255]");
2117   COMPARE(prfum(PLIL1KEEP, MemOperand(x1, -256), option),
2118           "prfum plil1keep, [x1, #-256]");
2119   COMPARE(prfum(PLIL1STRM, MemOperand(x1, 256), option),
2120           "prfm plil1strm, [x1, #256]");
2121   COMPARE(prfum(PLIL2KEEP, MemOperand(x1, 32760), option),
2122           "prfm plil2keep, [x1, #32760]");
2123 
2124   // Prefer scaled-offset forms, but allow unscaled-offset forms if necessary.
2125   option = PreferScaledOffset;
2126 
2127   COMPARE(prfm(PLDL1KEEP, MemOperand(x1), option), "prfm pldl1keep, [x1]");
2128   COMPARE(prfm(PLDL1STRM, MemOperand(x1, 8), option),
2129           "prfm pldl1strm, [x1, #8]");
2130   COMPARE(prfm(PLDL2KEEP, MemOperand(x1, 248), option),
2131           "prfm pldl2keep, [x1, #248]");
2132   COMPARE(prfm(PLDL2STRM, MemOperand(x1, 1), option),
2133           "prfum pldl2strm, [x1, #1]");
2134   COMPARE(prfm(PLDL3KEEP, MemOperand(x1, -1), option),
2135           "prfum pldl3keep, [x1, #-1]");
2136   COMPARE(prfm(PLDL3STRM, MemOperand(x1, 255), option),
2137           "prfum pldl3strm, [x1, #255]");
2138   COMPARE(prfm(PLIL1KEEP, MemOperand(x1, -256), option),
2139           "prfum plil1keep, [x1, #-256]");
2140   COMPARE(prfm(PLIL1STRM, MemOperand(x1, 256), option),
2141           "prfm plil1strm, [x1, #256]");
2142   COMPARE(prfm(PLIL2KEEP, MemOperand(x1, 32760), option),
2143           "prfm plil2keep, [x1, #32760]");
2144 
2145   CLEANUP();
2146 }
2147 
2148 
TEST(cond_select)2149 TEST(cond_select) {
2150   SETUP();
2151 
2152   COMPARE(csel(w0, w1, w2, eq), "csel w0, w1, w2, eq");
2153   COMPARE(csel(x3, x4, x5, ne), "csel x3, x4, x5, ne");
2154   COMPARE(csinc(w6, w7, w8, hs), "csinc w6, w7, w8, hs");
2155   COMPARE(csinc(x9, x10, x11, lo), "csinc x9, x10, x11, lo");
2156   COMPARE(csinv(w12, w13, w14, mi), "csinv w12, w13, w14, mi");
2157   COMPARE(csinv(x15, x16, x17, pl), "csinv x15, x16, x17, pl");
2158   COMPARE(csneg(w18, w19, w20, vs), "csneg w18, w19, w20, vs");
2159   COMPARE(csneg(x21, x22, x23, vc), "csneg x21, x22, x23, vc");
2160   COMPARE(cset(w24, hi), "cset w24, hi");
2161   COMPARE(cset(x25, ls), "cset x25, ls");
2162   COMPARE(csetm(w26, ge), "csetm w26, ge");
2163   COMPARE(csetm(x27, lt), "csetm x27, lt");
2164   COMPARE(cinc(w28, w29, gt), "cinc w28, w29, gt");
2165   COMPARE(cinc(x30, x0, le), "cinc x30, x0, le");
2166   COMPARE(cinv(w1, w2, eq), "cinv w1, w2, eq");
2167   COMPARE(cinv(x3, x4, ne), "cinv x3, x4, ne");
2168   COMPARE(cneg(w5, w6, hs), "cneg w5, w6, hs");
2169   COMPARE(cneg(x7, x8, lo), "cneg x7, x8, lo");
2170 
2171   COMPARE(csel(x0, x1, x2, al), "csel x0, x1, x2, al");
2172   COMPARE(csel(x1, x2, x3, nv), "csel x1, x2, x3, nv");
2173   COMPARE(csinc(x2, x3, x4, al), "csinc x2, x3, x4, al");
2174   COMPARE(csinc(x3, x4, x5, nv), "csinc x3, x4, x5, nv");
2175   COMPARE(csinv(x4, x5, x6, al), "csinv x4, x5, x6, al");
2176   COMPARE(csinv(x5, x6, x7, nv), "csinv x5, x6, x7, nv");
2177   COMPARE(csneg(x6, x7, x8, al), "csneg x6, x7, x8, al");
2178   COMPARE(csneg(x7, x8, x9, nv), "csneg x7, x8, x9, nv");
2179 
2180   CLEANUP();
2181 }
2182 
2183 
TEST(cond_select_macro)2184 TEST(cond_select_macro) {
2185   SETUP();
2186 
2187   // In the tests below we also test the `GetCselSynthesisInformation()` helper.
2188   // These tests are here (rather than in test-assembler-aarch64.cc) because the
2189   // disassembly makes it easy to see whether or not the inputs are synthesised.
2190   bool synthesises_left = false;
2191   bool synthesises_right = false;
2192 
2193   COMPARE_MACRO(Csel(w0, w1, -1, eq), "csinv w0, w1, wzr, eq");
2194   MacroAssembler::GetCselSynthesisInformation(w0,
2195                                               w1,
2196                                               -1,
2197                                               &synthesises_left,
2198                                               &synthesises_right);
2199   VIXL_CHECK(!synthesises_left && !synthesises_right);
2200 
2201   COMPARE_MACRO(Csel(w2, w3, 0, ne), "csel w2, w3, wzr, ne");
2202   MacroAssembler::GetCselSynthesisInformation(w2,
2203                                               w3,
2204                                               wzr,
2205                                               &synthesises_left,
2206                                               &synthesises_right);
2207   VIXL_CHECK(!synthesises_left && !synthesises_right);
2208 
2209   COMPARE_MACRO(Csel(w4, w5, 1, hs), "csinc w4, w5, wzr, hs");
2210   MacroAssembler::GetCselSynthesisInformation(w4,
2211                                               w5,
2212                                               1,
2213                                               &synthesises_left,
2214                                               &synthesises_right);
2215   VIXL_CHECK(!synthesises_left && !synthesises_right);
2216 
2217   COMPARE_MACRO(Csel(x6, x7, -1, lo), "csinv x6, x7, xzr, lo");
2218   MacroAssembler::GetCselSynthesisInformation(x6,
2219                                               x7,
2220                                               xzr,
2221                                               &synthesises_left,
2222                                               &synthesises_right);
2223   VIXL_CHECK(!synthesises_left && !synthesises_right);
2224 
2225   COMPARE_MACRO(Csel(x8, x9, 0, mi), "csel x8, x9, xzr, mi");
2226   MacroAssembler::GetCselSynthesisInformation(x8,
2227                                               x9,
2228                                               xzr,
2229                                               &synthesises_left,
2230                                               &synthesises_right);
2231   VIXL_CHECK(!synthesises_left && !synthesises_right);
2232 
2233   COMPARE_MACRO(Csel(x10, x11, 1, pl), "csinc x10, x11, xzr, pl");
2234   MacroAssembler::GetCselSynthesisInformation(x10,
2235                                               x11,
2236                                               xzr,
2237                                               &synthesises_left,
2238                                               &synthesises_right);
2239   VIXL_CHECK(!synthesises_left && !synthesises_right);
2240 
2241   COMPARE_MACRO(Csel(x12, 0, 0, eq), "mov x12, #0x0");
2242   MacroAssembler::GetCselSynthesisInformation(x12,
2243                                               0,
2244                                               0,
2245                                               &synthesises_left,
2246                                               &synthesises_right);
2247   VIXL_CHECK(!synthesises_left && !synthesises_right);
2248 
2249   COMPARE_MACRO(Csel(w13, 0, 1, eq), "cset w13, ne");
2250   MacroAssembler::GetCselSynthesisInformation(w13,
2251                                               0,
2252                                               1,
2253                                               &synthesises_left,
2254                                               &synthesises_right);
2255   VIXL_CHECK(!synthesises_left && !synthesises_right);
2256 
2257   COMPARE_MACRO(Csel(x14, 1, 0, eq), "cset x14, eq");
2258   MacroAssembler::GetCselSynthesisInformation(x14,
2259                                               1,
2260                                               0,
2261                                               &synthesises_left,
2262                                               &synthesises_right);
2263   VIXL_CHECK(!synthesises_left && !synthesises_right);
2264 
2265   COMPARE_MACRO(Csel(w15, 0, -1, eq), "csetm w15, ne");
2266   MacroAssembler::GetCselSynthesisInformation(w15,
2267                                               0,
2268                                               -1,
2269                                               &synthesises_left,
2270                                               &synthesises_right);
2271   VIXL_CHECK(!synthesises_left && !synthesises_right);
2272 
2273   COMPARE_MACRO(Csel(x18, -1, 0, eq), "csetm x18, eq");
2274   MacroAssembler::GetCselSynthesisInformation(x18,
2275                                               -1,
2276                                               0,
2277                                               &synthesises_left,
2278                                               &synthesises_right);
2279   VIXL_CHECK(!synthesises_left && !synthesises_right);
2280 
2281   COMPARE_MACRO(Csel(w19, -1, 1, eq),
2282                 "mov w19, #0x1\n"
2283                 "cneg w19, w19, eq");
2284   MacroAssembler::GetCselSynthesisInformation(w19,
2285                                               -1,
2286                                               1,
2287                                               &synthesises_left,
2288                                               &synthesises_right);
2289   VIXL_CHECK(!synthesises_left && synthesises_right);
2290 
2291   COMPARE_MACRO(Csel(x20, 1, -1, eq),
2292                 "mov x20, #0xffffffffffffffff\n"
2293                 "cneg x20, x20, eq");
2294   MacroAssembler::GetCselSynthesisInformation(x20,
2295                                               1,
2296                                               -1,
2297                                               &synthesises_left,
2298                                               &synthesises_right);
2299   VIXL_CHECK(!synthesises_left && synthesises_right);
2300 
2301   COMPARE_MACRO(Csel(w21, 0xaa, 0xbb, eq),
2302                 "mov w16, #0xaa\n"
2303                 "mov w17, #0xbb\n"
2304                 "csel w21, w16, w17, eq");
2305   MacroAssembler::GetCselSynthesisInformation(w21,
2306                                               0xaa,
2307                                               0xbb,
2308                                               &synthesises_left,
2309                                               &synthesises_right);
2310   VIXL_CHECK(synthesises_left && synthesises_right);
2311 
2312   COMPARE_MACRO(Csel(x22, 0xaa, -0xbb, eq),
2313                 "mov x16, #0xaa\n"
2314                 "mov x17, #0xffffffffffffff45\n"
2315                 "csel x22, x16, x17, eq");
2316   MacroAssembler::GetCselSynthesisInformation(x22,
2317                                               0xaa,
2318                                               -0xbb,
2319                                               &synthesises_left,
2320                                               &synthesises_right);
2321   VIXL_CHECK(synthesises_left && synthesises_right);
2322 
2323   COMPARE_MACRO(Csel(w23, 0, 0xaa, eq),
2324                 "mov w16, #0xaa\n"
2325                 "csel w23, w16, wzr, ne");
2326   MacroAssembler::GetCselSynthesisInformation(w23,
2327                                               0,
2328                                               0xaa,
2329                                               &synthesises_left,
2330                                               &synthesises_right);
2331   VIXL_CHECK(!synthesises_left && synthesises_right);
2332 
2333   COMPARE_MACRO(Csel(x24, -0xaa, 0, eq),
2334                 "mov x16, #0xffffffffffffff56\n"
2335                 "csel x24, x16, xzr, eq");
2336   MacroAssembler::GetCselSynthesisInformation(x24,
2337                                               -0xaa,
2338                                               0,
2339                                               &synthesises_left,
2340                                               &synthesises_right);
2341   VIXL_CHECK(synthesises_left && !synthesises_right);
2342 
2343   COMPARE_MACRO(Csel(w25, 0xcc, -0xcc, eq),
2344                 "mov w25, #0xffffff34\n"
2345                 "cneg w25, w25, eq");
2346   MacroAssembler::GetCselSynthesisInformation(w25,
2347                                               0xcc,
2348                                               -0xcc,
2349                                               &synthesises_left,
2350                                               &synthesises_right);
2351   VIXL_CHECK(!synthesises_left && synthesises_right);
2352 
2353   COMPARE_MACRO(Csel(x26, -0xcc, 0xcc, eq),
2354                 "mov x26, #0xcc\n"
2355                 "cneg x26, x26, eq");
2356   MacroAssembler::GetCselSynthesisInformation(w25,
2357                                               -0xcc,
2358                                               0xcc,
2359                                               &synthesises_left,
2360                                               &synthesises_right);
2361   VIXL_CHECK(!synthesises_left && synthesises_right);
2362 
2363   // Test with `Operand` inputs.
2364   COMPARE_MACRO(Csel(x0, x1, Operand(x2, LSL, 3), eq),
2365                 "lsl x16, x2, #3\n"
2366                 "csel x0, x1, x16, eq");
2367   MacroAssembler::GetCselSynthesisInformation(x0,
2368                                               x1,
2369                                               Operand(x2, LSL, 3),
2370                                               &synthesises_left,
2371                                               &synthesises_right);
2372   VIXL_CHECK(!synthesises_left && synthesises_right);
2373 
2374   COMPARE_MACRO(Csel(x3, x4, Operand(x5, SXTH), eq),
2375                 "sxth x16, w5\n"
2376                 "csel x3, x4, x16, eq");
2377   MacroAssembler::GetCselSynthesisInformation(x3,
2378                                               x4,
2379                                               Operand(x5, SXTH),
2380                                               &synthesises_left,
2381                                               &synthesises_right);
2382   VIXL_CHECK(!synthesises_left && synthesises_right);
2383 
2384   COMPARE_MACRO(Csel(x6, Operand(x7, LSL, 7), x8, eq),
2385                 "lsl x16, x7, #7\n"
2386                 "csel x6, x16, x8, eq");
2387   MacroAssembler::GetCselSynthesisInformation(x6,
2388                                               Operand(x7, LSL, 7),
2389                                               x8,
2390                                               &synthesises_left,
2391                                               &synthesises_right);
2392   VIXL_CHECK(synthesises_left && !synthesises_right);
2393 
2394   COMPARE_MACRO(Csel(x9, Operand(x10, SXTH), x11, eq),
2395                 "sxth x16, w10\n"
2396                 "csel x9, x16, x11, eq");
2397   MacroAssembler::GetCselSynthesisInformation(x9,
2398                                               Operand(x10, SXTH),
2399                                               x11,
2400                                               &synthesises_left,
2401                                               &synthesises_right);
2402   VIXL_CHECK(synthesises_left && !synthesises_right);
2403 
2404   COMPARE_MACRO(Csel(x12, Operand(x13, LSL, 13), Operand(x14, SXTB), eq),
2405                 "lsl x16, x13, #13\n"
2406                 "sxtb x17, w14\n"
2407                 "csel x12, x16, x17, eq");
2408   MacroAssembler::GetCselSynthesisInformation(x12,
2409                                               Operand(x13, LSL, 13),
2410                                               Operand(x14, SXTB),
2411                                               &synthesises_left,
2412                                               &synthesises_right);
2413   VIXL_CHECK(synthesises_left && synthesises_right);
2414 
2415   COMPARE_MACRO(Csel(x15, 0, Operand(x18, LSR, 18), eq),
2416                 "lsr x16, x18, #18\n"
2417                 "csel x15, x16, xzr, ne");
2418   MacroAssembler::GetCselSynthesisInformation(x15,
2419                                               0,
2420                                               Operand(x18, LSR, 18),
2421                                               &synthesises_left,
2422                                               &synthesises_right);
2423   VIXL_CHECK(!synthesises_left && synthesises_right);
2424 
2425   // Test with the zero register.
2426   COMPARE_MACRO(Csel(w19, wzr, wzr, eq), "mov w19, #0x0");
2427   MacroAssembler::GetCselSynthesisInformation(w19,
2428                                               wzr,
2429                                               wzr,
2430                                               &synthesises_left,
2431                                               &synthesises_right);
2432   VIXL_CHECK(!synthesises_left && !synthesises_right);
2433 
2434   COMPARE_MACRO(Csel(x20, x21, xzr, eq), "csel x20, x21, xzr, eq");
2435   MacroAssembler::GetCselSynthesisInformation(x20,
2436                                               x21,
2437                                               xzr,
2438                                               &synthesises_left,
2439                                               &synthesises_right);
2440   VIXL_CHECK(!synthesises_left && !synthesises_right);
2441 
2442   COMPARE_MACRO(Csel(w22, wzr, w23, eq), "csel w22, w23, wzr, ne");
2443   MacroAssembler::GetCselSynthesisInformation(w22,
2444                                               wzr,
2445                                               w23,
2446                                               &synthesises_left,
2447                                               &synthesises_right);
2448   VIXL_CHECK(!synthesises_left && !synthesises_right);
2449 
2450   COMPARE_MACRO(Csel(x24, xzr, 0, eq), "mov x24, #0x0");
2451   MacroAssembler::GetCselSynthesisInformation(x24,
2452                                               xzr,
2453                                               0,
2454                                               &synthesises_left,
2455                                               &synthesises_right);
2456   VIXL_CHECK(!synthesises_left && !synthesises_right);
2457 
2458   COMPARE_MACRO(Csel(w25, wzr, 1, eq), "cset w25, ne");
2459   MacroAssembler::GetCselSynthesisInformation(w25,
2460                                               wzr,
2461                                               1,
2462                                               &synthesises_left,
2463                                               &synthesises_right);
2464   VIXL_CHECK(!synthesises_left && !synthesises_right);
2465 
2466 
2467   CLEANUP();
2468 }
2469 
2470 
TEST(cond_cmp)2471 TEST(cond_cmp) {
2472   SETUP();
2473 
2474   COMPARE(ccmn(w0, w1, NZCVFlag, eq), "ccmn w0, w1, #NZCV, eq");
2475   COMPARE(ccmn(x2, x3, NZCFlag, ne), "ccmn x2, x3, #NZCv, ne");
2476   COMPARE(ccmp(w4, w5, NZVFlag, hs), "ccmp w4, w5, #NZcV, hs");
2477   COMPARE(ccmp(x6, x7, NZFlag, lo), "ccmp x6, x7, #NZcv, lo");
2478   COMPARE(ccmn(w8, 31, NFlag, mi), "ccmn w8, #31, #Nzcv, mi");
2479   COMPARE(ccmn(x9, 30, NCFlag, pl), "ccmn x9, #30, #NzCv, pl");
2480   COMPARE(ccmp(w10, 29, NVFlag, vs), "ccmp w10, #29, #NzcV, vs");
2481   COMPARE(ccmp(x11, 28, NFlag, vc), "ccmp x11, #28, #Nzcv, vc");
2482   COMPARE(ccmn(w12, w13, NoFlag, al), "ccmn w12, w13, #nzcv, al");
2483   COMPARE(ccmp(x14, 27, ZVFlag, nv), "ccmp x14, #27, #nZcV, nv");
2484 
2485   CLEANUP();
2486 }
2487 
2488 
TEST(cond_cmp_macro)2489 TEST(cond_cmp_macro) {
2490   SETUP();
2491 
2492   COMPARE_MACRO(Ccmp(w0, -1, VFlag, hi), "ccmn w0, #1, #nzcV, hi");
2493   COMPARE_MACRO(Ccmp(x1, -31, CFlag, ge), "ccmn x1, #31, #nzCv, ge");
2494   COMPARE_MACRO(Ccmn(w2, -1, CVFlag, gt), "ccmp w2, #1, #nzCV, gt");
2495   COMPARE_MACRO(Ccmn(x3, -31, ZCVFlag, ls), "ccmp x3, #31, #nZCV, ls");
2496 
2497   CLEANUP();
2498 }
2499 
2500 
TEST(fmov_imm)2501 TEST(fmov_imm) {
2502   SETUP();
2503 
2504   COMPARE(fmov(s0, 1.0f), "fmov s0, #0x70 (1.0000)");
2505   COMPARE(fmov(s31, -13.0f), "fmov s31, #0xaa (-13.0000)");
2506   COMPARE(fmov(d1, 1.0), "fmov d1, #0x70 (1.0000)");
2507   COMPARE(fmov(d29, -13.0), "fmov d29, #0xaa (-13.0000)");
2508 
2509   CLEANUP();
2510 }
2511 
2512 
TEST(fmov_reg)2513 TEST(fmov_reg) {
2514   SETUP();
2515 
2516   COMPARE(fmov(w3, s13), "fmov w3, s13");
2517   COMPARE(fmov(x6, d26), "fmov x6, d26");
2518   COMPARE(fmov(s11, w30), "fmov s11, w30");
2519   COMPARE(fmov(d31, x2), "fmov d31, x2");
2520   COMPARE(fmov(s12, s13), "fmov s12, s13");
2521   COMPARE(fmov(d22, d23), "fmov d22, d23");
2522   COMPARE(fmov(v0.D(), 1, x13), "fmov v0.D[1], x13");
2523   COMPARE(fmov(x13, v0.D(), 1), "fmov x13, v0.D[1]");
2524 
2525   CLEANUP();
2526 }
2527 
2528 
TEST(fp_dp1)2529 TEST(fp_dp1) {
2530   SETUP();
2531 
2532   COMPARE(fabs(s0, s1), "fabs s0, s1");
2533   COMPARE(fabs(s31, s30), "fabs s31, s30");
2534   COMPARE(fabs(d2, d3), "fabs d2, d3");
2535   COMPARE(fabs(d31, d30), "fabs d31, d30");
2536   COMPARE(fneg(s4, s5), "fneg s4, s5");
2537   COMPARE(fneg(s31, s30), "fneg s31, s30");
2538   COMPARE(fneg(d6, d7), "fneg d6, d7");
2539   COMPARE(fneg(d31, d30), "fneg d31, d30");
2540   COMPARE(fsqrt(s8, s9), "fsqrt s8, s9");
2541   COMPARE(fsqrt(s31, s30), "fsqrt s31, s30");
2542   COMPARE(fsqrt(d10, d11), "fsqrt d10, d11");
2543   COMPARE(fsqrt(d31, d30), "fsqrt d31, d30");
2544   COMPARE(frinta(s10, s11), "frinta s10, s11");
2545   COMPARE(frinta(s31, s30), "frinta s31, s30");
2546   COMPARE(frinta(d12, d13), "frinta d12, d13");
2547   COMPARE(frinta(d31, d30), "frinta d31, d30");
2548   COMPARE(frinti(s10, s11), "frinti s10, s11");
2549   COMPARE(frinti(s31, s30), "frinti s31, s30");
2550   COMPARE(frinti(d12, d13), "frinti d12, d13");
2551   COMPARE(frinti(d31, d30), "frinti d31, d30");
2552   COMPARE(frintm(s10, s11), "frintm s10, s11");
2553   COMPARE(frintm(s31, s30), "frintm s31, s30");
2554   COMPARE(frintm(d12, d13), "frintm d12, d13");
2555   COMPARE(frintm(d31, d30), "frintm d31, d30");
2556   COMPARE(frintn(s10, s11), "frintn s10, s11");
2557   COMPARE(frintn(s31, s30), "frintn s31, s30");
2558   COMPARE(frintn(d12, d13), "frintn d12, d13");
2559   COMPARE(frintn(d31, d30), "frintn d31, d30");
2560   COMPARE(frintx(s10, s11), "frintx s10, s11");
2561   COMPARE(frintx(s31, s30), "frintx s31, s30");
2562   COMPARE(frintx(d12, d13), "frintx d12, d13");
2563   COMPARE(frintx(d31, d30), "frintx d31, d30");
2564   COMPARE(frintz(s10, s11), "frintz s10, s11");
2565   COMPARE(frintz(s31, s30), "frintz s31, s30");
2566   COMPARE(frintz(d12, d13), "frintz d12, d13");
2567   COMPARE(frintz(d31, d30), "frintz d31, d30");
2568   COMPARE(fcvt(d14, s15), "fcvt d14, s15");
2569   COMPARE(fcvt(d31, s31), "fcvt d31, s31");
2570   COMPARE(fcvt(s0, d1), "fcvt s0, d1");
2571   COMPARE(fcvt(s2, h3), "fcvt s2, h3");
2572   COMPARE(fcvt(d4, h5), "fcvt d4, h5");
2573   COMPARE(fcvt(h6, s7), "fcvt h6, s7");
2574   COMPARE(fcvt(h8, d9), "fcvt h8, d9");
2575 
2576   CLEANUP();
2577 }
2578 
2579 
TEST(fp_dp2)2580 TEST(fp_dp2) {
2581   SETUP();
2582 
2583   COMPARE(fadd(s0, s1, s2), "fadd s0, s1, s2");
2584   COMPARE(fadd(d3, d4, d5), "fadd d3, d4, d5");
2585   COMPARE(fsub(s31, s30, s29), "fsub s31, s30, s29");
2586   COMPARE(fsub(d31, d30, d29), "fsub d31, d30, d29");
2587   COMPARE(fmul(s7, s8, s9), "fmul s7, s8, s9");
2588   COMPARE(fmul(d10, d11, d12), "fmul d10, d11, d12");
2589   COMPARE(fnmul(s7, s8, s9), "fnmul s7, s8, s9");
2590   COMPARE(fnmul(d10, d11, d12), "fnmul d10, d11, d12");
2591   COMPARE(fdiv(s13, s14, s15), "fdiv s13, s14, s15");
2592   COMPARE(fdiv(d16, d17, d18), "fdiv d16, d17, d18");
2593   COMPARE(fmax(s19, s20, s21), "fmax s19, s20, s21");
2594   COMPARE(fmax(d22, d23, d24), "fmax d22, d23, d24");
2595   COMPARE(fmin(s25, s26, s27), "fmin s25, s26, s27");
2596   COMPARE(fmin(d28, d29, d30), "fmin d28, d29, d30");
2597   COMPARE(fmaxnm(s31, s0, s1), "fmaxnm s31, s0, s1");
2598   COMPARE(fmaxnm(d2, d3, d4), "fmaxnm d2, d3, d4");
2599   COMPARE(fminnm(s5, s6, s7), "fminnm s5, s6, s7");
2600   COMPARE(fminnm(d8, d9, d10), "fminnm d8, d9, d10");
2601 
2602   CLEANUP();
2603 }
2604 
2605 
TEST(fp_dp3)2606 TEST(fp_dp3) {
2607   SETUP();
2608 
2609   COMPARE(fmadd(s7, s8, s9, s10), "fmadd s7, s8, s9, s10");
2610   COMPARE(fmadd(d10, d11, d12, d10), "fmadd d10, d11, d12, d10");
2611   COMPARE(fmsub(s7, s8, s9, s10), "fmsub s7, s8, s9, s10");
2612   COMPARE(fmsub(d10, d11, d12, d10), "fmsub d10, d11, d12, d10");
2613 
2614   COMPARE(fnmadd(s7, s8, s9, s10), "fnmadd s7, s8, s9, s10");
2615   COMPARE(fnmadd(d10, d11, d12, d10), "fnmadd d10, d11, d12, d10");
2616   COMPARE(fnmsub(s7, s8, s9, s10), "fnmsub s7, s8, s9, s10");
2617   COMPARE(fnmsub(d10, d11, d12, d10), "fnmsub d10, d11, d12, d10");
2618 
2619   CLEANUP();
2620 }
2621 
2622 
TEST(fp_compare)2623 TEST(fp_compare) {
2624   SETUP();
2625 
2626   COMPARE(fcmp(s0, s1), "fcmp s0, s1");
2627   COMPARE(fcmp(s31, s30), "fcmp s31, s30");
2628   COMPARE(fcmp(d0, d1), "fcmp d0, d1");
2629   COMPARE(fcmp(d31, d30), "fcmp d31, d30");
2630   COMPARE(fcmp(s12, 0), "fcmp s12, #0.0");
2631   COMPARE(fcmp(d12, 0), "fcmp d12, #0.0");
2632 
2633   COMPARE(fcmpe(s0, s1), "fcmpe s0, s1");
2634   COMPARE(fcmpe(s31, s30), "fcmpe s31, s30");
2635   COMPARE(fcmpe(d0, d1), "fcmpe d0, d1");
2636   COMPARE(fcmpe(d31, d30), "fcmpe d31, d30");
2637   COMPARE(fcmpe(s12, 0), "fcmpe s12, #0.0");
2638   COMPARE(fcmpe(d12, 0), "fcmpe d12, #0.0");
2639 
2640   CLEANUP();
2641 }
2642 
2643 
TEST(fp_cond_compare)2644 TEST(fp_cond_compare) {
2645   SETUP();
2646 
2647   COMPARE(fccmp(s0, s1, NoFlag, eq), "fccmp s0, s1, #nzcv, eq");
2648   COMPARE(fccmp(s2, s3, ZVFlag, ne), "fccmp s2, s3, #nZcV, ne");
2649   COMPARE(fccmp(s30, s16, NCFlag, pl), "fccmp s30, s16, #NzCv, pl");
2650   COMPARE(fccmp(s31, s31, NZCVFlag, le), "fccmp s31, s31, #NZCV, le");
2651   COMPARE(fccmp(d4, d5, VFlag, gt), "fccmp d4, d5, #nzcV, gt");
2652   COMPARE(fccmp(d6, d7, NFlag, vs), "fccmp d6, d7, #Nzcv, vs");
2653   COMPARE(fccmp(d30, d0, NZFlag, vc), "fccmp d30, d0, #NZcv, vc");
2654   COMPARE(fccmp(d31, d31, ZFlag, hs), "fccmp d31, d31, #nZcv, hs");
2655   COMPARE(fccmp(s14, s15, CVFlag, al), "fccmp s14, s15, #nzCV, al");
2656   COMPARE(fccmp(d16, d17, CFlag, nv), "fccmp d16, d17, #nzCv, nv");
2657 
2658   COMPARE(fccmpe(s0, s1, NoFlag, eq), "fccmpe s0, s1, #nzcv, eq");
2659   COMPARE(fccmpe(s2, s3, ZVFlag, ne), "fccmpe s2, s3, #nZcV, ne");
2660   COMPARE(fccmpe(s30, s16, NCFlag, pl), "fccmpe s30, s16, #NzCv, pl");
2661   COMPARE(fccmpe(s31, s31, NZCVFlag, le), "fccmpe s31, s31, #NZCV, le");
2662   COMPARE(fccmpe(d4, d5, VFlag, gt), "fccmpe d4, d5, #nzcV, gt");
2663   COMPARE(fccmpe(d6, d7, NFlag, vs), "fccmpe d6, d7, #Nzcv, vs");
2664   COMPARE(fccmpe(d30, d0, NZFlag, vc), "fccmpe d30, d0, #NZcv, vc");
2665   COMPARE(fccmpe(d31, d31, ZFlag, hs), "fccmpe d31, d31, #nZcv, hs");
2666   COMPARE(fccmpe(s14, s15, CVFlag, al), "fccmpe s14, s15, #nzCV, al");
2667   COMPARE(fccmpe(d16, d17, CFlag, nv), "fccmpe d16, d17, #nzCv, nv");
2668 
2669   CLEANUP();
2670 }
2671 
2672 
TEST(fp_select)2673 TEST(fp_select) {
2674   SETUP();
2675 
2676   COMPARE(fcsel(s0, s1, s2, eq), "fcsel s0, s1, s2, eq")
2677   COMPARE(fcsel(s31, s31, s30, ne), "fcsel s31, s31, s30, ne");
2678   COMPARE(fcsel(d0, d1, d2, mi), "fcsel d0, d1, d2, mi");
2679   COMPARE(fcsel(d31, d30, d31, pl), "fcsel d31, d30, d31, pl");
2680   COMPARE(fcsel(s14, s15, s16, al), "fcsel s14, s15, s16, al");
2681   COMPARE(fcsel(d17, d18, d19, nv), "fcsel d17, d18, d19, nv");
2682 
2683   CLEANUP();
2684 }
2685 
2686 
TEST(fcvt_scvtf_ucvtf)2687 TEST(fcvt_scvtf_ucvtf) {
2688   SETUP();
2689 
2690   COMPARE(fcvtas(w0, s1), "fcvtas w0, s1");
2691   COMPARE(fcvtas(x2, s3), "fcvtas x2, s3");
2692   COMPARE(fcvtas(w4, d5), "fcvtas w4, d5");
2693   COMPARE(fcvtas(x6, d7), "fcvtas x6, d7");
2694   COMPARE(fcvtau(w8, s9), "fcvtau w8, s9");
2695   COMPARE(fcvtau(x10, s11), "fcvtau x10, s11");
2696   COMPARE(fcvtau(w12, d13), "fcvtau w12, d13");
2697   COMPARE(fcvtau(x14, d15), "fcvtau x14, d15");
2698   COMPARE(fcvtns(w0, s1), "fcvtns w0, s1");
2699   COMPARE(fcvtns(x2, s3), "fcvtns x2, s3");
2700   COMPARE(fcvtns(w4, d5), "fcvtns w4, d5");
2701   COMPARE(fcvtns(x6, d7), "fcvtns x6, d7");
2702   COMPARE(fcvtnu(w8, s9), "fcvtnu w8, s9");
2703   COMPARE(fcvtnu(x10, s11), "fcvtnu x10, s11");
2704   COMPARE(fcvtnu(w12, d13), "fcvtnu w12, d13");
2705   COMPARE(fcvtnu(x14, d15), "fcvtnu x14, d15");
2706   COMPARE(fcvtzu(x16, d17), "fcvtzu x16, d17");
2707   COMPARE(fcvtzu(w18, d19), "fcvtzu w18, d19");
2708   COMPARE(fcvtzs(x20, d21), "fcvtzs x20, d21");
2709   COMPARE(fcvtzs(w22, d23), "fcvtzs w22, d23");
2710   COMPARE(fcvtzu(x16, s17), "fcvtzu x16, s17");
2711   COMPARE(fcvtzu(w18, s19), "fcvtzu w18, s19");
2712   COMPARE(fcvtzs(x20, s21), "fcvtzs x20, s21");
2713   COMPARE(fcvtzs(w22, s23), "fcvtzs w22, s23");
2714   COMPARE(fcvtzs(w2, d1, 1), "fcvtzs w2, d1, #1");
2715   COMPARE(fcvtzs(w2, s1, 1), "fcvtzs w2, s1, #1");
2716   COMPARE(fcvtzs(x4, d3, 15), "fcvtzs x4, d3, #15");
2717   COMPARE(fcvtzs(x4, s3, 15), "fcvtzs x4, s3, #15");
2718   COMPARE(fcvtzs(w6, d5, 32), "fcvtzs w6, d5, #32");
2719   COMPARE(fcvtzs(w6, s5, 32), "fcvtzs w6, s5, #32");
2720   COMPARE(fcvtzu(w2, d1, 1), "fcvtzu w2, d1, #1");
2721   COMPARE(fcvtzu(w2, s1, 1), "fcvtzu w2, s1, #1");
2722   COMPARE(fcvtzu(x4, d3, 15), "fcvtzu x4, d3, #15");
2723   COMPARE(fcvtzu(x4, s3, 15), "fcvtzu x4, s3, #15");
2724   COMPARE(fcvtzu(w6, d5, 32), "fcvtzu w6, d5, #32");
2725   COMPARE(fcvtzu(w6, s5, 32), "fcvtzu w6, s5, #32");
2726   COMPARE(fcvtpu(x24, d25), "fcvtpu x24, d25");
2727   COMPARE(fcvtpu(w26, d27), "fcvtpu w26, d27");
2728   COMPARE(fcvtps(x28, d29), "fcvtps x28, d29");
2729   COMPARE(fcvtps(w30, d31), "fcvtps w30, d31");
2730   COMPARE(fcvtpu(x0, s1), "fcvtpu x0, s1");
2731   COMPARE(fcvtpu(w2, s3), "fcvtpu w2, s3");
2732   COMPARE(fcvtps(x4, s5), "fcvtps x4, s5");
2733   COMPARE(fcvtps(w6, s7), "fcvtps w6, s7");
2734   COMPARE(scvtf(d24, w25), "scvtf d24, w25");
2735   COMPARE(scvtf(s24, w25), "scvtf s24, w25");
2736   COMPARE(scvtf(d26, x0), "scvtf d26, x0");
2737   COMPARE(scvtf(s26, x0), "scvtf s26, x0");
2738   COMPARE(ucvtf(d28, w29), "ucvtf d28, w29");
2739   COMPARE(ucvtf(s28, w29), "ucvtf s28, w29");
2740   COMPARE(ucvtf(d0, x1), "ucvtf d0, x1");
2741   COMPARE(ucvtf(s0, x1), "ucvtf s0, x1");
2742   COMPARE(ucvtf(d0, x1, 0), "ucvtf d0, x1");
2743   COMPARE(ucvtf(s0, x1, 0), "ucvtf s0, x1");
2744   COMPARE(scvtf(d1, x2, 1), "scvtf d1, x2, #1");
2745   COMPARE(scvtf(s1, x2, 1), "scvtf s1, x2, #1");
2746   COMPARE(scvtf(d3, x4, 15), "scvtf d3, x4, #15");
2747   COMPARE(scvtf(s3, x4, 15), "scvtf s3, x4, #15");
2748   COMPARE(scvtf(d5, x6, 32), "scvtf d5, x6, #32");
2749   COMPARE(scvtf(s5, x6, 32), "scvtf s5, x6, #32");
2750   COMPARE(ucvtf(d7, x8, 2), "ucvtf d7, x8, #2");
2751   COMPARE(ucvtf(s7, x8, 2), "ucvtf s7, x8, #2");
2752   COMPARE(ucvtf(d9, x10, 16), "ucvtf d9, x10, #16");
2753   COMPARE(ucvtf(s9, x10, 16), "ucvtf s9, x10, #16");
2754   COMPARE(ucvtf(d11, x12, 33), "ucvtf d11, x12, #33");
2755   COMPARE(ucvtf(s11, x12, 33), "ucvtf s11, x12, #33");
2756   COMPARE(fcvtms(w0, s1), "fcvtms w0, s1");
2757   COMPARE(fcvtms(x2, s3), "fcvtms x2, s3");
2758   COMPARE(fcvtms(w4, d5), "fcvtms w4, d5");
2759   COMPARE(fcvtms(x6, d7), "fcvtms x6, d7");
2760   COMPARE(fcvtmu(w8, s9), "fcvtmu w8, s9");
2761   COMPARE(fcvtmu(x10, s11), "fcvtmu x10, s11");
2762   COMPARE(fcvtmu(w12, d13), "fcvtmu w12, d13");
2763   COMPARE(fcvtmu(x14, d15), "fcvtmu x14, d15");
2764 
2765   CLEANUP();
2766 }
2767 
2768 
TEST(system_clrex)2769 TEST(system_clrex) {
2770   SETUP();
2771 
2772   COMPARE(clrex(0), "clrex #0x0");
2773   COMPARE(clrex(14), "clrex #0xe");
2774   COMPARE(clrex(15), "clrex");
2775   COMPARE(clrex(), "clrex");
2776 
2777   CLEANUP();
2778 }
2779 
2780 
TEST(system_mrs)2781 TEST(system_mrs) {
2782   SETUP();
2783 
2784   COMPARE(mrs(x0, NZCV), "mrs x0, nzcv");
2785   COMPARE(mrs(x30, NZCV), "mrs x30, nzcv");
2786   COMPARE(mrs(x15, FPCR), "mrs x15, fpcr");
2787 
2788   CLEANUP();
2789 }
2790 
2791 
TEST(system_msr)2792 TEST(system_msr) {
2793   SETUP();
2794 
2795   COMPARE(msr(NZCV, x0), "msr nzcv, x0");
2796   COMPARE(msr(NZCV, x30), "msr nzcv, x30");
2797   COMPARE(msr(FPCR, x15), "msr fpcr, x15");
2798 
2799   CLEANUP();
2800 }
2801 
2802 
TEST(system_sys)2803 TEST(system_sys) {
2804   SETUP();
2805 
2806   COMPARE(sys(0x3, 0x7, 0x5, 0x1, x1), "ic ivau, x1");
2807   COMPARE(sys(0x3, 0x7, 0xa, 0x1, x2), "dc cvac, x2");
2808   COMPARE(sys(0x3, 0x7, 0xb, 0x1, x3), "dc cvau, x3");
2809   COMPARE(sys(0x3, 0x7, 0xe, 0x1, x4), "dc civac, x4");
2810   COMPARE(sys(0x3, 0x7, 0x4, 0x1, x0), "dc zva, x0");
2811   COMPARE(sys(0x0, 0x0, 0x0, 0x0, x0), "sys #0, C0, C0, #0, x0");
2812   COMPARE(sys(0x1, 0x2, 0x5, 0x2, x5), "sys #1, C2, C5, #2, x5");
2813   COMPARE(sys(0x2, 0x8, 0xa, 0x3, x6), "sys #2, C8, C10, #3, x6");
2814   COMPARE(sys(0x2, 0xf, 0xf, 0x1, xzr), "sys #2, C15, C15, #1");
2815   COMPARE(sys(0x2, 0xf, 0xf, 0x1), "sys #2, C15, C15, #1");
2816 
2817   CLEANUP();
2818 }
2819 
2820 
TEST(system_ic)2821 TEST(system_ic) {
2822   SETUP();
2823 
2824   COMPARE(ic(IVAU, x0), "ic ivau, x0");
2825   COMPARE(ic(IVAU, x1), "ic ivau, x1");
2826   COMPARE(ic(IVAU, xzr), "ic ivau, xzr");
2827 
2828   CLEANUP();
2829 }
2830 
2831 
TEST(system_dc)2832 TEST(system_dc) {
2833   SETUP();
2834 
2835   COMPARE(dc(CVAC, x2), "dc cvac, x2");
2836   COMPARE(dc(CVAU, x3), "dc cvau, x3");
2837   COMPARE(dc(CIVAC, x4), "dc civac, x4");
2838   COMPARE(dc(ZVA, x0), "dc zva, x0");
2839   COMPARE(dc(ZVA, xzr), "dc zva, xzr");
2840 
2841   CLEANUP();
2842 }
2843 
2844 
TEST(system_nop)2845 TEST(system_nop) {
2846   SETUP();
2847 
2848   COMPARE(nop(), "nop");
2849 
2850   CLEANUP();
2851 }
2852 
2853 
TEST(unreachable)2854 TEST(unreachable) {
2855   SETUP();
2856 
2857 #ifdef VIXL_INCLUDE_SIMULATOR_AARCH64
2858   VIXL_ASSERT(kUnreachableOpcode == 0xdeb0);
2859   COMPARE_MACRO(Unreachable(), "hlt #0xdeb0");
2860 #else
2861   COMPARE_MACRO(Unreachable(), "blr xzr");
2862 #endif
2863 
2864   CLEANUP();
2865 }
2866 
2867 
2868 #ifdef VIXL_INCLUDE_SIMULATOR_AARCH64
TEST(trace)2869 TEST(trace) {
2870   SETUP();
2871 
2872   VIXL_ASSERT(kTraceOpcode == 0xdeb2);
2873 
2874   // All Trace calls should produce the same instruction.
2875   COMPARE_MACRO_PREFIX(Trace(LOG_ALL, TRACE_ENABLE), "hlt #0xdeb2");
2876   COMPARE_MACRO_PREFIX(Trace(LOG_REGS, TRACE_DISABLE), "hlt #0xdeb2");
2877 
2878   CLEANUP();
2879 }
2880 #endif
2881 
2882 
2883 #ifdef VIXL_INCLUDE_SIMULATOR_AARCH64
TEST(log)2884 TEST(log) {
2885   SETUP();
2886 
2887   VIXL_ASSERT(kLogOpcode == 0xdeb3);
2888 
2889   // All Log calls should produce the same instruction.
2890   COMPARE_MACRO_PREFIX(Log(LOG_ALL), "hlt #0xdeb3");
2891   COMPARE_MACRO_PREFIX(Log(LOG_SYSREGS), "hlt #0xdeb3");
2892 
2893   CLEANUP();
2894 }
2895 #endif
2896 
2897 
TEST(hlt)2898 TEST(hlt) {
2899   SETUP();
2900 
2901   COMPARE(hlt(0), "hlt #0x0");
2902   COMPARE(hlt(1), "hlt #0x1");
2903   COMPARE(hlt(65535), "hlt #0xffff");
2904 
2905   CLEANUP();
2906 }
2907 
2908 
TEST(brk)2909 TEST(brk) {
2910   SETUP();
2911 
2912   COMPARE(brk(0), "brk #0x0");
2913   COMPARE(brk(1), "brk #0x1");
2914   COMPARE(brk(65535), "brk #0xffff");
2915 
2916   CLEANUP();
2917 }
2918 
2919 
TEST(svc)2920 TEST(svc) {
2921   SETUP();
2922 
2923   COMPARE(svc(0), "svc #0x0");
2924   COMPARE(svc(1), "svc #0x1");
2925   COMPARE(svc(65535), "svc #0xffff");
2926 
2927   CLEANUP();
2928 }
2929 
2930 
TEST(add_sub_negative)2931 TEST(add_sub_negative) {
2932   SETUP();
2933 
2934   COMPARE_MACRO(Add(x10, x0, -42), "sub x10, x0, #0x2a (42)");
2935   COMPARE_MACRO(Add(x11, x1, -687), "sub x11, x1, #0x2af (687)");
2936   COMPARE_MACRO(Add(x12, x2, -0x88), "sub x12, x2, #0x88 (136)");
2937 
2938   COMPARE_MACRO(Sub(x13, x0, -600), "add x13, x0, #0x258 (600)");
2939   COMPARE_MACRO(Sub(x14, x1, -313), "add x14, x1, #0x139 (313)");
2940   COMPARE_MACRO(Sub(x15, x2, -0x555), "add x15, x2, #0x555 (1365)");
2941 
2942   COMPARE_MACRO(Add(w19, w3, -0x344), "sub w19, w3, #0x344 (836)");
2943   COMPARE_MACRO(Add(w20, w4, -2000), "sub w20, w4, #0x7d0 (2000)");
2944 
2945   COMPARE_MACRO(Add(w0, w1, 5, LeaveFlags), "add w0, w1, #0x5 (5)");
2946   COMPARE_MACRO(Add(w1, w2, 15, SetFlags), "adds w1, w2, #0xf (15)");
2947 
2948   COMPARE_MACRO(Sub(w0, w1, 5, LeaveFlags), "sub w0, w1, #0x5 (5)");
2949   COMPARE_MACRO(Sub(w1, w2, 15, SetFlags), "subs w1, w2, #0xf (15)");
2950 
2951   COMPARE_MACRO(Sub(w21, w3, -0xbc), "add w21, w3, #0xbc (188)");
2952   COMPARE_MACRO(Sub(w22, w4, -2000), "add w22, w4, #0x7d0 (2000)");
2953 
2954   COMPARE_MACRO(Cmp(w0, -1), "cmn w0, #0x1 (1)");
2955   COMPARE_MACRO(Cmp(x1, -1), "cmn x1, #0x1 (1)");
2956   COMPARE_MACRO(Cmp(w2, -4095), "cmn w2, #0xfff (4095)");
2957   COMPARE_MACRO(Cmp(x3, -4095), "cmn x3, #0xfff (4095)");
2958 
2959   COMPARE_MACRO(Cmn(w0, -1), "cmp w0, #0x1 (1)");
2960   COMPARE_MACRO(Cmn(x1, -1), "cmp x1, #0x1 (1)");
2961   COMPARE_MACRO(Cmn(w2, -4095), "cmp w2, #0xfff (4095)");
2962   COMPARE_MACRO(Cmn(x3, -4095), "cmp x3, #0xfff (4095)");
2963 
2964   CLEANUP();
2965 }
2966 
2967 
TEST(logical_immediate_move)2968 TEST(logical_immediate_move) {
2969   SETUP();
2970 
2971   COMPARE_MACRO(And(w0, w1, 0), "mov w0, #0x0");
2972   COMPARE_MACRO(And(x0, x1, 0), "mov x0, #0x0");
2973   COMPARE_MACRO(Orr(w2, w3, 0), "mov w2, w3");
2974   COMPARE_MACRO(Orr(x2, x3, 0), "mov x2, x3");
2975   COMPARE_MACRO(Eor(w4, w5, 0), "mov w4, w5");
2976   COMPARE_MACRO(Eor(x4, x5, 0), "mov x4, x5");
2977   COMPARE_MACRO(Bic(w6, w7, 0), "mov w6, w7");
2978   COMPARE_MACRO(Bic(x6, x7, 0), "mov x6, x7");
2979   COMPARE_MACRO(Orn(w8, w9, 0), "mov w8, #0xffffffff");
2980   COMPARE_MACRO(Orn(x8, x9, 0), "mov x8, #0xffffffffffffffff");
2981   COMPARE_MACRO(Eon(w10, w11, 0), "mvn w10, w11");
2982   COMPARE_MACRO(Eon(x10, x11, 0), "mvn x10, x11");
2983 
2984   COMPARE_MACRO(And(w12, w13, 0xffffffff), "mov w12, w13");
2985   COMPARE_MACRO(And(x12, x13, 0xffffffff), "and x12, x13, #0xffffffff");
2986   COMPARE_MACRO(And(x12, x13, 0xffffffffffffffff), "mov x12, x13");
2987   COMPARE_MACRO(Orr(w14, w15, 0xffffffff), "mov w14, #0xffffffff");
2988   COMPARE_MACRO(Orr(x14, x15, 0xffffffff), "orr x14, x15, #0xffffffff");
2989   COMPARE_MACRO(Orr(x14, x15, 0xffffffffffffffff),
2990                 "mov x14, #0xffffffffffffffff");
2991   COMPARE_MACRO(Eor(w16, w17, 0xffffffff), "mvn w16, w17");
2992   COMPARE_MACRO(Eor(x16, x17, 0xffffffff), "eor x16, x17, #0xffffffff");
2993   COMPARE_MACRO(Eor(x16, x17, 0xffffffffffffffff), "mvn x16, x17");
2994   COMPARE_MACRO(Bic(w18, w19, 0xffffffff), "mov w18, #0x0");
2995   COMPARE_MACRO(Bic(x18, x19, 0xffffffff), "and x18, x19, #0xffffffff00000000");
2996   COMPARE_MACRO(Bic(x18, x19, 0xffffffffffffffff), "mov x18, #0x0");
2997   COMPARE_MACRO(Orn(w20, w21, 0xffffffff), "mov w20, w21");
2998   COMPARE_MACRO(Orn(x20, x21, 0xffffffff), "orr x20, x21, #0xffffffff00000000");
2999   COMPARE_MACRO(Orn(x20, x21, 0xffffffffffffffff), "mov x20, x21");
3000   COMPARE_MACRO(Eon(w22, w23, 0xffffffff), "mov w22, w23");
3001   COMPARE_MACRO(Eon(x22, x23, 0xffffffff), "eor x22, x23, #0xffffffff00000000");
3002   COMPARE_MACRO(Eon(x22, x23, 0xffffffffffffffff), "mov x22, x23");
3003 
3004   CLEANUP();
3005 }
3006 
3007 
TEST(barriers)3008 TEST(barriers) {
3009   SETUP();
3010 
3011   // DMB
3012   COMPARE_MACRO(Dmb(FullSystem, BarrierAll), "dmb sy");
3013   COMPARE_MACRO(Dmb(FullSystem, BarrierReads), "dmb ld");
3014   COMPARE_MACRO(Dmb(FullSystem, BarrierWrites), "dmb st");
3015 
3016   COMPARE_MACRO(Dmb(InnerShareable, BarrierAll), "dmb ish");
3017   COMPARE_MACRO(Dmb(InnerShareable, BarrierReads), "dmb ishld");
3018   COMPARE_MACRO(Dmb(InnerShareable, BarrierWrites), "dmb ishst");
3019 
3020   COMPARE_MACRO(Dmb(NonShareable, BarrierAll), "dmb nsh");
3021   COMPARE_MACRO(Dmb(NonShareable, BarrierReads), "dmb nshld");
3022   COMPARE_MACRO(Dmb(NonShareable, BarrierWrites), "dmb nshst");
3023 
3024   COMPARE_MACRO(Dmb(OuterShareable, BarrierAll), "dmb osh");
3025   COMPARE_MACRO(Dmb(OuterShareable, BarrierReads), "dmb oshld");
3026   COMPARE_MACRO(Dmb(OuterShareable, BarrierWrites), "dmb oshst");
3027 
3028   COMPARE_MACRO(Dmb(FullSystem, BarrierOther), "dmb sy (0b1100)");
3029   COMPARE_MACRO(Dmb(InnerShareable, BarrierOther), "dmb sy (0b1000)");
3030   COMPARE_MACRO(Dmb(NonShareable, BarrierOther), "dmb sy (0b0100)");
3031   COMPARE_MACRO(Dmb(OuterShareable, BarrierOther), "dmb sy (0b0000)");
3032 
3033   // DSB
3034   COMPARE_MACRO(Dsb(FullSystem, BarrierAll), "dsb sy");
3035   COMPARE_MACRO(Dsb(FullSystem, BarrierReads), "dsb ld");
3036   COMPARE_MACRO(Dsb(FullSystem, BarrierWrites), "dsb st");
3037 
3038   COMPARE_MACRO(Dsb(InnerShareable, BarrierAll), "dsb ish");
3039   COMPARE_MACRO(Dsb(InnerShareable, BarrierReads), "dsb ishld");
3040   COMPARE_MACRO(Dsb(InnerShareable, BarrierWrites), "dsb ishst");
3041 
3042   COMPARE_MACRO(Dsb(NonShareable, BarrierAll), "dsb nsh");
3043   COMPARE_MACRO(Dsb(NonShareable, BarrierReads), "dsb nshld");
3044   COMPARE_MACRO(Dsb(NonShareable, BarrierWrites), "dsb nshst");
3045 
3046   COMPARE_MACRO(Dsb(OuterShareable, BarrierAll), "dsb osh");
3047   COMPARE_MACRO(Dsb(OuterShareable, BarrierReads), "dsb oshld");
3048   COMPARE_MACRO(Dsb(OuterShareable, BarrierWrites), "dsb oshst");
3049 
3050   COMPARE_MACRO(Dsb(FullSystem, BarrierOther), "dsb sy (0b1100)");
3051   COMPARE_MACRO(Dsb(InnerShareable, BarrierOther), "dsb sy (0b1000)");
3052   COMPARE_MACRO(Dsb(NonShareable, BarrierOther), "dsb sy (0b0100)");
3053   COMPARE_MACRO(Dsb(OuterShareable, BarrierOther), "dsb sy (0b0000)");
3054 
3055   // ISB
3056   COMPARE_MACRO(Isb(), "isb");
3057 
3058   CLEANUP();
3059 }
3060 
3061 
3062 #define VLIST2(v) \
3063   v, VRegister((v.GetCode() + 1) % 32, v.GetSizeInBits(), v.GetLanes())
3064 #define VLIST3(v) \
3065   VLIST2(v), VRegister((v.GetCode() + 2) % 32, v.GetSizeInBits(), v.GetLanes())
3066 #define VLIST4(v) \
3067   VLIST3(v), VRegister((v.GetCode() + 3) % 32, v.GetSizeInBits(), v.GetLanes())
3068 
3069 
3070 #define NEON_FORMAT_LIST(V) \
3071   V(V8B(), "8b")            \
3072   V(V16B(), "16b")          \
3073   V(V4H(), "4h")            \
3074   V(V8H(), "8h")            \
3075   V(V2S(), "2s")            \
3076   V(V4S(), "4s")            \
3077   V(V2D(), "2d")
3078 
3079 #define NEON_FORMAT_LIST_LP(V)  \
3080   V(V4H(), "4h", V8B(), "8b")   \
3081   V(V2S(), "2s", V4H(), "4h")   \
3082   V(V1D(), "1d", V2S(), "2s")   \
3083   V(V8H(), "8h", V16B(), "16b") \
3084   V(V4S(), "4s", V8H(), "8h")   \
3085   V(V2D(), "2d", V4S(), "4s")
3086 
3087 #define NEON_FORMAT_LIST_LW(V) \
3088   V(V8H(), "8h", V8B(), "8b")  \
3089   V(V4S(), "4s", V4H(), "4h")  \
3090   V(V2D(), "2d", V2S(), "2s")
3091 
3092 #define NEON_FORMAT_LIST_LW2(V) \
3093   V(V8H(), "8h", V16B(), "16b") \
3094   V(V4S(), "4s", V8H(), "8h")   \
3095   V(V2D(), "2d", V4S(), "4s")
3096 
3097 #define NEON_FORMAT_LIST_BHS(V) \
3098   V(V8B(), "8b")                \
3099   V(V16B(), "16b")              \
3100   V(V4H(), "4h")                \
3101   V(V8H(), "8h")                \
3102   V(V2S(), "2s")                \
3103   V(V4S(), "4s")
3104 
3105 #define NEON_FORMAT_LIST_HS(V) \
3106   V(V4H(), "4h")               \
3107   V(V8H(), "8h")               \
3108   V(V2S(), "2s")               \
3109   V(V4S(), "4s")
3110 
TEST(neon_load_store_vector)3111 TEST(neon_load_store_vector) {
3112   SETUP();
3113 
3114 #define DISASM_INST(M, S)                                               \
3115   COMPARE_MACRO(Ld1(v0.M, MemOperand(x15)), "ld1 {v0." S "}, [x15]");   \
3116   COMPARE_MACRO(Ld1(v1.M, v2.M, MemOperand(x16)),                       \
3117                 "ld1 {v1." S ", v2." S "}, [x16]");                     \
3118   COMPARE_MACRO(Ld1(v3.M, v4.M, v5.M, MemOperand(x17)),                 \
3119                 "ld1 {v3." S ", v4." S ", v5." S "}, [x17]");           \
3120   COMPARE_MACRO(Ld1(v6.M, v7.M, v8.M, v9.M, MemOperand(x18)),           \
3121                 "ld1 {v6." S ", v7." S ", v8." S ", v9." S "}, [x18]")  \
3122   COMPARE_MACRO(Ld1(v30.M, v31.M, v0.M, v1.M, MemOperand(sp)),          \
3123                 "ld1 {v30." S ", v31." S ", v0." S ", v1." S "}, [sp]") \
3124   COMPARE_MACRO(Ld2(v1.M, v2.M, MemOperand(x16)),                       \
3125                 "ld2 {v1." S ", v2." S "}, [x16]");                     \
3126   COMPARE_MACRO(Ld3(v3.M, v4.M, v5.M, MemOperand(x17)),                 \
3127                 "ld3 {v3." S ", v4." S ", v5." S "}, [x17]");           \
3128   COMPARE_MACRO(Ld4(v6.M, v7.M, v8.M, v9.M, MemOperand(x18)),           \
3129                 "ld4 {v6." S ", v7." S ", v8." S ", v9." S "}, [x18]")  \
3130   COMPARE_MACRO(Ld4(v30.M, v31.M, v0.M, v1.M, MemOperand(sp)),          \
3131                 "ld4 {v30." S ", v31." S ", v0." S ", v1." S "}, [sp]") \
3132   NEON_FORMAT_LIST(DISASM_INST);
3133 #undef DISASM_INST
3134 
3135 #define DISASM_INST(M, S)                                                      \
3136   COMPARE_MACRO(Ld1(v0.M, MemOperand(x15, x20, PostIndex)),                    \
3137                 "ld1 {v0." S "}, [x15], x20");                                 \
3138   COMPARE_MACRO(Ld1(v1.M, v2.M, MemOperand(x16, x21, PostIndex)),              \
3139                 "ld1 {v1." S ", v2." S "}, [x16], x21");                       \
3140   COMPARE_MACRO(Ld1(v3.M, v4.M, v5.M, MemOperand(x17, x22, PostIndex)),        \
3141                 "ld1 {v3." S ", v4." S ", v5." S "}, [x17], x22");             \
3142   COMPARE_MACRO(Ld1(v6.M, v7.M, v8.M, v9.M, MemOperand(x18, x23, PostIndex)),  \
3143                 "ld1 {v6." S ", v7." S ", v8." S ", v9." S "}, [x18], x23")    \
3144   COMPARE_MACRO(Ld1(v30.M, v31.M, v0.M, v1.M, MemOperand(sp, x24, PostIndex)), \
3145                 "ld1 {v30." S ", v31." S ", v0." S ", v1." S "}, [sp], x24")   \
3146   COMPARE_MACRO(Ld2(v1.M, v2.M, MemOperand(x16, x21, PostIndex)),              \
3147                 "ld2 {v1." S ", v2." S "}, [x16], x21");                       \
3148   COMPARE_MACRO(Ld3(v3.M, v4.M, v5.M, MemOperand(x17, x22, PostIndex)),        \
3149                 "ld3 {v3." S ", v4." S ", v5." S "}, [x17], x22");             \
3150   COMPARE_MACRO(Ld4(v6.M, v7.M, v8.M, v9.M, MemOperand(x18, x23, PostIndex)),  \
3151                 "ld4 {v6." S ", v7." S ", v8." S ", v9." S "}, [x18], x23")    \
3152   COMPARE_MACRO(Ld4(v30.M, v31.M, v0.M, v1.M, MemOperand(sp, x24, PostIndex)), \
3153                 "ld4 {v30." S ", v31." S ", v0." S ", v1." S "}, [sp], x24")   \
3154   NEON_FORMAT_LIST(DISASM_INST);
3155 #undef DISASM_INST
3156 
3157   COMPARE_MACRO(Ld1(v0.V8B(), MemOperand(x15, 8, PostIndex)),
3158                 "ld1 {v0.8b}, [x15], #8");
3159   COMPARE_MACRO(Ld1(v1.V16B(), MemOperand(x16, 16, PostIndex)),
3160                 "ld1 {v1.16b}, [x16], #16");
3161   COMPARE_MACRO(Ld1(v2.V4H(), v3.V4H(), MemOperand(x17, 16, PostIndex)),
3162                 "ld1 {v2.4h, v3.4h}, [x17], #16");
3163   COMPARE_MACRO(Ld1(v4.V8H(), v5.V8H(), MemOperand(x18, 32, PostIndex)),
3164                 "ld1 {v4.8h, v5.8h}, [x18], #32");
3165   COMPARE_MACRO(Ld1(v16.V2S(),
3166                     v17.V2S(),
3167                     v18.V2S(),
3168                     MemOperand(x19, 24, PostIndex)),
3169                 "ld1 {v16.2s, v17.2s, v18.2s}, [x19], #24");
3170   COMPARE_MACRO(Ld1(v16.V4S(),
3171                     v17.V4S(),
3172                     v18.V4S(),
3173                     MemOperand(x19, 48, PostIndex)),
3174                 "ld1 {v16.4s, v17.4s, v18.4s}, [x19], #48");
3175   COMPARE_MACRO(Ld1(v19.V2S(),
3176                     v20.V2S(),
3177                     v21.V2S(),
3178                     v22.V2S(),
3179                     MemOperand(x20, 32, PostIndex)),
3180                 "ld1 {v19.2s, v20.2s, v21.2s, v22.2s}, [x20], #32");
3181   COMPARE_MACRO(Ld1(v23.V2D(),
3182                     v24.V2D(),
3183                     v25.V2D(),
3184                     v26.V2D(),
3185                     MemOperand(x21, 64, PostIndex)),
3186                 "ld1 {v23.2d, v24.2d, v25.2d, v26.2d}, [x21], #64");
3187 
3188   COMPARE_MACRO(Ld2(v2.V4H(), v3.V4H(), MemOperand(x17, 16, PostIndex)),
3189                 "ld2 {v2.4h, v3.4h}, [x17], #16");
3190   COMPARE_MACRO(Ld2(v4.V8H(), v5.V8H(), MemOperand(x18, 32, PostIndex)),
3191                 "ld2 {v4.8h, v5.8h}, [x18], #32");
3192   COMPARE_MACRO(Ld3(v16.V2S(),
3193                     v17.V2S(),
3194                     v18.V2S(),
3195                     MemOperand(x19, 24, PostIndex)),
3196                 "ld3 {v16.2s, v17.2s, v18.2s}, [x19], #24");
3197   COMPARE_MACRO(Ld3(v16.V4S(),
3198                     v17.V4S(),
3199                     v18.V4S(),
3200                     MemOperand(x19, 48, PostIndex)),
3201                 "ld3 {v16.4s, v17.4s, v18.4s}, [x19], #48");
3202   COMPARE_MACRO(Ld4(v19.V2S(),
3203                     v20.V2S(),
3204                     v21.V2S(),
3205                     v22.V2S(),
3206                     MemOperand(x20, 32, PostIndex)),
3207                 "ld4 {v19.2s, v20.2s, v21.2s, v22.2s}, [x20], #32");
3208   COMPARE_MACRO(Ld4(v23.V2D(),
3209                     v24.V2D(),
3210                     v25.V2D(),
3211                     v26.V2D(),
3212                     MemOperand(x21, 64, PostIndex)),
3213                 "ld4 {v23.2d, v24.2d, v25.2d, v26.2d}, [x21], #64");
3214 
3215   COMPARE_MACRO(Ld1(v0.V1D(), MemOperand(x16)), "ld1 {v0.1d}, [x16]");
3216   COMPARE_MACRO(Ld1(v1.V1D(), v2.V1D(), MemOperand(x17, 16, PostIndex)),
3217                 "ld1 {v1.1d, v2.1d}, [x17], #16");
3218   COMPARE_MACRO(Ld1(v3.V1D(),
3219                     v4.V1D(),
3220                     v5.V1D(),
3221                     MemOperand(x18, x19, PostIndex)),
3222                 "ld1 {v3.1d, v4.1d, v5.1d}, [x18], x19");
3223   COMPARE_MACRO(Ld1(v30.V1D(),
3224                     v31.V1D(),
3225                     v0.V1D(),
3226                     v1.V1D(),
3227                     MemOperand(x20, 32, PostIndex)),
3228                 "ld1 {v30.1d, v31.1d, v0.1d, v1.1d}, [x20], #32");
3229   COMPARE_MACRO(Ld1(d30, d31, d0, d1, MemOperand(x21, x22, PostIndex)),
3230                 "ld1 {v30.1d, v31.1d, v0.1d, v1.1d}, [x21], x22");
3231 
3232 #define DISASM_INST(M, S)                                                  \
3233   COMPARE_MACRO(St1(v20.M, MemOperand(x15)), "st1 {v20." S "}, [x15]");    \
3234   COMPARE_MACRO(St1(v21.M, v22.M, MemOperand(x16)),                        \
3235                 "st1 {v21." S ", v22." S "}, [x16]");                      \
3236   COMPARE_MACRO(St1(v23.M, v24.M, v25.M, MemOperand(x17)),                 \
3237                 "st1 {v23." S ", v24." S ", v25." S "}, [x17]");           \
3238   COMPARE_MACRO(St1(v26.M, v27.M, v28.M, v29.M, MemOperand(x18)),          \
3239                 "st1 {v26." S ", v27." S ", v28." S ", v29." S "}, [x18]") \
3240   COMPARE_MACRO(St1(v30.M, v31.M, v0.M, v1.M, MemOperand(sp)),             \
3241                 "st1 {v30." S ", v31." S ", v0." S ", v1." S "}, [sp]")    \
3242   COMPARE_MACRO(St2(VLIST2(v21.M), MemOperand(x16)),                       \
3243                 "st2 {v21." S ", v22." S "}, [x16]");                      \
3244   COMPARE_MACRO(St3(v23.M, v24.M, v25.M, MemOperand(x17)),                 \
3245                 "st3 {v23." S ", v24." S ", v25." S "}, [x17]");           \
3246   COMPARE_MACRO(St4(v30.M, v31.M, v0.M, v1.M, MemOperand(sp)),             \
3247                 "st4 {v30." S ", v31." S ", v0." S ", v1." S "}, [sp]")
3248   NEON_FORMAT_LIST(DISASM_INST);
3249 #undef DISASM_INST
3250 
3251 #define DISASM_INST(M, S)                                                      \
3252   COMPARE_MACRO(St1(v0.M, MemOperand(x15, x20, PostIndex)),                    \
3253                 "st1 {v0." S "}, [x15], x20");                                 \
3254   COMPARE_MACRO(St1(v1.M, v2.M, MemOperand(x16, x21, PostIndex)),              \
3255                 "st1 {v1." S ", v2." S "}, [x16], x21");                       \
3256   COMPARE_MACRO(St1(v3.M, v4.M, v5.M, MemOperand(x17, x22, PostIndex)),        \
3257                 "st1 {v3." S ", v4." S ", v5." S "}, [x17], x22");             \
3258   COMPARE_MACRO(St1(v6.M, v7.M, v8.M, v9.M, MemOperand(x18, x23, PostIndex)),  \
3259                 "st1 {v6." S ", v7." S ", v8." S ", v9." S "}, [x18], x23")    \
3260   COMPARE_MACRO(St1(v30.M, v31.M, v0.M, v1.M, MemOperand(sp, x24, PostIndex)), \
3261                 "st1 {v30." S ", v31." S ", v0." S ", v1." S "}, [sp], x24")   \
3262   COMPARE_MACRO(St2(v1.M, v2.M, MemOperand(x16, x21, PostIndex)),              \
3263                 "st2 {v1." S ", v2." S "}, [x16], x21");                       \
3264   COMPARE_MACRO(St3(v3.M, v4.M, v5.M, MemOperand(x17, x22, PostIndex)),        \
3265                 "st3 {v3." S ", v4." S ", v5." S "}, [x17], x22");             \
3266   COMPARE_MACRO(St4(v6.M, v7.M, v8.M, v9.M, MemOperand(x18, x23, PostIndex)),  \
3267                 "st4 {v6." S ", v7." S ", v8." S ", v9." S "}, [x18], x23")    \
3268   COMPARE_MACRO(St4(v30.M, v31.M, v0.M, v1.M, MemOperand(sp, x24, PostIndex)), \
3269                 "st4 {v30." S ", v31." S ", v0." S ", v1." S "}, [sp], x24")
3270   NEON_FORMAT_LIST(DISASM_INST);
3271 #undef DISASM_INST
3272 
3273   COMPARE_MACRO(St1(v0.V8B(), MemOperand(x15, 8, PostIndex)),
3274                 "st1 {v0.8b}, [x15], #8");
3275   COMPARE_MACRO(St1(v1.V16B(), MemOperand(x16, 16, PostIndex)),
3276                 "st1 {v1.16b}, [x16], #16");
3277   COMPARE_MACRO(St1(v2.V4H(), v3.V4H(), MemOperand(x17, 16, PostIndex)),
3278                 "st1 {v2.4h, v3.4h}, [x17], #16");
3279   COMPARE_MACRO(St1(v4.V8H(), v5.V8H(), MemOperand(x18, 32, PostIndex)),
3280                 "st1 {v4.8h, v5.8h}, [x18], #32");
3281   COMPARE_MACRO(St1(v16.V2S(),
3282                     v17.V2S(),
3283                     v18.V2S(),
3284                     MemOperand(x19, 24, PostIndex)),
3285                 "st1 {v16.2s, v17.2s, v18.2s}, [x19], #24");
3286   COMPARE_MACRO(St1(v16.V4S(),
3287                     v17.V4S(),
3288                     v18.V4S(),
3289                     MemOperand(x19, 48, PostIndex)),
3290                 "st1 {v16.4s, v17.4s, v18.4s}, [x19], #48");
3291   COMPARE_MACRO(St1(v19.V2S(),
3292                     v20.V2S(),
3293                     v21.V2S(),
3294                     v22.V2S(),
3295                     MemOperand(x20, 32, PostIndex)),
3296                 "st1 {v19.2s, v20.2s, v21.2s, v22.2s}, [x20], #32");
3297   COMPARE_MACRO(St1(v23.V2D(),
3298                     v24.V2D(),
3299                     v25.V2D(),
3300                     v26.V2D(),
3301                     MemOperand(x21, 64, PostIndex)),
3302                 "st1 {v23.2d, v24.2d, v25.2d, v26.2d}, [x21], #64");
3303   COMPARE_MACRO(St2(v1.V16B(), v2.V16B(), MemOperand(x16, 32, PostIndex)),
3304                 "st2 {v1.16b, v2.16b}, [x16], #32");
3305   COMPARE_MACRO(St2(v2.V4H(), v3.V4H(), MemOperand(x17, 16, PostIndex)),
3306                 "st2 {v2.4h, v3.4h}, [x17], #16");
3307   COMPARE_MACRO(St2(v4.V8H(), v5.V8H(), MemOperand(x18, 32, PostIndex)),
3308                 "st2 {v4.8h, v5.8h}, [x18], #32");
3309   COMPARE_MACRO(St3(v16.V2S(),
3310                     v17.V2S(),
3311                     v18.V2S(),
3312                     MemOperand(x19, 24, PostIndex)),
3313                 "st3 {v16.2s, v17.2s, v18.2s}, [x19], #24");
3314   COMPARE_MACRO(St3(v16.V4S(),
3315                     v17.V4S(),
3316                     v18.V4S(),
3317                     MemOperand(x19, 48, PostIndex)),
3318                 "st3 {v16.4s, v17.4s, v18.4s}, [x19], #48");
3319   COMPARE_MACRO(St4(v19.V2S(),
3320                     v20.V2S(),
3321                     v21.V2S(),
3322                     v22.V2S(),
3323                     MemOperand(x20, 32, PostIndex)),
3324                 "st4 {v19.2s, v20.2s, v21.2s, v22.2s}, [x20], #32");
3325   COMPARE_MACRO(St4(v23.V2D(),
3326                     v24.V2D(),
3327                     v25.V2D(),
3328                     v26.V2D(),
3329                     MemOperand(x21, 64, PostIndex)),
3330                 "st4 {v23.2d, v24.2d, v25.2d, v26.2d}, [x21], #64");
3331 
3332   COMPARE_MACRO(St1(v0.V1D(), MemOperand(x16)), "st1 {v0.1d}, [x16]");
3333   COMPARE_MACRO(St1(v1.V1D(), v2.V1D(), MemOperand(x17, 16, PostIndex)),
3334                 "st1 {v1.1d, v2.1d}, [x17], #16");
3335   COMPARE_MACRO(St1(v3.V1D(),
3336                     v4.V1D(),
3337                     v5.V1D(),
3338                     MemOperand(x18, x19, PostIndex)),
3339                 "st1 {v3.1d, v4.1d, v5.1d}, [x18], x19");
3340   COMPARE_MACRO(St1(v30.V1D(),
3341                     v31.V1D(),
3342                     v0.V1D(),
3343                     v1.V1D(),
3344                     MemOperand(x20, 32, PostIndex)),
3345                 "st1 {v30.1d, v31.1d, v0.1d, v1.1d}, [x20], #32");
3346   COMPARE_MACRO(St1(d30, d31, d0, d1, MemOperand(x21, x22, PostIndex)),
3347                 "st1 {v30.1d, v31.1d, v0.1d, v1.1d}, [x21], x22");
3348 
3349   CLEANUP();
3350 }
3351 
3352 
TEST(neon_load_store_vector_unallocated)3353 TEST(neon_load_store_vector_unallocated) {
3354   SETUP();
3355 
3356   const char* expected = "unallocated (NEONLoadStoreMultiStruct)";
3357   // LD[1-4] (multiple structures) (no offset)
3358   COMPARE(dci(0x0c401000), expected);  // opcode = 0b0001
3359   COMPARE(dci(0x0c403000), expected);  // opcode = 0b0011
3360   COMPARE(dci(0x0c405000), expected);  // opcode = 0b0101
3361   COMPARE(dci(0x0c409000), expected);  // opcode = 0b1001
3362   COMPARE(dci(0x0c40b000), expected);  // opcode = 0b1011
3363   COMPARE(dci(0x0c40c000), expected);  // opcode = 0b1100
3364   COMPARE(dci(0x0c40d000), expected);  // opcode = 0b1101
3365   COMPARE(dci(0x0c40e000), expected);  // opcode = 0b1110
3366   COMPARE(dci(0x0c40f000), expected);  // opcode = 0b1111
3367   COMPARE(dci(0x0c400c00), expected);  // opcode = 0b0000, size:Q = 0b110
3368   COMPARE(dci(0x0c404c00), expected);  // opcode = 0b0100, size:Q = 0b110
3369   COMPARE(dci(0x0c408c00), expected);  // opcode = 0b1000, size:Q = 0b110
3370 
3371   // ST[1-4] (multiple structures) (no offset)
3372   COMPARE(dci(0x0c001000), expected);  // opcode = 0b0001
3373   COMPARE(dci(0x0c003000), expected);  // opcode = 0b0011
3374   COMPARE(dci(0x0c005000), expected);  // opcode = 0b0101
3375   COMPARE(dci(0x0c009000), expected);  // opcode = 0b1001
3376   COMPARE(dci(0x0c00b000), expected);  // opcode = 0b1011
3377   COMPARE(dci(0x0c00c000), expected);  // opcode = 0b1100
3378   COMPARE(dci(0x0c00d000), expected);  // opcode = 0b1101
3379   COMPARE(dci(0x0c00e000), expected);  // opcode = 0b1110
3380   COMPARE(dci(0x0c00f000), expected);  // opcode = 0b1111
3381   COMPARE(dci(0x0c000c00), expected);  // opcode = 0b0000, size:Q = 0b110
3382   COMPARE(dci(0x0c004c00), expected);  // opcode = 0b0100, size:Q = 0b110
3383   COMPARE(dci(0x0c008c00), expected);  // opcode = 0b1000, size:Q = 0b110
3384 
3385   expected = "unallocated (NEONLoadStoreMultiStructPostIndex)";
3386   // LD[1-4] (multiple structures) (post index)
3387   COMPARE(dci(0x0cc01000), expected);  // opcode = 0b0001
3388   COMPARE(dci(0x0cc03000), expected);  // opcode = 0b0011
3389   COMPARE(dci(0x0cc05000), expected);  // opcode = 0b0101
3390   COMPARE(dci(0x0cc09000), expected);  // opcode = 0b1001
3391   COMPARE(dci(0x0cc0b000), expected);  // opcode = 0b1011
3392   COMPARE(dci(0x0cc0c000), expected);  // opcode = 0b1100
3393   COMPARE(dci(0x0cc0d000), expected);  // opcode = 0b1101
3394   COMPARE(dci(0x0cc0e000), expected);  // opcode = 0b1110
3395   COMPARE(dci(0x0cc0f000), expected);  // opcode = 0b1111
3396   COMPARE(dci(0x0cc00c00), expected);  // opcode = 0b0000, size:Q = 0b110
3397   COMPARE(dci(0x0cc04c00), expected);  // opcode = 0b0100, size:Q = 0b110
3398   COMPARE(dci(0x0cc08c00), expected);  // opcode = 0b1000, size:Q = 0b110
3399 
3400   // ST[1-4] (multiple structures) (post index)
3401   COMPARE(dci(0x0c801000), expected);  // opcode = 0b0001
3402   COMPARE(dci(0x0c803000), expected);  // opcode = 0b0011
3403   COMPARE(dci(0x0c805000), expected);  // opcode = 0b0101
3404   COMPARE(dci(0x0c809000), expected);  // opcode = 0b1001
3405   COMPARE(dci(0x0c80b000), expected);  // opcode = 0b1011
3406   COMPARE(dci(0x0c80c000), expected);  // opcode = 0b1100
3407   COMPARE(dci(0x0c80d000), expected);  // opcode = 0b1101
3408   COMPARE(dci(0x0c80e000), expected);  // opcode = 0b1110
3409   COMPARE(dci(0x0c80f000), expected);  // opcode = 0b1111
3410   COMPARE(dci(0x0c800c00), expected);  // opcode = 0b0000, size:Q = 0b110
3411   COMPARE(dci(0x0c804c00), expected);  // opcode = 0b0100, size:Q = 0b110
3412   COMPARE(dci(0x0c808c00), expected);  // opcode = 0b1000, size:Q = 0b110
3413 
3414   CLEANUP();
3415 }
3416 
3417 
TEST(neon_load_store_lane)3418 TEST(neon_load_store_lane) {
3419   SETUP();
3420 
3421   COMPARE_MACRO(Ld1(v0.V8B(), 0, MemOperand(x15)), "ld1 {v0.b}[0], [x15]");
3422   COMPARE_MACRO(Ld1(v1.V16B(), 1, MemOperand(x16)), "ld1 {v1.b}[1], [x16]");
3423   COMPARE_MACRO(Ld1(v2.V4H(), 2, MemOperand(x17)), "ld1 {v2.h}[2], [x17]");
3424   COMPARE_MACRO(Ld1(v3.V8H(), 3, MemOperand(x18)), "ld1 {v3.h}[3], [x18]");
3425   COMPARE_MACRO(Ld1(v4.V2S(), 0, MemOperand(x19)), "ld1 {v4.s}[0], [x19]");
3426   COMPARE_MACRO(Ld1(v5.V4S(), 1, MemOperand(x20)), "ld1 {v5.s}[1], [x20]");
3427   COMPARE_MACRO(Ld1(v6.V2D(), 0, MemOperand(x21)), "ld1 {v6.d}[0], [x21]");
3428   COMPARE_MACRO(Ld1(v7.B(), 7, MemOperand(x22)), "ld1 {v7.b}[7], [x22]");
3429   COMPARE_MACRO(Ld1(v8.B(), 15, MemOperand(x23)), "ld1 {v8.b}[15], [x23]");
3430   COMPARE_MACRO(Ld1(v9.H(), 3, MemOperand(x24)), "ld1 {v9.h}[3], [x24]");
3431   COMPARE_MACRO(Ld1(v10.H(), 7, MemOperand(x25)), "ld1 {v10.h}[7], [x25]");
3432   COMPARE_MACRO(Ld1(v11.S(), 1, MemOperand(x26)), "ld1 {v11.s}[1], [x26]");
3433   COMPARE_MACRO(Ld1(v12.S(), 3, MemOperand(x27)), "ld1 {v12.s}[3], [x27]");
3434   COMPARE_MACRO(Ld1(v13.D(), 1, MemOperand(sp)), "ld1 {v13.d}[1], [sp]");
3435 
3436   COMPARE_MACRO(Ld1(v0.V8B(), 0, MemOperand(x15, x0, PostIndex)),
3437                 "ld1 {v0.b}[0], [x15], x0");
3438   COMPARE_MACRO(Ld1(v1.V16B(), 1, MemOperand(x16, 1, PostIndex)),
3439                 "ld1 {v1.b}[1], [x16], #1");
3440   COMPARE_MACRO(Ld1(v2.V4H(), 2, MemOperand(x17, 2, PostIndex)),
3441                 "ld1 {v2.h}[2], [x17], #2");
3442   COMPARE_MACRO(Ld1(v3.V8H(), 3, MemOperand(x18, x1, PostIndex)),
3443                 "ld1 {v3.h}[3], [x18], x1");
3444   COMPARE_MACRO(Ld1(v4.V2S(), 0, MemOperand(x19, x2, PostIndex)),
3445                 "ld1 {v4.s}[0], [x19], x2");
3446   COMPARE_MACRO(Ld1(v5.V4S(), 1, MemOperand(x20, 4, PostIndex)),
3447                 "ld1 {v5.s}[1], [x20], #4");
3448   COMPARE_MACRO(Ld1(v6.V2D(), 0, MemOperand(x21, 8, PostIndex)),
3449                 "ld1 {v6.d}[0], [x21], #8");
3450   COMPARE_MACRO(Ld1(v7.B(), 7, MemOperand(x22, 1, PostIndex)),
3451                 "ld1 {v7.b}[7], [x22], #1");
3452   COMPARE_MACRO(Ld1(v8.B(), 15, MemOperand(x23, x3, PostIndex)),
3453                 "ld1 {v8.b}[15], [x23], x3");
3454   COMPARE_MACRO(Ld1(v9.H(), 3, MemOperand(x24, x4, PostIndex)),
3455                 "ld1 {v9.h}[3], [x24], x4");
3456   COMPARE_MACRO(Ld1(v10.H(), 7, MemOperand(x25, 2, PostIndex)),
3457                 "ld1 {v10.h}[7], [x25], #2");
3458   COMPARE_MACRO(Ld1(v11.S(), 1, MemOperand(x26, 4, PostIndex)),
3459                 "ld1 {v11.s}[1], [x26], #4");
3460   COMPARE_MACRO(Ld1(v12.S(), 3, MemOperand(x27, x5, PostIndex)),
3461                 "ld1 {v12.s}[3], [x27], x5");
3462   COMPARE_MACRO(Ld1(v12.S(), 3, MemOperand(x27, 4, PostIndex)),
3463                 "ld1 {v12.s}[3], [x27], #4");
3464   COMPARE_MACRO(Ld1(v13.D(), 1, MemOperand(sp, x6, PostIndex)),
3465                 "ld1 {v13.d}[1], [sp], x6");
3466   COMPARE_MACRO(Ld1(v13.D(), 1, MemOperand(sp, 8, PostIndex)),
3467                 "ld1 {v13.d}[1], [sp], #8");
3468 
3469   COMPARE_MACRO(Ld2(v0.V8B(), v1.V8B(), 0, MemOperand(x15)),
3470                 "ld2 {v0.b, v1.b}[0], [x15]");
3471   COMPARE_MACRO(Ld2(v1.V16B(), v2.V16B(), 1, MemOperand(x16)),
3472                 "ld2 {v1.b, v2.b}[1], [x16]");
3473   COMPARE_MACRO(Ld2(v2.V4H(), v3.V4H(), 2, MemOperand(x17)),
3474                 "ld2 {v2.h, v3.h}[2], [x17]");
3475   COMPARE_MACRO(Ld2(v3.V8H(), v4.V8H(), 3, MemOperand(x18)),
3476                 "ld2 {v3.h, v4.h}[3], [x18]");
3477   COMPARE_MACRO(Ld2(v4.V2S(), v5.V2S(), 0, MemOperand(x19)),
3478                 "ld2 {v4.s, v5.s}[0], [x19]");
3479   COMPARE_MACRO(Ld2(v5.V4S(), v6.V4S(), 1, MemOperand(x20)),
3480                 "ld2 {v5.s, v6.s}[1], [x20]");
3481   COMPARE_MACRO(Ld2(v6.V2D(), v7.V2D(), 0, MemOperand(x21)),
3482                 "ld2 {v6.d, v7.d}[0], [x21]");
3483   COMPARE_MACRO(Ld2(v7.B(), v8.B(), 7, MemOperand(x22)),
3484                 "ld2 {v7.b, v8.b}[7], [x22]");
3485   COMPARE_MACRO(Ld2(v8.B(), v9.B(), 15, MemOperand(x23)),
3486                 "ld2 {v8.b, v9.b}[15], [x23]");
3487   COMPARE_MACRO(Ld2(v9.H(), v10.H(), 3, MemOperand(x24)),
3488                 "ld2 {v9.h, v10.h}[3], [x24]");
3489   COMPARE_MACRO(Ld2(v10.H(), v11.H(), 7, MemOperand(x25)),
3490                 "ld2 {v10.h, v11.h}[7], [x25]");
3491   COMPARE_MACRO(Ld2(v11.S(), v12.S(), 1, MemOperand(x26)),
3492                 "ld2 {v11.s, v12.s}[1], [x26]");
3493   COMPARE_MACRO(Ld2(v12.S(), v13.S(), 3, MemOperand(x27)),
3494                 "ld2 {v12.s, v13.s}[3], [x27]");
3495   COMPARE_MACRO(Ld2(v13.D(), v14.D(), 1, MemOperand(sp)),
3496                 "ld2 {v13.d, v14.d}[1], [sp]");
3497 
3498   COMPARE_MACRO(Ld2(v0.V8B(), v1.V8B(), 0, MemOperand(x15, x0, PostIndex)),
3499                 "ld2 {v0.b, v1.b}[0], [x15], x0");
3500   COMPARE_MACRO(Ld2(v1.V16B(), v2.V16B(), 1, MemOperand(x16, 2, PostIndex)),
3501                 "ld2 {v1.b, v2.b}[1], [x16], #2");
3502   COMPARE_MACRO(Ld2(v2.V4H(), v3.V4H(), 2, MemOperand(x17, 4, PostIndex)),
3503                 "ld2 {v2.h, v3.h}[2], [x17], #4");
3504   COMPARE_MACRO(Ld2(v3.V8H(), v4.V8H(), 3, MemOperand(x18, x1, PostIndex)),
3505                 "ld2 {v3.h, v4.h}[3], [x18], x1");
3506   COMPARE_MACRO(Ld2(v4.V2S(), v5.V2S(), 0, MemOperand(x19, x2, PostIndex)),
3507                 "ld2 {v4.s, v5.s}[0], [x19], x2");
3508   COMPARE_MACRO(Ld2(v5.V4S(), v6.V4S(), 1, MemOperand(x20, 8, PostIndex)),
3509                 "ld2 {v5.s, v6.s}[1], [x20], #8");
3510   COMPARE_MACRO(Ld2(v6.V2D(), v7.V2D(), 0, MemOperand(x21, 16, PostIndex)),
3511                 "ld2 {v6.d, v7.d}[0], [x21], #16");
3512   COMPARE_MACRO(Ld2(v7.B(), v8.B(), 7, MemOperand(x22, 2, PostIndex)),
3513                 "ld2 {v7.b, v8.b}[7], [x22], #2");
3514   COMPARE_MACRO(Ld2(v8.B(), v9.B(), 15, MemOperand(x23, x3, PostIndex)),
3515                 "ld2 {v8.b, v9.b}[15], [x23], x3");
3516   COMPARE_MACRO(Ld2(v9.H(), v10.H(), 3, MemOperand(x24, x4, PostIndex)),
3517                 "ld2 {v9.h, v10.h}[3], [x24], x4");
3518   COMPARE_MACRO(Ld2(v10.H(), v11.H(), 7, MemOperand(x25, 4, PostIndex)),
3519                 "ld2 {v10.h, v11.h}[7], [x25], #4");
3520   COMPARE_MACRO(Ld2(v11.S(), v12.S(), 1, MemOperand(x26, 8, PostIndex)),
3521                 "ld2 {v11.s, v12.s}[1], [x26], #8");
3522   COMPARE_MACRO(Ld2(v12.S(), v13.S(), 3, MemOperand(x27, x5, PostIndex)),
3523                 "ld2 {v12.s, v13.s}[3], [x27], x5");
3524   COMPARE_MACRO(Ld2(v11.S(), v12.S(), 3, MemOperand(x26, 8, PostIndex)),
3525                 "ld2 {v11.s, v12.s}[3], [x26], #8");
3526   COMPARE_MACRO(Ld2(v13.D(), v14.D(), 1, MemOperand(sp, x6, PostIndex)),
3527                 "ld2 {v13.d, v14.d}[1], [sp], x6");
3528   COMPARE_MACRO(Ld2(v13.D(), v14.D(), 1, MemOperand(sp, 16, PostIndex)),
3529                 "ld2 {v13.d, v14.d}[1], [sp], #16");
3530 
3531   COMPARE_MACRO(Ld3(v0.V8B(), v1.V8B(), v2.V8B(), 0, MemOperand(x15)),
3532                 "ld3 {v0.b, v1.b, v2.b}[0], [x15]");
3533   COMPARE_MACRO(Ld3(v1.V16B(), v2.V16B(), v3.V16B(), 1, MemOperand(x16)),
3534                 "ld3 {v1.b, v2.b, v3.b}[1], [x16]");
3535   COMPARE_MACRO(Ld3(v2.V4H(), v3.V4H(), v4.V4H(), 2, MemOperand(x17)),
3536                 "ld3 {v2.h, v3.h, v4.h}[2], [x17]");
3537   COMPARE_MACRO(Ld3(v3.V8H(), v4.V8H(), v5.V8H(), 3, MemOperand(x18)),
3538                 "ld3 {v3.h, v4.h, v5.h}[3], [x18]");
3539   COMPARE_MACRO(Ld3(v4.V2S(), v5.V2S(), v6.V2S(), 0, MemOperand(x19)),
3540                 "ld3 {v4.s, v5.s, v6.s}[0], [x19]");
3541   COMPARE_MACRO(Ld3(v5.V4S(), v6.V4S(), v7.V4S(), 1, MemOperand(x20)),
3542                 "ld3 {v5.s, v6.s, v7.s}[1], [x20]");
3543   COMPARE_MACRO(Ld3(v6.V2D(), v7.V2D(), v8.V2D(), 0, MemOperand(x21)),
3544                 "ld3 {v6.d, v7.d, v8.d}[0], [x21]");
3545   COMPARE_MACRO(Ld3(v7.B(), v8.B(), v9.B(), 7, MemOperand(x22)),
3546                 "ld3 {v7.b, v8.b, v9.b}[7], [x22]");
3547   COMPARE_MACRO(Ld3(v8.B(), v9.B(), v10.B(), 15, MemOperand(x23)),
3548                 "ld3 {v8.b, v9.b, v10.b}[15], [x23]");
3549   COMPARE_MACRO(Ld3(v9.H(), v10.H(), v11.H(), 3, MemOperand(x24)),
3550                 "ld3 {v9.h, v10.h, v11.h}[3], [x24]");
3551   COMPARE_MACRO(Ld3(v10.H(), v11.H(), v12.H(), 7, MemOperand(x25)),
3552                 "ld3 {v10.h, v11.h, v12.h}[7], [x25]");
3553   COMPARE_MACRO(Ld3(v11.S(), v12.S(), v13.S(), 1, MemOperand(x26)),
3554                 "ld3 {v11.s, v12.s, v13.s}[1], [x26]");
3555   COMPARE_MACRO(Ld3(v12.S(), v13.S(), v14.S(), 3, MemOperand(x27)),
3556                 "ld3 {v12.s, v13.s, v14.s}[3], [x27]");
3557   COMPARE_MACRO(Ld3(v13.D(), v14.D(), v15.D(), 1, MemOperand(sp)),
3558                 "ld3 {v13.d, v14.d, v15.d}[1], [sp]");
3559 
3560   COMPARE_MACRO(Ld3(v0.V8B(),
3561                     v1.V8B(),
3562                     v2.V8B(),
3563                     0,
3564                     MemOperand(x15, x0, PostIndex)),
3565                 "ld3 {v0.b, v1.b, v2.b}[0], [x15], x0");
3566   COMPARE_MACRO(Ld3(v1.V16B(),
3567                     v2.V16B(),
3568                     v3.V16B(),
3569                     1,
3570                     MemOperand(x16, 3, PostIndex)),
3571                 "ld3 {v1.b, v2.b, v3.b}[1], [x16], #3");
3572   COMPARE_MACRO(Ld3(v2.V4H(),
3573                     v3.V4H(),
3574                     v4.V4H(),
3575                     2,
3576                     MemOperand(x17, 6, PostIndex)),
3577                 "ld3 {v2.h, v3.h, v4.h}[2], [x17], #6");
3578   COMPARE_MACRO(Ld3(v3.V8H(),
3579                     v4.V8H(),
3580                     v5.V8H(),
3581                     3,
3582                     MemOperand(x18, x1, PostIndex)),
3583                 "ld3 {v3.h, v4.h, v5.h}[3], [x18], x1");
3584   COMPARE_MACRO(Ld3(v4.V2S(),
3585                     v5.V2S(),
3586                     v6.V2S(),
3587                     0,
3588                     MemOperand(x19, x2, PostIndex)),
3589                 "ld3 {v4.s, v5.s, v6.s}[0], [x19], x2");
3590   COMPARE_MACRO(Ld3(v5.V4S(),
3591                     v6.V4S(),
3592                     v7.V4S(),
3593                     1,
3594                     MemOperand(x20, 12, PostIndex)),
3595                 "ld3 {v5.s, v6.s, v7.s}[1], [x20], #12");
3596   COMPARE_MACRO(Ld3(v6.V2D(),
3597                     v7.V2D(),
3598                     v8.V2D(),
3599                     0,
3600                     MemOperand(x21, 24, PostIndex)),
3601                 "ld3 {v6.d, v7.d, v8.d}[0], [x21], #24");
3602   COMPARE_MACRO(Ld3(v7.B(), v8.B(), v9.B(), 7, MemOperand(x22, 3, PostIndex)),
3603                 "ld3 {v7.b, v8.b, v9.b}[7], [x22], #3");
3604   COMPARE_MACRO(Ld3(v8.B(),
3605                     v9.B(),
3606                     v10.B(),
3607                     15,
3608                     MemOperand(x23, x3, PostIndex)),
3609                 "ld3 {v8.b, v9.b, v10.b}[15], [x23], x3");
3610   COMPARE_MACRO(Ld3(v9.H(),
3611                     v10.H(),
3612                     v11.H(),
3613                     3,
3614                     MemOperand(x24, x4, PostIndex)),
3615                 "ld3 {v9.h, v10.h, v11.h}[3], [x24], x4");
3616   COMPARE_MACRO(Ld3(v10.H(),
3617                     v11.H(),
3618                     v12.H(),
3619                     7,
3620                     MemOperand(x25, 6, PostIndex)),
3621                 "ld3 {v10.h, v11.h, v12.h}[7], [x25], #6");
3622   COMPARE_MACRO(Ld3(v11.S(),
3623                     v12.S(),
3624                     v13.S(),
3625                     1,
3626                     MemOperand(x26, 12, PostIndex)),
3627                 "ld3 {v11.s, v12.s, v13.s}[1], [x26], #12");
3628   COMPARE_MACRO(Ld3(v12.S(),
3629                     v13.S(),
3630                     v14.S(),
3631                     3,
3632                     MemOperand(x27, x5, PostIndex)),
3633                 "ld3 {v12.s, v13.s, v14.s}[3], [x27], x5");
3634   COMPARE_MACRO(Ld3(v12.S(),
3635                     v13.S(),
3636                     v14.S(),
3637                     3,
3638                     MemOperand(x27, 12, PostIndex)),
3639                 "ld3 {v12.s, v13.s, v14.s}[3], [x27], #12");
3640   COMPARE_MACRO(Ld3(v13.D(),
3641                     v14.D(),
3642                     v15.D(),
3643                     1,
3644                     MemOperand(sp, x6, PostIndex)),
3645                 "ld3 {v13.d, v14.d, v15.d}[1], [sp], x6");
3646   COMPARE_MACRO(Ld3(v13.D(),
3647                     v14.D(),
3648                     v15.D(),
3649                     1,
3650                     MemOperand(sp, 24, PostIndex)),
3651                 "ld3 {v13.d, v14.d, v15.d}[1], [sp], #24");
3652 
3653   COMPARE_MACRO(Ld4(v0.V8B(), v1.V8B(), v2.V8B(), v3.V8B(), 0, MemOperand(x15)),
3654                 "ld4 {v0.b, v1.b, v2.b, v3.b}[0], [x15]");
3655   COMPARE_MACRO(Ld4(v1.V16B(),
3656                     v2.V16B(),
3657                     v3.V16B(),
3658                     v4.V16B(),
3659                     1,
3660                     MemOperand(x16)),
3661                 "ld4 {v1.b, v2.b, v3.b, v4.b}[1], [x16]");
3662   COMPARE_MACRO(Ld4(v2.V4H(), v3.V4H(), v4.V4H(), v5.V4H(), 2, MemOperand(x17)),
3663                 "ld4 {v2.h, v3.h, v4.h, v5.h}[2], [x17]");
3664   COMPARE_MACRO(Ld4(v3.V8H(), v4.V8H(), v5.V8H(), v6.V8H(), 3, MemOperand(x18)),
3665                 "ld4 {v3.h, v4.h, v5.h, v6.h}[3], [x18]");
3666   COMPARE_MACRO(Ld4(v4.V2S(), v5.V2S(), v6.V2S(), v7.V2S(), 0, MemOperand(x19)),
3667                 "ld4 {v4.s, v5.s, v6.s, v7.s}[0], [x19]");
3668   COMPARE_MACRO(Ld4(v5.V4S(), v6.V4S(), v7.V4S(), v8.V4S(), 1, MemOperand(x20)),
3669                 "ld4 {v5.s, v6.s, v7.s, v8.s}[1], [x20]");
3670   COMPARE_MACRO(Ld4(v6.V2D(), v7.V2D(), v8.V2D(), v9.V2D(), 0, MemOperand(x21)),
3671                 "ld4 {v6.d, v7.d, v8.d, v9.d}[0], [x21]");
3672   COMPARE_MACRO(Ld4(v7.B(), v8.B(), v9.B(), v10.B(), 7, MemOperand(x22)),
3673                 "ld4 {v7.b, v8.b, v9.b, v10.b}[7], [x22]");
3674   COMPARE_MACRO(Ld4(v8.B(), v9.B(), v10.B(), v11.B(), 15, MemOperand(x23)),
3675                 "ld4 {v8.b, v9.b, v10.b, v11.b}[15], [x23]");
3676   COMPARE_MACRO(Ld4(v9.H(), v10.H(), v11.H(), v12.H(), 3, MemOperand(x24)),
3677                 "ld4 {v9.h, v10.h, v11.h, v12.h}[3], [x24]");
3678   COMPARE_MACRO(Ld4(v10.H(), v11.H(), v12.H(), v13.H(), 7, MemOperand(x25)),
3679                 "ld4 {v10.h, v11.h, v12.h, v13.h}[7], [x25]");
3680   COMPARE_MACRO(Ld4(v11.S(), v12.S(), v13.S(), v14.S(), 1, MemOperand(x26)),
3681                 "ld4 {v11.s, v12.s, v13.s, v14.s}[1], [x26]");
3682   COMPARE_MACRO(Ld4(v12.S(), v13.S(), v14.S(), v15.S(), 3, MemOperand(x27)),
3683                 "ld4 {v12.s, v13.s, v14.s, v15.s}[3], [x27]");
3684   COMPARE_MACRO(Ld4(v13.D(), v14.D(), v15.D(), v16.D(), 1, MemOperand(sp)),
3685                 "ld4 {v13.d, v14.d, v15.d, v16.d}[1], [sp]");
3686 
3687   COMPARE_MACRO(Ld4(v0.V8B(),
3688                     v1.V8B(),
3689                     v2.V8B(),
3690                     v3.V8B(),
3691                     0,
3692                     MemOperand(x15, x0, PostIndex)),
3693                 "ld4 {v0.b, v1.b, v2.b, v3.b}[0], [x15], x0");
3694   COMPARE_MACRO(Ld4(v1.V16B(),
3695                     v2.V16B(),
3696                     v3.V16B(),
3697                     v4.V16B(),
3698                     1,
3699                     MemOperand(x16, 4, PostIndex)),
3700                 "ld4 {v1.b, v2.b, v3.b, v4.b}[1], [x16], #4");
3701   COMPARE_MACRO(Ld4(v2.V4H(),
3702                     v3.V4H(),
3703                     v4.V4H(),
3704                     v5.V4H(),
3705                     2,
3706                     MemOperand(x17, 8, PostIndex)),
3707                 "ld4 {v2.h, v3.h, v4.h, v5.h}[2], [x17], #8");
3708   COMPARE_MACRO(Ld4(v3.V8H(),
3709                     v4.V8H(),
3710                     v5.V8H(),
3711                     v6.V8H(),
3712                     3,
3713                     MemOperand(x18, x1, PostIndex)),
3714                 "ld4 {v3.h, v4.h, v5.h, v6.h}[3], [x18], x1");
3715   COMPARE_MACRO(Ld4(v4.V2S(),
3716                     v5.V2S(),
3717                     v6.V2S(),
3718                     v7.V2S(),
3719                     0,
3720                     MemOperand(x19, x2, PostIndex)),
3721                 "ld4 {v4.s, v5.s, v6.s, v7.s}[0], [x19], x2");
3722   COMPARE_MACRO(Ld4(v5.V4S(),
3723                     v6.V4S(),
3724                     v7.V4S(),
3725                     v8.V4S(),
3726                     1,
3727                     MemOperand(x20, 16, PostIndex)),
3728                 "ld4 {v5.s, v6.s, v7.s, v8.s}[1], [x20], #16");
3729   COMPARE_MACRO(Ld4(v6.V2D(),
3730                     v7.V2D(),
3731                     v8.V2D(),
3732                     v9.V2D(),
3733                     0,
3734                     MemOperand(x21, 32, PostIndex)),
3735                 "ld4 {v6.d, v7.d, v8.d, v9.d}[0], [x21], #32");
3736   COMPARE_MACRO(Ld4(v7.B(),
3737                     v8.B(),
3738                     v9.B(),
3739                     v10.B(),
3740                     7,
3741                     MemOperand(x22, 4, PostIndex)),
3742                 "ld4 {v7.b, v8.b, v9.b, v10.b}[7], [x22], #4");
3743   COMPARE_MACRO(Ld4(v8.B(),
3744                     v9.B(),
3745                     v10.B(),
3746                     v11.B(),
3747                     15,
3748                     MemOperand(x23, x3, PostIndex)),
3749                 "ld4 {v8.b, v9.b, v10.b, v11.b}[15], [x23], x3");
3750   COMPARE_MACRO(Ld4(v9.H(),
3751                     v10.H(),
3752                     v11.H(),
3753                     v12.H(),
3754                     3,
3755                     MemOperand(x24, x4, PostIndex)),
3756                 "ld4 {v9.h, v10.h, v11.h, v12.h}[3], [x24], x4");
3757   COMPARE_MACRO(Ld4(v10.H(),
3758                     v11.H(),
3759                     v12.H(),
3760                     v13.H(),
3761                     7,
3762                     MemOperand(x25, 8, PostIndex)),
3763                 "ld4 {v10.h, v11.h, v12.h, v13.h}[7], [x25], #8");
3764   COMPARE_MACRO(Ld4(v11.S(),
3765                     v12.S(),
3766                     v13.S(),
3767                     v14.S(),
3768                     1,
3769                     MemOperand(x26, 16, PostIndex)),
3770                 "ld4 {v11.s, v12.s, v13.s, v14.s}[1], [x26], #16");
3771   COMPARE_MACRO(Ld4(v12.S(),
3772                     v13.S(),
3773                     v14.S(),
3774                     v15.S(),
3775                     3,
3776                     MemOperand(x27, x5, PostIndex)),
3777                 "ld4 {v12.s, v13.s, v14.s, v15.s}[3], [x27], x5");
3778   COMPARE_MACRO(Ld4(v11.S(),
3779                     v12.S(),
3780                     v13.S(),
3781                     v14.S(),
3782                     3,
3783                     MemOperand(x26, 16, PostIndex)),
3784                 "ld4 {v11.s, v12.s, v13.s, v14.s}[3], [x26], #16");
3785   COMPARE_MACRO(Ld4(v13.D(),
3786                     v14.D(),
3787                     v15.D(),
3788                     v16.D(),
3789                     1,
3790                     MemOperand(sp, x6, PostIndex)),
3791                 "ld4 {v13.d, v14.d, v15.d, v16.d}[1], [sp], x6");
3792   COMPARE_MACRO(Ld4(v13.D(),
3793                     v14.D(),
3794                     v15.D(),
3795                     v16.D(),
3796                     1,
3797                     MemOperand(sp, 32, PostIndex)),
3798                 "ld4 {v13.d, v14.d, v15.d, v16.d}[1], [sp], #32");
3799 
3800   COMPARE_MACRO(St1(v0.V8B(), 0, MemOperand(x15)), "st1 {v0.b}[0], [x15]");
3801   COMPARE_MACRO(St1(v1.V16B(), 1, MemOperand(x16)), "st1 {v1.b}[1], [x16]");
3802   COMPARE_MACRO(St1(v2.V4H(), 2, MemOperand(x17)), "st1 {v2.h}[2], [x17]");
3803   COMPARE_MACRO(St1(v3.V8H(), 3, MemOperand(x18)), "st1 {v3.h}[3], [x18]");
3804   COMPARE_MACRO(St1(v4.V2S(), 0, MemOperand(x19)), "st1 {v4.s}[0], [x19]");
3805   COMPARE_MACRO(St1(v5.V4S(), 1, MemOperand(x20)), "st1 {v5.s}[1], [x20]");
3806   COMPARE_MACRO(St1(v6.V2D(), 0, MemOperand(x21)), "st1 {v6.d}[0], [x21]");
3807   COMPARE_MACRO(St1(v7.B(), 7, MemOperand(x22)), "st1 {v7.b}[7], [x22]");
3808   COMPARE_MACRO(St1(v8.B(), 15, MemOperand(x23)), "st1 {v8.b}[15], [x23]");
3809   COMPARE_MACRO(St1(v9.H(), 3, MemOperand(x24)), "st1 {v9.h}[3], [x24]");
3810   COMPARE_MACRO(St1(v10.H(), 7, MemOperand(x25)), "st1 {v10.h}[7], [x25]");
3811   COMPARE_MACRO(St1(v11.S(), 1, MemOperand(x26)), "st1 {v11.s}[1], [x26]");
3812   COMPARE_MACRO(St1(v12.S(), 3, MemOperand(x27)), "st1 {v12.s}[3], [x27]");
3813   COMPARE_MACRO(St1(v13.D(), 1, MemOperand(sp)), "st1 {v13.d}[1], [sp]");
3814 
3815   COMPARE_MACRO(St1(v0.V8B(), 0, MemOperand(x15, x0, PostIndex)),
3816                 "st1 {v0.b}[0], [x15], x0");
3817   COMPARE_MACRO(St1(v1.V16B(), 1, MemOperand(x16, 1, PostIndex)),
3818                 "st1 {v1.b}[1], [x16], #1");
3819   COMPARE_MACRO(St1(v2.V4H(), 2, MemOperand(x17, 2, PostIndex)),
3820                 "st1 {v2.h}[2], [x17], #2");
3821   COMPARE_MACRO(St1(v3.V8H(), 3, MemOperand(x18, x1, PostIndex)),
3822                 "st1 {v3.h}[3], [x18], x1");
3823   COMPARE_MACRO(St1(v4.V2S(), 0, MemOperand(x19, x2, PostIndex)),
3824                 "st1 {v4.s}[0], [x19], x2");
3825   COMPARE_MACRO(St1(v5.V4S(), 1, MemOperand(x20, 4, PostIndex)),
3826                 "st1 {v5.s}[1], [x20], #4");
3827   COMPARE_MACRO(St1(v6.V2D(), 0, MemOperand(x21, 8, PostIndex)),
3828                 "st1 {v6.d}[0], [x21], #8");
3829   COMPARE_MACRO(St1(v7.B(), 7, MemOperand(x22, 1, PostIndex)),
3830                 "st1 {v7.b}[7], [x22], #1");
3831   COMPARE_MACRO(St1(v8.B(), 15, MemOperand(x23, x3, PostIndex)),
3832                 "st1 {v8.b}[15], [x23], x3");
3833   COMPARE_MACRO(St1(v9.H(), 3, MemOperand(x24, x4, PostIndex)),
3834                 "st1 {v9.h}[3], [x24], x4");
3835   COMPARE_MACRO(St1(v10.H(), 7, MemOperand(x25, 2, PostIndex)),
3836                 "st1 {v10.h}[7], [x25], #2");
3837   COMPARE_MACRO(St1(v11.S(), 1, MemOperand(x26, 4, PostIndex)),
3838                 "st1 {v11.s}[1], [x26], #4");
3839   COMPARE_MACRO(St1(v12.S(), 3, MemOperand(x27, x5, PostIndex)),
3840                 "st1 {v12.s}[3], [x27], x5");
3841   COMPARE_MACRO(St1(v13.D(), 1, MemOperand(sp, x6, PostIndex)),
3842                 "st1 {v13.d}[1], [sp], x6");
3843   COMPARE_MACRO(St2(v0.V8B(), v1.V8B(), 0, MemOperand(x15, x0, PostIndex)),
3844                 "st2 {v0.b, v1.b}[0], [x15], x0");
3845   COMPARE_MACRO(St2(v1.V16B(), v2.V16B(), 1, MemOperand(x16, 2, PostIndex)),
3846                 "st2 {v1.b, v2.b}[1], [x16], #2");
3847   COMPARE_MACRO(St2(v2.V4H(), v3.V4H(), 2, MemOperand(x17, 4, PostIndex)),
3848                 "st2 {v2.h, v3.h}[2], [x17], #4");
3849   COMPARE_MACRO(St2(v3.V8H(), v4.V8H(), 3, MemOperand(x18, x1, PostIndex)),
3850                 "st2 {v3.h, v4.h}[3], [x18], x1");
3851   COMPARE_MACRO(St2(v4.V2S(), v5.V2S(), 0, MemOperand(x19, x2, PostIndex)),
3852                 "st2 {v4.s, v5.s}[0], [x19], x2");
3853   COMPARE_MACRO(St2(v5.V4S(), v6.V4S(), 1, MemOperand(x20, 8, PostIndex)),
3854                 "st2 {v5.s, v6.s}[1], [x20], #8");
3855   COMPARE_MACRO(St2(v6.V2D(), v7.V2D(), 0, MemOperand(x21, 16, PostIndex)),
3856                 "st2 {v6.d, v7.d}[0], [x21], #16");
3857   COMPARE_MACRO(St2(v7.B(), v8.B(), 7, MemOperand(x22, 2, PostIndex)),
3858                 "st2 {v7.b, v8.b}[7], [x22], #2");
3859   COMPARE_MACRO(St2(v8.B(), v9.B(), 15, MemOperand(x23, x3, PostIndex)),
3860                 "st2 {v8.b, v9.b}[15], [x23], x3");
3861   COMPARE_MACRO(St2(v9.H(), v10.H(), 3, MemOperand(x24, x4, PostIndex)),
3862                 "st2 {v9.h, v10.h}[3], [x24], x4");
3863   COMPARE_MACRO(St2(v10.H(), v11.H(), 7, MemOperand(x25, 4, PostIndex)),
3864                 "st2 {v10.h, v11.h}[7], [x25], #4");
3865   COMPARE_MACRO(St2(v11.S(), v12.S(), 1, MemOperand(x26, 8, PostIndex)),
3866                 "st2 {v11.s, v12.s}[1], [x26], #8");
3867   COMPARE_MACRO(St2(v12.S(), v13.S(), 3, MemOperand(x27, x5, PostIndex)),
3868                 "st2 {v12.s, v13.s}[3], [x27], x5");
3869   COMPARE_MACRO(St2(v13.D(), v14.D(), 1, MemOperand(sp, x6, PostIndex)),
3870                 "st2 {v13.d, v14.d}[1], [sp], x6");
3871   COMPARE_MACRO(St3(VLIST3(v0.V8B()), 0, MemOperand(x15, x0, PostIndex)),
3872                 "st3 {v0.b, v1.b, v2.b}[0], [x15], x0");
3873   COMPARE_MACRO(St3(VLIST3(v1.V16B()), 1, MemOperand(x16, 3, PostIndex)),
3874                 "st3 {v1.b, v2.b, v3.b}[1], [x16], #3");
3875   COMPARE_MACRO(St3(VLIST3(v2.V4H()), 2, MemOperand(x17, 6, PostIndex)),
3876                 "st3 {v2.h, v3.h, v4.h}[2], [x17], #6");
3877   COMPARE_MACRO(St3(VLIST3(v3.V8H()), 3, MemOperand(x18, x1, PostIndex)),
3878                 "st3 {v3.h, v4.h, v5.h}[3], [x18], x1");
3879   COMPARE_MACRO(St3(VLIST3(v4.V2S()), 0, MemOperand(x19, x2, PostIndex)),
3880                 "st3 {v4.s, v5.s, v6.s}[0], [x19], x2");
3881   COMPARE_MACRO(St3(VLIST3(v5.V4S()), 1, MemOperand(x20, 12, PostIndex)),
3882                 "st3 {v5.s, v6.s, v7.s}[1], [x20], #12");
3883   COMPARE_MACRO(St3(VLIST3(v6.V2D()), 0, MemOperand(x21, 24, PostIndex)),
3884                 "st3 {v6.d, v7.d, v8.d}[0], [x21], #24");
3885   COMPARE_MACRO(St3(VLIST3(v7.B()), 7, MemOperand(x22, 3, PostIndex)),
3886                 "st3 {v7.b, v8.b, v9.b}[7], [x22], #3");
3887   COMPARE_MACRO(St3(VLIST3(v8.B()), 15, MemOperand(x23, x3, PostIndex)),
3888                 "st3 {v8.b, v9.b, v10.b}[15], [x23], x3");
3889   COMPARE_MACRO(St3(VLIST3(v9.H()), 3, MemOperand(x24, x4, PostIndex)),
3890                 "st3 {v9.h, v10.h, v11.h}[3], [x24], x4");
3891   COMPARE_MACRO(St3(VLIST3(v10.H()), 7, MemOperand(x25, 6, PostIndex)),
3892                 "st3 {v10.h, v11.h, v12.h}[7], [x25], #6");
3893   COMPARE_MACRO(St3(VLIST3(v11.S()), 1, MemOperand(x26, 12, PostIndex)),
3894                 "st3 {v11.s, v12.s, v13.s}[1], [x26], #12");
3895   COMPARE_MACRO(St3(VLIST3(v12.S()), 3, MemOperand(x27, x5, PostIndex)),
3896                 "st3 {v12.s, v13.s, v14.s}[3], [x27], x5");
3897   COMPARE_MACRO(St3(VLIST3(v13.D()), 1, MemOperand(sp, x6, PostIndex)),
3898                 "st3 {v13.d, v14.d, v15.d}[1], [sp], x6");
3899 
3900   COMPARE_MACRO(St4(VLIST4(v0.V8B()), 0, MemOperand(x15, x0, PostIndex)),
3901                 "st4 {v0.b, v1.b, v2.b, v3.b}[0], [x15], x0");
3902   COMPARE_MACRO(St4(VLIST4(v1.V16B()), 1, MemOperand(x16, 4, PostIndex)),
3903                 "st4 {v1.b, v2.b, v3.b, v4.b}[1], [x16], #4");
3904   COMPARE_MACRO(St4(VLIST4(v2.V4H()), 2, MemOperand(x17, 8, PostIndex)),
3905                 "st4 {v2.h, v3.h, v4.h, v5.h}[2], [x17], #8");
3906   COMPARE_MACRO(St4(VLIST4(v3.V8H()), 3, MemOperand(x18, x1, PostIndex)),
3907                 "st4 {v3.h, v4.h, v5.h, v6.h}[3], [x18], x1");
3908   COMPARE_MACRO(St4(VLIST4(v4.V2S()), 0, MemOperand(x19, x2, PostIndex)),
3909                 "st4 {v4.s, v5.s, v6.s, v7.s}[0], [x19], x2");
3910   COMPARE_MACRO(St4(VLIST4(v5.V4S()), 1, MemOperand(x20, 16, PostIndex)),
3911                 "st4 {v5.s, v6.s, v7.s, v8.s}[1], [x20], #16");
3912   COMPARE_MACRO(St4(VLIST4(v6.V2D()), 0, MemOperand(x21, 32, PostIndex)),
3913                 "st4 {v6.d, v7.d, v8.d, v9.d}[0], [x21], #32");
3914   COMPARE_MACRO(St4(VLIST4(v7.B()), 7, MemOperand(x22, 4, PostIndex)),
3915                 "st4 {v7.b, v8.b, v9.b, v10.b}[7], [x22], #4");
3916   COMPARE_MACRO(St4(VLIST4(v8.B()), 15, MemOperand(x23, x3, PostIndex)),
3917                 "st4 {v8.b, v9.b, v10.b, v11.b}[15], [x23], x3");
3918   COMPARE_MACRO(St4(VLIST4(v9.H()), 3, MemOperand(x24, x4, PostIndex)),
3919                 "st4 {v9.h, v10.h, v11.h, v12.h}[3], [x24], x4");
3920   COMPARE_MACRO(St4(VLIST4(v10.H()), 7, MemOperand(x25, 8, PostIndex)),
3921                 "st4 {v10.h, v11.h, v12.h, v13.h}[7], [x25], #8");
3922   COMPARE_MACRO(St4(VLIST4(v11.S()), 1, MemOperand(x26, 16, PostIndex)),
3923                 "st4 {v11.s, v12.s, v13.s, v14.s}[1], [x26], #16");
3924   COMPARE_MACRO(St4(VLIST4(v12.S()), 3, MemOperand(x27, x5, PostIndex)),
3925                 "st4 {v12.s, v13.s, v14.s, v15.s}[3], [x27], x5");
3926   COMPARE_MACRO(St4(VLIST4(v13.D()), 1, MemOperand(sp, x6, PostIndex)),
3927                 "st4 {v13.d, v14.d, v15.d, v16.d}[1], [sp], x6");
3928 
3929   CLEANUP();
3930 }
3931 
3932 
TEST(neon_load_store_lane_unallocated)3933 TEST(neon_load_store_lane_unallocated) {
3934   SETUP();
3935 
3936   const char* expected = "unallocated (NEONLoadStoreSingleStruct)";
3937   // LD1 (single structure) (no offset)
3938   COMPARE(dci(0x0d404400), expected);  // .h, size<0> = 1
3939   COMPARE(dci(0x0d408800), expected);  // .s, size<1> = 1
3940   COMPARE(dci(0x0d409400), expected);  // .d, size<0> = 1, S = 1
3941   // LD2 (single structure) (no offset)
3942   COMPARE(dci(0x0d604400), expected);  // .h, size<0> = 1
3943   COMPARE(dci(0x0d608800), expected);  // .s, size<1> = 1
3944   COMPARE(dci(0x0d609400), expected);  // .d, size<0> = 1, S = 1
3945   // LD3 (single structure) (no offset)
3946   COMPARE(dci(0x0d406400), expected);  // .h, size<0> = 1
3947   COMPARE(dci(0x0d40a800), expected);  // .s, size<1> = 1
3948   COMPARE(dci(0x0d40b400), expected);  // .d, size<0> = 1, S = 1
3949   // LD4 (single structure) (no offset)
3950   COMPARE(dci(0x0d606400), expected);  // .h, size<0> = 1
3951   COMPARE(dci(0x0d60a800), expected);  // .s, size<1> = 1
3952   COMPARE(dci(0x0d60b400), expected);  // .d, size<0> = 1, S = 1
3953   // ST1 (single structure) (no offset)
3954   COMPARE(dci(0x0d004400), expected);  // .h, size<0> = 1
3955   COMPARE(dci(0x0d008800), expected);  // .s, size<1> = 1
3956   COMPARE(dci(0x0d009400), expected);  // .d, size<0> = 1, S = 1
3957   // ST2 (single structure) (no offset)
3958   COMPARE(dci(0x0d204400), expected);  // .h, size<0> = 1
3959   COMPARE(dci(0x0d208800), expected);  // .s, size<1> = 1
3960   COMPARE(dci(0x0d209400), expected);  // .d, size<0> = 1, S = 1
3961   // ST3 (single structure) (no offset)
3962   COMPARE(dci(0x0d006400), expected);  // .h, size<0> = 1
3963   COMPARE(dci(0x0d00a800), expected);  // .s, size<1> = 1
3964   COMPARE(dci(0x0d00b400), expected);  // .d, size<0> = 1, S = 1
3965   // ST4 (single structure) (no offset)
3966   COMPARE(dci(0x0d206400), expected);  // .h, size<0> = 1
3967   COMPARE(dci(0x0d20a800), expected);  // .s, size<1> = 1
3968   COMPARE(dci(0x0d20b400), expected);  // .d, size<0> = 1, S = 1
3969 
3970   expected = "unallocated (NEONLoadStoreSingleStructPostIndex)";
3971   // LD1 (single structure) (post index)
3972   COMPARE(dci(0x0dc04400), expected);  // .h, size<0> = 1
3973   COMPARE(dci(0x0dc08800), expected);  // .s, size<1> = 1
3974   COMPARE(dci(0x0dc09400), expected);  // .d, size<0> = 1, S = 1
3975   // LD2 (single structure) (post index)
3976   COMPARE(dci(0x0de04400), expected);  // .h, size<0> = 1
3977   COMPARE(dci(0x0de08800), expected);  // .s, size<1> = 1
3978   COMPARE(dci(0x0de09400), expected);  // .d, size<0> = 1, S = 1
3979   // LD3 (single structure) (post index)
3980   COMPARE(dci(0x0dc06400), expected);  // .h, size<0> = 1
3981   COMPARE(dci(0x0dc0a800), expected);  // .s, size<1> = 1
3982   COMPARE(dci(0x0dc0b400), expected);  // .d, size<0> = 1, S = 1
3983   // LD4 (single structure) (post index)
3984   COMPARE(dci(0x0de06400), expected);  // .h, size<0> = 1
3985   COMPARE(dci(0x0de0a800), expected);  // .s, size<1> = 1
3986   COMPARE(dci(0x0de0b400), expected);  // .d, size<0> = 1, S = 1
3987   // ST1 (single structure) (post index)
3988   COMPARE(dci(0x0d804400), expected);  // .h, size<0> = 1
3989   COMPARE(dci(0x0d808800), expected);  // .s, size<1> = 1
3990   COMPARE(dci(0x0d809400), expected);  // .d, size<0> = 1, S = 1
3991   // ST2 (single structure) (post index)
3992   COMPARE(dci(0x0da04400), expected);  // .h, size<0> = 1
3993   COMPARE(dci(0x0da08800), expected);  // .s, size<1> = 1
3994   COMPARE(dci(0x0da09400), expected);  // .d, size<0> = 1, S = 1
3995   // ST3 (single structure) (post index)
3996   COMPARE(dci(0x0d806400), expected);  // .h, size<0> = 1
3997   COMPARE(dci(0x0d80a800), expected);  // .s, size<1> = 1
3998   COMPARE(dci(0x0d80b400), expected);  // .d, size<0> = 1, S = 1
3999   // ST4 (single structure) (post index)
4000   COMPARE(dci(0x0da06400), expected);  // .h, size<0> = 1
4001   COMPARE(dci(0x0da0a800), expected);  // .s, size<1> = 1
4002   COMPARE(dci(0x0da0b400), expected);  // .d, size<0> = 1, S = 1
4003 
4004   CLEANUP();
4005 }
4006 
4007 
TEST(neon_load_all_lanes)4008 TEST(neon_load_all_lanes) {
4009   SETUP();
4010 
4011   COMPARE_MACRO(Ld1r(v14.V8B(), MemOperand(x0)), "ld1r {v14.8b}, [x0]");
4012   COMPARE_MACRO(Ld1r(v15.V16B(), MemOperand(x1)), "ld1r {v15.16b}, [x1]");
4013   COMPARE_MACRO(Ld1r(v16.V4H(), MemOperand(x2)), "ld1r {v16.4h}, [x2]");
4014   COMPARE_MACRO(Ld1r(v17.V8H(), MemOperand(x3)), "ld1r {v17.8h}, [x3]");
4015   COMPARE_MACRO(Ld1r(v18.V2S(), MemOperand(x4)), "ld1r {v18.2s}, [x4]");
4016   COMPARE_MACRO(Ld1r(v19.V4S(), MemOperand(x5)), "ld1r {v19.4s}, [x5]");
4017   COMPARE_MACRO(Ld1r(v20.V2D(), MemOperand(sp)), "ld1r {v20.2d}, [sp]");
4018   COMPARE_MACRO(Ld1r(v21.V1D(), MemOperand(x30)), "ld1r {v21.1d}, [x30]");
4019 
4020   COMPARE_MACRO(Ld1r(v22.V8B(), MemOperand(x6, 1, PostIndex)),
4021                 "ld1r {v22.8b}, [x6], #1");
4022   COMPARE_MACRO(Ld1r(v23.V16B(), MemOperand(x7, x16, PostIndex)),
4023                 "ld1r {v23.16b}, [x7], x16");
4024   COMPARE_MACRO(Ld1r(v24.V4H(), MemOperand(x8, x17, PostIndex)),
4025                 "ld1r {v24.4h}, [x8], x17");
4026   COMPARE_MACRO(Ld1r(v25.V8H(), MemOperand(x9, 2, PostIndex)),
4027                 "ld1r {v25.8h}, [x9], #2");
4028   COMPARE_MACRO(Ld1r(v26.V2S(), MemOperand(x10, 4, PostIndex)),
4029                 "ld1r {v26.2s}, [x10], #4");
4030   COMPARE_MACRO(Ld1r(v27.V4S(), MemOperand(x11, x18, PostIndex)),
4031                 "ld1r {v27.4s}, [x11], x18");
4032   COMPARE_MACRO(Ld1r(v28.V2D(), MemOperand(x12, 8, PostIndex)),
4033                 "ld1r {v28.2d}, [x12], #8");
4034   COMPARE_MACRO(Ld1r(v29.V1D(), MemOperand(x13, 8, PostIndex)),
4035                 "ld1r {v29.1d}, [x13], #8");
4036 
4037   COMPARE_MACRO(Ld2r(v14.V8B(), v15.V8B(), MemOperand(x0)),
4038                 "ld2r {v14.8b, v15.8b}, [x0]");
4039   COMPARE_MACRO(Ld2r(v15.V16B(), v16.V16B(), MemOperand(x1)),
4040                 "ld2r {v15.16b, v16.16b}, [x1]");
4041   COMPARE_MACRO(Ld2r(v16.V4H(), v17.V4H(), MemOperand(x2)),
4042                 "ld2r {v16.4h, v17.4h}, [x2]");
4043   COMPARE_MACRO(Ld2r(v17.V8H(), v18.V8H(), MemOperand(x3)),
4044                 "ld2r {v17.8h, v18.8h}, [x3]");
4045   COMPARE_MACRO(Ld2r(v18.V2S(), v19.V2S(), MemOperand(x4)),
4046                 "ld2r {v18.2s, v19.2s}, [x4]");
4047   COMPARE_MACRO(Ld2r(v19.V4S(), v20.V4S(), MemOperand(x5)),
4048                 "ld2r {v19.4s, v20.4s}, [x5]");
4049   COMPARE_MACRO(Ld2r(v20.V2D(), v21.V2D(), MemOperand(sp)),
4050                 "ld2r {v20.2d, v21.2d}, [sp]");
4051   COMPARE_MACRO(Ld2r(v21.V8B(), v22.V8B(), MemOperand(x6, 2, PostIndex)),
4052                 "ld2r {v21.8b, v22.8b}, [x6], #2");
4053   COMPARE_MACRO(Ld2r(v22.V16B(), v23.V16B(), MemOperand(x7, x16, PostIndex)),
4054                 "ld2r {v22.16b, v23.16b}, [x7], x16");
4055   COMPARE_MACRO(Ld2r(v23.V4H(), v24.V4H(), MemOperand(x8, x17, PostIndex)),
4056                 "ld2r {v23.4h, v24.4h}, [x8], x17");
4057   COMPARE_MACRO(Ld2r(v24.V8H(), v25.V8H(), MemOperand(x9, 4, PostIndex)),
4058                 "ld2r {v24.8h, v25.8h}, [x9], #4");
4059   COMPARE_MACRO(Ld2r(v25.V2S(), v26.V2S(), MemOperand(x10, 8, PostIndex)),
4060                 "ld2r {v25.2s, v26.2s}, [x10], #8");
4061   COMPARE_MACRO(Ld2r(v26.V4S(), v27.V4S(), MemOperand(x11, x18, PostIndex)),
4062                 "ld2r {v26.4s, v27.4s}, [x11], x18");
4063   COMPARE_MACRO(Ld2r(v27.V2D(), v28.V2D(), MemOperand(x12, 16, PostIndex)),
4064                 "ld2r {v27.2d, v28.2d}, [x12], #16");
4065 
4066   COMPARE_MACRO(Ld3r(v14.V8B(), v15.V8B(), v16.V8B(), MemOperand(x0)),
4067                 "ld3r {v14.8b, v15.8b, v16.8b}, [x0]");
4068   COMPARE_MACRO(Ld3r(v15.V16B(), v16.V16B(), v17.V16B(), MemOperand(x1)),
4069                 "ld3r {v15.16b, v16.16b, v17.16b}, [x1]");
4070   COMPARE_MACRO(Ld3r(v16.V4H(), v17.V4H(), v18.V4H(), MemOperand(x2)),
4071                 "ld3r {v16.4h, v17.4h, v18.4h}, [x2]");
4072   COMPARE_MACRO(Ld3r(v17.V8H(), v18.V8H(), v19.V8H(), MemOperand(x3)),
4073                 "ld3r {v17.8h, v18.8h, v19.8h}, [x3]");
4074   COMPARE_MACRO(Ld3r(v18.V2S(), v19.V2S(), v20.V2S(), MemOperand(x4)),
4075                 "ld3r {v18.2s, v19.2s, v20.2s}, [x4]");
4076   COMPARE_MACRO(Ld3r(v19.V4S(), v20.V4S(), v21.V4S(), MemOperand(x5)),
4077                 "ld3r {v19.4s, v20.4s, v21.4s}, [x5]");
4078   COMPARE_MACRO(Ld3r(v20.V2D(), v21.V2D(), v22.V2D(), MemOperand(sp)),
4079                 "ld3r {v20.2d, v21.2d, v22.2d}, [sp]");
4080   COMPARE_MACRO(Ld3r(v21.V8B(),
4081                      v22.V8B(),
4082                      v23.V8B(),
4083                      MemOperand(x6, 3, PostIndex)),
4084                 "ld3r {v21.8b, v22.8b, v23.8b}, [x6], #3");
4085   COMPARE_MACRO(Ld3r(v22.V16B(),
4086                      v23.V16B(),
4087                      v24.V16B(),
4088                      MemOperand(x7, x16, PostIndex)),
4089                 "ld3r {v22.16b, v23.16b, v24.16b}, [x7], x16");
4090   COMPARE_MACRO(Ld3r(v23.V4H(),
4091                      v24.V4H(),
4092                      v25.V4H(),
4093                      MemOperand(x8, x17, PostIndex)),
4094                 "ld3r {v23.4h, v24.4h, v25.4h}, [x8], x17");
4095   COMPARE_MACRO(Ld3r(v24.V8H(),
4096                      v25.V8H(),
4097                      v26.V8H(),
4098                      MemOperand(x9, 6, PostIndex)),
4099                 "ld3r {v24.8h, v25.8h, v26.8h}, [x9], #6");
4100   COMPARE_MACRO(Ld3r(v25.V2S(),
4101                      v26.V2S(),
4102                      v27.V2S(),
4103                      MemOperand(x10, 12, PostIndex)),
4104                 "ld3r {v25.2s, v26.2s, v27.2s}, [x10], #12");
4105   COMPARE_MACRO(Ld3r(v26.V4S(),
4106                      v27.V4S(),
4107                      v28.V4S(),
4108                      MemOperand(x11, x18, PostIndex)),
4109                 "ld3r {v26.4s, v27.4s, v28.4s}, [x11], x18");
4110   COMPARE_MACRO(Ld3r(v27.V2D(),
4111                      v28.V2D(),
4112                      v29.V2D(),
4113                      MemOperand(x12, 24, PostIndex)),
4114                 "ld3r {v27.2d, v28.2d, v29.2d}, [x12], #24");
4115 
4116   COMPARE_MACRO(Ld4r(v14.V8B(),
4117                      v15.V8B(),
4118                      v16.V8B(),
4119                      v17.V8B(),
4120                      MemOperand(x0)),
4121                 "ld4r {v14.8b, v15.8b, v16.8b, v17.8b}, [x0]");
4122   COMPARE_MACRO(Ld4r(v15.V16B(),
4123                      v16.V16B(),
4124                      v17.V16B(),
4125                      v18.V16B(),
4126                      MemOperand(x1)),
4127                 "ld4r {v15.16b, v16.16b, v17.16b, v18.16b}, [x1]");
4128   COMPARE_MACRO(Ld4r(v16.V4H(),
4129                      v17.V4H(),
4130                      v18.V4H(),
4131                      v19.V4H(),
4132                      MemOperand(x2)),
4133                 "ld4r {v16.4h, v17.4h, v18.4h, v19.4h}, [x2]");
4134   COMPARE_MACRO(Ld4r(v17.V8H(),
4135                      v18.V8H(),
4136                      v19.V8H(),
4137                      v20.V8H(),
4138                      MemOperand(x3)),
4139                 "ld4r {v17.8h, v18.8h, v19.8h, v20.8h}, [x3]");
4140   COMPARE_MACRO(Ld4r(v18.V2S(),
4141                      v19.V2S(),
4142                      v20.V2S(),
4143                      v21.V2S(),
4144                      MemOperand(x4)),
4145                 "ld4r {v18.2s, v19.2s, v20.2s, v21.2s}, [x4]");
4146   COMPARE_MACRO(Ld4r(v19.V4S(),
4147                      v20.V4S(),
4148                      v21.V4S(),
4149                      v22.V4S(),
4150                      MemOperand(x5)),
4151                 "ld4r {v19.4s, v20.4s, v21.4s, v22.4s}, [x5]");
4152   COMPARE_MACRO(Ld4r(v20.V2D(),
4153                      v21.V2D(),
4154                      v22.V2D(),
4155                      v23.V2D(),
4156                      MemOperand(sp)),
4157                 "ld4r {v20.2d, v21.2d, v22.2d, v23.2d}, [sp]");
4158   COMPARE_MACRO(Ld4r(v21.V8B(),
4159                      v22.V8B(),
4160                      v23.V8B(),
4161                      v24.V8B(),
4162                      MemOperand(x6, 4, PostIndex)),
4163                 "ld4r {v21.8b, v22.8b, v23.8b, v24.8b}, [x6], #4");
4164   COMPARE_MACRO(Ld4r(v22.V16B(),
4165                      v23.V16B(),
4166                      v24.V16B(),
4167                      v25.V16B(),
4168                      MemOperand(x7, x16, PostIndex)),
4169                 "ld4r {v22.16b, v23.16b, v24.16b, v25.16b}, [x7], x16");
4170   COMPARE_MACRO(Ld4r(v23.V4H(),
4171                      v24.V4H(),
4172                      v25.V4H(),
4173                      v26.V4H(),
4174                      MemOperand(x8, x17, PostIndex)),
4175                 "ld4r {v23.4h, v24.4h, v25.4h, v26.4h}, [x8], x17");
4176   COMPARE_MACRO(Ld4r(v24.V8H(),
4177                      v25.V8H(),
4178                      v26.V8H(),
4179                      v27.V8H(),
4180                      MemOperand(x9, 8, PostIndex)),
4181                 "ld4r {v24.8h, v25.8h, v26.8h, v27.8h}, [x9], #8");
4182   COMPARE_MACRO(Ld4r(v25.V2S(),
4183                      v26.V2S(),
4184                      v27.V2S(),
4185                      v28.V2S(),
4186                      MemOperand(x10, 16, PostIndex)),
4187                 "ld4r {v25.2s, v26.2s, v27.2s, v28.2s}, [x10], #16");
4188   COMPARE_MACRO(Ld4r(v26.V4S(),
4189                      v27.V4S(),
4190                      v28.V4S(),
4191                      v29.V4S(),
4192                      MemOperand(x11, x18, PostIndex)),
4193                 "ld4r {v26.4s, v27.4s, v28.4s, v29.4s}, [x11], x18");
4194   COMPARE_MACRO(Ld4r(v27.V2D(),
4195                      v28.V2D(),
4196                      v29.V2D(),
4197                      v30.V2D(),
4198                      MemOperand(x12, 32, PostIndex)),
4199                 "ld4r {v27.2d, v28.2d, v29.2d, v30.2d}, [x12], #32");
4200 
4201   CLEANUP();
4202 }
4203 
4204 
TEST(neon_load_all_lanes_unallocated)4205 TEST(neon_load_all_lanes_unallocated) {
4206   SETUP();
4207 
4208   const char* expected = "unallocated (NEONLoadStoreSingleStruct)";
4209   // LD1R (single structure) (no offset)
4210   COMPARE(dci(0x0d00c000), expected);  // L = 0
4211   COMPARE(dci(0x0d40d000), expected);  // S = 1
4212   // LD2R (single structure) (no offset)
4213   COMPARE(dci(0x0d20c000), expected);  // L = 0
4214   COMPARE(dci(0x0d60d000), expected);  // S = 1
4215   // LD3R (single structure) (no offset)
4216   COMPARE(dci(0x0d00e000), expected);  // L = 0
4217   COMPARE(dci(0x0d40f000), expected);  // S = 1
4218   // LD4R (single structure) (no offset)
4219   COMPARE(dci(0x0d20e000), expected);  // L = 0
4220   COMPARE(dci(0x0d60f000), expected);  // S = 1
4221 
4222   expected = "unallocated (NEONLoadStoreSingleStructPostIndex)";
4223   // LD1R (single structure) (post index)
4224   COMPARE(dci(0x0d80c000), expected);  // L = 0
4225   COMPARE(dci(0x0dc0d000), expected);  // S = 1
4226   // LD2R (single structure) (post index)
4227   COMPARE(dci(0x0da0c000), expected);  // L = 0
4228   COMPARE(dci(0x0de0d000), expected);  // S = 1
4229   // LD3R (single structure) (post index)
4230   COMPARE(dci(0x0d80e000), expected);  // L = 0
4231   COMPARE(dci(0x0dc0f000), expected);  // S = 1
4232   // LD4R (single structure) (post index)
4233   COMPARE(dci(0x0da0e000), expected);  // L = 0
4234   COMPARE(dci(0x0de0f000), expected);  // S = 1
4235 
4236   CLEANUP();
4237 }
4238 
4239 
TEST(neon_3same)4240 TEST(neon_3same) {
4241   SETUP();
4242 
4243 #define DISASM_INST(M, S) \
4244   COMPARE_MACRO(Cmeq(v0.M, v1.M, v2.M), "cmeq v0." S ", v1." S ", v2." S);
4245   NEON_FORMAT_LIST(DISASM_INST)
4246 #undef DISASM_INST
4247 
4248 #define DISASM_INST(M, S) \
4249   COMPARE_MACRO(Cmge(v0.M, v1.M, v2.M), "cmge v0." S ", v1." S ", v2." S);
4250   NEON_FORMAT_LIST(DISASM_INST)
4251 #undef DISASM_INST
4252 
4253 #define DISASM_INST(M, S) \
4254   COMPARE_MACRO(Cmgt(v0.M, v1.M, v2.M), "cmgt v0." S ", v1." S ", v2." S);
4255   NEON_FORMAT_LIST(DISASM_INST)
4256 #undef DISASM_INST
4257 
4258 #define DISASM_INST(M, S) \
4259   COMPARE_MACRO(Cmhi(v0.M, v1.M, v2.M), "cmhi v0." S ", v1." S ", v2." S);
4260   NEON_FORMAT_LIST(DISASM_INST)
4261 #undef DISASM_INST
4262 
4263 #define DISASM_INST(M, S) \
4264   COMPARE_MACRO(Cmhs(v0.M, v1.M, v2.M), "cmhs v0." S ", v1." S ", v2." S);
4265   NEON_FORMAT_LIST(DISASM_INST)
4266 #undef DISASM_INST
4267 
4268 #define DISASM_INST(M, S) \
4269   COMPARE_MACRO(Cmtst(v0.M, v1.M, v2.M), "cmtst v0." S ", v1." S ", v2." S);
4270   NEON_FORMAT_LIST(DISASM_INST)
4271 #undef DISASM_INST
4272 
4273 #define DISASM_INST(M, S) \
4274   COMPARE_MACRO(Add(v0.M, v1.M, v2.M), "add v0." S ", v1." S ", v2." S);
4275   NEON_FORMAT_LIST(DISASM_INST)
4276 #undef DISASM_INST
4277 
4278 #define DISASM_INST(M, S) \
4279   COMPARE_MACRO(Sub(v3.M, v4.M, v5.M), "sub v3." S ", v4." S ", v5." S);
4280   NEON_FORMAT_LIST(DISASM_INST)
4281 #undef DISASM_INST
4282 
4283 #define DISASM_INST(M, S) \
4284   COMPARE_MACRO(Sabd(v3.M, v4.M, v5.M), "sabd v3." S ", v4." S ", v5." S);
4285   NEON_FORMAT_LIST_BHS(DISASM_INST)
4286 #undef DISASM_INST
4287 
4288 #define DISASM_INST(M, S) \
4289   COMPARE_MACRO(Uabd(v3.M, v4.M, v5.M), "uabd v3." S ", v4." S ", v5." S);
4290   NEON_FORMAT_LIST_BHS(DISASM_INST)
4291 #undef DISASM_INST
4292 
4293 #define DISASM_INST(M, S) \
4294   COMPARE_MACRO(Saba(v3.M, v4.M, v5.M), "saba v3." S ", v4." S ", v5." S);
4295   NEON_FORMAT_LIST_BHS(DISASM_INST)
4296 #undef DISASM_INST
4297 
4298 #define DISASM_INST(M, S) \
4299   COMPARE_MACRO(Uaba(v3.M, v4.M, v5.M), "uaba v3." S ", v4." S ", v5." S);
4300   NEON_FORMAT_LIST_BHS(DISASM_INST)
4301 #undef DISASM_INST
4302 
4303 #define DISASM_INST(M, S) \
4304   COMPARE_MACRO(Smax(v3.M, v4.M, v5.M), "smax v3." S ", v4." S ", v5." S);
4305   NEON_FORMAT_LIST_BHS(DISASM_INST)
4306 #undef DISASM_INST
4307 
4308 #define DISASM_INST(M, S) \
4309   COMPARE_MACRO(Smin(v3.M, v4.M, v5.M), "smin v3." S ", v4." S ", v5." S);
4310   NEON_FORMAT_LIST_BHS(DISASM_INST)
4311 #undef DISASM_INST
4312 
4313 #define DISASM_INST(M, S) \
4314   COMPARE_MACRO(Umax(v3.M, v4.M, v5.M), "umax v3." S ", v4." S ", v5." S);
4315   NEON_FORMAT_LIST_BHS(DISASM_INST)
4316 #undef DISASM_INST
4317 
4318 #define DISASM_INST(M, S) \
4319   COMPARE_MACRO(Umin(v3.M, v4.M, v5.M), "umin v3." S ", v4." S ", v5." S);
4320   NEON_FORMAT_LIST_BHS(DISASM_INST)
4321 #undef DISASM_INST
4322 
4323 #define DISASM_INST(M, S) \
4324   COMPARE_MACRO(Smaxp(v3.M, v4.M, v5.M), "smaxp v3." S ", v4." S ", v5." S);
4325   NEON_FORMAT_LIST_BHS(DISASM_INST)
4326 #undef DISASM_INST
4327 
4328 #define DISASM_INST(M, S) \
4329   COMPARE_MACRO(Sminp(v3.M, v4.M, v5.M), "sminp v3." S ", v4." S ", v5." S);
4330   NEON_FORMAT_LIST_BHS(DISASM_INST)
4331 #undef DISASM_INST
4332 
4333 #define DISASM_INST(M, S) \
4334   COMPARE_MACRO(Umaxp(v3.M, v4.M, v5.M), "umaxp v3." S ", v4." S ", v5." S);
4335   NEON_FORMAT_LIST_BHS(DISASM_INST)
4336 #undef DISASM_INST
4337 
4338 #define DISASM_INST(M, S) \
4339   COMPARE_MACRO(Uminp(v3.M, v4.M, v5.M), "uminp v3." S ", v4." S ", v5." S);
4340   NEON_FORMAT_LIST_BHS(DISASM_INST)
4341 #undef DISASM_INST
4342 
4343 #define DISASM_INST(M, S) \
4344   COMPARE_MACRO(Uqadd(v6.M, v7.M, v8.M), "uqadd v6." S ", v7." S ", v8." S);
4345   NEON_FORMAT_LIST(DISASM_INST)
4346 #undef DISASM_INST
4347 
4348 #define DISASM_INST(M, S)                  \
4349   COMPARE_MACRO(Sqadd(v9.M, v10.M, v11.M), \
4350                 "sqadd v9." S ", v10." S   \
4351                 ", "                       \
4352                 "v11." S);
4353   NEON_FORMAT_LIST(DISASM_INST)
4354 #undef DISASM_INST
4355 
4356 #define DISASM_INST(M, S) \
4357   COMPARE_MACRO(Uqsub(v6.M, v7.M, v8.M), "uqsub v6." S ", v7." S ", v8." S);
4358   NEON_FORMAT_LIST(DISASM_INST)
4359 #undef DISASM_INST
4360 
4361 #define DISASM_INST(M, S)                  \
4362   COMPARE_MACRO(Sqsub(v9.M, v10.M, v11.M), \
4363                 "sqsub v9." S ", v10." S   \
4364                 ", "                       \
4365                 "v11." S);
4366   NEON_FORMAT_LIST(DISASM_INST)
4367 #undef DISASM_INST
4368 
4369 #define DISASM_INST(M, S)                  \
4370   COMPARE_MACRO(Sshl(v12.M, v13.M, v14.M), \
4371                 "sshl v12." S ", v13." S   \
4372                 ", "                       \
4373                 "v14." S);
4374   NEON_FORMAT_LIST(DISASM_INST)
4375 #undef DISASM_INST
4376 
4377 #define DISASM_INST(M, S)                  \
4378   COMPARE_MACRO(Ushl(v15.M, v16.M, v17.M), \
4379                 "ushl v15." S ", v16." S   \
4380                 ", "                       \
4381                 "v17." S);
4382   NEON_FORMAT_LIST(DISASM_INST)
4383 #undef DISASM_INST
4384 
4385 #define DISASM_INST(M, S)                   \
4386   COMPARE_MACRO(Sqshl(v18.M, v19.M, v20.M), \
4387                 "sqshl v18." S ", v19." S ", v20." S);
4388   NEON_FORMAT_LIST(DISASM_INST)
4389 #undef DISASM_INST
4390 
4391 #define DISASM_INST(M, S)                   \
4392   COMPARE_MACRO(Uqshl(v21.M, v22.M, v23.M), \
4393                 "uqshl v21." S ", v22." S ", v23." S);
4394   NEON_FORMAT_LIST(DISASM_INST)
4395 #undef DISASM_INST
4396 
4397 #define DISASM_INST(M, S)                   \
4398   COMPARE_MACRO(Srshl(v24.M, v25.M, v26.M), \
4399                 "srshl v24." S ", v25." S ", v26." S);
4400   NEON_FORMAT_LIST(DISASM_INST)
4401 #undef DISASM_INST
4402 
4403 #define DISASM_INST(M, S)                   \
4404   COMPARE_MACRO(Urshl(v27.M, v28.M, v29.M), \
4405                 "urshl v27." S ", v28." S ", v29." S);
4406   NEON_FORMAT_LIST(DISASM_INST)
4407 #undef DISASM_INST
4408 
4409 #define DISASM_INST(M, S)                   \
4410   COMPARE_MACRO(Sqrshl(v30.M, v31.M, v0.M), \
4411                 "sqrshl v30." S ", v31." S ", v0." S);
4412   NEON_FORMAT_LIST(DISASM_INST)
4413 #undef DISASM_INST
4414 
4415 #define DISASM_INST(M, S) \
4416   COMPARE_MACRO(Uqrshl(v1.M, v2.M, v3.M), "uqrshl v1." S ", v2." S ", v3." S);
4417   NEON_FORMAT_LIST(DISASM_INST)
4418 #undef DISASM_INST
4419 
4420 #define DISASM_INST(M, S) \
4421   COMPARE_MACRO(Shadd(v4.M, v5.M, v6.M), "shadd v4." S ", v5." S ", v6." S);
4422   NEON_FORMAT_LIST_BHS(DISASM_INST)
4423 #undef DISASM_INST
4424 
4425 #define DISASM_INST(M, S) \
4426   COMPARE_MACRO(Uhadd(v7.M, v8.M, v9.M), "uhadd v7." S ", v8." S ", v9." S);
4427   NEON_FORMAT_LIST_BHS(DISASM_INST)
4428 #undef DISASM_INST
4429 
4430 #define DISASM_INST(M, S)                    \
4431   COMPARE_MACRO(Srhadd(v10.M, v11.M, v12.M), \
4432                 "srhadd v10." S ", v11." S ", v12." S);
4433   NEON_FORMAT_LIST_BHS(DISASM_INST)
4434 #undef DISASM_INST
4435 
4436 #define DISASM_INST(M, S)                    \
4437   COMPARE_MACRO(Urhadd(v13.M, v14.M, v15.M), \
4438                 "urhadd v13." S ", v14." S ", v15." S);
4439   NEON_FORMAT_LIST_BHS(DISASM_INST)
4440 #undef DISASM_INST
4441 
4442 #define DISASM_INST(M, S)                   \
4443   COMPARE_MACRO(Shsub(v16.M, v17.M, v18.M), \
4444                 "shsub v16." S ", v17." S ", v18." S);
4445   NEON_FORMAT_LIST_BHS(DISASM_INST)
4446 #undef DISASM_INST
4447 
4448 #define DISASM_INST(M, S)                   \
4449   COMPARE_MACRO(Uhsub(v19.M, v20.M, v21.M), \
4450                 "uhsub v19." S ", v20." S ", v21." S);
4451   NEON_FORMAT_LIST_BHS(DISASM_INST)
4452 #undef DISASM_INST
4453 
4454 #define DISASM_INST(M, S)                  \
4455   COMPARE_MACRO(Addp(v19.M, v20.M, v21.M), \
4456                 "addp v19." S ", v20." S   \
4457                 ", "                       \
4458                 "v21." S);
4459   NEON_FORMAT_LIST(DISASM_INST)
4460 #undef DISASM_INST
4461 
4462 #define DISASM_INST(M, S) \
4463   COMPARE_MACRO(Mla(v19.M, v20.M, v21.M), "mla v19." S ", v20." S ", v21." S);
4464   NEON_FORMAT_LIST_BHS(DISASM_INST)
4465 #undef DISASM_INST
4466 
4467 #define DISASM_INST(M, S) \
4468   COMPARE_MACRO(Mls(v19.M, v20.M, v21.M), "mls v19." S ", v20." S ", v21." S);
4469   NEON_FORMAT_LIST_BHS(DISASM_INST)
4470 #undef DISASM_INST
4471 
4472 #define DISASM_INST(M, S) \
4473   COMPARE_MACRO(Mul(v19.M, v20.M, v21.M), "mul v19." S ", v20." S ", v21." S);
4474   NEON_FORMAT_LIST_BHS(DISASM_INST)
4475 #undef DISASM_INST
4476 
4477 #define DISASM_INST(M, S)                  \
4478   COMPARE_MACRO(Sqdmulh(v1.M, v2.M, v3.M), \
4479                 "sqdmulh v1." S ", v2." S  \
4480                 ", "                       \
4481                 "v3." S);
4482   NEON_FORMAT_LIST_HS(DISASM_INST)
4483 #undef DISASM_INST
4484 
4485 #define DISASM_INST(M, S)                   \
4486   COMPARE_MACRO(Sqrdmulh(v1.M, v2.M, v3.M), \
4487                 "sqrdmulh v1." S ", v2." S ", v3." S);
4488   NEON_FORMAT_LIST_HS(DISASM_INST)
4489 #undef DISASM_INST
4490 
4491   COMPARE_MACRO(And(v6.V8B(), v7.V8B(), v8.V8B()), "and v6.8b, v7.8b, v8.8b");
4492   COMPARE_MACRO(And(v6.V16B(), v7.V16B(), v8.V16B()),
4493                 "and v6.16b, v7.16b, v8.16b");
4494 
4495   COMPARE_MACRO(Bic(v6.V8B(), v7.V8B(), v8.V8B()), "bic v6.8b, v7.8b, v8.8b");
4496   COMPARE_MACRO(Bic(v6.V16B(), v7.V16B(), v8.V16B()),
4497                 "bic v6.16b, v7.16b, v8.16b");
4498 
4499   COMPARE_MACRO(Orr(v6.V8B(), v7.V8B(), v8.V8B()), "orr v6.8b, v7.8b, v8.8b");
4500   COMPARE_MACRO(Orr(v6.V16B(), v7.V16B(), v8.V16B()),
4501                 "orr v6.16b, v7.16b, v8.16b");
4502 
4503   COMPARE_MACRO(Orr(v6.V8B(), v7.V8B(), v7.V8B()), "mov v6.8b, v7.8b");
4504   COMPARE_MACRO(Orr(v6.V16B(), v7.V16B(), v7.V16B()), "mov v6.16b, v7.16b");
4505 
4506   COMPARE_MACRO(Mov(v6.V8B(), v8.V8B()), "mov v6.8b, v8.8b");
4507   COMPARE_MACRO(Mov(v6.V16B(), v8.V16B()), "mov v6.16b, v8.16b");
4508 
4509   COMPARE_MACRO(Orn(v6.V8B(), v7.V8B(), v8.V8B()), "orn v6.8b, v7.8b, v8.8b");
4510   COMPARE_MACRO(Orn(v6.V16B(), v7.V16B(), v8.V16B()),
4511                 "orn v6.16b, v7.16b, v8.16b");
4512 
4513   COMPARE_MACRO(Eor(v6.V8B(), v7.V8B(), v8.V8B()), "eor v6.8b, v7.8b, v8.8b");
4514   COMPARE_MACRO(Eor(v6.V16B(), v7.V16B(), v8.V16B()),
4515                 "eor v6.16b, v7.16b, v8.16b");
4516 
4517   COMPARE_MACRO(Bif(v6.V8B(), v7.V8B(), v8.V8B()), "bif v6.8b, v7.8b, v8.8b");
4518   COMPARE_MACRO(Bif(v6.V16B(), v7.V16B(), v8.V16B()),
4519                 "bif v6.16b, v7.16b, v8.16b");
4520 
4521   COMPARE_MACRO(Bit(v6.V8B(), v7.V8B(), v8.V8B()), "bit v6.8b, v7.8b, v8.8b");
4522   COMPARE_MACRO(Bit(v6.V16B(), v7.V16B(), v8.V16B()),
4523                 "bit v6.16b, v7.16b, v8.16b");
4524 
4525   COMPARE_MACRO(Bsl(v6.V8B(), v7.V8B(), v8.V8B()), "bsl v6.8b, v7.8b, v8.8b");
4526   COMPARE_MACRO(Bsl(v6.V16B(), v7.V16B(), v8.V16B()),
4527                 "bsl v6.16b, v7.16b, v8.16b");
4528 
4529   COMPARE_MACRO(Pmul(v6.V8B(), v7.V8B(), v8.V8B()), "pmul v6.8b, v7.8b, v8.8b");
4530   COMPARE_MACRO(Pmul(v6.V16B(), v7.V16B(), v8.V16B()),
4531                 "pmul v6.16b, v7.16b, v8.16b");
4532 
4533   CLEANUP();
4534 }
4535 
4536 
4537 #define NEON_FORMAT_LIST_FP(V) \
4538   V(V2S(), "2s")               \
4539   V(V4S(), "4s")               \
4540   V(V2D(), "2d")
4541 
TEST(neon_fp_3same)4542 TEST(neon_fp_3same) {
4543   SETUP();
4544 
4545 #define DISASM_INST(M, S) \
4546   COMPARE_MACRO(Fadd(v0.M, v1.M, v2.M), "fadd v0." S ", v1." S ", v2." S);
4547   NEON_FORMAT_LIST_FP(DISASM_INST)
4548 #undef DISASM_INST
4549 
4550 #define DISASM_INST(M, S) \
4551   COMPARE_MACRO(Fsub(v3.M, v4.M, v5.M), "fsub v3." S ", v4." S ", v5." S);
4552   NEON_FORMAT_LIST_FP(DISASM_INST)
4553 #undef DISASM_INST
4554 
4555 #define DISASM_INST(M, S) \
4556   COMPARE_MACRO(Fmul(v6.M, v7.M, v8.M), "fmul v6." S ", v7." S ", v8." S);
4557   NEON_FORMAT_LIST_FP(DISASM_INST)
4558 #undef DISASM_INST
4559 
4560 #define DISASM_INST(M, S) \
4561   COMPARE_MACRO(Fdiv(v9.M, v10.M, v11.M), "fdiv v9." S ", v10." S ", v11." S);
4562   NEON_FORMAT_LIST_FP(DISASM_INST)
4563 #undef DISASM_INST
4564 
4565 #define DISASM_INST(M, S)                  \
4566   COMPARE_MACRO(Fmin(v12.M, v13.M, v14.M), \
4567                 "fmin v12." S ", v13." S   \
4568                 ", "                       \
4569                 "v14." S);
4570   NEON_FORMAT_LIST_FP(DISASM_INST)
4571 #undef DISASM_INST
4572 
4573 #define DISASM_INST(M, S)                    \
4574   COMPARE_MACRO(Fminnm(v15.M, v16.M, v17.M), \
4575                 "fminnm v15." S ", v16." S ", v17." S);
4576   NEON_FORMAT_LIST_FP(DISASM_INST)
4577 #undef DISASM_INST
4578 
4579 #define DISASM_INST(M, S)                  \
4580   COMPARE_MACRO(Fmax(v18.M, v19.M, v20.M), \
4581                 "fmax v18." S ", v19." S   \
4582                 ", "                       \
4583                 "v20." S);
4584   NEON_FORMAT_LIST_FP(DISASM_INST)
4585 #undef DISASM_INST
4586 
4587 #define DISASM_INST(M, S)                    \
4588   COMPARE_MACRO(Fmaxnm(v21.M, v22.M, v23.M), \
4589                 "fmaxnm v21." S ", v22." S ", v23." S);
4590   NEON_FORMAT_LIST_FP(DISASM_INST)
4591 #undef DISASM_INST
4592 
4593 #define DISASM_INST(M, S)                    \
4594   COMPARE_MACRO(Frecps(v24.M, v25.M, v26.M), \
4595                 "frecps v24." S ", v25." S ", v26." S);
4596   NEON_FORMAT_LIST_FP(DISASM_INST)
4597 #undef DISASM_INST
4598 
4599 #define DISASM_INST(M, S)                     \
4600   COMPARE_MACRO(Frsqrts(v27.M, v28.M, v29.M), \
4601                 "frsqrts v27." S ", v28." S ", v29." S);
4602   NEON_FORMAT_LIST_FP(DISASM_INST)
4603 #undef DISASM_INST
4604 
4605 #define DISASM_INST(M, S)                  \
4606   COMPARE_MACRO(Fmulx(v30.M, v31.M, v0.M), \
4607                 "fmulx v30." S ", v31." S  \
4608                 ", "                       \
4609                 "v0." S);
4610   NEON_FORMAT_LIST_FP(DISASM_INST)
4611 #undef DISASM_INST
4612 
4613 #define DISASM_INST(M, S) \
4614   COMPARE_MACRO(Fmla(v1.M, v2.M, v3.M), "fmla v1." S ", v2." S ", v3." S);
4615   NEON_FORMAT_LIST_FP(DISASM_INST)
4616 #undef DISASM_INST
4617 
4618 #define DISASM_INST(M, S) \
4619   COMPARE_MACRO(Fmls(v4.M, v5.M, v6.M), "fmls v4." S ", v5." S ", v6." S);
4620   NEON_FORMAT_LIST_FP(DISASM_INST)
4621 #undef DISASM_INST
4622 
4623 #define DISASM_INST(M, S) \
4624   COMPARE_MACRO(Fabd(v7.M, v8.M, v9.M), "fabd v7." S ", v8." S ", v9." S);
4625   NEON_FORMAT_LIST_FP(DISASM_INST)
4626 #undef DISASM_INST
4627 
4628 #define DISASM_INST(M, S)                   \
4629   COMPARE_MACRO(Faddp(v10.M, v11.M, v12.M), \
4630                 "faddp v10." S ", v11." S ", v12." S);
4631   NEON_FORMAT_LIST_FP(DISASM_INST)
4632 #undef DISASM_INST
4633 
4634 #define DISASM_INST(M, S)                   \
4635   COMPARE_MACRO(Fmaxp(v13.M, v14.M, v15.M), \
4636                 "fmaxp v13." S ", v14." S ", v15." S);
4637   NEON_FORMAT_LIST_FP(DISASM_INST)
4638 #undef DISASM_INST
4639 
4640 #define DISASM_INST(M, S)                   \
4641   COMPARE_MACRO(Fminp(v16.M, v17.M, v18.M), \
4642                 "fminp v16." S ", v17." S ", v18." S);
4643   NEON_FORMAT_LIST_FP(DISASM_INST)
4644 #undef DISASM_INST
4645 
4646 #define DISASM_INST(M, S)                     \
4647   COMPARE_MACRO(Fmaxnmp(v19.M, v20.M, v21.M), \
4648                 "fmaxnmp v19." S ", v20." S ", v21." S);
4649   NEON_FORMAT_LIST_FP(DISASM_INST)
4650 #undef DISASM_INST
4651 
4652 #define DISASM_INST(M, S)                     \
4653   COMPARE_MACRO(Fminnmp(v22.M, v23.M, v24.M), \
4654                 "fminnmp v22." S ", v23." S ", v24." S);
4655   NEON_FORMAT_LIST_FP(DISASM_INST)
4656 #undef DISASM_INST
4657 
4658 #define DISASM_INST(M, S)                   \
4659   COMPARE_MACRO(Fcmeq(v25.M, v26.M, v27.M), \
4660                 "fcmeq v25." S ", v26." S ", v27." S);
4661   NEON_FORMAT_LIST_FP(DISASM_INST)
4662 #undef DISASM_INST
4663 
4664 #define DISASM_INST(M, S)                   \
4665   COMPARE_MACRO(Fcmge(v25.M, v26.M, v27.M), \
4666                 "fcmge v25." S ", v26." S ", v27." S);
4667   NEON_FORMAT_LIST_FP(DISASM_INST)
4668 #undef DISASM_INST
4669 
4670 #define DISASM_INST(M, S)                   \
4671   COMPARE_MACRO(Fcmgt(v25.M, v26.M, v27.M), \
4672                 "fcmgt v25." S ", v26." S ", v27." S);
4673   NEON_FORMAT_LIST_FP(DISASM_INST)
4674 #undef DISASM_INST
4675 
4676 #define DISASM_INST(M, S)                   \
4677   COMPARE_MACRO(Facge(v25.M, v26.M, v27.M), \
4678                 "facge v25." S ", v26." S ", v27." S);
4679   NEON_FORMAT_LIST_FP(DISASM_INST)
4680 #undef DISASM_INST
4681 
4682 #define DISASM_INST(M, S)                   \
4683   COMPARE_MACRO(Facgt(v25.M, v26.M, v27.M), \
4684                 "facgt v25." S ", v26." S ", v27." S);
4685   NEON_FORMAT_LIST_FP(DISASM_INST)
4686 #undef DISASM_INST
4687 
4688   CLEANUP();
4689 }
4690 
4691 
4692 #define NEON_SCALAR_FORMAT_LIST(V) \
4693   V(B(), "b")                      \
4694   V(H(), "h")                      \
4695   V(S(), "s")                      \
4696   V(D(), "d")
4697 
TEST(neon_scalar_3same)4698 TEST(neon_scalar_3same) {
4699   SETUP();
4700 
4701   // Instructions that only support D-sized scalar operations.
4702   COMPARE_MACRO(Add(v0.D(), v1.D(), v2.D()), "add d0, d1, d2");
4703   COMPARE_MACRO(Sub(v3.D(), v4.D(), v5.D()), "sub d3, d4, d5");
4704   COMPARE_MACRO(Cmeq(v0.D(), v1.D(), v2.D()), "cmeq d0, d1, d2");
4705   COMPARE_MACRO(Cmge(v3.D(), v4.D(), v5.D()), "cmge d3, d4, d5");
4706   COMPARE_MACRO(Cmgt(v6.D(), v7.D(), v8.D()), "cmgt d6, d7, d8");
4707   COMPARE_MACRO(Cmhi(v0.D(), v1.D(), v2.D()), "cmhi d0, d1, d2");
4708   COMPARE_MACRO(Cmhs(v3.D(), v4.D(), v5.D()), "cmhs d3, d4, d5");
4709   COMPARE_MACRO(Cmtst(v6.D(), v7.D(), v8.D()), "cmtst d6, d7, d8");
4710   COMPARE_MACRO(Ushl(v6.D(), v7.D(), v8.D()), "ushl d6, d7, d8");
4711   COMPARE_MACRO(Sshl(v6.D(), v7.D(), v8.D()), "sshl d6, d7, d8");
4712   COMPARE_MACRO(Urshl(v9.D(), v10.D(), v11.D()), "urshl d9, d10, d11");
4713   COMPARE_MACRO(Srshl(v9.D(), v10.D(), v11.D()), "srshl d9, d10, d11");
4714 
4715   // Instructions that support S and D-sized scalar operations.
4716   COMPARE_MACRO(Frecps(v12.S(), v13.S(), v14.S()), "frecps s12, s13, s14");
4717   COMPARE_MACRO(Frecps(v15.D(), v16.D(), v17.D()), "frecps d15, d16, d17");
4718   COMPARE_MACRO(Frsqrts(v18.S(), v19.S(), v20.S()), "frsqrts s18, s19, s20");
4719   COMPARE_MACRO(Frsqrts(v21.D(), v22.D(), v23.D()), "frsqrts d21, d22, d23");
4720   COMPARE_MACRO(Fmulx(v12.S(), v13.S(), v14.S()), "fmulx s12, s13, s14");
4721   COMPARE_MACRO(Fmulx(v15.D(), v16.D(), v17.D()), "fmulx d15, d16, d17");
4722   COMPARE_MACRO(Fcmeq(v12.S(), v13.S(), v14.S()), "fcmeq s12, s13, s14");
4723   COMPARE_MACRO(Fcmeq(v15.D(), v16.D(), v17.D()), "fcmeq d15, d16, d17");
4724   COMPARE_MACRO(Fcmge(v12.S(), v13.S(), v14.S()), "fcmge s12, s13, s14");
4725   COMPARE_MACRO(Fcmge(v15.D(), v16.D(), v17.D()), "fcmge d15, d16, d17");
4726   COMPARE_MACRO(Fcmgt(v12.S(), v13.S(), v14.S()), "fcmgt s12, s13, s14");
4727   COMPARE_MACRO(Fcmgt(v15.D(), v16.D(), v17.D()), "fcmgt d15, d16, d17");
4728   COMPARE_MACRO(Fcmge(v12.S(), v13.S(), v14.S()), "fcmge s12, s13, s14");
4729   COMPARE_MACRO(Fcmge(v15.D(), v16.D(), v17.D()), "fcmge d15, d16, d17");
4730   COMPARE_MACRO(Facgt(v12.S(), v13.S(), v14.S()), "facgt s12, s13, s14");
4731   COMPARE_MACRO(Facgt(v15.D(), v16.D(), v17.D()), "facgt d15, d16, d17");
4732 
4733   // Instructions that support H and S-sized scalar operations.
4734   COMPARE_MACRO(Sqdmulh(v12.S(), v13.S(), v14.S()), "sqdmulh s12, s13, s14");
4735   COMPARE_MACRO(Sqdmulh(v15.H(), v16.H(), v17.H()), "sqdmulh h15, h16, h17");
4736   COMPARE_MACRO(Sqrdmulh(v12.S(), v13.S(), v14.S()), "sqrdmulh s12, s13, s14");
4737   COMPARE_MACRO(Sqrdmulh(v15.H(), v16.H(), v17.H()), "sqrdmulh h15, h16, h17");
4738 
4739 #define DISASM_INST(M, R) \
4740   COMPARE_MACRO(Uqadd(v6.M, v7.M, v8.M), "uqadd " R "6, " R "7, " R "8");
4741   NEON_SCALAR_FORMAT_LIST(DISASM_INST)
4742 #undef DISASM_INST
4743 
4744 #define DISASM_INST(M, R) \
4745   COMPARE_MACRO(Uqsub(v9.M, v10.M, v11.M), "uqsub " R "9, " R "10, " R "11");
4746   NEON_SCALAR_FORMAT_LIST(DISASM_INST)
4747 #undef DISASM_INST
4748 
4749 #define DISASM_INST(M, R)                    \
4750   COMPARE_MACRO(Sqadd(v12.M, v13.M, v14.M),  \
4751                 "sqadd " R "12, " R "13, " R \
4752                 "1"                          \
4753                 "4");
4754   NEON_SCALAR_FORMAT_LIST(DISASM_INST)
4755 #undef DISASM_INST
4756 
4757 #define DISASM_INST(M, R)                    \
4758   COMPARE_MACRO(Sqsub(v15.M, v16.M, v17.M),  \
4759                 "sqsub " R "15, " R "16, " R \
4760                 "1"                          \
4761                 "7");
4762   NEON_SCALAR_FORMAT_LIST(DISASM_INST)
4763 #undef DISASM_INST
4764 
4765 #define DISASM_INST(M, R)                    \
4766   COMPARE_MACRO(Uqshl(v18.M, v19.M, v20.M),  \
4767                 "uqshl " R "18, " R "19, " R \
4768                 "2"                          \
4769                 "0");
4770   NEON_SCALAR_FORMAT_LIST(DISASM_INST)
4771 #undef DISASM_INST
4772 
4773 #define DISASM_INST(M, R)                    \
4774   COMPARE_MACRO(Sqshl(v21.M, v22.M, v23.M),  \
4775                 "sqshl " R "21, " R "22, " R \
4776                 "2"                          \
4777                 "3");
4778   NEON_SCALAR_FORMAT_LIST(DISASM_INST)
4779 #undef DISASM_INST
4780 
4781 #define DISASM_INST(M, R) \
4782   COMPARE_MACRO(Uqrshl(v30.M, v31.M, v0.M), "uqrshl " R "30, " R "31, " R "0");
4783   NEON_SCALAR_FORMAT_LIST(DISASM_INST)
4784 #undef DISASM_INST
4785 
4786 #define DISASM_INST(M, R) \
4787   COMPARE_MACRO(Sqrshl(v1.M, v2.M, v3.M), "sqrshl " R "1, " R "2, " R "3");
4788   NEON_SCALAR_FORMAT_LIST(DISASM_INST)
4789 #undef DISASM_INST
4790 
4791   CLEANUP();
4792 }
4793 
4794 
TEST(neon_byelement)4795 TEST(neon_byelement) {
4796   SETUP();
4797 
4798   COMPARE_MACRO(Mul(v0.V4H(), v1.V4H(), v2.H(), 0),
4799                 "mul v0.4h, v1.4h, v2.h[0]");
4800   COMPARE_MACRO(Mul(v2.V8H(), v3.V8H(), v15.H(), 7),
4801                 "mul v2.8h, v3.8h, v15.h[7]");
4802   COMPARE_MACRO(Mul(v0.V2S(), v1.V2S(), v2.S(), 0),
4803                 "mul v0.2s, v1.2s, v2.s[0]");
4804   COMPARE_MACRO(Mul(v2.V4S(), v3.V4S(), v15.S(), 3),
4805                 "mul v2.4s, v3.4s, v15.s[3]");
4806 
4807   COMPARE_MACRO(Mla(v0.V4H(), v1.V4H(), v2.H(), 0),
4808                 "mla v0.4h, v1.4h, v2.h[0]");
4809   COMPARE_MACRO(Mla(v2.V8H(), v3.V8H(), v15.H(), 7),
4810                 "mla v2.8h, v3.8h, v15.h[7]");
4811   COMPARE_MACRO(Mla(v0.V2S(), v1.V2S(), v2.S(), 0),
4812                 "mla v0.2s, v1.2s, v2.s[0]");
4813   COMPARE_MACRO(Mla(v2.V4S(), v3.V4S(), v15.S(), 3),
4814                 "mla v2.4s, v3.4s, v15.s[3]");
4815 
4816   COMPARE_MACRO(Mls(v0.V4H(), v1.V4H(), v2.H(), 0),
4817                 "mls v0.4h, v1.4h, v2.h[0]");
4818   COMPARE_MACRO(Mls(v2.V8H(), v3.V8H(), v15.H(), 7),
4819                 "mls v2.8h, v3.8h, v15.h[7]");
4820   COMPARE_MACRO(Mls(v0.V2S(), v1.V2S(), v2.S(), 0),
4821                 "mls v0.2s, v1.2s, v2.s[0]");
4822   COMPARE_MACRO(Mls(v2.V4S(), v3.V4S(), v15.S(), 3),
4823                 "mls v2.4s, v3.4s, v15.s[3]");
4824 
4825   COMPARE_MACRO(Sqdmulh(v0.V4H(), v1.V4H(), v2.H(), 0),
4826                 "sqdmulh v0.4h, v1.4h, v2.h[0]");
4827   COMPARE_MACRO(Sqdmulh(v2.V8H(), v3.V8H(), v15.H(), 7),
4828                 "sqdmulh v2.8h, v3.8h, v15.h[7]");
4829   COMPARE_MACRO(Sqdmulh(v0.V2S(), v1.V2S(), v2.S(), 0),
4830                 "sqdmulh v0.2s, v1.2s, v2.s[0]");
4831   COMPARE_MACRO(Sqdmulh(v2.V4S(), v3.V4S(), v15.S(), 3),
4832                 "sqdmulh v2.4s, v3.4s, v15.s[3]");
4833   COMPARE_MACRO(Sqdmulh(h0, h1, v2.H(), 0), "sqdmulh h0, h1, v2.h[0]");
4834   COMPARE_MACRO(Sqdmulh(s0, s1, v2.S(), 0), "sqdmulh s0, s1, v2.s[0]");
4835 
4836   COMPARE_MACRO(Sqrdmulh(v0.V4H(), v1.V4H(), v2.H(), 0),
4837                 "sqrdmulh v0.4h, v1.4h, v2.h[0]");
4838   COMPARE_MACRO(Sqrdmulh(v2.V8H(), v3.V8H(), v15.H(), 7),
4839                 "sqrdmulh v2.8h, v3.8h, v15.h[7]");
4840   COMPARE_MACRO(Sqrdmulh(v0.V2S(), v1.V2S(), v2.S(), 0),
4841                 "sqrdmulh v0.2s, v1.2s, v2.s[0]");
4842   COMPARE_MACRO(Sqrdmulh(v2.V4S(), v3.V4S(), v15.S(), 3),
4843                 "sqrdmulh v2.4s, v3.4s, v15.s[3]");
4844   COMPARE_MACRO(Sqrdmulh(h0, h1, v2.H(), 0), "sqrdmulh h0, h1, v2.h[0]");
4845   COMPARE_MACRO(Sqrdmulh(s0, s1, v2.S(), 0), "sqrdmulh s0, s1, v2.s[0]");
4846 
4847   COMPARE_MACRO(Smull(v0.V4S(), v1.V4H(), v2.H(), 0),
4848                 "smull v0.4s, v1.4h, v2.h[0]");
4849   COMPARE_MACRO(Smull2(v2.V4S(), v3.V8H(), v4.H(), 7),
4850                 "smull2 v2.4s, v3.8h, v4.h[7]");
4851   COMPARE_MACRO(Smull(v0.V2D(), v1.V2S(), v2.S(), 0),
4852                 "smull v0.2d, v1.2s, v2.s[0]");
4853   COMPARE_MACRO(Smull2(v2.V2D(), v3.V4S(), v4.S(), 3),
4854                 "smull2 v2.2d, v3.4s, v4.s[3]");
4855 
4856   COMPARE_MACRO(Umull(v0.V4S(), v1.V4H(), v2.H(), 0),
4857                 "umull v0.4s, v1.4h, v2.h[0]");
4858   COMPARE_MACRO(Umull2(v2.V4S(), v3.V8H(), v4.H(), 7),
4859                 "umull2 v2.4s, v3.8h, v4.h[7]");
4860   COMPARE_MACRO(Umull(v0.V2D(), v1.V2S(), v2.S(), 0),
4861                 "umull v0.2d, v1.2s, v2.s[0]");
4862   COMPARE_MACRO(Umull2(v2.V2D(), v3.V4S(), v4.S(), 3),
4863                 "umull2 v2.2d, v3.4s, v4.s[3]");
4864 
4865   COMPARE_MACRO(Smlal(v0.V4S(), v1.V4H(), v2.H(), 0),
4866                 "smlal v0.4s, v1.4h, v2.h[0]");
4867   COMPARE_MACRO(Smlal2(v2.V4S(), v3.V8H(), v4.H(), 7),
4868                 "smlal2 v2.4s, v3.8h, v4.h[7]");
4869   COMPARE_MACRO(Smlal(v0.V2D(), v1.V2S(), v2.S(), 0),
4870                 "smlal v0.2d, v1.2s, v2.s[0]");
4871   COMPARE_MACRO(Smlal2(v2.V2D(), v3.V4S(), v4.S(), 3),
4872                 "smlal2 v2.2d, v3.4s, v4.s[3]");
4873 
4874   COMPARE_MACRO(Umlal(v0.V4S(), v1.V4H(), v2.H(), 0),
4875                 "umlal v0.4s, v1.4h, v2.h[0]");
4876   COMPARE_MACRO(Umlal2(v2.V4S(), v3.V8H(), v4.H(), 7),
4877                 "umlal2 v2.4s, v3.8h, v4.h[7]");
4878   COMPARE_MACRO(Umlal(v0.V2D(), v1.V2S(), v2.S(), 0),
4879                 "umlal v0.2d, v1.2s, v2.s[0]");
4880   COMPARE_MACRO(Umlal2(v2.V2D(), v3.V4S(), v4.S(), 3),
4881                 "umlal2 v2.2d, v3.4s, v4.s[3]");
4882 
4883   COMPARE_MACRO(Smlsl(v0.V4S(), v1.V4H(), v2.H(), 0),
4884                 "smlsl v0.4s, v1.4h, v2.h[0]");
4885   COMPARE_MACRO(Smlsl2(v2.V4S(), v3.V8H(), v4.H(), 7),
4886                 "smlsl2 v2.4s, v3.8h, v4.h[7]");
4887   COMPARE_MACRO(Smlsl(v0.V2D(), v1.V2S(), v2.S(), 0),
4888                 "smlsl v0.2d, v1.2s, v2.s[0]");
4889   COMPARE_MACRO(Smlsl2(v2.V2D(), v3.V4S(), v4.S(), 3),
4890                 "smlsl2 v2.2d, v3.4s, v4.s[3]");
4891 
4892   COMPARE_MACRO(Umlsl(v0.V4S(), v1.V4H(), v2.H(), 0),
4893                 "umlsl v0.4s, v1.4h, v2.h[0]");
4894   COMPARE_MACRO(Umlsl2(v2.V4S(), v3.V8H(), v4.H(), 7),
4895                 "umlsl2 v2.4s, v3.8h, v4.h[7]");
4896   COMPARE_MACRO(Umlsl(v0.V2D(), v1.V2S(), v2.S(), 0),
4897                 "umlsl v0.2d, v1.2s, v2.s[0]");
4898   COMPARE_MACRO(Umlsl2(v2.V2D(), v3.V4S(), v4.S(), 3),
4899                 "umlsl2 v2.2d, v3.4s, v4.s[3]");
4900 
4901   COMPARE_MACRO(Sqdmull(v0.V4S(), v1.V4H(), v2.H(), 0),
4902                 "sqdmull v0.4s, v1.4h, v2.h[0]");
4903   COMPARE_MACRO(Sqdmull2(v2.V4S(), v3.V8H(), v4.H(), 7),
4904                 "sqdmull2 v2.4s, v3.8h, v4.h[7]");
4905   COMPARE_MACRO(Sqdmull(v0.V2D(), v1.V2S(), v2.S(), 0),
4906                 "sqdmull v0.2d, v1.2s, v2.s[0]");
4907   COMPARE_MACRO(Sqdmull2(v2.V2D(), v3.V4S(), v4.S(), 3),
4908                 "sqdmull2 v2.2d, v3.4s, v4.s[3]");
4909   COMPARE_MACRO(Sqdmull(s0, h1, v2.H(), 0), "sqdmull s0, h1, v2.h[0]");
4910   COMPARE_MACRO(Sqdmull(d0, s1, v2.S(), 0), "sqdmull d0, s1, v2.s[0]");
4911 
4912   COMPARE_MACRO(Sqdmlal(v0.V4S(), v1.V4H(), v2.H(), 0),
4913                 "sqdmlal v0.4s, v1.4h, v2.h[0]");
4914   COMPARE_MACRO(Sqdmlal2(v2.V4S(), v3.V8H(), v4.H(), 7),
4915                 "sqdmlal2 v2.4s, v3.8h, v4.h[7]");
4916   COMPARE_MACRO(Sqdmlal(v0.V2D(), v1.V2S(), v2.S(), 0),
4917                 "sqdmlal v0.2d, v1.2s, v2.s[0]");
4918   COMPARE_MACRO(Sqdmlal2(v2.V2D(), v3.V4S(), v4.S(), 3),
4919                 "sqdmlal2 v2.2d, v3.4s, v4.s[3]");
4920   COMPARE_MACRO(Sqdmlal(s0, h1, v2.H(), 0), "sqdmlal s0, h1, v2.h[0]");
4921   COMPARE_MACRO(Sqdmlal(d0, s1, v2.S(), 0), "sqdmlal d0, s1, v2.s[0]");
4922 
4923   COMPARE_MACRO(Sqdmlsl(v0.V4S(), v1.V4H(), v2.H(), 0),
4924                 "sqdmlsl v0.4s, v1.4h, v2.h[0]");
4925   COMPARE_MACRO(Sqdmlsl2(v2.V4S(), v3.V8H(), v4.H(), 7),
4926                 "sqdmlsl2 v2.4s, v3.8h, v4.h[7]");
4927   COMPARE_MACRO(Sqdmlsl(v0.V2D(), v1.V2S(), v2.S(), 0),
4928                 "sqdmlsl v0.2d, v1.2s, v2.s[0]");
4929   COMPARE_MACRO(Sqdmlsl2(v2.V2D(), v3.V4S(), v4.S(), 3),
4930                 "sqdmlsl2 v2.2d, v3.4s, v4.s[3]");
4931   COMPARE_MACRO(Sqdmlsl(s0, h1, v2.H(), 0), "sqdmlsl s0, h1, v2.h[0]");
4932   COMPARE_MACRO(Sqdmlsl(d0, s1, v2.S(), 0), "sqdmlsl d0, s1, v2.s[0]");
4933 
4934   CLEANUP();
4935 }
4936 
4937 
TEST(neon_fp_byelement)4938 TEST(neon_fp_byelement) {
4939   SETUP();
4940 
4941   COMPARE_MACRO(Fmul(v0.V2S(), v1.V2S(), v2.S(), 0),
4942                 "fmul v0.2s, v1.2s, v2.s[0]");
4943   COMPARE_MACRO(Fmul(v2.V4S(), v3.V4S(), v15.S(), 3),
4944                 "fmul v2.4s, v3.4s, v15.s[3]");
4945   COMPARE_MACRO(Fmul(v0.V2D(), v1.V2D(), v2.D(), 0),
4946                 "fmul v0.2d, v1.2d, v2.d[0]");
4947   COMPARE_MACRO(Fmul(d0, d1, v2.D(), 0), "fmul d0, d1, v2.d[0]");
4948   COMPARE_MACRO(Fmul(s0, s1, v2.S(), 0), "fmul s0, s1, v2.s[0]");
4949 
4950   COMPARE_MACRO(Fmla(v0.V2S(), v1.V2S(), v2.S(), 0),
4951                 "fmla v0.2s, v1.2s, v2.s[0]");
4952   COMPARE_MACRO(Fmla(v2.V4S(), v3.V4S(), v15.S(), 3),
4953                 "fmla v2.4s, v3.4s, v15.s[3]");
4954   COMPARE_MACRO(Fmla(v0.V2D(), v1.V2D(), v2.D(), 0),
4955                 "fmla v0.2d, v1.2d, v2.d[0]");
4956   COMPARE_MACRO(Fmla(d0, d1, v2.D(), 0), "fmla d0, d1, v2.d[0]");
4957   COMPARE_MACRO(Fmla(s0, s1, v2.S(), 0), "fmla s0, s1, v2.s[0]");
4958 
4959   COMPARE_MACRO(Fmls(v0.V2S(), v1.V2S(), v2.S(), 0),
4960                 "fmls v0.2s, v1.2s, v2.s[0]");
4961   COMPARE_MACRO(Fmls(v2.V4S(), v3.V4S(), v15.S(), 3),
4962                 "fmls v2.4s, v3.4s, v15.s[3]");
4963   COMPARE_MACRO(Fmls(v0.V2D(), v1.V2D(), v2.D(), 0),
4964                 "fmls v0.2d, v1.2d, v2.d[0]");
4965   COMPARE_MACRO(Fmls(d0, d1, v2.D(), 0), "fmls d0, d1, v2.d[0]");
4966   COMPARE_MACRO(Fmls(s0, s1, v2.S(), 0), "fmls s0, s1, v2.s[0]");
4967 
4968   COMPARE_MACRO(Fmulx(v0.V2S(), v1.V2S(), v2.S(), 0),
4969                 "fmulx v0.2s, v1.2s, v2.s[0]");
4970   COMPARE_MACRO(Fmulx(v2.V4S(), v3.V4S(), v8.S(), 3),
4971                 "fmulx v2.4s, v3.4s, v8.s[3]");
4972   COMPARE_MACRO(Fmulx(v0.V2D(), v1.V2D(), v2.D(), 0),
4973                 "fmulx v0.2d, v1.2d, v2.d[0]");
4974   COMPARE_MACRO(Fmulx(d0, d1, v2.D(), 0), "fmulx d0, d1, v2.d[0]");
4975   COMPARE_MACRO(Fmulx(s0, s1, v2.S(), 0), "fmulx s0, s1, v2.s[0]");
4976 
4977   CLEANUP();
4978 }
4979 
4980 
TEST(neon_3different)4981 TEST(neon_3different) {
4982   SETUP();
4983 
4984 #define DISASM_INST(TA, TAS, TB, TBS)       \
4985   COMPARE_MACRO(Uaddl(v0.TA, v1.TB, v2.TB), \
4986                 "uaddl v0." TAS ", v1." TBS ", v2." TBS);
4987   NEON_FORMAT_LIST_LW(DISASM_INST)
4988 #undef DISASM_INST
4989 
4990 #define DISASM_INST(TA, TAS, TB, TBS)        \
4991   COMPARE_MACRO(Uaddl2(v0.TA, v1.TB, v2.TB), \
4992                 "uaddl2 v0." TAS ", v1." TBS ", v2." TBS);
4993   NEON_FORMAT_LIST_LW2(DISASM_INST)
4994 #undef DISASM_INST
4995 
4996 #define DISASM_INST(TA, TAS, TB, TBS)       \
4997   COMPARE_MACRO(Uaddw(v0.TA, v1.TA, v2.TB), \
4998                 "uaddw v0." TAS ", v1." TAS ", v2." TBS);
4999   NEON_FORMAT_LIST_LW(DISASM_INST)
5000 #undef DISASM_INST
5001 
5002 #define DISASM_INST(TA, TAS, TB, TBS)        \
5003   COMPARE_MACRO(Uaddw2(v0.TA, v1.TA, v2.TB), \
5004                 "uaddw2 v0." TAS ", v1." TAS ", v2." TBS);
5005   NEON_FORMAT_LIST_LW2(DISASM_INST)
5006 #undef DISASM_INST
5007 
5008 #define DISASM_INST(TA, TAS, TB, TBS)       \
5009   COMPARE_MACRO(Saddl(v0.TA, v1.TB, v2.TB), \
5010                 "saddl v0." TAS ", v1." TBS ", v2." TBS);
5011   NEON_FORMAT_LIST_LW(DISASM_INST)
5012 #undef DISASM_INST
5013 
5014 #define DISASM_INST(TA, TAS, TB, TBS)        \
5015   COMPARE_MACRO(Saddl2(v0.TA, v1.TB, v2.TB), \
5016                 "saddl2 v0." TAS ", v1." TBS ", v2." TBS);
5017   NEON_FORMAT_LIST_LW2(DISASM_INST)
5018 #undef DISASM_INST
5019 
5020 #define DISASM_INST(TA, TAS, TB, TBS)       \
5021   COMPARE_MACRO(Saddw(v0.TA, v1.TA, v2.TB), \
5022                 "saddw v0." TAS ", v1." TAS ", v2." TBS);
5023   NEON_FORMAT_LIST_LW(DISASM_INST)
5024 #undef DISASM_INST
5025 
5026 #define DISASM_INST(TA, TAS, TB, TBS)        \
5027   COMPARE_MACRO(Saddw2(v0.TA, v1.TA, v2.TB), \
5028                 "saddw2 v0." TAS ", v1." TAS ", v2." TBS);
5029   NEON_FORMAT_LIST_LW2(DISASM_INST)
5030 #undef DISASM_INST
5031 
5032 #define DISASM_INST(TA, TAS, TB, TBS)       \
5033   COMPARE_MACRO(Usubl(v0.TA, v1.TB, v2.TB), \
5034                 "usubl v0." TAS ", v1." TBS ", v2." TBS);
5035   NEON_FORMAT_LIST_LW(DISASM_INST)
5036 #undef DISASM_INST
5037 
5038 #define DISASM_INST(TA, TAS, TB, TBS)        \
5039   COMPARE_MACRO(Usubl2(v0.TA, v1.TB, v2.TB), \
5040                 "usubl2 v0." TAS ", v1." TBS ", v2." TBS);
5041   NEON_FORMAT_LIST_LW2(DISASM_INST)
5042 #undef DISASM_INST
5043 
5044 #define DISASM_INST(TA, TAS, TB, TBS)       \
5045   COMPARE_MACRO(Usubw(v0.TA, v1.TA, v2.TB), \
5046                 "usubw v0." TAS ", v1." TAS ", v2." TBS);
5047   NEON_FORMAT_LIST_LW(DISASM_INST)
5048 #undef DISASM_INST
5049 
5050 #define DISASM_INST(TA, TAS, TB, TBS)        \
5051   COMPARE_MACRO(Usubw2(v0.TA, v1.TA, v2.TB), \
5052                 "usubw2 v0." TAS ", v1." TAS ", v2." TBS);
5053   NEON_FORMAT_LIST_LW2(DISASM_INST)
5054 #undef DISASM_INST
5055 
5056 #define DISASM_INST(TA, TAS, TB, TBS)       \
5057   COMPARE_MACRO(Ssubl(v0.TA, v1.TB, v2.TB), \
5058                 "ssubl v0." TAS ", v1." TBS ", v2." TBS);
5059   NEON_FORMAT_LIST_LW(DISASM_INST)
5060 #undef DISASM_INST
5061 
5062 #define DISASM_INST(TA, TAS, TB, TBS)        \
5063   COMPARE_MACRO(Ssubl2(v0.TA, v1.TB, v2.TB), \
5064                 "ssubl2 v0." TAS ", v1." TBS ", v2." TBS);
5065   NEON_FORMAT_LIST_LW2(DISASM_INST)
5066 #undef DISASM_INST
5067 
5068 #define DISASM_INST(TA, TAS, TB, TBS)       \
5069   COMPARE_MACRO(Ssubw(v0.TA, v1.TA, v2.TB), \
5070                 "ssubw v0." TAS ", v1." TAS ", v2." TBS);
5071   NEON_FORMAT_LIST_LW(DISASM_INST)
5072 #undef DISASM_INST
5073 
5074 #define DISASM_INST(TA, TAS, TB, TBS)        \
5075   COMPARE_MACRO(Ssubw2(v0.TA, v1.TA, v2.TB), \
5076                 "ssubw2 v0." TAS ", v1." TAS ", v2." TBS);
5077   NEON_FORMAT_LIST_LW2(DISASM_INST)
5078 #undef DISASM_INST
5079 
5080 #define DISASM_INST(TA, TAS, TB, TBS)       \
5081   COMPARE_MACRO(Sabal(v0.TA, v1.TB, v2.TB), \
5082                 "sabal v0." TAS ", v1." TBS ", v2." TBS);
5083   NEON_FORMAT_LIST_LW(DISASM_INST)
5084 #undef DISASM_INST
5085 
5086 #define DISASM_INST(TA, TAS, TB, TBS)        \
5087   COMPARE_MACRO(Sabal2(v0.TA, v1.TB, v2.TB), \
5088                 "sabal2 v0." TAS ", v1." TBS ", v2." TBS);
5089   NEON_FORMAT_LIST_LW2(DISASM_INST)
5090 #undef DISASM_INST
5091 
5092 #define DISASM_INST(TA, TAS, TB, TBS)       \
5093   COMPARE_MACRO(Uabal(v0.TA, v1.TB, v2.TB), \
5094                 "uabal v0." TAS ", v1." TBS ", v2." TBS);
5095   NEON_FORMAT_LIST_LW(DISASM_INST)
5096 #undef DISASM_INST
5097 
5098 #define DISASM_INST(TA, TAS, TB, TBS)        \
5099   COMPARE_MACRO(Uabal2(v0.TA, v1.TB, v2.TB), \
5100                 "uabal2 v0." TAS ", v1." TBS ", v2." TBS);
5101   NEON_FORMAT_LIST_LW2(DISASM_INST)
5102 #undef DISASM_INST
5103 
5104 #define DISASM_INST(TA, TAS, TB, TBS)       \
5105   COMPARE_MACRO(Sabdl(v0.TA, v1.TB, v2.TB), \
5106                 "sabdl v0." TAS ", v1." TBS ", v2." TBS);
5107   NEON_FORMAT_LIST_LW(DISASM_INST)
5108 #undef DISASM_INST
5109 
5110 #define DISASM_INST(TA, TAS, TB, TBS)        \
5111   COMPARE_MACRO(Sabdl2(v0.TA, v1.TB, v2.TB), \
5112                 "sabdl2 v0." TAS ", v1." TBS ", v2." TBS);
5113   NEON_FORMAT_LIST_LW2(DISASM_INST)
5114 #undef DISASM_INST
5115 
5116 #define DISASM_INST(TA, TAS, TB, TBS)       \
5117   COMPARE_MACRO(Uabdl(v0.TA, v1.TB, v2.TB), \
5118                 "uabdl v0." TAS ", v1." TBS ", v2." TBS);
5119   NEON_FORMAT_LIST_LW(DISASM_INST)
5120 #undef DISASM_INST
5121 
5122 #define DISASM_INST(TA, TAS, TB, TBS)        \
5123   COMPARE_MACRO(Uabdl2(v0.TA, v1.TB, v2.TB), \
5124                 "uabdl2 v0." TAS ", v1." TBS ", v2." TBS);
5125   NEON_FORMAT_LIST_LW2(DISASM_INST)
5126 #undef DISASM_INST
5127 
5128 #define DISASM_INST(TA, TAS, TB, TBS)       \
5129   COMPARE_MACRO(Smlal(v0.TA, v1.TB, v2.TB), \
5130                 "smlal v0." TAS ", v1." TBS ", v2." TBS);
5131   NEON_FORMAT_LIST_LW(DISASM_INST)
5132 #undef DISASM_INST
5133 
5134 #define DISASM_INST(TA, TAS, TB, TBS)        \
5135   COMPARE_MACRO(Smlal2(v0.TA, v1.TB, v2.TB), \
5136                 "smlal2 v0." TAS ", v1." TBS ", v2." TBS);
5137   NEON_FORMAT_LIST_LW2(DISASM_INST)
5138 #undef DISASM_INST
5139 
5140 #define DISASM_INST(TA, TAS, TB, TBS)       \
5141   COMPARE_MACRO(Umlsl(v0.TA, v1.TB, v2.TB), \
5142                 "umlsl v0." TAS ", v1." TBS ", v2." TBS);
5143   NEON_FORMAT_LIST_LW(DISASM_INST)
5144 #undef DISASM_INST
5145 
5146 #define DISASM_INST(TA, TAS, TB, TBS)        \
5147   COMPARE_MACRO(Umlsl2(v0.TA, v1.TB, v2.TB), \
5148                 "umlsl2 v0." TAS ", v1." TBS ", v2." TBS);
5149   NEON_FORMAT_LIST_LW2(DISASM_INST)
5150 #undef DISASM_INST
5151 
5152 #define DISASM_INST(TA, TAS, TB, TBS)       \
5153   COMPARE_MACRO(Smlsl(v0.TA, v1.TB, v2.TB), \
5154                 "smlsl v0." TAS ", v1." TBS ", v2." TBS);
5155   NEON_FORMAT_LIST_LW(DISASM_INST)
5156 #undef DISASM_INST
5157 
5158 #define DISASM_INST(TA, TAS, TB, TBS)        \
5159   COMPARE_MACRO(Smlsl2(v0.TA, v1.TB, v2.TB), \
5160                 "smlsl2 v0." TAS ", v1." TBS ", v2." TBS);
5161   NEON_FORMAT_LIST_LW2(DISASM_INST)
5162 #undef DISASM_INST
5163 
5164 #define DISASM_INST(TA, TAS, TB, TBS)       \
5165   COMPARE_MACRO(Umlsl(v0.TA, v1.TB, v2.TB), \
5166                 "umlsl v0." TAS ", v1." TBS ", v2." TBS);
5167   NEON_FORMAT_LIST_LW(DISASM_INST)
5168 #undef DISASM_INST
5169 
5170 #define DISASM_INST(TA, TAS, TB, TBS)        \
5171   COMPARE_MACRO(Umlsl2(v0.TA, v1.TB, v2.TB), \
5172                 "umlsl2 v0." TAS ", v1." TBS ", v2." TBS);
5173   NEON_FORMAT_LIST_LW2(DISASM_INST)
5174 #undef DISASM_INST
5175 
5176 #define DISASM_INST(TA, TAS, TB, TBS)       \
5177   COMPARE_MACRO(Smull(v0.TA, v1.TB, v2.TB), \
5178                 "smull v0." TAS ", v1." TBS ", v2." TBS);
5179   NEON_FORMAT_LIST_LW(DISASM_INST)
5180 #undef DISASM_INST
5181 
5182 #define DISASM_INST(TA, TAS, TB, TBS)        \
5183   COMPARE_MACRO(Smull2(v0.TA, v1.TB, v2.TB), \
5184                 "smull2 v0." TAS ", v1." TBS ", v2." TBS);
5185   NEON_FORMAT_LIST_LW2(DISASM_INST)
5186 #undef DISASM_INST
5187 
5188 #define DISASM_INST(TA, TAS, TB, TBS)       \
5189   COMPARE_MACRO(Umull(v0.TA, v1.TB, v2.TB), \
5190                 "umull v0." TAS ", v1." TBS ", v2." TBS);
5191   NEON_FORMAT_LIST_LW(DISASM_INST)
5192 #undef DISASM_INST
5193 
5194 #define DISASM_INST(TA, TAS, TB, TBS)        \
5195   COMPARE_MACRO(Umull2(v0.TA, v1.TB, v2.TB), \
5196                 "umull2 v0." TAS ", v1." TBS ", v2." TBS);
5197   NEON_FORMAT_LIST_LW2(DISASM_INST)
5198 #undef DISASM_INST
5199 
5200   COMPARE_MACRO(Sqdmull(v0.V4S(), v1.V4H(), v2.V4H()),
5201                 "sqdmull v0.4s, v1.4h, v2.4h");
5202   COMPARE_MACRO(Sqdmull(v1.V2D(), v2.V2S(), v3.V2S()),
5203                 "sqdmull v1.2d, v2.2s, v3.2s");
5204   COMPARE_MACRO(Sqdmull2(v2.V4S(), v3.V8H(), v4.V8H()),
5205                 "sqdmull2 v2.4s, v3.8h, v4.8h");
5206   COMPARE_MACRO(Sqdmull2(v3.V2D(), v4.V4S(), v5.V4S()),
5207                 "sqdmull2 v3.2d, v4.4s, v5.4s");
5208   COMPARE_MACRO(Sqdmull(s0, h1, h2), "sqdmull s0, h1, h2");
5209   COMPARE_MACRO(Sqdmull(d1, s2, s3), "sqdmull d1, s2, s3");
5210 
5211   COMPARE_MACRO(Sqdmlal(v0.V4S(), v1.V4H(), v2.V4H()),
5212                 "sqdmlal v0.4s, v1.4h, v2.4h");
5213   COMPARE_MACRO(Sqdmlal(v1.V2D(), v2.V2S(), v3.V2S()),
5214                 "sqdmlal v1.2d, v2.2s, v3.2s");
5215   COMPARE_MACRO(Sqdmlal2(v2.V4S(), v3.V8H(), v4.V8H()),
5216                 "sqdmlal2 v2.4s, v3.8h, v4.8h");
5217   COMPARE_MACRO(Sqdmlal2(v3.V2D(), v4.V4S(), v5.V4S()),
5218                 "sqdmlal2 v3.2d, v4.4s, v5.4s");
5219   COMPARE_MACRO(Sqdmlal(s0, h1, h2), "sqdmlal s0, h1, h2");
5220   COMPARE_MACRO(Sqdmlal(d1, s2, s3), "sqdmlal d1, s2, s3");
5221 
5222   COMPARE_MACRO(Sqdmlsl(v0.V4S(), v1.V4H(), v2.V4H()),
5223                 "sqdmlsl v0.4s, v1.4h, v2.4h");
5224   COMPARE_MACRO(Sqdmlsl(v1.V2D(), v2.V2S(), v3.V2S()),
5225                 "sqdmlsl v1.2d, v2.2s, v3.2s");
5226   COMPARE_MACRO(Sqdmlsl2(v2.V4S(), v3.V8H(), v4.V8H()),
5227                 "sqdmlsl2 v2.4s, v3.8h, v4.8h");
5228   COMPARE_MACRO(Sqdmlsl2(v3.V2D(), v4.V4S(), v5.V4S()),
5229                 "sqdmlsl2 v3.2d, v4.4s, v5.4s");
5230   COMPARE_MACRO(Sqdmlsl(s0, h1, h2), "sqdmlsl s0, h1, h2");
5231   COMPARE_MACRO(Sqdmlsl(d1, s2, s3), "sqdmlsl d1, s2, s3");
5232 
5233   COMPARE_MACRO(Addhn(v0.V8B(), v1.V8H(), v2.V8H()),
5234                 "addhn v0.8b, v1.8h, v2.8h");
5235   COMPARE_MACRO(Addhn(v1.V4H(), v2.V4S(), v3.V4S()),
5236                 "addhn v1.4h, v2.4s, v3.4s");
5237   COMPARE_MACRO(Addhn(v2.V2S(), v3.V2D(), v4.V2D()),
5238                 "addhn v2.2s, v3.2d, v4.2d");
5239   COMPARE_MACRO(Addhn2(v0.V16B(), v1.V8H(), v5.V8H()),
5240                 "addhn2 v0.16b, v1.8h, v5.8h");
5241   COMPARE_MACRO(Addhn2(v1.V8H(), v2.V4S(), v6.V4S()),
5242                 "addhn2 v1.8h, v2.4s, v6.4s");
5243   COMPARE_MACRO(Addhn2(v2.V4S(), v3.V2D(), v7.V2D()),
5244                 "addhn2 v2.4s, v3.2d, v7.2d");
5245 
5246   COMPARE_MACRO(Raddhn(v0.V8B(), v1.V8H(), v2.V8H()),
5247                 "raddhn v0.8b, v1.8h, v2.8h");
5248   COMPARE_MACRO(Raddhn(v1.V4H(), v2.V4S(), v3.V4S()),
5249                 "raddhn v1.4h, v2.4s, v3.4s");
5250   COMPARE_MACRO(Raddhn(v2.V2S(), v3.V2D(), v4.V2D()),
5251                 "raddhn v2.2s, v3.2d, v4.2d");
5252   COMPARE_MACRO(Raddhn2(v0.V16B(), v1.V8H(), v5.V8H()),
5253                 "raddhn2 v0.16b, v1.8h, v5.8h");
5254   COMPARE_MACRO(Raddhn2(v1.V8H(), v2.V4S(), v6.V4S()),
5255                 "raddhn2 v1.8h, v2.4s, v6.4s");
5256   COMPARE_MACRO(Raddhn2(v2.V4S(), v3.V2D(), v7.V2D()),
5257                 "raddhn2 v2.4s, v3.2d, v7.2d");
5258 
5259   COMPARE_MACRO(Subhn(v1.V4H(), v2.V4S(), v3.V4S()),
5260                 "subhn v1.4h, v2.4s, v3.4s");
5261   COMPARE_MACRO(Subhn(v2.V2S(), v3.V2D(), v4.V2D()),
5262                 "subhn v2.2s, v3.2d, v4.2d");
5263   COMPARE_MACRO(Subhn2(v0.V16B(), v1.V8H(), v5.V8H()),
5264                 "subhn2 v0.16b, v1.8h, v5.8h");
5265   COMPARE_MACRO(Subhn2(v1.V8H(), v2.V4S(), v6.V4S()),
5266                 "subhn2 v1.8h, v2.4s, v6.4s");
5267   COMPARE_MACRO(Subhn2(v2.V4S(), v3.V2D(), v7.V2D()),
5268                 "subhn2 v2.4s, v3.2d, v7.2d");
5269 
5270   COMPARE_MACRO(Rsubhn(v0.V8B(), v1.V8H(), v2.V8H()),
5271                 "rsubhn v0.8b, v1.8h, v2.8h");
5272   COMPARE_MACRO(Rsubhn(v1.V4H(), v2.V4S(), v3.V4S()),
5273                 "rsubhn v1.4h, v2.4s, v3.4s");
5274   COMPARE_MACRO(Rsubhn(v2.V2S(), v3.V2D(), v4.V2D()),
5275                 "rsubhn v2.2s, v3.2d, v4.2d");
5276   COMPARE_MACRO(Rsubhn2(v0.V16B(), v1.V8H(), v5.V8H()),
5277                 "rsubhn2 v0.16b, v1.8h, v5.8h");
5278   COMPARE_MACRO(Rsubhn2(v1.V8H(), v2.V4S(), v6.V4S()),
5279                 "rsubhn2 v1.8h, v2.4s, v6.4s");
5280   COMPARE_MACRO(Rsubhn2(v2.V4S(), v3.V2D(), v7.V2D()),
5281                 "rsubhn2 v2.4s, v3.2d, v7.2d");
5282 
5283   COMPARE_MACRO(Pmull(v0.V8H(), v1.V8B(), v2.V8B()),
5284                 "pmull v0.8h, v1.8b, v2.8b");
5285   COMPARE_MACRO(Pmull2(v2.V8H(), v3.V16B(), v4.V16B()),
5286                 "pmull2 v2.8h, v3.16b, v4.16b");
5287 
5288   CLEANUP();
5289 }
5290 
5291 
TEST(neon_perm)5292 TEST(neon_perm) {
5293   SETUP();
5294 
5295 #define DISASM_INST(M, S) \
5296   COMPARE_MACRO(Trn1(v0.M, v1.M, v2.M), "trn1 v0." S ", v1." S ", v2." S);
5297   NEON_FORMAT_LIST(DISASM_INST)
5298 #undef DISASM_INST
5299 
5300 #define DISASM_INST(M, S) \
5301   COMPARE_MACRO(Trn2(v0.M, v1.M, v2.M), "trn2 v0." S ", v1." S ", v2." S);
5302   NEON_FORMAT_LIST(DISASM_INST)
5303 #undef DISASM_INST
5304 
5305 #define DISASM_INST(M, S) \
5306   COMPARE_MACRO(Uzp1(v0.M, v1.M, v2.M), "uzp1 v0." S ", v1." S ", v2." S);
5307   NEON_FORMAT_LIST(DISASM_INST)
5308 #undef DISASM_INST
5309 
5310 #define DISASM_INST(M, S) \
5311   COMPARE_MACRO(Uzp2(v0.M, v1.M, v2.M), "uzp2 v0." S ", v1." S ", v2." S);
5312   NEON_FORMAT_LIST(DISASM_INST)
5313 #undef DISASM_INST
5314 
5315 #define DISASM_INST(M, S) \
5316   COMPARE_MACRO(Zip1(v0.M, v1.M, v2.M), "zip1 v0." S ", v1." S ", v2." S);
5317   NEON_FORMAT_LIST(DISASM_INST)
5318 #undef DISASM_INST
5319 
5320 #define DISASM_INST(M, S) \
5321   COMPARE_MACRO(Zip2(v0.M, v1.M, v2.M), "zip2 v0." S ", v1." S ", v2." S);
5322   NEON_FORMAT_LIST(DISASM_INST)
5323 #undef DISASM_INST
5324 
5325   CLEANUP();
5326 }
5327 
5328 
TEST(neon_copy)5329 TEST(neon_copy) {
5330   SETUP();
5331 
5332   COMPARE_MACRO(Ins(v1.V16B(), 4, v5.V16B(), 0), "mov v1.b[4], v5.b[0]");
5333   COMPARE_MACRO(Ins(v2.V8B(), 5, v6.V8B(), 1), "mov v2.b[5], v6.b[1]");
5334   COMPARE_MACRO(Ins(v3.B(), 6, v7.B(), 2), "mov v3.b[6], v7.b[2]");
5335   COMPARE_MACRO(Ins(v4.V8H(), 7, v8.V8H(), 3), "mov v4.h[7], v8.h[3]");
5336   COMPARE_MACRO(Ins(v5.V4H(), 3, v9.V4H(), 0), "mov v5.h[3], v9.h[0]");
5337   COMPARE_MACRO(Ins(v6.H(), 6, v1.H(), 1), "mov v6.h[6], v1.h[1]");
5338   COMPARE_MACRO(Ins(v7.V4S(), 2, v2.V4S(), 2), "mov v7.s[2], v2.s[2]");
5339   COMPARE_MACRO(Ins(v8.V2S(), 1, v3.V2S(), 0), "mov v8.s[1], v3.s[0]");
5340   COMPARE_MACRO(Ins(v9.S(), 0, v4.S(), 1), "mov v9.s[0], v4.s[1]");
5341   COMPARE_MACRO(Ins(v1.V2D(), 1, v5.V2D(), 0), "mov v1.d[1], v5.d[0]");
5342   COMPARE_MACRO(Ins(v2.D(), 0, v6.D(), 1), "mov v2.d[0], v6.d[1]");
5343 
5344   COMPARE_MACRO(Mov(v3.V16B(), 4, v7.V16B(), 0), "mov v3.b[4], v7.b[0]");
5345   COMPARE_MACRO(Mov(v4.V8B(), 5, v8.V8B(), 1), "mov v4.b[5], v8.b[1]");
5346   COMPARE_MACRO(Mov(v5.B(), 6, v9.B(), 2), "mov v5.b[6], v9.b[2]");
5347   COMPARE_MACRO(Mov(v6.V8H(), 7, v1.V8H(), 3), "mov v6.h[7], v1.h[3]");
5348   COMPARE_MACRO(Mov(v7.V4H(), 0, v2.V4H(), 0), "mov v7.h[0], v2.h[0]");
5349   COMPARE_MACRO(Mov(v8.H(), 1, v3.H(), 1), "mov v8.h[1], v3.h[1]");
5350   COMPARE_MACRO(Mov(v9.V4S(), 2, v4.V4S(), 2), "mov v9.s[2], v4.s[2]");
5351   COMPARE_MACRO(Mov(v1.V2S(), 3, v5.V2S(), 0), "mov v1.s[3], v5.s[0]");
5352   COMPARE_MACRO(Mov(v2.S(), 0, v6.S(), 1), "mov v2.s[0], v6.s[1]");
5353   COMPARE_MACRO(Mov(v3.V2D(), 1, v7.V2D(), 0), "mov v3.d[1], v7.d[0]");
5354   COMPARE_MACRO(Mov(v4.D(), 0, v8.D(), 1), "mov v4.d[0], v8.d[1]");
5355 
5356   COMPARE_MACRO(Ins(v1.V16B(), 4, w0), "mov v1.b[4], w0");
5357   COMPARE_MACRO(Ins(v2.V8B(), 5, w1), "mov v2.b[5], w1");
5358   COMPARE_MACRO(Ins(v3.B(), 6, w2), "mov v3.b[6], w2");
5359   COMPARE_MACRO(Ins(v4.V8H(), 7, w3), "mov v4.h[7], w3");
5360   COMPARE_MACRO(Ins(v5.V4H(), 3, w0), "mov v5.h[3], w0");
5361   COMPARE_MACRO(Ins(v6.H(), 6, w1), "mov v6.h[6], w1");
5362   COMPARE_MACRO(Ins(v7.V4S(), 2, w2), "mov v7.s[2], w2");
5363   COMPARE_MACRO(Ins(v8.V2S(), 1, w0), "mov v8.s[1], w0");
5364   COMPARE_MACRO(Ins(v9.S(), 0, w1), "mov v9.s[0], w1");
5365   COMPARE_MACRO(Ins(v1.V2D(), 1, x0), "mov v1.d[1], x0");
5366   COMPARE_MACRO(Ins(v2.D(), 0, x1), "mov v2.d[0], x1");
5367 
5368   COMPARE_MACRO(Mov(v1.V16B(), 4, w0), "mov v1.b[4], w0");
5369   COMPARE_MACRO(Mov(v2.V8B(), 5, w1), "mov v2.b[5], w1");
5370   COMPARE_MACRO(Mov(v3.B(), 6, w2), "mov v3.b[6], w2");
5371   COMPARE_MACRO(Mov(v4.V8H(), 7, w3), "mov v4.h[7], w3");
5372   COMPARE_MACRO(Mov(v5.V4H(), 3, w0), "mov v5.h[3], w0");
5373   COMPARE_MACRO(Mov(v6.H(), 6, w1), "mov v6.h[6], w1");
5374   COMPARE_MACRO(Mov(v7.V4S(), 2, w2), "mov v7.s[2], w2");
5375   COMPARE_MACRO(Mov(v8.V2S(), 1, w0), "mov v8.s[1], w0");
5376   COMPARE_MACRO(Mov(v9.S(), 0, w1), "mov v9.s[0], w1");
5377   COMPARE_MACRO(Mov(v1.V2D(), 1, x0), "mov v1.d[1], x0");
5378   COMPARE_MACRO(Mov(v2.D(), 0, x1), "mov v2.d[0], x1");
5379 
5380   COMPARE_MACRO(Dup(v5.V8B(), v9.V8B(), 6), "dup v5.8b, v9.b[6]");
5381   COMPARE_MACRO(Dup(v6.V16B(), v1.V16B(), 5), "dup v6.16b, v1.b[5]");
5382   COMPARE_MACRO(Dup(v7.V4H(), v2.V4H(), 4), "dup v7.4h, v2.h[4]");
5383   COMPARE_MACRO(Dup(v8.V8H(), v3.V8H(), 3), "dup v8.8h, v3.h[3]");
5384   COMPARE_MACRO(Dup(v9.V2S(), v4.V2S(), 2), "dup v9.2s, v4.s[2]");
5385   COMPARE_MACRO(Dup(v1.V4S(), v5.V4S(), 1), "dup v1.4s, v5.s[1]");
5386   COMPARE_MACRO(Dup(v2.V2D(), v6.V2D(), 0), "dup v2.2d, v6.d[0]");
5387 
5388   COMPARE_MACRO(Dup(v5.B(), v9.B(), 6), "mov b5, v9.b[6]");
5389   COMPARE_MACRO(Dup(v7.H(), v2.H(), 4), "mov h7, v2.h[4]");
5390   COMPARE_MACRO(Dup(v9.S(), v4.S(), 2), "mov s9, v4.s[2]");
5391   COMPARE_MACRO(Dup(v2.D(), v6.D(), 0), "mov d2, v6.d[0]");
5392 
5393   COMPARE_MACRO(Mov(v5.B(), v9.B(), 6), "mov b5, v9.b[6]");
5394   COMPARE_MACRO(Mov(v7.H(), v2.H(), 4), "mov h7, v2.h[4]");
5395   COMPARE_MACRO(Mov(v9.S(), v4.S(), 2), "mov s9, v4.s[2]");
5396   COMPARE_MACRO(Mov(v2.D(), v6.D(), 0), "mov d2, v6.d[0]");
5397 
5398   COMPARE_MACRO(Mov(v0.B(), v1.V8B(), 7), "mov b0, v1.b[7]");
5399   COMPARE_MACRO(Mov(b2, v3.V16B(), 15), "mov b2, v3.b[15]");
5400   COMPARE_MACRO(Mov(v4.H(), v5.V4H(), 3), "mov h4, v5.h[3]");
5401   COMPARE_MACRO(Mov(h6, v7.V8H(), 7), "mov h6, v7.h[7]");
5402   COMPARE_MACRO(Mov(v8.S(), v9.V2S(), 1), "mov s8, v9.s[1]");
5403   COMPARE_MACRO(Mov(s10, v11.V4S(), 3), "mov s10, v11.s[3]");
5404   COMPARE_MACRO(Mov(v12.D(), v13.V2D(), 1), "mov d12, v13.d[1]");
5405 
5406   COMPARE_MACRO(Dup(v5.V8B(), w0), "dup v5.8b, w0");
5407   COMPARE_MACRO(Dup(v6.V16B(), w1), "dup v6.16b, w1");
5408   COMPARE_MACRO(Dup(v7.V4H(), w2), "dup v7.4h, w2");
5409   COMPARE_MACRO(Dup(v8.V8H(), w3), "dup v8.8h, w3");
5410   COMPARE_MACRO(Dup(v9.V2S(), w4), "dup v9.2s, w4");
5411   COMPARE_MACRO(Dup(v1.V4S(), w5), "dup v1.4s, w5");
5412   COMPARE_MACRO(Dup(v2.V2D(), x6), "dup v2.2d, x6");
5413 
5414   COMPARE_MACRO(Smov(w0, v1.V16B(), 4), "smov w0, v1.b[4]");
5415   COMPARE_MACRO(Smov(w1, v2.V8B(), 5), "smov w1, v2.b[5]");
5416   COMPARE_MACRO(Smov(w2, v3.B(), 6), "smov w2, v3.b[6]");
5417   COMPARE_MACRO(Smov(w3, v4.V8H(), 7), "smov w3, v4.h[7]");
5418   COMPARE_MACRO(Smov(w0, v5.V4H(), 3), "smov w0, v5.h[3]");
5419   COMPARE_MACRO(Smov(w1, v6.H(), 6), "smov w1, v6.h[6]");
5420 
5421   COMPARE_MACRO(Smov(x0, v1.V16B(), 4), "smov x0, v1.b[4]");
5422   COMPARE_MACRO(Smov(x1, v2.V8B(), 5), "smov x1, v2.b[5]");
5423   COMPARE_MACRO(Smov(x2, v3.B(), 6), "smov x2, v3.b[6]");
5424   COMPARE_MACRO(Smov(x3, v4.V8H(), 7), "smov x3, v4.h[7]");
5425   COMPARE_MACRO(Smov(x0, v5.V4H(), 3), "smov x0, v5.h[3]");
5426   COMPARE_MACRO(Smov(x1, v6.H(), 6), "smov x1, v6.h[6]");
5427   COMPARE_MACRO(Smov(x2, v7.V4S(), 2), "smov x2, v7.s[2]");
5428   COMPARE_MACRO(Smov(x0, v8.V2S(), 1), "smov x0, v8.s[1]");
5429   COMPARE_MACRO(Smov(x1, v9.S(), 0), "smov x1, v9.s[0]");
5430 
5431   COMPARE_MACRO(Umov(w0, v1.V16B(), 4), "umov w0, v1.b[4]");
5432   COMPARE_MACRO(Umov(w1, v2.V8B(), 5), "umov w1, v2.b[5]");
5433   COMPARE_MACRO(Umov(w2, v3.B(), 6), "umov w2, v3.b[6]");
5434   COMPARE_MACRO(Umov(w3, v4.V8H(), 7), "umov w3, v4.h[7]");
5435   COMPARE_MACRO(Umov(w0, v5.V4H(), 3), "umov w0, v5.h[3]");
5436   COMPARE_MACRO(Umov(w1, v6.H(), 6), "umov w1, v6.h[6]");
5437   COMPARE_MACRO(Umov(w2, v7.V4S(), 2), "mov w2, v7.s[2]");
5438   COMPARE_MACRO(Umov(w0, v8.V2S(), 1), "mov w0, v8.s[1]");
5439   COMPARE_MACRO(Umov(w1, v9.S(), 0), "mov w1, v9.s[0]");
5440   COMPARE_MACRO(Umov(x0, v1.V2D(), 1), "mov x0, v1.d[1]");
5441   COMPARE_MACRO(Umov(x1, v2.D(), 0), "mov x1, v2.d[0]");
5442 
5443   COMPARE_MACRO(Mov(w2, v7.V4S(), 2), "mov w2, v7.s[2]");
5444   COMPARE_MACRO(Mov(w0, v8.V2S(), 1), "mov w0, v8.s[1]");
5445   COMPARE_MACRO(Mov(w1, v9.S(), 0), "mov w1, v9.s[0]");
5446   COMPARE_MACRO(Mov(x0, v1.V2D(), 1), "mov x0, v1.d[1]");
5447   COMPARE_MACRO(Mov(x1, v2.D(), 0), "mov x1, v2.d[0]");
5448 
5449   CLEANUP();
5450 }
5451 
5452 
TEST(neon_table)5453 TEST(neon_table) {
5454   SETUP();
5455 
5456   COMPARE_MACRO(Tbl(v0.V8B(), v1.V16B(), v2.V8B()),
5457                 "tbl v0.8b, {v1.16b}, v2.8b");
5458   COMPARE_MACRO(Tbl(v3.V8B(), v4.V16B(), v5.V16B(), v6.V8B()),
5459                 "tbl v3.8b, {v4.16b, v5.16b}, v6.8b");
5460   COMPARE_MACRO(Tbl(v7.V8B(), v8.V16B(), v9.V16B(), v10.V16B(), v11.V8B()),
5461                 "tbl v7.8b, {v8.16b, v9.16b, v10.16b}, v11.8b");
5462   COMPARE_MACRO(Tbl(v12.V8B(),
5463                     v13.V16B(),
5464                     v14.V16B(),
5465                     v15.V16B(),
5466                     v16.V16B(),
5467                     v17.V8B()),
5468                 "tbl v12.8b, {v13.16b, v14.16b, v15.16b, v16.16b}, v17.8b");
5469   COMPARE_MACRO(Tbl(v18.V16B(), v19.V16B(), v20.V16B()),
5470                 "tbl v18.16b, {v19.16b}, v20.16b");
5471   COMPARE_MACRO(Tbl(v21.V16B(), v22.V16B(), v23.V16B(), v24.V16B()),
5472                 "tbl v21.16b, {v22.16b, v23.16b}, v24.16b");
5473   COMPARE_MACRO(Tbl(v25.V16B(), v26.V16B(), v27.V16B(), v28.V16B(), v29.V16B()),
5474                 "tbl v25.16b, {v26.16b, v27.16b, v28.16b}, v29.16b");
5475   COMPARE_MACRO(Tbl(v30.V16B(),
5476                     v31.V16B(),
5477                     v0.V16B(),
5478                     v1.V16B(),
5479                     v2.V16B(),
5480                     v3.V16B()),
5481                 "tbl v30.16b, {v31.16b, v0.16b, v1.16b, v2.16b}, v3.16b");
5482 
5483   COMPARE_MACRO(Tbx(v0.V8B(), v1.V16B(), v2.V8B()),
5484                 "tbx v0.8b, {v1.16b}, v2.8b");
5485   COMPARE_MACRO(Tbx(v3.V8B(), v4.V16B(), v5.V16B(), v6.V8B()),
5486                 "tbx v3.8b, {v4.16b, v5.16b}, v6.8b");
5487   COMPARE_MACRO(Tbx(v7.V8B(), v8.V16B(), v9.V16B(), v10.V16B(), v11.V8B()),
5488                 "tbx v7.8b, {v8.16b, v9.16b, v10.16b}, v11.8b");
5489   COMPARE_MACRO(Tbx(v12.V8B(),
5490                     v13.V16B(),
5491                     v14.V16B(),
5492                     v15.V16B(),
5493                     v16.V16B(),
5494                     v17.V8B()),
5495                 "tbx v12.8b, {v13.16b, v14.16b, v15.16b, v16.16b}, v17.8b");
5496   COMPARE_MACRO(Tbx(v18.V16B(), v19.V16B(), v20.V16B()),
5497                 "tbx v18.16b, {v19.16b}, v20.16b");
5498   COMPARE_MACRO(Tbx(v21.V16B(), v22.V16B(), v23.V16B(), v24.V16B()),
5499                 "tbx v21.16b, {v22.16b, v23.16b}, v24.16b");
5500   COMPARE_MACRO(Tbx(v25.V16B(), v26.V16B(), v27.V16B(), v28.V16B(), v29.V16B()),
5501                 "tbx v25.16b, {v26.16b, v27.16b, v28.16b}, v29.16b");
5502   COMPARE_MACRO(Tbx(v30.V16B(),
5503                     v31.V16B(),
5504                     v0.V16B(),
5505                     v1.V16B(),
5506                     v2.V16B(),
5507                     v3.V16B()),
5508                 "tbx v30.16b, {v31.16b, v0.16b, v1.16b, v2.16b}, v3.16b");
5509 
5510   CLEANUP();
5511 }
5512 
5513 
TEST(neon_extract)5514 TEST(neon_extract) {
5515   SETUP();
5516 
5517   COMPARE_MACRO(Ext(v4.V8B(), v5.V8B(), v6.V8B(), 0),
5518                 "ext v4.8b, v5.8b, v6.8b, #0");
5519   COMPARE_MACRO(Ext(v1.V8B(), v2.V8B(), v3.V8B(), 7),
5520                 "ext v1.8b, v2.8b, v3.8b, #7");
5521   COMPARE_MACRO(Ext(v1.V16B(), v2.V16B(), v3.V16B(), 0),
5522                 "ext v1.16b, v2.16b, v3.16b, #0");
5523   COMPARE_MACRO(Ext(v1.V16B(), v2.V16B(), v3.V16B(), 15),
5524                 "ext v1.16b, v2.16b, v3.16b, #15");
5525 
5526   CLEANUP();
5527 }
5528 
5529 
TEST(neon_modimm)5530 TEST(neon_modimm) {
5531   SETUP();
5532 
5533   COMPARE_MACRO(Orr(v4.V4H(), 0xaa, 0), "orr v4.4h, #0xaa, lsl #0");
5534   COMPARE_MACRO(Orr(v1.V8H(), 0xcc, 8), "orr v1.8h, #0xcc, lsl #8");
5535   COMPARE_MACRO(Orr(v4.V2S(), 0xaa, 0), "orr v4.2s, #0xaa, lsl #0");
5536   COMPARE_MACRO(Orr(v1.V2S(), 0xcc, 8), "orr v1.2s, #0xcc, lsl #8");
5537   COMPARE_MACRO(Orr(v4.V4S(), 0xaa, 16), "orr v4.4s, #0xaa, lsl #16");
5538   COMPARE_MACRO(Orr(v1.V4S(), 0xcc, 24), "orr v1.4s, #0xcc, lsl #24");
5539 
5540   COMPARE_MACRO(Bic(v4.V4H(), 0xaa, 0), "bic v4.4h, #0xaa, lsl #0");
5541   COMPARE_MACRO(Bic(v1.V8H(), 0xcc, 8), "bic v1.8h, #0xcc, lsl #8");
5542   COMPARE_MACRO(Bic(v4.V2S(), 0xaa, 0), "bic v4.2s, #0xaa, lsl #0");
5543   COMPARE_MACRO(Bic(v1.V2S(), 0xcc, 8), "bic v1.2s, #0xcc, lsl #8");
5544   COMPARE_MACRO(Bic(v4.V4S(), 0xaa, 16), "bic v4.4s, #0xaa, lsl #16");
5545   COMPARE_MACRO(Bic(v1.V4S(), 0xcc, 24), "bic v1.4s, #0xcc, lsl #24");
5546 
5547   COMPARE_MACRO(Mvni(v4.V4H(), 0xaa, LSL, 0), "mvni v4.4h, #0xaa, lsl #0");
5548   COMPARE_MACRO(Mvni(v1.V8H(), 0xcc, LSL, 8), "mvni v1.8h, #0xcc, lsl #8");
5549   COMPARE_MACRO(Mvni(v4.V2S(), 0xaa, LSL, 0), "mvni v4.2s, #0xaa, lsl #0");
5550   COMPARE_MACRO(Mvni(v1.V2S(), 0xcc, LSL, 8), "mvni v1.2s, #0xcc, lsl #8");
5551   COMPARE_MACRO(Mvni(v4.V4S(), 0xaa, LSL, 16), "mvni v4.4s, #0xaa, lsl #16");
5552   COMPARE_MACRO(Mvni(v1.V4S(), 0xcc, LSL, 24), "mvni v1.4s, #0xcc, lsl #24");
5553 
5554   COMPARE_MACRO(Mvni(v4.V2S(), 0xaa, MSL, 8), "mvni v4.2s, #0xaa, msl #8");
5555   COMPARE_MACRO(Mvni(v1.V2S(), 0xcc, MSL, 16), "mvni v1.2s, #0xcc, msl #16");
5556   COMPARE_MACRO(Mvni(v4.V4S(), 0xaa, MSL, 8), "mvni v4.4s, #0xaa, msl #8");
5557   COMPARE_MACRO(Mvni(v1.V4S(), 0xcc, MSL, 16), "mvni v1.4s, #0xcc, msl #16");
5558 
5559   COMPARE_MACRO(Movi(v4.V8B(), 0xaa), "movi v4.8b, #0xaa");
5560   COMPARE_MACRO(Movi(v1.V16B(), 0xcc), "movi v1.16b, #0xcc");
5561 
5562   COMPARE_MACRO(Movi(v4.V4H(), 0xaa, LSL, 0), "movi v4.4h, #0xaa, lsl #0");
5563   COMPARE_MACRO(Movi(v1.V8H(), 0xcc, LSL, 8), "movi v1.8h, #0xcc, lsl #8");
5564 
5565   COMPARE_MACRO(Movi(v4.V2S(), 0xaa, LSL, 0), "movi v4.2s, #0xaa, lsl #0");
5566   COMPARE_MACRO(Movi(v1.V2S(), 0xcc, LSL, 8), "movi v1.2s, #0xcc, lsl #8");
5567   COMPARE_MACRO(Movi(v4.V4S(), 0xaa, LSL, 16), "movi v4.4s, #0xaa, lsl #16");
5568   COMPARE_MACRO(Movi(v1.V4S(), 0xcc, LSL, 24), "movi v1.4s, #0xcc, lsl #24");
5569 
5570   COMPARE_MACRO(Movi(v4.V2S(), 0xaa, MSL, 8), "movi v4.2s, #0xaa, msl #8");
5571   COMPARE_MACRO(Movi(v1.V2S(), 0xcc, MSL, 16), "movi v1.2s, #0xcc, msl #16");
5572   COMPARE_MACRO(Movi(v4.V4S(), 0xaa, MSL, 8), "movi v4.4s, #0xaa, msl #8");
5573   COMPARE_MACRO(Movi(v1.V4S(), 0xcc, MSL, 16), "movi v1.4s, #0xcc, msl #16");
5574 
5575   COMPARE_MACRO(Movi(d2, 0xffff0000ffffff), "movi d2, #0xffff0000ffffff");
5576   COMPARE_MACRO(Movi(v1.V2D(), 0xffff0000ffffff),
5577                 "movi v1.2d, #0xffff0000ffffff");
5578 
5579   COMPARE_MACRO(Fmov(v0.V2S(), 1.0f), "fmov v0.2s, #0x70 (1.0000)");
5580   COMPARE_MACRO(Fmov(v31.V2S(), -13.0f), "fmov v31.2s, #0xaa (-13.0000)");
5581   COMPARE_MACRO(Fmov(v0.V4S(), 1.0f), "fmov v0.4s, #0x70 (1.0000)");
5582   COMPARE_MACRO(Fmov(v31.V4S(), -13.0f), "fmov v31.4s, #0xaa (-13.0000)");
5583   COMPARE_MACRO(Fmov(v1.V2D(), 1.0), "fmov v1.2d, #0x70 (1.0000)");
5584   COMPARE_MACRO(Fmov(v29.V2D(), -13.0), "fmov v29.2d, #0xaa (-13.0000)");
5585 
5586   // An unallocated form of fmov.
5587   COMPARE(dci(0x2f07ffff), "unallocated (NEONModifiedImmediate)");
5588 
5589   CLEANUP();
5590 }
5591 
5592 
TEST(neon_2regmisc)5593 TEST(neon_2regmisc) {
5594   SETUP();
5595 
5596   COMPARE_MACRO(Shll(v1.V8H(), v8.V8B(), 8), "shll v1.8h, v8.8b, #8");
5597   COMPARE_MACRO(Shll(v3.V4S(), v1.V4H(), 16), "shll v3.4s, v1.4h, #16");
5598   COMPARE_MACRO(Shll(v5.V2D(), v3.V2S(), 32), "shll v5.2d, v3.2s, #32");
5599   COMPARE_MACRO(Shll2(v2.V8H(), v9.V16B(), 8), "shll2 v2.8h, v9.16b, #8");
5600   COMPARE_MACRO(Shll2(v4.V4S(), v2.V8H(), 16), "shll2 v4.4s, v2.8h, #16");
5601   COMPARE_MACRO(Shll2(v6.V2D(), v4.V4S(), 32), "shll2 v6.2d, v4.4s, #32");
5602 
5603   // An unallocated form of shll.
5604   COMPARE(dci(0x2ee13bff), "unallocated (NEON2RegMisc)");
5605   // An unallocated form of shll2.
5606   COMPARE(dci(0x6ee13bff), "unallocated (NEON2RegMisc)");
5607 
5608 #define DISASM_INST(M, S) \
5609   COMPARE_MACRO(Cmeq(v0.M, v1.M, 0), "cmeq v0." S ", v1." S ", #0");
5610   NEON_FORMAT_LIST(DISASM_INST)
5611 #undef DISASM_INST
5612 
5613 #define DISASM_INST(M, S) \
5614   COMPARE_MACRO(Cmge(v0.M, v1.M, 0), "cmge v0." S ", v1." S ", #0");
5615   NEON_FORMAT_LIST(DISASM_INST)
5616 #undef DISASM_INST
5617 
5618 #define DISASM_INST(M, S) \
5619   COMPARE_MACRO(Cmgt(v0.M, v1.M, 0), "cmgt v0." S ", v1." S ", #0");
5620   NEON_FORMAT_LIST(DISASM_INST)
5621 #undef DISASM_INST
5622 
5623 #define DISASM_INST(M, S) \
5624   COMPARE_MACRO(Cmle(v0.M, v1.M, 0), "cmle v0." S ", v1." S ", #0");
5625   NEON_FORMAT_LIST(DISASM_INST)
5626 #undef DISASM_INST
5627 
5628 #define DISASM_INST(M, S) \
5629   COMPARE_MACRO(Cmlt(v0.M, v1.M, 0), "cmlt v0." S ", v1." S ", #0");
5630   NEON_FORMAT_LIST(DISASM_INST)
5631 #undef DISASM_INST
5632 
5633   COMPARE_MACRO(Cmeq(v0.D(), v1.D(), 0), "cmeq d0, d1, #0");
5634   COMPARE_MACRO(Cmge(v3.D(), v4.D(), 0), "cmge d3, d4, #0");
5635   COMPARE_MACRO(Cmgt(v6.D(), v7.D(), 0), "cmgt d6, d7, #0");
5636   COMPARE_MACRO(Cmle(v0.D(), v1.D(), 0), "cmle d0, d1, #0");
5637   COMPARE_MACRO(Cmlt(v3.D(), v4.D(), 0), "cmlt d3, d4, #0");
5638 
5639 #define DISASM_INST(M, S) \
5640   COMPARE_MACRO(Fcmeq(v0.M, v1.M, 0), "fcmeq v0." S ", v1." S ", #0.0");
5641   NEON_FORMAT_LIST_FP(DISASM_INST)
5642 #undef DISASM_INST
5643 
5644   COMPARE_MACRO(Fcmeq(v0.S(), v1.S(), 0),
5645                 "fcmeq s0, s1, "
5646                 "#0.0");
5647   COMPARE_MACRO(Fcmeq(v0.D(), v1.D(), 0),
5648                 "fcmeq d0, d1, "
5649                 "#0.0");
5650 
5651 #define DISASM_INST(M, S) \
5652   COMPARE_MACRO(Fcmge(v0.M, v1.M, 0), "fcmge v0." S ", v1." S ", #0.0");
5653   NEON_FORMAT_LIST_FP(DISASM_INST)
5654 #undef DISASM_INST
5655 
5656   COMPARE_MACRO(Fcmge(v0.S(), v1.S(), 0),
5657                 "fcmge s0, s1, "
5658                 "#0.0");
5659   COMPARE_MACRO(Fcmge(v0.D(), v1.D(), 0),
5660                 "fcmge d0, d1, "
5661                 "#0.0");
5662 
5663 #define DISASM_INST(M, S) \
5664   COMPARE_MACRO(Fcmgt(v0.M, v1.M, 0), "fcmgt v0." S ", v1." S ", #0.0");
5665   NEON_FORMAT_LIST_FP(DISASM_INST)
5666 #undef DISASM_INST
5667 
5668   COMPARE_MACRO(Fcmgt(v0.S(), v1.S(), 0),
5669                 "fcmgt s0, s1, "
5670                 "#0.0");
5671   COMPARE_MACRO(Fcmgt(v0.D(), v1.D(), 0),
5672                 "fcmgt d0, d1, "
5673                 "#0.0");
5674 
5675 #define DISASM_INST(M, S) \
5676   COMPARE_MACRO(Fcmle(v0.M, v1.M, 0), "fcmle v0." S ", v1." S ", #0.0");
5677   NEON_FORMAT_LIST_FP(DISASM_INST)
5678 #undef DISASM_INST
5679 
5680   COMPARE_MACRO(Fcmle(v0.S(), v1.S(), 0),
5681                 "fcmle s0, s1, "
5682                 "#0.0");
5683   COMPARE_MACRO(Fcmle(v0.D(), v1.D(), 0),
5684                 "fcmle d0, d1, "
5685                 "#0.0");
5686 
5687 #define DISASM_INST(M, S) \
5688   COMPARE_MACRO(Fcmlt(v0.M, v1.M, 0), "fcmlt v0." S ", v1." S ", #0.0");
5689   NEON_FORMAT_LIST_FP(DISASM_INST)
5690 #undef DISASM_INST
5691 
5692   COMPARE_MACRO(Fcmlt(v0.S(), v1.S(), 0),
5693                 "fcmlt s0, s1, "
5694                 "#0.0");
5695   COMPARE_MACRO(Fcmlt(v0.D(), v1.D(), 0),
5696                 "fcmlt d0, d1, "
5697                 "#0.0");
5698 
5699 #define DISASM_INST(M, S) COMPARE_MACRO(Neg(v0.M, v1.M), "neg v0." S ", v1." S);
5700   NEON_FORMAT_LIST(DISASM_INST)
5701 #undef DISASM_INST
5702 
5703   COMPARE_MACRO(Neg(v0.D(), v1.D()), "neg d0, d1");
5704 
5705 #define DISASM_INST(M, S) \
5706   COMPARE_MACRO(Sqneg(v0.M, v1.M), "sqneg v0." S ", v1." S);
5707   NEON_FORMAT_LIST(DISASM_INST)
5708 #undef DISASM_INST
5709 
5710   COMPARE_MACRO(Sqneg(b0, b1), "sqneg b0, b1");
5711   COMPARE_MACRO(Sqneg(h1, h2), "sqneg h1, h2");
5712   COMPARE_MACRO(Sqneg(s2, s3), "sqneg s2, s3");
5713   COMPARE_MACRO(Sqneg(d3, d4), "sqneg d3, d4");
5714 
5715 #define DISASM_INST(M, S) COMPARE_MACRO(Abs(v0.M, v1.M), "abs v0." S ", v1." S);
5716   NEON_FORMAT_LIST(DISASM_INST)
5717 #undef DISASM_INST
5718 
5719   COMPARE_MACRO(Abs(v0.D(), v1.D()), "abs d0, d1");
5720 
5721 #define DISASM_INST(M, S) \
5722   COMPARE_MACRO(Sqabs(v0.M, v1.M), "sqabs v0." S ", v1." S);
5723   NEON_FORMAT_LIST(DISASM_INST)
5724 #undef DISASM_INST
5725 
5726   COMPARE_MACRO(Sqabs(b0, b1), "sqabs b0, b1");
5727   COMPARE_MACRO(Sqabs(h1, h2), "sqabs h1, h2");
5728   COMPARE_MACRO(Sqabs(s2, s3), "sqabs s2, s3");
5729   COMPARE_MACRO(Sqabs(d3, d4), "sqabs d3, d4");
5730 
5731 #define DISASM_INST(M, S) \
5732   COMPARE_MACRO(Suqadd(v0.M, v1.M), "suqadd v0." S ", v1." S);
5733   NEON_FORMAT_LIST(DISASM_INST)
5734 #undef DISASM_INST
5735 
5736   COMPARE_MACRO(Suqadd(b0, b1), "suqadd b0, b1");
5737   COMPARE_MACRO(Suqadd(h1, h2), "suqadd h1, h2");
5738   COMPARE_MACRO(Suqadd(s2, s3), "suqadd s2, s3");
5739   COMPARE_MACRO(Suqadd(d3, d4), "suqadd d3, d4");
5740 
5741 #define DISASM_INST(M, S) \
5742   COMPARE_MACRO(Usqadd(v0.M, v1.M), "usqadd v0." S ", v1." S);
5743   NEON_FORMAT_LIST(DISASM_INST)
5744 #undef DISASM_INST
5745 
5746   COMPARE_MACRO(Usqadd(b0, b1), "usqadd b0, b1");
5747   COMPARE_MACRO(Usqadd(h1, h2), "usqadd h1, h2");
5748   COMPARE_MACRO(Usqadd(s2, s3), "usqadd s2, s3");
5749   COMPARE_MACRO(Usqadd(d3, d4), "usqadd d3, d4");
5750 
5751   COMPARE_MACRO(Xtn(v0.V8B(), v1.V8H()),
5752                 "xtn v0.8b, "
5753                 "v1.8h");
5754   COMPARE_MACRO(Xtn(v1.V4H(), v2.V4S()),
5755                 "xtn v1.4h, "
5756                 "v2.4s");
5757   COMPARE_MACRO(Xtn(v2.V2S(), v3.V2D()),
5758                 "xtn v2.2s, "
5759                 "v3.2d");
5760   COMPARE_MACRO(Xtn2(v0.V16B(), v1.V8H()),
5761                 "xtn2 v0.16b, "
5762                 "v1.8h");
5763   COMPARE_MACRO(Xtn2(v1.V8H(), v2.V4S()),
5764                 "xtn2 v1.8h, "
5765                 "v2.4s");
5766   COMPARE_MACRO(Xtn2(v2.V4S(), v3.V2D()),
5767                 "xtn2 v2.4s, "
5768                 "v3.2d");
5769 
5770   COMPARE_MACRO(Sqxtn(v0.V8B(), v1.V8H()),
5771                 "sqxtn v0.8b, "
5772                 "v1.8h");
5773   COMPARE_MACRO(Sqxtn(v1.V4H(), v2.V4S()),
5774                 "sqxtn v1.4h, "
5775                 "v2.4s");
5776   COMPARE_MACRO(Sqxtn(v2.V2S(), v3.V2D()),
5777                 "sqxtn v2.2s, "
5778                 "v3.2d");
5779   COMPARE_MACRO(Sqxtn2(v0.V16B(), v1.V8H()),
5780                 "sqxtn2 v0.16b, "
5781                 "v1.8h");
5782   COMPARE_MACRO(Sqxtn2(v1.V8H(), v2.V4S()),
5783                 "sqxtn2 v1.8h, "
5784                 "v2.4s");
5785   COMPARE_MACRO(Sqxtn2(v2.V4S(), v3.V2D()),
5786                 "sqxtn2 v2.4s, "
5787                 "v3.2d");
5788   COMPARE_MACRO(Sqxtn(b19, h0), "sqxtn b19, h0");
5789   COMPARE_MACRO(Sqxtn(h20, s0), "sqxtn h20, s0");
5790   COMPARE_MACRO(Sqxtn(s21, d0), "sqxtn s21, d0");
5791 
5792   COMPARE_MACRO(Uqxtn(v0.V8B(), v1.V8H()),
5793                 "uqxtn v0.8b, "
5794                 "v1.8h");
5795   COMPARE_MACRO(Uqxtn(v1.V4H(), v2.V4S()),
5796                 "uqxtn v1.4h, "
5797                 "v2.4s");
5798   COMPARE_MACRO(Uqxtn(v2.V2S(), v3.V2D()),
5799                 "uqxtn v2.2s, "
5800                 "v3.2d");
5801   COMPARE_MACRO(Uqxtn2(v0.V16B(), v1.V8H()),
5802                 "uqxtn2 v0.16b, "
5803                 "v1.8h");
5804   COMPARE_MACRO(Uqxtn2(v1.V8H(), v2.V4S()),
5805                 "uqxtn2 v1.8h, "
5806                 "v2.4s");
5807   COMPARE_MACRO(Uqxtn2(v2.V4S(), v3.V2D()),
5808                 "uqxtn2 v2.4s, "
5809                 "v3.2d");
5810   COMPARE_MACRO(Uqxtn(b19, h0), "uqxtn b19, h0");
5811   COMPARE_MACRO(Uqxtn(h20, s0), "uqxtn h20, s0");
5812   COMPARE_MACRO(Uqxtn(s21, d0), "uqxtn s21, d0");
5813 
5814   COMPARE_MACRO(Sqxtun(v0.V8B(), v1.V8H()),
5815                 "sqxtun v0.8b, "
5816                 "v1.8h");
5817   COMPARE_MACRO(Sqxtun(v1.V4H(), v2.V4S()),
5818                 "sqxtun v1.4h, "
5819                 "v2.4s");
5820   COMPARE_MACRO(Sqxtun(v2.V2S(), v3.V2D()),
5821                 "sqxtun v2.2s, "
5822                 "v3.2d");
5823   COMPARE_MACRO(Sqxtun2(v0.V16B(), v1.V8H()),
5824                 "sqxtun2 v0.16b, "
5825                 "v1.8h");
5826   COMPARE_MACRO(Sqxtun2(v1.V8H(), v2.V4S()),
5827                 "sqxtun2 v1.8h, "
5828                 "v2.4s");
5829   COMPARE_MACRO(Sqxtun2(v2.V4S(), v3.V2D()),
5830                 "sqxtun2 v2.4s, "
5831                 "v3.2d");
5832   COMPARE_MACRO(Sqxtun(b19, h0), "sqxtun b19, h0");
5833   COMPARE_MACRO(Sqxtun(h20, s0), "sqxtun h20, s0");
5834   COMPARE_MACRO(Sqxtun(s21, d0), "sqxtun s21, d0");
5835 
5836   COMPARE_MACRO(Cls(v1.V8B(), v8.V8B()),
5837                 "cls v1.8b, "
5838                 "v8.8b");
5839   COMPARE_MACRO(Cls(v2.V16B(), v9.V16B()),
5840                 "cls v2.16b, "
5841                 "v9.16b");
5842   COMPARE_MACRO(Cls(v3.V4H(), v1.V4H()),
5843                 "cls v3.4h, "
5844                 "v1.4h");
5845   COMPARE_MACRO(Cls(v4.V8H(), v2.V8H()),
5846                 "cls v4.8h, "
5847                 "v2.8h");
5848   COMPARE_MACRO(Cls(v5.V2S(), v3.V2S()),
5849                 "cls v5.2s, "
5850                 "v3.2s");
5851   COMPARE_MACRO(Cls(v6.V4S(), v4.V4S()),
5852                 "cls v6.4s, "
5853                 "v4.4s");
5854 
5855   COMPARE_MACRO(Clz(v1.V8B(), v8.V8B()),
5856                 "clz v1.8b, "
5857                 "v8.8b");
5858   COMPARE_MACRO(Clz(v2.V16B(), v9.V16B()),
5859                 "clz v2.16b, "
5860                 "v9.16b");
5861   COMPARE_MACRO(Clz(v3.V4H(), v1.V4H()),
5862                 "clz v3.4h, "
5863                 "v1.4h");
5864   COMPARE_MACRO(Clz(v4.V8H(), v2.V8H()),
5865                 "clz v4.8h, "
5866                 "v2.8h");
5867   COMPARE_MACRO(Clz(v5.V2S(), v3.V2S()),
5868                 "clz v5.2s, "
5869                 "v3.2s");
5870   COMPARE_MACRO(Clz(v6.V4S(), v4.V4S()),
5871                 "clz v6.4s, "
5872                 "v4.4s");
5873 
5874   COMPARE_MACRO(Cnt(v1.V8B(), v8.V8B()),
5875                 "cnt v1.8b, "
5876                 "v8.8b");
5877   COMPARE_MACRO(Cnt(v2.V16B(), v9.V16B()),
5878                 "cnt v2.16b, "
5879                 "v9.16b");
5880 
5881   COMPARE_MACRO(Mvn(v4.V8B(), v5.V8B()),
5882                 "mvn v4.8b, "
5883                 "v5.8b");
5884   COMPARE_MACRO(Mvn(v4.V16B(), v5.V16B()),
5885                 "mvn v4.16b, "
5886                 "v5.16b");
5887 
5888   COMPARE_MACRO(Not(v4.V8B(), v5.V8B()),
5889                 "mvn v4.8b, "
5890                 "v5.8b");
5891   COMPARE_MACRO(Not(v4.V16B(), v5.V16B()),
5892                 "mvn v4.16b, "
5893                 "v5.16b");
5894 
5895   COMPARE_MACRO(Rev64(v1.V8B(), v8.V8B()),
5896                 "rev64 v1.8b, "
5897                 "v8.8b");
5898   COMPARE_MACRO(Rev64(v2.V16B(), v9.V16B()),
5899                 "rev64 v2.16b, "
5900                 "v9.16b");
5901   COMPARE_MACRO(Rev64(v3.V4H(), v1.V4H()),
5902                 "rev64 v3.4h, "
5903                 "v1.4h");
5904   COMPARE_MACRO(Rev64(v4.V8H(), v2.V8H()),
5905                 "rev64 v4.8h, "
5906                 "v2.8h");
5907   COMPARE_MACRO(Rev64(v5.V2S(), v3.V2S()),
5908                 "rev64 v5.2s, "
5909                 "v3.2s");
5910   COMPARE_MACRO(Rev64(v6.V4S(), v4.V4S()),
5911                 "rev64 v6.4s, "
5912                 "v4.4s");
5913 
5914   COMPARE_MACRO(Rev32(v1.V8B(), v8.V8B()),
5915                 "rev32 v1.8b, "
5916                 "v8.8b");
5917   COMPARE_MACRO(Rev32(v2.V16B(), v9.V16B()),
5918                 "rev32 v2.16b, "
5919                 "v9.16b");
5920   COMPARE_MACRO(Rev32(v3.V4H(), v1.V4H()),
5921                 "rev32 v3.4h, "
5922                 "v1.4h");
5923   COMPARE_MACRO(Rev32(v4.V8H(), v2.V8H()),
5924                 "rev32 v4.8h, "
5925                 "v2.8h");
5926 
5927   COMPARE_MACRO(Rev16(v1.V8B(), v8.V8B()),
5928                 "rev16 v1.8b, "
5929                 "v8.8b");
5930   COMPARE_MACRO(Rev16(v2.V16B(), v9.V16B()),
5931                 "rev16 v2.16b, "
5932                 "v9.16b");
5933 
5934   COMPARE_MACRO(Rbit(v1.V8B(), v8.V8B()),
5935                 "rbit v1.8b, "
5936                 "v8.8b");
5937   COMPARE_MACRO(Rbit(v2.V16B(), v9.V16B()),
5938                 "rbit v2.16b, "
5939                 "v9.16b");
5940 
5941   COMPARE_MACRO(Ursqrte(v2.V2S(), v9.V2S()),
5942                 "ursqrte v2.2s, "
5943                 "v9.2s");
5944   COMPARE_MACRO(Ursqrte(v16.V4S(), v23.V4S()),
5945                 "ursqrte v16.4s, "
5946                 "v23.4s");
5947 
5948   COMPARE_MACRO(Urecpe(v2.V2S(), v9.V2S()),
5949                 "urecpe v2.2s, "
5950                 "v9.2s");
5951   COMPARE_MACRO(Urecpe(v16.V4S(), v23.V4S()),
5952                 "urecpe v16.4s, "
5953                 "v23.4s");
5954 
5955   COMPARE_MACRO(Frsqrte(v2.V2S(), v9.V2S()),
5956                 "frsqrte v2.2s, "
5957                 "v9.2s");
5958   COMPARE_MACRO(Frsqrte(v16.V4S(), v23.V4S()),
5959                 "frsqrte v16.4s, "
5960                 "v23.4s");
5961   COMPARE_MACRO(Frsqrte(v2.V2D(), v9.V2D()),
5962                 "frsqrte v2.2d, "
5963                 "v9.2d");
5964   COMPARE_MACRO(Frsqrte(v0.S(), v1.S()), "frsqrte s0, s1");
5965   COMPARE_MACRO(Frsqrte(v0.D(), v1.D()), "frsqrte d0, d1");
5966 
5967   COMPARE_MACRO(Frecpe(v2.V2S(), v9.V2S()),
5968                 "frecpe v2.2s, "
5969                 "v9.2s");
5970   COMPARE_MACRO(Frecpe(v16.V4S(), v23.V4S()),
5971                 "frecpe v16.4s, "
5972                 "v23.4s");
5973   COMPARE_MACRO(Frecpe(v2.V2D(), v9.V2D()),
5974                 "frecpe v2.2d, "
5975                 "v9.2d");
5976   COMPARE_MACRO(Frecpe(v0.S(), v1.S()), "frecpe s0, s1");
5977   COMPARE_MACRO(Frecpe(v0.D(), v1.D()), "frecpe d0, d1");
5978 
5979   COMPARE_MACRO(Fabs(v2.V2S(), v9.V2S()),
5980                 "fabs v2.2s, "
5981                 "v9.2s");
5982   COMPARE_MACRO(Fabs(v16.V4S(), v23.V4S()),
5983                 "fabs v16.4s, "
5984                 "v23.4s");
5985   COMPARE_MACRO(Fabs(v31.V2D(), v30.V2D()),
5986                 "fabs v31.2d, "
5987                 "v30.2d");
5988 
5989   COMPARE_MACRO(Fneg(v2.V2S(), v9.V2S()),
5990                 "fneg v2.2s, "
5991                 "v9.2s");
5992   COMPARE_MACRO(Fneg(v16.V4S(), v23.V4S()),
5993                 "fneg v16.4s, "
5994                 "v23.4s");
5995   COMPARE_MACRO(Fneg(v31.V2D(), v30.V2D()),
5996                 "fneg v31.2d, "
5997                 "v30.2d");
5998 
5999   COMPARE_MACRO(Frintn(v2.V2S(), v9.V2S()),
6000                 "frintn v2.2s, "
6001                 "v9.2s");
6002   COMPARE_MACRO(Frintn(v16.V4S(), v23.V4S()),
6003                 "frintn v16.4s, "
6004                 "v23.4s");
6005   COMPARE_MACRO(Frintn(v31.V2D(), v30.V2D()),
6006                 "frintn v31.2d, "
6007                 "v30.2d");
6008 
6009   COMPARE_MACRO(Frinta(v2.V2S(), v9.V2S()),
6010                 "frinta v2.2s, "
6011                 "v9.2s");
6012   COMPARE_MACRO(Frinta(v16.V4S(), v23.V4S()),
6013                 "frinta v16.4s, "
6014                 "v23.4s");
6015   COMPARE_MACRO(Frinta(v31.V2D(), v30.V2D()),
6016                 "frinta v31.2d, "
6017                 "v30.2d");
6018 
6019   COMPARE_MACRO(Frintp(v2.V2S(), v9.V2S()),
6020                 "frintp v2.2s, "
6021                 "v9.2s");
6022   COMPARE_MACRO(Frintp(v16.V4S(), v23.V4S()),
6023                 "frintp v16.4s, "
6024                 "v23.4s");
6025   COMPARE_MACRO(Frintp(v31.V2D(), v30.V2D()),
6026                 "frintp v31.2d, "
6027                 "v30.2d");
6028 
6029   COMPARE_MACRO(Frintm(v2.V2S(), v9.V2S()),
6030                 "frintm v2.2s, "
6031                 "v9.2s");
6032   COMPARE_MACRO(Frintm(v16.V4S(), v23.V4S()),
6033                 "frintm v16.4s, "
6034                 "v23.4s");
6035   COMPARE_MACRO(Frintm(v31.V2D(), v30.V2D()),
6036                 "frintm v31.2d, "
6037                 "v30.2d");
6038 
6039   COMPARE_MACRO(Frintx(v2.V2S(), v9.V2S()),
6040                 "frintx v2.2s, "
6041                 "v9.2s");
6042   COMPARE_MACRO(Frintx(v16.V4S(), v23.V4S()),
6043                 "frintx v16.4s, "
6044                 "v23.4s");
6045   COMPARE_MACRO(Frintx(v31.V2D(), v30.V2D()),
6046                 "frintx v31.2d, "
6047                 "v30.2d");
6048 
6049   COMPARE_MACRO(Frintz(v2.V2S(), v9.V2S()),
6050                 "frintz v2.2s, "
6051                 "v9.2s");
6052   COMPARE_MACRO(Frintz(v16.V4S(), v23.V4S()),
6053                 "frintz v16.4s, "
6054                 "v23.4s");
6055   COMPARE_MACRO(Frintz(v31.V2D(), v30.V2D()),
6056                 "frintz v31.2d, "
6057                 "v30.2d");
6058 
6059   COMPARE_MACRO(Frinti(v2.V2S(), v9.V2S()),
6060                 "frinti v2.2s, "
6061                 "v9.2s");
6062   COMPARE_MACRO(Frinti(v16.V4S(), v23.V4S()),
6063                 "frinti v16.4s, "
6064                 "v23.4s");
6065   COMPARE_MACRO(Frinti(v31.V2D(), v30.V2D()),
6066                 "frinti v31.2d, "
6067                 "v30.2d");
6068 
6069   COMPARE_MACRO(Fsqrt(v3.V2S(), v10.V2S()),
6070                 "fsqrt v3.2s, "
6071                 "v10.2s");
6072   COMPARE_MACRO(Fsqrt(v22.V4S(), v11.V4S()),
6073                 "fsqrt v22.4s, "
6074                 "v11.4s");
6075   COMPARE_MACRO(Fsqrt(v31.V2D(), v0.V2D()),
6076                 "fsqrt v31.2d, "
6077                 "v0.2d");
6078 
6079   COMPARE_MACRO(Fcvtns(v4.V2S(), v11.V2S()),
6080                 "fcvtns v4.2s, "
6081                 "v11.2s");
6082   COMPARE_MACRO(Fcvtns(v23.V4S(), v12.V4S()),
6083                 "fcvtns v23.4s, "
6084                 "v12.4s");
6085   COMPARE_MACRO(Fcvtns(v30.V2D(), v1.V2D()),
6086                 "fcvtns v30.2d, "
6087                 "v1.2d");
6088   COMPARE_MACRO(Fcvtnu(v4.V2S(), v11.V2S()),
6089                 "fcvtnu v4.2s, "
6090                 "v11.2s");
6091   COMPARE_MACRO(Fcvtnu(v23.V4S(), v12.V4S()),
6092                 "fcvtnu v23.4s, "
6093                 "v12.4s");
6094   COMPARE_MACRO(Fcvtnu(v30.V2D(), v1.V2D()),
6095                 "fcvtnu v30.2d, "
6096                 "v1.2d");
6097 
6098   COMPARE_MACRO(Fcvtps(v4.V2S(), v11.V2S()),
6099                 "fcvtps v4.2s, "
6100                 "v11.2s");
6101   COMPARE_MACRO(Fcvtps(v23.V4S(), v12.V4S()),
6102                 "fcvtps v23.4s, "
6103                 "v12.4s");
6104   COMPARE_MACRO(Fcvtps(v30.V2D(), v1.V2D()),
6105                 "fcvtps v30.2d, "
6106                 "v1.2d");
6107   COMPARE_MACRO(Fcvtpu(v4.V2S(), v11.V2S()),
6108                 "fcvtpu v4.2s, "
6109                 "v11.2s");
6110   COMPARE_MACRO(Fcvtpu(v23.V4S(), v12.V4S()),
6111                 "fcvtpu v23.4s, "
6112                 "v12.4s");
6113   COMPARE_MACRO(Fcvtpu(v30.V2D(), v1.V2D()),
6114                 "fcvtpu v30.2d, "
6115                 "v1.2d");
6116 
6117   COMPARE_MACRO(Fcvtms(v4.V2S(), v11.V2S()),
6118                 "fcvtms v4.2s, "
6119                 "v11.2s");
6120   COMPARE_MACRO(Fcvtms(v23.V4S(), v12.V4S()),
6121                 "fcvtms v23.4s, "
6122                 "v12.4s");
6123   COMPARE_MACRO(Fcvtms(v30.V2D(), v1.V2D()),
6124                 "fcvtms v30.2d, "
6125                 "v1.2d");
6126   COMPARE_MACRO(Fcvtmu(v4.V2S(), v11.V2S()),
6127                 "fcvtmu v4.2s, "
6128                 "v11.2s");
6129   COMPARE_MACRO(Fcvtmu(v23.V4S(), v12.V4S()),
6130                 "fcvtmu v23.4s, "
6131                 "v12.4s");
6132   COMPARE_MACRO(Fcvtmu(v30.V2D(), v1.V2D()),
6133                 "fcvtmu v30.2d, "
6134                 "v1.2d");
6135 
6136   COMPARE_MACRO(Fcvtzs(v4.V2S(), v11.V2S()),
6137                 "fcvtzs v4.2s, "
6138                 "v11.2s");
6139   COMPARE_MACRO(Fcvtzs(v23.V4S(), v12.V4S()),
6140                 "fcvtzs v23.4s, "
6141                 "v12.4s");
6142   COMPARE_MACRO(Fcvtzs(v30.V2D(), v1.V2D()),
6143                 "fcvtzs v30.2d, "
6144                 "v1.2d");
6145   COMPARE_MACRO(Fcvtzu(v4.V2S(), v11.V2S()),
6146                 "fcvtzu v4.2s, "
6147                 "v11.2s");
6148   COMPARE_MACRO(Fcvtzu(v23.V4S(), v12.V4S()),
6149                 "fcvtzu v23.4s, "
6150                 "v12.4s");
6151   COMPARE_MACRO(Fcvtzu(v30.V2D(), v1.V2D()),
6152                 "fcvtzu v30.2d, "
6153                 "v1.2d");
6154 
6155   COMPARE_MACRO(Fcvtas(v4.V2S(), v11.V2S()),
6156                 "fcvtas v4.2s, "
6157                 "v11.2s");
6158   COMPARE_MACRO(Fcvtas(v23.V4S(), v12.V4S()),
6159                 "fcvtas v23.4s, "
6160                 "v12.4s");
6161   COMPARE_MACRO(Fcvtas(v30.V2D(), v1.V2D()),
6162                 "fcvtas v30.2d, "
6163                 "v1.2d");
6164   COMPARE_MACRO(Fcvtau(v4.V2S(), v11.V2S()),
6165                 "fcvtau v4.2s, "
6166                 "v11.2s");
6167   COMPARE_MACRO(Fcvtau(v23.V4S(), v12.V4S()),
6168                 "fcvtau v23.4s, "
6169                 "v12.4s");
6170   COMPARE_MACRO(Fcvtau(v30.V2D(), v1.V2D()),
6171                 "fcvtau v30.2d, "
6172                 "v1.2d");
6173 
6174   COMPARE_MACRO(Fcvtns(s0, s1), "fcvtns s0, s1");
6175   COMPARE_MACRO(Fcvtns(d2, d3), "fcvtns d2, d3");
6176   COMPARE_MACRO(Fcvtnu(s4, s5), "fcvtnu s4, s5");
6177   COMPARE_MACRO(Fcvtnu(d6, d7), "fcvtnu d6, d7");
6178   COMPARE_MACRO(Fcvtps(s8, s9), "fcvtps s8, s9");
6179   COMPARE_MACRO(Fcvtps(d10, d11), "fcvtps d10, d11");
6180   COMPARE_MACRO(Fcvtpu(s12, s13), "fcvtpu s12, s13");
6181   COMPARE_MACRO(Fcvtpu(d14, d15), "fcvtpu d14, d15");
6182   COMPARE_MACRO(Fcvtms(s16, s17), "fcvtms s16, s17");
6183   COMPARE_MACRO(Fcvtms(d18, d19), "fcvtms d18, d19");
6184   COMPARE_MACRO(Fcvtmu(s20, s21), "fcvtmu s20, s21");
6185   COMPARE_MACRO(Fcvtmu(d22, d23), "fcvtmu d22, d23");
6186   COMPARE_MACRO(Fcvtzs(s24, s25), "fcvtzs s24, s25");
6187   COMPARE_MACRO(Fcvtzs(d26, d27), "fcvtzs d26, d27");
6188   COMPARE_MACRO(Fcvtzu(s28, s29), "fcvtzu s28, s29");
6189   COMPARE_MACRO(Fcvtzu(d30, d31), "fcvtzu d30, d31");
6190   COMPARE_MACRO(Fcvtas(s0, s1), "fcvtas s0, s1");
6191   COMPARE_MACRO(Fcvtas(d2, d3), "fcvtas d2, d3");
6192   COMPARE_MACRO(Fcvtau(s4, s5), "fcvtau s4, s5");
6193   COMPARE_MACRO(Fcvtau(d6, d7), "fcvtau d6, d7");
6194 
6195   COMPARE_MACRO(Fcvtl(v3.V4S(), v5.V4H()),
6196                 "fcvtl v3.4s, "
6197                 "v5.4h");
6198   COMPARE_MACRO(Fcvtl(v7.V2D(), v11.V2S()),
6199                 "fcvtl v7.2d, "
6200                 "v11.2s");
6201   COMPARE_MACRO(Fcvtl2(v13.V4S(), v17.V8H()),
6202                 "fcvtl2 v13.4s, "
6203                 "v17.8h");
6204   COMPARE_MACRO(Fcvtl2(v23.V2D(), v29.V4S()),
6205                 "fcvtl2 v23.2d, "
6206                 "v29.4s");
6207 
6208   COMPARE_MACRO(Fcvtn(v3.V4H(), v5.V4S()),
6209                 "fcvtn v3.4h, "
6210                 "v5.4s");
6211   COMPARE_MACRO(Fcvtn(v7.V2S(), v11.V2D()),
6212                 "fcvtn v7.2s, "
6213                 "v11.2d");
6214   COMPARE_MACRO(Fcvtn2(v13.V8H(), v17.V4S()),
6215                 "fcvtn2 v13.8h, "
6216                 "v17.4s");
6217   COMPARE_MACRO(Fcvtn2(v23.V4S(), v29.V2D()),
6218                 "fcvtn2 v23.4s, "
6219                 "v29.2d");
6220 
6221   COMPARE_MACRO(Fcvtxn(v5.V2S(), v7.V2D()),
6222                 "fcvtxn v5.2s, "
6223                 "v7.2d");
6224   COMPARE_MACRO(Fcvtxn2(v8.V4S(), v13.V2D()),
6225                 "fcvtxn2 v8.4s, "
6226                 "v13.2d");
6227   COMPARE_MACRO(Fcvtxn(s17, d31), "fcvtxn s17, d31");
6228 
6229   COMPARE_MACRO(Frecpx(s0, s1), "frecpx s0, s1");
6230   COMPARE_MACRO(Frecpx(s31, s30), "frecpx s31, s30");
6231   COMPARE_MACRO(Frecpx(d2, d3), "frecpx d2, d3");
6232   COMPARE_MACRO(Frecpx(d31, d30), "frecpx d31, d30");
6233 
6234   COMPARE_MACRO(Scvtf(v5.V2S(), v3.V2S()),
6235                 "scvtf v5.2s, "
6236                 "v3.2s");
6237   COMPARE_MACRO(Scvtf(v6.V4S(), v4.V4S()),
6238                 "scvtf v6.4s, "
6239                 "v4.4s");
6240   COMPARE_MACRO(Scvtf(v7.V2D(), v5.V2D()),
6241                 "scvtf v7.2d, "
6242                 "v5.2d");
6243   COMPARE_MACRO(Scvtf(s8, s6), "scvtf s8, s6");
6244   COMPARE_MACRO(Scvtf(d8, d6), "scvtf d8, d6");
6245 
6246   COMPARE_MACRO(Ucvtf(v5.V2S(), v3.V2S()),
6247                 "ucvtf v5.2s, "
6248                 "v3.2s");
6249   COMPARE_MACRO(Ucvtf(v6.V4S(), v4.V4S()),
6250                 "ucvtf v6.4s, "
6251                 "v4.4s");
6252   COMPARE_MACRO(Ucvtf(v7.V2D(), v5.V2D()),
6253                 "ucvtf v7.2d, "
6254                 "v5.2d");
6255   COMPARE_MACRO(Ucvtf(s8, s6), "ucvtf s8, s6");
6256   COMPARE_MACRO(Ucvtf(d8, d6), "ucvtf d8, d6");
6257 
6258 #define DISASM_INST(TA, TAS, TB, TBS) \
6259   COMPARE_MACRO(Saddlp(v0.TA, v1.TB), "saddlp v0." TAS ", v1." TBS);
6260   NEON_FORMAT_LIST_LP(DISASM_INST)
6261 #undef DISASM_INST
6262 
6263 #define DISASM_INST(TA, TAS, TB, TBS) \
6264   COMPARE_MACRO(Uaddlp(v0.TA, v1.TB), "uaddlp v0." TAS ", v1." TBS);
6265   NEON_FORMAT_LIST_LP(DISASM_INST)
6266 #undef DISASM_INST
6267 
6268 #define DISASM_INST(TA, TAS, TB, TBS) \
6269   COMPARE_MACRO(Sadalp(v0.TA, v1.TB), "sadalp v0." TAS ", v1." TBS);
6270   NEON_FORMAT_LIST_LP(DISASM_INST)
6271 #undef DISASM_INST
6272 
6273 #define DISASM_INST(TA, TAS, TB, TBS) \
6274   COMPARE_MACRO(Uadalp(v0.TA, v1.TB), "uadalp v0." TAS ", v1." TBS);
6275   NEON_FORMAT_LIST_LP(DISASM_INST)
6276 #undef DISASM_INST
6277 
6278   CLEANUP();
6279 }
6280 
TEST(neon_acrosslanes)6281 TEST(neon_acrosslanes) {
6282   SETUP();
6283 
6284   COMPARE_MACRO(Smaxv(b4, v5.V8B()), "smaxv b4, v5.8b");
6285   COMPARE_MACRO(Smaxv(b4, v5.V16B()), "smaxv b4, v5.16b");
6286   COMPARE_MACRO(Smaxv(h4, v5.V4H()), "smaxv h4, v5.4h");
6287   COMPARE_MACRO(Smaxv(h4, v5.V8H()), "smaxv h4, v5.8h");
6288   COMPARE_MACRO(Smaxv(s4, v5.V4S()), "smaxv s4, v5.4s");
6289 
6290   COMPARE_MACRO(Sminv(b4, v5.V8B()), "sminv b4, v5.8b");
6291   COMPARE_MACRO(Sminv(b4, v5.V16B()), "sminv b4, v5.16b");
6292   COMPARE_MACRO(Sminv(h4, v5.V4H()), "sminv h4, v5.4h");
6293   COMPARE_MACRO(Sminv(h4, v5.V8H()), "sminv h4, v5.8h");
6294   COMPARE_MACRO(Sminv(s4, v5.V4S()), "sminv s4, v5.4s");
6295 
6296   COMPARE_MACRO(Umaxv(b4, v5.V8B()), "umaxv b4, v5.8b");
6297   COMPARE_MACRO(Umaxv(b4, v5.V16B()), "umaxv b4, v5.16b");
6298   COMPARE_MACRO(Umaxv(h4, v5.V4H()), "umaxv h4, v5.4h");
6299   COMPARE_MACRO(Umaxv(h4, v5.V8H()), "umaxv h4, v5.8h");
6300   COMPARE_MACRO(Umaxv(s4, v5.V4S()), "umaxv s4, v5.4s");
6301 
6302   COMPARE_MACRO(Uminv(b4, v5.V8B()), "uminv b4, v5.8b");
6303   COMPARE_MACRO(Uminv(b4, v5.V16B()), "uminv b4, v5.16b");
6304   COMPARE_MACRO(Uminv(h4, v5.V4H()), "uminv h4, v5.4h");
6305   COMPARE_MACRO(Uminv(h4, v5.V8H()), "uminv h4, v5.8h");
6306   COMPARE_MACRO(Uminv(s4, v5.V4S()), "uminv s4, v5.4s");
6307 
6308   COMPARE_MACRO(Addv(b4, v5.V8B()), "addv b4, v5.8b");
6309   COMPARE_MACRO(Addv(b4, v5.V16B()), "addv b4, v5.16b");
6310   COMPARE_MACRO(Addv(h4, v5.V4H()), "addv h4, v5.4h");
6311   COMPARE_MACRO(Addv(h4, v5.V8H()), "addv h4, v5.8h");
6312   COMPARE_MACRO(Addv(s4, v5.V4S()), "addv s4, v5.4s");
6313 
6314   COMPARE_MACRO(Saddlv(h4, v5.V8B()), "saddlv h4, v5.8b");
6315   COMPARE_MACRO(Saddlv(h4, v5.V16B()), "saddlv h4, v5.16b");
6316   COMPARE_MACRO(Saddlv(s4, v5.V4H()), "saddlv s4, v5.4h");
6317   COMPARE_MACRO(Saddlv(s4, v5.V8H()), "saddlv s4, v5.8h");
6318   COMPARE_MACRO(Saddlv(d4, v5.V4S()), "saddlv d4, v5.4s");
6319 
6320   COMPARE_MACRO(Uaddlv(h4, v5.V8B()), "uaddlv h4, v5.8b");
6321   COMPARE_MACRO(Uaddlv(h4, v5.V16B()), "uaddlv h4, v5.16b");
6322   COMPARE_MACRO(Uaddlv(s4, v5.V4H()), "uaddlv s4, v5.4h");
6323   COMPARE_MACRO(Uaddlv(s4, v5.V8H()), "uaddlv s4, v5.8h");
6324   COMPARE_MACRO(Uaddlv(d4, v5.V4S()), "uaddlv d4, v5.4s");
6325 
6326   COMPARE_MACRO(Fmaxv(s4, v5.V4S()), "fmaxv s4, v5.4s");
6327   COMPARE_MACRO(Fminv(s4, v5.V4S()), "fminv s4, v5.4s");
6328   COMPARE_MACRO(Fmaxnmv(s4, v5.V4S()), "fmaxnmv s4, v5.4s");
6329   COMPARE_MACRO(Fminnmv(s4, v5.V4S()), "fminnmv s4, v5.4s");
6330 
6331   CLEANUP();
6332 }
6333 
TEST(neon_scalar_pairwise)6334 TEST(neon_scalar_pairwise) {
6335   SETUP();
6336 
6337   COMPARE_MACRO(Addp(d0, v1.V2D()), "addp d0, v1.2d");
6338   COMPARE_MACRO(Faddp(s0, v1.V2S()), "faddp s0, v1.2s");
6339   COMPARE_MACRO(Faddp(d2, v3.V2D()), "faddp d2, v3.2d");
6340   COMPARE_MACRO(Fmaxp(s4, v5.V2S()), "fmaxp s4, v5.2s");
6341   COMPARE_MACRO(Fmaxp(d6, v7.V2D()), "fmaxp d6, v7.2d");
6342   COMPARE_MACRO(Fmaxnmp(s8, v9.V2S()), "fmaxnmp s8, v9.2s");
6343   COMPARE_MACRO(Fmaxnmp(d10, v11.V2D()), "fmaxnmp d10, v11.2d");
6344   COMPARE_MACRO(Fminp(s12, v13.V2S()), "fminp s12, v13.2s");
6345   COMPARE_MACRO(Fminp(d14, v15.V2D()), "fminp d14, v15.2d");
6346   COMPARE_MACRO(Fminnmp(s16, v17.V2S()), "fminnmp s16, v17.2s");
6347   COMPARE_MACRO(Fminnmp(d18, v19.V2D()), "fminnmp d18, v19.2d");
6348   CLEANUP();
6349 }
6350 
TEST(neon_shift_immediate)6351 TEST(neon_shift_immediate) {
6352   SETUP();
6353 
6354   COMPARE_MACRO(Sshr(v0.V8B(), v1.V8B(), 1), "sshr v0.8b, v1.8b, #1");
6355   COMPARE_MACRO(Sshr(v2.V8B(), v3.V8B(), 8), "sshr v2.8b, v3.8b, #8");
6356   COMPARE_MACRO(Sshr(v4.V16B(), v5.V16B(), 1), "sshr v4.16b, v5.16b, #1");
6357   COMPARE_MACRO(Sshr(v6.V16B(), v7.V16B(), 8), "sshr v6.16b, v7.16b, #8");
6358   COMPARE_MACRO(Sshr(v8.V4H(), v9.V4H(), 1), "sshr v8.4h, v9.4h, #1");
6359   COMPARE_MACRO(Sshr(v10.V4H(), v11.V4H(), 16), "sshr v10.4h, v11.4h, #16");
6360   COMPARE_MACRO(Sshr(v12.V8H(), v13.V8H(), 1), "sshr v12.8h, v13.8h, #1");
6361   COMPARE_MACRO(Sshr(v14.V8H(), v15.V8H(), 16), "sshr v14.8h, v15.8h, #16");
6362   COMPARE_MACRO(Sshr(v16.V2S(), v17.V2S(), 1), "sshr v16.2s, v17.2s, #1");
6363   COMPARE_MACRO(Sshr(v18.V2S(), v19.V2S(), 32), "sshr v18.2s, v19.2s, #32");
6364   COMPARE_MACRO(Sshr(v20.V4S(), v21.V4S(), 1), "sshr v20.4s, v21.4s, #1");
6365   COMPARE_MACRO(Sshr(v22.V4S(), v23.V4S(), 32), "sshr v22.4s, v23.4s, #32");
6366   COMPARE_MACRO(Sshr(v28.V2D(), v29.V2D(), 1), "sshr v28.2d, v29.2d, #1");
6367   COMPARE_MACRO(Sshr(v30.V2D(), v31.V2D(), 64), "sshr v30.2d, v31.2d, #64");
6368   COMPARE_MACRO(Sshr(d0, d1, 7), "sshr d0, d1, #7");
6369 
6370   COMPARE_MACRO(Ushr(v0.V8B(), v1.V8B(), 1), "ushr v0.8b, v1.8b, #1");
6371   COMPARE_MACRO(Ushr(v2.V8B(), v3.V8B(), 8), "ushr v2.8b, v3.8b, #8");
6372   COMPARE_MACRO(Ushr(v4.V16B(), v5.V16B(), 1), "ushr v4.16b, v5.16b, #1");
6373   COMPARE_MACRO(Ushr(v6.V16B(), v7.V16B(), 8), "ushr v6.16b, v7.16b, #8");
6374   COMPARE_MACRO(Ushr(v8.V4H(), v9.V4H(), 1), "ushr v8.4h, v9.4h, #1");
6375   COMPARE_MACRO(Ushr(v10.V4H(), v11.V4H(), 16), "ushr v10.4h, v11.4h, #16");
6376   COMPARE_MACRO(Ushr(v12.V8H(), v13.V8H(), 1), "ushr v12.8h, v13.8h, #1");
6377   COMPARE_MACRO(Ushr(v14.V8H(), v15.V8H(), 16), "ushr v14.8h, v15.8h, #16");
6378   COMPARE_MACRO(Ushr(v16.V2S(), v17.V2S(), 1), "ushr v16.2s, v17.2s, #1");
6379   COMPARE_MACRO(Ushr(v18.V2S(), v19.V2S(), 32), "ushr v18.2s, v19.2s, #32");
6380   COMPARE_MACRO(Ushr(v20.V4S(), v21.V4S(), 1), "ushr v20.4s, v21.4s, #1");
6381   COMPARE_MACRO(Ushr(v22.V4S(), v23.V4S(), 32), "ushr v22.4s, v23.4s, #32");
6382   COMPARE_MACRO(Ushr(v28.V2D(), v29.V2D(), 1), "ushr v28.2d, v29.2d, #1");
6383   COMPARE_MACRO(Ushr(v30.V2D(), v31.V2D(), 64), "ushr v30.2d, v31.2d, #64");
6384   COMPARE_MACRO(Ushr(d0, d1, 7), "ushr d0, d1, #7");
6385 
6386   COMPARE_MACRO(Srshr(v0.V8B(), v1.V8B(), 1), "srshr v0.8b, v1.8b, #1");
6387   COMPARE_MACRO(Srshr(v2.V8B(), v3.V8B(), 8), "srshr v2.8b, v3.8b, #8");
6388   COMPARE_MACRO(Srshr(v4.V16B(), v5.V16B(), 1), "srshr v4.16b, v5.16b, #1");
6389   COMPARE_MACRO(Srshr(v6.V16B(), v7.V16B(), 8), "srshr v6.16b, v7.16b, #8");
6390   COMPARE_MACRO(Srshr(v8.V4H(), v9.V4H(), 1), "srshr v8.4h, v9.4h, #1");
6391   COMPARE_MACRO(Srshr(v10.V4H(), v11.V4H(), 16), "srshr v10.4h, v11.4h, #16");
6392   COMPARE_MACRO(Srshr(v12.V8H(), v13.V8H(), 1), "srshr v12.8h, v13.8h, #1");
6393   COMPARE_MACRO(Srshr(v14.V8H(), v15.V8H(), 16), "srshr v14.8h, v15.8h, #16");
6394   COMPARE_MACRO(Srshr(v16.V2S(), v17.V2S(), 1), "srshr v16.2s, v17.2s, #1");
6395   COMPARE_MACRO(Srshr(v18.V2S(), v19.V2S(), 32), "srshr v18.2s, v19.2s, #32");
6396   COMPARE_MACRO(Srshr(v20.V4S(), v21.V4S(), 1), "srshr v20.4s, v21.4s, #1");
6397   COMPARE_MACRO(Srshr(v22.V4S(), v23.V4S(), 32), "srshr v22.4s, v23.4s, #32");
6398   COMPARE_MACRO(Srshr(v28.V2D(), v29.V2D(), 1), "srshr v28.2d, v29.2d, #1");
6399   COMPARE_MACRO(Srshr(v30.V2D(), v31.V2D(), 64), "srshr v30.2d, v31.2d, #64");
6400   COMPARE_MACRO(Srshr(d0, d1, 7), "srshr d0, d1, #7");
6401 
6402   COMPARE_MACRO(Urshr(v0.V8B(), v1.V8B(), 1), "urshr v0.8b, v1.8b, #1");
6403   COMPARE_MACRO(Urshr(v2.V8B(), v3.V8B(), 8), "urshr v2.8b, v3.8b, #8");
6404   COMPARE_MACRO(Urshr(v4.V16B(), v5.V16B(), 1), "urshr v4.16b, v5.16b, #1");
6405   COMPARE_MACRO(Urshr(v6.V16B(), v7.V16B(), 8), "urshr v6.16b, v7.16b, #8");
6406   COMPARE_MACRO(Urshr(v8.V4H(), v9.V4H(), 1), "urshr v8.4h, v9.4h, #1");
6407   COMPARE_MACRO(Urshr(v10.V4H(), v11.V4H(), 16), "urshr v10.4h, v11.4h, #16");
6408   COMPARE_MACRO(Urshr(v12.V8H(), v13.V8H(), 1), "urshr v12.8h, v13.8h, #1");
6409   COMPARE_MACRO(Urshr(v14.V8H(), v15.V8H(), 16), "urshr v14.8h, v15.8h, #16");
6410   COMPARE_MACRO(Urshr(v16.V2S(), v17.V2S(), 1), "urshr v16.2s, v17.2s, #1");
6411   COMPARE_MACRO(Urshr(v18.V2S(), v19.V2S(), 32), "urshr v18.2s, v19.2s, #32");
6412   COMPARE_MACRO(Urshr(v20.V4S(), v21.V4S(), 1), "urshr v20.4s, v21.4s, #1");
6413   COMPARE_MACRO(Urshr(v22.V4S(), v23.V4S(), 32), "urshr v22.4s, v23.4s, #32");
6414   COMPARE_MACRO(Urshr(v28.V2D(), v29.V2D(), 1), "urshr v28.2d, v29.2d, #1");
6415   COMPARE_MACRO(Urshr(v30.V2D(), v31.V2D(), 64), "urshr v30.2d, v31.2d, #64");
6416   COMPARE_MACRO(Urshr(d0, d1, 7), "urshr d0, d1, #7");
6417 
6418   COMPARE_MACRO(Srsra(v0.V8B(), v1.V8B(), 1), "srsra v0.8b, v1.8b, #1");
6419   COMPARE_MACRO(Srsra(v2.V8B(), v3.V8B(), 8), "srsra v2.8b, v3.8b, #8");
6420   COMPARE_MACRO(Srsra(v4.V16B(), v5.V16B(), 1), "srsra v4.16b, v5.16b, #1");
6421   COMPARE_MACRO(Srsra(v6.V16B(), v7.V16B(), 8), "srsra v6.16b, v7.16b, #8");
6422   COMPARE_MACRO(Srsra(v8.V4H(), v9.V4H(), 1), "srsra v8.4h, v9.4h, #1");
6423   COMPARE_MACRO(Srsra(v10.V4H(), v11.V4H(), 16), "srsra v10.4h, v11.4h, #16");
6424   COMPARE_MACRO(Srsra(v12.V8H(), v13.V8H(), 1), "srsra v12.8h, v13.8h, #1");
6425   COMPARE_MACRO(Srsra(v14.V8H(), v15.V8H(), 16), "srsra v14.8h, v15.8h, #16");
6426   COMPARE_MACRO(Srsra(v16.V2S(), v17.V2S(), 1), "srsra v16.2s, v17.2s, #1");
6427   COMPARE_MACRO(Srsra(v18.V2S(), v19.V2S(), 32), "srsra v18.2s, v19.2s, #32");
6428   COMPARE_MACRO(Srsra(v20.V4S(), v21.V4S(), 1), "srsra v20.4s, v21.4s, #1");
6429   COMPARE_MACRO(Srsra(v22.V4S(), v23.V4S(), 32), "srsra v22.4s, v23.4s, #32");
6430   COMPARE_MACRO(Srsra(v28.V2D(), v29.V2D(), 1), "srsra v28.2d, v29.2d, #1");
6431   COMPARE_MACRO(Srsra(v30.V2D(), v31.V2D(), 64), "srsra v30.2d, v31.2d, #64");
6432   COMPARE_MACRO(Srsra(d0, d1, 7), "srsra d0, d1, #7");
6433 
6434   COMPARE_MACRO(Ssra(v0.V8B(), v1.V8B(), 1), "ssra v0.8b, v1.8b, #1");
6435   COMPARE_MACRO(Ssra(v2.V8B(), v3.V8B(), 8), "ssra v2.8b, v3.8b, #8");
6436   COMPARE_MACRO(Ssra(v4.V16B(), v5.V16B(), 1), "ssra v4.16b, v5.16b, #1");
6437   COMPARE_MACRO(Ssra(v6.V16B(), v7.V16B(), 8), "ssra v6.16b, v7.16b, #8");
6438   COMPARE_MACRO(Ssra(v8.V4H(), v9.V4H(), 1), "ssra v8.4h, v9.4h, #1");
6439   COMPARE_MACRO(Ssra(v10.V4H(), v11.V4H(), 16), "ssra v10.4h, v11.4h, #16");
6440   COMPARE_MACRO(Ssra(v12.V8H(), v13.V8H(), 1), "ssra v12.8h, v13.8h, #1");
6441   COMPARE_MACRO(Ssra(v14.V8H(), v15.V8H(), 16), "ssra v14.8h, v15.8h, #16");
6442   COMPARE_MACRO(Ssra(v16.V2S(), v17.V2S(), 1), "ssra v16.2s, v17.2s, #1");
6443   COMPARE_MACRO(Ssra(v18.V2S(), v19.V2S(), 32), "ssra v18.2s, v19.2s, #32");
6444   COMPARE_MACRO(Ssra(v20.V4S(), v21.V4S(), 1), "ssra v20.4s, v21.4s, #1");
6445   COMPARE_MACRO(Ssra(v22.V4S(), v23.V4S(), 32), "ssra v22.4s, v23.4s, #32");
6446   COMPARE_MACRO(Ssra(v28.V2D(), v29.V2D(), 1), "ssra v28.2d, v29.2d, #1");
6447   COMPARE_MACRO(Ssra(v30.V2D(), v31.V2D(), 64), "ssra v30.2d, v31.2d, #64");
6448   COMPARE_MACRO(Ssra(d0, d1, 7), "ssra d0, d1, #7");
6449 
6450   COMPARE_MACRO(Ursra(v0.V8B(), v1.V8B(), 1), "ursra v0.8b, v1.8b, #1");
6451   COMPARE_MACRO(Ursra(v2.V8B(), v3.V8B(), 8), "ursra v2.8b, v3.8b, #8");
6452   COMPARE_MACRO(Ursra(v4.V16B(), v5.V16B(), 1), "ursra v4.16b, v5.16b, #1");
6453   COMPARE_MACRO(Ursra(v6.V16B(), v7.V16B(), 8), "ursra v6.16b, v7.16b, #8");
6454   COMPARE_MACRO(Ursra(v8.V4H(), v9.V4H(), 1), "ursra v8.4h, v9.4h, #1");
6455   COMPARE_MACRO(Ursra(v10.V4H(), v11.V4H(), 16), "ursra v10.4h, v11.4h, #16");
6456   COMPARE_MACRO(Ursra(v12.V8H(), v13.V8H(), 1), "ursra v12.8h, v13.8h, #1");
6457   COMPARE_MACRO(Ursra(v14.V8H(), v15.V8H(), 16), "ursra v14.8h, v15.8h, #16");
6458   COMPARE_MACRO(Ursra(v16.V2S(), v17.V2S(), 1), "ursra v16.2s, v17.2s, #1");
6459   COMPARE_MACRO(Ursra(v18.V2S(), v19.V2S(), 32), "ursra v18.2s, v19.2s, #32");
6460   COMPARE_MACRO(Ursra(v20.V4S(), v21.V4S(), 1), "ursra v20.4s, v21.4s, #1");
6461   COMPARE_MACRO(Ursra(v22.V4S(), v23.V4S(), 32), "ursra v22.4s, v23.4s, #32");
6462   COMPARE_MACRO(Ursra(v28.V2D(), v29.V2D(), 1), "ursra v28.2d, v29.2d, #1");
6463   COMPARE_MACRO(Ursra(v30.V2D(), v31.V2D(), 64), "ursra v30.2d, v31.2d, #64");
6464   COMPARE_MACRO(Ursra(d0, d1, 7), "ursra d0, d1, #7");
6465 
6466   COMPARE_MACRO(Usra(v0.V8B(), v1.V8B(), 1), "usra v0.8b, v1.8b, #1");
6467   COMPARE_MACRO(Usra(v2.V8B(), v3.V8B(), 8), "usra v2.8b, v3.8b, #8");
6468   COMPARE_MACRO(Usra(v4.V16B(), v5.V16B(), 1), "usra v4.16b, v5.16b, #1");
6469   COMPARE_MACRO(Usra(v6.V16B(), v7.V16B(), 8), "usra v6.16b, v7.16b, #8");
6470   COMPARE_MACRO(Usra(v8.V4H(), v9.V4H(), 1), "usra v8.4h, v9.4h, #1");
6471   COMPARE_MACRO(Usra(v10.V4H(), v11.V4H(), 16), "usra v10.4h, v11.4h, #16");
6472   COMPARE_MACRO(Usra(v12.V8H(), v13.V8H(), 1), "usra v12.8h, v13.8h, #1");
6473   COMPARE_MACRO(Usra(v14.V8H(), v15.V8H(), 16), "usra v14.8h, v15.8h, #16");
6474   COMPARE_MACRO(Usra(v16.V2S(), v17.V2S(), 1), "usra v16.2s, v17.2s, #1");
6475   COMPARE_MACRO(Usra(v18.V2S(), v19.V2S(), 32), "usra v18.2s, v19.2s, #32");
6476   COMPARE_MACRO(Usra(v20.V4S(), v21.V4S(), 1), "usra v20.4s, v21.4s, #1");
6477   COMPARE_MACRO(Usra(v22.V4S(), v23.V4S(), 32), "usra v22.4s, v23.4s, #32");
6478   COMPARE_MACRO(Usra(v28.V2D(), v29.V2D(), 1), "usra v28.2d, v29.2d, #1");
6479   COMPARE_MACRO(Usra(v30.V2D(), v31.V2D(), 64), "usra v30.2d, v31.2d, #64");
6480   COMPARE_MACRO(Usra(d0, d1, 7), "usra d0, d1, #7");
6481 
6482   COMPARE_MACRO(Sli(v1.V8B(), v8.V8B(), 1), "sli v1.8b, v8.8b, #1");
6483   COMPARE_MACRO(Sli(v2.V16B(), v9.V16B(), 2), "sli v2.16b, v9.16b, #2");
6484   COMPARE_MACRO(Sli(v3.V4H(), v1.V4H(), 3), "sli v3.4h, v1.4h, #3");
6485   COMPARE_MACRO(Sli(v4.V8H(), v2.V8H(), 4), "sli v4.8h, v2.8h, #4");
6486   COMPARE_MACRO(Sli(v5.V2S(), v3.V2S(), 5), "sli v5.2s, v3.2s, #5");
6487   COMPARE_MACRO(Sli(v6.V4S(), v4.V4S(), 6), "sli v6.4s, v4.4s, #6");
6488   COMPARE_MACRO(Sli(v7.V2D(), v5.V2D(), 7), "sli v7.2d, v5.2d, #7");
6489   COMPARE_MACRO(Sli(d8, d6, 8), "sli d8, d6, #8");
6490 
6491   COMPARE_MACRO(Shl(v1.V8B(), v8.V8B(), 1), "shl v1.8b, v8.8b, #1");
6492   COMPARE_MACRO(Shl(v2.V16B(), v9.V16B(), 2), "shl v2.16b, v9.16b, #2");
6493   COMPARE_MACRO(Shl(v3.V4H(), v1.V4H(), 3), "shl v3.4h, v1.4h, #3");
6494   COMPARE_MACRO(Shl(v4.V8H(), v2.V8H(), 4), "shl v4.8h, v2.8h, #4");
6495   COMPARE_MACRO(Shl(v5.V2S(), v3.V2S(), 5), "shl v5.2s, v3.2s, #5");
6496   COMPARE_MACRO(Shl(v6.V4S(), v4.V4S(), 6), "shl v6.4s, v4.4s, #6");
6497   COMPARE_MACRO(Shl(v7.V2D(), v5.V2D(), 7), "shl v7.2d, v5.2d, #7");
6498   COMPARE_MACRO(Shl(d8, d6, 8), "shl d8, d6, #8");
6499 
6500   COMPARE_MACRO(Sqshl(v1.V8B(), v8.V8B(), 1), "sqshl v1.8b, v8.8b, #1");
6501   COMPARE_MACRO(Sqshl(v2.V16B(), v9.V16B(), 2), "sqshl v2.16b, v9.16b, #2");
6502   COMPARE_MACRO(Sqshl(v3.V4H(), v1.V4H(), 3), "sqshl v3.4h, v1.4h, #3");
6503   COMPARE_MACRO(Sqshl(v4.V8H(), v2.V8H(), 4), "sqshl v4.8h, v2.8h, #4");
6504   COMPARE_MACRO(Sqshl(v5.V2S(), v3.V2S(), 5), "sqshl v5.2s, v3.2s, #5");
6505   COMPARE_MACRO(Sqshl(v6.V4S(), v4.V4S(), 6), "sqshl v6.4s, v4.4s, #6");
6506   COMPARE_MACRO(Sqshl(v7.V2D(), v5.V2D(), 7), "sqshl v7.2d, v5.2d, #7");
6507   COMPARE_MACRO(Sqshl(b8, b7, 1), "sqshl b8, b7, #1");
6508   COMPARE_MACRO(Sqshl(h9, h8, 2), "sqshl h9, h8, #2");
6509   COMPARE_MACRO(Sqshl(s10, s9, 3), "sqshl s10, s9, #3");
6510   COMPARE_MACRO(Sqshl(d11, d10, 4), "sqshl d11, d10, #4");
6511 
6512   COMPARE_MACRO(Sqshlu(v1.V8B(), v8.V8B(), 1), "sqshlu v1.8b, v8.8b, #1");
6513   COMPARE_MACRO(Sqshlu(v2.V16B(), v9.V16B(), 2), "sqshlu v2.16b, v9.16b, #2");
6514   COMPARE_MACRO(Sqshlu(v3.V4H(), v1.V4H(), 3), "sqshlu v3.4h, v1.4h, #3");
6515   COMPARE_MACRO(Sqshlu(v4.V8H(), v2.V8H(), 4), "sqshlu v4.8h, v2.8h, #4");
6516   COMPARE_MACRO(Sqshlu(v5.V2S(), v3.V2S(), 5), "sqshlu v5.2s, v3.2s, #5");
6517   COMPARE_MACRO(Sqshlu(v6.V4S(), v4.V4S(), 6), "sqshlu v6.4s, v4.4s, #6");
6518   COMPARE_MACRO(Sqshlu(v7.V2D(), v5.V2D(), 7), "sqshlu v7.2d, v5.2d, #7");
6519   COMPARE_MACRO(Sqshlu(b8, b7, 1), "sqshlu b8, b7, #1");
6520   COMPARE_MACRO(Sqshlu(h9, h8, 2), "sqshlu h9, h8, #2");
6521   COMPARE_MACRO(Sqshlu(s10, s9, 3), "sqshlu s10, s9, #3");
6522   COMPARE_MACRO(Sqshlu(d11, d10, 4), "sqshlu d11, d10, #4");
6523 
6524   COMPARE_MACRO(Uqshl(v1.V8B(), v8.V8B(), 1), "uqshl v1.8b, v8.8b, #1");
6525   COMPARE_MACRO(Uqshl(v2.V16B(), v9.V16B(), 2), "uqshl v2.16b, v9.16b, #2");
6526   COMPARE_MACRO(Uqshl(v3.V4H(), v1.V4H(), 3), "uqshl v3.4h, v1.4h, #3");
6527   COMPARE_MACRO(Uqshl(v4.V8H(), v2.V8H(), 4), "uqshl v4.8h, v2.8h, #4");
6528   COMPARE_MACRO(Uqshl(v5.V2S(), v3.V2S(), 5), "uqshl v5.2s, v3.2s, #5");
6529   COMPARE_MACRO(Uqshl(v6.V4S(), v4.V4S(), 6), "uqshl v6.4s, v4.4s, #6");
6530   COMPARE_MACRO(Uqshl(v7.V2D(), v5.V2D(), 7), "uqshl v7.2d, v5.2d, #7");
6531   COMPARE_MACRO(Uqshl(b8, b7, 1), "uqshl b8, b7, #1");
6532   COMPARE_MACRO(Uqshl(h9, h8, 2), "uqshl h9, h8, #2");
6533   COMPARE_MACRO(Uqshl(s10, s9, 3), "uqshl s10, s9, #3");
6534   COMPARE_MACRO(Uqshl(d11, d10, 4), "uqshl d11, d10, #4");
6535 
6536   COMPARE_MACRO(Sshll(v1.V8H(), v8.V8B(), 1), "sshll v1.8h, v8.8b, #1");
6537   COMPARE_MACRO(Sshll(v3.V4S(), v1.V4H(), 3), "sshll v3.4s, v1.4h, #3");
6538   COMPARE_MACRO(Sshll(v5.V2D(), v3.V2S(), 5), "sshll v5.2d, v3.2s, #5");
6539   COMPARE_MACRO(Sshll2(v2.V8H(), v9.V16B(), 2), "sshll2 v2.8h, v9.16b, #2");
6540   COMPARE_MACRO(Sshll2(v4.V4S(), v2.V8H(), 4), "sshll2 v4.4s, v2.8h, #4");
6541   COMPARE_MACRO(Sshll2(v6.V2D(), v4.V4S(), 6), "sshll2 v6.2d, v4.4s, #6");
6542 
6543   COMPARE_MACRO(Sshll(v1.V8H(), v8.V8B(), 0), "sxtl v1.8h, v8.8b");
6544   COMPARE_MACRO(Sshll(v3.V4S(), v1.V4H(), 0), "sxtl v3.4s, v1.4h");
6545   COMPARE_MACRO(Sshll(v5.V2D(), v3.V2S(), 0), "sxtl v5.2d, v3.2s");
6546   COMPARE_MACRO(Sshll2(v2.V8H(), v9.V16B(), 0), "sxtl2 v2.8h, v9.16b");
6547   COMPARE_MACRO(Sshll2(v4.V4S(), v2.V8H(), 0), "sxtl2 v4.4s, v2.8h");
6548   COMPARE_MACRO(Sshll2(v6.V2D(), v4.V4S(), 0), "sxtl2 v6.2d, v4.4s");
6549 
6550   COMPARE_MACRO(Sxtl(v1.V8H(), v8.V8B()), "sxtl v1.8h, v8.8b");
6551   COMPARE_MACRO(Sxtl(v3.V4S(), v1.V4H()), "sxtl v3.4s, v1.4h");
6552   COMPARE_MACRO(Sxtl(v5.V2D(), v3.V2S()), "sxtl v5.2d, v3.2s");
6553   COMPARE_MACRO(Sxtl2(v2.V8H(), v9.V16B()), "sxtl2 v2.8h, v9.16b");
6554   COMPARE_MACRO(Sxtl2(v4.V4S(), v2.V8H()), "sxtl2 v4.4s, v2.8h");
6555   COMPARE_MACRO(Sxtl2(v6.V2D(), v4.V4S()), "sxtl2 v6.2d, v4.4s");
6556 
6557   COMPARE_MACRO(Ushll(v1.V8H(), v8.V8B(), 1), "ushll v1.8h, v8.8b, #1");
6558   COMPARE_MACRO(Ushll(v3.V4S(), v1.V4H(), 3), "ushll v3.4s, v1.4h, #3");
6559   COMPARE_MACRO(Ushll(v5.V2D(), v3.V2S(), 5), "ushll v5.2d, v3.2s, #5");
6560   COMPARE_MACRO(Ushll2(v2.V8H(), v9.V16B(), 2), "ushll2 v2.8h, v9.16b, #2");
6561   COMPARE_MACRO(Ushll2(v4.V4S(), v2.V8H(), 4), "ushll2 v4.4s, v2.8h, #4");
6562   COMPARE_MACRO(Ushll2(v6.V2D(), v4.V4S(), 6), "ushll2 v6.2d, v4.4s, #6");
6563 
6564   COMPARE_MACRO(Ushll(v1.V8H(), v8.V8B(), 0), "uxtl v1.8h, v8.8b");
6565   COMPARE_MACRO(Ushll(v3.V4S(), v1.V4H(), 0), "uxtl v3.4s, v1.4h");
6566   COMPARE_MACRO(Ushll(v5.V2D(), v3.V2S(), 0), "uxtl v5.2d, v3.2s");
6567   COMPARE_MACRO(Ushll2(v2.V8H(), v9.V16B(), 0), "uxtl2 v2.8h, v9.16b");
6568   COMPARE_MACRO(Ushll2(v4.V4S(), v2.V8H(), 0), "uxtl2 v4.4s, v2.8h");
6569   COMPARE_MACRO(Ushll2(v6.V2D(), v4.V4S(), 0), "uxtl2 v6.2d, v4.4s");
6570 
6571   COMPARE_MACRO(Uxtl(v1.V8H(), v8.V8B()), "uxtl v1.8h, v8.8b");
6572   COMPARE_MACRO(Uxtl(v3.V4S(), v1.V4H()), "uxtl v3.4s, v1.4h");
6573   COMPARE_MACRO(Uxtl(v5.V2D(), v3.V2S()), "uxtl v5.2d, v3.2s");
6574   COMPARE_MACRO(Uxtl2(v2.V8H(), v9.V16B()), "uxtl2 v2.8h, v9.16b");
6575   COMPARE_MACRO(Uxtl2(v4.V4S(), v2.V8H()), "uxtl2 v4.4s, v2.8h");
6576   COMPARE_MACRO(Uxtl2(v6.V2D(), v4.V4S()), "uxtl2 v6.2d, v4.4s");
6577 
6578   COMPARE_MACRO(Sri(v1.V8B(), v8.V8B(), 1), "sri v1.8b, v8.8b, #1");
6579   COMPARE_MACRO(Sri(v2.V16B(), v9.V16B(), 2), "sri v2.16b, v9.16b, #2");
6580   COMPARE_MACRO(Sri(v3.V4H(), v1.V4H(), 3), "sri v3.4h, v1.4h, #3");
6581   COMPARE_MACRO(Sri(v4.V8H(), v2.V8H(), 4), "sri v4.8h, v2.8h, #4");
6582   COMPARE_MACRO(Sri(v5.V2S(), v3.V2S(), 5), "sri v5.2s, v3.2s, #5");
6583   COMPARE_MACRO(Sri(v6.V4S(), v4.V4S(), 6), "sri v6.4s, v4.4s, #6");
6584   COMPARE_MACRO(Sri(v7.V2D(), v5.V2D(), 7), "sri v7.2d, v5.2d, #7");
6585   COMPARE_MACRO(Sri(d8, d6, 8), "sri d8, d6, #8");
6586 
6587   COMPARE_MACRO(Shrn(v0.V8B(), v1.V8H(), 1), "shrn v0.8b, v1.8h, #1");
6588   COMPARE_MACRO(Shrn(v1.V4H(), v2.V4S(), 2), "shrn v1.4h, v2.4s, #2");
6589   COMPARE_MACRO(Shrn(v2.V2S(), v3.V2D(), 3), "shrn v2.2s, v3.2d, #3");
6590   COMPARE_MACRO(Shrn2(v0.V16B(), v1.V8H(), 4), "shrn2 v0.16b, v1.8h, #4");
6591   COMPARE_MACRO(Shrn2(v1.V8H(), v2.V4S(), 5), "shrn2 v1.8h, v2.4s, #5");
6592   COMPARE_MACRO(Shrn2(v2.V4S(), v3.V2D(), 6), "shrn2 v2.4s, v3.2d, #6");
6593 
6594   COMPARE_MACRO(Rshrn(v0.V8B(), v1.V8H(), 1), "rshrn v0.8b, v1.8h, #1");
6595   COMPARE_MACRO(Rshrn(v1.V4H(), v2.V4S(), 2), "rshrn v1.4h, v2.4s, #2");
6596   COMPARE_MACRO(Rshrn(v2.V2S(), v3.V2D(), 3), "rshrn v2.2s, v3.2d, #3");
6597   COMPARE_MACRO(Rshrn2(v0.V16B(), v1.V8H(), 4), "rshrn2 v0.16b, v1.8h, #4");
6598   COMPARE_MACRO(Rshrn2(v1.V8H(), v2.V4S(), 5), "rshrn2 v1.8h, v2.4s, #5");
6599   COMPARE_MACRO(Rshrn2(v2.V4S(), v3.V2D(), 6), "rshrn2 v2.4s, v3.2d, #6");
6600 
6601   COMPARE_MACRO(Uqshrn(v0.V8B(), v1.V8H(), 1), "uqshrn v0.8b, v1.8h, #1");
6602   COMPARE_MACRO(Uqshrn(v1.V4H(), v2.V4S(), 2), "uqshrn v1.4h, v2.4s, #2");
6603   COMPARE_MACRO(Uqshrn(v2.V2S(), v3.V2D(), 3), "uqshrn v2.2s, v3.2d, #3");
6604   COMPARE_MACRO(Uqshrn2(v0.V16B(), v1.V8H(), 4), "uqshrn2 v0.16b, v1.8h, #4");
6605   COMPARE_MACRO(Uqshrn2(v1.V8H(), v2.V4S(), 5), "uqshrn2 v1.8h, v2.4s, #5");
6606   COMPARE_MACRO(Uqshrn2(v2.V4S(), v3.V2D(), 6), "uqshrn2 v2.4s, v3.2d, #6");
6607   COMPARE_MACRO(Uqshrn(b0, h1, 1), "uqshrn b0, h1, #1");
6608   COMPARE_MACRO(Uqshrn(h1, s2, 2), "uqshrn h1, s2, #2");
6609   COMPARE_MACRO(Uqshrn(s2, d3, 3), "uqshrn s2, d3, #3");
6610 
6611   COMPARE_MACRO(Uqrshrn(v0.V8B(), v1.V8H(), 1), "uqrshrn v0.8b, v1.8h, #1");
6612   COMPARE_MACRO(Uqrshrn(v1.V4H(), v2.V4S(), 2), "uqrshrn v1.4h, v2.4s, #2");
6613   COMPARE_MACRO(Uqrshrn(v2.V2S(), v3.V2D(), 3), "uqrshrn v2.2s, v3.2d, #3");
6614   COMPARE_MACRO(Uqrshrn2(v0.V16B(), v1.V8H(), 4), "uqrshrn2 v0.16b, v1.8h, #4");
6615   COMPARE_MACRO(Uqrshrn2(v1.V8H(), v2.V4S(), 5), "uqrshrn2 v1.8h, v2.4s, #5");
6616   COMPARE_MACRO(Uqrshrn2(v2.V4S(), v3.V2D(), 6), "uqrshrn2 v2.4s, v3.2d, #6");
6617   COMPARE_MACRO(Uqrshrn(b0, h1, 1), "uqrshrn b0, h1, #1");
6618   COMPARE_MACRO(Uqrshrn(h1, s2, 2), "uqrshrn h1, s2, #2");
6619   COMPARE_MACRO(Uqrshrn(s2, d3, 3), "uqrshrn s2, d3, #3");
6620 
6621   COMPARE_MACRO(Sqshrn(v0.V8B(), v1.V8H(), 1), "sqshrn v0.8b, v1.8h, #1");
6622   COMPARE_MACRO(Sqshrn(v1.V4H(), v2.V4S(), 2), "sqshrn v1.4h, v2.4s, #2");
6623   COMPARE_MACRO(Sqshrn(v2.V2S(), v3.V2D(), 3), "sqshrn v2.2s, v3.2d, #3");
6624   COMPARE_MACRO(Sqshrn2(v0.V16B(), v1.V8H(), 4), "sqshrn2 v0.16b, v1.8h, #4");
6625   COMPARE_MACRO(Sqshrn2(v1.V8H(), v2.V4S(), 5), "sqshrn2 v1.8h, v2.4s, #5");
6626   COMPARE_MACRO(Sqshrn2(v2.V4S(), v3.V2D(), 6), "sqshrn2 v2.4s, v3.2d, #6");
6627   COMPARE_MACRO(Sqshrn(b0, h1, 1), "sqshrn b0, h1, #1");
6628   COMPARE_MACRO(Sqshrn(h1, s2, 2), "sqshrn h1, s2, #2");
6629   COMPARE_MACRO(Sqshrn(s2, d3, 3), "sqshrn s2, d3, #3");
6630 
6631   COMPARE_MACRO(Sqrshrn(v0.V8B(), v1.V8H(), 1), "sqrshrn v0.8b, v1.8h, #1");
6632   COMPARE_MACRO(Sqrshrn(v1.V4H(), v2.V4S(), 2), "sqrshrn v1.4h, v2.4s, #2");
6633   COMPARE_MACRO(Sqrshrn(v2.V2S(), v3.V2D(), 3), "sqrshrn v2.2s, v3.2d, #3");
6634   COMPARE_MACRO(Sqrshrn2(v0.V16B(), v1.V8H(), 4), "sqrshrn2 v0.16b, v1.8h, #4");
6635   COMPARE_MACRO(Sqrshrn2(v1.V8H(), v2.V4S(), 5), "sqrshrn2 v1.8h, v2.4s, #5");
6636   COMPARE_MACRO(Sqrshrn2(v2.V4S(), v3.V2D(), 6), "sqrshrn2 v2.4s, v3.2d, #6");
6637   COMPARE_MACRO(Sqrshrn(b0, h1, 1), "sqrshrn b0, h1, #1");
6638   COMPARE_MACRO(Sqrshrn(h1, s2, 2), "sqrshrn h1, s2, #2");
6639   COMPARE_MACRO(Sqrshrn(s2, d3, 3), "sqrshrn s2, d3, #3");
6640 
6641   COMPARE_MACRO(Sqshrun(v0.V8B(), v1.V8H(), 1), "sqshrun v0.8b, v1.8h, #1");
6642   COMPARE_MACRO(Sqshrun(v1.V4H(), v2.V4S(), 2), "sqshrun v1.4h, v2.4s, #2");
6643   COMPARE_MACRO(Sqshrun(v2.V2S(), v3.V2D(), 3), "sqshrun v2.2s, v3.2d, #3");
6644   COMPARE_MACRO(Sqshrun2(v0.V16B(), v1.V8H(), 4), "sqshrun2 v0.16b, v1.8h, #4");
6645   COMPARE_MACRO(Sqshrun2(v1.V8H(), v2.V4S(), 5), "sqshrun2 v1.8h, v2.4s, #5");
6646   COMPARE_MACRO(Sqshrun2(v2.V4S(), v3.V2D(), 6), "sqshrun2 v2.4s, v3.2d, #6");
6647   COMPARE_MACRO(Sqshrun(b0, h1, 1), "sqshrun b0, h1, #1");
6648   COMPARE_MACRO(Sqshrun(h1, s2, 2), "sqshrun h1, s2, #2");
6649   COMPARE_MACRO(Sqshrun(s2, d3, 3), "sqshrun s2, d3, #3");
6650 
6651   COMPARE_MACRO(Sqrshrun(v0.V8B(), v1.V8H(), 1), "sqrshrun v0.8b, v1.8h, #1");
6652   COMPARE_MACRO(Sqrshrun(v1.V4H(), v2.V4S(), 2), "sqrshrun v1.4h, v2.4s, #2");
6653   COMPARE_MACRO(Sqrshrun(v2.V2S(), v3.V2D(), 3), "sqrshrun v2.2s, v3.2d, #3");
6654   COMPARE_MACRO(Sqrshrun2(v0.V16B(), v1.V8H(), 4),
6655                 "sqrshrun2 v0.16b, v1.8h, #4");
6656   COMPARE_MACRO(Sqrshrun2(v1.V8H(), v2.V4S(), 5), "sqrshrun2 v1.8h, v2.4s, #5");
6657   COMPARE_MACRO(Sqrshrun2(v2.V4S(), v3.V2D(), 6), "sqrshrun2 v2.4s, v3.2d, #6");
6658   COMPARE_MACRO(Sqrshrun(b0, h1, 1), "sqrshrun b0, h1, #1");
6659   COMPARE_MACRO(Sqrshrun(h1, s2, 2), "sqrshrun h1, s2, #2");
6660   COMPARE_MACRO(Sqrshrun(s2, d3, 3), "sqrshrun s2, d3, #3");
6661 
6662   COMPARE_MACRO(Scvtf(v5.V2S(), v3.V2S(), 11), "scvtf v5.2s, v3.2s, #11");
6663   COMPARE_MACRO(Scvtf(v6.V4S(), v4.V4S(), 12), "scvtf v6.4s, v4.4s, #12");
6664   COMPARE_MACRO(Scvtf(v7.V2D(), v5.V2D(), 33), "scvtf v7.2d, v5.2d, #33");
6665   COMPARE_MACRO(Scvtf(s8, s6, 13), "scvtf s8, s6, #13");
6666   COMPARE_MACRO(Scvtf(d8, d6, 34), "scvtf d8, d6, #34");
6667 
6668   COMPARE_MACRO(Ucvtf(v5.V2S(), v3.V2S(), 11), "ucvtf v5.2s, v3.2s, #11");
6669   COMPARE_MACRO(Ucvtf(v6.V4S(), v4.V4S(), 12), "ucvtf v6.4s, v4.4s, #12");
6670   COMPARE_MACRO(Ucvtf(v7.V2D(), v5.V2D(), 33), "ucvtf v7.2d, v5.2d, #33");
6671   COMPARE_MACRO(Ucvtf(s8, s6, 13), "ucvtf s8, s6, #13");
6672   COMPARE_MACRO(Ucvtf(d8, d6, 34), "ucvtf d8, d6, #34");
6673 
6674   COMPARE_MACRO(Fcvtzs(v5.V2S(), v3.V2S(), 11), "fcvtzs v5.2s, v3.2s, #11");
6675   COMPARE_MACRO(Fcvtzs(v6.V4S(), v4.V4S(), 12), "fcvtzs v6.4s, v4.4s, #12");
6676   COMPARE_MACRO(Fcvtzs(v7.V2D(), v5.V2D(), 33), "fcvtzs v7.2d, v5.2d, #33");
6677   COMPARE_MACRO(Fcvtzs(s8, s6, 13), "fcvtzs s8, s6, #13");
6678   COMPARE_MACRO(Fcvtzs(d8, d6, 34), "fcvtzs d8, d6, #34");
6679 
6680   COMPARE_MACRO(Fcvtzu(v5.V2S(), v3.V2S(), 11), "fcvtzu v5.2s, v3.2s, #11");
6681   COMPARE_MACRO(Fcvtzu(v6.V4S(), v4.V4S(), 12), "fcvtzu v6.4s, v4.4s, #12");
6682   COMPARE_MACRO(Fcvtzu(v7.V2D(), v5.V2D(), 33), "fcvtzu v7.2d, v5.2d, #33");
6683   COMPARE_MACRO(Fcvtzu(s8, s6, 13), "fcvtzu s8, s6, #13");
6684   COMPARE_MACRO(Fcvtzu(d8, d6, 34), "fcvtzu d8, d6, #34");
6685   CLEANUP();
6686 }
6687 
TEST(address_map)6688 TEST(address_map) {
6689   // Check that we can disassemble from a fake base address.
6690   SETUP();
6691 
6692   disasm.MapCodeAddress(0, masm.GetBuffer()->GetStartAddress<Instruction*>());
6693   COMPARE(ldr(x0, INT64_C(0)), "ldr x0, pc+0 (addr 0x0)");
6694   COMPARE(ldr(x0, -1), "ldr x0, pc-4 (addr -0x4)");
6695   COMPARE(ldr(x0, 1), "ldr x0, pc+4 (addr 0x4)");
6696   COMPARE(prfm(PLIL1KEEP, INT64_C(0)), "prfm plil1keep, pc+0 (addr 0x0)");
6697   COMPARE(prfm(PLIL1KEEP, -1), "prfm plil1keep, pc-4 (addr -0x4)");
6698   COMPARE(prfm(PLIL1KEEP, 1), "prfm plil1keep, pc+4 (addr 0x4)");
6699   COMPARE(adr(x0, INT64_C(0)), "adr x0, #+0x0 (addr 0x0)");
6700   COMPARE(adr(x0, -1), "adr x0, #-0x1 (addr -0x1)");
6701   COMPARE(adr(x0, 1), "adr x0, #+0x1 (addr 0x1)");
6702   COMPARE(adrp(x0, INT64_C(0)), "adrp x0, #+0x0 (addr 0x0)");
6703   COMPARE(adrp(x0, -1), "adrp x0, #-0x1000 (addr -0x1000)");
6704   COMPARE(adrp(x0, 1), "adrp x0, #+0x1000 (addr 0x1000)");
6705   COMPARE(b(INT64_C(0)), "b #+0x0 (addr 0x0)");
6706   COMPARE(b(-1), "b #-0x4 (addr -0x4)");
6707   COMPARE(b(1), "b #+0x4 (addr 0x4)");
6708 
6709   disasm.MapCodeAddress(0x1234,
6710                         masm.GetBuffer()->GetStartAddress<Instruction*>());
6711   COMPARE(ldr(x0, INT64_C(0)), "ldr x0, pc+0 (addr 0x1234)");
6712   COMPARE(ldr(x0, -1), "ldr x0, pc-4 (addr 0x1230)");
6713   COMPARE(ldr(x0, 1), "ldr x0, pc+4 (addr 0x1238)");
6714   COMPARE(prfm(PLIL1KEEP, INT64_C(0)), "prfm plil1keep, pc+0 (addr 0x1234)");
6715   COMPARE(prfm(PLIL1KEEP, -1), "prfm plil1keep, pc-4 (addr 0x1230)");
6716   COMPARE(prfm(PLIL1KEEP, 1), "prfm plil1keep, pc+4 (addr 0x1238)");
6717   COMPARE(adr(x0, INT64_C(0)), "adr x0, #+0x0 (addr 0x1234)");
6718   COMPARE(adr(x0, -1), "adr x0, #-0x1 (addr 0x1233)");
6719   COMPARE(adr(x0, 1), "adr x0, #+0x1 (addr 0x1235)");
6720   COMPARE(adrp(x0, INT64_C(0)), "adrp x0, #+0x0 (addr 0x1000)");
6721   COMPARE(adrp(x0, -1), "adrp x0, #-0x1000 (addr 0x0)");
6722   COMPARE(adrp(x0, 1), "adrp x0, #+0x1000 (addr 0x2000)");
6723   COMPARE(b(INT64_C(0)), "b #+0x0 (addr 0x1234)");
6724   COMPARE(b(-1), "b #-0x4 (addr 0x1230)");
6725   COMPARE(b(1), "b #+0x4 (addr 0x1238)");
6726 
6727   // Check that 64-bit addresses work.
6728   disasm.MapCodeAddress(UINT64_C(0x100000000),
6729                         masm.GetBuffer()->GetStartAddress<Instruction*>());
6730   COMPARE(ldr(x0, INT64_C(0)), "ldr x0, pc+0 (addr 0x100000000)");
6731   COMPARE(ldr(x0, -1), "ldr x0, pc-4 (addr 0xfffffffc)");
6732   COMPARE(ldr(x0, 1), "ldr x0, pc+4 (addr 0x100000004)");
6733   COMPARE(prfm(PLIL1KEEP, INT64_C(0)),
6734           "prfm plil1keep, pc+0 (addr 0x100000000)");
6735   COMPARE(prfm(PLIL1KEEP, -1), "prfm plil1keep, pc-4 (addr 0xfffffffc)");
6736   COMPARE(prfm(PLIL1KEEP, 1), "prfm plil1keep, pc+4 (addr 0x100000004)");
6737   COMPARE(adr(x0, INT64_C(0)), "adr x0, #+0x0 (addr 0x100000000)");
6738   COMPARE(adr(x0, -1), "adr x0, #-0x1 (addr 0xffffffff)");
6739   COMPARE(adr(x0, 1), "adr x0, #+0x1 (addr 0x100000001)");
6740   COMPARE(adrp(x0, INT64_C(0)), "adrp x0, #+0x0 (addr 0x100000000)");
6741   COMPARE(adrp(x0, -1), "adrp x0, #-0x1000 (addr 0xfffff000)");
6742   COMPARE(adrp(x0, 1), "adrp x0, #+0x1000 (addr 0x100001000)");
6743   COMPARE(b(INT64_C(0)), "b #+0x0 (addr 0x100000000)");
6744   COMPARE(b(-1), "b #-0x4 (addr 0xfffffffc)");
6745   COMPARE(b(1), "b #+0x4 (addr 0x100000004)");
6746 
6747   disasm.MapCodeAddress(0xfffffffc,
6748                         masm.GetBuffer()->GetStartAddress<Instruction*>());
6749   COMPARE(ldr(x0, 1), "ldr x0, pc+4 (addr 0x100000000)");
6750   COMPARE(prfm(PLIL1KEEP, 1), "prfm plil1keep, pc+4 (addr 0x100000000)");
6751   COMPARE(b(1), "b #+0x4 (addr 0x100000000)");
6752   COMPARE(adr(x0, 4), "adr x0, #+0x4 (addr 0x100000000)");
6753   COMPARE(adrp(x0, 1), "adrp x0, #+0x1000 (addr 0x100000000)");
6754 
6755   // Check that very large offsets are handled properly. This detects misuse of
6756   // the host's ptrdiff_t type when run on a 32-bit host. Only adrp is capable
6757   // of encoding such offsets.
6758   disasm.MapCodeAddress(0, masm.GetBuffer()->GetStartAddress<Instruction*>());
6759   COMPARE(adrp(x0, 0x000fffff), "adrp x0, #+0xfffff000 (addr 0xfffff000)");
6760   COMPARE(adrp(x0, -0x00100000), "adrp x0, #-0x100000000 (addr -0x100000000)");
6761 
6762   CLEANUP();
6763 }
6764 
6765 }  // namespace aarch64
6766 }  // namespace vixl
6767