Skip to content

Commit 62d5784

Browse files
committed
Add RISC-V target features
1 parent d4bf056 commit 62d5784

File tree

5 files changed

+15
-0
lines changed

5 files changed

+15
-0
lines changed

src/librustc_codegen_llvm/llvm_util.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,15 @@ const POWERPC_WHITELIST: &[(&str, Option<Symbol>)] = &[
236236
const MIPS_WHITELIST: &[(&str, Option<Symbol>)] =
237237
&[("fp64", Some(sym::mips_target_feature)), ("msa", Some(sym::mips_target_feature))];
238238

239+
const RISCV_WHITELIST: &[(&str, Option<Symbol>)] = &[
240+
("m", Some(sym::riscv_target_feature)),
241+
("a", Some(sym::riscv_target_feature)),
242+
("c", Some(sym::riscv_target_feature)),
243+
("f", Some(sym::riscv_target_feature)),
244+
("d", Some(sym::riscv_target_feature)),
245+
("e", Some(sym::riscv_target_feature)),
246+
];
247+
239248
const WASM_WHITELIST: &[(&str, Option<Symbol>)] =
240249
&[("simd128", Some(sym::wasm_target_feature)), ("atomics", Some(sym::wasm_target_feature))];
241250

@@ -253,6 +262,7 @@ pub fn all_known_features() -> impl Iterator<Item = (&'static str, Option<Symbol
253262
.chain(HEXAGON_WHITELIST.iter().cloned())
254263
.chain(POWERPC_WHITELIST.iter().cloned())
255264
.chain(MIPS_WHITELIST.iter().cloned())
265+
.chain(RISCV_WHITELIST.iter().cloned())
256266
.chain(WASM_WHITELIST.iter().cloned())
257267
}
258268

@@ -297,6 +307,7 @@ pub fn target_feature_whitelist(sess: &Session) -> &'static [(&'static str, Opti
297307
"hexagon" => HEXAGON_WHITELIST,
298308
"mips" | "mips64" => MIPS_WHITELIST,
299309
"powerpc" | "powerpc64" => POWERPC_WHITELIST,
310+
"riscv32" | "riscv64" => RISCV_WHITELIST,
300311
"wasm32" => WASM_WHITELIST,
301312
_ => &[],
302313
}

src/librustc_feature/active.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ declare_features! (
228228
(active, hexagon_target_feature, "1.27.0", Some(44839), None),
229229
(active, powerpc_target_feature, "1.27.0", Some(44839), None),
230230
(active, mips_target_feature, "1.27.0", Some(44839), None),
231+
(active, riscv_target_feature, "1.27.0", Some(44839), None),
231232
(active, avx512_target_feature, "1.27.0", Some(44839), None),
232233
(active, mmx_target_feature, "1.27.0", Some(44839), None),
233234
(active, sse4a_target_feature, "1.27.0", Some(44839), None),

src/librustc_span/symbol.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -607,6 +607,7 @@ symbols! {
607607
Result,
608608
Return,
609609
rhs,
610+
riscv_target_feature,
610611
rlib,
611612
rotate_left,
612613
rotate_right,

src/librustc_typeck/collect.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2278,6 +2278,7 @@ fn from_target_feature(
22782278
Some(sym::hexagon_target_feature) => rust_features.hexagon_target_feature,
22792279
Some(sym::powerpc_target_feature) => rust_features.powerpc_target_feature,
22802280
Some(sym::mips_target_feature) => rust_features.mips_target_feature,
2281+
Some(sym::riscv_target_feature) => rust_features.riscv_target_feature,
22812282
Some(sym::avx512_target_feature) => rust_features.avx512_target_feature,
22822283
Some(sym::mmx_target_feature) => rust_features.mmx_target_feature,
22832284
Some(sym::sse4a_target_feature) => rust_features.sse4a_target_feature,

src/test/ui/target-feature/gate.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
// gate-test-movbe_target_feature
2626
// gate-test-rtm_target_feature
2727
// gate-test-f16c_target_feature
28+
// gate-test-riscv_target_feature
2829

2930
#[target_feature(enable = "avx512bw")]
3031
//~^ ERROR: currently unstable

0 commit comments

Comments
 (0)