From 7b3dcced70be227bb43e71d84d11a2f15fb25072 Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Wed, 26 Aug 2026 17:55:16 +0800 Subject: [RISCV] Implement push-pop optimization --- backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp | 26 +++++++++++------------ 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp') diff --git a/backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp b/backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp index fb09772..6945f68 100644 --- a/backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp +++ b/backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp @@ -585,19 +585,19 @@ public: return expandAddressPseudo(Instruction, Function, Target, true); return false; } - if (Phase != MachinePseudoExpansionPhase::PostRA) - return false; - if (Instruction.opcode() == opcode(GenericOpcode::COPY)) - return expandCopy(Instruction, Function, Target); - auto Subregister = expandSubregisterCopy(Instruction, Function, Target); - if (!Subregister || *Subregister) - return Subregister; - if (Instruction.opcode() == instructionOpcode(InstructionOpcode::PseudoCALL)) - return expandCall(Instruction, Function, Target, false); - if (Instruction.opcode() == instructionOpcode(InstructionOpcode::PseudoCALLReg)) - return expandCall(Instruction, Function, Target, false); - if (Instruction.opcode() == instructionOpcode(InstructionOpcode::PseudoTAIL)) - return expandCall(Instruction, Function, Target, true); + if (Phase == MachinePseudoExpansionPhase::PostRA) { + if (Instruction.opcode() == opcode(GenericOpcode::COPY)) + return expandCopy(Instruction, Function, Target); + return expandSubregisterCopy(Instruction, Function, Target); + } + if (Phase == MachinePseudoExpansionPhase::TargetLate) { + if (Instruction.opcode() == instructionOpcode(InstructionOpcode::PseudoCALL)) + return expandCall(Instruction, Function, Target, false); + if (Instruction.opcode() == instructionOpcode(InstructionOpcode::PseudoCALLReg)) + return expandCall(Instruction, Function, Target, false); + if (Instruction.opcode() == instructionOpcode(InstructionOpcode::PseudoTAIL)) + return expandCall(Instruction, Function, Target, true); + } return false; } }; -- cgit v1.2.3