2012-02-18 12:03:15 +00:00
|
|
|
//===-- ARMDisassembler.cpp - Disassembler for ARM/Thumb ISA --------------===//
|
2010-04-02 22:27:38 +00:00
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#define DEBUG_TYPE "arm-disassembler"
|
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
#include "MCTargetDesc/ARMAddressingModes.h"
|
2011-10-04 22:44:48 +00:00
|
|
|
#include "MCTargetDesc/ARMMCExpr.h"
|
2011-08-09 20:55:18 +00:00
|
|
|
#include "MCTargetDesc/ARMBaseInfo.h"
|
2010-04-13 21:21:57 +00:00
|
|
|
#include "llvm/MC/EDInstInfo.h"
|
2010-04-02 22:27:38 +00:00
|
|
|
#include "llvm/MC/MCInst.h"
|
2011-11-11 12:39:41 +00:00
|
|
|
#include "llvm/MC/MCInstrDesc.h"
|
2011-08-09 20:55:18 +00:00
|
|
|
#include "llvm/MC/MCExpr.h"
|
|
|
|
#include "llvm/MC/MCContext.h"
|
2011-09-01 23:35:51 +00:00
|
|
|
#include "llvm/MC/MCDisassembler.h"
|
2012-04-03 15:48:14 +00:00
|
|
|
#include "llvm/MC/MCSubtargetInfo.h"
|
2010-04-02 22:27:38 +00:00
|
|
|
#include "llvm/Support/Debug.h"
|
|
|
|
#include "llvm/Support/MemoryObject.h"
|
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
2011-08-24 18:08:43 +00:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
2010-04-02 22:27:38 +00:00
|
|
|
#include "llvm/Support/raw_ostream.h"
|
|
|
|
|
2011-09-01 18:02:14 +00:00
|
|
|
using namespace llvm;
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
typedef MCDisassembler::DecodeStatus DecodeStatus;
|
|
|
|
|
2011-09-01 23:35:51 +00:00
|
|
|
namespace {
|
|
|
|
/// ARMDisassembler - ARM disassembler for all ARM platforms.
|
|
|
|
class ARMDisassembler : public MCDisassembler {
|
|
|
|
public:
|
|
|
|
/// Constructor - Initializes the disassembler.
|
|
|
|
///
|
2011-09-07 17:24:38 +00:00
|
|
|
ARMDisassembler(const MCSubtargetInfo &STI) :
|
|
|
|
MCDisassembler(STI) {
|
2011-09-01 23:35:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~ARMDisassembler() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getInstruction - See MCDisassembler.
|
|
|
|
DecodeStatus getInstruction(MCInst &instr,
|
|
|
|
uint64_t &size,
|
2012-02-29 01:09:06 +00:00
|
|
|
const MemoryObject ®ion,
|
2011-09-01 23:35:51 +00:00
|
|
|
uint64_t address,
|
2011-09-15 23:38:46 +00:00
|
|
|
raw_ostream &vStream,
|
|
|
|
raw_ostream &cStream) const;
|
2011-09-01 23:35:51 +00:00
|
|
|
|
|
|
|
/// getEDInfo - See MCDisassembler.
|
2012-02-11 14:51:07 +00:00
|
|
|
const EDInstInfo *getEDInfo() const;
|
2011-09-01 23:35:51 +00:00
|
|
|
private:
|
|
|
|
};
|
|
|
|
|
|
|
|
/// ThumbDisassembler - Thumb disassembler for all Thumb platforms.
|
|
|
|
class ThumbDisassembler : public MCDisassembler {
|
|
|
|
public:
|
|
|
|
/// Constructor - Initializes the disassembler.
|
|
|
|
///
|
2011-09-07 17:24:38 +00:00
|
|
|
ThumbDisassembler(const MCSubtargetInfo &STI) :
|
|
|
|
MCDisassembler(STI) {
|
2011-09-01 23:35:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
~ThumbDisassembler() {
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getInstruction - See MCDisassembler.
|
|
|
|
DecodeStatus getInstruction(MCInst &instr,
|
|
|
|
uint64_t &size,
|
2012-02-29 01:09:06 +00:00
|
|
|
const MemoryObject ®ion,
|
2011-09-01 23:35:51 +00:00
|
|
|
uint64_t address,
|
2011-09-15 23:38:46 +00:00
|
|
|
raw_ostream &vStream,
|
|
|
|
raw_ostream &cStream) const;
|
2011-09-01 23:35:51 +00:00
|
|
|
|
|
|
|
/// getEDInfo - See MCDisassembler.
|
2012-02-11 14:51:07 +00:00
|
|
|
const EDInstInfo *getEDInfo() const;
|
2011-09-01 23:35:51 +00:00
|
|
|
private:
|
|
|
|
mutable std::vector<unsigned> ITBlock;
|
2011-09-08 22:42:49 +00:00
|
|
|
DecodeStatus AddThumbPredicate(MCInst&) const;
|
2011-09-01 23:35:51 +00:00
|
|
|
void UpdateThumbVFPPredicate(MCInst&) const;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
static bool Check(DecodeStatus &Out, DecodeStatus In) {
|
2011-09-01 18:02:14 +00:00
|
|
|
switch (In) {
|
|
|
|
case MCDisassembler::Success:
|
|
|
|
// Out stays the same.
|
|
|
|
return true;
|
|
|
|
case MCDisassembler::SoftFail:
|
|
|
|
Out = In;
|
|
|
|
return true;
|
|
|
|
case MCDisassembler::Fail:
|
|
|
|
Out = In;
|
|
|
|
return false;
|
|
|
|
}
|
2012-01-20 21:51:11 +00:00
|
|
|
llvm_unreachable("Invalid DecodeStatus!");
|
2011-09-01 18:02:14 +00:00
|
|
|
}
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-09-07 19:42:28 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
// Forward declare these because the autogenerated code will reference them.
|
|
|
|
// Definitions are further down.
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeGPRRegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeGPRnopcRegisterClass(MCInst &Inst,
|
2011-08-17 21:58:18 +00:00
|
|
|
unsigned RegNo, uint64_t Address,
|
|
|
|
const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodetGPRRegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodetcGPRRegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecoderGPRRegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSPRRegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeDPRRegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeDPR_8RegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeDPR_VFP2RegisterClass(MCInst &Inst,
|
2011-08-17 21:58:18 +00:00
|
|
|
unsigned RegNo,
|
|
|
|
uint64_t Address,
|
|
|
|
const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeQPRRegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeDPairRegisterClass(MCInst &Inst, unsigned RegNo,
|
2012-03-05 19:33:30 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeDPairSpacedRegisterClass(MCInst &Inst,
|
2012-03-05 21:43:40 +00:00
|
|
|
unsigned RegNo, uint64_t Address,
|
|
|
|
const void *Decoder);
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodePredicateOperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeCCOutOperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSOImmOperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeRegListOperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSPRRegListOperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeDPRRegListOperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeBitfieldMaskOperand(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeCopMemInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeAddrMode2IdxInstruction(MCInst &Inst,
|
2011-08-17 21:58:18 +00:00
|
|
|
unsigned Insn,
|
|
|
|
uint64_t Address,
|
|
|
|
const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSORegMemOperand(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeAddrMode3Instruction(MCInst &Inst,unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSORegImmOperand(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSORegRegOperand(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeMemMultipleWritebackInstruction(MCInst & Inst,
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Insn,
|
|
|
|
uint64_t Adddress,
|
|
|
|
const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2MOVTWInstruction(MCInst &Inst, unsigned Insn,
|
2011-10-04 22:44:48 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeArmMOVTWInstruction(MCInst &Inst, unsigned Insn,
|
2011-10-04 22:44:48 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSMLAInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeCPSInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-09 23:05:39 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2CPSInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-23 17:45:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeAddrModeImm12Operand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeAddrMode5Operand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeAddrMode7Operand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeBranchImmInstruction(MCInst &Inst,unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeAddrMode6Operand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLDInstruction(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVSTInstruction(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLD1DupInstruction(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLD2DupInstruction(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLD3DupInstruction(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLD4DupInstruction(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeNEONModImmInstruction(MCInst &Inst,unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVSHLMaxInstruction(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeShiftRight8Imm(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeShiftRight16Imm(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeShiftRight32Imm(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeShiftRight64Imm(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeTBLInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodePostIdxReg(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeCoprocessor(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeMemBarrierOption(MCInst &Inst, unsigned Insn,
|
2011-08-09 23:25:42 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeMSRMask(MCInst &Inst, unsigned Insn,
|
2011-08-11 20:21:46 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeDoubleRegLoad(MCInst &Inst, unsigned Insn,
|
2011-08-12 17:58:32 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeDoubleRegStore(MCInst &Inst, unsigned Insn,
|
2011-08-11 21:34:58 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeLDRPreImm(MCInst &Inst, unsigned Insn,
|
2011-08-26 20:43:14 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeLDRPreReg(MCInst &Inst, unsigned Insn,
|
2011-08-26 20:43:14 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSTRPreImm(MCInst &Inst, unsigned Insn,
|
2011-08-12 18:12:39 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSTRPreReg(MCInst &Inst, unsigned Insn,
|
2011-08-12 18:12:39 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLD1LN(MCInst &Inst, unsigned Insn,
|
2011-08-15 18:44:44 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLD2LN(MCInst &Inst, unsigned Insn,
|
2011-08-15 18:44:44 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLD3LN(MCInst &Inst, unsigned Insn,
|
2011-08-15 18:44:44 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLD4LN(MCInst &Inst, unsigned Insn,
|
2011-08-15 18:44:44 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVST1LN(MCInst &Inst, unsigned Insn,
|
2011-08-15 18:44:44 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVST2LN(MCInst &Inst, unsigned Insn,
|
2011-08-15 18:44:44 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVST3LN(MCInst &Inst, unsigned Insn,
|
2011-08-15 18:44:44 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVST4LN(MCInst &Inst, unsigned Insn,
|
2011-08-15 18:44:44 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVMOVSRR(MCInst &Inst, unsigned Insn,
|
2011-08-22 20:27:12 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVMOVRRS(MCInst &Inst, unsigned Insn,
|
2011-08-22 20:27:12 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSwap(MCInst &Inst, unsigned Insn,
|
2011-10-28 18:02:13 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVCVTD(MCInst &Inst, unsigned Insn,
|
2011-11-15 19:55:00 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVCVTQ(MCInst &Inst, unsigned Insn,
|
2011-11-15 19:55:00 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbAddSpecialReg(MCInst &Inst, uint16_t Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbBROperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2BROperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbCmpBROperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbAddrModeRR(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbAddrModeIS(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbAddrModePC(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbAddrModeSP(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2AddrModeSOReg(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2LoadShift(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2Imm8S4(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2AddrModeImm8s4(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2AddrModeImm0_1020s4(MCInst &Inst,unsigned Val,
|
2011-09-09 18:37:27 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2Imm8(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2AddrModeImm8(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbAddSPImm(MCInst &Inst, uint16_t Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbAddSPReg(MCInst &Inst, uint16_t Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbCPS(MCInst &Inst, uint16_t Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbBLXOffset(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2AddrModeImm12(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbTableBranch(MCInst &Inst, unsigned Val,
|
2011-09-19 22:21:13 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumb2BCCInstruction(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2SOImm(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbBCCTargetOperand(MCInst &Inst,unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbBLTargetOperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeIT(MCInst &Inst, unsigned Val,
|
2011-08-24 22:40:22 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2LDRDPreInstruction(MCInst &Inst,unsigned Insn,
|
2011-09-08 22:07:06 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2STRDPreInstruction(MCInst &Inst,unsigned Insn,
|
2011-09-08 22:07:06 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2Adr(MCInst &Inst, unsigned Val,
|
2011-09-09 22:24:36 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2LdStPre(MCInst &Inst, unsigned Val,
|
2011-09-12 18:56:30 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2ShifterImmOperand(MCInst &Inst, unsigned Val,
|
2011-09-26 21:06:22 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeLDR(MCInst &Inst, unsigned Val,
|
2012-03-22 13:24:43 +00:00
|
|
|
uint64_t Address, const void *Decoder);
|
2011-08-09 20:55:18 +00:00
|
|
|
#include "ARMGenDisassemblerTables.inc"
|
|
|
|
#include "ARMGenInstrInfo.inc"
|
2010-09-28 11:48:19 +00:00
|
|
|
#include "ARMGenEDInfo.inc"
|
2010-04-13 21:21:57 +00:00
|
|
|
|
2011-09-07 17:24:38 +00:00
|
|
|
static MCDisassembler *createARMDisassembler(const Target &T, const MCSubtargetInfo &STI) {
|
|
|
|
return new ARMDisassembler(STI);
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2011-09-07 17:24:38 +00:00
|
|
|
static MCDisassembler *createThumbDisassembler(const Target &T, const MCSubtargetInfo &STI) {
|
|
|
|
return new ThumbDisassembler(STI);
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-02-11 14:51:07 +00:00
|
|
|
const EDInstInfo *ARMDisassembler::getEDInfo() const {
|
2011-08-09 20:55:18 +00:00
|
|
|
return instInfoARM;
|
|
|
|
}
|
|
|
|
|
2012-02-11 14:51:07 +00:00
|
|
|
const EDInstInfo *ThumbDisassembler::getEDInfo() const {
|
2011-08-09 20:55:18 +00:00
|
|
|
return instInfoARM;
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus ARMDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
2012-02-29 01:09:06 +00:00
|
|
|
const MemoryObject &Region,
|
2011-08-17 21:58:18 +00:00
|
|
|
uint64_t Address,
|
2011-09-15 23:38:46 +00:00
|
|
|
raw_ostream &os,
|
|
|
|
raw_ostream &cs) const {
|
2011-10-04 22:44:48 +00:00
|
|
|
CommentStream = &cs;
|
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
uint8_t bytes[4];
|
|
|
|
|
2011-09-07 19:42:28 +00:00
|
|
|
assert(!(STI.getFeatureBits() & ARM::ModeThumb) &&
|
|
|
|
"Asked to disassemble an ARM instruction but Subtarget is in Thumb mode!");
|
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
// We want to read exactly 4 bytes of data.
|
2011-08-26 18:21:36 +00:00
|
|
|
if (Region.readBytes(Address, 4, (uint8_t*)bytes, NULL) == -1) {
|
|
|
|
Size = 0;
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-26 18:21:36 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
// Encoded as a small-endian 32-bit word in the stream.
|
|
|
|
uint32_t insn = (bytes[3] << 24) |
|
|
|
|
(bytes[2] << 16) |
|
|
|
|
(bytes[1] << 8) |
|
|
|
|
(bytes[0] << 0);
|
|
|
|
|
|
|
|
// Calling the auto-generated decoder function.
|
2011-09-07 19:42:28 +00:00
|
|
|
DecodeStatus result = decodeARMInstruction32(MI, insn, Address, this, STI);
|
2011-09-01 18:02:14 +00:00
|
|
|
if (result != MCDisassembler::Fail) {
|
2011-08-09 20:55:18 +00:00
|
|
|
Size = 4;
|
2011-08-17 17:44:15 +00:00
|
|
|
return result;
|
2010-04-02 22:27:38 +00:00
|
|
|
}
|
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
// VFP and NEON instructions, similarly, are shared between ARM
|
|
|
|
// and Thumb modes.
|
|
|
|
MI.clear();
|
2011-09-07 19:42:28 +00:00
|
|
|
result = decodeVFPInstruction32(MI, insn, Address, this, STI);
|
2011-09-01 18:02:14 +00:00
|
|
|
if (result != MCDisassembler::Fail) {
|
2011-08-09 20:55:18 +00:00
|
|
|
Size = 4;
|
2011-08-17 17:44:15 +00:00
|
|
|
return result;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MI.clear();
|
2011-09-07 19:42:28 +00:00
|
|
|
result = decodeNEONDataInstruction32(MI, insn, Address, this, STI);
|
2011-09-01 18:02:14 +00:00
|
|
|
if (result != MCDisassembler::Fail) {
|
2011-08-10 19:01:10 +00:00
|
|
|
Size = 4;
|
2011-08-09 20:55:18 +00:00
|
|
|
// Add a fake predicate operand, because we share these instruction
|
|
|
|
// definitions with Thumb2 where these instructions are predicable.
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!DecodePredicateOperand(MI, 0xE, Address, this))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-17 17:44:15 +00:00
|
|
|
return result;
|
2011-08-10 19:01:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MI.clear();
|
2011-09-07 19:42:28 +00:00
|
|
|
result = decodeNEONLoadStoreInstruction32(MI, insn, Address, this, STI);
|
2011-09-01 18:02:14 +00:00
|
|
|
if (result != MCDisassembler::Fail) {
|
2011-08-09 20:55:18 +00:00
|
|
|
Size = 4;
|
2011-08-10 19:01:10 +00:00
|
|
|
// Add a fake predicate operand, because we share these instruction
|
|
|
|
// definitions with Thumb2 where these instructions are predicable.
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!DecodePredicateOperand(MI, 0xE, Address, this))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-17 17:44:15 +00:00
|
|
|
return result;
|
2011-08-10 19:01:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MI.clear();
|
2011-09-07 19:42:28 +00:00
|
|
|
result = decodeNEONDupInstruction32(MI, insn, Address, this, STI);
|
2011-09-01 18:02:14 +00:00
|
|
|
if (result != MCDisassembler::Fail) {
|
2011-08-10 19:01:10 +00:00
|
|
|
Size = 4;
|
|
|
|
// Add a fake predicate operand, because we share these instruction
|
|
|
|
// definitions with Thumb2 where these instructions are predicable.
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!DecodePredicateOperand(MI, 0xE, Address, this))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-17 17:44:15 +00:00
|
|
|
return result;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MI.clear();
|
|
|
|
|
2011-08-26 18:21:36 +00:00
|
|
|
Size = 0;
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
namespace llvm {
|
2011-10-22 16:50:00 +00:00
|
|
|
extern const MCInstrDesc ARMInsts[];
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2011-10-04 22:44:48 +00:00
|
|
|
/// tryAddingSymbolicOperand - trys to add a symbolic operand in place of the
|
|
|
|
/// immediate Value in the MCInst. The immediate Value has had any PC
|
|
|
|
/// adjustment made by the caller. If the instruction is a branch instruction
|
|
|
|
/// then isBranch is true, else false. If the getOpInfo() function was set as
|
|
|
|
/// part of the setupForSymbolicDisassembly() call then that function is called
|
|
|
|
/// to get any symbolic information at the Address for this instruction. If
|
|
|
|
/// that returns non-zero then the symbolic information it returns is used to
|
|
|
|
/// create an MCExpr and that is added as an operand to the MCInst. If
|
|
|
|
/// getOpInfo() returns zero and isBranch is true then a symbol look up for
|
|
|
|
/// Value is done and if a symbol is found an MCExpr is created with that, else
|
|
|
|
/// an MCExpr with Value is created. This function returns true if it adds an
|
|
|
|
/// operand to the MCInst and false otherwise.
|
|
|
|
static bool tryAddingSymbolicOperand(uint64_t Address, int32_t Value,
|
|
|
|
bool isBranch, uint64_t InstSize,
|
|
|
|
MCInst &MI, const void *Decoder) {
|
|
|
|
const MCDisassembler *Dis = static_cast<const MCDisassembler*>(Decoder);
|
|
|
|
LLVMOpInfoCallback getOpInfo = Dis->getLLVMOpInfoCallback();
|
|
|
|
struct LLVMOpInfo1 SymbolicOp;
|
2012-02-23 18:18:17 +00:00
|
|
|
memset(&SymbolicOp, '\0', sizeof(struct LLVMOpInfo1));
|
2011-10-04 22:44:48 +00:00
|
|
|
SymbolicOp.Value = Value;
|
|
|
|
void *DisInfo = Dis->getDisInfoBlock();
|
2012-02-23 18:18:17 +00:00
|
|
|
|
|
|
|
if (!getOpInfo ||
|
|
|
|
!getOpInfo(DisInfo, Address, 0 /* Offset */, InstSize, 1, &SymbolicOp)) {
|
|
|
|
// Clear SymbolicOp.Value from above and also all other fields.
|
|
|
|
memset(&SymbolicOp, '\0', sizeof(struct LLVMOpInfo1));
|
|
|
|
LLVMSymbolLookupCallback SymbolLookUp = Dis->getLLVMSymbolLookupCallback();
|
|
|
|
if (!SymbolLookUp)
|
2011-10-04 22:44:48 +00:00
|
|
|
return false;
|
2012-02-23 18:18:17 +00:00
|
|
|
uint64_t ReferenceType;
|
|
|
|
if (isBranch)
|
|
|
|
ReferenceType = LLVMDisassembler_ReferenceType_In_Branch;
|
|
|
|
else
|
|
|
|
ReferenceType = LLVMDisassembler_ReferenceType_InOut_None;
|
|
|
|
const char *ReferenceName;
|
|
|
|
const char *Name = SymbolLookUp(DisInfo, Value, &ReferenceType, Address,
|
|
|
|
&ReferenceName);
|
|
|
|
if (Name) {
|
|
|
|
SymbolicOp.AddSymbol.Name = Name;
|
|
|
|
SymbolicOp.AddSymbol.Present = true;
|
|
|
|
}
|
|
|
|
// For branches always create an MCExpr so it gets printed as hex address.
|
|
|
|
else if (isBranch) {
|
|
|
|
SymbolicOp.Value = Value;
|
2011-10-04 22:44:48 +00:00
|
|
|
}
|
2012-02-23 18:18:17 +00:00
|
|
|
if(ReferenceType == LLVMDisassembler_ReferenceType_Out_SymbolStub)
|
|
|
|
(*Dis->CommentStream) << "symbol stub for: " << ReferenceName;
|
|
|
|
if (!Name && !isBranch)
|
|
|
|
return false;
|
2011-10-04 22:44:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MCContext *Ctx = Dis->getMCContext();
|
|
|
|
const MCExpr *Add = NULL;
|
|
|
|
if (SymbolicOp.AddSymbol.Present) {
|
|
|
|
if (SymbolicOp.AddSymbol.Name) {
|
|
|
|
StringRef Name(SymbolicOp.AddSymbol.Name);
|
|
|
|
MCSymbol *Sym = Ctx->GetOrCreateSymbol(Name);
|
|
|
|
Add = MCSymbolRefExpr::Create(Sym, *Ctx);
|
|
|
|
} else {
|
|
|
|
Add = MCConstantExpr::Create(SymbolicOp.AddSymbol.Value, *Ctx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const MCExpr *Sub = NULL;
|
|
|
|
if (SymbolicOp.SubtractSymbol.Present) {
|
|
|
|
if (SymbolicOp.SubtractSymbol.Name) {
|
|
|
|
StringRef Name(SymbolicOp.SubtractSymbol.Name);
|
|
|
|
MCSymbol *Sym = Ctx->GetOrCreateSymbol(Name);
|
|
|
|
Sub = MCSymbolRefExpr::Create(Sym, *Ctx);
|
|
|
|
} else {
|
|
|
|
Sub = MCConstantExpr::Create(SymbolicOp.SubtractSymbol.Value, *Ctx);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const MCExpr *Off = NULL;
|
|
|
|
if (SymbolicOp.Value != 0)
|
|
|
|
Off = MCConstantExpr::Create(SymbolicOp.Value, *Ctx);
|
|
|
|
|
|
|
|
const MCExpr *Expr;
|
|
|
|
if (Sub) {
|
|
|
|
const MCExpr *LHS;
|
|
|
|
if (Add)
|
|
|
|
LHS = MCBinaryExpr::CreateSub(Add, Sub, *Ctx);
|
|
|
|
else
|
|
|
|
LHS = MCUnaryExpr::CreateMinus(Sub, *Ctx);
|
|
|
|
if (Off != 0)
|
|
|
|
Expr = MCBinaryExpr::CreateAdd(LHS, Off, *Ctx);
|
|
|
|
else
|
|
|
|
Expr = LHS;
|
|
|
|
} else if (Add) {
|
|
|
|
if (Off != 0)
|
|
|
|
Expr = MCBinaryExpr::CreateAdd(Add, Off, *Ctx);
|
|
|
|
else
|
|
|
|
Expr = Add;
|
|
|
|
} else {
|
|
|
|
if (Off != 0)
|
|
|
|
Expr = Off;
|
|
|
|
else
|
|
|
|
Expr = MCConstantExpr::Create(0, *Ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (SymbolicOp.VariantKind == LLVMDisassembler_VariantKind_ARM_HI16)
|
|
|
|
MI.addOperand(MCOperand::CreateExpr(ARMMCExpr::CreateUpper16(Expr, *Ctx)));
|
|
|
|
else if (SymbolicOp.VariantKind == LLVMDisassembler_VariantKind_ARM_LO16)
|
|
|
|
MI.addOperand(MCOperand::CreateExpr(ARMMCExpr::CreateLower16(Expr, *Ctx)));
|
|
|
|
else if (SymbolicOp.VariantKind == LLVMDisassembler_VariantKind_None)
|
|
|
|
MI.addOperand(MCOperand::CreateExpr(Expr));
|
2011-10-20 17:28:20 +00:00
|
|
|
else
|
2012-02-07 02:50:20 +00:00
|
|
|
llvm_unreachable("bad SymbolicOp.VariantKind");
|
2011-10-04 22:44:48 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// tryAddingPcLoadReferenceComment - trys to add a comment as to what is being
|
|
|
|
/// referenced by a load instruction with the base register that is the Pc.
|
|
|
|
/// These can often be values in a literal pool near the Address of the
|
|
|
|
/// instruction. The Address of the instruction and its immediate Value are
|
|
|
|
/// used as a possible literal pool entry. The SymbolLookUp call back will
|
|
|
|
/// return the name of a symbol referenced by the the literal pool's entry if
|
|
|
|
/// the referenced address is that of a symbol. Or it will return a pointer to
|
|
|
|
/// a literal 'C' string if the referenced address of the literal pool's entry
|
|
|
|
/// is an address into a section with 'C' string literals.
|
|
|
|
static void tryAddingPcLoadReferenceComment(uint64_t Address, int Value,
|
2012-02-23 18:18:17 +00:00
|
|
|
const void *Decoder) {
|
2011-10-04 22:44:48 +00:00
|
|
|
const MCDisassembler *Dis = static_cast<const MCDisassembler*>(Decoder);
|
|
|
|
LLVMSymbolLookupCallback SymbolLookUp = Dis->getLLVMSymbolLookupCallback();
|
|
|
|
if (SymbolLookUp) {
|
|
|
|
void *DisInfo = Dis->getDisInfoBlock();
|
|
|
|
uint64_t ReferenceType;
|
|
|
|
ReferenceType = LLVMDisassembler_ReferenceType_In_PCrel_Load;
|
|
|
|
const char *ReferenceName;
|
|
|
|
(void)SymbolLookUp(DisInfo, Value, &ReferenceType, Address, &ReferenceName);
|
|
|
|
if(ReferenceType == LLVMDisassembler_ReferenceType_Out_LitPool_SymAddr ||
|
|
|
|
ReferenceType == LLVMDisassembler_ReferenceType_Out_LitPool_CstrAddr)
|
|
|
|
(*Dis->CommentStream) << "literal pool for: " << ReferenceName;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
// Thumb1 instructions don't have explicit S bits. Rather, they
|
|
|
|
// implicitly set CPSR. Since it's not represented in the encoding, the
|
|
|
|
// auto-generated decoder won't inject the CPSR operand. We need to fix
|
|
|
|
// that as a post-pass.
|
|
|
|
static void AddThumb1SBit(MCInst &MI, bool InITBlock) {
|
|
|
|
const MCOperandInfo *OpInfo = ARMInsts[MI.getOpcode()].OpInfo;
|
2011-08-17 18:14:48 +00:00
|
|
|
unsigned short NumOps = ARMInsts[MI.getOpcode()].NumOperands;
|
2011-08-09 20:55:18 +00:00
|
|
|
MCInst::iterator I = MI.begin();
|
2011-08-17 18:14:48 +00:00
|
|
|
for (unsigned i = 0; i < NumOps; ++i, ++I) {
|
|
|
|
if (I == MI.end()) break;
|
2011-08-09 20:55:18 +00:00
|
|
|
if (OpInfo[i].isOptionalDef() && OpInfo[i].RegClass == ARM::CCRRegClassID) {
|
2011-08-17 18:14:48 +00:00
|
|
|
if (i > 0 && OpInfo[i-1].isPredicate()) continue;
|
2011-08-09 20:55:18 +00:00
|
|
|
MI.insert(I, MCOperand::CreateReg(InITBlock ? 0 : ARM::CPSR));
|
|
|
|
return;
|
2010-04-02 22:27:38 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-17 18:14:48 +00:00
|
|
|
MI.insert(I, MCOperand::CreateReg(InITBlock ? 0 : ARM::CPSR));
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Most Thumb instructions don't have explicit predicates in the
|
|
|
|
// encoding, but rather get their predicates from IT context. We need
|
|
|
|
// to fix up the predicate operands using this context information as a
|
|
|
|
// post-pass.
|
2011-09-08 22:42:49 +00:00
|
|
|
MCDisassembler::DecodeStatus
|
|
|
|
ThumbDisassembler::AddThumbPredicate(MCInst &MI) const {
|
2011-09-09 21:48:23 +00:00
|
|
|
MCDisassembler::DecodeStatus S = Success;
|
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
// A few instructions actually have predicates encoded in them. Don't
|
|
|
|
// try to overwrite it if we're seeing one of those.
|
|
|
|
switch (MI.getOpcode()) {
|
|
|
|
case ARM::tBcc:
|
|
|
|
case ARM::t2Bcc:
|
2011-09-08 22:42:49 +00:00
|
|
|
case ARM::tCBZ:
|
|
|
|
case ARM::tCBNZ:
|
2011-09-19 23:47:10 +00:00
|
|
|
case ARM::tCPS:
|
|
|
|
case ARM::t2CPS3p:
|
|
|
|
case ARM::t2CPS2p:
|
|
|
|
case ARM::t2CPS1p:
|
2011-09-19 23:57:20 +00:00
|
|
|
case ARM::tMOVSr:
|
2011-10-13 17:58:39 +00:00
|
|
|
case ARM::tSETEND:
|
2011-09-08 22:48:37 +00:00
|
|
|
// Some instructions (mostly conditional branches) are not
|
|
|
|
// allowed in IT blocks.
|
2011-09-08 22:42:49 +00:00
|
|
|
if (!ITBlock.empty())
|
2011-09-09 21:48:23 +00:00
|
|
|
S = SoftFail;
|
|
|
|
else
|
|
|
|
return Success;
|
|
|
|
break;
|
|
|
|
case ARM::tB:
|
|
|
|
case ARM::t2B:
|
2011-09-19 22:34:23 +00:00
|
|
|
case ARM::t2TBB:
|
|
|
|
case ARM::t2TBH:
|
2011-09-09 21:48:23 +00:00
|
|
|
// Some instructions (mostly unconditional branches) can
|
|
|
|
// only appears at the end of, or outside of, an IT.
|
|
|
|
if (ITBlock.size() > 1)
|
|
|
|
S = SoftFail;
|
2011-09-08 22:42:49 +00:00
|
|
|
break;
|
2010-04-02 22:27:38 +00:00
|
|
|
default:
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
2010-04-02 22:27:38 +00:00
|
|
|
}
|
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
// If we're in an IT block, base the predicate on that. Otherwise,
|
|
|
|
// assume a predicate of AL.
|
|
|
|
unsigned CC;
|
2011-08-10 17:36:48 +00:00
|
|
|
if (!ITBlock.empty()) {
|
2011-08-09 20:55:18 +00:00
|
|
|
CC = ITBlock.back();
|
2011-08-26 06:19:51 +00:00
|
|
|
if (CC == 0xF)
|
|
|
|
CC = ARMCC::AL;
|
2011-08-09 20:55:18 +00:00
|
|
|
ITBlock.pop_back();
|
|
|
|
} else
|
|
|
|
CC = ARMCC::AL;
|
|
|
|
|
|
|
|
const MCOperandInfo *OpInfo = ARMInsts[MI.getOpcode()].OpInfo;
|
2011-08-17 18:14:48 +00:00
|
|
|
unsigned short NumOps = ARMInsts[MI.getOpcode()].NumOperands;
|
2011-08-09 20:55:18 +00:00
|
|
|
MCInst::iterator I = MI.begin();
|
2011-08-17 18:14:48 +00:00
|
|
|
for (unsigned i = 0; i < NumOps; ++i, ++I) {
|
|
|
|
if (I == MI.end()) break;
|
2011-08-09 20:55:18 +00:00
|
|
|
if (OpInfo[i].isPredicate()) {
|
|
|
|
I = MI.insert(I, MCOperand::CreateImm(CC));
|
|
|
|
++I;
|
|
|
|
if (CC == ARMCC::AL)
|
|
|
|
MI.insert(I, MCOperand::CreateReg(0));
|
|
|
|
else
|
|
|
|
MI.insert(I, MCOperand::CreateReg(ARM::CPSR));
|
2011-09-09 21:48:23 +00:00
|
|
|
return S;
|
2010-04-02 22:27:38 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
2010-04-02 22:27:38 +00:00
|
|
|
|
2011-08-17 18:14:48 +00:00
|
|
|
I = MI.insert(I, MCOperand::CreateImm(CC));
|
|
|
|
++I;
|
2011-08-09 20:55:18 +00:00
|
|
|
if (CC == ARMCC::AL)
|
2011-08-17 18:14:48 +00:00
|
|
|
MI.insert(I, MCOperand::CreateReg(0));
|
2011-08-09 20:55:18 +00:00
|
|
|
else
|
2011-08-17 18:14:48 +00:00
|
|
|
MI.insert(I, MCOperand::CreateReg(ARM::CPSR));
|
2011-09-08 22:42:49 +00:00
|
|
|
|
2011-09-09 21:48:23 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Thumb VFP instructions are a special case. Because we share their
|
|
|
|
// encodings between ARM and Thumb modes, and they are predicable in ARM
|
|
|
|
// mode, the auto-generated decoder will give them an (incorrect)
|
|
|
|
// predicate operand. We need to rewrite these operands based on the IT
|
|
|
|
// context as a post-pass.
|
|
|
|
void ThumbDisassembler::UpdateThumbVFPPredicate(MCInst &MI) const {
|
|
|
|
unsigned CC;
|
2011-08-10 17:36:48 +00:00
|
|
|
if (!ITBlock.empty()) {
|
2011-08-09 20:55:18 +00:00
|
|
|
CC = ITBlock.back();
|
|
|
|
ITBlock.pop_back();
|
|
|
|
} else
|
|
|
|
CC = ARMCC::AL;
|
|
|
|
|
|
|
|
const MCOperandInfo *OpInfo = ARMInsts[MI.getOpcode()].OpInfo;
|
|
|
|
MCInst::iterator I = MI.begin();
|
2011-08-24 21:35:46 +00:00
|
|
|
unsigned short NumOps = ARMInsts[MI.getOpcode()].NumOperands;
|
|
|
|
for (unsigned i = 0; i < NumOps; ++i, ++I) {
|
2011-08-09 20:55:18 +00:00
|
|
|
if (OpInfo[i].isPredicate() ) {
|
|
|
|
I->setImm(CC);
|
|
|
|
++I;
|
|
|
|
if (CC == ARMCC::AL)
|
|
|
|
I->setReg(0);
|
|
|
|
else
|
|
|
|
I->setReg(ARM::CPSR);
|
|
|
|
return;
|
2011-03-26 01:32:48 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus ThumbDisassembler::getInstruction(MCInst &MI, uint64_t &Size,
|
2012-02-29 01:09:06 +00:00
|
|
|
const MemoryObject &Region,
|
2011-08-17 21:58:18 +00:00
|
|
|
uint64_t Address,
|
2011-09-15 23:38:46 +00:00
|
|
|
raw_ostream &os,
|
|
|
|
raw_ostream &cs) const {
|
2011-10-04 22:44:48 +00:00
|
|
|
CommentStream = &cs;
|
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
uint8_t bytes[4];
|
|
|
|
|
2011-09-07 19:42:28 +00:00
|
|
|
assert((STI.getFeatureBits() & ARM::ModeThumb) &&
|
|
|
|
"Asked to disassemble in Thumb mode but Subtarget is in ARM mode!");
|
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
// We want to read exactly 2 bytes of data.
|
2011-08-26 18:21:36 +00:00
|
|
|
if (Region.readBytes(Address, 2, (uint8_t*)bytes, NULL) == -1) {
|
|
|
|
Size = 0;
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-26 18:21:36 +00:00
|
|
|
}
|
2011-03-26 01:32:48 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
uint16_t insn16 = (bytes[1] << 8) | bytes[0];
|
2011-09-07 19:42:28 +00:00
|
|
|
DecodeStatus result = decodeThumbInstruction16(MI, insn16, Address, this, STI);
|
2011-09-01 18:02:14 +00:00
|
|
|
if (result != MCDisassembler::Fail) {
|
2011-08-16 23:45:44 +00:00
|
|
|
Size = 2;
|
2011-09-08 22:42:49 +00:00
|
|
|
Check(result, AddThumbPredicate(MI));
|
2011-08-17 17:44:15 +00:00
|
|
|
return result;
|
2011-08-16 23:45:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MI.clear();
|
2011-09-07 19:42:28 +00:00
|
|
|
result = decodeThumbSBitInstruction16(MI, insn16, Address, this, STI);
|
2011-08-09 20:55:18 +00:00
|
|
|
if (result) {
|
|
|
|
Size = 2;
|
2011-08-10 17:36:48 +00:00
|
|
|
bool InITBlock = !ITBlock.empty();
|
2011-09-08 22:42:49 +00:00
|
|
|
Check(result, AddThumbPredicate(MI));
|
2011-08-09 20:55:18 +00:00
|
|
|
AddThumb1SBit(MI, InITBlock);
|
2011-08-17 17:44:15 +00:00
|
|
|
return result;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MI.clear();
|
2011-09-07 19:42:28 +00:00
|
|
|
result = decodeThumb2Instruction16(MI, insn16, Address, this, STI);
|
2011-09-01 18:02:14 +00:00
|
|
|
if (result != MCDisassembler::Fail) {
|
2011-08-09 20:55:18 +00:00
|
|
|
Size = 2;
|
2011-10-06 23:33:11 +00:00
|
|
|
|
|
|
|
// Nested IT blocks are UNPREDICTABLE. Must be checked before we add
|
|
|
|
// the Thumb predicate.
|
|
|
|
if (MI.getOpcode() == ARM::t2IT && !ITBlock.empty())
|
|
|
|
result = MCDisassembler::SoftFail;
|
|
|
|
|
2011-09-08 22:42:49 +00:00
|
|
|
Check(result, AddThumbPredicate(MI));
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
// If we find an IT instruction, we need to parse its condition
|
|
|
|
// code and mask operands so that we can apply them correctly
|
|
|
|
// to the subsequent instructions.
|
|
|
|
if (MI.getOpcode() == ARM::t2IT) {
|
2011-09-14 21:06:21 +00:00
|
|
|
|
2011-08-30 22:58:27 +00:00
|
|
|
// (3 - the number of trailing zeros) is the number of then / else.
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned firstcond = MI.getOperand(0).getImm();
|
2011-08-30 22:58:27 +00:00
|
|
|
unsigned Mask = MI.getOperand(1).getImm();
|
|
|
|
unsigned CondBit0 = Mask >> 4 & 1;
|
|
|
|
unsigned NumTZ = CountTrailingZeros_32(Mask);
|
|
|
|
assert(NumTZ <= 3 && "Invalid IT mask!");
|
|
|
|
for (unsigned Pos = 3, e = NumTZ; Pos > e; --Pos) {
|
|
|
|
bool T = ((Mask >> Pos) & 1) == CondBit0;
|
|
|
|
if (T)
|
|
|
|
ITBlock.insert(ITBlock.begin(), firstcond);
|
2011-08-09 20:55:18 +00:00
|
|
|
else
|
2011-08-30 22:58:27 +00:00
|
|
|
ITBlock.insert(ITBlock.begin(), firstcond ^ 1);
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
2011-08-30 22:58:27 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
ITBlock.push_back(firstcond);
|
2011-03-26 01:32:48 +00:00
|
|
|
}
|
2010-04-02 22:27:38 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return result;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// We want to read exactly 4 bytes of data.
|
2011-08-26 18:21:36 +00:00
|
|
|
if (Region.readBytes(Address, 4, (uint8_t*)bytes, NULL) == -1) {
|
|
|
|
Size = 0;
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-26 18:21:36 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
uint32_t insn32 = (bytes[3] << 8) |
|
|
|
|
(bytes[2] << 0) |
|
|
|
|
(bytes[1] << 24) |
|
|
|
|
(bytes[0] << 16);
|
|
|
|
MI.clear();
|
2011-09-07 19:42:28 +00:00
|
|
|
result = decodeThumbInstruction32(MI, insn32, Address, this, STI);
|
2011-09-01 18:02:14 +00:00
|
|
|
if (result != MCDisassembler::Fail) {
|
2011-08-09 20:55:18 +00:00
|
|
|
Size = 4;
|
|
|
|
bool InITBlock = ITBlock.size();
|
2011-09-08 22:42:49 +00:00
|
|
|
Check(result, AddThumbPredicate(MI));
|
2011-08-09 20:55:18 +00:00
|
|
|
AddThumb1SBit(MI, InITBlock);
|
2011-08-17 17:44:15 +00:00
|
|
|
return result;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MI.clear();
|
2011-09-07 19:42:28 +00:00
|
|
|
result = decodeThumb2Instruction32(MI, insn32, Address, this, STI);
|
2011-09-01 18:02:14 +00:00
|
|
|
if (result != MCDisassembler::Fail) {
|
2011-08-09 20:55:18 +00:00
|
|
|
Size = 4;
|
2011-09-08 22:42:49 +00:00
|
|
|
Check(result, AddThumbPredicate(MI));
|
2011-08-17 17:44:15 +00:00
|
|
|
return result;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
MI.clear();
|
2011-09-07 19:42:28 +00:00
|
|
|
result = decodeVFPInstruction32(MI, insn32, Address, this, STI);
|
2011-09-01 18:02:14 +00:00
|
|
|
if (result != MCDisassembler::Fail) {
|
2011-08-09 20:55:18 +00:00
|
|
|
Size = 4;
|
|
|
|
UpdateThumbVFPPredicate(MI);
|
2011-08-17 17:44:15 +00:00
|
|
|
return result;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
2010-04-02 22:27:38 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
MI.clear();
|
2011-09-07 19:42:28 +00:00
|
|
|
result = decodeNEONDupInstruction32(MI, insn32, Address, this, STI);
|
2011-09-01 18:02:14 +00:00
|
|
|
if (result != MCDisassembler::Fail) {
|
2011-08-15 23:38:54 +00:00
|
|
|
Size = 4;
|
2011-09-08 22:42:49 +00:00
|
|
|
Check(result, AddThumbPredicate(MI));
|
2011-08-17 17:44:15 +00:00
|
|
|
return result;
|
2011-08-15 23:38:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (fieldFromInstruction32(insn32, 24, 8) == 0xF9) {
|
|
|
|
MI.clear();
|
|
|
|
uint32_t NEONLdStInsn = insn32;
|
|
|
|
NEONLdStInsn &= 0xF0FFFFFF;
|
|
|
|
NEONLdStInsn |= 0x04000000;
|
2011-09-07 19:42:28 +00:00
|
|
|
result = decodeNEONLoadStoreInstruction32(MI, NEONLdStInsn, Address, this, STI);
|
2011-09-01 18:02:14 +00:00
|
|
|
if (result != MCDisassembler::Fail) {
|
2011-08-15 23:38:54 +00:00
|
|
|
Size = 4;
|
2011-09-08 22:42:49 +00:00
|
|
|
Check(result, AddThumbPredicate(MI));
|
2011-08-17 17:44:15 +00:00
|
|
|
return result;
|
2011-08-15 23:38:54 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-10 19:01:10 +00:00
|
|
|
if (fieldFromInstruction32(insn32, 24, 4) == 0xF) {
|
2011-08-15 23:38:54 +00:00
|
|
|
MI.clear();
|
2011-08-10 19:01:10 +00:00
|
|
|
uint32_t NEONDataInsn = insn32;
|
|
|
|
NEONDataInsn &= 0xF0FFFFFF; // Clear bits 27-24
|
|
|
|
NEONDataInsn |= (NEONDataInsn & 0x10000000) >> 4; // Move bit 28 to bit 24
|
|
|
|
NEONDataInsn |= 0x12000000; // Set bits 28 and 25
|
2011-09-07 19:42:28 +00:00
|
|
|
result = decodeNEONDataInstruction32(MI, NEONDataInsn, Address, this, STI);
|
2011-09-01 18:02:14 +00:00
|
|
|
if (result != MCDisassembler::Fail) {
|
2011-08-10 19:01:10 +00:00
|
|
|
Size = 4;
|
2011-09-08 22:42:49 +00:00
|
|
|
Check(result, AddThumbPredicate(MI));
|
2011-08-17 17:44:15 +00:00
|
|
|
return result;
|
2011-08-10 19:01:10 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-26 18:21:36 +00:00
|
|
|
Size = 0;
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2010-04-02 22:27:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
extern "C" void LLVMInitializeARMDisassembler() {
|
|
|
|
TargetRegistry::RegisterMCDisassembler(TheARMTarget,
|
|
|
|
createARMDisassembler);
|
|
|
|
TargetRegistry::RegisterMCDisassembler(TheThumbTarget,
|
|
|
|
createThumbDisassembler);
|
|
|
|
}
|
2010-04-02 22:27:38 +00:00
|
|
|
|
2012-03-11 07:16:55 +00:00
|
|
|
static const uint16_t GPRDecoderTable[] = {
|
2011-08-09 20:55:18 +00:00
|
|
|
ARM::R0, ARM::R1, ARM::R2, ARM::R3,
|
|
|
|
ARM::R4, ARM::R5, ARM::R6, ARM::R7,
|
|
|
|
ARM::R8, ARM::R9, ARM::R10, ARM::R11,
|
|
|
|
ARM::R12, ARM::SP, ARM::LR, ARM::PC
|
|
|
|
};
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeGPRRegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
if (RegNo > 15)
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2010-04-02 22:27:38 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Register = GPRDecoderTable[RegNo];
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(Register));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
static DecodeStatus
|
2012-03-27 07:21:54 +00:00
|
|
|
DecodeGPRnopcRegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-17 21:58:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2012-03-20 15:54:56 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
|
|
|
|
|
|
|
if (RegNo == 15)
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
|
|
|
|
Check(S, DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder));
|
|
|
|
|
|
|
|
return S;
|
2011-08-09 22:48:45 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodetGPRRegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
if (RegNo > 7)
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);
|
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodetcGPRRegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
unsigned Register = 0;
|
|
|
|
switch (RegNo) {
|
|
|
|
case 0:
|
|
|
|
Register = ARM::R0;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
Register = ARM::R1;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
Register = ARM::R2;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
Register = ARM::R3;
|
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
Register = ARM::R9;
|
|
|
|
break;
|
|
|
|
case 12:
|
|
|
|
Register = ARM::R12;
|
|
|
|
break;
|
|
|
|
default:
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
2010-04-02 22:27:38 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateReg(Register));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecoderGPRRegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 18:02:14 +00:00
|
|
|
if (RegNo == 13 || RegNo == 15) return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
return DecodeGPRRegisterClass(Inst, RegNo, Address, Decoder);
|
|
|
|
}
|
2011-04-11 18:08:50 +00:00
|
|
|
|
2012-03-11 07:16:55 +00:00
|
|
|
static const uint16_t SPRDecoderTable[] = {
|
2011-08-09 20:55:18 +00:00
|
|
|
ARM::S0, ARM::S1, ARM::S2, ARM::S3,
|
|
|
|
ARM::S4, ARM::S5, ARM::S6, ARM::S7,
|
|
|
|
ARM::S8, ARM::S9, ARM::S10, ARM::S11,
|
|
|
|
ARM::S12, ARM::S13, ARM::S14, ARM::S15,
|
|
|
|
ARM::S16, ARM::S17, ARM::S18, ARM::S19,
|
|
|
|
ARM::S20, ARM::S21, ARM::S22, ARM::S23,
|
|
|
|
ARM::S24, ARM::S25, ARM::S26, ARM::S27,
|
|
|
|
ARM::S28, ARM::S29, ARM::S30, ARM::S31
|
|
|
|
};
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSPRRegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
if (RegNo > 31)
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2010-04-02 22:27:38 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Register = SPRDecoderTable[RegNo];
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(Register));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2010-04-02 22:27:38 +00:00
|
|
|
}
|
|
|
|
|
2012-03-11 07:16:55 +00:00
|
|
|
static const uint16_t DPRDecoderTable[] = {
|
2011-08-09 20:55:18 +00:00
|
|
|
ARM::D0, ARM::D1, ARM::D2, ARM::D3,
|
|
|
|
ARM::D4, ARM::D5, ARM::D6, ARM::D7,
|
|
|
|
ARM::D8, ARM::D9, ARM::D10, ARM::D11,
|
|
|
|
ARM::D12, ARM::D13, ARM::D14, ARM::D15,
|
|
|
|
ARM::D16, ARM::D17, ARM::D18, ARM::D19,
|
|
|
|
ARM::D20, ARM::D21, ARM::D22, ARM::D23,
|
|
|
|
ARM::D24, ARM::D25, ARM::D26, ARM::D27,
|
|
|
|
ARM::D28, ARM::D29, ARM::D30, ARM::D31
|
|
|
|
};
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeDPRRegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
if (RegNo > 31)
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2010-04-02 22:27:38 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Register = DPRDecoderTable[RegNo];
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(Register));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeDPR_8RegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
if (RegNo > 7)
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
return DecodeDPRRegisterClass(Inst, RegNo, Address, Decoder);
|
|
|
|
}
|
2010-04-02 22:27:38 +00:00
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
static DecodeStatus
|
2012-03-27 07:21:54 +00:00
|
|
|
DecodeDPR_VFP2RegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-17 21:58:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-08-09 20:55:18 +00:00
|
|
|
if (RegNo > 15)
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
return DecodeDPRRegisterClass(Inst, RegNo, Address, Decoder);
|
|
|
|
}
|
2010-04-02 22:27:38 +00:00
|
|
|
|
2012-03-11 07:16:55 +00:00
|
|
|
static const uint16_t QPRDecoderTable[] = {
|
2011-08-09 20:55:18 +00:00
|
|
|
ARM::Q0, ARM::Q1, ARM::Q2, ARM::Q3,
|
|
|
|
ARM::Q4, ARM::Q5, ARM::Q6, ARM::Q7,
|
|
|
|
ARM::Q8, ARM::Q9, ARM::Q10, ARM::Q11,
|
|
|
|
ARM::Q12, ARM::Q13, ARM::Q14, ARM::Q15
|
|
|
|
};
|
2010-04-16 23:02:25 +00:00
|
|
|
|
2011-04-11 18:08:50 +00:00
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeQPRRegisterClass(MCInst &Inst, unsigned RegNo,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
if (RegNo > 31)
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
RegNo >>= 1;
|
2010-04-02 22:27:38 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Register = QPRDecoderTable[RegNo];
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(Register));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2010-04-02 22:27:38 +00:00
|
|
|
}
|
|
|
|
|
2012-03-11 07:16:55 +00:00
|
|
|
static const uint16_t DPairDecoderTable[] = {
|
2012-03-05 19:33:30 +00:00
|
|
|
ARM::Q0, ARM::D1_D2, ARM::Q1, ARM::D3_D4, ARM::Q2, ARM::D5_D6,
|
|
|
|
ARM::Q3, ARM::D7_D8, ARM::Q4, ARM::D9_D10, ARM::Q5, ARM::D11_D12,
|
|
|
|
ARM::Q6, ARM::D13_D14, ARM::Q7, ARM::D15_D16, ARM::Q8, ARM::D17_D18,
|
|
|
|
ARM::Q9, ARM::D19_D20, ARM::Q10, ARM::D21_D22, ARM::Q11, ARM::D23_D24,
|
|
|
|
ARM::Q12, ARM::D25_D26, ARM::Q13, ARM::D27_D28, ARM::Q14, ARM::D29_D30,
|
|
|
|
ARM::Q15
|
|
|
|
};
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeDPairRegisterClass(MCInst &Inst, unsigned RegNo,
|
2012-03-05 19:33:30 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
if (RegNo > 30)
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
|
|
|
|
unsigned Register = DPairDecoderTable[RegNo];
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(Register));
|
|
|
|
return MCDisassembler::Success;
|
|
|
|
}
|
|
|
|
|
2012-03-11 07:16:55 +00:00
|
|
|
static const uint16_t DPairSpacedDecoderTable[] = {
|
2012-03-05 21:43:40 +00:00
|
|
|
ARM::D0_D2, ARM::D1_D3, ARM::D2_D4, ARM::D3_D5,
|
|
|
|
ARM::D4_D6, ARM::D5_D7, ARM::D6_D8, ARM::D7_D9,
|
|
|
|
ARM::D8_D10, ARM::D9_D11, ARM::D10_D12, ARM::D11_D13,
|
|
|
|
ARM::D12_D14, ARM::D13_D15, ARM::D14_D16, ARM::D15_D17,
|
|
|
|
ARM::D16_D18, ARM::D17_D19, ARM::D18_D20, ARM::D19_D21,
|
|
|
|
ARM::D20_D22, ARM::D21_D23, ARM::D22_D24, ARM::D23_D25,
|
|
|
|
ARM::D24_D26, ARM::D25_D27, ARM::D26_D28, ARM::D27_D29,
|
|
|
|
ARM::D28_D30, ARM::D29_D31
|
|
|
|
};
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeDPairSpacedRegisterClass(MCInst &Inst,
|
2012-03-05 21:43:40 +00:00
|
|
|
unsigned RegNo,
|
|
|
|
uint64_t Address,
|
|
|
|
const void *Decoder) {
|
|
|
|
if (RegNo > 29)
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
|
|
|
|
unsigned Register = DPairSpacedDecoderTable[RegNo];
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(Register));
|
|
|
|
return MCDisassembler::Success;
|
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodePredicateOperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 18:02:14 +00:00
|
|
|
if (Val == 0xF) return MCDisassembler::Fail;
|
2011-08-09 21:07:45 +00:00
|
|
|
// AL predicate is not allowed on Thumb1 branches.
|
|
|
|
if (Inst.getOpcode() == ARM::tBcc && Val == 0xE)
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(Val));
|
|
|
|
if (Val == ARMCC::AL) {
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(0));
|
|
|
|
} else
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(ARM::CPSR));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2010-04-02 22:27:38 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeCCOutOperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
if (Val)
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(ARM::CPSR));
|
|
|
|
else
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(0));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
2010-04-20 00:15:41 +00:00
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSOImmOperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
uint32_t imm = Val & 0xFF;
|
|
|
|
uint32_t rot = (Val & 0xF00) >> 7;
|
2011-10-13 23:36:06 +00:00
|
|
|
uint32_t rot_imm = (imm >> rot) | (imm << ((32-rot) & 0x1F));
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(rot_imm));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSORegImmOperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
unsigned Rm = fieldFromInstruction32(Val, 0, 4);
|
|
|
|
unsigned type = fieldFromInstruction32(Val, 5, 2);
|
|
|
|
unsigned imm = fieldFromInstruction32(Val, 7, 5);
|
|
|
|
|
|
|
|
// Register-immediate
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
ARM_AM::ShiftOpc Shift = ARM_AM::lsl;
|
|
|
|
switch (type) {
|
|
|
|
case 0:
|
|
|
|
Shift = ARM_AM::lsl;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
Shift = ARM_AM::lsr;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
Shift = ARM_AM::asr;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
Shift = ARM_AM::ror;
|
|
|
|
break;
|
2010-04-20 00:15:41 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
if (Shift == ARM_AM::ror && imm == 0)
|
|
|
|
Shift = ARM_AM::rrx;
|
|
|
|
|
|
|
|
unsigned Op = Shift | (imm << 3);
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(Op));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSORegRegOperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
unsigned Rm = fieldFromInstruction32(Val, 0, 4);
|
|
|
|
unsigned type = fieldFromInstruction32(Val, 5, 2);
|
|
|
|
unsigned Rs = fieldFromInstruction32(Val, 8, 4);
|
|
|
|
|
|
|
|
// Register-register
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRnopcRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRnopcRegisterClass(Inst, Rs, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
ARM_AM::ShiftOpc Shift = ARM_AM::lsl;
|
|
|
|
switch (type) {
|
|
|
|
case 0:
|
|
|
|
Shift = ARM_AM::lsl;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
Shift = ARM_AM::lsr;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
Shift = ARM_AM::asr;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
Shift = ARM_AM::ror;
|
|
|
|
break;
|
2010-04-20 00:15:41 +00:00
|
|
|
}
|
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(Shift));
|
2010-04-20 00:15:41 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2010-04-02 22:27:38 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeRegListOperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-09-09 23:13:33 +00:00
|
|
|
bool writebackLoad = false;
|
|
|
|
unsigned writebackReg = 0;
|
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
case ARM::LDMIA_UPD:
|
|
|
|
case ARM::LDMDB_UPD:
|
|
|
|
case ARM::LDMIB_UPD:
|
|
|
|
case ARM::LDMDA_UPD:
|
|
|
|
case ARM::t2LDMIA_UPD:
|
|
|
|
case ARM::t2LDMDB_UPD:
|
|
|
|
writebackLoad = true;
|
|
|
|
writebackReg = Inst.getOperand(0).getReg();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-08-11 20:21:46 +00:00
|
|
|
// Empty register lists are not allowed.
|
2011-11-02 17:46:18 +00:00
|
|
|
if (CountPopulation_32(Val) == 0) return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
for (unsigned i = 0; i < 16; ++i) {
|
2011-08-11 18:24:51 +00:00
|
|
|
if (Val & (1 << i)) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, i, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-09-09 23:13:33 +00:00
|
|
|
// Writeback not allowed if Rn is in the target list.
|
|
|
|
if (writebackLoad && writebackReg == Inst.end()[-1].getReg())
|
|
|
|
Check(S, MCDisassembler::SoftFail);
|
2011-08-11 18:24:51 +00:00
|
|
|
}
|
2010-04-02 22:27:38 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2010-04-02 22:27:38 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSPRRegListOperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Vd = fieldFromInstruction32(Val, 8, 4);
|
|
|
|
unsigned regs = Val & 0xFF;
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeSPRRegisterClass(Inst, Vd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-11 18:24:51 +00:00
|
|
|
for (unsigned i = 0; i < (regs - 1); ++i) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeSPRRegisterClass(Inst, ++Vd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-11 18:24:51 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2010-04-02 22:27:38 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeDPRRegListOperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Vd = fieldFromInstruction32(Val, 8, 4);
|
|
|
|
unsigned regs = (Val & 0xFF) / 2;
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Vd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-11 18:24:51 +00:00
|
|
|
for (unsigned i = 0; i < (regs - 1); ++i) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, ++Vd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-11 18:24:51 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2010-04-02 22:27:38 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeBitfieldMaskOperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-08-10 17:36:48 +00:00
|
|
|
// 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
|
2011-08-17 21:58:18 +00:00
|
|
|
// the mask of that's all ones on [msb, lsb]. Finally we not it to
|
2011-08-10 17:36:48 +00:00
|
|
|
// create the final mask.
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned msb = fieldFromInstruction32(Val, 5, 5);
|
|
|
|
unsigned lsb = fieldFromInstruction32(Val, 0, 5);
|
2011-09-16 22:29:48 +00:00
|
|
|
|
2011-09-16 23:30:01 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
|
|
|
if (lsb > msb) Check(S, MCDisassembler::SoftFail);
|
|
|
|
|
2011-09-16 23:04:48 +00:00
|
|
|
uint32_t msb_mask = 0xFFFFFFFF;
|
|
|
|
if (msb != 31) msb_mask = (1U << (msb+1)) - 1;
|
|
|
|
uint32_t lsb_mask = (1U << lsb) - 1;
|
2011-09-16 22:29:48 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(~(msb_mask ^ lsb_mask)));
|
2011-09-16 23:30:01 +00:00
|
|
|
return S;
|
2010-04-02 22:27:38 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeCopMemInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 28, 4);
|
|
|
|
unsigned CRd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
unsigned coproc = fieldFromInstruction32(Insn, 8, 4);
|
|
|
|
unsigned imm = fieldFromInstruction32(Insn, 0, 8);
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned U = fieldFromInstruction32(Insn, 23, 1);
|
|
|
|
|
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::LDC_OFFSET:
|
|
|
|
case ARM::LDC_PRE:
|
|
|
|
case ARM::LDC_POST:
|
|
|
|
case ARM::LDC_OPTION:
|
|
|
|
case ARM::LDCL_OFFSET:
|
|
|
|
case ARM::LDCL_PRE:
|
|
|
|
case ARM::LDCL_POST:
|
|
|
|
case ARM::LDCL_OPTION:
|
|
|
|
case ARM::STC_OFFSET:
|
|
|
|
case ARM::STC_PRE:
|
|
|
|
case ARM::STC_POST:
|
|
|
|
case ARM::STC_OPTION:
|
|
|
|
case ARM::STCL_OFFSET:
|
|
|
|
case ARM::STCL_PRE:
|
|
|
|
case ARM::STCL_POST:
|
|
|
|
case ARM::STCL_OPTION:
|
2011-09-07 21:10:42 +00:00
|
|
|
case ARM::t2LDC_OFFSET:
|
|
|
|
case ARM::t2LDC_PRE:
|
|
|
|
case ARM::t2LDC_POST:
|
|
|
|
case ARM::t2LDC_OPTION:
|
|
|
|
case ARM::t2LDCL_OFFSET:
|
|
|
|
case ARM::t2LDCL_PRE:
|
|
|
|
case ARM::t2LDCL_POST:
|
|
|
|
case ARM::t2LDCL_OPTION:
|
|
|
|
case ARM::t2STC_OFFSET:
|
|
|
|
case ARM::t2STC_PRE:
|
|
|
|
case ARM::t2STC_POST:
|
|
|
|
case ARM::t2STC_OPTION:
|
|
|
|
case ARM::t2STCL_OFFSET:
|
|
|
|
case ARM::t2STCL_PRE:
|
|
|
|
case ARM::t2STCL_POST:
|
|
|
|
case ARM::t2STCL_OPTION:
|
2011-08-09 20:55:18 +00:00
|
|
|
if (coproc == 0xA || coproc == 0xB)
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(coproc));
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(CRd));
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
switch (Inst.getOpcode()) {
|
2011-10-12 20:54:17 +00:00
|
|
|
case ARM::t2LDC2_OFFSET:
|
|
|
|
case ARM::t2LDC2L_OFFSET:
|
|
|
|
case ARM::t2LDC2_PRE:
|
|
|
|
case ARM::t2LDC2L_PRE:
|
|
|
|
case ARM::t2STC2_OFFSET:
|
|
|
|
case ARM::t2STC2L_OFFSET:
|
|
|
|
case ARM::t2STC2_PRE:
|
|
|
|
case ARM::t2STC2L_PRE:
|
|
|
|
case ARM::LDC2_OFFSET:
|
|
|
|
case ARM::LDC2L_OFFSET:
|
|
|
|
case ARM::LDC2_PRE:
|
|
|
|
case ARM::LDC2L_PRE:
|
|
|
|
case ARM::STC2_OFFSET:
|
|
|
|
case ARM::STC2L_OFFSET:
|
|
|
|
case ARM::STC2_PRE:
|
|
|
|
case ARM::STC2L_PRE:
|
|
|
|
case ARM::t2LDC_OFFSET:
|
|
|
|
case ARM::t2LDCL_OFFSET:
|
|
|
|
case ARM::t2LDC_PRE:
|
|
|
|
case ARM::t2LDCL_PRE:
|
|
|
|
case ARM::t2STC_OFFSET:
|
|
|
|
case ARM::t2STCL_OFFSET:
|
|
|
|
case ARM::t2STC_PRE:
|
|
|
|
case ARM::t2STCL_PRE:
|
|
|
|
case ARM::LDC_OFFSET:
|
|
|
|
case ARM::LDCL_OFFSET:
|
|
|
|
case ARM::LDC_PRE:
|
|
|
|
case ARM::LDCL_PRE:
|
|
|
|
case ARM::STC_OFFSET:
|
|
|
|
case ARM::STCL_OFFSET:
|
|
|
|
case ARM::STC_PRE:
|
|
|
|
case ARM::STCL_PRE:
|
2011-10-12 21:59:02 +00:00
|
|
|
imm = ARM_AM::getAM5Opc(U ? ARM_AM::add : ARM_AM::sub, imm);
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
|
|
|
break;
|
|
|
|
case ARM::t2LDC2_POST:
|
|
|
|
case ARM::t2LDC2L_POST:
|
|
|
|
case ARM::t2STC2_POST:
|
|
|
|
case ARM::t2STC2L_POST:
|
|
|
|
case ARM::LDC2_POST:
|
|
|
|
case ARM::LDC2L_POST:
|
|
|
|
case ARM::STC2_POST:
|
|
|
|
case ARM::STC2L_POST:
|
|
|
|
case ARM::t2LDC_POST:
|
|
|
|
case ARM::t2LDCL_POST:
|
|
|
|
case ARM::t2STC_POST:
|
|
|
|
case ARM::t2STCL_POST:
|
|
|
|
case ARM::LDC_POST:
|
|
|
|
case ARM::LDCL_POST:
|
2011-10-12 20:54:17 +00:00
|
|
|
case ARM::STC_POST:
|
|
|
|
case ARM::STCL_POST:
|
2011-08-09 20:55:18 +00:00
|
|
|
imm |= U << 8;
|
2011-10-12 20:54:17 +00:00
|
|
|
// fall through.
|
2011-08-09 20:55:18 +00:00
|
|
|
default:
|
2011-10-12 20:54:17 +00:00
|
|
|
// The 'option' variant doesn't encode 'U' in the immediate since
|
|
|
|
// the immediate is unsigned [0,255].
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::LDC_OFFSET:
|
|
|
|
case ARM::LDC_PRE:
|
|
|
|
case ARM::LDC_POST:
|
|
|
|
case ARM::LDC_OPTION:
|
|
|
|
case ARM::LDCL_OFFSET:
|
|
|
|
case ARM::LDCL_PRE:
|
|
|
|
case ARM::LDCL_POST:
|
|
|
|
case ARM::LDCL_OPTION:
|
|
|
|
case ARM::STC_OFFSET:
|
|
|
|
case ARM::STC_PRE:
|
|
|
|
case ARM::STC_POST:
|
|
|
|
case ARM::STC_OPTION:
|
|
|
|
case ARM::STCL_OFFSET:
|
|
|
|
case ARM::STCL_PRE:
|
|
|
|
case ARM::STCL_POST:
|
|
|
|
case ARM::STCL_OPTION:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2010-04-13 21:21:57 +00:00
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
static DecodeStatus
|
2012-03-27 07:21:54 +00:00
|
|
|
DecodeAddrMode2IdxInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-17 21:58:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned imm = fieldFromInstruction32(Insn, 0, 12);
|
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 28, 4);
|
|
|
|
unsigned reg = fieldFromInstruction32(Insn, 25, 1);
|
|
|
|
unsigned P = fieldFromInstruction32(Insn, 24, 1);
|
|
|
|
unsigned W = fieldFromInstruction32(Insn, 21, 1);
|
|
|
|
|
|
|
|
// On stores, the writeback operand precedes Rt.
|
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::STR_POST_IMM:
|
|
|
|
case ARM::STR_POST_REG:
|
2011-08-11 20:47:56 +00:00
|
|
|
case ARM::STRB_POST_IMM:
|
|
|
|
case ARM::STRB_POST_REG:
|
2011-08-11 22:18:00 +00:00
|
|
|
case ARM::STRT_POST_REG:
|
|
|
|
case ARM::STRT_POST_IMM:
|
2011-08-11 20:04:56 +00:00
|
|
|
case ARM::STRBT_POST_REG:
|
|
|
|
case ARM::STRBT_POST_IMM:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
// On loads, the writeback operand comes after Rt.
|
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::LDR_POST_IMM:
|
|
|
|
case ARM::LDR_POST_REG:
|
2011-08-11 20:47:56 +00:00
|
|
|
case ARM::LDRB_POST_IMM:
|
|
|
|
case ARM::LDRB_POST_REG:
|
2011-08-09 20:55:18 +00:00
|
|
|
case ARM::LDRBT_POST_REG:
|
|
|
|
case ARM::LDRBT_POST_IMM:
|
2011-08-10 23:43:54 +00:00
|
|
|
case ARM::LDRT_POST_REG:
|
|
|
|
case ARM::LDRT_POST_IMM:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
ARM_AM::AddrOpc Op = ARM_AM::add;
|
|
|
|
if (!fieldFromInstruction32(Insn, 23, 1))
|
|
|
|
Op = ARM_AM::sub;
|
|
|
|
|
|
|
|
bool writeback = (P == 0) || (W == 1);
|
|
|
|
unsigned idx_mode = 0;
|
|
|
|
if (P && writeback)
|
|
|
|
idx_mode = ARMII::IndexModePre;
|
|
|
|
else if (!P && writeback)
|
|
|
|
idx_mode = ARMII::IndexModePost;
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (writeback && (Rn == 15 || Rn == Rt))
|
|
|
|
S = MCDisassembler::SoftFail; // UNPREDICTABLE
|
2011-08-11 19:00:18 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
if (reg) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRnopcRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
ARM_AM::ShiftOpc Opc = ARM_AM::lsl;
|
|
|
|
switch( fieldFromInstruction32(Insn, 5, 2)) {
|
|
|
|
case 0:
|
|
|
|
Opc = ARM_AM::lsl;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
Opc = ARM_AM::lsr;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
Opc = ARM_AM::asr;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
Opc = ARM_AM::ror;
|
|
|
|
break;
|
|
|
|
default:
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
unsigned amt = fieldFromInstruction32(Insn, 7, 5);
|
|
|
|
unsigned imm = ARM_AM::getAM2Opc(Op, amt, Opc, idx_mode);
|
|
|
|
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
|
|
|
} else {
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(0));
|
|
|
|
unsigned tmp = ARM_AM::getAM2Opc(Op, imm, ARM_AM::lsl, idx_mode);
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(tmp));
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSORegMemOperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Val, 13, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Val, 0, 4);
|
|
|
|
unsigned type = fieldFromInstruction32(Val, 5, 2);
|
|
|
|
unsigned imm = fieldFromInstruction32(Val, 7, 5);
|
|
|
|
unsigned U = fieldFromInstruction32(Val, 12, 1);
|
|
|
|
|
2011-08-09 21:38:14 +00:00
|
|
|
ARM_AM::ShiftOpc ShOp = ARM_AM::lsl;
|
2011-08-09 20:55:18 +00:00
|
|
|
switch (type) {
|
|
|
|
case 0:
|
|
|
|
ShOp = ARM_AM::lsl;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
ShOp = ARM_AM::lsr;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
ShOp = ARM_AM::asr;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
ShOp = ARM_AM::ror;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned shift;
|
|
|
|
if (U)
|
|
|
|
shift = ARM_AM::getAM2Opc(ARM_AM::add, imm, ShOp);
|
|
|
|
else
|
|
|
|
shift = ARM_AM::getAM2Opc(ARM_AM::sub, imm, ShOp);
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(shift));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
static DecodeStatus
|
2012-03-27 07:21:54 +00:00
|
|
|
DecodeAddrMode3Instruction(MCInst &Inst, unsigned Insn,
|
2011-08-17 21:58:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned type = fieldFromInstruction32(Insn, 22, 1);
|
|
|
|
unsigned imm = fieldFromInstruction32(Insn, 8, 4);
|
|
|
|
unsigned U = ((~fieldFromInstruction32(Insn, 23, 1)) & 1) << 8;
|
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 28, 4);
|
|
|
|
unsigned W = fieldFromInstruction32(Insn, 21, 1);
|
|
|
|
unsigned P = fieldFromInstruction32(Insn, 24, 1);
|
2012-03-22 14:14:49 +00:00
|
|
|
unsigned Rt2 = Rt + 1;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
bool writeback = (W == 1) | (P == 0);
|
2011-08-15 20:51:32 +00:00
|
|
|
|
|
|
|
// For {LD,ST}RD, Rt must be even, else undefined.
|
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::STRD:
|
|
|
|
case ARM::STRD_PRE:
|
|
|
|
case ARM::STRD_POST:
|
|
|
|
case ARM::LDRD:
|
|
|
|
case ARM::LDRD_PRE:
|
|
|
|
case ARM::LDRD_POST:
|
2012-03-22 14:14:49 +00:00
|
|
|
if (Rt & 0x1) S = MCDisassembler::SoftFail;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::STRD:
|
|
|
|
case ARM::STRD_PRE:
|
|
|
|
case ARM::STRD_POST:
|
|
|
|
if (P == 0 && W == 1)
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
|
|
|
|
if (writeback && (Rn == 15 || Rn == Rt || Rn == Rt2))
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
if (type && Rm == 15)
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
if (Rt2 == 15)
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
if (!type && fieldFromInstruction32(Insn, 8, 4))
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
break;
|
|
|
|
case ARM::STRH:
|
|
|
|
case ARM::STRH_PRE:
|
|
|
|
case ARM::STRH_POST:
|
|
|
|
if (Rt == 15)
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
if (writeback && (Rn == 15 || Rn == Rt))
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
if (!type && Rm == 15)
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
break;
|
|
|
|
case ARM::LDRD:
|
|
|
|
case ARM::LDRD_PRE:
|
|
|
|
case ARM::LDRD_POST:
|
|
|
|
if (type && Rn == 15){
|
|
|
|
if (Rt2 == 15)
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (P == 0 && W == 1)
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
if (!type && (Rt2 == 15 || Rm == 15 || Rm == Rt || Rm == Rt2))
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
if (!type && writeback && Rn == 15)
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
if (writeback && (Rn == Rt || Rn == Rt2))
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
break;
|
|
|
|
case ARM::LDRH:
|
|
|
|
case ARM::LDRH_PRE:
|
|
|
|
case ARM::LDRH_POST:
|
|
|
|
if (type && Rn == 15){
|
|
|
|
if (Rt == 15)
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (Rt == 15)
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
if (!type && Rm == 15)
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
if (!type && writeback && (Rn == 15 || Rn == Rt))
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
break;
|
|
|
|
case ARM::LDRSH:
|
|
|
|
case ARM::LDRSH_PRE:
|
|
|
|
case ARM::LDRSH_POST:
|
|
|
|
case ARM::LDRSB:
|
|
|
|
case ARM::LDRSB_PRE:
|
|
|
|
case ARM::LDRSB_POST:
|
|
|
|
if (type && Rn == 15){
|
|
|
|
if (Rt == 15)
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (type && (Rt == 15 || (writeback && Rn == Rt)))
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
if (!type && (Rt == 15 || Rm == 15))
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
if (!type && writeback && (Rn == 15 || Rn == Rt))
|
|
|
|
S = MCDisassembler::SoftFail;
|
2011-08-15 20:51:32 +00:00
|
|
|
break;
|
2011-09-01 23:23:50 +00:00
|
|
|
default:
|
|
|
|
break;
|
2011-08-15 20:51:32 +00:00
|
|
|
}
|
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
if (writeback) { // Writeback
|
|
|
|
if (P)
|
|
|
|
U |= ARMII::IndexModePre << 9;
|
|
|
|
else
|
|
|
|
U |= ARMII::IndexModePost << 9;
|
|
|
|
|
|
|
|
// On stores, the writeback operand precedes Rt.
|
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::STRD:
|
|
|
|
case ARM::STRD_PRE:
|
|
|
|
case ARM::STRD_POST:
|
2011-08-12 20:02:50 +00:00
|
|
|
case ARM::STRH:
|
|
|
|
case ARM::STRH_PRE:
|
|
|
|
case ARM::STRH_POST:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::STRD:
|
|
|
|
case ARM::STRD_PRE:
|
|
|
|
case ARM::STRD_POST:
|
|
|
|
case ARM::LDRD:
|
|
|
|
case ARM::LDRD_PRE:
|
|
|
|
case ARM::LDRD_POST:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rt+1, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (writeback) {
|
|
|
|
// On loads, the writeback operand comes after Rt.
|
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::LDRD:
|
|
|
|
case ARM::LDRD_PRE:
|
|
|
|
case ARM::LDRD_POST:
|
2011-08-12 20:36:11 +00:00
|
|
|
case ARM::LDRH:
|
|
|
|
case ARM::LDRH_PRE:
|
|
|
|
case ARM::LDRH_POST:
|
|
|
|
case ARM::LDRSH:
|
|
|
|
case ARM::LDRSH_PRE:
|
|
|
|
case ARM::LDRSH_POST:
|
|
|
|
case ARM::LDRSB:
|
|
|
|
case ARM::LDRSB_PRE:
|
|
|
|
case ARM::LDRSB_POST:
|
2011-08-09 20:55:18 +00:00
|
|
|
case ARM::LDRHTr:
|
|
|
|
case ARM::LDRSBTr:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
if (type) {
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(0));
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(U | (imm << 4) | Rm));
|
|
|
|
} else {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(U));
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeRFEInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned mode = fieldFromInstruction32(Insn, 23, 2);
|
|
|
|
|
|
|
|
switch (mode) {
|
|
|
|
case 0:
|
|
|
|
mode = ARM_AM::da;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
mode = ARM_AM::ia;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
mode = ARM_AM::db;
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
mode = ARM_AM::ib;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(mode));
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeMemMultipleWritebackInstruction(MCInst &Inst,
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Insn,
|
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 28, 4);
|
|
|
|
unsigned reglist = fieldFromInstruction32(Insn, 0, 16);
|
|
|
|
|
|
|
|
if (pred == 0xF) {
|
|
|
|
switch (Inst.getOpcode()) {
|
2011-08-18 22:31:17 +00:00
|
|
|
case ARM::LDMDA:
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.setOpcode(ARM::RFEDA);
|
|
|
|
break;
|
2011-08-18 22:31:17 +00:00
|
|
|
case ARM::LDMDA_UPD:
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.setOpcode(ARM::RFEDA_UPD);
|
|
|
|
break;
|
2011-08-18 22:31:17 +00:00
|
|
|
case ARM::LDMDB:
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.setOpcode(ARM::RFEDB);
|
|
|
|
break;
|
2011-08-18 22:31:17 +00:00
|
|
|
case ARM::LDMDB_UPD:
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.setOpcode(ARM::RFEDB_UPD);
|
|
|
|
break;
|
2011-08-18 22:31:17 +00:00
|
|
|
case ARM::LDMIA:
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.setOpcode(ARM::RFEIA);
|
|
|
|
break;
|
2011-08-18 22:31:17 +00:00
|
|
|
case ARM::LDMIA_UPD:
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.setOpcode(ARM::RFEIA_UPD);
|
|
|
|
break;
|
2011-08-18 22:31:17 +00:00
|
|
|
case ARM::LDMIB:
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.setOpcode(ARM::RFEIB);
|
|
|
|
break;
|
2011-08-18 22:31:17 +00:00
|
|
|
case ARM::LDMIB_UPD:
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.setOpcode(ARM::RFEIB_UPD);
|
|
|
|
break;
|
2011-08-18 22:31:17 +00:00
|
|
|
case ARM::STMDA:
|
|
|
|
Inst.setOpcode(ARM::SRSDA);
|
|
|
|
break;
|
|
|
|
case ARM::STMDA_UPD:
|
|
|
|
Inst.setOpcode(ARM::SRSDA_UPD);
|
|
|
|
break;
|
|
|
|
case ARM::STMDB:
|
|
|
|
Inst.setOpcode(ARM::SRSDB);
|
|
|
|
break;
|
|
|
|
case ARM::STMDB_UPD:
|
|
|
|
Inst.setOpcode(ARM::SRSDB_UPD);
|
|
|
|
break;
|
|
|
|
case ARM::STMIA:
|
|
|
|
Inst.setOpcode(ARM::SRSIA);
|
|
|
|
break;
|
|
|
|
case ARM::STMIA_UPD:
|
|
|
|
Inst.setOpcode(ARM::SRSIA_UPD);
|
|
|
|
break;
|
|
|
|
case ARM::STMIB:
|
|
|
|
Inst.setOpcode(ARM::SRSIB);
|
|
|
|
break;
|
|
|
|
case ARM::STMIB_UPD:
|
|
|
|
Inst.setOpcode(ARM::SRSIB_UPD);
|
|
|
|
break;
|
|
|
|
default:
|
2011-09-01 18:02:14 +00:00
|
|
|
if (!Check(S, MCDisassembler::Fail)) return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
2011-08-18 22:31:17 +00:00
|
|
|
|
|
|
|
// For stores (which become SRS's, the only operand is the mode.
|
|
|
|
if (fieldFromInstruction32(Insn, 20, 1) == 0) {
|
|
|
|
Inst.addOperand(
|
|
|
|
MCOperand::CreateImm(fieldFromInstruction32(Insn, 0, 4)));
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
return DecodeRFEInstruction(Inst, Insn, Address, Decoder);
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail; // Tied
|
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeRegListOperand(Inst, reglist, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeCPSInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
unsigned imod = fieldFromInstruction32(Insn, 18, 2);
|
|
|
|
unsigned M = fieldFromInstruction32(Insn, 17, 1);
|
|
|
|
unsigned iflags = fieldFromInstruction32(Insn, 6, 3);
|
|
|
|
unsigned mode = fieldFromInstruction32(Insn, 0, 5);
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-18 22:11:02 +00:00
|
|
|
|
2011-08-09 23:05:39 +00:00
|
|
|
// imod == '01' --> UNPREDICTABLE
|
2011-08-18 22:11:02 +00:00
|
|
|
// NOTE: Even though this is technically UNPREDICTABLE, we choose to
|
|
|
|
// return failure here. The '01' imod value is unprintable, so there's
|
|
|
|
// nothing useful we could do even if we returned UNPREDICTABLE.
|
2011-08-09 23:05:39 +00:00
|
|
|
|
2011-09-01 18:02:14 +00:00
|
|
|
if (imod == 1) return MCDisassembler::Fail;
|
2011-08-18 22:11:02 +00:00
|
|
|
|
|
|
|
if (imod && M) {
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.setOpcode(ARM::CPS3p);
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imod));
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(iflags));
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(mode));
|
2011-08-18 22:11:02 +00:00
|
|
|
} else if (imod && !M) {
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.setOpcode(ARM::CPS2p);
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imod));
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(iflags));
|
2011-09-01 18:02:14 +00:00
|
|
|
if (mode) S = MCDisassembler::SoftFail;
|
2011-08-18 22:11:02 +00:00
|
|
|
} else if (!imod && M) {
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.setOpcode(ARM::CPS1p);
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(mode));
|
2011-09-01 18:02:14 +00:00
|
|
|
if (iflags) S = MCDisassembler::SoftFail;
|
2011-08-18 22:15:25 +00:00
|
|
|
} else {
|
2011-08-18 22:11:02 +00:00
|
|
|
// imod == '00' && M == '0' --> UNPREDICTABLE
|
2011-08-18 22:15:25 +00:00
|
|
|
Inst.setOpcode(ARM::CPS1p);
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(mode));
|
2011-09-01 18:02:14 +00:00
|
|
|
S = MCDisassembler::SoftFail;
|
2011-08-18 22:15:25 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-18 22:11:02 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2CPSInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-23 17:45:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
unsigned imod = fieldFromInstruction32(Insn, 9, 2);
|
|
|
|
unsigned M = fieldFromInstruction32(Insn, 8, 1);
|
|
|
|
unsigned iflags = fieldFromInstruction32(Insn, 5, 3);
|
|
|
|
unsigned mode = fieldFromInstruction32(Insn, 0, 5);
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-23 17:45:18 +00:00
|
|
|
|
|
|
|
// imod == '01' --> UNPREDICTABLE
|
|
|
|
// NOTE: Even though this is technically UNPREDICTABLE, we choose to
|
|
|
|
// return failure here. The '01' imod value is unprintable, so there's
|
|
|
|
// nothing useful we could do even if we returned UNPREDICTABLE.
|
|
|
|
|
2011-09-01 18:02:14 +00:00
|
|
|
if (imod == 1) return MCDisassembler::Fail;
|
2011-08-23 17:45:18 +00:00
|
|
|
|
|
|
|
if (imod && M) {
|
|
|
|
Inst.setOpcode(ARM::t2CPS3p);
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imod));
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(iflags));
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(mode));
|
|
|
|
} else if (imod && !M) {
|
|
|
|
Inst.setOpcode(ARM::t2CPS2p);
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imod));
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(iflags));
|
2011-09-01 18:02:14 +00:00
|
|
|
if (mode) S = MCDisassembler::SoftFail;
|
2011-08-23 17:45:18 +00:00
|
|
|
} else if (!imod && M) {
|
|
|
|
Inst.setOpcode(ARM::t2CPS1p);
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(mode));
|
2011-09-01 18:02:14 +00:00
|
|
|
if (iflags) S = MCDisassembler::SoftFail;
|
2011-08-23 17:45:18 +00:00
|
|
|
} else {
|
|
|
|
// imod == '00' && M == '0' --> UNPREDICTABLE
|
|
|
|
Inst.setOpcode(ARM::t2CPS1p);
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(mode));
|
2011-09-01 18:02:14 +00:00
|
|
|
S = MCDisassembler::SoftFail;
|
2011-08-23 17:45:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2MOVTWInstruction(MCInst &Inst, unsigned Insn,
|
2011-10-04 22:44:48 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
|
|
|
|
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 8, 4);
|
|
|
|
unsigned imm = 0;
|
|
|
|
|
|
|
|
imm |= (fieldFromInstruction32(Insn, 0, 8) << 0);
|
|
|
|
imm |= (fieldFromInstruction32(Insn, 12, 3) << 8);
|
|
|
|
imm |= (fieldFromInstruction32(Insn, 16, 4) << 12);
|
|
|
|
imm |= (fieldFromInstruction32(Insn, 26, 1) << 11);
|
|
|
|
|
|
|
|
if (Inst.getOpcode() == ARM::t2MOVTi16)
|
|
|
|
if (!Check(S, DecoderGPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecoderGPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
|
|
|
|
if (!tryAddingSymbolicOperand(Address, imm, false, 4, Inst, Decoder))
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
|
|
|
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeArmMOVTWInstruction(MCInst &Inst, unsigned Insn,
|
2011-10-04 22:44:48 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
|
|
|
|
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 28, 4);
|
|
|
|
unsigned imm = 0;
|
|
|
|
|
|
|
|
imm |= (fieldFromInstruction32(Insn, 0, 12) << 0);
|
|
|
|
imm |= (fieldFromInstruction32(Insn, 16, 4) << 12);
|
|
|
|
|
|
|
|
if (Inst.getOpcode() == ARM::MOVTi16)
|
|
|
|
if (!Check(S, DecoderGPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecoderGPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
|
|
|
|
if (!tryAddingSymbolicOperand(Address, imm, false, 4, Inst, Decoder))
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
|
|
|
|
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
|
|
|
|
return S;
|
|
|
|
}
|
2011-08-23 17:45:18 +00:00
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSMLAInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 8, 4);
|
|
|
|
unsigned Ra = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 28, 4);
|
|
|
|
|
|
|
|
if (pred == 0xF)
|
|
|
|
return DecodeCPSInstruction(Inst, Insn, Address, Decoder);
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRnopcRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRnopcRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRnopcRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRnopcRegisterClass(Inst, Ra, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-11 22:05:38 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeAddrModeImm12Operand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned add = fieldFromInstruction32(Val, 12, 1);
|
|
|
|
unsigned imm = fieldFromInstruction32(Val, 0, 12);
|
|
|
|
unsigned Rn = fieldFromInstruction32(Val, 13, 4);
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
if (!add) imm *= -1;
|
|
|
|
if (imm == 0 && !add) imm = INT32_MIN;
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
2011-10-04 22:44:48 +00:00
|
|
|
if (Rn == 15)
|
|
|
|
tryAddingPcLoadReferenceComment(Address, Address + imm + 8, Decoder);
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeAddrMode5Operand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Val, 9, 4);
|
|
|
|
unsigned U = fieldFromInstruction32(Val, 8, 1);
|
|
|
|
unsigned imm = fieldFromInstruction32(Val, 0, 8);
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
if (U)
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(ARM_AM::getAM5Opc(ARM_AM::add, imm)));
|
|
|
|
else
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(ARM_AM::getAM5Opc(ARM_AM::sub, imm)));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeAddrMode7Operand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
return DecodeGPRRegisterClass(Inst, Val, Address, Decoder);
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
static DecodeStatus
|
2012-03-27 07:21:54 +00:00
|
|
|
DecodeBranchImmInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-17 21:58:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 28, 4);
|
|
|
|
unsigned imm = fieldFromInstruction32(Insn, 0, 24) << 2;
|
|
|
|
|
|
|
|
if (pred == 0xF) {
|
|
|
|
Inst.setOpcode(ARM::BLXi);
|
|
|
|
imm |= fieldFromInstruction32(Insn, 24, 1) << 1;
|
2012-02-23 18:18:17 +00:00
|
|
|
if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<26>(imm) + 8,
|
|
|
|
true, 4, Inst, Decoder))
|
2011-08-09 22:02:50 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(SignExtend32<26>(imm)));
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-02-23 18:18:17 +00:00
|
|
|
if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<26>(imm) + 8,
|
|
|
|
true, 4, Inst, Decoder))
|
2011-10-04 22:44:48 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(SignExtend32<26>(imm)));
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeAddrMode6Operand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rm = fieldFromInstruction32(Val, 0, 4);
|
|
|
|
unsigned align = fieldFromInstruction32(Val, 4, 2);
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
if (!align)
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(0));
|
|
|
|
else
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(4 << align));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLDInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
|
|
|
|
unsigned wb = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
Rn |= fieldFromInstruction32(Insn, 4, 2) << 4;
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
|
|
|
|
// First output register
|
2012-03-05 19:33:30 +00:00
|
|
|
switch (Inst.getOpcode()) {
|
2012-03-06 22:01:44 +00:00
|
|
|
case ARM::VLD1q16: case ARM::VLD1q32: case ARM::VLD1q64: case ARM::VLD1q8:
|
|
|
|
case ARM::VLD1q16wb_fixed: case ARM::VLD1q16wb_register:
|
|
|
|
case ARM::VLD1q32wb_fixed: case ARM::VLD1q32wb_register:
|
|
|
|
case ARM::VLD1q64wb_fixed: case ARM::VLD1q64wb_register:
|
|
|
|
case ARM::VLD1q8wb_fixed: case ARM::VLD1q8wb_register:
|
|
|
|
case ARM::VLD2d16: case ARM::VLD2d32: case ARM::VLD2d8:
|
|
|
|
case ARM::VLD2d16wb_fixed: case ARM::VLD2d16wb_register:
|
|
|
|
case ARM::VLD2d32wb_fixed: case ARM::VLD2d32wb_register:
|
|
|
|
case ARM::VLD2d8wb_fixed: case ARM::VLD2d8wb_register:
|
2012-03-05 19:33:30 +00:00
|
|
|
if (!Check(S, DecodeDPairRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
break;
|
2012-03-05 21:43:40 +00:00
|
|
|
case ARM::VLD2b16:
|
|
|
|
case ARM::VLD2b32:
|
|
|
|
case ARM::VLD2b8:
|
|
|
|
case ARM::VLD2b16wb_fixed:
|
|
|
|
case ARM::VLD2b16wb_register:
|
|
|
|
case ARM::VLD2b32wb_fixed:
|
|
|
|
case ARM::VLD2b32wb_register:
|
|
|
|
case ARM::VLD2b8wb_fixed:
|
|
|
|
case ARM::VLD2b8wb_register:
|
|
|
|
if (!Check(S, DecodeDPairSpacedRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
break;
|
2012-03-05 19:33:30 +00:00
|
|
|
default:
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
// Second output register
|
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::VLD3d8:
|
|
|
|
case ARM::VLD3d16:
|
|
|
|
case ARM::VLD3d32:
|
|
|
|
case ARM::VLD3d8_UPD:
|
|
|
|
case ARM::VLD3d16_UPD:
|
|
|
|
case ARM::VLD3d32_UPD:
|
|
|
|
case ARM::VLD4d8:
|
|
|
|
case ARM::VLD4d16:
|
|
|
|
case ARM::VLD4d32:
|
|
|
|
case ARM::VLD4d8_UPD:
|
|
|
|
case ARM::VLD4d16_UPD:
|
|
|
|
case ARM::VLD4d32_UPD:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, (Rd+1)%32, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
case ARM::VLD3q8:
|
|
|
|
case ARM::VLD3q16:
|
|
|
|
case ARM::VLD3q32:
|
|
|
|
case ARM::VLD3q8_UPD:
|
|
|
|
case ARM::VLD3q16_UPD:
|
|
|
|
case ARM::VLD3q32_UPD:
|
|
|
|
case ARM::VLD4q8:
|
|
|
|
case ARM::VLD4q16:
|
|
|
|
case ARM::VLD4q32:
|
|
|
|
case ARM::VLD4q8_UPD:
|
|
|
|
case ARM::VLD4q16_UPD:
|
|
|
|
case ARM::VLD4q32_UPD:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, (Rd+2)%32, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Third output register
|
|
|
|
switch(Inst.getOpcode()) {
|
|
|
|
case ARM::VLD3d8:
|
|
|
|
case ARM::VLD3d16:
|
|
|
|
case ARM::VLD3d32:
|
|
|
|
case ARM::VLD3d8_UPD:
|
|
|
|
case ARM::VLD3d16_UPD:
|
|
|
|
case ARM::VLD3d32_UPD:
|
|
|
|
case ARM::VLD4d8:
|
|
|
|
case ARM::VLD4d16:
|
|
|
|
case ARM::VLD4d32:
|
|
|
|
case ARM::VLD4d8_UPD:
|
|
|
|
case ARM::VLD4d16_UPD:
|
|
|
|
case ARM::VLD4d32_UPD:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, (Rd+2)%32, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
case ARM::VLD3q8:
|
|
|
|
case ARM::VLD3q16:
|
|
|
|
case ARM::VLD3q32:
|
|
|
|
case ARM::VLD3q8_UPD:
|
|
|
|
case ARM::VLD3q16_UPD:
|
|
|
|
case ARM::VLD3q32_UPD:
|
|
|
|
case ARM::VLD4q8:
|
|
|
|
case ARM::VLD4q16:
|
|
|
|
case ARM::VLD4q32:
|
|
|
|
case ARM::VLD4q8_UPD:
|
|
|
|
case ARM::VLD4q16_UPD:
|
|
|
|
case ARM::VLD4q32_UPD:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, (Rd+4)%32, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fourth output register
|
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::VLD4d8:
|
|
|
|
case ARM::VLD4d16:
|
|
|
|
case ARM::VLD4d32:
|
|
|
|
case ARM::VLD4d8_UPD:
|
|
|
|
case ARM::VLD4d16_UPD:
|
|
|
|
case ARM::VLD4d32_UPD:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, (Rd+3)%32, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
case ARM::VLD4q8:
|
|
|
|
case ARM::VLD4q16:
|
|
|
|
case ARM::VLD4q32:
|
|
|
|
case ARM::VLD4q8_UPD:
|
|
|
|
case ARM::VLD4q16_UPD:
|
|
|
|
case ARM::VLD4q32_UPD:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, (Rd+6)%32, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Writeback operand
|
|
|
|
switch (Inst.getOpcode()) {
|
2011-10-24 21:45:13 +00:00
|
|
|
case ARM::VLD1d8wb_fixed:
|
|
|
|
case ARM::VLD1d16wb_fixed:
|
|
|
|
case ARM::VLD1d32wb_fixed:
|
|
|
|
case ARM::VLD1d64wb_fixed:
|
|
|
|
case ARM::VLD1d8wb_register:
|
|
|
|
case ARM::VLD1d16wb_register:
|
|
|
|
case ARM::VLD1d32wb_register:
|
|
|
|
case ARM::VLD1d64wb_register:
|
|
|
|
case ARM::VLD1q8wb_fixed:
|
|
|
|
case ARM::VLD1q16wb_fixed:
|
|
|
|
case ARM::VLD1q32wb_fixed:
|
|
|
|
case ARM::VLD1q64wb_fixed:
|
|
|
|
case ARM::VLD1q8wb_register:
|
|
|
|
case ARM::VLD1q16wb_register:
|
|
|
|
case ARM::VLD1q32wb_register:
|
|
|
|
case ARM::VLD1q64wb_register:
|
2011-10-24 23:26:05 +00:00
|
|
|
case ARM::VLD1d8Twb_fixed:
|
|
|
|
case ARM::VLD1d8Twb_register:
|
|
|
|
case ARM::VLD1d16Twb_fixed:
|
|
|
|
case ARM::VLD1d16Twb_register:
|
|
|
|
case ARM::VLD1d32Twb_fixed:
|
|
|
|
case ARM::VLD1d32Twb_register:
|
|
|
|
case ARM::VLD1d64Twb_fixed:
|
|
|
|
case ARM::VLD1d64Twb_register:
|
2011-10-25 00:14:01 +00:00
|
|
|
case ARM::VLD1d8Qwb_fixed:
|
|
|
|
case ARM::VLD1d8Qwb_register:
|
|
|
|
case ARM::VLD1d16Qwb_fixed:
|
|
|
|
case ARM::VLD1d16Qwb_register:
|
|
|
|
case ARM::VLD1d32Qwb_fixed:
|
|
|
|
case ARM::VLD1d32Qwb_register:
|
|
|
|
case ARM::VLD1d64Qwb_fixed:
|
|
|
|
case ARM::VLD1d64Qwb_register:
|
2011-12-09 21:28:25 +00:00
|
|
|
case ARM::VLD2d8wb_fixed:
|
|
|
|
case ARM::VLD2d16wb_fixed:
|
|
|
|
case ARM::VLD2d32wb_fixed:
|
|
|
|
case ARM::VLD2q8wb_fixed:
|
|
|
|
case ARM::VLD2q16wb_fixed:
|
|
|
|
case ARM::VLD2q32wb_fixed:
|
|
|
|
case ARM::VLD2d8wb_register:
|
|
|
|
case ARM::VLD2d16wb_register:
|
|
|
|
case ARM::VLD2d32wb_register:
|
|
|
|
case ARM::VLD2q8wb_register:
|
|
|
|
case ARM::VLD2q16wb_register:
|
|
|
|
case ARM::VLD2q32wb_register:
|
|
|
|
case ARM::VLD2b8wb_fixed:
|
|
|
|
case ARM::VLD2b16wb_fixed:
|
|
|
|
case ARM::VLD2b32wb_fixed:
|
|
|
|
case ARM::VLD2b8wb_register:
|
|
|
|
case ARM::VLD2b16wb_register:
|
|
|
|
case ARM::VLD2b32wb_register:
|
2012-04-11 00:25:40 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(0));
|
|
|
|
break;
|
2011-08-09 20:55:18 +00:00
|
|
|
case ARM::VLD3d8_UPD:
|
|
|
|
case ARM::VLD3d16_UPD:
|
|
|
|
case ARM::VLD3d32_UPD:
|
|
|
|
case ARM::VLD3q8_UPD:
|
|
|
|
case ARM::VLD3q16_UPD:
|
|
|
|
case ARM::VLD3q32_UPD:
|
|
|
|
case ARM::VLD4d8_UPD:
|
|
|
|
case ARM::VLD4d16_UPD:
|
|
|
|
case ARM::VLD4d32_UPD:
|
|
|
|
case ARM::VLD4q8_UPD:
|
|
|
|
case ARM::VLD4q16_UPD:
|
|
|
|
case ARM::VLD4q32_UPD:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, wb, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddrMode6 Base (register+alignment)
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeAddrMode6Operand(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
// AddrMode6 Offset (register)
|
2011-10-24 21:45:13 +00:00
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
default:
|
|
|
|
// The below have been updated to have explicit am6offset split
|
|
|
|
// between fixed and register offset. For those instructions not
|
|
|
|
// yet updated, we need to add an additional reg0 operand for the
|
|
|
|
// fixed variant.
|
|
|
|
//
|
|
|
|
// The fixed offset encodes as Rm == 0xd, so we check for that.
|
|
|
|
if (Rm == 0xd) {
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(0));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// Fall through to handle the register offset variant.
|
|
|
|
case ARM::VLD1d8wb_fixed:
|
|
|
|
case ARM::VLD1d16wb_fixed:
|
|
|
|
case ARM::VLD1d32wb_fixed:
|
|
|
|
case ARM::VLD1d64wb_fixed:
|
2011-10-27 22:53:10 +00:00
|
|
|
case ARM::VLD1d8Twb_fixed:
|
|
|
|
case ARM::VLD1d16Twb_fixed:
|
|
|
|
case ARM::VLD1d32Twb_fixed:
|
|
|
|
case ARM::VLD1d64Twb_fixed:
|
2011-10-31 17:17:32 +00:00
|
|
|
case ARM::VLD1d8Qwb_fixed:
|
|
|
|
case ARM::VLD1d16Qwb_fixed:
|
|
|
|
case ARM::VLD1d32Qwb_fixed:
|
|
|
|
case ARM::VLD1d64Qwb_fixed:
|
2011-10-24 21:45:13 +00:00
|
|
|
case ARM::VLD1d8wb_register:
|
|
|
|
case ARM::VLD1d16wb_register:
|
|
|
|
case ARM::VLD1d32wb_register:
|
|
|
|
case ARM::VLD1d64wb_register:
|
|
|
|
case ARM::VLD1q8wb_fixed:
|
|
|
|
case ARM::VLD1q16wb_fixed:
|
|
|
|
case ARM::VLD1q32wb_fixed:
|
|
|
|
case ARM::VLD1q64wb_fixed:
|
|
|
|
case ARM::VLD1q8wb_register:
|
|
|
|
case ARM::VLD1q16wb_register:
|
|
|
|
case ARM::VLD1q32wb_register:
|
|
|
|
case ARM::VLD1q64wb_register:
|
|
|
|
// The fixed offset post-increment encodes Rm == 0xd. The no-writeback
|
|
|
|
// variant encodes Rm == 0xf. Anything else is a register offset post-
|
|
|
|
// increment and we need to add the register operand to the instruction.
|
|
|
|
if (Rm != 0xD && Rm != 0xF &&
|
|
|
|
!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
2011-09-01 23:23:50 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-10-24 21:45:13 +00:00
|
|
|
break;
|
2012-04-11 00:25:40 +00:00
|
|
|
case ARM::VLD2d8wb_fixed:
|
|
|
|
case ARM::VLD2d16wb_fixed:
|
|
|
|
case ARM::VLD2d32wb_fixed:
|
|
|
|
case ARM::VLD2b8wb_fixed:
|
|
|
|
case ARM::VLD2b16wb_fixed:
|
|
|
|
case ARM::VLD2b32wb_fixed:
|
|
|
|
case ARM::VLD2q8wb_fixed:
|
|
|
|
case ARM::VLD2q16wb_fixed:
|
|
|
|
case ARM::VLD2q32wb_fixed:
|
|
|
|
break;
|
2011-08-11 18:24:51 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVSTInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
|
|
|
|
unsigned wb = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
Rn |= fieldFromInstruction32(Insn, 4, 2) << 4;
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
|
|
|
|
// Writeback Operand
|
|
|
|
switch (Inst.getOpcode()) {
|
2011-10-31 21:50:31 +00:00
|
|
|
case ARM::VST1d8wb_fixed:
|
|
|
|
case ARM::VST1d16wb_fixed:
|
|
|
|
case ARM::VST1d32wb_fixed:
|
|
|
|
case ARM::VST1d64wb_fixed:
|
|
|
|
case ARM::VST1d8wb_register:
|
|
|
|
case ARM::VST1d16wb_register:
|
|
|
|
case ARM::VST1d32wb_register:
|
|
|
|
case ARM::VST1d64wb_register:
|
|
|
|
case ARM::VST1q8wb_fixed:
|
|
|
|
case ARM::VST1q16wb_fixed:
|
|
|
|
case ARM::VST1q32wb_fixed:
|
|
|
|
case ARM::VST1q64wb_fixed:
|
|
|
|
case ARM::VST1q8wb_register:
|
|
|
|
case ARM::VST1q16wb_register:
|
|
|
|
case ARM::VST1q32wb_register:
|
|
|
|
case ARM::VST1q64wb_register:
|
2011-11-29 22:38:04 +00:00
|
|
|
case ARM::VST1d8Twb_fixed:
|
|
|
|
case ARM::VST1d16Twb_fixed:
|
|
|
|
case ARM::VST1d32Twb_fixed:
|
|
|
|
case ARM::VST1d64Twb_fixed:
|
|
|
|
case ARM::VST1d8Twb_register:
|
|
|
|
case ARM::VST1d16Twb_register:
|
|
|
|
case ARM::VST1d32Twb_register:
|
|
|
|
case ARM::VST1d64Twb_register:
|
2011-11-29 22:58:48 +00:00
|
|
|
case ARM::VST1d8Qwb_fixed:
|
|
|
|
case ARM::VST1d16Qwb_fixed:
|
|
|
|
case ARM::VST1d32Qwb_fixed:
|
|
|
|
case ARM::VST1d64Qwb_fixed:
|
|
|
|
case ARM::VST1d8Qwb_register:
|
|
|
|
case ARM::VST1d16Qwb_register:
|
|
|
|
case ARM::VST1d32Qwb_register:
|
|
|
|
case ARM::VST1d64Qwb_register:
|
2011-12-14 21:32:11 +00:00
|
|
|
case ARM::VST2d8wb_fixed:
|
|
|
|
case ARM::VST2d16wb_fixed:
|
|
|
|
case ARM::VST2d32wb_fixed:
|
|
|
|
case ARM::VST2d8wb_register:
|
|
|
|
case ARM::VST2d16wb_register:
|
|
|
|
case ARM::VST2d32wb_register:
|
|
|
|
case ARM::VST2q8wb_fixed:
|
|
|
|
case ARM::VST2q16wb_fixed:
|
|
|
|
case ARM::VST2q32wb_fixed:
|
|
|
|
case ARM::VST2q8wb_register:
|
|
|
|
case ARM::VST2q16wb_register:
|
|
|
|
case ARM::VST2q32wb_register:
|
|
|
|
case ARM::VST2b8wb_fixed:
|
|
|
|
case ARM::VST2b16wb_fixed:
|
|
|
|
case ARM::VST2b32wb_fixed:
|
|
|
|
case ARM::VST2b8wb_register:
|
|
|
|
case ARM::VST2b16wb_register:
|
|
|
|
case ARM::VST2b32wb_register:
|
2012-04-11 22:40:17 +00:00
|
|
|
if (Rm == 0xF)
|
|
|
|
return MCDisassembler::Fail;
|
2012-03-21 20:54:32 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(0));
|
|
|
|
break;
|
2011-08-09 20:55:18 +00:00
|
|
|
case ARM::VST3d8_UPD:
|
|
|
|
case ARM::VST3d16_UPD:
|
|
|
|
case ARM::VST3d32_UPD:
|
|
|
|
case ARM::VST3q8_UPD:
|
|
|
|
case ARM::VST3q16_UPD:
|
|
|
|
case ARM::VST3q32_UPD:
|
|
|
|
case ARM::VST4d8_UPD:
|
|
|
|
case ARM::VST4d16_UPD:
|
|
|
|
case ARM::VST4d32_UPD:
|
|
|
|
case ARM::VST4q8_UPD:
|
|
|
|
case ARM::VST4q16_UPD:
|
|
|
|
case ARM::VST4q32_UPD:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, wb, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// AddrMode6 Base (register+alignment)
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeAddrMode6Operand(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
// AddrMode6 Offset (register)
|
2011-11-01 22:18:13 +00:00
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
default:
|
|
|
|
if (Rm == 0xD)
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(0));
|
|
|
|
else if (Rm != 0xF) {
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case ARM::VST1d8wb_fixed:
|
|
|
|
case ARM::VST1d16wb_fixed:
|
|
|
|
case ARM::VST1d32wb_fixed:
|
|
|
|
case ARM::VST1d64wb_fixed:
|
|
|
|
case ARM::VST1q8wb_fixed:
|
|
|
|
case ARM::VST1q16wb_fixed:
|
|
|
|
case ARM::VST1q32wb_fixed:
|
|
|
|
case ARM::VST1q64wb_fixed:
|
2012-03-21 20:54:32 +00:00
|
|
|
case ARM::VST1d8Twb_fixed:
|
|
|
|
case ARM::VST1d16Twb_fixed:
|
|
|
|
case ARM::VST1d32Twb_fixed:
|
|
|
|
case ARM::VST1d64Twb_fixed:
|
|
|
|
case ARM::VST1d8Qwb_fixed:
|
|
|
|
case ARM::VST1d16Qwb_fixed:
|
|
|
|
case ARM::VST1d32Qwb_fixed:
|
|
|
|
case ARM::VST1d64Qwb_fixed:
|
|
|
|
case ARM::VST2d8wb_fixed:
|
|
|
|
case ARM::VST2d16wb_fixed:
|
|
|
|
case ARM::VST2d32wb_fixed:
|
|
|
|
case ARM::VST2q8wb_fixed:
|
|
|
|
case ARM::VST2q16wb_fixed:
|
|
|
|
case ARM::VST2q32wb_fixed:
|
|
|
|
case ARM::VST2b8wb_fixed:
|
|
|
|
case ARM::VST2b16wb_fixed:
|
|
|
|
case ARM::VST2b32wb_fixed:
|
2011-11-01 22:18:13 +00:00
|
|
|
break;
|
2011-08-11 18:24:51 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-11-01 22:18:13 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
// First input register
|
2012-03-05 19:33:30 +00:00
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::VST1q16:
|
|
|
|
case ARM::VST1q32:
|
|
|
|
case ARM::VST1q64:
|
|
|
|
case ARM::VST1q8:
|
|
|
|
case ARM::VST1q16wb_fixed:
|
|
|
|
case ARM::VST1q16wb_register:
|
|
|
|
case ARM::VST1q32wb_fixed:
|
|
|
|
case ARM::VST1q32wb_register:
|
|
|
|
case ARM::VST1q64wb_fixed:
|
|
|
|
case ARM::VST1q64wb_register:
|
|
|
|
case ARM::VST1q8wb_fixed:
|
|
|
|
case ARM::VST1q8wb_register:
|
|
|
|
case ARM::VST2d16:
|
|
|
|
case ARM::VST2d32:
|
|
|
|
case ARM::VST2d8:
|
|
|
|
case ARM::VST2d16wb_fixed:
|
|
|
|
case ARM::VST2d16wb_register:
|
|
|
|
case ARM::VST2d32wb_fixed:
|
|
|
|
case ARM::VST2d32wb_register:
|
|
|
|
case ARM::VST2d8wb_fixed:
|
|
|
|
case ARM::VST2d8wb_register:
|
|
|
|
if (!Check(S, DecodeDPairRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
break;
|
2012-03-05 21:43:40 +00:00
|
|
|
case ARM::VST2b16:
|
|
|
|
case ARM::VST2b32:
|
|
|
|
case ARM::VST2b8:
|
|
|
|
case ARM::VST2b16wb_fixed:
|
|
|
|
case ARM::VST2b16wb_register:
|
|
|
|
case ARM::VST2b32wb_fixed:
|
|
|
|
case ARM::VST2b32wb_register:
|
|
|
|
case ARM::VST2b8wb_fixed:
|
|
|
|
case ARM::VST2b8wb_register:
|
|
|
|
if (!Check(S, DecodeDPairSpacedRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
break;
|
2012-03-05 19:33:30 +00:00
|
|
|
default:
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
// Second input register
|
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::VST3d8:
|
|
|
|
case ARM::VST3d16:
|
|
|
|
case ARM::VST3d32:
|
|
|
|
case ARM::VST3d8_UPD:
|
|
|
|
case ARM::VST3d16_UPD:
|
|
|
|
case ARM::VST3d32_UPD:
|
|
|
|
case ARM::VST4d8:
|
|
|
|
case ARM::VST4d16:
|
|
|
|
case ARM::VST4d32:
|
|
|
|
case ARM::VST4d8_UPD:
|
|
|
|
case ARM::VST4d16_UPD:
|
|
|
|
case ARM::VST4d32_UPD:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, (Rd+1)%32, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
case ARM::VST3q8:
|
|
|
|
case ARM::VST3q16:
|
|
|
|
case ARM::VST3q32:
|
|
|
|
case ARM::VST3q8_UPD:
|
|
|
|
case ARM::VST3q16_UPD:
|
|
|
|
case ARM::VST3q32_UPD:
|
|
|
|
case ARM::VST4q8:
|
|
|
|
case ARM::VST4q16:
|
|
|
|
case ARM::VST4q32:
|
|
|
|
case ARM::VST4q8_UPD:
|
|
|
|
case ARM::VST4q16_UPD:
|
|
|
|
case ARM::VST4q32_UPD:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, (Rd+2)%32, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Third input register
|
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::VST3d8:
|
|
|
|
case ARM::VST3d16:
|
|
|
|
case ARM::VST3d32:
|
|
|
|
case ARM::VST3d8_UPD:
|
|
|
|
case ARM::VST3d16_UPD:
|
|
|
|
case ARM::VST3d32_UPD:
|
|
|
|
case ARM::VST4d8:
|
|
|
|
case ARM::VST4d16:
|
|
|
|
case ARM::VST4d32:
|
|
|
|
case ARM::VST4d8_UPD:
|
|
|
|
case ARM::VST4d16_UPD:
|
|
|
|
case ARM::VST4d32_UPD:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, (Rd+2)%32, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
case ARM::VST3q8:
|
|
|
|
case ARM::VST3q16:
|
|
|
|
case ARM::VST3q32:
|
|
|
|
case ARM::VST3q8_UPD:
|
|
|
|
case ARM::VST3q16_UPD:
|
|
|
|
case ARM::VST3q32_UPD:
|
|
|
|
case ARM::VST4q8:
|
|
|
|
case ARM::VST4q16:
|
|
|
|
case ARM::VST4q32:
|
|
|
|
case ARM::VST4q8_UPD:
|
|
|
|
case ARM::VST4q16_UPD:
|
|
|
|
case ARM::VST4q32_UPD:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, (Rd+4)%32, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Fourth input register
|
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::VST4d8:
|
|
|
|
case ARM::VST4d16:
|
|
|
|
case ARM::VST4d32:
|
|
|
|
case ARM::VST4d8_UPD:
|
|
|
|
case ARM::VST4d16_UPD:
|
|
|
|
case ARM::VST4d32_UPD:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, (Rd+3)%32, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
case ARM::VST4q8:
|
|
|
|
case ARM::VST4q16:
|
|
|
|
case ARM::VST4q32:
|
|
|
|
case ARM::VST4q8_UPD:
|
|
|
|
case ARM::VST4q16_UPD:
|
|
|
|
case ARM::VST4q32_UPD:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, (Rd+6)%32, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLD1DupInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned align = fieldFromInstruction32(Insn, 4, 1);
|
|
|
|
unsigned size = fieldFromInstruction32(Insn, 6, 2);
|
|
|
|
|
|
|
|
align *= (1 << size);
|
|
|
|
|
2012-03-06 22:01:44 +00:00
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::VLD1DUPq16: case ARM::VLD1DUPq32: case ARM::VLD1DUPq8:
|
|
|
|
case ARM::VLD1DUPq16wb_fixed: case ARM::VLD1DUPq16wb_register:
|
|
|
|
case ARM::VLD1DUPq32wb_fixed: case ARM::VLD1DUPq32wb_register:
|
|
|
|
case ARM::VLD1DUPq8wb_fixed: case ARM::VLD1DUPq8wb_register:
|
|
|
|
if (!Check(S, DecodeDPairRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
break;
|
|
|
|
}
|
2011-08-22 18:22:06 +00:00
|
|
|
if (Rm != 0xF) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-11 18:24:51 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(align));
|
|
|
|
|
2011-11-30 19:35:44 +00:00
|
|
|
// The fixed offset post-increment encodes Rm == 0xd. The no-writeback
|
|
|
|
// variant encodes Rm == 0xf. Anything else is a register offset post-
|
|
|
|
// increment and we need to add the register operand to the instruction.
|
|
|
|
if (Rm != 0xD && Rm != 0xF &&
|
|
|
|
!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLD2DupInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned align = fieldFromInstruction32(Insn, 4, 1);
|
|
|
|
unsigned size = 1 << fieldFromInstruction32(Insn, 6, 2);
|
2012-03-06 18:33:12 +00:00
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 22, 4);
|
2011-08-09 20:55:18 +00:00
|
|
|
align *= 2*size;
|
|
|
|
|
2012-03-06 22:01:44 +00:00
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::VLD2DUPd16: case ARM::VLD2DUPd32: case ARM::VLD2DUPd8:
|
|
|
|
case ARM::VLD2DUPd16wb_fixed: case ARM::VLD2DUPd16wb_register:
|
|
|
|
case ARM::VLD2DUPd32wb_fixed: case ARM::VLD2DUPd32wb_register:
|
|
|
|
case ARM::VLD2DUPd8wb_fixed: case ARM::VLD2DUPd8wb_register:
|
|
|
|
if (!Check(S, DecodeDPairRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
break;
|
2012-03-06 23:10:38 +00:00
|
|
|
case ARM::VLD2DUPd16x2: case ARM::VLD2DUPd32x2: case ARM::VLD2DUPd8x2:
|
|
|
|
case ARM::VLD2DUPd16x2wb_fixed: case ARM::VLD2DUPd16x2wb_register:
|
|
|
|
case ARM::VLD2DUPd32x2wb_fixed: case ARM::VLD2DUPd32x2wb_register:
|
|
|
|
case ARM::VLD2DUPd8x2wb_fixed: case ARM::VLD2DUPd8x2wb_register:
|
|
|
|
if (!Check(S, DecodeDPairSpacedRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
break;
|
2012-03-06 22:01:44 +00:00
|
|
|
default:
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
break;
|
|
|
|
}
|
2012-03-06 18:33:12 +00:00
|
|
|
|
|
|
|
if (Rm != 0xF)
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(0));
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(align));
|
|
|
|
|
|
|
|
if (Rm == 0xD)
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(0));
|
2011-08-11 18:24:51 +00:00
|
|
|
else if (Rm != 0xF) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-11 18:24:51 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2012-03-06 18:33:12 +00:00
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLD3DupInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned inc = fieldFromInstruction32(Insn, 5, 1) + 1;
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, (Rd+inc)%32, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, (Rd+2*inc)%32, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-22 18:22:06 +00:00
|
|
|
if (Rm != 0xF) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-11 18:24:51 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(0));
|
|
|
|
|
|
|
|
if (Rm == 0xD)
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(0));
|
2011-08-11 18:24:51 +00:00
|
|
|
else if (Rm != 0xF) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-11 18:24:51 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLD4DupInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned size = fieldFromInstruction32(Insn, 6, 2);
|
|
|
|
unsigned inc = fieldFromInstruction32(Insn, 5, 1) + 1;
|
|
|
|
unsigned align = fieldFromInstruction32(Insn, 4, 1);
|
|
|
|
|
|
|
|
if (size == 0x3) {
|
|
|
|
size = 4;
|
|
|
|
align = 16;
|
|
|
|
} else {
|
|
|
|
if (size == 2) {
|
|
|
|
size = 1 << size;
|
|
|
|
align *= 8;
|
|
|
|
} else {
|
|
|
|
size = 1 << size;
|
|
|
|
align *= 4*size;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, (Rd+inc)%32, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, (Rd+2*inc)%32, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, (Rd+3*inc)%32, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-22 18:22:06 +00:00
|
|
|
if (Rm != 0xF) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-11 18:24:51 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(align));
|
|
|
|
|
|
|
|
if (Rm == 0xD)
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(0));
|
2011-08-11 18:24:51 +00:00
|
|
|
else if (Rm != 0xF) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-11 18:24:51 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
static DecodeStatus
|
2012-03-27 07:21:54 +00:00
|
|
|
DecodeNEONModImmInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-17 21:58:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
|
|
|
|
unsigned imm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
imm |= fieldFromInstruction32(Insn, 16, 3) << 4;
|
|
|
|
imm |= fieldFromInstruction32(Insn, 24, 1) << 7;
|
|
|
|
imm |= fieldFromInstruction32(Insn, 8, 4) << 8;
|
|
|
|
imm |= fieldFromInstruction32(Insn, 5, 1) << 12;
|
|
|
|
unsigned Q = fieldFromInstruction32(Insn, 6, 1);
|
|
|
|
|
2011-08-11 18:24:51 +00:00
|
|
|
if (Q) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeQPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-11 18:24:51 +00:00
|
|
|
} else {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-11 18:24:51 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
|
|
|
|
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::VORRiv4i16:
|
|
|
|
case ARM::VORRiv2i32:
|
|
|
|
case ARM::VBICiv4i16:
|
|
|
|
case ARM::VBICiv2i32:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
case ARM::VORRiv8i16:
|
|
|
|
case ARM::VORRiv4i32:
|
|
|
|
case ARM::VBICiv8i16:
|
|
|
|
case ARM::VBICiv4i32:
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeQPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVSHLMaxInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
Rm |= fieldFromInstruction32(Insn, 5, 1) << 4;
|
|
|
|
unsigned size = fieldFromInstruction32(Insn, 18, 2);
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeQPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(8 << size));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeShiftRight8Imm(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(8 - Val));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeShiftRight16Imm(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(16 - Val));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeShiftRight32Imm(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(32 - Val));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeShiftRight64Imm(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(64 - Val));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeTBLInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
Rn |= fieldFromInstruction32(Insn, 7, 1) << 4;
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
Rm |= fieldFromInstruction32(Insn, 5, 1) << 4;
|
|
|
|
unsigned op = fieldFromInstruction32(Insn, 6, 1);
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-11 18:24:51 +00:00
|
|
|
if (op) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail; // Writeback
|
2011-08-11 18:24:51 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2012-03-05 19:33:30 +00:00
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::VTBL2:
|
|
|
|
case ARM::VTBX2:
|
|
|
|
if (!Check(S, DecodeDPairRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbAddSpecialReg(MCInst &Inst, uint16_t Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned dst = fieldFromInstruction16(Insn, 8, 3);
|
|
|
|
unsigned imm = fieldFromInstruction16(Insn, 0, 8);
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodetGPRRegisterClass(Inst, dst, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-26 18:09:22 +00:00
|
|
|
switch(Inst.getOpcode()) {
|
2011-08-26 19:39:26 +00:00
|
|
|
default:
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-26 18:09:22 +00:00
|
|
|
case ARM::tADR:
|
2011-08-26 21:47:57 +00:00
|
|
|
break; // tADR does not explicitly represent the PC as an operand.
|
2011-08-26 18:09:22 +00:00
|
|
|
case ARM::tADDrSPi:
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(ARM::SP));
|
|
|
|
break;
|
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbBROperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(SignExtend32<12>(Val << 1)));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2BROperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(SignExtend32<21>(Val)));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbCmpBROperand(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(SignExtend32<7>(Val << 1)));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbAddrModeRR(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Val, 0, 3);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Val, 3, 3);
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodetGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodetGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbAddrModeIS(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Val, 0, 3);
|
|
|
|
unsigned imm = fieldFromInstruction32(Val, 3, 5);
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodetGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbAddrModePC(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-10-04 22:44:48 +00:00
|
|
|
unsigned imm = Val << 2;
|
|
|
|
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
|
|
|
tryAddingPcLoadReferenceComment(Address, (Address & ~2u) + imm + 4, Decoder);
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbAddrModeSP(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(ARM::SP));
|
2011-08-22 17:56:58 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(Val));
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2AddrModeSOReg(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Val, 6, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Val, 2, 4);
|
|
|
|
unsigned imm = fieldFromInstruction32(Val, 0, 2);
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecoderGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2LoadShift(MCInst &Inst, unsigned Insn,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-23 17:51:38 +00:00
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::t2PLDs:
|
|
|
|
case ARM::t2PLDWs:
|
|
|
|
case ARM::t2PLIs:
|
|
|
|
break;
|
|
|
|
default: {
|
|
|
|
unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
|
2011-09-23 21:07:25 +00:00
|
|
|
if (!Check(S, DecoderGPRRegisterClass(Inst, Rt, Address, Decoder)))
|
2011-09-01 23:23:50 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-23 17:51:38 +00:00
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
if (Rn == 0xF) {
|
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::t2LDRBs:
|
|
|
|
Inst.setOpcode(ARM::t2LDRBpci);
|
|
|
|
break;
|
|
|
|
case ARM::t2LDRHs:
|
|
|
|
Inst.setOpcode(ARM::t2LDRHpci);
|
|
|
|
break;
|
|
|
|
case ARM::t2LDRSHs:
|
|
|
|
Inst.setOpcode(ARM::t2LDRSHpci);
|
|
|
|
break;
|
|
|
|
case ARM::t2LDRSBs:
|
|
|
|
Inst.setOpcode(ARM::t2LDRSBpci);
|
|
|
|
break;
|
|
|
|
case ARM::t2PLDs:
|
|
|
|
Inst.setOpcode(ARM::t2PLDi12);
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(ARM::PC));
|
|
|
|
break;
|
|
|
|
default:
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int imm = fieldFromInstruction32(Insn, 0, 12);
|
|
|
|
if (!fieldFromInstruction32(Insn, 23, 1)) imm *= -1;
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned addrmode = fieldFromInstruction32(Insn, 4, 2);
|
|
|
|
addrmode |= fieldFromInstruction32(Insn, 0, 4) << 2;
|
|
|
|
addrmode |= fieldFromInstruction32(Insn, 16, 4) << 6;
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeT2AddrModeSOReg(Inst, addrmode, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2Imm8S4(MCInst &Inst, unsigned Val,
|
2011-08-10 17:36:48 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-08-09 20:55:18 +00:00
|
|
|
int imm = Val & 0xFF;
|
|
|
|
if (!(Val & 0x100)) imm *= -1;
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm << 2));
|
|
|
|
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2AddrModeImm8s4(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Val, 9, 4);
|
|
|
|
unsigned imm = fieldFromInstruction32(Val, 0, 9);
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeT2Imm8S4(Inst, imm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2AddrModeImm0_1020s4(MCInst &Inst,unsigned Val,
|
2011-09-09 18:37:27 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
|
|
|
|
|
|
|
unsigned Rn = fieldFromInstruction32(Val, 8, 4);
|
|
|
|
unsigned imm = fieldFromInstruction32(Val, 0, 8);
|
|
|
|
|
|
|
|
if (!Check(S, DecodeGPRnopcRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
|
|
|
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2Imm8(MCInst &Inst, unsigned Val,
|
2011-08-10 17:36:48 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-08-09 20:55:18 +00:00
|
|
|
int imm = Val & 0xFF;
|
2011-09-16 21:08:33 +00:00
|
|
|
if (Val == 0)
|
|
|
|
imm = INT32_MIN;
|
|
|
|
else if (!(Val & 0x100))
|
|
|
|
imm *= -1;
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
|
|
|
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2AddrModeImm8(MCInst &Inst, unsigned Val,
|
2011-08-10 17:36:48 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Val, 9, 4);
|
|
|
|
unsigned imm = fieldFromInstruction32(Val, 0, 9);
|
|
|
|
|
|
|
|
// Some instructions always use an additive offset.
|
|
|
|
switch (Inst.getOpcode()) {
|
|
|
|
case ARM::t2LDRT:
|
|
|
|
case ARM::t2LDRBT:
|
|
|
|
case ARM::t2LDRHT:
|
|
|
|
case ARM::t2LDRSBT:
|
|
|
|
case ARM::t2LDRSHT:
|
2011-09-19 18:07:10 +00:00
|
|
|
case ARM::t2STRT:
|
|
|
|
case ARM::t2STRBT:
|
|
|
|
case ARM::t2STRHT:
|
2011-08-09 20:55:18 +00:00
|
|
|
imm |= 0x100;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeT2Imm8(Inst, imm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2LdStPre(MCInst &Inst, unsigned Insn,
|
2011-09-12 18:56:30 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
|
|
|
|
|
|
|
unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned addr = fieldFromInstruction32(Insn, 0, 8);
|
|
|
|
addr |= fieldFromInstruction32(Insn, 9, 1) << 8;
|
|
|
|
addr |= Rn << 9;
|
|
|
|
unsigned load = fieldFromInstruction32(Insn, 20, 1);
|
|
|
|
|
|
|
|
if (!load) {
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
}
|
|
|
|
|
2011-09-16 22:42:36 +00:00
|
|
|
if (!Check(S, DecoderGPRRegisterClass(Inst, Rt, Address, Decoder)))
|
2011-09-12 18:56:30 +00:00
|
|
|
return MCDisassembler::Fail;
|
|
|
|
|
|
|
|
if (load) {
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Check(S, DecodeT2AddrModeImm8(Inst, addr, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
|
|
|
|
return S;
|
|
|
|
}
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2AddrModeImm12(MCInst &Inst, unsigned Val,
|
2011-08-10 17:36:48 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Val, 13, 4);
|
|
|
|
unsigned imm = fieldFromInstruction32(Val, 0, 12);
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbAddSPImm(MCInst &Inst, uint16_t Insn,
|
2011-08-10 17:36:48 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned imm = fieldFromInstruction16(Insn, 0, 7);
|
|
|
|
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(ARM::SP));
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(ARM::SP));
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
|
|
|
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbAddSPReg(MCInst &Inst, uint16_t Insn,
|
2011-08-10 17:36:48 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
if (Inst.getOpcode() == ARM::tADDrSP) {
|
|
|
|
unsigned Rdm = fieldFromInstruction16(Insn, 0, 3);
|
|
|
|
Rdm |= fieldFromInstruction16(Insn, 7, 1) << 3;
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rdm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rdm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-25 18:30:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateReg(ARM::SP));
|
2011-08-09 20:55:18 +00:00
|
|
|
} else if (Inst.getOpcode() == ARM::tADDspr) {
|
|
|
|
unsigned Rm = fieldFromInstruction16(Insn, 3, 4);
|
|
|
|
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(ARM::SP));
|
|
|
|
Inst.addOperand(MCOperand::CreateReg(ARM::SP));
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbCPS(MCInst &Inst, uint16_t Insn,
|
2011-08-10 17:36:48 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned imod = fieldFromInstruction16(Insn, 4, 1) | 0x2;
|
|
|
|
unsigned flags = fieldFromInstruction16(Insn, 0, 3);
|
|
|
|
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imod));
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(flags));
|
|
|
|
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodePostIdxReg(MCInst &Inst, unsigned Insn,
|
2011-08-10 17:36:48 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned add = fieldFromInstruction32(Insn, 4, 1);
|
|
|
|
|
2012-03-22 13:24:43 +00:00
|
|
|
if (!Check(S, DecodeGPRnopcRegisterClass(Inst, Rm, Address, Decoder)))
|
2011-09-01 23:23:50 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(add));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbBLXOffset(MCInst &Inst, unsigned Val,
|
2011-08-10 17:36:48 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-10-20 17:28:20 +00:00
|
|
|
if (!tryAddingSymbolicOperand(Address,
|
2011-10-04 22:44:48 +00:00
|
|
|
(Address & ~2u) + SignExtend32<22>(Val << 1) + 4,
|
|
|
|
true, 4, Inst, Decoder))
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(SignExtend32<22>(Val << 1)));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeCoprocessor(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
if (Val == 0xA || Val == 0xB)
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(Val));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2011-09-19 22:21:13 +00:00
|
|
|
static DecodeStatus
|
2012-03-27 07:21:54 +00:00
|
|
|
DecodeThumbTableBranch(MCInst &Inst, unsigned Insn,
|
2011-09-19 22:21:13 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
|
|
|
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
|
|
|
|
if (Rn == ARM::SP) S = MCDisassembler::SoftFail;
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecoderGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
static DecodeStatus
|
2012-03-27 07:21:54 +00:00
|
|
|
DecodeThumb2BCCInstruction(MCInst &Inst, unsigned Insn,
|
2011-08-17 21:58:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-09 20:55:18 +00:00
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 22, 4);
|
|
|
|
if (pred == 0xE || pred == 0xF) {
|
2011-08-31 22:00:41 +00:00
|
|
|
unsigned opc = fieldFromInstruction32(Insn, 4, 28);
|
2011-08-09 20:55:18 +00:00
|
|
|
switch (opc) {
|
|
|
|
default:
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-31 22:00:41 +00:00
|
|
|
case 0xf3bf8f4:
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.setOpcode(ARM::t2DSB);
|
|
|
|
break;
|
2011-08-31 22:00:41 +00:00
|
|
|
case 0xf3bf8f5:
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.setOpcode(ARM::t2DMB);
|
|
|
|
break;
|
2011-08-31 22:00:41 +00:00
|
|
|
case 0xf3bf8f6:
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.setOpcode(ARM::t2ISB);
|
2011-09-07 17:55:19 +00:00
|
|
|
break;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned imm = fieldFromInstruction32(Insn, 0, 4);
|
2011-08-09 23:25:42 +00:00
|
|
|
return DecodeMemBarrierOption(Inst, imm, Address, Decoder);
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
unsigned brtarget = fieldFromInstruction32(Insn, 0, 11) << 1;
|
|
|
|
brtarget |= fieldFromInstruction32(Insn, 11, 1) << 19;
|
|
|
|
brtarget |= fieldFromInstruction32(Insn, 13, 1) << 18;
|
|
|
|
brtarget |= fieldFromInstruction32(Insn, 16, 6) << 12;
|
|
|
|
brtarget |= fieldFromInstruction32(Insn, 26, 1) << 20;
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeT2BROperand(Inst, brtarget, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 20:55:18 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Decode a shifted immediate operand. These basically consist
|
|
|
|
// of an 8-bit value, and a 4-bit directive that specifies either
|
|
|
|
// a splat operation or a rotation.
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2SOImm(MCInst &Inst, unsigned Val,
|
2011-08-09 20:55:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
unsigned ctrl = fieldFromInstruction32(Val, 10, 2);
|
|
|
|
if (ctrl == 0) {
|
|
|
|
unsigned byte = fieldFromInstruction32(Val, 8, 2);
|
|
|
|
unsigned imm = fieldFromInstruction32(Val, 0, 8);
|
|
|
|
switch (byte) {
|
|
|
|
case 0:
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
Inst.addOperand(MCOperand::CreateImm((imm << 16) | imm));
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
Inst.addOperand(MCOperand::CreateImm((imm << 24) | (imm << 8)));
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
Inst.addOperand(MCOperand::CreateImm((imm << 24) | (imm << 16) |
|
|
|
|
(imm << 8) | imm));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
unsigned unrot = fieldFromInstruction32(Val, 0, 7) | 0x80;
|
|
|
|
unsigned rot = fieldFromInstruction32(Val, 7, 5);
|
|
|
|
unsigned imm = (unrot >> rot) | (unrot << ((32-rot)&31));
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(imm));
|
|
|
|
}
|
|
|
|
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
static DecodeStatus
|
2012-03-27 07:21:54 +00:00
|
|
|
DecodeThumbBCCTargetOperand(MCInst &Inst, unsigned Val,
|
2011-08-17 21:58:18 +00:00
|
|
|
uint64_t Address, const void *Decoder){
|
2011-08-09 20:55:18 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(Val << 1));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeThumbBLTargetOperand(MCInst &Inst, unsigned Val,
|
2011-08-10 17:36:48 +00:00
|
|
|
uint64_t Address, const void *Decoder){
|
2012-02-27 18:15:15 +00:00
|
|
|
if (!tryAddingSymbolicOperand(Address, Address + SignExtend32<22>(Val<<1) + 4,
|
2012-02-23 18:18:17 +00:00
|
|
|
true, 4, Inst, Decoder))
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(SignExtend32<22>(Val << 1)));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 20:55:18 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeMemBarrierOption(MCInst &Inst, unsigned Val,
|
2011-08-09 23:25:42 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
switch (Val) {
|
|
|
|
default:
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-09 23:25:42 +00:00
|
|
|
case 0xF: // SY
|
|
|
|
case 0xE: // ST
|
|
|
|
case 0xB: // ISH
|
|
|
|
case 0xA: // ISHST
|
|
|
|
case 0x7: // NSH
|
|
|
|
case 0x6: // NSHST
|
|
|
|
case 0x3: // OSH
|
|
|
|
case 0x2: // OSHST
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(Val));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-09 23:25:42 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeMSRMask(MCInst &Inst, unsigned Val,
|
2011-08-11 20:21:46 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 18:02:14 +00:00
|
|
|
if (!Val) return MCDisassembler::Fail;
|
2011-08-11 20:21:46 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(Val));
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Success;
|
2011-08-11 20:21:46 +00:00
|
|
|
}
|
2011-08-11 21:34:58 +00:00
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeDoubleRegLoad(MCInst &Inst, unsigned Insn,
|
2011-08-17 21:58:18 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-12 17:58:32 +00:00
|
|
|
unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 28, 4);
|
|
|
|
|
2011-09-01 18:02:14 +00:00
|
|
|
if ((Rt & 1) || Rt == 0xE || Rn == 0xF) return MCDisassembler::Fail;
|
2011-08-12 17:58:32 +00:00
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rt+1, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-12 17:58:32 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-12 17:58:32 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeDoubleRegStore(MCInst &Inst, unsigned Insn,
|
2011-08-17 21:58:18 +00:00
|
|
|
uint64_t Address, const void *Decoder){
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-11 21:34:58 +00:00
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
unsigned Rt = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
2011-08-11 22:08:38 +00:00
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 28, 4);
|
2011-08-11 21:34:58 +00:00
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecoderGPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-11 21:34:58 +00:00
|
|
|
|
2011-09-01 18:02:14 +00:00
|
|
|
if ((Rt & 1) || Rt == 0xE || Rn == 0xF) return MCDisassembler::Fail;
|
|
|
|
if (Rd == Rn || Rd == Rt || Rd == Rt+1) return MCDisassembler::Fail;
|
2011-08-11 21:34:58 +00:00
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rt+1, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-11 21:34:58 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-11 21:34:58 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeLDRPreImm(MCInst &Inst, unsigned Insn,
|
2011-08-26 20:43:14 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-26 20:43:14 +00:00
|
|
|
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
unsigned imm = fieldFromInstruction32(Insn, 0, 12);
|
|
|
|
imm |= fieldFromInstruction32(Insn, 16, 4) << 13;
|
|
|
|
imm |= fieldFromInstruction32(Insn, 23, 1) << 12;
|
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 28, 4);
|
|
|
|
|
2011-09-01 18:02:14 +00:00
|
|
|
if (Rn == 0xF || Rn == Rt) S = MCDisassembler::SoftFail;
|
2011-08-26 20:43:14 +00:00
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeAddrModeImm12Operand(Inst, imm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-26 20:43:14 +00:00
|
|
|
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeLDRPreReg(MCInst &Inst, unsigned Insn,
|
2011-08-26 20:43:14 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-26 20:43:14 +00:00
|
|
|
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
unsigned imm = fieldFromInstruction32(Insn, 0, 12);
|
|
|
|
imm |= fieldFromInstruction32(Insn, 16, 4) << 13;
|
|
|
|
imm |= fieldFromInstruction32(Insn, 23, 1) << 12;
|
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 28, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
|
2011-09-01 18:02:14 +00:00
|
|
|
if (Rn == 0xF || Rn == Rt) S = MCDisassembler::SoftFail;
|
|
|
|
if (Rm == 0xF) S = MCDisassembler::SoftFail;
|
2011-08-26 20:43:14 +00:00
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeSORegMemOperand(Inst, imm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-26 20:43:14 +00:00
|
|
|
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSTRPreImm(MCInst &Inst, unsigned Insn,
|
2011-08-12 18:12:39 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-12 18:12:39 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
unsigned imm = fieldFromInstruction32(Insn, 0, 12);
|
|
|
|
imm |= fieldFromInstruction32(Insn, 16, 4) << 13;
|
|
|
|
imm |= fieldFromInstruction32(Insn, 23, 1) << 12;
|
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 28, 4);
|
2011-08-11 21:34:58 +00:00
|
|
|
|
2011-09-01 18:02:14 +00:00
|
|
|
if (Rn == 0xF || Rn == Rt) S = MCDisassembler::SoftFail;
|
2011-08-12 18:12:39 +00:00
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeAddrModeImm12Operand(Inst, imm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-12 18:12:39 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-12 18:12:39 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSTRPreReg(MCInst &Inst, unsigned Insn,
|
2011-08-12 18:12:39 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-12 18:12:39 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
unsigned imm = fieldFromInstruction32(Insn, 0, 12);
|
|
|
|
imm |= fieldFromInstruction32(Insn, 16, 4) << 13;
|
|
|
|
imm |= fieldFromInstruction32(Insn, 23, 1) << 12;
|
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 28, 4);
|
|
|
|
|
2011-09-01 18:02:14 +00:00
|
|
|
if (Rn == 0xF || Rn == Rt) S = MCDisassembler::SoftFail;
|
2011-08-12 18:12:39 +00:00
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rt, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeSORegMemOperand(Inst, imm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-12 18:12:39 +00:00
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-12 18:12:39 +00:00
|
|
|
}
|
2011-08-15 18:44:44 +00:00
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLD1LN(MCInst &Inst, unsigned Insn,
|
2011-08-15 18:44:44 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-15 18:44:44 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
|
|
|
|
unsigned size = fieldFromInstruction32(Insn, 10, 2);
|
|
|
|
|
|
|
|
unsigned align = 0;
|
|
|
|
unsigned index = 0;
|
|
|
|
switch (size) {
|
|
|
|
default:
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
case 0:
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1))
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail; // UNDEFINED
|
2011-08-15 18:44:44 +00:00
|
|
|
index = fieldFromInstruction32(Insn, 5, 3);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (fieldFromInstruction32(Insn, 5, 1))
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail; // UNDEFINED
|
2011-08-15 18:44:44 +00:00
|
|
|
index = fieldFromInstruction32(Insn, 6, 2);
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1))
|
|
|
|
align = 2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (fieldFromInstruction32(Insn, 6, 1))
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail; // UNDEFINED
|
2011-08-15 18:44:44 +00:00
|
|
|
index = fieldFromInstruction32(Insn, 7, 1);
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 2) != 0)
|
|
|
|
align = 4;
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
if (Rm != 0xF) { // Writeback
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(align));
|
2011-08-22 18:42:13 +00:00
|
|
|
if (Rm != 0xF) {
|
2011-09-01 18:02:14 +00:00
|
|
|
if (Rm != 0xD) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-09-01 18:02:14 +00:00
|
|
|
} else
|
2011-08-22 18:42:13 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateReg(0));
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(index));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVST1LN(MCInst &Inst, unsigned Insn,
|
2011-08-15 18:44:44 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-15 18:44:44 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
|
|
|
|
unsigned size = fieldFromInstruction32(Insn, 10, 2);
|
|
|
|
|
|
|
|
unsigned align = 0;
|
|
|
|
unsigned index = 0;
|
|
|
|
switch (size) {
|
|
|
|
default:
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
case 0:
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1))
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail; // UNDEFINED
|
2011-08-15 18:44:44 +00:00
|
|
|
index = fieldFromInstruction32(Insn, 5, 3);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (fieldFromInstruction32(Insn, 5, 1))
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail; // UNDEFINED
|
2011-08-15 18:44:44 +00:00
|
|
|
index = fieldFromInstruction32(Insn, 6, 2);
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1))
|
|
|
|
align = 2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (fieldFromInstruction32(Insn, 6, 1))
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail; // UNDEFINED
|
2011-08-15 18:44:44 +00:00
|
|
|
index = fieldFromInstruction32(Insn, 7, 1);
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 2) != 0)
|
|
|
|
align = 4;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Rm != 0xF) { // Writeback
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(align));
|
2011-08-22 18:42:13 +00:00
|
|
|
if (Rm != 0xF) {
|
2011-09-01 18:02:14 +00:00
|
|
|
if (Rm != 0xD) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-09-01 18:02:14 +00:00
|
|
|
} else
|
2011-08-22 18:42:13 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateReg(0));
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(index));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLD2LN(MCInst &Inst, unsigned Insn,
|
2011-08-15 18:44:44 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-15 18:44:44 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
|
|
|
|
unsigned size = fieldFromInstruction32(Insn, 10, 2);
|
|
|
|
|
|
|
|
unsigned align = 0;
|
|
|
|
unsigned index = 0;
|
|
|
|
unsigned inc = 1;
|
|
|
|
switch (size) {
|
|
|
|
default:
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
case 0:
|
|
|
|
index = fieldFromInstruction32(Insn, 5, 3);
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1))
|
|
|
|
align = 2;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
index = fieldFromInstruction32(Insn, 6, 2);
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1))
|
|
|
|
align = 4;
|
|
|
|
if (fieldFromInstruction32(Insn, 5, 1))
|
|
|
|
inc = 2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (fieldFromInstruction32(Insn, 5, 1))
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail; // UNDEFINED
|
2011-08-15 18:44:44 +00:00
|
|
|
index = fieldFromInstruction32(Insn, 7, 1);
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1) != 0)
|
|
|
|
align = 8;
|
|
|
|
if (fieldFromInstruction32(Insn, 6, 1))
|
|
|
|
inc = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
if (Rm != 0xF) { // Writeback
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(align));
|
2011-08-22 18:42:13 +00:00
|
|
|
if (Rm != 0xF) {
|
2011-09-01 18:02:14 +00:00
|
|
|
if (Rm != 0xD) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-09-01 18:02:14 +00:00
|
|
|
} else
|
2011-08-22 18:42:13 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateReg(0));
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(index));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVST2LN(MCInst &Inst, unsigned Insn,
|
2011-08-15 18:44:44 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-15 18:44:44 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
|
|
|
|
unsigned size = fieldFromInstruction32(Insn, 10, 2);
|
|
|
|
|
|
|
|
unsigned align = 0;
|
|
|
|
unsigned index = 0;
|
|
|
|
unsigned inc = 1;
|
|
|
|
switch (size) {
|
|
|
|
default:
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
case 0:
|
|
|
|
index = fieldFromInstruction32(Insn, 5, 3);
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1))
|
|
|
|
align = 2;
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
index = fieldFromInstruction32(Insn, 6, 2);
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1))
|
|
|
|
align = 4;
|
|
|
|
if (fieldFromInstruction32(Insn, 5, 1))
|
|
|
|
inc = 2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (fieldFromInstruction32(Insn, 5, 1))
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail; // UNDEFINED
|
2011-08-15 18:44:44 +00:00
|
|
|
index = fieldFromInstruction32(Insn, 7, 1);
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1) != 0)
|
|
|
|
align = 8;
|
|
|
|
if (fieldFromInstruction32(Insn, 6, 1))
|
|
|
|
inc = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Rm != 0xF) { // Writeback
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(align));
|
2011-08-22 18:42:13 +00:00
|
|
|
if (Rm != 0xF) {
|
2011-09-01 18:02:14 +00:00
|
|
|
if (Rm != 0xD) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-09-01 18:02:14 +00:00
|
|
|
} else
|
2011-08-22 18:42:13 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateReg(0));
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(index));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLD3LN(MCInst &Inst, unsigned Insn,
|
2011-08-15 18:44:44 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-15 18:44:44 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
|
|
|
|
unsigned size = fieldFromInstruction32(Insn, 10, 2);
|
|
|
|
|
|
|
|
unsigned align = 0;
|
|
|
|
unsigned index = 0;
|
|
|
|
unsigned inc = 1;
|
|
|
|
switch (size) {
|
|
|
|
default:
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
case 0:
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1))
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail; // UNDEFINED
|
2011-08-15 18:44:44 +00:00
|
|
|
index = fieldFromInstruction32(Insn, 5, 3);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1))
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail; // UNDEFINED
|
2011-08-15 18:44:44 +00:00
|
|
|
index = fieldFromInstruction32(Insn, 6, 2);
|
|
|
|
if (fieldFromInstruction32(Insn, 5, 1))
|
|
|
|
inc = 2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 2))
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail; // UNDEFINED
|
2011-08-15 18:44:44 +00:00
|
|
|
index = fieldFromInstruction32(Insn, 7, 1);
|
|
|
|
if (fieldFromInstruction32(Insn, 6, 1))
|
|
|
|
inc = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
|
|
|
|
if (Rm != 0xF) { // Writeback
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(align));
|
2011-08-30 22:58:27 +00:00
|
|
|
if (Rm != 0xF) {
|
2011-09-01 18:02:14 +00:00
|
|
|
if (Rm != 0xD) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-09-01 18:02:14 +00:00
|
|
|
} else
|
2011-08-22 18:42:13 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateReg(0));
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(index));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVST3LN(MCInst &Inst, unsigned Insn,
|
2011-08-15 18:44:44 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-15 18:44:44 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
|
|
|
|
unsigned size = fieldFromInstruction32(Insn, 10, 2);
|
|
|
|
|
|
|
|
unsigned align = 0;
|
|
|
|
unsigned index = 0;
|
|
|
|
unsigned inc = 1;
|
|
|
|
switch (size) {
|
|
|
|
default:
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
case 0:
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1))
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail; // UNDEFINED
|
2011-08-15 18:44:44 +00:00
|
|
|
index = fieldFromInstruction32(Insn, 5, 3);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1))
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail; // UNDEFINED
|
2011-08-15 18:44:44 +00:00
|
|
|
index = fieldFromInstruction32(Insn, 6, 2);
|
|
|
|
if (fieldFromInstruction32(Insn, 5, 1))
|
|
|
|
inc = 2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 2))
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail; // UNDEFINED
|
2011-08-15 18:44:44 +00:00
|
|
|
index = fieldFromInstruction32(Insn, 7, 1);
|
|
|
|
if (fieldFromInstruction32(Insn, 6, 1))
|
|
|
|
inc = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Rm != 0xF) { // Writeback
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(align));
|
2011-08-22 18:42:13 +00:00
|
|
|
if (Rm != 0xF) {
|
2011-09-01 18:02:14 +00:00
|
|
|
if (Rm != 0xD) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-09-01 18:02:14 +00:00
|
|
|
} else
|
2011-08-22 18:42:13 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateReg(0));
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(index));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVLD4LN(MCInst &Inst, unsigned Insn,
|
2011-08-15 18:44:44 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-15 18:44:44 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
|
|
|
|
unsigned size = fieldFromInstruction32(Insn, 10, 2);
|
|
|
|
|
|
|
|
unsigned align = 0;
|
|
|
|
unsigned index = 0;
|
|
|
|
unsigned inc = 1;
|
|
|
|
switch (size) {
|
|
|
|
default:
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
case 0:
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1))
|
|
|
|
align = 4;
|
|
|
|
index = fieldFromInstruction32(Insn, 5, 3);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1))
|
|
|
|
align = 8;
|
|
|
|
index = fieldFromInstruction32(Insn, 6, 2);
|
|
|
|
if (fieldFromInstruction32(Insn, 5, 1))
|
|
|
|
inc = 2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 2))
|
|
|
|
align = 4 << fieldFromInstruction32(Insn, 4, 2);
|
|
|
|
index = fieldFromInstruction32(Insn, 7, 1);
|
|
|
|
if (fieldFromInstruction32(Insn, 6, 1))
|
|
|
|
inc = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+3*inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
|
|
|
|
if (Rm != 0xF) { // Writeback
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(align));
|
2011-08-22 18:42:13 +00:00
|
|
|
if (Rm != 0xF) {
|
2011-09-01 18:02:14 +00:00
|
|
|
if (Rm != 0xD) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-09-01 18:02:14 +00:00
|
|
|
} else
|
2011-08-22 18:42:13 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateReg(0));
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+3*inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(index));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVST4LN(MCInst &Inst, unsigned Insn,
|
2011-08-15 18:44:44 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-17 17:44:15 +00:00
|
|
|
|
2011-08-15 18:44:44 +00:00
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned Rd = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
Rd |= fieldFromInstruction32(Insn, 22, 1) << 4;
|
|
|
|
unsigned size = fieldFromInstruction32(Insn, 10, 2);
|
|
|
|
|
|
|
|
unsigned align = 0;
|
|
|
|
unsigned index = 0;
|
|
|
|
unsigned inc = 1;
|
|
|
|
switch (size) {
|
|
|
|
default:
|
2011-09-01 18:02:14 +00:00
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
case 0:
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1))
|
|
|
|
align = 4;
|
|
|
|
index = fieldFromInstruction32(Insn, 5, 3);
|
|
|
|
break;
|
|
|
|
case 1:
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 1))
|
|
|
|
align = 8;
|
|
|
|
index = fieldFromInstruction32(Insn, 6, 2);
|
|
|
|
if (fieldFromInstruction32(Insn, 5, 1))
|
|
|
|
inc = 2;
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (fieldFromInstruction32(Insn, 4, 2))
|
|
|
|
align = 4 << fieldFromInstruction32(Insn, 4, 2);
|
|
|
|
index = fieldFromInstruction32(Insn, 7, 1);
|
|
|
|
if (fieldFromInstruction32(Insn, 6, 1))
|
|
|
|
inc = 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Rm != 0xF) { // Writeback
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(align));
|
2011-08-22 18:42:13 +00:00
|
|
|
if (Rm != 0xF) {
|
2011-09-01 18:02:14 +00:00
|
|
|
if (Rm != 0xD) {
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-09-01 18:02:14 +00:00
|
|
|
} else
|
2011-08-22 18:42:13 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateReg(0));
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+2*inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Rd+3*inc, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-15 18:44:44 +00:00
|
|
|
Inst.addOperand(MCOperand::CreateImm(index));
|
|
|
|
|
2011-08-17 17:44:15 +00:00
|
|
|
return S;
|
2011-08-15 18:44:44 +00:00
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVMOVSRR(MCInst &Inst, unsigned Insn,
|
2011-08-22 20:27:12 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-22 20:27:12 +00:00
|
|
|
unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
unsigned Rt2 = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 28, 4);
|
|
|
|
Rm |= fieldFromInstruction32(Insn, 5, 1) << 4;
|
|
|
|
|
|
|
|
if (Rt == 0xF || Rt2 == 0xF || Rm == 0x1F)
|
2011-09-01 18:02:14 +00:00
|
|
|
S = MCDisassembler::SoftFail;
|
2011-08-22 20:27:12 +00:00
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeSPRRegisterClass(Inst, Rm , Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeSPRRegisterClass(Inst, Rm+1, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rt , Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rt2 , Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-22 20:27:12 +00:00
|
|
|
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVMOVRRS(MCInst &Inst, unsigned Insn,
|
2011-08-22 20:27:12 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-22 20:27:12 +00:00
|
|
|
unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
unsigned Rt2 = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 28, 4);
|
|
|
|
Rm |= fieldFromInstruction32(Insn, 5, 1) << 4;
|
|
|
|
|
|
|
|
if (Rt == 0xF || Rt2 == 0xF || Rm == 0x1F)
|
2011-09-01 18:02:14 +00:00
|
|
|
S = MCDisassembler::SoftFail;
|
2011-08-22 20:27:12 +00:00
|
|
|
|
2011-09-01 23:23:50 +00:00
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rt , Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRRegisterClass(Inst, Rt2 , Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeSPRRegisterClass(Inst, Rm , Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeSPRRegisterClass(Inst, Rm+1, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
2011-08-22 20:27:12 +00:00
|
|
|
|
|
|
|
return S;
|
|
|
|
}
|
2011-08-22 23:44:04 +00:00
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeIT(MCInst &Inst, unsigned Insn,
|
2011-08-30 22:58:27 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
2011-09-01 23:23:50 +00:00
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
2011-08-30 22:58:27 +00:00
|
|
|
unsigned pred = fieldFromInstruction16(Insn, 4, 4);
|
|
|
|
// The InstPrinter needs to have the low bit of the predicate in
|
|
|
|
// the mask operand to be able to print it properly.
|
|
|
|
unsigned mask = fieldFromInstruction16(Insn, 0, 5);
|
|
|
|
|
|
|
|
if (pred == 0xF) {
|
|
|
|
pred = 0xE;
|
2011-09-01 18:02:14 +00:00
|
|
|
S = MCDisassembler::SoftFail;
|
2011-08-24 17:21:43 +00:00
|
|
|
}
|
|
|
|
|
2011-08-30 22:58:27 +00:00
|
|
|
if ((mask & 0xF) == 0) {
|
|
|
|
// Preserve the high bit of the mask, which is the low bit of
|
|
|
|
// the predicate.
|
|
|
|
mask &= 0x10;
|
|
|
|
mask |= 0x8;
|
2011-09-01 18:02:14 +00:00
|
|
|
S = MCDisassembler::SoftFail;
|
2011-08-24 22:40:22 +00:00
|
|
|
}
|
2011-08-30 22:58:27 +00:00
|
|
|
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(pred));
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(mask));
|
2011-08-24 22:40:22 +00:00
|
|
|
return S;
|
|
|
|
}
|
2011-09-08 22:07:06 +00:00
|
|
|
|
|
|
|
static DecodeStatus
|
2012-03-27 07:21:54 +00:00
|
|
|
DecodeT2LDRDPreInstruction(MCInst &Inst, unsigned Insn,
|
2011-09-08 22:07:06 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
|
|
|
|
|
|
|
unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
unsigned Rt2 = fieldFromInstruction32(Insn, 8, 4);
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned addr = fieldFromInstruction32(Insn, 0, 8);
|
|
|
|
unsigned W = fieldFromInstruction32(Insn, 21, 1);
|
|
|
|
unsigned U = fieldFromInstruction32(Insn, 23, 1);
|
|
|
|
unsigned P = fieldFromInstruction32(Insn, 24, 1);
|
|
|
|
bool writeback = (W == 1) | (P == 0);
|
|
|
|
|
|
|
|
addr |= (U << 8) | (Rn << 9);
|
|
|
|
|
|
|
|
if (writeback && (Rn == Rt || Rn == Rt2))
|
|
|
|
Check(S, MCDisassembler::SoftFail);
|
|
|
|
if (Rt == Rt2)
|
|
|
|
Check(S, MCDisassembler::SoftFail);
|
|
|
|
|
|
|
|
// Rt
|
|
|
|
if (!Check(S, DecoderGPRRegisterClass(Inst, Rt, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
// Rt2
|
|
|
|
if (!Check(S, DecoderGPRRegisterClass(Inst, Rt2, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
// Writeback operand
|
|
|
|
if (!Check(S, DecoderGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
// addr
|
|
|
|
if (!Check(S, DecodeT2AddrModeImm8s4(Inst, addr, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
|
|
|
static DecodeStatus
|
2012-03-27 07:21:54 +00:00
|
|
|
DecodeT2STRDPreInstruction(MCInst &Inst, unsigned Insn,
|
2011-09-08 22:07:06 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
|
|
|
|
|
|
|
unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
unsigned Rt2 = fieldFromInstruction32(Insn, 8, 4);
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned addr = fieldFromInstruction32(Insn, 0, 8);
|
|
|
|
unsigned W = fieldFromInstruction32(Insn, 21, 1);
|
|
|
|
unsigned U = fieldFromInstruction32(Insn, 23, 1);
|
|
|
|
unsigned P = fieldFromInstruction32(Insn, 24, 1);
|
|
|
|
bool writeback = (W == 1) | (P == 0);
|
|
|
|
|
|
|
|
addr |= (U << 8) | (Rn << 9);
|
|
|
|
|
|
|
|
if (writeback && (Rn == Rt || Rn == Rt2))
|
|
|
|
Check(S, MCDisassembler::SoftFail);
|
|
|
|
|
|
|
|
// Writeback operand
|
|
|
|
if (!Check(S, DecoderGPRRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
// Rt
|
|
|
|
if (!Check(S, DecoderGPRRegisterClass(Inst, Rt, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
// Rt2
|
|
|
|
if (!Check(S, DecoderGPRRegisterClass(Inst, Rt2, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
// addr
|
|
|
|
if (!Check(S, DecodeT2AddrModeImm8s4(Inst, addr, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
|
|
|
|
return S;
|
|
|
|
}
|
2011-09-09 22:24:36 +00:00
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2Adr(MCInst &Inst, uint32_t Insn,
|
2011-09-09 22:24:36 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
unsigned sign1 = fieldFromInstruction32(Insn, 21, 1);
|
|
|
|
unsigned sign2 = fieldFromInstruction32(Insn, 23, 1);
|
|
|
|
if (sign1 != sign2) return MCDisassembler::Fail;
|
|
|
|
|
|
|
|
unsigned Val = fieldFromInstruction32(Insn, 0, 8);
|
|
|
|
Val |= fieldFromInstruction32(Insn, 12, 3) << 8;
|
|
|
|
Val |= fieldFromInstruction32(Insn, 26, 1) << 11;
|
|
|
|
Val |= sign1 << 12;
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(SignExtend32<13>(Val)));
|
|
|
|
|
|
|
|
return MCDisassembler::Success;
|
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeT2ShifterImmOperand(MCInst &Inst, uint32_t Val,
|
2011-09-26 21:06:22 +00:00
|
|
|
uint64_t Address,
|
|
|
|
const void *Decoder) {
|
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
|
|
|
|
|
|
|
// Shift of "asr #32" is not allowed in Thumb2 mode.
|
|
|
|
if (Val == 0x20) S = MCDisassembler::SoftFail;
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(Val));
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeSwap(MCInst &Inst, unsigned Insn,
|
2011-10-28 18:02:13 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
unsigned Rt = fieldFromInstruction32(Insn, 12, 4);
|
|
|
|
unsigned Rt2 = fieldFromInstruction32(Insn, 0, 4);
|
|
|
|
unsigned Rn = fieldFromInstruction32(Insn, 16, 4);
|
|
|
|
unsigned pred = fieldFromInstruction32(Insn, 28, 4);
|
|
|
|
|
|
|
|
if (pred == 0xF)
|
|
|
|
return DecodeCPSInstruction(Inst, Insn, Address, Decoder);
|
|
|
|
|
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
|
|
|
if (!Check(S, DecodeGPRnopcRegisterClass(Inst, Rt, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRnopcRegisterClass(Inst, Rt2, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRnopcRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, pred, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
|
|
|
|
return S;
|
|
|
|
}
|
2011-11-15 19:55:00 +00:00
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVCVTD(MCInst &Inst, unsigned Insn,
|
2011-11-15 19:55:00 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
unsigned Vd = (fieldFromInstruction32(Insn, 12, 4) << 0);
|
|
|
|
Vd |= (fieldFromInstruction32(Insn, 22, 1) << 4);
|
|
|
|
unsigned Vm = (fieldFromInstruction32(Insn, 0, 4) << 0);
|
|
|
|
Vm |= (fieldFromInstruction32(Insn, 5, 1) << 4);
|
|
|
|
unsigned imm = fieldFromInstruction32(Insn, 16, 6);
|
|
|
|
unsigned cmode = fieldFromInstruction32(Insn, 8, 4);
|
|
|
|
|
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
|
|
|
|
|
|
|
// VMOVv2f32 is ambiguous with these decodings.
|
2011-11-15 20:30:41 +00:00
|
|
|
if (!(imm & 0x38) && cmode == 0xF) {
|
2011-11-15 19:55:00 +00:00
|
|
|
Inst.setOpcode(ARM::VMOVv2f32);
|
|
|
|
return DecodeNEONModImmInstruction(Inst, Insn, Address, Decoder);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(imm & 0x20)) Check(S, MCDisassembler::SoftFail);
|
|
|
|
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Vd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeDPRRegisterClass(Inst, Vm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(64 - imm));
|
|
|
|
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeVCVTQ(MCInst &Inst, unsigned Insn,
|
2011-11-15 19:55:00 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
unsigned Vd = (fieldFromInstruction32(Insn, 12, 4) << 0);
|
|
|
|
Vd |= (fieldFromInstruction32(Insn, 22, 1) << 4);
|
|
|
|
unsigned Vm = (fieldFromInstruction32(Insn, 0, 4) << 0);
|
|
|
|
Vm |= (fieldFromInstruction32(Insn, 5, 1) << 4);
|
|
|
|
unsigned imm = fieldFromInstruction32(Insn, 16, 6);
|
|
|
|
unsigned cmode = fieldFromInstruction32(Insn, 8, 4);
|
|
|
|
|
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
|
|
|
|
|
|
|
// VMOVv4f32 is ambiguous with these decodings.
|
|
|
|
if (!(imm & 0x38) && cmode == 0xF) {
|
|
|
|
Inst.setOpcode(ARM::VMOVv4f32);
|
|
|
|
return DecodeNEONModImmInstruction(Inst, Insn, Address, Decoder);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(imm & 0x20)) Check(S, MCDisassembler::SoftFail);
|
|
|
|
|
|
|
|
if (!Check(S, DecodeQPRRegisterClass(Inst, Vd, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeQPRRegisterClass(Inst, Vm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
Inst.addOperand(MCOperand::CreateImm(64 - imm));
|
|
|
|
|
|
|
|
return S;
|
|
|
|
}
|
2012-03-22 13:24:43 +00:00
|
|
|
|
2012-03-27 07:21:54 +00:00
|
|
|
static DecodeStatus DecodeLDR(MCInst &Inst, unsigned Val,
|
2012-03-22 13:24:43 +00:00
|
|
|
uint64_t Address, const void *Decoder) {
|
|
|
|
DecodeStatus S = MCDisassembler::Success;
|
|
|
|
|
|
|
|
unsigned Rn = fieldFromInstruction32(Val, 16, 4);
|
|
|
|
unsigned Rt = fieldFromInstruction32(Val, 12, 4);
|
|
|
|
unsigned Rm = fieldFromInstruction32(Val, 0, 4);
|
|
|
|
Rm |= (fieldFromInstruction32(Val, 23, 1) << 4);
|
|
|
|
unsigned Cond = fieldFromInstruction32(Val, 28, 4);
|
|
|
|
|
|
|
|
if (fieldFromInstruction32(Val, 8, 4) != 0 || Rn == Rt)
|
|
|
|
S = MCDisassembler::SoftFail;
|
|
|
|
|
|
|
|
if (!Check(S, DecodeGPRnopcRegisterClass(Inst, Rt, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeGPRnopcRegisterClass(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodeAddrMode7Operand(Inst, Rn, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodePostIdxReg(Inst, Rm, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
if (!Check(S, DecodePredicateOperand(Inst, Cond, Address, Decoder)))
|
|
|
|
return MCDisassembler::Fail;
|
|
|
|
|
|
|
|
return S;
|
|
|
|
}
|
|
|
|
|