1 # RUN: llvm-mc -triple riscv32 -mattr=+experimental -show-encoding < %s \
2 # RUN: | FileCheck -check-prefixes=CHECK %s
3 # RUN: llvm-mc -triple riscv32 -mattr=+experimental -filetype=obj < %s \
4 # RUN: | llvm-objdump --triple=riscv32 --mattr=+c,+m,+a,+f,+zba,+experimental-zicfiss -d -M no-aliases - \
5 # RUN: | FileCheck -check-prefixes=CHECK-INST %s
7 # Test '.option arch, +' and '.option arch, -' directive
8 # The following test cases were copied from MC/RISCV/option-rvc.s
10 # CHECK-INST: addi a0, a1, 0x0
11 # CHECK: # encoding: [0x13,0x85,0x05,0x00]
14 # CHECK-INST: addi s0, sp, 0x3fc
15 # CHECK: # encoding: [0x13,0x04,0xc1,0x3f]
18 # CHECK: .option arch, +c
20 # CHECK-INST: c.mv a0, a1
21 # CHECK: # encoding: [0x2e,0x85]
24 # CHECK-INST: c.addi4spn s0, sp, 0x3fc
25 # CHECK: # encoding: [0xe0,0x1f]
28 # CHECK: .option arch, -c
30 # CHECK-INST: addi a0, a1, 0x0
31 # CHECK: # encoding: [0x13,0x85,0x05,0x00]
34 # CHECK-INST: addi s0, sp, 0x3fc
35 # CHECK: # encoding: [0x13,0x04,0xc1,0x3f]
38 # CHECK: .option arch, +c
40 # CHECK-INST: c.mv a0, a1
41 # CHECK: # encoding: [0x2e,0x85]
44 # CHECK-INST: c.addi4spn s0, sp, 0x3fc
45 # CHECK: # encoding: [0xe0,0x1f]
48 # CHECK: .option arch, -c
50 # CHECK-INST: addi a0, a1, 0x0
51 # CHECK: # encoding: [0x13,0x85,0x05,0x00]
54 # CHECK-INST: addi s0, sp, 0x3fc
55 # CHECK: # encoding: [0x13,0x04,0xc1,0x3f]
58 # CHECK: .option arch, +d, -d
60 # CHECK-INST: flw ft0, 0xc(a0)
61 # CHECK: # encoding: [0x07,0x20,0xc5,0x00]
64 # Test comma-separated list
67 # CHECK-INST: mul a4, ra, s0
68 # CHECK: # encoding: [0x33,0x87,0x80,0x02]
70 # CHECK-INST: lr.w t0, (t1)
71 # CHECK: # encoding: [0xaf,0x22,0x03,0x10]
74 # Test multi-letter extension
75 # CHECK: .option arch, +zba
77 # CHECK-INST: sh1add t0, t1, t2
78 # CHECK: encoding: [0xb3,0x22,0x73,0x20]
81 # Test experimental extension
82 # CHECK: .option arch, +zicfiss
83 .option arch, +zicfiss
84 # CHECK-INST: sspopchk ra
85 # CHECK: encoding: [0x73,0xc0,0xc0,0xcd]
88 # Test '.option arch, <arch-string>' directive
89 # CHECK: .option arch, rv32i2p1_m2p0_a2p1_c2p0
90 .option arch, rv32i2p1_m2p0_a2p1_c2p0
92 # CHECK-INST: mul a4, ra, s0
93 # CHECK: # encoding: [0x33,0x87,0x80,0x02]
95 # CHECK-INST: lr.w t0, (t1)
96 # CHECK: # encoding: [0xaf,0x22,0x03,0x10]
99 # Test arch string without version number
100 # CHECK: .option arch, rv32i2p1_m2p0_a2p1_c2p0
101 .option arch, rv32imac
102 # CHECK-INST: mul a4, ra, s0
103 # CHECK: # encoding: [0x33,0x87,0x80,0x02]
105 # CHECK-INST: lr.w t0, (t1)
106 # CHECK: # encoding: [0xaf,0x22,0x03,0x10]
109 # Test +c, -c and vice-versa
111 # CHECK-INST: addi a0, a1, 0x0
112 # CHECK: # encoding: [0x13,0x85,0x05,0x00]
116 # CHECK-INST: c.mv a0, a1
117 # CHECK: # encoding: [0x2e,0x85]
121 # CHECK-INST: c.mv a0, a1
122 # CHECK: # encoding: [0x2e,0x85]
125 # Test extension name that has digits.
126 .option arch, +zve32x
127 # CHECK: .option arch, +zve32x
130 .option arch, +zce, +f
131 # CHECK-INST: flw fa0, 0x0(a0)
132 # CHECK: # encoding: [0x08,0x61]