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

Function switch_64bit

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

Source from the content-addressed store, hash-verified

574
575 #[test]
576 fn switch_64bit() {
577 let mut func = Function::new();
578 let mut func_ctx = FunctionBuilderContext::new();
579 {
580 let mut bx = FunctionBuilder::new(&mut func, &mut func_ctx);
581 let block0 = bx.create_block();
582 bx.switch_to_block(block0);
583 let val = bx.ins().iconst(types::I64, 0);
584 let mut switch = Switch::new();
585 let block1 = bx.create_block();
586 switch.set_entry(1, block1);
587 let block2 = bx.create_block();
588 switch.set_entry(0, block2);
589 let block3 = bx.create_block();
590 switch.emit(&mut bx, val, block3);
591 }
592 let func = func
593 .to_string()
594 .trim_start_matches("function u0:0() fast {\n")
595 .trim_end_matches("\n}\n")
596 .to_string();
597 assert_eq_output!(
598 func,
599 "block0:
600 v0 = iconst.i64 0
601 v1 = iconst.i64 0xffff_ffff
602 v2 = icmp ugt v0, v1 ; v0 = 0, v1 = 0xffff_ffff
603 brif v2, block3, block4
604
605block4:
606 v3 = ireduce.i32 v0 ; v0 = 0
607 br_table v3, block3, [block2, block1]"
608 );
609 }
610
611 #[test]
612 fn switch_128bit() {

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