mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-23 19:23:23 +01:00
Revert "- Implement asm parsing support for LDRT, LDRBT, STRT, STRBT and"
This revision introduced a dependency cycle, as nlewycky mentioned by email. llvm-svn: 128597
This commit is contained in:
parent
6429481136
commit
325e16f668
@ -200,51 +200,6 @@ inline static unsigned getARMRegisterNumbering(unsigned Reg) {
|
||||
}
|
||||
|
||||
namespace ARMII {
|
||||
|
||||
/// ARM Addressing Modes
|
||||
enum AddrMode {
|
||||
AddrModeNone = 0,
|
||||
AddrMode1 = 1,
|
||||
AddrMode2 = 2,
|
||||
AddrMode3 = 3,
|
||||
AddrMode4 = 4,
|
||||
AddrMode5 = 5,
|
||||
AddrMode6 = 6,
|
||||
AddrModeT1_1 = 7,
|
||||
AddrModeT1_2 = 8,
|
||||
AddrModeT1_4 = 9,
|
||||
AddrModeT1_s = 10, // i8 * 4 for pc and sp relative data
|
||||
AddrModeT2_i12 = 11,
|
||||
AddrModeT2_i8 = 12,
|
||||
AddrModeT2_so = 13,
|
||||
AddrModeT2_pc = 14, // +/- i12 for pc relative data
|
||||
AddrModeT2_i8s4 = 15, // i8 * 4
|
||||
AddrMode_i12 = 16
|
||||
};
|
||||
|
||||
inline static const char *AddrModeToString(AddrMode addrmode) {
|
||||
switch (addrmode) {
|
||||
default: llvm_unreachable("Unknown memory operation");
|
||||
case AddrModeNone: return "AddrModeNone";
|
||||
case AddrMode1: return "AddrMode1";
|
||||
case AddrMode2: return "AddrMode2";
|
||||
case AddrMode3: return "AddrMode3";
|
||||
case AddrMode4: return "AddrMode4";
|
||||
case AddrMode5: return "AddrMode5";
|
||||
case AddrMode6: return "AddrMode6";
|
||||
case AddrModeT1_1: return "AddrModeT1_1";
|
||||
case AddrModeT1_2: return "AddrModeT1_2";
|
||||
case AddrModeT1_4: return "AddrModeT1_4";
|
||||
case AddrModeT1_s: return "AddrModeT1_s";
|
||||
case AddrModeT2_i12: return "AddrModeT2_i12";
|
||||
case AddrModeT2_i8: return "AddrModeT2_i8";
|
||||
case AddrModeT2_so: return "AddrModeT2_so";
|
||||
case AddrModeT2_pc: return "AddrModeT2_pc";
|
||||
case AddrModeT2_i8s4: return "AddrModeT2_i8s4";
|
||||
case AddrMode_i12: return "AddrMode_i12";
|
||||
}
|
||||
}
|
||||
|
||||
/// Target Operand Flag enum.
|
||||
enum TOF {
|
||||
//===------------------------------------------------------------------===//
|
||||
|
@ -34,7 +34,25 @@ namespace ARMII {
|
||||
|
||||
//===------------------------------------------------------------------===//
|
||||
// This four-bit field describes the addressing mode used.
|
||||
AddrModeMask = 0x1f, // The AddrMode enums are declared in ARMBaseInfo.h
|
||||
|
||||
AddrModeMask = 0x1f,
|
||||
AddrModeNone = 0,
|
||||
AddrMode1 = 1,
|
||||
AddrMode2 = 2,
|
||||
AddrMode3 = 3,
|
||||
AddrMode4 = 4,
|
||||
AddrMode5 = 5,
|
||||
AddrMode6 = 6,
|
||||
AddrModeT1_1 = 7,
|
||||
AddrModeT1_2 = 8,
|
||||
AddrModeT1_4 = 9,
|
||||
AddrModeT1_s = 10, // i8 * 4 for pc and sp relative data
|
||||
AddrModeT2_i12 = 11,
|
||||
AddrModeT2_i8 = 12,
|
||||
AddrModeT2_so = 13,
|
||||
AddrModeT2_pc = 14, // +/- i12 for pc relative data
|
||||
AddrModeT2_i8s4 = 15, // i8 * 4
|
||||
AddrMode_i12 = 16,
|
||||
|
||||
// Size* - Flags to keep track of the size of an instruction.
|
||||
SizeShift = 5,
|
||||
|
@ -515,15 +515,15 @@ class AI2stridx<bit isByte, bit isPre, dag oops, dag iops,
|
||||
: AI2ldstidx<0, isByte, isPre, oops, iops, im, f, itin, opc, asm, cstr,
|
||||
pattern> {
|
||||
// AM2 store w/ two operands: (GPR, am2offset)
|
||||
// {17-14} Rn
|
||||
// {13} 1 == Rm, 0 == imm12
|
||||
// {12} isAdd
|
||||
// {11-0} imm12/Rm
|
||||
bits<18> addr;
|
||||
let Inst{25} = addr{13};
|
||||
let Inst{23} = addr{12};
|
||||
let Inst{19-16} = addr{17-14};
|
||||
let Inst{11-0} = addr{11-0};
|
||||
bits<14> offset;
|
||||
bits<4> Rn;
|
||||
let Inst{25} = offset{13};
|
||||
let Inst{23} = offset{12};
|
||||
let Inst{19-16} = Rn;
|
||||
let Inst{11-0} = offset{11-0};
|
||||
}
|
||||
|
||||
// addrmode3 instructions
|
||||
|
@ -498,12 +498,6 @@ def ldst_so_reg : Operand<i32>,
|
||||
let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
|
||||
}
|
||||
|
||||
def MemMode2AsmOperand : AsmOperandClass {
|
||||
let Name = "MemMode2";
|
||||
let SuperClasses = [];
|
||||
let ParserMethod = "tryParseMemMode2Operand";
|
||||
}
|
||||
|
||||
// addrmode2 := reg +/- imm12
|
||||
// := reg +/- reg shop imm
|
||||
//
|
||||
@ -511,7 +505,6 @@ def addrmode2 : Operand<i32>,
|
||||
ComplexPattern<i32, 3, "SelectAddrMode2", []> {
|
||||
let EncoderMethod = "getAddrMode2OpValue";
|
||||
let PrintMethod = "printAddrMode2Operand";
|
||||
let ParserMatchClass = MemMode2AsmOperand;
|
||||
let MIOperandInfo = (ops GPR:$base, GPR:$offsreg, i32imm:$offsimm);
|
||||
}
|
||||
|
||||
@ -1663,7 +1656,6 @@ multiclass AI2_ldridx<bit isByte, string opc, InstrItinClass itin> {
|
||||
let Inst{23} = addr{12};
|
||||
let Inst{19-16} = addr{17-14};
|
||||
let Inst{11-0} = addr{11-0};
|
||||
let AsmMatchConverter = "CvtLdWriteBackRegAddrMode2";
|
||||
}
|
||||
def _POST : AI2ldstidx<1, isByte, 0, (outs GPR:$Rt, GPR:$Rn_wb),
|
||||
(ins GPR:$Rn, am2offset:$offset),
|
||||
@ -1722,35 +1714,17 @@ defm LDRD : AI3_ldridx<0b1101, 0, "ldrd", IIC_iLoad_d_ru>;
|
||||
|
||||
// LDRT, LDRBT, LDRSBT, LDRHT, LDRSHT are for disassembly only.
|
||||
let mayLoad = 1, neverHasSideEffects = 1 in {
|
||||
def LDRT : AI2ldstidx<1, 0, 0, (outs GPR:$Rt, GPR:$base_wb),
|
||||
(ins addrmode2:$addr), IndexModePost, LdFrm, IIC_iLoad_ru,
|
||||
"ldrt", "\t$Rt, $addr", "$addr.base = $base_wb", []> {
|
||||
// {17-14} Rn
|
||||
// {13} 1 == Rm, 0 == imm12
|
||||
// {12} isAdd
|
||||
// {11-0} imm12/Rm
|
||||
bits<18> addr;
|
||||
let Inst{25} = addr{13};
|
||||
let Inst{23} = addr{12};
|
||||
def LDRT : AI2ldstidx<1, 0, 0, (outs GPR:$dst, GPR:$base_wb),
|
||||
(ins GPR:$base, am2offset:$offset), IndexModePost,
|
||||
LdFrm, IIC_iLoad_ru,
|
||||
"ldrt", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
|
||||
let Inst{21} = 1; // overwrite
|
||||
let Inst{19-16} = addr{17-14};
|
||||
let Inst{11-0} = addr{11-0};
|
||||
let AsmMatchConverter = "CvtLdWriteBackRegAddrMode2";
|
||||
}
|
||||
def LDRBT : AI2ldstidx<1, 1, 0, (outs GPR:$Rt, GPR:$base_wb),
|
||||
(ins addrmode2:$addr), IndexModePost, LdFrm, IIC_iLoad_bh_ru,
|
||||
"ldrbt", "\t$Rt, $addr", "$addr.base = $base_wb", []> {
|
||||
// {17-14} Rn
|
||||
// {13} 1 == Rm, 0 == imm12
|
||||
// {12} isAdd
|
||||
// {11-0} imm12/Rm
|
||||
bits<18> addr;
|
||||
let Inst{25} = addr{13};
|
||||
let Inst{23} = addr{12};
|
||||
def LDRBT : AI2ldstidx<1, 1, 0, (outs GPR:$dst, GPR:$base_wb),
|
||||
(ins GPR:$base, am2offset:$offset), IndexModePost,
|
||||
LdFrm, IIC_iLoad_bh_ru,
|
||||
"ldrbt", "\t$dst, [$base], $offset", "$base = $base_wb", []> {
|
||||
let Inst{21} = 1; // overwrite
|
||||
let Inst{19-16} = addr{17-14};
|
||||
let Inst{11-0} = addr{11-0};
|
||||
let AsmMatchConverter = "CvtLdWriteBackRegAddrMode2";
|
||||
}
|
||||
def LDRSBT : AI3ldstidx<0b1101, 1, 1, 0, (outs GPR:$dst, GPR:$base_wb),
|
||||
(ins GPR:$base, am3offset:$offset), IndexModePost,
|
||||
@ -1844,20 +1818,20 @@ def STRD_POST: AI3stdpo<(outs GPR:$base_wb),
|
||||
|
||||
// STRT, STRBT, and STRHT are for disassembly only.
|
||||
|
||||
def STRT : AI2stridx<0, 0, (outs GPR:$Rn_wb), (ins GPR:$Rt, addrmode2:$addr),
|
||||
def STRT : AI2stridx<0, 0, (outs GPR:$Rn_wb),
|
||||
(ins GPR:$Rt, GPR:$Rn,am2offset:$offset),
|
||||
IndexModePost, StFrm, IIC_iStore_ru,
|
||||
"strt", "\t$Rt, $addr", "$addr.base = $Rn_wb",
|
||||
"strt", "\t$Rt, [$Rn], $offset", "$Rn = $Rn_wb",
|
||||
[/* For disassembly only; pattern left blank */]> {
|
||||
let Inst{21} = 1; // overwrite
|
||||
let AsmMatchConverter = "CvtStWriteBackRegAddrMode2";
|
||||
}
|
||||
|
||||
def STRBT : AI2stridx<1, 0, (outs GPR:$Rn_wb), (ins GPR:$Rt, addrmode2:$addr),
|
||||
def STRBT : AI2stridx<1, 0, (outs GPR:$Rn_wb),
|
||||
(ins GPR:$Rt, GPR:$Rn, am2offset:$offset),
|
||||
IndexModePost, StFrm, IIC_iStore_bh_ru,
|
||||
"strbt", "\t$Rt, $addr", "$addr.base = $Rn_wb",
|
||||
"strbt", "\t$Rt, [$Rn], $offset", "$Rn = $Rn_wb",
|
||||
[/* For disassembly only; pattern left blank */]> {
|
||||
let Inst{21} = 1; // overwrite
|
||||
let AsmMatchConverter = "CvtStWriteBackRegAddrMode2";
|
||||
}
|
||||
|
||||
def STRHT: AI3sthpo<(outs GPR:$base_wb),
|
||||
@ -3417,9 +3391,8 @@ def CDP2 : ABXI<0b1110, (outs), (ins p_imm:$cop, i32imm:$opc1,
|
||||
let Inst{23-20} = opc1;
|
||||
}
|
||||
|
||||
class ACI<dag oops, dag iops, string opc, string asm,
|
||||
IndexMode im = IndexModeNone>
|
||||
: I<oops, iops, AddrModeNone, Size4Bytes, im, BrFrm, NoItinerary,
|
||||
class ACI<dag oops, dag iops, string opc, string asm>
|
||||
: I<oops, iops, AddrModeNone, Size4Bytes, IndexModeNone, BrFrm, NoItinerary,
|
||||
opc, asm, "", [/* For disassembly only; pattern left blank */]> {
|
||||
let Inst{27-25} = 0b110;
|
||||
}
|
||||
@ -3438,7 +3411,7 @@ multiclass LdStCop<bits<4> op31_28, bit load, string opc> {
|
||||
|
||||
def _PRE : ACI<(outs),
|
||||
(ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
|
||||
opc, "\tp$cop, cr$CRd, $addr!", IndexModePre> {
|
||||
opc, "\tp$cop, cr$CRd, $addr!"> {
|
||||
let Inst{31-28} = op31_28;
|
||||
let Inst{24} = 1; // P = 1
|
||||
let Inst{21} = 1; // W = 1
|
||||
@ -3479,7 +3452,7 @@ multiclass LdStCop<bits<4> op31_28, bit load, string opc> {
|
||||
|
||||
def L_PRE : ACI<(outs),
|
||||
(ins nohash_imm:$cop, nohash_imm:$CRd, addrmode2:$addr),
|
||||
!strconcat(opc, "l"), "\tp$cop, cr$CRd, $addr!", IndexModePre> {
|
||||
!strconcat(opc, "l"), "\tp$cop, cr$CRd, $addr!"> {
|
||||
let Inst{31-28} = op31_28;
|
||||
let Inst{24} = 1; // P = 1
|
||||
let Inst{21} = 1; // W = 1
|
||||
|
@ -48,8 +48,7 @@ class ARMAsmParser : public TargetAsmParser {
|
||||
bool TryParseRegisterWithWriteBack(SmallVectorImpl<MCParsedAsmOperand*> &);
|
||||
bool TryParseShiftRegister(SmallVectorImpl<MCParsedAsmOperand*> &);
|
||||
bool ParseRegisterList(SmallVectorImpl<MCParsedAsmOperand*> &);
|
||||
bool ParseMemory(SmallVectorImpl<MCParsedAsmOperand*> &,
|
||||
ARMII::AddrMode AddrMode);
|
||||
bool ParseMemory(SmallVectorImpl<MCParsedAsmOperand*> &);
|
||||
bool ParseOperand(SmallVectorImpl<MCParsedAsmOperand*> &, StringRef Mnemonic);
|
||||
bool ParsePrefix(ARMMCExpr::VariantKind &RefKind);
|
||||
const MCExpr *ApplyPrefixToExpr(const MCExpr *E,
|
||||
@ -96,14 +95,6 @@ class ARMAsmParser : public TargetAsmParser {
|
||||
SmallVectorImpl<MCParsedAsmOperand*>&);
|
||||
OperandMatchResultTy tryParseMSRMaskOperand(
|
||||
SmallVectorImpl<MCParsedAsmOperand*>&);
|
||||
OperandMatchResultTy tryParseMemMode2Operand(
|
||||
SmallVectorImpl<MCParsedAsmOperand*>&);
|
||||
|
||||
// Asm Match Converter Methods
|
||||
bool CvtLdWriteBackRegAddrMode2(MCInst &Inst, unsigned Opcode,
|
||||
const SmallVectorImpl<MCParsedAsmOperand*> &);
|
||||
bool CvtStWriteBackRegAddrMode2(MCInst &Inst, unsigned Opcode,
|
||||
const SmallVectorImpl<MCParsedAsmOperand*> &);
|
||||
|
||||
public:
|
||||
ARMAsmParser(const Target &T, MCAsmParser &_Parser, TargetMachine &_TM)
|
||||
@ -181,7 +172,6 @@ class ARMOperand : public MCParsedAsmOperand {
|
||||
|
||||
/// Combined record for all forms of ARM address expressions.
|
||||
struct {
|
||||
ARMII::AddrMode AddrMode;
|
||||
unsigned BaseRegNum;
|
||||
union {
|
||||
unsigned RegNum; ///< Offset register num, when OffsetIsReg.
|
||||
@ -303,9 +293,7 @@ public:
|
||||
|
||||
/// @name Memory Operand Accessors
|
||||
/// @{
|
||||
ARMII::AddrMode getMemAddrMode() const {
|
||||
return Mem.AddrMode;
|
||||
}
|
||||
|
||||
unsigned getMemBaseRegNum() const {
|
||||
return Mem.BaseRegNum;
|
||||
}
|
||||
@ -350,27 +338,6 @@ public:
|
||||
bool isMemBarrierOpt() const { return Kind == MemBarrierOpt; }
|
||||
bool isMemory() const { return Kind == Memory; }
|
||||
bool isShifter() const { return Kind == Shifter; }
|
||||
bool isMemMode2() const {
|
||||
if (getMemAddrMode() != ARMII::AddrMode2)
|
||||
return false;
|
||||
|
||||
if (getMemOffsetIsReg())
|
||||
return true;
|
||||
|
||||
if (getMemNegative() &&
|
||||
!(getMemPostindexed() || getMemPreindexed()))
|
||||
return false;
|
||||
|
||||
const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getMemOffset());
|
||||
if (!CE) return false;
|
||||
int64_t Value = CE->getValue();
|
||||
|
||||
// The offset must be in the range 0-4095 (imm12).
|
||||
if (Value > 4095 || Value < -4095)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
bool isMemMode5() const {
|
||||
if (!isMemory() || getMemOffsetIsReg() || getMemWriteback() ||
|
||||
getMemNegative())
|
||||
@ -498,46 +465,6 @@ public:
|
||||
"No offset operand support in mode 7");
|
||||
}
|
||||
|
||||
void addMemMode2Operands(MCInst &Inst, unsigned N) const {
|
||||
assert(isMemMode2() && "Invalid mode or number of operands!");
|
||||
Inst.addOperand(MCOperand::CreateReg(getMemBaseRegNum()));
|
||||
|
||||
if (getMemOffsetIsReg()) {
|
||||
Inst.addOperand(MCOperand::CreateReg(getMemOffsetRegNum()));
|
||||
|
||||
ARM_AM::AddrOpc AMOpc = getMemNegative() ? ARM_AM::sub : ARM_AM::add;
|
||||
ARM_AM::ShiftOpc ShOpc = ARM_AM::no_shift;
|
||||
int64_t ShiftAmount = 0;
|
||||
|
||||
if (getMemOffsetRegShifted()) {
|
||||
ShOpc = getMemShiftType();
|
||||
const MCConstantExpr *CE =
|
||||
dyn_cast<MCConstantExpr>(getMemShiftAmount());
|
||||
ShiftAmount = CE->getValue();
|
||||
}
|
||||
|
||||
Inst.addOperand(MCOperand::CreateImm(ARM_AM::getAM2Opc(AMOpc, ShiftAmount,
|
||||
ShOpc)));
|
||||
return;
|
||||
}
|
||||
|
||||
// Create a operand placeholder to always yield the same number of operands.
|
||||
Inst.addOperand(MCOperand::CreateReg(0));
|
||||
|
||||
// FIXME: #-0 is encoded differently than #0. Does the parser preserve
|
||||
// the difference?
|
||||
const MCConstantExpr *CE = dyn_cast<MCConstantExpr>(getMemOffset());
|
||||
assert(CE && "Non-constant mode 2 offset operand!");
|
||||
int64_t Offset = CE->getValue();
|
||||
|
||||
if (Offset >= 0)
|
||||
Inst.addOperand(MCOperand::CreateImm(ARM_AM::getAM2Opc(ARM_AM::add,
|
||||
Offset, ARM_AM::no_shift)));
|
||||
else
|
||||
Inst.addOperand(MCOperand::CreateImm(ARM_AM::getAM2Opc(ARM_AM::sub,
|
||||
-Offset, ARM_AM::no_shift)));
|
||||
}
|
||||
|
||||
void addMemMode5Operands(MCInst &Inst, unsigned N) const {
|
||||
assert(N == 2 && isMemMode5() && "Invalid number of operands!");
|
||||
|
||||
@ -672,9 +599,9 @@ public:
|
||||
return Op;
|
||||
}
|
||||
|
||||
static ARMOperand *CreateMem(ARMII::AddrMode AddrMode, unsigned BaseRegNum,
|
||||
bool OffsetIsReg, const MCExpr *Offset,
|
||||
int OffsetRegNum, bool OffsetRegShifted,
|
||||
static ARMOperand *CreateMem(unsigned BaseRegNum, bool OffsetIsReg,
|
||||
const MCExpr *Offset, int OffsetRegNum,
|
||||
bool OffsetRegShifted,
|
||||
enum ARM_AM::ShiftOpc ShiftType,
|
||||
const MCExpr *ShiftAmount, bool Preindexed,
|
||||
bool Postindexed, bool Negative, bool Writeback,
|
||||
@ -691,7 +618,6 @@ public:
|
||||
"Cannot have expression offset and register offset!");
|
||||
|
||||
ARMOperand *Op = new ARMOperand(Memory);
|
||||
Op->Mem.AddrMode = AddrMode;
|
||||
Op->Mem.BaseRegNum = BaseRegNum;
|
||||
Op->Mem.OffsetIsReg = OffsetIsReg;
|
||||
if (OffsetIsReg)
|
||||
@ -763,8 +689,7 @@ void ARMOperand::dump(raw_ostream &OS) const {
|
||||
break;
|
||||
case Memory:
|
||||
OS << "<memory "
|
||||
<< "am:" << ARMII::AddrModeToString(getMemAddrMode())
|
||||
<< " base:" << getMemBaseRegNum();
|
||||
<< "base:" << getMemBaseRegNum();
|
||||
if (getMemOffsetIsReg()) {
|
||||
OS << " offset:<register " << getMemOffsetRegNum();
|
||||
if (getMemOffsetRegShifted()) {
|
||||
@ -1207,57 +1132,13 @@ tryParseMSRMaskOperand(SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
|
||||
return MatchOperand_Success;
|
||||
}
|
||||
|
||||
/// tryParseMemMode2Operand - Try to parse memory addressing mode 2 operand.
|
||||
ARMAsmParser::OperandMatchResultTy ARMAsmParser::
|
||||
tryParseMemMode2Operand(SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
|
||||
SMLoc S = Parser.getTok().getLoc();
|
||||
const AsmToken &Tok = Parser.getTok();
|
||||
assert(Tok.is(AsmToken::LBrac) && "Token is not a \"[\"");
|
||||
|
||||
if (ParseMemory(Operands, ARMII::AddrMode2))
|
||||
return MatchOperand_NoMatch;
|
||||
|
||||
return MatchOperand_Success;
|
||||
}
|
||||
|
||||
/// CvtLdWriteBackRegAddrMode2 - Convert parsed operands to MCInst.
|
||||
/// Needed here because the Asm Gen Matcher can't handle properly tied operands
|
||||
/// when they refer multiple MIOperands inside a single one.
|
||||
bool ARMAsmParser::
|
||||
CvtLdWriteBackRegAddrMode2(MCInst &Inst, unsigned Opcode,
|
||||
const SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
|
||||
((ARMOperand*)Operands[2])->addRegOperands(Inst, 1);
|
||||
|
||||
// Create a writeback register dummy placeholder.
|
||||
Inst.addOperand(MCOperand::CreateImm(0));
|
||||
|
||||
((ARMOperand*)Operands[3])->addMemMode2Operands(Inst, 3);
|
||||
((ARMOperand*)Operands[1])->addCondCodeOperands(Inst, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// CvtStWriteBackRegAddrMode2 - Convert parsed operands to MCInst.
|
||||
/// Needed here because the Asm Gen Matcher can't handle properly tied operands
|
||||
/// when they refer multiple MIOperands inside a single one.
|
||||
bool ARMAsmParser::
|
||||
CvtStWriteBackRegAddrMode2(MCInst &Inst, unsigned Opcode,
|
||||
const SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
|
||||
// Create a writeback register dummy placeholder.
|
||||
Inst.addOperand(MCOperand::CreateImm(0));
|
||||
((ARMOperand*)Operands[2])->addRegOperands(Inst, 1);
|
||||
((ARMOperand*)Operands[3])->addMemMode2Operands(Inst, 3);
|
||||
((ARMOperand*)Operands[1])->addCondCodeOperands(Inst, 2);
|
||||
return true;
|
||||
}
|
||||
|
||||
/// Parse an ARM memory expression, return false if successful else return true
|
||||
/// or an error. The first token must be a '[' when called.
|
||||
///
|
||||
/// TODO Only preindexing and postindexing addressing are started, unindexed
|
||||
/// with option, etc are still to do.
|
||||
bool ARMAsmParser::
|
||||
ParseMemory(SmallVectorImpl<MCParsedAsmOperand*> &Operands,
|
||||
ARMII::AddrMode AddrMode = ARMII::AddrModeNone) {
|
||||
ParseMemory(SmallVectorImpl<MCParsedAsmOperand*> &Operands) {
|
||||
SMLoc S, E;
|
||||
assert(Parser.getTok().is(AsmToken::LBrac) &&
|
||||
"Token is not a Left Bracket");
|
||||
@ -1350,10 +1231,11 @@ ParseMemory(SmallVectorImpl<MCParsedAsmOperand*> &Operands,
|
||||
Offset = MCConstantExpr::Create(0, getContext());
|
||||
}
|
||||
|
||||
Operands.push_back(ARMOperand::CreateMem(AddrMode, BaseRegNum, OffsetIsReg,
|
||||
Offset, OffsetRegNum, OffsetRegShifted,
|
||||
ShiftType, ShiftAmount, Preindexed,
|
||||
Postindexed, Negative, Writeback, S, E));
|
||||
Operands.push_back(ARMOperand::CreateMem(BaseRegNum, OffsetIsReg, Offset,
|
||||
OffsetRegNum, OffsetRegShifted,
|
||||
ShiftType, ShiftAmount, Preindexed,
|
||||
Postindexed, Negative, Writeback,
|
||||
S, E));
|
||||
if (WBOp)
|
||||
Operands.push_back(WBOp);
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
#define DEBUG_TYPE "asm-printer"
|
||||
#include "ARMBaseInfo.h"
|
||||
#include "ARMInstPrinter.h"
|
||||
#include "ARMInstrInfo.h"
|
||||
#include "ARMAddressingModes.h"
|
||||
#include "llvm/MC/MCInst.h"
|
||||
#include "llvm/MC/MCAsmInfo.h"
|
||||
@ -182,12 +181,18 @@ void ARMInstPrinter::printSORegOperand(const MCInst *MI, unsigned OpNum,
|
||||
}
|
||||
}
|
||||
|
||||
void ARMInstPrinter::printAM2PreOrOffsetIndexOp(const MCInst *MI, unsigned Op,
|
||||
raw_ostream &O) {
|
||||
|
||||
void ARMInstPrinter::printAddrMode2Operand(const MCInst *MI, unsigned Op,
|
||||
raw_ostream &O) {
|
||||
const MCOperand &MO1 = MI->getOperand(Op);
|
||||
const MCOperand &MO2 = MI->getOperand(Op+1);
|
||||
const MCOperand &MO3 = MI->getOperand(Op+2);
|
||||
|
||||
if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
|
||||
printOperand(MI, Op, O);
|
||||
return;
|
||||
}
|
||||
|
||||
O << "[" << getRegisterName(MO1.getReg());
|
||||
|
||||
if (!MO2.getReg()) {
|
||||
@ -210,52 +215,6 @@ void ARMInstPrinter::printAM2PreOrOffsetIndexOp(const MCInst *MI, unsigned Op,
|
||||
O << "]";
|
||||
}
|
||||
|
||||
void ARMInstPrinter::printAM2PostIndexOp(const MCInst *MI, unsigned Op,
|
||||
raw_ostream &O) {
|
||||
const MCOperand &MO1 = MI->getOperand(Op);
|
||||
const MCOperand &MO2 = MI->getOperand(Op+1);
|
||||
const MCOperand &MO3 = MI->getOperand(Op+2);
|
||||
|
||||
O << "[" << getRegisterName(MO1.getReg()) << "], ";
|
||||
|
||||
if (!MO2.getReg()) {
|
||||
unsigned ImmOffs = ARM_AM::getAM2Offset(MO3.getImm());
|
||||
O << '#'
|
||||
<< ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
|
||||
<< ImmOffs;
|
||||
return;
|
||||
}
|
||||
|
||||
O << ARM_AM::getAddrOpcStr(ARM_AM::getAM2Op(MO3.getImm()))
|
||||
<< getRegisterName(MO2.getReg());
|
||||
|
||||
if (unsigned ShImm = ARM_AM::getAM2Offset(MO3.getImm()))
|
||||
O << ", "
|
||||
<< ARM_AM::getShiftOpcStr(ARM_AM::getAM2ShiftOpc(MO3.getImm()))
|
||||
<< " #" << ShImm;
|
||||
}
|
||||
|
||||
void ARMInstPrinter::printAddrMode2Operand(const MCInst *MI, unsigned Op,
|
||||
raw_ostream &O) {
|
||||
const MCOperand &MO1 = MI->getOperand(Op);
|
||||
|
||||
if (!MO1.isReg()) { // FIXME: This is for CP entries, but isn't right.
|
||||
printOperand(MI, Op, O);
|
||||
return;
|
||||
}
|
||||
|
||||
unsigned Opcode = MI->getOpcode();
|
||||
const TargetInstrDesc &Desc = TM.getInstrInfo()->get(Opcode);
|
||||
uint64_t TSFlags = Desc.TSFlags;
|
||||
unsigned IdxMode = (TSFlags & ARMII::IndexModeMask) >> ARMII::IndexModeShift;
|
||||
|
||||
if (IdxMode == ARMII::IndexModePost) {
|
||||
printAM2PostIndexOp(MI, Op, O);
|
||||
return;
|
||||
}
|
||||
printAM2PreOrOffsetIndexOp(MI, Op, O);
|
||||
}
|
||||
|
||||
void ARMInstPrinter::printAddrMode2OffsetOperand(const MCInst *MI,
|
||||
unsigned OpNum,
|
||||
raw_ostream &O) {
|
||||
|
@ -22,11 +22,9 @@ class MCOperand;
|
||||
class TargetMachine;
|
||||
|
||||
class ARMInstPrinter : public MCInstPrinter {
|
||||
private:
|
||||
TargetMachine &TM;
|
||||
public:
|
||||
ARMInstPrinter(TargetMachine &_TM, const MCAsmInfo &MAI)
|
||||
: MCInstPrinter(MAI), TM(_TM) {}
|
||||
ARMInstPrinter(TargetMachine &TM, const MCAsmInfo &MAI)
|
||||
: MCInstPrinter(MAI) {}
|
||||
|
||||
virtual void printInst(const MCInst *MI, raw_ostream &O);
|
||||
virtual StringRef getOpcodeName(unsigned Opcode) const;
|
||||
@ -44,11 +42,7 @@ public:
|
||||
void printSOImmOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
|
||||
|
||||
void printSORegOperand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
|
||||
|
||||
void printAddrMode2Operand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
|
||||
void printAM2PostIndexOp(const MCInst *MI, unsigned OpNum, raw_ostream &O);
|
||||
void printAM2PreOrOffsetIndexOp(const MCInst *MI, unsigned OpNum,
|
||||
raw_ostream &O);
|
||||
void printAddrMode2OffsetOperand(const MCInst *MI, unsigned OpNum,
|
||||
raw_ostream &O);
|
||||
void printAddrMode3Operand(const MCInst *MI, unsigned OpNum, raw_ostream &O);
|
||||
|
@ -1,34 +0,0 @@
|
||||
@ RUN: llvm-mc -mcpu=cortex-a8 -triple arm-unknown-unknown -show-encoding %s | FileCheck %s
|
||||
|
||||
@ Post-indexed
|
||||
@ CHECK: ldrt r1, [r0], r2 @ encoding: [0x02,0x10,0xb0,0xe6]
|
||||
@ CHECK: ldrt r1, [r0], r2, lsr #3 @ encoding: [0xa2,0x11,0xb0,0xe6]
|
||||
@ CHECK: ldrt r1, [r0], #4 @ encoding: [0x04,0x10,0xb0,0xe4]
|
||||
@ CHECK: ldrbt r1, [r0], r2 @ encoding: [0x02,0x10,0xf0,0xe6]
|
||||
@ CHECK: ldrbt r1, [r0], r2, lsr #3 @ encoding: [0xa2,0x11,0xf0,0xe6]
|
||||
@ CHECK: ldrbt r1, [r0], #4 @ encoding: [0x04,0x10,0xf0,0xe4]
|
||||
@ CHECK: strt r1, [r0], r2 @ encoding: [0x02,0x10,0xa0,0xe6]
|
||||
@ CHECK: strt r1, [r0], r2, lsr #3 @ encoding: [0xa2,0x11,0xa0,0xe6]
|
||||
@ CHECK: strt r1, [r0], #4 @ encoding: [0x04,0x10,0xa0,0xe4]
|
||||
@ CHECK: strbt r1, [r0], r2 @ encoding: [0x02,0x10,0xe0,0xe6]
|
||||
@ CHECK: strbt r1, [r0], r2, lsr #3 @ encoding: [0xa2,0x11,0xe0,0xe6]
|
||||
@ CHECK: strbt r1, [r0], #4 @ encoding: [0x04,0x10,0xe0,0xe4]
|
||||
ldrt r1, [r0], r2
|
||||
ldrt r1, [r0], r2, lsr #3
|
||||
ldrt r1, [r0], #4
|
||||
ldrbt r1, [r0], r2
|
||||
ldrbt r1, [r0], r2, lsr #3
|
||||
ldrbt r1, [r0], #4
|
||||
strt r1, [r0], r2
|
||||
strt r1, [r0], r2, lsr #3
|
||||
strt r1, [r0], #4
|
||||
strbt r1, [r0], r2
|
||||
strbt r1, [r0], r2, lsr #3
|
||||
strbt r1, [r0], #4
|
||||
|
||||
@ Pre-indexed
|
||||
@ CHECK: ldr r1, [r0, r2, lsr #3]! @ encoding: [0xa2,0x11,0xb0,0xe7]
|
||||
@ CHECK: ldrb r1, [r0, r2, lsr #3]! @ encoding: [0xa2,0x11,0xf0,0xe7]
|
||||
ldr r1, [r0, r2, lsr #3]!
|
||||
ldrb r1, [r0, r2, lsr #3]!
|
||||
|
Loading…
Reference in New Issue
Block a user