# RUN: llvm-mc -filetype=obj -triple=mips64el-unknown-linux -mcpu=mips64r2 %s \
# RUN: | llvm-objdump -d - | FileCheck %s
# RUN: llvm-mc -filetype=obj -triple=mips64el-unknown-linux -mcpu=mips64r2 %s \
# RUN: | llvm-readobj -r - | FileCheck %s -check-prefix=CHECK-REL
# Test that R_MIPS_HIGHER and R_MIPS_HIGHEST relocations are created. By using
# NEXT we also test that none of the expressions from the test2 generates
# relocations.
test1:
# CHECK-LABEL: <test1>:
lui $5, %
daddiu $5, $5, %
# CHECK-REL: Relocations [
# CHECK-REL-NEXT: {
# CHECK-REL-NEXT: 0x{{[0-9,A-F]+}} R_MIPS_HIGHEST
# CHECK-REL-NEXT: 0x{{[0-9,A-F]+}} R_MIPS_HIGHER
# CHECK-REL-NEXT: }
# Test the calculation of %higher and %highest:
# ((x + 0x80008000) >> 32) & 0xffff (higher)
# ((x + 0x800080008000) >> 48) & 0xffff (highest).
test2:
# CHECK-LABEL: <test2>:
# Check the case where relocations are not modified by adding +1. The constant
# is chosen so that it is just below the value that triggers the addition of +1
# to %higher.
$L1:
lui $6, %
daddiu $6, $6, %
$L2:
# CHECK: lui $6, 3
# CHECK: daddiu $6, $6, 4
# Check the case where %higher is modified by adding +1.
lui $7, %
ld $7, %($7)
# CHECK: lui $7, 3
# CHECK: ld $7, 5($7)
# Check the case where both %higher and %highest are modified by adding +1.
lui $8, %
ld $8, %($8)
# CHECK: lui $8, 4
# CHECK: ld $8, -32768($8)