blob: 7f85cba65e13dcc304c3f5f49c6c2b98733e8482 [file] [log] [blame]
armvixlad96eda2013-06-14 11:42:37 +01001// Copyright 2013, ARM Limited
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#include <stdio.h>
28#include <cstring>
29#include "cctest.h"
30
31#include "a64/macro-assembler-a64.h"
32#include "a64/disasm-a64.h"
33
34#define TEST(name) TEST_(DISASM_##name)
35
36#define EXP_SIZE (256)
37#define INSTR_SIZE (1024)
38#define SETUP_CLASS(ASMCLASS) \
39 byte* buf = static_cast<byte*>(malloc(INSTR_SIZE)); \
40 uint32_t encoding = 0; \
41 ASMCLASS* masm = new ASMCLASS(buf, INSTR_SIZE); \
42 Decoder* decoder = new Decoder(); \
43 Disassembler* disasm = new Disassembler(); \
44 decoder->AppendVisitor(disasm)
45
46#define SETUP() SETUP_CLASS(Assembler)
47
48#define COMPARE(ASM, EXP) \
49 masm->Reset(); \
50 masm->ASM; \
51 masm->FinalizeCode(); \
52 decoder->Decode(reinterpret_cast<Instruction*>(buf)); \
53 encoding = *reinterpret_cast<uint32_t*>(buf); \
54 if (strcmp(disasm->GetOutput(), EXP) != 0) { \
55 printf("Encoding: %08" PRIx32 "\nExpected: %s\nFound: %s\n", \
56 encoding, EXP, disasm->GetOutput()); \
57 abort(); \
58 }
59
armvixl578645f2013-08-15 17:21:42 +010060#define COMPARE_PREFIX(ASM, EXP) \
61 masm->Reset(); \
62 masm->ASM; \
63 masm->FinalizeCode(); \
64 decoder->Decode(reinterpret_cast<Instruction*>(buf)); \
65 encoding = *reinterpret_cast<uint32_t*>(buf); \
66 if (strncmp(disasm->GetOutput(), EXP, strlen(EXP)) != 0) { \
67 printf("Encoding: %08" PRIx32 "\nExpected: %s\nFound: %s\n", \
68 encoding, EXP, disasm->GetOutput()); \
69 abort(); \
70 }
71
armvixlad96eda2013-06-14 11:42:37 +010072#define CLEANUP() \
73 delete disasm; \
74 delete decoder; \
75 delete masm
76
77namespace vixl {
78
79TEST(bootstrap) {
80 SETUP();
81
82 // Instructions generated by C compiler, disassembled by objdump, and
83 // reformatted to suit our disassembly style.
84 COMPARE(dci(0xa9ba7bfd), "stp x29, x30, [sp, #-96]!");
85 COMPARE(dci(0x910003fd), "mov x29, sp");
86 COMPARE(dci(0x9100e3a0), "add x0, x29, #0x38 (56)");
87 COMPARE(dci(0xb900001f), "str wzr, [x0]");
88 COMPARE(dci(0x528000e1), "movz w1, #0x7");
89 COMPARE(dci(0xb9001c01), "str w1, [x0, #28]");
90 COMPARE(dci(0x390043a0), "strb w0, [x29, #16]");
91 COMPARE(dci(0x790027a0), "strh w0, [x29, #18]");
92 COMPARE(dci(0xb9400400), "ldr w0, [x0, #4]");
93 COMPARE(dci(0x0b000021), "add w1, w1, w0");
94 COMPARE(dci(0x531b6800), "lsl w0, w0, #5");
95 COMPARE(dci(0x521e0400), "eor w0, w0, #0xc");
96 COMPARE(dci(0x72af0f00), "movk w0, #0x7878, lsl #16");
97 COMPARE(dci(0xd360fc00), "lsr x0, x0, #32");
98 COMPARE(dci(0x13037c01), "asr w1, w0, #3");
99 COMPARE(dci(0x4b000021), "sub w1, w1, w0");
100 COMPARE(dci(0x2a0103e0), "mov w0, w1");
101 COMPARE(dci(0x93407c00), "sxtw x0, w0");
102 COMPARE(dci(0x2a000020), "orr w0, w1, w0");
103 COMPARE(dci(0xa8c67bfd), "ldp x29, x30, [sp], #96");
104
105 CLEANUP();
106}
107
armvixl4a102ba2014-07-14 09:02:40 +0100108
armvixlad96eda2013-06-14 11:42:37 +0100109TEST(mov_mvn) {
110 SETUP_CLASS(MacroAssembler);
111
112 COMPARE(Mov(w0, Operand(0x1234)), "movz w0, #0x1234");
113 COMPARE(Mov(x1, Operand(0x1234)), "movz x1, #0x1234");
114 COMPARE(Mov(w2, Operand(w3)), "mov w2, w3");
115 COMPARE(Mov(x4, Operand(x5)), "mov x4, x5");
116 COMPARE(Mov(w6, Operand(w7, LSL, 5)), "lsl w6, w7, #5");
117 COMPARE(Mov(x8, Operand(x9, ASR, 42)), "asr x8, x9, #42");
118 COMPARE(Mov(w10, Operand(w11, UXTB)), "uxtb w10, w11");
119 COMPARE(Mov(x12, Operand(x13, UXTB, 1)), "ubfiz x12, x13, #1, #8");
120 COMPARE(Mov(w14, Operand(w15, SXTH, 2)), "sbfiz w14, w15, #2, #16");
121 COMPARE(Mov(x16, Operand(x17, SXTW, 3)), "sbfiz x16, x17, #3, #32");
122
armvixlf37fdc02014-02-05 13:22:16 +0000123 COMPARE(Mvn(w0, Operand(0x101)), "movn w0, #0x101");
124 COMPARE(Mvn(x1, Operand(0xfff1)), "movn x1, #0xfff1");
armvixlad96eda2013-06-14 11:42:37 +0100125 COMPARE(Mvn(w2, Operand(w3)), "mvn w2, w3");
126 COMPARE(Mvn(x4, Operand(x5)), "mvn x4, x5");
127 COMPARE(Mvn(w6, Operand(w7, LSL, 12)), "mvn w6, w7, lsl #12");
128 COMPARE(Mvn(x8, Operand(x9, ASR, 63)), "mvn x8, x9, asr #63");
129
130 CLEANUP();
131}
132
armvixl4a102ba2014-07-14 09:02:40 +0100133
armvixlad96eda2013-06-14 11:42:37 +0100134TEST(move_immediate) {
135 SETUP();
136
137 COMPARE(movz(w0, 0x1234), "movz w0, #0x1234");
138 COMPARE(movz(x1, 0xabcd0000), "movz x1, #0xabcd0000");
139 COMPARE(movz(x2, 0x555500000000), "movz x2, #0x555500000000");
140 COMPARE(movz(x3, 0xaaaa000000000000), "movz x3, #0xaaaa000000000000");
141 COMPARE(movz(x4, 0xabcd, 16), "movz x4, #0xabcd0000");
142 COMPARE(movz(x5, 0x5555, 32), "movz x5, #0x555500000000");
143 COMPARE(movz(x6, 0xaaaa, 48), "movz x6, #0xaaaa000000000000");
144
145 COMPARE(movk(w7, 0x1234), "movk w7, #0x1234");
146 COMPARE(movk(x8, 0xabcd0000), "movk x8, #0xabcd, lsl #16");
147 COMPARE(movk(x9, 0x555500000000), "movk x9, #0x5555, lsl #32");
148 COMPARE(movk(x10, 0xaaaa000000000000), "movk x10, #0xaaaa, lsl #48");
149 COMPARE(movk(w11, 0xabcd, 16), "movk w11, #0xabcd, lsl #16");
150 COMPARE(movk(x12, 0x5555, 32), "movk x12, #0x5555, lsl #32");
151 COMPARE(movk(x13, 0xaaaa, 48), "movk x13, #0xaaaa, lsl #48");
152
153 COMPARE(movn(w14, 0x1234), "movn w14, #0x1234");
154 COMPARE(movn(x15, 0xabcd0000), "movn x15, #0xabcd0000");
155 COMPARE(movn(x16, 0x555500000000), "movn x16, #0x555500000000");
156 COMPARE(movn(x17, 0xaaaa000000000000), "movn x17, #0xaaaa000000000000");
157 COMPARE(movn(w18, 0xabcd, 16), "movn w18, #0xabcd0000");
158 COMPARE(movn(x19, 0x5555, 32), "movn x19, #0x555500000000");
159 COMPARE(movn(x20, 0xaaaa, 48), "movn x20, #0xaaaa000000000000");
160
161 COMPARE(movk(w21, 0), "movk w21, #0x0");
162 COMPARE(movk(x22, 0, 0), "movk x22, #0x0");
163 COMPARE(movk(w23, 0, 16), "movk w23, #0x0, lsl #16");
164 COMPARE(movk(x24, 0, 32), "movk x24, #0x0, lsl #32");
165 COMPARE(movk(x25, 0, 48), "movk x25, #0x0, lsl #48");
166
167 CLEANUP();
168}
169
armvixl4a102ba2014-07-14 09:02:40 +0100170
armvixlf37fdc02014-02-05 13:22:16 +0000171TEST(move_immediate_2) {
172 SETUP_CLASS(MacroAssembler);
173
174 // Move instructions expected for certain immediates. This is really a macro
175 // assembler test, to ensure it generates immediates efficiently.
176 COMPARE(Mov(w0, 0), "movz w0, #0x0");
177 COMPARE(Mov(w0, 0x0000ffff), "movz w0, #0xffff");
178 COMPARE(Mov(w0, 0x00010000), "movz w0, #0x10000");
179 COMPARE(Mov(w0, 0xffff0000), "movz w0, #0xffff0000");
180 COMPARE(Mov(w0, 0x0001ffff), "movn w0, #0xfffe0000");
181 COMPARE(Mov(w0, 0xffff8000), "movn w0, #0x7fff");
182 COMPARE(Mov(w0, 0xfffffffe), "movn w0, #0x1");
183 COMPARE(Mov(w0, 0xffffffff), "movn w0, #0x0");
184 COMPARE(Mov(w0, 0x00ffff00), "mov w0, #0xffff00");
185 COMPARE(Mov(w0, 0xfffe7fff), "mov w0, #0xfffe7fff");
186 COMPARE(Mov(w0, 0xfffeffff), "movn w0, #0x10000");
187 COMPARE(Mov(w0, 0xffff7fff), "movn w0, #0x8000");
188
189 COMPARE(Mov(x0, 0), "movz x0, #0x0");
190 COMPARE(Mov(x0, 0x0000ffff), "movz x0, #0xffff");
191 COMPARE(Mov(x0, 0x00010000), "movz x0, #0x10000");
192 COMPARE(Mov(x0, 0xffff0000), "movz x0, #0xffff0000");
193 COMPARE(Mov(x0, 0x0001ffff), "mov x0, #0x1ffff");
194 COMPARE(Mov(x0, 0xffff8000), "mov x0, #0xffff8000");
195 COMPARE(Mov(x0, 0xfffffffe), "mov x0, #0xfffffffe");
196 COMPARE(Mov(x0, 0xffffffff), "mov x0, #0xffffffff");
197 COMPARE(Mov(x0, 0x00ffff00), "mov x0, #0xffff00");
198 COMPARE(Mov(x0, 0xffff000000000000), "movz x0, #0xffff000000000000");
199 COMPARE(Mov(x0, 0x0000ffff00000000), "movz x0, #0xffff00000000");
200 COMPARE(Mov(x0, 0x00000000ffff0000), "movz x0, #0xffff0000");
201 COMPARE(Mov(x0, 0xffffffffffff0000), "movn x0, #0xffff");
202 COMPARE(Mov(x0, 0xffffffff0000ffff), "movn x0, #0xffff0000");
203 COMPARE(Mov(x0, 0xffff0000ffffffff), "movn x0, #0xffff00000000");
204 COMPARE(Mov(x0, 0x0000ffffffffffff), "movn x0, #0xffff000000000000");
205 COMPARE(Mov(x0, 0xfffe7fffffffffff), "mov x0, #0xfffe7fffffffffff");
206 COMPARE(Mov(x0, 0xfffeffffffffffff), "movn x0, #0x1000000000000");
207 COMPARE(Mov(x0, 0xffff7fffffffffff), "movn x0, #0x800000000000");
208 COMPARE(Mov(x0, 0xfffffffe7fffffff), "mov x0, #0xfffffffe7fffffff");
209 COMPARE(Mov(x0, 0xfffffffeffffffff), "movn x0, #0x100000000");
210 COMPARE(Mov(x0, 0xffffffff7fffffff), "movn x0, #0x80000000");
211 COMPARE(Mov(x0, 0xfffffffffffe7fff), "mov x0, #0xfffffffffffe7fff");
212 COMPARE(Mov(x0, 0xfffffffffffeffff), "movn x0, #0x10000");
213 COMPARE(Mov(x0, 0xffffffffffff7fff), "movn x0, #0x8000");
214 COMPARE(Mov(x0, 0xffffffffffffffff), "movn x0, #0x0");
215
216 COMPARE(Movk(w0, 0x1234, 0), "movk w0, #0x1234");
217 COMPARE(Movk(x1, 0x2345, 0), "movk x1, #0x2345");
218 COMPARE(Movk(w2, 0x3456, 16), "movk w2, #0x3456, lsl #16");
219 COMPARE(Movk(x3, 0x4567, 16), "movk x3, #0x4567, lsl #16");
220 COMPARE(Movk(x4, 0x5678, 32), "movk x4, #0x5678, lsl #32");
221 COMPARE(Movk(x5, 0x6789, 48), "movk x5, #0x6789, lsl #48");
222
223 CLEANUP();
224}
225
armvixl4a102ba2014-07-14 09:02:40 +0100226
armvixlad96eda2013-06-14 11:42:37 +0100227TEST(add_immediate) {
228 SETUP();
229
230 COMPARE(add(w0, w1, Operand(0xff)), "add w0, w1, #0xff (255)");
231 COMPARE(add(x2, x3, Operand(0x3ff)), "add x2, x3, #0x3ff (1023)");
232 COMPARE(add(w4, w5, Operand(0xfff)), "add w4, w5, #0xfff (4095)");
233 COMPARE(add(x6, x7, Operand(0x1000)), "add x6, x7, #0x1000 (4096)");
234 COMPARE(add(w8, w9, Operand(0xff000)), "add w8, w9, #0xff000 (1044480)");
235 COMPARE(add(x10, x11, Operand(0x3ff000)),
236 "add x10, x11, #0x3ff000 (4190208)");
237 COMPARE(add(w12, w13, Operand(0xfff000)),
238 "add w12, w13, #0xfff000 (16773120)");
armvixlf37fdc02014-02-05 13:22:16 +0000239 COMPARE(adds(w14, w15, Operand(0xff)), "adds w14, w15, #0xff (255)");
240 COMPARE(adds(x16, x17, Operand(0xaa000)), "adds x16, x17, #0xaa000 (696320)");
241
armvixlad96eda2013-06-14 11:42:37 +0100242 COMPARE(cmn(w18, Operand(0xff)), "cmn w18, #0xff (255)");
243 COMPARE(cmn(x19, Operand(0xff000)), "cmn x19, #0xff000 (1044480)");
244 COMPARE(add(w0, wsp, Operand(0)), "mov w0, wsp");
245 COMPARE(add(sp, x0, Operand(0)), "mov sp, x0");
246
247 COMPARE(add(w1, wsp, Operand(8)), "add w1, wsp, #0x8 (8)");
248 COMPARE(add(x2, sp, Operand(16)), "add x2, sp, #0x10 (16)");
249 COMPARE(add(wsp, wsp, Operand(42)), "add wsp, wsp, #0x2a (42)");
250 COMPARE(cmn(sp, Operand(24)), "cmn sp, #0x18 (24)");
armvixlf37fdc02014-02-05 13:22:16 +0000251 COMPARE(adds(wzr, wsp, Operand(9)), "cmn wsp, #0x9 (9)");
armvixlad96eda2013-06-14 11:42:37 +0100252
253 CLEANUP();
254}
255
armvixl4a102ba2014-07-14 09:02:40 +0100256
armvixlad96eda2013-06-14 11:42:37 +0100257TEST(sub_immediate) {
258 SETUP();
259
260 COMPARE(sub(w0, w1, Operand(0xff)), "sub w0, w1, #0xff (255)");
261 COMPARE(sub(x2, x3, Operand(0x3ff)), "sub x2, x3, #0x3ff (1023)");
262 COMPARE(sub(w4, w5, Operand(0xfff)), "sub w4, w5, #0xfff (4095)");
263 COMPARE(sub(x6, x7, Operand(0x1000)), "sub x6, x7, #0x1000 (4096)");
264 COMPARE(sub(w8, w9, Operand(0xff000)), "sub w8, w9, #0xff000 (1044480)");
265 COMPARE(sub(x10, x11, Operand(0x3ff000)),
266 "sub x10, x11, #0x3ff000 (4190208)");
267 COMPARE(sub(w12, w13, Operand(0xfff000)),
268 "sub w12, w13, #0xfff000 (16773120)");
armvixlf37fdc02014-02-05 13:22:16 +0000269 COMPARE(subs(w14, w15, Operand(0xff)), "subs w14, w15, #0xff (255)");
270 COMPARE(subs(x16, x17, Operand(0xaa000)), "subs x16, x17, #0xaa000 (696320)");
armvixlad96eda2013-06-14 11:42:37 +0100271 COMPARE(cmp(w18, Operand(0xff)), "cmp w18, #0xff (255)");
272 COMPARE(cmp(x19, Operand(0xff000)), "cmp x19, #0xff000 (1044480)");
273
274 COMPARE(sub(w1, wsp, Operand(8)), "sub w1, wsp, #0x8 (8)");
275 COMPARE(sub(x2, sp, Operand(16)), "sub x2, sp, #0x10 (16)");
276 COMPARE(sub(wsp, wsp, Operand(42)), "sub wsp, wsp, #0x2a (42)");
277 COMPARE(cmp(sp, Operand(24)), "cmp sp, #0x18 (24)");
armvixlf37fdc02014-02-05 13:22:16 +0000278 COMPARE(subs(wzr, wsp, Operand(9)), "cmp wsp, #0x9 (9)");
armvixlad96eda2013-06-14 11:42:37 +0100279
280 CLEANUP();
281}
282
283
284TEST(add_shifted) {
285 SETUP();
286
287 COMPARE(add(w0, w1, Operand(w2)), "add w0, w1, w2");
288 COMPARE(add(x3, x4, Operand(x5)), "add x3, x4, x5");
289 COMPARE(add(w6, w7, Operand(w8, LSL, 1)), "add w6, w7, w8, lsl #1");
290 COMPARE(add(x9, x10, Operand(x11, LSL, 2)), "add x9, x10, x11, lsl #2");
291 COMPARE(add(w12, w13, Operand(w14, LSR, 3)), "add w12, w13, w14, lsr #3");
292 COMPARE(add(x15, x16, Operand(x17, LSR, 4)), "add x15, x16, x17, lsr #4");
293 COMPARE(add(w18, w19, Operand(w20, ASR, 5)), "add w18, w19, w20, asr #5");
294 COMPARE(add(x21, x22, Operand(x23, ASR, 6)), "add x21, x22, x23, asr #6");
295 COMPARE(cmn(w24, Operand(w25)), "cmn w24, w25");
296 COMPARE(cmn(x26, Operand(x27, LSL, 63)), "cmn x26, x27, lsl #63");
297
298 COMPARE(add(x0, sp, Operand(x1)), "add x0, sp, x1");
299 COMPARE(add(w2, wsp, Operand(w3)), "add w2, wsp, w3");
300 COMPARE(add(x4, sp, Operand(x5, LSL, 1)), "add x4, sp, x5, lsl #1");
301 COMPARE(add(x4, xzr, Operand(x5, LSL, 1)), "add x4, xzr, x5, lsl #1");
302 COMPARE(add(w6, wsp, Operand(w7, LSL, 3)), "add w6, wsp, w7, lsl #3");
armvixlf37fdc02014-02-05 13:22:16 +0000303 COMPARE(adds(xzr, sp, Operand(x8, LSL, 4)), "cmn sp, x8, lsl #4");
304 COMPARE(adds(xzr, xzr, Operand(x8, LSL, 5)), "cmn xzr, x8, lsl #5");
armvixlad96eda2013-06-14 11:42:37 +0100305
306 CLEANUP();
307}
308
309
310TEST(sub_shifted) {
311 SETUP();
312
313 COMPARE(sub(w0, w1, Operand(w2)), "sub w0, w1, w2");
314 COMPARE(sub(x3, x4, Operand(x5)), "sub x3, x4, x5");
315 COMPARE(sub(w6, w7, Operand(w8, LSL, 1)), "sub w6, w7, w8, lsl #1");
316 COMPARE(sub(x9, x10, Operand(x11, LSL, 2)), "sub x9, x10, x11, lsl #2");
317 COMPARE(sub(w12, w13, Operand(w14, LSR, 3)), "sub w12, w13, w14, lsr #3");
318 COMPARE(sub(x15, x16, Operand(x17, LSR, 4)), "sub x15, x16, x17, lsr #4");
319 COMPARE(sub(w18, w19, Operand(w20, ASR, 5)), "sub w18, w19, w20, asr #5");
320 COMPARE(sub(x21, x22, Operand(x23, ASR, 6)), "sub x21, x22, x23, asr #6");
321 COMPARE(cmp(w24, Operand(w25)), "cmp w24, w25");
322 COMPARE(cmp(x26, Operand(x27, LSL, 63)), "cmp x26, x27, lsl #63");
323 COMPARE(neg(w28, Operand(w29)), "neg w28, w29");
324 COMPARE(neg(x30, Operand(x0, LSR, 62)), "neg x30, x0, lsr #62");
armvixlf37fdc02014-02-05 13:22:16 +0000325 COMPARE(negs(w1, Operand(w2)), "negs w1, w2");
326 COMPARE(negs(x3, Operand(x4, ASR, 61)), "negs x3, x4, asr #61");
armvixlad96eda2013-06-14 11:42:37 +0100327
328 COMPARE(sub(x0, sp, Operand(x1)), "sub x0, sp, x1");
329 COMPARE(sub(w2, wsp, Operand(w3)), "sub w2, wsp, w3");
330 COMPARE(sub(x4, sp, Operand(x5, LSL, 1)), "sub x4, sp, x5, lsl #1");
331 COMPARE(sub(x4, xzr, Operand(x5, LSL, 1)), "neg x4, x5, lsl #1");
332 COMPARE(sub(w6, wsp, Operand(w7, LSL, 3)), "sub w6, wsp, w7, lsl #3");
armvixlf37fdc02014-02-05 13:22:16 +0000333 COMPARE(subs(xzr, sp, Operand(x8, LSL, 4)), "cmp sp, x8, lsl #4");
334 COMPARE(subs(xzr, xzr, Operand(x8, LSL, 5)), "cmp xzr, x8, lsl #5");
armvixlad96eda2013-06-14 11:42:37 +0100335
336 CLEANUP();
337}
338
339
340TEST(add_extended) {
341 SETUP();
342
343 COMPARE(add(w0, w1, Operand(w2, UXTB)), "add w0, w1, w2, uxtb");
armvixlf37fdc02014-02-05 13:22:16 +0000344 COMPARE(adds(x3, x4, Operand(w5, UXTB, 1)), "adds x3, x4, w5, uxtb #1");
armvixlad96eda2013-06-14 11:42:37 +0100345 COMPARE(add(w6, w7, Operand(w8, UXTH, 2)), "add w6, w7, w8, uxth #2");
armvixlf37fdc02014-02-05 13:22:16 +0000346 COMPARE(adds(x9, x10, Operand(x11, UXTW, 3)), "adds x9, x10, w11, uxtw #3");
armvixlad96eda2013-06-14 11:42:37 +0100347 COMPARE(add(x12, x13, Operand(x14, UXTX, 4)), "add x12, x13, x14, uxtx #4");
armvixlf37fdc02014-02-05 13:22:16 +0000348 COMPARE(adds(w15, w16, Operand(w17, SXTB, 4)), "adds w15, w16, w17, sxtb #4");
armvixlad96eda2013-06-14 11:42:37 +0100349 COMPARE(add(x18, x19, Operand(x20, SXTB, 3)), "add x18, x19, w20, sxtb #3");
armvixlf37fdc02014-02-05 13:22:16 +0000350 COMPARE(adds(w21, w22, Operand(w23, SXTH, 2)), "adds w21, w22, w23, sxth #2");
armvixlad96eda2013-06-14 11:42:37 +0100351 COMPARE(add(x24, x25, Operand(x26, SXTW, 1)), "add x24, x25, w26, sxtw #1");
armvixlf37fdc02014-02-05 13:22:16 +0000352 COMPARE(adds(x27, x28, Operand(x29, SXTX)), "adds x27, x28, x29, sxtx");
armvixlad96eda2013-06-14 11:42:37 +0100353 COMPARE(cmn(w0, Operand(w1, UXTB, 2)), "cmn w0, w1, uxtb #2");
354 COMPARE(cmn(x2, Operand(x3, SXTH, 4)), "cmn x2, w3, sxth #4");
355
356 COMPARE(add(w0, wsp, Operand(w1, UXTB)), "add w0, wsp, w1, uxtb");
357 COMPARE(add(x2, sp, Operand(x3, UXTH, 1)), "add x2, sp, w3, uxth #1");
358 COMPARE(add(wsp, wsp, Operand(w4, UXTW, 2)), "add wsp, wsp, w4, lsl #2");
359 COMPARE(cmn(sp, Operand(xzr, UXTX, 3)), "cmn sp, xzr, lsl #3");
360 COMPARE(cmn(sp, Operand(xzr, LSL, 4)), "cmn sp, xzr, lsl #4");
361
362 CLEANUP();
363}
364
365
366TEST(sub_extended) {
367 SETUP();
368
369 COMPARE(sub(w0, w1, Operand(w2, UXTB)), "sub w0, w1, w2, uxtb");
armvixlf37fdc02014-02-05 13:22:16 +0000370 COMPARE(subs(x3, x4, Operand(w5, UXTB, 1)), "subs x3, x4, w5, uxtb #1");
armvixlad96eda2013-06-14 11:42:37 +0100371 COMPARE(sub(w6, w7, Operand(w8, UXTH, 2)), "sub w6, w7, w8, uxth #2");
armvixlf37fdc02014-02-05 13:22:16 +0000372 COMPARE(subs(x9, x10, Operand(x11, UXTW, 3)), "subs x9, x10, w11, uxtw #3");
armvixlad96eda2013-06-14 11:42:37 +0100373 COMPARE(sub(x12, x13, Operand(x14, UXTX, 4)), "sub x12, x13, x14, uxtx #4");
armvixlf37fdc02014-02-05 13:22:16 +0000374 COMPARE(subs(w15, w16, Operand(w17, SXTB, 4)), "subs w15, w16, w17, sxtb #4");
armvixlad96eda2013-06-14 11:42:37 +0100375 COMPARE(sub(x18, x19, Operand(x20, SXTB, 3)), "sub x18, x19, w20, sxtb #3");
armvixlf37fdc02014-02-05 13:22:16 +0000376 COMPARE(subs(w21, w22, Operand(w23, SXTH, 2)), "subs w21, w22, w23, sxth #2");
armvixlad96eda2013-06-14 11:42:37 +0100377 COMPARE(sub(x24, x25, Operand(x26, SXTW, 1)), "sub x24, x25, w26, sxtw #1");
armvixlf37fdc02014-02-05 13:22:16 +0000378 COMPARE(subs(x27, x28, Operand(x29, SXTX)), "subs x27, x28, x29, sxtx");
armvixlad96eda2013-06-14 11:42:37 +0100379 COMPARE(cmp(w0, Operand(w1, SXTB, 1)), "cmp w0, w1, sxtb #1");
380 COMPARE(cmp(x2, Operand(x3, UXTH, 3)), "cmp x2, w3, uxth #3");
381
382 COMPARE(sub(w0, wsp, Operand(w1, UXTB)), "sub w0, wsp, w1, uxtb");
383 COMPARE(sub(x2, sp, Operand(x3, UXTH, 1)), "sub x2, sp, w3, uxth #1");
384 COMPARE(sub(wsp, wsp, Operand(w4, UXTW, 2)), "sub wsp, wsp, w4, lsl #2");
385 COMPARE(cmp(sp, Operand(xzr, UXTX, 3)), "cmp sp, xzr, lsl #3");
386 COMPARE(cmp(sp, Operand(xzr, LSL, 4)), "cmp sp, xzr, lsl #4");
387
388 CLEANUP();
389}
390
391
392TEST(adc_subc_ngc) {
393 SETUP();
394
395 COMPARE(adc(w0, w1, Operand(w2)), "adc w0, w1, w2");
396 COMPARE(adc(x3, x4, Operand(x5)), "adc x3, x4, x5");
armvixlf37fdc02014-02-05 13:22:16 +0000397 COMPARE(adcs(w6, w7, Operand(w8)), "adcs w6, w7, w8");
398 COMPARE(adcs(x9, x10, Operand(x11)), "adcs x9, x10, x11");
armvixlad96eda2013-06-14 11:42:37 +0100399 COMPARE(sbc(w12, w13, Operand(w14)), "sbc w12, w13, w14");
400 COMPARE(sbc(x15, x16, Operand(x17)), "sbc x15, x16, x17");
armvixlf37fdc02014-02-05 13:22:16 +0000401 COMPARE(sbcs(w18, w19, Operand(w20)), "sbcs w18, w19, w20");
402 COMPARE(sbcs(x21, x22, Operand(x23)), "sbcs x21, x22, x23");
armvixlad96eda2013-06-14 11:42:37 +0100403 COMPARE(ngc(w24, Operand(w25)), "ngc w24, w25");
404 COMPARE(ngc(x26, Operand(x27)), "ngc x26, x27");
armvixlf37fdc02014-02-05 13:22:16 +0000405 COMPARE(ngcs(w28, Operand(w29)), "ngcs w28, w29");
406 COMPARE(ngcs(x30, Operand(x0)), "ngcs x30, x0");
armvixlad96eda2013-06-14 11:42:37 +0100407
408 CLEANUP();
409}
410
411
412TEST(mul_and_div) {
413 SETUP();
414
415 COMPARE(mul(w0, w1, w2), "mul w0, w1, w2");
416 COMPARE(mul(x3, x4, x5), "mul x3, x4, x5");
417 COMPARE(mul(w30, w0, w1), "mul w30, w0, w1");
418 COMPARE(mul(x30, x0, x1), "mul x30, x0, x1");
419 COMPARE(mneg(w0, w1, w2), "mneg w0, w1, w2");
420 COMPARE(mneg(x3, x4, x5), "mneg x3, x4, x5");
421 COMPARE(mneg(w30, w0, w1), "mneg w30, w0, w1");
422 COMPARE(mneg(x30, x0, x1), "mneg x30, x0, x1");
423 COMPARE(smull(x0, w0, w1), "smull x0, w0, w1");
424 COMPARE(smull(x30, w30, w0), "smull x30, w30, w0");
425 COMPARE(smulh(x0, x1, x2), "smulh x0, x1, x2");
426
427 COMPARE(sdiv(w0, w1, w2), "sdiv w0, w1, w2");
428 COMPARE(sdiv(x3, x4, x5), "sdiv x3, x4, x5");
429 COMPARE(udiv(w6, w7, w8), "udiv w6, w7, w8");
430 COMPARE(udiv(x9, x10, x11), "udiv x9, x10, x11");
431
432 CLEANUP();
433}
434
435
436TEST(madd) {
437 SETUP();
438
439 COMPARE(madd(w0, w1, w2, w3), "madd w0, w1, w2, w3");
440 COMPARE(madd(w30, w21, w22, w16), "madd w30, w21, w22, w16");
441 COMPARE(madd(x0, x1, x2, x3), "madd x0, x1, x2, x3");
442 COMPARE(madd(x30, x21, x22, x16), "madd x30, x21, x22, x16");
443
444 COMPARE(smaddl(x0, w1, w2, x3), "smaddl x0, w1, w2, x3");
445 COMPARE(smaddl(x30, w21, w22, x16), "smaddl x30, w21, w22, x16");
446 COMPARE(umaddl(x0, w1, w2, x3), "umaddl x0, w1, w2, x3");
447 COMPARE(umaddl(x30, w21, w22, x16), "umaddl x30, w21, w22, x16");
448
449 CLEANUP();
450}
451
452
453TEST(msub) {
454 SETUP();
455
456 COMPARE(msub(w0, w1, w2, w3), "msub w0, w1, w2, w3");
457 COMPARE(msub(w30, w21, w22, w16), "msub w30, w21, w22, w16");
458 COMPARE(msub(x0, x1, x2, x3), "msub x0, x1, x2, x3");
459 COMPARE(msub(x30, x21, x22, x16), "msub x30, x21, x22, x16");
460
461 COMPARE(smsubl(x0, w1, w2, x3), "smsubl x0, w1, w2, x3");
462 COMPARE(smsubl(x30, w21, w22, x16), "smsubl x30, w21, w22, x16");
463 COMPARE(umsubl(x0, w1, w2, x3), "umsubl x0, w1, w2, x3");
464 COMPARE(umsubl(x30, w21, w22, x16), "umsubl x30, w21, w22, x16");
465
466 CLEANUP();
467}
468
469
470TEST(dp_1_source) {
471 SETUP();
472
473 COMPARE(rbit(w0, w1), "rbit w0, w1");
474 COMPARE(rbit(x2, x3), "rbit x2, x3");
475 COMPARE(rev16(w4, w5), "rev16 w4, w5");
476 COMPARE(rev16(x6, x7), "rev16 x6, x7");
477 COMPARE(rev32(x8, x9), "rev32 x8, x9");
478 COMPARE(rev(w10, w11), "rev w10, w11");
479 COMPARE(rev(x12, x13), "rev x12, x13");
480 COMPARE(clz(w14, w15), "clz w14, w15");
481 COMPARE(clz(x16, x17), "clz x16, x17");
482 COMPARE(cls(w18, w19), "cls w18, w19");
483 COMPARE(cls(x20, x21), "cls x20, x21");
484
485 CLEANUP();
486}
487
488
489TEST(bitfield) {
490 SETUP();
491
492 COMPARE(sxtb(w0, w1), "sxtb w0, w1");
493 COMPARE(sxtb(x2, x3), "sxtb x2, w3");
494 COMPARE(sxth(w4, w5), "sxth w4, w5");
495 COMPARE(sxth(x6, x7), "sxth x6, w7");
496 COMPARE(sxtw(x8, x9), "sxtw x8, w9");
armvixlf37fdc02014-02-05 13:22:16 +0000497 COMPARE(sxtb(x0, w1), "sxtb x0, w1");
498 COMPARE(sxth(x2, w3), "sxth x2, w3");
499 COMPARE(sxtw(x4, w5), "sxtw x4, w5");
500
armvixlad96eda2013-06-14 11:42:37 +0100501 COMPARE(uxtb(w10, w11), "uxtb w10, w11");
502 COMPARE(uxtb(x12, x13), "uxtb x12, w13");
503 COMPARE(uxth(w14, w15), "uxth w14, w15");
504 COMPARE(uxth(x16, x17), "uxth x16, w17");
505 COMPARE(uxtw(x18, x19), "ubfx x18, x19, #0, #32");
506
507 COMPARE(asr(w20, w21, 10), "asr w20, w21, #10");
508 COMPARE(asr(x22, x23, 20), "asr x22, x23, #20");
509 COMPARE(lsr(w24, w25, 10), "lsr w24, w25, #10");
510 COMPARE(lsr(x26, x27, 20), "lsr x26, x27, #20");
511 COMPARE(lsl(w28, w29, 10), "lsl w28, w29, #10");
512 COMPARE(lsl(x30, x0, 20), "lsl x30, x0, #20");
513
514 COMPARE(sbfiz(w1, w2, 1, 20), "sbfiz w1, w2, #1, #20");
515 COMPARE(sbfiz(x3, x4, 2, 19), "sbfiz x3, x4, #2, #19");
516 COMPARE(sbfx(w5, w6, 3, 18), "sbfx w5, w6, #3, #18");
517 COMPARE(sbfx(x7, x8, 4, 17), "sbfx x7, x8, #4, #17");
518 COMPARE(bfi(w9, w10, 5, 16), "bfi w9, w10, #5, #16");
519 COMPARE(bfi(x11, x12, 6, 15), "bfi x11, x12, #6, #15");
520 COMPARE(bfxil(w13, w14, 7, 14), "bfxil w13, w14, #7, #14");
521 COMPARE(bfxil(x15, x16, 8, 13), "bfxil x15, x16, #8, #13");
522 COMPARE(ubfiz(w17, w18, 9, 12), "ubfiz w17, w18, #9, #12");
523 COMPARE(ubfiz(x19, x20, 10, 11), "ubfiz x19, x20, #10, #11");
524 COMPARE(ubfx(w21, w22, 11, 10), "ubfx w21, w22, #11, #10");
525 COMPARE(ubfx(x23, x24, 12, 9), "ubfx x23, x24, #12, #9");
526
527 CLEANUP();
528}
529
530
531TEST(extract) {
532 SETUP();
533
534 COMPARE(extr(w0, w1, w2, 0), "extr w0, w1, w2, #0");
535 COMPARE(extr(x3, x4, x5, 1), "extr x3, x4, x5, #1");
536 COMPARE(extr(w6, w7, w8, 31), "extr w6, w7, w8, #31");
537 COMPARE(extr(x9, x10, x11, 63), "extr x9, x10, x11, #63");
538 COMPARE(extr(w12, w13, w13, 10), "ror w12, w13, #10");
539 COMPARE(extr(x14, x15, x15, 42), "ror x14, x15, #42");
540
541 CLEANUP();
542}
543
544
545TEST(logical_immediate) {
546 SETUP();
547 #define RESULT_SIZE (256)
548
549 char result[RESULT_SIZE];
550
551 // Test immediate encoding - 64-bit destination.
552 // 64-bit patterns.
553 uint64_t value = 0x7fffffff;
554 for (int i = 0; i < 64; i++) {
555 snprintf(result, RESULT_SIZE, "and x0, x0, #0x%" PRIx64, value);
556 COMPARE(and_(x0, x0, Operand(value)), result);
557 value = ((value & 1) << 63) | (value >> 1); // Rotate right 1 bit.
558 }
559
560 // 32-bit patterns.
armvixlb0c8ae22014-03-21 14:03:59 +0000561 value = 0x00003fff00003fff;
armvixlad96eda2013-06-14 11:42:37 +0100562 for (int i = 0; i < 32; i++) {
563 snprintf(result, RESULT_SIZE, "and x0, x0, #0x%" PRIx64, value);
564 COMPARE(and_(x0, x0, Operand(value)), result);
565 value = ((value & 1) << 63) | (value >> 1); // Rotate right 1 bit.
566 }
567
568 // 16-bit patterns.
armvixlb0c8ae22014-03-21 14:03:59 +0000569 value = 0x001f001f001f001f;
armvixlad96eda2013-06-14 11:42:37 +0100570 for (int i = 0; i < 16; i++) {
571 snprintf(result, RESULT_SIZE, "and x0, x0, #0x%" PRIx64, value);
572 COMPARE(and_(x0, x0, Operand(value)), result);
573 value = ((value & 1) << 63) | (value >> 1); // Rotate right 1 bit.
574 }
575
576 // 8-bit patterns.
armvixlb0c8ae22014-03-21 14:03:59 +0000577 value = 0x0e0e0e0e0e0e0e0e;
armvixlad96eda2013-06-14 11:42:37 +0100578 for (int i = 0; i < 8; i++) {
579 snprintf(result, RESULT_SIZE, "and x0, x0, #0x%" PRIx64, value);
580 COMPARE(and_(x0, x0, Operand(value)), result);
581 value = ((value & 1) << 63) | (value >> 1); // Rotate right 1 bit.
582 }
583
584 // 4-bit patterns.
armvixlb0c8ae22014-03-21 14:03:59 +0000585 value = 0x6666666666666666;
armvixlad96eda2013-06-14 11:42:37 +0100586 for (int i = 0; i < 4; i++) {
587 snprintf(result, RESULT_SIZE, "and x0, x0, #0x%" PRIx64, value);
588 COMPARE(and_(x0, x0, Operand(value)), result);
589 value = ((value & 1) << 63) | (value >> 1); // Rotate right 1 bit.
590 }
591
592 // 2-bit patterns.
armvixlb0c8ae22014-03-21 14:03:59 +0000593 COMPARE(and_(x0, x0, Operand(0x5555555555555555)),
armvixlad96eda2013-06-14 11:42:37 +0100594 "and x0, x0, #0x5555555555555555");
armvixlb0c8ae22014-03-21 14:03:59 +0000595 COMPARE(and_(x0, x0, Operand(0xaaaaaaaaaaaaaaaa)),
armvixlad96eda2013-06-14 11:42:37 +0100596 "and x0, x0, #0xaaaaaaaaaaaaaaaa");
597
598 // Test immediate encoding - 32-bit destination.
599 COMPARE(and_(w0, w0, Operand(0xff8007ff)),
600 "and w0, w0, #0xff8007ff"); // 32-bit pattern.
601 COMPARE(and_(w0, w0, Operand(0xf87ff87f)),
602 "and w0, w0, #0xf87ff87f"); // 16-bit pattern.
603 COMPARE(and_(w0, w0, Operand(0x87878787)),
604 "and w0, w0, #0x87878787"); // 8-bit pattern.
605 COMPARE(and_(w0, w0, Operand(0x66666666)),
606 "and w0, w0, #0x66666666"); // 4-bit pattern.
607 COMPARE(and_(w0, w0, Operand(0x55555555)),
608 "and w0, w0, #0x55555555"); // 2-bit pattern.
609
610 // Test other instructions.
611 COMPARE(tst(w1, Operand(0x11111111)),
612 "tst w1, #0x11111111");
armvixlb0c8ae22014-03-21 14:03:59 +0000613 COMPARE(tst(x2, Operand(0x8888888888888888)),
armvixlad96eda2013-06-14 11:42:37 +0100614 "tst x2, #0x8888888888888888");
615 COMPARE(orr(w7, w8, Operand(0xaaaaaaaa)),
616 "orr w7, w8, #0xaaaaaaaa");
armvixlb0c8ae22014-03-21 14:03:59 +0000617 COMPARE(orr(x9, x10, Operand(0x5555555555555555)),
armvixlad96eda2013-06-14 11:42:37 +0100618 "orr x9, x10, #0x5555555555555555");
619 COMPARE(eor(w15, w16, Operand(0x00000001)),
620 "eor w15, w16, #0x1");
armvixlb0c8ae22014-03-21 14:03:59 +0000621 COMPARE(eor(x17, x18, Operand(0x0000000000000003)),
armvixlad96eda2013-06-14 11:42:37 +0100622 "eor x17, x18, #0x3");
armvixlf37fdc02014-02-05 13:22:16 +0000623 COMPARE(ands(w23, w24, Operand(0x0000000f)), "ands w23, w24, #0xf");
armvixlb0c8ae22014-03-21 14:03:59 +0000624 COMPARE(ands(x25, x26, Operand(0x800000000000000f)),
armvixlad96eda2013-06-14 11:42:37 +0100625 "ands x25, x26, #0x800000000000000f");
626
627 // Test inverse.
628 COMPARE(bic(w3, w4, Operand(0x20202020)),
629 "and w3, w4, #0xdfdfdfdf");
armvixlb0c8ae22014-03-21 14:03:59 +0000630 COMPARE(bic(x5, x6, Operand(0x4040404040404040)),
armvixlad96eda2013-06-14 11:42:37 +0100631 "and x5, x6, #0xbfbfbfbfbfbfbfbf");
632 COMPARE(orn(w11, w12, Operand(0x40004000)),
633 "orr w11, w12, #0xbfffbfff");
armvixlb0c8ae22014-03-21 14:03:59 +0000634 COMPARE(orn(x13, x14, Operand(0x8181818181818181)),
armvixlad96eda2013-06-14 11:42:37 +0100635 "orr x13, x14, #0x7e7e7e7e7e7e7e7e");
636 COMPARE(eon(w19, w20, Operand(0x80000001)),
637 "eor w19, w20, #0x7ffffffe");
armvixlb0c8ae22014-03-21 14:03:59 +0000638 COMPARE(eon(x21, x22, Operand(0xc000000000000003)),
armvixlad96eda2013-06-14 11:42:37 +0100639 "eor x21, x22, #0x3ffffffffffffffc");
armvixlf37fdc02014-02-05 13:22:16 +0000640 COMPARE(bics(w27, w28, Operand(0xfffffff7)), "ands w27, w28, #0x8");
armvixlb0c8ae22014-03-21 14:03:59 +0000641 COMPARE(bics(x29, x0, Operand(0xfffffffeffffffff)),
armvixlad96eda2013-06-14 11:42:37 +0100642 "ands x29, x0, #0x100000000");
643
644 // Test stack pointer.
645 COMPARE(and_(wsp, wzr, Operand(7)), "and wsp, wzr, #0x7");
armvixlf37fdc02014-02-05 13:22:16 +0000646 COMPARE(ands(xzr, xzr, Operand(7)), "tst xzr, #0x7");
armvixlad96eda2013-06-14 11:42:37 +0100647 COMPARE(orr(sp, xzr, Operand(15)), "orr sp, xzr, #0xf");
648 COMPARE(eor(wsp, w0, Operand(31)), "eor wsp, w0, #0x1f");
649
650 // Test move aliases.
651 COMPARE(orr(w0, wzr, Operand(0x00000780)), "orr w0, wzr, #0x780");
652 COMPARE(orr(w1, wzr, Operand(0x00007800)), "orr w1, wzr, #0x7800");
653 COMPARE(orr(w2, wzr, Operand(0x00078000)), "mov w2, #0x78000");
654 COMPARE(orr(w3, wzr, Operand(0x00780000)), "orr w3, wzr, #0x780000");
655 COMPARE(orr(w4, wzr, Operand(0x07800000)), "orr w4, wzr, #0x7800000");
armvixlb0c8ae22014-03-21 14:03:59 +0000656 COMPARE(orr(x5, xzr, Operand(0xffffffffffffc001)),
armvixlad96eda2013-06-14 11:42:37 +0100657 "orr x5, xzr, #0xffffffffffffc001");
armvixlb0c8ae22014-03-21 14:03:59 +0000658 COMPARE(orr(x6, xzr, Operand(0xfffffffffffc001f)),
armvixlad96eda2013-06-14 11:42:37 +0100659 "mov x6, #0xfffffffffffc001f");
armvixlb0c8ae22014-03-21 14:03:59 +0000660 COMPARE(orr(x7, xzr, Operand(0xffffffffffc001ff)),
armvixlad96eda2013-06-14 11:42:37 +0100661 "mov x7, #0xffffffffffc001ff");
armvixlb0c8ae22014-03-21 14:03:59 +0000662 COMPARE(orr(x8, xzr, Operand(0xfffffffffc001fff)),
armvixlad96eda2013-06-14 11:42:37 +0100663 "mov x8, #0xfffffffffc001fff");
armvixlb0c8ae22014-03-21 14:03:59 +0000664 COMPARE(orr(x9, xzr, Operand(0xffffffffc001ffff)),
armvixlad96eda2013-06-14 11:42:37 +0100665 "orr x9, xzr, #0xffffffffc001ffff");
666
667 CLEANUP();
668}
669
670
671TEST(logical_shifted) {
672 SETUP();
673
674 COMPARE(and_(w0, w1, Operand(w2)), "and w0, w1, w2");
675 COMPARE(and_(x3, x4, Operand(x5, LSL, 1)), "and x3, x4, x5, lsl #1");
676 COMPARE(and_(w6, w7, Operand(w8, LSR, 2)), "and w6, w7, w8, lsr #2");
677 COMPARE(and_(x9, x10, Operand(x11, ASR, 3)), "and x9, x10, x11, asr #3");
678 COMPARE(and_(w12, w13, Operand(w14, ROR, 4)), "and w12, w13, w14, ror #4");
679
680 COMPARE(bic(w15, w16, Operand(w17)), "bic w15, w16, w17");
681 COMPARE(bic(x18, x19, Operand(x20, LSL, 5)), "bic x18, x19, x20, lsl #5");
682 COMPARE(bic(w21, w22, Operand(w23, LSR, 6)), "bic w21, w22, w23, lsr #6");
683 COMPARE(bic(x24, x25, Operand(x26, ASR, 7)), "bic x24, x25, x26, asr #7");
684 COMPARE(bic(w27, w28, Operand(w29, ROR, 8)), "bic w27, w28, w29, ror #8");
685
686 COMPARE(orr(w0, w1, Operand(w2)), "orr w0, w1, w2");
687 COMPARE(orr(x3, x4, Operand(x5, LSL, 9)), "orr x3, x4, x5, lsl #9");
688 COMPARE(orr(w6, w7, Operand(w8, LSR, 10)), "orr w6, w7, w8, lsr #10");
689 COMPARE(orr(x9, x10, Operand(x11, ASR, 11)), "orr x9, x10, x11, asr #11");
690 COMPARE(orr(w12, w13, Operand(w14, ROR, 12)), "orr w12, w13, w14, ror #12");
691
692 COMPARE(orn(w15, w16, Operand(w17)), "orn w15, w16, w17");
693 COMPARE(orn(x18, x19, Operand(x20, LSL, 13)), "orn x18, x19, x20, lsl #13");
694 COMPARE(orn(w21, w22, Operand(w23, LSR, 14)), "orn w21, w22, w23, lsr #14");
695 COMPARE(orn(x24, x25, Operand(x26, ASR, 15)), "orn x24, x25, x26, asr #15");
696 COMPARE(orn(w27, w28, Operand(w29, ROR, 16)), "orn w27, w28, w29, ror #16");
697
698 COMPARE(eor(w0, w1, Operand(w2)), "eor w0, w1, w2");
699 COMPARE(eor(x3, x4, Operand(x5, LSL, 17)), "eor x3, x4, x5, lsl #17");
700 COMPARE(eor(w6, w7, Operand(w8, LSR, 18)), "eor w6, w7, w8, lsr #18");
701 COMPARE(eor(x9, x10, Operand(x11, ASR, 19)), "eor x9, x10, x11, asr #19");
702 COMPARE(eor(w12, w13, Operand(w14, ROR, 20)), "eor w12, w13, w14, ror #20");
703
704 COMPARE(eon(w15, w16, Operand(w17)), "eon w15, w16, w17");
705 COMPARE(eon(x18, x19, Operand(x20, LSL, 21)), "eon x18, x19, x20, lsl #21");
706 COMPARE(eon(w21, w22, Operand(w23, LSR, 22)), "eon w21, w22, w23, lsr #22");
707 COMPARE(eon(x24, x25, Operand(x26, ASR, 23)), "eon x24, x25, x26, asr #23");
708 COMPARE(eon(w27, w28, Operand(w29, ROR, 24)), "eon w27, w28, w29, ror #24");
709
armvixlf37fdc02014-02-05 13:22:16 +0000710 COMPARE(ands(w0, w1, Operand(w2)), "ands w0, w1, w2");
711 COMPARE(ands(x3, x4, Operand(x5, LSL, 1)), "ands x3, x4, x5, lsl #1");
712 COMPARE(ands(w6, w7, Operand(w8, LSR, 2)), "ands w6, w7, w8, lsr #2");
713 COMPARE(ands(x9, x10, Operand(x11, ASR, 3)), "ands x9, x10, x11, asr #3");
714 COMPARE(ands(w12, w13, Operand(w14, ROR, 4)), "ands w12, w13, w14, ror #4");
armvixlad96eda2013-06-14 11:42:37 +0100715
armvixlf37fdc02014-02-05 13:22:16 +0000716 COMPARE(bics(w15, w16, Operand(w17)), "bics w15, w16, w17");
717 COMPARE(bics(x18, x19, Operand(x20, LSL, 5)), "bics x18, x19, x20, lsl #5");
718 COMPARE(bics(w21, w22, Operand(w23, LSR, 6)), "bics w21, w22, w23, lsr #6");
719 COMPARE(bics(x24, x25, Operand(x26, ASR, 7)), "bics x24, x25, x26, asr #7");
720 COMPARE(bics(w27, w28, Operand(w29, ROR, 8)), "bics w27, w28, w29, ror #8");
armvixlad96eda2013-06-14 11:42:37 +0100721
722 COMPARE(tst(w0, Operand(w1)), "tst w0, w1");
723 COMPARE(tst(w2, Operand(w3, ROR, 10)), "tst w2, w3, ror #10");
724 COMPARE(tst(x0, Operand(x1)), "tst x0, x1");
725 COMPARE(tst(x2, Operand(x3, ROR, 42)), "tst x2, x3, ror #42");
726
727 COMPARE(orn(w0, wzr, Operand(w1)), "mvn w0, w1");
728 COMPARE(orn(w2, wzr, Operand(w3, ASR, 5)), "mvn w2, w3, asr #5");
729 COMPARE(orn(x0, xzr, Operand(x1)), "mvn x0, x1");
730 COMPARE(orn(x2, xzr, Operand(x3, ASR, 42)), "mvn x2, x3, asr #42");
731
732 COMPARE(orr(w0, wzr, Operand(w1)), "mov w0, w1");
733 COMPARE(orr(x0, xzr, Operand(x1)), "mov x0, x1");
734 COMPARE(orr(w16, wzr, Operand(w17, LSL, 1)), "orr w16, wzr, w17, lsl #1");
735 COMPARE(orr(x16, xzr, Operand(x17, ASR, 2)), "orr x16, xzr, x17, asr #2");
736
737 CLEANUP();
738}
739
740
741TEST(dp_2_source) {
742 SETUP();
743
744 COMPARE(lslv(w0, w1, w2), "lsl w0, w1, w2");
745 COMPARE(lslv(x3, x4, x5), "lsl x3, x4, x5");
746 COMPARE(lsrv(w6, w7, w8), "lsr w6, w7, w8");
747 COMPARE(lsrv(x9, x10, x11), "lsr x9, x10, x11");
748 COMPARE(asrv(w12, w13, w14), "asr w12, w13, w14");
749 COMPARE(asrv(x15, x16, x17), "asr x15, x16, x17");
750 COMPARE(rorv(w18, w19, w20), "ror w18, w19, w20");
751 COMPARE(rorv(x21, x22, x23), "ror x21, x22, x23");
752
753 CLEANUP();
754}
755
armvixl4a102ba2014-07-14 09:02:40 +0100756
armvixlad96eda2013-06-14 11:42:37 +0100757TEST(adr) {
758 SETUP();
759
armvixlb0c8ae22014-03-21 14:03:59 +0000760 COMPARE_PREFIX(adr(x0, 0), "adr x0, #+0x0");
761 COMPARE_PREFIX(adr(x1, 1), "adr x1, #+0x1");
762 COMPARE_PREFIX(adr(x2, -1), "adr x2, #-0x1");
763 COMPARE_PREFIX(adr(x3, 4), "adr x3, #+0x4");
764 COMPARE_PREFIX(adr(x4, -4), "adr x4, #-0x4");
765 COMPARE_PREFIX(adr(x5, 0x000fffff), "adr x5, #+0xfffff");
766 COMPARE_PREFIX(adr(x6, -0x00100000), "adr x6, #-0x100000");
767 COMPARE_PREFIX(adr(xzr, 0), "adr xzr, #+0x0");
armvixlad96eda2013-06-14 11:42:37 +0100768
769 CLEANUP();
770}
771
armvixl4a102ba2014-07-14 09:02:40 +0100772
773TEST(adrp) {
774 SETUP();
775
776 COMPARE_PREFIX(adrp(x0, 0), "adrp x0, #+0x0");
777 COMPARE_PREFIX(adrp(x1, 1), "adrp x1, #+0x1");
778 COMPARE_PREFIX(adrp(x2, -1), "adrp x2, #-0x1");
779 COMPARE_PREFIX(adrp(x3, 4), "adrp x3, #+0x4");
780 COMPARE_PREFIX(adrp(x4, -4), "adrp x4, #-0x4");
781 COMPARE_PREFIX(adrp(x5, 0x000fffff), "adrp x5, #+0xfffff");
782 COMPARE_PREFIX(adrp(x6, -0x00100000), "adrp x6, #-0x100000");
783 COMPARE_PREFIX(adrp(xzr, 0), "adrp xzr, #+0x0");
784
785 CLEANUP();
786}
787
788
armvixlad96eda2013-06-14 11:42:37 +0100789TEST(branch) {
790 SETUP();
791
792 #define INST_OFF(x) ((x) >> kInstructionSizeLog2)
armvixlb0c8ae22014-03-21 14:03:59 +0000793 COMPARE_PREFIX(b(INST_OFF(0x4)), "b #+0x4");
794 COMPARE_PREFIX(b(INST_OFF(-0x4)), "b #-0x4");
795 COMPARE_PREFIX(b(INST_OFF(0x7fffffc)), "b #+0x7fffffc");
796 COMPARE_PREFIX(b(INST_OFF(-0x8000000)), "b #-0x8000000");
797 COMPARE_PREFIX(b(INST_OFF(0xffffc), eq), "b.eq #+0xffffc");
798 COMPARE_PREFIX(b(INST_OFF(-0x100000), mi), "b.mi #-0x100000");
799 COMPARE_PREFIX(b(INST_OFF(0xffffc), al), "b.al #+0xffffc");
800 COMPARE_PREFIX(b(INST_OFF(-0x100000), nv), "b.nv #-0x100000");
801 COMPARE_PREFIX(bl(INST_OFF(0x4)), "bl #+0x4");
802 COMPARE_PREFIX(bl(INST_OFF(-0x4)), "bl #-0x4");
803 COMPARE_PREFIX(bl(INST_OFF(0xffffc)), "bl #+0xffffc");
804 COMPARE_PREFIX(bl(INST_OFF(-0x100000)), "bl #-0x100000");
805 COMPARE_PREFIX(cbz(w0, INST_OFF(0xffffc)), "cbz w0, #+0xffffc");
806 COMPARE_PREFIX(cbz(x1, INST_OFF(-0x100000)), "cbz x1, #-0x100000");
807 COMPARE_PREFIX(cbnz(w2, INST_OFF(0xffffc)), "cbnz w2, #+0xffffc");
808 COMPARE_PREFIX(cbnz(x3, INST_OFF(-0x100000)), "cbnz x3, #-0x100000");
809 COMPARE_PREFIX(tbz(w4, 0, INST_OFF(0x7ffc)), "tbz w4, #0, #+0x7ffc");
810 COMPARE_PREFIX(tbz(x5, 63, INST_OFF(-0x8000)), "tbz x5, #63, #-0x8000");
811 COMPARE_PREFIX(tbz(w6, 31, INST_OFF(0)), "tbz w6, #31, #+0x0");
812 COMPARE_PREFIX(tbz(x7, 31, INST_OFF(0x4)), "tbz w7, #31, #+0x4");
813 COMPARE_PREFIX(tbz(x8, 32, INST_OFF(0x8)), "tbz x8, #32, #+0x8");
814 COMPARE_PREFIX(tbnz(w8, 0, INST_OFF(0x7ffc)), "tbnz w8, #0, #+0x7ffc");
815 COMPARE_PREFIX(tbnz(x9, 63, INST_OFF(-0x8000)), "tbnz x9, #63, #-0x8000");
816 COMPARE_PREFIX(tbnz(w10, 31, INST_OFF(0)), "tbnz w10, #31, #+0x0");
817 COMPARE_PREFIX(tbnz(x11, 31, INST_OFF(0x4)), "tbnz w11, #31, #+0x4");
818 COMPARE_PREFIX(tbnz(x12, 32, INST_OFF(0x8)), "tbnz x12, #32, #+0x8");
armvixlad96eda2013-06-14 11:42:37 +0100819 COMPARE(br(x0), "br x0");
820 COMPARE(blr(x1), "blr x1");
821 COMPARE(ret(x2), "ret x2");
822 COMPARE(ret(lr), "ret")
823
824 CLEANUP();
825}
826
armvixl4a102ba2014-07-14 09:02:40 +0100827
armvixlad96eda2013-06-14 11:42:37 +0100828TEST(load_store) {
829 SETUP();
830
831 COMPARE(ldr(w0, MemOperand(x1)), "ldr w0, [x1]");
832 COMPARE(ldr(w2, MemOperand(x3, 4)), "ldr w2, [x3, #4]");
833 COMPARE(ldr(w4, MemOperand(x5, 16380)), "ldr w4, [x5, #16380]");
834 COMPARE(ldr(x6, MemOperand(x7)), "ldr x6, [x7]");
835 COMPARE(ldr(x8, MemOperand(x9, 8)), "ldr x8, [x9, #8]");
836 COMPARE(ldr(x10, MemOperand(x11, 32760)), "ldr x10, [x11, #32760]");
837 COMPARE(str(w12, MemOperand(x13)), "str w12, [x13]");
838 COMPARE(str(w14, MemOperand(x15, 4)), "str w14, [x15, #4]");
839 COMPARE(str(w16, MemOperand(x17, 16380)), "str w16, [x17, #16380]");
840 COMPARE(str(x18, MemOperand(x19)), "str x18, [x19]");
841 COMPARE(str(x20, MemOperand(x21, 8)), "str x20, [x21, #8]");
842 COMPARE(str(x22, MemOperand(x23, 32760)), "str x22, [x23, #32760]");
843
844 COMPARE(ldr(w0, MemOperand(x1, 4, PreIndex)), "ldr w0, [x1, #4]!");
845 COMPARE(ldr(w2, MemOperand(x3, 255, PreIndex)), "ldr w2, [x3, #255]!");
846 COMPARE(ldr(w4, MemOperand(x5, -256, PreIndex)), "ldr w4, [x5, #-256]!");
847 COMPARE(ldr(x6, MemOperand(x7, 8, PreIndex)), "ldr x6, [x7, #8]!");
848 COMPARE(ldr(x8, MemOperand(x9, 255, PreIndex)), "ldr x8, [x9, #255]!");
849 COMPARE(ldr(x10, MemOperand(x11, -256, PreIndex)), "ldr x10, [x11, #-256]!");
850 COMPARE(str(w12, MemOperand(x13, 4, PreIndex)), "str w12, [x13, #4]!");
851 COMPARE(str(w14, MemOperand(x15, 255, PreIndex)), "str w14, [x15, #255]!");
852 COMPARE(str(w16, MemOperand(x17, -256, PreIndex)), "str w16, [x17, #-256]!");
853 COMPARE(str(x18, MemOperand(x19, 8, PreIndex)), "str x18, [x19, #8]!");
854 COMPARE(str(x20, MemOperand(x21, 255, PreIndex)), "str x20, [x21, #255]!");
855 COMPARE(str(x22, MemOperand(x23, -256, PreIndex)), "str x22, [x23, #-256]!");
856
857 COMPARE(ldr(w0, MemOperand(x1, 4, PostIndex)), "ldr w0, [x1], #4");
858 COMPARE(ldr(w2, MemOperand(x3, 255, PostIndex)), "ldr w2, [x3], #255");
859 COMPARE(ldr(w4, MemOperand(x5, -256, PostIndex)), "ldr w4, [x5], #-256");
860 COMPARE(ldr(x6, MemOperand(x7, 8, PostIndex)), "ldr x6, [x7], #8");
861 COMPARE(ldr(x8, MemOperand(x9, 255, PostIndex)), "ldr x8, [x9], #255");
862 COMPARE(ldr(x10, MemOperand(x11, -256, PostIndex)), "ldr x10, [x11], #-256");
863 COMPARE(str(w12, MemOperand(x13, 4, PostIndex)), "str w12, [x13], #4");
864 COMPARE(str(w14, MemOperand(x15, 255, PostIndex)), "str w14, [x15], #255");
865 COMPARE(str(w16, MemOperand(x17, -256, PostIndex)), "str w16, [x17], #-256");
866 COMPARE(str(x18, MemOperand(x19, 8, PostIndex)), "str x18, [x19], #8");
867 COMPARE(str(x20, MemOperand(x21, 255, PostIndex)), "str x20, [x21], #255");
868 COMPARE(str(x22, MemOperand(x23, -256, PostIndex)), "str x22, [x23], #-256");
869
870 COMPARE(ldr(w24, MemOperand(sp)), "ldr w24, [sp]");
871 COMPARE(ldr(x25, MemOperand(sp, 8)), "ldr x25, [sp, #8]");
872 COMPARE(str(w26, MemOperand(sp, 4, PreIndex)), "str w26, [sp, #4]!");
873 COMPARE(str(x27, MemOperand(sp, -8, PostIndex)), "str x27, [sp], #-8");
874
875 COMPARE(ldrsw(x0, MemOperand(x1)), "ldrsw x0, [x1]");
876 COMPARE(ldrsw(x2, MemOperand(x3, 8)), "ldrsw x2, [x3, #8]");
877 COMPARE(ldrsw(x4, MemOperand(x5, 42, PreIndex)), "ldrsw x4, [x5, #42]!");
878 COMPARE(ldrsw(x6, MemOperand(x7, -11, PostIndex)), "ldrsw x6, [x7], #-11");
879
880 CLEANUP();
881}
882
883
884TEST(load_store_regoffset) {
885 SETUP();
886
887 COMPARE(ldr(w0, MemOperand(x1, w2, UXTW)), "ldr w0, [x1, w2, uxtw]");
888 COMPARE(ldr(w3, MemOperand(x4, w5, UXTW, 2)), "ldr w3, [x4, w5, uxtw #2]");
889 COMPARE(ldr(w6, MemOperand(x7, x8)), "ldr w6, [x7, x8]");
890 COMPARE(ldr(w9, MemOperand(x10, x11, LSL, 2)), "ldr w9, [x10, x11, lsl #2]");
891 COMPARE(ldr(w12, MemOperand(x13, w14, SXTW)), "ldr w12, [x13, w14, sxtw]");
892 COMPARE(ldr(w15, MemOperand(x16, w17, SXTW, 2)),
893 "ldr w15, [x16, w17, sxtw #2]");
894 COMPARE(ldr(w18, MemOperand(x19, x20, SXTX)), "ldr w18, [x19, x20, sxtx]");
895 COMPARE(ldr(w21, MemOperand(x22, x23, SXTX, 2)),
896 "ldr w21, [x22, x23, sxtx #2]");
897 COMPARE(ldr(x0, MemOperand(x1, w2, UXTW)), "ldr x0, [x1, w2, uxtw]");
898 COMPARE(ldr(x3, MemOperand(x4, w5, UXTW, 3)), "ldr x3, [x4, w5, uxtw #3]");
899 COMPARE(ldr(x6, MemOperand(x7, x8)), "ldr x6, [x7, x8]");
900 COMPARE(ldr(x9, MemOperand(x10, x11, LSL, 3)), "ldr x9, [x10, x11, lsl #3]");
901 COMPARE(ldr(x12, MemOperand(x13, w14, SXTW)), "ldr x12, [x13, w14, sxtw]");
902 COMPARE(ldr(x15, MemOperand(x16, w17, SXTW, 3)),
903 "ldr x15, [x16, w17, sxtw #3]");
904 COMPARE(ldr(x18, MemOperand(x19, x20, SXTX)), "ldr x18, [x19, x20, sxtx]");
905 COMPARE(ldr(x21, MemOperand(x22, x23, SXTX, 3)),
906 "ldr x21, [x22, x23, sxtx #3]");
907
908 COMPARE(str(w0, MemOperand(x1, w2, UXTW)), "str w0, [x1, w2, uxtw]");
909 COMPARE(str(w3, MemOperand(x4, w5, UXTW, 2)), "str w3, [x4, w5, uxtw #2]");
910 COMPARE(str(w6, MemOperand(x7, x8)), "str w6, [x7, x8]");
911 COMPARE(str(w9, MemOperand(x10, x11, LSL, 2)), "str w9, [x10, x11, lsl #2]");
912 COMPARE(str(w12, MemOperand(x13, w14, SXTW)), "str w12, [x13, w14, sxtw]");
913 COMPARE(str(w15, MemOperand(x16, w17, SXTW, 2)),
914 "str w15, [x16, w17, sxtw #2]");
915 COMPARE(str(w18, MemOperand(x19, x20, SXTX)), "str w18, [x19, x20, sxtx]");
916 COMPARE(str(w21, MemOperand(x22, x23, SXTX, 2)),
917 "str w21, [x22, x23, sxtx #2]");
918 COMPARE(str(x0, MemOperand(x1, w2, UXTW)), "str x0, [x1, w2, uxtw]");
919 COMPARE(str(x3, MemOperand(x4, w5, UXTW, 3)), "str x3, [x4, w5, uxtw #3]");
920 COMPARE(str(x6, MemOperand(x7, x8)), "str x6, [x7, x8]");
921 COMPARE(str(x9, MemOperand(x10, x11, LSL, 3)), "str x9, [x10, x11, lsl #3]");
922 COMPARE(str(x12, MemOperand(x13, w14, SXTW)), "str x12, [x13, w14, sxtw]");
923 COMPARE(str(x15, MemOperand(x16, w17, SXTW, 3)),
924 "str x15, [x16, w17, sxtw #3]");
925 COMPARE(str(x18, MemOperand(x19, x20, SXTX)), "str x18, [x19, x20, sxtx]");
926 COMPARE(str(x21, MemOperand(x22, x23, SXTX, 3)),
927 "str x21, [x22, x23, sxtx #3]");
928
929 COMPARE(ldrb(w0, MemOperand(x1, w2, UXTW)), "ldrb w0, [x1, w2, uxtw]");
930 COMPARE(ldrb(w6, MemOperand(x7, x8)), "ldrb w6, [x7, x8]");
931 COMPARE(ldrb(w12, MemOperand(x13, w14, SXTW)), "ldrb w12, [x13, w14, sxtw]");
932 COMPARE(ldrb(w18, MemOperand(x19, x20, SXTX)), "ldrb w18, [x19, x20, sxtx]");
933 COMPARE(strb(w0, MemOperand(x1, w2, UXTW)), "strb w0, [x1, w2, uxtw]");
934 COMPARE(strb(w6, MemOperand(x7, x8)), "strb w6, [x7, x8]");
935 COMPARE(strb(w12, MemOperand(x13, w14, SXTW)), "strb w12, [x13, w14, sxtw]");
936 COMPARE(strb(w18, MemOperand(x19, x20, SXTX)), "strb w18, [x19, x20, sxtx]");
937
938 COMPARE(ldrh(w0, MemOperand(x1, w2, UXTW)), "ldrh w0, [x1, w2, uxtw]");
939 COMPARE(ldrh(w3, MemOperand(x4, w5, UXTW, 1)), "ldrh w3, [x4, w5, uxtw #1]");
940 COMPARE(ldrh(w6, MemOperand(x7, x8)), "ldrh w6, [x7, x8]");
941 COMPARE(ldrh(w9, MemOperand(x10, x11, LSL, 1)),
942 "ldrh w9, [x10, x11, lsl #1]");
943 COMPARE(ldrh(w12, MemOperand(x13, w14, SXTW)), "ldrh w12, [x13, w14, sxtw]");
944 COMPARE(ldrh(w15, MemOperand(x16, w17, SXTW, 1)),
945 "ldrh w15, [x16, w17, sxtw #1]");
946 COMPARE(ldrh(w18, MemOperand(x19, x20, SXTX)), "ldrh w18, [x19, x20, sxtx]");
947 COMPARE(ldrh(w21, MemOperand(x22, x23, SXTX, 1)),
948 "ldrh w21, [x22, x23, sxtx #1]");
949 COMPARE(strh(w0, MemOperand(x1, w2, UXTW)), "strh w0, [x1, w2, uxtw]");
950 COMPARE(strh(w3, MemOperand(x4, w5, UXTW, 1)), "strh w3, [x4, w5, uxtw #1]");
951 COMPARE(strh(w6, MemOperand(x7, x8)), "strh w6, [x7, x8]");
952 COMPARE(strh(w9, MemOperand(x10, x11, LSL, 1)),
953 "strh w9, [x10, x11, lsl #1]");
954 COMPARE(strh(w12, MemOperand(x13, w14, SXTW)), "strh w12, [x13, w14, sxtw]");
955 COMPARE(strh(w15, MemOperand(x16, w17, SXTW, 1)),
956 "strh w15, [x16, w17, sxtw #1]");
957 COMPARE(strh(w18, MemOperand(x19, x20, SXTX)), "strh w18, [x19, x20, sxtx]");
958 COMPARE(strh(w21, MemOperand(x22, x23, SXTX, 1)),
959 "strh w21, [x22, x23, sxtx #1]");
960
961 COMPARE(ldr(x0, MemOperand(sp, wzr, SXTW)), "ldr x0, [sp, wzr, sxtw]");
962 COMPARE(str(x1, MemOperand(sp, xzr)), "str x1, [sp, xzr]");
963
964 CLEANUP();
965}
966
967
968TEST(load_store_byte) {
969 SETUP();
970
971 COMPARE(ldrb(w0, MemOperand(x1)), "ldrb w0, [x1]");
972 COMPARE(ldrb(x2, MemOperand(x3)), "ldrb w2, [x3]");
973 COMPARE(ldrb(w4, MemOperand(x5, 4095)), "ldrb w4, [x5, #4095]");
974 COMPARE(ldrb(w6, MemOperand(x7, 255, PreIndex)), "ldrb w6, [x7, #255]!");
975 COMPARE(ldrb(w8, MemOperand(x9, -256, PreIndex)), "ldrb w8, [x9, #-256]!");
976 COMPARE(ldrb(w10, MemOperand(x11, 255, PostIndex)), "ldrb w10, [x11], #255");
977 COMPARE(ldrb(w12, MemOperand(x13, -256, PostIndex)),
978 "ldrb w12, [x13], #-256");
979 COMPARE(strb(w14, MemOperand(x15)), "strb w14, [x15]");
980 COMPARE(strb(x16, MemOperand(x17)), "strb w16, [x17]");
981 COMPARE(strb(w18, MemOperand(x19, 4095)), "strb w18, [x19, #4095]");
982 COMPARE(strb(w20, MemOperand(x21, 255, PreIndex)), "strb w20, [x21, #255]!");
983 COMPARE(strb(w22, MemOperand(x23, -256, PreIndex)),
984 "strb w22, [x23, #-256]!");
985 COMPARE(strb(w24, MemOperand(x25, 255, PostIndex)), "strb w24, [x25], #255");
986 COMPARE(strb(w26, MemOperand(x27, -256, PostIndex)),
987 "strb w26, [x27], #-256");
988 COMPARE(ldrb(w28, MemOperand(sp, 3, PostIndex)), "ldrb w28, [sp], #3");
989 COMPARE(strb(x29, MemOperand(sp, -42, PreIndex)), "strb w29, [sp, #-42]!");
990 COMPARE(ldrsb(w0, MemOperand(x1)), "ldrsb w0, [x1]");
991 COMPARE(ldrsb(x2, MemOperand(x3, 8)), "ldrsb x2, [x3, #8]");
992 COMPARE(ldrsb(w4, MemOperand(x5, 42, PreIndex)), "ldrsb w4, [x5, #42]!");
993 COMPARE(ldrsb(x6, MemOperand(x7, -11, PostIndex)), "ldrsb x6, [x7], #-11");
994
995 CLEANUP();
996}
997
998
999TEST(load_store_half) {
1000 SETUP();
1001
1002 COMPARE(ldrh(w0, MemOperand(x1)), "ldrh w0, [x1]");
1003 COMPARE(ldrh(x2, MemOperand(x3)), "ldrh w2, [x3]");
1004 COMPARE(ldrh(w4, MemOperand(x5, 8190)), "ldrh w4, [x5, #8190]");
1005 COMPARE(ldrh(w6, MemOperand(x7, 255, PreIndex)), "ldrh w6, [x7, #255]!");
1006 COMPARE(ldrh(w8, MemOperand(x9, -256, PreIndex)), "ldrh w8, [x9, #-256]!");
1007 COMPARE(ldrh(w10, MemOperand(x11, 255, PostIndex)), "ldrh w10, [x11], #255");
1008 COMPARE(ldrh(w12, MemOperand(x13, -256, PostIndex)),
1009 "ldrh w12, [x13], #-256");
1010 COMPARE(strh(w14, MemOperand(x15)), "strh w14, [x15]");
1011 COMPARE(strh(x16, MemOperand(x17)), "strh w16, [x17]");
1012 COMPARE(strh(w18, MemOperand(x19, 8190)), "strh w18, [x19, #8190]");
1013 COMPARE(strh(w20, MemOperand(x21, 255, PreIndex)), "strh w20, [x21, #255]!");
1014 COMPARE(strh(w22, MemOperand(x23, -256, PreIndex)),
1015 "strh w22, [x23, #-256]!");
1016 COMPARE(strh(w24, MemOperand(x25, 255, PostIndex)), "strh w24, [x25], #255");
1017 COMPARE(strh(w26, MemOperand(x27, -256, PostIndex)),
1018 "strh w26, [x27], #-256");
1019 COMPARE(ldrh(w28, MemOperand(sp, 3, PostIndex)), "ldrh w28, [sp], #3");
1020 COMPARE(strh(x29, MemOperand(sp, -42, PreIndex)), "strh w29, [sp, #-42]!");
1021 COMPARE(ldrh(w30, MemOperand(x0, 255)), "ldurh w30, [x0, #255]");
1022 COMPARE(ldrh(x1, MemOperand(x2, -256)), "ldurh w1, [x2, #-256]");
1023 COMPARE(strh(w3, MemOperand(x4, 255)), "sturh w3, [x4, #255]");
1024 COMPARE(strh(x5, MemOperand(x6, -256)), "sturh w5, [x6, #-256]");
1025 COMPARE(ldrsh(w0, MemOperand(x1)), "ldrsh w0, [x1]");
1026 COMPARE(ldrsh(w2, MemOperand(x3, 8)), "ldrsh w2, [x3, #8]");
1027 COMPARE(ldrsh(w4, MemOperand(x5, 42, PreIndex)), "ldrsh w4, [x5, #42]!");
1028 COMPARE(ldrsh(x6, MemOperand(x7, -11, PostIndex)), "ldrsh x6, [x7], #-11");
1029
1030 CLEANUP();
1031}
1032
1033
1034TEST(load_store_fp) {
1035 SETUP();
1036
1037 COMPARE(ldr(s0, MemOperand(x1)), "ldr s0, [x1]");
1038 COMPARE(ldr(s2, MemOperand(x3, 4)), "ldr s2, [x3, #4]");
1039 COMPARE(ldr(s4, MemOperand(x5, 16380)), "ldr s4, [x5, #16380]");
1040 COMPARE(ldr(d6, MemOperand(x7)), "ldr d6, [x7]");
1041 COMPARE(ldr(d8, MemOperand(x9, 8)), "ldr d8, [x9, #8]");
1042 COMPARE(ldr(d10, MemOperand(x11, 32760)), "ldr d10, [x11, #32760]");
1043 COMPARE(str(s12, MemOperand(x13)), "str s12, [x13]");
1044 COMPARE(str(s14, MemOperand(x15, 4)), "str s14, [x15, #4]");
1045 COMPARE(str(s16, MemOperand(x17, 16380)), "str s16, [x17, #16380]");
1046 COMPARE(str(d18, MemOperand(x19)), "str d18, [x19]");
1047 COMPARE(str(d20, MemOperand(x21, 8)), "str d20, [x21, #8]");
1048 COMPARE(str(d22, MemOperand(x23, 32760)), "str d22, [x23, #32760]");
1049
1050 COMPARE(ldr(s0, MemOperand(x1, 4, PreIndex)), "ldr s0, [x1, #4]!");
1051 COMPARE(ldr(s2, MemOperand(x3, 255, PreIndex)), "ldr s2, [x3, #255]!");
1052 COMPARE(ldr(s4, MemOperand(x5, -256, PreIndex)), "ldr s4, [x5, #-256]!");
1053 COMPARE(ldr(d6, MemOperand(x7, 8, PreIndex)), "ldr d6, [x7, #8]!");
1054 COMPARE(ldr(d8, MemOperand(x9, 255, PreIndex)), "ldr d8, [x9, #255]!");
1055 COMPARE(ldr(d10, MemOperand(x11, -256, PreIndex)), "ldr d10, [x11, #-256]!");
1056 COMPARE(str(s12, MemOperand(x13, 4, PreIndex)), "str s12, [x13, #4]!");
1057 COMPARE(str(s14, MemOperand(x15, 255, PreIndex)), "str s14, [x15, #255]!");
1058 COMPARE(str(s16, MemOperand(x17, -256, PreIndex)), "str s16, [x17, #-256]!");
1059 COMPARE(str(d18, MemOperand(x19, 8, PreIndex)), "str d18, [x19, #8]!");
1060 COMPARE(str(d20, MemOperand(x21, 255, PreIndex)), "str d20, [x21, #255]!");
1061 COMPARE(str(d22, MemOperand(x23, -256, PreIndex)), "str d22, [x23, #-256]!");
1062
1063 COMPARE(ldr(s0, MemOperand(x1, 4, PostIndex)), "ldr s0, [x1], #4");
1064 COMPARE(ldr(s2, MemOperand(x3, 255, PostIndex)), "ldr s2, [x3], #255");
1065 COMPARE(ldr(s4, MemOperand(x5, -256, PostIndex)), "ldr s4, [x5], #-256");
1066 COMPARE(ldr(d6, MemOperand(x7, 8, PostIndex)), "ldr d6, [x7], #8");
1067 COMPARE(ldr(d8, MemOperand(x9, 255, PostIndex)), "ldr d8, [x9], #255");
1068 COMPARE(ldr(d10, MemOperand(x11, -256, PostIndex)), "ldr d10, [x11], #-256");
1069 COMPARE(str(s12, MemOperand(x13, 4, PostIndex)), "str s12, [x13], #4");
1070 COMPARE(str(s14, MemOperand(x15, 255, PostIndex)), "str s14, [x15], #255");
1071 COMPARE(str(s16, MemOperand(x17, -256, PostIndex)), "str s16, [x17], #-256");
1072 COMPARE(str(d18, MemOperand(x19, 8, PostIndex)), "str d18, [x19], #8");
1073 COMPARE(str(d20, MemOperand(x21, 255, PostIndex)), "str d20, [x21], #255");
1074 COMPARE(str(d22, MemOperand(x23, -256, PostIndex)), "str d22, [x23], #-256");
1075
1076 COMPARE(ldr(s24, MemOperand(sp)), "ldr s24, [sp]");
1077 COMPARE(ldr(d25, MemOperand(sp, 8)), "ldr d25, [sp, #8]");
1078 COMPARE(str(s26, MemOperand(sp, 4, PreIndex)), "str s26, [sp, #4]!");
1079 COMPARE(str(d27, MemOperand(sp, -8, PostIndex)), "str d27, [sp], #-8");
1080
1081 CLEANUP();
1082}
1083
1084
1085TEST(load_store_unscaled) {
1086 SETUP();
1087
armvixl4a102ba2014-07-14 09:02:40 +01001088 // If an unscaled-offset instruction is requested, it is used, even if the
1089 // offset could be encoded in a scaled-offset instruction.
1090 COMPARE(ldurb(w0, MemOperand(x1)), "ldurb w0, [x1]");
1091 COMPARE(ldurb(x2, MemOperand(x3, 1)), "ldurb w2, [x3, #1]");
1092 COMPARE(ldurb(w4, MemOperand(x5, 255)), "ldurb w4, [x5, #255]");
1093 COMPARE(sturb(w14, MemOperand(x15)), "sturb w14, [x15]");
1094 COMPARE(sturb(x16, MemOperand(x17, 1)), "sturb w16, [x17, #1]");
1095 COMPARE(sturb(w18, MemOperand(x19, 255)), "sturb w18, [x19, #255]");
1096 COMPARE(ldursb(w0, MemOperand(x1)), "ldursb w0, [x1]");
1097 COMPARE(ldursb(w2, MemOperand(x3, 1)), "ldursb w2, [x3, #1]");
1098 COMPARE(ldursb(x2, MemOperand(x3, 255)), "ldursb x2, [x3, #255]");
1099
1100 COMPARE(ldurh(w0, MemOperand(x1)), "ldurh w0, [x1]");
1101 COMPARE(ldurh(x2, MemOperand(x3, 2)), "ldurh w2, [x3, #2]");
1102 COMPARE(ldurh(w4, MemOperand(x5, 254)), "ldurh w4, [x5, #254]");
1103 COMPARE(sturh(w14, MemOperand(x15)), "sturh w14, [x15]");
1104 COMPARE(sturh(x16, MemOperand(x17, 2)), "sturh w16, [x17, #2]");
1105 COMPARE(sturh(w18, MemOperand(x19, 254)), "sturh w18, [x19, #254]");
1106 COMPARE(ldursh(w0, MemOperand(x1)), "ldursh w0, [x1]");
1107 COMPARE(ldursh(w2, MemOperand(x3, 2)), "ldursh w2, [x3, #2]");
1108 COMPARE(ldursh(x4, MemOperand(x5, 254)), "ldursh x4, [x5, #254]");
1109
1110 COMPARE(ldur(w0, MemOperand(x1)), "ldur w0, [x1]");
1111 COMPARE(ldur(w2, MemOperand(x3, 4)), "ldur w2, [x3, #4]");
1112 COMPARE(ldur(w4, MemOperand(x5, 248)), "ldur w4, [x5, #248]");
1113 COMPARE(stur(w12, MemOperand(x13)), "stur w12, [x13]");
1114 COMPARE(stur(w14, MemOperand(x15, 4)), "stur w14, [x15, #4]");
1115 COMPARE(stur(w16, MemOperand(x17, 248)), "stur w16, [x17, #248]");
1116 COMPARE(ldursw(x0, MemOperand(x1)), "ldursw x0, [x1]");
1117 COMPARE(ldursw(x2, MemOperand(x3, 4)), "ldursw x2, [x3, #4]");
1118 COMPARE(ldursw(x4, MemOperand(x5, 248)), "ldursw x4, [x5, #248]");
1119
1120 COMPARE(ldur(x6, MemOperand(x7)), "ldur x6, [x7]");
1121 COMPARE(ldur(x8, MemOperand(x9, 8)), "ldur x8, [x9, #8]");
1122 COMPARE(ldur(x10, MemOperand(x11, 248)), "ldur x10, [x11, #248]");
1123 COMPARE(stur(x18, MemOperand(x19)), "stur x18, [x19]");
1124 COMPARE(stur(x20, MemOperand(x21, 8)), "stur x20, [x21, #8]");
1125 COMPARE(stur(x22, MemOperand(x23, 248)), "stur x22, [x23, #248]");
1126
1127 // Normal loads and stores are converted to unscaled loads and stores if the
1128 // offset requires it.
armvixlad96eda2013-06-14 11:42:37 +01001129 COMPARE(ldr(w0, MemOperand(x1, 1)), "ldur w0, [x1, #1]");
1130 COMPARE(ldr(w2, MemOperand(x3, -1)), "ldur w2, [x3, #-1]");
1131 COMPARE(ldr(w4, MemOperand(x5, 255)), "ldur w4, [x5, #255]");
1132 COMPARE(ldr(w6, MemOperand(x7, -256)), "ldur w6, [x7, #-256]");
1133 COMPARE(ldr(x8, MemOperand(x9, 1)), "ldur x8, [x9, #1]");
1134 COMPARE(ldr(x10, MemOperand(x11, -1)), "ldur x10, [x11, #-1]");
1135 COMPARE(ldr(x12, MemOperand(x13, 255)), "ldur x12, [x13, #255]");
1136 COMPARE(ldr(x14, MemOperand(x15, -256)), "ldur x14, [x15, #-256]");
1137 COMPARE(str(w16, MemOperand(x17, 1)), "stur w16, [x17, #1]");
1138 COMPARE(str(w18, MemOperand(x19, -1)), "stur w18, [x19, #-1]");
1139 COMPARE(str(w20, MemOperand(x21, 255)), "stur w20, [x21, #255]");
1140 COMPARE(str(w22, MemOperand(x23, -256)), "stur w22, [x23, #-256]");
1141 COMPARE(str(x24, MemOperand(x25, 1)), "stur x24, [x25, #1]");
1142 COMPARE(str(x26, MemOperand(x27, -1)), "stur x26, [x27, #-1]");
1143 COMPARE(str(x28, MemOperand(x29, 255)), "stur x28, [x29, #255]");
1144 COMPARE(str(x30, MemOperand(x0, -256)), "stur x30, [x0, #-256]");
1145 COMPARE(ldr(w0, MemOperand(sp, 1)), "ldur w0, [sp, #1]");
1146 COMPARE(str(x1, MemOperand(sp, -1)), "stur x1, [sp, #-1]");
1147 COMPARE(ldrb(w2, MemOperand(x3, -2)), "ldurb w2, [x3, #-2]");
1148 COMPARE(ldrsb(w4, MemOperand(x5, -3)), "ldursb w4, [x5, #-3]");
1149 COMPARE(ldrsb(x6, MemOperand(x7, -4)), "ldursb x6, [x7, #-4]");
1150 COMPARE(ldrh(w8, MemOperand(x9, -5)), "ldurh w8, [x9, #-5]");
1151 COMPARE(ldrsh(w10, MemOperand(x11, -6)), "ldursh w10, [x11, #-6]");
1152 COMPARE(ldrsh(x12, MemOperand(x13, -7)), "ldursh x12, [x13, #-7]");
1153 COMPARE(ldrsw(x14, MemOperand(x15, -8)), "ldursw x14, [x15, #-8]");
1154
1155 CLEANUP();
1156}
1157
armvixl4a102ba2014-07-14 09:02:40 +01001158
1159TEST(load_store_unscaled_option) {
1160 SETUP();
1161
1162 // Just like load_store_unscaled, but specify the scaling option explicitly.
1163 LoadStoreScalingOption options[] = {
1164 PreferUnscaledOffset,
1165 RequireUnscaledOffset
1166 };
1167
1168 for (size_t i = 0; i < sizeof(options)/sizeof(options[0]); i++) {
1169 LoadStoreScalingOption option = options[i];
1170
1171 // If an unscaled-offset instruction is requested, it is used, even if the
1172 // offset could be encoded in a scaled-offset instruction.
1173 COMPARE(ldurb(w0, MemOperand(x1), option), "ldurb w0, [x1]");
1174 COMPARE(ldurb(x2, MemOperand(x3, 1), option), "ldurb w2, [x3, #1]");
1175 COMPARE(ldurb(w4, MemOperand(x5, 255), option), "ldurb w4, [x5, #255]");
1176 COMPARE(sturb(w14, MemOperand(x15), option), "sturb w14, [x15]");
1177 COMPARE(sturb(x16, MemOperand(x17, 1), option), "sturb w16, [x17, #1]");
1178 COMPARE(sturb(w18, MemOperand(x19, 255), option), "sturb w18, [x19, #255]");
1179 COMPARE(ldursb(w0, MemOperand(x1), option), "ldursb w0, [x1]");
1180 COMPARE(ldursb(w2, MemOperand(x3, 1), option), "ldursb w2, [x3, #1]");
1181 COMPARE(ldursb(x2, MemOperand(x3, 255), option), "ldursb x2, [x3, #255]");
1182
1183 COMPARE(ldurh(w0, MemOperand(x1), option), "ldurh w0, [x1]");
1184 COMPARE(ldurh(x2, MemOperand(x3, 2), option), "ldurh w2, [x3, #2]");
1185 COMPARE(ldurh(w4, MemOperand(x5, 254), option), "ldurh w4, [x5, #254]");
1186 COMPARE(sturh(w14, MemOperand(x15), option), "sturh w14, [x15]");
1187 COMPARE(sturh(x16, MemOperand(x17, 2), option), "sturh w16, [x17, #2]");
1188 COMPARE(sturh(w18, MemOperand(x19, 254), option), "sturh w18, [x19, #254]");
1189 COMPARE(ldursh(w0, MemOperand(x1), option), "ldursh w0, [x1]");
1190 COMPARE(ldursh(w2, MemOperand(x3, 2), option), "ldursh w2, [x3, #2]");
1191 COMPARE(ldursh(x4, MemOperand(x5, 254), option), "ldursh x4, [x5, #254]");
1192
1193 COMPARE(ldur(w0, MemOperand(x1), option), "ldur w0, [x1]");
1194 COMPARE(ldur(w2, MemOperand(x3, 4), option), "ldur w2, [x3, #4]");
1195 COMPARE(ldur(w4, MemOperand(x5, 248), option), "ldur w4, [x5, #248]");
1196 COMPARE(stur(w12, MemOperand(x13), option), "stur w12, [x13]");
1197 COMPARE(stur(w14, MemOperand(x15, 4), option), "stur w14, [x15, #4]");
1198 COMPARE(stur(w16, MemOperand(x17, 248), option), "stur w16, [x17, #248]");
1199 COMPARE(ldursw(x0, MemOperand(x1), option), "ldursw x0, [x1]");
1200 COMPARE(ldursw(x2, MemOperand(x3, 4), option), "ldursw x2, [x3, #4]");
1201 COMPARE(ldursw(x4, MemOperand(x5, 248), option), "ldursw x4, [x5, #248]");
1202
1203 COMPARE(ldur(x6, MemOperand(x7), option), "ldur x6, [x7]");
1204 COMPARE(ldur(x8, MemOperand(x9, 8), option), "ldur x8, [x9, #8]");
1205 COMPARE(ldur(x10, MemOperand(x11, 248), option), "ldur x10, [x11, #248]");
1206 COMPARE(stur(x18, MemOperand(x19), option), "stur x18, [x19]");
1207 COMPARE(stur(x20, MemOperand(x21, 8), option), "stur x20, [x21, #8]");
1208 COMPARE(stur(x22, MemOperand(x23, 248), option), "stur x22, [x23, #248]");
1209 }
1210
1211 // Normal loads and stores are converted to unscaled loads and stores if the
1212 // offset requires it. PreferScaledOffset is the default for these cases, so
1213 // the behaviour here is the same when no option is specified.
1214 LoadStoreScalingOption option = PreferScaledOffset;
1215 COMPARE(ldr(w0, MemOperand(x1, 1), option), "ldur w0, [x1, #1]");
1216 COMPARE(ldr(w2, MemOperand(x3, -1), option), "ldur w2, [x3, #-1]");
1217 COMPARE(ldr(w4, MemOperand(x5, 255), option), "ldur w4, [x5, #255]");
1218 COMPARE(ldr(w6, MemOperand(x7, -256), option), "ldur w6, [x7, #-256]");
1219 COMPARE(ldr(x8, MemOperand(x9, 1), option), "ldur x8, [x9, #1]");
1220 COMPARE(ldr(x10, MemOperand(x11, -1), option), "ldur x10, [x11, #-1]");
1221 COMPARE(ldr(x12, MemOperand(x13, 255), option), "ldur x12, [x13, #255]");
1222 COMPARE(ldr(x14, MemOperand(x15, -256), option), "ldur x14, [x15, #-256]");
1223 COMPARE(str(w16, MemOperand(x17, 1), option), "stur w16, [x17, #1]");
1224 COMPARE(str(w18, MemOperand(x19, -1), option), "stur w18, [x19, #-1]");
1225 COMPARE(str(w20, MemOperand(x21, 255), option), "stur w20, [x21, #255]");
1226 COMPARE(str(w22, MemOperand(x23, -256), option), "stur w22, [x23, #-256]");
1227 COMPARE(str(x24, MemOperand(x25, 1), option), "stur x24, [x25, #1]");
1228 COMPARE(str(x26, MemOperand(x27, -1), option), "stur x26, [x27, #-1]");
1229 COMPARE(str(x28, MemOperand(x29, 255), option), "stur x28, [x29, #255]");
1230 COMPARE(str(x30, MemOperand(x0, -256), option), "stur x30, [x0, #-256]");
1231 COMPARE(ldr(w0, MemOperand(sp, 1), option), "ldur w0, [sp, #1]");
1232 COMPARE(str(x1, MemOperand(sp, -1), option), "stur x1, [sp, #-1]");
1233 COMPARE(ldrb(w2, MemOperand(x3, -2), option), "ldurb w2, [x3, #-2]");
1234 COMPARE(ldrsb(w4, MemOperand(x5, -3), option), "ldursb w4, [x5, #-3]");
1235 COMPARE(ldrsb(x6, MemOperand(x7, -4), option), "ldursb x6, [x7, #-4]");
1236 COMPARE(ldrh(w8, MemOperand(x9, -5), option), "ldurh w8, [x9, #-5]");
1237 COMPARE(ldrsh(w10, MemOperand(x11, -6), option), "ldursh w10, [x11, #-6]");
1238 COMPARE(ldrsh(x12, MemOperand(x13, -7), option), "ldursh x12, [x13, #-7]");
1239 COMPARE(ldrsw(x14, MemOperand(x15, -8), option), "ldursw x14, [x15, #-8]");
1240
1241 CLEANUP();
1242}
1243
1244
armvixlad96eda2013-06-14 11:42:37 +01001245TEST(load_store_pair) {
1246 SETUP();
1247
1248 COMPARE(ldp(w0, w1, MemOperand(x2)), "ldp w0, w1, [x2]");
1249 COMPARE(ldp(x3, x4, MemOperand(x5)), "ldp x3, x4, [x5]");
1250 COMPARE(ldp(w6, w7, MemOperand(x8, 4)), "ldp w6, w7, [x8, #4]");
1251 COMPARE(ldp(x9, x10, MemOperand(x11, 8)), "ldp x9, x10, [x11, #8]");
1252 COMPARE(ldp(w12, w13, MemOperand(x14, 252)), "ldp w12, w13, [x14, #252]");
1253 COMPARE(ldp(x15, x16, MemOperand(x17, 504)), "ldp x15, x16, [x17, #504]");
1254 COMPARE(ldp(w18, w19, MemOperand(x20, -256)), "ldp w18, w19, [x20, #-256]");
1255 COMPARE(ldp(x21, x22, MemOperand(x23, -512)), "ldp x21, x22, [x23, #-512]");
1256 COMPARE(ldp(w24, w25, MemOperand(x26, 252, PreIndex)),
1257 "ldp w24, w25, [x26, #252]!");
1258 COMPARE(ldp(x27, x28, MemOperand(x29, 504, PreIndex)),
1259 "ldp x27, x28, [x29, #504]!");
1260 COMPARE(ldp(w30, w0, MemOperand(x1, -256, PreIndex)),
1261 "ldp w30, w0, [x1, #-256]!");
1262 COMPARE(ldp(x2, x3, MemOperand(x4, -512, PreIndex)),
1263 "ldp x2, x3, [x4, #-512]!");
1264 COMPARE(ldp(w5, w6, MemOperand(x7, 252, PostIndex)),
1265 "ldp w5, w6, [x7], #252");
1266 COMPARE(ldp(x8, x9, MemOperand(x10, 504, PostIndex)),
1267 "ldp x8, x9, [x10], #504");
1268 COMPARE(ldp(w11, w12, MemOperand(x13, -256, PostIndex)),
1269 "ldp w11, w12, [x13], #-256");
1270 COMPARE(ldp(x14, x15, MemOperand(x16, -512, PostIndex)),
1271 "ldp x14, x15, [x16], #-512");
1272
1273 COMPARE(ldp(s17, s18, MemOperand(x19)), "ldp s17, s18, [x19]");
1274 COMPARE(ldp(s20, s21, MemOperand(x22, 252)), "ldp s20, s21, [x22, #252]");
1275 COMPARE(ldp(s23, s24, MemOperand(x25, -256)), "ldp s23, s24, [x25, #-256]");
1276 COMPARE(ldp(s26, s27, MemOperand(x28, 252, PreIndex)),
1277 "ldp s26, s27, [x28, #252]!");
1278 COMPARE(ldp(s29, s30, MemOperand(x29, -256, PreIndex)),
1279 "ldp s29, s30, [x29, #-256]!");
1280 COMPARE(ldp(s31, s0, MemOperand(x1, 252, PostIndex)),
1281 "ldp s31, s0, [x1], #252");
1282 COMPARE(ldp(s2, s3, MemOperand(x4, -256, PostIndex)),
1283 "ldp s2, s3, [x4], #-256");
1284 COMPARE(ldp(d17, d18, MemOperand(x19)), "ldp d17, d18, [x19]");
1285 COMPARE(ldp(d20, d21, MemOperand(x22, 504)), "ldp d20, d21, [x22, #504]");
1286 COMPARE(ldp(d23, d24, MemOperand(x25, -512)), "ldp d23, d24, [x25, #-512]");
1287 COMPARE(ldp(d26, d27, MemOperand(x28, 504, PreIndex)),
1288 "ldp d26, d27, [x28, #504]!");
1289 COMPARE(ldp(d29, d30, MemOperand(x29, -512, PreIndex)),
1290 "ldp d29, d30, [x29, #-512]!");
1291 COMPARE(ldp(d31, d0, MemOperand(x1, 504, PostIndex)),
1292 "ldp d31, d0, [x1], #504");
1293 COMPARE(ldp(d2, d3, MemOperand(x4, -512, PostIndex)),
1294 "ldp d2, d3, [x4], #-512");
1295
1296 COMPARE(stp(w0, w1, MemOperand(x2)), "stp w0, w1, [x2]");
1297 COMPARE(stp(x3, x4, MemOperand(x5)), "stp x3, x4, [x5]");
1298 COMPARE(stp(w6, w7, MemOperand(x8, 4)), "stp w6, w7, [x8, #4]");
1299 COMPARE(stp(x9, x10, MemOperand(x11, 8)), "stp x9, x10, [x11, #8]");
1300 COMPARE(stp(w12, w13, MemOperand(x14, 252)), "stp w12, w13, [x14, #252]");
1301 COMPARE(stp(x15, x16, MemOperand(x17, 504)), "stp x15, x16, [x17, #504]");
1302 COMPARE(stp(w18, w19, MemOperand(x20, -256)), "stp w18, w19, [x20, #-256]");
1303 COMPARE(stp(x21, x22, MemOperand(x23, -512)), "stp x21, x22, [x23, #-512]");
1304 COMPARE(stp(w24, w25, MemOperand(x26, 252, PreIndex)),
1305 "stp w24, w25, [x26, #252]!");
1306 COMPARE(stp(x27, x28, MemOperand(x29, 504, PreIndex)),
1307 "stp x27, x28, [x29, #504]!");
1308 COMPARE(stp(w30, w0, MemOperand(x1, -256, PreIndex)),
1309 "stp w30, w0, [x1, #-256]!");
1310 COMPARE(stp(x2, x3, MemOperand(x4, -512, PreIndex)),
1311 "stp x2, x3, [x4, #-512]!");
1312 COMPARE(stp(w5, w6, MemOperand(x7, 252, PostIndex)),
1313 "stp w5, w6, [x7], #252");
1314 COMPARE(stp(x8, x9, MemOperand(x10, 504, PostIndex)),
1315 "stp x8, x9, [x10], #504");
1316 COMPARE(stp(w11, w12, MemOperand(x13, -256, PostIndex)),
1317 "stp w11, w12, [x13], #-256");
1318 COMPARE(stp(x14, x15, MemOperand(x16, -512, PostIndex)),
1319 "stp x14, x15, [x16], #-512");
1320
1321 COMPARE(stp(s17, s18, MemOperand(x19)), "stp s17, s18, [x19]");
1322 COMPARE(stp(s20, s21, MemOperand(x22, 252)), "stp s20, s21, [x22, #252]");
1323 COMPARE(stp(s23, s24, MemOperand(x25, -256)), "stp s23, s24, [x25, #-256]");
1324 COMPARE(stp(s26, s27, MemOperand(x28, 252, PreIndex)),
1325 "stp s26, s27, [x28, #252]!");
1326 COMPARE(stp(s29, s30, MemOperand(x29, -256, PreIndex)),
1327 "stp s29, s30, [x29, #-256]!");
1328 COMPARE(stp(s31, s0, MemOperand(x1, 252, PostIndex)),
1329 "stp s31, s0, [x1], #252");
1330 COMPARE(stp(s2, s3, MemOperand(x4, -256, PostIndex)),
1331 "stp s2, s3, [x4], #-256");
1332 COMPARE(stp(d17, d18, MemOperand(x19)), "stp d17, d18, [x19]");
1333 COMPARE(stp(d20, d21, MemOperand(x22, 504)), "stp d20, d21, [x22, #504]");
1334 COMPARE(stp(d23, d24, MemOperand(x25, -512)), "stp d23, d24, [x25, #-512]");
1335 COMPARE(stp(d26, d27, MemOperand(x28, 504, PreIndex)),
1336 "stp d26, d27, [x28, #504]!");
1337 COMPARE(stp(d29, d30, MemOperand(x29, -512, PreIndex)),
1338 "stp d29, d30, [x29, #-512]!");
1339 COMPARE(stp(d31, d0, MemOperand(x1, 504, PostIndex)),
1340 "stp d31, d0, [x1], #504");
1341 COMPARE(stp(d2, d3, MemOperand(x4, -512, PostIndex)),
1342 "stp d2, d3, [x4], #-512");
1343
1344 COMPARE(ldp(w16, w17, MemOperand(sp, 4, PostIndex)),
1345 "ldp w16, w17, [sp], #4");
1346 COMPARE(stp(x18, x19, MemOperand(sp, -8, PreIndex)),
1347 "stp x18, x19, [sp, #-8]!");
1348 COMPARE(ldp(s30, s31, MemOperand(sp, 12, PostIndex)),
1349 "ldp s30, s31, [sp], #12");
1350 COMPARE(stp(d30, d31, MemOperand(sp, -16)),
1351 "stp d30, d31, [sp, #-16]");
1352
1353 COMPARE(ldpsw(x0, x1, MemOperand(x2)), "ldpsw x0, x1, [x2]");
1354 COMPARE(ldpsw(x3, x4, MemOperand(x5, 16)), "ldpsw x3, x4, [x5, #16]");
1355 COMPARE(ldpsw(x6, x7, MemOperand(x8, -32, PreIndex)),
1356 "ldpsw x6, x7, [x8, #-32]!");
1357 COMPARE(ldpsw(x9, x10, MemOperand(x11, 128, PostIndex)),
1358 "ldpsw x9, x10, [x11], #128");
1359
1360 CLEANUP();
1361}
1362
armvixl4a102ba2014-07-14 09:02:40 +01001363
1364TEST(load_store_exclusive) {
1365 SETUP();
1366
1367 COMPARE(stxrb(w0, w1, MemOperand(x2)), "stxrb w0, w1, [x2]");
1368 COMPARE(stxrb(x3, w4, MemOperand(sp)), "stxrb w3, w4, [sp]");
1369 COMPARE(stxrb(w5, x6, MemOperand(x7)), "stxrb w5, w6, [x7]");
1370 COMPARE(stxrb(x8, x9, MemOperand(sp)), "stxrb w8, w9, [sp]");
1371 COMPARE(stxrh(w10, w11, MemOperand(x12)), "stxrh w10, w11, [x12]");
1372 COMPARE(stxrh(x13, w14, MemOperand(sp)), "stxrh w13, w14, [sp]");
1373 COMPARE(stxrh(w15, x16, MemOperand(x17)), "stxrh w15, w16, [x17]");
1374 COMPARE(stxrh(x18, x19, MemOperand(sp)), "stxrh w18, w19, [sp]");
1375 COMPARE(stxr(w20, w21, MemOperand(x22)), "stxr w20, w21, [x22]");
1376 COMPARE(stxr(x23, w24, MemOperand(sp)), "stxr w23, w24, [sp]");
1377 COMPARE(stxr(w25, x26, MemOperand(x27)), "stxr w25, x26, [x27]");
1378 COMPARE(stxr(x28, x29, MemOperand(sp)), "stxr w28, x29, [sp]");
1379 COMPARE(ldxrb(w30, MemOperand(x0)), "ldxrb w30, [x0]");
1380 COMPARE(ldxrb(w1, MemOperand(sp)), "ldxrb w1, [sp]");
1381 COMPARE(ldxrb(x2, MemOperand(x3)), "ldxrb w2, [x3]");
1382 COMPARE(ldxrb(x4, MemOperand(sp)), "ldxrb w4, [sp]");
1383 COMPARE(ldxrh(w5, MemOperand(x6)), "ldxrh w5, [x6]");
1384 COMPARE(ldxrh(w7, MemOperand(sp)), "ldxrh w7, [sp]");
1385 COMPARE(ldxrh(x8, MemOperand(x9)), "ldxrh w8, [x9]");
1386 COMPARE(ldxrh(x10, MemOperand(sp)), "ldxrh w10, [sp]");
1387 COMPARE(ldxr(w11, MemOperand(x12)), "ldxr w11, [x12]");
1388 COMPARE(ldxr(w13, MemOperand(sp)), "ldxr w13, [sp]");
1389 COMPARE(ldxr(x14, MemOperand(x15)), "ldxr x14, [x15]");
1390 COMPARE(ldxr(x16, MemOperand(sp)), "ldxr x16, [sp]");
1391 COMPARE(stxp(w17, w18, w19, MemOperand(x20)), "stxp w17, w18, w19, [x20]");
1392 COMPARE(stxp(x21, w22, w23, MemOperand(sp)), "stxp w21, w22, w23, [sp]");
1393 COMPARE(stxp(w24, x25, x26, MemOperand(x27)), "stxp w24, x25, x26, [x27]");
1394 COMPARE(stxp(x28, x29, x30, MemOperand(sp)), "stxp w28, x29, x30, [sp]");
1395 COMPARE(ldxp(w0, w1, MemOperand(x2)), "ldxp w0, w1, [x2]");
1396 COMPARE(ldxp(w3, w4, MemOperand(sp)), "ldxp w3, w4, [sp]");
1397 COMPARE(ldxp(x5, x6, MemOperand(x7)), "ldxp x5, x6, [x7]");
1398 COMPARE(ldxp(x8, x9, MemOperand(sp)), "ldxp x8, x9, [sp]");
1399 COMPARE(stlxrb(w10, w11, MemOperand(x12)), "stlxrb w10, w11, [x12]");
1400 COMPARE(stlxrb(x13, w14, MemOperand(sp)), "stlxrb w13, w14, [sp]");
1401 COMPARE(stlxrb(w15, x16, MemOperand(x17)), "stlxrb w15, w16, [x17]");
1402 COMPARE(stlxrb(x18, x19, MemOperand(sp)), "stlxrb w18, w19, [sp]");
1403 COMPARE(stlxrh(w20, w21, MemOperand(x22)), "stlxrh w20, w21, [x22]");
1404 COMPARE(stlxrh(x23, w24, MemOperand(sp)), "stlxrh w23, w24, [sp]");
1405 COMPARE(stlxrh(w25, x26, MemOperand(x27)), "stlxrh w25, w26, [x27]");
1406 COMPARE(stlxrh(x28, x29, MemOperand(sp)), "stlxrh w28, w29, [sp]");
1407 COMPARE(stlxr(w30, w0, MemOperand(x1)), "stlxr w30, w0, [x1]");
1408 COMPARE(stlxr(x2, w3, MemOperand(sp)), "stlxr w2, w3, [sp]");
1409 COMPARE(stlxr(w4, x5, MemOperand(x6)), "stlxr w4, x5, [x6]");
1410 COMPARE(stlxr(x7, x8, MemOperand(sp)), "stlxr w7, x8, [sp]");
1411 COMPARE(ldaxrb(w9, MemOperand(x10)), "ldaxrb w9, [x10]");
1412 COMPARE(ldaxrb(w11, MemOperand(sp)), "ldaxrb w11, [sp]");
1413 COMPARE(ldaxrb(x12, MemOperand(x13)), "ldaxrb w12, [x13]");
1414 COMPARE(ldaxrb(x14, MemOperand(sp)), "ldaxrb w14, [sp]");
1415 COMPARE(ldaxrh(w15, MemOperand(x16)), "ldaxrh w15, [x16]");
1416 COMPARE(ldaxrh(w17, MemOperand(sp)), "ldaxrh w17, [sp]");
1417 COMPARE(ldaxrh(x18, MemOperand(x19)), "ldaxrh w18, [x19]");
1418 COMPARE(ldaxrh(x20, MemOperand(sp)), "ldaxrh w20, [sp]");
1419 COMPARE(ldaxr(w21, MemOperand(x22)), "ldaxr w21, [x22]");
1420 COMPARE(ldaxr(w23, MemOperand(sp)), "ldaxr w23, [sp]");
1421 COMPARE(ldaxr(x24, MemOperand(x25)), "ldaxr x24, [x25]");
1422 COMPARE(ldaxr(x26, MemOperand(sp)), "ldaxr x26, [sp]");
1423 COMPARE(stlxp(w27, w28, w29, MemOperand(x30)), "stlxp w27, w28, w29, [x30]");
1424 COMPARE(stlxp(x0, w1, w2, MemOperand(sp)), "stlxp w0, w1, w2, [sp]");
1425 COMPARE(stlxp(w3, x4, x5, MemOperand(x6)), "stlxp w3, x4, x5, [x6]");
1426 COMPARE(stlxp(x7, x8, x9, MemOperand(sp)), "stlxp w7, x8, x9, [sp]");
1427 COMPARE(ldaxp(w10, w11, MemOperand(x12)), "ldaxp w10, w11, [x12]");
1428 COMPARE(ldaxp(w13, w14, MemOperand(sp)), "ldaxp w13, w14, [sp]");
1429 COMPARE(ldaxp(x15, x16, MemOperand(x17)), "ldaxp x15, x16, [x17]");
1430 COMPARE(ldaxp(x18, x19, MemOperand(sp)), "ldaxp x18, x19, [sp]");
1431 COMPARE(stlrb(w20, MemOperand(x21)), "stlrb w20, [x21]");
1432 COMPARE(stlrb(w22, MemOperand(sp)), "stlrb w22, [sp]");
1433 COMPARE(stlrb(x23, MemOperand(x24)), "stlrb w23, [x24]");
1434 COMPARE(stlrb(x25, MemOperand(sp)), "stlrb w25, [sp]");
1435 COMPARE(stlrh(w26, MemOperand(x27)), "stlrh w26, [x27]");
1436 COMPARE(stlrh(w28, MemOperand(sp)), "stlrh w28, [sp]");
1437 COMPARE(stlrh(x29, MemOperand(x30)), "stlrh w29, [x30]");
1438 COMPARE(stlrh(x0, MemOperand(sp)), "stlrh w0, [sp]");
1439 COMPARE(stlr(w1, MemOperand(x2)), "stlr w1, [x2]");
1440 COMPARE(stlr(w3, MemOperand(sp)), "stlr w3, [sp]");
1441 COMPARE(stlr(x4, MemOperand(x5)), "stlr x4, [x5]");
1442 COMPARE(stlr(x6, MemOperand(sp)), "stlr x6, [sp]");
1443 COMPARE(ldarb(w7, MemOperand(x8)), "ldarb w7, [x8]");
1444 COMPARE(ldarb(w9, MemOperand(sp)), "ldarb w9, [sp]");
1445 COMPARE(ldarb(x10, MemOperand(x11)), "ldarb w10, [x11]");
1446 COMPARE(ldarb(x12, MemOperand(sp)), "ldarb w12, [sp]");
1447 COMPARE(ldarh(w13, MemOperand(x14)), "ldarh w13, [x14]");
1448 COMPARE(ldarh(w15, MemOperand(sp)), "ldarh w15, [sp]");
1449 COMPARE(ldarh(x16, MemOperand(x17)), "ldarh w16, [x17]");
1450 COMPARE(ldarh(x18, MemOperand(sp)), "ldarh w18, [sp]");
1451 COMPARE(ldar(w19, MemOperand(x20)), "ldar w19, [x20]");
1452 COMPARE(ldar(w21, MemOperand(sp)), "ldar w21, [sp]");
1453 COMPARE(ldar(x22, MemOperand(x23)), "ldar x22, [x23]");
1454 COMPARE(ldar(x24, MemOperand(sp)), "ldar x24, [sp]");
1455
1456 CLEANUP();
1457}
1458
1459
armvixlad96eda2013-06-14 11:42:37 +01001460TEST(load_store_pair_nontemp) {
1461 SETUP();
1462
1463 COMPARE(ldnp(w0, w1, MemOperand(x2)), "ldnp w0, w1, [x2]");
1464 COMPARE(stnp(w3, w4, MemOperand(x5, 252)), "stnp w3, w4, [x5, #252]");
1465 COMPARE(ldnp(w6, w7, MemOperand(x8, -256)), "ldnp w6, w7, [x8, #-256]");
1466 COMPARE(stnp(x9, x10, MemOperand(x11)), "stnp x9, x10, [x11]");
1467 COMPARE(ldnp(x12, x13, MemOperand(x14, 504)), "ldnp x12, x13, [x14, #504]");
1468 COMPARE(stnp(x15, x16, MemOperand(x17, -512)), "stnp x15, x16, [x17, #-512]");
1469 COMPARE(ldnp(s18, s19, MemOperand(x20)), "ldnp s18, s19, [x20]");
1470 COMPARE(stnp(s21, s22, MemOperand(x23, 252)), "stnp s21, s22, [x23, #252]");
1471 COMPARE(ldnp(s24, s25, MemOperand(x26, -256)), "ldnp s24, s25, [x26, #-256]");
1472 COMPARE(stnp(d27, d28, MemOperand(x29)), "stnp d27, d28, [x29]");
1473 COMPARE(ldnp(d30, d31, MemOperand(x0, 504)), "ldnp d30, d31, [x0, #504]");
1474 COMPARE(stnp(d1, d2, MemOperand(x3, -512)), "stnp d1, d2, [x3, #-512]");
1475
1476 CLEANUP();
1477}
1478
armvixl4a102ba2014-07-14 09:02:40 +01001479
armvixlad96eda2013-06-14 11:42:37 +01001480TEST(load_literal) {
1481 SETUP();
1482
armvixlb0c8ae22014-03-21 14:03:59 +00001483 COMPARE_PREFIX(ldr(x10, 0x1234567890abcdef), "ldr x10, pc+8");
armvixl578645f2013-08-15 17:21:42 +01001484 COMPARE_PREFIX(ldr(w20, 0xfedcba09), "ldr w20, pc+8");
1485 COMPARE_PREFIX(ldr(d11, 1.234), "ldr d11, pc+8");
armvixlb0c8ae22014-03-21 14:03:59 +00001486 COMPARE_PREFIX(ldr(s22, 2.5f), "ldr s22, pc+8");
armvixlad96eda2013-06-14 11:42:37 +01001487
1488 CLEANUP();
1489}
1490
armvixl4a102ba2014-07-14 09:02:40 +01001491
armvixlad96eda2013-06-14 11:42:37 +01001492TEST(cond_select) {
1493 SETUP();
1494
1495 COMPARE(csel(w0, w1, w2, eq), "csel w0, w1, w2, eq");
1496 COMPARE(csel(x3, x4, x5, ne), "csel x3, x4, x5, ne");
1497 COMPARE(csinc(w6, w7, w8, hs), "csinc w6, w7, w8, hs");
1498 COMPARE(csinc(x9, x10, x11, lo), "csinc x9, x10, x11, lo");
1499 COMPARE(csinv(w12, w13, w14, mi), "csinv w12, w13, w14, mi");
1500 COMPARE(csinv(x15, x16, x17, pl), "csinv x15, x16, x17, pl");
1501 COMPARE(csneg(w18, w19, w20, vs), "csneg w18, w19, w20, vs");
1502 COMPARE(csneg(x21, x22, x23, vc), "csneg x21, x22, x23, vc");
1503 COMPARE(cset(w24, hi), "cset w24, hi");
1504 COMPARE(cset(x25, ls), "cset x25, ls");
1505 COMPARE(csetm(w26, ge), "csetm w26, ge");
1506 COMPARE(csetm(x27, lt), "csetm x27, lt");
1507 COMPARE(cinc(w28, w29, gt), "cinc w28, w29, gt");
1508 COMPARE(cinc(x30, x0, le), "cinc x30, x0, le");
1509 COMPARE(cinv(w1, w2, eq), "cinv w1, w2, eq");
1510 COMPARE(cinv(x3, x4, ne), "cinv x3, x4, ne");
1511 COMPARE(cneg(w5, w6, hs), "cneg w5, w6, hs");
1512 COMPARE(cneg(x7, x8, lo), "cneg x7, x8, lo");
1513
armvixl578645f2013-08-15 17:21:42 +01001514 COMPARE(csel(x0, x1, x2, al), "csel x0, x1, x2, al");
1515 COMPARE(csel(x1, x2, x3, nv), "csel x1, x2, x3, nv");
1516 COMPARE(csinc(x2, x3, x4, al), "csinc x2, x3, x4, al");
1517 COMPARE(csinc(x3, x4, x5, nv), "csinc x3, x4, x5, nv");
1518 COMPARE(csinv(x4, x5, x6, al), "csinv x4, x5, x6, al");
1519 COMPARE(csinv(x5, x6, x7, nv), "csinv x5, x6, x7, nv");
1520 COMPARE(csneg(x6, x7, x8, al), "csneg x6, x7, x8, al");
1521 COMPARE(csneg(x7, x8, x9, nv), "csneg x7, x8, x9, nv");
1522
armvixlad96eda2013-06-14 11:42:37 +01001523 CLEANUP();
1524}
1525
armvixl4a102ba2014-07-14 09:02:40 +01001526
armvixlf37fdc02014-02-05 13:22:16 +00001527TEST(cond_select_macro) {
1528 SETUP_CLASS(MacroAssembler);
1529
1530 COMPARE(Csel(w0, w1, -1, eq), "csinv w0, w1, wzr, eq");
1531 COMPARE(Csel(w2, w3, 0, ne), "csel w2, w3, wzr, ne");
1532 COMPARE(Csel(w4, w5, 1, hs), "csinc w4, w5, wzr, hs");
1533 COMPARE(Csel(x6, x7, -1, lo), "csinv x6, x7, xzr, lo");
1534 COMPARE(Csel(x8, x9, 0, mi), "csel x8, x9, xzr, mi");
1535 COMPARE(Csel(x10, x11, 1, pl), "csinc x10, x11, xzr, pl");
1536
1537 CLEANUP();
1538}
1539
armvixl4a102ba2014-07-14 09:02:40 +01001540
armvixlad96eda2013-06-14 11:42:37 +01001541TEST(cond_cmp) {
1542 SETUP();
1543
armvixl578645f2013-08-15 17:21:42 +01001544 COMPARE(ccmn(w0, w1, NZCVFlag, eq), "ccmn w0, w1, #NZCV, eq");
1545 COMPARE(ccmn(x2, x3, NZCFlag, ne), "ccmn x2, x3, #NZCv, ne");
1546 COMPARE(ccmp(w4, w5, NZVFlag, hs), "ccmp w4, w5, #NZcV, hs");
1547 COMPARE(ccmp(x6, x7, NZFlag, lo), "ccmp x6, x7, #NZcv, lo");
1548 COMPARE(ccmn(w8, 31, NFlag, mi), "ccmn w8, #31, #Nzcv, mi");
1549 COMPARE(ccmn(x9, 30, NCFlag, pl), "ccmn x9, #30, #NzCv, pl");
1550 COMPARE(ccmp(w10, 29, NVFlag, vs), "ccmp w10, #29, #NzcV, vs");
1551 COMPARE(ccmp(x11, 28, NFlag, vc), "ccmp x11, #28, #Nzcv, vc");
1552 COMPARE(ccmn(w12, w13, NoFlag, al), "ccmn w12, w13, #nzcv, al");
1553 COMPARE(ccmp(x14, 27, ZVFlag, nv), "ccmp x14, #27, #nZcV, nv");
armvixlad96eda2013-06-14 11:42:37 +01001554
1555 CLEANUP();
1556}
1557
armvixl4a102ba2014-07-14 09:02:40 +01001558
armvixlf37fdc02014-02-05 13:22:16 +00001559TEST(cond_cmp_macro) {
1560 SETUP_CLASS(MacroAssembler);
1561
1562 COMPARE(Ccmp(w0, -1, VFlag, hi), "ccmn w0, #1, #nzcV, hi");
1563 COMPARE(Ccmp(x1, -31, CFlag, ge), "ccmn x1, #31, #nzCv, ge");
1564 COMPARE(Ccmn(w2, -1, CVFlag, gt), "ccmp w2, #1, #nzCV, gt");
1565 COMPARE(Ccmn(x3, -31, ZCVFlag, ls), "ccmp x3, #31, #nZCV, ls");
1566
1567 CLEANUP();
1568}
1569
armvixl4a102ba2014-07-14 09:02:40 +01001570
armvixlad96eda2013-06-14 11:42:37 +01001571TEST(fmov_imm) {
1572 SETUP();
1573
armvixlb0c8ae22014-03-21 14:03:59 +00001574 COMPARE(fmov(s0, 1.0f), "fmov s0, #0x70 (1.0000)");
1575 COMPARE(fmov(s31, -13.0f), "fmov s31, #0xaa (-13.0000)");
armvixlad96eda2013-06-14 11:42:37 +01001576 COMPARE(fmov(d1, 1.0), "fmov d1, #0x70 (1.0000)");
1577 COMPARE(fmov(d29, -13.0), "fmov d29, #0xaa (-13.0000)");
1578
1579 CLEANUP();
1580}
1581
armvixl4a102ba2014-07-14 09:02:40 +01001582
armvixlad96eda2013-06-14 11:42:37 +01001583TEST(fmov_reg) {
1584 SETUP();
1585
1586 COMPARE(fmov(w3, s13), "fmov w3, s13");
1587 COMPARE(fmov(x6, d26), "fmov x6, d26");
1588 COMPARE(fmov(s11, w30), "fmov s11, w30");
1589 COMPARE(fmov(d31, x2), "fmov d31, x2");
1590 COMPARE(fmov(s12, s13), "fmov s12, s13");
1591 COMPARE(fmov(d22, d23), "fmov d22, d23");
1592
1593 CLEANUP();
1594}
1595
1596
1597TEST(fp_dp1) {
1598 SETUP();
1599
1600 COMPARE(fabs(s0, s1), "fabs s0, s1");
1601 COMPARE(fabs(s31, s30), "fabs s31, s30");
1602 COMPARE(fabs(d2, d3), "fabs d2, d3");
1603 COMPARE(fabs(d31, d30), "fabs d31, d30");
1604 COMPARE(fneg(s4, s5), "fneg s4, s5");
1605 COMPARE(fneg(s31, s30), "fneg s31, s30");
1606 COMPARE(fneg(d6, d7), "fneg d6, d7");
1607 COMPARE(fneg(d31, d30), "fneg d31, d30");
1608 COMPARE(fsqrt(s8, s9), "fsqrt s8, s9");
1609 COMPARE(fsqrt(s31, s30), "fsqrt s31, s30");
1610 COMPARE(fsqrt(d10, d11), "fsqrt d10, d11");
1611 COMPARE(fsqrt(d31, d30), "fsqrt d31, d30");
armvixlf37fdc02014-02-05 13:22:16 +00001612 COMPARE(frinta(s10, s11), "frinta s10, s11");
1613 COMPARE(frinta(s31, s30), "frinta s31, s30");
1614 COMPARE(frinta(d12, d13), "frinta d12, d13");
1615 COMPARE(frinta(d31, d30), "frinta d31, d30");
armvixlad96eda2013-06-14 11:42:37 +01001616 COMPARE(frintn(s10, s11), "frintn s10, s11");
1617 COMPARE(frintn(s31, s30), "frintn s31, s30");
1618 COMPARE(frintn(d12, d13), "frintn d12, d13");
1619 COMPARE(frintn(d31, d30), "frintn d31, d30");
1620 COMPARE(frintz(s10, s11), "frintz s10, s11");
1621 COMPARE(frintz(s31, s30), "frintz s31, s30");
1622 COMPARE(frintz(d12, d13), "frintz d12, d13");
1623 COMPARE(frintz(d31, d30), "frintz d31, d30");
1624 COMPARE(fcvt(d14, s15), "fcvt d14, s15");
1625 COMPARE(fcvt(d31, s31), "fcvt d31, s31");
1626
1627 CLEANUP();
1628}
1629
1630
1631TEST(fp_dp2) {
1632 SETUP();
1633
1634 COMPARE(fadd(s0, s1, s2), "fadd s0, s1, s2");
1635 COMPARE(fadd(d3, d4, d5), "fadd d3, d4, d5");
1636 COMPARE(fsub(s31, s30, s29), "fsub s31, s30, s29");
1637 COMPARE(fsub(d31, d30, d29), "fsub d31, d30, d29");
1638 COMPARE(fmul(s7, s8, s9), "fmul s7, s8, s9");
1639 COMPARE(fmul(d10, d11, d12), "fmul d10, d11, d12");
1640 COMPARE(fdiv(s13, s14, s15), "fdiv s13, s14, s15");
1641 COMPARE(fdiv(d16, d17, d18), "fdiv d16, d17, d18");
1642 COMPARE(fmax(s19, s20, s21), "fmax s19, s20, s21");
1643 COMPARE(fmax(d22, d23, d24), "fmax d22, d23, d24");
1644 COMPARE(fmin(s25, s26, s27), "fmin s25, s26, s27");
1645 COMPARE(fmin(d28, d29, d30), "fmin d28, d29, d30");
armvixlf37fdc02014-02-05 13:22:16 +00001646 COMPARE(fmaxnm(s31, s0, s1), "fmaxnm s31, s0, s1");
1647 COMPARE(fmaxnm(d2, d3, d4), "fmaxnm d2, d3, d4");
1648 COMPARE(fminnm(s5, s6, s7), "fminnm s5, s6, s7");
1649 COMPARE(fminnm(d8, d9, d10), "fminnm d8, d9, d10");
armvixlad96eda2013-06-14 11:42:37 +01001650
1651 CLEANUP();
1652}
1653
1654
1655TEST(fp_dp3) {
1656 SETUP();
1657
armvixlf37fdc02014-02-05 13:22:16 +00001658 COMPARE(fmadd(s7, s8, s9, s10), "fmadd s7, s8, s9, s10");
1659 COMPARE(fmadd(d10, d11, d12, d10), "fmadd d10, d11, d12, d10");
armvixlad96eda2013-06-14 11:42:37 +01001660 COMPARE(fmsub(s7, s8, s9, s10), "fmsub s7, s8, s9, s10");
1661 COMPARE(fmsub(d10, d11, d12, d10), "fmsub d10, d11, d12, d10");
1662
armvixlf37fdc02014-02-05 13:22:16 +00001663 COMPARE(fnmadd(s7, s8, s9, s10), "fnmadd s7, s8, s9, s10");
1664 COMPARE(fnmadd(d10, d11, d12, d10), "fnmadd d10, d11, d12, d10");
1665 COMPARE(fnmsub(s7, s8, s9, s10), "fnmsub s7, s8, s9, s10");
1666 COMPARE(fnmsub(d10, d11, d12, d10), "fnmsub d10, d11, d12, d10");
1667
armvixlad96eda2013-06-14 11:42:37 +01001668 CLEANUP();
1669}
1670
1671
1672TEST(fp_compare) {
1673 SETUP();
1674
1675 COMPARE(fcmp(s0, s1), "fcmp s0, s1");
1676 COMPARE(fcmp(s31, s30), "fcmp s31, s30");
1677 COMPARE(fcmp(d0, d1), "fcmp d0, d1");
1678 COMPARE(fcmp(d31, d30), "fcmp d31, d30");
1679 COMPARE(fcmp(s12, 0), "fcmp s12, #0.0");
1680 COMPARE(fcmp(d12, 0), "fcmp d12, #0.0");
1681
1682 CLEANUP();
1683}
1684
1685
1686TEST(fp_cond_compare) {
1687 SETUP();
1688
1689 COMPARE(fccmp(s0, s1, NoFlag, eq), "fccmp s0, s1, #nzcv, eq");
1690 COMPARE(fccmp(s2, s3, ZVFlag, ne), "fccmp s2, s3, #nZcV, ne");
1691 COMPARE(fccmp(s30, s16, NCFlag, pl), "fccmp s30, s16, #NzCv, pl");
1692 COMPARE(fccmp(s31, s31, NZCVFlag, le), "fccmp s31, s31, #NZCV, le");
1693 COMPARE(fccmp(d4, d5, VFlag, gt), "fccmp d4, d5, #nzcV, gt");
1694 COMPARE(fccmp(d6, d7, NFlag, vs), "fccmp d6, d7, #Nzcv, vs");
1695 COMPARE(fccmp(d30, d0, NZFlag, vc), "fccmp d30, d0, #NZcv, vc");
1696 COMPARE(fccmp(d31, d31, ZFlag, hs), "fccmp d31, d31, #nZcv, hs");
armvixl578645f2013-08-15 17:21:42 +01001697 COMPARE(fccmp(s14, s15, CVFlag, al), "fccmp s14, s15, #nzCV, al");
1698 COMPARE(fccmp(d16, d17, CFlag, nv), "fccmp d16, d17, #nzCv, nv");
armvixlad96eda2013-06-14 11:42:37 +01001699
1700 CLEANUP();
1701}
1702
1703
1704TEST(fp_select) {
1705 SETUP();
1706
1707 COMPARE(fcsel(s0, s1, s2, eq), "fcsel s0, s1, s2, eq")
1708 COMPARE(fcsel(s31, s31, s30, ne), "fcsel s31, s31, s30, ne");
1709 COMPARE(fcsel(d0, d1, d2, mi), "fcsel d0, d1, d2, mi");
1710 COMPARE(fcsel(d31, d30, d31, pl), "fcsel d31, d30, d31, pl");
armvixl578645f2013-08-15 17:21:42 +01001711 COMPARE(fcsel(s14, s15, s16, al), "fcsel s14, s15, s16, al");
1712 COMPARE(fcsel(d17, d18, d19, nv), "fcsel d17, d18, d19, nv");
armvixlad96eda2013-06-14 11:42:37 +01001713
1714 CLEANUP();
1715}
1716
1717
1718TEST(fcvt_scvtf_ucvtf) {
1719 SETUP();
1720
armvixlf37fdc02014-02-05 13:22:16 +00001721 COMPARE(fcvtas(w0, s1), "fcvtas w0, s1");
1722 COMPARE(fcvtas(x2, s3), "fcvtas x2, s3");
1723 COMPARE(fcvtas(w4, d5), "fcvtas w4, d5");
1724 COMPARE(fcvtas(x6, d7), "fcvtas x6, d7");
1725 COMPARE(fcvtau(w8, s9), "fcvtau w8, s9");
1726 COMPARE(fcvtau(x10, s11), "fcvtau x10, s11");
1727 COMPARE(fcvtau(w12, d13), "fcvtau w12, d13");
1728 COMPARE(fcvtau(x14, d15), "fcvtau x14, d15");
armvixlad96eda2013-06-14 11:42:37 +01001729 COMPARE(fcvtns(w0, s1), "fcvtns w0, s1");
1730 COMPARE(fcvtns(x2, s3), "fcvtns x2, s3");
1731 COMPARE(fcvtns(w4, d5), "fcvtns w4, d5");
1732 COMPARE(fcvtns(x6, d7), "fcvtns x6, d7");
1733 COMPARE(fcvtnu(w8, s9), "fcvtnu w8, s9");
1734 COMPARE(fcvtnu(x10, s11), "fcvtnu x10, s11");
1735 COMPARE(fcvtnu(w12, d13), "fcvtnu w12, d13");
1736 COMPARE(fcvtnu(x14, d15), "fcvtnu x14, d15");
1737 COMPARE(fcvtzu(x16, d17), "fcvtzu x16, d17");
1738 COMPARE(fcvtzu(w18, d19), "fcvtzu w18, d19");
1739 COMPARE(fcvtzs(x20, d21), "fcvtzs x20, d21");
1740 COMPARE(fcvtzs(w22, d23), "fcvtzs w22, d23");
1741 COMPARE(fcvtzu(x16, s17), "fcvtzu x16, s17");
1742 COMPARE(fcvtzu(w18, s19), "fcvtzu w18, s19");
1743 COMPARE(fcvtzs(x20, s21), "fcvtzs x20, s21");
1744 COMPARE(fcvtzs(w22, s23), "fcvtzs w22, s23");
1745 COMPARE(scvtf(d24, w25), "scvtf d24, w25");
armvixl578645f2013-08-15 17:21:42 +01001746 COMPARE(scvtf(s24, w25), "scvtf s24, w25");
1747 COMPARE(scvtf(d26, x0), "scvtf d26, x0");
1748 COMPARE(scvtf(s26, x0), "scvtf s26, x0");
armvixlad96eda2013-06-14 11:42:37 +01001749 COMPARE(ucvtf(d28, w29), "ucvtf d28, w29");
armvixl578645f2013-08-15 17:21:42 +01001750 COMPARE(ucvtf(s28, w29), "ucvtf s28, w29");
armvixlad96eda2013-06-14 11:42:37 +01001751 COMPARE(ucvtf(d0, x1), "ucvtf d0, x1");
armvixl578645f2013-08-15 17:21:42 +01001752 COMPARE(ucvtf(s0, x1), "ucvtf s0, x1");
1753 COMPARE(ucvtf(d0, x1, 0), "ucvtf d0, x1");
1754 COMPARE(ucvtf(s0, x1, 0), "ucvtf s0, x1");
armvixlad96eda2013-06-14 11:42:37 +01001755 COMPARE(scvtf(d1, x2, 1), "scvtf d1, x2, #1");
armvixl578645f2013-08-15 17:21:42 +01001756 COMPARE(scvtf(s1, x2, 1), "scvtf s1, x2, #1");
armvixlad96eda2013-06-14 11:42:37 +01001757 COMPARE(scvtf(d3, x4, 15), "scvtf d3, x4, #15");
armvixl578645f2013-08-15 17:21:42 +01001758 COMPARE(scvtf(s3, x4, 15), "scvtf s3, x4, #15");
armvixlad96eda2013-06-14 11:42:37 +01001759 COMPARE(scvtf(d5, x6, 32), "scvtf d5, x6, #32");
armvixl578645f2013-08-15 17:21:42 +01001760 COMPARE(scvtf(s5, x6, 32), "scvtf s5, x6, #32");
armvixlad96eda2013-06-14 11:42:37 +01001761 COMPARE(ucvtf(d7, x8, 2), "ucvtf d7, x8, #2");
armvixl578645f2013-08-15 17:21:42 +01001762 COMPARE(ucvtf(s7, x8, 2), "ucvtf s7, x8, #2");
armvixlad96eda2013-06-14 11:42:37 +01001763 COMPARE(ucvtf(d9, x10, 16), "ucvtf d9, x10, #16");
armvixl578645f2013-08-15 17:21:42 +01001764 COMPARE(ucvtf(s9, x10, 16), "ucvtf s9, x10, #16");
armvixlad96eda2013-06-14 11:42:37 +01001765 COMPARE(ucvtf(d11, x12, 33), "ucvtf d11, x12, #33");
armvixl578645f2013-08-15 17:21:42 +01001766 COMPARE(ucvtf(s11, x12, 33), "ucvtf s11, x12, #33");
armvixlad96eda2013-06-14 11:42:37 +01001767 COMPARE(fcvtms(w0, s1), "fcvtms w0, s1");
1768 COMPARE(fcvtms(x2, s3), "fcvtms x2, s3");
1769 COMPARE(fcvtms(w4, d5), "fcvtms w4, d5");
1770 COMPARE(fcvtms(x6, d7), "fcvtms x6, d7");
1771 COMPARE(fcvtmu(w8, s9), "fcvtmu w8, s9");
1772 COMPARE(fcvtmu(x10, s11), "fcvtmu x10, s11");
1773 COMPARE(fcvtmu(w12, d13), "fcvtmu w12, d13");
1774 COMPARE(fcvtmu(x14, d15), "fcvtmu x14, d15");
1775
1776 CLEANUP();
1777}
1778
1779
armvixl4a102ba2014-07-14 09:02:40 +01001780TEST(system_clrex) {
1781 SETUP();
1782
1783 COMPARE(clrex(0), "clrex #0x0");
1784 COMPARE(clrex(14), "clrex #0xe");
1785 COMPARE(clrex(15), "clrex");
1786 COMPARE(clrex(), "clrex");
1787
1788 CLEANUP();
1789}
1790
1791
armvixlad96eda2013-06-14 11:42:37 +01001792TEST(system_mrs) {
1793 SETUP();
1794
1795 COMPARE(mrs(x0, NZCV), "mrs x0, nzcv");
1796 COMPARE(mrs(x30, NZCV), "mrs x30, nzcv");
armvixl578645f2013-08-15 17:21:42 +01001797 COMPARE(mrs(x15, FPCR), "mrs x15, fpcr");
armvixlad96eda2013-06-14 11:42:37 +01001798
1799 CLEANUP();
1800}
1801
1802
1803TEST(system_msr) {
1804 SETUP();
1805
1806 COMPARE(msr(NZCV, x0), "msr nzcv, x0");
1807 COMPARE(msr(NZCV, x30), "msr nzcv, x30");
armvixl578645f2013-08-15 17:21:42 +01001808 COMPARE(msr(FPCR, x15), "msr fpcr, x15");
armvixlad96eda2013-06-14 11:42:37 +01001809
1810 CLEANUP();
1811}
1812
1813
1814TEST(system_nop) {
1815 SETUP();
1816
1817 COMPARE(nop(), "nop");
1818
1819 CLEANUP();
1820}
1821
1822
1823TEST(unreachable) {
1824 SETUP_CLASS(MacroAssembler);
1825
1826#ifdef USE_SIMULATOR
armvixlb0c8ae22014-03-21 14:03:59 +00001827 VIXL_ASSERT(kUnreachableOpcode == 0xdeb0);
armvixlad96eda2013-06-14 11:42:37 +01001828 COMPARE(Unreachable(), "hlt #0xdeb0");
1829#else
1830 COMPARE(Unreachable(), "blr xzr");
1831#endif
1832
1833 CLEANUP();
1834}
1835
1836
1837#ifdef USE_SIMULATOR
1838TEST(trace) {
1839 SETUP_CLASS(MacroAssembler);
1840
armvixlb0c8ae22014-03-21 14:03:59 +00001841 VIXL_ASSERT(kTraceOpcode == 0xdeb2);
armvixlad96eda2013-06-14 11:42:37 +01001842
1843 // All Trace calls should produce the same instruction.
1844 COMPARE(Trace(LOG_ALL, TRACE_ENABLE), "hlt #0xdeb2");
1845 COMPARE(Trace(LOG_REGS, TRACE_DISABLE), "hlt #0xdeb2");
1846
1847 CLEANUP();
1848}
1849#endif
1850
1851
1852#ifdef USE_SIMULATOR
1853TEST(log) {
1854 SETUP_CLASS(MacroAssembler);
1855
armvixlb0c8ae22014-03-21 14:03:59 +00001856 VIXL_ASSERT(kLogOpcode == 0xdeb3);
armvixlad96eda2013-06-14 11:42:37 +01001857
1858 // All Log calls should produce the same instruction.
1859 COMPARE(Log(LOG_ALL), "hlt #0xdeb3");
armvixl578645f2013-08-15 17:21:42 +01001860 COMPARE(Log(LOG_SYS_REGS), "hlt #0xdeb3");
armvixlad96eda2013-06-14 11:42:37 +01001861
1862 CLEANUP();
1863}
1864#endif
1865
1866
1867TEST(hlt) {
1868 SETUP();
1869
1870 COMPARE(hlt(0), "hlt #0x0");
1871 COMPARE(hlt(1), "hlt #0x1");
1872 COMPARE(hlt(65535), "hlt #0xffff");
1873
1874 CLEANUP();
1875}
1876
1877
1878TEST(brk) {
1879 SETUP();
1880
1881 COMPARE(brk(0), "brk #0x0");
1882 COMPARE(brk(1), "brk #0x1");
1883 COMPARE(brk(65535), "brk #0xffff");
1884
1885 CLEANUP();
1886}
1887
1888
1889TEST(add_sub_negative) {
1890 SETUP_CLASS(MacroAssembler);
1891
1892 COMPARE(Add(x10, x0, -42), "sub x10, x0, #0x2a (42)");
1893 COMPARE(Add(x11, x1, -687), "sub x11, x1, #0x2af (687)");
1894 COMPARE(Add(x12, x2, -0x88), "sub x12, x2, #0x88 (136)");
1895
1896 COMPARE(Sub(x13, x0, -600), "add x13, x0, #0x258 (600)");
1897 COMPARE(Sub(x14, x1, -313), "add x14, x1, #0x139 (313)");
1898 COMPARE(Sub(x15, x2, -0x555), "add x15, x2, #0x555 (1365)");
1899
1900 COMPARE(Add(w19, w3, -0x344), "sub w19, w3, #0x344 (836)");
1901 COMPARE(Add(w20, w4, -2000), "sub w20, w4, #0x7d0 (2000)");
1902
1903 COMPARE(Sub(w21, w3, -0xbc), "add w21, w3, #0xbc (188)");
1904 COMPARE(Sub(w22, w4, -2000), "add w22, w4, #0x7d0 (2000)");
1905
armvixlf37fdc02014-02-05 13:22:16 +00001906 COMPARE(Cmp(w0, -1), "cmn w0, #0x1 (1)");
1907 COMPARE(Cmp(x1, -1), "cmn x1, #0x1 (1)");
1908 COMPARE(Cmp(w2, -4095), "cmn w2, #0xfff (4095)");
1909 COMPARE(Cmp(x3, -4095), "cmn x3, #0xfff (4095)");
1910
1911 COMPARE(Cmn(w0, -1), "cmp w0, #0x1 (1)");
1912 COMPARE(Cmn(x1, -1), "cmp x1, #0x1 (1)");
1913 COMPARE(Cmn(w2, -4095), "cmp w2, #0xfff (4095)");
1914 COMPARE(Cmn(x3, -4095), "cmp x3, #0xfff (4095)");
1915
armvixlad96eda2013-06-14 11:42:37 +01001916 CLEANUP();
1917}
1918
1919
1920TEST(logical_immediate_move) {
1921 SETUP_CLASS(MacroAssembler);
1922
1923 COMPARE(And(w0, w1, 0), "movz w0, #0x0");
1924 COMPARE(And(x0, x1, 0), "movz x0, #0x0");
1925 COMPARE(Orr(w2, w3, 0), "mov w2, w3");
1926 COMPARE(Orr(x2, x3, 0), "mov x2, x3");
1927 COMPARE(Eor(w4, w5, 0), "mov w4, w5");
1928 COMPARE(Eor(x4, x5, 0), "mov x4, x5");
1929 COMPARE(Bic(w6, w7, 0), "mov w6, w7");
1930 COMPARE(Bic(x6, x7, 0), "mov x6, x7");
1931 COMPARE(Orn(w8, w9, 0), "movn w8, #0x0");
1932 COMPARE(Orn(x8, x9, 0), "movn x8, #0x0");
1933 COMPARE(Eon(w10, w11, 0), "mvn w10, w11");
1934 COMPARE(Eon(x10, x11, 0), "mvn x10, x11");
1935
1936 COMPARE(And(w12, w13, 0xffffffff), "mov w12, w13");
1937 COMPARE(And(x12, x13, 0xffffffff), "and x12, x13, #0xffffffff");
1938 COMPARE(And(x12, x13, 0xffffffffffffffff), "mov x12, x13");
1939 COMPARE(Orr(w14, w15, 0xffffffff), "movn w14, #0x0");
1940 COMPARE(Orr(x14, x15, 0xffffffff), "orr x14, x15, #0xffffffff");
1941 COMPARE(Orr(x14, x15, 0xffffffffffffffff), "movn x14, #0x0");
1942 COMPARE(Eor(w16, w17, 0xffffffff), "mvn w16, w17");
1943 COMPARE(Eor(x16, x17, 0xffffffff), "eor x16, x17, #0xffffffff");
1944 COMPARE(Eor(x16, x17, 0xffffffffffffffff), "mvn x16, x17");
1945 COMPARE(Bic(w18, w19, 0xffffffff), "movz w18, #0x0");
1946 COMPARE(Bic(x18, x19, 0xffffffff), "and x18, x19, #0xffffffff00000000");
1947 COMPARE(Bic(x18, x19, 0xffffffffffffffff), "movz x18, #0x0");
1948 COMPARE(Orn(w20, w21, 0xffffffff), "mov w20, w21");
1949 COMPARE(Orn(x20, x21, 0xffffffff), "orr x20, x21, #0xffffffff00000000");
1950 COMPARE(Orn(x20, x21, 0xffffffffffffffff), "mov x20, x21");
1951 COMPARE(Eon(w22, w23, 0xffffffff), "mov w22, w23");
1952 COMPARE(Eon(x22, x23, 0xffffffff), "eor x22, x23, #0xffffffff00000000");
1953 COMPARE(Eon(x22, x23, 0xffffffffffffffff), "mov x22, x23");
1954
1955 CLEANUP();
1956}
armvixlf37fdc02014-02-05 13:22:16 +00001957
armvixl4a102ba2014-07-14 09:02:40 +01001958
armvixlf37fdc02014-02-05 13:22:16 +00001959TEST(barriers) {
1960 SETUP_CLASS(MacroAssembler);
1961
1962 // DMB
1963 COMPARE(Dmb(FullSystem, BarrierAll), "dmb sy");
1964 COMPARE(Dmb(FullSystem, BarrierReads), "dmb ld");
1965 COMPARE(Dmb(FullSystem, BarrierWrites), "dmb st");
1966
1967 COMPARE(Dmb(InnerShareable, BarrierAll), "dmb ish");
1968 COMPARE(Dmb(InnerShareable, BarrierReads), "dmb ishld");
1969 COMPARE(Dmb(InnerShareable, BarrierWrites), "dmb ishst");
1970
1971 COMPARE(Dmb(NonShareable, BarrierAll), "dmb nsh");
1972 COMPARE(Dmb(NonShareable, BarrierReads), "dmb nshld");
1973 COMPARE(Dmb(NonShareable, BarrierWrites), "dmb nshst");
1974
1975 COMPARE(Dmb(OuterShareable, BarrierAll), "dmb osh");
1976 COMPARE(Dmb(OuterShareable, BarrierReads), "dmb oshld");
1977 COMPARE(Dmb(OuterShareable, BarrierWrites), "dmb oshst");
1978
1979 COMPARE(Dmb(FullSystem, BarrierOther), "dmb sy (0b1100)");
1980 COMPARE(Dmb(InnerShareable, BarrierOther), "dmb sy (0b1000)");
1981 COMPARE(Dmb(NonShareable, BarrierOther), "dmb sy (0b0100)");
1982 COMPARE(Dmb(OuterShareable, BarrierOther), "dmb sy (0b0000)");
1983
1984 // DSB
1985 COMPARE(Dsb(FullSystem, BarrierAll), "dsb sy");
1986 COMPARE(Dsb(FullSystem, BarrierReads), "dsb ld");
1987 COMPARE(Dsb(FullSystem, BarrierWrites), "dsb st");
1988
1989 COMPARE(Dsb(InnerShareable, BarrierAll), "dsb ish");
1990 COMPARE(Dsb(InnerShareable, BarrierReads), "dsb ishld");
1991 COMPARE(Dsb(InnerShareable, BarrierWrites), "dsb ishst");
1992
1993 COMPARE(Dsb(NonShareable, BarrierAll), "dsb nsh");
1994 COMPARE(Dsb(NonShareable, BarrierReads), "dsb nshld");
1995 COMPARE(Dsb(NonShareable, BarrierWrites), "dsb nshst");
1996
1997 COMPARE(Dsb(OuterShareable, BarrierAll), "dsb osh");
1998 COMPARE(Dsb(OuterShareable, BarrierReads), "dsb oshld");
1999 COMPARE(Dsb(OuterShareable, BarrierWrites), "dsb oshst");
2000
2001 COMPARE(Dsb(FullSystem, BarrierOther), "dsb sy (0b1100)");
2002 COMPARE(Dsb(InnerShareable, BarrierOther), "dsb sy (0b1000)");
2003 COMPARE(Dsb(NonShareable, BarrierOther), "dsb sy (0b0100)");
2004 COMPARE(Dsb(OuterShareable, BarrierOther), "dsb sy (0b0000)");
2005
2006 // ISB
2007 COMPARE(Isb(), "isb");
2008
2009 CLEANUP();
2010}
armvixlad96eda2013-06-14 11:42:37 +01002011} // namespace vixl