Debian Codegraph @

js/src/jit/arm64/vixl/Decoder-vixl.cpp

raw
1 // Copyright 2014, VIXL authors
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
6 //
7 // * Redistributions of source code must retain the above copyright notice,
8 // this list of conditions and the following disclaimer.
9 // * Redistributions in binary form must reproduce the above copyright notice,
10 // this list of conditions and the following disclaimer in the documentation
11 // and/or other materials provided with the distribution.
12 // * Neither the name of ARM Limited nor the names of its contributors may be
13 // used to endorse or promote products derived from this software without
14 // specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND
17 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
20 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
22 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
23 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
24 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
27 #include "jit/arm64/vixl/Decoder-vixl.h"
28
29 #include <algorithm>
30
31 #include "jit/arm64/vixl/Globals-vixl.h"
32 #include "jit/arm64/vixl/Utils-vixl.h"
33
34 namespace vixl {
35
36 void Decoder::DecodeInstruction(const Instruction *instr) {
37 if (instr->Bits(28, 27) == 0) {
38 VisitUnallocated(instr);
39 } else {
40 switch (instr->Bits(27, 24)) {
41 // 0: PC relative addressing.
42 case 0x0: DecodePCRelAddressing(instr); break;
43
44 // 1: Add/sub immediate.
45 case 0x1: DecodeAddSubImmediate(instr); break;
46
47 // A: Logical shifted register.
48 // Add/sub with carry.
49 // Conditional compare register.
50 // Conditional compare immediate.
51 // Conditional select.
52 // Data processing 1 source.
53 // Data processing 2 source.
54 // B: Add/sub shifted register.
55 // Add/sub extended register.
56 // Data processing 3 source.
57 case 0xA:
58 case 0xB: DecodeDataProcessing(instr); break;
59
60 // 2: Logical immediate.
61 // Move wide immediate.
62 case 0x2: DecodeLogical(instr); break;
63
64 // 3: Bitfield.
65 // Extract.
66 case 0x3: DecodeBitfieldExtract(instr); break;
67
68 // 4: Unconditional branch immediate.
69 // Exception generation.
70 // Compare and branch immediate.
71 // 5: Compare and branch immediate.
72 // Conditional branch.
73 // System.
74 // 6,7: Unconditional branch.
75 // Test and branch immediate.
76 case 0x4:
77 case 0x5:
78 case 0x6:
79 case 0x7: DecodeBranchSystemException(instr); break;
80
81 // 8,9: Load/store register pair post-index.
82 // Load register literal.
83 // Load/store register unscaled immediate.
84 // Load/store register immediate post-index.
85 // Load/store register immediate pre-index.
86 // Load/store register offset.
87 // Load/store exclusive.
88 // C,D: Load/store register pair offset.
89 // Load/store register pair pre-index.
90 // Load/store register unsigned immediate.
91 // Advanced SIMD.
92 case 0x8:
93 case 0x9:
94 case 0xC:
95 case 0xD: DecodeLoadStore(instr); break;
96
97 // E: FP fixed point conversion.
98 // FP integer conversion.
99 // FP data processing 1 source.
100 // FP compare.
101 // FP immediate.
102 // FP data processing 2 source.
103 // FP conditional compare.
104 // FP conditional select.
105 // Advanced SIMD.
106 // F: FP data processing 3 source.
107 // Advanced SIMD.
108 case 0xE:
109 case 0xF: DecodeFP(instr); break;
110 }
111 }
112 }
113
114 void Decoder::AppendVisitor(DecoderVisitor* new_visitor) {
115 MOZ_ALWAYS_TRUE(visitors_.append(new_visitor));
116 }
117
118
119 void Decoder::PrependVisitor(DecoderVisitor* new_visitor) {
120 MOZ_ALWAYS_TRUE(visitors_.insert(visitors_.begin(), new_visitor));
121 }
122
123
124 void Decoder::InsertVisitorBefore(DecoderVisitor* new_visitor,
125 DecoderVisitor* registered_visitor) {
126 for (auto it = visitors_.begin(); it != visitors_.end(); it++) {
127 if (*it == registered_visitor) {
128 MOZ_ALWAYS_TRUE(visitors_.insert(it, new_visitor));
129 return;
130 }
131 }
132 // We reached the end of the list without finding registered_visitor.
133 MOZ_ALWAYS_TRUE(visitors_.append(new_visitor));
134 }
135
136
137 void Decoder::InsertVisitorAfter(DecoderVisitor* new_visitor,
138 DecoderVisitor* registered_visitor) {
139 for (auto it = visitors_.begin(); it != visitors_.end(); it++) {
140 if (*it == registered_visitor) {
141 it++;
142 MOZ_ALWAYS_TRUE(visitors_.insert(it, new_visitor));
143 return;
144 }
145 }
146 // We reached the end of the list without finding registered_visitor.
147 MOZ_ALWAYS_TRUE(visitors_.append(new_visitor));
148 }
149
150
151 void Decoder::RemoveVisitor(DecoderVisitor* visitor) {
152 visitors_.erase(std::remove(visitors_.begin(), visitors_.end(), visitor),
153 visitors_.end());
154 }
155
156
157 void Decoder::DecodePCRelAddressing(const Instruction* instr) {
158 VIXL_ASSERT(instr->Bits(27, 24) == 0x0);
159 // We know bit 28 is set, as <b28:b27> = 0 is filtered out at the top level
160 // decode.
161 VIXL_ASSERT(instr->Bit(28) == 0x1);
162 VisitPCRelAddressing(instr);
163 }
164
165
166 void Decoder::DecodeBranchSystemException(const Instruction* instr) {
167 VIXL_ASSERT((instr->Bits(27, 24) == 0x4) ||
168 (instr->Bits(27, 24) == 0x5) ||
169 (instr->Bits(27, 24) == 0x6) ||
170 (instr->Bits(27, 24) == 0x7) );
171
172 switch (instr->Bits(31, 29)) {
173 case 0:
174 case 4: {
175 VisitUnconditionalBranch(instr);
176 break;
177 }
178 case 1:
179 case 5: {
180 if (instr->Bit(25) == 0) {
181 VisitCompareBranch(instr);
182 } else {
183 VisitTestBranch(instr);
184 }
185 break;
186 }
187 case 2: {
188 if (instr->Bit(25) == 0) {
189 if ((instr->Bit(24) == 0x1) ||
190 (instr->Mask(0x01000010) == 0x00000010)) {
191 VisitUnallocated(instr);
192 } else {
193 VisitConditionalBranch(instr);
194 }
195 } else {
196 VisitUnallocated(instr);
197 }
198 break;
199 }
200 case 6: {
201 if (instr->Bit(25) == 0) {
202 if (instr->Bit(24) == 0) {
203 if ((instr->Bits(4, 2) != 0) ||
204 (instr->Mask(0x00E0001D) == 0x00200001) ||
205 (instr->Mask(0x00E0001D) == 0x00400001) ||
206 (instr->Mask(0x00E0001E) == 0x00200002) ||
207 (instr->Mask(0x00E0001E) == 0x00400002) ||
208 (instr->Mask(0x00E0001C) == 0x00600000) ||
209 (instr->Mask(0x00E0001C) == 0x00800000) ||
210 (instr->Mask(0x00E0001F) == 0x00A00000) ||
211 (instr->Mask(0x00C0001C) == 0x00C00000)) {
212 if (instr->InstructionBits() == UNDEFINED_INST_PATTERN) {
213 VisitException(instr);
214 } else {
215 VisitUnallocated(instr);
216 }
217 } else {
218 VisitException(instr);
219 }
220 } else {
221 if (instr->Bits(23, 22) == 0) {
222 const Instr masked_003FF0E0 = instr->Mask(0x003FF0E0);
223 if ((instr->Bits(21, 19) == 0x4) ||
224 (masked_003FF0E0 == 0x00033000) ||
225 (masked_003FF0E0 == 0x003FF020) ||
226 (masked_003FF0E0 == 0x003FF060) ||
227 (masked_003FF0E0 == 0x003FF0E0) ||
228 (instr->Mask(0x00388000) == 0x00008000) ||
229 (instr->Mask(0x0038E000) == 0x00000000) ||
230 (instr->Mask(0x0039E000) == 0x00002000) ||
231 (instr->Mask(0x003AE000) == 0x00002000) ||
232 (instr->Mask(0x003CE000) == 0x00042000) ||
233 (instr->Mask(0x003FFFC0) == 0x000320C0) ||
234 (instr->Mask(0x003FF100) == 0x00032100) ||
235 // (instr->Mask(0x003FF200) == 0x00032200) || // match CSDB
236 (instr->Mask(0x003FF400) == 0x00032400) ||
237 (instr->Mask(0x003FF800) == 0x00032800) ||
238 (instr->Mask(0x0038F000) == 0x00005000) ||
239 (instr->Mask(0x0038E000) == 0x00006000)) {
240 VisitUnallocated(instr);
241 } else {
242 VisitSystem(instr);
243 }
244 } else {
245 VisitUnallocated(instr);
246 }
247 }
248 } else {
249 if ((instr->Bit(24) == 0x1) ||
250 (instr->Bits(20, 16) != 0x1F) ||
251 (instr->Bits(15, 10) != 0) ||
252 (instr->Bits(4, 0) != 0) ||
253 (instr->Bits(24, 21) == 0x3) ||
254 (instr->Bits(24, 22) == 0x3)) {
255 VisitUnallocated(instr);
256 } else {
257 VisitUnconditionalBranchToRegister(instr);
258 }
259 }
260 break;
261 }
262 case 3:
263 case 7: {
264 VisitUnallocated(instr);
265 break;
266 }
267 }
268 }
269
270
271 void Decoder::DecodeLoadStore(const Instruction* instr) {
272 VIXL_ASSERT((instr->Bits(27, 24) == 0x8) ||
273 (instr->Bits(27, 24) == 0x9) ||
274 (instr->Bits(27, 24) == 0xC) ||
275 (instr->Bits(27, 24) == 0xD) );
276 // TODO(all): rearrange the tree to integrate this branch.
277 if ((instr->Bit(28) == 0) && (instr->Bit(29) == 0) && (instr->Bit(26) == 1)) {
278 DecodeNEONLoadStore(instr);
279 return;
280 }
281
282 if (instr->Bit(24) == 0) {
283 if (instr->Bit(28) == 0) {
284 if (instr->Bit(29) == 0) {
285 if (instr->Bit(26) == 0) {
286 VisitLoadStoreExclusive(instr);
287 } else {
288 VIXL_UNREACHABLE();
289 }
290 } else {
291 if ((instr->Bits(31, 30) == 0x3) ||
292 (instr->Mask(0xC4400000) == 0x40000000)) {
293 VisitUnallocated(instr);
294 } else {
295 if (instr->Bit(23) == 0) {
296 if (instr->Mask(0xC4400000) == 0xC0400000) {
297 VisitUnallocated(instr);
298 } else {
299 VisitLoadStorePairNonTemporal(instr);
300 }
301 } else {
302 VisitLoadStorePairPostIndex(instr);
303 }
304 }
305 }
306 } else {
307 if (instr->Bit(29) == 0) {
308 if (instr->Mask(0xC4000000) == 0xC4000000) {
309 VisitUnallocated(instr);
310 } else {
311 VisitLoadLiteral(instr);
312 }
313 } else {
314 if ((instr->Mask(0x44800000) == 0x44800000) ||
315 (instr->Mask(0x84800000) == 0x84800000)) {
316 VisitUnallocated(instr);
317 } else {
318 if (instr->Bit(21) == 0) {
319 switch (instr->Bits(11, 10)) {
320 case 0: {
321 VisitLoadStoreUnscaledOffset(instr);
322 break;
323 }
324 case 1: {
325 if (instr->Mask(0xC4C00000) == 0xC0800000) {
326 VisitUnallocated(instr);
327 } else {
328 VisitLoadStorePostIndex(instr);
329 }
330 break;
331 }
332 case 2: {
333 // TODO: VisitLoadStoreRegisterOffsetUnpriv.
334 VisitUnimplemented(instr);
335 break;
336 }
337 case 3: {
338 if (instr->Mask(0xC4C00000) == 0xC0800000) {
339 VisitUnallocated(instr);
340 } else {
341 VisitLoadStorePreIndex(instr);
342 }
343 break;
344 }
345 }
346 } else {
347 if (instr->Bits(11, 10) == 0x2) {
348 if (instr->Bit(14) == 0) {
349 VisitUnallocated(instr);
350 } else {
351 VisitLoadStoreRegisterOffset(instr);
352 }
353 } else {
354 if (instr->Bits(11, 10) == 0x0) {
355 if (instr->Bit(25) == 0) {
356 if (instr->Bit(26) == 0) {
357 if ((instr->Bit(15) == 1) &&
358 ((instr->Bits(14, 12) == 0x1) ||
359 (instr->Bit(13) == 1) ||
360 (instr->Bits(14, 12) == 0x5) ||
361 ((instr->Bits(14, 12) == 0x4) &&
362 ((instr->Bit(23) == 0) ||
363 (instr->Bits(23, 22) == 0x3))))) {
364 VisitUnallocated(instr);
365 } else {
366 VisitAtomicMemory(instr);
367 }
368 } else {
369 VisitUnallocated(instr);
370 }
371 } else {
372 VisitUnallocated(instr);
373 }
374 } else {
375 VisitUnallocated(instr);
376 }
377 }
378 }
379 }
380 }
381 }
382 } else {
383 if (instr->Bit(28) == 0) {
384 if (instr->Bit(29) == 0) {
385 VisitUnallocated(instr);
386 } else {
387 if ((instr->Bits(31, 30) == 0x3) ||
388 (instr->Mask(0xC4400000) == 0x40000000)) {
389 VisitUnallocated(instr);
390 } else {
391 if (instr->Bit(23) == 0) {
392 VisitLoadStorePairOffset(instr);
393 } else {
394 VisitLoadStorePairPreIndex(instr);
395 }
396 }
397 }
398 } else {
399 if (instr->Bit(29) == 0) {
400 VisitUnallocated(instr);
401 } else {
402 if ((instr->Mask(0x84C00000) == 0x80C00000) ||
403 (instr->Mask(0x44800000) == 0x44800000) ||
404 (instr->Mask(0x84800000) == 0x84800000)) {
405 VisitUnallocated(instr);
406 } else {
407 VisitLoadStoreUnsignedOffset(instr);
408 }
409 }
410 }
411 }
412 }
413
414
415 void Decoder::DecodeLogical(const Instruction* instr) {
416 VIXL_ASSERT(instr->Bits(27, 24) == 0x2);
417
418 if (instr->Mask(0x80400000) == 0x00400000) {
419 VisitUnallocated(instr);
420 } else {
421 if (instr->Bit(23) == 0) {
422 VisitLogicalImmediate(instr);
423 } else {
424 if (instr->Bits(30, 29) == 0x1) {
425 VisitUnallocated(instr);
426 } else {
427 VisitMoveWideImmediate(instr);
428 }
429 }
430 }
431 }
432
433
434 void Decoder::DecodeBitfieldExtract(const Instruction* instr) {
435 VIXL_ASSERT(instr->Bits(27, 24) == 0x3);
436
437 if ((instr->Mask(0x80400000) == 0x80000000) ||
438 (instr->Mask(0x80400000) == 0x00400000) ||
439 (instr->Mask(0x80008000) == 0x00008000)) {
440 VisitUnallocated(instr);
441 } else if (instr->Bit(23) == 0) {
442 if ((instr->Mask(0x80200000) == 0x00200000) ||
443 (instr->Mask(0x60000000) == 0x60000000)) {
444 VisitUnallocated(instr);
445 } else {
446 VisitBitfield(instr);
447 }
448 } else {
449 if ((instr->Mask(0x60200000) == 0x00200000) ||
450 (instr->Mask(0x60000000) != 0x00000000)) {
451 VisitUnallocated(instr);
452 } else {
453 VisitExtract(instr);
454 }
455 }
456 }
457
458
459 void Decoder::DecodeAddSubImmediate(const Instruction* instr) {
460 VIXL_ASSERT(instr->Bits(27, 24) == 0x1);
461 if (instr->Bit(23) == 1) {
462 VisitUnallocated(instr);
463 } else {
464 VisitAddSubImmediate(instr);
465 }
466 }
467
468
469 void Decoder::DecodeDataProcessing(const Instruction* instr) {
470 VIXL_ASSERT((instr->Bits(27, 24) == 0xA) ||
471 (instr->Bits(27, 24) == 0xB));
472
473 if (instr->Bit(24) == 0) {
474 if (instr->Bit(28) == 0) {
475 if (instr->Mask(0x80008000) == 0x00008000) {
476 VisitUnallocated(instr);
477 } else {
478 VisitLogicalShifted(instr);
479 }
480 } else {
481 switch (instr->Bits(23, 21)) {
482 case 0: {
483 if (instr->Mask(0x0000FC00) != 0) {
484 VisitUnallocated(instr);
485 } else {
486 VisitAddSubWithCarry(instr);
487 }
488 break;
489 }
490 case 2: {
491 if ((instr->Bit(29) == 0) ||
492 (instr->Mask(0x00000410) != 0)) {
493 VisitUnallocated(instr);
494 } else {
495 if (instr->Bit(11) == 0) {
496 VisitConditionalCompareRegister(instr);
497 } else {
498 VisitConditionalCompareImmediate(instr);
499 }
500 }
501 break;
502 }
503 case 4: {
504 if (instr->Mask(0x20000800) != 0x00000000) {
505 VisitUnallocated(instr);
506 } else {
507 VisitConditionalSelect(instr);
508 }
509 break;
510 }
511 case 6: {
512 if (instr->Bit(29) == 0x1) {
513 VisitUnallocated(instr);
514 VIXL_FALLTHROUGH();
515 } else {
516 if (instr->Bit(30) == 0) {
517 if ((instr->Bit(15) == 0x1) ||
518 (instr->Bits(15, 11) == 0) ||
519 (instr->Bits(15, 12) == 0x1) ||
520 (instr->Bits(15, 12) == 0x3) ||
521 (instr->Bits(15, 13) == 0x3) ||
522 (instr->Mask(0x8000EC00) == 0x00004C00) ||
523 (instr->Mask(0x8000E800) == 0x80004000) ||
524 (instr->Mask(0x8000E400) == 0x80004000)) {
525 VisitUnallocated(instr);
526 } else {
527 VisitDataProcessing2Source(instr);
528 }
529 } else {
530 if ((instr->Bit(13) == 1) ||
531 (instr->Bits(20, 16) != 0) ||
532 (instr->Bits(15, 14) != 0) ||
533 (instr->Mask(0xA01FFC00) == 0x00000C00) ||
534 (instr->Mask(0x201FF800) == 0x00001800)) {
535 VisitUnallocated(instr);
536 } else {
537 VisitDataProcessing1Source(instr);
538 }
539 }
540 break;
541 }
542 }
543 case 1:
544 case 3:
545 case 5:
546 case 7: VisitUnallocated(instr); break;
547 }
548 }
549 } else {
550 if (instr->Bit(28) == 0) {
551 if (instr->Bit(21) == 0) {
552 if ((instr->Bits(23, 22) == 0x3) ||
553 (instr->Mask(0x80008000) == 0x00008000)) {
554 VisitUnallocated(instr);
555 } else {
556 VisitAddSubShifted(instr);
557 }
558 } else {
559 if ((instr->Mask(0x00C00000) != 0x00000000) ||
560 (instr->Mask(0x00001400) == 0x00001400) ||
561 (instr->Mask(0x00001800) == 0x00001800)) {
562 VisitUnallocated(instr);
563 } else {
564 VisitAddSubExtended(instr);
565 }
566 }
567 } else {
568 if ((instr->Bit(30) == 0x1) ||
569 (instr->Bits(30, 29) == 0x1) ||
570 (instr->Mask(0xE0600000) == 0x00200000) ||
571 (instr->Mask(0xE0608000) == 0x00400000) ||
572 (instr->Mask(0x60608000) == 0x00408000) ||
573 (instr->Mask(0x60E00000) == 0x00E00000) ||
574 (instr->Mask(0x60E00000) == 0x00800000) ||
575 (instr->Mask(0x60E00000) == 0x00600000)) {
576 VisitUnallocated(instr);
577 } else {
578 VisitDataProcessing3Source(instr);
579 }
580 }
581 }
582 }
583
584
585 void Decoder::DecodeFP(const Instruction* instr) {
586 VIXL_ASSERT((instr->Bits(27, 24) == 0xE) ||
587 (instr->Bits(27, 24) == 0xF));
588 if (instr->Bit(28) == 0) {
589 DecodeNEONVectorDataProcessing(instr);
590 } else {
591 if (instr->Bits(31, 30) == 0x3) {
592 VisitUnallocated(instr);
593 } else if (instr->Bits(31, 30) == 0x1) {
594 DecodeNEONScalarDataProcessing(instr);
595 } else {
596 if (instr->Bit(29) == 0) {
597 if (instr->Bit(24) == 0) {
598 if (instr->Bit(21) == 0) {
599 if ((instr->Bit(23) == 1) ||
600 (instr->Bit(18) == 1) ||
601 (instr->Mask(0x80008000) == 0x00000000) ||
602 (instr->Mask(0x000E0000) == 0x00000000) ||
603 (instr->Mask(0x000E0000) == 0x000A0000) ||
604 (instr->Mask(0x00160000) == 0x00000000) ||
605 (instr->Mask(0x00160000) == 0x00120000)) {
606 VisitUnallocated(instr);
607 } else {
608 VisitFPFixedPointConvert(instr);
609 }
610 } else {
611 if (instr->Bits(15, 10) == 32) {
612 VisitUnallocated(instr);
613 } else if (instr->Bits(15, 10) == 0) {
614 if ((instr->Bits(23, 22) == 0x3) ||
615 (instr->Mask(0x000E0000) == 0x000A0000) ||
616 (instr->Mask(0x000E0000) == 0x000C0000) ||
617 (instr->Mask(0x00160000) == 0x00120000) ||
618 (instr->Mask(0x00160000) == 0x00140000) ||
619 (instr->Mask(0x20C40000) == 0x00800000) ||
620 (instr->Mask(0x20C60000) == 0x00840000) ||
621 (instr->Mask(0xA0C60000) == 0x80060000) ||
622 (instr->Mask(0xA0C60000) == 0x00860000) ||
623 (instr->Mask(0xA0CE0000) == 0x80860000) ||
624 (instr->Mask(0xA0CE0000) == 0x804E0000) ||
625 (instr->Mask(0xA0CE0000) == 0x000E0000) ||
626 (instr->Mask(0xA0D60000) == 0x00160000) ||
627 (instr->Mask(0xA0D60000) == 0x80560000) ||
628 (instr->Mask(0xA0D60000) == 0x80960000)) {
629 VisitUnallocated(instr);
630 } else {
631 VisitFPIntegerConvert(instr);
632 }
633 } else if (instr->Bits(14, 10) == 16) {
634 const Instr masked_A0DF8000 = instr->Mask(0xA0DF8000);
635 if ((instr->Mask(0x80180000) != 0) ||
636 (masked_A0DF8000 == 0x00020000) ||
637 (masked_A0DF8000 == 0x00030000) ||
638 (masked_A0DF8000 == 0x00068000) ||
639 (masked_A0DF8000 == 0x00428000) ||
640 (masked_A0DF8000 == 0x00430000) ||
641 (masked_A0DF8000 == 0x00468000) ||
642 (instr->Mask(0xA0D80000) == 0x00800000) ||
643 (instr->Mask(0xA0DE0000) == 0x00C00000) ||
644 (instr->Mask(0xA0DF0000) == 0x00C30000) ||
645 (instr->Mask(0xA0DC0000) == 0x00C40000)) {
646 VisitUnallocated(instr);
647 } else {
648 VisitFPDataProcessing1Source(instr);
649 }
650 } else if (instr->Bits(13, 10) == 8) {
651 if ((instr->Bits(15, 14) != 0) ||
652 (instr->Bits(2, 0) != 0) ||
653 (instr->Mask(0x80800000) != 0x00000000)) {
654 VisitUnallocated(instr);
655 } else {
656 VisitFPCompare(instr);
657 }
658 } else if (instr->Bits(12, 10) == 4) {
659 if ((instr->Bits(9, 5) != 0) ||
660 (instr->Mask(0x80800000) != 0x00000000)) {
661 VisitUnallocated(instr);
662 } else {
663 VisitFPImmediate(instr);
664 }
665 } else {
666 if (instr->Mask(0x80800000) != 0x00000000) {
667 VisitUnallocated(instr);
668 } else {
669 switch (instr->Bits(11, 10)) {
670 case 1: {
671 VisitFPConditionalCompare(instr);
672 break;
673 }
674 case 2: {
675 if ((instr->Bits(15, 14) == 0x3) ||
676 (instr->Mask(0x00009000) == 0x00009000) ||
677 (instr->Mask(0x0000A000) == 0x0000A000)) {
678 VisitUnallocated(instr);
679 } else {
680 VisitFPDataProcessing2Source(instr);
681 }
682 break;
683 }
684 case 3: {
685 VisitFPConditionalSelect(instr);
686 break;
687 }
688 default: VIXL_UNREACHABLE();
689 }
690 }
691 }
692 }
693 } else {
694 // Bit 30 == 1 has been handled earlier.
695 VIXL_ASSERT(instr->Bit(30) == 0);
696 if (instr->Mask(0xA0800000) != 0) {
697 VisitUnallocated(instr);
698 } else {
699 VisitFPDataProcessing3Source(instr);
700 }
701 }
702 } else {
703 VisitUnallocated(instr);
704 }
705 }
706 }
707 }
708
709
710 void Decoder::DecodeNEONLoadStore(const Instruction* instr) {
711 VIXL_ASSERT(instr->Bits(29, 25) == 0x6);
712 if (instr->Bit(31) == 0) {
713 if ((instr->Bit(24) == 0) && (instr->Bit(21) == 1)) {
714 VisitUnallocated(instr);
715 return;
716 }
717
718 if (instr->Bit(23) == 0) {
719 if (instr->Bits(20, 16) == 0) {
720 if (instr->Bit(24) == 0) {
721 VisitNEONLoadStoreMultiStruct(instr);
722 } else {
723 VisitNEONLoadStoreSingleStruct(instr);
724 }
725 } else {
726 VisitUnallocated(instr);
727 }
728 } else {
729 if (instr->Bit(24) == 0) {
730 VisitNEONLoadStoreMultiStructPostIndex(instr);
731 } else {
732 VisitNEONLoadStoreSingleStructPostIndex(instr);
733 }
734 }
735 } else {
736 VisitUnallocated(instr);
737 }
738 }
739
740
741 void Decoder::DecodeNEONVectorDataProcessing(const Instruction* instr) {
742 VIXL_ASSERT(instr->Bits(28, 25) == 0x7);
743 if (instr->Bit(31) == 0) {
744 if (instr->Bit(24) == 0) {
745 if (instr->Bit(21) == 0) {
746 if (instr->Bit(15) == 0) {
747 if (instr->Bit(10) == 0) {
748 if (instr->Bit(29) == 0) {
749 if (instr->Bit(11) == 0) {
750 VisitNEONTable(instr);
751 } else {
752 VisitNEONPerm(instr);
753 }
754 } else {
755 VisitNEONExtract(instr);
756 }
757 } else {
758 if (instr->Bits(23, 22) == 0) {
759 VisitNEONCopy(instr);
760 } else {
761 VisitUnallocated(instr);
762 }
763 }
764 } else {
765 VisitUnallocated(instr);
766 }
767 } else {
768 if (instr->Bit(10) == 0) {
769 if (instr->Bit(11) == 0) {
770 VisitNEON3Different(instr);
771 } else {
772 if (instr->Bits(18, 17) == 0) {
773 if (instr->Bit(20) == 0) {
774 if (instr->Bit(19) == 0) {
775 VisitNEON2RegMisc(instr);
776 } else {
777 if (instr->Bits(30, 29) == 0x2) {
778 VisitCryptoAES(instr);
779 } else {
780 VisitUnallocated(instr);
781 }
782 }
783 } else {
784 if (instr->Bit(19) == 0) {
785 VisitNEONAcrossLanes(instr);
786 } else {
787 VisitUnallocated(instr);
788 }
789 }
790 } else {
791 VisitUnallocated(instr);
792 }
793 }
794 } else {
795 VisitNEON3Same(instr);
796 }
797 }
798 } else {
799 if (instr->Bit(10) == 0) {
800 VisitNEONByIndexedElement(instr);
801 } else {
802 if (instr->Bit(23) == 0) {
803 if (instr->Bits(22, 19) == 0) {
804 VisitNEONModifiedImmediate(instr);
805 } else {
806 VisitNEONShiftImmediate(instr);
807 }
808 } else {
809 VisitUnallocated(instr);
810 }
811 }
812 }
813 } else {
814 VisitUnallocated(instr);
815 }
816 }
817
818
819 void Decoder::DecodeNEONScalarDataProcessing(const Instruction* instr) {
820 VIXL_ASSERT(instr->Bits(28, 25) == 0xF);
821 if (instr->Bit(24) == 0) {
822 if (instr->Bit(21) == 0) {
823 if (instr->Bit(15) == 0) {
824 if (instr->Bit(10) == 0) {
825 if (instr->Bit(29) == 0) {
826 if (instr->Bit(11) == 0) {
827 VisitCrypto3RegSHA(instr);
828 } else {
829 VisitUnallocated(instr);
830 }
831 } else {
832 VisitUnallocated(instr);
833 }
834 } else {
835 if (instr->Bits(23, 22) == 0) {
836 VisitNEONScalarCopy(instr);
837 } else {
838 VisitUnallocated(instr);
839 }
840 }
841 } else {
842 VisitUnallocated(instr);
843 }
844 } else {
845 if (instr->Bit(10) == 0) {
846 if (instr->Bit(11) == 0) {
847 VisitNEONScalar3Diff(instr);
848 } else {
849 if (instr->Bits(18, 17) == 0) {
850 if (instr->Bit(20) == 0) {
851 if (instr->Bit(19) == 0) {
852 VisitNEONScalar2RegMisc(instr);
853 } else {
854 if (instr->Bit(29) == 0) {
855 VisitCrypto2RegSHA(instr);
856 } else {
857 VisitUnallocated(instr);
858 }
859 }
860 } else {
861 if (instr->Bit(19) == 0) {
862 VisitNEONScalarPairwise(instr);
863 } else {
864 VisitUnallocated(instr);
865 }
866 }
867 } else {
868 VisitUnallocated(instr);
869 }
870 }
871 } else {
872 VisitNEONScalar3Same(instr);
873 }
874 }
875 } else {
876 if (instr->Bit(10) == 0) {
877 VisitNEONScalarByIndexedElement(instr);
878 } else {
879 if (instr->Bit(23) == 0) {
880 VisitNEONScalarShiftImmediate(instr);
881 } else {
882 VisitUnallocated(instr);
883 }
884 }
885 }
886 }
887
888
889 #define DEFINE_VISITOR_CALLERS(A) \
890 void Decoder::Visit##A(const Instruction *instr) { \
891 VIXL_ASSERT(instr->Mask(A##FMask) == A##Fixed); \
892 for (auto visitor : visitors_) { \
893 visitor->Visit##A(instr); \
894 } \
895 }
896 VISITOR_LIST(DEFINE_VISITOR_CALLERS)
897 #undef DEFINE_VISITOR_CALLERS
898 } // namespace vixl