[llvm-commits] [llvm] r142934 - in /llvm/trunk: include/llvm/MC/MCExpr.h lib/MC/MCELFStreamer.cpp lib/MC/MCExpr.cpp
Bruno Cardoso Lopes
bruno.cardoso at gmail.com
Tue Oct 25 11:13:21 PDT 2011
Author: bruno
Date: Tue Oct 25 13:13:20 2011
New Revision: 142934
URL: http://llvm.org/viewvc/llvm-project?rev=142934&view=rev
Log:
This is the first of several patches for Mips direct object generation.
This first patch is for expression variable kinds.
Patch by Jack Carter!
Modified:
llvm/trunk/include/llvm/MC/MCExpr.h
llvm/trunk/lib/MC/MCELFStreamer.cpp
llvm/trunk/lib/MC/MCExpr.cpp
Modified: llvm/trunk/include/llvm/MC/MCExpr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCExpr.h?rev=142934&r1=142933&r2=142934&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCExpr.h (original)
+++ llvm/trunk/include/llvm/MC/MCExpr.h Tue Oct 25 13:13:20 2011
@@ -174,7 +174,23 @@
VK_PPC_DARWIN_HA16, // ha16(symbol)
VK_PPC_DARWIN_LO16, // lo16(symbol)
VK_PPC_GAS_HA16, // symbol at ha
- VK_PPC_GAS_LO16 // symbol at l
+ VK_PPC_GAS_LO16, // symbol at l
+
+ VK_Mips_None,
+ VK_Mips_GPREL,
+ VK_Mips_GOT_CALL,
+ VK_Mips_GOT,
+ VK_Mips_ABS_HI,
+ VK_Mips_ABS_LO,
+ VK_Mips_TLSGD,
+ VK_Mips_GOTTPREL,
+ VK_Mips_TPREL_HI,
+ VK_Mips_TPREL_LO,
+ VK_Mips_GPOFF_HI,
+ VK_Mips_GPOFF_LO,
+ VK_Mips_GOT_DISP,
+ VK_Mips_GOT_PAGE,
+ VK_Mips_GOT_OFST
};
private:
Modified: llvm/trunk/lib/MC/MCELFStreamer.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCELFStreamer.cpp?rev=142934&r1=142933&r2=142934&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCELFStreamer.cpp (original)
+++ llvm/trunk/lib/MC/MCELFStreamer.cpp Tue Oct 25 13:13:20 2011
@@ -308,6 +308,10 @@
case MCSymbolRefExpr::VK_ARM_TLSGD:
case MCSymbolRefExpr::VK_ARM_TPOFF:
case MCSymbolRefExpr::VK_ARM_GOTTPOFF:
+ case MCSymbolRefExpr::VK_Mips_TLSGD:
+ case MCSymbolRefExpr::VK_Mips_GOTTPREL:
+ case MCSymbolRefExpr::VK_Mips_TPREL_HI:
+ case MCSymbolRefExpr::VK_Mips_TPREL_LO:
break;
}
MCSymbolData &SD = getAssembler().getOrCreateSymbolData(symRef.getSymbol());
Modified: llvm/trunk/lib/MC/MCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=142934&r1=142933&r2=142934&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCExpr.cpp (original)
+++ llvm/trunk/lib/MC/MCExpr.cpp Tue Oct 25 13:13:20 2011
@@ -26,6 +26,38 @@
}
}
+static bool printMipsSymbolRef(const MCSymbolRefExpr &SRE,
+ const MCSymbol &Sym, raw_ostream &OS) {
+ MCSymbolRefExpr::VariantKind Kind= SRE.getKind();
+
+ switch (Kind) {
+ default:
+ return false;
+ case MCSymbolRefExpr::VK_Mips_None: break;
+ case MCSymbolRefExpr::VK_Mips_GPREL: OS << "%gp_rel("; break;
+ case MCSymbolRefExpr::VK_Mips_GOT_CALL: OS << "%call16("; break;
+ case MCSymbolRefExpr::VK_Mips_GOT: OS << "%got("; break;
+ case MCSymbolRefExpr::VK_Mips_ABS_HI: OS << "%hi("; break;
+ case MCSymbolRefExpr::VK_Mips_ABS_LO: OS << "%lo("; break;
+ case MCSymbolRefExpr::VK_Mips_TLSGD: OS << "%tlsgd("; break;
+ case MCSymbolRefExpr::VK_Mips_GOTTPREL: OS << "%gottprel("; break;
+ case MCSymbolRefExpr::VK_Mips_TPREL_HI: OS << "%tprel_hi("; break;
+ case MCSymbolRefExpr::VK_Mips_TPREL_LO: OS << "%tprel_lo("; break;
+ case MCSymbolRefExpr::VK_Mips_GPOFF_HI: OS << "%hi(%neg(%gp_rel("; break;
+ case MCSymbolRefExpr::VK_Mips_GPOFF_LO: OS << "%lo(%neg(%gp_rel("; break;
+ case MCSymbolRefExpr::VK_Mips_GOT_DISP: OS << "%got_disp("; break;
+ case MCSymbolRefExpr::VK_Mips_GOT_PAGE: OS << "%got_page("; break;
+ case MCSymbolRefExpr::VK_Mips_GOT_OFST: OS << "%got_ofst("; break;
+ }
+
+ OS << Sym;
+
+ if (Kind != MCSymbolRefExpr::VK_Mips_None)
+ OS << ')';
+
+ return true;
+}
+
void MCExpr::print(raw_ostream &OS) const {
switch (getKind()) {
case MCExpr::Target:
@@ -41,6 +73,9 @@
// absolute names.
bool UseParens = Sym.getName()[0] == '$';
+ if (printMipsSymbolRef(SRE, Sym, OS))
+ return;
+
if (SRE.getKind() == MCSymbolRefExpr::VK_PPC_DARWIN_HA16 ||
SRE.getKind() == MCSymbolRefExpr::VK_PPC_DARWIN_LO16) {
OS << MCSymbolRefExpr::getVariantKindName(SRE.getKind());
More information about the llvm-commits
mailing list