Skip to content

Commit a05552d

Browse files
committed
std_detect: RISC-V: Best effort implication by target config (C-related)
On the RISC-V architecture, there are some complex implications around the "C" extension. This commit implements implication of such target features in a best effort manner. The reason why we can make this exact is lack of `"zcd"` and `"zcf"` target features (that would require additional feature handling system). Still, weaker implications implemented here are formally verified to be optimal if we have to avoid tautology (except `"c"`) and uses of `"zcf"` and `"zcd"` are prohibited. For "C", the author deduced minimal expression which makes equal to the "C" extension and extracted all cases where `"zcd"` and `"zcf"` are not involved. For "Zcd" and "Zcf", the author created proof statements, each stating that implication expression (which avoids tautology and accidentally avoids using `"zcd"` or `"zcf"`) is optimal to force corresponding target feature to be enabled.
1 parent bd2bb51 commit a05552d

File tree

1 file changed

+10
-2
lines changed
  • library/std_detect/src/detect/arch

1 file changed

+10
-2
lines changed

library/std_detect/src/detect/arch/riscv.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -270,14 +270,22 @@ features! {
270270
/// "Zhinxmin" Extension for Minimal Half-Precision Floating-Point in Integer Registers
271271
272272
@FEATURE: #[stable(feature = "riscv_ratified", since = "1.78.0")] c: "c";
273+
implied by cfg(any(
274+
target_feature = "c",
275+
all(
276+
not(target_feature = "d"),
277+
any(not(target_arch = "riscv32"), not(target_feature = "f")),
278+
target_feature = "zca",
279+
)
280+
));
273281
/// "C" Extension for Compressed Instructions
274282
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zca: "zca";
275283
/// "Zca" Compressed Instructions excluding Floating-Point Loads/Stores
276284
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zcf: "zcf";
277-
without cfg check: true;
285+
implied by cfg(all(target_arch = "riscv32", target_feature = "c", target_feature = "f"));
278286
/// "Zcf" Compressed Instructions for Single-Precision Floating-Point Loads/Stores on RV32
279287
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zcd: "zcd";
280-
without cfg check: true;
288+
implied by cfg(all(target_feature = "c", target_feature = "d"));
281289
/// "Zcd" Compressed Instructions for Double-Precision Floating-Point Loads/Stores
282290
@FEATURE: #[unstable(feature = "stdarch_riscv_feature_detection", issue = "111192")] zcb: "zcb";
283291
/// "Zcb" Simple Code-size Saving Compressed Instructions

0 commit comments

Comments
 (0)