Target

Struct Target 

Source
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: Xlen

Register width.

§privileged: bool

Whether instructions from the privileged spec are supported.

§supervisor_mode: bool

Whether S-mode (supervisor) instructions are supported.

§m: bool

M standard extension (integer multiply and divide).

§a: bool

A standard extension (atomics).

§f: bool

F standard extension (32-bit floating point).

§d: bool

D standard extension (64-bit (double) floating point).

§q: bool

Q standard extension (128-bit (quad) floating point).

§c: bool

C standard extension (16-bit compressed instructions).

§zicsr: bool

Zicsr standard extension.

§zifencei: bool

Zifencei standard extension.

§zawrs: bool

Zawrs standard extension.

§zfh: bool

Zfh standard extension (16-bit (half) floating point).

§zba: bool

Zba standard extension (bitmanip).

§zbb: bool

Zbb standard extension (bitmanip).

§zbc: bool

Zbc standard extension (bitmanip).

§zbkb: bool

Zbkb standard extension (bitmanip for cryptography).

§zbs: bool

Zbs standard extension (bitmanip).

Implementations§

Source§

impl Target

Source

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);
Source

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.

Source

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 RV32 or RV64.
  • 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.

Trait Implementations§

Source§

impl Clone for Target

Source§

fn clone(&self) -> Target

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Target

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Target

Source§

fn default() -> Target

Returns the “default value” for a type. Read more
Source§

impl Display for Target

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl FromStr for Target

Source§

fn from_str(s: &str) -> Result<Self, Self::Err>

Parse a RISC-V target from a target string, e.g. RV64IMAFDZicsr_Zifencei

Target strings are case-insensitive. The non-standard riscv prefix is accepted due to its use in target tuples/triples.

Source§

type Err = ParseTargetError

The associated error which can be returned from parsing.
Source§

impl PartialEq for Target

Source§

fn eq(&self, other: &Target) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for Target

Source§

impl Eq for Target

Source§

impl StructuralPartialEq for Target

Auto Trait Implementations§

§

impl Freeze for Target

§

impl RefUnwindSafe for Target

§

impl Send for Target

§

impl Sync for Target

§

impl Unpin for Target

§

impl UnwindSafe for Target

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.