aboutsummaryrefslogtreecommitdiff
path: root/llvm/test/MC/RISCV/option-arch.s
blob: 0367ef317e71a9b2bd5f81faaffd9e7d9bf0eb8f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# RUN: llvm-mc -triple riscv32 -mattr=+experimental -show-encoding < %s \
# RUN:   | FileCheck -check-prefixes=CHECK %s
# RUN: llvm-mc -triple riscv32 -mattr=+experimental -filetype=obj < %s \
# RUN:   | llvm-objdump  --triple=riscv32 --mattr=+c,+m,+a,+f,+zba,+experimental-zicfiss -d -M no-aliases - \
# RUN:   | FileCheck -check-prefixes=CHECK-INST %s

# Test '.option arch, +' and '.option arch, -' directive
# The following test cases were copied from MC/RISCV/option-rvc.s

# CHECK-INST: addi a0, a1, 0x0
# CHECK: # encoding:  [0x13,0x85,0x05,0x00]
addi a0, a1, 0

# CHECK-INST: addi s0, sp, 0x3fc
# CHECK: # encoding:  [0x13,0x04,0xc1,0x3f]
addi s0, sp, 1020

# CHECK: .option arch, +c
.option arch, +c
# CHECK-INST: c.mv a0, a1
# CHECK: # encoding:  [0x2e,0x85]
addi a0, a1, 0

# CHECK-INST: c.addi4spn s0, sp, 0x3fc
# CHECK: # encoding:  [0xe0,0x1f]
addi s0, sp, 1020

# CHECK: .option arch, -c, -zca
.option arch, -c, -zca
# CHECK-INST: addi a0, a1, 0x0
# CHECK: # encoding:  [0x13,0x85,0x05,0x00]
addi a0, a1, 0

# CHECK-INST: addi s0, sp, 0x3fc
# CHECK: # encoding:  [0x13,0x04,0xc1,0x3f]
addi s0, sp, 1020

# CHECK: .option arch, +c
.option arch, +c
# CHECK-INST: c.mv a0, a1
# CHECK: # encoding:  [0x2e,0x85]
addi a0, a1, 0

# CHECK-INST: c.addi4spn s0, sp, 0x3fc
# CHECK: # encoding:  [0xe0,0x1f]
addi s0, sp, 1020

# CHECK: .option arch, -c, -zca
.option arch, -c, -zca
# CHECK-INST: addi a0, a1, 0x0
# CHECK: # encoding:  [0x13,0x85,0x05,0x00]
addi a0, a1, 0

# CHECK-INST: addi s0, sp, 0x3fc
# CHECK: # encoding:  [0x13,0x04,0xc1,0x3f]
addi s0, sp, 1020

# CHECK: .option arch, +d, -d
.option arch, +d, -d
# CHECK-INST: flw ft0, 0xc(a0)
# CHECK: # encoding:  [0x07,0x20,0xc5,0x00]
flw f0, 12(a0)

# Test comma-separated list
# CHECK: arch, +m, +a
.option arch, +m, +a
# CHECK-INST: mul a4, ra, s0
# CHECK: # encoding:  [0x33,0x87,0x80,0x02]
mul a4, ra, s0
# CHECK-INST: lr.w t0, (t1)
# CHECK: # encoding:  [0xaf,0x22,0x03,0x10]
lr.w t0, (t1)

# Test multi-letter extension
# CHECK: .option arch, +zba
.option arch, +zba
# CHECK-INST: sh1add t0, t1, t2
# CHECK: encoding: [0xb3,0x22,0x73,0x20]
sh1add t0, t1, t2

# Test experimental extension
# CHECK: .option arch, +zicfiss
.option arch, +zicfiss
# CHECK-INST: sspopchk ra
# CHECK: encoding: [0x73,0xc0,0xc0,0xcd]
sspopchk ra

# Test '.option arch, <arch-string>' directive
# CHECK: .option arch, rv32i2p1_m2p0_a2p1_c2p0
.option arch, rv32i2p1_m2p0_a2p1_c2p0

# CHECK-INST: mul a4, ra, s0
# CHECK: # encoding:  [0x33,0x87,0x80,0x02]
mul a4, ra, s0
# CHECK-INST: lr.w t0, (t1)
# CHECK: # encoding:  [0xaf,0x22,0x03,0x10]
lr.w t0, (t1)

# Test arch string without version number
# CHECK: .option arch, rv32i2p1_m2p0_a2p1_c2p0
.option arch, rv32imac
# CHECK-INST: mul a4, ra, s0
# CHECK: # encoding:  [0x33,0x87,0x80,0x02]
mul a4, ra, s0
# CHECK-INST: lr.w t0, (t1)
# CHECK: # encoding:  [0xaf,0x22,0x03,0x10]
lr.w t0, (t1)

# Test +c, -c and vice-versa
.option arch, +c, -c, -zca
# CHECK-INST: addi a0, a1, 0x0
# CHECK: # encoding:  [0x13,0x85,0x05,0x00]
addi a0, a1, 0

.option arch, -c, -zca, +c
# CHECK-INST: c.mv a0, a1
# CHECK: # encoding:  [0x2e,0x85]
addi a0, a1, 0

.option arch, rv32ic
# CHECK-INST: c.mv a0, a1
# CHECK: # encoding:  [0x2e,0x85]
addi a0, a1, 0

# Test extension name that has digits.
.option arch, +zve32x
# CHECK: .option arch, +zve32x

.option arch, rv32i
.option arch, +zce, +f
# CHECK-INST: flw fa0, 0x0(a0)
# CHECK: # encoding: [0x08,0x61]
c.flw fa0, 0(a0)