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

Function run_ir

tests/integration/vm_execution.rs:62–78  ·  view source on GitHub ↗

Compile a directly-constructed IR program (for ops the HLL surface lacks), link against the cached stdlib, and run it.

(program: &IrProgram)

Source from the content-addressed store, hash-verified

60/// Compile a directly-constructed IR program (for ops the HLL surface lacks),
61/// link against the cached stdlib, and run it.
62fn run_ir(program: &IrProgram) -> (VirtualMachine, StepOutcome, String) {
63 let mut pipeline = CompilationPipeline::new();
64 pipeline.set_write_artifacts(false);
65
66 let (_, user_tokens) = pipeline.compile_ir_to_assembly_with_tokens(program);
67 let user_obj = pipeline
68 .assemble(&user_tokens)
69 .expect("user assemble failed");
70
71 let assembled = pipeline
72 .link_assembled_objects(&link_with_stdlib(&user_obj))
73 .expect("link failed");
74 let mut vm = VirtualMachine::new(&assembled);
75 let run = vm.run(5_000_000);
76 let uart = run.uart_output.clone();
77 (vm, run.outcome, uart)
78}
79
80/// Build a minimal pass/fail IR program around an entry block. `entry` must not
81/// yet have a terminator; this adds the branch, a pass block (return 0), and a

Callers 7

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 7

link_with_stdlibFunction · 0.85
set_write_artifactsMethod · 0.80
assembleMethod · 0.45
runMethod · 0.45
cloneMethod · 0.45

Tested by 7

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