1# RUN: llvm-mc --triple=loongarch64 %s --show-encoding \ 2# RUN: | FileCheck --check-prefix=CHECK-FIXUP %s 3# RUN: llvm-mc --filetype=obj --triple=loongarch64 %s \ 4# RUN: | llvm-objdump -d - | FileCheck --check-prefix=CHECK-INSTR %s 5# RUN: llvm-mc --filetype=obj --triple=loongarch64 %s \ 6# RUN: | llvm-readobj -r - | FileCheck --check-prefix=CHECK-REL %s 7 8## Checks that fixups that can be resolved within the same object file are 9## applied correctly. 10 11.LBB0: 12lu12i.w $t1, %abs_hi20(val) 13# CHECK-FIXUP: fixup A - offset: 0, value: %abs_hi20(val), kind: fixup_loongarch_abs_hi20 14# CHECK-INSTR: lu12i.w $t1, 74565 15 16ori $t1, $t1, %abs_lo12(val) 17# CHECK-FIXUP: fixup A - offset: 0, value: %abs_lo12(val), kind: fixup_loongarch_abs_lo12 18# CHECK-INSTR: ori $t1, $t1, 1656 19 20b .LBB0 21# CHECK-FIXUP: fixup A - offset: 0, value: .LBB0, kind: fixup_loongarch_b26 22# CHECK-INSTR: b -8 23b .LBB2 24# CHECK-FIXUP: fixup A - offset: 0, value: .LBB2, kind: fixup_loongarch_b26 25# CHECK-INSTR: b 331004 26beq $a0, $a1, .LBB0 27# CHECK-FIXUP: fixup A - offset: 0, value: .LBB0, kind: fixup_loongarch_b16 28# CHECK-INSTR: beq $a0, $a1, -16 29blt $a0, $a1, .LBB1 30# CHECK-FIXUP: fixup A - offset: 0, value: .LBB1, kind: fixup_loongarch_b16 31# CHECK-INSTR: blt $a0, $a1, 1116 32beqz $a0, .LBB0 33# CHECK-FIXUP: fixup A - offset: 0, value: .LBB0, kind: fixup_loongarch_b21 34# CHECK-INSTR: beqz $a0, -24 35bnez $a0, .LBB1 36# CHECK-FIXUP: fixup A - offset: 0, value: .LBB1, kind: fixup_loongarch_b21 37# CHECK-INSTR: bnez $a0, 1108 38 39.fill 1104 40 41.LBB1: 42 43.fill 329876 44nop 45.LBB2: 46 47.set val, 0x12345678 48 49# CHECK-REL-NOT: R_LARCH 50 51## Testing the function call offset could resolved by assembler 52## when the function and the callsite within the same compile unit. 53func: 54.fill 100 55bl func 56# CHECK-FIXUP: fixup A - offset: 0, value: func, kind: fixup_loongarch_b26 57# CHECK-INSTR: bl -100 58 59.fill 10000 60bl func 61# CHECK-FIXUP: fixup A - offset: 0, value: func, kind: fixup_loongarch_b26 62# CHECK-INSTR: bl -10104 63 64.fill 20888 65bl func 66# CHECK-FIXUP: fixup A - offset: 0, value: func, kind: fixup_loongarch_b26 67# CHECK-INSTR: bl -30996 68