diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-11 20:37:03 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-11 20:37:03 +0800 |
| commit | 234d7d3bec020103e46daaff39d207d978479730 (patch) | |
| tree | c3fe4f23416b0f37e9fe77366884983dbba15125 /backend/unittests/Target | |
| parent | 38626ed37c9ea78c76c12dae4806b750881fd910 (diff) | |
| download | rcc-project-234d7d3bec020103e46daaff39d207d978479730.tar.gz rcc-project-234d7d3bec020103e46daaff39d207d978479730.tar.xz | |
[RISCV] Order call operands like LLVM MIR
Diffstat (limited to 'backend/unittests/Target')
| -rw-r--r-- | backend/unittests/Target/RISCVCallLoweringTest.cpp | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/backend/unittests/Target/RISCVCallLoweringTest.cpp b/backend/unittests/Target/RISCVCallLoweringTest.cpp index 08049f6..c18898f 100644 --- a/backend/unittests/Target/RISCVCallLoweringTest.cpp +++ b/backend/unittests/Target/RISCVCallLoweringTest.cpp @@ -551,19 +551,32 @@ void testOrdinaryAndIndirectEmission(TestContext &Context) { "call-frame pseudos must use LLVM amount/prepared-byte operands and implicit SP effects"); bool HasArgumentUse = false; bool HasResultDef = false; + std::optional<std::size_t> ArgumentUseIndex; + std::optional<std::size_t> ResultDefIndex; + std::size_t OperandIndex = 0; for (const rcc::MachineOperand &Operand : Call->operands()) { - if (!Operand.isRegister() || !Operand.isImplicit()) + if (!Operand.isRegister() || !Operand.isImplicit()) { + ++OperandIndex; continue; - HasArgumentUse |= - Operand.isUse() && Operand.registerValue() == rcc::Register::fromPhysical(argumentGPR(0)); - HasResultDef |= - Operand.isDef() && Operand.registerValue() == rcc::Register::fromPhysical(returnFPR(0)); + } + if (Operand.isUse() && Operand.registerValue() == rcc::Register::fromPhysical(argumentGPR(0))) { + HasArgumentUse = true; + ArgumentUseIndex = OperandIndex; + } + if (Operand.isDef() && Operand.registerValue() == rcc::Register::fromPhysical(returnFPR(0))) { + HasResultDef = true; + ResultDefIndex = OperandIndex; + } + ++OperandIndex; } - Context.expect(HasArgumentUse && HasResultDef && Function->frameInfo().state().HasCalls && + Context.expect(HasArgumentUse && HasResultDef && ArgumentUseIndex && ResultDefIndex && + *ArgumentUseIndex < *ResultDefIndex && + Function->frameInfo().state().HasCalls && Function->frameInfo().maxCallFrameSize() == 0 && Function->frameInfo().stackAlignment().bytes() == 16 && verifyFunction(*Function, *Target), - "ordinary call emission must record implicit ABI registers and valid frame state"); + "ordinary call emission must order implicit uses before defs and record frame " + "state"); rcc::MachineBasicBlock *IndirectBlock = nullptr; auto IndirectFunction = createFunction(Context, "indirect_call", 2, IndirectBlock); |
