1 //===- ARMDisassembler.cpp - Disassembler for ARM/Thumb ISA -----*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #define DEBUG_TYPE "arm-disassembler"
12 #include "ARMDisassembler.h"
14 #include "ARMRegisterInfo.h"
15 #include "MCTargetDesc/ARMAddressingModes.h"
16 #include "MCTargetDesc/ARMBaseInfo.h"
17 #include "llvm/MC/EDInstInfo.h"
18 #include "llvm/MC/MCInst.h"
19 #include "llvm/MC/MCExpr.h"
20 #include "llvm/MC/MCContext.h"
21 #include "llvm/Target/TargetRegistry.h"
22 #include "llvm/Support/Debug.h"
23 #include "llvm/Support/MemoryObject.h"
24 #include "llvm/Support/ErrorHandling.h"
25 #include "llvm/Support/raw_ostream.h"
27 // Forward declare these because the autogenerated code will reference them.
28 // Definitions are further down.
29 static bool DecodeGPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
30 uint64_t Address, const void *Decoder);
31 static bool DecodeGPRnopcRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
32 uint64_t Address, const void *Decoder);
33 static bool DecodetGPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
34 uint64_t Address, const void *Decoder);
35 static bool DecodetcGPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
36 uint64_t Address, const void *Decoder);
37 static bool DecoderGPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
38 uint64_t Address, const void *Decoder);
39 static bool DecodeSPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
40 uint64_t Address, const void *Decoder);
41 static bool DecodeDPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
42 uint64_t Address, const void *Decoder);
43 static bool DecodeDPR_8RegisterClass(llvm::MCInst &Inst, unsigned RegNo,
44 uint64_t Address, const void *Decoder);
45 static bool DecodeDPR_VFP2RegisterClass(llvm::MCInst &Inst, unsigned RegNo,
46 uint64_t Address, const void *Decoder);
47 static bool DecodeQPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
48 uint64_t Address, const void *Decoder);
50 static bool DecodePredicateOperand(llvm::MCInst &Inst, unsigned Val,
51 uint64_t Address, const void *Decoder);
52 static bool DecodeCCOutOperand(llvm::MCInst &Inst, unsigned Val,
53 uint64_t Address, const void *Decoder);
54 static bool DecodeSOImmOperand(llvm::MCInst &Inst, unsigned Val,
55 uint64_t Address, const void *Decoder);
56 static bool DecodeBLTargetOperand(llvm::MCInst &Inst, unsigned Val,
57 uint64_t Address, const void *Decoder);
58 static bool DecodeRegListOperand(llvm::MCInst &Inst, unsigned Val,
59 uint64_t Address, const void *Decoder);
60 static bool DecodeSPRRegListOperand(llvm::MCInst &Inst, unsigned Val,
61 uint64_t Address, const void *Decoder);
62 static bool DecodeDPRRegListOperand(llvm::MCInst &Inst, unsigned Val,
63 uint64_t Address, const void *Decoder);
65 static bool DecodeBitfieldMaskOperand(llvm::MCInst &Inst, unsigned Insn,
66 uint64_t Address, const void *Decoder);
67 static bool DecodeCopMemInstruction(llvm::MCInst &Inst, unsigned Insn,
68 uint64_t Address, const void *Decoder);
69 static bool DecodeAddrMode2IdxInstruction(llvm::MCInst &Inst, unsigned Insn,
70 uint64_t Address, const void *Decoder);
71 static bool DecodeSORegMemOperand(llvm::MCInst &Inst, unsigned Insn,
72 uint64_t Address, const void *Decoder);
73 static bool DecodeAddrMode3Instruction(llvm::MCInst &Inst, unsigned Insn,
74 uint64_t Address, const void *Decoder);
75 static bool DecodeSORegImmOperand(llvm::MCInst &Inst, unsigned Insn,
76 uint64_t Address, const void *Decoder);
77 static bool DecodeSORegRegOperand(llvm::MCInst &Inst, unsigned Insn,
78 uint64_t Address, const void *Decoder);
80 static bool DecodeMemMultipleWritebackInstruction(llvm::MCInst & Inst,
84 static bool DecodeSMLAInstruction(llvm::MCInst &Inst, unsigned Insn,
85 uint64_t Address, const void *Decoder);
86 static bool DecodeCPSInstruction(llvm::MCInst &Inst, unsigned Insn,
87 uint64_t Address, const void *Decoder);
88 static bool DecodeAddrModeImm12Operand(llvm::MCInst &Inst, unsigned Val,
89 uint64_t Address, const void *Decoder);
90 static bool DecodeAddrMode5Operand(llvm::MCInst &Inst, unsigned Val,
91 uint64_t Address, const void *Decoder);
92 static bool DecodeAddrMode7Operand(llvm::MCInst &Inst, unsigned Val,
93 uint64_t Address, const void *Decoder);
94 static bool DecodeBranchImmInstruction(llvm::MCInst &Inst, unsigned Insn,
95 uint64_t Address, const void *Decoder);
96 static bool DecodeVCVTImmOperand(llvm::MCInst &Inst, unsigned Val,
97 uint64_t Address, const void *Decoder);
98 static bool DecodeAddrMode6Operand(llvm::MCInst &Inst, unsigned Val,
99 uint64_t Address, const void *Decoder);
100 static bool DecodeVLDInstruction(llvm::MCInst &Inst, unsigned Val,
101 uint64_t Address, const void *Decoder);
102 static bool DecodeVSTInstruction(llvm::MCInst &Inst, unsigned Val,
103 uint64_t Address, const void *Decoder);
104 static bool DecodeVLD1DupInstruction(llvm::MCInst &Inst, unsigned Val,
105 uint64_t Address, const void *Decoder);
106 static bool DecodeVLD2DupInstruction(llvm::MCInst &Inst, unsigned Val,
107 uint64_t Address, const void *Decoder);
108 static bool DecodeVLD3DupInstruction(llvm::MCInst &Inst, unsigned Val,
109 uint64_t Address, const void *Decoder);
110 static bool DecodeVLD4DupInstruction(llvm::MCInst &Inst, unsigned Val,
111 uint64_t Address, const void *Decoder);
112 static bool DecodeNEONModImmInstruction(llvm::MCInst &Inst, unsigned Val,
113 uint64_t Address, const void *Decoder);
114 static bool DecodeVSHLMaxInstruction(llvm::MCInst &Inst, unsigned Val,
115 uint64_t Address, const void *Decoder);
116 static bool DecodeShiftRight8Imm(llvm::MCInst &Inst, unsigned Val,
117 uint64_t Address, const void *Decoder);
118 static bool DecodeShiftRight16Imm(llvm::MCInst &Inst, unsigned Val,
119 uint64_t Address, const void *Decoder);
120 static bool DecodeShiftRight32Imm(llvm::MCInst &Inst, unsigned Val,
121 uint64_t Address, const void *Decoder);
122 static bool DecodeShiftRight64Imm(llvm::MCInst &Inst, unsigned Val,
123 uint64_t Address, const void *Decoder);
124 static bool DecodeTBLInstruction(llvm::MCInst &Inst, unsigned Insn,
125 uint64_t Address, const void *Decoder);
126 static bool DecodeVFPfpImm(llvm::MCInst &Inst, unsigned Val,
127 uint64_t Address, const void *Decoder);
128 static bool DecodePostIdxReg(llvm::MCInst &Inst, unsigned Insn,
129 uint64_t Address, const void *Decoder);
130 static bool DecodeCoprocessor(llvm::MCInst &Inst, unsigned Insn,
131 uint64_t Address, const void *Decoder);
132 static bool DecodeMemBarrierOption(llvm::MCInst &Inst, unsigned Insn,
133 uint64_t Address, const void *Decoder);
134 static bool DecodeMSRMask(llvm::MCInst &Inst, unsigned Insn,
135 uint64_t Address, const void *Decoder);
136 static bool DecodeDoubleRegLoad(llvm::MCInst &Inst, unsigned Insn,
137 uint64_t Address, const void *Decoder);
138 static bool DecodeDoubleRegStore(llvm::MCInst &Inst, unsigned Insn,
139 uint64_t Address, const void *Decoder);
140 static bool DecodeSTRPreImm(llvm::MCInst &Inst, unsigned Insn,
141 uint64_t Address, const void *Decoder);
142 static bool DecodeSTRPreReg(llvm::MCInst &Inst, unsigned Insn,
143 uint64_t Address, const void *Decoder);
144 static bool DecodeVLD1LN(llvm::MCInst &Inst, unsigned Insn,
145 uint64_t Address, const void *Decoder);
146 static bool DecodeVLD2LN(llvm::MCInst &Inst, unsigned Insn,
147 uint64_t Address, const void *Decoder);
148 static bool DecodeVLD3LN(llvm::MCInst &Inst, unsigned Insn,
149 uint64_t Address, const void *Decoder);
150 static bool DecodeVLD4LN(llvm::MCInst &Inst, unsigned Insn,
151 uint64_t Address, const void *Decoder);
152 static bool DecodeVST1LN(llvm::MCInst &Inst, unsigned Insn,
153 uint64_t Address, const void *Decoder);
154 static bool DecodeVST2LN(llvm::MCInst &Inst, unsigned Insn,
155 uint64_t Address, const void *Decoder);
156 static bool DecodeVST3LN(llvm::MCInst &Inst, unsigned Insn,
157 uint64_t Address, const void *Decoder);
158 static bool DecodeVST4LN(llvm::MCInst &Inst, unsigned Insn,
159 uint64_t Address, const void *Decoder);
162 static bool DecodeThumbAddSpecialReg(llvm::MCInst &Inst, uint16_t Insn,
163 uint64_t Address, const void *Decoder);
164 static bool DecodeThumbBROperand(llvm::MCInst &Inst, unsigned Val,
165 uint64_t Address, const void *Decoder);
166 static bool DecodeT2BROperand(llvm::MCInst &Inst, unsigned Val,
167 uint64_t Address, const void *Decoder);
168 static bool DecodeThumbCmpBROperand(llvm::MCInst &Inst, unsigned Val,
169 uint64_t Address, const void *Decoder);
170 static bool DecodeThumbAddrModeRR(llvm::MCInst &Inst, unsigned Val,
171 uint64_t Address, const void *Decoder);
172 static bool DecodeThumbAddrModeIS(llvm::MCInst &Inst, unsigned Val,
173 uint64_t Address, const void *Decoder);
174 static bool DecodeThumbAddrModePC(llvm::MCInst &Inst, unsigned Val,
175 uint64_t Address, const void *Decoder);
176 static bool DecodeThumbAddrModeSP(llvm::MCInst &Inst, unsigned Val,
177 uint64_t Address, const void *Decoder);
178 static bool DecodeT2AddrModeSOReg(llvm::MCInst &Inst, unsigned Val,
179 uint64_t Address, const void *Decoder);
180 static bool DecodeT2LoadShift(llvm::MCInst &Inst, unsigned Val,
181 uint64_t Address, const void *Decoder);
182 static bool DecodeT2Imm8S4(llvm::MCInst &Inst, unsigned Val,
183 uint64_t Address, const void *Decoder);
184 static bool DecodeT2AddrModeImm8s4(llvm::MCInst &Inst, unsigned Val,
185 uint64_t Address, const void *Decoder);
186 static bool DecodeT2Imm8(llvm::MCInst &Inst, unsigned Val,
187 uint64_t Address, const void *Decoder);
188 static bool DecodeT2AddrModeImm8(llvm::MCInst &Inst, unsigned Val,
189 uint64_t Address, const void *Decoder);
190 static bool DecodeThumbAddSPImm(llvm::MCInst &Inst, uint16_t Val,
191 uint64_t Address, const void *Decoder);
192 static bool DecodeThumbAddSPReg(llvm::MCInst &Inst, uint16_t Insn,
193 uint64_t Address, const void *Decoder);
194 static bool DecodeThumbCPS(llvm::MCInst &Inst, uint16_t Insn,
195 uint64_t Address, const void *Decoder);
196 static bool DecodeThumbBLXOffset(llvm::MCInst &Inst, unsigned Insn,
197 uint64_t Address, const void *Decoder);
198 static bool DecodeT2AddrModeImm12(llvm::MCInst &Inst, unsigned Val,
199 uint64_t Address, const void *Decoder);
200 static bool DecodeThumbSRImm(llvm::MCInst &Inst, unsigned Val,
201 uint64_t Address, const void *Decoder);
202 static bool DecodeThumb2BCCInstruction(llvm::MCInst &Inst, unsigned Val,
203 uint64_t Address, const void *Decoder);
204 static bool DecodeT2SOImm(llvm::MCInst &Inst, unsigned Val,
205 uint64_t Address, const void *Decoder);
206 static bool DecodeThumbBCCTargetOperand(llvm::MCInst &Inst, unsigned Val,
207 uint64_t Address, const void *Decoder);
208 static bool DecodeThumbBLTargetOperand(llvm::MCInst &Inst, unsigned Val,
209 uint64_t Address, const void *Decoder);
211 #include "ARMGenDisassemblerTables.inc"
212 #include "ARMGenInstrInfo.inc"
213 #include "ARMGenEDInfo.inc"
215 using namespace llvm;
217 static MCDisassembler *createARMDisassembler(const Target &T) {
218 return new ARMDisassembler;
221 static MCDisassembler *createThumbDisassembler(const Target &T) {
222 return new ThumbDisassembler;
225 EDInstInfo *ARMDisassembler::getEDInfo() const {
229 EDInstInfo *ThumbDisassembler::getEDInfo() const {
234 bool ARMDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
235 const MemoryObject &Region,
236 uint64_t Address,raw_ostream &os) const {
239 // We want to read exactly 4 bytes of data.
240 if (Region.readBytes(Address, 4, (uint8_t*)bytes, NULL) == -1)
243 // Encoded as a small-endian 32-bit word in the stream.
244 uint32_t insn = (bytes[3] << 24) |
249 // Calling the auto-generated decoder function.
250 bool result = decodeARMInstruction32(MI, insn, Address, this);
256 // Instructions that are shared between ARM and Thumb modes.
257 // FIXME: This shouldn't really exist. It's an artifact of the
258 // fact that we fail to encode a few instructions properly for Thumb.
260 result = decodeCommonInstruction32(MI, insn, Address, this);
266 // VFP and NEON instructions, similarly, are shared between ARM
269 result = decodeVFPInstruction32(MI, insn, Address, this);
276 result = decodeNEONDataInstruction32(MI, insn, Address, this);
279 // Add a fake predicate operand, because we share these instruction
280 // definitions with Thumb2 where these instructions are predicable.
281 if (!DecodePredicateOperand(MI, 0xE, Address, this)) return false;
286 result = decodeNEONLoadStoreInstruction32(MI, insn, Address, this);
289 // Add a fake predicate operand, because we share these instruction
290 // definitions with Thumb2 where these instructions are predicable.
291 if (!DecodePredicateOperand(MI, 0xE, Address, this)) return false;
296 result = decodeNEONDupInstruction32(MI, insn, Address, this);
299 // Add a fake predicate operand, because we share these instruction
300 // definitions with Thumb2 where these instructions are predicable.
301 if (!DecodePredicateOperand(MI, 0xE, Address, this)) return false;
311 extern MCInstrDesc ARMInsts[];
314 // Thumb1 instructions don't have explicit S bits. Rather, they
315 // implicitly set CPSR. Since it's not represented in the encoding, the
316 // auto-generated decoder won't inject the CPSR operand. We need to fix
317 // that as a post-pass.
318 static void AddThumb1SBit(MCInst &MI, bool InITBlock) {
319 const MCOperandInfo *OpInfo = ARMInsts[MI.getOpcode()].OpInfo;
320 MCInst::iterator I = MI.begin();
321 for (unsigned i = 0, e = MI.size(); i < e; ++i, ++I) {
322 if (OpInfo[i].isOptionalDef() && OpInfo[i].RegClass == ARM::CCRRegClassID) {
323 MI.insert(I, MCOperand::CreateReg(InITBlock ? 0 : ARM::CPSR));
328 if (OpInfo[MI.size()].isOptionalDef() &&
329 OpInfo[MI.size()].RegClass == ARM::CCRRegClassID)
330 MI.insert(MI.end(), MCOperand::CreateReg(InITBlock ? 0 : ARM::CPSR));
333 // Most Thumb instructions don't have explicit predicates in the
334 // encoding, but rather get their predicates from IT context. We need
335 // to fix up the predicate operands using this context information as a
337 void ThumbDisassembler::AddThumbPredicate(MCInst &MI) const {
338 // A few instructions actually have predicates encoded in them. Don't
339 // try to overwrite it if we're seeing one of those.
340 switch (MI.getOpcode()) {
348 // If we're in an IT block, base the predicate on that. Otherwise,
349 // assume a predicate of AL.
351 if (!ITBlock.empty()) {
357 const MCOperandInfo *OpInfo = ARMInsts[MI.getOpcode()].OpInfo;
358 MCInst::iterator I = MI.begin();
359 for (unsigned i = 0, e = MI.size(); i < e; ++i, ++I) {
360 if (OpInfo[i].isPredicate()) {
361 I = MI.insert(I, MCOperand::CreateImm(CC));
364 MI.insert(I, MCOperand::CreateReg(0));
366 MI.insert(I, MCOperand::CreateReg(ARM::CPSR));
371 MI.insert(MI.end(), MCOperand::CreateImm(CC));
373 MI.insert(MI.end(), MCOperand::CreateReg(0));
375 MI.insert(MI.end(), MCOperand::CreateReg(ARM::CPSR));
378 // Thumb VFP instructions are a special case. Because we share their
379 // encodings between ARM and Thumb modes, and they are predicable in ARM
380 // mode, the auto-generated decoder will give them an (incorrect)
381 // predicate operand. We need to rewrite these operands based on the IT
382 // context as a post-pass.
383 void ThumbDisassembler::UpdateThumbVFPPredicate(MCInst &MI) const {
385 if (!ITBlock.empty()) {
391 const MCOperandInfo *OpInfo = ARMInsts[MI.getOpcode()].OpInfo;
392 MCInst::iterator I = MI.begin();
393 for (unsigned i = 0, e = MI.size(); i < e; ++i, ++I) {
394 if (OpInfo[i].isPredicate() ) {
400 I->setReg(ARM::CPSR);
407 bool ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
408 const MemoryObject &Region,
409 uint64_t Address,raw_ostream &os) const {
412 // We want to read exactly 2 bytes of data.
413 if (Region.readBytes(Address, 2, (uint8_t*)bytes, NULL) == -1)
416 uint16_t insn16 = (bytes[1] << 8) | bytes[0];
417 bool result = decodeThumbInstruction16(MI, insn16, Address, this);
420 bool InITBlock = !ITBlock.empty();
421 AddThumbPredicate(MI);
422 AddThumb1SBit(MI, InITBlock);
427 result = decodeThumb2Instruction16(MI, insn16, Address, this);
430 AddThumbPredicate(MI);
432 // If we find an IT instruction, we need to parse its condition
433 // code and mask operands so that we can apply them correctly
434 // to the subsequent instructions.
435 if (MI.getOpcode() == ARM::t2IT) {
436 unsigned firstcond = MI.getOperand(0).getImm();
437 uint32_t mask = MI.getOperand(1).getImm();
438 unsigned zeros = CountTrailingZeros_32(mask);
441 for (unsigned i = 0; i < 4 - (zeros+1); ++i) {
442 if (firstcond ^ (mask & 1))
443 ITBlock.push_back(firstcond ^ 1);
445 ITBlock.push_back(firstcond);
448 ITBlock.push_back(firstcond);
454 // We want to read exactly 4 bytes of data.
455 if (Region.readBytes(Address, 4, (uint8_t*)bytes, NULL) == -1)
458 uint32_t insn32 = (bytes[3] << 8) |
463 result = decodeThumbInstruction32(MI, insn32, Address, this);
466 bool InITBlock = ITBlock.size();
467 AddThumbPredicate(MI);
468 AddThumb1SBit(MI, InITBlock);
473 result = decodeThumb2Instruction32(MI, insn32, Address, this);
476 AddThumbPredicate(MI);
481 result = decodeCommonInstruction32(MI, insn32, Address, this);
484 AddThumbPredicate(MI);
489 result = decodeVFPInstruction32(MI, insn32, Address, this);
492 UpdateThumbVFPPredicate(MI);
497 if (fieldFromInstruction32(insn32, 24, 4) == 0xF) {
498 uint32_t NEONDataInsn = insn32;
499 NEONDataInsn &= 0xF0FFFFFF; // Clear bits 27-24
500 NEONDataInsn |= (NEONDataInsn & 0x10000000) >> 4; // Move bit 28 to bit 24
501 NEONDataInsn |= 0x12000000; // Set bits 28 and 25
502 result = decodeNEONDataInstruction32(MI, NEONDataInsn, Address, this);
505 AddThumbPredicate(MI);
511 result = decodeNEONLoadStoreInstruction32(MI, insn32, Address, this);
514 AddThumbPredicate(MI);
519 result = decodeNEONDupInstruction32(MI, insn32, Address, this);
522 AddThumbPredicate(MI);
530 extern "C" void LLVMInitializeARMDisassembler() {
531 TargetRegistry::RegisterMCDisassembler(TheARMTarget,
532 createARMDisassembler);
533 TargetRegistry::RegisterMCDisassembler(TheThumbTarget,
534 createThumbDisassembler);
537 static const unsigned GPRDecoderTable[] = {
538 ARM::R0, ARM::R1, ARM::R2, ARM::R3,
539 ARM::R4, ARM::R5, ARM::R6, ARM::R7,
540 ARM::R8, ARM::R9, ARM::R10, ARM::R11,
541 ARM::R12, ARM::SP, ARM::LR, ARM::PC
544 static bool DecodeGPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
545 uint64_t Address, const void *Decoder) {
549 unsigned Register = GPRDecoderTable[RegNo];
550 Inst.addOperand(MCOperand::CreateReg(Register));
554 static bool DecodeGPRnopcRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
555 uint64_t Address, const void *Decoder) {
556 if (RegNo == 15) return false;
557 return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);
560 static bool DecodetGPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
561 uint64_t Address, const void *Decoder) {
564 return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);
567 static bool DecodetcGPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
568 uint64_t Address, const void *Decoder) {
569 unsigned Register = 0;
593 Inst.addOperand(MCOperand::CreateReg(Register));
597 static bool DecoderGPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
598 uint64_t Address, const void *Decoder) {
599 if (RegNo == 13 || RegNo == 15) return false;
600 return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);
603 static const unsigned SPRDecoderTable[] = {
604 ARM::S0, ARM::S1, ARM::S2, ARM::S3,
605 ARM::S4, ARM::S5, ARM::S6, ARM::S7,
606 ARM::S8, ARM::S9, ARM::S10, ARM::S11,
607 ARM::S12, ARM::S13, ARM::S14, ARM::S15,
608 ARM::S16, ARM::S17, ARM::S18, ARM::S19,
609 ARM::S20, ARM::S21, ARM::S22, ARM::S23,
610 ARM::S24, ARM::S25, ARM::S26, ARM::S27,
611 ARM::S28, ARM::S29, ARM::S30, ARM::S31
614 static bool DecodeSPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
615 uint64_t Address, const void *Decoder) {
619 unsigned Register = SPRDecoderTable[RegNo];
620 Inst.addOperand(MCOperand::CreateReg(Register));
624 static const unsigned DPRDecoderTable[] = {
625 ARM::D0, ARM::D1, ARM::D2, ARM::D3,
626 ARM::D4, ARM::D5, ARM::D6, ARM::D7,
627 ARM::D8, ARM::D9, ARM::D10, ARM::D11,
628 ARM::D12, ARM::D13, ARM::D14, ARM::D15,
629 ARM::D16, ARM::D17, ARM::D18, ARM::D19,
630 ARM::D20, ARM::D21, ARM::D22, ARM::D23,
631 ARM::D24, ARM::D25, ARM::D26, ARM::D27,
632 ARM::D28, ARM::D29, ARM::D30, ARM::D31
635 static bool DecodeDPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
636 uint64_t Address, const void *Decoder) {
640 unsigned Register = DPRDecoderTable[RegNo];
641 Inst.addOperand(MCOperand::CreateReg(Register));
645 static bool DecodeDPR_8RegisterClass(llvm::MCInst &Inst, unsigned RegNo,
646 uint64_t Address, const void *Decoder) {
649 return DecodeDPRRegisterClass(Inst, RegNo, Address, Decoder);
652 static bool DecodeDPR_VFP2RegisterClass(llvm::MCInst &Inst, unsigned RegNo,
653 uint64_t Address, const void *Decoder) {
656 return DecodeDPRRegisterClass(Inst, RegNo, Address, Decoder);
659 static const unsigned QPRDecoderTable[] = {
660 ARM::Q0, ARM::Q1, ARM::Q2, ARM::Q3,
661 ARM::Q4, ARM::Q5, ARM::Q6, ARM::Q7,
662 ARM::Q8, ARM::Q9, ARM::Q10, ARM::Q11,
663 ARM::Q12, ARM::Q13, ARM::Q14, ARM::Q15
667 static bool DecodeQPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
668 uint64_t Address, const void *Decoder) {
673 unsigned Register = QPRDecoderTable[RegNo];
674 Inst.addOperand(MCOperand::CreateReg(Register));
678 static bool DecodePredicateOperand(llvm::MCInst &Inst, unsigned Val,
679 uint64_t Address, const void *Decoder) {
680 if (Val == 0xF) return false;
681 // AL predicate is not allowed on Thumb1 branches.
682 if (Inst.getOpcode() == ARM::tBcc && Val == 0xE)
684 Inst.addOperand(MCOperand::CreateImm(Val));
685 if (Val == ARMCC::AL) {
686 Inst.addOperand(MCOperand::CreateReg(0));
688 Inst.addOperand(MCOperand::CreateReg(ARM::CPSR));
692 static bool DecodeCCOutOperand(llvm::MCInst &Inst, unsigned Val,
693 uint64_t Address, const void *Decoder) {
695 Inst.addOperand(MCOperand::CreateReg(ARM::CPSR));
697 Inst.addOperand(MCOperand::CreateReg(0));
701 static bool DecodeSOImmOperand(llvm::MCInst &Inst, unsigned Val,
702 uint64_t Address, const void *Decoder) {
703 uint32_t imm = Val & 0xFF;
704 uint32_t rot = (Val & 0xF00) >> 7;
705 uint32_t rot_imm = (imm >> rot) | (imm << (32-rot));
706 Inst.addOperand(MCOperand::CreateImm(rot_imm));
710 static bool DecodeBLTargetOperand(llvm::MCInst &Inst, unsigned Val,
711 uint64_t Address, const void *Decoder) {
713 Inst.addOperand(MCOperand::CreateImm(SignExtend32<26>(Val)));
717 static bool DecodeSORegImmOperand(llvm::MCInst &Inst, unsigned Val,
718 uint64_t Address, const void *Decoder) {
720 unsigned Rm = fieldFromInstruction32(Val, 0, 4);
721 unsigned type = fieldFromInstruction32(Val, 5, 2);
722 unsigned imm = fieldFromInstruction32(Val, 7, 5);
724 // Register-immediate
725 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)) return false;
727 ARM_AM::ShiftOpc Shift = ARM_AM::lsl;
743 if (Shift == ARM_AM::ror && imm == 0)
746 unsigned Op = Shift | (imm << 3);
747 Inst.addOperand(MCOperand::CreateImm(Op));
752 static bool DecodeSORegRegOperand(llvm::MCInst &Inst, unsigned Val,
753 uint64_t Address, const void *Decoder) {
755 unsigned Rm = fieldFromInstruction32(Val, 0, 4);
756 unsigned type = fieldFromInstruction32(Val, 5, 2);
757 unsigned Rs = fieldFromInstruction32(Val, 8, 4);
760 if (!DecodeGPRnopcRegisterClass(Inst, Rm, Address, Decoder)) return false;
761 if (!DecodeGPRnopcRegisterClass(Inst, Rs, Address, Decoder)) return false;
763 ARM_AM::ShiftOpc Shift = ARM_AM::lsl;
779 Inst.addOperand(MCOperand::CreateImm(Shift));
784 static bool DecodeRegListOperand(llvm::MCInst &Inst, unsigned Val,
785 uint64_t Address, const void *Decoder) {
786 // Empty register lists are not allowed.
787 if (CountPopulation_32(Val) == 0) return false;
788 for (unsigned i = 0; i < 16; ++i) {
789 if (Val & (1 << i)) {
790 if (!DecodeGPRRegisterClass(Inst, i, Address, Decoder)) return false;
797 static bool DecodeSPRRegListOperand(llvm::MCInst &Inst, unsigned Val,
798 uint64_t Address, const void *Decoder) {
799 unsigned Vd = fieldFromInstruction32(Val, 8, 4);
800 unsigned regs = Val & 0xFF;
802 if (!DecodeSPRRegisterClass(Inst, Vd, Address, Decoder)) return false;
803 for (unsigned i = 0; i < (regs - 1); ++i) {
804 if (!DecodeSPRRegisterClass(Inst, ++Vd, Address, Decoder)) return false;
810 static bool DecodeDPRRegListOperand(llvm::MCInst &Inst, unsigned Val,
811 uint64_t Address, const void *Decoder) {
812 unsigned Vd = fieldFromInstruction32(Val, 8, 4);
813 unsigned regs = (Val & 0xFF) / 2;
815 if (!DecodeDPRRegisterClass(Inst, Vd, Address, Decoder)) return false;
816 for (unsigned i = 0; i < (regs - 1); ++i) {
817 if (!DecodeDPRRegisterClass(Inst, ++Vd, Address, Decoder)) return false;
823 static bool DecodeBitfieldMaskOperand(llvm::MCInst &Inst, unsigned Val,
824 uint64_t Address, const void *Decoder) {
825 // This operand encodes a mask of contiguous zeros between a specified MSB
826 // and LSB. To decode it, we create the mask of all bits MSB-and-lower,
827 // the mask of all bits LSB-and-lower, and then xor them to create
828 // the mask of that's all ones on [msb, lsb]. Finally we not it to
829 // create the final mask.
830 unsigned msb = fieldFromInstruction32(Val, 5, 5);
831 unsigned lsb = fieldFromInstruction32(Val, 0, 5);
832 uint32_t msb_mask = (1 << (msb+1)) - 1;
833 uint32_t lsb_mask = (1 << lsb) - 1;
834 Inst.addOperand(MCOperand::CreateImm(~(msb_mask ^ lsb_mask)));
838 static bool DecodeCopMemInstruction(llvm::MCInst &Inst, unsigned Insn,
839 uint64_t Address, const void *Decoder) {
840 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
841 unsigned CRd = fieldFromInstruction32(Insn, 12, 4);
842 unsigned coproc = fieldFromInstruction32(Insn, 8, 4);
843 unsigned imm = fieldFromInstruction32(Insn, 0, 8);
844 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
845 unsigned U = fieldFromInstruction32(Insn, 23, 1);
847 switch (Inst.getOpcode()) {
848 case ARM::LDC_OFFSET:
851 case ARM::LDC_OPTION:
852 case ARM::LDCL_OFFSET:
855 case ARM::LDCL_OPTION:
856 case ARM::STC_OFFSET:
859 case ARM::STC_OPTION:
860 case ARM::STCL_OFFSET:
863 case ARM::STCL_OPTION:
864 if (coproc == 0xA || coproc == 0xB)
871 Inst.addOperand(MCOperand::CreateImm(coproc));
872 Inst.addOperand(MCOperand::CreateImm(CRd));
873 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
874 switch (Inst.getOpcode()) {
875 case ARM::LDC_OPTION:
876 case ARM::LDCL_OPTION:
877 case ARM::LDC2_OPTION:
878 case ARM::LDC2L_OPTION:
879 case ARM::STC_OPTION:
880 case ARM::STCL_OPTION:
881 case ARM::STC2_OPTION:
882 case ARM::STC2L_OPTION:
887 Inst.addOperand(MCOperand::CreateReg(0));
891 unsigned P = fieldFromInstruction32(Insn, 24, 1);
892 unsigned W = fieldFromInstruction32(Insn, 21, 1);
894 bool writeback = (P == 0) || (W == 1);
895 unsigned idx_mode = 0;
897 idx_mode = ARMII::IndexModePre;
898 else if (!P && writeback)
899 idx_mode = ARMII::IndexModePost;
901 switch (Inst.getOpcode()) {
905 case ARM::LDC_OPTION:
906 case ARM::LDCL_OPTION:
907 case ARM::LDC2_OPTION:
908 case ARM::LDC2L_OPTION:
909 case ARM::STC_OPTION:
910 case ARM::STCL_OPTION:
911 case ARM::STC2_OPTION:
912 case ARM::STC2L_OPTION:
913 Inst.addOperand(MCOperand::CreateImm(imm));
917 Inst.addOperand(MCOperand::CreateImm(
918 ARM_AM::getAM2Opc(ARM_AM::add, imm, ARM_AM::lsl, idx_mode)));
920 Inst.addOperand(MCOperand::CreateImm(
921 ARM_AM::getAM2Opc(ARM_AM::sub, imm, ARM_AM::lsl, idx_mode)));
925 switch (Inst.getOpcode()) {
926 case ARM::LDC_OFFSET:
929 case ARM::LDC_OPTION:
930 case ARM::LDCL_OFFSET:
933 case ARM::LDCL_OPTION:
934 case ARM::STC_OFFSET:
937 case ARM::STC_OPTION:
938 case ARM::STCL_OFFSET:
941 case ARM::STCL_OPTION:
942 if (!DecodePredicateOperand(Inst, pred, Address, Decoder)) return false;
951 static bool DecodeAddrMode2IdxInstruction(llvm::MCInst &Inst, unsigned Insn,
952 uint64_t Address, const void *Decoder) {
953 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
954 unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
955 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
956 unsigned imm = fieldFromInstruction32(Insn, 0, 12);
957 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
958 unsigned reg = fieldFromInstruction32(Insn, 25, 1);
959 unsigned P = fieldFromInstruction32(Insn, 24, 1);
960 unsigned W = fieldFromInstruction32(Insn, 21, 1);
962 // On stores, the writeback operand precedes Rt.
963 switch (Inst.getOpcode()) {
964 case ARM::STR_POST_IMM:
965 case ARM::STR_POST_REG:
966 case ARM::STRB_POST_IMM:
967 case ARM::STRB_POST_REG:
968 case ARM::STRT_POST_REG:
969 case ARM::STRT_POST_IMM:
970 case ARM::STRBT_POST_REG:
971 case ARM::STRBT_POST_IMM:
972 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
978 if (!DecodeGPRRegisterClass(Inst, Rt, Address, Decoder)) return false;
980 // On loads, the writeback operand comes after Rt.
981 switch (Inst.getOpcode()) {
982 case ARM::LDR_POST_IMM:
983 case ARM::LDR_POST_REG:
984 case ARM::LDRB_POST_IMM:
985 case ARM::LDRB_POST_REG:
988 case ARM::LDRBT_POST_REG:
989 case ARM::LDRBT_POST_IMM:
990 case ARM::LDRT_POST_REG:
991 case ARM::LDRT_POST_IMM:
992 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder))
999 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
1001 ARM_AM::AddrOpc Op = ARM_AM::add;
1002 if (!fieldFromInstruction32(Insn, 23, 1))
1005 bool writeback = (P == 0) || (W == 1);
1006 unsigned idx_mode = 0;
1008 idx_mode = ARMII::IndexModePre;
1009 else if (!P && writeback)
1010 idx_mode = ARMII::IndexModePost;
1012 if (writeback && (Rn == 15 || Rn == Rt)) return false; // UNPREDICTABLE
1015 if (!DecodeGPRnopcRegisterClass(Inst, Rm, Address, Decoder)) return false;
1016 ARM_AM::ShiftOpc Opc = ARM_AM::lsl;
1017 switch( fieldFromInstruction32(Insn, 5, 2)) {
1033 unsigned amt = fieldFromInstruction32(Insn, 7, 5);
1034 unsigned imm = ARM_AM::getAM2Opc(Op, amt, Opc, idx_mode);
1036 Inst.addOperand(MCOperand::CreateImm(imm));
1038 Inst.addOperand(MCOperand::CreateReg(0));
1039 unsigned tmp = ARM_AM::getAM2Opc(Op, imm, ARM_AM::lsl, idx_mode);
1040 Inst.addOperand(MCOperand::CreateImm(tmp));
1043 if (!DecodePredicateOperand(Inst, pred, Address, Decoder)) return false;
1048 static bool DecodeSORegMemOperand(llvm::MCInst &Inst, unsigned Val,
1049 uint64_t Address, const void *Decoder) {
1050 unsigned Rn = fieldFromInstruction32(Val, 13, 4);
1051 unsigned Rm = fieldFromInstruction32(Val, 0, 4);
1052 unsigned type = fieldFromInstruction32(Val, 5, 2);
1053 unsigned imm = fieldFromInstruction32(Val, 7, 5);
1054 unsigned U = fieldFromInstruction32(Val, 12, 1);
1056 ARM_AM::ShiftOpc ShOp = ARM_AM::lsl;
1072 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
1073 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)) return false;
1076 shift = ARM_AM::getAM2Opc(ARM_AM::add, imm, ShOp);
1078 shift = ARM_AM::getAM2Opc(ARM_AM::sub, imm, ShOp);
1079 Inst.addOperand(MCOperand::CreateImm(shift));
1084 static bool DecodeAddrMode3Instruction(llvm::MCInst &Inst, unsigned Insn,
1085 uint64_t Address, const void *Decoder) {
1086 unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
1087 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
1088 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
1089 unsigned type = fieldFromInstruction32(Insn, 22, 1);
1090 unsigned imm = fieldFromInstruction32(Insn, 8, 4);
1091 unsigned U = ((~fieldFromInstruction32(Insn, 23, 1)) & 1) << 8;
1092 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
1093 unsigned W = fieldFromInstruction32(Insn, 21, 1);
1094 unsigned P = fieldFromInstruction32(Insn, 24, 1);
1096 bool writeback = (W == 1) | (P == 0);
1097 if (writeback) { // Writeback
1099 U |= ARMII::IndexModePre << 9;
1101 U |= ARMII::IndexModePost << 9;
1103 // On stores, the writeback operand precedes Rt.
1104 switch (Inst.getOpcode()) {
1107 case ARM::STRD_POST:
1110 case ARM::STRH_POST:
1111 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder))
1119 if (!DecodeGPRRegisterClass(Inst, Rt, Address, Decoder))
1121 switch (Inst.getOpcode()) {
1124 case ARM::STRD_POST:
1127 case ARM::LDRD_POST:
1128 if (!DecodeGPRRegisterClass(Inst, Rt+1, Address, Decoder))
1136 // On loads, the writeback operand comes after Rt.
1137 switch (Inst.getOpcode()) {
1140 case ARM::LDRD_POST:
1143 case ARM::LDRH_POST:
1145 case ARM::LDRSH_PRE:
1146 case ARM::LDRSH_POST:
1148 case ARM::LDRSB_PRE:
1149 case ARM::LDRSB_POST:
1152 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder))
1160 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder))
1164 Inst.addOperand(MCOperand::CreateReg(0));
1165 Inst.addOperand(MCOperand::CreateImm(U | (imm << 4) | Rm));
1167 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder))
1169 Inst.addOperand(MCOperand::CreateImm(U));
1172 if (!DecodePredicateOperand(Inst, pred, Address, Decoder)) return false;
1177 static bool DecodeRFEInstruction(llvm::MCInst &Inst, unsigned Insn,
1178 uint64_t Address, const void *Decoder) {
1179 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
1180 unsigned mode = fieldFromInstruction32(Insn, 23, 2);
1197 Inst.addOperand(MCOperand::CreateImm(mode));
1198 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
1203 static bool DecodeMemMultipleWritebackInstruction(llvm::MCInst &Inst,
1205 uint64_t Address, const void *Decoder) {
1206 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
1207 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
1208 unsigned reglist = fieldFromInstruction32(Insn, 0, 16);
1211 switch (Inst.getOpcode()) {
1213 Inst.setOpcode(ARM::RFEDA);
1215 case ARM::STMDA_UPD:
1216 Inst.setOpcode(ARM::RFEDA_UPD);
1219 Inst.setOpcode(ARM::RFEDB);
1221 case ARM::STMDB_UPD:
1222 Inst.setOpcode(ARM::RFEDB_UPD);
1225 Inst.setOpcode(ARM::RFEIA);
1227 case ARM::STMIA_UPD:
1228 Inst.setOpcode(ARM::RFEIA_UPD);
1231 Inst.setOpcode(ARM::RFEIB);
1233 case ARM::STMIB_UPD:
1234 Inst.setOpcode(ARM::RFEIB_UPD);
1237 return DecodeRFEInstruction(Inst, Insn, Address, Decoder);
1240 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder) ||
1241 !DecodeGPRRegisterClass(Inst, Rn, Address, Decoder) || // Tied
1242 !DecodePredicateOperand(Inst, pred, Address, Decoder) ||
1243 !DecodeRegListOperand(Inst, reglist, Address, Decoder))
1249 static bool DecodeCPSInstruction(llvm::MCInst &Inst, unsigned Insn,
1250 uint64_t Address, const void *Decoder) {
1251 unsigned imod = fieldFromInstruction32(Insn, 18, 2);
1252 unsigned M = fieldFromInstruction32(Insn, 17, 1);
1253 unsigned iflags = fieldFromInstruction32(Insn, 6, 3);
1254 unsigned mode = fieldFromInstruction32(Insn, 0, 5);
1256 // imod == '01' --> UNPREDICTABLE
1257 if (imod == 1) return false;
1259 if (M && mode && imod && iflags) {
1260 Inst.setOpcode(ARM::CPS3p);
1261 Inst.addOperand(MCOperand::CreateImm(imod));
1262 Inst.addOperand(MCOperand::CreateImm(iflags));
1263 Inst.addOperand(MCOperand::CreateImm(mode));
1265 } else if (!mode && !M) {
1266 Inst.setOpcode(ARM::CPS2p);
1267 Inst.addOperand(MCOperand::CreateImm(imod));
1268 Inst.addOperand(MCOperand::CreateImm(iflags));
1270 } else if (!imod && !iflags && M) {
1271 Inst.setOpcode(ARM::CPS1p);
1272 Inst.addOperand(MCOperand::CreateImm(mode));
1279 static bool DecodeSMLAInstruction(llvm::MCInst &Inst, unsigned Insn,
1280 uint64_t Address, const void *Decoder) {
1281 unsigned Rd = fieldFromInstruction32(Insn, 16, 4);
1282 unsigned Rn = fieldFromInstruction32(Insn, 0, 4);
1283 unsigned Rm = fieldFromInstruction32(Insn, 8, 4);
1284 unsigned Ra = fieldFromInstruction32(Insn, 12, 4);
1285 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
1288 return DecodeCPSInstruction(Inst, Insn, Address, Decoder);
1290 if (!DecodeGPRnopcRegisterClass(Inst, Rd, Address, Decoder) ||
1291 !DecodeGPRnopcRegisterClass(Inst, Rn, Address, Decoder) ||
1292 !DecodeGPRnopcRegisterClass(Inst, Rm, Address, Decoder) ||
1293 !DecodeGPRnopcRegisterClass(Inst, Ra, Address, Decoder))
1296 if (!DecodePredicateOperand(Inst, pred, Address, Decoder)) return false;
1301 static bool DecodeAddrModeImm12Operand(llvm::MCInst &Inst, unsigned Val,
1302 uint64_t Address, const void *Decoder) {
1303 unsigned add = fieldFromInstruction32(Val, 12, 1);
1304 unsigned imm = fieldFromInstruction32(Val, 0, 12);
1305 unsigned Rn = fieldFromInstruction32(Val, 13, 4);
1307 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder))
1310 if (!add) imm *= -1;
1311 if (imm == 0 && !add) imm = INT32_MIN;
1312 Inst.addOperand(MCOperand::CreateImm(imm));
1317 static bool DecodeAddrMode5Operand(llvm::MCInst &Inst, unsigned Val,
1318 uint64_t Address, const void *Decoder) {
1319 unsigned Rn = fieldFromInstruction32(Val, 9, 4);
1320 unsigned U = fieldFromInstruction32(Val, 8, 1);
1321 unsigned imm = fieldFromInstruction32(Val, 0, 8);
1323 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder))
1327 Inst.addOperand(MCOperand::CreateImm(ARM_AM::getAM5Opc(ARM_AM::add, imm)));
1329 Inst.addOperand(MCOperand::CreateImm(ARM_AM::getAM5Opc(ARM_AM::sub, imm)));
1334 static bool DecodeAddrMode7Operand(llvm::MCInst &Inst, unsigned Val,
1335 uint64_t Address, const void *Decoder) {
1336 return DecodeGPRRegisterClass(Inst, Val, Address, Decoder);
1339 static bool DecodeBranchImmInstruction(llvm::MCInst &Inst, unsigned Insn,
1340 uint64_t Address, const void *Decoder) {
1341 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
1342 unsigned imm = fieldFromInstruction32(Insn, 0, 24) << 2;
1345 Inst.setOpcode(ARM::BLXi);
1346 imm |= fieldFromInstruction32(Insn, 24, 1) << 1;
1347 Inst.addOperand(MCOperand::CreateImm(SignExtend32<26>(imm)));
1351 Inst.addOperand(MCOperand::CreateImm(SignExtend32<26>(imm)));
1352 if (!DecodePredicateOperand(Inst, pred, Address, Decoder)) return false;
1358 static bool DecodeVCVTImmOperand(llvm::MCInst &Inst, unsigned Val,
1359 uint64_t Address, const void *Decoder) {
1360 Inst.addOperand(MCOperand::CreateImm(64 - Val));
1364 static bool DecodeAddrMode6Operand(llvm::MCInst &Inst, unsigned Val,
1365 uint64_t Address, const void *Decoder) {
1366 unsigned Rm = fieldFromInstruction32(Val, 0, 4);
1367 unsigned align = fieldFromInstruction32(Val, 4, 2);
1369 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder))
1372 Inst.addOperand(MCOperand::CreateImm(0));
1374 Inst.addOperand(MCOperand::CreateImm(4 << align));
1379 static bool DecodeVLDInstruction(llvm::MCInst &Inst, unsigned Insn,
1380 uint64_t Address, const void *Decoder) {
1381 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
1382 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
1383 unsigned wb = fieldFromInstruction32(Insn, 16, 4);
1384 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
1385 Rn |= fieldFromInstruction32(Insn, 4, 2) << 4;
1386 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
1388 // First output register
1389 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
1391 // Second output register
1392 switch (Inst.getOpcode()) {
1397 case ARM::VLD1q8_UPD:
1398 case ARM::VLD1q16_UPD:
1399 case ARM::VLD1q32_UPD:
1400 case ARM::VLD1q64_UPD:
1405 case ARM::VLD1d8T_UPD:
1406 case ARM::VLD1d16T_UPD:
1407 case ARM::VLD1d32T_UPD:
1408 case ARM::VLD1d64T_UPD:
1413 case ARM::VLD1d8Q_UPD:
1414 case ARM::VLD1d16Q_UPD:
1415 case ARM::VLD1d32Q_UPD:
1416 case ARM::VLD1d64Q_UPD:
1420 case ARM::VLD2d8_UPD:
1421 case ARM::VLD2d16_UPD:
1422 case ARM::VLD2d32_UPD:
1426 case ARM::VLD2q8_UPD:
1427 case ARM::VLD2q16_UPD:
1428 case ARM::VLD2q32_UPD:
1432 case ARM::VLD3d8_UPD:
1433 case ARM::VLD3d16_UPD:
1434 case ARM::VLD3d32_UPD:
1438 case ARM::VLD4d8_UPD:
1439 case ARM::VLD4d16_UPD:
1440 case ARM::VLD4d32_UPD:
1441 if (!DecodeDPRRegisterClass(Inst, (Rd+1)%32, Address, Decoder)) return false;
1446 case ARM::VLD2b8_UPD:
1447 case ARM::VLD2b16_UPD:
1448 case ARM::VLD2b32_UPD:
1452 case ARM::VLD3q8_UPD:
1453 case ARM::VLD3q16_UPD:
1454 case ARM::VLD3q32_UPD:
1458 case ARM::VLD4q8_UPD:
1459 case ARM::VLD4q16_UPD:
1460 case ARM::VLD4q32_UPD:
1461 if (!DecodeDPRRegisterClass(Inst, (Rd+2)%32, Address, Decoder)) return false;
1466 // Third output register
1467 switch(Inst.getOpcode()) {
1472 case ARM::VLD1d8T_UPD:
1473 case ARM::VLD1d16T_UPD:
1474 case ARM::VLD1d32T_UPD:
1475 case ARM::VLD1d64T_UPD:
1480 case ARM::VLD1d8Q_UPD:
1481 case ARM::VLD1d16Q_UPD:
1482 case ARM::VLD1d32Q_UPD:
1483 case ARM::VLD1d64Q_UPD:
1487 case ARM::VLD2q8_UPD:
1488 case ARM::VLD2q16_UPD:
1489 case ARM::VLD2q32_UPD:
1493 case ARM::VLD3d8_UPD:
1494 case ARM::VLD3d16_UPD:
1495 case ARM::VLD3d32_UPD:
1499 case ARM::VLD4d8_UPD:
1500 case ARM::VLD4d16_UPD:
1501 case ARM::VLD4d32_UPD:
1502 if (!DecodeDPRRegisterClass(Inst, (Rd+2)%32, Address, Decoder)) return false;
1507 case ARM::VLD3q8_UPD:
1508 case ARM::VLD3q16_UPD:
1509 case ARM::VLD3q32_UPD:
1513 case ARM::VLD4q8_UPD:
1514 case ARM::VLD4q16_UPD:
1515 case ARM::VLD4q32_UPD:
1516 if (!DecodeDPRRegisterClass(Inst, (Rd+4)%32, Address, Decoder)) return false;
1522 // Fourth output register
1523 switch (Inst.getOpcode()) {
1528 case ARM::VLD1d8Q_UPD:
1529 case ARM::VLD1d16Q_UPD:
1530 case ARM::VLD1d32Q_UPD:
1531 case ARM::VLD1d64Q_UPD:
1535 case ARM::VLD2q8_UPD:
1536 case ARM::VLD2q16_UPD:
1537 case ARM::VLD2q32_UPD:
1541 case ARM::VLD4d8_UPD:
1542 case ARM::VLD4d16_UPD:
1543 case ARM::VLD4d32_UPD:
1544 if (!DecodeDPRRegisterClass(Inst, (Rd+3)%32, Address, Decoder)) return false;
1549 case ARM::VLD4q8_UPD:
1550 case ARM::VLD4q16_UPD:
1551 case ARM::VLD4q32_UPD:
1552 if (!DecodeDPRRegisterClass(Inst, (Rd+6)%32, Address, Decoder)) return false;
1558 // Writeback operand
1559 switch (Inst.getOpcode()) {
1560 case ARM::VLD1d8_UPD:
1561 case ARM::VLD1d16_UPD:
1562 case ARM::VLD1d32_UPD:
1563 case ARM::VLD1d64_UPD:
1564 case ARM::VLD1q8_UPD:
1565 case ARM::VLD1q16_UPD:
1566 case ARM::VLD1q32_UPD:
1567 case ARM::VLD1q64_UPD:
1568 case ARM::VLD1d8T_UPD:
1569 case ARM::VLD1d16T_UPD:
1570 case ARM::VLD1d32T_UPD:
1571 case ARM::VLD1d64T_UPD:
1572 case ARM::VLD1d8Q_UPD:
1573 case ARM::VLD1d16Q_UPD:
1574 case ARM::VLD1d32Q_UPD:
1575 case ARM::VLD1d64Q_UPD:
1576 case ARM::VLD2d8_UPD:
1577 case ARM::VLD2d16_UPD:
1578 case ARM::VLD2d32_UPD:
1579 case ARM::VLD2q8_UPD:
1580 case ARM::VLD2q16_UPD:
1581 case ARM::VLD2q32_UPD:
1582 case ARM::VLD2b8_UPD:
1583 case ARM::VLD2b16_UPD:
1584 case ARM::VLD2b32_UPD:
1585 case ARM::VLD3d8_UPD:
1586 case ARM::VLD3d16_UPD:
1587 case ARM::VLD3d32_UPD:
1588 case ARM::VLD3q8_UPD:
1589 case ARM::VLD3q16_UPD:
1590 case ARM::VLD3q32_UPD:
1591 case ARM::VLD4d8_UPD:
1592 case ARM::VLD4d16_UPD:
1593 case ARM::VLD4d32_UPD:
1594 case ARM::VLD4q8_UPD:
1595 case ARM::VLD4q16_UPD:
1596 case ARM::VLD4q32_UPD:
1597 if (!DecodeGPRRegisterClass(Inst, wb, Address, Decoder)) return false;
1603 // AddrMode6 Base (register+alignment)
1604 if (!DecodeAddrMode6Operand(Inst, Rn, Address, Decoder)) return false;
1606 // AddrMode6 Offset (register)
1608 Inst.addOperand(MCOperand::CreateReg(0));
1609 else if (Rm != 0xF) {
1610 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder))
1617 static bool DecodeVSTInstruction(llvm::MCInst &Inst, unsigned Insn,
1618 uint64_t Address, const void *Decoder) {
1619 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
1620 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
1621 unsigned wb = fieldFromInstruction32(Insn, 16, 4);
1622 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
1623 Rn |= fieldFromInstruction32(Insn, 4, 2) << 4;
1624 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
1626 // Writeback Operand
1627 switch (Inst.getOpcode()) {
1628 case ARM::VST1d8_UPD:
1629 case ARM::VST1d16_UPD:
1630 case ARM::VST1d32_UPD:
1631 case ARM::VST1d64_UPD:
1632 case ARM::VST1q8_UPD:
1633 case ARM::VST1q16_UPD:
1634 case ARM::VST1q32_UPD:
1635 case ARM::VST1q64_UPD:
1636 case ARM::VST1d8T_UPD:
1637 case ARM::VST1d16T_UPD:
1638 case ARM::VST1d32T_UPD:
1639 case ARM::VST1d64T_UPD:
1640 case ARM::VST1d8Q_UPD:
1641 case ARM::VST1d16Q_UPD:
1642 case ARM::VST1d32Q_UPD:
1643 case ARM::VST1d64Q_UPD:
1644 case ARM::VST2d8_UPD:
1645 case ARM::VST2d16_UPD:
1646 case ARM::VST2d32_UPD:
1647 case ARM::VST2q8_UPD:
1648 case ARM::VST2q16_UPD:
1649 case ARM::VST2q32_UPD:
1650 case ARM::VST2b8_UPD:
1651 case ARM::VST2b16_UPD:
1652 case ARM::VST2b32_UPD:
1653 case ARM::VST3d8_UPD:
1654 case ARM::VST3d16_UPD:
1655 case ARM::VST3d32_UPD:
1656 case ARM::VST3q8_UPD:
1657 case ARM::VST3q16_UPD:
1658 case ARM::VST3q32_UPD:
1659 case ARM::VST4d8_UPD:
1660 case ARM::VST4d16_UPD:
1661 case ARM::VST4d32_UPD:
1662 case ARM::VST4q8_UPD:
1663 case ARM::VST4q16_UPD:
1664 case ARM::VST4q32_UPD:
1665 if (!DecodeGPRRegisterClass(Inst, wb, Address, Decoder))
1672 // AddrMode6 Base (register+alignment)
1673 if (!DecodeAddrMode6Operand(Inst, Rn, Address, Decoder)) return false;
1675 // AddrMode6 Offset (register)
1677 Inst.addOperand(MCOperand::CreateReg(0));
1678 else if (Rm != 0xF) {
1679 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)) return false;
1682 // First input register
1683 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
1685 // Second input register
1686 switch (Inst.getOpcode()) {
1691 case ARM::VST1q8_UPD:
1692 case ARM::VST1q16_UPD:
1693 case ARM::VST1q32_UPD:
1694 case ARM::VST1q64_UPD:
1699 case ARM::VST1d8T_UPD:
1700 case ARM::VST1d16T_UPD:
1701 case ARM::VST1d32T_UPD:
1702 case ARM::VST1d64T_UPD:
1707 case ARM::VST1d8Q_UPD:
1708 case ARM::VST1d16Q_UPD:
1709 case ARM::VST1d32Q_UPD:
1710 case ARM::VST1d64Q_UPD:
1714 case ARM::VST2d8_UPD:
1715 case ARM::VST2d16_UPD:
1716 case ARM::VST2d32_UPD:
1720 case ARM::VST2q8_UPD:
1721 case ARM::VST2q16_UPD:
1722 case ARM::VST2q32_UPD:
1726 case ARM::VST3d8_UPD:
1727 case ARM::VST3d16_UPD:
1728 case ARM::VST3d32_UPD:
1732 case ARM::VST4d8_UPD:
1733 case ARM::VST4d16_UPD:
1734 case ARM::VST4d32_UPD:
1735 if (!DecodeDPRRegisterClass(Inst, (Rd+1)%32, Address, Decoder)) return false;
1740 case ARM::VST2b8_UPD:
1741 case ARM::VST2b16_UPD:
1742 case ARM::VST2b32_UPD:
1746 case ARM::VST3q8_UPD:
1747 case ARM::VST3q16_UPD:
1748 case ARM::VST3q32_UPD:
1752 case ARM::VST4q8_UPD:
1753 case ARM::VST4q16_UPD:
1754 case ARM::VST4q32_UPD:
1755 if (!DecodeDPRRegisterClass(Inst, (Rd+2)%32, Address, Decoder)) return false;
1761 // Third input register
1762 switch (Inst.getOpcode()) {
1767 case ARM::VST1d8T_UPD:
1768 case ARM::VST1d16T_UPD:
1769 case ARM::VST1d32T_UPD:
1770 case ARM::VST1d64T_UPD:
1775 case ARM::VST1d8Q_UPD:
1776 case ARM::VST1d16Q_UPD:
1777 case ARM::VST1d32Q_UPD:
1778 case ARM::VST1d64Q_UPD:
1782 case ARM::VST2q8_UPD:
1783 case ARM::VST2q16_UPD:
1784 case ARM::VST2q32_UPD:
1788 case ARM::VST3d8_UPD:
1789 case ARM::VST3d16_UPD:
1790 case ARM::VST3d32_UPD:
1794 case ARM::VST4d8_UPD:
1795 case ARM::VST4d16_UPD:
1796 case ARM::VST4d32_UPD:
1797 if (!DecodeDPRRegisterClass(Inst, (Rd+2)%32, Address, Decoder)) return false;
1802 case ARM::VST3q8_UPD:
1803 case ARM::VST3q16_UPD:
1804 case ARM::VST3q32_UPD:
1808 case ARM::VST4q8_UPD:
1809 case ARM::VST4q16_UPD:
1810 case ARM::VST4q32_UPD:
1811 if (!DecodeDPRRegisterClass(Inst, (Rd+4)%32, Address, Decoder)) return false;
1817 // Fourth input register
1818 switch (Inst.getOpcode()) {
1823 case ARM::VST1d8Q_UPD:
1824 case ARM::VST1d16Q_UPD:
1825 case ARM::VST1d32Q_UPD:
1826 case ARM::VST1d64Q_UPD:
1830 case ARM::VST2q8_UPD:
1831 case ARM::VST2q16_UPD:
1832 case ARM::VST2q32_UPD:
1836 case ARM::VST4d8_UPD:
1837 case ARM::VST4d16_UPD:
1838 case ARM::VST4d32_UPD:
1839 if (!DecodeDPRRegisterClass(Inst, (Rd+3)%32, Address, Decoder)) return false;
1844 case ARM::VST4q8_UPD:
1845 case ARM::VST4q16_UPD:
1846 case ARM::VST4q32_UPD:
1847 if (!DecodeDPRRegisterClass(Inst, (Rd+6)%32, Address, Decoder)) return false;
1856 static bool DecodeVLD1DupInstruction(llvm::MCInst &Inst, unsigned Insn,
1857 uint64_t Address, const void *Decoder) {
1858 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
1859 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
1860 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
1861 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
1862 unsigned align = fieldFromInstruction32(Insn, 4, 1);
1863 unsigned size = fieldFromInstruction32(Insn, 6, 2);
1864 unsigned regs = fieldFromInstruction32(Insn, 5, 1) + 1;
1866 align *= (1 << size);
1868 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
1870 if (!DecodeDPRRegisterClass(Inst, (Rd+1)%32, Address, Decoder)) return false;
1873 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
1876 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
1877 Inst.addOperand(MCOperand::CreateImm(align));
1880 Inst.addOperand(MCOperand::CreateReg(0));
1881 else if (Rm != 0xF) {
1882 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)) return false;
1888 static bool DecodeVLD2DupInstruction(llvm::MCInst &Inst, unsigned Insn,
1889 uint64_t Address, const void *Decoder) {
1890 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
1891 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
1892 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
1893 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
1894 unsigned align = fieldFromInstruction32(Insn, 4, 1);
1895 unsigned size = 1 << fieldFromInstruction32(Insn, 6, 2);
1896 unsigned inc = fieldFromInstruction32(Insn, 5, 1) + 1;
1899 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
1900 if (!DecodeDPRRegisterClass(Inst, (Rd+inc)%32, Address, Decoder)) return false;
1902 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
1905 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
1906 Inst.addOperand(MCOperand::CreateImm(align));
1909 Inst.addOperand(MCOperand::CreateReg(0));
1910 else if (Rm != 0xF) {
1911 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)) return false;
1917 static bool DecodeVLD3DupInstruction(llvm::MCInst &Inst, unsigned Insn,
1918 uint64_t Address, const void *Decoder) {
1919 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
1920 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
1921 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
1922 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
1923 unsigned inc = fieldFromInstruction32(Insn, 5, 1) + 1;
1925 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder) ||
1926 !DecodeDPRRegisterClass(Inst, (Rd+inc)%32, Address, Decoder) ||
1927 !DecodeDPRRegisterClass(Inst, (Rd+2*inc)%32, Address, Decoder))
1930 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
1933 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
1934 Inst.addOperand(MCOperand::CreateImm(0));
1937 Inst.addOperand(MCOperand::CreateReg(0));
1938 else if (Rm != 0xF) {
1939 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)) return false;
1945 static bool DecodeVLD4DupInstruction(llvm::MCInst &Inst, unsigned Insn,
1946 uint64_t Address, const void *Decoder) {
1947 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
1948 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
1949 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
1950 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
1951 unsigned size = fieldFromInstruction32(Insn, 6, 2);
1952 unsigned inc = fieldFromInstruction32(Insn, 5, 1) + 1;
1953 unsigned align = fieldFromInstruction32(Insn, 4, 1);
1968 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder) ||
1969 !DecodeDPRRegisterClass(Inst, (Rd+inc)%32, Address, Decoder) ||
1970 !DecodeDPRRegisterClass(Inst, (Rd+2*inc)%32, Address, Decoder) ||
1971 !DecodeDPRRegisterClass(Inst, (Rd+3*inc)%32, Address, Decoder))
1974 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
1977 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
1978 Inst.addOperand(MCOperand::CreateImm(align));
1981 Inst.addOperand(MCOperand::CreateReg(0));
1982 else if (Rm != 0xF) {
1983 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)) return false;
1989 static bool DecodeNEONModImmInstruction(llvm::MCInst &Inst, unsigned Insn,
1990 uint64_t Address, const void *Decoder) {
1991 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
1992 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
1993 unsigned imm = fieldFromInstruction32(Insn, 0, 4);
1994 imm |= fieldFromInstruction32(Insn, 16, 3) << 4;
1995 imm |= fieldFromInstruction32(Insn, 24, 1) << 7;
1996 imm |= fieldFromInstruction32(Insn, 8, 4) << 8;
1997 imm |= fieldFromInstruction32(Insn, 5, 1) << 12;
1998 unsigned Q = fieldFromInstruction32(Insn, 6, 1);
2001 if (!DecodeQPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2003 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2006 Inst.addOperand(MCOperand::CreateImm(imm));
2008 switch (Inst.getOpcode()) {
2009 case ARM::VORRiv4i16:
2010 case ARM::VORRiv2i32:
2011 case ARM::VBICiv4i16:
2012 case ARM::VBICiv2i32:
2013 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2015 case ARM::VORRiv8i16:
2016 case ARM::VORRiv4i32:
2017 case ARM::VBICiv8i16:
2018 case ARM::VBICiv4i32:
2019 if (!DecodeQPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2028 static bool DecodeVSHLMaxInstruction(llvm::MCInst &Inst, unsigned Insn,
2029 uint64_t Address, const void *Decoder) {
2030 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2031 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2032 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2033 Rm |= fieldFromInstruction32(Insn, 5, 1) << 4;
2034 unsigned size = fieldFromInstruction32(Insn, 18, 2);
2036 if (!DecodeQPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2037 if (!DecodeDPRRegisterClass(Inst, Rm, Address, Decoder)) return false;
2038 Inst.addOperand(MCOperand::CreateImm(8 << size));
2043 static bool DecodeShiftRight8Imm(llvm::MCInst &Inst, unsigned Val,
2044 uint64_t Address, const void *Decoder) {
2045 Inst.addOperand(MCOperand::CreateImm(8 - Val));
2049 static bool DecodeShiftRight16Imm(llvm::MCInst &Inst, unsigned Val,
2050 uint64_t Address, const void *Decoder) {
2051 Inst.addOperand(MCOperand::CreateImm(16 - Val));
2055 static bool DecodeShiftRight32Imm(llvm::MCInst &Inst, unsigned Val,
2056 uint64_t Address, const void *Decoder) {
2057 Inst.addOperand(MCOperand::CreateImm(32 - Val));
2061 static bool DecodeShiftRight64Imm(llvm::MCInst &Inst, unsigned Val,
2062 uint64_t Address, const void *Decoder) {
2063 Inst.addOperand(MCOperand::CreateImm(64 - Val));
2067 static bool DecodeTBLInstruction(llvm::MCInst &Inst, unsigned Insn,
2068 uint64_t Address, const void *Decoder) {
2069 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2070 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2071 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2072 Rn |= fieldFromInstruction32(Insn, 7, 1) << 4;
2073 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2074 Rm |= fieldFromInstruction32(Insn, 5, 1) << 4;
2075 unsigned op = fieldFromInstruction32(Insn, 6, 1);
2076 unsigned length = fieldFromInstruction32(Insn, 8, 2) + 1;
2078 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2080 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false; // Writeback
2083 for (unsigned i = 0; i < length; ++i) {
2084 if (!DecodeDPRRegisterClass(Inst, (Rn+i)%32, Address, Decoder)) return false;
2087 if (!DecodeDPRRegisterClass(Inst, Rm, Address, Decoder)) return false;
2092 static bool DecodeVFPfpImm(llvm::MCInst &Inst, unsigned Val,
2093 uint64_t Address, const void *Decoder) {
2094 // The immediate needs to be a fully instantiated float. However, the
2095 // auto-generated decoder is only able to fill in some of the bits
2096 // necessary. For instance, the 'b' bit is replicated multiple times,
2097 // and is even present in inverted form in one bit. We do a little
2098 // binary parsing here to fill in those missing bits, and then
2099 // reinterpret it all as a float.
2105 fp_conv.integer = Val;
2106 uint32_t b = fieldFromInstruction32(Val, 25, 1);
2107 fp_conv.integer |= b << 26;
2108 fp_conv.integer |= b << 27;
2109 fp_conv.integer |= b << 28;
2110 fp_conv.integer |= b << 29;
2111 fp_conv.integer |= (~b & 0x1) << 30;
2113 Inst.addOperand(MCOperand::CreateFPImm(fp_conv.fp));
2117 static bool DecodeThumbAddSpecialReg(llvm::MCInst &Inst, uint16_t Insn,
2118 uint64_t Address, const void *Decoder) {
2119 unsigned dst = fieldFromInstruction16(Insn, 8, 3);
2120 unsigned imm = fieldFromInstruction16(Insn, 0, 8);
2122 if (!DecodetGPRRegisterClass(Inst, dst, Address, Decoder)) return false;
2124 if (Inst.getOpcode() == ARM::tADR)
2125 Inst.addOperand(MCOperand::CreateReg(ARM::PC));
2126 else if (Inst.getOpcode() == ARM::tADDrSPi)
2127 Inst.addOperand(MCOperand::CreateReg(ARM::SP));
2131 Inst.addOperand(MCOperand::CreateImm(imm));
2135 static bool DecodeThumbBROperand(llvm::MCInst &Inst, unsigned Val,
2136 uint64_t Address, const void *Decoder) {
2137 Inst.addOperand(MCOperand::CreateImm(SignExtend32<12>(Val << 1)));
2141 static bool DecodeT2BROperand(llvm::MCInst &Inst, unsigned Val,
2142 uint64_t Address, const void *Decoder) {
2143 Inst.addOperand(MCOperand::CreateImm(SignExtend32<21>(Val)));
2147 static bool DecodeThumbCmpBROperand(llvm::MCInst &Inst, unsigned Val,
2148 uint64_t Address, const void *Decoder) {
2149 Inst.addOperand(MCOperand::CreateImm(SignExtend32<7>(Val << 1)));
2153 static bool DecodeThumbAddrModeRR(llvm::MCInst &Inst, unsigned Val,
2154 uint64_t Address, const void *Decoder) {
2155 unsigned Rn = fieldFromInstruction32(Val, 0, 3);
2156 unsigned Rm = fieldFromInstruction32(Val, 3, 3);
2158 if (!DecodetGPRRegisterClass(Inst, Rn, Address, Decoder) ||
2159 !DecodetGPRRegisterClass(Inst, Rm, Address, Decoder))
2165 static bool DecodeThumbAddrModeIS(llvm::MCInst &Inst, unsigned Val,
2166 uint64_t Address, const void *Decoder) {
2167 unsigned Rn = fieldFromInstruction32(Val, 0, 3);
2168 unsigned imm = fieldFromInstruction32(Val, 3, 5);
2170 if (!DecodetGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
2171 Inst.addOperand(MCOperand::CreateImm(imm));
2176 static bool DecodeThumbAddrModePC(llvm::MCInst &Inst, unsigned Val,
2177 uint64_t Address, const void *Decoder) {
2178 Inst.addOperand(MCOperand::CreateImm(Val << 2));
2183 static bool DecodeThumbAddrModeSP(llvm::MCInst &Inst, unsigned Val,
2184 uint64_t Address, const void *Decoder) {
2185 Inst.addOperand(MCOperand::CreateReg(ARM::SP));
2186 Inst.addOperand(MCOperand::CreateImm(Val << 2));
2191 static bool DecodeT2AddrModeSOReg(llvm::MCInst &Inst, unsigned Val,
2192 uint64_t Address, const void *Decoder) {
2193 unsigned Rn = fieldFromInstruction32(Val, 6, 4);
2194 unsigned Rm = fieldFromInstruction32(Val, 2, 4);
2195 unsigned imm = fieldFromInstruction32(Val, 0, 2);
2197 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder) ||
2198 !DecoderGPRRegisterClass(Inst, Rm, Address, Decoder))
2200 Inst.addOperand(MCOperand::CreateImm(imm));
2205 static bool DecodeT2LoadShift(llvm::MCInst &Inst, unsigned Insn,
2206 uint64_t Address, const void *Decoder) {
2207 if (Inst.getOpcode() != ARM::t2PLDs) {
2208 unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
2209 if (!DecodeGPRRegisterClass(Inst, Rt, Address, Decoder)) return false;
2212 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2214 switch (Inst.getOpcode()) {
2216 Inst.setOpcode(ARM::t2LDRBpci);
2219 Inst.setOpcode(ARM::t2LDRHpci);
2222 Inst.setOpcode(ARM::t2LDRSHpci);
2225 Inst.setOpcode(ARM::t2LDRSBpci);
2228 Inst.setOpcode(ARM::t2PLDi12);
2229 Inst.addOperand(MCOperand::CreateReg(ARM::PC));
2235 int imm = fieldFromInstruction32(Insn, 0, 12);
2236 if (!fieldFromInstruction32(Insn, 23, 1)) imm *= -1;
2237 Inst.addOperand(MCOperand::CreateImm(imm));
2242 unsigned addrmode = fieldFromInstruction32(Insn, 4, 2);
2243 addrmode |= fieldFromInstruction32(Insn, 0, 4) << 2;
2244 addrmode |= fieldFromInstruction32(Insn, 16, 4) << 6;
2245 DecodeT2AddrModeSOReg(Inst, addrmode, Address, Decoder);
2250 static bool DecodeT2Imm8S4(llvm::MCInst &Inst, unsigned Val,
2251 uint64_t Address, const void *Decoder) {
2252 int imm = Val & 0xFF;
2253 if (!(Val & 0x100)) imm *= -1;
2254 Inst.addOperand(MCOperand::CreateImm(imm << 2));
2259 static bool DecodeT2AddrModeImm8s4(llvm::MCInst &Inst, unsigned Val,
2260 uint64_t Address, const void *Decoder) {
2261 unsigned Rn = fieldFromInstruction32(Val, 9, 4);
2262 unsigned imm = fieldFromInstruction32(Val, 0, 9);
2264 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder) ||
2265 !DecodeT2Imm8S4(Inst, imm, Address, Decoder))
2271 static bool DecodeT2Imm8(llvm::MCInst &Inst, unsigned Val,
2272 uint64_t Address, const void *Decoder) {
2273 int imm = Val & 0xFF;
2274 if (!(Val & 0x100)) imm *= -1;
2275 Inst.addOperand(MCOperand::CreateImm(imm));
2281 static bool DecodeT2AddrModeImm8(llvm::MCInst &Inst, unsigned Val,
2282 uint64_t Address, const void *Decoder) {
2283 unsigned Rn = fieldFromInstruction32(Val, 9, 4);
2284 unsigned imm = fieldFromInstruction32(Val, 0, 9);
2286 // Some instructions always use an additive offset.
2287 switch (Inst.getOpcode()) {
2299 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder) ||
2300 !DecodeT2Imm8(Inst, imm, Address, Decoder))
2307 static bool DecodeT2AddrModeImm12(llvm::MCInst &Inst, unsigned Val,
2308 uint64_t Address, const void *Decoder) {
2309 unsigned Rn = fieldFromInstruction32(Val, 13, 4);
2310 unsigned imm = fieldFromInstruction32(Val, 0, 12);
2312 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
2313 Inst.addOperand(MCOperand::CreateImm(imm));
2319 static bool DecodeThumbAddSPImm(llvm::MCInst &Inst, uint16_t Insn,
2320 uint64_t Address, const void *Decoder) {
2321 unsigned imm = fieldFromInstruction16(Insn, 0, 7);
2323 Inst.addOperand(MCOperand::CreateReg(ARM::SP));
2324 Inst.addOperand(MCOperand::CreateReg(ARM::SP));
2325 Inst.addOperand(MCOperand::CreateImm(imm));
2330 static bool DecodeThumbAddSPReg(llvm::MCInst &Inst, uint16_t Insn,
2331 uint64_t Address, const void *Decoder) {
2332 if (Inst.getOpcode() == ARM::tADDrSP) {
2333 unsigned Rdm = fieldFromInstruction16(Insn, 0, 3);
2334 Rdm |= fieldFromInstruction16(Insn, 7, 1) << 3;
2336 if (!DecodeGPRRegisterClass(Inst, Rdm, Address, Decoder)) return false;
2337 Inst.addOperand(MCOperand::CreateReg(ARM::SP));
2338 if (!DecodeGPRRegisterClass(Inst, Rdm, Address, Decoder)) return false;
2339 } else if (Inst.getOpcode() == ARM::tADDspr) {
2340 unsigned Rm = fieldFromInstruction16(Insn, 3, 4);
2342 Inst.addOperand(MCOperand::CreateReg(ARM::SP));
2343 Inst.addOperand(MCOperand::CreateReg(ARM::SP));
2344 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)) return false;
2350 static bool DecodeThumbCPS(llvm::MCInst &Inst, uint16_t Insn,
2351 uint64_t Address, const void *Decoder) {
2352 unsigned imod = fieldFromInstruction16(Insn, 4, 1) | 0x2;
2353 unsigned flags = fieldFromInstruction16(Insn, 0, 3);
2355 Inst.addOperand(MCOperand::CreateImm(imod));
2356 Inst.addOperand(MCOperand::CreateImm(flags));
2361 static bool DecodePostIdxReg(llvm::MCInst &Inst, unsigned Insn,
2362 uint64_t Address, const void *Decoder) {
2363 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2364 unsigned add = fieldFromInstruction32(Insn, 4, 1);
2366 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)) return false;
2367 Inst.addOperand(MCOperand::CreateImm(add));
2372 static bool DecodeThumbBLXOffset(llvm::MCInst &Inst, unsigned Val,
2373 uint64_t Address, const void *Decoder) {
2374 Inst.addOperand(MCOperand::CreateImm(SignExtend32<22>(Val << 1)));
2378 static bool DecodeCoprocessor(llvm::MCInst &Inst, unsigned Val,
2379 uint64_t Address, const void *Decoder) {
2380 if (Val == 0xA || Val == 0xB)
2383 Inst.addOperand(MCOperand::CreateImm(Val));
2387 static bool DecodeThumbSRImm(llvm::MCInst &Inst, unsigned Val,
2388 uint64_t Address, const void *Decoder) {
2390 Inst.addOperand(MCOperand::CreateImm(32));
2392 Inst.addOperand(MCOperand::CreateImm(Val));
2396 static bool DecodeThumb2BCCInstruction(llvm::MCInst &Inst, unsigned Insn,
2397 uint64_t Address, const void *Decoder) {
2398 unsigned pred = fieldFromInstruction32(Insn, 22, 4);
2399 if (pred == 0xE || pred == 0xF) {
2400 unsigned opc = fieldFromInstruction32(Insn, 4, 2);
2405 Inst.setOpcode(ARM::t2DSB);
2408 Inst.setOpcode(ARM::t2DMB);
2411 Inst.setOpcode(ARM::t2ISB);
2415 unsigned imm = fieldFromInstruction32(Insn, 0, 4);
2416 return DecodeMemBarrierOption(Inst, imm, Address, Decoder);
2419 unsigned brtarget = fieldFromInstruction32(Insn, 0, 11) << 1;
2420 brtarget |= fieldFromInstruction32(Insn, 11, 1) << 19;
2421 brtarget |= fieldFromInstruction32(Insn, 13, 1) << 18;
2422 brtarget |= fieldFromInstruction32(Insn, 16, 6) << 12;
2423 brtarget |= fieldFromInstruction32(Insn, 26, 1) << 20;
2425 if (!DecodeT2BROperand(Inst, brtarget, Address, Decoder) ||
2426 !DecodePredicateOperand(Inst, pred, Address, Decoder))
2432 // Decode a shifted immediate operand. These basically consist
2433 // of an 8-bit value, and a 4-bit directive that specifies either
2434 // a splat operation or a rotation.
2435 static bool DecodeT2SOImm(llvm::MCInst &Inst, unsigned Val,
2436 uint64_t Address, const void *Decoder) {
2437 unsigned ctrl = fieldFromInstruction32(Val, 10, 2);
2439 unsigned byte = fieldFromInstruction32(Val, 8, 2);
2440 unsigned imm = fieldFromInstruction32(Val, 0, 8);
2443 Inst.addOperand(MCOperand::CreateImm(imm));
2446 Inst.addOperand(MCOperand::CreateImm((imm << 16) | imm));
2449 Inst.addOperand(MCOperand::CreateImm((imm << 24) | (imm << 8)));
2452 Inst.addOperand(MCOperand::CreateImm((imm << 24) | (imm << 16) |
2457 unsigned unrot = fieldFromInstruction32(Val, 0, 7) | 0x80;
2458 unsigned rot = fieldFromInstruction32(Val, 7, 5);
2459 unsigned imm = (unrot >> rot) | (unrot << ((32-rot)&31));
2460 Inst.addOperand(MCOperand::CreateImm(imm));
2466 static bool DecodeThumbBCCTargetOperand(llvm::MCInst &Inst, unsigned Val,
2467 uint64_t Address, const void *Decoder){
2468 Inst.addOperand(MCOperand::CreateImm(Val << 1));
2472 static bool DecodeThumbBLTargetOperand(llvm::MCInst &Inst, unsigned Val,
2473 uint64_t Address, const void *Decoder){
2474 Inst.addOperand(MCOperand::CreateImm(SignExtend32<22>(Val << 1)));
2478 static bool DecodeMemBarrierOption(llvm::MCInst &Inst, unsigned Val,
2479 uint64_t Address, const void *Decoder) {
2494 Inst.addOperand(MCOperand::CreateImm(Val));
2498 static bool DecodeMSRMask(llvm::MCInst &Inst, unsigned Val,
2499 uint64_t Address, const void *Decoder) {
2500 if (!Val) return false;
2501 Inst.addOperand(MCOperand::CreateImm(Val));
2505 static bool DecodeDoubleRegLoad(llvm::MCInst &Inst, unsigned Insn,
2506 uint64_t Address, const void *Decoder) {
2507 unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
2508 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2509 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
2511 if ((Rt & 1) || Rt == 0xE || Rn == 0xF) return false;
2513 if (!DecodeGPRRegisterClass(Inst, Rt, Address, Decoder)) return false;
2514 if (!DecodeGPRRegisterClass(Inst, Rt+1, Address, Decoder)) return false;
2515 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
2516 if (!DecodePredicateOperand(Inst, pred, Address, Decoder)) return false;
2522 static bool DecodeDoubleRegStore(llvm::MCInst &Inst, unsigned Insn,
2523 uint64_t Address, const void *Decoder) {
2524 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2525 unsigned Rt = fieldFromInstruction32(Insn, 0, 4);
2526 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2527 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
2529 if (!DecoderGPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2531 if ((Rt & 1) || Rt == 0xE || Rn == 0xF) return false;
2532 if (Rd == Rn || Rd == Rt || Rd == Rt+1) return false;
2534 if (!DecodeGPRRegisterClass(Inst, Rt, Address, Decoder)) return false;
2535 if (!DecodeGPRRegisterClass(Inst, Rt+1, Address, Decoder)) return false;
2536 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
2537 if (!DecodePredicateOperand(Inst, pred, Address, Decoder)) return false;
2542 static bool DecodeSTRPreImm(llvm::MCInst &Inst, unsigned Insn,
2543 uint64_t Address, const void *Decoder) {
2544 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2545 unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
2546 unsigned imm = fieldFromInstruction32(Insn, 0, 12);
2547 imm |= fieldFromInstruction32(Insn, 16, 4) << 13;
2548 imm |= fieldFromInstruction32(Insn, 23, 1) << 12;
2549 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
2551 if (Rn == 0xF || Rn == Rt) return false; // UNPREDICTABLE
2553 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
2554 if (!DecodeGPRRegisterClass(Inst, Rt, Address, Decoder)) return false;
2555 if (!DecodeAddrModeImm12Operand(Inst, imm, Address, Decoder)) return false;
2556 if (!DecodePredicateOperand(Inst, pred, Address, Decoder)) return false;
2561 static bool DecodeSTRPreReg(llvm::MCInst &Inst, unsigned Insn,
2562 uint64_t Address, const void *Decoder) {
2563 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2564 unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
2565 unsigned imm = fieldFromInstruction32(Insn, 0, 12);
2566 imm |= fieldFromInstruction32(Insn, 16, 4) << 13;
2567 imm |= fieldFromInstruction32(Insn, 23, 1) << 12;
2568 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
2570 if (Rn == 0xF || Rn == Rt) return false; // UNPREDICTABLE
2572 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
2573 if (!DecodeGPRRegisterClass(Inst, Rt, Address, Decoder)) return false;
2574 if (!DecodeSORegMemOperand(Inst, imm, Address, Decoder)) return false;
2575 if (!DecodePredicateOperand(Inst, pred, Address, Decoder)) return false;
2580 static bool DecodeVLD1LN(llvm::MCInst &Inst, unsigned Insn,
2581 uint64_t Address, const void *Decoder) {
2582 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2583 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2584 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2585 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2586 unsigned size = fieldFromInstruction32(Insn, 10, 2);
2594 if (fieldFromInstruction32(Insn, 4, 1))
2595 return false; // UNDEFINED
2596 index = fieldFromInstruction32(Insn, 5, 3);
2599 if (fieldFromInstruction32(Insn, 5, 1))
2600 return false; // UNDEFINED
2601 index = fieldFromInstruction32(Insn, 6, 2);
2602 if (fieldFromInstruction32(Insn, 4, 1))
2606 if (fieldFromInstruction32(Insn, 6, 1))
2607 return false; // UNDEFINED
2608 index = fieldFromInstruction32(Insn, 7, 1);
2609 if (fieldFromInstruction32(Insn, 4, 2) != 0)
2613 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2614 if (Rm != 0xF) { // Writeback
2615 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder))
2618 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
2619 Inst.addOperand(MCOperand::CreateImm(align));
2620 if (Rm != 0xF && Rm != 0xD) {
2621 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder))
2625 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2626 Inst.addOperand(MCOperand::CreateImm(index));
2631 static bool DecodeVST1LN(llvm::MCInst &Inst, unsigned Insn,
2632 uint64_t Address, const void *Decoder) {
2633 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2634 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2635 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2636 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2637 unsigned size = fieldFromInstruction32(Insn, 10, 2);
2645 if (fieldFromInstruction32(Insn, 4, 1))
2646 return false; // UNDEFINED
2647 index = fieldFromInstruction32(Insn, 5, 3);
2650 if (fieldFromInstruction32(Insn, 5, 1))
2651 return false; // UNDEFINED
2652 index = fieldFromInstruction32(Insn, 6, 2);
2653 if (fieldFromInstruction32(Insn, 4, 1))
2657 if (fieldFromInstruction32(Insn, 6, 1))
2658 return false; // UNDEFINED
2659 index = fieldFromInstruction32(Insn, 7, 1);
2660 if (fieldFromInstruction32(Insn, 4, 2) != 0)
2664 if (Rm != 0xF) { // Writeback
2665 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder))
2668 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
2669 Inst.addOperand(MCOperand::CreateImm(align));
2670 if (Rm != 0xF && Rm != 0xD) {
2671 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder))
2675 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2676 Inst.addOperand(MCOperand::CreateImm(index));
2682 static bool DecodeVLD2LN(llvm::MCInst &Inst, unsigned Insn,
2683 uint64_t Address, const void *Decoder) {
2684 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2685 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2686 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2687 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2688 unsigned size = fieldFromInstruction32(Insn, 10, 2);
2697 index = fieldFromInstruction32(Insn, 5, 3);
2698 if (fieldFromInstruction32(Insn, 4, 1))
2702 index = fieldFromInstruction32(Insn, 6, 2);
2703 if (fieldFromInstruction32(Insn, 4, 1))
2705 if (fieldFromInstruction32(Insn, 5, 1))
2709 if (fieldFromInstruction32(Insn, 5, 1))
2710 return false; // UNDEFINED
2711 index = fieldFromInstruction32(Insn, 7, 1);
2712 if (fieldFromInstruction32(Insn, 4, 1) != 0)
2714 if (fieldFromInstruction32(Insn, 6, 1))
2719 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2720 if (!DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)) return false;
2721 if (Rm != 0xF) { // Writeback
2722 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder))
2725 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
2726 Inst.addOperand(MCOperand::CreateImm(align));
2727 if (Rm != 0xF && Rm != 0xD) {
2728 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder))
2732 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2733 if (!DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)) return false;
2734 Inst.addOperand(MCOperand::CreateImm(index));
2739 static bool DecodeVST2LN(llvm::MCInst &Inst, unsigned Insn,
2740 uint64_t Address, const void *Decoder) {
2741 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2742 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2743 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2744 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2745 unsigned size = fieldFromInstruction32(Insn, 10, 2);
2754 index = fieldFromInstruction32(Insn, 5, 3);
2755 if (fieldFromInstruction32(Insn, 4, 1))
2759 index = fieldFromInstruction32(Insn, 6, 2);
2760 if (fieldFromInstruction32(Insn, 4, 1))
2762 if (fieldFromInstruction32(Insn, 5, 1))
2766 if (fieldFromInstruction32(Insn, 5, 1))
2767 return false; // UNDEFINED
2768 index = fieldFromInstruction32(Insn, 7, 1);
2769 if (fieldFromInstruction32(Insn, 4, 1) != 0)
2771 if (fieldFromInstruction32(Insn, 6, 1))
2776 if (Rm != 0xF) { // Writeback
2777 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder))
2780 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
2781 Inst.addOperand(MCOperand::CreateImm(align));
2782 if (Rm != 0xF && Rm != 0xD) {
2783 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder))
2787 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2788 if (!DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)) return false;
2789 Inst.addOperand(MCOperand::CreateImm(index));
2795 static bool DecodeVLD3LN(llvm::MCInst &Inst, unsigned Insn,
2796 uint64_t Address, const void *Decoder) {
2797 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2798 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2799 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2800 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2801 unsigned size = fieldFromInstruction32(Insn, 10, 2);
2810 if (fieldFromInstruction32(Insn, 4, 1))
2811 return false; // UNDEFINED
2812 index = fieldFromInstruction32(Insn, 5, 3);
2815 if (fieldFromInstruction32(Insn, 4, 1))
2816 return false; // UNDEFINED
2817 index = fieldFromInstruction32(Insn, 6, 2);
2818 if (fieldFromInstruction32(Insn, 5, 1))
2822 if (fieldFromInstruction32(Insn, 4, 2))
2823 return false; // UNDEFINED
2824 index = fieldFromInstruction32(Insn, 7, 1);
2825 if (fieldFromInstruction32(Insn, 6, 1))
2830 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2831 if (!DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)) return false;
2832 if (!DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder)) return false;
2834 if (Rm != 0xF) { // Writeback
2835 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder))
2838 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
2839 Inst.addOperand(MCOperand::CreateImm(align));
2840 if (Rm != 0xF && Rm != 0xD) {
2841 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder))
2845 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2846 if (!DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)) return false;
2847 if (!DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder)) return false;
2848 Inst.addOperand(MCOperand::CreateImm(index));
2853 static bool DecodeVST3LN(llvm::MCInst &Inst, unsigned Insn,
2854 uint64_t Address, const void *Decoder) {
2855 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2856 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2857 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2858 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2859 unsigned size = fieldFromInstruction32(Insn, 10, 2);
2868 if (fieldFromInstruction32(Insn, 4, 1))
2869 return false; // UNDEFINED
2870 index = fieldFromInstruction32(Insn, 5, 3);
2873 if (fieldFromInstruction32(Insn, 4, 1))
2874 return false; // UNDEFINED
2875 index = fieldFromInstruction32(Insn, 6, 2);
2876 if (fieldFromInstruction32(Insn, 5, 1))
2880 if (fieldFromInstruction32(Insn, 4, 2))
2881 return false; // UNDEFINED
2882 index = fieldFromInstruction32(Insn, 7, 1);
2883 if (fieldFromInstruction32(Insn, 6, 1))
2888 if (Rm != 0xF) { // Writeback
2889 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder))
2892 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
2893 Inst.addOperand(MCOperand::CreateImm(align));
2894 if (Rm != 0xF && Rm != 0xD) {
2895 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder))
2899 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2900 if (!DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)) return false;
2901 if (!DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder)) return false;
2902 Inst.addOperand(MCOperand::CreateImm(index));
2908 static bool DecodeVLD4LN(llvm::MCInst &Inst, unsigned Insn,
2909 uint64_t Address, const void *Decoder) {
2910 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2911 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2912 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2913 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2914 unsigned size = fieldFromInstruction32(Insn, 10, 2);
2923 if (fieldFromInstruction32(Insn, 4, 1))
2925 index = fieldFromInstruction32(Insn, 5, 3);
2928 if (fieldFromInstruction32(Insn, 4, 1))
2930 index = fieldFromInstruction32(Insn, 6, 2);
2931 if (fieldFromInstruction32(Insn, 5, 1))
2935 if (fieldFromInstruction32(Insn, 4, 2))
2936 align = 4 << fieldFromInstruction32(Insn, 4, 2);
2937 index = fieldFromInstruction32(Insn, 7, 1);
2938 if (fieldFromInstruction32(Insn, 6, 1))
2943 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2944 if (!DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)) return false;
2945 if (!DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder)) return false;
2946 if (!DecodeDPRRegisterClass(Inst, Rd+3*inc, Address, Decoder)) return false;
2948 if (Rm != 0xF) { // Writeback
2949 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder))
2952 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
2953 Inst.addOperand(MCOperand::CreateImm(align));
2954 if (Rm != 0xF && Rm != 0xD) {
2955 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder))
2959 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
2960 if (!DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)) return false;
2961 if (!DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder)) return false;
2962 if (!DecodeDPRRegisterClass(Inst, Rd+3*inc, Address, Decoder)) return false;
2963 Inst.addOperand(MCOperand::CreateImm(index));
2968 static bool DecodeVST4LN(llvm::MCInst &Inst, unsigned Insn,
2969 uint64_t Address, const void *Decoder) {
2970 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2971 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2972 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2973 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2974 unsigned size = fieldFromInstruction32(Insn, 10, 2);
2983 if (fieldFromInstruction32(Insn, 4, 1))
2985 index = fieldFromInstruction32(Insn, 5, 3);
2988 if (fieldFromInstruction32(Insn, 4, 1))
2990 index = fieldFromInstruction32(Insn, 6, 2);
2991 if (fieldFromInstruction32(Insn, 5, 1))
2995 if (fieldFromInstruction32(Insn, 4, 2))
2996 align = 4 << fieldFromInstruction32(Insn, 4, 2);
2997 index = fieldFromInstruction32(Insn, 7, 1);
2998 if (fieldFromInstruction32(Insn, 6, 1))
3003 if (Rm != 0xF) { // Writeback
3004 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder))
3007 if (!DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)) return false;
3008 Inst.addOperand(MCOperand::CreateImm(align));
3009 if (Rm != 0xF && Rm != 0xD) {
3010 if (!DecodeGPRRegisterClass(Inst, Rm, Address, Decoder))
3014 if (!DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)) return false;
3015 if (!DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)) return false;
3016 if (!DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder)) return false;
3017 if (!DecodeDPRRegisterClass(Inst, Rd+3*inc, Address, Decoder)) return false;
3018 Inst.addOperand(MCOperand::CreateImm(index));