xref: /llvm-project/llvm/test/ExecutionEngine/JITLink/RISCV/ELF_rvc.s (revision c8d43dca2332623f138d118c62176e93711f06e0)
1# RUN: rm -rf %t && mkdir -p %t
2# RUN: llvm-mc -triple=riscv64 -mattr=+c,+relax -filetype=obj \
3# RUN:     -o %t/elf_riscv64_rvc.o %s
4# RUN: llvm-mc -triple=riscv32 -mattr=+c,+relax -filetype=obj \
5# RUN:     -o %t/elf_riscv32_rvc.o %s
6# RUN: llvm-jitlink -noexec \
7# RUN:     -slab-allocate 100Kb -slab-address 0x1ff00000 -slab-page-size 4096 \
8# RUN:     -check %s %t/elf_riscv64_rvc.o
9# RUN: llvm-jitlink -noexec \
10# RUN:     -slab-allocate 100Kb -slab-address 0x1ff00000 -slab-page-size 4096 \
11# RUN:     -check %s %t/elf_riscv32_rvc.o
12
13.globl main
14main:
15  ret
16
17# Test R_RISCV_RVC_BRANCH
18
19# jitlink-check: *{2}(test_rvc_branch) = 0xC111
20# jitlink-check: *{2}(test_rvc_branch+2) = 0xE109
21.globl test_rvc_branch
22.type test_rvc_branch,@function
23test_rvc_branch:
24  c.beqz a0, test_rvc_branch_ret
25  c.bnez a0, test_rvc_branch_ret
26test_rvc_branch_ret:
27  ret
28# jitlink-check: *{2}(test_rvc_branch+6) = 0xDD7D
29# jitlink-check: *{2}(test_rvc_branch+8) = 0xFD75
30test_rvc_branch2:
31  c.beqz a0, test_rvc_branch_ret
32  c.bnez a0, test_rvc_branch_ret
33
34.size test_rvc_branch, .-test_rvc_branch
35
36# Test R_RISCV_RVC_JUMP
37
38# jitlink-check: *{2}(test_rvc_jump) = 0xA009
39.globl test_rvc_jump
40.type test_rvc_jump,@function
41test_rvc_jump:
42  c.j test_rvc_jump_ret
43test_rvc_jump_ret:
44  ret
45# jitlink-check: *{2}(test_rvc_jump+4) = 0xBFFD
46test_rvc_jump2:
47  c.j test_rvc_jump_ret
48
49.size test_rvc_jump, .-test_rvc_jump
50