mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 19:52:54 +01:00
Update ARMConstantPoolValue to not use a modifier string. Use an explicit
VariantKind marker to indicate the additional information necessary. Update MC to handle the new Kinds. rdar://8647623 llvm-svn: 118671
This commit is contained in:
parent
c911863e01
commit
4e3653e4e1
@ -141,9 +141,15 @@ public:
|
||||
VK_TLSLDM,
|
||||
VK_TPOFF,
|
||||
VK_DTPOFF,
|
||||
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)
|
||||
VK_ARM_PLT, // ARM-style PLT symbol references. i.e., (PLT) instead of @PLT
|
||||
VK_ARM_HI16, // The R_ARM_MOVT_ABS relocation (:upper16: in the .s file)
|
||||
VK_ARM_LO16, // The R_ARM_MOVW_ABS_NC relocation (:lower16: in the .w file)
|
||||
// FIXME: We'd really like to use the generic Kinds listed above for these.
|
||||
VK_ARM_PLT, // ARM-style PLT references. i.e., (PLT) instead of @PLT
|
||||
VK_ARM_TLSGD, // ditto for TLSGD, GOT, GOTOFF, TPOFF and GOTTPOFF
|
||||
VK_ARM_GOT,
|
||||
VK_ARM_GOTOFF,
|
||||
VK_ARM_TPOFF,
|
||||
VK_ARM_GOTTPOFF,
|
||||
VK_TLVP // Mach-O thread local variable relocation
|
||||
};
|
||||
|
||||
|
@ -51,7 +51,12 @@ void MCExpr::print(raw_ostream &OS) const {
|
||||
else
|
||||
OS << Sym;
|
||||
|
||||
if (SRE.getKind() == MCSymbolRefExpr::VK_ARM_PLT)
|
||||
if (SRE.getKind() == MCSymbolRefExpr::VK_ARM_PLT ||
|
||||
SRE.getKind() == MCSymbolRefExpr::VK_ARM_TLSGD ||
|
||||
SRE.getKind() == MCSymbolRefExpr::VK_ARM_GOT ||
|
||||
SRE.getKind() == MCSymbolRefExpr::VK_ARM_GOTOFF ||
|
||||
SRE.getKind() == MCSymbolRefExpr::VK_ARM_TPOFF ||
|
||||
SRE.getKind() == MCSymbolRefExpr::VK_ARM_GOTTPOFF)
|
||||
OS << MCSymbolRefExpr::getVariantKindName(SRE.getKind());
|
||||
else if (SRE.getKind() != MCSymbolRefExpr::VK_None &&
|
||||
SRE.getKind() != MCSymbolRefExpr::VK_ARM_HI16 &&
|
||||
@ -185,6 +190,11 @@ StringRef MCSymbolRefExpr::getVariantKindName(VariantKind Kind) {
|
||||
case VK_ARM_HI16: return ":upper16:";
|
||||
case VK_ARM_LO16: return ":lower16:";
|
||||
case VK_ARM_PLT: return "(PLT)";
|
||||
case VK_ARM_GOT: return "(GOT)";
|
||||
case VK_ARM_GOTOFF: return "(GOTOFF)";
|
||||
case VK_ARM_TPOFF: return "(tpoff)";
|
||||
case VK_ARM_GOTTPOFF: return "(gottpoff)";
|
||||
case VK_ARM_TLSGD: return "(tldgd)";
|
||||
case VK_TLVP: return "TLVP";
|
||||
}
|
||||
}
|
||||
|
@ -603,6 +603,20 @@ static MCSymbol *getPICLabel(const char *Prefix, unsigned FunctionNumber,
|
||||
return Label;
|
||||
}
|
||||
|
||||
static MCSymbolRefExpr::VariantKind
|
||||
getModifierVariantKind(ARMCP::ARMCPModifier Modifier) {
|
||||
switch (Modifier) {
|
||||
default: llvm_unreachable("Unknown modifier!");
|
||||
case ARMCP::no_modifier: return MCSymbolRefExpr::VK_None;
|
||||
case ARMCP::TLSGD: return MCSymbolRefExpr::VK_ARM_TLSGD;
|
||||
case ARMCP::TPOFF: return MCSymbolRefExpr::VK_ARM_TPOFF;
|
||||
case ARMCP::GOTTPOFF: return MCSymbolRefExpr::VK_ARM_GOTTPOFF;
|
||||
case ARMCP::GOT: return MCSymbolRefExpr::VK_ARM_GOT;
|
||||
case ARMCP::GOTOFF: return MCSymbolRefExpr::VK_ARM_GOTOFF;
|
||||
}
|
||||
return MCSymbolRefExpr::VK_None;
|
||||
}
|
||||
|
||||
void ARMAsmPrinter::
|
||||
EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
|
||||
int Size = TM.getTargetData()->getTypeAllocSize(MCPV->getType());
|
||||
@ -642,32 +656,10 @@ EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
|
||||
|
||||
// Create an MCSymbol for the reference.
|
||||
MCSymbol *MCSym = OutContext.GetOrCreateSymbol(OS.str());
|
||||
const MCExpr *Expr = MCSymbolRefExpr::Create(MCSym, OutContext);
|
||||
const MCExpr *Expr =
|
||||
MCSymbolRefExpr::Create(MCSym, getModifierVariantKind(ACPV->getModifier()),
|
||||
OutContext);
|
||||
|
||||
// FIXME: Model the whole expression an an MCExpr and we can get rid
|
||||
// of this hasRawTextSupport() clause and just do an EmitValue().
|
||||
if (OutStreamer.hasRawTextSupport()) {
|
||||
if (ACPV->hasModifier()) OS << "(" << ACPV->getModifierText() << ")";
|
||||
if (ACPV->getPCAdjustment() != 0) {
|
||||
OS << "-(" << MAI->getPrivateGlobalPrefix() << "PC"
|
||||
<< getFunctionNumber() << "_" << ACPV->getLabelId()
|
||||
<< "+" << (unsigned)ACPV->getPCAdjustment();
|
||||
if (ACPV->mustAddCurrentAddress())
|
||||
OS << "-.";
|
||||
OS << ')';
|
||||
}
|
||||
const char *DataDirective = 0;
|
||||
switch (Size) {
|
||||
case 1: DataDirective = MAI->getData8bitsDirective(0); break;
|
||||
case 2: DataDirective = MAI->getData16bitsDirective(0); break;
|
||||
case 4: DataDirective = MAI->getData32bitsDirective(0); break;
|
||||
default: assert(0 && "Unknown CPV size");
|
||||
}
|
||||
Twine Text(DataDirective, OS.str());
|
||||
OutStreamer.EmitRawText(Text);
|
||||
} else {
|
||||
assert(!ACPV->hasModifier() &&
|
||||
"ARM binary streamer of non-trivial constant pool value!");
|
||||
if (ACPV->getPCAdjustment()) {
|
||||
MCSymbol *PCLabel = getPICLabel(MAI->getPrivateGlobalPrefix(),
|
||||
getFunctionNumber(),
|
||||
@ -685,13 +677,12 @@ EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV) {
|
||||
MCSymbol *DotSym = OutContext.CreateTempSymbol();
|
||||
OutStreamer.EmitLabel(DotSym);
|
||||
const MCExpr *DotExpr = MCSymbolRefExpr::Create(DotSym, OutContext);
|
||||
Expr = MCBinaryExpr::CreateSub(Expr, DotExpr, OutContext);
|
||||
PCRelExpr = MCBinaryExpr::CreateSub(PCRelExpr, DotExpr, OutContext);
|
||||
}
|
||||
Expr = MCBinaryExpr::CreateSub(Expr, PCRelExpr, OutContext);
|
||||
}
|
||||
OutStreamer.EmitValue(Expr, Size);
|
||||
}
|
||||
}
|
||||
|
||||
void ARMAsmPrinter::EmitJumpTable(const MachineInstr *MI) {
|
||||
unsigned Opcode = MI->getOpcode();
|
||||
|
Loading…
Reference in New Issue
Block a user