xref: /llvm-project/llvm/test/MC/RISCV/rv32c-only-valid.s (revision 4b3d439e7e7b4e794e523caea9863d67ff8cf85f)
1# RUN: llvm-mc %s -triple=riscv32 -mattr=+c -M no-aliases -show-encoding \
2# RUN:     | FileCheck --check-prefix=CHECK-ASM %s
3# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+c < %s \
4# RUN:     | llvm-objdump --mattr=+c --no-print-imm-hex -M no-aliases -d -r - \
5# RUN:     | FileCheck --check-prefix=CHECK-OBJ %s
6#
7# RUN: not llvm-mc -triple riscv32 \
8# RUN:     -M no-aliases -show-encoding < %s 2>&1 \
9# RUN:     | FileCheck --check-prefix=CHECK-NO-EXT %s
10# RUN: not llvm-mc -triple riscv64 -mattr=+c \
11# RUN:     -M no-aliases -show-encoding < %s 2>&1 \
12# RUN:     | FileCheck --check-prefix=CHECK-NO-RV32 %s
13# RUN: not llvm-mc -triple riscv64 \
14# RUN:     -M no-aliases -show-encoding < %s 2>&1 \
15# RUN:     | FileCheck --check-prefix=CHECK-NO-RV32-AND-EXT %s
16
17# CHECK-OBJ: c.jal 0x7fe
18# CHECK-ASM: c.jal 2046
19# CHECK-ASM: encoding: [0xfd,0x2f]
20# CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
21# CHECK-NO-RV32: error: instruction requires the following: RV32I Base Instruction Set{{$}}
22# CHECK-NO-RV32-AND-EXT: error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores), RV32I Base Instruction Set{{$}}
23c.jal 2046
24
25# CHECK-OBJ: c.addi a1, -1
26# CHECK-ASM: c.addi a1, -1
27# CHECK-ASM: encoding: [0xfd,0x15]
28c.addi a1, 0xffffffff
29
30# CHECK-OBJ: c.addi16sp sp, -352
31# CHECK-ASM: c.addi16sp sp, -352
32# CHECK-ASM: encoding: [0x0d,0x71]
33c.addi16sp sp, 0xfffffea0
34
35## Branch and Jump immediates are relative but printed as their absolute address
36## when disassembling.
37
38# CHECK-OBJ: c.beqz a2, 0xffffff06
39# CHECK-ASM: c.beqz a2, -256
40# CHECK-ASM: encoding: [0x01,0xd2]
41c.beqz a2, 0xffffff00
42
43# CHECK-OBJ: c.beqz a0, 0xffffff16
44# CHECK-ASM: .insn cb 1, 6, a0, -242
45# CHECK-ASM: encoding: [0x19,0xd5]
46.insn cb 1, 6, a0, 0xffffff0e
47
48# CHECK-OBJ: c.jal 0xfffffab4
49# CHECK-ASM: c.jal -1366
50# CHECK-ASM: encoding: [0x6d,0x34]
51c.jal 0xfffffaaa
52
53# CHECK-OBJ: c.j 0xfffffcd8
54# CHECK-ASM: .insn cj 1, 5, -820
55# CHECK-ASM: encoding: [0xf1,0xb1]
56.insn cj 1, 5, 0xfffffccc
57