• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 //     * Redistributions of source code must retain the above copyright
7 //       notice, this list of conditions and the following disclaimer.
8 //     * Redistributions in binary form must reproduce the above
9 //       copyright notice, this list of conditions and the following
10 //       disclaimer in the documentation and/or other materials provided
11 //       with the distribution.
12 //     * Neither the name of Google Inc. nor the names of its
13 //       contributors may be used to endorse or promote products derived
14 //       from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 //
28 
29 #include <stdlib.h>
30 
31 #include "src/v8.h"
32 
33 #include "src/debug/debug.h"
34 #include "src/disasm.h"
35 #include "src/disassembler.h"
36 #include "src/macro-assembler.h"
37 #include "test/cctest/cctest.h"
38 
39 using namespace v8::internal;
40 
41 
DisassembleAndCompare(byte * pc,const char * compare_string)42 bool DisassembleAndCompare(byte* pc, const char* compare_string) {
43   disasm::NameConverter converter;
44   disasm::Disassembler disasm(converter);
45   EmbeddedVector<char, 128> disasm_buffer;
46 
47   disasm.InstructionDecode(disasm_buffer, pc);
48 
49   if (strcmp(compare_string, disasm_buffer.start()) != 0) {
50     fprintf(stderr,
51             "expected: \n"
52             "%s\n"
53             "disassembled: \n"
54             "%s\n\n",
55             compare_string, disasm_buffer.start());
56     return false;
57   }
58   return true;
59 }
60 
61 
62 // Set up V8 to a state where we can at least run the assembler and
63 // disassembler. Declare the variables and allocate the data structures used
64 // in the rest of the macros.
65 #define SET_UP()                                          \
66   CcTest::InitializeVM();                                 \
67   Isolate* isolate = CcTest::i_isolate();                  \
68   HandleScope scope(isolate);                             \
69   byte *buffer = reinterpret_cast<byte*>(malloc(4*1024)); \
70   Assembler assm(isolate, buffer, 4*1024);                \
71   bool failure = false;
72 
73 
74 // This macro assembles one instruction using the preallocated assembler and
75 // disassembles the generated instruction, comparing the output to the expected
76 // value. If the comparison fails an error message is printed, but the test
77 // continues to run until the end.
78 #define COMPARE(asm_, compare_string) \
79   { \
80     int pc_offset = assm.pc_offset(); \
81     byte *progcounter = &buffer[pc_offset]; \
82     assm.asm_; \
83     if (!DisassembleAndCompare(progcounter, compare_string)) failure = true; \
84   }
85 
86 // Force emission of any pending literals into a pool.
87 #define EMIT_PENDING_LITERALS() \
88   assm.CheckConstPool(true, false)
89 
90 
91 // Verify that all invocations of the COMPARE macro passed successfully.
92 // Exit with a failure if at least one of the tests failed.
93 #define VERIFY_RUN() \
94 if (failure) { \
95     V8_Fatal(__FILE__, __LINE__, "ARM Disassembler tests failed.\n"); \
96   }
97 
98 // clang-format off
99 
100 
TEST(Type0)101 TEST(Type0) {
102   SET_UP();
103 
104   COMPARE(and_(r0, r1, Operand(r2)),
105           "e0010002       and r0, r1, r2");
106   COMPARE(and_(r1, r2, Operand(r3), LeaveCC),
107           "e0021003       and r1, r2, r3");
108   COMPARE(and_(r2, r3, Operand(r4), SetCC),
109           "e0132004       ands r2, r3, r4");
110   COMPARE(and_(r3, r4, Operand(r5), LeaveCC, eq),
111           "00043005       andeq r3, r4, r5");
112 
113   COMPARE(eor(r4, r5, Operand(r6, LSL, 0)),
114           "e0254006       eor r4, r5, r6");
115   COMPARE(eor(r4, r5, Operand(r7, LSL, 1), SetCC),
116           "e0354087       eors r4, r5, r7, lsl #1");
117   COMPARE(eor(r4, r5, Operand(r8, LSL, 2), LeaveCC, ne),
118           "10254108       eorne r4, r5, r8, lsl #2");
119   COMPARE(eor(r4, r5, Operand(r9, LSL, 3), SetCC, cs),
120           "20354189       eorcss r4, r5, r9, lsl #3");
121 
122   COMPARE(sub(r5, r6, Operand(r10, LSL, 31), LeaveCC, hs),
123           "20465f8a       subcs r5, r6, r10, lsl #31");
124   COMPARE(sub(r5, r6, Operand(r10, LSL, 30), SetCC, cc),
125           "30565f0a       subccs r5, r6, r10, lsl #30");
126   COMPARE(sub(r5, r6, Operand(r10, LSL, 24), LeaveCC, lo),
127           "30465c0a       subcc r5, r6, r10, lsl #24");
128   COMPARE(sub(r5, r6, Operand(r10, LSL, 16), SetCC, mi),
129           "4056580a       submis r5, r6, r10, lsl #16");
130 
131   COMPARE(rsb(r6, r7, Operand(fp)),
132           "e067600b       rsb r6, r7, fp");
133   COMPARE(rsb(r6, r7, Operand(fp, LSR, 1)),
134           "e06760ab       rsb r6, r7, fp, lsr #1");
135   COMPARE(rsb(r6, r7, Operand(fp, LSR, 0), SetCC),
136           "e077602b       rsbs r6, r7, fp, lsr #32");
137   COMPARE(rsb(r6, r7, Operand(fp, LSR, 31), LeaveCC, pl),
138           "50676fab       rsbpl r6, r7, fp, lsr #31");
139 
140   COMPARE(add(r7, r8, Operand(ip, ASR, 1)),
141           "e08870cc       add r7, r8, ip, asr #1");
142   COMPARE(add(r7, r8, Operand(ip, ASR, 0)),
143           "e088704c       add r7, r8, ip, asr #32");
144   COMPARE(add(r7, r8, Operand(ip), SetCC),
145           "e098700c       adds r7, r8, ip");
146   COMPARE(add(r7, r8, Operand(ip, ASR, 31), SetCC, vs),
147           "60987fcc       addvss r7, r8, ip, asr #31");
148 
149   COMPARE(adc(r7, fp, Operand(ip, ASR, 5)),
150           "e0ab72cc       adc r7, fp, ip, asr #5");
151   COMPARE(adc(r4, ip, Operand(ip, ASR, 1), LeaveCC, vc),
152           "70ac40cc       adcvc r4, ip, ip, asr #1");
153   COMPARE(adc(r5, sp, Operand(ip), SetCC),
154           "e0bd500c       adcs r5, sp, ip");
155   COMPARE(adc(r8, lr, Operand(ip, ASR, 31), SetCC, vc),
156           "70be8fcc       adcvcs r8, lr, ip, asr #31");
157 
158   COMPARE(sbc(r7, r1, Operand(ip, ROR, 1), LeaveCC, hi),
159           "80c170ec       sbchi r7, r1, ip, ror #1");
160   COMPARE(sbc(r7, r9, Operand(ip, ROR, 4)),
161           "e0c9726c       sbc r7, r9, ip, ror #4");
162   COMPARE(sbc(r7, r10, Operand(ip), SetCC),
163           "e0da700c       sbcs r7, r10, ip");
164   COMPARE(sbc(r7, ip, Operand(ip, ROR, 31), SetCC, hi),
165           "80dc7fec       sbchis r7, ip, ip, ror #31");
166 
167   COMPARE(rsc(r7, r8, Operand(ip, LSL, r0)),
168           "e0e8701c       rsc r7, r8, ip, lsl r0");
169   COMPARE(rsc(r7, r8, Operand(ip, LSL, r1)),
170           "e0e8711c       rsc r7, r8, ip, lsl r1");
171   COMPARE(rsc(r7, r8, Operand(ip), SetCC),
172           "e0f8700c       rscs r7, r8, ip");
173   COMPARE(rsc(r7, r8, Operand(ip, LSL, r3), SetCC, ls),
174           "90f8731c       rsclss r7, r8, ip, lsl r3");
175 
176   COMPARE(tst(r7, Operand(r5, ASR, ip), ge),
177           "a1170c55       tstge r7, r5, asr ip");
178   COMPARE(tst(r7, Operand(r6, ASR, sp)),
179           "e1170d56       tst r7, r6, asr sp");
180   COMPARE(tst(r7, Operand(r7), ge),
181           "a1170007       tstge r7, r7");
182   COMPARE(tst(r7, Operand(r8, ASR, fp), ge),
183           "a1170b58       tstge r7, r8, asr fp");
184 
185   COMPARE(teq(r7, Operand(r5, ROR, r0), lt),
186           "b1370075       teqlt r7, r5, ror r0");
187   COMPARE(teq(r7, Operand(r6, ROR, lr)),
188           "e1370e76       teq r7, r6, ror lr");
189   COMPARE(teq(r7, Operand(r7), lt),
190           "b1370007       teqlt r7, r7");
191   COMPARE(teq(r7, Operand(r8, ROR, r1)),
192           "e1370178       teq r7, r8, ror r1");
193 
194   COMPARE(cmp(r7, Operand(r4)),
195           "e1570004       cmp r7, r4");
196   COMPARE(cmp(r7, Operand(r6, LSL, 1), gt),
197           "c1570086       cmpgt r7, r6, lsl #1");
198   COMPARE(cmp(r7, Operand(r8, LSR, 3), gt),
199           "c15701a8       cmpgt r7, r8, lsr #3");
200   COMPARE(cmp(r7, Operand(r8, ASR, 19)),
201           "e15709c8       cmp r7, r8, asr #19");
202 
203   COMPARE(cmn(r0, Operand(r4)),
204           "e1700004       cmn r0, r4");
205   COMPARE(cmn(r1, Operand(r6, ROR, 1)),
206           "e17100e6       cmn r1, r6, ror #1");
207   COMPARE(cmn(r2, Operand(r8)),
208           "e1720008       cmn r2, r8");
209   COMPARE(cmn(r3, Operand(fp), le),
210           "d173000b       cmnle r3, fp");
211 
212   COMPARE(orr(r7, r8, Operand(lr), LeaveCC, al),
213           "e188700e       orr r7, r8, lr");
214   COMPARE(orr(r7, r8, Operand(fp)),
215           "e188700b       orr r7, r8, fp");
216   COMPARE(orr(r7, r8, Operand(sp), SetCC),
217           "e198700d       orrs r7, r8, sp");
218   COMPARE(orr(r7, r8, Operand(ip), SetCC, al),
219           "e198700c       orrs r7, r8, ip");
220 
221   COMPARE(mov(r0, Operand(r1), LeaveCC, eq),
222           "01a00001       moveq r0, r1");
223   COMPARE(mov(r0, Operand(r2)),
224           "e1a00002       mov r0, r2");
225   COMPARE(mov(r0, Operand(r3), SetCC),
226           "e1b00003       movs r0, r3");
227   COMPARE(mov(r0, Operand(r4), SetCC, pl),
228           "51b00004       movpls r0, r4");
229 
230   COMPARE(bic(r0, lr, Operand(r1), LeaveCC, vs),
231           "61ce0001       bicvs r0, lr, r1");
232   COMPARE(bic(r0, r9, Operand(r2), LeaveCC, vc),
233           "71c90002       bicvc r0, r9, r2");
234   COMPARE(bic(r0, r5, Operand(r3), SetCC),
235           "e1d50003       bics r0, r5, r3");
236   COMPARE(bic(r0, r1, Operand(r4), SetCC, pl),
237           "51d10004       bicpls r0, r1, r4");
238 
239   COMPARE(mvn(r10, Operand(r1)),
240           "e1e0a001       mvn r10, r1");
241   COMPARE(mvn(r9, Operand(r2)),
242           "e1e09002       mvn r9, r2");
243   COMPARE(mvn(r0, Operand(r3), SetCC),
244           "e1f00003       mvns r0, r3");
245   COMPARE(mvn(r5, Operand(r4), SetCC, cc),
246           "31f05004       mvnccs r5, r4");
247 
248   // Instructions autotransformed by the assembler.
249   // mov -> mvn.
250   COMPARE(mov(r3, Operand(-1), LeaveCC, al),
251           "e3e03000       mvn r3, #0");
252   COMPARE(mov(r4, Operand(-2), SetCC, al),
253           "e3f04001       mvns r4, #1");
254   COMPARE(mov(r5, Operand(0x0ffffff0), SetCC, ne),
255           "13f052ff       mvnnes r5, #-268435441");
256   COMPARE(mov(r6, Operand(-1), LeaveCC, ne),
257           "13e06000       mvnne r6, #0");
258 
259   // mvn -> mov.
260   COMPARE(mvn(r3, Operand(-1), LeaveCC, al),
261           "e3a03000       mov r3, #0");
262   COMPARE(mvn(r4, Operand(-2), SetCC, al),
263           "e3b04001       movs r4, #1");
264   COMPARE(mvn(r5, Operand(0x0ffffff0), SetCC, ne),
265           "13b052ff       movnes r5, #-268435441");
266   COMPARE(mvn(r6, Operand(-1), LeaveCC, ne),
267           "13a06000       movne r6, #0");
268 
269   // mov -> movw.
270   if (CpuFeatures::IsSupported(ARMv7)) {
271     COMPARE(mov(r5, Operand(0x01234), LeaveCC, ne),
272             "13015234       movwne r5, #4660");
273     // We only disassemble one instruction so the eor instruction is not here.
274     COMPARE(eor(r5, r4, Operand(0x1234), LeaveCC, ne),
275             "1301c234       movwne ip, #4660");
276     // Movw can't do setcc, so first move to ip, then the following instruction
277     // moves to r5.  Mov immediate with setcc is pretty strange anyway.
278     COMPARE(mov(r5, Operand(0x01234), SetCC, ne),
279             "1301c234       movwne ip, #4660");
280     // Emit a literal pool now, otherwise this could be dumped later, in the
281     // middle of a different test.
282     EMIT_PENDING_LITERALS();
283 
284     // We only disassemble one instruction so the eor instruction is not here.
285     // The eor does the setcc so we get a movw here.
286     COMPARE(eor(r5, r4, Operand(0x1234), SetCC, ne),
287             "1301c234       movwne ip, #4660");
288 
289     COMPARE(movt(r5, 0x4321, ne),
290             "13445321       movtne r5, #17185");
291     COMPARE(movw(r5, 0xabcd, eq),
292             "030a5bcd       movweq r5, #43981");
293   }
294 
295   // Eor doesn't have an eor-negative variant, but we can do an mvn followed by
296   // an eor to get the same effect.
297   COMPARE(eor(r5, r4, Operand(0xffffff34), SetCC, ne),
298           "13e0c0cb       mvnne ip, #203");
299 
300   // and <-> bic.
301   COMPARE(and_(r3, r5, Operand(0xfc03ffff)),
302           "e3c537ff       bic r3, r5, #66846720");
303   COMPARE(bic(r3, r5, Operand(0xfc03ffff)),
304           "e20537ff       and r3, r5, #66846720");
305 
306   // sub <-> add.
307   COMPARE(add(r3, r5, Operand(-1024)),
308           "e2453b01       sub r3, r5, #1024");
309   COMPARE(sub(r3, r5, Operand(-1024)),
310           "e2853b01       add r3, r5, #1024");
311 
312   // cmp <-> cmn.
313   COMPARE(cmp(r3, Operand(-1024)),
314           "e3730b01       cmn r3, #1024");
315   COMPARE(cmn(r3, Operand(-1024)),
316           "e3530b01       cmp r3, #1024");
317 
318   // Miscellaneous instructions encoded as type 0.
319   COMPARE(blx(ip),
320           "e12fff3c       blx ip");
321   COMPARE(bkpt(0),
322           "e1200070       bkpt 0");
323   COMPARE(bkpt(0xffff),
324           "e12fff7f       bkpt 65535");
325   COMPARE(clz(r6, r7),
326           "e16f6f17       clz r6, r7");
327 
328   VERIFY_RUN();
329 }
330 
331 
TEST(Type1)332 TEST(Type1) {
333   SET_UP();
334 
335   COMPARE(and_(r0, r1, Operand(0x00000000)),
336           "e2010000       and r0, r1, #0");
337   COMPARE(and_(r1, r2, Operand(0x00000001), LeaveCC),
338           "e2021001       and r1, r2, #1");
339   COMPARE(and_(r2, r3, Operand(0x00000010), SetCC),
340           "e2132010       ands r2, r3, #16");
341   COMPARE(and_(r3, r4, Operand(0x00000100), LeaveCC, eq),
342           "02043c01       andeq r3, r4, #256");
343   COMPARE(and_(r4, r5, Operand(0x00001000), SetCC, ne),
344           "12154a01       andnes r4, r5, #4096");
345 
346   COMPARE(eor(r4, r5, Operand(0x00001000)),
347           "e2254a01       eor r4, r5, #4096");
348   COMPARE(eor(r4, r4, Operand(0x00010000), LeaveCC),
349           "e2244801       eor r4, r4, #65536");
350   COMPARE(eor(r4, r3, Operand(0x00100000), SetCC),
351           "e2334601       eors r4, r3, #1048576");
352   COMPARE(eor(r4, r2, Operand(0x01000000), LeaveCC, cs),
353           "22224401       eorcs r4, r2, #16777216");
354   COMPARE(eor(r4, r1, Operand(0x10000000), SetCC, cc),
355           "32314201       eorccs r4, r1, #268435456");
356 
357   VERIFY_RUN();
358 }
359 
360 
TEST(Type3)361 TEST(Type3) {
362   SET_UP();
363 
364   if (CpuFeatures::IsSupported(ARMv7)) {
365     COMPARE(ubfx(r0, r1, 5, 10),
366             "e7e902d1       ubfx r0, r1, #5, #10");
367     COMPARE(ubfx(r1, r0, 5, 10),
368             "e7e912d0       ubfx r1, r0, #5, #10");
369     COMPARE(ubfx(r0, r1, 31, 1),
370             "e7e00fd1       ubfx r0, r1, #31, #1");
371     COMPARE(ubfx(r1, r0, 31, 1),
372             "e7e01fd0       ubfx r1, r0, #31, #1");
373 
374     COMPARE(sbfx(r0, r1, 5, 10),
375             "e7a902d1       sbfx r0, r1, #5, #10");
376     COMPARE(sbfx(r1, r0, 5, 10),
377             "e7a912d0       sbfx r1, r0, #5, #10");
378     COMPARE(sbfx(r0, r1, 31, 1),
379             "e7a00fd1       sbfx r0, r1, #31, #1");
380     COMPARE(sbfx(r1, r0, 31, 1),
381             "e7a01fd0       sbfx r1, r0, #31, #1");
382 
383     COMPARE(bfc(r0, 5, 10),
384             "e7ce029f       bfc r0, #5, #10");
385     COMPARE(bfc(r1, 5, 10),
386             "e7ce129f       bfc r1, #5, #10");
387     COMPARE(bfc(r0, 31, 1),
388             "e7df0f9f       bfc r0, #31, #1");
389     COMPARE(bfc(r1, 31, 1),
390             "e7df1f9f       bfc r1, #31, #1");
391 
392     COMPARE(bfi(r0, r1, 5, 10),
393             "e7ce0291       bfi r0, r1, #5, #10");
394     COMPARE(bfi(r1, r0, 5, 10),
395             "e7ce1290       bfi r1, r0, #5, #10");
396     COMPARE(bfi(r0, r1, 31, 1),
397             "e7df0f91       bfi r0, r1, #31, #1");
398     COMPARE(bfi(r1, r0, 31, 1),
399             "e7df1f90       bfi r1, r0, #31, #1");
400 
401     COMPARE(usat(r0, 1, Operand(r1)),
402             "e6e10011       usat r0, #1, r1");
403     COMPARE(usat(r2, 7, Operand(lr)),
404             "e6e7201e       usat r2, #7, lr");
405     COMPARE(usat(r3, 31, Operand(r4, LSL, 31)),
406             "e6ff3f94       usat r3, #31, r4, lsl #31");
407     COMPARE(usat(r8, 0, Operand(r5, ASR, 17)),
408             "e6e088d5       usat r8, #0, r5, asr #17");
409 
410     COMPARE(pkhbt(r3, r4, Operand(r5, LSL, 17)),
411             "e6843895       pkhbt r3, r4, r5, lsl #17");
412     COMPARE(pkhtb(r3, r4, Operand(r5, ASR, 17)),
413             "e68438d5       pkhtb r3, r4, r5, asr #17");
414 
415     COMPARE(sxtb(r1, r7, 0, eq), "06af1077       sxtbeq r1, r7");
416     COMPARE(sxtb(r0, r0, 8, ne), "16af0470       sxtbne r0, r0, ror #8");
417     COMPARE(sxtb(r9, r10, 16), "e6af987a       sxtb r9, r10, ror #16");
418     COMPARE(sxtb(r4, r3, 24), "e6af4c73       sxtb r4, r3, ror #24");
419 
420     COMPARE(sxtab(r3, r4, r5), "e6a43075       sxtab r3, r4, r5");
421 
422     COMPARE(sxth(r5, r0), "e6bf5070       sxth r5, r0");
423     COMPARE(sxth(r5, r9, 8), "e6bf5479       sxth r5, r9, ror #8");
424     COMPARE(sxth(r5, r9, 16, hi), "86bf5879       sxthhi r5, r9, ror #16");
425     COMPARE(sxth(r8, r9, 24, cc), "36bf8c79       sxthcc r8, r9, ror #24");
426 
427     COMPARE(sxtah(r3, r4, r5, 16), "e6b43875       sxtah r3, r4, r5, ror #16");
428 
429     COMPARE(uxtb(r9, r10), "e6ef907a       uxtb r9, r10");
430     COMPARE(uxtb(r3, r4, 8), "e6ef3474       uxtb r3, r4, ror #8");
431 
432     COMPARE(uxtab(r3, r4, r5, 8), "e6e43475       uxtab r3, r4, r5, ror #8");
433 
434     COMPARE(uxtb16(r3, r4, 8), "e6cf3474       uxtb16 r3, r4, ror #8");
435 
436     COMPARE(uxth(r9, r10), "e6ff907a       uxth r9, r10");
437     COMPARE(uxth(r3, r4, 8), "e6ff3474       uxth r3, r4, ror #8");
438 
439     COMPARE(uxtah(r3, r4, r5, 24), "e6f43c75       uxtah r3, r4, r5, ror #24");
440   }
441 
442   COMPARE(smmla(r0, r1, r2, r3), "e7503211       smmla r0, r1, r2, r3");
443   COMPARE(smmla(r10, r9, r8, r7), "e75a7819       smmla r10, r9, r8, r7");
444 
445   COMPARE(smmul(r0, r1, r2), "e750f211       smmul r0, r1, r2");
446   COMPARE(smmul(r8, r9, r10), "e758fa19       smmul r8, r9, r10");
447 
448   VERIFY_RUN();
449 }
450 
451 
452 
TEST(Vfp)453 TEST(Vfp) {
454   SET_UP();
455 
456   if (CpuFeatures::IsSupported(VFP3)) {
457     CpuFeatureScope scope(&assm, VFP3);
458     COMPARE(vmov(d0, r2, r3),
459             "ec432b10       vmov d0, r2, r3");
460     COMPARE(vmov(r2, r3, d0),
461             "ec532b10       vmov r2, r3, d0");
462     COMPARE(vmov(d0, d1),
463             "eeb00b41       vmov.f64 d0, d1");
464     COMPARE(vmov(d3, d3, eq),
465             "0eb03b43       vmoveq.f64 d3, d3");
466 
467     COMPARE(vmov(s0, s31),
468             "eeb00a6f       vmov.f32 s0, s31");
469     COMPARE(vmov(s31, s0),
470             "eef0fa40       vmov.f32 s31, s0");
471     COMPARE(vmov(r0, s0),
472             "ee100a10       vmov r0, s0");
473     COMPARE(vmov(r10, s31),
474             "ee1faa90       vmov r10, s31");
475     COMPARE(vmov(s0, r0),
476             "ee000a10       vmov s0, r0");
477     COMPARE(vmov(s31, r10),
478             "ee0faa90       vmov s31, r10");
479 
480     COMPARE(vabs(d0, d1),
481             "eeb00bc1       vabs.f64 d0, d1");
482     COMPARE(vabs(d3, d4, mi),
483             "4eb03bc4       vabsmi.f64 d3, d4");
484 
485     COMPARE(vabs(s0, s1),
486             "eeb00ae0       vabs.f32 s0, s1");
487     COMPARE(vabs(s3, s4, mi),
488             "4ef01ac2       vabsmi.f32 s3, s4");
489 
490     COMPARE(vneg(d0, d1),
491             "eeb10b41       vneg.f64 d0, d1");
492     COMPARE(vneg(d3, d4, mi),
493             "4eb13b44       vnegmi.f64 d3, d4");
494 
495     COMPARE(vneg(s0, s1),
496             "eeb10a60       vneg.f32 s0, s1");
497     COMPARE(vneg(s3, s4, mi),
498             "4ef11a42       vnegmi.f32 s3, s4");
499 
500     COMPARE(vadd(d0, d1, d2),
501             "ee310b02       vadd.f64 d0, d1, d2");
502     COMPARE(vadd(d3, d4, d5, mi),
503             "4e343b05       vaddmi.f64 d3, d4, d5");
504 
505     COMPARE(vadd(s0, s1, s2),
506             "ee300a81       vadd.f32 s0, s1, s2");
507     COMPARE(vadd(s3, s4, s5, mi),
508             "4e721a22       vaddmi.f32 s3, s4, s5");
509 
510     COMPARE(vsub(d0, d1, d2),
511             "ee310b42       vsub.f64 d0, d1, d2");
512     COMPARE(vsub(d3, d4, d5, ne),
513             "1e343b45       vsubne.f64 d3, d4, d5");
514 
515     COMPARE(vsub(s0, s1, s2),
516             "ee300ac1       vsub.f32 s0, s1, s2");
517     COMPARE(vsub(s3, s4, s5, ne),
518             "1e721a62       vsubne.f32 s3, s4, s5");
519 
520     COMPARE(vmul(d2, d1, d0),
521             "ee212b00       vmul.f64 d2, d1, d0");
522     COMPARE(vmul(d6, d4, d5, cc),
523             "3e246b05       vmulcc.f64 d6, d4, d5");
524 
525     COMPARE(vmul(s2, s1, s0),
526             "ee201a80       vmul.f32 s2, s1, s0");
527     COMPARE(vmul(s6, s4, s5, cc),
528             "3e223a22       vmulcc.f32 s6, s4, s5");
529 
530     COMPARE(vdiv(d2, d2, d2),
531             "ee822b02       vdiv.f64 d2, d2, d2");
532     COMPARE(vdiv(d6, d7, d7, hi),
533             "8e876b07       vdivhi.f64 d6, d7, d7");
534 
535     COMPARE(vdiv(s2, s2, s2),
536             "ee811a01       vdiv.f32 s2, s2, s2");
537     COMPARE(vdiv(s6, s7, s7, hi),
538             "8e833aa3       vdivhi.f32 s6, s7, s7");
539 
540     COMPARE(vcmp(d0, d1),
541             "eeb40b41       vcmp.f64 d0, d1");
542     COMPARE(vcmp(d0, 0.0),
543             "eeb50b40       vcmp.f64 d0, #0.0");
544 
545     COMPARE(vcmp(s0, s1),
546             "eeb40a60       vcmp.f32 s0, s1");
547     COMPARE(vcmp(s0, 0.0f),
548             "eeb50a40       vcmp.f32 s0, #0.0");
549 
550     COMPARE(vsqrt(d0, d0),
551             "eeb10bc0       vsqrt.f64 d0, d0");
552     COMPARE(vsqrt(d2, d3, ne),
553             "1eb12bc3       vsqrtne.f64 d2, d3");
554 
555     COMPARE(vsqrt(s0, s0),
556             "eeb10ac0       vsqrt.f32 s0, s0");
557     COMPARE(vsqrt(s2, s3, ne),
558             "1eb11ae1       vsqrtne.f32 s2, s3");
559 
560     COMPARE(vmov(d0, 1.0),
561             "eeb70b00       vmov.f64 d0, #1");
562     COMPARE(vmov(d2, -13.0),
563             "eeba2b0a       vmov.f64 d2, #-13");
564 
565     COMPARE(vmov(d0, VmovIndexLo, r0),
566             "ee000b10       vmov.32 d0[0], r0");
567     COMPARE(vmov(d0, VmovIndexHi, r0),
568             "ee200b10       vmov.32 d0[1], r0");
569 
570     COMPARE(vmov(r2, VmovIndexLo, d15),
571             "ee1f2b10       vmov.32 r2, d15[0]");
572     COMPARE(vmov(r3, VmovIndexHi, d14),
573             "ee3e3b10       vmov.32 r3, d14[1]");
574 
575     COMPARE(vldr(s0, r0, 0),
576             "ed900a00       vldr s0, [r0 + 4*0]");
577     COMPARE(vldr(s1, r1, 4),
578             "edd10a01       vldr s1, [r1 + 4*1]");
579     COMPARE(vldr(s15, r4, 16),
580             "edd47a04       vldr s15, [r4 + 4*4]");
581     COMPARE(vldr(s16, r5, 20),
582             "ed958a05       vldr s16, [r5 + 4*5]");
583     COMPARE(vldr(s31, r10, 1020),
584             "eddafaff       vldr s31, [r10 + 4*255]");
585 
586     COMPARE(vstr(s0, r0, 0),
587             "ed800a00       vstr s0, [r0 + 4*0]");
588     COMPARE(vstr(s1, r1, 4),
589             "edc10a01       vstr s1, [r1 + 4*1]");
590     COMPARE(vstr(s15, r8, 8),
591             "edc87a02       vstr s15, [r8 + 4*2]");
592     COMPARE(vstr(s16, r9, 12),
593             "ed898a03       vstr s16, [r9 + 4*3]");
594     COMPARE(vstr(s31, r10, 1020),
595             "edcafaff       vstr s31, [r10 + 4*255]");
596 
597     COMPARE(vldr(d0, r0, 0),
598             "ed900b00       vldr d0, [r0 + 4*0]");
599     COMPARE(vldr(d1, r1, 4),
600             "ed911b01       vldr d1, [r1 + 4*1]");
601     COMPARE(vldr(d15, r10, 1020),
602             "ed9afbff       vldr d15, [r10 + 4*255]");
603     COMPARE(vstr(d0, r0, 0),
604             "ed800b00       vstr d0, [r0 + 4*0]");
605     COMPARE(vstr(d1, r1, 4),
606             "ed811b01       vstr d1, [r1 + 4*1]");
607     COMPARE(vstr(d15, r10, 1020),
608             "ed8afbff       vstr d15, [r10 + 4*255]");
609 
610     COMPARE(vmsr(r5),
611             "eee15a10       vmsr FPSCR, r5");
612     COMPARE(vmsr(r10, pl),
613             "5ee1aa10       vmsrpl FPSCR, r10");
614     COMPARE(vmsr(pc),
615             "eee1fa10       vmsr FPSCR, APSR");
616     COMPARE(vmrs(r5),
617             "eef15a10       vmrs r5, FPSCR");
618     COMPARE(vmrs(r10, ge),
619             "aef1aa10       vmrsge r10, FPSCR");
620     COMPARE(vmrs(pc),
621             "eef1fa10       vmrs APSR, FPSCR");
622 
623     COMPARE(vstm(ia, r0, d1, d3),
624             "ec801b06       vstmia r0, {d1-d3}");
625     COMPARE(vldm(ia, r1, d2, d5),
626             "ec912b08       vldmia r1, {d2-d5}");
627     COMPARE(vstm(ia, r2, d0, d15),
628             "ec820b20       vstmia r2, {d0-d15}");
629     COMPARE(vldm(ia, r3, d0, d15),
630             "ec930b20       vldmia r3, {d0-d15}");
631     COMPARE(vstm(ia, r4, s1, s3),
632             "ecc40a03       vstmia r4, {s1-s3}");
633     COMPARE(vldm(ia, r5, s2, s5),
634             "ec951a04       vldmia r5, {s2-s5}");
635     COMPARE(vstm(ia, r6, s0, s31),
636             "ec860a20       vstmia r6, {s0-s31}");
637     COMPARE(vldm(ia, r7, s0, s31),
638             "ec970a20       vldmia r7, {s0-s31}");
639 
640     COMPARE(vmla(d2, d1, d0),
641             "ee012b00       vmla.f64 d2, d1, d0");
642     COMPARE(vmla(d6, d4, d5, cc),
643             "3e046b05       vmlacc.f64 d6, d4, d5");
644 
645     COMPARE(vmla(s2, s1, s0),
646             "ee001a80       vmla.f32 s2, s1, s0");
647     COMPARE(vmla(s6, s4, s5, cc),
648             "3e023a22       vmlacc.f32 s6, s4, s5");
649 
650     COMPARE(vmls(d2, d1, d0),
651             "ee012b40       vmls.f64 d2, d1, d0");
652     COMPARE(vmls(d6, d4, d5, cc),
653             "3e046b45       vmlscc.f64 d6, d4, d5");
654 
655     COMPARE(vmls(s2, s1, s0),
656             "ee001ac0       vmls.f32 s2, s1, s0");
657     COMPARE(vmls(s6, s4, s5, cc),
658             "3e023a62       vmlscc.f32 s6, s4, s5");
659 
660     COMPARE(vcvt_u32_f64(s0, d0),
661             "eebc0bc0       vcvt.u32.f64 s0, d0");
662     COMPARE(vcvt_s32_f64(s0, d0),
663             "eebd0bc0       vcvt.s32.f64 s0, d0");
664     COMPARE(vcvt_f64_u32(d0, s1),
665             "eeb80b60       vcvt.f64.u32 d0, s1");
666     COMPARE(vcvt_f64_s32(d0, s1),
667             "eeb80be0       vcvt.f64.s32 d0, s1");
668     COMPARE(vcvt_f32_s32(s0, s2),
669             "eeb80ac1       vcvt.f32.s32 s0, s2");
670     COMPARE(vcvt_f64_s32(d0, 2),
671             "eeba0bcf       vcvt.f64.s32 d0, d0, #2");
672 
673     if (CpuFeatures::IsSupported(VFP32DREGS)) {
674       COMPARE(vmov(d3, d27),
675               "eeb03b6b       vmov.f64 d3, d27");
676       COMPARE(vmov(d18, d7),
677               "eef02b47       vmov.f64 d18, d7");
678       COMPARE(vmov(d18, r2, r3),
679               "ec432b32       vmov d18, r2, r3");
680       COMPARE(vmov(r2, r3, d18),
681               "ec532b32       vmov r2, r3, d18");
682       COMPARE(vmov(d20, d31),
683               "eef04b6f       vmov.f64 d20, d31");
684 
685       COMPARE(vabs(d16, d31),
686               "eef00bef       vabs.f64 d16, d31");
687 
688       COMPARE(vneg(d16, d31),
689               "eef10b6f       vneg.f64 d16, d31");
690 
691       COMPARE(vadd(d16, d17, d18),
692               "ee710ba2       vadd.f64 d16, d17, d18");
693 
694       COMPARE(vsub(d16, d17, d18),
695               "ee710be2       vsub.f64 d16, d17, d18");
696 
697       COMPARE(vmul(d16, d17, d18),
698               "ee610ba2       vmul.f64 d16, d17, d18");
699 
700       COMPARE(vdiv(d16, d17, d18),
701               "eec10ba2       vdiv.f64 d16, d17, d18");
702 
703       COMPARE(vcmp(d16, d17),
704               "eef40b61       vcmp.f64 d16, d17");
705       COMPARE(vcmp(d16, 0.0),
706               "eef50b40       vcmp.f64 d16, #0.0");
707 
708       COMPARE(vsqrt(d16, d17),
709               "eef10be1       vsqrt.f64 d16, d17");
710 
711       COMPARE(vmov(d30, 16.0),
712               "eef3eb00       vmov.f64 d30, #16");
713 
714       COMPARE(vmov(d31, VmovIndexLo, r7),
715               "ee0f7b90       vmov.32 d31[0], r7");
716       COMPARE(vmov(d31, VmovIndexHi, r7),
717               "ee2f7b90       vmov.32 d31[1], r7");
718 
719       COMPARE(vldr(d25, r0, 0),
720               "edd09b00       vldr d25, [r0 + 4*0]");
721       COMPARE(vldr(d26, r1, 4),
722               "edd1ab01       vldr d26, [r1 + 4*1]");
723       COMPARE(vldr(d31, r10, 1020),
724               "eddafbff       vldr d31, [r10 + 4*255]");
725 
726       COMPARE(vstr(d16, r0, 0),
727               "edc00b00       vstr d16, [r0 + 4*0]");
728       COMPARE(vstr(d17, r1, 4),
729               "edc11b01       vstr d17, [r1 + 4*1]");
730       COMPARE(vstr(d31, r10, 1020),
731               "edcafbff       vstr d31, [r10 + 4*255]");
732 
733       COMPARE(vstm(ia, r0, d16, d31),
734               "ecc00b20       vstmia r0, {d16-d31}");
735       COMPARE(vldm(ia, r3, d16, d31),
736               "ecd30b20       vldmia r3, {d16-d31}");
737       COMPARE(vstm(ia, r0, d23, d27),
738               "ecc07b0a       vstmia r0, {d23-d27}");
739       COMPARE(vldm(ia, r3, d23, d27),
740               "ecd37b0a       vldmia r3, {d23-d27}");
741 
742       COMPARE(vmla(d16, d17, d18),
743               "ee410ba2       vmla.f64 d16, d17, d18");
744 
745       COMPARE(vcvt_u32_f64(s0, d16),
746               "eebc0be0       vcvt.u32.f64 s0, d16");
747       COMPARE(vcvt_s32_f64(s0, d16),
748               "eebd0be0       vcvt.s32.f64 s0, d16");
749       COMPARE(vcvt_f64_u32(d16, s1),
750               "eef80b60       vcvt.f64.u32 d16, s1");
751     }
752   }
753 
754   VERIFY_RUN();
755 }
756 
757 
TEST(ARMv8_vrintX_disasm)758 TEST(ARMv8_vrintX_disasm) {
759   SET_UP();
760 
761   if (CpuFeatures::IsSupported(ARMv8)) {
762     COMPARE(vrinta(d0, d0), "feb80b40       vrinta.f64.f64 d0, d0");
763     COMPARE(vrinta(d2, d3), "feb82b43       vrinta.f64.f64 d2, d3");
764 
765     COMPARE(vrintp(d0, d0), "feba0b40       vrintp.f64.f64 d0, d0");
766     COMPARE(vrintp(d2, d3), "feba2b43       vrintp.f64.f64 d2, d3");
767 
768     COMPARE(vrintn(d0, d0), "feb90b40       vrintn.f64.f64 d0, d0");
769     COMPARE(vrintn(d2, d3), "feb92b43       vrintn.f64.f64 d2, d3");
770 
771     COMPARE(vrintm(d0, d0), "febb0b40       vrintm.f64.f64 d0, d0");
772     COMPARE(vrintm(d2, d3), "febb2b43       vrintm.f64.f64 d2, d3");
773 
774     COMPARE(vrintz(d0, d0), "eeb60bc0       vrintz.f64.f64 d0, d0");
775     COMPARE(vrintz(d2, d3, ne), "1eb62bc3       vrintzne.f64.f64 d2, d3");
776   }
777 
778   VERIFY_RUN();
779 }
780 
781 
TEST(Neon)782 TEST(Neon) {
783   SET_UP();
784 
785   if (CpuFeatures::IsSupported(NEON)) {
786     CpuFeatureScope scope(&assm, NEON);
787       COMPARE(vld1(Neon8, NeonListOperand(d4, 4), NeonMemOperand(r1)),
788               "f421420f       vld1.8 {d4, d5, d6, d7}, [r1]");
789       COMPARE(vst1(Neon16, NeonListOperand(d17, 4), NeonMemOperand(r9)),
790               "f449124f       vst1.16 {d17, d18, d19, d20}, [r9]");
791       COMPARE(vmovl(NeonU8, q3, d1),
792               "f3886a11       vmovl.u8 q3, d1");
793       COMPARE(vmovl(NeonU8, q4, d2),
794               "f3888a12       vmovl.u8 q4, d2");
795   }
796 
797   VERIFY_RUN();
798 }
799 
800 
TEST(LoadStore)801 TEST(LoadStore) {
802   SET_UP();
803 
804   COMPARE(ldrb(r0, MemOperand(r1)),
805           "e5d10000       ldrb r0, [r1, #+0]");
806   COMPARE(ldrb(r2, MemOperand(r3, 42)),
807           "e5d3202a       ldrb r2, [r3, #+42]");
808   COMPARE(ldrb(r4, MemOperand(r5, -42)),
809           "e555402a       ldrb r4, [r5, #-42]");
810   COMPARE(ldrb(r6, MemOperand(r7, 42, PostIndex)),
811           "e4d7602a       ldrb r6, [r7], #+42");
812   COMPARE(ldrb(r8, MemOperand(r9, -42, PostIndex)),
813           "e459802a       ldrb r8, [r9], #-42");
814   COMPARE(ldrb(r10, MemOperand(fp, 42, PreIndex)),
815           "e5fba02a       ldrb r10, [fp, #+42]!");
816   COMPARE(ldrb(ip, MemOperand(sp, -42, PreIndex)),
817           "e57dc02a       ldrb ip, [sp, #-42]!");
818   COMPARE(ldrb(r0, MemOperand(r1, r2)),
819           "e7d10002       ldrb r0, [r1, +r2]");
820   COMPARE(ldrb(r0, MemOperand(r1, r2, NegOffset)),
821           "e7510002       ldrb r0, [r1, -r2]");
822   COMPARE(ldrb(r0, MemOperand(r1, r2, PostIndex)),
823           "e6d10002       ldrb r0, [r1], +r2");
824   COMPARE(ldrb(r0, MemOperand(r1, r2, NegPostIndex)),
825           "e6510002       ldrb r0, [r1], -r2");
826   COMPARE(ldrb(r0, MemOperand(r1, r2, PreIndex)),
827           "e7f10002       ldrb r0, [r1, +r2]!");
828   COMPARE(ldrb(r0, MemOperand(r1, r2, NegPreIndex)),
829           "e7710002       ldrb r0, [r1, -r2]!");
830 
831   COMPARE(strb(r0, MemOperand(r1)),
832           "e5c10000       strb r0, [r1, #+0]");
833   COMPARE(strb(r2, MemOperand(r3, 42)),
834           "e5c3202a       strb r2, [r3, #+42]");
835   COMPARE(strb(r4, MemOperand(r5, -42)),
836           "e545402a       strb r4, [r5, #-42]");
837   COMPARE(strb(r6, MemOperand(r7, 42, PostIndex)),
838           "e4c7602a       strb r6, [r7], #+42");
839   COMPARE(strb(r8, MemOperand(r9, -42, PostIndex)),
840           "e449802a       strb r8, [r9], #-42");
841   COMPARE(strb(r10, MemOperand(fp, 42, PreIndex)),
842           "e5eba02a       strb r10, [fp, #+42]!");
843   COMPARE(strb(ip, MemOperand(sp, -42, PreIndex)),
844           "e56dc02a       strb ip, [sp, #-42]!");
845   COMPARE(strb(r0, MemOperand(r1, r2)),
846           "e7c10002       strb r0, [r1, +r2]");
847   COMPARE(strb(r0, MemOperand(r1, r2, NegOffset)),
848           "e7410002       strb r0, [r1, -r2]");
849   COMPARE(strb(r0, MemOperand(r1, r2, PostIndex)),
850           "e6c10002       strb r0, [r1], +r2");
851   COMPARE(strb(r0, MemOperand(r1, r2, NegPostIndex)),
852           "e6410002       strb r0, [r1], -r2");
853   COMPARE(strb(r0, MemOperand(r1, r2, PreIndex)),
854           "e7e10002       strb r0, [r1, +r2]!");
855   COMPARE(strb(r0, MemOperand(r1, r2, NegPreIndex)),
856           "e7610002       strb r0, [r1, -r2]!");
857 
858   COMPARE(ldrh(r0, MemOperand(r1)),
859           "e1d100b0       ldrh r0, [r1, #+0]");
860   COMPARE(ldrh(r2, MemOperand(r3, 42)),
861           "e1d322ba       ldrh r2, [r3, #+42]");
862   COMPARE(ldrh(r4, MemOperand(r5, -42)),
863           "e15542ba       ldrh r4, [r5, #-42]");
864   COMPARE(ldrh(r6, MemOperand(r7, 42, PostIndex)),
865           "e0d762ba       ldrh r6, [r7], #+42");
866   COMPARE(ldrh(r8, MemOperand(r9, -42, PostIndex)),
867           "e05982ba       ldrh r8, [r9], #-42");
868   COMPARE(ldrh(r10, MemOperand(fp, 42, PreIndex)),
869           "e1fba2ba       ldrh r10, [fp, #+42]!");
870   COMPARE(ldrh(ip, MemOperand(sp, -42, PreIndex)),
871           "e17dc2ba       ldrh ip, [sp, #-42]!");
872   COMPARE(ldrh(r0, MemOperand(r1, r2)),
873           "e19100b2       ldrh r0, [r1, +r2]");
874   COMPARE(ldrh(r0, MemOperand(r1, r2, NegOffset)),
875           "e11100b2       ldrh r0, [r1, -r2]");
876   COMPARE(ldrh(r0, MemOperand(r1, r2, PostIndex)),
877           "e09100b2       ldrh r0, [r1], +r2");
878   COMPARE(ldrh(r0, MemOperand(r1, r2, NegPostIndex)),
879           "e01100b2       ldrh r0, [r1], -r2");
880   COMPARE(ldrh(r0, MemOperand(r1, r2, PreIndex)),
881           "e1b100b2       ldrh r0, [r1, +r2]!");
882   COMPARE(ldrh(r0, MemOperand(r1, r2, NegPreIndex)),
883           "e13100b2       ldrh r0, [r1, -r2]!");
884 
885   COMPARE(strh(r0, MemOperand(r1)),
886           "e1c100b0       strh r0, [r1, #+0]");
887   COMPARE(strh(r2, MemOperand(r3, 42)),
888           "e1c322ba       strh r2, [r3, #+42]");
889   COMPARE(strh(r4, MemOperand(r5, -42)),
890           "e14542ba       strh r4, [r5, #-42]");
891   COMPARE(strh(r6, MemOperand(r7, 42, PostIndex)),
892           "e0c762ba       strh r6, [r7], #+42");
893   COMPARE(strh(r8, MemOperand(r9, -42, PostIndex)),
894           "e04982ba       strh r8, [r9], #-42");
895   COMPARE(strh(r10, MemOperand(fp, 42, PreIndex)),
896           "e1eba2ba       strh r10, [fp, #+42]!");
897   COMPARE(strh(ip, MemOperand(sp, -42, PreIndex)),
898           "e16dc2ba       strh ip, [sp, #-42]!");
899   COMPARE(strh(r0, MemOperand(r1, r2)),
900           "e18100b2       strh r0, [r1, +r2]");
901   COMPARE(strh(r0, MemOperand(r1, r2, NegOffset)),
902           "e10100b2       strh r0, [r1, -r2]");
903   COMPARE(strh(r0, MemOperand(r1, r2, PostIndex)),
904           "e08100b2       strh r0, [r1], +r2");
905   COMPARE(strh(r0, MemOperand(r1, r2, NegPostIndex)),
906           "e00100b2       strh r0, [r1], -r2");
907   COMPARE(strh(r0, MemOperand(r1, r2, PreIndex)),
908           "e1a100b2       strh r0, [r1, +r2]!");
909   COMPARE(strh(r0, MemOperand(r1, r2, NegPreIndex)),
910           "e12100b2       strh r0, [r1, -r2]!");
911 
912   COMPARE(ldr(r0, MemOperand(r1)),
913           "e5910000       ldr r0, [r1, #+0]");
914   COMPARE(ldr(r2, MemOperand(r3, 42)),
915           "e593202a       ldr r2, [r3, #+42]");
916   COMPARE(ldr(r4, MemOperand(r5, -42)),
917           "e515402a       ldr r4, [r5, #-42]");
918   COMPARE(ldr(r6, MemOperand(r7, 42, PostIndex)),
919           "e497602a       ldr r6, [r7], #+42");
920   COMPARE(ldr(r8, MemOperand(r9, -42, PostIndex)),
921           "e419802a       ldr r8, [r9], #-42");
922   COMPARE(ldr(r10, MemOperand(fp, 42, PreIndex)),
923           "e5bba02a       ldr r10, [fp, #+42]!");
924   COMPARE(ldr(ip, MemOperand(sp, -42, PreIndex)),
925           "e53dc02a       ldr ip, [sp, #-42]!");
926   COMPARE(ldr(r0, MemOperand(r1, r2)),
927           "e7910002       ldr r0, [r1, +r2]");
928   COMPARE(ldr(r0, MemOperand(r1, r2, NegOffset)),
929           "e7110002       ldr r0, [r1, -r2]");
930   COMPARE(ldr(r0, MemOperand(r1, r2, PostIndex)),
931           "e6910002       ldr r0, [r1], +r2");
932   COMPARE(ldr(r0, MemOperand(r1, r2, NegPostIndex)),
933           "e6110002       ldr r0, [r1], -r2");
934   COMPARE(ldr(r0, MemOperand(r1, r2, PreIndex)),
935           "e7b10002       ldr r0, [r1, +r2]!");
936   COMPARE(ldr(r0, MemOperand(r1, r2, NegPreIndex)),
937           "e7310002       ldr r0, [r1, -r2]!");
938 
939   COMPARE(str(r0, MemOperand(r1)),
940           "e5810000       str r0, [r1, #+0]");
941   COMPARE(str(r2, MemOperand(r3, 42)),
942           "e583202a       str r2, [r3, #+42]");
943   COMPARE(str(r4, MemOperand(r5, -42)),
944           "e505402a       str r4, [r5, #-42]");
945   COMPARE(str(r6, MemOperand(r7, 42, PostIndex)),
946           "e487602a       str r6, [r7], #+42");
947   COMPARE(str(r8, MemOperand(r9, -42, PostIndex)),
948           "e409802a       str r8, [r9], #-42");
949   COMPARE(str(r10, MemOperand(fp, 42, PreIndex)),
950           "e5aba02a       str r10, [fp, #+42]!");
951   COMPARE(str(ip, MemOperand(sp, -42, PreIndex)),
952           "e52dc02a       str ip, [sp, #-42]!");
953   COMPARE(str(r0, MemOperand(r1, r2)),
954           "e7810002       str r0, [r1, +r2]");
955   COMPARE(str(r0, MemOperand(r1, r2, NegOffset)),
956           "e7010002       str r0, [r1, -r2]");
957   COMPARE(str(r0, MemOperand(r1, r2, PostIndex)),
958           "e6810002       str r0, [r1], +r2");
959   COMPARE(str(r0, MemOperand(r1, r2, NegPostIndex)),
960           "e6010002       str r0, [r1], -r2");
961   COMPARE(str(r0, MemOperand(r1, r2, PreIndex)),
962           "e7a10002       str r0, [r1, +r2]!");
963   COMPARE(str(r0, MemOperand(r1, r2, NegPreIndex)),
964           "e7210002       str r0, [r1, -r2]!");
965 
966   if (CpuFeatures::IsSupported(ARMv7)) {
967     CpuFeatureScope scope(&assm, ARMv7);
968     COMPARE(ldrd(r0, r1, MemOperand(r1)),
969             "e1c100d0       ldrd r0, [r1, #+0]");
970     COMPARE(ldrd(r2, r3, MemOperand(r3, 127)),
971             "e1c327df       ldrd r2, [r3, #+127]");
972     COMPARE(ldrd(r4, r5, MemOperand(r5, -127)),
973             "e14547df       ldrd r4, [r5, #-127]");
974     COMPARE(ldrd(r6, r7, MemOperand(r7, 127, PostIndex)),
975             "e0c767df       ldrd r6, [r7], #+127");
976     COMPARE(ldrd(r8, r9, MemOperand(r9, -127, PostIndex)),
977             "e04987df       ldrd r8, [r9], #-127");
978     COMPARE(ldrd(r10, fp, MemOperand(fp, 127, PreIndex)),
979             "e1eba7df       ldrd r10, [fp, #+127]!");
980     COMPARE(ldrd(ip, sp, MemOperand(sp, -127, PreIndex)),
981             "e16dc7df       ldrd ip, [sp, #-127]!");
982 
983     COMPARE(strd(r0, r1, MemOperand(r1)),
984             "e1c100f0       strd r0, [r1, #+0]");
985     COMPARE(strd(r2, r3, MemOperand(r3, 127)),
986             "e1c327ff       strd r2, [r3, #+127]");
987     COMPARE(strd(r4, r5, MemOperand(r5, -127)),
988             "e14547ff       strd r4, [r5, #-127]");
989     COMPARE(strd(r6, r7, MemOperand(r7, 127, PostIndex)),
990             "e0c767ff       strd r6, [r7], #+127");
991     COMPARE(strd(r8, r9, MemOperand(r9, -127, PostIndex)),
992             "e04987ff       strd r8, [r9], #-127");
993     COMPARE(strd(r10, fp, MemOperand(fp, 127, PreIndex)),
994             "e1eba7ff       strd r10, [fp, #+127]!");
995     COMPARE(strd(ip, sp, MemOperand(sp, -127, PreIndex)),
996             "e16dc7ff       strd ip, [sp, #-127]!");
997 
998     COMPARE(pld(MemOperand(r1, 0)),
999             "f5d1f000       pld [r1]");
1000     COMPARE(pld(MemOperand(r2, 128)),
1001             "f5d2f080       pld [r2, #+128]");
1002   }
1003 
1004   VERIFY_RUN();
1005 }
1006