MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / pass_fail_ir

Function pass_fail_ir

tests/integration/vm_execution.rs:83–105  ·  view source on GitHub ↗

Build a minimal pass/fail IR program around an entry block. `entry` must not yet have a terminator; this adds the branch, a pass block (return 0), and a fail block (return 1).

(module: &str, mut entry: IrBlock, cond: IrValue)

Source from the content-addressed store, hash-verified

81 let i32_ty = IrType::Integer(IntWidth::I32);
82 let mut program = IrProgram::new(module);
83 let mut func = IrFunction::new("main", i32_ty.clone());
84
85 entry.set_terminator(IrTerminator::Branch {
86 cond,
87 then_label: IrLabel::new("pass"),
88 else_label: IrLabel::new("fail"),
89 });
90
91 let mut pass_block = IrBlock::new("pass");
92 pass_block.set_terminator(IrTerminator::Return(Some(IrValue::Integer(0))));
93
94 let mut fail_block = IrBlock::new("fail");
95 fail_block.set_terminator(IrTerminator::Return(Some(IrValue::Integer(1))));
96
97 func.push_block(entry);
98 func.push_block(pass_block);
99 func.push_block(fail_block);
100 program.push_function(func);
101 program
102}
103
104fn run_hll_file(path: &str) -> (VirtualMachine, StepOutcome, String) {
105 let manifest = env!("CARGO_MANIFEST_DIR");
106 let full_path = std::path::Path::new(manifest).join(path);
107 let src = std::fs::read_to_string(&full_path)
108 .unwrap_or_else(|e| panic!("failed to read {path}: {e}"));

Callers 5

ir_math_shr_signedFunction · 0.85
ir_math_shlFunction · 0.85
ir_unary_neg_irFunction · 0.85
ir_cmp_ultFunction · 0.85
ir_cmp_slt_negativeFunction · 0.85

Calls 4

push_blockMethod · 0.80
push_functionMethod · 0.80
cloneMethod · 0.45
set_terminatorMethod · 0.45

Tested by 5

ir_math_shr_signedFunction · 0.68
ir_math_shlFunction · 0.68
ir_unary_neg_irFunction · 0.68
ir_cmp_ultFunction · 0.68
ir_cmp_slt_negativeFunction · 0.68