static void AddThumb1SBit(MCInst &MI, bool InITBlock) {
const MCOperandInfo *OpInfo = ARMInsts[MI.getOpcode()].OpInfo;
MCInst::iterator I = MI.begin();
- for (unsigned i = 0; i < MI.size(); ++i, ++I) {
+ for (unsigned i = 0, e = MI.size(); i < e; ++i, ++I) {
if (OpInfo[i].isOptionalDef() && OpInfo[i].RegClass == ARM::CCRRegClassID) {
MI.insert(I, MCOperand::CreateReg(InITBlock ? 0 : ARM::CPSR));
return;
// If we're in an IT block, base the predicate on that. Otherwise,
// assume a predicate of AL.
unsigned CC;
- if (ITBlock.size()) {
+ if (!ITBlock.empty()) {
CC = ITBlock.back();
ITBlock.pop_back();
} else
const MCOperandInfo *OpInfo = ARMInsts[MI.getOpcode()].OpInfo;
MCInst::iterator I = MI.begin();
- for (unsigned i = 0; i < MI.size(); ++i, ++I) {
+ for (unsigned i = 0, e = MI.size(); i < e; ++i, ++I) {
if (OpInfo[i].isPredicate()) {
I = MI.insert(I, MCOperand::CreateImm(CC));
++I;
// context as a post-pass.
void ThumbDisassembler::UpdateThumbVFPPredicate(MCInst &MI) const {
unsigned CC;
- if (ITBlock.size()) {
+ if (!ITBlock.empty()) {
CC = ITBlock.back();
ITBlock.pop_back();
} else
const MCOperandInfo *OpInfo = ARMInsts[MI.getOpcode()].OpInfo;
MCInst::iterator I = MI.begin();
- for (unsigned i = 0; i < MI.size(); ++i, ++I) {
+ for (unsigned i = 0, e = MI.size(); i < e; ++i, ++I) {
if (OpInfo[i].isPredicate() ) {
I->setImm(CC);
++I;
bool result = decodeThumbInstruction16(MI, insn16, Address, this);
if (result) {
Size = 2;
- bool InITBlock = ITBlock.size();
+ bool InITBlock = !ITBlock.empty();
AddThumbPredicate(MI);
AddThumb1SBit(MI, InITBlock);
return true;
static bool DecodeBitfieldMaskOperand(llvm::MCInst &Inst, unsigned Val,
uint64_t Address, const void *Decoder) {
+ // This operand encodes a mask of contiguous zeros between a specified MSB
+ // and LSB. To decode it, we create the mask of all bits MSB-and-lower,
+ // the mask of all bits LSB-and-lower, and then xor them to create
+ // the mask of that's all ones on [msb, lsb]. Finally we not it to
+ // create the final mask.
unsigned msb = fieldFromInstruction32(Val, 5, 5);
unsigned lsb = fieldFromInstruction32(Val, 0, 5);
uint32_t msb_mask = (1 << (msb+1)) - 1;
case ARM::STMIB_UPD:
Inst.setOpcode(ARM::RFEIB_UPD);
break;
-
}
return DecodeRFEInstruction(Inst, Insn, Address, Decoder);
}
break;
}
-
return true;
}
}
static bool DecodeT2Imm8S4(llvm::MCInst &Inst, unsigned Val,
- uint64_t Address, const void *Decoder) {
+ uint64_t Address, const void *Decoder) {
int imm = Val & 0xFF;
if (!(Val & 0x100)) imm *= -1;
Inst.addOperand(MCOperand::CreateImm(imm << 2));
}
static bool DecodeT2Imm8(llvm::MCInst &Inst, unsigned Val,
- uint64_t Address, const void *Decoder) {
+ uint64_t Address, const void *Decoder) {
int imm = Val & 0xFF;
if (!(Val & 0x100)) imm *= -1;
Inst.addOperand(MCOperand::CreateImm(imm));
static bool DecodeT2AddrModeImm8(llvm::MCInst &Inst, unsigned Val,
- uint64_t Address, const void *Decoder) {
+ uint64_t Address, const void *Decoder) {
unsigned Rn = fieldFromInstruction32(Val, 9, 4);
unsigned imm = fieldFromInstruction32(Val, 0, 9);
static bool DecodeT2AddrModeImm12(llvm::MCInst &Inst, unsigned Val,
- uint64_t Address, const void *Decoder) {
+ uint64_t Address, const void *Decoder) {
unsigned Rn = fieldFromInstruction32(Val, 13, 4);
unsigned imm = fieldFromInstruction32(Val, 0, 12);
static bool DecodeThumbAddSPImm(llvm::MCInst &Inst, uint16_t Insn,
- uint64_t Address, const void *Decoder) {
+ uint64_t Address, const void *Decoder) {
unsigned imm = fieldFromInstruction16(Insn, 0, 7);
Inst.addOperand(MCOperand::CreateReg(ARM::SP));
}
static bool DecodeThumbAddSPReg(llvm::MCInst &Inst, uint16_t Insn,
- uint64_t Address, const void *Decoder) {
+ uint64_t Address, const void *Decoder) {
if (Inst.getOpcode() == ARM::tADDrSP) {
unsigned Rdm = fieldFromInstruction16(Insn, 0, 3);
Rdm |= fieldFromInstruction16(Insn, 7, 1) << 3;
}
static bool DecodeThumbCPS(llvm::MCInst &Inst, uint16_t Insn,
- uint64_t Address, const void *Decoder) {
+ uint64_t Address, const void *Decoder) {
unsigned imod = fieldFromInstruction16(Insn, 4, 1) | 0x2;
unsigned flags = fieldFromInstruction16(Insn, 0, 3);
}
static bool DecodePostIdxReg(llvm::MCInst &Inst, unsigned Insn,
- uint64_t Address, const void *Decoder) {
+ uint64_t Address, const void *Decoder) {
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
unsigned add = fieldFromInstruction32(Insn, 4, 1);
}
static bool DecodeThumbBLXOffset(llvm::MCInst &Inst, unsigned Val,
- uint64_t Address, const void *Decoder) {
+ uint64_t Address, const void *Decoder) {
Inst.addOperand(MCOperand::CreateImm(SignExtend32<22>(Val << 1)));
return true;
}
}
static bool DecodeThumbSRImm(llvm::MCInst &Inst, unsigned Val,
- uint64_t Address, const void *Decoder) {
+ uint64_t Address, const void *Decoder) {
if (Val == 0)
Inst.addOperand(MCOperand::CreateImm(32));
else
}
static bool DecodeThumbBLTargetOperand(llvm::MCInst &Inst, unsigned Val,
- uint64_t Address, const void *Decoder){
+ uint64_t Address, const void *Decoder){
Inst.addOperand(MCOperand::CreateImm(SignExtend32<22>(Val << 1)));
return true;
}