diff --git a/lib/MC/MCExpr.cpp b/lib/MC/MCExpr.cpp index 6cde26cff17..06bc72f2c6b 100644 --- a/lib/MC/MCExpr.cpp +++ b/lib/MC/MCExpr.cpp @@ -290,6 +290,40 @@ MCSymbolRefExpr::getVariantKindForName(StringRef Name) { .Case("imgrel", VK_COFF_IMGREL32) .Case("SECREL32", VK_SECREL) .Case("secrel32", VK_SECREL) + .Case("HA", VK_PPC_GAS_HA16) + .Case("ha", VK_PPC_GAS_HA16) + .Case("L", VK_PPC_GAS_LO16) + .Case("l", VK_PPC_GAS_LO16) + .Case("TOCBASE", VK_PPC_TOC) + .Case("tocbase", VK_PPC_TOC) + .Case("TOC", VK_PPC_TOC_ENTRY) + .Case("toc", VK_PPC_TOC_ENTRY) + .Case("TOC@HA", VK_PPC_TOC16_HA) + .Case("toc@ha", VK_PPC_TOC16_HA) + .Case("TOC@L", VK_PPC_TOC16_LO) + .Case("toc@l", VK_PPC_TOC16_LO) + .Case("TLS", VK_PPC_TLS) + .Case("tls", VK_PPC_TLS) + .Case("TPREL@HA", VK_PPC_TPREL16_HA) + .Case("tprel@ha", VK_PPC_TPREL16_HA) + .Case("TPREL@L", VK_PPC_TPREL16_LO) + .Case("tprel@l", VK_PPC_TPREL16_LO) + .Case("DTPREL@HA", VK_PPC_DTPREL16_HA) + .Case("dtprel@ha", VK_PPC_DTPREL16_HA) + .Case("DTPREL@L", VK_PPC_DTPREL16_LO) + .Case("dtprel@l", VK_PPC_DTPREL16_LO) + .Case("GOT@TPREL@HA", VK_PPC_GOT_TPREL16_HA) + .Case("got@tprel@ha", VK_PPC_GOT_TPREL16_HA) + .Case("GOT@TPREL@L", VK_PPC_GOT_TPREL16_LO) + .Case("got@tprel@l", VK_PPC_GOT_TPREL16_LO) + .Case("GOT@TLSGD@HA", VK_PPC_GOT_TLSGD16_HA) + .Case("got@tlsgd@ha", VK_PPC_GOT_TLSGD16_HA) + .Case("GOT@TLSGD@L", VK_PPC_GOT_TLSGD16_LO) + .Case("got@tlsgd@l", VK_PPC_GOT_TLSGD16_LO) + .Case("GOT@TLSLD@HA", VK_PPC_GOT_TLSLD16_HA) + .Case("got@tlsld@ha", VK_PPC_GOT_TLSLD16_HA) + .Case("GOT@TLSLD@L", VK_PPC_GOT_TLSLD16_LO) + .Case("got@tlsld@l", VK_PPC_GOT_TLSLD16_LO) .Default(VK_Invalid); } diff --git a/test/MC/PowerPC/ppc64-fixups.s b/test/MC/PowerPC/ppc64-fixups.s new file mode 100644 index 00000000000..1dcbca8f818 --- /dev/null +++ b/test/MC/PowerPC/ppc64-fixups.s @@ -0,0 +1,95 @@ + +# RUN: llvm-mc -triple powerpc64-unknown-unknown --show-encoding %s | FileCheck %s + +# FIXME: .TOC.@tocbase + +# CHECK: li 3, target@l # encoding: [0x38,0x60,A,A] +# CHECK-NEXT: # fixup A - offset: 0, value: target@l, kind: fixup_ppc_lo16 + li 3, target@l + +# CHECK: addis 3, 3, target@ha # encoding: [0x3c,0x63,A,A] +# CHECK-NEXT: # fixup A - offset: 0, value: target@ha, kind: fixup_ppc_ha16 + addis 3, 3, target@ha + +# CHECK: lis 3, target@ha # encoding: [0x3c,0x60,A,A] +# CHECK-NEXT: # fixup A - offset: 0, value: target@ha, kind: fixup_ppc_ha16 + lis 3, target@ha + +# CHECK: addi 4, 3, target@l # encoding: [0x38,0x83,A,A] +# CHECK-NEXT: # fixup A - offset: 0, value: target@l, kind: fixup_ppc_lo16 + addi 4, 3, target@l + +# CHECK: lwz 1, target@l(3) # encoding: [0x80,0x23,A,A] +# CHECK-NEXT: # fixup A - offset: 0, value: target@l, kind: fixup_ppc_lo16 + lwz 1, target@l(3) + +# CHECK: ld 1, target@l(3) # encoding: [0xe8,0x23,A,0bAAAAAA00] +# CHECK-NEXT: # fixup A - offset: 0, value: target@l, kind: fixup_ppc_lo16_ds + ld 1, target@l(3) + +# CHECK: ld 1, target@toc(2) # encoding: [0xe8,0x22,A,0bAAAAAA00] +# CHECK-NEXT: # fixup A - offset: 0, value: target@toc, kind: fixup_ppc_lo16_ds + ld 1, target@toc(2) + +# CHECK: addis 3, 2, target@toc@ha # encoding: [0x3c,0x62,A,A] +# CHECK-NEXT: # fixup A - offset: 0, value: target@toc@ha, kind: fixup_ppc_ha16 + addis 3, 2, target@toc@ha + +# CHECK: addi 4, 3, target@toc@l # encoding: [0x38,0x83,A,A] +# CHECK-NEXT: # fixup A - offset: 0, value: target@toc@l, kind: fixup_ppc_lo16 + addi 4, 3, target@toc@l + +# CHECK: lwz 1, target@toc@l(3) # encoding: [0x80,0x23,A,A] +# CHECK-NEXT: # fixup A - offset: 0, value: target@toc@l, kind: fixup_ppc_lo16 + lwz 1, target@toc@l(3) + +# CHECK: ld 1, target@toc@l(3) # encoding: [0xe8,0x23,A,0bAAAAAA00] +# CHECK-NEXT: # fixup A - offset: 0, value: target@toc@l, kind: fixup_ppc_lo16_ds + ld 1, target@toc@l(3) + +# FIXME: @tls + + +# CHECK: addis 3, 2, target@tprel@ha # encoding: [0x3c,0x62,A,A] +# CHECK-NEXT: # fixup A - offset: 0, value: target@tprel@ha, kind: fixup_ppc_ha16 + addis 3, 2, target@tprel@ha + +# CHECK: addi 3, 3, target@tprel@l # encoding: [0x38,0x63,A,A] +# CHECK-NEXT: # fixup A - offset: 0, value: target@tprel@l, kind: fixup_ppc_lo16 + addi 3, 3, target@tprel@l + +# CHECK: addis 3, 2, target@dtprel@ha # encoding: [0x3c,0x62,A,A] +# CHECK-NEXT: # fixup A - offset: 0, value: target@dtprel@ha, kind: fixup_ppc_ha16 + addis 3, 2, target@dtprel@ha + +# CHECK: addi 3, 3, target@dtprel@l # encoding: [0x38,0x63,A,A] +# CHECK-NEXT: # fixup A - offset: 0, value: target@dtprel@l, kind: fixup_ppc_lo16 + addi 3, 3, target@dtprel@l + + +# CHECK: addis 3, 2, target@got@tprel@ha # encoding: [0x3c,0x62,A,A] +# CHECK-NEXT: # fixup A - offset: 0, value: target@got@tprel@ha, kind: fixup_ppc_ha16 + addis 3, 2, target@got@tprel@ha + +# CHECK: ld 1, target@got@tprel@l(3) # encoding: [0xe8,0x23,A,0bAAAAAA00] +# CHECK-NEXT: # fixup A - offset: 0, value: target@got@tprel@l, kind: fixup_ppc_lo16_ds + ld 1, target@got@tprel@l(3) + + +# CHECK: addis 3, 2, target@got@tlsgd@ha # encoding: [0x3c,0x62,A,A] +# CHECK-NEXT: # fixup A - offset: 0, value: target@got@tlsgd@ha, kind: fixup_ppc_ha16 + addis 3, 2, target@got@tlsgd@ha + +# CHECK: addi 3, 3, target@got@tlsgd@l # encoding: [0x38,0x63,A,A] +# CHECK-NEXT: # fixup A - offset: 0, value: target@got@tlsgd@l, kind: fixup_ppc_lo16 + addi 3, 3, target@got@tlsgd@l + + +# CHECK: addis 3, 2, target@got@tlsld@ha # encoding: [0x3c,0x62,A,A] +# CHECK-NEXT: # fixup A - offset: 0, value: target@got@tlsld@ha, kind: fixup_ppc_ha16 + addis 3, 2, target@got@tlsld@ha + +# CHECK: addi 3, 3, target@got@tlsld@l # encoding: [0x38,0x63,A,A] +# CHECK-NEXT: # fixup A - offset: 0, value: target@got@tlsld@l, kind: fixup_ppc_lo16 + addi 3, 3, target@got@tlsld@l +