Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / llvm / test / MC / RISCV / option-arch.s
blob5d23e2c73c3e83ada2ec30090cf6eeb334f2934f
1 # RUN: llvm-mc -triple riscv32 -show-encoding < %s \
2 # RUN: | FileCheck -check-prefixes=CHECK %s
3 # RUN: llvm-mc -triple riscv32 -filetype=obj < %s \
4 # RUN: | llvm-objdump --triple=riscv32 --mattr=+c,+m,+a,+f,+zba -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, 0
11 # CHECK: # encoding: [0x13,0x85,0x05,0x00]
12 addi a0, a1, 0
14 # CHECK-INST: addi s0, sp, 1020
15 # CHECK: # encoding: [0x13,0x04,0xc1,0x3f]
16 addi s0, sp, 1020
18 # CHECK: .option arch, +c
19 .option arch, +c
20 # CHECK-INST: c.mv a0, a1
21 # CHECK: # encoding: [0x2e,0x85]
22 addi a0, a1, 0
24 # CHECK-INST: c.addi4spn s0, sp, 1020
25 # CHECK: # encoding: [0xe0,0x1f]
26 addi s0, sp, 1020
28 # CHECK: .option arch, -c
29 .option arch, -c
30 # CHECK-INST: addi a0, a1, 0
31 # CHECK: # encoding: [0x13,0x85,0x05,0x00]
32 addi a0, a1, 0
34 # CHECK-INST: addi s0, sp, 1020
35 # CHECK: # encoding: [0x13,0x04,0xc1,0x3f]
36 addi s0, sp, 1020
38 # CHECK: .option arch, +c
39 .option arch, +c
40 # CHECK-INST: c.mv a0, a1
41 # CHECK: # encoding: [0x2e,0x85]
42 addi a0, a1, 0
44 # CHECK-INST: c.addi4spn s0, sp, 1020
45 # CHECK: # encoding: [0xe0,0x1f]
46 addi s0, sp, 1020
48 # CHECK: .option arch, -c
49 .option arch, -c
50 # CHECK-INST: addi a0, a1, 0
51 # CHECK: # encoding: [0x13,0x85,0x05,0x00]
52 addi a0, a1, 0
54 # CHECK-INST: addi s0, sp, 1020
55 # CHECK: # encoding: [0x13,0x04,0xc1,0x3f]
56 addi s0, sp, 1020
58 # CHECK: .option arch, +d, -d
59 .option arch, +d, -d
60 # CHECK-INST: flw ft0, 12(a0)
61 # CHECK: # encoding: [0x07,0x20,0xc5,0x00]
62 flw f0, 12(a0)
64 # Test comma-separated list
65 # CHECK: arch, +m, +a
66 .option arch, +m, +a
67 # CHECK-INST: mul a4, ra, s0
68 # CHECK: # encoding: [0x33,0x87,0x80,0x02]
69 mul a4, ra, s0
70 # CHECK-INST: lr.w t0, (t1)
71 # CHECK: # encoding: [0xaf,0x22,0x03,0x10]
72 lr.w t0, (t1)
74 # Test multi-letter extension
75 # CHECK: .option arch, +zba
76 .option arch, +zba
77 # CHECK-INST: sh1add t0, t1, t2
78 # CHECK: encoding: [0xb3,0x22,0x73,0x20]
79 sh1add t0, t1, t2
81 # Test '.option arch, <arch-string>' directive
82 # CHECK: .option arch, rv32i2p1_m2p0_a2p1_c2p0
83 .option arch, rv32i2p1_m2p0_a2p1_c2p0
85 # CHECK-INST: mul a4, ra, s0
86 # CHECK: # encoding: [0x33,0x87,0x80,0x02]
87 mul a4, ra, s0
88 # CHECK-INST: lr.w t0, (t1)
89 # CHECK: # encoding: [0xaf,0x22,0x03,0x10]
90 lr.w t0, (t1)
92 # Test arch string without version number
93 # CHECK: .option arch, rv32i2p1_m2p0_a2p1_c2p0
94 .option arch, rv32imac
95 # CHECK-INST: mul a4, ra, s0
96 # CHECK: # encoding: [0x33,0x87,0x80,0x02]
97 mul a4, ra, s0
98 # CHECK-INST: lr.w t0, (t1)
99 # CHECK: # encoding: [0xaf,0x22,0x03,0x10]
100 lr.w t0, (t1)
102 # Test +c, -c and vice-versa
103 .option arch, +c, -c
104 # CHECK-INST: addi a0, a1, 0
105 # CHECK: # encoding: [0x13,0x85,0x05,0x00]
106 addi a0, a1, 0
108 .option arch, -c, +c
109 # CHECK-INST: c.mv a0, a1
110 # CHECK: # encoding: [0x2e,0x85]
111 addi a0, a1, 0
113 .option arch, rv32ic
114 # CHECK-INST: c.mv a0, a1
115 # CHECK: # encoding: [0x2e,0x85]
116 addi a0, a1, 0
118 # Test extension name that has digits.
119 .option arch, +zve32x
120 # CHECK: .option arch, +zve32x
122 .option arch, rv32i
123 .option arch, +zce, +f
124 # CHECK-INST: flw fa0, 0(a0)
125 # CHECK: # encoding: [0x08,0x61]
126 c.flw fa0, 0(a0)