-
Notifications
You must be signed in to change notification settings - Fork 53
/
0039-RISCV-MC-layer-support-for-the-standard-RV64A-instru.patch
265 lines (261 loc) · 12 KB
/
0039-RISCV-MC-layer-support-for-the-standard-RV64A-instru.patch
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Alex Bradbury <[email protected]>
Subject: [RISCV] MC layer support for the standard RV64A instruction set
extension
---
lib/Target/RISCV/RISCVInstrInfoA.td | 14 +++
test/MC/RISCV/rv32a-invalid.s | 3 +
test/MC/RISCV/rv64a-invalid.s | 14 +++
test/MC/RISCV/rv64a-valid.s | 189 ++++++++++++++++++++++++++++++++++++
4 files changed, 220 insertions(+)
create mode 100644 test/MC/RISCV/rv64a-invalid.s
create mode 100644 test/MC/RISCV/rv64a-valid.s
diff --git a/lib/Target/RISCV/RISCVInstrInfoA.td b/lib/Target/RISCV/RISCVInstrInfoA.td
index 54f35c3c0ba..33e863ba6a1 100644
--- a/lib/Target/RISCV/RISCVInstrInfoA.td
+++ b/lib/Target/RISCV/RISCVInstrInfoA.td
@@ -61,3 +61,17 @@ defm AMOMAX_W : AMO_rr_aq_rl<0b10100, 0b010, "amomax.w">;
defm AMOMINU_W : AMO_rr_aq_rl<0b11000, 0b010, "amominu.w">;
defm AMOMAXU_W : AMO_rr_aq_rl<0b11100, 0b010, "amomaxu.w">;
} // Predicates = [HasStdExtA]
+
+let Predicates = [HasStdExtA, IsRV64] in {
+defm LR_D : LR_r_aq_rl<0b011, "lr.d">;
+defm SC_D : AMO_rr_aq_rl<0b00011, 0b011, "sc.d">;
+defm AMOSWAP_D : AMO_rr_aq_rl<0b00001, 0b011, "amoswap.d">;
+defm AMOADD_D : AMO_rr_aq_rl<0b00000, 0b011, "amoadd.d">;
+defm AMOXOR_D : AMO_rr_aq_rl<0b00100, 0b011, "amoxor.d">;
+defm AMOAND_D : AMO_rr_aq_rl<0b01100, 0b011, "amoand.d">;
+defm AMOOR_D : AMO_rr_aq_rl<0b01000, 0b011, "amoor.d">;
+defm AMOMIN_D : AMO_rr_aq_rl<0b10000, 0b011, "amomin.d">;
+defm AMOMAX_D : AMO_rr_aq_rl<0b10100, 0b011, "amomax.d">;
+defm AMOMINU_D : AMO_rr_aq_rl<0b11000, 0b011, "amominu.d">;
+defm AMOMAXU_D : AMO_rr_aq_rl<0b11100, 0b011, "amomaxu.d">;
+} // Predicates = [HasStedExtA, IsRV64]
diff --git a/test/MC/RISCV/rv32a-invalid.s b/test/MC/RISCV/rv32a-invalid.s
index 0b293ac26fa..8ee21bc501b 100644
--- a/test/MC/RISCV/rv32a-invalid.s
+++ b/test/MC/RISCV/rv32a-invalid.s
@@ -12,3 +12,6 @@ amoor.w. a4, a5, (a6) # CHECK: :[[@LINE]]:1: error: unrecognized instruction mne
# lr only takes two operands
lr.w s0, (s1), s2 # CHECK: :[[@LINE]]:16: error: invalid operand for instruction
+
+# Note: errors for use of RV64A instructions for RV32 are checked in
+# rv64a-valid.s
diff --git a/test/MC/RISCV/rv64a-invalid.s b/test/MC/RISCV/rv64a-invalid.s
new file mode 100644
index 00000000000..7ab89ff9994
--- /dev/null
+++ b/test/MC/RISCV/rv64a-invalid.s
@@ -0,0 +1,14 @@
+# RUN: not llvm-mc -triple riscv64 -mattr=+a < %s 2>&1 | FileCheck %s
+
+# Final operand must have parentheses
+amoswap.d a1, a2, a3 # CHECK: :[[@LINE]]:19: error: invalid operand for instruction
+amomin.d a1, a2, 1 # CHECK: :[[@LINE]]:18: error: invalid operand for instruction
+lr.d a4, a5 # CHECK: :[[@LINE]]:10: error: invalid operand for instruction
+
+# Only .aq, .rl, and .aqrl suffixes are valid
+amoxor.d.rlqa a2, a3, (a4) # CHECK: :[[@LINE]]:1: error: unrecognized instruction mnemonic
+amoor.d.aq.rl a4, a5, (a6) # CHECK: :[[@LINE]]:1: error: unrecognized instruction mnemonic
+amoor.d. a4, a5, (a6) # CHECK: :[[@LINE]]:1: error: unrecognized instruction mnemonic
+
+# lr only takes two operands
+lr.d s0, (s1), s2 # CHECK: :[[@LINE]]:16: error: invalid operand for instruction
diff --git a/test/MC/RISCV/rv64a-valid.s b/test/MC/RISCV/rv64a-valid.s
new file mode 100644
index 00000000000..18299548ffa
--- /dev/null
+++ b/test/MC/RISCV/rv64a-valid.s
@@ -0,0 +1,189 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+a -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK,CHECK-INST %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+a < %s \
+# RUN: | llvm-objdump -mattr=+a -d - | FileCheck -check-prefix=CHECK-INST %s
+# RUN: not llvm-mc -triple riscv32 -mattr=+a < %s 2>&1 \
+# RUN: | FileCheck -check-prefix=CHECK-RV32 %s
+
+# CHECK-INST: lr.d t0, (t1)
+# CHECK: encoding: [0xaf,0x32,0x03,0x10]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+lr.d t0, (t1)
+# CHECK-INST: lr.d.aq t1, (t2)
+# CHECK: encoding: [0x2f,0xb3,0x03,0x14]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+lr.d.aq t1, (t2)
+# CHECK-INST: lr.d.rl t2, (t3)
+# CHECK: encoding: [0xaf,0x33,0x0e,0x12]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+lr.d.rl t2, (t3)
+# CHECK-INST: lr.d.aqrl t3, (t4)
+# CHECK: encoding: [0x2f,0xbe,0x0e,0x16]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+lr.d.aqrl t3, (t4)
+
+# CHECK-INST: sc.d t6, t5, (t4)
+# CHECK: encoding: [0xaf,0xbf,0xee,0x19]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+sc.d t6, t5, (t4)
+# CHECK-INST: sc.d.aq t5, t4, (t3)
+# CHECK: encoding: [0x2f,0x3f,0xde,0x1d]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+sc.d.aq t5, t4, (t3)
+# CHECK-INST: sc.d.rl t4, t3, (t2)
+# CHECK: encoding: [0xaf,0xbe,0xc3,0x1b]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+sc.d.rl t4, t3, (t2)
+# CHECK-INST: sc.d.aqrl t3, t2, (t1)
+# CHECK: encoding: [0x2f,0x3e,0x73,0x1e]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+sc.d.aqrl t3, t2, (t1)
+
+# CHECK-INST: amoswap.d a4, ra, (s0)
+# CHECK: encoding: [0x2f,0x37,0x14,0x08]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoswap.d a4, ra, (s0)
+# CHECK-INST: amoadd.d a1, a2, (a3)
+# CHECK: encoding: [0xaf,0xb5,0xc6,0x00]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoadd.d a1, a2, (a3)
+# CHECK-INST: amoxor.d a2, a3, (a4)
+# CHECK: encoding: [0x2f,0x36,0xd7,0x20]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoxor.d a2, a3, (a4)
+# CHECK-INST: amoand.d a3, a4, (a5)
+# CHECK: encoding: [0xaf,0xb6,0xe7,0x60]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoand.d a3, a4, (a5)
+# CHECK-INST: amoor.d a4, a5, (a6)
+# CHECK: encoding: [0x2f,0x37,0xf8,0x40]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoor.d a4, a5, (a6)
+# CHECK-INST: amomin.d a5, a6, (a7)
+# CHECK: encoding: [0xaf,0xb7,0x08,0x81]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amomin.d a5, a6, (a7)
+# CHECK-INST: amomax.d s7, s6, (s5)
+# CHECK: encoding: [0xaf,0xbb,0x6a,0xa1]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amomax.d s7, s6, (s5)
+# CHECK-INST: amominu.d s6, s5, (s4)
+# CHECK: encoding: [0x2f,0x3b,0x5a,0xc1]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amominu.d s6, s5, (s4)
+# CHECK-INST: amomaxu.d s5, s4, (s3)
+# CHECK: encoding: [0xaf,0xba,0x49,0xe1]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amomaxu.d s5, s4, (s3)
+
+
+# CHECK-INST: amoswap.d.aq a4, ra, (s0)
+# CHECK: encoding: [0x2f,0x37,0x14,0x0c]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoswap.d.aq a4, ra, (s0)
+# CHECK-INST: amoadd.d.aq a1, a2, (a3)
+# CHECK: encoding: [0xaf,0xb5,0xc6,0x04]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoadd.d.aq a1, a2, (a3)
+# CHECK-INST: amoxor.d.aq a2, a3, (a4)
+# CHECK: encoding: [0x2f,0x36,0xd7,0x24]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoxor.d.aq a2, a3, (a4)
+# CHECK-INST: amoand.d.aq a3, a4, (a5)
+# CHECK: encoding: [0xaf,0xb6,0xe7,0x64]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoand.d.aq a3, a4, (a5)
+# CHECK-INST: amoor.d.aq a4, a5, (a6)
+# CHECK: encoding: [0x2f,0x37,0xf8,0x44]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoor.d.aq a4, a5, (a6)
+# CHECK-INST: amomin.d.aq a5, a6, (a7)
+# CHECK: encoding: [0xaf,0xb7,0x08,0x85]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amomin.d.aq a5, a6, (a7)
+# CHECK-INST: amomax.d.aq s7, s6, (s5)
+# CHECK: encoding: [0xaf,0xbb,0x6a,0xa5]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amomax.d.aq s7, s6, (s5)
+# CHECK-INST: amominu.d.aq s6, s5, (s4)
+# CHECK: encoding: [0x2f,0x3b,0x5a,0xc5]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amominu.d.aq s6, s5, (s4)
+# CHECK-INST: amomaxu.d.aq s5, s4, (s3)
+# CHECK: encoding: [0xaf,0xba,0x49,0xe5]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amomaxu.d.aq s5, s4, (s3)
+
+# CHECK-INST: amoswap.d.rl a4, ra, (s0)
+# CHECK: encoding: [0x2f,0x37,0x14,0x0a]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoswap.d.rl a4, ra, (s0)
+# CHECK-INST: amoadd.d.rl a1, a2, (a3)
+# CHECK: encoding: [0xaf,0xb5,0xc6,0x02]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoadd.d.rl a1, a2, (a3)
+# CHECK-INST: amoxor.d.rl a2, a3, (a4)
+# CHECK: encoding: [0x2f,0x36,0xd7,0x22]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoxor.d.rl a2, a3, (a4)
+# CHECK-INST: amoand.d.rl a3, a4, (a5)
+# CHECK: encoding: [0xaf,0xb6,0xe7,0x62]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoand.d.rl a3, a4, (a5)
+# CHECK-INST: amoor.d.rl a4, a5, (a6)
+# CHECK: encoding: [0x2f,0x37,0xf8,0x42]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoor.d.rl a4, a5, (a6)
+# CHECK-INST: amomin.d.rl a5, a6, (a7)
+# CHECK: encoding: [0xaf,0xb7,0x08,0x83]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amomin.d.rl a5, a6, (a7)
+# CHECK-INST: amomax.d.rl s7, s6, (s5)
+# CHECK: encoding: [0xaf,0xbb,0x6a,0xa3]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amomax.d.rl s7, s6, (s5)
+# CHECK-INST: amominu.d.rl s6, s5, (s4)
+# CHECK: encoding: [0x2f,0x3b,0x5a,0xc3]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amominu.d.rl s6, s5, (s4)
+# CHECK-INST: amomaxu.d.rl s5, s4, (s3)
+# CHECK: encoding: [0xaf,0xba,0x49,0xe3]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amomaxu.d.rl s5, s4, (s3)
+
+# CHECK-INST: amoswap.d.aqrl a4, ra, (s0)
+# CHECK: encoding: [0x2f,0x37,0x14,0x0e]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoswap.d.aqrl a4, ra, (s0)
+# CHECK-INST: amoadd.d.aqrl a1, a2, (a3)
+# CHECK: encoding: [0xaf,0xb5,0xc6,0x06]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoadd.d.aqrl a1, a2, (a3)
+# CHECK-INST: amoxor.d.aqrl a2, a3, (a4)
+# CHECK: encoding: [0x2f,0x36,0xd7,0x26]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoxor.d.aqrl a2, a3, (a4)
+# CHECK-INST: amoand.d.aqrl a3, a4, (a5)
+# CHECK: encoding: [0xaf,0xb6,0xe7,0x66]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoand.d.aqrl a3, a4, (a5)
+# CHECK-INST: amoor.d.aqrl a4, a5, (a6)
+# CHECK: encoding: [0x2f,0x37,0xf8,0x46]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amoor.d.aqrl a4, a5, (a6)
+# CHECK-INST: amomin.d.aqrl a5, a6, (a7)
+# CHECK: encoding: [0xaf,0xb7,0x08,0x87]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amomin.d.aqrl a5, a6, (a7)
+# CHECK-INST: amomax.d.aqrl s7, s6, (s5)
+# CHECK: encoding: [0xaf,0xbb,0x6a,0xa7]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amomax.d.aqrl s7, s6, (s5)
+# CHECK-INST: amominu.d.aqrl s6, s5, (s4)
+# CHECK: encoding: [0x2f,0x3b,0x5a,0xc7]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amominu.d.aqrl s6, s5, (s4)
+# CHECK-INST: amomaxu.d.aqrl s5, s4, (s3)
+# CHECK: encoding: [0xaf,0xba,0x49,0xe7]
+# CHECK-RV32: :[[@LINE+1]]:1: error: instruction use requires an option to be enabled
+amomaxu.d.aqrl s5, s4, (s3)
--
2.16.2