[llvm-commits] [llvm] r95595 - in /llvm/trunk/lib/Target/X86: AsmPrinter/X86MCInstLower.cpp AsmPrinter/X86MCInstLower.h X86MCTargetExpr.cpp X86MCTargetExpr.h
Chris Lattner
sabre at nondot.org
Mon Feb 8 14:52:48 PST 2010
Author: lattner
Date: Mon Feb 8 16:52:47 2010
New Revision: 95595
URL: http://llvm.org/viewvc/llvm-project?rev=95595&view=rev
Log:
switch the rest of the "@ concatentation" logic in the X86
backend to use X86MCTargetExpr, simplifying a bunch of code.
Modified:
llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.h
llvm/trunk/lib/Target/X86/X86MCTargetExpr.cpp
llvm/trunk/lib/Target/X86/X86MCTargetExpr.h
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp?rev=95595&r1=95594&r2=95595&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp Mon Feb 8 16:52:47 2010
@@ -68,12 +68,19 @@
COFFMMI.DecorateCygMingName(Name, GV, *AsmPrinter.TM.getTargetData());
}
- //X86MCTargetExpr::VariantKind Kind = X86MCTargetExpr::Invalid;
-
switch (MO.getTargetFlags()) {
default: llvm_unreachable("Unknown target flag on GV operand");
- case X86II::MO_NO_FLAG: // No flag.
- case X86II::MO_PIC_BASE_OFFSET: // Doesn't modify symbol name.
+ case X86II::MO_NO_FLAG: // These don't modify the symbol name.
+ case X86II::MO_PIC_BASE_OFFSET:
+ case X86II::MO_TLSGD:
+ case X86II::MO_GOTTPOFF:
+ case X86II::MO_INDNTPOFF:
+ case X86II::MO_TPOFF:
+ case X86II::MO_NTPOFF:
+ case X86II::MO_GOTPCREL:
+ case X86II::MO_GOT:
+ case X86II::MO_GOTOFF:
+ case X86II::MO_PLT:
break;
case X86II::MO_DLLIMPORT: {
// Handle dllimport linkage.
@@ -107,16 +114,6 @@
StubSym = AsmPrinter.GetGlobalValueSymbol(GV);
return Sym;
}
- // FIXME: These probably should be a modifier on the symbol or something??
- case X86II::MO_TLSGD: Name += "@TLSGD"; break;
- case X86II::MO_GOTTPOFF: Name += "@GOTTPOFF"; break;
- case X86II::MO_INDNTPOFF: Name += "@INDNTPOFF"; break;
- case X86II::MO_TPOFF: Name += "@TPOFF"; break;
- case X86II::MO_NTPOFF: Name += "@NTPOFF"; break;
- case X86II::MO_GOTPCREL: Name += "@GOTPCREL"; break;
- case X86II::MO_GOT: Name += "@GOT"; break;
- case X86II::MO_GOTOFF: Name += "@GOTOFF"; break;
- case X86II::MO_PLT: Name += "@PLT"; break;
}
return Ctx.GetOrCreateSymbol(Name.str());
@@ -130,9 +127,18 @@
switch (MO.getTargetFlags()) {
default: llvm_unreachable("Unknown target flag on GV operand");
- case X86II::MO_NO_FLAG: // No flag.
+ case X86II::MO_NO_FLAG: // These don't modify the symbol name.
case X86II::MO_GOT_ABSOLUTE_ADDRESS: // Doesn't modify symbol name.
- case X86II::MO_PIC_BASE_OFFSET: // Doesn't modify symbol name.
+ case X86II::MO_PIC_BASE_OFFSET:
+ case X86II::MO_TLSGD:
+ case X86II::MO_GOTTPOFF:
+ case X86II::MO_INDNTPOFF:
+ case X86II::MO_TPOFF:
+ case X86II::MO_NTPOFF:
+ case X86II::MO_GOTPCREL:
+ case X86II::MO_GOT:
+ case X86II::MO_GOTOFF:
+ case X86II::MO_PLT:
break;
case X86II::MO_DLLIMPORT: {
// Handle dllimport linkage.
@@ -151,125 +157,40 @@
}
return Sym;
}
- // FIXME: These probably should be a modifier on the symbol or something??
- case X86II::MO_TLSGD: Name += "@TLSGD"; break;
- case X86II::MO_GOTTPOFF: Name += "@GOTTPOFF"; break;
- case X86II::MO_INDNTPOFF: Name += "@INDNTPOFF"; break;
- case X86II::MO_TPOFF: Name += "@TPOFF"; break;
- case X86II::MO_NTPOFF: Name += "@NTPOFF"; break;
- case X86II::MO_GOTPCREL: Name += "@GOTPCREL"; break;
- case X86II::MO_GOT: Name += "@GOT"; break;
- case X86II::MO_GOTOFF: Name += "@GOTOFF"; break;
- case X86II::MO_PLT: Name += "@PLT"; break;
- }
-
- return Ctx.GetOrCreateSymbol(Name.str());
-}
-
-MCSymbol *X86MCInstLower::GetJumpTableSymbol(const MachineOperand &MO) const {
- SmallString<256> Name;
- // FIXME: Use AsmPrinter.GetJTISymbol. @TLSGD shouldn't be part of the symbol
- // name!
- raw_svector_ostream(Name) << AsmPrinter.MAI->getPrivateGlobalPrefix() << "JTI"
- << AsmPrinter.getFunctionNumber() << '_' << MO.getIndex();
-
- switch (MO.getTargetFlags()) {
- default:
- llvm_unreachable("Unknown target flag on GV operand");
- case X86II::MO_NO_FLAG: // No flag.
- case X86II::MO_PIC_BASE_OFFSET:
- case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
- case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE:
- break;
- // FIXME: These probably should be a modifier on the symbol or something??
- case X86II::MO_TLSGD: Name += "@TLSGD"; break;
- case X86II::MO_GOTTPOFF: Name += "@GOTTPOFF"; break;
- case X86II::MO_INDNTPOFF: Name += "@INDNTPOFF"; break;
- case X86II::MO_TPOFF: Name += "@TPOFF"; break;
- case X86II::MO_NTPOFF: Name += "@NTPOFF"; break;
- case X86II::MO_GOTPCREL: Name += "@GOTPCREL"; break;
- case X86II::MO_GOT: Name += "@GOT"; break;
- case X86II::MO_GOTOFF: Name += "@GOTOFF"; break;
- case X86II::MO_PLT: Name += "@PLT"; break;
- }
-
- // Create a symbol for the name.
- return Ctx.GetOrCreateSymbol(Name.str());
-}
-
-
-MCSymbol *X86MCInstLower::
-GetConstantPoolIndexSymbol(const MachineOperand &MO) const {
- SmallString<256> Name;
- // FIXME: USe AsmPrinter.GetCPISymbol. @TLSGD shouldn't be part of the symbol
- // name!
- raw_svector_ostream(Name) << AsmPrinter.MAI->getPrivateGlobalPrefix() << "CPI"
- << AsmPrinter.getFunctionNumber() << '_' << MO.getIndex();
-
- switch (MO.getTargetFlags()) {
- default:
- llvm_unreachable("Unknown target flag on GV operand");
- case X86II::MO_NO_FLAG: // No flag.
- case X86II::MO_PIC_BASE_OFFSET:
- case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
- case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE:
- break;
- // FIXME: These probably should be a modifier on the symbol or something??
- case X86II::MO_TLSGD: Name += "@TLSGD"; break;
- case X86II::MO_GOTTPOFF: Name += "@GOTTPOFF"; break;
- case X86II::MO_INDNTPOFF: Name += "@INDNTPOFF"; break;
- case X86II::MO_TPOFF: Name += "@TPOFF"; break;
- case X86II::MO_NTPOFF: Name += "@NTPOFF"; break;
- case X86II::MO_GOTPCREL: Name += "@GOTPCREL"; break;
- case X86II::MO_GOT: Name += "@GOT"; break;
- case X86II::MO_GOTOFF: Name += "@GOTOFF"; break;
- case X86II::MO_PLT: Name += "@PLT"; break;
}
- // Create a symbol for the name.
return Ctx.GetOrCreateSymbol(Name.str());
}
-MCSymbol *X86MCInstLower::
-GetBlockAddressSymbol(const MachineOperand &MO) const {
- const char *Suffix = "";
- switch (MO.getTargetFlags()) {
- default: llvm_unreachable("Unknown target flag on BA operand");
- case X86II::MO_NO_FLAG: break; // No flag.
- case X86II::MO_PIC_BASE_OFFSET: break; // Doesn't modify symbol name.
- case X86II::MO_GOTOFF: Suffix = "@GOTOFF"; break;
- }
-
- return AsmPrinter.GetBlockAddressSymbol(MO.getBlockAddress(), Suffix);
-}
-
MCOperand X86MCInstLower::LowerSymbolOperand(const MachineOperand &MO,
MCSymbol *Sym) const {
// FIXME: We would like an efficient form for this, so we don't have to do a
// lot of extra uniquing.
- const MCExpr *Expr = MCSymbolRefExpr::Create(Sym, Ctx);
+ const MCExpr *Expr = 0;
+ X86MCTargetExpr::VariantKind RefKind = X86MCTargetExpr::Invalid;
switch (MO.getTargetFlags()) {
default: llvm_unreachable("Unknown target flag on GV operand");
case X86II::MO_NO_FLAG: // No flag.
-
// These affect the name of the symbol, not any suffix.
case X86II::MO_DARWIN_NONLAZY:
case X86II::MO_DLLIMPORT:
case X86II::MO_DARWIN_STUB:
- case X86II::MO_TLSGD:
- case X86II::MO_GOTTPOFF:
- case X86II::MO_INDNTPOFF:
- case X86II::MO_TPOFF:
- case X86II::MO_NTPOFF:
- case X86II::MO_GOTPCREL:
- case X86II::MO_GOT:
- case X86II::MO_GOTOFF:
- case X86II::MO_PLT:
break;
+
+ case X86II::MO_TLSGD: RefKind = X86MCTargetExpr::TLSGD; break;
+ case X86II::MO_GOTTPOFF: RefKind = X86MCTargetExpr::GOTTPOFF; break;
+ case X86II::MO_INDNTPOFF: RefKind = X86MCTargetExpr::INDNTPOFF; break;
+ case X86II::MO_TPOFF: RefKind = X86MCTargetExpr::TPOFF; break;
+ case X86II::MO_NTPOFF: RefKind = X86MCTargetExpr::NTPOFF; break;
+ case X86II::MO_GOTPCREL: RefKind = X86MCTargetExpr::GOTPCREL; break;
+ case X86II::MO_GOT: RefKind = X86MCTargetExpr::GOT; break;
+ case X86II::MO_GOTOFF: RefKind = X86MCTargetExpr::GOTOFF; break;
+ case X86II::MO_PLT: RefKind = X86MCTargetExpr::PLT; break;
case X86II::MO_PIC_BASE_OFFSET:
case X86II::MO_DARWIN_NONLAZY_PIC_BASE:
case X86II::MO_DARWIN_HIDDEN_NONLAZY_PIC_BASE:
+ Expr = MCSymbolRefExpr::Create(Sym, Ctx);
// Subtract the pic base.
Expr = MCBinaryExpr::CreateSub(Expr,
MCSymbolRefExpr::Create(GetPICBaseSymbol(), Ctx),
@@ -277,6 +198,13 @@
break;
}
+ if (Expr == 0) {
+ if (RefKind == X86MCTargetExpr::Invalid)
+ Expr = MCSymbolRefExpr::Create(Sym, Ctx);
+ else
+ Expr = X86MCTargetExpr::Create(Sym, RefKind, Ctx);
+ }
+
if (!MO.isJTI() && MO.getOffset())
Expr = MCBinaryExpr::CreateAdd(Expr,
MCConstantExpr::Create(MO.getOffset(), Ctx),
@@ -348,13 +276,14 @@
MCOp = LowerSymbolOperand(MO, GetExternalSymbolSymbol(MO));
break;
case MachineOperand::MO_JumpTableIndex:
- MCOp = LowerSymbolOperand(MO, GetJumpTableSymbol(MO));
+ MCOp = LowerSymbolOperand(MO, AsmPrinter.GetJTISymbol(MO.getIndex()));
break;
case MachineOperand::MO_ConstantPoolIndex:
- MCOp = LowerSymbolOperand(MO, GetConstantPoolIndexSymbol(MO));
+ MCOp = LowerSymbolOperand(MO, AsmPrinter.GetCPISymbol(MO.getIndex()));
break;
case MachineOperand::MO_BlockAddress:
- MCOp = LowerSymbolOperand(MO, GetBlockAddressSymbol(MO));
+ MCOp = LowerSymbolOperand(MO,
+ AsmPrinter.GetBlockAddressSymbol(MO.getBlockAddress()));
break;
}
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.h?rev=95595&r1=95594&r2=95595&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.h (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86MCInstLower.h Mon Feb 8 16:52:47 2010
@@ -41,9 +41,6 @@
MCSymbol *GetGlobalAddressSymbol(const MachineOperand &MO) const;
MCSymbol *GetExternalSymbolSymbol(const MachineOperand &MO) const;
- MCSymbol *GetJumpTableSymbol(const MachineOperand &MO) const;
- MCSymbol *GetConstantPoolIndexSymbol(const MachineOperand &MO) const;
- MCSymbol *GetBlockAddressSymbol(const MachineOperand &MO) const;
MCOperand LowerSymbolOperand(const MachineOperand &MO, MCSymbol *Sym) const;
private:
Modified: llvm/trunk/lib/Target/X86/X86MCTargetExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCTargetExpr.cpp?rev=95595&r1=95594&r2=95595&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86MCTargetExpr.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86MCTargetExpr.cpp Mon Feb 8 16:52:47 2010
@@ -23,11 +23,16 @@
OS << *Sym;
switch (Kind) {
- case Invalid: OS << "@<invalid>"; break;
- case GOT: OS << "@GOT"; break;
- case PLT: OS << "@PLT"; break;
- case GOTPCREL: OS << "@GOTPCREL"; break;
- case GOTOFF: OS << "@GOTOFF"; break;
+ case Invalid: OS << "@<invalid>"; break;
+ case GOT: OS << "@GOT"; break;
+ case GOTOFF: OS << "@GOTOFF"; break;
+ case GOTPCREL: OS << "@GOTPCREL"; break;
+ case GOTTPOFF: OS << "@GOTTPOFF"; break;
+ case INDNTPOFF: OS << "@INDNTPOFF"; break;
+ case NTPOFF: OS << "@NTPOFF"; break;
+ case PLT: OS << "@PLT"; break;
+ case TLSGD: OS << "@TLSGD"; break;
+ case TPOFF: OS << "@TPOFF"; break;
}
}
Modified: llvm/trunk/lib/Target/X86/X86MCTargetExpr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86MCTargetExpr.h?rev=95595&r1=95594&r2=95595&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86MCTargetExpr.h (original)
+++ llvm/trunk/lib/Target/X86/X86MCTargetExpr.h Mon Feb 8 16:52:47 2010
@@ -20,9 +20,14 @@
enum VariantKind {
Invalid,
GOT,
- PLT,
+ GOTOFF,
GOTPCREL,
- GOTOFF
+ GOTTPOFF,
+ INDNTPOFF,
+ NTPOFF,
+ PLT,
+ TLSGD,
+ TPOFF
};
private:
/// Sym - The symbol being referenced.
More information about the llvm-commits
mailing list