From da8bc76b4bf7d1a7b025d6c8ef5809551467dcc7 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Sun, 9 Aug 2026 13:23:48 +0800 Subject: [CodeGen] Implement RV64GC frame lowering --- backend/unittests/CodeGen/MachineIRCoreTest.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'backend/unittests/CodeGen') diff --git a/backend/unittests/CodeGen/MachineIRCoreTest.cpp b/backend/unittests/CodeGen/MachineIRCoreTest.cpp index 028afc5..7982b04 100644 --- a/backend/unittests/CodeGen/MachineIRCoreTest.cpp +++ b/backend/unittests/CodeGen/MachineIRCoreTest.cpp @@ -438,12 +438,20 @@ void testOwnershipCFGAndMemory(TestContext &Context) { "instruction must reject a block operand from another function"); auto MemOperand = Function->createMemOperand(makeLoadDescription()); + auto ReplacementMemOperand = Function->createMemOperand(makeLoadDescription()); auto ForeignMemOperand = OtherFunction->createMemOperand(makeLoadDescription()); - Context.expect(MemOperand && ForeignMemOperand, + Context.expect(MemOperand && ReplacementMemOperand && ForeignMemOperand, "function arena must allocate immutable memory operands"); - if (MemOperand && ForeignMemOperand) { + if (MemOperand && ReplacementMemOperand && ForeignMemOperand) { Context.expect((*Instr)->addMemOperand(**MemOperand).has_value(), "instruction must accept a memory operand owned by its function"); + Context.expect((*Instr)->replaceMemOperand(0, **ReplacementMemOperand).has_value() && + (*Instr)->memOperands().front() == *ReplacementMemOperand, + "instruction must replace an owned memory operand in place"); + Context.expect(!(*Instr)->replaceMemOperand(1, **MemOperand) && + !(*Instr)->replaceMemOperand(0, **ForeignMemOperand) && + (*Instr)->memOperands().front() == *ReplacementMemOperand, + "invalid memory replacement must fail without mutation"); Context.expect(!(*Instr)->addMemOperand(**ForeignMemOperand), "instruction must reject a memory operand from another function"); } -- cgit v1.2.3