[llvm] r184550 - [PowerPC] Support @higher et.al. modifiers
Ulrich Weigand
ulrich.weigand at de.ibm.com
Fri Jun 21 07:43:43 PDT 2013
Author: uweigand
Date: Fri Jun 21 09:43:42 2013
New Revision: 184550
URL: http://llvm.org/viewvc/llvm-project?rev=184550&view=rev
Log:
[PowerPC] Support @higher et.al. modifiers
This adds support for the @higher, @highera, @highest, and @highesta
modifers, including some missing relocation types.
Modified:
llvm/trunk/include/llvm/MC/MCExpr.h
llvm/trunk/include/llvm/Object/ELF.h
llvm/trunk/include/llvm/Support/ELF.h
llvm/trunk/lib/MC/MCExpr.cpp
llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp
llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h
llvm/trunk/test/MC/PowerPC/ppc64-fixup-apply.s
llvm/trunk/test/MC/PowerPC/ppc64-fixups.s
Modified: llvm/trunk/include/llvm/MC/MCExpr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCExpr.h?rev=184550&r1=184549&r2=184550&view=diff
==============================================================================
--- llvm/trunk/include/llvm/MC/MCExpr.h (original)
+++ llvm/trunk/include/llvm/MC/MCExpr.h Fri Jun 21 09:43:42 2013
@@ -174,6 +174,10 @@ public:
VK_PPC_LO, // symbol at l
VK_PPC_HI, // symbol at h
VK_PPC_HA, // symbol at ha
+ VK_PPC_HIGHER, // symbol at higher
+ VK_PPC_HIGHERA, // symbol at highera
+ VK_PPC_HIGHEST, // symbol at highest
+ VK_PPC_HIGHESTA, // symbol at highesta
VK_PPC_TOCBASE, // symbol at tocbase
VK_PPC_TOC, // symbol at toc
VK_PPC_TOC_LO, // symbol at toc@l
Modified: llvm/trunk/include/llvm/Object/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/ELF.h?rev=184550&r1=184549&r2=184550&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/ELF.h (original)
+++ llvm/trunk/include/llvm/Object/ELF.h Fri Jun 21 09:43:42 2013
@@ -2053,7 +2053,9 @@ StringRef ELFObjectFile<ELFT>::getReloca
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL32);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR64);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_HIGHER);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_HIGHERA);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_HIGHEST);
+ LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_ADDR16_HIGHESTA);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_REL64);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TOC16);
LLVM_ELF_SWITCH_RELOC_TYPE_NAME(R_PPC64_TOC16_LO);
Modified: llvm/trunk/include/llvm/Support/ELF.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Support/ELF.h?rev=184550&r1=184549&r2=184550&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Support/ELF.h (original)
+++ llvm/trunk/include/llvm/Support/ELF.h Fri Jun 21 09:43:42 2013
@@ -484,7 +484,9 @@ enum {
R_PPC64_REL32 = 26,
R_PPC64_ADDR64 = 38,
R_PPC64_ADDR16_HIGHER = 39,
+ R_PPC64_ADDR16_HIGHERA = 40,
R_PPC64_ADDR16_HIGHEST = 41,
+ R_PPC64_ADDR16_HIGHESTA = 42,
R_PPC64_REL64 = 44,
R_PPC64_TOC16 = 47,
R_PPC64_TOC16_LO = 48,
Modified: llvm/trunk/lib/MC/MCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=184550&r1=184549&r2=184550&view=diff
==============================================================================
--- llvm/trunk/lib/MC/MCExpr.cpp (original)
+++ llvm/trunk/lib/MC/MCExpr.cpp Fri Jun 21 09:43:42 2013
@@ -199,6 +199,10 @@ StringRef MCSymbolRefExpr::getVariantKin
case VK_PPC_LO: return "l";
case VK_PPC_HI: return "h";
case VK_PPC_HA: return "ha";
+ case VK_PPC_HIGHER: return "higher";
+ case VK_PPC_HIGHERA: return "highera";
+ case VK_PPC_HIGHEST: return "highest";
+ case VK_PPC_HIGHESTA: return "highesta";
case VK_PPC_TOCBASE: return "tocbase";
case VK_PPC_TOC: return "toc";
case VK_PPC_TOC_LO: return "toc at l";
@@ -287,6 +291,14 @@ MCSymbolRefExpr::getVariantKindForName(S
.Case("h", VK_PPC_HI)
.Case("HA", VK_PPC_HA)
.Case("ha", VK_PPC_HA)
+ .Case("HIGHER", VK_PPC_HIGHER)
+ .Case("higher", VK_PPC_HIGHER)
+ .Case("HIGHERA", VK_PPC_HIGHERA)
+ .Case("highera", VK_PPC_HIGHERA)
+ .Case("HIGHEST", VK_PPC_HIGHEST)
+ .Case("highest", VK_PPC_HIGHEST)
+ .Case("HIGHESTA", VK_PPC_HIGHESTA)
+ .Case("highesta", VK_PPC_HIGHESTA)
.Case("TOCBASE", VK_PPC_TOCBASE)
.Case("tocbase", VK_PPC_TOCBASE)
.Case("TOC", VK_PPC_TOC)
Modified: llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp?rev=184550&r1=184549&r2=184550&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/AsmParser/PPCAsmParser.cpp Fri Jun 21 09:43:42 2013
@@ -575,6 +575,18 @@ ExtractModifierFromExpr(const MCExpr *E,
case MCSymbolRefExpr::VK_PPC_HA:
Variant = PPCMCExpr::VK_PPC_HA;
break;
+ case MCSymbolRefExpr::VK_PPC_HIGHER:
+ Variant = PPCMCExpr::VK_PPC_HIGHER;
+ break;
+ case MCSymbolRefExpr::VK_PPC_HIGHERA:
+ Variant = PPCMCExpr::VK_PPC_HIGHERA;
+ break;
+ case MCSymbolRefExpr::VK_PPC_HIGHEST:
+ Variant = PPCMCExpr::VK_PPC_HIGHEST;
+ break;
+ case MCSymbolRefExpr::VK_PPC_HIGHESTA:
+ Variant = PPCMCExpr::VK_PPC_HIGHESTA;
+ break;
default:
return 0;
}
Modified: llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp?rev=184550&r1=184549&r2=184550&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCELFObjectWriter.cpp Fri Jun 21 09:43:42 2013
@@ -96,6 +96,18 @@ unsigned PPCELFObjectWriter::getRelocTyp
case MCSymbolRefExpr::VK_PPC_HA:
Type = ELF::R_PPC_ADDR16_HA;
break;
+ case MCSymbolRefExpr::VK_PPC_HIGHER:
+ Type = ELF::R_PPC64_ADDR16_HIGHER;
+ break;
+ case MCSymbolRefExpr::VK_PPC_HIGHERA:
+ Type = ELF::R_PPC64_ADDR16_HIGHERA;
+ break;
+ case MCSymbolRefExpr::VK_PPC_HIGHEST:
+ Type = ELF::R_PPC64_ADDR16_HIGHEST;
+ break;
+ case MCSymbolRefExpr::VK_PPC_HIGHESTA:
+ Type = ELF::R_PPC64_ADDR16_HIGHESTA;
+ break;
case MCSymbolRefExpr::VK_PPC_TOC:
Type = ELF::R_PPC64_TOC16;
break;
Modified: llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp?rev=184550&r1=184549&r2=184550&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp (original)
+++ llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.cpp Fri Jun 21 09:43:42 2013
@@ -42,6 +42,10 @@ void PPCMCExpr::PrintImpl(raw_ostream &O
case VK_PPC_LO: OS << "@l"; break;
case VK_PPC_HI: OS << "@h"; break;
case VK_PPC_HA: OS << "@ha"; break;
+ case VK_PPC_HIGHER: OS << "@higher"; break;
+ case VK_PPC_HIGHERA: OS << "@highera"; break;
+ case VK_PPC_HIGHEST: OS << "@highest"; break;
+ case VK_PPC_HIGHESTA: OS << "@highesta"; break;
}
}
}
@@ -66,7 +70,19 @@ PPCMCExpr::EvaluateAsRelocatableImpl(MCV
Result = (Result >> 16) & 0xffff;
break;
case VK_PPC_HA:
- Result = ((Result >> 16) + ((Result & 0x8000) ? 1 : 0)) & 0xffff;
+ Result = ((Result + 0x8000) >> 16) & 0xffff;
+ break;
+ case VK_PPC_HIGHER:
+ Result = (Result >> 32) & 0xffff;
+ break;
+ case VK_PPC_HIGHERA:
+ Result = ((Result + 0x8000) >> 32) & 0xffff;
+ break;
+ case VK_PPC_HIGHEST:
+ Result = (Result >> 48) & 0xffff;
+ break;
+ case VK_PPC_HIGHESTA:
+ Result = ((Result + 0x8000) >> 48) & 0xffff;
break;
}
Res = MCValue::get(Result);
@@ -88,6 +104,18 @@ PPCMCExpr::EvaluateAsRelocatableImpl(MCV
case VK_PPC_HA:
Modifier = MCSymbolRefExpr::VK_PPC_HA;
break;
+ case VK_PPC_HIGHERA:
+ Modifier = MCSymbolRefExpr::VK_PPC_HIGHERA;
+ break;
+ case VK_PPC_HIGHER:
+ Modifier = MCSymbolRefExpr::VK_PPC_HIGHER;
+ break;
+ case VK_PPC_HIGHEST:
+ Modifier = MCSymbolRefExpr::VK_PPC_HIGHEST;
+ break;
+ case VK_PPC_HIGHESTA:
+ Modifier = MCSymbolRefExpr::VK_PPC_HIGHESTA;
+ break;
}
Sym = MCSymbolRefExpr::Create(&Sym->getSymbol(), Modifier, Context);
Res = MCValue::get(Sym, Value.getSymB(), Value.getConstant());
Modified: llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h?rev=184550&r1=184549&r2=184550&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h (original)
+++ llvm/trunk/lib/Target/PowerPC/MCTargetDesc/PPCMCExpr.h Fri Jun 21 09:43:42 2013
@@ -22,7 +22,11 @@ public:
VK_PPC_None,
VK_PPC_LO,
VK_PPC_HI,
- VK_PPC_HA
+ VK_PPC_HA,
+ VK_PPC_HIGHER,
+ VK_PPC_HIGHERA,
+ VK_PPC_HIGHEST,
+ VK_PPC_HIGHESTA
};
private:
Modified: llvm/trunk/test/MC/PowerPC/ppc64-fixup-apply.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/PowerPC/ppc64-fixup-apply.s?rev=184550&r1=184549&r2=184550&view=diff
==============================================================================
--- llvm/trunk/test/MC/PowerPC/ppc64-fixup-apply.s (original)
+++ llvm/trunk/test/MC/PowerPC/ppc64-fixup-apply.s Fri Jun 21 09:43:42 2013
@@ -38,6 +38,13 @@ addis 1, 1, target6 at h
.set target6, 0x4321fedc
+addi 1, 1, target7 at higher
+addis 1, 1, target7 at highest
+addi 1, 1, target7 at highera
+addis 1, 1, target7 at highesta
+
+.set target7, 0x1234ffffffff8000
+
.data
.quad v1
@@ -59,7 +66,7 @@ addis 1, 1, target6 at h
# CHECK-NEXT: ]
# CHECK-NEXT: Address: 0x0
# CHECK-NEXT: Offset:
-# CHECK-NEXT: Size: 48
+# CHECK-NEXT: Size: 64
# CHECK-NEXT: Link: 0
# CHECK-NEXT: Info: 0
# CHECK-NEXT: AddressAlignment: 4
@@ -68,6 +75,7 @@ addis 1, 1, target6 at h
# CHECK-NEXT: 0000: 38211234 3C211234 38215678 3C211234
# CHECK-NEXT: 0010: 38214444 3C211111 38218001 3C211001
# CHECK-NEXT: 0020: 38210008 3C210000 38214321 3C214321
+# CHECK-NEXT: 0030: 3821FFFF 3C211234 38210000 3C211235
# CHECK-NEXT: )
# CHECK-NEXT: }
Modified: llvm/trunk/test/MC/PowerPC/ppc64-fixups.s
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/PowerPC/ppc64-fixups.s?rev=184550&r1=184549&r2=184550&view=diff
==============================================================================
--- llvm/trunk/test/MC/PowerPC/ppc64-fixups.s (original)
+++ llvm/trunk/test/MC/PowerPC/ppc64-fixups.s Fri Jun 21 09:43:42 2013
@@ -57,6 +57,26 @@
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_ADDR16_HI target 0x0
lis 3, target at h
+# CHECK: li 3, target at higher # encoding: [0x38,0x60,A,A]
+# CHECK-NEXT: # fixup A - offset: 2, value: target at higher, kind: fixup_ppc_half16
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_ADDR16_HIGHER target 0x0
+ li 3, target at higher
+
+# CHECK: lis 3, target at highest # encoding: [0x3c,0x60,A,A]
+# CHECK-NEXT: # fixup A - offset: 2, value: target at highest, kind: fixup_ppc_half16
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_ADDR16_HIGHEST target 0x0
+ lis 3, target at highest
+
+# CHECK: li 3, target at highera # encoding: [0x38,0x60,A,A]
+# CHECK-NEXT: # fixup A - offset: 2, value: target at highera, kind: fixup_ppc_half16
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_ADDR16_HIGHERA target 0x0
+ li 3, target at highera
+
+# CHECK: lis 3, target at highesta # encoding: [0x3c,0x60,A,A]
+# CHECK-NEXT: # fixup A - offset: 2, value: target at highesta, kind: fixup_ppc_half16
+# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_ADDR16_HIGHESTA target 0x0
+ lis 3, target at highesta
+
# CHECK: lwz 1, target at l(3) # encoding: [0x80,0x23,A,A]
# CHECK-NEXT: # fixup A - offset: 2, value: target at l, kind: fixup_ppc_half16
# CHECK-REL: 0x{{[0-9A-F]*[26AE]}} R_PPC64_ADDR16_LO target 0x0
More information about the llvm-commits
mailing list