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/Support/Debug.h"
22 #include "llvm/Support/MemoryObject.h"
23 #include "llvm/Support/ErrorHandling.h"
24 #include "llvm/Support/TargetRegistry.h"
25 #include "llvm/Support/raw_ostream.h"
27 // Pull DecodeStatus and its enum values into the global namespace.
28 typedef llvm::MCDisassembler::DecodeStatus DecodeStatus;
29 #define Success llvm::MCDisassembler::Success
30 #define Unpredictable llvm::MCDisassembler::SoftFail
31 #define Fail llvm::MCDisassembler::Fail
33 // Helper macro to perform setwise reduction of the current running status
34 // and another status, and return if the new status is Fail.
35 #define CHECK(S,X) do { \
36 S = (DecodeStatus) ((int)S & (X)); \
37 if (S == Fail) return Fail; \
40 // Forward declare these because the autogenerated code will reference them.
41 // Definitions are further down.
42 static DecodeStatus DecodeGPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
43 uint64_t Address, const void *Decoder);
44 static DecodeStatus DecodeGPRnopcRegisterClass(llvm::MCInst &Inst,
45 unsigned RegNo, uint64_t Address,
47 static DecodeStatus DecodetGPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
48 uint64_t Address, const void *Decoder);
49 static DecodeStatus DecodetcGPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
50 uint64_t Address, const void *Decoder);
51 static DecodeStatus DecoderGPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
52 uint64_t Address, const void *Decoder);
53 static DecodeStatus DecodeSPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
54 uint64_t Address, const void *Decoder);
55 static DecodeStatus DecodeDPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
56 uint64_t Address, const void *Decoder);
57 static DecodeStatus DecodeDPR_8RegisterClass(llvm::MCInst &Inst, unsigned RegNo,
58 uint64_t Address, const void *Decoder);
59 static DecodeStatus DecodeDPR_VFP2RegisterClass(llvm::MCInst &Inst,
63 static DecodeStatus DecodeQPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
64 uint64_t Address, const void *Decoder);
66 static DecodeStatus DecodePredicateOperand(llvm::MCInst &Inst, unsigned Val,
67 uint64_t Address, const void *Decoder);
68 static DecodeStatus DecodeCCOutOperand(llvm::MCInst &Inst, unsigned Val,
69 uint64_t Address, const void *Decoder);
70 static DecodeStatus DecodeSOImmOperand(llvm::MCInst &Inst, unsigned Val,
71 uint64_t Address, const void *Decoder);
72 static DecodeStatus DecodeBLTargetOperand(llvm::MCInst &Inst, unsigned Val,
73 uint64_t Address, const void *Decoder);
74 static DecodeStatus DecodeRegListOperand(llvm::MCInst &Inst, unsigned Val,
75 uint64_t Address, const void *Decoder);
76 static DecodeStatus DecodeSPRRegListOperand(llvm::MCInst &Inst, unsigned Val,
77 uint64_t Address, const void *Decoder);
78 static DecodeStatus DecodeDPRRegListOperand(llvm::MCInst &Inst, unsigned Val,
79 uint64_t Address, const void *Decoder);
81 static DecodeStatus DecodeBitfieldMaskOperand(llvm::MCInst &Inst, unsigned Insn,
82 uint64_t Address, const void *Decoder);
83 static DecodeStatus DecodeCopMemInstruction(llvm::MCInst &Inst, unsigned Insn,
84 uint64_t Address, const void *Decoder);
85 static DecodeStatus DecodeAddrMode2IdxInstruction(llvm::MCInst &Inst,
89 static DecodeStatus DecodeSORegMemOperand(llvm::MCInst &Inst, unsigned Insn,
90 uint64_t Address, const void *Decoder);
91 static DecodeStatus DecodeAddrMode3Instruction(llvm::MCInst &Inst,unsigned Insn,
92 uint64_t Address, const void *Decoder);
93 static DecodeStatus DecodeSORegImmOperand(llvm::MCInst &Inst, unsigned Insn,
94 uint64_t Address, const void *Decoder);
95 static DecodeStatus DecodeSORegRegOperand(llvm::MCInst &Inst, unsigned Insn,
96 uint64_t Address, const void *Decoder);
98 static DecodeStatus DecodeMemMultipleWritebackInstruction(llvm::MCInst & Inst,
101 const void *Decoder);
102 static DecodeStatus DecodeSMLAInstruction(llvm::MCInst &Inst, unsigned Insn,
103 uint64_t Address, const void *Decoder);
104 static DecodeStatus DecodeCPSInstruction(llvm::MCInst &Inst, unsigned Insn,
105 uint64_t Address, const void *Decoder);
106 static DecodeStatus DecodeT2CPSInstruction(llvm::MCInst &Inst, unsigned Insn,
107 uint64_t Address, const void *Decoder);
108 static DecodeStatus DecodeAddrModeImm12Operand(llvm::MCInst &Inst, unsigned Val,
109 uint64_t Address, const void *Decoder);
110 static DecodeStatus DecodeAddrMode5Operand(llvm::MCInst &Inst, unsigned Val,
111 uint64_t Address, const void *Decoder);
112 static DecodeStatus DecodeAddrMode7Operand(llvm::MCInst &Inst, unsigned Val,
113 uint64_t Address, const void *Decoder);
114 static DecodeStatus DecodeBranchImmInstruction(llvm::MCInst &Inst,unsigned Insn,
115 uint64_t Address, const void *Decoder);
116 static DecodeStatus DecodeVCVTImmOperand(llvm::MCInst &Inst, unsigned Val,
117 uint64_t Address, const void *Decoder);
118 static DecodeStatus DecodeAddrMode6Operand(llvm::MCInst &Inst, unsigned Val,
119 uint64_t Address, const void *Decoder);
120 static DecodeStatus DecodeVLDInstruction(llvm::MCInst &Inst, unsigned Val,
121 uint64_t Address, const void *Decoder);
122 static DecodeStatus DecodeVSTInstruction(llvm::MCInst &Inst, unsigned Val,
123 uint64_t Address, const void *Decoder);
124 static DecodeStatus DecodeVLD1DupInstruction(llvm::MCInst &Inst, unsigned Val,
125 uint64_t Address, const void *Decoder);
126 static DecodeStatus DecodeVLD2DupInstruction(llvm::MCInst &Inst, unsigned Val,
127 uint64_t Address, const void *Decoder);
128 static DecodeStatus DecodeVLD3DupInstruction(llvm::MCInst &Inst, unsigned Val,
129 uint64_t Address, const void *Decoder);
130 static DecodeStatus DecodeVLD4DupInstruction(llvm::MCInst &Inst, unsigned Val,
131 uint64_t Address, const void *Decoder);
132 static DecodeStatus DecodeNEONModImmInstruction(llvm::MCInst &Inst,unsigned Val,
133 uint64_t Address, const void *Decoder);
134 static DecodeStatus DecodeVSHLMaxInstruction(llvm::MCInst &Inst, unsigned Val,
135 uint64_t Address, const void *Decoder);
136 static DecodeStatus DecodeShiftRight8Imm(llvm::MCInst &Inst, unsigned Val,
137 uint64_t Address, const void *Decoder);
138 static DecodeStatus DecodeShiftRight16Imm(llvm::MCInst &Inst, unsigned Val,
139 uint64_t Address, const void *Decoder);
140 static DecodeStatus DecodeShiftRight32Imm(llvm::MCInst &Inst, unsigned Val,
141 uint64_t Address, const void *Decoder);
142 static DecodeStatus DecodeShiftRight64Imm(llvm::MCInst &Inst, unsigned Val,
143 uint64_t Address, const void *Decoder);
144 static DecodeStatus DecodeTBLInstruction(llvm::MCInst &Inst, unsigned Insn,
145 uint64_t Address, const void *Decoder);
146 static DecodeStatus DecodeVFPfpImm(llvm::MCInst &Inst, unsigned Val,
147 uint64_t Address, const void *Decoder);
148 static DecodeStatus DecodePostIdxReg(llvm::MCInst &Inst, unsigned Insn,
149 uint64_t Address, const void *Decoder);
150 static DecodeStatus DecodeCoprocessor(llvm::MCInst &Inst, unsigned Insn,
151 uint64_t Address, const void *Decoder);
152 static DecodeStatus DecodeMemBarrierOption(llvm::MCInst &Inst, unsigned Insn,
153 uint64_t Address, const void *Decoder);
154 static DecodeStatus DecodeMSRMask(llvm::MCInst &Inst, unsigned Insn,
155 uint64_t Address, const void *Decoder);
156 static DecodeStatus DecodeDoubleRegLoad(llvm::MCInst &Inst, unsigned Insn,
157 uint64_t Address, const void *Decoder);
158 static DecodeStatus DecodeDoubleRegStore(llvm::MCInst &Inst, unsigned Insn,
159 uint64_t Address, const void *Decoder);
160 static DecodeStatus DecodeLDRPreImm(llvm::MCInst &Inst, unsigned Insn,
161 uint64_t Address, const void *Decoder);
162 static DecodeStatus DecodeLDRPreReg(llvm::MCInst &Inst, unsigned Insn,
163 uint64_t Address, const void *Decoder);
164 static DecodeStatus DecodeSTRPreImm(llvm::MCInst &Inst, unsigned Insn,
165 uint64_t Address, const void *Decoder);
166 static DecodeStatus DecodeSTRPreReg(llvm::MCInst &Inst, unsigned Insn,
167 uint64_t Address, const void *Decoder);
168 static DecodeStatus DecodeVLD1LN(llvm::MCInst &Inst, unsigned Insn,
169 uint64_t Address, const void *Decoder);
170 static DecodeStatus DecodeVLD2LN(llvm::MCInst &Inst, unsigned Insn,
171 uint64_t Address, const void *Decoder);
172 static DecodeStatus DecodeVLD3LN(llvm::MCInst &Inst, unsigned Insn,
173 uint64_t Address, const void *Decoder);
174 static DecodeStatus DecodeVLD4LN(llvm::MCInst &Inst, unsigned Insn,
175 uint64_t Address, const void *Decoder);
176 static DecodeStatus DecodeVST1LN(llvm::MCInst &Inst, unsigned Insn,
177 uint64_t Address, const void *Decoder);
178 static DecodeStatus DecodeVST2LN(llvm::MCInst &Inst, unsigned Insn,
179 uint64_t Address, const void *Decoder);
180 static DecodeStatus DecodeVST3LN(llvm::MCInst &Inst, unsigned Insn,
181 uint64_t Address, const void *Decoder);
182 static DecodeStatus DecodeVST4LN(llvm::MCInst &Inst, unsigned Insn,
183 uint64_t Address, const void *Decoder);
184 static DecodeStatus DecodeVMOVSRR(llvm::MCInst &Inst, unsigned Insn,
185 uint64_t Address, const void *Decoder);
186 static DecodeStatus DecodeVMOVRRS(llvm::MCInst &Inst, unsigned Insn,
187 uint64_t Address, const void *Decoder);
189 static DecodeStatus DecodeThumbAddSpecialReg(llvm::MCInst &Inst, uint16_t Insn,
190 uint64_t Address, const void *Decoder);
191 static DecodeStatus DecodeThumbBROperand(llvm::MCInst &Inst, unsigned Val,
192 uint64_t Address, const void *Decoder);
193 static DecodeStatus DecodeT2BROperand(llvm::MCInst &Inst, unsigned Val,
194 uint64_t Address, const void *Decoder);
195 static DecodeStatus DecodeThumbCmpBROperand(llvm::MCInst &Inst, unsigned Val,
196 uint64_t Address, const void *Decoder);
197 static DecodeStatus DecodeThumbAddrModeRR(llvm::MCInst &Inst, unsigned Val,
198 uint64_t Address, const void *Decoder);
199 static DecodeStatus DecodeThumbAddrModeIS(llvm::MCInst &Inst, unsigned Val,
200 uint64_t Address, const void *Decoder);
201 static DecodeStatus DecodeThumbAddrModePC(llvm::MCInst &Inst, unsigned Val,
202 uint64_t Address, const void *Decoder);
203 static DecodeStatus DecodeThumbAddrModeSP(llvm::MCInst &Inst, unsigned Val,
204 uint64_t Address, const void *Decoder);
205 static DecodeStatus DecodeT2AddrModeSOReg(llvm::MCInst &Inst, unsigned Val,
206 uint64_t Address, const void *Decoder);
207 static DecodeStatus DecodeT2LoadShift(llvm::MCInst &Inst, unsigned Val,
208 uint64_t Address, const void *Decoder);
209 static DecodeStatus DecodeT2Imm8S4(llvm::MCInst &Inst, unsigned Val,
210 uint64_t Address, const void *Decoder);
211 static DecodeStatus DecodeT2AddrModeImm8s4(llvm::MCInst &Inst, unsigned Val,
212 uint64_t Address, const void *Decoder);
213 static DecodeStatus DecodeT2Imm8(llvm::MCInst &Inst, unsigned Val,
214 uint64_t Address, const void *Decoder);
215 static DecodeStatus DecodeT2AddrModeImm8(llvm::MCInst &Inst, unsigned Val,
216 uint64_t Address, const void *Decoder);
217 static DecodeStatus DecodeThumbAddSPImm(llvm::MCInst &Inst, uint16_t Val,
218 uint64_t Address, const void *Decoder);
219 static DecodeStatus DecodeThumbAddSPReg(llvm::MCInst &Inst, uint16_t Insn,
220 uint64_t Address, const void *Decoder);
221 static DecodeStatus DecodeThumbCPS(llvm::MCInst &Inst, uint16_t Insn,
222 uint64_t Address, const void *Decoder);
223 static DecodeStatus DecodeThumbBLXOffset(llvm::MCInst &Inst, unsigned Insn,
224 uint64_t Address, const void *Decoder);
225 static DecodeStatus DecodeT2AddrModeImm12(llvm::MCInst &Inst, unsigned Val,
226 uint64_t Address, const void *Decoder);
227 static DecodeStatus DecodeThumb2BCCInstruction(llvm::MCInst &Inst, unsigned Val,
228 uint64_t Address, const void *Decoder);
229 static DecodeStatus DecodeT2SOImm(llvm::MCInst &Inst, unsigned Val,
230 uint64_t Address, const void *Decoder);
231 static DecodeStatus DecodeThumbBCCTargetOperand(llvm::MCInst &Inst,unsigned Val,
232 uint64_t Address, const void *Decoder);
233 static DecodeStatus DecodeThumbBLTargetOperand(llvm::MCInst &Inst, unsigned Val,
234 uint64_t Address, const void *Decoder);
235 static DecodeStatus DecodeITCond(llvm::MCInst &Inst, unsigned Val,
236 uint64_t Address, const void *Decoder);
237 static DecodeStatus DecodeITMask(llvm::MCInst &Inst, unsigned Val,
238 uint64_t Address, const void *Decoder);
240 #include "ARMGenDisassemblerTables.inc"
241 #include "ARMGenInstrInfo.inc"
242 #include "ARMGenEDInfo.inc"
244 using namespace llvm;
246 static MCDisassembler *createARMDisassembler(const Target &T) {
247 return new ARMDisassembler;
250 static MCDisassembler *createThumbDisassembler(const Target &T) {
251 return new ThumbDisassembler;
254 EDInstInfo *ARMDisassembler::getEDInfo() const {
258 EDInstInfo *ThumbDisassembler::getEDInfo() const {
262 DecodeStatus ARMDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
263 const MemoryObject &Region,
265 raw_ostream &os) const {
268 // We want to read exactly 4 bytes of data.
269 if (Region.readBytes(Address, 4, (uint8_t*)bytes, NULL) == -1) {
274 // Encoded as a small-endian 32-bit word in the stream.
275 uint32_t insn = (bytes[3] << 24) |
280 // Calling the auto-generated decoder function.
281 DecodeStatus result = decodeARMInstruction32(MI, insn, Address, this);
282 if (result != Fail) {
287 // Instructions that are shared between ARM and Thumb modes.
288 // FIXME: This shouldn't really exist. It's an artifact of the
289 // fact that we fail to encode a few instructions properly for Thumb.
291 result = decodeCommonInstruction32(MI, insn, Address, this);
292 if (result != Fail) {
297 // VFP and NEON instructions, similarly, are shared between ARM
300 result = decodeVFPInstruction32(MI, insn, Address, this);
301 if (result != Fail) {
307 result = decodeNEONDataInstruction32(MI, insn, Address, this);
308 if (result != Fail) {
310 // Add a fake predicate operand, because we share these instruction
311 // definitions with Thumb2 where these instructions are predicable.
312 if (!DecodePredicateOperand(MI, 0xE, Address, this)) return Fail;
317 result = decodeNEONLoadStoreInstruction32(MI, insn, Address, this);
318 if (result != Fail) {
320 // Add a fake predicate operand, because we share these instruction
321 // definitions with Thumb2 where these instructions are predicable.
322 if (!DecodePredicateOperand(MI, 0xE, Address, this)) return Fail;
327 result = decodeNEONDupInstruction32(MI, insn, Address, this);
328 if (result != Fail) {
330 // Add a fake predicate operand, because we share these instruction
331 // definitions with Thumb2 where these instructions are predicable.
332 if (!DecodePredicateOperand(MI, 0xE, Address, this)) return Fail;
343 extern MCInstrDesc ARMInsts[];
346 // Thumb1 instructions don't have explicit S bits. Rather, they
347 // implicitly set CPSR. Since it's not represented in the encoding, the
348 // auto-generated decoder won't inject the CPSR operand. We need to fix
349 // that as a post-pass.
350 static void AddThumb1SBit(MCInst &MI, bool InITBlock) {
351 const MCOperandInfo *OpInfo = ARMInsts[MI.getOpcode()].OpInfo;
352 unsigned short NumOps = ARMInsts[MI.getOpcode()].NumOperands;
353 MCInst::iterator I = MI.begin();
354 for (unsigned i = 0; i < NumOps; ++i, ++I) {
355 if (I == MI.end()) break;
356 if (OpInfo[i].isOptionalDef() && OpInfo[i].RegClass == ARM::CCRRegClassID) {
357 if (i > 0 && OpInfo[i-1].isPredicate()) continue;
358 MI.insert(I, MCOperand::CreateReg(InITBlock ? 0 : ARM::CPSR));
363 MI.insert(I, MCOperand::CreateReg(InITBlock ? 0 : ARM::CPSR));
366 // Most Thumb instructions don't have explicit predicates in the
367 // encoding, but rather get their predicates from IT context. We need
368 // to fix up the predicate operands using this context information as a
370 void ThumbDisassembler::AddThumbPredicate(MCInst &MI) const {
371 // A few instructions actually have predicates encoded in them. Don't
372 // try to overwrite it if we're seeing one of those.
373 switch (MI.getOpcode()) {
381 // If we're in an IT block, base the predicate on that. Otherwise,
382 // assume a predicate of AL.
384 if (!ITBlock.empty()) {
392 const MCOperandInfo *OpInfo = ARMInsts[MI.getOpcode()].OpInfo;
393 unsigned short NumOps = ARMInsts[MI.getOpcode()].NumOperands;
394 MCInst::iterator I = MI.begin();
395 for (unsigned i = 0; i < NumOps; ++i, ++I) {
396 if (I == MI.end()) break;
397 if (OpInfo[i].isPredicate()) {
398 I = MI.insert(I, MCOperand::CreateImm(CC));
401 MI.insert(I, MCOperand::CreateReg(0));
403 MI.insert(I, MCOperand::CreateReg(ARM::CPSR));
408 I = MI.insert(I, MCOperand::CreateImm(CC));
411 MI.insert(I, MCOperand::CreateReg(0));
413 MI.insert(I, MCOperand::CreateReg(ARM::CPSR));
416 // Thumb VFP instructions are a special case. Because we share their
417 // encodings between ARM and Thumb modes, and they are predicable in ARM
418 // mode, the auto-generated decoder will give them an (incorrect)
419 // predicate operand. We need to rewrite these operands based on the IT
420 // context as a post-pass.
421 void ThumbDisassembler::UpdateThumbVFPPredicate(MCInst &MI) const {
423 if (!ITBlock.empty()) {
429 const MCOperandInfo *OpInfo = ARMInsts[MI.getOpcode()].OpInfo;
430 MCInst::iterator I = MI.begin();
431 unsigned short NumOps = ARMInsts[MI.getOpcode()].NumOperands;
432 for (unsigned i = 0; i < NumOps; ++i, ++I) {
433 if (OpInfo[i].isPredicate() ) {
439 I->setReg(ARM::CPSR);
445 DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
446 const MemoryObject &Region,
448 raw_ostream &os) const {
451 // We want to read exactly 2 bytes of data.
452 if (Region.readBytes(Address, 2, (uint8_t*)bytes, NULL) == -1) {
457 uint16_t insn16 = (bytes[1] << 8) | bytes[0];
458 DecodeStatus result = decodeThumbInstruction16(MI, insn16, Address, this);
459 if (result != Fail) {
461 AddThumbPredicate(MI);
466 result = decodeThumbSBitInstruction16(MI, insn16, Address, this);
469 bool InITBlock = !ITBlock.empty();
470 AddThumbPredicate(MI);
471 AddThumb1SBit(MI, InITBlock);
476 result = decodeThumb2Instruction16(MI, insn16, Address, this);
477 if (result != Fail) {
479 AddThumbPredicate(MI);
481 // If we find an IT instruction, we need to parse its condition
482 // code and mask operands so that we can apply them correctly
483 // to the subsequent instructions.
484 if (MI.getOpcode() == ARM::t2IT) {
485 unsigned firstcond = MI.getOperand(0).getImm();
486 uint32_t mask = MI.getOperand(1).getImm();
487 unsigned zeros = CountTrailingZeros_32(mask);
490 for (unsigned i = 0; i < 4 - (zeros+1); ++i) {
491 if (firstcond ^ (mask & 1))
492 ITBlock.push_back(firstcond ^ 1);
494 ITBlock.push_back(firstcond);
497 ITBlock.push_back(firstcond);
503 // We want to read exactly 4 bytes of data.
504 if (Region.readBytes(Address, 4, (uint8_t*)bytes, NULL) == -1) {
509 uint32_t insn32 = (bytes[3] << 8) |
514 result = decodeThumbInstruction32(MI, insn32, Address, this);
515 if (result != Fail) {
517 bool InITBlock = ITBlock.size();
518 AddThumbPredicate(MI);
519 AddThumb1SBit(MI, InITBlock);
524 result = decodeThumb2Instruction32(MI, insn32, Address, this);
525 if (result != Fail) {
527 AddThumbPredicate(MI);
532 result = decodeCommonInstruction32(MI, insn32, Address, this);
533 if (result != Fail) {
535 AddThumbPredicate(MI);
540 result = decodeVFPInstruction32(MI, insn32, Address, this);
541 if (result != Fail) {
543 UpdateThumbVFPPredicate(MI);
548 result = decodeNEONDupInstruction32(MI, insn32, Address, this);
549 if (result != Fail) {
551 AddThumbPredicate(MI);
555 if (fieldFromInstruction32(insn32, 24, 8) == 0xF9) {
557 uint32_t NEONLdStInsn = insn32;
558 NEONLdStInsn &= 0xF0FFFFFF;
559 NEONLdStInsn |= 0x04000000;
560 result = decodeNEONLoadStoreInstruction32(MI, NEONLdStInsn, Address, this);
561 if (result != Fail) {
563 AddThumbPredicate(MI);
568 if (fieldFromInstruction32(insn32, 24, 4) == 0xF) {
570 uint32_t NEONDataInsn = insn32;
571 NEONDataInsn &= 0xF0FFFFFF; // Clear bits 27-24
572 NEONDataInsn |= (NEONDataInsn & 0x10000000) >> 4; // Move bit 28 to bit 24
573 NEONDataInsn |= 0x12000000; // Set bits 28 and 25
574 result = decodeNEONDataInstruction32(MI, NEONDataInsn, Address, this);
575 if (result != Fail) {
577 AddThumbPredicate(MI);
587 extern "C" void LLVMInitializeARMDisassembler() {
588 TargetRegistry::RegisterMCDisassembler(TheARMTarget,
589 createARMDisassembler);
590 TargetRegistry::RegisterMCDisassembler(TheThumbTarget,
591 createThumbDisassembler);
594 static const unsigned GPRDecoderTable[] = {
595 ARM::R0, ARM::R1, ARM::R2, ARM::R3,
596 ARM::R4, ARM::R5, ARM::R6, ARM::R7,
597 ARM::R8, ARM::R9, ARM::R10, ARM::R11,
598 ARM::R12, ARM::SP, ARM::LR, ARM::PC
601 static DecodeStatus DecodeGPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
602 uint64_t Address, const void *Decoder) {
606 unsigned Register = GPRDecoderTable[RegNo];
607 Inst.addOperand(MCOperand::CreateReg(Register));
612 DecodeGPRnopcRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
613 uint64_t Address, const void *Decoder) {
614 if (RegNo == 15) return Fail;
615 return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);
618 static DecodeStatus DecodetGPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
619 uint64_t Address, const void *Decoder) {
622 return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);
625 static DecodeStatus DecodetcGPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
626 uint64_t Address, const void *Decoder) {
627 unsigned Register = 0;
651 Inst.addOperand(MCOperand::CreateReg(Register));
655 static DecodeStatus DecoderGPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
656 uint64_t Address, const void *Decoder) {
657 if (RegNo == 13 || RegNo == 15) return Fail;
658 return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);
661 static const unsigned SPRDecoderTable[] = {
662 ARM::S0, ARM::S1, ARM::S2, ARM::S3,
663 ARM::S4, ARM::S5, ARM::S6, ARM::S7,
664 ARM::S8, ARM::S9, ARM::S10, ARM::S11,
665 ARM::S12, ARM::S13, ARM::S14, ARM::S15,
666 ARM::S16, ARM::S17, ARM::S18, ARM::S19,
667 ARM::S20, ARM::S21, ARM::S22, ARM::S23,
668 ARM::S24, ARM::S25, ARM::S26, ARM::S27,
669 ARM::S28, ARM::S29, ARM::S30, ARM::S31
672 static DecodeStatus DecodeSPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
673 uint64_t Address, const void *Decoder) {
677 unsigned Register = SPRDecoderTable[RegNo];
678 Inst.addOperand(MCOperand::CreateReg(Register));
682 static const unsigned DPRDecoderTable[] = {
683 ARM::D0, ARM::D1, ARM::D2, ARM::D3,
684 ARM::D4, ARM::D5, ARM::D6, ARM::D7,
685 ARM::D8, ARM::D9, ARM::D10, ARM::D11,
686 ARM::D12, ARM::D13, ARM::D14, ARM::D15,
687 ARM::D16, ARM::D17, ARM::D18, ARM::D19,
688 ARM::D20, ARM::D21, ARM::D22, ARM::D23,
689 ARM::D24, ARM::D25, ARM::D26, ARM::D27,
690 ARM::D28, ARM::D29, ARM::D30, ARM::D31
693 static DecodeStatus DecodeDPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
694 uint64_t Address, const void *Decoder) {
698 unsigned Register = DPRDecoderTable[RegNo];
699 Inst.addOperand(MCOperand::CreateReg(Register));
703 static DecodeStatus DecodeDPR_8RegisterClass(llvm::MCInst &Inst, unsigned RegNo,
704 uint64_t Address, const void *Decoder) {
707 return DecodeDPRRegisterClass(Inst, RegNo, Address, Decoder);
711 DecodeDPR_VFP2RegisterClass(llvm::MCInst &Inst, unsigned RegNo,
712 uint64_t Address, const void *Decoder) {
715 return DecodeDPRRegisterClass(Inst, RegNo, Address, Decoder);
718 static const unsigned QPRDecoderTable[] = {
719 ARM::Q0, ARM::Q1, ARM::Q2, ARM::Q3,
720 ARM::Q4, ARM::Q5, ARM::Q6, ARM::Q7,
721 ARM::Q8, ARM::Q9, ARM::Q10, ARM::Q11,
722 ARM::Q12, ARM::Q13, ARM::Q14, ARM::Q15
726 static DecodeStatus DecodeQPRRegisterClass(llvm::MCInst &Inst, unsigned RegNo,
727 uint64_t Address, const void *Decoder) {
732 unsigned Register = QPRDecoderTable[RegNo];
733 Inst.addOperand(MCOperand::CreateReg(Register));
737 static DecodeStatus DecodePredicateOperand(llvm::MCInst &Inst, unsigned Val,
738 uint64_t Address, const void *Decoder) {
739 if (Val == 0xF) return Fail;
740 // AL predicate is not allowed on Thumb1 branches.
741 if (Inst.getOpcode() == ARM::tBcc && Val == 0xE)
743 Inst.addOperand(MCOperand::CreateImm(Val));
744 if (Val == ARMCC::AL) {
745 Inst.addOperand(MCOperand::CreateReg(0));
747 Inst.addOperand(MCOperand::CreateReg(ARM::CPSR));
751 static DecodeStatus DecodeCCOutOperand(llvm::MCInst &Inst, unsigned Val,
752 uint64_t Address, const void *Decoder) {
754 Inst.addOperand(MCOperand::CreateReg(ARM::CPSR));
756 Inst.addOperand(MCOperand::CreateReg(0));
760 static DecodeStatus DecodeSOImmOperand(llvm::MCInst &Inst, unsigned Val,
761 uint64_t Address, const void *Decoder) {
762 uint32_t imm = Val & 0xFF;
763 uint32_t rot = (Val & 0xF00) >> 7;
764 uint32_t rot_imm = (imm >> rot) | (imm << (32-rot));
765 Inst.addOperand(MCOperand::CreateImm(rot_imm));
769 static DecodeStatus DecodeBLTargetOperand(llvm::MCInst &Inst, unsigned Val,
770 uint64_t Address, const void *Decoder) {
772 Inst.addOperand(MCOperand::CreateImm(SignExtend32<26>(Val)));
776 static DecodeStatus DecodeSORegImmOperand(llvm::MCInst &Inst, unsigned Val,
777 uint64_t Address, const void *Decoder) {
778 DecodeStatus S = Success;
780 unsigned Rm = fieldFromInstruction32(Val, 0, 4);
781 unsigned type = fieldFromInstruction32(Val, 5, 2);
782 unsigned imm = fieldFromInstruction32(Val, 7, 5);
784 // Register-immediate
785 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
787 ARM_AM::ShiftOpc Shift = ARM_AM::lsl;
803 if (Shift == ARM_AM::ror && imm == 0)
806 unsigned Op = Shift | (imm << 3);
807 Inst.addOperand(MCOperand::CreateImm(Op));
812 static DecodeStatus DecodeSORegRegOperand(llvm::MCInst &Inst, unsigned Val,
813 uint64_t Address, const void *Decoder) {
814 DecodeStatus S = Success;
816 unsigned Rm = fieldFromInstruction32(Val, 0, 4);
817 unsigned type = fieldFromInstruction32(Val, 5, 2);
818 unsigned Rs = fieldFromInstruction32(Val, 8, 4);
821 CHECK(S, DecodeGPRnopcRegisterClass(Inst, Rm, Address, Decoder));
822 CHECK(S, DecodeGPRnopcRegisterClass(Inst, Rs, Address, Decoder));
824 ARM_AM::ShiftOpc Shift = ARM_AM::lsl;
840 Inst.addOperand(MCOperand::CreateImm(Shift));
845 static DecodeStatus DecodeRegListOperand(llvm::MCInst &Inst, unsigned Val,
846 uint64_t Address, const void *Decoder) {
847 DecodeStatus S = Success;
849 // Empty register lists are not allowed.
850 if (CountPopulation_32(Val) == 0) return Fail;
851 for (unsigned i = 0; i < 16; ++i) {
852 if (Val & (1 << i)) {
853 CHECK(S, DecodeGPRRegisterClass(Inst, i, Address, Decoder));
860 static DecodeStatus DecodeSPRRegListOperand(llvm::MCInst &Inst, unsigned Val,
861 uint64_t Address, const void *Decoder) {
862 DecodeStatus S = Success;
864 unsigned Vd = fieldFromInstruction32(Val, 8, 4);
865 unsigned regs = Val & 0xFF;
867 CHECK(S, DecodeSPRRegisterClass(Inst, Vd, Address, Decoder));
868 for (unsigned i = 0; i < (regs - 1); ++i) {
869 CHECK(S, DecodeSPRRegisterClass(Inst, ++Vd, Address, Decoder));
875 static DecodeStatus DecodeDPRRegListOperand(llvm::MCInst &Inst, unsigned Val,
876 uint64_t Address, const void *Decoder) {
877 DecodeStatus S = Success;
879 unsigned Vd = fieldFromInstruction32(Val, 8, 4);
880 unsigned regs = (Val & 0xFF) / 2;
882 CHECK(S, DecodeDPRRegisterClass(Inst, Vd, Address, Decoder));
883 for (unsigned i = 0; i < (regs - 1); ++i) {
884 CHECK(S, DecodeDPRRegisterClass(Inst, ++Vd, Address, Decoder));
890 static DecodeStatus DecodeBitfieldMaskOperand(llvm::MCInst &Inst, unsigned Val,
891 uint64_t Address, const void *Decoder) {
892 // This operand encodes a mask of contiguous zeros between a specified MSB
893 // and LSB. To decode it, we create the mask of all bits MSB-and-lower,
894 // the mask of all bits LSB-and-lower, and then xor them to create
895 // the mask of that's all ones on [msb, lsb]. Finally we not it to
896 // create the final mask.
897 unsigned msb = fieldFromInstruction32(Val, 5, 5);
898 unsigned lsb = fieldFromInstruction32(Val, 0, 5);
899 uint32_t msb_mask = (1 << (msb+1)) - 1;
900 uint32_t lsb_mask = (1 << lsb) - 1;
901 Inst.addOperand(MCOperand::CreateImm(~(msb_mask ^ lsb_mask)));
905 static DecodeStatus DecodeCopMemInstruction(llvm::MCInst &Inst, unsigned Insn,
906 uint64_t Address, const void *Decoder) {
907 DecodeStatus S = Success;
909 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
910 unsigned CRd = fieldFromInstruction32(Insn, 12, 4);
911 unsigned coproc = fieldFromInstruction32(Insn, 8, 4);
912 unsigned imm = fieldFromInstruction32(Insn, 0, 8);
913 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
914 unsigned U = fieldFromInstruction32(Insn, 23, 1);
916 switch (Inst.getOpcode()) {
917 case ARM::LDC_OFFSET:
920 case ARM::LDC_OPTION:
921 case ARM::LDCL_OFFSET:
924 case ARM::LDCL_OPTION:
925 case ARM::STC_OFFSET:
928 case ARM::STC_OPTION:
929 case ARM::STCL_OFFSET:
932 case ARM::STCL_OPTION:
933 if (coproc == 0xA || coproc == 0xB)
940 Inst.addOperand(MCOperand::CreateImm(coproc));
941 Inst.addOperand(MCOperand::CreateImm(CRd));
942 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
943 switch (Inst.getOpcode()) {
944 case ARM::LDC_OPTION:
945 case ARM::LDCL_OPTION:
946 case ARM::LDC2_OPTION:
947 case ARM::LDC2L_OPTION:
948 case ARM::STC_OPTION:
949 case ARM::STCL_OPTION:
950 case ARM::STC2_OPTION:
951 case ARM::STC2L_OPTION:
954 case ARM::LDC2L_POST:
955 case ARM::STC2L_POST:
958 Inst.addOperand(MCOperand::CreateReg(0));
962 unsigned P = fieldFromInstruction32(Insn, 24, 1);
963 unsigned W = fieldFromInstruction32(Insn, 21, 1);
965 bool writeback = (P == 0) || (W == 1);
966 unsigned idx_mode = 0;
968 idx_mode = ARMII::IndexModePre;
969 else if (!P && writeback)
970 idx_mode = ARMII::IndexModePost;
972 switch (Inst.getOpcode()) {
975 case ARM::LDC2L_POST:
976 case ARM::STC2L_POST:
978 case ARM::LDC_OPTION:
979 case ARM::LDCL_OPTION:
980 case ARM::LDC2_OPTION:
981 case ARM::LDC2L_OPTION:
982 case ARM::STC_OPTION:
983 case ARM::STCL_OPTION:
984 case ARM::STC2_OPTION:
985 case ARM::STC2L_OPTION:
986 Inst.addOperand(MCOperand::CreateImm(imm));
990 Inst.addOperand(MCOperand::CreateImm(
991 ARM_AM::getAM2Opc(ARM_AM::add, imm, ARM_AM::lsl, idx_mode)));
993 Inst.addOperand(MCOperand::CreateImm(
994 ARM_AM::getAM2Opc(ARM_AM::sub, imm, ARM_AM::lsl, idx_mode)));
998 switch (Inst.getOpcode()) {
999 case ARM::LDC_OFFSET:
1002 case ARM::LDC_OPTION:
1003 case ARM::LDCL_OFFSET:
1005 case ARM::LDCL_POST:
1006 case ARM::LDCL_OPTION:
1007 case ARM::STC_OFFSET:
1010 case ARM::STC_OPTION:
1011 case ARM::STCL_OFFSET:
1013 case ARM::STCL_POST:
1014 case ARM::STCL_OPTION:
1015 CHECK(S, DecodePredicateOperand(Inst, pred, Address, Decoder));
1025 DecodeAddrMode2IdxInstruction(llvm::MCInst &Inst, unsigned Insn,
1026 uint64_t Address, const void *Decoder) {
1027 DecodeStatus S = Success;
1029 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
1030 unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
1031 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
1032 unsigned imm = fieldFromInstruction32(Insn, 0, 12);
1033 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
1034 unsigned reg = fieldFromInstruction32(Insn, 25, 1);
1035 unsigned P = fieldFromInstruction32(Insn, 24, 1);
1036 unsigned W = fieldFromInstruction32(Insn, 21, 1);
1038 // On stores, the writeback operand precedes Rt.
1039 switch (Inst.getOpcode()) {
1040 case ARM::STR_POST_IMM:
1041 case ARM::STR_POST_REG:
1042 case ARM::STRB_POST_IMM:
1043 case ARM::STRB_POST_REG:
1044 case ARM::STRT_POST_REG:
1045 case ARM::STRT_POST_IMM:
1046 case ARM::STRBT_POST_REG:
1047 case ARM::STRBT_POST_IMM:
1048 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
1054 CHECK(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder));
1056 // On loads, the writeback operand comes after Rt.
1057 switch (Inst.getOpcode()) {
1058 case ARM::LDR_POST_IMM:
1059 case ARM::LDR_POST_REG:
1060 case ARM::LDRB_POST_IMM:
1061 case ARM::LDRB_POST_REG:
1062 case ARM::LDRBT_POST_REG:
1063 case ARM::LDRBT_POST_IMM:
1064 case ARM::LDRT_POST_REG:
1065 case ARM::LDRT_POST_IMM:
1066 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
1072 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
1074 ARM_AM::AddrOpc Op = ARM_AM::add;
1075 if (!fieldFromInstruction32(Insn, 23, 1))
1078 bool writeback = (P == 0) || (W == 1);
1079 unsigned idx_mode = 0;
1081 idx_mode = ARMII::IndexModePre;
1082 else if (!P && writeback)
1083 idx_mode = ARMII::IndexModePost;
1085 if (writeback && (Rn == 15 || Rn == Rt)) S = Unpredictable; // UNPREDICTABLE
1088 CHECK(S, DecodeGPRnopcRegisterClass(Inst, Rm, Address, Decoder));
1089 ARM_AM::ShiftOpc Opc = ARM_AM::lsl;
1090 switch( fieldFromInstruction32(Insn, 5, 2)) {
1106 unsigned amt = fieldFromInstruction32(Insn, 7, 5);
1107 unsigned imm = ARM_AM::getAM2Opc(Op, amt, Opc, idx_mode);
1109 Inst.addOperand(MCOperand::CreateImm(imm));
1111 Inst.addOperand(MCOperand::CreateReg(0));
1112 unsigned tmp = ARM_AM::getAM2Opc(Op, imm, ARM_AM::lsl, idx_mode);
1113 Inst.addOperand(MCOperand::CreateImm(tmp));
1116 CHECK(S, DecodePredicateOperand(Inst, pred, Address, Decoder));
1121 static DecodeStatus DecodeSORegMemOperand(llvm::MCInst &Inst, unsigned Val,
1122 uint64_t Address, const void *Decoder) {
1123 DecodeStatus S = Success;
1125 unsigned Rn = fieldFromInstruction32(Val, 13, 4);
1126 unsigned Rm = fieldFromInstruction32(Val, 0, 4);
1127 unsigned type = fieldFromInstruction32(Val, 5, 2);
1128 unsigned imm = fieldFromInstruction32(Val, 7, 5);
1129 unsigned U = fieldFromInstruction32(Val, 12, 1);
1131 ARM_AM::ShiftOpc ShOp = ARM_AM::lsl;
1147 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
1148 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
1151 shift = ARM_AM::getAM2Opc(ARM_AM::add, imm, ShOp);
1153 shift = ARM_AM::getAM2Opc(ARM_AM::sub, imm, ShOp);
1154 Inst.addOperand(MCOperand::CreateImm(shift));
1160 DecodeAddrMode3Instruction(llvm::MCInst &Inst, unsigned Insn,
1161 uint64_t Address, const void *Decoder) {
1162 DecodeStatus S = Success;
1164 unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
1165 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
1166 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
1167 unsigned type = fieldFromInstruction32(Insn, 22, 1);
1168 unsigned imm = fieldFromInstruction32(Insn, 8, 4);
1169 unsigned U = ((~fieldFromInstruction32(Insn, 23, 1)) & 1) << 8;
1170 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
1171 unsigned W = fieldFromInstruction32(Insn, 21, 1);
1172 unsigned P = fieldFromInstruction32(Insn, 24, 1);
1174 bool writeback = (W == 1) | (P == 0);
1176 // For {LD,ST}RD, Rt must be even, else undefined.
1177 switch (Inst.getOpcode()) {
1180 case ARM::STRD_POST:
1183 case ARM::LDRD_POST:
1184 if (Rt & 0x1) return Fail;
1190 if (writeback) { // Writeback
1192 U |= ARMII::IndexModePre << 9;
1194 U |= ARMII::IndexModePost << 9;
1196 // On stores, the writeback operand precedes Rt.
1197 switch (Inst.getOpcode()) {
1200 case ARM::STRD_POST:
1203 case ARM::STRH_POST:
1204 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
1211 CHECK(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder));
1212 switch (Inst.getOpcode()) {
1215 case ARM::STRD_POST:
1218 case ARM::LDRD_POST:
1219 CHECK(S, DecodeGPRRegisterClass(Inst, Rt+1, Address, Decoder));
1226 // On loads, the writeback operand comes after Rt.
1227 switch (Inst.getOpcode()) {
1230 case ARM::LDRD_POST:
1233 case ARM::LDRH_POST:
1235 case ARM::LDRSH_PRE:
1236 case ARM::LDRSH_POST:
1238 case ARM::LDRSB_PRE:
1239 case ARM::LDRSB_POST:
1242 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
1249 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
1252 Inst.addOperand(MCOperand::CreateReg(0));
1253 Inst.addOperand(MCOperand::CreateImm(U | (imm << 4) | Rm));
1255 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
1256 Inst.addOperand(MCOperand::CreateImm(U));
1259 CHECK(S, DecodePredicateOperand(Inst, pred, Address, Decoder));
1264 static DecodeStatus DecodeRFEInstruction(llvm::MCInst &Inst, unsigned Insn,
1265 uint64_t Address, const void *Decoder) {
1266 DecodeStatus S = Success;
1268 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
1269 unsigned mode = fieldFromInstruction32(Insn, 23, 2);
1286 Inst.addOperand(MCOperand::CreateImm(mode));
1287 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
1292 static DecodeStatus DecodeMemMultipleWritebackInstruction(llvm::MCInst &Inst,
1294 uint64_t Address, const void *Decoder) {
1295 DecodeStatus S = Success;
1297 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
1298 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
1299 unsigned reglist = fieldFromInstruction32(Insn, 0, 16);
1302 switch (Inst.getOpcode()) {
1304 Inst.setOpcode(ARM::RFEDA);
1306 case ARM::LDMDA_UPD:
1307 Inst.setOpcode(ARM::RFEDA_UPD);
1310 Inst.setOpcode(ARM::RFEDB);
1312 case ARM::LDMDB_UPD:
1313 Inst.setOpcode(ARM::RFEDB_UPD);
1316 Inst.setOpcode(ARM::RFEIA);
1318 case ARM::LDMIA_UPD:
1319 Inst.setOpcode(ARM::RFEIA_UPD);
1322 Inst.setOpcode(ARM::RFEIB);
1324 case ARM::LDMIB_UPD:
1325 Inst.setOpcode(ARM::RFEIB_UPD);
1328 Inst.setOpcode(ARM::SRSDA);
1330 case ARM::STMDA_UPD:
1331 Inst.setOpcode(ARM::SRSDA_UPD);
1334 Inst.setOpcode(ARM::SRSDB);
1336 case ARM::STMDB_UPD:
1337 Inst.setOpcode(ARM::SRSDB_UPD);
1340 Inst.setOpcode(ARM::SRSIA);
1342 case ARM::STMIA_UPD:
1343 Inst.setOpcode(ARM::SRSIA_UPD);
1346 Inst.setOpcode(ARM::SRSIB);
1348 case ARM::STMIB_UPD:
1349 Inst.setOpcode(ARM::SRSIB_UPD);
1355 // For stores (which become SRS's, the only operand is the mode.
1356 if (fieldFromInstruction32(Insn, 20, 1) == 0) {
1358 MCOperand::CreateImm(fieldFromInstruction32(Insn, 0, 4)));
1362 return DecodeRFEInstruction(Inst, Insn, Address, Decoder);
1365 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
1366 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)); // Tied
1367 CHECK(S, DecodePredicateOperand(Inst, pred, Address, Decoder));
1368 CHECK(S, DecodeRegListOperand(Inst, reglist, Address, Decoder));
1373 static DecodeStatus DecodeCPSInstruction(llvm::MCInst &Inst, unsigned Insn,
1374 uint64_t Address, const void *Decoder) {
1375 unsigned imod = fieldFromInstruction32(Insn, 18, 2);
1376 unsigned M = fieldFromInstruction32(Insn, 17, 1);
1377 unsigned iflags = fieldFromInstruction32(Insn, 6, 3);
1378 unsigned mode = fieldFromInstruction32(Insn, 0, 5);
1380 DecodeStatus S = Success;
1382 // imod == '01' --> UNPREDICTABLE
1383 // NOTE: Even though this is technically UNPREDICTABLE, we choose to
1384 // return failure here. The '01' imod value is unprintable, so there's
1385 // nothing useful we could do even if we returned UNPREDICTABLE.
1387 if (imod == 1) CHECK(S, Fail);
1390 Inst.setOpcode(ARM::CPS3p);
1391 Inst.addOperand(MCOperand::CreateImm(imod));
1392 Inst.addOperand(MCOperand::CreateImm(iflags));
1393 Inst.addOperand(MCOperand::CreateImm(mode));
1394 } else if (imod && !M) {
1395 Inst.setOpcode(ARM::CPS2p);
1396 Inst.addOperand(MCOperand::CreateImm(imod));
1397 Inst.addOperand(MCOperand::CreateImm(iflags));
1398 if (mode) CHECK(S, Unpredictable);
1399 } else if (!imod && M) {
1400 Inst.setOpcode(ARM::CPS1p);
1401 Inst.addOperand(MCOperand::CreateImm(mode));
1402 if (iflags) CHECK(S, Unpredictable);
1404 // imod == '00' && M == '0' --> UNPREDICTABLE
1405 Inst.setOpcode(ARM::CPS1p);
1406 Inst.addOperand(MCOperand::CreateImm(mode));
1407 CHECK(S, Unpredictable);
1413 static DecodeStatus DecodeT2CPSInstruction(llvm::MCInst &Inst, unsigned Insn,
1414 uint64_t Address, const void *Decoder) {
1415 unsigned imod = fieldFromInstruction32(Insn, 9, 2);
1416 unsigned M = fieldFromInstruction32(Insn, 8, 1);
1417 unsigned iflags = fieldFromInstruction32(Insn, 5, 3);
1418 unsigned mode = fieldFromInstruction32(Insn, 0, 5);
1420 DecodeStatus S = Success;
1422 // imod == '01' --> UNPREDICTABLE
1423 // NOTE: Even though this is technically UNPREDICTABLE, we choose to
1424 // return failure here. The '01' imod value is unprintable, so there's
1425 // nothing useful we could do even if we returned UNPREDICTABLE.
1427 if (imod == 1) CHECK(S, Fail);
1430 Inst.setOpcode(ARM::t2CPS3p);
1431 Inst.addOperand(MCOperand::CreateImm(imod));
1432 Inst.addOperand(MCOperand::CreateImm(iflags));
1433 Inst.addOperand(MCOperand::CreateImm(mode));
1434 } else if (imod && !M) {
1435 Inst.setOpcode(ARM::t2CPS2p);
1436 Inst.addOperand(MCOperand::CreateImm(imod));
1437 Inst.addOperand(MCOperand::CreateImm(iflags));
1438 if (mode) CHECK(S, Unpredictable);
1439 } else if (!imod && M) {
1440 Inst.setOpcode(ARM::t2CPS1p);
1441 Inst.addOperand(MCOperand::CreateImm(mode));
1442 if (iflags) CHECK(S, Unpredictable);
1444 // imod == '00' && M == '0' --> UNPREDICTABLE
1445 Inst.setOpcode(ARM::t2CPS1p);
1446 Inst.addOperand(MCOperand::CreateImm(mode));
1447 CHECK(S, Unpredictable);
1454 static DecodeStatus DecodeSMLAInstruction(llvm::MCInst &Inst, unsigned Insn,
1455 uint64_t Address, const void *Decoder) {
1456 DecodeStatus S = Success;
1458 unsigned Rd = fieldFromInstruction32(Insn, 16, 4);
1459 unsigned Rn = fieldFromInstruction32(Insn, 0, 4);
1460 unsigned Rm = fieldFromInstruction32(Insn, 8, 4);
1461 unsigned Ra = fieldFromInstruction32(Insn, 12, 4);
1462 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
1465 return DecodeCPSInstruction(Inst, Insn, Address, Decoder);
1467 CHECK(S, DecodeGPRnopcRegisterClass(Inst, Rd, Address, Decoder));
1468 CHECK(S, DecodeGPRnopcRegisterClass(Inst, Rn, Address, Decoder));
1469 CHECK(S, DecodeGPRnopcRegisterClass(Inst, Rm, Address, Decoder));
1470 CHECK(S, DecodeGPRnopcRegisterClass(Inst, Ra, Address, Decoder));
1472 CHECK(S, DecodePredicateOperand(Inst, pred, Address, Decoder));
1477 static DecodeStatus DecodeAddrModeImm12Operand(llvm::MCInst &Inst, unsigned Val,
1478 uint64_t Address, const void *Decoder) {
1479 DecodeStatus S = Success;
1481 unsigned add = fieldFromInstruction32(Val, 12, 1);
1482 unsigned imm = fieldFromInstruction32(Val, 0, 12);
1483 unsigned Rn = fieldFromInstruction32(Val, 13, 4);
1485 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
1487 if (!add) imm *= -1;
1488 if (imm == 0 && !add) imm = INT32_MIN;
1489 Inst.addOperand(MCOperand::CreateImm(imm));
1494 static DecodeStatus DecodeAddrMode5Operand(llvm::MCInst &Inst, unsigned Val,
1495 uint64_t Address, const void *Decoder) {
1496 DecodeStatus S = Success;
1498 unsigned Rn = fieldFromInstruction32(Val, 9, 4);
1499 unsigned U = fieldFromInstruction32(Val, 8, 1);
1500 unsigned imm = fieldFromInstruction32(Val, 0, 8);
1502 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
1505 Inst.addOperand(MCOperand::CreateImm(ARM_AM::getAM5Opc(ARM_AM::add, imm)));
1507 Inst.addOperand(MCOperand::CreateImm(ARM_AM::getAM5Opc(ARM_AM::sub, imm)));
1512 static DecodeStatus DecodeAddrMode7Operand(llvm::MCInst &Inst, unsigned Val,
1513 uint64_t Address, const void *Decoder) {
1514 return DecodeGPRRegisterClass(Inst, Val, Address, Decoder);
1518 DecodeBranchImmInstruction(llvm::MCInst &Inst, unsigned Insn,
1519 uint64_t Address, const void *Decoder) {
1520 DecodeStatus S = Success;
1522 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
1523 unsigned imm = fieldFromInstruction32(Insn, 0, 24) << 2;
1526 Inst.setOpcode(ARM::BLXi);
1527 imm |= fieldFromInstruction32(Insn, 24, 1) << 1;
1528 Inst.addOperand(MCOperand::CreateImm(SignExtend32<26>(imm)));
1532 Inst.addOperand(MCOperand::CreateImm(SignExtend32<26>(imm)));
1533 CHECK(S, DecodePredicateOperand(Inst, pred, Address, Decoder));
1539 static DecodeStatus DecodeVCVTImmOperand(llvm::MCInst &Inst, unsigned Val,
1540 uint64_t Address, const void *Decoder) {
1541 Inst.addOperand(MCOperand::CreateImm(64 - Val));
1545 static DecodeStatus DecodeAddrMode6Operand(llvm::MCInst &Inst, unsigned Val,
1546 uint64_t Address, const void *Decoder) {
1547 DecodeStatus S = Success;
1549 unsigned Rm = fieldFromInstruction32(Val, 0, 4);
1550 unsigned align = fieldFromInstruction32(Val, 4, 2);
1552 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
1554 Inst.addOperand(MCOperand::CreateImm(0));
1556 Inst.addOperand(MCOperand::CreateImm(4 << align));
1561 static DecodeStatus DecodeVLDInstruction(llvm::MCInst &Inst, unsigned Insn,
1562 uint64_t Address, const void *Decoder) {
1563 DecodeStatus S = Success;
1565 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
1566 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
1567 unsigned wb = fieldFromInstruction32(Insn, 16, 4);
1568 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
1569 Rn |= fieldFromInstruction32(Insn, 4, 2) << 4;
1570 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
1572 // First output register
1573 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
1575 // Second output register
1576 switch (Inst.getOpcode()) {
1581 case ARM::VLD1q8_UPD:
1582 case ARM::VLD1q16_UPD:
1583 case ARM::VLD1q32_UPD:
1584 case ARM::VLD1q64_UPD:
1589 case ARM::VLD1d8T_UPD:
1590 case ARM::VLD1d16T_UPD:
1591 case ARM::VLD1d32T_UPD:
1592 case ARM::VLD1d64T_UPD:
1597 case ARM::VLD1d8Q_UPD:
1598 case ARM::VLD1d16Q_UPD:
1599 case ARM::VLD1d32Q_UPD:
1600 case ARM::VLD1d64Q_UPD:
1604 case ARM::VLD2d8_UPD:
1605 case ARM::VLD2d16_UPD:
1606 case ARM::VLD2d32_UPD:
1610 case ARM::VLD2q8_UPD:
1611 case ARM::VLD2q16_UPD:
1612 case ARM::VLD2q32_UPD:
1616 case ARM::VLD3d8_UPD:
1617 case ARM::VLD3d16_UPD:
1618 case ARM::VLD3d32_UPD:
1622 case ARM::VLD4d8_UPD:
1623 case ARM::VLD4d16_UPD:
1624 case ARM::VLD4d32_UPD:
1625 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+1)%32, Address, Decoder));
1630 case ARM::VLD2b8_UPD:
1631 case ARM::VLD2b16_UPD:
1632 case ARM::VLD2b32_UPD:
1636 case ARM::VLD3q8_UPD:
1637 case ARM::VLD3q16_UPD:
1638 case ARM::VLD3q32_UPD:
1642 case ARM::VLD4q8_UPD:
1643 case ARM::VLD4q16_UPD:
1644 case ARM::VLD4q32_UPD:
1645 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+2)%32, Address, Decoder));
1650 // Third output register
1651 switch(Inst.getOpcode()) {
1656 case ARM::VLD1d8T_UPD:
1657 case ARM::VLD1d16T_UPD:
1658 case ARM::VLD1d32T_UPD:
1659 case ARM::VLD1d64T_UPD:
1664 case ARM::VLD1d8Q_UPD:
1665 case ARM::VLD1d16Q_UPD:
1666 case ARM::VLD1d32Q_UPD:
1667 case ARM::VLD1d64Q_UPD:
1671 case ARM::VLD2q8_UPD:
1672 case ARM::VLD2q16_UPD:
1673 case ARM::VLD2q32_UPD:
1677 case ARM::VLD3d8_UPD:
1678 case ARM::VLD3d16_UPD:
1679 case ARM::VLD3d32_UPD:
1683 case ARM::VLD4d8_UPD:
1684 case ARM::VLD4d16_UPD:
1685 case ARM::VLD4d32_UPD:
1686 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+2)%32, Address, Decoder));
1691 case ARM::VLD3q8_UPD:
1692 case ARM::VLD3q16_UPD:
1693 case ARM::VLD3q32_UPD:
1697 case ARM::VLD4q8_UPD:
1698 case ARM::VLD4q16_UPD:
1699 case ARM::VLD4q32_UPD:
1700 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+4)%32, Address, Decoder));
1706 // Fourth output register
1707 switch (Inst.getOpcode()) {
1712 case ARM::VLD1d8Q_UPD:
1713 case ARM::VLD1d16Q_UPD:
1714 case ARM::VLD1d32Q_UPD:
1715 case ARM::VLD1d64Q_UPD:
1719 case ARM::VLD2q8_UPD:
1720 case ARM::VLD2q16_UPD:
1721 case ARM::VLD2q32_UPD:
1725 case ARM::VLD4d8_UPD:
1726 case ARM::VLD4d16_UPD:
1727 case ARM::VLD4d32_UPD:
1728 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+3)%32, Address, Decoder));
1733 case ARM::VLD4q8_UPD:
1734 case ARM::VLD4q16_UPD:
1735 case ARM::VLD4q32_UPD:
1736 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+6)%32, Address, Decoder));
1742 // Writeback operand
1743 switch (Inst.getOpcode()) {
1744 case ARM::VLD1d8_UPD:
1745 case ARM::VLD1d16_UPD:
1746 case ARM::VLD1d32_UPD:
1747 case ARM::VLD1d64_UPD:
1748 case ARM::VLD1q8_UPD:
1749 case ARM::VLD1q16_UPD:
1750 case ARM::VLD1q32_UPD:
1751 case ARM::VLD1q64_UPD:
1752 case ARM::VLD1d8T_UPD:
1753 case ARM::VLD1d16T_UPD:
1754 case ARM::VLD1d32T_UPD:
1755 case ARM::VLD1d64T_UPD:
1756 case ARM::VLD1d8Q_UPD:
1757 case ARM::VLD1d16Q_UPD:
1758 case ARM::VLD1d32Q_UPD:
1759 case ARM::VLD1d64Q_UPD:
1760 case ARM::VLD2d8_UPD:
1761 case ARM::VLD2d16_UPD:
1762 case ARM::VLD2d32_UPD:
1763 case ARM::VLD2q8_UPD:
1764 case ARM::VLD2q16_UPD:
1765 case ARM::VLD2q32_UPD:
1766 case ARM::VLD2b8_UPD:
1767 case ARM::VLD2b16_UPD:
1768 case ARM::VLD2b32_UPD:
1769 case ARM::VLD3d8_UPD:
1770 case ARM::VLD3d16_UPD:
1771 case ARM::VLD3d32_UPD:
1772 case ARM::VLD3q8_UPD:
1773 case ARM::VLD3q16_UPD:
1774 case ARM::VLD3q32_UPD:
1775 case ARM::VLD4d8_UPD:
1776 case ARM::VLD4d16_UPD:
1777 case ARM::VLD4d32_UPD:
1778 case ARM::VLD4q8_UPD:
1779 case ARM::VLD4q16_UPD:
1780 case ARM::VLD4q32_UPD:
1781 CHECK(S, DecodeGPRRegisterClass(Inst, wb, Address, Decoder));
1787 // AddrMode6 Base (register+alignment)
1788 CHECK(S, DecodeAddrMode6Operand(Inst, Rn, Address, Decoder));
1790 // AddrMode6 Offset (register)
1792 Inst.addOperand(MCOperand::CreateReg(0));
1793 else if (Rm != 0xF) {
1794 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
1800 static DecodeStatus DecodeVSTInstruction(llvm::MCInst &Inst, unsigned Insn,
1801 uint64_t Address, const void *Decoder) {
1802 DecodeStatus S = Success;
1804 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
1805 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
1806 unsigned wb = fieldFromInstruction32(Insn, 16, 4);
1807 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
1808 Rn |= fieldFromInstruction32(Insn, 4, 2) << 4;
1809 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
1811 // Writeback Operand
1812 switch (Inst.getOpcode()) {
1813 case ARM::VST1d8_UPD:
1814 case ARM::VST1d16_UPD:
1815 case ARM::VST1d32_UPD:
1816 case ARM::VST1d64_UPD:
1817 case ARM::VST1q8_UPD:
1818 case ARM::VST1q16_UPD:
1819 case ARM::VST1q32_UPD:
1820 case ARM::VST1q64_UPD:
1821 case ARM::VST1d8T_UPD:
1822 case ARM::VST1d16T_UPD:
1823 case ARM::VST1d32T_UPD:
1824 case ARM::VST1d64T_UPD:
1825 case ARM::VST1d8Q_UPD:
1826 case ARM::VST1d16Q_UPD:
1827 case ARM::VST1d32Q_UPD:
1828 case ARM::VST1d64Q_UPD:
1829 case ARM::VST2d8_UPD:
1830 case ARM::VST2d16_UPD:
1831 case ARM::VST2d32_UPD:
1832 case ARM::VST2q8_UPD:
1833 case ARM::VST2q16_UPD:
1834 case ARM::VST2q32_UPD:
1835 case ARM::VST2b8_UPD:
1836 case ARM::VST2b16_UPD:
1837 case ARM::VST2b32_UPD:
1838 case ARM::VST3d8_UPD:
1839 case ARM::VST3d16_UPD:
1840 case ARM::VST3d32_UPD:
1841 case ARM::VST3q8_UPD:
1842 case ARM::VST3q16_UPD:
1843 case ARM::VST3q32_UPD:
1844 case ARM::VST4d8_UPD:
1845 case ARM::VST4d16_UPD:
1846 case ARM::VST4d32_UPD:
1847 case ARM::VST4q8_UPD:
1848 case ARM::VST4q16_UPD:
1849 case ARM::VST4q32_UPD:
1850 CHECK(S, DecodeGPRRegisterClass(Inst, wb, Address, Decoder));
1856 // AddrMode6 Base (register+alignment)
1857 CHECK(S, DecodeAddrMode6Operand(Inst, Rn, Address, Decoder));
1859 // AddrMode6 Offset (register)
1861 Inst.addOperand(MCOperand::CreateReg(0));
1862 else if (Rm != 0xF) {
1863 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
1866 // First input register
1867 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
1869 // Second input register
1870 switch (Inst.getOpcode()) {
1875 case ARM::VST1q8_UPD:
1876 case ARM::VST1q16_UPD:
1877 case ARM::VST1q32_UPD:
1878 case ARM::VST1q64_UPD:
1883 case ARM::VST1d8T_UPD:
1884 case ARM::VST1d16T_UPD:
1885 case ARM::VST1d32T_UPD:
1886 case ARM::VST1d64T_UPD:
1891 case ARM::VST1d8Q_UPD:
1892 case ARM::VST1d16Q_UPD:
1893 case ARM::VST1d32Q_UPD:
1894 case ARM::VST1d64Q_UPD:
1898 case ARM::VST2d8_UPD:
1899 case ARM::VST2d16_UPD:
1900 case ARM::VST2d32_UPD:
1904 case ARM::VST2q8_UPD:
1905 case ARM::VST2q16_UPD:
1906 case ARM::VST2q32_UPD:
1910 case ARM::VST3d8_UPD:
1911 case ARM::VST3d16_UPD:
1912 case ARM::VST3d32_UPD:
1916 case ARM::VST4d8_UPD:
1917 case ARM::VST4d16_UPD:
1918 case ARM::VST4d32_UPD:
1919 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+1)%32, Address, Decoder));
1924 case ARM::VST2b8_UPD:
1925 case ARM::VST2b16_UPD:
1926 case ARM::VST2b32_UPD:
1930 case ARM::VST3q8_UPD:
1931 case ARM::VST3q16_UPD:
1932 case ARM::VST3q32_UPD:
1936 case ARM::VST4q8_UPD:
1937 case ARM::VST4q16_UPD:
1938 case ARM::VST4q32_UPD:
1939 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+2)%32, Address, Decoder));
1945 // Third input register
1946 switch (Inst.getOpcode()) {
1951 case ARM::VST1d8T_UPD:
1952 case ARM::VST1d16T_UPD:
1953 case ARM::VST1d32T_UPD:
1954 case ARM::VST1d64T_UPD:
1959 case ARM::VST1d8Q_UPD:
1960 case ARM::VST1d16Q_UPD:
1961 case ARM::VST1d32Q_UPD:
1962 case ARM::VST1d64Q_UPD:
1966 case ARM::VST2q8_UPD:
1967 case ARM::VST2q16_UPD:
1968 case ARM::VST2q32_UPD:
1972 case ARM::VST3d8_UPD:
1973 case ARM::VST3d16_UPD:
1974 case ARM::VST3d32_UPD:
1978 case ARM::VST4d8_UPD:
1979 case ARM::VST4d16_UPD:
1980 case ARM::VST4d32_UPD:
1981 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+2)%32, Address, Decoder));
1986 case ARM::VST3q8_UPD:
1987 case ARM::VST3q16_UPD:
1988 case ARM::VST3q32_UPD:
1992 case ARM::VST4q8_UPD:
1993 case ARM::VST4q16_UPD:
1994 case ARM::VST4q32_UPD:
1995 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+4)%32, Address, Decoder));
2001 // Fourth input register
2002 switch (Inst.getOpcode()) {
2007 case ARM::VST1d8Q_UPD:
2008 case ARM::VST1d16Q_UPD:
2009 case ARM::VST1d32Q_UPD:
2010 case ARM::VST1d64Q_UPD:
2014 case ARM::VST2q8_UPD:
2015 case ARM::VST2q16_UPD:
2016 case ARM::VST2q32_UPD:
2020 case ARM::VST4d8_UPD:
2021 case ARM::VST4d16_UPD:
2022 case ARM::VST4d32_UPD:
2023 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+3)%32, Address, Decoder));
2028 case ARM::VST4q8_UPD:
2029 case ARM::VST4q16_UPD:
2030 case ARM::VST4q32_UPD:
2031 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+6)%32, Address, Decoder));
2040 static DecodeStatus DecodeVLD1DupInstruction(llvm::MCInst &Inst, unsigned Insn,
2041 uint64_t Address, const void *Decoder) {
2042 DecodeStatus S = Success;
2044 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2045 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2046 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2047 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2048 unsigned align = fieldFromInstruction32(Insn, 4, 1);
2049 unsigned size = fieldFromInstruction32(Insn, 6, 2);
2050 unsigned regs = fieldFromInstruction32(Insn, 5, 1) + 1;
2052 align *= (1 << size);
2054 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
2056 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+1)%32, Address, Decoder));
2059 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2062 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2063 Inst.addOperand(MCOperand::CreateImm(align));
2066 Inst.addOperand(MCOperand::CreateReg(0));
2067 else if (Rm != 0xF) {
2068 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
2074 static DecodeStatus DecodeVLD2DupInstruction(llvm::MCInst &Inst, unsigned Insn,
2075 uint64_t Address, const void *Decoder) {
2076 DecodeStatus S = Success;
2078 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2079 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2080 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2081 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2082 unsigned align = fieldFromInstruction32(Insn, 4, 1);
2083 unsigned size = 1 << fieldFromInstruction32(Insn, 6, 2);
2084 unsigned inc = fieldFromInstruction32(Insn, 5, 1) + 1;
2087 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
2088 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+inc)%32, Address, Decoder));
2090 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2093 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2094 Inst.addOperand(MCOperand::CreateImm(align));
2097 Inst.addOperand(MCOperand::CreateReg(0));
2098 else if (Rm != 0xF) {
2099 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
2105 static DecodeStatus DecodeVLD3DupInstruction(llvm::MCInst &Inst, unsigned Insn,
2106 uint64_t Address, const void *Decoder) {
2107 DecodeStatus S = Success;
2109 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2110 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2111 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2112 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2113 unsigned inc = fieldFromInstruction32(Insn, 5, 1) + 1;
2115 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
2116 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+inc)%32, Address, Decoder));
2117 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+2*inc)%32, Address, Decoder));
2119 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2122 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2123 Inst.addOperand(MCOperand::CreateImm(0));
2126 Inst.addOperand(MCOperand::CreateReg(0));
2127 else if (Rm != 0xF) {
2128 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
2134 static DecodeStatus DecodeVLD4DupInstruction(llvm::MCInst &Inst, unsigned Insn,
2135 uint64_t Address, const void *Decoder) {
2136 DecodeStatus S = Success;
2138 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2139 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2140 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2141 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2142 unsigned size = fieldFromInstruction32(Insn, 6, 2);
2143 unsigned inc = fieldFromInstruction32(Insn, 5, 1) + 1;
2144 unsigned align = fieldFromInstruction32(Insn, 4, 1);
2159 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
2160 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+inc)%32, Address, Decoder));
2161 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+2*inc)%32, Address, Decoder));
2162 CHECK(S, DecodeDPRRegisterClass(Inst, (Rd+3*inc)%32, Address, Decoder));
2164 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2167 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2168 Inst.addOperand(MCOperand::CreateImm(align));
2171 Inst.addOperand(MCOperand::CreateReg(0));
2172 else if (Rm != 0xF) {
2173 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
2180 DecodeNEONModImmInstruction(llvm::MCInst &Inst, unsigned Insn,
2181 uint64_t Address, const void *Decoder) {
2182 DecodeStatus S = Success;
2184 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2185 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2186 unsigned imm = fieldFromInstruction32(Insn, 0, 4);
2187 imm |= fieldFromInstruction32(Insn, 16, 3) << 4;
2188 imm |= fieldFromInstruction32(Insn, 24, 1) << 7;
2189 imm |= fieldFromInstruction32(Insn, 8, 4) << 8;
2190 imm |= fieldFromInstruction32(Insn, 5, 1) << 12;
2191 unsigned Q = fieldFromInstruction32(Insn, 6, 1);
2194 CHECK(S, DecodeQPRRegisterClass(Inst, Rd, Address, Decoder));
2196 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
2199 Inst.addOperand(MCOperand::CreateImm(imm));
2201 switch (Inst.getOpcode()) {
2202 case ARM::VORRiv4i16:
2203 case ARM::VORRiv2i32:
2204 case ARM::VBICiv4i16:
2205 case ARM::VBICiv2i32:
2206 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
2208 case ARM::VORRiv8i16:
2209 case ARM::VORRiv4i32:
2210 case ARM::VBICiv8i16:
2211 case ARM::VBICiv4i32:
2212 CHECK(S, DecodeQPRRegisterClass(Inst, Rd, Address, Decoder));
2221 static DecodeStatus DecodeVSHLMaxInstruction(llvm::MCInst &Inst, unsigned Insn,
2222 uint64_t Address, const void *Decoder) {
2223 DecodeStatus S = Success;
2225 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2226 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2227 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2228 Rm |= fieldFromInstruction32(Insn, 5, 1) << 4;
2229 unsigned size = fieldFromInstruction32(Insn, 18, 2);
2231 CHECK(S, DecodeQPRRegisterClass(Inst, Rd, Address, Decoder));
2232 CHECK(S, DecodeDPRRegisterClass(Inst, Rm, Address, Decoder));
2233 Inst.addOperand(MCOperand::CreateImm(8 << size));
2238 static DecodeStatus DecodeShiftRight8Imm(llvm::MCInst &Inst, unsigned Val,
2239 uint64_t Address, const void *Decoder) {
2240 Inst.addOperand(MCOperand::CreateImm(8 - Val));
2244 static DecodeStatus DecodeShiftRight16Imm(llvm::MCInst &Inst, unsigned Val,
2245 uint64_t Address, const void *Decoder) {
2246 Inst.addOperand(MCOperand::CreateImm(16 - Val));
2250 static DecodeStatus DecodeShiftRight32Imm(llvm::MCInst &Inst, unsigned Val,
2251 uint64_t Address, const void *Decoder) {
2252 Inst.addOperand(MCOperand::CreateImm(32 - Val));
2256 static DecodeStatus DecodeShiftRight64Imm(llvm::MCInst &Inst, unsigned Val,
2257 uint64_t Address, const void *Decoder) {
2258 Inst.addOperand(MCOperand::CreateImm(64 - Val));
2262 static DecodeStatus DecodeTBLInstruction(llvm::MCInst &Inst, unsigned Insn,
2263 uint64_t Address, const void *Decoder) {
2264 DecodeStatus S = Success;
2266 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2267 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2268 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2269 Rn |= fieldFromInstruction32(Insn, 7, 1) << 4;
2270 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2271 Rm |= fieldFromInstruction32(Insn, 5, 1) << 4;
2272 unsigned op = fieldFromInstruction32(Insn, 6, 1);
2273 unsigned length = fieldFromInstruction32(Insn, 8, 2) + 1;
2275 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
2277 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)); // Writeback
2280 for (unsigned i = 0; i < length; ++i) {
2281 CHECK(S, DecodeDPRRegisterClass(Inst, (Rn+i)%32, Address, Decoder));
2284 CHECK(S, DecodeDPRRegisterClass(Inst, Rm, Address, Decoder));
2289 static DecodeStatus DecodeVFPfpImm(llvm::MCInst &Inst, unsigned Val,
2290 uint64_t Address, const void *Decoder) {
2291 // The immediate needs to be a fully instantiated float. However, the
2292 // auto-generated decoder is only able to fill in some of the bits
2293 // necessary. For instance, the 'b' bit is replicated multiple times,
2294 // and is even present in inverted form in one bit. We do a little
2295 // binary parsing here to fill in those missing bits, and then
2296 // reinterpret it all as a float.
2302 fp_conv.integer = Val;
2303 uint32_t b = fieldFromInstruction32(Val, 25, 1);
2304 fp_conv.integer |= b << 26;
2305 fp_conv.integer |= b << 27;
2306 fp_conv.integer |= b << 28;
2307 fp_conv.integer |= b << 29;
2308 fp_conv.integer |= (~b & 0x1) << 30;
2310 Inst.addOperand(MCOperand::CreateFPImm(fp_conv.fp));
2314 static DecodeStatus DecodeThumbAddSpecialReg(llvm::MCInst &Inst, uint16_t Insn,
2315 uint64_t Address, const void *Decoder) {
2316 DecodeStatus S = Success;
2318 unsigned dst = fieldFromInstruction16(Insn, 8, 3);
2319 unsigned imm = fieldFromInstruction16(Insn, 0, 8);
2321 CHECK(S, DecodetGPRRegisterClass(Inst, dst, Address, Decoder));
2323 switch(Inst.getOpcode()) {
2327 break; // tADR does not explicitly represent the PC as an oeprand.
2329 Inst.addOperand(MCOperand::CreateReg(ARM::SP));
2333 Inst.addOperand(MCOperand::CreateImm(imm));
2337 static DecodeStatus DecodeThumbBROperand(llvm::MCInst &Inst, unsigned Val,
2338 uint64_t Address, const void *Decoder) {
2339 Inst.addOperand(MCOperand::CreateImm(SignExtend32<12>(Val << 1)));
2343 static DecodeStatus DecodeT2BROperand(llvm::MCInst &Inst, unsigned Val,
2344 uint64_t Address, const void *Decoder) {
2345 Inst.addOperand(MCOperand::CreateImm(SignExtend32<21>(Val)));
2349 static DecodeStatus DecodeThumbCmpBROperand(llvm::MCInst &Inst, unsigned Val,
2350 uint64_t Address, const void *Decoder) {
2351 Inst.addOperand(MCOperand::CreateImm(SignExtend32<7>(Val << 1)));
2355 static DecodeStatus DecodeThumbAddrModeRR(llvm::MCInst &Inst, unsigned Val,
2356 uint64_t Address, const void *Decoder) {
2357 DecodeStatus S = Success;
2359 unsigned Rn = fieldFromInstruction32(Val, 0, 3);
2360 unsigned Rm = fieldFromInstruction32(Val, 3, 3);
2362 CHECK(S, DecodetGPRRegisterClass(Inst, Rn, Address, Decoder));
2363 CHECK(S, DecodetGPRRegisterClass(Inst, Rm, Address, Decoder));
2368 static DecodeStatus DecodeThumbAddrModeIS(llvm::MCInst &Inst, unsigned Val,
2369 uint64_t Address, const void *Decoder) {
2370 DecodeStatus S = Success;
2372 unsigned Rn = fieldFromInstruction32(Val, 0, 3);
2373 unsigned imm = fieldFromInstruction32(Val, 3, 5);
2375 CHECK(S, DecodetGPRRegisterClass(Inst, Rn, Address, Decoder));
2376 Inst.addOperand(MCOperand::CreateImm(imm));
2381 static DecodeStatus DecodeThumbAddrModePC(llvm::MCInst &Inst, unsigned Val,
2382 uint64_t Address, const void *Decoder) {
2383 Inst.addOperand(MCOperand::CreateImm(Val << 2));
2388 static DecodeStatus DecodeThumbAddrModeSP(llvm::MCInst &Inst, unsigned Val,
2389 uint64_t Address, const void *Decoder) {
2390 Inst.addOperand(MCOperand::CreateReg(ARM::SP));
2391 Inst.addOperand(MCOperand::CreateImm(Val));
2396 static DecodeStatus DecodeT2AddrModeSOReg(llvm::MCInst &Inst, unsigned Val,
2397 uint64_t Address, const void *Decoder) {
2398 DecodeStatus S = Success;
2400 unsigned Rn = fieldFromInstruction32(Val, 6, 4);
2401 unsigned Rm = fieldFromInstruction32(Val, 2, 4);
2402 unsigned imm = fieldFromInstruction32(Val, 0, 2);
2404 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2405 CHECK(S, DecoderGPRRegisterClass(Inst, Rm, Address, Decoder));
2406 Inst.addOperand(MCOperand::CreateImm(imm));
2411 static DecodeStatus DecodeT2LoadShift(llvm::MCInst &Inst, unsigned Insn,
2412 uint64_t Address, const void *Decoder) {
2413 DecodeStatus S = Success;
2415 switch (Inst.getOpcode()) {
2421 unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
2422 CHECK(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder));
2426 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2428 switch (Inst.getOpcode()) {
2430 Inst.setOpcode(ARM::t2LDRBpci);
2433 Inst.setOpcode(ARM::t2LDRHpci);
2436 Inst.setOpcode(ARM::t2LDRSHpci);
2439 Inst.setOpcode(ARM::t2LDRSBpci);
2442 Inst.setOpcode(ARM::t2PLDi12);
2443 Inst.addOperand(MCOperand::CreateReg(ARM::PC));
2449 int imm = fieldFromInstruction32(Insn, 0, 12);
2450 if (!fieldFromInstruction32(Insn, 23, 1)) imm *= -1;
2451 Inst.addOperand(MCOperand::CreateImm(imm));
2456 unsigned addrmode = fieldFromInstruction32(Insn, 4, 2);
2457 addrmode |= fieldFromInstruction32(Insn, 0, 4) << 2;
2458 addrmode |= fieldFromInstruction32(Insn, 16, 4) << 6;
2459 CHECK(S, DecodeT2AddrModeSOReg(Inst, addrmode, Address, Decoder));
2464 static DecodeStatus DecodeT2Imm8S4(llvm::MCInst &Inst, unsigned Val,
2465 uint64_t Address, const void *Decoder) {
2466 int imm = Val & 0xFF;
2467 if (!(Val & 0x100)) imm *= -1;
2468 Inst.addOperand(MCOperand::CreateImm(imm << 2));
2473 static DecodeStatus DecodeT2AddrModeImm8s4(llvm::MCInst &Inst, unsigned Val,
2474 uint64_t Address, const void *Decoder) {
2475 DecodeStatus S = Success;
2477 unsigned Rn = fieldFromInstruction32(Val, 9, 4);
2478 unsigned imm = fieldFromInstruction32(Val, 0, 9);
2480 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2481 CHECK(S, DecodeT2Imm8S4(Inst, imm, Address, Decoder));
2486 static DecodeStatus DecodeT2Imm8(llvm::MCInst &Inst, unsigned Val,
2487 uint64_t Address, const void *Decoder) {
2488 int imm = Val & 0xFF;
2489 if (!(Val & 0x100)) imm *= -1;
2490 Inst.addOperand(MCOperand::CreateImm(imm));
2496 static DecodeStatus DecodeT2AddrModeImm8(llvm::MCInst &Inst, unsigned Val,
2497 uint64_t Address, const void *Decoder) {
2498 DecodeStatus S = Success;
2500 unsigned Rn = fieldFromInstruction32(Val, 9, 4);
2501 unsigned imm = fieldFromInstruction32(Val, 0, 9);
2503 // Some instructions always use an additive offset.
2504 switch (Inst.getOpcode()) {
2516 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2517 CHECK(S, DecodeT2Imm8(Inst, imm, Address, Decoder));
2523 static DecodeStatus DecodeT2AddrModeImm12(llvm::MCInst &Inst, unsigned Val,
2524 uint64_t Address, const void *Decoder) {
2525 DecodeStatus S = Success;
2527 unsigned Rn = fieldFromInstruction32(Val, 13, 4);
2528 unsigned imm = fieldFromInstruction32(Val, 0, 12);
2530 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2531 Inst.addOperand(MCOperand::CreateImm(imm));
2537 static DecodeStatus DecodeThumbAddSPImm(llvm::MCInst &Inst, uint16_t Insn,
2538 uint64_t Address, const void *Decoder) {
2539 unsigned imm = fieldFromInstruction16(Insn, 0, 7);
2541 Inst.addOperand(MCOperand::CreateReg(ARM::SP));
2542 Inst.addOperand(MCOperand::CreateReg(ARM::SP));
2543 Inst.addOperand(MCOperand::CreateImm(imm));
2548 static DecodeStatus DecodeThumbAddSPReg(llvm::MCInst &Inst, uint16_t Insn,
2549 uint64_t Address, const void *Decoder) {
2550 DecodeStatus S = Success;
2552 if (Inst.getOpcode() == ARM::tADDrSP) {
2553 unsigned Rdm = fieldFromInstruction16(Insn, 0, 3);
2554 Rdm |= fieldFromInstruction16(Insn, 7, 1) << 3;
2556 CHECK(S, DecodeGPRRegisterClass(Inst, Rdm, Address, Decoder));
2557 CHECK(S, DecodeGPRRegisterClass(Inst, Rdm, Address, Decoder));
2558 Inst.addOperand(MCOperand::CreateReg(ARM::SP));
2559 } else if (Inst.getOpcode() == ARM::tADDspr) {
2560 unsigned Rm = fieldFromInstruction16(Insn, 3, 4);
2562 Inst.addOperand(MCOperand::CreateReg(ARM::SP));
2563 Inst.addOperand(MCOperand::CreateReg(ARM::SP));
2564 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
2570 static DecodeStatus DecodeThumbCPS(llvm::MCInst &Inst, uint16_t Insn,
2571 uint64_t Address, const void *Decoder) {
2572 unsigned imod = fieldFromInstruction16(Insn, 4, 1) | 0x2;
2573 unsigned flags = fieldFromInstruction16(Insn, 0, 3);
2575 Inst.addOperand(MCOperand::CreateImm(imod));
2576 Inst.addOperand(MCOperand::CreateImm(flags));
2581 static DecodeStatus DecodePostIdxReg(llvm::MCInst &Inst, unsigned Insn,
2582 uint64_t Address, const void *Decoder) {
2583 DecodeStatus S = Success;
2584 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2585 unsigned add = fieldFromInstruction32(Insn, 4, 1);
2587 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)) ;
2588 Inst.addOperand(MCOperand::CreateImm(add));
2593 static DecodeStatus DecodeThumbBLXOffset(llvm::MCInst &Inst, unsigned Val,
2594 uint64_t Address, const void *Decoder) {
2595 Inst.addOperand(MCOperand::CreateImm(SignExtend32<22>(Val << 1)));
2599 static DecodeStatus DecodeCoprocessor(llvm::MCInst &Inst, unsigned Val,
2600 uint64_t Address, const void *Decoder) {
2601 if (Val == 0xA || Val == 0xB)
2604 Inst.addOperand(MCOperand::CreateImm(Val));
2609 DecodeThumb2BCCInstruction(llvm::MCInst &Inst, unsigned Insn,
2610 uint64_t Address, const void *Decoder) {
2611 DecodeStatus S = Success;
2613 unsigned pred = fieldFromInstruction32(Insn, 22, 4);
2614 if (pred == 0xE || pred == 0xF) {
2615 unsigned opc = fieldFromInstruction32(Insn, 4, 2);
2620 Inst.setOpcode(ARM::t2DSB);
2623 Inst.setOpcode(ARM::t2DMB);
2626 Inst.setOpcode(ARM::t2ISB);
2630 unsigned imm = fieldFromInstruction32(Insn, 0, 4);
2631 return DecodeMemBarrierOption(Inst, imm, Address, Decoder);
2634 unsigned brtarget = fieldFromInstruction32(Insn, 0, 11) << 1;
2635 brtarget |= fieldFromInstruction32(Insn, 11, 1) << 19;
2636 brtarget |= fieldFromInstruction32(Insn, 13, 1) << 18;
2637 brtarget |= fieldFromInstruction32(Insn, 16, 6) << 12;
2638 brtarget |= fieldFromInstruction32(Insn, 26, 1) << 20;
2640 CHECK(S, DecodeT2BROperand(Inst, brtarget, Address, Decoder));
2641 CHECK(S, DecodePredicateOperand(Inst, pred, Address, Decoder));
2646 // Decode a shifted immediate operand. These basically consist
2647 // of an 8-bit value, and a 4-bit directive that specifies either
2648 // a splat operation or a rotation.
2649 static DecodeStatus DecodeT2SOImm(llvm::MCInst &Inst, unsigned Val,
2650 uint64_t Address, const void *Decoder) {
2651 unsigned ctrl = fieldFromInstruction32(Val, 10, 2);
2653 unsigned byte = fieldFromInstruction32(Val, 8, 2);
2654 unsigned imm = fieldFromInstruction32(Val, 0, 8);
2657 Inst.addOperand(MCOperand::CreateImm(imm));
2660 Inst.addOperand(MCOperand::CreateImm((imm << 16) | imm));
2663 Inst.addOperand(MCOperand::CreateImm((imm << 24) | (imm << 8)));
2666 Inst.addOperand(MCOperand::CreateImm((imm << 24) | (imm << 16) |
2671 unsigned unrot = fieldFromInstruction32(Val, 0, 7) | 0x80;
2672 unsigned rot = fieldFromInstruction32(Val, 7, 5);
2673 unsigned imm = (unrot >> rot) | (unrot << ((32-rot)&31));
2674 Inst.addOperand(MCOperand::CreateImm(imm));
2681 DecodeThumbBCCTargetOperand(llvm::MCInst &Inst, unsigned Val,
2682 uint64_t Address, const void *Decoder){
2683 Inst.addOperand(MCOperand::CreateImm(Val << 1));
2687 static DecodeStatus DecodeThumbBLTargetOperand(llvm::MCInst &Inst, unsigned Val,
2688 uint64_t Address, const void *Decoder){
2689 Inst.addOperand(MCOperand::CreateImm(SignExtend32<22>(Val << 1)));
2693 static DecodeStatus DecodeMemBarrierOption(llvm::MCInst &Inst, unsigned Val,
2694 uint64_t Address, const void *Decoder) {
2709 Inst.addOperand(MCOperand::CreateImm(Val));
2713 static DecodeStatus DecodeMSRMask(llvm::MCInst &Inst, unsigned Val,
2714 uint64_t Address, const void *Decoder) {
2715 if (!Val) return Fail;
2716 Inst.addOperand(MCOperand::CreateImm(Val));
2720 static DecodeStatus DecodeDoubleRegLoad(llvm::MCInst &Inst, unsigned Insn,
2721 uint64_t Address, const void *Decoder) {
2722 DecodeStatus S = Success;
2724 unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
2725 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2726 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
2728 if ((Rt & 1) || Rt == 0xE || Rn == 0xF) return Fail;
2730 CHECK(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder));
2731 CHECK(S, DecodeGPRRegisterClass(Inst, Rt+1, Address, Decoder));
2732 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2733 CHECK(S, DecodePredicateOperand(Inst, pred, Address, Decoder));
2739 static DecodeStatus DecodeDoubleRegStore(llvm::MCInst &Inst, unsigned Insn,
2740 uint64_t Address, const void *Decoder){
2741 DecodeStatus S = Success;
2743 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2744 unsigned Rt = fieldFromInstruction32(Insn, 0, 4);
2745 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2746 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
2748 CHECK(S, DecoderGPRRegisterClass(Inst, Rd, Address, Decoder));
2750 if ((Rt & 1) || Rt == 0xE || Rn == 0xF) return Fail;
2751 if (Rd == Rn || Rd == Rt || Rd == Rt+1) return Fail;
2753 CHECK(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder));
2754 CHECK(S, DecodeGPRRegisterClass(Inst, Rt+1, Address, Decoder));
2755 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2756 CHECK(S, DecodePredicateOperand(Inst, pred, Address, Decoder));
2761 static DecodeStatus DecodeLDRPreImm(llvm::MCInst &Inst, unsigned Insn,
2762 uint64_t Address, const void *Decoder) {
2763 DecodeStatus S = Success;
2765 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2766 unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
2767 unsigned imm = fieldFromInstruction32(Insn, 0, 12);
2768 imm |= fieldFromInstruction32(Insn, 16, 4) << 13;
2769 imm |= fieldFromInstruction32(Insn, 23, 1) << 12;
2770 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
2772 if (Rn == 0xF || Rn == Rt) CHECK(S, Unpredictable);
2774 CHECK(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder));
2775 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2776 CHECK(S, DecodeAddrModeImm12Operand(Inst, imm, Address, Decoder));
2777 CHECK(S, DecodePredicateOperand(Inst, pred, Address, Decoder));
2782 static DecodeStatus DecodeLDRPreReg(llvm::MCInst &Inst, unsigned Insn,
2783 uint64_t Address, const void *Decoder) {
2784 DecodeStatus S = Success;
2786 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2787 unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
2788 unsigned imm = fieldFromInstruction32(Insn, 0, 12);
2789 imm |= fieldFromInstruction32(Insn, 16, 4) << 13;
2790 imm |= fieldFromInstruction32(Insn, 23, 1) << 12;
2791 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
2792 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2794 if (Rn == 0xF || Rn == Rt) CHECK(S, Unpredictable);
2795 if (Rm == 0xF) CHECK(S, Unpredictable);
2797 CHECK(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder));
2798 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2799 CHECK(S, DecodeSORegMemOperand(Inst, imm, Address, Decoder));
2800 CHECK(S, DecodePredicateOperand(Inst, pred, Address, Decoder));
2806 static DecodeStatus DecodeSTRPreImm(llvm::MCInst &Inst, unsigned Insn,
2807 uint64_t Address, const void *Decoder) {
2808 DecodeStatus S = Success;
2810 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2811 unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
2812 unsigned imm = fieldFromInstruction32(Insn, 0, 12);
2813 imm |= fieldFromInstruction32(Insn, 16, 4) << 13;
2814 imm |= fieldFromInstruction32(Insn, 23, 1) << 12;
2815 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
2817 if (Rn == 0xF || Rn == Rt) CHECK(S, Unpredictable);
2819 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2820 CHECK(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder));
2821 CHECK(S, DecodeAddrModeImm12Operand(Inst, imm, Address, Decoder));
2822 CHECK(S, DecodePredicateOperand(Inst, pred, Address, Decoder));
2827 static DecodeStatus DecodeSTRPreReg(llvm::MCInst &Inst, unsigned Insn,
2828 uint64_t Address, const void *Decoder) {
2829 DecodeStatus S = Success;
2831 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2832 unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
2833 unsigned imm = fieldFromInstruction32(Insn, 0, 12);
2834 imm |= fieldFromInstruction32(Insn, 16, 4) << 13;
2835 imm |= fieldFromInstruction32(Insn, 23, 1) << 12;
2836 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
2838 if (Rn == 0xF || Rn == Rt) CHECK(S, Unpredictable);
2840 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2841 CHECK(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder));
2842 CHECK(S, DecodeSORegMemOperand(Inst, imm, Address, Decoder));
2843 CHECK(S, DecodePredicateOperand(Inst, pred, Address, Decoder));
2848 static DecodeStatus DecodeVLD1LN(llvm::MCInst &Inst, unsigned Insn,
2849 uint64_t Address, const void *Decoder) {
2850 DecodeStatus S = Success;
2852 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2853 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2854 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2855 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2856 unsigned size = fieldFromInstruction32(Insn, 10, 2);
2864 if (fieldFromInstruction32(Insn, 4, 1))
2865 return Fail; // UNDEFINED
2866 index = fieldFromInstruction32(Insn, 5, 3);
2869 if (fieldFromInstruction32(Insn, 5, 1))
2870 return Fail; // UNDEFINED
2871 index = fieldFromInstruction32(Insn, 6, 2);
2872 if (fieldFromInstruction32(Insn, 4, 1))
2876 if (fieldFromInstruction32(Insn, 6, 1))
2877 return Fail; // UNDEFINED
2878 index = fieldFromInstruction32(Insn, 7, 1);
2879 if (fieldFromInstruction32(Insn, 4, 2) != 0)
2883 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
2884 if (Rm != 0xF) { // Writeback
2885 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2887 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2888 Inst.addOperand(MCOperand::CreateImm(align));
2891 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
2893 Inst.addOperand(MCOperand::CreateReg(0));
2896 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
2897 Inst.addOperand(MCOperand::CreateImm(index));
2902 static DecodeStatus DecodeVST1LN(llvm::MCInst &Inst, unsigned Insn,
2903 uint64_t Address, const void *Decoder) {
2904 DecodeStatus S = Success;
2906 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2907 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2908 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2909 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2910 unsigned size = fieldFromInstruction32(Insn, 10, 2);
2918 if (fieldFromInstruction32(Insn, 4, 1))
2919 return Fail; // UNDEFINED
2920 index = fieldFromInstruction32(Insn, 5, 3);
2923 if (fieldFromInstruction32(Insn, 5, 1))
2924 return Fail; // UNDEFINED
2925 index = fieldFromInstruction32(Insn, 6, 2);
2926 if (fieldFromInstruction32(Insn, 4, 1))
2930 if (fieldFromInstruction32(Insn, 6, 1))
2931 return Fail; // UNDEFINED
2932 index = fieldFromInstruction32(Insn, 7, 1);
2933 if (fieldFromInstruction32(Insn, 4, 2) != 0)
2937 if (Rm != 0xF) { // Writeback
2938 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2940 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
2941 Inst.addOperand(MCOperand::CreateImm(align));
2944 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
2946 Inst.addOperand(MCOperand::CreateReg(0));
2949 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
2950 Inst.addOperand(MCOperand::CreateImm(index));
2956 static DecodeStatus DecodeVLD2LN(llvm::MCInst &Inst, unsigned Insn,
2957 uint64_t Address, const void *Decoder) {
2958 DecodeStatus S = Success;
2960 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
2961 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
2962 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
2963 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
2964 unsigned size = fieldFromInstruction32(Insn, 10, 2);
2973 index = fieldFromInstruction32(Insn, 5, 3);
2974 if (fieldFromInstruction32(Insn, 4, 1))
2978 index = fieldFromInstruction32(Insn, 6, 2);
2979 if (fieldFromInstruction32(Insn, 4, 1))
2981 if (fieldFromInstruction32(Insn, 5, 1))
2985 if (fieldFromInstruction32(Insn, 5, 1))
2986 return Fail; // UNDEFINED
2987 index = fieldFromInstruction32(Insn, 7, 1);
2988 if (fieldFromInstruction32(Insn, 4, 1) != 0)
2990 if (fieldFromInstruction32(Insn, 6, 1))
2995 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
2996 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder));
2997 if (Rm != 0xF) { // Writeback
2998 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
3000 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
3001 Inst.addOperand(MCOperand::CreateImm(align));
3004 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
3006 Inst.addOperand(MCOperand::CreateReg(0));
3009 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
3010 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder));
3011 Inst.addOperand(MCOperand::CreateImm(index));
3016 static DecodeStatus DecodeVST2LN(llvm::MCInst &Inst, unsigned Insn,
3017 uint64_t Address, const void *Decoder) {
3018 DecodeStatus S = Success;
3020 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
3021 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
3022 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
3023 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
3024 unsigned size = fieldFromInstruction32(Insn, 10, 2);
3033 index = fieldFromInstruction32(Insn, 5, 3);
3034 if (fieldFromInstruction32(Insn, 4, 1))
3038 index = fieldFromInstruction32(Insn, 6, 2);
3039 if (fieldFromInstruction32(Insn, 4, 1))
3041 if (fieldFromInstruction32(Insn, 5, 1))
3045 if (fieldFromInstruction32(Insn, 5, 1))
3046 return Fail; // UNDEFINED
3047 index = fieldFromInstruction32(Insn, 7, 1);
3048 if (fieldFromInstruction32(Insn, 4, 1) != 0)
3050 if (fieldFromInstruction32(Insn, 6, 1))
3055 if (Rm != 0xF) { // Writeback
3056 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
3058 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
3059 Inst.addOperand(MCOperand::CreateImm(align));
3062 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
3064 Inst.addOperand(MCOperand::CreateReg(0));
3067 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
3068 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder));
3069 Inst.addOperand(MCOperand::CreateImm(index));
3075 static DecodeStatus DecodeVLD3LN(llvm::MCInst &Inst, unsigned Insn,
3076 uint64_t Address, const void *Decoder) {
3077 DecodeStatus S = Success;
3079 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
3080 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
3081 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
3082 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
3083 unsigned size = fieldFromInstruction32(Insn, 10, 2);
3092 if (fieldFromInstruction32(Insn, 4, 1))
3093 return Fail; // UNDEFINED
3094 index = fieldFromInstruction32(Insn, 5, 3);
3097 if (fieldFromInstruction32(Insn, 4, 1))
3098 return Fail; // UNDEFINED
3099 index = fieldFromInstruction32(Insn, 6, 2);
3100 if (fieldFromInstruction32(Insn, 5, 1))
3104 if (fieldFromInstruction32(Insn, 4, 2))
3105 return Fail; // UNDEFINED
3106 index = fieldFromInstruction32(Insn, 7, 1);
3107 if (fieldFromInstruction32(Insn, 6, 1))
3112 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
3113 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder));
3114 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder));
3116 if (Rm != 0xF) { // Writeback
3117 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
3119 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
3120 Inst.addOperand(MCOperand::CreateImm(align));
3123 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
3125 Inst.addOperand(MCOperand::CreateReg(0));
3128 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
3129 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder));
3130 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder));
3131 Inst.addOperand(MCOperand::CreateImm(index));
3136 static DecodeStatus DecodeVST3LN(llvm::MCInst &Inst, unsigned Insn,
3137 uint64_t Address, const void *Decoder) {
3138 DecodeStatus S = Success;
3140 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
3141 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
3142 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
3143 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
3144 unsigned size = fieldFromInstruction32(Insn, 10, 2);
3153 if (fieldFromInstruction32(Insn, 4, 1))
3154 return Fail; // UNDEFINED
3155 index = fieldFromInstruction32(Insn, 5, 3);
3158 if (fieldFromInstruction32(Insn, 4, 1))
3159 return Fail; // UNDEFINED
3160 index = fieldFromInstruction32(Insn, 6, 2);
3161 if (fieldFromInstruction32(Insn, 5, 1))
3165 if (fieldFromInstruction32(Insn, 4, 2))
3166 return Fail; // UNDEFINED
3167 index = fieldFromInstruction32(Insn, 7, 1);
3168 if (fieldFromInstruction32(Insn, 6, 1))
3173 if (Rm != 0xF) { // Writeback
3174 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
3176 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
3177 Inst.addOperand(MCOperand::CreateImm(align));
3180 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
3182 Inst.addOperand(MCOperand::CreateReg(0));
3185 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
3186 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder));
3187 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder));
3188 Inst.addOperand(MCOperand::CreateImm(index));
3194 static DecodeStatus DecodeVLD4LN(llvm::MCInst &Inst, unsigned Insn,
3195 uint64_t Address, const void *Decoder) {
3196 DecodeStatus S = Success;
3198 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
3199 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
3200 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
3201 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
3202 unsigned size = fieldFromInstruction32(Insn, 10, 2);
3211 if (fieldFromInstruction32(Insn, 4, 1))
3213 index = fieldFromInstruction32(Insn, 5, 3);
3216 if (fieldFromInstruction32(Insn, 4, 1))
3218 index = fieldFromInstruction32(Insn, 6, 2);
3219 if (fieldFromInstruction32(Insn, 5, 1))
3223 if (fieldFromInstruction32(Insn, 4, 2))
3224 align = 4 << fieldFromInstruction32(Insn, 4, 2);
3225 index = fieldFromInstruction32(Insn, 7, 1);
3226 if (fieldFromInstruction32(Insn, 6, 1))
3231 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
3232 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder));
3233 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder));
3234 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+3*inc, Address, Decoder));
3236 if (Rm != 0xF) { // Writeback
3237 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
3239 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
3240 Inst.addOperand(MCOperand::CreateImm(align));
3243 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
3245 Inst.addOperand(MCOperand::CreateReg(0));
3248 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
3249 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder));
3250 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder));
3251 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+3*inc, Address, Decoder));
3252 Inst.addOperand(MCOperand::CreateImm(index));
3257 static DecodeStatus DecodeVST4LN(llvm::MCInst &Inst, unsigned Insn,
3258 uint64_t Address, const void *Decoder) {
3259 DecodeStatus S = Success;
3261 unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
3262 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
3263 unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
3264 Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
3265 unsigned size = fieldFromInstruction32(Insn, 10, 2);
3274 if (fieldFromInstruction32(Insn, 4, 1))
3276 index = fieldFromInstruction32(Insn, 5, 3);
3279 if (fieldFromInstruction32(Insn, 4, 1))
3281 index = fieldFromInstruction32(Insn, 6, 2);
3282 if (fieldFromInstruction32(Insn, 5, 1))
3286 if (fieldFromInstruction32(Insn, 4, 2))
3287 align = 4 << fieldFromInstruction32(Insn, 4, 2);
3288 index = fieldFromInstruction32(Insn, 7, 1);
3289 if (fieldFromInstruction32(Insn, 6, 1))
3294 if (Rm != 0xF) { // Writeback
3295 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
3297 CHECK(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder));
3298 Inst.addOperand(MCOperand::CreateImm(align));
3301 CHECK(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder));
3303 Inst.addOperand(MCOperand::CreateReg(0));
3306 CHECK(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder));
3307 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder));
3308 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder));
3309 CHECK(S, DecodeDPRRegisterClass(Inst, Rd+3*inc, Address, Decoder));
3310 Inst.addOperand(MCOperand::CreateImm(index));
3315 static DecodeStatus DecodeVMOVSRR(llvm::MCInst &Inst, unsigned Insn,
3316 uint64_t Address, const void *Decoder) {
3317 DecodeStatus S = Success;
3318 unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
3319 unsigned Rt2 = fieldFromInstruction32(Insn, 16, 4);
3320 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
3321 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
3322 Rm |= fieldFromInstruction32(Insn, 5, 1) << 4;
3324 if (Rt == 0xF || Rt2 == 0xF || Rm == 0x1F)
3325 CHECK(S, Unpredictable);
3327 CHECK(S, DecodeSPRRegisterClass(Inst, Rm , Address, Decoder));
3328 CHECK(S, DecodeSPRRegisterClass(Inst, Rm+1, Address, Decoder));
3329 CHECK(S, DecodeGPRRegisterClass(Inst, Rt , Address, Decoder));
3330 CHECK(S, DecodeGPRRegisterClass(Inst, Rt2 , Address, Decoder));
3331 CHECK(S, DecodePredicateOperand(Inst, pred, Address, Decoder));
3336 static DecodeStatus DecodeVMOVRRS(llvm::MCInst &Inst, unsigned Insn,
3337 uint64_t Address, const void *Decoder) {
3338 DecodeStatus S = Success;
3339 unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
3340 unsigned Rt2 = fieldFromInstruction32(Insn, 16, 4);
3341 unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
3342 unsigned pred = fieldFromInstruction32(Insn, 28, 4);
3343 Rm |= fieldFromInstruction32(Insn, 5, 1) << 4;
3345 if (Rt == 0xF || Rt2 == 0xF || Rm == 0x1F)
3346 CHECK(S, Unpredictable);
3348 CHECK(S, DecodeGPRRegisterClass(Inst, Rt , Address, Decoder));
3349 CHECK(S, DecodeGPRRegisterClass(Inst, Rt2 , Address, Decoder));
3350 CHECK(S, DecodeSPRRegisterClass(Inst, Rm , Address, Decoder));
3351 CHECK(S, DecodeSPRRegisterClass(Inst, Rm+1, Address, Decoder));
3352 CHECK(S, DecodePredicateOperand(Inst, pred, Address, Decoder));
3357 static DecodeStatus DecodeITCond(llvm::MCInst &Inst, unsigned Cond,
3358 uint64_t Address, const void *Decoder) {
3359 DecodeStatus S = Success;
3362 CHECK(S, Unpredictable);
3365 Inst.addOperand(MCOperand::CreateImm(Cond));
3369 static DecodeStatus DecodeITMask(llvm::MCInst &Inst, unsigned Mask,
3370 uint64_t Address, const void *Decoder) {
3371 DecodeStatus S = Success;
3374 CHECK(S, Unpredictable);
3376 Inst.addOperand(MCOperand::CreateImm(Mask));