Struct cranelift_codegen::ir::instructions::OpcodeConstraints
source · pub struct OpcodeConstraints { /* private fields */ }
Expand description
Value type constraints for a given opcode.
The InstructionFormat
determines the constraints on most operands, but Value
operands and
results are not determined by the format. Every Opcode
has an associated
OpcodeConstraints
object that provides the missing details.
Implementations§
source§impl OpcodeConstraints
impl OpcodeConstraints
sourcepub fn use_typevar_operand(self) -> bool
pub fn use_typevar_operand(self) -> bool
Can the controlling type variable for this opcode be inferred from the designated value input operand? This also implies that this opcode is polymorphic.
sourcepub fn requires_typevar_operand(self) -> bool
pub fn requires_typevar_operand(self) -> bool
Is it necessary to look at the designated value input operand in order to determine the controlling type variable, or is it good enough to use the first return type?
Most polymorphic instructions produce a single result with the type of the controlling type
variable. A few polymorphic instructions either don’t produce any results, or produce
results with a fixed type. These instructions return true
.
sourcepub fn num_fixed_results(self) -> usize
pub fn num_fixed_results(self) -> usize
Get the number of fixed result values produced by this opcode.
This does not include variable_args
produced by calls.
sourcepub fn num_fixed_value_arguments(self) -> usize
pub fn num_fixed_value_arguments(self) -> usize
Get the number of fixed input values required by this opcode.
This does not include variable_args
arguments on call and branch instructions.
The number of fixed input values is usually implied by the instruction format, but
instruction formats that use a ValueList
put both fixed and variable arguments in the
list. This method returns the minimum number of values required in the value list.
sourcepub fn result_type(self, n: usize, ctrl_type: Type) -> Type
pub fn result_type(self, n: usize, ctrl_type: Type) -> Type
Get the value type of result number n
, having resolved the controlling type variable to
ctrl_type
.
sourcepub fn value_argument_constraint(
self,
n: usize,
ctrl_type: Type,
) -> ResolvedConstraint
pub fn value_argument_constraint( self, n: usize, ctrl_type: Type, ) -> ResolvedConstraint
Get the value type of input value number n
, having resolved the controlling type variable
to ctrl_type
.
Unlike results, it is possible for some input values to vary freely within a specific
ValueTypeSet
. This is represented with the ArgumentConstraint::Free
variant.
sourcepub fn ctrl_typeset(self) -> Option<ValueTypeSet>
pub fn ctrl_typeset(self) -> Option<ValueTypeSet>
Get the typeset of allowed types for the controlling type variable in a polymorphic instruction.
sourcepub fn is_polymorphic(self) -> bool
pub fn is_polymorphic(self) -> bool
Is this instruction polymorphic?
Trait Implementations§
source§impl Clone for OpcodeConstraints
impl Clone for OpcodeConstraints
source§fn clone(&self) -> OpcodeConstraints
fn clone(&self) -> OpcodeConstraints
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreimpl Copy for OpcodeConstraints
Auto Trait Implementations§
impl Freeze for OpcodeConstraints
impl RefUnwindSafe for OpcodeConstraints
impl Send for OpcodeConstraints
impl Sync for OpcodeConstraints
impl Unpin for OpcodeConstraints
impl UnwindSafe for OpcodeConstraints
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
source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)