pub struct ValueRange { /* private fields */ }Expand description
The results of one instruction: a run of consecutive values.
An instruction defines zero or more values, always with consecutive handles, so the run is stored as a start and a length rather than a list.
§Examples
use ir_lang::{Module, Signature, Type, Linkage, MemOrder};
let mut m = Module::new("demo");
let f = m.declare_function("f", &Signature::new(&[Type::Ptr], &[]), Linkage::Export)?;
let mut b = m.build(f)?;
let p = b.param(0)?;
let old = b.iconst(Type::I64, 1)?;
let new = b.iconst(Type::I64, 2)?;
let inst = b.cmpxchg(p, old, new, MemOrder::SeqCst, MemOrder::SeqCst)?;
let results = b.results(inst);
assert_eq!(results.len(), 2);
assert_eq!(results.get(1), Some(results.first().unwrap().next()));Implementations§
Source§impl ValueRange
impl ValueRange
Sourcepub const fn len(self) -> usize
pub const fn len(self) -> usize
The number of values in the run.
§Examples
use ir_lang::ValueRange;
assert_eq!(ValueRange::default().len(), 0);Sourcepub const fn is_empty(self) -> bool
pub const fn is_empty(self) -> bool
Whether the run is empty (the instruction defines nothing).
§Examples
use ir_lang::ValueRange;
assert!(ValueRange::default().is_empty());Sourcepub const fn get(self, i: usize) -> Option<Value>
pub const fn get(self, i: usize) -> Option<Value>
The i-th value of the run, if there is one.
§Examples
use ir_lang::ValueRange;
assert_eq!(ValueRange::default().get(0), None);Sourcepub const fn first(self) -> Option<Value>
pub const fn first(self) -> Option<Value>
The first value of the run, if there is one.
§Examples
use ir_lang::ValueRange;
assert_eq!(ValueRange::default().first(), None);Sourcepub const fn contains(self, value: Value) -> bool
pub const fn contains(self, value: Value) -> bool
Whether value is one of the run’s values.
§Examples
use ir_lang::{Value, ValueRange};
assert!(!ValueRange::default().contains(Value::from_u32(0)));Sourcepub fn iter(self) -> impl ExactSizeIterator<Item = Value> + DoubleEndedIterator
pub fn iter(self) -> impl ExactSizeIterator<Item = Value> + DoubleEndedIterator
Iterates over the run’s values in order.
§Examples
use ir_lang::ValueRange;
assert_eq!(ValueRange::default().iter().count(), 0);Trait Implementations§
Source§impl Clone for ValueRange
impl Clone for ValueRange
impl Copy for ValueRange
Source§impl Debug for ValueRange
impl Debug for ValueRange
Source§impl Default for ValueRange
impl Default for ValueRange
impl Eq for ValueRange
Source§impl Hash for ValueRange
impl Hash for ValueRange
Source§impl IntoIterator for ValueRange
impl IntoIterator for ValueRange
Source§impl PartialEq for ValueRange
impl PartialEq for ValueRange
impl StructuralPartialEq for ValueRange
Auto Trait Implementations§
impl Freeze for ValueRange
impl RefUnwindSafe for ValueRange
impl Send for ValueRange
impl Sync for ValueRange
impl Unpin for ValueRange
impl UnsafeUnpin for ValueRange
impl UnwindSafe for ValueRange
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more