Clang Project

clang_source_code/test/Driver/riscv-arch.c
1// RUN: %clang -target riscv32-unknown-elf -march=rv32i -### %s \
2// RUN: -fsyntax-only 2>&1 | FileCheck %s
3// RUN: %clang -target riscv32-unknown-elf -march=rv32im -### %s \
4// RUN: -fsyntax-only 2>&1 | FileCheck %s
5// RUN: %clang -target riscv32-unknown-elf -march=rv32ima -### %s \
6// RUN: -fsyntax-only 2>&1 | FileCheck %s
7// RUN: %clang -target riscv32-unknown-elf -march=rv32imaf -### %s \
8// RUN: -fsyntax-only 2>&1 | FileCheck %s
9// RUN: %clang -target riscv32-unknown-elf -march=rv32imafd -### %s \
10// RUN: -fsyntax-only 2>&1 | FileCheck %s
11
12// RUN: %clang -target riscv32-unknown-elf -march=rv32ic -### %s \
13// RUN: -fsyntax-only 2>&1 | FileCheck %s
14// RUN: %clang -target riscv32-unknown-elf -march=rv32imc -### %s \
15// RUN: -fsyntax-only 2>&1 | FileCheck %s
16// RUN: %clang -target riscv32-unknown-elf -march=rv32imac -### %s \
17// RUN: -fsyntax-only 2>&1 | FileCheck %s
18// RUN: %clang -target riscv32-unknown-elf -march=rv32imafc -### %s \
19// RUN: -fsyntax-only 2>&1 | FileCheck %s
20// RUN: %clang -target riscv32-unknown-elf -march=rv32imafdc -### %s \
21// RUN: -fsyntax-only 2>&1 | FileCheck %s
22
23// RUN: %clang -target riscv32-unknown-elf -march=rv32ia -### %s \
24// RUN: -fsyntax-only 2>&1 | FileCheck %s
25// RUN: %clang -target riscv32-unknown-elf -march=rv32iaf -### %s \
26// RUN: -fsyntax-only 2>&1 | FileCheck %s
27// RUN: %clang -target riscv32-unknown-elf -march=rv32iafd -### %s \
28// RUN: -fsyntax-only 2>&1 | FileCheck %s
29
30// RUN: %clang -target riscv32-unknown-elf -march=rv32iac -### %s \
31// RUN: -fsyntax-only 2>&1 | FileCheck %s
32// RUN: %clang -target riscv32-unknown-elf -march=rv32iafc -### %s \
33// RUN: -fsyntax-only 2>&1 | FileCheck %s
34// RUN: %clang -target riscv32-unknown-elf -march=rv32iafdc -### %s \
35// RUN: -fsyntax-only 2>&1 | FileCheck %s
36
37// RUN: %clang -target riscv32-unknown-elf -march=rv32g -### %s \
38// RUN: -fsyntax-only 2>&1 | FileCheck %s
39// RUN: %clang -target riscv32-unknown-elf -march=rv32gc -### %s \
40// RUN: -fsyntax-only 2>&1 | FileCheck %s
41
42// RUN: %clang -target riscv64-unknown-elf -march=rv64i -### %s \
43// RUN: -fsyntax-only 2>&1 | FileCheck %s
44// RUN: %clang -target riscv64-unknown-elf -march=rv64im -### %s \
45// RUN: -fsyntax-only 2>&1 | FileCheck %s
46// RUN: %clang -target riscv64-unknown-elf -march=rv64ima -### %s \
47// RUN: -fsyntax-only 2>&1 | FileCheck %s
48// RUN: %clang -target riscv64-unknown-elf -march=rv64imaf -### %s \
49// RUN: -fsyntax-only 2>&1 | FileCheck %s
50// RUN: %clang -target riscv64-unknown-elf -march=rv64imafd -### %s \
51// RUN: -fsyntax-only 2>&1 | FileCheck %s
52
53// RUN: %clang -target riscv64-unknown-elf -march=rv64ic -### %s \
54// RUN: -fsyntax-only 2>&1 | FileCheck %s
55// RUN: %clang -target riscv64-unknown-elf -march=rv64imc -### %s \
56// RUN: -fsyntax-only 2>&1 | FileCheck %s
57// RUN: %clang -target riscv64-unknown-elf -march=rv64imac -### %s \
58// RUN: -fsyntax-only 2>&1 | FileCheck %s
59// RUN: %clang -target riscv64-unknown-elf -march=rv64imafc -### %s \
60// RUN: -fsyntax-only 2>&1 | FileCheck %s
61// RUN: %clang -target riscv64-unknown-elf -march=rv64imafdc -### %s \
62// RUN: -fsyntax-only 2>&1 | FileCheck %s
63
64// RUN: %clang -target riscv64-unknown-elf -march=rv64ia -### %s \
65// RUN: -fsyntax-only 2>&1 | FileCheck %s
66// RUN: %clang -target riscv64-unknown-elf -march=rv64iaf -### %s \
67// RUN: -fsyntax-only 2>&1 | FileCheck %s
68// RUN: %clang -target riscv64-unknown-elf -march=rv64iafd -### %s \
69// RUN: -fsyntax-only 2>&1 | FileCheck %s
70
71// RUN: %clang -target riscv64-unknown-elf -march=rv64iac -### %s \
72// RUN: -fsyntax-only 2>&1 | FileCheck %s
73// RUN: %clang -target riscv64-unknown-elf -march=rv64iafc -### %s \
74// RUN: -fsyntax-only 2>&1 | FileCheck %s
75// RUN: %clang -target riscv64-unknown-elf -march=rv64iafdc -### %s \
76// RUN: -fsyntax-only 2>&1 | FileCheck %s
77
78// RUN: %clang -target riscv64-unknown-elf -march=rv64g -### %s \
79// RUN: -fsyntax-only 2>&1 | FileCheck %s
80// RUN: %clang -target riscv64-unknown-elf -march=rv64gc -### %s \
81// RUN: -fsyntax-only 2>&1 | FileCheck %s
82
83// CHECK-NOT: error: invalid arch name '
84
85// RUN: %clang -target riscv32-unknown-elf -march=rv32 -### %s \
86// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32 %s
87// RV32: error: invalid arch name 'rv32'
88
89// RUN: %clang -target riscv32-unknown-elf -march=rv32m -### %s \
90// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32M %s
91// RV32M: error: invalid arch name 'rv32m'
92
93// RUN: %clang -target riscv32-unknown-elf -march=rv32id -### %s \
94// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32ID %s
95// RV32ID: error: invalid arch name 'rv32id'
96
97// RUN: %clang -target riscv32-unknown-elf -march=rv32l -### %s \
98// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32L %s
99// RV32L: error: invalid arch name 'rv32l'
100
101// RUN: %clang -target riscv32-unknown-elf -march=rv32imadf -### %s \
102// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32IMADF %s
103// RV32IMADF: error: invalid arch name 'rv32imadf'
104
105// RUN: %clang -target riscv32-unknown-elf -march=rv32imm -### %s \
106// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32IMM %s
107// RV32IMM: error: invalid arch name 'rv32imm'
108
109// RUN: %clang -target riscv32-unknown-elf -march=RV32I -### %s \
110// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32I-UPPER %s
111// RV32I-UPPER: error: invalid arch name 'RV32I'
112
113// RUN: %clang -target riscv64-unknown-elf -march=rv64 -### %s \
114// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64 %s
115// RV64: error: invalid arch name 'rv64'
116
117// RUN: %clang -target riscv64-unknown-elf -march=rv64m -### %s \
118// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64M %s
119// RV64M: error: invalid arch name 'rv64m'
120
121// RUN: %clang -target riscv64-unknown-elf -march=rv64id -### %s \
122// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64ID %s
123// RV64ID: error: invalid arch name 'rv64id'
124
125// RUN: %clang -target riscv64-unknown-elf -march=rv64l -### %s \
126// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64L %s
127// RV64L: error: invalid arch name 'rv64l'
128
129// RUN: %clang -target riscv64-unknown-elf -march=rv64imadf -### %s \
130// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64IMADF %s
131// RV64IMADF: error: invalid arch name 'rv64imadf'
132
133// RUN: %clang -target riscv64-unknown-elf -march=rv64imm -### %s \
134// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64IMM %s
135// RV64IMM: error: invalid arch name 'rv64imm'
136
137// RUN: %clang -target riscv64-unknown-elf -march=RV64I -### %s \
138// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64I-UPPER %s
139// RV64I-UPPER: error: invalid arch name 'RV64I'
140
141
142// Testing specific messages and unsupported extensions.
143
144// RUN: %clang -target riscv32-unknown-elf -march=rv32e -### %s \
145// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32E %s
146// RV32E: error: invalid arch name 'rv32e',
147// RV32E: standard user-level extension 'e'
148
149// RUN: %clang -target riscv64-unknown-elf -march=rv64e -### %s \
150// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV64E %s
151// RV64E: error: invalid arch name 'rv64e',
152// RV64E: standard user-level extension 'e' requires 'rv32'
153
154// RUN: %clang -target riscv32-unknown-elf -march=rv32imC -### %s \
155// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-LOWER %s
156// RV32-LOWER: error: invalid arch name 'rv32imC',
157// RV32-LOWER: string must be lowercase
158
159// RUN: %clang -target riscv32-unknown-elf -march=rv32 -### %s \
160// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-STR %s
161// RV32-STR: error: invalid arch name 'rv32',
162// RV32-STR: string must begin with rv32{i,e,g} or rv64{i,g}
163
164// RUN: %clang -target riscv32-unknown-elf -march=rv32q -### %s \
165// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-LETTER %s
166// RV32-LETTER: error: invalid arch name 'rv32q',
167// RV32-LETTER: first letter should be 'e', 'i' or 'g'
168
169// RUN: %clang -target riscv32-unknown-elf -march=rv32imcq -### %s \
170// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-ORDER %s
171// RV32-ORDER: error: invalid arch name 'rv32imcq',
172// RV32-ORDER: standard user-level extension not given in canonical order 'q'
173
174// RUN: %clang -target riscv32-unknown-elf -march=rv32imw -### %s \
175// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-STD-INVAL %s
176// RV32-STD-INVAL: error: invalid arch name 'rv32imw',
177// RV32-STD-INVAL: invalid standard user-level extension 'w'
178
179// RUN: %clang -target riscv32-unknown-elf -march=rv32imqc -### %s \
180// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-STD %s
181// RV32-STD: error: invalid arch name 'rv32imqc',
182// RV32-STD: unsupported standard user-level extension 'q'
183
184// RUN: %clang -target riscv32-unknown-elf -march=rv32xabc -### %s \
185// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32X %s
186// RV32X: error: invalid arch name 'rv32xabc',
187// RV32X: first letter should be 'e', 'i' or 'g'
188
189// RUN: %clang -target riscv32-unknown-elf -march=rv32sxabc -### %s \
190// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32SX %s
191// RV32SX: error: invalid arch name 'rv32sxabc',
192// RV32SX: first letter should be 'e', 'i' or 'g'
193
194// RUN: %clang -target riscv32-unknown-elf -march=rv32sabc -### %s \
195// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32S %s
196// RV32S: error: invalid arch name 'rv32sabc',
197// RV32S: first letter should be 'e', 'i' or 'g'
198
199// RUN: %clang -target riscv32-unknown-elf -march=rv32ix -### %s \
200// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32X-NAME %s
201// RV32X-NAME: error: invalid arch name 'rv32ix',
202// RV32X-NAME: non-standard user-level extension name missing after 'x'
203
204// RUN: %clang -target riscv32-unknown-elf -march=rv32isx -### %s \
205// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32SX-NAME %s
206// RV32SX-NAME: error: invalid arch name 'rv32isx',
207// RV32SX-NAME: non-standard supervisor-level extension
208// RV32SX-NAME: name missing after 'sx'
209
210// RUN: %clang -target riscv32-unknown-elf -march=rv32is -### %s \
211// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32S-NAME %s
212// RV32S-NAME: error: invalid arch name 'rv32is',
213// RV32S-NAME: standard supervisor-level extension
214// RV32S-NAME: name missing after 's'
215
216// RUN: %clang -target riscv32-unknown-elf -march=rv32ix_s_sx -### %s \
217// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32ALL-NAME %s
218// RV32ALL-NAME: error: invalid arch name 'rv32ix_s_sx',
219// RV32ALL-NAME: non-standard user-level extension
220// RV32ALL-NAME: name missing after 'x'
221
222// RUN: %clang -target riscv32-unknown-elf -march=rv32ixabc -### %s \
223// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32X-UNS %s
224// RV32X-UNS: error: invalid arch name 'rv32ixabc',
225// RV32X-UNS: unsupported non-standard user-level extension 'xabc'
226
227// RUN: %clang -target riscv32-unknown-elf -march=rv32isa -### %s \
228// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32S-UNS %s
229// RV32S-UNS: error: invalid arch name 'rv32isa',
230// RV32S-UNS: unsupported standard supervisor-level extension 'sa'
231
232// RUN: %clang -target riscv32-unknown-elf -march=rv32isxabc -### %s \
233// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32SX-UNS %s
234// RV32SX-UNS: error: invalid arch name 'rv32isxabc',
235// RV32SX-UNS: unsupported non-standard supervisor-level extension 'sxabc'
236
237// RUN: %clang -target riscv32-unknown-elf -march=rv32ixabc_sp_sxlw -### %s \
238// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32ALL %s
239// RV32ALL: error: invalid arch name 'rv32ixabc_sp_sxlw',
240// RV32ALL: unsupported non-standard user-level extension 'xabc'
241
242// RUN: %clang -target riscv32-unknown-elf -march=rv32i20 -### %s \
243// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-IVER %s
244// RV32-IVER: error: invalid arch name 'rv32i20', unsupported
245// RV32-IVER: version number 20 for extension 'i'
246
247// RUN: %clang -target riscv32-unknown-elf -march=rv32imc5 -### %s \
248// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-CVER %s
249// RV32-CVER: error: invalid arch name 'rv32imc5', unsupported
250// RV32-CVER: version number 5 for extension 'c'
251
252// RUN: %clang -target riscv32-unknown-elf -march=rv32i2p -### %s \
253// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-IMINOR-MISS %s
254// RV32-IMINOR-MISS: error: invalid arch name 'rv32i2p',
255// RV32-IMINOR-MISS: minor version number missing after 'p' for extension 'i'
256
257// RUN: %clang -target riscv32-unknown-elf -march=rv32i2p0 -### %s \
258// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-IMINOR0 %s
259// RV32-IMINOR0: error: invalid arch name 'rv32i2p0',
260// RV32-IMINOR0: unsupported version number 2.0 for extension 'i'
261
262// RUN: %clang -target riscv32-unknown-elf -march=rv32i2p1 -### %s \
263// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-IMINOR1 %s
264// RV32-IMINOR1: error: invalid arch name 'rv32i2p1', unsupported
265// RV32-IMINOR1: version number 2.1 for extension 'i'
266
267// RUN: %clang -target riscv32-unknown-elf -march=rv32ix2p -### %s \
268// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-XMINOR-MISS %s
269// RV32-XMINOR-MISS: error: invalid arch name 'rv32ix2p',
270// RV32-XMINOR-MISS: minor version number missing after 'p' for extension 'x2p'
271
272// RUN: %clang -target riscv32-unknown-elf -march=rv32is2p0 -### %s \
273// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-SMINOR0 %s
274// RV32-SMINOR0: error: invalid arch name 'rv32is2p0',
275// RV32-SMINOR0: unsupported version number 2.0 for extension 's2p0'
276
277// RUN: %clang -target riscv32-unknown-elf -march=rv32isx2p1 -### %s \
278// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-SXMINOR1 %s
279// RV32-SXMINOR1: error: invalid arch name 'rv32isx2p1', unsupported
280// RV32-SXMINOR1: version number 2.1 for extension 'sx2p1'
281
282// RUN: %clang -target riscv32-unknown-elf -march=rv32ixabc_ -### %s \
283// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-XSEP %s
284// RV32-XSEP: error: invalid arch name 'rv32ixabc_',
285// RV32-XSEP: extension name missing after separator '_'
286
287// RUN: %clang -target riscv32-unknown-elf -march=rv32ixabc_a -### %s \
288// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-PREFIX %s
289// RV32-PREFIX: error: invalid arch name 'rv32ixabc_a',
290// RV32-PREFIX: invalid extension prefix 'a'
291
292// RUN: %clang -target riscv32-unknown-elf -march=rv32isabc_xdef -### %s \
293// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-X-ORDER %s
294// RV32-X-ORDER: error: invalid arch name 'rv32isabc_xdef',
295// RV32-X-ORDER: non-standard user-level extension not given
296// RV32-X-ORDER: in canonical order 'xdef'
297
298// RUN: %clang -target riscv32-unknown-elf -march=rv32isxabc_sdef -### %s \
299// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-S-ORDER %s
300// RV32-S-ORDER: error: invalid arch name 'rv32isxabc_sdef',
301// RV32-S-ORDER: standard supervisor-level extension not given
302// RV32-S-ORDER: in canonical order 'sdef'
303
304// RUN: %clang -target riscv32-unknown-elf -march=rv32ixabc_xabc -### %s \
305// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-XDUP %s
306// RV32-XDUP: error: invalid arch name 'rv32ixabc_xabc',
307// RV32-XDUP: duplicated non-standard user-level extension 'xabc'
308
309// RUN: %clang -target riscv32-unknown-elf -march=rv32ixabc_xdef -### %s \
310// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-X-X-INVAL %s
311// RV32-X-X-INVAL: error: invalid arch name 'rv32ixabc_xdef', unsupported
312// RV32-X-X-INVAL: non-standard user-level extension 'xabc'
313
314// RUN: %clang -target riscv32-unknown-elf -march=rv32ixabc_sdef_sxghi -### %s \
315// RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-X-S-SX-INVAL %s
316// RV32-X-S-SX-INVAL: error: invalid arch name 'rv32ixabc_sdef_sxghi',
317// RV32-X-S-SX-INVAL: unsupported non-standard user-level extension 'xabc'
318