xref: /llvm-project/llvm/test/tools/llvm-objdump/ELF/RISCV/multi-instr-target.s (revision c532ba4edd7ad7675ba450ba43268aa9e7bda46b)
195f924f3SJob Noorman# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+c < %s | \
2*c532ba4eSWang Yaduo# RUN:     llvm-objdump --no-print-imm-hex -d -M no-aliases --no-show-raw-insn - | \
395f924f3SJob Noorman# RUN:     FileCheck %s
495f924f3SJob Noorman
595f924f3SJob Noorman## Test multiple interleaved auipc/jalr pairs
695f924f3SJob Noorman# CHECK: auipc t0, 0
795f924f3SJob Noorman1: auipc t0, %pcrel_hi(bar)
895f924f3SJob Noorman# CHECK: auipc t1, 0
995f924f3SJob Noorman2: auipc t1, %pcrel_hi(bar)
1095f924f3SJob Noorman# CHECK: jalr ra, {{[0-9]+}}(t0) <bar>
1195f924f3SJob Noormanjalr %pcrel_lo(1b)(t0)
1295f924f3SJob Noorman## Target should not be printed because the call above clobbers register state
1395f924f3SJob Noorman# CHECK: jalr ra, {{[0-9]+}}(t1){{$}}
1495f924f3SJob Noormanjalr %pcrel_lo(2b)(t1)
1595f924f3SJob Noorman
1695f924f3SJob Noorman## Test that auipc+jalr with a write to the target register in between does not
1795f924f3SJob Noorman## print the target
1895f924f3SJob Noorman# CHECK: auipc t0, 0
1995f924f3SJob Noorman1: auipc t0, %pcrel_hi(bar)
2095f924f3SJob Noorman# CHECK: c.li t0, 0
2195f924f3SJob Noormanli t0, 0
2295f924f3SJob Noorman# CHECK: jalr ra, {{[0-9]+}}(t0){{$}}
2395f924f3SJob Noormanjalr %pcrel_lo(1b)(t0)
2495f924f3SJob Noorman
2595f924f3SJob Noorman## Test that auipc+jalr with a write to an unrelated register in between does
2695f924f3SJob Noorman## print the target
2795f924f3SJob Noorman# CHECK: auipc t0, 0
2895f924f3SJob Noorman1: auipc t0, %pcrel_hi(bar)
2995f924f3SJob Noorman# CHECK: c.li t1, 0
3095f924f3SJob Noormanli t1, 0
3195f924f3SJob Noorman# CHECK: jalr ra, {{[0-9]+}}(t0) <bar>
3295f924f3SJob Noormanjalr %pcrel_lo(1b)(t0)
3395f924f3SJob Noorman
3495f924f3SJob Noorman## Test that auipc+jalr with a terminator in between does not print the target
3595f924f3SJob Noorman# CHECK: auipc t0, 0
3695f924f3SJob Noorman1: auipc t0, %pcrel_hi(bar)
3795f924f3SJob Noorman# CHECK: c.j {{.*}} <bar>
3895f924f3SJob Noormanj bar
3995f924f3SJob Noorman# CHECK: jalr ra, {{[0-9]+}}(t0){{$}}
4095f924f3SJob Noormanjalr %pcrel_lo(1b)(t0)
4195f924f3SJob Noorman
4295f924f3SJob Noorman# CHECK-LABEL: <bar>:
4395f924f3SJob Noormanbar:
4495f924f3SJob Noorman# CHECK: c.nop
4595f924f3SJob Noormannop
46