Skip to content

Commit 03aa3b8

Browse files
authored
Rollup merge of #145415 - a4lg:riscv-implication-to-c, r=Amanieu
std_detect: RISC-V: implement implication to "C" Just like we implemented relatively complex rules to imply other extensions **from** "C" (and some others), this commit implements implication **to** the "C" extension from others, complying the following text in the ISA Manual (although there's no direct imply/depend references). > The C extension is the superset of the following extensions: > > - Zca > - Zcf if F is specified (RV32 only) > - Zcd if D is specified This is formally verified so that no other extension combinations (*not* in this implementation) can (currently) imply the "C" extension. Note: this is a `std_detect` change and not main target feature handling.
2 parents 62582eb + ee7627e commit 03aa3b8

File tree

1 file changed

+21
-1
lines changed
  • library/std_detect/src/detect/os

1 file changed

+21
-1
lines changed

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

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,31 @@ pub(crate) fn imply_features(mut value: cache::Initializer) -> cache::Initialize
119119
imply!(d | zfhmin | zfa => f);
120120
imply!(zfbfmin => f); // and some of (not all) "Zfh" instructions.
121121

122-
// Relatively complex implication rules from the "C" extension.
122+
// Relatively complex implication rules around the "C" extension.
123+
// (from "C" and some others)
123124
imply!(c => zca);
124125
imply!(c & d => zcd);
125126
#[cfg(target_arch = "riscv32")]
126127
imply!(c & f => zcf);
128+
// (to "C"; defined as superset)
129+
cfg_select! {
130+
target_arch = "riscv32" => {
131+
if value.test(Feature::d as u32) {
132+
imply!(zcf & zcd => c);
133+
} else if value.test(Feature::f as u32) {
134+
imply!(zcf => c);
135+
} else {
136+
imply!(zca => c);
137+
}
138+
}
139+
_ => {
140+
if value.test(Feature::d as u32) {
141+
imply!(zcd => c);
142+
} else {
143+
imply!(zca => c);
144+
}
145+
}
146+
}
127147

128148
imply!(zicntr | zihpm | f | zfinx | zve32x => zicsr);
129149

0 commit comments

Comments
 (0)