[DAGCombiner] Add target hook function to decide folding (mul (add x, c1), c2)
[llvm-project.git] / llvm / test / MC / RISCV / rv64c-valid.s
blob36bd35317327197592a7d907ebd5d5c71d7a304f
1 # RUN: llvm-mc %s -triple=riscv64 -mattr=+c -riscv-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 -M no-aliases -d -r - \
5 # RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
8 # RUN: not llvm-mc -triple riscv64 \
9 # RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
10 # RUN: | FileCheck -check-prefixes=CHECK-NO-EXT %s
11 # RUN: not llvm-mc -triple riscv32 -mattr=+c \
12 # RUN: -riscv-no-aliases -show-encoding < %s 2>&1 \
13 # RUN: | FileCheck -check-prefixes=CHECK-NO-RV64 %s
15 # TODO: more exhaustive testing of immediate encoding.
17 # CHECK-ASM-AND-OBJ: c.ldsp ra, 0(sp)
18 # CHECK-ASM: encoding: [0x82,0x60]
19 # CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions)
20 # CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set
21 c.ldsp ra, 0(sp)
22 # CHECK-ASM-AND-OBJ: c.sdsp ra, 504(sp)
23 # CHECK-ASM: encoding: [0x86,0xff]
24 # CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions)
25 # CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set
26 c.sdsp ra, 504(sp)
27 # CHECK-ASM-AND-OBJ: c.ld a4, 0(a3)
28 # CHECK-ASM: encoding: [0x98,0x62]
29 # CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions)
30 # CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set
31 c.ld a4, 0(a3)
32 # CHECK-ASM-AND-OBJ: c.sd a5, 248(a3)
33 # CHECK-ASM: encoding: [0xfc,0xfe]
34 # CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions)
35 # CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set
36 c.sd a5, 248(a3)
38 # CHECK-ASM-AND-OBJ: c.subw a3, a4
39 # CHECK-ASM: encoding: [0x99,0x9e]
40 c.subw a3, a4
41 # CHECK-ASM-AND-OBJ: c.addw a0, a2
42 # CHECK-ASM: encoding: [0x31,0x9d]
43 # CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions)
44 # CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set
45 c.addw a0, a2
47 # CHECK-ASM-AND-OBJ: c.addiw a3, -32
48 # CHECK-ASM: encoding: [0x81,0x36]
49 # CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions)
50 # CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set
51 c.addiw a3, -32
52 # CHECK-ASM-AND-OBJ: c.addiw a3, 31
53 # CHECK-ASM: encoding: [0xfd,0x26]
54 # CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions)
55 # CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set
56 c.addiw a3, 31
58 # CHECK-ASM-AND-OBJ: c.slli s0, 1
59 # CHECK-ASM: encoding: [0x06,0x04]
60 # CHECK-NO-EXT: error: instruction requires the following: 'C' (Compressed Instructions)
61 # CHECK-NO-RV64: error: instruction requires the following: RV64I Base Instruction Set
62 c.slli s0, 1
63 # CHECK-ASM-AND-OBJ: c.srli a3, 63
64 # CHECK-ASM: encoding: [0xfd,0x92]
65 c.srli a3, 63
66 # CHECK-ASM-AND-OBJ: c.srai a2, 63
67 # CHECK-ASM: encoding: [0x7d,0x96]
68 c.srai a2, 63