diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-28 13:45:07 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-28 13:45:07 +0800 |
| commit | e72ad2cd524ff38f162a23d69da5f78494d337ae (patch) | |
| tree | 2e590806b0f610e4392f25f6e8cdff57d2f5a929 /backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp | |
| parent | 3b14bd4d5324b5a280c1ee5567b5526b59e60c5b (diff) | |
| download | rcc-project-e72ad2cd524ff38f162a23d69da5f78494d337ae.tar.gz rcc-project-e72ad2cd524ff38f162a23d69da5f78494d337ae.tar.xz | |
[CodeGen] Centralize machine instruction erasure
Diffstat (limited to 'backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp')
| -rw-r--r-- | backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp b/backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp index 6945f68..3b3a205 100644 --- a/backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp +++ b/backend/lib/Target/RISCV/RISCVPseudoExpansion.cpp @@ -121,13 +121,6 @@ registerBank(Register Reg, const MachineFunction &Function, const TargetDescript return {}; } -[[nodiscard]] Expected<void> removeOldInstruction(MachineInstr &Instruction) { - MachineBasicBlock *Block = Instruction.parent(); - if (Block == nullptr) - return makeUnexpected(ErrorCode::InvalidArgument, "pseudo instruction is not linked"); - return Block->removeInstruction(Instruction); -} - [[nodiscard]] Expected<std::pair<Register, Register>> copyRegisters(const MachineInstr &Instruction) { const MachineOperand *DestinationOperand = Instruction.operandAt(0); @@ -190,7 +183,7 @@ copyRegisters(const MachineInstr &Instruction) { "RISC-V post-RA COPY retains a virtual register"); } if (Destination == Source) { - auto Removed = removeOldInstruction(Instruction); + auto Removed = Instruction.eraseFromParent(); if (!Removed) return std::unexpected(Removed.error()); return true; @@ -270,7 +263,7 @@ copyRegisters(const MachineInstr &Instruction) { auto Decoration = copyCommonDecoration(Instruction, **Replacement, true, true, true); if (!Decoration) return std::unexpected(Decoration.error()); - auto Removed = removeOldInstruction(Instruction); + auto Removed = Instruction.eraseFromParent(); if (!Removed) return std::unexpected(Removed.error()); return true; @@ -418,7 +411,7 @@ copyRegisters(const MachineInstr &Instruction) { Function.records().replaceInstructionReference(Instruction.stableID(), (*Low)->stableID()); if (!Records) return std::unexpected(Records.error()); - auto Removed = removeOldInstruction(Instruction); + auto Removed = Instruction.eraseFromParent(); if (!Removed) return std::unexpected(Removed.error()); return true; @@ -560,7 +553,7 @@ copyRegisters(const MachineInstr &Instruction) { Function.records().replaceInstructionReference(Instruction.stableID(), (*Low)->stableID()); if (!Records) return std::unexpected(Records.error()); - auto Removed = removeOldInstruction(Instruction); + auto Removed = Instruction.eraseFromParent(); if (!Removed) return std::unexpected(Removed.error()); return true; |
