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

Method emit

cranelift/frontend/src/switch.rs:267–278  ·  view source on GitHub ↗

Build the switch # Arguments The function builder to emit to The value to switch on The default block

(self, bx: &mut FunctionBuilder, val: Value, otherwise: Block)

Source from the content-addressed store, hash-verified

265 /// * The value to switch on
266 /// * The default block
267 pub fn emit(self, bx: &mut FunctionBuilder, val: Value, otherwise: Block) {
268 // Validate that the type of `val` is sufficiently wide to address all cases.
269 let max = self.cases.keys().max().copied().unwrap_or(0);
270 let val_ty = bx.func.dfg.value_type(val);
271 let val_ty_max = val_ty.bounds(false).1;
272 if max > val_ty_max {
273 panic!("The index type {val_ty} does not fit the maximum switch entry of {max}");
274 }
275
276 let contiguous_case_ranges = self.collect_contiguous_case_ranges();
277 Self::build_search_tree(bx, val, otherwise, &contiguous_case_ranges);
278 }
279}
280
281fn icmp_imm_u128(bx: &mut FunctionBuilder, cond: IntCC, x: Value, y: u128) -> Value {

Callers 6

runMethod · 0.45
do_caseFunction · 0.45
switch_64bitFunction · 0.45
switch_128bitFunction · 0.45
switch_128bit_max_u64Function · 0.45
insert_terminatorMethod · 0.45

Calls 6

copiedMethod · 0.80
boundsMethod · 0.80
maxMethod · 0.45
keysMethod · 0.45
value_typeMethod · 0.45

Tested by 4

runMethod · 0.36
switch_64bitFunction · 0.36
switch_128bitFunction · 0.36
switch_128bit_max_u64Function · 0.36