mirror of
https://github.com/RPCS3/llvm.git
synced 2024-12-13 23:18:58 +00:00
Add support for movi32 of global values to the new (MC) asm printer.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@103576 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
72c2a83951
commit
18c1021ec1
@ -134,7 +134,9 @@ public:
|
||||
VK_NTPOFF,
|
||||
VK_PLT,
|
||||
VK_TLSGD,
|
||||
VK_TPOFF
|
||||
VK_TPOFF,
|
||||
VK_ARM_HI16, // The R_ARM_MOVT_ABS relocation (:upper16: in the asm file)
|
||||
VK_ARM_LO16 // The R_ARM_MOVW_ABS_NC relocation (:lower16: in the asm file)
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -39,6 +39,10 @@ void MCExpr::print(raw_ostream &OS) const {
|
||||
const MCSymbolRefExpr &SRE = cast<MCSymbolRefExpr>(*this);
|
||||
const MCSymbol &Sym = SRE.getSymbol();
|
||||
|
||||
if (SRE.getKind() == MCSymbolRefExpr::VK_ARM_HI16 ||
|
||||
SRE.getKind() == MCSymbolRefExpr::VK_ARM_LO16)
|
||||
OS << MCSymbolRefExpr::getVariantKindName(SRE.getKind());
|
||||
|
||||
// Parenthesize names that start with $ so that they don't look like
|
||||
// absolute names.
|
||||
if (Sym.getName()[0] == '$')
|
||||
@ -46,7 +50,9 @@ void MCExpr::print(raw_ostream &OS) const {
|
||||
else
|
||||
OS << Sym;
|
||||
|
||||
if (SRE.getKind() != MCSymbolRefExpr::VK_None)
|
||||
if (SRE.getKind() != MCSymbolRefExpr::VK_None &&
|
||||
SRE.getKind() != MCSymbolRefExpr::VK_ARM_HI16 &&
|
||||
SRE.getKind() != MCSymbolRefExpr::VK_ARM_LO16)
|
||||
OS << '@' << MCSymbolRefExpr::getVariantKindName(SRE.getKind());
|
||||
|
||||
return;
|
||||
@ -169,6 +175,8 @@ StringRef MCSymbolRefExpr::getVariantKindName(VariantKind Kind) {
|
||||
case VK_PLT: return "PLT";
|
||||
case VK_TLSGD: return "TLSGD";
|
||||
case VK_TPOFF: return "TPOFF";
|
||||
case VK_ARM_HI16: return ":upper16:";
|
||||
case VK_ARM_LO16: return ":lower16:";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1375,13 +1375,32 @@ void ARMAsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI) {
|
||||
case ARM::MOVi32imm: { // FIXME: Remove asmstring from td file.
|
||||
// This is a hack that lowers as a two instruction sequence.
|
||||
unsigned DstReg = MI->getOperand(0).getReg();
|
||||
unsigned ImmVal = (unsigned)MI->getOperand(1).getImm();
|
||||
|
||||
const MachineOperand &MO = MI->getOperand(1);
|
||||
MCOperand V1, V2;
|
||||
if (MO.isImm()) {
|
||||
unsigned ImmVal = (unsigned)MI->getOperand(1).getImm();
|
||||
V1 = MCOperand::CreateImm(ImmVal & 65535);
|
||||
V2 = MCOperand::CreateImm(ImmVal >> 16);
|
||||
} else if (MO.isGlobal()) {
|
||||
MCSymbol *Symbol = MCInstLowering.GetGlobalAddressSymbol(MO);
|
||||
const MCSymbolRefExpr *SymRef1 =
|
||||
MCSymbolRefExpr::Create(Symbol,
|
||||
MCSymbolRefExpr::VK_ARM_LO16, OutContext);
|
||||
const MCSymbolRefExpr *SymRef2 =
|
||||
MCSymbolRefExpr::Create(Symbol,
|
||||
MCSymbolRefExpr::VK_ARM_HI16, OutContext);
|
||||
V1 = MCOperand::CreateExpr(SymRef1);
|
||||
V2 = MCOperand::CreateExpr(SymRef2);
|
||||
} else {
|
||||
MI->dump();
|
||||
llvm_unreachable("cannot handle this operand");
|
||||
}
|
||||
|
||||
{
|
||||
MCInst TmpInst;
|
||||
TmpInst.setOpcode(ARM::MOVi16);
|
||||
TmpInst.addOperand(MCOperand::CreateReg(DstReg)); // dstreg
|
||||
TmpInst.addOperand(MCOperand::CreateImm(ImmVal & 65535)); // lower16(imm)
|
||||
TmpInst.addOperand(V1); // lower16(imm)
|
||||
|
||||
// Predicate.
|
||||
TmpInst.addOperand(MCOperand::CreateImm(MI->getOperand(2).getImm()));
|
||||
@ -1395,7 +1414,7 @@ void ARMAsmPrinter::printInstructionThroughMCStreamer(const MachineInstr *MI) {
|
||||
TmpInst.setOpcode(ARM::MOVTi16);
|
||||
TmpInst.addOperand(MCOperand::CreateReg(DstReg)); // dstreg
|
||||
TmpInst.addOperand(MCOperand::CreateReg(DstReg)); // srcreg
|
||||
TmpInst.addOperand(MCOperand::CreateImm(ImmVal >> 16)); // upper16(imm)
|
||||
TmpInst.addOperand(V2); // upper16(imm)
|
||||
|
||||
// Predicate.
|
||||
TmpInst.addOperand(MCOperand::CreateImm(MI->getOperand(2).getImm()));
|
||||
|
@ -217,7 +217,8 @@ void ARMInstPrinter::printOperand(const MCInst *MI, unsigned OpNo,
|
||||
((Modifier == 0 || Modifier[0] == 0) && "No modifiers supported"));
|
||||
O << '#' << Op.getImm();
|
||||
} else {
|
||||
assert((Modifier == 0 || Modifier[0] == 0) && "No modifiers supported");
|
||||
if (Modifier && Modifier[0] != 0 && strcmp(Modifier, "call") != 0)
|
||||
llvm_unreachable("Unsupported modifier");
|
||||
assert(Op.isExpr() && "unknown operand kind in printOperand");
|
||||
O << *Op.getExpr();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user