pub struct Target {Show 18 fields
pub xlen: Xlen,
pub privileged: bool,
pub supervisor_mode: bool,
pub m: bool,
pub a: bool,
pub f: bool,
pub d: bool,
pub q: bool,
pub c: bool,
pub zicsr: bool,
pub zifencei: bool,
pub zawrs: bool,
pub zfh: bool,
pub zba: bool,
pub zbb: bool,
pub zbc: bool,
pub zbkb: bool,
pub zbs: bool,
}Expand description
RISC-V target configuration.
§Example
let target = Target::from_str("RV32IMACZifencei_Zicsr").unwrap();
assert_eq!(
target,
Target {
xlen: Xlen::Rv32,
m: true,
a: true,
c: true,
zifencei: true,
zicsr: true,
..Default::default()
},
);Fields§
§xlen: XlenRegister width.
privileged: boolWhether instructions from the privileged spec are supported.
supervisor_mode: boolWhether S-mode (supervisor) instructions are supported.
m: boolM standard extension (integer multiply and divide).
a: boolA standard extension (atomics).
f: boolF standard extension (32-bit floating point).
d: boolD standard extension (64-bit (double) floating point).
q: boolQ standard extension (128-bit (quad) floating point).
c: boolC standard extension (16-bit compressed instructions).
zicsr: boolZicsr standard extension.
zifencei: boolZifencei standard extension.
zawrs: boolZawrs standard extension.
zfh: boolZfh standard extension (16-bit (half) floating point).
zba: boolZba standard extension (bitmanip).
zbb: boolZbb standard extension (bitmanip).
zbc: boolZbc standard extension (bitmanip).
zbkb: boolZbkb standard extension (bitmanip for cryptography).
zbs: boolZbs standard extension (bitmanip).
Implementations§
Source§impl Target
impl Target
Sourcepub fn supports(&self, extension: &str) -> Result<bool, ParseTargetError>
pub fn supports(&self, extension: &str) -> Result<bool, ParseTargetError>
Check whether this target supports an extension.
The given extension is case-insensitive and must not be multiple extensions. Both supersets and subsets of extension groups can be used.
Register widths can be given as either X, rvX, or rvXi (e.g. 32,
rv32, rv32i).
Examples:
let target = Target::from_str("RV32IMACZba_Zbb_Zbs").unwrap();
// Single-letter extensions:
assert_eq!(target.supports("M").unwrap(), true);
assert_eq!(target.supports("F").unwrap(), false);
// Multi-letter extensions:
assert_eq!(target.supports("Zifencei").unwrap(), false);
// Supersets and subsets of extensions:
assert_eq!(target.supports("B").unwrap(), true);
assert_eq!(target.supports("Zba").unwrap(), true);
// Register widths:
assert_eq!(target.supports("RV32").unwrap(), true);
assert_eq!(target.supports("RV64").unwrap(), false);Sourcepub fn contains(&self, other: &Target) -> bool
pub fn contains(&self, other: &Target) -> bool
Check whether this target contains another, i.e. it is a superset of the other.
All features of other must be supported by self for this to be true.
Note that two targets with different XLENs will always return false because
instruction encodings will have strict differences between the two.
Sourcepub fn from_str_strict(s: &str) -> Result<Self, ParseTargetError>
pub fn from_str_strict(s: &str) -> Result<Self, ParseTargetError>
Parse a target string, only accepting those which match the spec.
The strict layout requires:
- The string begins
RV32orRV64. - Single-letter extensions must be in the order given by the spec.
- Z-extensions must come at the end.
- Z-extensions are first ordered into groups by their second character, then alphabetically.
- Multi-character extensions must be separated by underscores.