summaryrefslogtreecommitdiff
path: root/lib/MC/MCExpr.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-11-15 02:46:57 +0000
committerChris Lattner <sabre@nondot.org>2010-11-15 02:46:57 +0000
commit1e61e69d401045c54b15815f15a0fdb3ca56a9b5 (patch)
treeece661c4c7b88ccde11f44e0ef5de5c1b1bdd82d /lib/MC/MCExpr.cpp
parentdd57417c08d3fbb52935b70cf14edef34535d045 (diff)
downloadllvm-1e61e69d401045c54b15815f15a0fdb3ca56a9b5.tar.gz
llvm-1e61e69d401045c54b15815f15a0fdb3ca56a9b5.tar.bz2
llvm-1e61e69d401045c54b15815f15a0fdb3ca56a9b5.tar.xz
add targetoperand flags for jump tables, constant pool and block address
nodes to indicate when ha16/lo16 modifiers should be used. This lets us pass PowerPC/indirectbr.ll. The one annoying thing about this patch is that the MCSymbolExpr isn't expressive enough to represent ha16(label1-label2) which we need on PowerPC. I have a terrible hack in the meantime, but this will have to be revisited at some point. Last major conversion item left is global variable references. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119105 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/MC/MCExpr.cpp')
-rw-r--r--lib/MC/MCExpr.cpp19
1 files changed, 15 insertions, 4 deletions
diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp
index e6f2a8f790..b1617ecc5e 100644
--- a/lib/MC/MCExpr.cpp
+++ b/lib/MC/MCExpr.cpp
@@ -39,14 +39,21 @@ void MCExpr::print(raw_ostream &OS) const {
case MCExpr::SymbolRef: {
const MCSymbolRefExpr &SRE = cast<MCSymbolRefExpr>(*this);
const MCSymbol &Sym = SRE.getSymbol();
+ // Parenthesize names that start with $ so that they don't look like
+ // absolute names.
+ bool UseParens = Sym.getName()[0] == '$';
if (SRE.getKind() == MCSymbolRefExpr::VK_ARM_HI16 ||
SRE.getKind() == MCSymbolRefExpr::VK_ARM_LO16)
OS << MCSymbolRefExpr::getVariantKindName(SRE.getKind());
- // Parenthesize names that start with $ so that they don't look like
- // absolute names.
- if (Sym.getName()[0] == '$')
+ if (SRE.getKind() == MCSymbolRefExpr::VK_PPC_HA16 ||
+ SRE.getKind() == MCSymbolRefExpr::VK_PPC_LO16) {
+ OS << MCSymbolRefExpr::getVariantKindName(SRE.getKind());
+ UseParens = true;
+ }
+
+ if (UseParens)
OS << '(' << Sym << ')';
else
OS << Sym;
@@ -60,7 +67,9 @@ void MCExpr::print(raw_ostream &OS) const {
OS << MCSymbolRefExpr::getVariantKindName(SRE.getKind());
else if (SRE.getKind() != MCSymbolRefExpr::VK_None &&
SRE.getKind() != MCSymbolRefExpr::VK_ARM_HI16 &&
- SRE.getKind() != MCSymbolRefExpr::VK_ARM_LO16)
+ SRE.getKind() != MCSymbolRefExpr::VK_ARM_LO16 &&
+ SRE.getKind() != MCSymbolRefExpr::VK_PPC_HA16 &&
+ SRE.getKind() != MCSymbolRefExpr::VK_PPC_LO16)
OS << '@' << MCSymbolRefExpr::getVariantKindName(SRE.getKind());
return;
@@ -197,6 +206,8 @@ StringRef MCSymbolRefExpr::getVariantKindName(VariantKind Kind) {
case VK_ARM_GOTTPOFF: return "(gottpoff)";
case VK_ARM_TLSGD: return "(tldgd)";
case VK_PPC_TOC: return "toc";
+ case VK_PPC_HA16: return "ha16";
+ case VK_PPC_LO16: return "lo16";
}
}