Index: lib/Target/Mips/AsmParser/MipsAsmParser.cpp =================================================================== --- lib/Target/Mips/AsmParser/MipsAsmParser.cpp +++ lib/Target/Mips/AsmParser/MipsAsmParser.cpp @@ -4095,6 +4095,15 @@ // Get the 4th 16-bits. Val = ((MCE->getValue() + 0x800080008000LL) >> 48) & 0xffff; break; + case MCSymbolRefExpr::VK_Mips_DTPREL_HI: + case MCSymbolRefExpr::VK_Mips_TPREL_HI: + case MCSymbolRefExpr::VK_Mips_DTPREL_LO: + case MCSymbolRefExpr::VK_Mips_TPREL_LO: + // Get the 16-bits for both 'hi' and 'lo' relocations. + // TPREL and DTPREL relocations do not use combined addend calculated + // using both HI and LO parts like %hi and %lo do. + Val = MCE->getValue() & 0xffff; + break; default: report_fatal_error("unsupported reloc value"); } Index: test/MC/Mips/tprel-hi-lo-expr.s =================================================================== --- /dev/null +++ test/MC/Mips/tprel-hi-lo-expr.s @@ -0,0 +1,25 @@ +# Check that llvm-mc accepts arithmetic expression as an argument +# of the %tprel_hi, %tprel_lo relocations. + +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s \ +# RUN: | llvm-objdump -d -r - | FileCheck %s + + .text +foo: + lui $3,%tprel_hi($loc0+0x7ffc) +# CHECK: 0: 3c 03 7f fc lui $3, 32764 +# CHECK: 00000000: R_MIPS_TLS_TPREL_HI16 $loc0 + addiu $3,$3,%tprel_lo($loc0+0x7ffc) +# CHECK: 4: 24 63 7f fc addiu $3, $3, 32764 +# CHECK: 00000004: R_MIPS_TLS_TPREL_LO16 $loc0 + lui $3,%dtprel_hi($loc0+0x7ffc) +# CHECK: 8: 3c 03 7f fc lui $3, 32764 +# CHECK: 00000008: R_MIPS_TLS_DTPREL_HI16 $loc0 + addiu $3,$3,%dtprel_lo($loc0+0x7ffc) +# CHECK: c: 24 63 7f fc addiu $3, $3, 32764 +# CHECK: 0000000c: R_MIPS_TLS_DTPREL_LO16 $loc0 + + .section .tdata,"awT",%progbits +$loc0: + .word 0 + .space 0x8000