aboutsummaryrefslogtreecommitdiff
path: root/backend/unittests/CodeGen
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-09 13:23:48 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-09 13:23:48 +0800
commitda8bc76b4bf7d1a7b025d6c8ef5809551467dcc7 (patch)
tree3b64eb08cd6376deceef2d7bac20eea5ce4de184 /backend/unittests/CodeGen
parente5fdceb9b869f010a2a75638fd38aaf1867f3008 (diff)
downloadrcc-project-da8bc76b4bf7d1a7b025d6c8ef5809551467dcc7.tar.gz
rcc-project-da8bc76b4bf7d1a7b025d6c8ef5809551467dcc7.tar.xz
[CodeGen] Implement RV64GC frame lowering
Diffstat (limited to 'backend/unittests/CodeGen')
-rw-r--r--backend/unittests/CodeGen/MachineIRCoreTest.cpp12
1 files changed, 10 insertions, 2 deletions
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");
}