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

Function keeps_pointer_stack_values_64_bit

tests/integration/rv64_codegen.rs:162–197  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

160
161#[test]
162fn keeps_pointer_stack_values_64_bit() {
163 let mut program = IrProgram::new("test");
164 let mut func = IrFunction::new("ptrs", int32());
165
166 let mut entry = IrBlock::new("entry");
167 entry.push_instruction(IrInstruction::HeapAlloc {
168 dest: IrRegister::Named("heap".into()),
169 ty: int32(),
170 count: None,
171 });
172 entry.push_instruction(IrInstruction::Alloc {
173 dest: IrRegister::Named("holder".into()),
174 ty: IrType::Pointer(Box::new(int32())),
175 count: None,
176 });
177 entry.push_instruction(IrInstruction::Store {
178 ty: IrType::Pointer(Box::new(int32())),
179 value: IrValue::Register(IrRegister::Named("heap".into())),
180 ptr: IrRegister::Named("holder".into()),
181 offset: None,
182 });
183 entry.push_instruction(IrInstruction::Load {
184 dest: IrRegister::Named("alias".into()),
185 ty: IrType::Pointer(Box::new(int32())),
186 ptr: IrRegister::Named("holder".into()),
187 offset: None,
188 });
189 entry.set_terminator(IrTerminator::Return(Some(IrValue::Integer(0))));
190 func.push_block(entry);
191 program.push_function(func);
192
193 let asm = compile(&program);
194
195 assert!(asm.contains("\tsd") || asm.contains("sd "), "expected pointer store to use sd, got:\n{asm}");
196 assert!(asm.contains("\tld") || asm.contains("ld "), "expected pointer load to use ld, got:\n{asm}");
197}
198
199#[test]
200fn heap_alloc_zeroes_memory_and_skips_null() {

Callers

nothing calls this directly

Calls 6

compileFunction · 0.85
push_blockMethod · 0.80
push_functionMethod · 0.80
int32Function · 0.70
push_instructionMethod · 0.45
set_terminatorMethod · 0.45

Tested by

no test coverage detected