Skip to content

Commit 61028ad

Browse files
wangpc-ppchencha3
authored andcommitted
[RISCV] Support RISC-V Profiles in -march option (llvm#76357)
This PR implements the draft riscv-non-isa/riscv-toolchain-conventions#36. Currently, we replace specified profile in `-march` with standard arch string. This is recommitted as 66f88de was reverted because of failures caused by lacking `--target` option.
1 parent 78b3503 commit 61028ad

File tree

3 files changed

+389
-0
lines changed

3 files changed

+389
-0
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ RISC-V Support
520520
^^^^^^^^^^^^^^
521521

522522
- ``__attribute__((rvv_vector_bits(N)))`` is now supported for RVV vbool*_t types.
523+
- Profile names in ``-march`` option are now supported.
523524

524525
CUDA/HIP Language Changes
525526
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/test/Driver/riscv-profiles.c

Lines changed: 324 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,324 @@
1+
// RUN: %clang --target=riscv32 -### -c %s 2>&1 -march=rvi20u32 \
2+
// RUN: | FileCheck -check-prefix=RVI20U32 %s
3+
// RVI20U32: "-target-feature" "-a"
4+
// RVI20U32: "-target-feature" "-c"
5+
// RVI20U32: "-target-feature" "-d"
6+
// RVI20U32: "-target-feature" "-f"
7+
// RVI20U32: "-target-feature" "-m"
8+
9+
// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rvi20u64 \
10+
// RUN: | FileCheck -check-prefix=RVI20U64 %s
11+
// RVI20U64: "-target-feature" "-a"
12+
// RVI20U64: "-target-feature" "-c"
13+
// RVI20U64: "-target-feature" "-d"
14+
// RVI20U64: "-target-feature" "-f"
15+
// RVI20U64: "-target-feature" "-m"
16+
17+
// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rva20u64 \
18+
// RUN: | FileCheck -check-prefix=RVA20U64 %s
19+
// RVA20U64: "-target-feature" "+m"
20+
// RVA20U64: "-target-feature" "+a"
21+
// RVA20U64: "-target-feature" "+f"
22+
// RVA20U64: "-target-feature" "+d"
23+
// RVA20U64: "-target-feature" "+c"
24+
// RVA20U64: "-target-feature" "+ziccamoa"
25+
// RVA20U64: "-target-feature" "+ziccif"
26+
// RVA20U64: "-target-feature" "+zicclsm"
27+
// RVA20U64: "-target-feature" "+ziccrse"
28+
// RVA20U64: "-target-feature" "+zicntr"
29+
// RVA20U64: "-target-feature" "+zicsr"
30+
// RVA20U64: "-target-feature" "+za128rs"
31+
32+
// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rva20s64 \
33+
// RUN: | FileCheck -check-prefix=RVA20S64 %s
34+
// RVA20S64: "-target-feature" "+m"
35+
// RVA20S64: "-target-feature" "+a"
36+
// RVA20S64: "-target-feature" "+f"
37+
// RVA20S64: "-target-feature" "+d"
38+
// RVA20S64: "-target-feature" "+c"
39+
// RVA20S64: "-target-feature" "+ziccamoa"
40+
// RVA20S64: "-target-feature" "+ziccif"
41+
// RVA20S64: "-target-feature" "+zicclsm"
42+
// RVA20S64: "-target-feature" "+ziccrse"
43+
// RVA20S64: "-target-feature" "+zicntr"
44+
// RVA20S64: "-target-feature" "+zicsr"
45+
// RVA20S64: "-target-feature" "+zifencei"
46+
// RVA20S64: "-target-feature" "+za128rs"
47+
// RVA20S64: "-target-feature" "+ssccptr"
48+
// RVA20S64: "-target-feature" "+sstvala"
49+
// RVA20S64: "-target-feature" "+sstvecd"
50+
// RVA20S64: "-target-feature" "+svade"
51+
// RVA20S64: "-target-feature" "+svbare"
52+
53+
// RUN: %clang --target=riscv64 --target=riscv64 -### -c %s 2>&1 -march=rva22u64 \
54+
// RUN: | FileCheck -check-prefix=RVA22U64 %s
55+
// RVA22U64: "-target-feature" "+m"
56+
// RVA22U64: "-target-feature" "+a"
57+
// RVA22U64: "-target-feature" "+f"
58+
// RVA22U64: "-target-feature" "+d"
59+
// RVA22U64: "-target-feature" "+c"
60+
// RVA22U64: "-target-feature" "+zic64b"
61+
// RVA22U64: "-target-feature" "+zicbom"
62+
// RVA22U64: "-target-feature" "+zicbop"
63+
// RVA22U64: "-target-feature" "+zicboz"
64+
// RVA22U64: "-target-feature" "+ziccamoa"
65+
// RVA22U64: "-target-feature" "+ziccif"
66+
// RVA22U64: "-target-feature" "+zicclsm"
67+
// RVA22U64: "-target-feature" "+ziccrse"
68+
// RVA22U64: "-target-feature" "+zicntr"
69+
// RVA22U64: "-target-feature" "+zicsr"
70+
// RVA22U64: "-target-feature" "+zihintpause"
71+
// RVA22U64: "-target-feature" "+zihpm"
72+
// RVA22U64: "-target-feature" "+za64rs"
73+
// RVA22U64: "-target-feature" "+zfhmin"
74+
// RVA22U64: "-target-feature" "+zba"
75+
// RVA22U64: "-target-feature" "+zbb"
76+
// RVA22U64: "-target-feature" "+zbs"
77+
// RVA22U64: "-target-feature" "+zkt"
78+
79+
// RUN: %clang --target=riscv64 --target=riscv64 -### -c %s 2>&1 -march=rva22s64 \
80+
// RUN: | FileCheck -check-prefix=RVA22S64 %s
81+
// RVA22S64: "-target-feature" "+m"
82+
// RVA22S64: "-target-feature" "+a"
83+
// RVA22S64: "-target-feature" "+f"
84+
// RVA22S64: "-target-feature" "+d"
85+
// RVA22S64: "-target-feature" "+c"
86+
// RVA22S64: "-target-feature" "+zic64b"
87+
// RVA22S64: "-target-feature" "+zicbom"
88+
// RVA22S64: "-target-feature" "+zicbop"
89+
// RVA22S64: "-target-feature" "+zicboz"
90+
// RVA22S64: "-target-feature" "+ziccamoa"
91+
// RVA22S64: "-target-feature" "+ziccif"
92+
// RVA22S64: "-target-feature" "+zicclsm"
93+
// RVA22S64: "-target-feature" "+ziccrse"
94+
// RVA22S64: "-target-feature" "+zicntr"
95+
// RVA22S64: "-target-feature" "+zicsr"
96+
// RVA22S64: "-target-feature" "+zifencei"
97+
// RVA22S64: "-target-feature" "+zihintpause"
98+
// RVA22S64: "-target-feature" "+zihpm"
99+
// RVA22S64: "-target-feature" "+za64rs"
100+
// RVA22S64: "-target-feature" "+zfhmin"
101+
// RVA22S64: "-target-feature" "+zba"
102+
// RVA22S64: "-target-feature" "+zbb"
103+
// RVA22S64: "-target-feature" "+zbs"
104+
// RVA22S64: "-target-feature" "+zkt"
105+
// RVA22S64: "-target-feature" "+ssccptr"
106+
// RVA22S64: "-target-feature" "+sscounterenw"
107+
// RVA22S64: "-target-feature" "+sstvala"
108+
// RVA22S64: "-target-feature" "+sstvecd"
109+
// RVA22S64: "-target-feature" "+svade"
110+
// RVA22S64: "-target-feature" "+svbare"
111+
// RVA22S64: "-target-feature" "+svinval"
112+
// RVA22S64: "-target-feature" "+svpbmt"
113+
114+
// RUN: %clang --target=riscv64 --target=riscv64 -### -c %s 2>&1 -march=rva23u64 -menable-experimental-extensions \
115+
// RUN: | FileCheck -check-prefix=RVA23U64 %s
116+
// RVA23U64: "-target-feature" "+m"
117+
// RVA23U64: "-target-feature" "+a"
118+
// RVA23U64: "-target-feature" "+f"
119+
// RVA23U64: "-target-feature" "+d"
120+
// RVA23U64: "-target-feature" "+c"
121+
// RVA23U64: "-target-feature" "+v"
122+
// RVA23U64: "-target-feature" "+zic64b"
123+
// RVA23U64: "-target-feature" "+zicbom"
124+
// RVA23U64: "-target-feature" "+zicbop"
125+
// RVA23U64: "-target-feature" "+zicboz"
126+
// RVA23U64: "-target-feature" "+ziccamoa"
127+
// RVA23U64: "-target-feature" "+ziccif"
128+
// RVA23U64: "-target-feature" "+zicclsm"
129+
// RVA23U64: "-target-feature" "+ziccrse"
130+
// RVA23U64: "-target-feature" "+zicntr"
131+
// RVA23U64: "-target-feature" "+zicond"
132+
// RVA23U64: "-target-feature" "+zicsr"
133+
// RVA23U64: "-target-feature" "+zihintntl"
134+
// RVA23U64: "-target-feature" "+zihintpause"
135+
// RVA23U64: "-target-feature" "+zihpm"
136+
// RVA23U64: "-target-feature" "+experimental-zimop"
137+
// RVA23U64: "-target-feature" "+za64rs"
138+
// RVA23U64: "-target-feature" "+zawrs"
139+
// RVA23U64: "-target-feature" "+zfa"
140+
// RVA23U64: "-target-feature" "+zfhmin"
141+
// RVA23U64: "-target-feature" "+zcb"
142+
// RVA23U64: "-target-feature" "+experimental-zcmop"
143+
// RVA23U64: "-target-feature" "+zba"
144+
// RVA23U64: "-target-feature" "+zbb"
145+
// RVA23U64: "-target-feature" "+zbs"
146+
// RVA23U64: "-target-feature" "+zkt"
147+
// RVA23U64: "-target-feature" "+zvbb"
148+
// RVA23U64: "-target-feature" "+zvfhmin"
149+
// RVA23U64: "-target-feature" "+zvkt"
150+
151+
// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rva23s64 -menable-experimental-extensions \
152+
// RUN: | FileCheck -check-prefix=RVA23S64 %s
153+
// RVA23S64: "-target-feature" "+m"
154+
// RVA23S64: "-target-feature" "+a"
155+
// RVA23S64: "-target-feature" "+f"
156+
// RVA23S64: "-target-feature" "+d"
157+
// RVA23S64: "-target-feature" "+c"
158+
// RVA23S64: "-target-feature" "+v"
159+
// RVA23S64: "-target-feature" "+h"
160+
// RVA23S64: "-target-feature" "+zic64b"
161+
// RVA23S64: "-target-feature" "+zicbom"
162+
// RVA23S64: "-target-feature" "+zicbop"
163+
// RVA23S64: "-target-feature" "+zicboz"
164+
// RVA23S64: "-target-feature" "+ziccamoa"
165+
// RVA23S64: "-target-feature" "+ziccif"
166+
// RVA23S64: "-target-feature" "+zicclsm"
167+
// RVA23S64: "-target-feature" "+ziccrse"
168+
// RVA23S64: "-target-feature" "+zicntr"
169+
// RVA23S64: "-target-feature" "+zicond"
170+
// RVA23S64: "-target-feature" "+zicsr"
171+
// RVA23S64: "-target-feature" "+zifencei"
172+
// RVA23S64: "-target-feature" "+zihintntl"
173+
// RVA23S64: "-target-feature" "+zihintpause"
174+
// RVA23S64: "-target-feature" "+zihpm"
175+
// RVA23S64: "-target-feature" "+experimental-zimop"
176+
// RVA23S64: "-target-feature" "+za64rs"
177+
// RVA23S64: "-target-feature" "+zawrs"
178+
// RVA23S64: "-target-feature" "+zfa"
179+
// RVA23S64: "-target-feature" "+zfhmin"
180+
// RVA23S64: "-target-feature" "+zcb"
181+
// RVA23S64: "-target-feature" "+experimental-zcmop"
182+
// RVA23S64: "-target-feature" "+zba"
183+
// RVA23S64: "-target-feature" "+zbb"
184+
// RVA23S64: "-target-feature" "+zbs"
185+
// RVA23S64: "-target-feature" "+zkt"
186+
// RVA23S64: "-target-feature" "+zvbb"
187+
// RVA23S64: "-target-feature" "+zvfhmin"
188+
// RVA23S64: "-target-feature" "+zvkt"
189+
// RVA23S64: "-target-feature" "+shcounterenw"
190+
// RVA23S64: "-target-feature" "+shgatpa"
191+
// RVA23S64: "-target-feature" "+shtvala"
192+
// RVA23S64: "-target-feature" "+shvsatpa"
193+
// RVA23S64: "-target-feature" "+shvstvala"
194+
// RVA23S64: "-target-feature" "+shvstvecd"
195+
// RVA23S64: "-target-feature" "+ssccptr"
196+
// RVA23S64: "-target-feature" "+sscofpmf"
197+
// RVA23S64: "-target-feature" "+sscounterenw"
198+
// RVA23S64: "-target-feature" "+experimental-ssnpm"
199+
// RVA23S64: "-target-feature" "+ssstateen"
200+
// RVA23S64: "-target-feature" "+sstc"
201+
// RVA23S64: "-target-feature" "+sstvala"
202+
// RVA23S64: "-target-feature" "+sstvecd"
203+
// RVA23S64: "-target-feature" "+ssu64xl"
204+
// RVA23S64: "-target-feature" "+svade"
205+
// RVA23S64: "-target-feature" "+svbare"
206+
// RVA23S64: "-target-feature" "+svinval"
207+
// RVA23S64: "-target-feature" "+svnapot"
208+
// RVA23S64: "-target-feature" "+svpbmt"
209+
210+
// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rvb23u64 -menable-experimental-extensions \
211+
// RUN: | FileCheck -check-prefix=RVB23U64 %s
212+
// RVB23U64: "-target-feature" "+m"
213+
// RVB23U64: "-target-feature" "+a"
214+
// RVB23U64: "-target-feature" "+f"
215+
// RVB23U64: "-target-feature" "+d"
216+
// RVB23U64: "-target-feature" "+c"
217+
// RVB23U64: "-target-feature" "+zic64b"
218+
// RVB23U64: "-target-feature" "+zicbom"
219+
// RVB23U64: "-target-feature" "+zicbop"
220+
// RVB23U64: "-target-feature" "+zicboz"
221+
// RVB23U64: "-target-feature" "+ziccamoa"
222+
// RVB23U64: "-target-feature" "+ziccif"
223+
// RVB23U64: "-target-feature" "+zicclsm"
224+
// RVB23U64: "-target-feature" "+ziccrse"
225+
// RVB23U64: "-target-feature" "+zicntr"
226+
// RVB23U64: "-target-feature" "+zicond"
227+
// RVB23U64: "-target-feature" "+zicsr"
228+
// RVB23U64: "-target-feature" "+zihintntl"
229+
// RVB23U64: "-target-feature" "+zihintpause"
230+
// RVB23U64: "-target-feature" "+zihpm"
231+
// RVB23U64: "-target-feature" "+experimental-zimop"
232+
// RVB23U64: "-target-feature" "+za64rs"
233+
// RVB23U64: "-target-feature" "+zawrs"
234+
// RVB23U64: "-target-feature" "+zfa"
235+
// RVB23U64: "-target-feature" "+zcb"
236+
// RVB23U64: "-target-feature" "+experimental-zcmop"
237+
// RVB23U64: "-target-feature" "+zba"
238+
// RVB23U64: "-target-feature" "+zbb"
239+
// RVB23U64: "-target-feature" "+zbs"
240+
// RVB23U64: "-target-feature" "+zkt"
241+
242+
// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rvb23s64 -menable-experimental-extensions \
243+
// RUN: | FileCheck -check-prefix=RVB23S64 %s
244+
// RVB23S64: "-target-feature" "+m"
245+
// RVB23S64: "-target-feature" "+a"
246+
// RVB23S64: "-target-feature" "+f"
247+
// RVB23S64: "-target-feature" "+d"
248+
// RVB23S64: "-target-feature" "+c"
249+
// RVB23S64: "-target-feature" "+zic64b"
250+
// RVB23S64: "-target-feature" "+zicbom"
251+
// RVB23S64: "-target-feature" "+zicbop"
252+
// RVB23S64: "-target-feature" "+zicboz"
253+
// RVB23S64: "-target-feature" "+ziccamoa"
254+
// RVB23S64: "-target-feature" "+ziccif"
255+
// RVB23S64: "-target-feature" "+zicclsm"
256+
// RVB23S64: "-target-feature" "+ziccrse"
257+
// RVB23S64: "-target-feature" "+zicntr"
258+
// RVB23S64: "-target-feature" "+zicond"
259+
// RVB23S64: "-target-feature" "+zicsr"
260+
// RVB23S64: "-target-feature" "+zifencei"
261+
// RVB23S64: "-target-feature" "+zihintntl"
262+
// RVB23S64: "-target-feature" "+zihintpause"
263+
// RVB23S64: "-target-feature" "+zihpm"
264+
// RVB23S64: "-target-feature" "+experimental-zimop"
265+
// RVB23S64: "-target-feature" "+za64rs"
266+
// RVB23S64: "-target-feature" "+zawrs"
267+
// RVB23S64: "-target-feature" "+zfa"
268+
// RVB23S64: "-target-feature" "+zcb"
269+
// RVB23S64: "-target-feature" "+experimental-zcmop"
270+
// RVB23S64: "-target-feature" "+zba"
271+
// RVB23S64: "-target-feature" "+zbb"
272+
// RVB23S64: "-target-feature" "+zbs"
273+
// RVB23S64: "-target-feature" "+zkt"
274+
// RVB23S64: "-target-feature" "+ssccptr"
275+
// RVB23S64: "-target-feature" "+sscofpmf"
276+
// RVB23S64: "-target-feature" "+sscounterenw"
277+
// RVB23S64: "-target-feature" "+sstc"
278+
// RVB23S64: "-target-feature" "+sstvala"
279+
// RVB23S64: "-target-feature" "+sstvecd"
280+
// RVB23S64: "-target-feature" "+ssu64xl"
281+
// RVB23S64: "-target-feature" "+svade"
282+
// RVB23S64: "-target-feature" "+svbare"
283+
// RVB23S64: "-target-feature" "+svinval"
284+
// RVB23S64: "-target-feature" "+svnapot"
285+
// RVB23S64: "-target-feature" "+svpbmt"
286+
287+
// RUN: %clang --target=riscv32 -### -c %s 2>&1 -march=rvm23u32 -menable-experimental-extensions \
288+
// RUN: | FileCheck -check-prefix=RVM23U32 %s
289+
// RVM23U32: "-target-feature" "+m"
290+
// RVM23U32: "-target-feature" "+zicbop"
291+
// RVM23U32: "-target-feature" "+zicond"
292+
// RVM23U32: "-target-feature" "+zicsr"
293+
// RVM23U32: "-target-feature" "+zihintntl"
294+
// RVM23U32: "-target-feature" "+zihintpause"
295+
// RVM23U32: "-target-feature" "+experimental-zimop"
296+
// RVM23U32: "-target-feature" "+zce"
297+
// RVM23U32: "-target-feature" "+experimental-zcmop"
298+
// RVM23U32: "-target-feature" "+zba"
299+
// RVM23U32: "-target-feature" "+zbb"
300+
// RVM23U32: "-target-feature" "+zbs"
301+
302+
// RUN: %clang --target=riscv64 -### -c %s 2>&1 -march=rva22u64_zfa \
303+
// RUN: | FileCheck -check-prefix=PROFILE-WITH-ADDITIONAL %s
304+
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+m"
305+
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+a"
306+
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+f"
307+
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+d"
308+
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+c"
309+
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zicbom"
310+
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zicbop"
311+
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zicboz"
312+
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zihintpause"
313+
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zfa"
314+
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zfhmin"
315+
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zba"
316+
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zbb"
317+
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zbs"
318+
// PROFILE-WITH-ADDITIONAL: "-target-feature" "+zkt"
319+
320+
// RUN: not %clang --target=riscv64 -### -c %s 2>&1 -march=rva19u64_zfa | FileCheck -check-prefix=INVALID-PROFILE %s
321+
// INVALID-PROFILE: error: invalid arch name 'rva19u64_zfa', unsupported profile
322+
323+
// RUN: not %clang --target=riscv64 -### -c %s 2>&1 -march=rva22u64zfa | FileCheck -check-prefix=INVALID-ADDITIONAL %s
324+
// INVALID-ADDITIONAL: error: invalid arch name 'rva22u64zfa', additional extensions must be after separator '_'

0 commit comments

Comments
 (0)