[−][src]Struct cranelift_frontend::Switch
Unlike with br_table
, Switch
cases may be sparse or non-0-based.
They emit efficient code using branches, jump tables, or a combination of both.
Example
let block0 = builder.create_ebb(); let block1 = builder.create_ebb(); let block2 = builder.create_ebb(); let fallback = builder.create_ebb(); let val = builder.ins().iconst(I32, 1); let mut switch = Switch::new(); switch.set_entry(0, block0); switch.set_entry(1, block1); switch.set_entry(7, block2); switch.emit(&mut builder, val, fallback);
Methods
impl Switch
[src]
pub fn new() -> Self
[src]
Create a new empty switch
pub fn set_entry(&mut self, index: u64, ebb: Ebb)
[src]
Set a switch entry
pub fn emit(self, bx: &mut FunctionBuilder, val: Value, otherwise: Ebb)
[src]
Trait Implementations
Auto Trait Implementations
impl Unpin for Switch
impl Sync for Switch
impl Send for Switch
impl UnwindSafe for Switch
impl RefUnwindSafe for Switch
Blanket Implementations
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,