Skip to content

Commit 66f88de

Browse files
authored
[RISCV] Support RISC-V Profiles in -march option (#76357)
This PR implements the draft riscv-non-isa/riscv-toolchain-conventions#36. Currently, we replace specified profile in `-march` with standard arch string.
1 parent de7a50f commit 66f88de

File tree

3 files changed

+377
-0
lines changed

3 files changed

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

0 commit comments

Comments
 (0)