pub struct Value(pub Index);
Tuple Fields
0: Index
Implementations
sourceimpl Value
impl Value
sourcepub fn new_argument(context: &mut Context, arg: BlockArgument) -> Value
pub fn new_argument(context: &mut Context, arg: BlockArgument) -> Value
Return a new argument Value
.
sourcepub fn new_constant(context: &mut Context, constant: Constant) -> Value
pub fn new_constant(context: &mut Context, constant: Constant) -> Value
Return a new constant Value
.
sourcepub fn new_instruction(context: &mut Context, instruction: Instruction) -> Value
pub fn new_instruction(context: &mut Context, instruction: Instruction) -> Value
Return a new instruction Value
.
sourcepub fn add_metadatum(
self,
context: &mut Context,
md_idx: Option<MetadataIndex>
) -> Self
pub fn add_metadatum(
self,
context: &mut Context,
md_idx: Option<MetadataIndex>
) -> Self
Add some metadata to this value.
As a convenience the md_idx
argument is an Option
, in which case this function is a
no-op.
If there is no existing metadata then the new metadata are added alone. Otherwise the new metadatum are added to the list of metadata.
sourcepub fn get_metadata(&self, context: &Context) -> Option<MetadataIndex>
pub fn get_metadata(&self, context: &Context) -> Option<MetadataIndex>
Return this value’s metadata.
sourcepub fn is_constant(&self, context: &Context) -> bool
pub fn is_constant(&self, context: &Context) -> bool
Return whether this is a constant value.
sourcepub fn is_terminator(&self, context: &Context) -> bool
pub fn is_terminator(&self, context: &Context) -> bool
Return whether this value is an instruction, and specifically a ‘terminator’.
A terminator is always the last instruction in a block (and may not appear anywhere else) and is either a branch or return.
pub fn is_diverging(&self, context: &Context) -> bool
sourcepub fn replace_instruction_values(
&self,
context: &mut Context,
replace_map: &FxHashMap<Value, Value>
)
pub fn replace_instruction_values(
&self,
context: &mut Context,
replace_map: &FxHashMap<Value, Value>
)
If this value is an instruction and if any of its parameters is old_val
then replace them
with new_val
.
sourcepub fn replace(&self, context: &mut Context, other: ValueDatum)
pub fn replace(&self, context: &mut Context, other: ValueDatum)
Replace this value with another one, in-place.
sourcepub fn get_instruction<'a>(
&self,
context: &'a Context
) -> Option<&'a Instruction>
pub fn get_instruction<'a>(
&self,
context: &'a Context
) -> Option<&'a Instruction>
Get a reference to this value as an instruction, iff it is one.
sourcepub fn get_instruction_mut<'a>(
&self,
context: &'a mut Context
) -> Option<&'a mut Instruction>
pub fn get_instruction_mut<'a>(
&self,
context: &'a mut Context
) -> Option<&'a mut Instruction>
Get a mutable reference to this value as an instruction, iff it is one.
sourcepub fn get_constant<'a>(&self, context: &'a Context) -> Option<&'a Constant>
pub fn get_constant<'a>(&self, context: &'a Context) -> Option<&'a Constant>
Get a reference to this value as a constant, iff it is one.
sourcepub fn get_argument_type(&self, context: &Context) -> Option<Type>
pub fn get_argument_type(&self, context: &Context) -> Option<Type>
Iff this value is an argument, return its type.
sourcepub fn get_type(&self, context: &Context) -> Option<Type>
pub fn get_type(&self, context: &Context) -> Option<Type>
Get the type for this value, if found.
Arguments and constants always have a type, but only some instructions do.
sourcepub fn get_pointer(&self, context: &Context) -> Option<Pointer>
pub fn get_pointer(&self, context: &Context) -> Option<Pointer>
Get the pointer argument for this value if there is one. I.e., where get_ptr is essentially a Value wrapper around a Pointer, this function unwrap it.
sourcepub fn get_stripped_ptr_type(&self, context: &Context) -> Option<Type>
pub fn get_stripped_ptr_type(&self, context: &Context) -> Option<Type>
Get the type for this value with any pointer stripped, if found.