1 | /*===- TableGen'erated file -------------------------------------*- C++ -*-===*\ |
2 | |* *| |
3 | |* * AVR Disassembler *| |
4 | |* *| |
5 | |* Automatically generated file, do not edit! *| |
6 | |* *| |
7 | \*===----------------------------------------------------------------------===*/ |
8 | |
9 | |
10 | #include "llvm/MC/MCInst.h" |
11 | #include "llvm/MC/MCSubtargetInfo.h" |
12 | #include "llvm/Support/DataTypes.h" |
13 | #include "llvm/Support/Debug.h" |
14 | #include "llvm/Support/LEB128.h" |
15 | #include "llvm/Support/raw_ostream.h" |
16 | #include "llvm/TargetParser/SubtargetFeature.h" |
17 | #include <assert.h> |
18 | |
19 | namespace llvm { |
20 | |
21 | // Helper functions for extracting fields from encoded instructions. |
22 | // InsnType must either be integral or an APInt-like object that must: |
23 | // * be default-constructible and copy-constructible |
24 | // * be constructible from an APInt (this can be private) |
25 | // * Support insertBits(bits, startBit, numBits) |
26 | // * Support extractBitsAsZExtValue(numBits, startBit) |
27 | // * Support the ~, &, ==, and != operators with other objects of the same type |
28 | // * Support the != and bitwise & with uint64_t |
29 | // * Support put (<<) to raw_ostream& |
30 | template <typename InsnType> |
31 | #if defined(_MSC_VER) && !defined(__clang__) |
32 | __declspec(noinline) |
33 | #endif |
34 | static std::enable_if_t<std::is_integral<InsnType>::value, InsnType> |
35 | fieldFromInstruction(const InsnType &insn, unsigned startBit, |
36 | unsigned numBits) { |
37 | assert(startBit + numBits <= 64 && "Cannot support >64-bit extractions!" ); |
38 | assert(startBit + numBits <= (sizeof(InsnType) * 8) && |
39 | "Instruction field out of bounds!" ); |
40 | InsnType fieldMask; |
41 | if (numBits == sizeof(InsnType) * 8) |
42 | fieldMask = (InsnType)(-1LL); |
43 | else |
44 | fieldMask = (((InsnType)1 << numBits) - 1) << startBit; |
45 | return (insn & fieldMask) >> startBit; |
46 | } |
47 | |
48 | template <typename InsnType> |
49 | static std::enable_if_t<!std::is_integral<InsnType>::value, uint64_t> |
50 | fieldFromInstruction(const InsnType &insn, unsigned startBit, |
51 | unsigned numBits) { |
52 | return insn.extractBitsAsZExtValue(numBits, startBit); |
53 | } |
54 | |
55 | // Helper function for inserting bits extracted from an encoded instruction into |
56 | // a field. |
57 | template <typename InsnType> |
58 | static std::enable_if_t<std::is_integral<InsnType>::value> |
59 | insertBits(InsnType &field, InsnType bits, unsigned startBit, unsigned numBits) { |
60 | assert(startBit + numBits <= sizeof field * 8); |
61 | field |= (InsnType)bits << startBit; |
62 | } |
63 | |
64 | template <typename InsnType> |
65 | static std::enable_if_t<!std::is_integral<InsnType>::value> |
66 | insertBits(InsnType &field, uint64_t bits, unsigned startBit, unsigned numBits) { |
67 | field.insertBits(bits, startBit, numBits); |
68 | } |
69 | |
70 | static bool Check(DecodeStatus &Out, DecodeStatus In) { |
71 | Out = static_cast<DecodeStatus>(Out & In); |
72 | return Out != MCDisassembler::Fail; |
73 | } |
74 | |
75 | static const uint8_t DecoderTable16[] = { |
76 | /* 0 */ MCD::OPC_ExtractField, 14, 2, // Inst{15-14} ... |
77 | /* 3 */ MCD::OPC_FilterValue, 0, 5, 1, 0, // Skip to: 269 |
78 | /* 8 */ MCD::OPC_ExtractField, 12, 2, // Inst{13-12} ... |
79 | /* 11 */ MCD::OPC_FilterValue, 0, 156, 0, 0, // Skip to: 172 |
80 | /* 16 */ MCD::OPC_ExtractField, 10, 2, // Inst{11-10} ... |
81 | /* 19 */ MCD::OPC_FilterValue, 0, 121, 0, 0, // Skip to: 145 |
82 | /* 24 */ MCD::OPC_ExtractField, 8, 2, // Inst{9-8} ... |
83 | /* 27 */ MCD::OPC_FilterValue, 0, 11, 0, 0, // Skip to: 43 |
84 | /* 32 */ MCD::OPC_CheckField, 0, 8, 0, 52, 5, 0, // Skip to: 1371 |
85 | /* 39 */ MCD::OPC_Decode, 198, 3, 0, // Opcode: NOP |
86 | /* 43 */ MCD::OPC_FilterValue, 1, 9, 0, 0, // Skip to: 57 |
87 | /* 48 */ MCD::OPC_CheckPredicate, 0, 38, 5, 0, // Skip to: 1371 |
88 | /* 53 */ MCD::OPC_Decode, 193, 3, 1, // Opcode: MOVWRdRr |
89 | /* 57 */ MCD::OPC_FilterValue, 2, 9, 0, 0, // Skip to: 71 |
90 | /* 62 */ MCD::OPC_CheckPredicate, 1, 24, 5, 0, // Skip to: 1371 |
91 | /* 67 */ MCD::OPC_Decode, 195, 3, 2, // Opcode: MULSRdRr |
92 | /* 71 */ MCD::OPC_FilterValue, 3, 15, 5, 0, // Skip to: 1371 |
93 | /* 76 */ MCD::OPC_ExtractField, 3, 1, // Inst{3} ... |
94 | /* 79 */ MCD::OPC_FilterValue, 0, 16, 0, 0, // Skip to: 100 |
95 | /* 84 */ MCD::OPC_CheckPredicate, 1, 47, 0, 0, // Skip to: 136 |
96 | /* 89 */ MCD::OPC_CheckField, 7, 1, 1, 40, 0, 0, // Skip to: 136 |
97 | /* 96 */ MCD::OPC_Decode, 171, 3, 3, // Opcode: FMULS |
98 | /* 100 */ MCD::OPC_FilterValue, 1, 31, 0, 0, // Skip to: 136 |
99 | /* 105 */ MCD::OPC_ExtractField, 7, 1, // Inst{7} ... |
100 | /* 108 */ MCD::OPC_FilterValue, 0, 9, 0, 0, // Skip to: 122 |
101 | /* 113 */ MCD::OPC_CheckPredicate, 1, 18, 0, 0, // Skip to: 136 |
102 | /* 118 */ MCD::OPC_Decode, 170, 3, 3, // Opcode: FMUL |
103 | /* 122 */ MCD::OPC_FilterValue, 1, 9, 0, 0, // Skip to: 136 |
104 | /* 127 */ MCD::OPC_CheckPredicate, 1, 4, 0, 0, // Skip to: 136 |
105 | /* 132 */ MCD::OPC_Decode, 172, 3, 3, // Opcode: FMULSU |
106 | /* 136 */ MCD::OPC_CheckPredicate, 1, 206, 4, 0, // Skip to: 1371 |
107 | /* 141 */ MCD::OPC_Decode, 196, 3, 2, // Opcode: MULSURdRr |
108 | /* 145 */ MCD::OPC_FilterValue, 1, 4, 0, 0, // Skip to: 154 |
109 | /* 150 */ MCD::OPC_Decode, 158, 3, 4, // Opcode: CPCRdRr |
110 | /* 154 */ MCD::OPC_FilterValue, 2, 4, 0, 0, // Skip to: 163 |
111 | /* 159 */ MCD::OPC_Decode, 210, 3, 5, // Opcode: SBCRdRr |
112 | /* 163 */ MCD::OPC_FilterValue, 3, 179, 4, 0, // Skip to: 1371 |
113 | /* 168 */ MCD::OPC_Decode, 135, 3, 5, // Opcode: ADDRdRr |
114 | /* 172 */ MCD::OPC_FilterValue, 1, 39, 0, 0, // Skip to: 216 |
115 | /* 177 */ MCD::OPC_ExtractField, 10, 2, // Inst{11-10} ... |
116 | /* 180 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 189 |
117 | /* 185 */ MCD::OPC_Decode, 161, 3, 4, // Opcode: CPSE |
118 | /* 189 */ MCD::OPC_FilterValue, 1, 4, 0, 0, // Skip to: 198 |
119 | /* 194 */ MCD::OPC_Decode, 160, 3, 4, // Opcode: CPRdRr |
120 | /* 198 */ MCD::OPC_FilterValue, 2, 4, 0, 0, // Skip to: 207 |
121 | /* 203 */ MCD::OPC_Decode, 227, 3, 5, // Opcode: SUBRdRr |
122 | /* 207 */ MCD::OPC_FilterValue, 3, 135, 4, 0, // Skip to: 1371 |
123 | /* 212 */ MCD::OPC_Decode, 134, 3, 5, // Opcode: ADCRdRr |
124 | /* 216 */ MCD::OPC_FilterValue, 2, 39, 0, 0, // Skip to: 260 |
125 | /* 221 */ MCD::OPC_ExtractField, 10, 2, // Inst{11-10} ... |
126 | /* 224 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 233 |
127 | /* 229 */ MCD::OPC_Decode, 138, 3, 5, // Opcode: ANDRdRr |
128 | /* 233 */ MCD::OPC_FilterValue, 1, 4, 0, 0, // Skip to: 242 |
129 | /* 238 */ MCD::OPC_Decode, 169, 3, 5, // Opcode: EORRdRr |
130 | /* 242 */ MCD::OPC_FilterValue, 2, 4, 0, 0, // Skip to: 251 |
131 | /* 247 */ MCD::OPC_Decode, 200, 3, 5, // Opcode: ORRdRr |
132 | /* 251 */ MCD::OPC_FilterValue, 3, 91, 4, 0, // Skip to: 1371 |
133 | /* 256 */ MCD::OPC_Decode, 192, 3, 4, // Opcode: MOVRdRr |
134 | /* 260 */ MCD::OPC_FilterValue, 3, 82, 4, 0, // Skip to: 1371 |
135 | /* 265 */ MCD::OPC_Decode, 159, 3, 6, // Opcode: CPIRdK |
136 | /* 269 */ MCD::OPC_FilterValue, 1, 39, 0, 0, // Skip to: 313 |
137 | /* 274 */ MCD::OPC_ExtractField, 12, 2, // Inst{13-12} ... |
138 | /* 277 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 286 |
139 | /* 282 */ MCD::OPC_Decode, 209, 3, 7, // Opcode: SBCIRdK |
140 | /* 286 */ MCD::OPC_FilterValue, 1, 4, 0, 0, // Skip to: 295 |
141 | /* 291 */ MCD::OPC_Decode, 226, 3, 7, // Opcode: SUBIRdK |
142 | /* 295 */ MCD::OPC_FilterValue, 2, 4, 0, 0, // Skip to: 304 |
143 | /* 300 */ MCD::OPC_Decode, 199, 3, 7, // Opcode: ORIRdK |
144 | /* 304 */ MCD::OPC_FilterValue, 3, 38, 4, 0, // Skip to: 1371 |
145 | /* 309 */ MCD::OPC_Decode, 137, 3, 7, // Opcode: ANDIRdK |
146 | /* 313 */ MCD::OPC_FilterValue, 2, 66, 3, 0, // Skip to: 1152 |
147 | /* 318 */ MCD::OPC_ExtractField, 12, 1, // Inst{12} ... |
148 | /* 321 */ MCD::OPC_FilterValue, 0, 205, 0, 0, // Skip to: 531 |
149 | /* 326 */ MCD::OPC_ExtractField, 9, 1, // Inst{9} ... |
150 | /* 329 */ MCD::OPC_FilterValue, 0, 96, 0, 0, // Skip to: 430 |
151 | /* 334 */ MCD::OPC_ExtractField, 0, 2, // Inst{1-0} ... |
152 | /* 337 */ MCD::OPC_FilterValue, 0, 23, 0, 0, // Skip to: 365 |
153 | /* 342 */ MCD::OPC_CheckPredicate, 2, 74, 0, 0, // Skip to: 421 |
154 | /* 347 */ MCD::OPC_CheckField, 13, 1, 0, 67, 0, 0, // Skip to: 421 |
155 | /* 354 */ MCD::OPC_CheckField, 10, 2, 0, 60, 0, 0, // Skip to: 421 |
156 | /* 361 */ MCD::OPC_Decode, 183, 3, 8, // Opcode: LDRdPtr |
157 | /* 365 */ MCD::OPC_FilterValue, 1, 23, 0, 0, // Skip to: 393 |
158 | /* 370 */ MCD::OPC_CheckPredicate, 2, 46, 0, 0, // Skip to: 421 |
159 | /* 375 */ MCD::OPC_CheckField, 13, 1, 0, 39, 0, 0, // Skip to: 421 |
160 | /* 382 */ MCD::OPC_CheckField, 10, 2, 0, 32, 0, 0, // Skip to: 421 |
161 | /* 389 */ MCD::OPC_Decode, 185, 3, 8, // Opcode: LDRdPtrPi |
162 | /* 393 */ MCD::OPC_FilterValue, 2, 23, 0, 0, // Skip to: 421 |
163 | /* 398 */ MCD::OPC_CheckPredicate, 2, 18, 0, 0, // Skip to: 421 |
164 | /* 403 */ MCD::OPC_CheckField, 13, 1, 0, 11, 0, 0, // Skip to: 421 |
165 | /* 410 */ MCD::OPC_CheckField, 10, 2, 0, 4, 0, 0, // Skip to: 421 |
166 | /* 417 */ MCD::OPC_Decode, 184, 3, 8, // Opcode: LDRdPtrPd |
167 | /* 421 */ MCD::OPC_CheckPredicate, 3, 177, 3, 0, // Skip to: 1371 |
168 | /* 426 */ MCD::OPC_Decode, 181, 3, 9, // Opcode: LDDRdPtrQ |
169 | /* 430 */ MCD::OPC_FilterValue, 1, 168, 3, 0, // Skip to: 1371 |
170 | /* 435 */ MCD::OPC_ExtractField, 0, 2, // Inst{1-0} ... |
171 | /* 438 */ MCD::OPC_FilterValue, 0, 23, 0, 0, // Skip to: 466 |
172 | /* 443 */ MCD::OPC_CheckPredicate, 2, 74, 0, 0, // Skip to: 522 |
173 | /* 448 */ MCD::OPC_CheckField, 13, 1, 0, 67, 0, 0, // Skip to: 522 |
174 | /* 455 */ MCD::OPC_CheckField, 10, 2, 0, 60, 0, 0, // Skip to: 522 |
175 | /* 462 */ MCD::OPC_Decode, 223, 3, 8, // Opcode: STPtrRr |
176 | /* 466 */ MCD::OPC_FilterValue, 1, 23, 0, 0, // Skip to: 494 |
177 | /* 471 */ MCD::OPC_CheckPredicate, 2, 46, 0, 0, // Skip to: 522 |
178 | /* 476 */ MCD::OPC_CheckField, 13, 1, 0, 39, 0, 0, // Skip to: 522 |
179 | /* 483 */ MCD::OPC_CheckField, 10, 2, 0, 32, 0, 0, // Skip to: 522 |
180 | /* 490 */ MCD::OPC_Decode, 222, 3, 8, // Opcode: STPtrPiRr |
181 | /* 494 */ MCD::OPC_FilterValue, 2, 23, 0, 0, // Skip to: 522 |
182 | /* 499 */ MCD::OPC_CheckPredicate, 2, 18, 0, 0, // Skip to: 522 |
183 | /* 504 */ MCD::OPC_CheckField, 13, 1, 0, 11, 0, 0, // Skip to: 522 |
184 | /* 511 */ MCD::OPC_CheckField, 10, 2, 0, 4, 0, 0, // Skip to: 522 |
185 | /* 518 */ MCD::OPC_Decode, 221, 3, 8, // Opcode: STPtrPdRr |
186 | /* 522 */ MCD::OPC_CheckPredicate, 3, 76, 3, 0, // Skip to: 1371 |
187 | /* 527 */ MCD::OPC_Decode, 220, 3, 10, // Opcode: STDPtrQRr |
188 | /* 531 */ MCD::OPC_FilterValue, 1, 67, 3, 0, // Skip to: 1371 |
189 | /* 536 */ MCD::OPC_ExtractField, 11, 1, // Inst{11} ... |
190 | /* 539 */ MCD::OPC_FilterValue, 0, 13, 2, 0, // Skip to: 1069 |
191 | /* 544 */ MCD::OPC_ExtractField, 13, 1, // Inst{13} ... |
192 | /* 547 */ MCD::OPC_FilterValue, 0, 252, 1, 0, // Skip to: 1060 |
193 | /* 552 */ MCD::OPC_ExtractField, 9, 2, // Inst{10-9} ... |
194 | /* 555 */ MCD::OPC_FilterValue, 0, 73, 0, 0, // Skip to: 633 |
195 | /* 560 */ MCD::OPC_ExtractField, 0, 4, // Inst{3-0} ... |
196 | /* 563 */ MCD::OPC_FilterValue, 4, 9, 0, 0, // Skip to: 577 |
197 | /* 568 */ MCD::OPC_CheckPredicate, 4, 30, 3, 0, // Skip to: 1371 |
198 | /* 573 */ MCD::OPC_Decode, 189, 3, 11, // Opcode: LPMRdZ |
199 | /* 577 */ MCD::OPC_FilterValue, 5, 9, 0, 0, // Skip to: 591 |
200 | /* 582 */ MCD::OPC_CheckPredicate, 4, 16, 3, 0, // Skip to: 1371 |
201 | /* 587 */ MCD::OPC_Decode, 190, 3, 11, // Opcode: LPMRdZPi |
202 | /* 591 */ MCD::OPC_FilterValue, 6, 9, 0, 0, // Skip to: 605 |
203 | /* 596 */ MCD::OPC_CheckPredicate, 5, 2, 3, 0, // Skip to: 1371 |
204 | /* 601 */ MCD::OPC_Decode, 167, 3, 11, // Opcode: ELPMRdZ |
205 | /* 605 */ MCD::OPC_FilterValue, 7, 9, 0, 0, // Skip to: 619 |
206 | /* 610 */ MCD::OPC_CheckPredicate, 5, 244, 2, 0, // Skip to: 1371 |
207 | /* 615 */ MCD::OPC_Decode, 168, 3, 11, // Opcode: ELPMRdZPi |
208 | /* 619 */ MCD::OPC_FilterValue, 15, 235, 2, 0, // Skip to: 1371 |
209 | /* 624 */ MCD::OPC_CheckPredicate, 2, 230, 2, 0, // Skip to: 1371 |
210 | /* 629 */ MCD::OPC_Decode, 202, 3, 12, // Opcode: POPRd |
211 | /* 633 */ MCD::OPC_FilterValue, 1, 73, 0, 0, // Skip to: 711 |
212 | /* 638 */ MCD::OPC_ExtractField, 0, 4, // Inst{3-0} ... |
213 | /* 641 */ MCD::OPC_FilterValue, 4, 9, 0, 0, // Skip to: 655 |
214 | /* 646 */ MCD::OPC_CheckPredicate, 6, 208, 2, 0, // Skip to: 1371 |
215 | /* 651 */ MCD::OPC_Decode, 230, 3, 13, // Opcode: XCHZRd |
216 | /* 655 */ MCD::OPC_FilterValue, 5, 9, 0, 0, // Skip to: 669 |
217 | /* 660 */ MCD::OPC_CheckPredicate, 6, 194, 2, 0, // Skip to: 1371 |
218 | /* 665 */ MCD::OPC_Decode, 179, 3, 13, // Opcode: LASZRd |
219 | /* 669 */ MCD::OPC_FilterValue, 6, 9, 0, 0, // Skip to: 683 |
220 | /* 674 */ MCD::OPC_CheckPredicate, 6, 180, 2, 0, // Skip to: 1371 |
221 | /* 679 */ MCD::OPC_Decode, 178, 3, 13, // Opcode: LACZRd |
222 | /* 683 */ MCD::OPC_FilterValue, 7, 9, 0, 0, // Skip to: 697 |
223 | /* 688 */ MCD::OPC_CheckPredicate, 6, 166, 2, 0, // Skip to: 1371 |
224 | /* 693 */ MCD::OPC_Decode, 180, 3, 13, // Opcode: LATZRd |
225 | /* 697 */ MCD::OPC_FilterValue, 15, 157, 2, 0, // Skip to: 1371 |
226 | /* 702 */ MCD::OPC_CheckPredicate, 2, 152, 2, 0, // Skip to: 1371 |
227 | /* 707 */ MCD::OPC_Decode, 203, 3, 12, // Opcode: PUSHRr |
228 | /* 711 */ MCD::OPC_FilterValue, 2, 52, 1, 0, // Skip to: 1024 |
229 | /* 716 */ MCD::OPC_ExtractField, 0, 4, // Inst{3-0} ... |
230 | /* 719 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 728 |
231 | /* 724 */ MCD::OPC_Decode, 157, 3, 12, // Opcode: COMRd |
232 | /* 728 */ MCD::OPC_FilterValue, 1, 4, 0, 0, // Skip to: 737 |
233 | /* 733 */ MCD::OPC_Decode, 197, 3, 12, // Opcode: NEGRd |
234 | /* 737 */ MCD::OPC_FilterValue, 2, 4, 0, 0, // Skip to: 746 |
235 | /* 742 */ MCD::OPC_Decode, 228, 3, 12, // Opcode: SWAPRd |
236 | /* 746 */ MCD::OPC_FilterValue, 3, 4, 0, 0, // Skip to: 755 |
237 | /* 751 */ MCD::OPC_Decode, 175, 3, 12, // Opcode: INCRd |
238 | /* 755 */ MCD::OPC_FilterValue, 5, 4, 0, 0, // Skip to: 764 |
239 | /* 760 */ MCD::OPC_Decode, 139, 3, 12, // Opcode: ASRRd |
240 | /* 764 */ MCD::OPC_FilterValue, 6, 4, 0, 0, // Skip to: 773 |
241 | /* 769 */ MCD::OPC_Decode, 191, 3, 12, // Opcode: LSRRd |
242 | /* 773 */ MCD::OPC_FilterValue, 7, 4, 0, 0, // Skip to: 782 |
243 | /* 778 */ MCD::OPC_Decode, 208, 3, 12, // Opcode: RORRd |
244 | /* 782 */ MCD::OPC_FilterValue, 8, 143, 0, 0, // Skip to: 930 |
245 | /* 787 */ MCD::OPC_ExtractField, 7, 2, // Inst{8-7} ... |
246 | /* 790 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 799 |
247 | /* 795 */ MCD::OPC_Decode, 153, 3, 14, // Opcode: BSETs |
248 | /* 799 */ MCD::OPC_FilterValue, 1, 4, 0, 0, // Skip to: 808 |
249 | /* 804 */ MCD::OPC_Decode, 140, 3, 14, // Opcode: BCLRs |
250 | /* 808 */ MCD::OPC_FilterValue, 2, 21, 0, 0, // Skip to: 834 |
251 | /* 813 */ MCD::OPC_ExtractField, 4, 3, // Inst{6-4} ... |
252 | /* 816 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 825 |
253 | /* 821 */ MCD::OPC_Decode, 205, 3, 0, // Opcode: RET |
254 | /* 825 */ MCD::OPC_FilterValue, 1, 29, 2, 0, // Skip to: 1371 |
255 | /* 830 */ MCD::OPC_Decode, 206, 3, 0, // Opcode: RETI |
256 | /* 834 */ MCD::OPC_FilterValue, 3, 20, 2, 0, // Skip to: 1371 |
257 | /* 839 */ MCD::OPC_ExtractField, 4, 3, // Inst{6-4} ... |
258 | /* 842 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 851 |
259 | /* 847 */ MCD::OPC_Decode, 217, 3, 0, // Opcode: SLEEP |
260 | /* 851 */ MCD::OPC_FilterValue, 1, 9, 0, 0, // Skip to: 865 |
261 | /* 856 */ MCD::OPC_CheckPredicate, 7, 254, 1, 0, // Skip to: 1371 |
262 | /* 861 */ MCD::OPC_Decode, 144, 3, 0, // Opcode: BREAK |
263 | /* 865 */ MCD::OPC_FilterValue, 2, 4, 0, 0, // Skip to: 874 |
264 | /* 870 */ MCD::OPC_Decode, 229, 3, 0, // Opcode: WDR |
265 | /* 874 */ MCD::OPC_FilterValue, 4, 9, 0, 0, // Skip to: 888 |
266 | /* 879 */ MCD::OPC_CheckPredicate, 8, 231, 1, 0, // Skip to: 1371 |
267 | /* 884 */ MCD::OPC_Decode, 188, 3, 0, // Opcode: LPM |
268 | /* 888 */ MCD::OPC_FilterValue, 5, 9, 0, 0, // Skip to: 902 |
269 | /* 893 */ MCD::OPC_CheckPredicate, 9, 217, 1, 0, // Skip to: 1371 |
270 | /* 898 */ MCD::OPC_Decode, 166, 3, 0, // Opcode: ELPM |
271 | /* 902 */ MCD::OPC_FilterValue, 6, 9, 0, 0, // Skip to: 916 |
272 | /* 907 */ MCD::OPC_CheckPredicate, 10, 203, 1, 0, // Skip to: 1371 |
273 | /* 912 */ MCD::OPC_Decode, 218, 3, 0, // Opcode: SPM |
274 | /* 916 */ MCD::OPC_FilterValue, 7, 194, 1, 0, // Skip to: 1371 |
275 | /* 921 */ MCD::OPC_CheckPredicate, 11, 189, 1, 0, // Skip to: 1371 |
276 | /* 926 */ MCD::OPC_Decode, 219, 3, 0, // Opcode: SPMZPi |
277 | /* 930 */ MCD::OPC_FilterValue, 9, 59, 0, 0, // Skip to: 994 |
278 | /* 935 */ MCD::OPC_ExtractField, 4, 5, // Inst{8-4} ... |
279 | /* 938 */ MCD::OPC_FilterValue, 0, 9, 0, 0, // Skip to: 952 |
280 | /* 943 */ MCD::OPC_CheckPredicate, 12, 167, 1, 0, // Skip to: 1371 |
281 | /* 948 */ MCD::OPC_Decode, 174, 3, 0, // Opcode: IJMP |
282 | /* 952 */ MCD::OPC_FilterValue, 1, 9, 0, 0, // Skip to: 966 |
283 | /* 957 */ MCD::OPC_CheckPredicate, 13, 153, 1, 0, // Skip to: 1371 |
284 | /* 962 */ MCD::OPC_Decode, 165, 3, 0, // Opcode: EIJMP |
285 | /* 966 */ MCD::OPC_FilterValue, 16, 9, 0, 0, // Skip to: 980 |
286 | /* 971 */ MCD::OPC_CheckPredicate, 12, 139, 1, 0, // Skip to: 1371 |
287 | /* 976 */ MCD::OPC_Decode, 173, 3, 0, // Opcode: ICALL |
288 | /* 980 */ MCD::OPC_FilterValue, 17, 130, 1, 0, // Skip to: 1371 |
289 | /* 985 */ MCD::OPC_CheckPredicate, 13, 125, 1, 0, // Skip to: 1371 |
290 | /* 990 */ MCD::OPC_Decode, 164, 3, 0, // Opcode: EICALL |
291 | /* 994 */ MCD::OPC_FilterValue, 10, 4, 0, 0, // Skip to: 1003 |
292 | /* 999 */ MCD::OPC_Decode, 162, 3, 12, // Opcode: DECRd |
293 | /* 1003 */ MCD::OPC_FilterValue, 11, 107, 1, 0, // Skip to: 1371 |
294 | /* 1008 */ MCD::OPC_CheckPredicate, 14, 102, 1, 0, // Skip to: 1371 |
295 | /* 1013 */ MCD::OPC_CheckField, 8, 1, 0, 95, 1, 0, // Skip to: 1371 |
296 | /* 1020 */ MCD::OPC_Decode, 163, 3, 15, // Opcode: DESK |
297 | /* 1024 */ MCD::OPC_FilterValue, 3, 86, 1, 0, // Skip to: 1371 |
298 | /* 1029 */ MCD::OPC_ExtractField, 8, 1, // Inst{8} ... |
299 | /* 1032 */ MCD::OPC_FilterValue, 0, 9, 0, 0, // Skip to: 1046 |
300 | /* 1037 */ MCD::OPC_CheckPredicate, 15, 73, 1, 0, // Skip to: 1371 |
301 | /* 1042 */ MCD::OPC_Decode, 136, 3, 16, // Opcode: ADIWRdK |
302 | /* 1046 */ MCD::OPC_FilterValue, 1, 64, 1, 0, // Skip to: 1371 |
303 | /* 1051 */ MCD::OPC_CheckPredicate, 15, 59, 1, 0, // Skip to: 1371 |
304 | /* 1056 */ MCD::OPC_Decode, 214, 3, 16, // Opcode: SBIWRdK |
305 | /* 1060 */ MCD::OPC_FilterValue, 1, 50, 1, 0, // Skip to: 1371 |
306 | /* 1065 */ MCD::OPC_Decode, 176, 3, 17, // Opcode: INRdA |
307 | /* 1069 */ MCD::OPC_FilterValue, 1, 41, 1, 0, // Skip to: 1371 |
308 | /* 1074 */ MCD::OPC_ExtractField, 13, 1, // Inst{13} ... |
309 | /* 1077 */ MCD::OPC_FilterValue, 0, 61, 0, 0, // Skip to: 1143 |
310 | /* 1082 */ MCD::OPC_ExtractField, 10, 1, // Inst{10} ... |
311 | /* 1085 */ MCD::OPC_FilterValue, 0, 39, 0, 0, // Skip to: 1129 |
312 | /* 1090 */ MCD::OPC_ExtractField, 8, 2, // Inst{9-8} ... |
313 | /* 1093 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 1102 |
314 | /* 1098 */ MCD::OPC_Decode, 156, 3, 18, // Opcode: CBIAb |
315 | /* 1102 */ MCD::OPC_FilterValue, 1, 4, 0, 0, // Skip to: 1111 |
316 | /* 1107 */ MCD::OPC_Decode, 212, 3, 18, // Opcode: SBICAb |
317 | /* 1111 */ MCD::OPC_FilterValue, 2, 4, 0, 0, // Skip to: 1120 |
318 | /* 1116 */ MCD::OPC_Decode, 211, 3, 18, // Opcode: SBIAb |
319 | /* 1120 */ MCD::OPC_FilterValue, 3, 246, 0, 0, // Skip to: 1371 |
320 | /* 1125 */ MCD::OPC_Decode, 213, 3, 18, // Opcode: SBISAb |
321 | /* 1129 */ MCD::OPC_FilterValue, 1, 237, 0, 0, // Skip to: 1371 |
322 | /* 1134 */ MCD::OPC_CheckPredicate, 1, 232, 0, 0, // Skip to: 1371 |
323 | /* 1139 */ MCD::OPC_Decode, 194, 3, 4, // Opcode: MULRdRr |
324 | /* 1143 */ MCD::OPC_FilterValue, 1, 223, 0, 0, // Skip to: 1371 |
325 | /* 1148 */ MCD::OPC_Decode, 201, 3, 19, // Opcode: OUTARr |
326 | /* 1152 */ MCD::OPC_FilterValue, 3, 214, 0, 0, // Skip to: 1371 |
327 | /* 1157 */ MCD::OPC_ExtractField, 12, 2, // Inst{13-12} ... |
328 | /* 1160 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 1169 |
329 | /* 1165 */ MCD::OPC_Decode, 207, 3, 20, // Opcode: RJMPk |
330 | /* 1169 */ MCD::OPC_FilterValue, 1, 4, 0, 0, // Skip to: 1178 |
331 | /* 1174 */ MCD::OPC_Decode, 204, 3, 20, // Opcode: RCALLk |
332 | /* 1178 */ MCD::OPC_FilterValue, 2, 4, 0, 0, // Skip to: 1187 |
333 | /* 1183 */ MCD::OPC_Decode, 182, 3, 6, // Opcode: LDIRdK |
334 | /* 1187 */ MCD::OPC_FilterValue, 3, 179, 0, 0, // Skip to: 1371 |
335 | /* 1192 */ MCD::OPC_ExtractField, 10, 2, // Inst{11-10} ... |
336 | /* 1195 */ MCD::OPC_FilterValue, 0, 43, 0, 0, // Skip to: 1243 |
337 | /* 1200 */ MCD::OPC_ExtractField, 0, 3, // Inst{2-0} ... |
338 | /* 1203 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 1212 |
339 | /* 1208 */ MCD::OPC_Decode, 147, 3, 21, // Opcode: BRLOk |
340 | /* 1212 */ MCD::OPC_FilterValue, 1, 4, 0, 0, // Skip to: 1221 |
341 | /* 1217 */ MCD::OPC_Decode, 145, 3, 21, // Opcode: BREQk |
342 | /* 1221 */ MCD::OPC_FilterValue, 2, 4, 0, 0, // Skip to: 1230 |
343 | /* 1226 */ MCD::OPC_Decode, 149, 3, 21, // Opcode: BRMIk |
344 | /* 1230 */ MCD::OPC_FilterValue, 4, 4, 0, 0, // Skip to: 1239 |
345 | /* 1235 */ MCD::OPC_Decode, 148, 3, 21, // Opcode: BRLTk |
346 | /* 1239 */ MCD::OPC_Decode, 143, 3, 21, // Opcode: BRBSsk |
347 | /* 1243 */ MCD::OPC_FilterValue, 1, 43, 0, 0, // Skip to: 1291 |
348 | /* 1248 */ MCD::OPC_ExtractField, 0, 3, // Inst{2-0} ... |
349 | /* 1251 */ MCD::OPC_FilterValue, 0, 4, 0, 0, // Skip to: 1260 |
350 | /* 1256 */ MCD::OPC_Decode, 152, 3, 21, // Opcode: BRSHk |
351 | /* 1260 */ MCD::OPC_FilterValue, 1, 4, 0, 0, // Skip to: 1269 |
352 | /* 1265 */ MCD::OPC_Decode, 150, 3, 21, // Opcode: BRNEk |
353 | /* 1269 */ MCD::OPC_FilterValue, 2, 4, 0, 0, // Skip to: 1278 |
354 | /* 1274 */ MCD::OPC_Decode, 151, 3, 21, // Opcode: BRPLk |
355 | /* 1278 */ MCD::OPC_FilterValue, 4, 4, 0, 0, // Skip to: 1287 |
356 | /* 1283 */ MCD::OPC_Decode, 146, 3, 21, // Opcode: BRGEk |
357 | /* 1287 */ MCD::OPC_Decode, 142, 3, 21, // Opcode: BRBCsk |
358 | /* 1291 */ MCD::OPC_FilterValue, 2, 35, 0, 0, // Skip to: 1331 |
359 | /* 1296 */ MCD::OPC_ExtractField, 9, 1, // Inst{9} ... |
360 | /* 1299 */ MCD::OPC_FilterValue, 0, 11, 0, 0, // Skip to: 1315 |
361 | /* 1304 */ MCD::OPC_CheckField, 3, 1, 0, 60, 0, 0, // Skip to: 1371 |
362 | /* 1311 */ MCD::OPC_Decode, 141, 3, 22, // Opcode: BLD |
363 | /* 1315 */ MCD::OPC_FilterValue, 1, 51, 0, 0, // Skip to: 1371 |
364 | /* 1320 */ MCD::OPC_CheckField, 3, 1, 0, 44, 0, 0, // Skip to: 1371 |
365 | /* 1327 */ MCD::OPC_Decode, 154, 3, 23, // Opcode: BST |
366 | /* 1331 */ MCD::OPC_FilterValue, 3, 35, 0, 0, // Skip to: 1371 |
367 | /* 1336 */ MCD::OPC_ExtractField, 9, 1, // Inst{9} ... |
368 | /* 1339 */ MCD::OPC_FilterValue, 0, 11, 0, 0, // Skip to: 1355 |
369 | /* 1344 */ MCD::OPC_CheckField, 3, 1, 0, 20, 0, 0, // Skip to: 1371 |
370 | /* 1351 */ MCD::OPC_Decode, 215, 3, 23, // Opcode: SBRCRrB |
371 | /* 1355 */ MCD::OPC_FilterValue, 1, 11, 0, 0, // Skip to: 1371 |
372 | /* 1360 */ MCD::OPC_CheckField, 3, 1, 0, 4, 0, 0, // Skip to: 1371 |
373 | /* 1367 */ MCD::OPC_Decode, 216, 3, 23, // Opcode: SBRSRrB |
374 | /* 1371 */ MCD::OPC_Fail, |
375 | 0 |
376 | }; |
377 | |
378 | static const uint8_t DecoderTable32[] = { |
379 | /* 0 */ MCD::OPC_ExtractField, 17, 3, // Inst{19-17} ... |
380 | /* 3 */ MCD::OPC_FilterValue, 0, 45, 0, 0, // Skip to: 53 |
381 | /* 8 */ MCD::OPC_ExtractField, 25, 7, // Inst{31-25} ... |
382 | /* 11 */ MCD::OPC_FilterValue, 72, 16, 0, 0, // Skip to: 32 |
383 | /* 16 */ MCD::OPC_CheckPredicate, 3, 74, 0, 0, // Skip to: 95 |
384 | /* 21 */ MCD::OPC_CheckField, 16, 1, 0, 67, 0, 0, // Skip to: 95 |
385 | /* 28 */ MCD::OPC_Decode, 186, 3, 24, // Opcode: LDSRdK |
386 | /* 32 */ MCD::OPC_FilterValue, 73, 58, 0, 0, // Skip to: 95 |
387 | /* 37 */ MCD::OPC_CheckPredicate, 3, 53, 0, 0, // Skip to: 95 |
388 | /* 42 */ MCD::OPC_CheckField, 16, 1, 0, 46, 0, 0, // Skip to: 95 |
389 | /* 49 */ MCD::OPC_Decode, 224, 3, 25, // Opcode: STSKRr |
390 | /* 53 */ MCD::OPC_FilterValue, 6, 16, 0, 0, // Skip to: 74 |
391 | /* 58 */ MCD::OPC_CheckPredicate, 16, 32, 0, 0, // Skip to: 95 |
392 | /* 63 */ MCD::OPC_CheckField, 25, 7, 74, 25, 0, 0, // Skip to: 95 |
393 | /* 70 */ MCD::OPC_Decode, 177, 3, 26, // Opcode: JMPk |
394 | /* 74 */ MCD::OPC_FilterValue, 7, 16, 0, 0, // Skip to: 95 |
395 | /* 79 */ MCD::OPC_CheckPredicate, 16, 11, 0, 0, // Skip to: 95 |
396 | /* 84 */ MCD::OPC_CheckField, 25, 7, 74, 4, 0, 0, // Skip to: 95 |
397 | /* 91 */ MCD::OPC_Decode, 155, 3, 26, // Opcode: CALLk |
398 | /* 95 */ MCD::OPC_Fail, |
399 | 0 |
400 | }; |
401 | |
402 | static const uint8_t DecoderTableAVRTiny16[] = { |
403 | /* 0 */ MCD::OPC_ExtractField, 11, 5, // Inst{15-11} ... |
404 | /* 3 */ MCD::OPC_FilterValue, 20, 9, 0, 0, // Skip to: 17 |
405 | /* 8 */ MCD::OPC_CheckPredicate, 17, 18, 0, 0, // Skip to: 31 |
406 | /* 13 */ MCD::OPC_Decode, 187, 3, 27, // Opcode: LDSRdKTiny |
407 | /* 17 */ MCD::OPC_FilterValue, 21, 9, 0, 0, // Skip to: 31 |
408 | /* 22 */ MCD::OPC_CheckPredicate, 17, 4, 0, 0, // Skip to: 31 |
409 | /* 27 */ MCD::OPC_Decode, 225, 3, 28, // Opcode: STSKRrTiny |
410 | /* 31 */ MCD::OPC_Fail, |
411 | 0 |
412 | }; |
413 | |
414 | static bool checkDecoderPredicate(unsigned Idx, const FeatureBitset &Bits) { |
415 | switch (Idx) { |
416 | default: llvm_unreachable("Invalid index!" ); |
417 | case 0: |
418 | return (Bits[AVR::FeatureMOVW]); |
419 | case 1: |
420 | return (Bits[AVR::FeatureMultiplication]); |
421 | case 2: |
422 | return (Bits[AVR::FeatureSRAM]); |
423 | case 3: |
424 | return (Bits[AVR::FeatureSRAM] && !Bits[AVR::FeatureTinyEncoding]); |
425 | case 4: |
426 | return (Bits[AVR::FeatureLPMX]); |
427 | case 5: |
428 | return (Bits[AVR::FeatureELPMX]); |
429 | case 6: |
430 | return (Bits[AVR::FeatureRMW]); |
431 | case 7: |
432 | return (Bits[AVR::FeatureBREAK]); |
433 | case 8: |
434 | return (Bits[AVR::FeatureLPM]); |
435 | case 9: |
436 | return (Bits[AVR::FeatureELPM]); |
437 | case 10: |
438 | return (Bits[AVR::FeatureSPM]); |
439 | case 11: |
440 | return (Bits[AVR::FeatureSPMX]); |
441 | case 12: |
442 | return (Bits[AVR::FeatureIJMPCALL]); |
443 | case 13: |
444 | return (Bits[AVR::FeatureEIJMPCALL]); |
445 | case 14: |
446 | return (Bits[AVR::FeatureDES]); |
447 | case 15: |
448 | return (Bits[AVR::FeatureADDSUBIW]); |
449 | case 16: |
450 | return (Bits[AVR::FeatureJMPCALL]); |
451 | case 17: |
452 | return (Bits[AVR::FeatureSRAM] && Bits[AVR::FeatureTinyEncoding]); |
453 | } |
454 | } |
455 | |
456 | template <typename InsnType> |
457 | static DecodeStatus decodeToMCInst(DecodeStatus S, unsigned Idx, InsnType insn, MCInst &MI, |
458 | uint64_t Address, const MCDisassembler *Decoder, bool &DecodeComplete) { |
459 | DecodeComplete = true; |
460 | using TmpType = std::conditional_t<std::is_integral<InsnType>::value, InsnType, uint64_t>; |
461 | TmpType tmp; |
462 | switch (Idx) { |
463 | default: llvm_unreachable("Invalid index!" ); |
464 | case 0: |
465 | return S; |
466 | case 1: |
467 | if (!Check(S, decodeFMOVWRdRr(MI, insn, Address, Decoder))) { return MCDisassembler::Fail; } |
468 | return S; |
469 | case 2: |
470 | if (!Check(S, decodeFMUL2RdRr(MI, insn, Address, Decoder))) { return MCDisassembler::Fail; } |
471 | return S; |
472 | case 3: |
473 | if (!Check(S, decodeFFMULRdRr(MI, insn, Address, Decoder))) { return MCDisassembler::Fail; } |
474 | return S; |
475 | case 4: |
476 | tmp = fieldFromInstruction(insn, 4, 5); |
477 | if (!Check(S, DecodeGPR8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
478 | tmp = 0x0; |
479 | insertBits(tmp, fieldFromInstruction(insn, 0, 4), 0, 4); |
480 | insertBits(tmp, fieldFromInstruction(insn, 9, 1), 4, 1); |
481 | if (!Check(S, DecodeGPR8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
482 | return S; |
483 | case 5: |
484 | tmp = fieldFromInstruction(insn, 4, 5); |
485 | if (!Check(S, DecodeGPR8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
486 | tmp = fieldFromInstruction(insn, 4, 5); |
487 | if (!Check(S, DecodeGPR8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
488 | tmp = 0x0; |
489 | insertBits(tmp, fieldFromInstruction(insn, 0, 4), 0, 4); |
490 | insertBits(tmp, fieldFromInstruction(insn, 9, 1), 4, 1); |
491 | if (!Check(S, DecodeGPR8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
492 | return S; |
493 | case 6: |
494 | tmp = fieldFromInstruction(insn, 4, 4); |
495 | if (!Check(S, DecodeLD8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
496 | tmp = 0x0; |
497 | insertBits(tmp, fieldFromInstruction(insn, 0, 4), 0, 4); |
498 | insertBits(tmp, fieldFromInstruction(insn, 8, 4), 4, 4); |
499 | MI.addOperand(Op: MCOperand::createImm(Val: tmp)); |
500 | return S; |
501 | case 7: |
502 | tmp = fieldFromInstruction(insn, 4, 4); |
503 | if (!Check(S, DecodeLD8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
504 | tmp = fieldFromInstruction(insn, 4, 4); |
505 | if (!Check(S, DecodeLD8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
506 | tmp = 0x0; |
507 | insertBits(tmp, fieldFromInstruction(insn, 0, 4), 0, 4); |
508 | insertBits(tmp, fieldFromInstruction(insn, 8, 4), 4, 4); |
509 | MI.addOperand(Op: MCOperand::createImm(Val: tmp)); |
510 | return S; |
511 | case 8: |
512 | if (!Check(S, decodeLoadStore(MI, insn, Address, Decoder))) { return MCDisassembler::Fail; } |
513 | return S; |
514 | case 9: |
515 | tmp = fieldFromInstruction(insn, 4, 5); |
516 | if (!Check(S, DecodeGPR8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
517 | tmp = 0x0; |
518 | insertBits(tmp, fieldFromInstruction(insn, 0, 3), 0, 3); |
519 | insertBits(tmp, fieldFromInstruction(insn, 3, 1), 6, 1); |
520 | insertBits(tmp, fieldFromInstruction(insn, 10, 2), 3, 2); |
521 | insertBits(tmp, fieldFromInstruction(insn, 13, 1), 5, 1); |
522 | if (!Check(S, decodeMemri(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
523 | return S; |
524 | case 10: |
525 | tmp = 0x0; |
526 | insertBits(tmp, fieldFromInstruction(insn, 0, 3), 0, 3); |
527 | insertBits(tmp, fieldFromInstruction(insn, 3, 1), 6, 1); |
528 | insertBits(tmp, fieldFromInstruction(insn, 10, 2), 3, 2); |
529 | insertBits(tmp, fieldFromInstruction(insn, 13, 1), 5, 1); |
530 | if (!Check(S, decodeMemri(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
531 | tmp = fieldFromInstruction(insn, 4, 5); |
532 | if (!Check(S, DecodeGPR8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
533 | return S; |
534 | case 11: |
535 | if (!Check(S, decodeFLPMX(MI, insn, Address, Decoder))) { return MCDisassembler::Fail; } |
536 | return S; |
537 | case 12: |
538 | if (!Check(S, decodeFRd(MI, insn, Address, Decoder))) { return MCDisassembler::Fail; } |
539 | return S; |
540 | case 13: |
541 | tmp = fieldFromInstruction(insn, 4, 5); |
542 | if (!Check(S, DecodeGPR8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
543 | return S; |
544 | case 14: |
545 | tmp = fieldFromInstruction(insn, 4, 3); |
546 | MI.addOperand(Op: MCOperand::createImm(Val: tmp)); |
547 | return S; |
548 | case 15: |
549 | tmp = fieldFromInstruction(insn, 4, 4); |
550 | MI.addOperand(Op: MCOperand::createImm(Val: tmp)); |
551 | return S; |
552 | case 16: |
553 | if (!Check(S, decodeFWRdK(MI, insn, Address, Decoder))) { return MCDisassembler::Fail; } |
554 | return S; |
555 | case 17: |
556 | if (!Check(S, decodeFIORdA(MI, insn, Address, Decoder))) { return MCDisassembler::Fail; } |
557 | return S; |
558 | case 18: |
559 | if (!Check(S, decodeFIOBIT(MI, insn, Address, Decoder))) { return MCDisassembler::Fail; } |
560 | return S; |
561 | case 19: |
562 | if (!Check(S, decodeFIOARr(MI, insn, Address, Decoder))) { return MCDisassembler::Fail; } |
563 | return S; |
564 | case 20: |
565 | if (!Check(S, decodeFBRk(MI, insn, Address, Decoder))) { return MCDisassembler::Fail; } |
566 | return S; |
567 | case 21: |
568 | if (!Check(S, decodeCondBranch(MI, insn, Address, Decoder))) { return MCDisassembler::Fail; } |
569 | return S; |
570 | case 22: |
571 | tmp = fieldFromInstruction(insn, 4, 5); |
572 | if (!Check(S, DecodeGPR8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
573 | tmp = fieldFromInstruction(insn, 4, 5); |
574 | if (!Check(S, DecodeGPR8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
575 | tmp = fieldFromInstruction(insn, 0, 3); |
576 | MI.addOperand(Op: MCOperand::createImm(Val: tmp)); |
577 | return S; |
578 | case 23: |
579 | tmp = fieldFromInstruction(insn, 4, 5); |
580 | if (!Check(S, DecodeGPR8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
581 | tmp = fieldFromInstruction(insn, 0, 3); |
582 | MI.addOperand(Op: MCOperand::createImm(Val: tmp)); |
583 | return S; |
584 | case 24: |
585 | tmp = fieldFromInstruction(insn, 20, 5); |
586 | if (!Check(S, DecodeGPR8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
587 | tmp = fieldFromInstruction(insn, 0, 16); |
588 | MI.addOperand(Op: MCOperand::createImm(Val: tmp)); |
589 | return S; |
590 | case 25: |
591 | tmp = fieldFromInstruction(insn, 0, 16); |
592 | MI.addOperand(Op: MCOperand::createImm(Val: tmp)); |
593 | tmp = fieldFromInstruction(insn, 20, 5); |
594 | if (!Check(S, DecodeGPR8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
595 | return S; |
596 | case 26: |
597 | tmp = 0x0; |
598 | insertBits(tmp, fieldFromInstruction(insn, 0, 17), 0, 17); |
599 | insertBits(tmp, fieldFromInstruction(insn, 20, 5), 17, 5); |
600 | if (!Check(S, decodeCallTarget(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
601 | return S; |
602 | case 27: |
603 | tmp = fieldFromInstruction(insn, 4, 4); |
604 | if (!Check(S, DecodeLD8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
605 | tmp = 0x0; |
606 | insertBits(tmp, fieldFromInstruction(insn, 0, 4), 0, 4); |
607 | insertBits(tmp, fieldFromInstruction(insn, 8, 3), 4, 3); |
608 | MI.addOperand(Op: MCOperand::createImm(Val: tmp)); |
609 | return S; |
610 | case 28: |
611 | tmp = 0x0; |
612 | insertBits(tmp, fieldFromInstruction(insn, 0, 4), 0, 4); |
613 | insertBits(tmp, fieldFromInstruction(insn, 8, 3), 4, 3); |
614 | MI.addOperand(Op: MCOperand::createImm(Val: tmp)); |
615 | tmp = fieldFromInstruction(insn, 4, 4); |
616 | if (!Check(S, DecodeLD8RegisterClass(MI, tmp, Address, Decoder))) { return MCDisassembler::Fail; } |
617 | return S; |
618 | } |
619 | } |
620 | |
621 | template <typename InsnType> |
622 | static DecodeStatus decodeInstruction(const uint8_t DecodeTable[], MCInst &MI, |
623 | InsnType insn, uint64_t Address, |
624 | const MCDisassembler *DisAsm, |
625 | const MCSubtargetInfo &STI) { |
626 | const FeatureBitset &Bits = STI.getFeatureBits(); |
627 | |
628 | const uint8_t *Ptr = DecodeTable; |
629 | uint64_t CurFieldValue = 0; |
630 | DecodeStatus S = MCDisassembler::Success; |
631 | while (true) { |
632 | ptrdiff_t Loc = Ptr - DecodeTable; |
633 | switch (*Ptr) { |
634 | default: |
635 | errs() << Loc << ": Unexpected decode table opcode!\n" ; |
636 | return MCDisassembler::Fail; |
637 | case MCD::OPC_ExtractField: { |
638 | // Decode the start value. |
639 | unsigned Start = decodeULEB128AndIncUnsafe(p&: ++Ptr); |
640 | unsigned Len = *Ptr++; |
641 | CurFieldValue = fieldFromInstruction(insn, Start, Len); |
642 | LLVM_DEBUG(dbgs() << Loc << ": OPC_ExtractField(" << Start << ", " |
643 | << Len << "): " << CurFieldValue << "\n" ); |
644 | break; |
645 | } |
646 | case MCD::OPC_FilterValue: { |
647 | // Decode the field value. |
648 | uint64_t Val = decodeULEB128AndIncUnsafe(p&: ++Ptr); |
649 | // NumToSkip is a plain 24-bit integer. |
650 | unsigned NumToSkip = *Ptr++; |
651 | NumToSkip |= (*Ptr++) << 8; |
652 | NumToSkip |= (*Ptr++) << 16; |
653 | |
654 | // Perform the filter operation. |
655 | if (Val != CurFieldValue) |
656 | Ptr += NumToSkip; |
657 | LLVM_DEBUG(dbgs() << Loc << ": OPC_FilterValue(" << Val << ", " << NumToSkip |
658 | << "): " << ((Val != CurFieldValue) ? "FAIL:" : "PASS:" ) |
659 | << " continuing at " << (Ptr - DecodeTable) << "\n" ); |
660 | |
661 | break; |
662 | } |
663 | case MCD::OPC_CheckField: { |
664 | // Decode the start value. |
665 | unsigned Start = decodeULEB128AndIncUnsafe(p&: ++Ptr); |
666 | unsigned Len = *Ptr; |
667 | uint64_t FieldValue = fieldFromInstruction(insn, Start, Len); |
668 | // Decode the field value. |
669 | unsigned PtrLen = 0; |
670 | uint64_t ExpectedValue = decodeULEB128(p: ++Ptr, n: &PtrLen); |
671 | Ptr += PtrLen; |
672 | // NumToSkip is a plain 24-bit integer. |
673 | unsigned NumToSkip = *Ptr++; |
674 | NumToSkip |= (*Ptr++) << 8; |
675 | NumToSkip |= (*Ptr++) << 16; |
676 | |
677 | // If the actual and expected values don't match, skip. |
678 | if (ExpectedValue != FieldValue) |
679 | Ptr += NumToSkip; |
680 | LLVM_DEBUG(dbgs() << Loc << ": OPC_CheckField(" << Start << ", " |
681 | << Len << ", " << ExpectedValue << ", " << NumToSkip |
682 | << "): FieldValue = " << FieldValue << ", ExpectedValue = " |
683 | << ExpectedValue << ": " |
684 | << ((ExpectedValue == FieldValue) ? "PASS\n" : "FAIL\n" )); |
685 | break; |
686 | } |
687 | case MCD::OPC_CheckPredicate: { |
688 | // Decode the Predicate Index value. |
689 | unsigned PIdx = decodeULEB128AndIncUnsafe(p&: ++Ptr); |
690 | // NumToSkip is a plain 24-bit integer. |
691 | unsigned NumToSkip = *Ptr++; |
692 | NumToSkip |= (*Ptr++) << 8; |
693 | NumToSkip |= (*Ptr++) << 16; |
694 | // Check the predicate. |
695 | bool Pred; |
696 | if (!(Pred = checkDecoderPredicate(Idx: PIdx, Bits))) |
697 | Ptr += NumToSkip; |
698 | (void)Pred; |
699 | LLVM_DEBUG(dbgs() << Loc << ": OPC_CheckPredicate(" << PIdx << "): " |
700 | << (Pred ? "PASS\n" : "FAIL\n" )); |
701 | |
702 | break; |
703 | } |
704 | case MCD::OPC_Decode: { |
705 | // Decode the Opcode value. |
706 | unsigned Opc = decodeULEB128AndIncUnsafe(p&: ++Ptr); |
707 | unsigned DecodeIdx = decodeULEB128AndIncUnsafe(p&: Ptr); |
708 | |
709 | MI.clear(); |
710 | MI.setOpcode(Opc); |
711 | bool DecodeComplete; |
712 | S = decodeToMCInst(S, DecodeIdx, insn, MI, Address, DisAsm, DecodeComplete); |
713 | assert(DecodeComplete); |
714 | |
715 | LLVM_DEBUG(dbgs() << Loc << ": OPC_Decode: opcode " << Opc |
716 | << ", using decoder " << DecodeIdx << ": " |
717 | << (S != MCDisassembler::Fail ? "PASS" : "FAIL" ) << "\n" ); |
718 | return S; |
719 | } |
720 | case MCD::OPC_TryDecode: { |
721 | // Decode the Opcode value. |
722 | unsigned Opc = decodeULEB128AndIncUnsafe(p&: ++Ptr); |
723 | unsigned DecodeIdx = decodeULEB128AndIncUnsafe(p&: Ptr); |
724 | // NumToSkip is a plain 24-bit integer. |
725 | unsigned NumToSkip = *Ptr++; |
726 | NumToSkip |= (*Ptr++) << 8; |
727 | NumToSkip |= (*Ptr++) << 16; |
728 | |
729 | // Perform the decode operation. |
730 | MCInst TmpMI; |
731 | TmpMI.setOpcode(Opc); |
732 | bool DecodeComplete; |
733 | S = decodeToMCInst(S, DecodeIdx, insn, TmpMI, Address, DisAsm, DecodeComplete); |
734 | LLVM_DEBUG(dbgs() << Loc << ": OPC_TryDecode: opcode " << Opc |
735 | << ", using decoder " << DecodeIdx << ": " ); |
736 | |
737 | if (DecodeComplete) { |
738 | // Decoding complete. |
739 | LLVM_DEBUG(dbgs() << (S != MCDisassembler::Fail ? "PASS" : "FAIL" ) << "\n" ); |
740 | MI = TmpMI; |
741 | return S; |
742 | } else { |
743 | assert(S == MCDisassembler::Fail); |
744 | // If the decoding was incomplete, skip. |
745 | Ptr += NumToSkip; |
746 | LLVM_DEBUG(dbgs() << "FAIL: continuing at " << (Ptr - DecodeTable) << "\n" ); |
747 | // Reset decode status. This also drops a SoftFail status that could be |
748 | // set before the decode attempt. |
749 | S = MCDisassembler::Success; |
750 | } |
751 | break; |
752 | } |
753 | case MCD::OPC_SoftFail: { |
754 | // Decode the mask values. |
755 | uint64_t PositiveMask = decodeULEB128AndIncUnsafe(p&: ++Ptr); |
756 | uint64_t NegativeMask = decodeULEB128AndIncUnsafe(p&: Ptr); |
757 | bool Fail = (insn & PositiveMask) != 0 || (~insn & NegativeMask) != 0; |
758 | if (Fail) |
759 | S = MCDisassembler::SoftFail; |
760 | LLVM_DEBUG(dbgs() << Loc << ": OPC_SoftFail: " << (Fail ? "FAIL\n" : "PASS\n" )); |
761 | break; |
762 | } |
763 | case MCD::OPC_Fail: { |
764 | LLVM_DEBUG(dbgs() << Loc << ": OPC_Fail\n" ); |
765 | return MCDisassembler::Fail; |
766 | } |
767 | } |
768 | } |
769 | llvm_unreachable("bogosity detected in disassembler state machine!" ); |
770 | } |
771 | |
772 | |
773 | } // end namespace llvm |
774 | |