From 017ec35e28d9960e5398102eceffe9a652703119 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 8 Feb 2010 22:33:55 +0000 Subject: [PATCH] switch ELF @GOTOFF references to use X86MCTargetExpr. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@95593 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/X86/AsmPrinter/X86MCInstLower.cpp | 7 +++++-- lib/Target/X86/X86ISelLowering.cpp | 8 +++----- lib/Target/X86/X86MCTargetExpr.cpp | 8 ++++---- lib/Target/X86/X86MCTargetExpr.h | 4 +++- lib/Target/X86/X86TargetObjectFile.cpp | 1 + 5 files changed, 16 insertions(+), 12 deletions(-) diff --git a/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp b/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp index 4f09699ef67..c9a96794285 100644 --- a/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp +++ b/lib/Target/X86/AsmPrinter/X86MCInstLower.cpp @@ -14,8 +14,9 @@ #include "X86MCInstLower.h" #include "X86AsmPrinter.h" -#include "X86MCAsmInfo.h" #include "X86COFFMachineModuleInfo.h" +#include "X86MCAsmInfo.h" +#include "X86MCTargetExpr.h" #include "llvm/Analysis/DebugInfo.h" #include "llvm/CodeGen/MachineModuleInfoImpls.h" #include "llvm/MC/MCContext.h" @@ -67,6 +68,8 @@ GetGlobalAddressSymbol(const MachineOperand &MO) const { 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. @@ -115,7 +118,7 @@ GetGlobalAddressSymbol(const MachineOperand &MO) const { case X86II::MO_GOTOFF: Name += "@GOTOFF"; break; case X86II::MO_PLT: Name += "@PLT"; break; } - + return Ctx.GetOrCreateSymbol(Name.str()); } diff --git a/lib/Target/X86/X86ISelLowering.cpp b/lib/Target/X86/X86ISelLowering.cpp index 331bac695d0..9061337fd54 100644 --- a/lib/Target/X86/X86ISelLowering.cpp +++ b/lib/Target/X86/X86ISelLowering.cpp @@ -16,6 +16,7 @@ #include "X86.h" #include "X86InstrBuilder.h" #include "X86ISelLowering.h" +#include "X86MCTargetExpr.h" #include "X86TargetMachine.h" #include "X86TargetObjectFile.h" #include "llvm/CallingConv.h" @@ -36,7 +37,6 @@ #include "llvm/CodeGen/PseudoSourceValue.h" #include "llvm/MC/MCAsmInfo.h" #include "llvm/MC/MCContext.h" -#include "llvm/MC/MCExpr.h" #include "llvm/MC/MCSymbol.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/SmallSet.h" @@ -1130,10 +1130,8 @@ X86TargetLowering::LowerCustomJumpTableEntry(const MachineJumpTableInfo *MJTI, Subtarget->isPICStyleGOT()); // In 32-bit ELF systems, our jump table entries are formed with @GOTOFF // entries. - - // FIXME: @GOTOFF should be a property of MCSymbolRefExpr not in the MCSymbol. - std::string Name = MBB->getSymbol(Ctx)->getName() + "@GOTOFF"; - return MCSymbolRefExpr::Create(Ctx.GetOrCreateSymbol(StringRef(Name)), Ctx); + return X86MCTargetExpr::Create(MBB->getSymbol(Ctx), + X86MCTargetExpr::GOTOFF, Ctx); } /// getPICJumpTableRelocaBase - Returns relocation base for the given PIC diff --git a/lib/Target/X86/X86MCTargetExpr.cpp b/lib/Target/X86/X86MCTargetExpr.cpp index 1b0d75a0b5a..d089150eaba 100644 --- a/lib/Target/X86/X86MCTargetExpr.cpp +++ b/lib/Target/X86/X86MCTargetExpr.cpp @@ -23,9 +23,11 @@ void X86MCTargetExpr::PrintImpl(raw_ostream &OS) const { OS << *Sym; switch (Kind) { - case GOT: OS << "@GOT"; break; - case PLT: OS << "@PLT"; break; + case Invalid: OS << "@"; break; + case GOT: OS << "@GOT"; break; + case PLT: OS << "@PLT"; 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); return true; } - -X86MCTargetExpr *foo(MCExpr *A) { return (X86MCTargetExpr*)A; } \ No newline at end of file diff --git a/lib/Target/X86/X86MCTargetExpr.h b/lib/Target/X86/X86MCTargetExpr.h index b6d22bb690c..690f56beec8 100644 --- a/lib/Target/X86/X86MCTargetExpr.h +++ b/lib/Target/X86/X86MCTargetExpr.h @@ -18,9 +18,11 @@ namespace llvm { class X86MCTargetExpr : public MCTargetExpr { public: enum VariantKind { + Invalid, GOT, PLT, - GOTPCREL + GOTPCREL, + GOTOFF }; private: /// Sym - The symbol being referenced. diff --git a/lib/Target/X86/X86TargetObjectFile.cpp b/lib/Target/X86/X86TargetObjectFile.cpp index 9b7d5d23881..b8cef7def23 100644 --- a/lib/Target/X86/X86TargetObjectFile.cpp +++ b/lib/Target/X86/X86TargetObjectFile.cpp @@ -55,6 +55,7 @@ getSymbolForDwarfGlobalReference(const GlobalValue *GV, Mangler *Mang, IsIndirect = true; IsPCRel = true; + // FIXME: Use GetSymbolWithGlobalValueBase. SmallString<128> Name; Mang->getNameWithPrefix(Name, GV, false); const MCSymbol *Sym = getContext().CreateSymbol(Name);