1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 //     * Redistributions of source code must retain the above copyright
7 //       notice, this list of conditions and the following disclaimer.
8 //     * Redistributions in binary form must reproduce the above
9 //       copyright notice, this list of conditions and the following
10 //       disclaimer in the documentation and/or other materials provided
11 //       with the distribution.
12 //     * Neither the name of Google Inc. nor the names of its
13 //       contributors may be used to endorse or promote products derived
14 //       from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 #include <stdio.h>
29 #include <cstring>
30 
31 #include "src/v8.h"
32 #include "test/cctest/cctest.h"
33 
34 #include "src/macro-assembler.h"
35 
36 #include "src/arm64/assembler-arm64.h"
37 #include "src/arm64/decoder-arm64-inl.h"
38 #include "src/arm64/disasm-arm64.h"
39 #include "src/arm64/macro-assembler-arm64.h"
40 #include "src/arm64/utils-arm64.h"
41 
42 using namespace v8::internal;
43 
44 #define TEST_(name)  TEST(DISASM_##name)
45 
46 #define EXP_SIZE   (256)
47 #define INSTR_SIZE (1024)
48 #define SET_UP_MASM()                                                    \
49   InitializeVM();                                                        \
50   Isolate* isolate = CcTest::i_isolate();                                \
51   HandleScope scope(isolate);                                            \
52   byte* buf = static_cast<byte*>(malloc(INSTR_SIZE));                    \
53   uint32_t encoding = 0;                                                 \
54   MacroAssembler* assm = new MacroAssembler(                             \
55       isolate, buf, INSTR_SIZE, v8::internal::CodeObjectRequired::kYes); \
56   Decoder<DispatchingDecoderVisitor>* decoder =                          \
57       new Decoder<DispatchingDecoderVisitor>();                          \
58   DisassemblingDecoder* disasm = new DisassemblingDecoder();             \
59   decoder->AppendVisitor(disasm)
60 
61 #define SET_UP_ASM()                                         \
62   InitializeVM();                                            \
63   Isolate* isolate = CcTest::i_isolate();                    \
64   HandleScope scope(isolate);                                \
65   byte* buf = static_cast<byte*>(malloc(INSTR_SIZE));        \
66   uint32_t encoding = 0;                                     \
67   Assembler* assm = new Assembler(isolate, buf, INSTR_SIZE); \
68   Decoder<DispatchingDecoderVisitor>* decoder =              \
69       new Decoder<DispatchingDecoderVisitor>();              \
70   DisassemblingDecoder* disasm = new DisassemblingDecoder(); \
71   decoder->AppendVisitor(disasm)
72 
73 #define COMPARE(ASM, EXP)                                                      \
74   assm->Reset();                                                               \
75   assm->ASM;                                                                   \
76   assm->GetCode(NULL);                                                         \
77   decoder->Decode(reinterpret_cast<Instruction*>(buf));                        \
78   encoding = *reinterpret_cast<uint32_t*>(buf);                                \
79   if (strcmp(disasm->GetOutput(), EXP) != 0) {                                 \
80     printf("%u : Encoding: %08" PRIx32 "\nExpected: %s\nFound:    %s\n",       \
81            __LINE__, encoding, EXP, disasm->GetOutput());                      \
82     abort();                                                                   \
83   }
84 
85 #define COMPARE_PREFIX(ASM, EXP)                                               \
86   assm->Reset();                                                               \
87   assm->ASM;                                                                   \
88   assm->GetCode(NULL);                                                         \
89   decoder->Decode(reinterpret_cast<Instruction*>(buf));                        \
90   encoding = *reinterpret_cast<uint32_t*>(buf);                                \
91   if (strncmp(disasm->GetOutput(), EXP, strlen(EXP)) != 0) {                   \
92     printf("%u : Encoding: %08" PRIx32 "\nExpected: %s\nFound:    %s\n",       \
93            __LINE__, encoding, EXP, disasm->GetOutput());                      \
94     abort();                                                                   \
95   }
96 
97 #define CLEANUP() \
98   delete disasm;  \
99   delete decoder; \
100   delete assm;    \
101   free(buf)
102 
103 
104 static bool vm_initialized = false;
105 
106 
InitializeVM()107 static void InitializeVM() {
108   if (!vm_initialized) {
109     CcTest::InitializeVM();
110     vm_initialized = true;
111   }
112 }
113 
114 
TEST_(bootstrap)115 TEST_(bootstrap) {
116   SET_UP_ASM();
117 
118   // Instructions generated by C compiler, disassembled by objdump, and
119   // reformatted to suit our disassembly style.
120   COMPARE(dci(0xa9ba7bfd), "stp fp, lr, [csp, #-96]!");
121   COMPARE(dci(0x910003fd), "mov fp, csp");
122   COMPARE(dci(0x9100e3a0), "add x0, fp, #0x38 (56)");
123   COMPARE(dci(0xb900001f), "str wzr, [x0]");
124   COMPARE(dci(0x528000e1), "movz w1, #0x7");
125   COMPARE(dci(0xb9001c01), "str w1, [x0, #28]");
126   COMPARE(dci(0x390043a0), "strb w0, [fp, #16]");
127   COMPARE(dci(0x790027a0), "strh w0, [fp, #18]");
128   COMPARE(dci(0xb9400400), "ldr w0, [x0, #4]");
129   COMPARE(dci(0x0b000021), "add w1, w1, w0");
130   COMPARE(dci(0x531b6800), "lsl w0, w0, #5");
131   COMPARE(dci(0x521e0400), "eor w0, w0, #0xc");
132   COMPARE(dci(0x72af0f00), "movk w0, #0x7878, lsl #16");
133   COMPARE(dci(0xd360fc00), "lsr x0, x0, #32");
134   COMPARE(dci(0x13037c01), "asr w1, w0, #3");
135   COMPARE(dci(0x4b000021), "sub w1, w1, w0");
136   COMPARE(dci(0x2a0103e0), "mov w0, w1");
137   COMPARE(dci(0x93407c00), "sxtw x0, w0");
138   COMPARE(dci(0x2a000020), "orr w0, w1, w0");
139   COMPARE(dci(0xa8c67bfd), "ldp fp, lr, [csp], #96");
140 
141   CLEANUP();
142 }
143 
144 
TEST_(mov_mvn)145 TEST_(mov_mvn) {
146   SET_UP_MASM();
147 
148   COMPARE(Mov(w0, Operand(0x1234)), "movz w0, #0x1234");
149   COMPARE(Mov(x1, Operand(0x1234)), "movz x1, #0x1234");
150   COMPARE(Mov(w2, Operand(w3)), "mov w2, w3");
151   COMPARE(Mov(x4, Operand(x5)), "mov x4, x5");
152   COMPARE(Mov(w6, Operand(w7, LSL, 5)), "lsl w6, w7, #5");
153   COMPARE(Mov(x8, Operand(x9, ASR, 42)), "asr x8, x9, #42");
154   COMPARE(Mov(w10, Operand(w11, UXTB)), "uxtb w10, w11");
155   COMPARE(Mov(x12, Operand(x13, UXTB, 1)), "ubfiz x12, x13, #1, #8");
156   COMPARE(Mov(w14, Operand(w15, SXTH, 2)), "sbfiz w14, w15, #2, #16");
157   COMPARE(Mov(x16, Operand(x20, SXTW, 3)), "sbfiz x16, x20, #3, #32");
158 
159   COMPARE(Mov(x0, csp), "mov x0, csp");
160   COMPARE(Mov(w0, wcsp), "mov w0, wcsp");
161   COMPARE(Mov(x0, xzr), "mov x0, xzr");
162   COMPARE(Mov(w0, wzr), "mov w0, wzr");
163   COMPARE(mov(x0, csp), "mov x0, csp");
164   COMPARE(mov(w0, wcsp), "mov w0, wcsp");
165   COMPARE(mov(x0, xzr), "mov x0, xzr");
166   COMPARE(mov(w0, wzr), "mov w0, wzr");
167 
168   COMPARE(Mvn(w0, Operand(0x1)), "movn w0, #0x1");
169   COMPARE(Mvn(x1, Operand(0xfff)), "movn x1, #0xfff");
170   COMPARE(Mvn(w2, Operand(w3)), "mvn w2, w3");
171   COMPARE(Mvn(x4, Operand(x5)), "mvn x4, x5");
172   COMPARE(Mvn(w6, Operand(w7, LSL, 12)), "mvn w6, w7, lsl #12");
173   COMPARE(Mvn(x8, Operand(x9, ASR, 63)), "mvn x8, x9, asr #63");
174 
175   CLEANUP();
176 }
177 
178 
TEST_(move_immediate)179 TEST_(move_immediate) {
180   SET_UP_ASM();
181 
182   COMPARE(movz(w0, 0x1234), "movz w0, #0x1234");
183   COMPARE(movz(x1, 0xabcd0000), "movz x1, #0xabcd0000");
184   COMPARE(movz(x2, 0x555500000000), "movz x2, #0x555500000000");
185   COMPARE(movz(x3, 0xaaaa000000000000), "movz x3, #0xaaaa000000000000");
186   COMPARE(movz(x4, 0xabcd, 16), "movz x4, #0xabcd0000");
187   COMPARE(movz(x5, 0x5555, 32), "movz x5, #0x555500000000");
188   COMPARE(movz(x6, 0xaaaa, 48), "movz x6, #0xaaaa000000000000");
189 
190   COMPARE(movk(w7, 0x1234), "movk w7, #0x1234");
191   COMPARE(movk(x8, 0xabcd0000), "movk x8, #0xabcd, lsl #16");
192   COMPARE(movk(x9, 0x555500000000), "movk x9, #0x5555, lsl #32");
193   COMPARE(movk(x10, 0xaaaa000000000000), "movk x10, #0xaaaa, lsl #48");
194   COMPARE(movk(w11, 0xabcd, 16), "movk w11, #0xabcd, lsl #16");
195   COMPARE(movk(x12, 0x5555, 32), "movk x12, #0x5555, lsl #32");
196   COMPARE(movk(x13, 0xaaaa, 48), "movk x13, #0xaaaa, lsl #48");
197 
198   COMPARE(movn(w14, 0x1234), "movn w14, #0x1234");
199   COMPARE(movn(x15, 0xabcd0000), "movn x15, #0xabcd0000");
200   COMPARE(movn(x16, 0x555500000000), "movn x16, #0x555500000000");
201   COMPARE(movn(x17, 0xaaaa000000000000), "movn x17, #0xaaaa000000000000");
202   COMPARE(movn(w18, 0xabcd, 16), "movn w18, #0xabcd0000");
203   COMPARE(movn(x19, 0x5555, 32), "movn x19, #0x555500000000");
204   COMPARE(movn(x20, 0xaaaa, 48), "movn x20, #0xaaaa000000000000");
205 
206   COMPARE(movk(w21, 0), "movk w21, #0x0");
207   COMPARE(movk(x22, 0, 0), "movk x22, #0x0");
208   COMPARE(movk(w23, 0, 16), "movk w23, #0x0, lsl #16");
209   COMPARE(movk(x24, 0, 32), "movk x24, #0x0, lsl #32");
210   COMPARE(movk(x25, 0, 48), "movk x25, #0x0, lsl #48");
211 
212   CLEANUP();
213 }
214 
215 
TEST(move_immediate_2)216 TEST(move_immediate_2) {
217   SET_UP_MASM();
218 
219   // Move instructions expected for certain immediates. This is really a macro
220   // assembler test, to ensure it generates immediates efficiently.
221   COMPARE(Mov(w0, 0), "movz w0, #0x0");
222   COMPARE(Mov(w0, 0x0000ffff), "movz w0, #0xffff");
223   COMPARE(Mov(w0, 0x00010000), "movz w0, #0x10000");
224   COMPARE(Mov(w0, 0xffff0000), "movz w0, #0xffff0000");
225   COMPARE(Mov(w0, 0x0001ffff), "movn w0, #0xfffe0000");
226   COMPARE(Mov(w0, 0xffff8000), "movn w0, #0x7fff");
227   COMPARE(Mov(w0, 0xfffffffe), "movn w0, #0x1");
228   COMPARE(Mov(w0, 0xffffffff), "movn w0, #0x0");
229   COMPARE(Mov(w0, 0x00ffff00), "mov w0, #0xffff00");
230   COMPARE(Mov(w0, 0xfffe7fff), "mov w0, #0xfffe7fff");
231   COMPARE(Mov(w0, 0xfffeffff), "movn w0, #0x10000");
232   COMPARE(Mov(w0, 0xffff7fff), "movn w0, #0x8000");
233 
234   COMPARE(Mov(x0, 0), "movz x0, #0x0");
235   COMPARE(Mov(x0, 0x0000ffff), "movz x0, #0xffff");
236   COMPARE(Mov(x0, 0x00010000), "movz x0, #0x10000");
237   COMPARE(Mov(x0, 0xffff0000), "movz x0, #0xffff0000");
238   COMPARE(Mov(x0, 0x0001ffff), "mov x0, #0x1ffff");
239   COMPARE(Mov(x0, 0xffff8000), "mov x0, #0xffff8000");
240   COMPARE(Mov(x0, 0xfffffffe), "mov x0, #0xfffffffe");
241   COMPARE(Mov(x0, 0xffffffff), "mov x0, #0xffffffff");
242   COMPARE(Mov(x0, 0x00ffff00), "mov x0, #0xffff00");
243   COMPARE(Mov(x0, 0xffff000000000000), "movz x0, #0xffff000000000000");
244   COMPARE(Mov(x0, 0x0000ffff00000000), "movz x0, #0xffff00000000");
245   COMPARE(Mov(x0, 0x00000000ffff0000), "movz x0, #0xffff0000");
246   COMPARE(Mov(x0, 0xffffffffffff0000), "movn x0, #0xffff");
247   COMPARE(Mov(x0, 0xffffffff0000ffff), "movn x0, #0xffff0000");
248   COMPARE(Mov(x0, 0xffff0000ffffffff), "movn x0, #0xffff00000000");
249   COMPARE(Mov(x0, 0x0000ffffffffffff), "movn x0, #0xffff000000000000");
250   COMPARE(Mov(x0, 0xfffe7fffffffffff), "mov x0, #0xfffe7fffffffffff");
251   COMPARE(Mov(x0, 0xfffeffffffffffff), "movn x0, #0x1000000000000");
252   COMPARE(Mov(x0, 0xffff7fffffffffff), "movn x0, #0x800000000000");
253   COMPARE(Mov(x0, 0xfffffffe7fffffff), "mov x0, #0xfffffffe7fffffff");
254   COMPARE(Mov(x0, 0xfffffffeffffffff), "movn x0, #0x100000000");
255   COMPARE(Mov(x0, 0xffffffff7fffffff), "movn x0, #0x80000000");
256   COMPARE(Mov(x0, 0xfffffffffffe7fff), "mov x0, #0xfffffffffffe7fff");
257   COMPARE(Mov(x0, 0xfffffffffffeffff), "movn x0, #0x10000");
258   COMPARE(Mov(x0, 0xffffffffffff7fff), "movn x0, #0x8000");
259   COMPARE(Mov(x0, 0xffffffffffffffff), "movn x0, #0x0");
260 
261   COMPARE(Movk(w0, 0x1234, 0), "movk w0, #0x1234");
262   COMPARE(Movk(x1, 0x2345, 0), "movk x1, #0x2345");
263   COMPARE(Movk(w2, 0x3456, 16), "movk w2, #0x3456, lsl #16");
264   COMPARE(Movk(x3, 0x4567, 16), "movk x3, #0x4567, lsl #16");
265   COMPARE(Movk(x4, 0x5678, 32), "movk x4, #0x5678, lsl #32");
266   COMPARE(Movk(x5, 0x6789, 48), "movk x5, #0x6789, lsl #48");
267 
268   CLEANUP();
269 }
270 
271 
TEST_(add_immediate)272 TEST_(add_immediate) {
273   SET_UP_ASM();
274 
275   COMPARE(add(w0, w1, Operand(0xff)), "add w0, w1, #0xff (255)");
276   COMPARE(add(x2, x3, Operand(0x3ff)), "add x2, x3, #0x3ff (1023)");
277   COMPARE(add(w4, w5, Operand(0xfff)), "add w4, w5, #0xfff (4095)");
278   COMPARE(add(x6, x7, Operand(0x1000)), "add x6, x7, #0x1000 (4096)");
279   COMPARE(add(w8, w9, Operand(0xff000)), "add w8, w9, #0xff000 (1044480)");
280   COMPARE(add(x10, x11, Operand(0x3ff000)),
281           "add x10, x11, #0x3ff000 (4190208)");
282   COMPARE(add(w12, w13, Operand(0xfff000)),
283           "add w12, w13, #0xfff000 (16773120)");
284   COMPARE(adds(w14, w15, Operand(0xff)), "adds w14, w15, #0xff (255)");
285   COMPARE(adds(x16, x17, Operand(0xaa000)),
286           "adds x16, x17, #0xaa000 (696320)");
287   COMPARE(cmn(w18, Operand(0xff)), "cmn w18, #0xff (255)");
288   COMPARE(cmn(x19, Operand(0xff000)), "cmn x19, #0xff000 (1044480)");
289   COMPARE(add(w0, wcsp, Operand(0)), "mov w0, wcsp");
290   COMPARE(add(csp, x0, Operand(0)), "mov csp, x0");
291 
292   COMPARE(add(w1, wcsp, Operand(8)), "add w1, wcsp, #0x8 (8)");
293   COMPARE(add(x2, csp, Operand(16)), "add x2, csp, #0x10 (16)");
294   COMPARE(add(wcsp, wcsp, Operand(42)), "add wcsp, wcsp, #0x2a (42)");
295   COMPARE(cmn(csp, Operand(24)), "cmn csp, #0x18 (24)");
296   COMPARE(adds(wzr, wcsp, Operand(9)), "cmn wcsp, #0x9 (9)");
297 
298   CLEANUP();
299 }
300 
301 
TEST_(sub_immediate)302 TEST_(sub_immediate) {
303   SET_UP_ASM();
304 
305   COMPARE(sub(w0, w1, Operand(0xff)), "sub w0, w1, #0xff (255)");
306   COMPARE(sub(x2, x3, Operand(0x3ff)), "sub x2, x3, #0x3ff (1023)");
307   COMPARE(sub(w4, w5, Operand(0xfff)), "sub w4, w5, #0xfff (4095)");
308   COMPARE(sub(x6, x7, Operand(0x1000)), "sub x6, x7, #0x1000 (4096)");
309   COMPARE(sub(w8, w9, Operand(0xff000)), "sub w8, w9, #0xff000 (1044480)");
310   COMPARE(sub(x10, x11, Operand(0x3ff000)),
311           "sub x10, x11, #0x3ff000 (4190208)");
312   COMPARE(sub(w12, w13, Operand(0xfff000)),
313           "sub w12, w13, #0xfff000 (16773120)");
314   COMPARE(subs(w14, w15, Operand(0xff)), "subs w14, w15, #0xff (255)");
315   COMPARE(subs(x16, x17, Operand(0xaa000)),
316           "subs x16, x17, #0xaa000 (696320)");
317   COMPARE(cmp(w18, Operand(0xff)), "cmp w18, #0xff (255)");
318   COMPARE(cmp(x19, Operand(0xff000)), "cmp x19, #0xff000 (1044480)");
319 
320   COMPARE(add(w1, wcsp, Operand(8)), "add w1, wcsp, #0x8 (8)");
321   COMPARE(add(x2, csp, Operand(16)), "add x2, csp, #0x10 (16)");
322   COMPARE(add(wcsp, wcsp, Operand(42)), "add wcsp, wcsp, #0x2a (42)");
323   COMPARE(cmn(csp, Operand(24)), "cmn csp, #0x18 (24)");
324   COMPARE(adds(wzr, wcsp, Operand(9)), "cmn wcsp, #0x9 (9)");
325 
326   CLEANUP();
327 }
328 
329 
TEST_(add_shifted)330 TEST_(add_shifted) {
331   SET_UP_ASM();
332 
333   COMPARE(add(w0, w1, Operand(w2)), "add w0, w1, w2");
334   COMPARE(add(x3, x4, Operand(x5)), "add x3, x4, x5");
335   COMPARE(add(w6, w7, Operand(w8, LSL, 1)), "add w6, w7, w8, lsl #1");
336   COMPARE(add(x9, x10, Operand(x11, LSL, 2)), "add x9, x10, x11, lsl #2");
337   COMPARE(add(w12, w13, Operand(w14, LSR, 3)), "add w12, w13, w14, lsr #3");
338   COMPARE(add(x15, x16, Operand(x17, LSR, 4)), "add x15, x16, x17, lsr #4");
339   COMPARE(add(w18, w19, Operand(w20, ASR, 5)), "add w18, w19, w20, asr #5");
340   COMPARE(add(x21, x22, Operand(x23, ASR, 6)), "add x21, x22, x23, asr #6");
341   COMPARE(cmn(w24, Operand(w25)), "cmn w24, w25");
342   COMPARE(cmn(x26, Operand(cp, LSL, 63)), "cmn x26, cp, lsl #63");
343 
344   COMPARE(add(x0, csp, Operand(x1)), "add x0, csp, x1");
345   COMPARE(add(w2, wcsp, Operand(w3)), "add w2, wcsp, w3");
346   COMPARE(add(x4, csp, Operand(x5, LSL, 1)), "add x4, csp, x5, lsl #1");
347   COMPARE(add(x4, xzr, Operand(x5, LSL, 1)), "add x4, xzr, x5, lsl #1");
348   COMPARE(add(w6, wcsp, Operand(w7, LSL, 3)), "add w6, wcsp, w7, lsl #3");
349   COMPARE(adds(xzr, csp, Operand(x8, LSL, 4)), "cmn csp, x8, lsl #4");
350   COMPARE(adds(xzr, xzr, Operand(x8, LSL, 5)), "cmn xzr, x8, lsl #5");
351 
352   CLEANUP();
353 }
354 
355 
TEST_(sub_shifted)356 TEST_(sub_shifted) {
357   SET_UP_ASM();
358 
359   COMPARE(sub(w0, w1, Operand(w2)), "sub w0, w1, w2");
360   COMPARE(sub(x3, x4, Operand(x5)), "sub x3, x4, x5");
361   COMPARE(sub(w6, w7, Operand(w8, LSL, 1)), "sub w6, w7, w8, lsl #1");
362   COMPARE(sub(x9, x10, Operand(x11, LSL, 2)), "sub x9, x10, x11, lsl #2");
363   COMPARE(sub(w12, w13, Operand(w14, LSR, 3)), "sub w12, w13, w14, lsr #3");
364   COMPARE(sub(x15, x16, Operand(x17, LSR, 4)), "sub x15, x16, x17, lsr #4");
365   COMPARE(sub(w18, w19, Operand(w20, ASR, 5)), "sub w18, w19, w20, asr #5");
366   COMPARE(sub(x21, x22, Operand(x23, ASR, 6)), "sub x21, x22, x23, asr #6");
367   COMPARE(cmp(w24, Operand(w25)), "cmp w24, w25");
368   COMPARE(cmp(x26, Operand(cp, LSL, 63)), "cmp x26, cp, lsl #63");
369   COMPARE(neg(w28, Operand(w29)), "neg w28, w29");
370   COMPARE(neg(lr, Operand(x0, LSR, 62)), "neg lr, x0, lsr #62");
371   COMPARE(negs(w1, Operand(w2)), "negs w1, w2");
372   COMPARE(negs(x3, Operand(x4, ASR, 61)), "negs x3, x4, asr #61");
373 
374   COMPARE(sub(x0, csp, Operand(x1)), "sub x0, csp, x1");
375   COMPARE(sub(w2, wcsp, Operand(w3)), "sub w2, wcsp, w3");
376   COMPARE(sub(x4, csp, Operand(x5, LSL, 1)), "sub x4, csp, x5, lsl #1");
377   COMPARE(sub(x4, xzr, Operand(x5, LSL, 1)), "neg x4, x5, lsl #1");
378   COMPARE(sub(w6, wcsp, Operand(w7, LSL, 3)), "sub w6, wcsp, w7, lsl #3");
379   COMPARE(subs(xzr, csp, Operand(x8, LSL, 4)), "cmp csp, x8, lsl #4");
380   COMPARE(subs(xzr, xzr, Operand(x8, LSL, 5)), "cmp xzr, x8, lsl #5");
381 
382   CLEANUP();
383 }
384 
385 
TEST_(add_extended)386 TEST_(add_extended) {
387   SET_UP_ASM();
388 
389   COMPARE(add(w0, w1, Operand(w2, UXTB)), "add w0, w1, w2, uxtb");
390   COMPARE(adds(x3, x4, Operand(w5, UXTB, 1)), "adds x3, x4, w5, uxtb #1");
391   COMPARE(add(w6, w7, Operand(w8, UXTH, 2)), "add w6, w7, w8, uxth #2");
392   COMPARE(adds(x9, x10, Operand(x11, UXTW, 3)), "adds x9, x10, w11, uxtw #3");
393   COMPARE(add(x12, x13, Operand(x14, UXTX, 4)), "add x12, x13, x14, uxtx #4");
394   COMPARE(adds(w15, w16, Operand(w17, SXTB, 4)), "adds w15, w16, w17, sxtb #4");
395   COMPARE(add(x18, x19, Operand(x20, SXTB, 3)), "add x18, x19, w20, sxtb #3");
396   COMPARE(adds(w21, w22, Operand(w23, SXTH, 2)), "adds w21, w22, w23, sxth #2");
397   COMPARE(add(x24, x25, Operand(x26, SXTW, 1)), "add x24, x25, w26, sxtw #1");
398   COMPARE(adds(cp, jssp, Operand(fp, SXTX)), "adds cp, jssp, fp, sxtx");
399   COMPARE(cmn(w0, Operand(w1, UXTB, 2)), "cmn w0, w1, uxtb #2");
400   COMPARE(cmn(x2, Operand(x3, SXTH, 4)), "cmn x2, w3, sxth #4");
401 
402   COMPARE(add(w0, wcsp, Operand(w1, UXTB)), "add w0, wcsp, w1, uxtb");
403   COMPARE(add(x2, csp, Operand(x3, UXTH, 1)), "add x2, csp, w3, uxth #1");
404   COMPARE(add(wcsp, wcsp, Operand(w4, UXTW, 2)), "add wcsp, wcsp, w4, lsl #2");
405   COMPARE(cmn(csp, Operand(xzr, UXTX, 3)), "cmn csp, xzr, lsl #3");
406   COMPARE(cmn(csp, Operand(xzr, LSL, 4)), "cmn csp, xzr, lsl #4");
407 
408   CLEANUP();
409 }
410 
411 
TEST_(sub_extended)412 TEST_(sub_extended) {
413   SET_UP_ASM();
414 
415   COMPARE(sub(w0, w1, Operand(w2, UXTB)), "sub w0, w1, w2, uxtb");
416   COMPARE(subs(x3, x4, Operand(w5, UXTB, 1)), "subs x3, x4, w5, uxtb #1");
417   COMPARE(sub(w6, w7, Operand(w8, UXTH, 2)), "sub w6, w7, w8, uxth #2");
418   COMPARE(subs(x9, x10, Operand(x11, UXTW, 3)), "subs x9, x10, w11, uxtw #3");
419   COMPARE(sub(x12, x13, Operand(x14, UXTX, 4)), "sub x12, x13, x14, uxtx #4");
420   COMPARE(subs(w15, w16, Operand(w17, SXTB, 4)), "subs w15, w16, w17, sxtb #4");
421   COMPARE(sub(x18, x19, Operand(x20, SXTB, 3)), "sub x18, x19, w20, sxtb #3");
422   COMPARE(subs(w21, w22, Operand(w23, SXTH, 2)), "subs w21, w22, w23, sxth #2");
423   COMPARE(sub(x24, x25, Operand(x26, SXTW, 1)), "sub x24, x25, w26, sxtw #1");
424   COMPARE(subs(cp, jssp, Operand(fp, SXTX)), "subs cp, jssp, fp, sxtx");
425   COMPARE(cmp(w0, Operand(w1, SXTB, 1)), "cmp w0, w1, sxtb #1");
426   COMPARE(cmp(x2, Operand(x3, UXTH, 3)), "cmp x2, w3, uxth #3");
427 
428   COMPARE(sub(w0, wcsp, Operand(w1, UXTB)), "sub w0, wcsp, w1, uxtb");
429   COMPARE(sub(x2, csp, Operand(x3, UXTH, 1)), "sub x2, csp, w3, uxth #1");
430   COMPARE(sub(wcsp, wcsp, Operand(w4, UXTW, 2)), "sub wcsp, wcsp, w4, lsl #2");
431   COMPARE(cmp(csp, Operand(xzr, UXTX, 3)), "cmp csp, xzr, lsl #3");
432   COMPARE(cmp(csp, Operand(xzr, LSL, 4)), "cmp csp, xzr, lsl #4");
433 
434   CLEANUP();
435 }
436 
437 
TEST_(adc_subc_ngc)438 TEST_(adc_subc_ngc) {
439   SET_UP_ASM();
440 
441   COMPARE(adc(w0, w1, Operand(w2)), "adc w0, w1, w2");
442   COMPARE(adc(x3, x4, Operand(x5)), "adc x3, x4, x5");
443   COMPARE(adcs(w6, w7, Operand(w8)), "adcs w6, w7, w8");
444   COMPARE(adcs(x9, x10, Operand(x11)), "adcs x9, x10, x11");
445   COMPARE(sbc(w12, w13, Operand(w14)), "sbc w12, w13, w14");
446   COMPARE(sbc(x15, x16, Operand(x17)), "sbc x15, x16, x17");
447   COMPARE(sbcs(w18, w19, Operand(w20)), "sbcs w18, w19, w20");
448   COMPARE(sbcs(x21, x22, Operand(x23)), "sbcs x21, x22, x23");
449   COMPARE(ngc(w24, Operand(w25)), "ngc w24, w25");
450   COMPARE(ngc(x26, Operand(cp)), "ngc x26, cp");
451   COMPARE(ngcs(w28, Operand(w29)), "ngcs w28, w29");
452   COMPARE(ngcs(lr, Operand(x0)), "ngcs lr, x0");
453 
454   CLEANUP();
455 }
456 
457 
TEST_(mul_and_div)458 TEST_(mul_and_div) {
459   SET_UP_ASM();
460 
461   COMPARE(mul(w0, w1, w2), "mul w0, w1, w2");
462   COMPARE(mul(x3, x4, x5), "mul x3, x4, x5");
463   COMPARE(mul(w30, w0, w1), "mul w30, w0, w1");
464   COMPARE(mul(lr, x0, x1), "mul lr, x0, x1");
465   COMPARE(mneg(w0, w1, w2), "mneg w0, w1, w2");
466   COMPARE(mneg(x3, x4, x5), "mneg x3, x4, x5");
467   COMPARE(mneg(w30, w0, w1), "mneg w30, w0, w1");
468   COMPARE(mneg(lr, x0, x1), "mneg lr, x0, x1");
469   COMPARE(smull(x0, w0, w1), "smull x0, w0, w1");
470   COMPARE(smull(lr, w30, w0), "smull lr, w30, w0");
471   COMPARE(smulh(x0, x1, x2), "smulh x0, x1, x2");
472 
473   COMPARE(madd(w0, w1, w2, w3), "madd w0, w1, w2, w3");
474   COMPARE(madd(x4, x5, x6, x7), "madd x4, x5, x6, x7");
475   COMPARE(madd(w8, w9, w10, wzr), "mul w8, w9, w10");
476   COMPARE(madd(x11, x12, x13, xzr), "mul x11, x12, x13");
477   COMPARE(msub(w14, w15, w16, w17), "msub w14, w15, w16, w17");
478   COMPARE(msub(x18, x19, x20, x21), "msub x18, x19, x20, x21");
479   COMPARE(msub(w22, w23, w24, wzr), "mneg w22, w23, w24");
480   COMPARE(msub(x25, x26, x0, xzr), "mneg x25, x26, x0");
481 
482   COMPARE(sdiv(w0, w1, w2), "sdiv w0, w1, w2");
483   COMPARE(sdiv(x3, x4, x5), "sdiv x3, x4, x5");
484   COMPARE(udiv(w6, w7, w8), "udiv w6, w7, w8");
485   COMPARE(udiv(x9, x10, x11), "udiv x9, x10, x11");
486 
487   CLEANUP();
488 }
489 
490 
TEST(maddl_msubl)491 TEST(maddl_msubl) {
492   SET_UP_ASM();
493 
494   COMPARE(smaddl(x0, w1, w2, x3), "smaddl x0, w1, w2, x3");
495   COMPARE(smaddl(x25, w21, w22, x16), "smaddl x25, w21, w22, x16");
496   COMPARE(umaddl(x0, w1, w2, x3), "umaddl x0, w1, w2, x3");
497   COMPARE(umaddl(x25, w21, w22, x16), "umaddl x25, w21, w22, x16");
498 
499   COMPARE(smsubl(x0, w1, w2, x3), "smsubl x0, w1, w2, x3");
500   COMPARE(smsubl(x25, w21, w22, x16), "smsubl x25, w21, w22, x16");
501   COMPARE(umsubl(x0, w1, w2, x3), "umsubl x0, w1, w2, x3");
502   COMPARE(umsubl(x25, w21, w22, x16), "umsubl x25, w21, w22, x16");
503 
504   CLEANUP();
505 }
506 
507 
TEST_(dp_1_source)508 TEST_(dp_1_source) {
509   SET_UP_ASM();
510 
511   COMPARE(rbit(w0, w1), "rbit w0, w1");
512   COMPARE(rbit(x2, x3), "rbit x2, x3");
513   COMPARE(rev16(w4, w5), "rev16 w4, w5");
514   COMPARE(rev16(x6, x7), "rev16 x6, x7");
515   COMPARE(rev32(x8, x9), "rev32 x8, x9");
516   COMPARE(rev(w10, w11), "rev w10, w11");
517   COMPARE(rev(x12, x13), "rev x12, x13");
518   COMPARE(clz(w14, w15), "clz w14, w15");
519   COMPARE(clz(x16, x17), "clz x16, x17");
520   COMPARE(cls(w18, w19), "cls w18, w19");
521   COMPARE(cls(x20, x21), "cls x20, x21");
522 
523   CLEANUP();
524 }
525 
526 
TEST_(bitfield)527 TEST_(bitfield) {
528   SET_UP_ASM();
529 
530   COMPARE(sxtb(w0, w1), "sxtb w0, w1");
531   COMPARE(sxtb(x2, x3), "sxtb x2, w3");
532   COMPARE(sxth(w4, w5), "sxth w4, w5");
533   COMPARE(sxth(x6, x7), "sxth x6, w7");
534   COMPARE(sxtw(x8, x9), "sxtw x8, w9");
535   COMPARE(sxtb(x0, w1), "sxtb x0, w1");
536   COMPARE(sxth(x2, w3), "sxth x2, w3");
537   COMPARE(sxtw(x4, w5), "sxtw x4, w5");
538 
539   COMPARE(uxtb(w10, w11), "uxtb w10, w11");
540   COMPARE(uxtb(x12, x13), "uxtb x12, w13");
541   COMPARE(uxth(w14, w15), "uxth w14, w15");
542   COMPARE(uxth(x16, x17), "uxth x16, w17");
543   COMPARE(uxtw(x18, x19), "ubfx x18, x19, #0, #32");
544 
545   COMPARE(asr(w20, w21, 10), "asr w20, w21, #10");
546   COMPARE(asr(x22, x23, 20), "asr x22, x23, #20");
547   COMPARE(lsr(w24, w25, 10), "lsr w24, w25, #10");
548   COMPARE(lsr(x26, cp, 20), "lsr x26, cp, #20");
549   COMPARE(lsl(w28, w29, 10), "lsl w28, w29, #10");
550   COMPARE(lsl(lr, x0, 20), "lsl lr, x0, #20");
551 
552   COMPARE(sbfiz(w1, w2, 1, 20), "sbfiz w1, w2, #1, #20");
553   COMPARE(sbfiz(x3, x4, 2, 19), "sbfiz x3, x4, #2, #19");
554   COMPARE(sbfx(w5, w6, 3, 18), "sbfx w5, w6, #3, #18");
555   COMPARE(sbfx(x7, x8, 4, 17), "sbfx x7, x8, #4, #17");
556   COMPARE(bfi(w9, w10, 5, 16), "bfi w9, w10, #5, #16");
557   COMPARE(bfi(x11, x12, 6, 15), "bfi x11, x12, #6, #15");
558   COMPARE(bfxil(w13, w14, 7, 14), "bfxil w13, w14, #7, #14");
559   COMPARE(bfxil(x15, x16, 8, 13), "bfxil x15, x16, #8, #13");
560   COMPARE(ubfiz(w17, w18, 9, 12), "ubfiz w17, w18, #9, #12");
561   COMPARE(ubfiz(x19, x20, 10, 11), "ubfiz x19, x20, #10, #11");
562   COMPARE(ubfx(w21, w22, 11, 10), "ubfx w21, w22, #11, #10");
563   COMPARE(ubfx(x23, x24, 12, 9), "ubfx x23, x24, #12, #9");
564 
565   CLEANUP();
566 }
567 
568 
TEST_(extract)569 TEST_(extract) {
570   SET_UP_ASM();
571 
572   COMPARE(extr(w0, w1, w2, 0), "extr w0, w1, w2, #0");
573   COMPARE(extr(x3, x4, x5, 1), "extr x3, x4, x5, #1");
574   COMPARE(extr(w6, w7, w8, 31), "extr w6, w7, w8, #31");
575   COMPARE(extr(x9, x10, x11, 63), "extr x9, x10, x11, #63");
576   COMPARE(extr(w12, w13, w13, 10), "ror w12, w13, #10");
577   COMPARE(extr(x14, x15, x15, 42), "ror x14, x15, #42");
578 
579   CLEANUP();
580 }
581 
582 
TEST_(logical_immediate)583 TEST_(logical_immediate) {
584   SET_UP_ASM();
585   #define RESULT_SIZE (256)
586 
587   char result[RESULT_SIZE];
588 
589   // Test immediate encoding - 64-bit destination.
590   // 64-bit patterns.
591   uint64_t value = 0x7fffffff;
592   for (int i = 0; i < 64; i++) {
593     snprintf(result, RESULT_SIZE, "and x0, x0, #0x%" PRIx64, value);
594     COMPARE(and_(x0, x0, Operand(value)), result);
595     value = ((value & 1) << 63) | (value >> 1);  // Rotate right 1 bit.
596   }
597 
598   // 32-bit patterns.
599   value = 0x00003fff00003fffL;
600   for (int i = 0; i < 32; i++) {
601     snprintf(result, RESULT_SIZE, "and x0, x0, #0x%" PRIx64, value);
602     COMPARE(and_(x0, x0, Operand(value)), result);
603     value = ((value & 1) << 63) | (value >> 1);  // Rotate right 1 bit.
604   }
605 
606   // 16-bit patterns.
607   value = 0x001f001f001f001fL;
608   for (int i = 0; i < 16; i++) {
609     snprintf(result, RESULT_SIZE, "and x0, x0, #0x%" PRIx64, value);
610     COMPARE(and_(x0, x0, Operand(value)), result);
611     value = ((value & 1) << 63) | (value >> 1);  // Rotate right 1 bit.
612   }
613 
614   // 8-bit patterns.
615   value = 0x0e0e0e0e0e0e0e0eL;
616   for (int i = 0; i < 8; i++) {
617     snprintf(result, RESULT_SIZE, "and x0, x0, #0x%" PRIx64, value);
618     COMPARE(and_(x0, x0, Operand(value)), result);
619     value = ((value & 1) << 63) | (value >> 1);  // Rotate right 1 bit.
620   }
621 
622   // 4-bit patterns.
623   value = 0x6666666666666666L;
624   for (int i = 0; i < 4; i++) {
625     snprintf(result, RESULT_SIZE, "and x0, x0, #0x%" PRIx64, value);
626     COMPARE(and_(x0, x0, Operand(value)), result);
627     value = ((value & 1) << 63) | (value >> 1);  // Rotate right 1 bit.
628   }
629 
630   // 2-bit patterns.
631   COMPARE(and_(x0, x0, Operand(0x5555555555555555L)),
632           "and x0, x0, #0x5555555555555555");
633   COMPARE(and_(x0, x0, Operand(0xaaaaaaaaaaaaaaaaL)),
634           "and x0, x0, #0xaaaaaaaaaaaaaaaa");
635 
636   // Test immediate encoding - 32-bit destination.
637   COMPARE(and_(w0, w0, Operand(0xff8007ff)),
638           "and w0, w0, #0xff8007ff");  // 32-bit pattern.
639   COMPARE(and_(w0, w0, Operand(0xf87ff87f)),
640           "and w0, w0, #0xf87ff87f");  // 16-bit pattern.
641   COMPARE(and_(w0, w0, Operand(0x87878787)),
642           "and w0, w0, #0x87878787");  // 8-bit pattern.
643   COMPARE(and_(w0, w0, Operand(0x66666666)),
644           "and w0, w0, #0x66666666");  // 4-bit pattern.
645   COMPARE(and_(w0, w0, Operand(0x55555555)),
646           "and w0, w0, #0x55555555");  // 2-bit pattern.
647 
648   // Test other instructions.
649   COMPARE(tst(w1, Operand(0x11111111)),
650           "tst w1, #0x11111111");
651   COMPARE(tst(x2, Operand(0x8888888888888888L)),
652           "tst x2, #0x8888888888888888");
653   COMPARE(orr(w7, w8, Operand(0xaaaaaaaa)),
654           "orr w7, w8, #0xaaaaaaaa");
655   COMPARE(orr(x9, x10, Operand(0x5555555555555555L)),
656           "orr x9, x10, #0x5555555555555555");
657   COMPARE(eor(w15, w16, Operand(0x00000001)),
658           "eor w15, w16, #0x1");
659   COMPARE(eor(x17, x18, Operand(0x0000000000000003L)),
660           "eor x17, x18, #0x3");
661   COMPARE(ands(w23, w24, Operand(0x0000000f)), "ands w23, w24, #0xf");
662   COMPARE(ands(x25, x26, Operand(0x800000000000000fL)),
663           "ands x25, x26, #0x800000000000000f");
664 
665   // Test inverse.
666   COMPARE(bic(w3, w4, Operand(0x20202020)),
667           "and w3, w4, #0xdfdfdfdf");
668   COMPARE(bic(x5, x6, Operand(0x4040404040404040L)),
669           "and x5, x6, #0xbfbfbfbfbfbfbfbf");
670   COMPARE(orn(w11, w12, Operand(0x40004000)),
671           "orr w11, w12, #0xbfffbfff");
672   COMPARE(orn(x13, x14, Operand(0x8181818181818181L)),
673           "orr x13, x14, #0x7e7e7e7e7e7e7e7e");
674   COMPARE(eon(w19, w20, Operand(0x80000001)),
675           "eor w19, w20, #0x7ffffffe");
676   COMPARE(eon(x21, x22, Operand(0xc000000000000003L)),
677           "eor x21, x22, #0x3ffffffffffffffc");
678   COMPARE(bics(w27, w28, Operand(0xfffffff7)), "ands w27, w28, #0x8");
679   COMPARE(bics(fp, x0, Operand(0xfffffffeffffffffL)),
680           "ands fp, x0, #0x100000000");
681 
682   // Test stack pointer.
683   COMPARE(and_(wcsp, wzr, Operand(7)), "and wcsp, wzr, #0x7");
684   COMPARE(ands(xzr, xzr, Operand(7)), "tst xzr, #0x7");
685   COMPARE(orr(csp, xzr, Operand(15)), "orr csp, xzr, #0xf");
686   COMPARE(eor(wcsp, w0, Operand(31)), "eor wcsp, w0, #0x1f");
687 
688   // Test move aliases.
689   COMPARE(orr(w0, wzr, Operand(0x00000780)), "orr w0, wzr, #0x780");
690   COMPARE(orr(w1, wzr, Operand(0x00007800)), "orr w1, wzr, #0x7800");
691   COMPARE(orr(w2, wzr, Operand(0x00078000)), "mov w2, #0x78000");
692   COMPARE(orr(w3, wzr, Operand(0x00780000)), "orr w3, wzr, #0x780000");
693   COMPARE(orr(w4, wzr, Operand(0x07800000)), "orr w4, wzr, #0x7800000");
694   COMPARE(orr(x5, xzr, Operand(0xffffffffffffc001UL)),
695           "orr x5, xzr, #0xffffffffffffc001");
696   COMPARE(orr(x6, xzr, Operand(0xfffffffffffc001fUL)),
697           "mov x6, #0xfffffffffffc001f");
698   COMPARE(orr(x7, xzr, Operand(0xffffffffffc001ffUL)),
699           "mov x7, #0xffffffffffc001ff");
700   COMPARE(orr(x8, xzr, Operand(0xfffffffffc001fffUL)),
701           "mov x8, #0xfffffffffc001fff");
702   COMPARE(orr(x9, xzr, Operand(0xffffffffc001ffffUL)),
703           "orr x9, xzr, #0xffffffffc001ffff");
704 
705   CLEANUP();
706 }
707 
708 
TEST_(logical_shifted)709 TEST_(logical_shifted) {
710   SET_UP_ASM();
711 
712   COMPARE(and_(w0, w1, Operand(w2)), "and w0, w1, w2");
713   COMPARE(and_(x3, x4, Operand(x5, LSL, 1)), "and x3, x4, x5, lsl #1");
714   COMPARE(and_(w6, w7, Operand(w8, LSR, 2)), "and w6, w7, w8, lsr #2");
715   COMPARE(and_(x9, x10, Operand(x11, ASR, 3)), "and x9, x10, x11, asr #3");
716   COMPARE(and_(w12, w13, Operand(w14, ROR, 4)), "and w12, w13, w14, ror #4");
717 
718   COMPARE(bic(w15, w16, Operand(w17)), "bic w15, w16, w17");
719   COMPARE(bic(x18, x19, Operand(x20, LSL, 5)), "bic x18, x19, x20, lsl #5");
720   COMPARE(bic(w21, w22, Operand(w23, LSR, 6)), "bic w21, w22, w23, lsr #6");
721   COMPARE(bic(x24, x25, Operand(x26, ASR, 7)), "bic x24, x25, x26, asr #7");
722   COMPARE(bic(w27, w28, Operand(w29, ROR, 8)), "bic w27, w28, w29, ror #8");
723 
724   COMPARE(orr(w0, w1, Operand(w2)), "orr w0, w1, w2");
725   COMPARE(orr(x3, x4, Operand(x5, LSL, 9)), "orr x3, x4, x5, lsl #9");
726   COMPARE(orr(w6, w7, Operand(w8, LSR, 10)), "orr w6, w7, w8, lsr #10");
727   COMPARE(orr(x9, x10, Operand(x11, ASR, 11)), "orr x9, x10, x11, asr #11");
728   COMPARE(orr(w12, w13, Operand(w14, ROR, 12)), "orr w12, w13, w14, ror #12");
729 
730   COMPARE(orn(w15, w16, Operand(w17)), "orn w15, w16, w17");
731   COMPARE(orn(x18, x19, Operand(x20, LSL, 13)), "orn x18, x19, x20, lsl #13");
732   COMPARE(orn(w21, w22, Operand(w23, LSR, 14)), "orn w21, w22, w23, lsr #14");
733   COMPARE(orn(x24, x25, Operand(x26, ASR, 15)), "orn x24, x25, x26, asr #15");
734   COMPARE(orn(w27, w28, Operand(w29, ROR, 16)), "orn w27, w28, w29, ror #16");
735 
736   COMPARE(eor(w0, w1, Operand(w2)), "eor w0, w1, w2");
737   COMPARE(eor(x3, x4, Operand(x5, LSL, 17)), "eor x3, x4, x5, lsl #17");
738   COMPARE(eor(w6, w7, Operand(w8, LSR, 18)), "eor w6, w7, w8, lsr #18");
739   COMPARE(eor(x9, x10, Operand(x11, ASR, 19)), "eor x9, x10, x11, asr #19");
740   COMPARE(eor(w12, w13, Operand(w14, ROR, 20)), "eor w12, w13, w14, ror #20");
741 
742   COMPARE(eon(w15, w16, Operand(w17)), "eon w15, w16, w17");
743   COMPARE(eon(x18, x19, Operand(x20, LSL, 21)), "eon x18, x19, x20, lsl #21");
744   COMPARE(eon(w21, w22, Operand(w23, LSR, 22)), "eon w21, w22, w23, lsr #22");
745   COMPARE(eon(x24, x25, Operand(x26, ASR, 23)), "eon x24, x25, x26, asr #23");
746   COMPARE(eon(w27, w28, Operand(w29, ROR, 24)), "eon w27, w28, w29, ror #24");
747 
748   COMPARE(ands(w0, w1, Operand(w2)), "ands w0, w1, w2");
749   COMPARE(ands(x3, x4, Operand(x5, LSL, 1)), "ands x3, x4, x5, lsl #1");
750   COMPARE(ands(w6, w7, Operand(w8, LSR, 2)), "ands w6, w7, w8, lsr #2");
751   COMPARE(ands(x9, x10, Operand(x11, ASR, 3)), "ands x9, x10, x11, asr #3");
752   COMPARE(ands(w12, w13, Operand(w14, ROR, 4)), "ands w12, w13, w14, ror #4");
753 
754   COMPARE(bics(w15, w16, Operand(w17)), "bics w15, w16, w17");
755   COMPARE(bics(x18, x19, Operand(x20, LSL, 5)), "bics x18, x19, x20, lsl #5");
756   COMPARE(bics(w21, w22, Operand(w23, LSR, 6)), "bics w21, w22, w23, lsr #6");
757   COMPARE(bics(x24, x25, Operand(x26, ASR, 7)), "bics x24, x25, x26, asr #7");
758   COMPARE(bics(w27, w28, Operand(w29, ROR, 8)), "bics w27, w28, w29, ror #8");
759 
760   COMPARE(tst(w0, Operand(w1)), "tst w0, w1");
761   COMPARE(tst(w2, Operand(w3, ROR, 10)), "tst w2, w3, ror #10");
762   COMPARE(tst(x0, Operand(x1)), "tst x0, x1");
763   COMPARE(tst(x2, Operand(x3, ROR, 42)), "tst x2, x3, ror #42");
764 
765   COMPARE(orn(w0, wzr, Operand(w1)), "mvn w0, w1");
766   COMPARE(orn(w2, wzr, Operand(w3, ASR, 5)), "mvn w2, w3, asr #5");
767   COMPARE(orn(x0, xzr, Operand(x1)), "mvn x0, x1");
768   COMPARE(orn(x2, xzr, Operand(x3, ASR, 42)), "mvn x2, x3, asr #42");
769 
770   COMPARE(orr(w0, wzr, Operand(w1)), "mov w0, w1");
771   COMPARE(orr(x0, xzr, Operand(x1)), "mov x0, x1");
772   COMPARE(orr(w16, wzr, Operand(w17, LSL, 1)), "orr w16, wzr, w17, lsl #1");
773   COMPARE(orr(x16, xzr, Operand(x17, ASR, 2)), "orr x16, xzr, x17, asr #2");
774 
775   CLEANUP();
776 }
777 
778 
TEST_(dp_2_source)779 TEST_(dp_2_source) {
780   SET_UP_ASM();
781 
782   COMPARE(lslv(w0, w1, w2), "lsl w0, w1, w2");
783   COMPARE(lslv(x3, x4, x5), "lsl x3, x4, x5");
784   COMPARE(lsrv(w6, w7, w8), "lsr w6, w7, w8");
785   COMPARE(lsrv(x9, x10, x11), "lsr x9, x10, x11");
786   COMPARE(asrv(w12, w13, w14), "asr w12, w13, w14");
787   COMPARE(asrv(x15, x16, x17), "asr x15, x16, x17");
788   COMPARE(rorv(w18, w19, w20), "ror w18, w19, w20");
789   COMPARE(rorv(x21, x22, x23), "ror x21, x22, x23");
790 
791   CLEANUP();
792 }
793 
794 
TEST_(adr)795 TEST_(adr) {
796   SET_UP_ASM();
797 
798   COMPARE_PREFIX(adr(x0, 0), "adr x0, #+0x0");
799   COMPARE_PREFIX(adr(x1, 1), "adr x1, #+0x1");
800   COMPARE_PREFIX(adr(x2, -1), "adr x2, #-0x1");
801   COMPARE_PREFIX(adr(x3, 4), "adr x3, #+0x4");
802   COMPARE_PREFIX(adr(x4, -4), "adr x4, #-0x4");
803   COMPARE_PREFIX(adr(x5, 0x000fffff), "adr x5, #+0xfffff");
804   COMPARE_PREFIX(adr(x6, -0x00100000), "adr x6, #-0x100000");
805   COMPARE_PREFIX(adr(xzr, 0), "adr xzr, #+0x0");
806 
807   CLEANUP();
808 }
809 
810 
TEST_(branch)811 TEST_(branch) {
812   SET_UP_ASM();
813 
814   #define INST_OFF(x) ((x) >> kInstructionSizeLog2)
815   COMPARE_PREFIX(b(INST_OFF(0x4)), "b #+0x4");
816   COMPARE_PREFIX(b(INST_OFF(-0x4)), "b #-0x4");
817   COMPARE_PREFIX(b(INST_OFF(0x7fffffc)), "b #+0x7fffffc");
818   COMPARE_PREFIX(b(INST_OFF(-0x8000000)), "b #-0x8000000");
819   COMPARE_PREFIX(b(INST_OFF(0xffffc), eq), "b.eq #+0xffffc");
820   COMPARE_PREFIX(b(INST_OFF(-0x100000), mi), "b.mi #-0x100000");
821   COMPARE_PREFIX(bl(INST_OFF(0x4)), "bl #+0x4");
822   COMPARE_PREFIX(bl(INST_OFF(-0x4)), "bl #-0x4");
823   COMPARE_PREFIX(bl(INST_OFF(0xffffc)), "bl #+0xffffc");
824   COMPARE_PREFIX(bl(INST_OFF(-0x100000)), "bl #-0x100000");
825   COMPARE_PREFIX(cbz(w0, INST_OFF(0xffffc)), "cbz w0, #+0xffffc");
826   COMPARE_PREFIX(cbz(x1, INST_OFF(-0x100000)), "cbz x1, #-0x100000");
827   COMPARE_PREFIX(cbnz(w2, INST_OFF(0xffffc)), "cbnz w2, #+0xffffc");
828   COMPARE_PREFIX(cbnz(x3, INST_OFF(-0x100000)), "cbnz x3, #-0x100000");
829   COMPARE_PREFIX(tbz(w4, 0, INST_OFF(0x7ffc)), "tbz w4, #0, #+0x7ffc");
830   COMPARE_PREFIX(tbz(x5, 63, INST_OFF(-0x8000)), "tbz x5, #63, #-0x8000");
831   COMPARE_PREFIX(tbz(w6, 31, INST_OFF(0)), "tbz w6, #31, #+0x0");
832   COMPARE_PREFIX(tbz(x7, 31, INST_OFF(0x4)), "tbz w7, #31, #+0x4");
833   COMPARE_PREFIX(tbz(x8, 32, INST_OFF(0x8)), "tbz x8, #32, #+0x8");
834   COMPARE_PREFIX(tbnz(w8, 0, INST_OFF(0x7ffc)), "tbnz w8, #0, #+0x7ffc");
835   COMPARE_PREFIX(tbnz(x9, 63, INST_OFF(-0x8000)), "tbnz x9, #63, #-0x8000");
836   COMPARE_PREFIX(tbnz(w10, 31, INST_OFF(0)), "tbnz w10, #31, #+0x0");
837   COMPARE_PREFIX(tbnz(x11, 31, INST_OFF(0x4)), "tbnz w11, #31, #+0x4");
838   COMPARE_PREFIX(tbnz(x12, 32, INST_OFF(0x8)), "tbnz x12, #32, #+0x8");
839   COMPARE(br(x0), "br x0");
840   COMPARE(blr(x1), "blr x1");
841   COMPARE(ret(x2), "ret x2");
842   COMPARE(ret(lr), "ret")
843 
844   CLEANUP();
845 }
846 
847 
TEST_(load_store)848 TEST_(load_store) {
849   SET_UP_ASM();
850 
851   COMPARE(ldr(w0, MemOperand(x1)), "ldr w0, [x1]");
852   COMPARE(ldr(w2, MemOperand(x3, 4)), "ldr w2, [x3, #4]");
853   COMPARE(ldr(w4, MemOperand(x5, 16380)), "ldr w4, [x5, #16380]");
854   COMPARE(ldr(x6, MemOperand(x7)), "ldr x6, [x7]");
855   COMPARE(ldr(x8, MemOperand(x9, 8)), "ldr x8, [x9, #8]");
856   COMPARE(ldr(x10, MemOperand(x11, 32760)), "ldr x10, [x11, #32760]");
857   COMPARE(str(w12, MemOperand(x13)), "str w12, [x13]");
858   COMPARE(str(w14, MemOperand(x15, 4)), "str w14, [x15, #4]");
859   COMPARE(str(w16, MemOperand(x17, 16380)), "str w16, [x17, #16380]");
860   COMPARE(str(x18, MemOperand(x19)), "str x18, [x19]");
861   COMPARE(str(x20, MemOperand(x21, 8)), "str x20, [x21, #8]");
862   COMPARE(str(x22, MemOperand(x23, 32760)), "str x22, [x23, #32760]");
863 
864   COMPARE(ldr(w0, MemOperand(x1, 4, PreIndex)), "ldr w0, [x1, #4]!");
865   COMPARE(ldr(w2, MemOperand(x3, 255, PreIndex)), "ldr w2, [x3, #255]!");
866   COMPARE(ldr(w4, MemOperand(x5, -256, PreIndex)), "ldr w4, [x5, #-256]!");
867   COMPARE(ldr(x6, MemOperand(x7, 8, PreIndex)), "ldr x6, [x7, #8]!");
868   COMPARE(ldr(x8, MemOperand(x9, 255, PreIndex)), "ldr x8, [x9, #255]!");
869   COMPARE(ldr(x10, MemOperand(x11, -256, PreIndex)), "ldr x10, [x11, #-256]!");
870   COMPARE(str(w12, MemOperand(x13, 4, PreIndex)), "str w12, [x13, #4]!");
871   COMPARE(str(w14, MemOperand(x15, 255, PreIndex)), "str w14, [x15, #255]!");
872   COMPARE(str(w16, MemOperand(x17, -256, PreIndex)), "str w16, [x17, #-256]!");
873   COMPARE(str(x18, MemOperand(x19, 8, PreIndex)), "str x18, [x19, #8]!");
874   COMPARE(str(x20, MemOperand(x21, 255, PreIndex)), "str x20, [x21, #255]!");
875   COMPARE(str(x22, MemOperand(x23, -256, PreIndex)), "str x22, [x23, #-256]!");
876 
877   COMPARE(ldr(w0, MemOperand(x1, 4, PostIndex)), "ldr w0, [x1], #4");
878   COMPARE(ldr(w2, MemOperand(x3, 255, PostIndex)), "ldr w2, [x3], #255");
879   COMPARE(ldr(w4, MemOperand(x5, -256, PostIndex)), "ldr w4, [x5], #-256");
880   COMPARE(ldr(x6, MemOperand(x7, 8, PostIndex)), "ldr x6, [x7], #8");
881   COMPARE(ldr(x8, MemOperand(x9, 255, PostIndex)), "ldr x8, [x9], #255");
882   COMPARE(ldr(x10, MemOperand(x11, -256, PostIndex)), "ldr x10, [x11], #-256");
883   COMPARE(str(w12, MemOperand(x13, 4, PostIndex)), "str w12, [x13], #4");
884   COMPARE(str(w14, MemOperand(x15, 255, PostIndex)), "str w14, [x15], #255");
885   COMPARE(str(w16, MemOperand(x17, -256, PostIndex)), "str w16, [x17], #-256");
886   COMPARE(str(x18, MemOperand(x19, 8, PostIndex)), "str x18, [x19], #8");
887   COMPARE(str(x20, MemOperand(x21, 255, PostIndex)), "str x20, [x21], #255");
888   COMPARE(str(x22, MemOperand(x23, -256, PostIndex)), "str x22, [x23], #-256");
889 
890   // TODO(all): Fix this for jssp.
891   COMPARE(ldr(w24, MemOperand(jssp)), "ldr w24, [jssp]");
892   COMPARE(ldr(x25, MemOperand(jssp, 8)), "ldr x25, [jssp, #8]");
893   COMPARE(str(w26, MemOperand(jssp, 4, PreIndex)), "str w26, [jssp, #4]!");
894   COMPARE(str(cp, MemOperand(jssp, -8, PostIndex)), "str cp, [jssp], #-8");
895 
896   COMPARE(ldrsw(x0, MemOperand(x1)), "ldrsw x0, [x1]");
897   COMPARE(ldrsw(x2, MemOperand(x3, 8)), "ldrsw x2, [x3, #8]");
898   COMPARE(ldrsw(x4, MemOperand(x5, 42, PreIndex)), "ldrsw x4, [x5, #42]!");
899   COMPARE(ldrsw(x6, MemOperand(x7, -11, PostIndex)), "ldrsw x6, [x7], #-11");
900 
901   CLEANUP();
902 }
903 
904 
TEST_(load_store_regoffset)905 TEST_(load_store_regoffset) {
906   SET_UP_ASM();
907 
908   COMPARE(ldr(w0, MemOperand(x1, w2, UXTW)), "ldr w0, [x1, w2, uxtw]");
909   COMPARE(ldr(w3, MemOperand(x4, w5, UXTW, 2)), "ldr w3, [x4, w5, uxtw #2]");
910   COMPARE(ldr(w6, MemOperand(x7, x8)), "ldr w6, [x7, x8]");
911   COMPARE(ldr(w9, MemOperand(x10, x11, LSL, 2)), "ldr w9, [x10, x11, lsl #2]");
912   COMPARE(ldr(w12, MemOperand(x13, w14, SXTW)), "ldr w12, [x13, w14, sxtw]");
913   COMPARE(ldr(w15, MemOperand(x16, w17, SXTW, 2)),
914           "ldr w15, [x16, w17, sxtw #2]");
915   COMPARE(ldr(w18, MemOperand(x19, x20, SXTX)), "ldr w18, [x19, x20, sxtx]");
916   COMPARE(ldr(w21, MemOperand(x22, x23, SXTX, 2)),
917           "ldr w21, [x22, x23, sxtx #2]");
918   COMPARE(ldr(x0, MemOperand(x1, w2, UXTW)), "ldr x0, [x1, w2, uxtw]");
919   COMPARE(ldr(x3, MemOperand(x4, w5, UXTW, 3)), "ldr x3, [x4, w5, uxtw #3]");
920   COMPARE(ldr(x6, MemOperand(x7, x8)), "ldr x6, [x7, x8]");
921   COMPARE(ldr(x9, MemOperand(x10, x11, LSL, 3)), "ldr x9, [x10, x11, lsl #3]");
922   COMPARE(ldr(x12, MemOperand(x13, w14, SXTW)), "ldr x12, [x13, w14, sxtw]");
923   COMPARE(ldr(x15, MemOperand(x16, w17, SXTW, 3)),
924           "ldr x15, [x16, w17, sxtw #3]");
925   COMPARE(ldr(x18, MemOperand(x19, x20, SXTX)), "ldr x18, [x19, x20, sxtx]");
926   COMPARE(ldr(x21, MemOperand(x22, x23, SXTX, 3)),
927           "ldr x21, [x22, x23, sxtx #3]");
928 
929   COMPARE(str(w0, MemOperand(x1, w2, UXTW)), "str w0, [x1, w2, uxtw]");
930   COMPARE(str(w3, MemOperand(x4, w5, UXTW, 2)), "str w3, [x4, w5, uxtw #2]");
931   COMPARE(str(w6, MemOperand(x7, x8)), "str w6, [x7, x8]");
932   COMPARE(str(w9, MemOperand(x10, x11, LSL, 2)), "str w9, [x10, x11, lsl #2]");
933   COMPARE(str(w12, MemOperand(x13, w14, SXTW)), "str w12, [x13, w14, sxtw]");
934   COMPARE(str(w15, MemOperand(x16, w17, SXTW, 2)),
935           "str w15, [x16, w17, sxtw #2]");
936   COMPARE(str(w18, MemOperand(x19, x20, SXTX)), "str w18, [x19, x20, sxtx]");
937   COMPARE(str(w21, MemOperand(x22, x23, SXTX, 2)),
938           "str w21, [x22, x23, sxtx #2]");
939   COMPARE(str(x0, MemOperand(x1, w2, UXTW)), "str x0, [x1, w2, uxtw]");
940   COMPARE(str(x3, MemOperand(x4, w5, UXTW, 3)), "str x3, [x4, w5, uxtw #3]");
941   COMPARE(str(x6, MemOperand(x7, x8)), "str x6, [x7, x8]");
942   COMPARE(str(x9, MemOperand(x10, x11, LSL, 3)), "str x9, [x10, x11, lsl #3]");
943   COMPARE(str(x12, MemOperand(x13, w14, SXTW)), "str x12, [x13, w14, sxtw]");
944   COMPARE(str(x15, MemOperand(x16, w17, SXTW, 3)),
945           "str x15, [x16, w17, sxtw #3]");
946   COMPARE(str(x18, MemOperand(x19, x20, SXTX)), "str x18, [x19, x20, sxtx]");
947   COMPARE(str(x21, MemOperand(x22, x23, SXTX, 3)),
948           "str x21, [x22, x23, sxtx #3]");
949 
950   COMPARE(ldrb(w0, MemOperand(x1, w2, UXTW)), "ldrb w0, [x1, w2, uxtw]");
951   COMPARE(ldrb(w6, MemOperand(x7, x8)), "ldrb w6, [x7, x8]");
952   COMPARE(ldrb(w12, MemOperand(x13, w14, SXTW)), "ldrb w12, [x13, w14, sxtw]");
953   COMPARE(ldrb(w18, MemOperand(x19, x20, SXTX)), "ldrb w18, [x19, x20, sxtx]");
954   COMPARE(strb(w0, MemOperand(x1, w2, UXTW)), "strb w0, [x1, w2, uxtw]");
955   COMPARE(strb(w6, MemOperand(x7, x8)), "strb w6, [x7, x8]");
956   COMPARE(strb(w12, MemOperand(x13, w14, SXTW)), "strb w12, [x13, w14, sxtw]");
957   COMPARE(strb(w18, MemOperand(x19, x20, SXTX)), "strb w18, [x19, x20, sxtx]");
958 
959   COMPARE(ldrh(w0, MemOperand(x1, w2, UXTW)), "ldrh w0, [x1, w2, uxtw]");
960   COMPARE(ldrh(w3, MemOperand(x4, w5, UXTW, 1)), "ldrh w3, [x4, w5, uxtw #1]");
961   COMPARE(ldrh(w6, MemOperand(x7, x8)), "ldrh w6, [x7, x8]");
962   COMPARE(ldrh(w9, MemOperand(x10, x11, LSL, 1)),
963           "ldrh w9, [x10, x11, lsl #1]");
964   COMPARE(ldrh(w12, MemOperand(x13, w14, SXTW)), "ldrh w12, [x13, w14, sxtw]");
965   COMPARE(ldrh(w15, MemOperand(x16, w17, SXTW, 1)),
966           "ldrh w15, [x16, w17, sxtw #1]");
967   COMPARE(ldrh(w18, MemOperand(x19, x20, SXTX)), "ldrh w18, [x19, x20, sxtx]");
968   COMPARE(ldrh(w21, MemOperand(x22, x23, SXTX, 1)),
969           "ldrh w21, [x22, x23, sxtx #1]");
970   COMPARE(strh(w0, MemOperand(x1, w2, UXTW)), "strh w0, [x1, w2, uxtw]");
971   COMPARE(strh(w3, MemOperand(x4, w5, UXTW, 1)), "strh w3, [x4, w5, uxtw #1]");
972   COMPARE(strh(w6, MemOperand(x7, x8)), "strh w6, [x7, x8]");
973   COMPARE(strh(w9, MemOperand(x10, x11, LSL, 1)),
974           "strh w9, [x10, x11, lsl #1]");
975   COMPARE(strh(w12, MemOperand(x13, w14, SXTW)), "strh w12, [x13, w14, sxtw]");
976   COMPARE(strh(w15, MemOperand(x16, w17, SXTW, 1)),
977           "strh w15, [x16, w17, sxtw #1]");
978   COMPARE(strh(w18, MemOperand(x19, x20, SXTX)), "strh w18, [x19, x20, sxtx]");
979   COMPARE(strh(w21, MemOperand(x22, x23, SXTX, 1)),
980           "strh w21, [x22, x23, sxtx #1]");
981 
982   // TODO(all): Fix this for jssp.
983   COMPARE(ldr(x0, MemOperand(jssp, wzr, SXTW)), "ldr x0, [jssp, wzr, sxtw]");
984   COMPARE(str(x1, MemOperand(jssp, xzr)), "str x1, [jssp, xzr]");
985 
986   CLEANUP();
987 }
988 
989 
TEST_(load_store_byte)990 TEST_(load_store_byte) {
991   SET_UP_ASM();
992 
993   COMPARE(ldrb(w0, MemOperand(x1)), "ldrb w0, [x1]");
994   COMPARE(ldrb(x2, MemOperand(x3)), "ldrb w2, [x3]");
995   COMPARE(ldrb(w4, MemOperand(x5, 4095)), "ldrb w4, [x5, #4095]");
996   COMPARE(ldrb(w6, MemOperand(x7, 255, PreIndex)), "ldrb w6, [x7, #255]!");
997   COMPARE(ldrb(w8, MemOperand(x9, -256, PreIndex)), "ldrb w8, [x9, #-256]!");
998   COMPARE(ldrb(w10, MemOperand(x11, 255, PostIndex)), "ldrb w10, [x11], #255");
999   COMPARE(ldrb(w12, MemOperand(x13, -256, PostIndex)),
1000           "ldrb w12, [x13], #-256");
1001   COMPARE(strb(w14, MemOperand(x15)), "strb w14, [x15]");
1002   COMPARE(strb(x16, MemOperand(x17)), "strb w16, [x17]");
1003   COMPARE(strb(w18, MemOperand(x19, 4095)), "strb w18, [x19, #4095]");
1004   COMPARE(strb(w20, MemOperand(x21, 255, PreIndex)), "strb w20, [x21, #255]!");
1005   COMPARE(strb(w22, MemOperand(x23, -256, PreIndex)),
1006           "strb w22, [x23, #-256]!");
1007   COMPARE(strb(w24, MemOperand(x25, 255, PostIndex)), "strb w24, [x25], #255");
1008   COMPARE(strb(w26, MemOperand(cp, -256, PostIndex)),
1009           "strb w26, [cp], #-256");
1010   // TODO(all): Fix this for jssp.
1011   COMPARE(ldrb(w28, MemOperand(jssp, 3, PostIndex)), "ldrb w28, [jssp], #3");
1012   COMPARE(strb(fp, MemOperand(jssp, -42, PreIndex)), "strb w29, [jssp, #-42]!");
1013   COMPARE(ldrsb(w0, MemOperand(x1)), "ldrsb w0, [x1]");
1014   COMPARE(ldrsb(x2, MemOperand(x3, 8)), "ldrsb x2, [x3, #8]");
1015   COMPARE(ldrsb(w4, MemOperand(x5, 42, PreIndex)), "ldrsb w4, [x5, #42]!");
1016   COMPARE(ldrsb(x6, MemOperand(x7, -11, PostIndex)), "ldrsb x6, [x7], #-11");
1017 
1018   CLEANUP();
1019 }
1020 
1021 
TEST_(load_store_half)1022 TEST_(load_store_half) {
1023   SET_UP_ASM();
1024 
1025   COMPARE(ldrh(w0, MemOperand(x1)), "ldrh w0, [x1]");
1026   COMPARE(ldrh(x2, MemOperand(x3)), "ldrh w2, [x3]");
1027   COMPARE(ldrh(w4, MemOperand(x5, 8190)), "ldrh w4, [x5, #8190]");
1028   COMPARE(ldrh(w6, MemOperand(x7, 255, PreIndex)), "ldrh w6, [x7, #255]!");
1029   COMPARE(ldrh(w8, MemOperand(x9, -256, PreIndex)), "ldrh w8, [x9, #-256]!");
1030   COMPARE(ldrh(w10, MemOperand(x11, 255, PostIndex)), "ldrh w10, [x11], #255");
1031   COMPARE(ldrh(w12, MemOperand(x13, -256, PostIndex)),
1032           "ldrh w12, [x13], #-256");
1033   COMPARE(strh(w14, MemOperand(x15)), "strh w14, [x15]");
1034   COMPARE(strh(x16, MemOperand(x17)), "strh w16, [x17]");
1035   COMPARE(strh(w18, MemOperand(x19, 8190)), "strh w18, [x19, #8190]");
1036   COMPARE(strh(w20, MemOperand(x21, 255, PreIndex)), "strh w20, [x21, #255]!");
1037   COMPARE(strh(w22, MemOperand(x23, -256, PreIndex)),
1038           "strh w22, [x23, #-256]!");
1039   COMPARE(strh(w24, MemOperand(x25, 255, PostIndex)), "strh w24, [x25], #255");
1040   COMPARE(strh(w26, MemOperand(cp, -256, PostIndex)),
1041           "strh w26, [cp], #-256");
1042   // TODO(all): Fix this for jssp.
1043   COMPARE(ldrh(w28, MemOperand(jssp, 3, PostIndex)), "ldrh w28, [jssp], #3");
1044   COMPARE(strh(fp, MemOperand(jssp, -42, PreIndex)), "strh w29, [jssp, #-42]!");
1045   COMPARE(ldrh(w30, MemOperand(x0, 255)), "ldurh w30, [x0, #255]");
1046   COMPARE(ldrh(x1, MemOperand(x2, -256)), "ldurh w1, [x2, #-256]");
1047   COMPARE(strh(w3, MemOperand(x4, 255)), "sturh w3, [x4, #255]");
1048   COMPARE(strh(x5, MemOperand(x6, -256)), "sturh w5, [x6, #-256]");
1049   COMPARE(ldrsh(w0, MemOperand(x1)), "ldrsh w0, [x1]");
1050   COMPARE(ldrsh(w2, MemOperand(x3, 8)), "ldrsh w2, [x3, #8]");
1051   COMPARE(ldrsh(w4, MemOperand(x5, 42, PreIndex)), "ldrsh w4, [x5, #42]!");
1052   COMPARE(ldrsh(x6, MemOperand(x7, -11, PostIndex)), "ldrsh x6, [x7], #-11");
1053 
1054   CLEANUP();
1055 }
1056 
1057 
TEST_(load_store_fp)1058 TEST_(load_store_fp) {
1059   SET_UP_ASM();
1060 
1061   COMPARE(ldr(s0, MemOperand(x1)), "ldr s0, [x1]");
1062   COMPARE(ldr(s2, MemOperand(x3, 4)), "ldr s2, [x3, #4]");
1063   COMPARE(ldr(s4, MemOperand(x5, 16380)), "ldr s4, [x5, #16380]");
1064   COMPARE(ldr(d6, MemOperand(x7)), "ldr d6, [x7]");
1065   COMPARE(ldr(d8, MemOperand(x9, 8)), "ldr d8, [x9, #8]");
1066   COMPARE(ldr(d10, MemOperand(x11, 32760)), "ldr d10, [x11, #32760]");
1067   COMPARE(str(s12, MemOperand(x13)), "str s12, [x13]");
1068   COMPARE(str(s14, MemOperand(x15, 4)), "str s14, [x15, #4]");
1069   COMPARE(str(s16, MemOperand(x17, 16380)), "str s16, [x17, #16380]");
1070   COMPARE(str(d18, MemOperand(x19)), "str d18, [x19]");
1071   COMPARE(str(d20, MemOperand(x21, 8)), "str d20, [x21, #8]");
1072   COMPARE(str(d22, MemOperand(x23, 32760)), "str d22, [x23, #32760]");
1073 
1074   COMPARE(ldr(s0, MemOperand(x1, 4, PreIndex)), "ldr s0, [x1, #4]!");
1075   COMPARE(ldr(s2, MemOperand(x3, 255, PreIndex)), "ldr s2, [x3, #255]!");
1076   COMPARE(ldr(s4, MemOperand(x5, -256, PreIndex)), "ldr s4, [x5, #-256]!");
1077   COMPARE(ldr(d6, MemOperand(x7, 8, PreIndex)), "ldr d6, [x7, #8]!");
1078   COMPARE(ldr(d8, MemOperand(x9, 255, PreIndex)), "ldr d8, [x9, #255]!");
1079   COMPARE(ldr(d10, MemOperand(x11, -256, PreIndex)), "ldr d10, [x11, #-256]!");
1080   COMPARE(str(s12, MemOperand(x13, 4, PreIndex)), "str s12, [x13, #4]!");
1081   COMPARE(str(s14, MemOperand(x15, 255, PreIndex)), "str s14, [x15, #255]!");
1082   COMPARE(str(s16, MemOperand(x17, -256, PreIndex)), "str s16, [x17, #-256]!");
1083   COMPARE(str(d18, MemOperand(x19, 8, PreIndex)), "str d18, [x19, #8]!");
1084   COMPARE(str(d20, MemOperand(x21, 255, PreIndex)), "str d20, [x21, #255]!");
1085   COMPARE(str(d22, MemOperand(x23, -256, PreIndex)), "str d22, [x23, #-256]!");
1086 
1087   COMPARE(ldr(s0, MemOperand(x1, 4, PostIndex)), "ldr s0, [x1], #4");
1088   COMPARE(ldr(s2, MemOperand(x3, 255, PostIndex)), "ldr s2, [x3], #255");
1089   COMPARE(ldr(s4, MemOperand(x5, -256, PostIndex)), "ldr s4, [x5], #-256");
1090   COMPARE(ldr(d6, MemOperand(x7, 8, PostIndex)), "ldr d6, [x7], #8");
1091   COMPARE(ldr(d8, MemOperand(x9, 255, PostIndex)), "ldr d8, [x9], #255");
1092   COMPARE(ldr(d10, MemOperand(x11, -256, PostIndex)), "ldr d10, [x11], #-256");
1093   COMPARE(str(s12, MemOperand(x13, 4, PostIndex)), "str s12, [x13], #4");
1094   COMPARE(str(s14, MemOperand(x15, 255, PostIndex)), "str s14, [x15], #255");
1095   COMPARE(str(s16, MemOperand(x17, -256, PostIndex)), "str s16, [x17], #-256");
1096   COMPARE(str(d18, MemOperand(x19, 8, PostIndex)), "str d18, [x19], #8");
1097   COMPARE(str(d20, MemOperand(x21, 255, PostIndex)), "str d20, [x21], #255");
1098   COMPARE(str(d22, MemOperand(x23, -256, PostIndex)), "str d22, [x23], #-256");
1099 
1100   // TODO(all): Fix this for jssp.
1101   COMPARE(ldr(s24, MemOperand(jssp)), "ldr s24, [jssp]");
1102   COMPARE(ldr(d25, MemOperand(jssp, 8)), "ldr d25, [jssp, #8]");
1103   COMPARE(str(s26, MemOperand(jssp, 4, PreIndex)), "str s26, [jssp, #4]!");
1104   COMPARE(str(d27, MemOperand(jssp, -8, PostIndex)), "str d27, [jssp], #-8");
1105 
1106   CLEANUP();
1107 }
1108 
1109 
TEST_(load_store_unscaled)1110 TEST_(load_store_unscaled) {
1111   SET_UP_ASM();
1112 
1113   COMPARE(ldr(w0, MemOperand(x1, 1)), "ldur w0, [x1, #1]");
1114   COMPARE(ldr(w2, MemOperand(x3, -1)), "ldur w2, [x3, #-1]");
1115   COMPARE(ldr(w4, MemOperand(x5, 255)), "ldur w4, [x5, #255]");
1116   COMPARE(ldr(w6, MemOperand(x7, -256)), "ldur w6, [x7, #-256]");
1117   COMPARE(ldr(x8, MemOperand(x9, 1)), "ldur x8, [x9, #1]");
1118   COMPARE(ldr(x10, MemOperand(x11, -1)), "ldur x10, [x11, #-1]");
1119   COMPARE(ldr(x12, MemOperand(x13, 255)), "ldur x12, [x13, #255]");
1120   COMPARE(ldr(x14, MemOperand(x15, -256)), "ldur x14, [x15, #-256]");
1121   COMPARE(str(w16, MemOperand(x17, 1)), "stur w16, [x17, #1]");
1122   COMPARE(str(w18, MemOperand(x19, -1)), "stur w18, [x19, #-1]");
1123   COMPARE(str(w20, MemOperand(x21, 255)), "stur w20, [x21, #255]");
1124   COMPARE(str(w22, MemOperand(x23, -256)), "stur w22, [x23, #-256]");
1125   COMPARE(str(x24, MemOperand(x25, 1)), "stur x24, [x25, #1]");
1126   COMPARE(str(x26, MemOperand(cp, -1)), "stur x26, [cp, #-1]");
1127   COMPARE(str(jssp, MemOperand(fp, 255)), "stur jssp, [fp, #255]");
1128   COMPARE(str(lr, MemOperand(x0, -256)), "stur lr, [x0, #-256]");
1129   COMPARE(ldr(w0, MemOperand(csp, 1)), "ldur w0, [csp, #1]");
1130   COMPARE(str(x1, MemOperand(csp, -1)), "stur x1, [csp, #-1]");
1131   COMPARE(ldrb(w2, MemOperand(x3, -2)), "ldurb w2, [x3, #-2]");
1132   COMPARE(ldrsb(w4, MemOperand(x5, -3)), "ldursb w4, [x5, #-3]");
1133   COMPARE(ldrsb(x6, MemOperand(x7, -4)), "ldursb x6, [x7, #-4]");
1134   COMPARE(ldrh(w8, MemOperand(x9, -5)), "ldurh w8, [x9, #-5]");
1135   COMPARE(ldrsh(w10, MemOperand(x11, -6)), "ldursh w10, [x11, #-6]");
1136   COMPARE(ldrsh(x12, MemOperand(x13, -7)), "ldursh x12, [x13, #-7]");
1137   COMPARE(ldrsw(x14, MemOperand(x15, -8)), "ldursw x14, [x15, #-8]");
1138 
1139   CLEANUP();
1140 }
1141 
1142 
TEST_(load_store_pair)1143 TEST_(load_store_pair) {
1144   SET_UP_ASM();
1145 
1146   COMPARE(ldp(w0, w1, MemOperand(x2)), "ldp w0, w1, [x2]");
1147   COMPARE(ldp(x3, x4, MemOperand(x5)), "ldp x3, x4, [x5]");
1148   COMPARE(ldp(w6, w7, MemOperand(x8, 4)), "ldp w6, w7, [x8, #4]");
1149   COMPARE(ldp(x9, x10, MemOperand(x11, 8)), "ldp x9, x10, [x11, #8]");
1150   COMPARE(ldp(w12, w13, MemOperand(x14, 252)), "ldp w12, w13, [x14, #252]");
1151   COMPARE(ldp(x15, x16, MemOperand(x17, 504)), "ldp x15, x16, [x17, #504]");
1152   COMPARE(ldp(w18, w19, MemOperand(x20, -256)), "ldp w18, w19, [x20, #-256]");
1153   COMPARE(ldp(x21, x22, MemOperand(x23, -512)), "ldp x21, x22, [x23, #-512]");
1154   COMPARE(ldp(w24, w25, MemOperand(x26, 252, PreIndex)),
1155           "ldp w24, w25, [x26, #252]!");
1156   COMPARE(ldp(cp, jssp, MemOperand(fp, 504, PreIndex)),
1157           "ldp cp, jssp, [fp, #504]!");
1158   COMPARE(ldp(w30, w0, MemOperand(x1, -256, PreIndex)),
1159           "ldp w30, w0, [x1, #-256]!");
1160   COMPARE(ldp(x2, x3, MemOperand(x4, -512, PreIndex)),
1161           "ldp x2, x3, [x4, #-512]!");
1162   COMPARE(ldp(w5, w6, MemOperand(x7, 252, PostIndex)),
1163           "ldp w5, w6, [x7], #252");
1164   COMPARE(ldp(x8, x9, MemOperand(x10, 504, PostIndex)),
1165           "ldp x8, x9, [x10], #504");
1166   COMPARE(ldp(w11, w12, MemOperand(x13, -256, PostIndex)),
1167           "ldp w11, w12, [x13], #-256");
1168   COMPARE(ldp(x14, x15, MemOperand(x16, -512, PostIndex)),
1169           "ldp x14, x15, [x16], #-512");
1170 
1171   COMPARE(ldp(s17, s18, MemOperand(x19)), "ldp s17, s18, [x19]");
1172   COMPARE(ldp(s20, s21, MemOperand(x22, 252)), "ldp s20, s21, [x22, #252]");
1173   COMPARE(ldp(s23, s24, MemOperand(x25, -256)), "ldp s23, s24, [x25, #-256]");
1174   COMPARE(ldp(s26, s27, MemOperand(jssp, 252, PreIndex)),
1175           "ldp s26, s27, [jssp, #252]!");
1176   COMPARE(ldp(s29, s30, MemOperand(fp, -256, PreIndex)),
1177           "ldp s29, s30, [fp, #-256]!");
1178   COMPARE(ldp(s31, s0, MemOperand(x1, 252, PostIndex)),
1179           "ldp s31, s0, [x1], #252");
1180   COMPARE(ldp(s2, s3, MemOperand(x4, -256, PostIndex)),
1181           "ldp s2, s3, [x4], #-256");
1182   COMPARE(ldp(d17, d18, MemOperand(x19)), "ldp d17, d18, [x19]");
1183   COMPARE(ldp(d20, d21, MemOperand(x22, 504)), "ldp d20, d21, [x22, #504]");
1184   COMPARE(ldp(d23, d24, MemOperand(x25, -512)), "ldp d23, d24, [x25, #-512]");
1185   COMPARE(ldp(d26, d27, MemOperand(jssp, 504, PreIndex)),
1186           "ldp d26, d27, [jssp, #504]!");
1187   COMPARE(ldp(d29, d30, MemOperand(fp, -512, PreIndex)),
1188           "ldp d29, d30, [fp, #-512]!");
1189   COMPARE(ldp(d31, d0, MemOperand(x1, 504, PostIndex)),
1190           "ldp d31, d0, [x1], #504");
1191   COMPARE(ldp(d2, d3, MemOperand(x4, -512, PostIndex)),
1192           "ldp d2, d3, [x4], #-512");
1193 
1194   COMPARE(stp(w0, w1, MemOperand(x2)), "stp w0, w1, [x2]");
1195   COMPARE(stp(x3, x4, MemOperand(x5)), "stp x3, x4, [x5]");
1196   COMPARE(stp(w6, w7, MemOperand(x8, 4)), "stp w6, w7, [x8, #4]");
1197   COMPARE(stp(x9, x10, MemOperand(x11, 8)), "stp x9, x10, [x11, #8]");
1198   COMPARE(stp(w12, w13, MemOperand(x14, 252)), "stp w12, w13, [x14, #252]");
1199   COMPARE(stp(x15, x16, MemOperand(x17, 504)), "stp x15, x16, [x17, #504]");
1200   COMPARE(stp(w18, w19, MemOperand(x20, -256)), "stp w18, w19, [x20, #-256]");
1201   COMPARE(stp(x21, x22, MemOperand(x23, -512)), "stp x21, x22, [x23, #-512]");
1202   COMPARE(stp(w24, w25, MemOperand(x26, 252, PreIndex)),
1203           "stp w24, w25, [x26, #252]!");
1204   COMPARE(stp(cp, jssp, MemOperand(fp, 504, PreIndex)),
1205           "stp cp, jssp, [fp, #504]!");
1206   COMPARE(stp(w30, w0, MemOperand(x1, -256, PreIndex)),
1207           "stp w30, w0, [x1, #-256]!");
1208   COMPARE(stp(x2, x3, MemOperand(x4, -512, PreIndex)),
1209           "stp x2, x3, [x4, #-512]!");
1210   COMPARE(stp(w5, w6, MemOperand(x7, 252, PostIndex)),
1211           "stp w5, w6, [x7], #252");
1212   COMPARE(stp(x8, x9, MemOperand(x10, 504, PostIndex)),
1213           "stp x8, x9, [x10], #504");
1214   COMPARE(stp(w11, w12, MemOperand(x13, -256, PostIndex)),
1215           "stp w11, w12, [x13], #-256");
1216   COMPARE(stp(x14, x15, MemOperand(x16, -512, PostIndex)),
1217           "stp x14, x15, [x16], #-512");
1218 
1219   COMPARE(stp(s17, s18, MemOperand(x19)), "stp s17, s18, [x19]");
1220   COMPARE(stp(s20, s21, MemOperand(x22, 252)), "stp s20, s21, [x22, #252]");
1221   COMPARE(stp(s23, s24, MemOperand(x25, -256)), "stp s23, s24, [x25, #-256]");
1222   COMPARE(stp(s26, s27, MemOperand(jssp, 252, PreIndex)),
1223           "stp s26, s27, [jssp, #252]!");
1224   COMPARE(stp(s29, s30, MemOperand(fp, -256, PreIndex)),
1225           "stp s29, s30, [fp, #-256]!");
1226   COMPARE(stp(s31, s0, MemOperand(x1, 252, PostIndex)),
1227           "stp s31, s0, [x1], #252");
1228   COMPARE(stp(s2, s3, MemOperand(x4, -256, PostIndex)),
1229           "stp s2, s3, [x4], #-256");
1230   COMPARE(stp(d17, d18, MemOperand(x19)), "stp d17, d18, [x19]");
1231   COMPARE(stp(d20, d21, MemOperand(x22, 504)), "stp d20, d21, [x22, #504]");
1232   COMPARE(stp(d23, d24, MemOperand(x25, -512)), "stp d23, d24, [x25, #-512]");
1233   COMPARE(stp(d26, d27, MemOperand(jssp, 504, PreIndex)),
1234           "stp d26, d27, [jssp, #504]!");
1235   COMPARE(stp(d29, d30, MemOperand(fp, -512, PreIndex)),
1236           "stp d29, d30, [fp, #-512]!");
1237   COMPARE(stp(d31, d0, MemOperand(x1, 504, PostIndex)),
1238           "stp d31, d0, [x1], #504");
1239   COMPARE(stp(d2, d3, MemOperand(x4, -512, PostIndex)),
1240           "stp d2, d3, [x4], #-512");
1241 
1242   // TODO(all): Update / Restore this test.
1243   COMPARE(ldp(w16, w17, MemOperand(jssp, 4, PostIndex)),
1244           "ldp w16, w17, [jssp], #4");
1245   COMPARE(stp(x18, x19, MemOperand(jssp, -8, PreIndex)),
1246           "stp x18, x19, [jssp, #-8]!");
1247   COMPARE(ldp(s30, s31, MemOperand(jssp, 12, PostIndex)),
1248           "ldp s30, s31, [jssp], #12");
1249   COMPARE(stp(d30, d31, MemOperand(jssp, -16)),
1250           "stp d30, d31, [jssp, #-16]");
1251 
1252   COMPARE(ldpsw(x0, x1, MemOperand(x2)), "ldpsw x0, x1, [x2]");
1253   COMPARE(ldpsw(x3, x4, MemOperand(x5, 16)), "ldpsw x3, x4, [x5, #16]");
1254   COMPARE(ldpsw(x6, x7, MemOperand(x8, -32, PreIndex)),
1255           "ldpsw x6, x7, [x8, #-32]!");
1256   COMPARE(ldpsw(x9, x10, MemOperand(x11, 128, PostIndex)),
1257           "ldpsw x9, x10, [x11], #128");
1258 
1259   CLEANUP();
1260 }
1261 
1262 
1263 #if 0  // TODO(all): enable.
1264 TEST_(load_literal) {
1265   SET_UP_ASM();
1266 
1267   COMPARE_PREFIX(ldr(x10, 0x1234567890abcdefUL),  "ldr x10, pc+8");
1268   COMPARE_PREFIX(ldr(w20, 0xfedcba09),  "ldr w20, pc+8");
1269   COMPARE_PREFIX(ldr(d11, 1.234),  "ldr d11, pc+8");
1270   COMPARE_PREFIX(ldr(s22, 2.5f),  "ldr s22, pc+8");
1271 
1272   CLEANUP();
1273 }
1274 #endif
1275 
TEST_(cond_select)1276 TEST_(cond_select) {
1277   SET_UP_ASM();
1278 
1279   COMPARE(csel(w0, w1, w2, eq), "csel w0, w1, w2, eq");
1280   COMPARE(csel(x3, x4, x5, ne), "csel x3, x4, x5, ne");
1281   COMPARE(csinc(w6, w7, w8, hs), "csinc w6, w7, w8, hs");
1282   COMPARE(csinc(x9, x10, x11, lo), "csinc x9, x10, x11, lo");
1283   COMPARE(csinv(w12, w13, w14, mi), "csinv w12, w13, w14, mi");
1284   COMPARE(csinv(x15, x16, x17, pl), "csinv x15, x16, x17, pl");
1285   COMPARE(csneg(w18, w19, w20, vs), "csneg w18, w19, w20, vs");
1286   COMPARE(csneg(x21, x22, x23, vc), "csneg x21, x22, x23, vc");
1287   COMPARE(cset(w24, hi), "cset w24, hi");
1288   COMPARE(cset(x25, ls), "cset x25, ls");
1289   COMPARE(csetm(w26, ge), "csetm w26, ge");
1290   COMPARE(csetm(cp, lt), "csetm cp, lt");
1291   COMPARE(cinc(w28, w29, gt), "cinc w28, w29, gt");
1292   COMPARE(cinc(lr, x0, le), "cinc lr, x0, le");
1293   COMPARE(cinv(w1, w2, eq), "cinv w1, w2, eq");
1294   COMPARE(cinv(x3, x4, ne), "cinv x3, x4, ne");
1295   COMPARE(cneg(w5, w6, hs), "cneg w5, w6, hs");
1296   COMPARE(cneg(x7, x8, lo), "cneg x7, x8, lo");
1297 
1298   COMPARE(csel(x0, x1, x2, al), "csel x0, x1, x2, al");
1299   COMPARE(csel(x1, x2, x3, nv), "csel x1, x2, x3, nv");
1300   COMPARE(csinc(x2, x3, x4, al), "csinc x2, x3, x4, al");
1301   COMPARE(csinc(x3, x4, x5, nv), "csinc x3, x4, x5, nv");
1302   COMPARE(csinv(x4, x5, x6, al), "csinv x4, x5, x6, al");
1303   COMPARE(csinv(x5, x6, x7, nv), "csinv x5, x6, x7, nv");
1304   COMPARE(csneg(x6, x7, x8, al), "csneg x6, x7, x8, al");
1305   COMPARE(csneg(x7, x8, x9, nv), "csneg x7, x8, x9, nv");
1306 
1307   CLEANUP();
1308 }
1309 
1310 
TEST(cond_select_macro)1311 TEST(cond_select_macro) {
1312   SET_UP_MASM();
1313 
1314   COMPARE(Csel(w0, w1, -1, eq), "csinv w0, w1, wzr, eq");
1315   COMPARE(Csel(w2, w3, 0, ne), "csel w2, w3, wzr, ne");
1316   COMPARE(Csel(w4, w5, 1, hs), "csinc w4, w5, wzr, hs");
1317   COMPARE(Csel(x6, x7, -1, lo), "csinv x6, x7, xzr, lo");
1318   COMPARE(Csel(x8, x9, 0, mi), "csel x8, x9, xzr, mi");
1319   COMPARE(Csel(x10, x11, 1, pl), "csinc x10, x11, xzr, pl");
1320 
1321   CLEANUP();
1322 }
1323 
1324 
TEST_(cond_cmp)1325 TEST_(cond_cmp) {
1326   SET_UP_ASM();
1327 
1328   COMPARE(ccmn(w0, w1, NZCVFlag, eq), "ccmn w0, w1, #NZCV, eq");
1329   COMPARE(ccmn(x2, x3, NZCFlag, ne), "ccmn x2, x3, #NZCv, ne");
1330   COMPARE(ccmp(w4, w5, NZVFlag, hs), "ccmp w4, w5, #NZcV, hs");
1331   COMPARE(ccmp(x6, x7, NZFlag, lo), "ccmp x6, x7, #NZcv, lo");
1332   COMPARE(ccmn(w8, 31, NFlag, mi), "ccmn w8, #31, #Nzcv, mi");
1333   COMPARE(ccmn(x9, 30, NCFlag, pl), "ccmn x9, #30, #NzCv, pl");
1334   COMPARE(ccmp(w10, 29, NVFlag, vs), "ccmp w10, #29, #NzcV, vs");
1335   COMPARE(ccmp(x11, 28, NFlag, vc), "ccmp x11, #28, #Nzcv, vc");
1336   COMPARE(ccmn(w12, w13, NoFlag, al), "ccmn w12, w13, #nzcv, al");
1337   COMPARE(ccmp(x14, 27, ZVFlag, nv), "ccmp x14, #27, #nZcV, nv");
1338 
1339   CLEANUP();
1340 }
1341 
1342 
TEST_(cond_cmp_macro)1343 TEST_(cond_cmp_macro) {
1344   SET_UP_MASM();
1345 
1346   COMPARE(Ccmp(w0, -1, VFlag, hi), "ccmn w0, #1, #nzcV, hi");
1347   COMPARE(Ccmp(x1, -31, CFlag, ge), "ccmn x1, #31, #nzCv, ge");
1348   COMPARE(Ccmn(w2, -1, CVFlag, gt), "ccmp w2, #1, #nzCV, gt");
1349   COMPARE(Ccmn(x3, -31, ZCVFlag, ls), "ccmp x3, #31, #nZCV, ls");
1350 
1351   CLEANUP();
1352 }
1353 
1354 
TEST_(fmov_imm)1355 TEST_(fmov_imm) {
1356   SET_UP_ASM();
1357 
1358   COMPARE(fmov(s0, 1.0f), "fmov s0, #0x70 (1.0000)");
1359   COMPARE(fmov(s31, -13.0f), "fmov s31, #0xaa (-13.0000)");
1360   COMPARE(fmov(d1, 1.0), "fmov d1, #0x70 (1.0000)");
1361   COMPARE(fmov(d29, -13.0), "fmov d29, #0xaa (-13.0000)");
1362 
1363   CLEANUP();
1364 }
1365 
1366 
TEST_(fmov_reg)1367 TEST_(fmov_reg) {
1368   SET_UP_ASM();
1369 
1370   COMPARE(fmov(w3, s13), "fmov w3, s13");
1371   COMPARE(fmov(x6, d26), "fmov x6, d26");
1372   COMPARE(fmov(s11, w30), "fmov s11, w30");
1373   COMPARE(fmov(d31, x2), "fmov d31, x2");
1374   COMPARE(fmov(s12, s13), "fmov s12, s13");
1375   COMPARE(fmov(d22, d23), "fmov d22, d23");
1376 
1377   CLEANUP();
1378 }
1379 
1380 
TEST_(fp_dp1)1381 TEST_(fp_dp1) {
1382   SET_UP_ASM();
1383 
1384   COMPARE(fabs(s0, s1), "fabs s0, s1");
1385   COMPARE(fabs(s31, s30), "fabs s31, s30");
1386   COMPARE(fabs(d2, d3), "fabs d2, d3");
1387   COMPARE(fabs(d31, d30), "fabs d31, d30");
1388   COMPARE(fneg(s4, s5), "fneg s4, s5");
1389   COMPARE(fneg(s31, s30), "fneg s31, s30");
1390   COMPARE(fneg(d6, d7), "fneg d6, d7");
1391   COMPARE(fneg(d31, d30), "fneg d31, d30");
1392   COMPARE(fsqrt(s8, s9), "fsqrt s8, s9");
1393   COMPARE(fsqrt(s31, s30), "fsqrt s31, s30");
1394   COMPARE(fsqrt(d10, d11), "fsqrt d10, d11");
1395   COMPARE(fsqrt(d31, d30), "fsqrt d31, d30");
1396   COMPARE(frinta(s10, s11), "frinta s10, s11");
1397   COMPARE(frinta(s31, s30), "frinta s31, s30");
1398   COMPARE(frinta(d12, d13), "frinta d12, d13");
1399   COMPARE(frinta(d31, d30), "frinta d31, d30");
1400   COMPARE(frintn(s10, s11), "frintn s10, s11");
1401   COMPARE(frintn(s31, s30), "frintn s31, s30");
1402   COMPARE(frintn(d12, d13), "frintn d12, d13");
1403   COMPARE(frintn(d31, d30), "frintn d31, d30");
1404   COMPARE(frintp(s10, s11), "frintp s10, s11");
1405   COMPARE(frintp(s31, s30), "frintp s31, s30");
1406   COMPARE(frintp(d12, d13), "frintp d12, d13");
1407   COMPARE(frintp(d31, d30), "frintp d31, d30");
1408   COMPARE(frintz(s10, s11), "frintz s10, s11");
1409   COMPARE(frintz(s31, s30), "frintz s31, s30");
1410   COMPARE(frintz(d12, d13), "frintz d12, d13");
1411   COMPARE(frintz(d31, d30), "frintz d31, d30");
1412   COMPARE(fcvt(d14, s15), "fcvt d14, s15");
1413   COMPARE(fcvt(d31, s31), "fcvt d31, s31");
1414 
1415   CLEANUP();
1416 }
1417 
1418 
TEST_(fp_dp2)1419 TEST_(fp_dp2) {
1420   SET_UP_ASM();
1421 
1422   COMPARE(fadd(s0, s1, s2), "fadd s0, s1, s2");
1423   COMPARE(fadd(d3, d4, d5), "fadd d3, d4, d5");
1424   COMPARE(fsub(s31, s30, s29), "fsub s31, s30, s29");
1425   COMPARE(fsub(d31, d30, d29), "fsub d31, d30, d29");
1426   COMPARE(fmul(s7, s8, s9), "fmul s7, s8, s9");
1427   COMPARE(fmul(d10, d11, d12), "fmul d10, d11, d12");
1428   COMPARE(fdiv(s13, s14, s15), "fdiv s13, s14, s15");
1429   COMPARE(fdiv(d16, d17, d18), "fdiv d16, d17, d18");
1430   COMPARE(fmax(s19, s20, s21), "fmax s19, s20, s21");
1431   COMPARE(fmax(d22, d23, d24), "fmax d22, d23, d24");
1432   COMPARE(fmin(s25, s26, s27), "fmin s25, s26, s27");
1433   COMPARE(fmin(d28, d29, d30), "fmin d28, d29, d30");
1434   COMPARE(fmaxnm(s31, s0, s1), "fmaxnm s31, s0, s1");
1435   COMPARE(fmaxnm(d2, d3, d4), "fmaxnm d2, d3, d4");
1436   COMPARE(fminnm(s5, s6, s7), "fminnm s5, s6, s7");
1437   COMPARE(fminnm(d8, d9, d10), "fminnm d8, d9, d10");
1438 
1439   CLEANUP();
1440 }
1441 
1442 
TEST(fp_dp3)1443 TEST(fp_dp3) {
1444   SET_UP_ASM();
1445 
1446   COMPARE(fmadd(s7, s8, s9, s10), "fmadd s7, s8, s9, s10");
1447   COMPARE(fmadd(d10, d11, d12, d10), "fmadd d10, d11, d12, d10");
1448   COMPARE(fmsub(s7, s8, s9, s10), "fmsub s7, s8, s9, s10");
1449   COMPARE(fmsub(d10, d11, d12, d10), "fmsub d10, d11, d12, d10");
1450 
1451   COMPARE(fnmadd(s7, s8, s9, s10), "fnmadd s7, s8, s9, s10");
1452   COMPARE(fnmadd(d10, d11, d12, d10), "fnmadd d10, d11, d12, d10");
1453   COMPARE(fnmsub(s7, s8, s9, s10), "fnmsub s7, s8, s9, s10");
1454   COMPARE(fnmsub(d10, d11, d12, d10), "fnmsub d10, d11, d12, d10");
1455 
1456   CLEANUP();
1457 }
1458 
1459 
TEST_(fp_compare)1460 TEST_(fp_compare) {
1461   SET_UP_ASM();
1462 
1463   COMPARE(fcmp(s0, s1), "fcmp s0, s1");
1464   COMPARE(fcmp(s31, s30), "fcmp s31, s30");
1465   COMPARE(fcmp(d0, d1), "fcmp d0, d1");
1466   COMPARE(fcmp(d31, d30), "fcmp d31, d30");
1467   COMPARE(fcmp(s12, 0), "fcmp s12, #0.0");
1468   COMPARE(fcmp(d12, 0), "fcmp d12, #0.0");
1469 
1470   CLEANUP();
1471 }
1472 
1473 
TEST_(fp_cond_compare)1474 TEST_(fp_cond_compare) {
1475   SET_UP_ASM();
1476 
1477   COMPARE(fccmp(s0, s1, NoFlag, eq), "fccmp s0, s1, #nzcv, eq");
1478   COMPARE(fccmp(s2, s3, ZVFlag, ne), "fccmp s2, s3, #nZcV, ne");
1479   COMPARE(fccmp(s30, s16, NCFlag, pl), "fccmp s30, s16, #NzCv, pl");
1480   COMPARE(fccmp(s31, s31, NZCVFlag, le), "fccmp s31, s31, #NZCV, le");
1481   COMPARE(fccmp(d4, d5, VFlag, gt), "fccmp d4, d5, #nzcV, gt");
1482   COMPARE(fccmp(d6, d7, NFlag, vs), "fccmp d6, d7, #Nzcv, vs");
1483   COMPARE(fccmp(d30, d0, NZFlag, vc), "fccmp d30, d0, #NZcv, vc");
1484   COMPARE(fccmp(d31, d31, ZFlag, hs), "fccmp d31, d31, #nZcv, hs");
1485   COMPARE(fccmp(s14, s15, CVFlag, al), "fccmp s14, s15, #nzCV, al");
1486   COMPARE(fccmp(d16, d17, CFlag, nv), "fccmp d16, d17, #nzCv, nv");
1487 
1488   CLEANUP();
1489 }
1490 
1491 
TEST_(fp_select)1492 TEST_(fp_select) {
1493   SET_UP_ASM();
1494 
1495   COMPARE(fcsel(s0, s1, s2, eq), "fcsel s0, s1, s2, eq")
1496   COMPARE(fcsel(s31, s31, s30, ne), "fcsel s31, s31, s30, ne");
1497   COMPARE(fcsel(d0, d1, d2, mi), "fcsel d0, d1, d2, mi");
1498   COMPARE(fcsel(d31, d30, d31, pl), "fcsel d31, d30, d31, pl");
1499   COMPARE(fcsel(s14, s15, s16, al), "fcsel s14, s15, s16, al");
1500   COMPARE(fcsel(d17, d18, d19, nv), "fcsel d17, d18, d19, nv");
1501 
1502   CLEANUP();
1503 }
1504 
1505 
TEST_(fcvt_scvtf_ucvtf)1506 TEST_(fcvt_scvtf_ucvtf) {
1507   SET_UP_ASM();
1508 
1509   COMPARE(fcvtas(w0, s1), "fcvtas w0, s1");
1510   COMPARE(fcvtas(x2, s3), "fcvtas x2, s3");
1511   COMPARE(fcvtas(w4, d5), "fcvtas w4, d5");
1512   COMPARE(fcvtas(x6, d7), "fcvtas x6, d7");
1513   COMPARE(fcvtau(w8, s9), "fcvtau w8, s9");
1514   COMPARE(fcvtau(x10, s11), "fcvtau x10, s11");
1515   COMPARE(fcvtau(w12, d13), "fcvtau w12, d13");
1516   COMPARE(fcvtau(x14, d15), "fcvtau x14, d15");
1517   COMPARE(fcvtns(w0, s1), "fcvtns w0, s1");
1518   COMPARE(fcvtns(x2, s3), "fcvtns x2, s3");
1519   COMPARE(fcvtns(w4, d5), "fcvtns w4, d5");
1520   COMPARE(fcvtns(x6, d7), "fcvtns x6, d7");
1521   COMPARE(fcvtnu(w8, s9), "fcvtnu w8, s9");
1522   COMPARE(fcvtnu(x10, s11), "fcvtnu x10, s11");
1523   COMPARE(fcvtnu(w12, d13), "fcvtnu w12, d13");
1524   COMPARE(fcvtnu(x14, d15), "fcvtnu x14, d15");
1525   COMPARE(fcvtzu(x16, d17), "fcvtzu x16, d17");
1526   COMPARE(fcvtzu(w18, d19), "fcvtzu w18, d19");
1527   COMPARE(fcvtzs(x20, d21), "fcvtzs x20, d21");
1528   COMPARE(fcvtzs(w22, d23), "fcvtzs w22, d23");
1529   COMPARE(fcvtzu(x16, s17), "fcvtzu x16, s17");
1530   COMPARE(fcvtzu(w18, s19), "fcvtzu w18, s19");
1531   COMPARE(fcvtzs(x20, s21), "fcvtzs x20, s21");
1532   COMPARE(fcvtzs(w22, s23), "fcvtzs w22, s23");
1533   COMPARE(scvtf(d24, w25), "scvtf d24, w25");
1534   COMPARE(scvtf(s24, w25), "scvtf s24, w25");
1535   COMPARE(scvtf(d26, x0), "scvtf d26, x0");
1536   COMPARE(scvtf(s26, x0), "scvtf s26, x0");
1537   COMPARE(ucvtf(d28, w29), "ucvtf d28, w29");
1538   COMPARE(ucvtf(s28, w29), "ucvtf s28, w29");
1539   COMPARE(ucvtf(d0, x1), "ucvtf d0, x1");
1540   COMPARE(ucvtf(s0, x1), "ucvtf s0, x1");
1541   COMPARE(ucvtf(d0, x1, 0), "ucvtf d0, x1");
1542   COMPARE(ucvtf(s0, x1, 0), "ucvtf s0, x1");
1543   COMPARE(scvtf(d1, x2, 1), "scvtf d1, x2, #1");
1544   COMPARE(scvtf(s1, x2, 1), "scvtf s1, x2, #1");
1545   COMPARE(scvtf(d3, x4, 15), "scvtf d3, x4, #15");
1546   COMPARE(scvtf(s3, x4, 15), "scvtf s3, x4, #15");
1547   COMPARE(scvtf(d5, x6, 32), "scvtf d5, x6, #32");
1548   COMPARE(scvtf(s5, x6, 32), "scvtf s5, x6, #32");
1549   COMPARE(ucvtf(d7, x8, 2), "ucvtf d7, x8, #2");
1550   COMPARE(ucvtf(s7, x8, 2), "ucvtf s7, x8, #2");
1551   COMPARE(ucvtf(d9, x10, 16), "ucvtf d9, x10, #16");
1552   COMPARE(ucvtf(s9, x10, 16), "ucvtf s9, x10, #16");
1553   COMPARE(ucvtf(d11, x12, 33), "ucvtf d11, x12, #33");
1554   COMPARE(ucvtf(s11, x12, 33), "ucvtf s11, x12, #33");
1555   COMPARE(fcvtms(w0, s1), "fcvtms w0, s1");
1556   COMPARE(fcvtms(x2, s3), "fcvtms x2, s3");
1557   COMPARE(fcvtms(w4, d5), "fcvtms w4, d5");
1558   COMPARE(fcvtms(x6, d7), "fcvtms x6, d7");
1559   COMPARE(fcvtmu(w8, s9), "fcvtmu w8, s9");
1560   COMPARE(fcvtmu(x10, s11), "fcvtmu x10, s11");
1561   COMPARE(fcvtmu(w12, d13), "fcvtmu w12, d13");
1562   COMPARE(fcvtmu(x14, d15), "fcvtmu x14, d15");
1563 
1564   CLEANUP();
1565 }
1566 
1567 
TEST_(system_mrs)1568 TEST_(system_mrs) {
1569   SET_UP_ASM();
1570 
1571   COMPARE(mrs(x0, NZCV), "mrs x0, nzcv");
1572   COMPARE(mrs(lr, NZCV), "mrs lr, nzcv");
1573   COMPARE(mrs(x15, FPCR), "mrs x15, fpcr");
1574 
1575   CLEANUP();
1576 }
1577 
1578 
TEST_(system_msr)1579 TEST_(system_msr) {
1580   SET_UP_ASM();
1581 
1582   COMPARE(msr(NZCV, x0), "msr nzcv, x0");
1583   COMPARE(msr(NZCV, x30), "msr nzcv, lr");
1584   COMPARE(msr(FPCR, x15), "msr fpcr, x15");
1585 
1586   CLEANUP();
1587 }
1588 
1589 
TEST_(system_nop)1590 TEST_(system_nop) {
1591   SET_UP_ASM();
1592 
1593   COMPARE(nop(), "nop");
1594 
1595   CLEANUP();
1596 }
1597 
1598 
TEST_(debug)1599 TEST_(debug) {
1600   SET_UP_ASM();
1601 
1602   CHECK(kImmExceptionIsDebug == 0xdeb0);
1603 
1604   // All debug codes should produce the same instruction, and the debug code
1605   // can be any uint32_t.
1606   COMPARE(debug("message", 0, BREAK), "hlt #0xdeb0");
1607   COMPARE(debug("message", 1, BREAK), "hlt #0xdeb0");
1608   COMPARE(debug("message", 0xffff, BREAK), "hlt #0xdeb0");
1609   COMPARE(debug("message", 0x10000, BREAK), "hlt #0xdeb0");
1610   COMPARE(debug("message", 0x7fffffff, BREAK), "hlt #0xdeb0");
1611   COMPARE(debug("message", 0x80000000u, BREAK), "hlt #0xdeb0");
1612   COMPARE(debug("message", 0xffffffffu, BREAK), "hlt #0xdeb0");
1613 
1614   CLEANUP();
1615 }
1616 
1617 
TEST_(hlt)1618 TEST_(hlt) {
1619   SET_UP_ASM();
1620 
1621   COMPARE(hlt(0), "hlt #0x0");
1622   COMPARE(hlt(1), "hlt #0x1");
1623   COMPARE(hlt(65535), "hlt #0xffff");
1624 
1625   CLEANUP();
1626 }
1627 
1628 
TEST_(brk)1629 TEST_(brk) {
1630   SET_UP_ASM();
1631 
1632   COMPARE(brk(0), "brk #0x0");
1633   COMPARE(brk(1), "brk #0x1");
1634   COMPARE(brk(65535), "brk #0xffff");
1635 
1636   CLEANUP();
1637 }
1638 
1639 
TEST_(add_sub_negative)1640 TEST_(add_sub_negative) {
1641   SET_UP_MASM();
1642 
1643   COMPARE(Add(x10, x0, -42), "sub x10, x0, #0x2a (42)");
1644   COMPARE(Add(x11, x1, -687), "sub x11, x1, #0x2af (687)");
1645   COMPARE(Add(x12, x2, -0x88), "sub x12, x2, #0x88 (136)");
1646 
1647   COMPARE(Sub(x13, x0, -600), "add x13, x0, #0x258 (600)");
1648   COMPARE(Sub(x14, x1, -313), "add x14, x1, #0x139 (313)");
1649   COMPARE(Sub(x15, x2, -0x555), "add x15, x2, #0x555 (1365)");
1650 
1651   COMPARE(Add(w19, w3, -0x344), "sub w19, w3, #0x344 (836)");
1652   COMPARE(Add(w20, w4, -2000), "sub w20, w4, #0x7d0 (2000)");
1653 
1654   COMPARE(Sub(w21, w3, -0xbc), "add w21, w3, #0xbc (188)");
1655   COMPARE(Sub(w22, w4, -2000), "add w22, w4, #0x7d0 (2000)");
1656 
1657   COMPARE(Cmp(w0, -1), "cmn w0, #0x1 (1)");
1658   COMPARE(Cmp(x1, -1), "cmn x1, #0x1 (1)");
1659   COMPARE(Cmp(w2, -4095), "cmn w2, #0xfff (4095)");
1660   COMPARE(Cmp(x3, -4095), "cmn x3, #0xfff (4095)");
1661 
1662   COMPARE(Cmn(w0, -1), "cmp w0, #0x1 (1)");
1663   COMPARE(Cmn(x1, -1), "cmp x1, #0x1 (1)");
1664   COMPARE(Cmn(w2, -4095), "cmp w2, #0xfff (4095)");
1665   COMPARE(Cmn(x3, -4095), "cmp x3, #0xfff (4095)");
1666 
1667   CLEANUP();
1668 }
1669 
1670 
TEST_(logical_immediate_move)1671 TEST_(logical_immediate_move) {
1672   SET_UP_MASM();
1673 
1674   COMPARE(And(w0, w1, 0), "movz w0, #0x0");
1675   COMPARE(And(x0, x1, 0), "movz x0, #0x0");
1676   COMPARE(Orr(w2, w3, 0), "mov w2, w3");
1677   COMPARE(Orr(x2, x3, 0), "mov x2, x3");
1678   COMPARE(Eor(w4, w5, 0), "mov w4, w5");
1679   COMPARE(Eor(x4, x5, 0), "mov x4, x5");
1680   COMPARE(Bic(w6, w7, 0), "mov w6, w7");
1681   COMPARE(Bic(x6, x7, 0), "mov x6, x7");
1682   COMPARE(Orn(w8, w9, 0), "movn w8, #0x0");
1683   COMPARE(Orn(x8, x9, 0), "movn x8, #0x0");
1684   COMPARE(Eon(w10, w11, 0), "mvn w10, w11");
1685   COMPARE(Eon(x10, x11, 0), "mvn x10, x11");
1686 
1687   COMPARE(And(w12, w13, 0xffffffff), "mov w12, w13");
1688   COMPARE(And(x12, x13, 0xffffffff), "and x12, x13, #0xffffffff");
1689   COMPARE(And(x12, x13, 0xffffffffffffffff), "mov x12, x13");
1690   COMPARE(Orr(w14, w15, 0xffffffff), "movn w14, #0x0");
1691   COMPARE(Orr(x14, x15, 0xffffffff), "orr x14, x15, #0xffffffff");
1692   COMPARE(Orr(x14, x15, 0xffffffffffffffff), "movn x14, #0x0");
1693   COMPARE(Eor(w16, w17, 0xffffffff), "mvn w16, w17");
1694   COMPARE(Eor(x16, x17, 0xffffffff), "eor x16, x17, #0xffffffff");
1695   COMPARE(Eor(x16, x17, 0xffffffffffffffff), "mvn x16, x17");
1696   COMPARE(Bic(w18, w19, 0xffffffff), "movz w18, #0x0");
1697   COMPARE(Bic(x18, x19, 0xffffffff), "and x18, x19, #0xffffffff00000000");
1698   COMPARE(Bic(x18, x19, 0xffffffffffffffff), "movz x18, #0x0");
1699   COMPARE(Orn(w20, w21, 0xffffffff), "mov w20, w21");
1700   COMPARE(Orn(x20, x21, 0xffffffff), "orr x20, x21, #0xffffffff00000000");
1701   COMPARE(Orn(x20, x21, 0xffffffffffffffff), "mov x20, x21");
1702   COMPARE(Eon(w22, w23, 0xffffffff), "mov w22, w23");
1703   COMPARE(Eon(x22, x23, 0xffffffff), "eor x22, x23, #0xffffffff00000000");
1704   COMPARE(Eon(x22, x23, 0xffffffffffffffff), "mov x22, x23");
1705 
1706   CLEANUP();
1707 }
1708 
1709 
TEST_(barriers)1710 TEST_(barriers) {
1711   SET_UP_MASM();
1712 
1713   // DMB
1714   COMPARE(Dmb(FullSystem, BarrierAll), "dmb sy");
1715   COMPARE(Dmb(FullSystem, BarrierReads), "dmb ld");
1716   COMPARE(Dmb(FullSystem, BarrierWrites), "dmb st");
1717 
1718   COMPARE(Dmb(InnerShareable, BarrierAll), "dmb ish");
1719   COMPARE(Dmb(InnerShareable, BarrierReads), "dmb ishld");
1720   COMPARE(Dmb(InnerShareable, BarrierWrites), "dmb ishst");
1721 
1722   COMPARE(Dmb(NonShareable, BarrierAll), "dmb nsh");
1723   COMPARE(Dmb(NonShareable, BarrierReads), "dmb nshld");
1724   COMPARE(Dmb(NonShareable, BarrierWrites), "dmb nshst");
1725 
1726   COMPARE(Dmb(OuterShareable, BarrierAll), "dmb osh");
1727   COMPARE(Dmb(OuterShareable, BarrierReads), "dmb oshld");
1728   COMPARE(Dmb(OuterShareable, BarrierWrites), "dmb oshst");
1729 
1730   COMPARE(Dmb(FullSystem, BarrierOther), "dmb sy (0b1100)");
1731   COMPARE(Dmb(InnerShareable, BarrierOther), "dmb sy (0b1000)");
1732   COMPARE(Dmb(NonShareable, BarrierOther), "dmb sy (0b0100)");
1733   COMPARE(Dmb(OuterShareable, BarrierOther), "dmb sy (0b0000)");
1734 
1735   // DSB
1736   COMPARE(Dsb(FullSystem, BarrierAll), "dsb sy");
1737   COMPARE(Dsb(FullSystem, BarrierReads), "dsb ld");
1738   COMPARE(Dsb(FullSystem, BarrierWrites), "dsb st");
1739 
1740   COMPARE(Dsb(InnerShareable, BarrierAll), "dsb ish");
1741   COMPARE(Dsb(InnerShareable, BarrierReads), "dsb ishld");
1742   COMPARE(Dsb(InnerShareable, BarrierWrites), "dsb ishst");
1743 
1744   COMPARE(Dsb(NonShareable, BarrierAll), "dsb nsh");
1745   COMPARE(Dsb(NonShareable, BarrierReads), "dsb nshld");
1746   COMPARE(Dsb(NonShareable, BarrierWrites), "dsb nshst");
1747 
1748   COMPARE(Dsb(OuterShareable, BarrierAll), "dsb osh");
1749   COMPARE(Dsb(OuterShareable, BarrierReads), "dsb oshld");
1750   COMPARE(Dsb(OuterShareable, BarrierWrites), "dsb oshst");
1751 
1752   COMPARE(Dsb(FullSystem, BarrierOther), "dsb sy (0b1100)");
1753   COMPARE(Dsb(InnerShareable, BarrierOther), "dsb sy (0b1000)");
1754   COMPARE(Dsb(NonShareable, BarrierOther), "dsb sy (0b0100)");
1755   COMPARE(Dsb(OuterShareable, BarrierOther), "dsb sy (0b0000)");
1756 
1757   // ISB
1758   COMPARE(Isb(), "isb");
1759 
1760   CLEANUP();
1761 }
1762