xref: /llvm-project/llvm/test/MC/RISCV/rv64c-valid.s (revision 4b3d439e7e7b4e794e523caea9863d67ff8cf85f)
1# RUN: llvm-mc %s -triple=riscv64 -mattr=+c -M no-aliases -show-encoding \
2# RUN:     | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
3# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+c < %s \
4# RUN:     | llvm-objdump --mattr=+c --no-print-imm-hex -M no-aliases -d -r - \
5# RUN:     | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
6# RUN: llvm-mc %s -triple=riscv64 -mattr=+zca -M no-aliases -show-encoding \
7# RUN:     | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
8# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+c < %s \
9# RUN:     | llvm-objdump --mattr=+c --no-print-imm-hex -M no-aliases -d -r - \
10# RUN:     | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
11#
12#
13# RUN: not llvm-mc -triple riscv64 \
14# RUN:     -M no-aliases -show-encoding < %s 2>&1 \
15# RUN:     | FileCheck -check-prefixes=CHECK-NO-EXT %s
16# RUN: not llvm-mc -triple riscv32 -mattr=+c \
17# RUN:     -M no-aliases -show-encoding < %s 2>&1 \
18# RUN:     | FileCheck -check-prefixes=CHECK-NO-RV64 %s
19
20# TODO: more exhaustive testing of immediate encoding.
21
22# CHECK-ASM-AND-OBJ: c.ldsp ra, 0(sp)
23# CHECK-ASM: encoding: [0x82,0x60]
24# CHECK-NO-EXT:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
25# CHECK-NO-RV64:  error: instruction requires the following: RV64I Base Instruction Set{{$}}
26c.ldsp ra, 0(sp)
27# CHECK-ASM-AND-OBJ: c.sdsp ra, 504(sp)
28# CHECK-ASM: encoding: [0x86,0xff]
29# CHECK-NO-EXT:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
30# CHECK-NO-RV64:  error: instruction requires the following: RV64I Base Instruction Set{{$}}
31c.sdsp ra, 504(sp)
32# CHECK-ASM-AND-OBJ: c.ld a4, 0(a3)
33# CHECK-ASM: encoding: [0x98,0x62]
34# CHECK-NO-EXT:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
35# CHECK-NO-RV64:  error: instruction requires the following: RV64I Base Instruction Set{{$}}
36c.ld a4, 0(a3)
37# CHECK-ASM-AND-OBJ: c.sd a5, 248(a3)
38# CHECK-ASM: encoding: [0xfc,0xfe]
39# CHECK-NO-EXT:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
40# CHECK-NO-RV64:  error: instruction requires the following: RV64I Base Instruction Set{{$}}
41c.sd a5, 248(a3)
42
43# CHECK-ASM-AND-OBJ: c.subw a3, a4
44# CHECK-ASM: encoding: [0x99,0x9e]
45# CHECK-NO-EXT:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
46# CHECK-NO-RV64:  error: instruction requires the following: RV64I Base Instruction Set{{$}}
47c.subw a3, a4
48# CHECK-ASM-AND-OBJ: c.addw a0, a2
49# CHECK-ASM: encoding: [0x31,0x9d]
50# CHECK-NO-EXT:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
51# CHECK-NO-RV64:  error: instruction requires the following: RV64I Base Instruction Set{{$}}
52c.addw a0, a2
53
54# CHECK-ASM-AND-OBJ: c.addiw a3, -32
55# CHECK-ASM: encoding: [0x81,0x36]
56# CHECK-NO-EXT:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
57# CHECK-NO-RV64:  error: instruction requires the following: RV64I Base Instruction Set{{$}}
58c.addiw a3, -32
59# CHECK-ASM-AND-OBJ: c.addiw a3, 31
60# CHECK-ASM: encoding: [0xfd,0x26]
61# CHECK-NO-EXT:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
62# CHECK-NO-RV64:  error: instruction requires the following: RV64I Base Instruction Set{{$}}
63c.addiw a3, 31
64
65# CHECK-ASM-AND-OBJ: c.slli s0, 63
66# CHECK-ASM: encoding: [0x7e,0x14]
67# CHECK-NO-EXT:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
68c.slli s0, 63
69# CHECK-ASM-AND-OBJ: c.srli a3, 63
70# CHECK-ASM: encoding: [0xfd,0x92]
71# CHECK-NO-EXT:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
72c.srli a3, 63
73# CHECK-ASM-AND-OBJ: c.srai a2, 63
74# CHECK-ASM: encoding: [0x7d,0x96]
75# CHECK-NO-EXT:  error: instruction requires the following: 'C' (Compressed Instructions) or 'Zca' (part of the C extension, excluding compressed floating point loads/stores){{$}}
76c.srai a2, 63
77