1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #ifndef V8_CODEGEN_ARM64_DECODER_ARM64_INL_H_
6 #define V8_CODEGEN_ARM64_DECODER_ARM64_INL_H_
7 
8 #include "src/codegen/arm64/decoder-arm64.h"
9 #include "src/common/globals.h"
10 #include "src/utils/utils.h"
11 
12 namespace v8 {
13 namespace internal {
14 
15 // Top-level instruction decode function.
16 template <typename V>
Decode(Instruction* instr)17 void Decoder<V>::Decode(Instruction* instr) {
18   if (instr->Bits(28, 27) == 0) {
19     V::VisitUnallocated(instr);
20   } else {
21     switch (instr->Bits(27, 24)) {
22       // 0:   PC relative addressing.
23       case 0x0:
24         DecodePCRelAddressing(instr);
25         break;
26 
27       // 1:   Add/sub immediate.
28       case 0x1:
29         DecodeAddSubImmediate(instr);
30         break;
31 
32       // A:   Logical shifted register.
33       //      Add/sub with carry.
34       //      Conditional compare register.
35       //      Conditional compare immediate.
36       //      Conditional select.
37       //      Data processing 1 source.
38       //      Data processing 2 source.
39       // B:   Add/sub shifted register.
40       //      Add/sub extended register.
41       //      Data processing 3 source.
42       case 0xA:
43       case 0xB:
44         DecodeDataProcessing(instr);
45         break;
46 
47       // 2:   Logical immediate.
48       //      Move wide immediate.
49       case 0x2:
50         DecodeLogical(instr);
51         break;
52 
53       // 3:   Bitfield.
54       //      Extract.
55       case 0x3:
56         DecodeBitfieldExtract(instr);
57         break;
58 
59       // 4:   Unconditional branch immediate.
60       //      Exception generation.
61       //      Compare and branch immediate.
62       // 5:   Compare and branch immediate.
63       //      Conditional branch.
64       //      System.
65       // 6,7: Unconditional branch.
66       //      Test and branch immediate.
67       case 0x4:
68       case 0x5:
69       case 0x6:
70       case 0x7:
71         DecodeBranchSystemException(instr);
72         break;
73 
74       // 8,9: Load/store register pair post-index.
75       //      Load register literal.
76       //      Load/store register unscaled immediate.
77       //      Load/store register immediate post-index.
78       //      Load/store register immediate pre-index.
79       //      Load/store register offset.
80       // C,D: Load/store register pair offset.
81       //      Load/store register pair pre-index.
82       //      Load/store register unsigned immediate.
83       //      Advanced SIMD.
84       case 0x8:
85       case 0x9:
86       case 0xC:
87       case 0xD:
88         DecodeLoadStore(instr);
89         break;
90 
91       // E:   FP fixed point conversion.
92       //      FP integer conversion.
93       //      FP data processing 1 source.
94       //      FP compare.
95       //      FP immediate.
96       //      FP data processing 2 source.
97       //      FP conditional compare.
98       //      FP conditional select.
99       //      Advanced SIMD.
100       // F:   FP data processing 3 source.
101       //      Advanced SIMD.
102       case 0xE:
103       case 0xF:
104         DecodeFP(instr);
105         break;
106     }
107   }
108 }
109 
110 template <typename V>
DecodePCRelAddressing(Instruction* instr)111 void Decoder<V>::DecodePCRelAddressing(Instruction* instr) {
112   DCHECK_EQ(0x0, instr->Bits(27, 24));
113   // We know bit 28 is set, as <b28:b27> = 0 is filtered out at the top level
114   // decode.
115   DCHECK_EQ(0x1, instr->Bit(28));
116   V::VisitPCRelAddressing(instr);
117 }
118 
119 template <typename V>
DecodeBranchSystemException(Instruction* instr)120 void Decoder<V>::DecodeBranchSystemException(Instruction* instr) {
121   DCHECK_EQ(0x4, instr->Bits(27, 24) & 0xC);  // 0x4, 0x5, 0x6, 0x7
122 
123   switch (instr->Bits(31, 29)) {
124     case 0:
125     case 4: {
126       V::VisitUnconditionalBranch(instr);
127       break;
128     }
129     case 1:
130     case 5: {
131       if (instr->Bit(25) == 0) {
132         V::VisitCompareBranch(instr);
133       } else {
134         V::VisitTestBranch(instr);
135       }
136       break;
137     }
138     case 2: {
139       if (instr->Bit(25) == 0) {
140         if ((instr->Bit(24) == 0x1) ||
141             (instr->Mask(0x01000010) == 0x00000010)) {
142           V::VisitUnallocated(instr);
143         } else {
144           V::VisitConditionalBranch(instr);
145         }
146       } else {
147         V::VisitUnallocated(instr);
148       }
149       break;
150     }
151     case 6: {
152       if (instr->Bit(25) == 0) {
153         if (instr->Bit(24) == 0) {
154           if ((instr->Bits(4, 2) != 0) ||
155               (instr->Mask(0x00E0001D) == 0x00200001) ||
156               (instr->Mask(0x00E0001D) == 0x00400001) ||
157               (instr->Mask(0x00E0001E) == 0x00200002) ||
158               (instr->Mask(0x00E0001E) == 0x00400002) ||
159               (instr->Mask(0x00E0001C) == 0x00600000) ||
160               (instr->Mask(0x00E0001C) == 0x00800000) ||
161               (instr->Mask(0x00E0001F) == 0x00A00000) ||
162               (instr->Mask(0x00C0001C) == 0x00C00000)) {
163             V::VisitUnallocated(instr);
164           } else {
165             V::VisitException(instr);
166           }
167         } else {
168           if (instr->Bits(23, 22) == 0) {
169             const Instr masked_003FF0E0 = instr->Mask(0x003FF0E0);
170             if ((instr->Bits(21, 19) == 0x4) ||
171                 (masked_003FF0E0 == 0x00033000) ||
172                 (masked_003FF0E0 == 0x003FF020) ||
173                 (masked_003FF0E0 == 0x003FF060) ||
174                 (masked_003FF0E0 == 0x003FF0E0) ||
175                 (instr->Mask(0x00388000) == 0x00008000) ||
176                 (instr->Mask(0x0038E000) == 0x00000000) ||
177                 (instr->Mask(0x0039E000) == 0x00002000) ||
178                 (instr->Mask(0x003AE000) == 0x00002000) ||
179                 (instr->Mask(0x003CE000) == 0x00042000) ||
180                 (instr->Mask(0x0038F000) == 0x00005000) ||
181                 (instr->Mask(0x0038E000) == 0x00006000)) {
182               V::VisitUnallocated(instr);
183             } else {
184               V::VisitSystem(instr);
185             }
186           } else {
187             V::VisitUnallocated(instr);
188           }
189         }
190       } else {
191         if ((instr->Bit(24) == 0x1) || (instr->Bits(20, 16) != 0x1F) ||
192             (instr->Bits(15, 10) != 0) || (instr->Bits(4, 0) != 0) ||
193             (instr->Bits(24, 21) == 0x3) || (instr->Bits(24, 22) == 0x3)) {
194           V::VisitUnallocated(instr);
195         } else {
196           V::VisitUnconditionalBranchToRegister(instr);
197         }
198       }
199       break;
200     }
201     case 3:
202     case 7: {
203       V::VisitUnallocated(instr);
204       break;
205     }
206   }
207 }
208 
209 template <typename V>
DecodeLoadStore(Instruction* instr)210 void Decoder<V>::DecodeLoadStore(Instruction* instr) {
211   DCHECK_EQ(0x8, instr->Bits(27, 24) & 0xA);  // 0x8, 0x9, 0xC, 0xD
212 
213   if ((instr->Bit(28) == 0) && (instr->Bit(29) == 0) && (instr->Bit(26) == 1)) {
214     DecodeNEONLoadStore(instr);
215     return;
216   }
217 
218   if (instr->Bit(24) == 0) {
219     if (instr->Bit(28) == 0) {
220       if (instr->Bit(29) == 0) {
221         if (instr->Bit(26) == 0) {
222           if (instr->Mask(0xA08000) == 0x800000 ||
223               instr->Mask(0xA00000) == 0xA00000) {
224             V::VisitUnallocated(instr);
225           } else if (instr->Mask(0x808000) == 0) {
226             // Load/Store exclusive without acquire/release are unimplemented.
227             V::VisitUnimplemented(instr);
228           } else {
229             V::VisitLoadStoreAcquireRelease(instr);
230           }
231         }
232       } else {
233         if ((instr->Bits(31, 30) == 0x3) ||
234             (instr->Mask(0xC4400000) == 0x40000000)) {
235           V::VisitUnallocated(instr);
236         } else {
237           if (instr->Bit(23) == 0) {
238             if (instr->Mask(0xC4400000) == 0xC0400000) {
239               V::VisitUnallocated(instr);
240             } else {
241               // Nontemporals are unimplemented.
242               V::VisitUnimplemented(instr);
243             }
244           } else {
245             V::VisitLoadStorePairPostIndex(instr);
246           }
247         }
248       }
249     } else {
250       if (instr->Bit(29) == 0) {
251         if (instr->Mask(0xC4000000) == 0xC4000000) {
252           V::VisitUnallocated(instr);
253         } else {
254           V::VisitLoadLiteral(instr);
255         }
256       } else {
257         if ((instr->Mask(0x84C00000) == 0x80C00000) ||
258             (instr->Mask(0x44800000) == 0x44800000) ||
259             (instr->Mask(0x84800000) == 0x84800000)) {
260           V::VisitUnallocated(instr);
261         } else {
262           if (instr->Bit(21) == 0) {
263             switch (instr->Bits(11, 10)) {
264               case 0: {
265                 V::VisitLoadStoreUnscaledOffset(instr);
266                 break;
267               }
268               case 1: {
269                 if (instr->Mask(0xC4C00000) == 0xC0800000) {
270                   V::VisitUnallocated(instr);
271                 } else {
272                   V::VisitLoadStorePostIndex(instr);
273                 }
274                 break;
275               }
276               case 2: {
277                 // TODO(all): VisitLoadStoreRegisterOffsetUnpriv.
278                 V::VisitUnimplemented(instr);
279                 break;
280               }
281               case 3: {
282                 if (instr->Mask(0xC4C00000) == 0xC0800000) {
283                   V::VisitUnallocated(instr);
284                 } else {
285                   V::VisitLoadStorePreIndex(instr);
286                 }
287                 break;
288               }
289             }
290           } else {
291             if (instr->Bits(11, 10) == 0x2) {
292               if (instr->Bit(14) == 0) {
293                 V::VisitUnallocated(instr);
294               } else {
295                 V::VisitLoadStoreRegisterOffset(instr);
296               }
297             } else {
298               V::VisitUnallocated(instr);
299             }
300           }
301         }
302       }
303     }
304   } else {
305     if (instr->Bit(28) == 0) {
306       if (instr->Bit(29) == 0) {
307         V::VisitUnallocated(instr);
308       } else {
309         if ((instr->Bits(31, 30) == 0x3) ||
310             (instr->Mask(0xC4400000) == 0x40000000)) {
311           V::VisitUnallocated(instr);
312         } else {
313           if (instr->Bit(23) == 0) {
314             V::VisitLoadStorePairOffset(instr);
315           } else {
316             V::VisitLoadStorePairPreIndex(instr);
317           }
318         }
319       }
320     } else {
321       if (instr->Bit(29) == 0) {
322         V::VisitUnallocated(instr);
323       } else {
324         if ((instr->Mask(0x84C00000) == 0x80C00000) ||
325             (instr->Mask(0x44800000) == 0x44800000) ||
326             (instr->Mask(0x84800000) == 0x84800000)) {
327           V::VisitUnallocated(instr);
328         } else {
329           V::VisitLoadStoreUnsignedOffset(instr);
330         }
331       }
332     }
333   }
334 }
335 
336 template <typename V>
DecodeLogical(Instruction* instr)337 void Decoder<V>::DecodeLogical(Instruction* instr) {
338   DCHECK_EQ(0x2, instr->Bits(27, 24));
339 
340   if (instr->Mask(0x80400000) == 0x00400000) {
341     V::VisitUnallocated(instr);
342   } else {
343     if (instr->Bit(23) == 0) {
344       V::VisitLogicalImmediate(instr);
345     } else {
346       if (instr->Bits(30, 29) == 0x1) {
347         V::VisitUnallocated(instr);
348       } else {
349         V::VisitMoveWideImmediate(instr);
350       }
351     }
352   }
353 }
354 
355 template <typename V>
DecodeBitfieldExtract(Instruction* instr)356 void Decoder<V>::DecodeBitfieldExtract(Instruction* instr) {
357   DCHECK_EQ(0x3, instr->Bits(27, 24));
358 
359   if ((instr->Mask(0x80400000) == 0x80000000) ||
360       (instr->Mask(0x80400000) == 0x00400000) ||
361       (instr->Mask(0x80008000) == 0x00008000)) {
362     V::VisitUnallocated(instr);
363   } else if (instr->Bit(23) == 0) {
364     if ((instr->Mask(0x80200000) == 0x00200000) ||
365         (instr->Mask(0x60000000) == 0x60000000)) {
366       V::VisitUnallocated(instr);
367     } else {
368       V::VisitBitfield(instr);
369     }
370   } else {
371     if ((instr->Mask(0x60200000) == 0x00200000) ||
372         (instr->Mask(0x60000000) != 0x00000000)) {
373       V::VisitUnallocated(instr);
374     } else {
375       V::VisitExtract(instr);
376     }
377   }
378 }
379 
380 template <typename V>
DecodeAddSubImmediate(Instruction* instr)381 void Decoder<V>::DecodeAddSubImmediate(Instruction* instr) {
382   DCHECK_EQ(0x1, instr->Bits(27, 24));
383   if (instr->Bit(23) == 1) {
384     V::VisitUnallocated(instr);
385   } else {
386     V::VisitAddSubImmediate(instr);
387   }
388 }
389 
390 template <typename V>
DecodeDataProcessing(Instruction* instr)391 void Decoder<V>::DecodeDataProcessing(Instruction* instr) {
392   DCHECK((instr->Bits(27, 24) == 0xA) || (instr->Bits(27, 24) == 0xB));
393 
394   if (instr->Bit(24) == 0) {
395     if (instr->Bit(28) == 0) {
396       if (instr->Mask(0x80008000) == 0x00008000) {
397         V::VisitUnallocated(instr);
398       } else {
399         V::VisitLogicalShifted(instr);
400       }
401     } else {
402       switch (instr->Bits(23, 21)) {
403         case 0: {
404           if (instr->Mask(0x0000FC00) != 0) {
405             V::VisitUnallocated(instr);
406           } else {
407             V::VisitAddSubWithCarry(instr);
408           }
409           break;
410         }
411         case 2: {
412           if ((instr->Bit(29) == 0) || (instr->Mask(0x00000410) != 0)) {
413             V::VisitUnallocated(instr);
414           } else {
415             if (instr->Bit(11) == 0) {
416               V::VisitConditionalCompareRegister(instr);
417             } else {
418               V::VisitConditionalCompareImmediate(instr);
419             }
420           }
421           break;
422         }
423         case 4: {
424           if (instr->Mask(0x20000800) != 0x00000000) {
425             V::VisitUnallocated(instr);
426           } else {
427             V::VisitConditionalSelect(instr);
428           }
429           break;
430         }
431         case 6: {
432           if (instr->Bit(29) == 0x1) {
433             V::VisitUnallocated(instr);
434           } else {
435             if (instr->Bit(30) == 0) {
436               if ((instr->Bit(15) == 0x1) || (instr->Bits(15, 11) == 0) ||
437                   (instr->Bits(15, 12) == 0x1) ||
438                   (instr->Bits(15, 12) == 0x3) ||
439                   (instr->Bits(15, 13) == 0x3) ||
440                   (instr->Mask(0x8000EC00) == 0x00004C00) ||
441                   (instr->Mask(0x8000E800) == 0x80004000) ||
442                   (instr->Mask(0x8000E400) == 0x80004000)) {
443                 V::VisitUnallocated(instr);
444               } else {
445                 V::VisitDataProcessing2Source(instr);
446               }
447             } else {
448               if ((instr->Bit(13) == 1) || (instr->Bits(20, 16) != 0) ||
449                   (instr->Bits(15, 14) != 0) ||
450                   (instr->Mask(0xA01FFC00) == 0x00000C00) ||
451                   (instr->Mask(0x201FF800) == 0x00001800)) {
452                 V::VisitUnallocated(instr);
453               } else {
454                 V::VisitDataProcessing1Source(instr);
455               }
456             }
457             break;
458           }
459           V8_FALLTHROUGH;
460         }
461         case 1:
462         case 3:
463         case 5:
464         case 7:
465           V::VisitUnallocated(instr);
466           break;
467       }
468     }
469   } else {
470     if (instr->Bit(28) == 0) {
471       if (instr->Bit(21) == 0) {
472         if ((instr->Bits(23, 22) == 0x3) ||
473             (instr->Mask(0x80008000) == 0x00008000)) {
474           V::VisitUnallocated(instr);
475         } else {
476           V::VisitAddSubShifted(instr);
477         }
478       } else {
479         if ((instr->Mask(0x00C00000) != 0x00000000) ||
480             (instr->Mask(0x00001400) == 0x00001400) ||
481             (instr->Mask(0x00001800) == 0x00001800)) {
482           V::VisitUnallocated(instr);
483         } else {
484           V::VisitAddSubExtended(instr);
485         }
486       }
487     } else {
488       if ((instr->Bit(30) == 0x1) || (instr->Bits(30, 29) == 0x1) ||
489           (instr->Mask(0xE0600000) == 0x00200000) ||
490           (instr->Mask(0xE0608000) == 0x00400000) ||
491           (instr->Mask(0x60608000) == 0x00408000) ||
492           (instr->Mask(0x60E00000) == 0x00E00000) ||
493           (instr->Mask(0x60E00000) == 0x00800000) ||
494           (instr->Mask(0x60E00000) == 0x00600000)) {
495         V::VisitUnallocated(instr);
496       } else {
497         V::VisitDataProcessing3Source(instr);
498       }
499     }
500   }
501 }
502 
503 template <typename V>
DecodeFP(Instruction* instr)504 void Decoder<V>::DecodeFP(Instruction* instr) {
505   DCHECK((instr->Bits(27, 24) == 0xE) || (instr->Bits(27, 24) == 0xF));
506 
507   if (instr->Bit(28) == 0) {
508     DecodeNEONVectorDataProcessing(instr);
509   } else {
510     if (instr->Bits(31, 30) == 0x3) {
511       V::VisitUnallocated(instr);
512     } else if (instr->Bits(31, 30) == 0x1) {
513       DecodeNEONScalarDataProcessing(instr);
514     } else {
515       if (instr->Bit(29) == 0) {
516         if (instr->Bit(24) == 0) {
517           if (instr->Bit(21) == 0) {
518             if ((instr->Bit(23) == 1) || (instr->Bit(18) == 1) ||
519                 (instr->Mask(0x80008000) == 0x00000000) ||
520                 (instr->Mask(0x000E0000) == 0x00000000) ||
521                 (instr->Mask(0x000E0000) == 0x000A0000) ||
522                 (instr->Mask(0x00160000) == 0x00000000) ||
523                 (instr->Mask(0x00160000) == 0x00120000)) {
524               V::VisitUnallocated(instr);
525             } else {
526               V::VisitFPFixedPointConvert(instr);
527             }
528           } else {
529             if (instr->Bits(15, 10) == 32) {
530               V::VisitUnallocated(instr);
531             } else if (instr->Bits(15, 10) == 0) {
532               if ((instr->Bits(23, 22) == 0x3) ||
533                   (instr->Mask(0x000E0000) == 0x000A0000) ||
534                   (instr->Mask(0x000E0000) == 0x000C0000) ||
535                   (instr->Mask(0x00160000) == 0x00120000) ||
536                   (instr->Mask(0x00160000) == 0x00140000) ||
537                   (instr->Mask(0x20C40000) == 0x00800000) ||
538                   (instr->Mask(0x20C60000) == 0x00840000) ||
539                   (instr->Mask(0xA0C60000) == 0x80060000) ||
540                   (instr->Mask(0xA0C60000) == 0x00860000) ||
541                   (instr->Mask(0xA0CE0000) == 0x80860000) ||
542                   (instr->Mask(0xA0CE0000) == 0x804E0000) ||
543                   (instr->Mask(0xA0CE0000) == 0x000E0000) ||
544                   (instr->Mask(0xA0D60000) == 0x00160000) ||
545                   (instr->Mask(0xA0D60000) == 0x80560000) ||
546                   (instr->Mask(0xA0D60000) == 0x80960000)) {
547                 V::VisitUnallocated(instr);
548               } else {
549                 V::VisitFPIntegerConvert(instr);
550               }
551             } else if (instr->Bits(14, 10) == 16) {
552               const Instr masked_A0DF8000 = instr->Mask(0xA0DF8000);
553               if ((instr->Mask(0x80180000) != 0) ||
554                   (masked_A0DF8000 == 0x00020000) ||
555                   (masked_A0DF8000 == 0x00030000) ||
556                   (masked_A0DF8000 == 0x00068000) ||
557                   (masked_A0DF8000 == 0x00428000) ||
558                   (masked_A0DF8000 == 0x00430000) ||
559                   (masked_A0DF8000 == 0x00468000) ||
560                   (instr->Mask(0xA0D80000) == 0x00800000) ||
561                   (instr->Mask(0xA0DE0000) == 0x00C00000) ||
562                   (instr->Mask(0xA0DF0000) == 0x00C30000) ||
563                   (instr->Mask(0xA0DC0000) == 0x00C40000)) {
564                 V::VisitUnallocated(instr);
565               } else {
566                 V::VisitFPDataProcessing1Source(instr);
567               }
568             } else if (instr->Bits(13, 10) == 8) {
569               if ((instr->Bits(15, 14) != 0) || (instr->Bits(2, 0) != 0) ||
570                   (instr->Mask(0x80800000) != 0x00000000)) {
571                 V::VisitUnallocated(instr);
572               } else {
573                 V::VisitFPCompare(instr);
574               }
575             } else if (instr->Bits(12, 10) == 4) {
576               if ((instr->Bits(9, 5) != 0) ||
577                   (instr->Mask(0x80800000) != 0x00000000)) {
578                 V::VisitUnallocated(instr);
579               } else {
580                 V::VisitFPImmediate(instr);
581               }
582             } else {
583               if (instr->Mask(0x80800000) != 0x00000000) {
584                 V::VisitUnallocated(instr);
585               } else {
586                 switch (instr->Bits(11, 10)) {
587                   case 1: {
588                     V::VisitFPConditionalCompare(instr);
589                     break;
590                   }
591                   case 2: {
592                     if ((instr->Bits(15, 14) == 0x3) ||
593                         (instr->Mask(0x00009000) == 0x00009000) ||
594                         (instr->Mask(0x0000A000) == 0x0000A000)) {
595                       V::VisitUnallocated(instr);
596                     } else {
597                       V::VisitFPDataProcessing2Source(instr);
598                     }
599                     break;
600                   }
601                   case 3: {
602                     V::VisitFPConditionalSelect(instr);
603                     break;
604                   }
605                   default:
606                     UNREACHABLE();
607                 }
608               }
609             }
610           }
611         } else {
612           // Bit 30 == 1 has been handled earlier.
613           DCHECK_EQ(0, instr->Bit(30));
614           if (instr->Mask(0xA0800000) != 0) {
615             V::VisitUnallocated(instr);
616           } else {
617             V::VisitFPDataProcessing3Source(instr);
618           }
619         }
620       } else {
621         V::VisitUnallocated(instr);
622       }
623     }
624   }
625 }
626 
627 template <typename V>
DecodeNEONLoadStore(Instruction* instr)628 void Decoder<V>::DecodeNEONLoadStore(Instruction* instr) {
629   DCHECK_EQ(0x6, instr->Bits(29, 25));
630   if (instr->Bit(31) == 0) {
631     if ((instr->Bit(24) == 0) && (instr->Bit(21) == 1)) {
632       V::VisitUnallocated(instr);
633       return;
634     }
635 
636     if (instr->Bit(23) == 0) {
637       if (instr->Bits(20, 16) == 0) {
638         if (instr->Bit(24) == 0) {
639           V::VisitNEONLoadStoreMultiStruct(instr);
640         } else {
641           V::VisitNEONLoadStoreSingleStruct(instr);
642         }
643       } else {
644         V::VisitUnallocated(instr);
645       }
646     } else {
647       if (instr->Bit(24) == 0) {
648         V::VisitNEONLoadStoreMultiStructPostIndex(instr);
649       } else {
650         V::VisitNEONLoadStoreSingleStructPostIndex(instr);
651       }
652     }
653   } else {
654     V::VisitUnallocated(instr);
655   }
656 }
657 
658 template <typename V>
DecodeNEONVectorDataProcessing(Instruction* instr)659 void Decoder<V>::DecodeNEONVectorDataProcessing(Instruction* instr) {
660   DCHECK_EQ(0x7, instr->Bits(28, 25));
661   if (instr->Bit(31) == 0) {
662     if (instr->Bit(24) == 0) {
663       if (instr->Bit(21) == 0) {
664         if (instr->Bit(15) == 0) {
665           if (instr->Bit(10) == 0) {
666             if (instr->Bit(29) == 0) {
667               if (instr->Bit(11) == 0) {
668                 V::VisitNEONTable(instr);
669               } else {
670                 V::VisitNEONPerm(instr);
671               }
672             } else {
673               V::VisitNEONExtract(instr);
674             }
675           } else {
676             if (instr->Bits(23, 22) == 0) {
677               V::VisitNEONCopy(instr);
678             } else {
679               V::VisitUnallocated(instr);
680             }
681           }
682         } else {
683           V::VisitUnallocated(instr);
684         }
685       } else {
686         if (instr->Bit(10) == 0) {
687           if (instr->Bit(11) == 0) {
688             V::VisitNEON3Different(instr);
689           } else {
690             if (instr->Bits(18, 17) == 0) {
691               if (instr->Bit(20) == 0) {
692                 if (instr->Bit(19) == 0) {
693                   V::VisitNEON2RegMisc(instr);
694                 } else {
695                   if (instr->Bits(30, 29) == 0x2) {
696                     V::VisitUnallocated(instr);
697                   } else {
698                     V::VisitUnallocated(instr);
699                   }
700                 }
701               } else {
702                 if (instr->Bit(19) == 0) {
703                   V::VisitNEONAcrossLanes(instr);
704                 } else {
705                   V::VisitUnallocated(instr);
706                 }
707               }
708             } else {
709               V::VisitUnallocated(instr);
710             }
711           }
712         } else {
713           V::VisitNEON3Same(instr);
714         }
715       }
716     } else {
717       if (instr->Bit(10) == 0) {
718         V::VisitNEONByIndexedElement(instr);
719       } else {
720         if (instr->Bit(23) == 0) {
721           if (instr->Bits(22, 19) == 0) {
722             V::VisitNEONModifiedImmediate(instr);
723           } else {
724             V::VisitNEONShiftImmediate(instr);
725           }
726         } else {
727           V::VisitUnallocated(instr);
728         }
729       }
730     }
731   } else {
732     V::VisitUnallocated(instr);
733   }
734 }
735 
736 template <typename V>
DecodeNEONScalarDataProcessing(Instruction* instr)737 void Decoder<V>::DecodeNEONScalarDataProcessing(Instruction* instr) {
738   DCHECK_EQ(0xF, instr->Bits(28, 25));
739   if (instr->Bit(24) == 0) {
740     if (instr->Bit(21) == 0) {
741       if (instr->Bit(15) == 0) {
742         if (instr->Bit(10) == 0) {
743           if (instr->Bit(29) == 0) {
744             if (instr->Bit(11) == 0) {
745               V::VisitUnallocated(instr);
746             } else {
747               V::VisitUnallocated(instr);
748             }
749           } else {
750             V::VisitUnallocated(instr);
751           }
752         } else {
753           if (instr->Bits(23, 22) == 0) {
754             V::VisitNEONScalarCopy(instr);
755           } else {
756             V::VisitUnallocated(instr);
757           }
758         }
759       } else {
760         V::VisitUnallocated(instr);
761       }
762     } else {
763       if (instr->Bit(10) == 0) {
764         if (instr->Bit(11) == 0) {
765           V::VisitNEONScalar3Diff(instr);
766         } else {
767           if (instr->Bits(18, 17) == 0) {
768             if (instr->Bit(20) == 0) {
769               if (instr->Bit(19) == 0) {
770                 V::VisitNEONScalar2RegMisc(instr);
771               } else {
772                 if (instr->Bit(29) == 0) {
773                   V::VisitUnallocated(instr);
774                 } else {
775                   V::VisitUnallocated(instr);
776                 }
777               }
778             } else {
779               if (instr->Bit(19) == 0) {
780                 V::VisitNEONScalarPairwise(instr);
781               } else {
782                 V::VisitUnallocated(instr);
783               }
784             }
785           } else {
786             V::VisitUnallocated(instr);
787           }
788         }
789       } else {
790         V::VisitNEONScalar3Same(instr);
791       }
792     }
793   } else {
794     if (instr->Bit(10) == 0) {
795       V::VisitNEONScalarByIndexedElement(instr);
796     } else {
797       if (instr->Bit(23) == 0) {
798         V::VisitNEONScalarShiftImmediate(instr);
799       } else {
800         V::VisitUnallocated(instr);
801       }
802     }
803   }
804 }
805 
806 }  // namespace internal
807 }  // namespace v8
808 
809 #endif  // V8_CODEGEN_ARM64_DECODER_ARM64_INL_H_
810