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

Function test_call_pseudo_expansion

tests/integration/relocation_tests.rs:101–130  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

99
100#[test]
101fn test_call_pseudo_expansion() {
102 // Test specifically the 'call' pseudo-instruction expansion
103 let tokens = vec![
104 RvInstruction::Directive("\t.text".to_string()),
105 RvInstruction::Label("main".to_string()),
106 RvInstruction::Directive("\t.globl main".to_string()),
107
108 // Call another function using call pseudo
109 RvInstruction::Pseudo(PseudoInstruction::Call {
110 symbol: "target_func".to_string(),
111 }),
112
113 RvInstruction::Real(RealInstruction::Jalr(Jalr::new(0, 1, 0))), // ret
114
115 RvInstruction::Label("target_func".to_string()),
116 RvInstruction::Real(RealInstruction::Jalr(Jalr::new(0, 1, 0))), // ret
117 ];
118
119 match Assembler::assemble(&tokens) {
120 Ok(output) => {
121 // call expands to auipc + jalr = at least 2 instructions
122 assert!(output.text_bytes().len() >= 8, "Expected at least 2 instructions from call expansion");
123 assert!(output.has_symbol("main"));
124 assert!(output.has_symbol("target_func"));
125 }
126 Err(e) => {
127 panic!("Assembly failed for call test: {}", e.message);
128 }
129 }
130}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected