switch ELF @GOTOFF references to use X86MCTargetExpr.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95593 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2010-02-08 22:33:55 +00:00
parent 54e72eca0c
commit 017ec35e28
5 changed files with 16 additions and 12 deletions

View File

@ -14,8 +14,9 @@
#include "X86MCInstLower.h" #include "X86MCInstLower.h"
#include "X86AsmPrinter.h" #include "X86AsmPrinter.h"
#include "X86MCAsmInfo.h"
#include "X86COFFMachineModuleInfo.h" #include "X86COFFMachineModuleInfo.h"
#include "X86MCAsmInfo.h"
#include "X86MCTargetExpr.h"
#include "llvm/Analysis/DebugInfo.h" #include "llvm/Analysis/DebugInfo.h"
#include "llvm/CodeGen/MachineModuleInfoImpls.h" #include "llvm/CodeGen/MachineModuleInfoImpls.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
@ -67,6 +68,8 @@ GetGlobalAddressSymbol(const MachineOperand &MO) const {
COFFMMI.DecorateCygMingName(Name, GV, *AsmPrinter.TM.getTargetData()); COFFMMI.DecorateCygMingName(Name, GV, *AsmPrinter.TM.getTargetData());
} }
//X86MCTargetExpr::VariantKind Kind = X86MCTargetExpr::Invalid;
switch (MO.getTargetFlags()) { switch (MO.getTargetFlags()) {
default: llvm_unreachable("Unknown target flag on GV operand"); default: llvm_unreachable("Unknown target flag on GV operand");
case X86II::MO_NO_FLAG: // No flag. case X86II::MO_NO_FLAG: // No flag.
@ -115,7 +118,7 @@ GetGlobalAddressSymbol(const MachineOperand &MO) const {
case X86II::MO_GOTOFF: Name += "@GOTOFF"; break; case X86II::MO_GOTOFF: Name += "@GOTOFF"; break;
case X86II::MO_PLT: Name += "@PLT"; break; case X86II::MO_PLT: Name += "@PLT"; break;
} }
return Ctx.GetOrCreateSymbol(Name.str()); return Ctx.GetOrCreateSymbol(Name.str());
} }

View File

@ -16,6 +16,7 @@
#include "X86.h" #include "X86.h"
#include "X86InstrBuilder.h" #include "X86InstrBuilder.h"
#include "X86ISelLowering.h" #include "X86ISelLowering.h"
#include "X86MCTargetExpr.h"
#include "X86TargetMachine.h" #include "X86TargetMachine.h"
#include "X86TargetObjectFile.h" #include "X86TargetObjectFile.h"
#include "llvm/CallingConv.h" #include "llvm/CallingConv.h"
@ -36,7 +37,6 @@
#include "llvm/CodeGen/PseudoSourceValue.h" #include "llvm/CodeGen/PseudoSourceValue.h"
#include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCAsmInfo.h"
#include "llvm/MC/MCContext.h" #include "llvm/MC/MCContext.h"
#include "llvm/MC/MCExpr.h"
#include "llvm/MC/MCSymbol.h" #include "llvm/MC/MCSymbol.h"
#include "llvm/ADT/BitVector.h" #include "llvm/ADT/BitVector.h"
#include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallSet.h"
@ -1130,10 +1130,8 @@ X86TargetLowering::LowerCustomJumpTableEntry(const MachineJumpTableInfo *MJTI,
Subtarget->isPICStyleGOT()); Subtarget->isPICStyleGOT());
// In 32-bit ELF systems, our jump table entries are formed with @GOTOFF // In 32-bit ELF systems, our jump table entries are formed with @GOTOFF
// entries. // entries.
return X86MCTargetExpr::Create(MBB->getSymbol(Ctx),
// FIXME: @GOTOFF should be a property of MCSymbolRefExpr not in the MCSymbol. X86MCTargetExpr::GOTOFF, Ctx);
std::string Name = MBB->getSymbol(Ctx)->getName() + "@GOTOFF";
return MCSymbolRefExpr::Create(Ctx.GetOrCreateSymbol(StringRef(Name)), Ctx);
} }
/// getPICJumpTableRelocaBase - Returns relocation base for the given PIC /// getPICJumpTableRelocaBase - Returns relocation base for the given PIC

View File

@ -23,9 +23,11 @@ void X86MCTargetExpr::PrintImpl(raw_ostream &OS) const {
OS << *Sym; OS << *Sym;
switch (Kind) { switch (Kind) {
case GOT: OS << "@GOT"; break; case Invalid: OS << "@<invalid>"; break;
case PLT: OS << "@PLT"; break; case GOT: OS << "@GOT"; break;
case PLT: OS << "@PLT"; break;
case GOTPCREL: OS << "@GOTPCREL"; break; case GOTPCREL: OS << "@GOTPCREL"; break;
case GOTOFF: OS << "@GOTOFF"; break;
} }
} }
@ -39,5 +41,3 @@ bool X86MCTargetExpr::EvaluateAsRelocatableImpl(MCValue &Res) const {
Res = MCValue::get(Sym, 0, 0); Res = MCValue::get(Sym, 0, 0);
return true; return true;
} }
X86MCTargetExpr *foo(MCExpr *A) { return (X86MCTargetExpr*)A; }

View File

@ -18,9 +18,11 @@ namespace llvm {
class X86MCTargetExpr : public MCTargetExpr { class X86MCTargetExpr : public MCTargetExpr {
public: public:
enum VariantKind { enum VariantKind {
Invalid,
GOT, GOT,
PLT, PLT,
GOTPCREL GOTPCREL,
GOTOFF
}; };
private: private:
/// Sym - The symbol being referenced. /// Sym - The symbol being referenced.

View File

@ -55,6 +55,7 @@ getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang,
IsIndirect = true; IsIndirect = true;
IsPCRel = true; IsPCRel = true;
// FIXME: Use GetSymbolWithGlobalValueBase.
SmallString<128> Name; SmallString<128> Name;
Mang->getNameWithPrefix(Name, GV, false); Mang->getNameWithPrefix(Name, GV, false);
const MCSymbol *Sym = getContext().CreateSymbol(Name); const MCSymbol *Sym = getContext().CreateSymbol(Name);