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

Function switch_128bit

cranelift/frontend/src/switch.rs:612–648  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

610
611 #[test]
612 fn switch_128bit() {
613 let mut func = Function::new();
614 let mut func_ctx = FunctionBuilderContext::new();
615 {
616 let mut bx = FunctionBuilder::new(&mut func, &mut func_ctx);
617 let block0 = bx.create_block();
618 bx.switch_to_block(block0);
619 let val = bx.ins().iconst(types::I64, 0);
620 let val = bx.ins().uextend(types::I128, val);
621 let mut switch = Switch::new();
622 let block1 = bx.create_block();
623 switch.set_entry(1, block1);
624 let block2 = bx.create_block();
625 switch.set_entry(0, block2);
626 let block3 = bx.create_block();
627 switch.emit(&mut bx, val, block3);
628 }
629 let func = func
630 .to_string()
631 .trim_start_matches("function u0:0() fast {\n")
632 .trim_end_matches("\n}\n")
633 .to_string();
634 assert_eq_output!(
635 func,
636 "block0:
637 v0 = iconst.i64 0
638 v1 = uextend.i128 v0 ; v0 = 0
639 v2 = iconst.i64 0xffff_ffff
640 v3 = sextend.i128 v2 ; v2 = 0xffff_ffff
641 v4 = icmp ugt v1, v3
642 brif v4, block3, block4
643
644block4:
645 v5 = ireduce.i32 v1
646 br_table v5, block3, [block2, block1]"
647 );
648 }
649
650 #[test]
651 fn switch_128bit_max_u64() {

Callers

nothing calls this directly

Calls 7

create_blockMethod · 0.80
switch_to_blockMethod · 0.80
newFunction · 0.50
insMethod · 0.45
set_entryMethod · 0.45
emitMethod · 0.45
to_stringMethod · 0.45

Tested by

no test coverage detected