MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / get_constraint

Function get_constraint

cranelift/codegen/meta/src/gen_inst.rs:788–814  ·  view source on GitHub ↗

Get the value type constraint for an SSA value operand, where `ctrl_typevar` is the controlling type variable. Each operand constraint is represented as a string, one of: - `Concrete(vt)`, where `vt` is a value type name. - `Free(idx)` where `idx` is an index into `type_sets`. - `Same`, `Lane`, `AsTruthy` for controlling typevar-derived constraints.

(
    operand: &'entries Operand,
    ctrl_typevar: Option<&TypeVar>,
    type_sets: &'table mut UniqueTable<'entries, TypeSet>,
)

Source from the content-addressed store, hash-verified

786/// - `Free(idx)` where `idx` is an index into `type_sets`.
787/// - `Same`, `Lane`, `AsTruthy` for controlling typevar-derived constraints.
788fn get_constraint<'entries, 'table>(
789 operand: &'entries Operand,
790 ctrl_typevar: Option<&TypeVar>,
791 type_sets: &'table mut UniqueTable<'entries, TypeSet>,
792) -> String {
793 assert!(operand.is_value());
794 let type_var = operand.type_var().unwrap();
795
796 if let Some(typ) = type_var.singleton_type() {
797 return format!("Concrete({})", typ.rust_name());
798 }
799
800 if let Some(free_typevar) = type_var.free_typevar() {
801 if ctrl_typevar.is_some() && free_typevar != *ctrl_typevar.unwrap() {
802 assert!(type_var.base.is_none());
803 return format!("Free({})", type_sets.add(type_var.get_raw_typeset()));
804 }
805 }
806
807 if let Some(base) = &type_var.base {
808 assert!(base.type_var == *ctrl_typevar.unwrap());
809 return camel_case(base.derived_func.name());
810 }
811
812 assert!(type_var == ctrl_typevar.unwrap());
813 "Same".into()
814}
815
816fn gen_bitset<'a, T: IntoIterator<Item = &'a u16>>(
817 iterable: T,

Callers 2

make_control_flowMethod · 0.85
gen_type_constraintsFunction · 0.85

Calls 7

camel_caseFunction · 0.85
type_varMethod · 0.80
singleton_typeMethod · 0.80
free_typevarMethod · 0.80
unwrapMethod · 0.45
is_someMethod · 0.45
nameMethod · 0.45

Tested by

no test coverage detected