xref: /llvm-project/llvm/test/MC/RISCV/tail-call.s (revision e3f42b02a4129947ca2dd820bfb63ffed83027b7)
1# RUN: llvm-mc -filetype=obj -triple riscv32 < %s \
2# RUN:   | llvm-objdump -d - | FileCheck --check-prefix=INSTR %s
3# RUN: llvm-mc -filetype=obj -triple riscv32 < %s \
4# RUN:   | llvm-readobj -r - | FileCheck -check-prefix=RELOC %s
5# RUN: llvm-mc -triple riscv32 < %s -show-encoding \
6# RUN:   | FileCheck -check-prefix=FIXUP %s
7
8# RUN: llvm-mc -filetype=obj -triple riscv64 < %s \
9# RUN:   | llvm-objdump -d - | FileCheck --check-prefix=INSTR %s
10# RUN: llvm-mc -filetype=obj -triple riscv64 < %s \
11# RUN:   | llvm-readobj -r - | FileCheck -check-prefix=RELOC %s
12# RUN: llvm-mc -triple riscv64 < %s -show-encoding \
13# RUN:   | FileCheck -check-prefix=FIXUP %s
14
15# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zicfilp < %s \
16# RUN:   | llvm-objdump -d - | FileCheck --check-prefix=INSTR-ZICFILP %s
17# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-zicfilp < %s \
18# RUN:   | llvm-readobj -r - | FileCheck -check-prefix=RELOC %s
19# RUN: llvm-mc -triple riscv32 -mattr=+experimental-zicfilp < %s -show-encoding \
20# RUN:   | FileCheck -check-prefix=FIXUP %s
21
22# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zicfilp < %s \
23# RUN:   | llvm-objdump -d - | FileCheck --check-prefix=INSTR-ZICFILP %s
24# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zicfilp < %s \
25# RUN:   | llvm-readobj -r - | FileCheck -check-prefix=RELOC %s
26# RUN: llvm-mc -triple riscv64 -mattr=+experimental-zicfilp < %s -show-encoding \
27# RUN:   | FileCheck -check-prefix=FIXUP %s
28
29.long foo
30
31tail foo
32# RELOC: R_RISCV_CALL_PLT foo 0x0
33# INSTR: auipc t1, 0
34# INSTR: jr  t1
35# INSTR-ZICFILP: auipc t2, 0
36# INSTR-ZICFILP: jr  t2
37# FIXUP: fixup A - offset: 0, value: foo, kind:
38
39tail bar
40# RELOC: R_RISCV_CALL_PLT bar 0x0
41# INSTR: auipc t1, 0
42# INSTR: jr  t1
43# INSTR-ZICFILP: auipc t2, 0
44# INSTR-ZICFILP: jr  t2
45# FIXUP: fixup A - offset: 0, value: bar, kind:
46
47# Ensure that tail calls to functions whose names coincide with register names
48# work.
49
50tail zero
51# RELOC: R_RISCV_CALL_PLT zero 0x0
52# INSTR: auipc t1, 0
53# INSTR: jr  t1
54# INSTR-ZICFILP: auipc t2, 0
55# INSTR-ZICFILP: jr  t2
56# FIXUP: fixup A - offset: 0, value: zero, kind:
57
58tail f1
59# RELOC: R_RISCV_CALL_PLT f1 0x0
60# INSTR: auipc t1, 0
61# INSTR: jr  t1
62# INSTR-ZICFILP: auipc t2, 0
63# INSTR-ZICFILP: jr  t2
64# FIXUP: fixup A - offset: 0, value: f1, kind:
65
66tail ra
67# RELOC: R_RISCV_CALL_PLT ra 0x0
68# INSTR: auipc t1, 0
69# INSTR: jr  t1
70# INSTR-ZICFILP: auipc t2, 0
71# INSTR-ZICFILP: jr  t2
72# FIXUP: fixup A - offset: 0, value: ra, kind:
73
74tail foo@plt
75# RELOC: R_RISCV_CALL_PLT foo 0x0
76# INSTR: auipc t1, 0
77# INSTR: jr  t1
78# INSTR-ZICFILP: auipc t2, 0
79# INSTR-ZICFILP: jr  t2
80# FIXUP: fixup A - offset: 0, value: foo, kind: fixup_riscv_call_plt
81