diff options
| author | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-17 02:46:40 +0800 |
|---|---|---|
| committer | Richard-Qin-X <richard.qin.001@gmail.com> | 2026-08-17 02:46:40 +0800 |
| commit | 103299abab6922f450671baa76e34ad746ac4312 (patch) | |
| tree | 19c684e8fc7dd8f48f7b938f7d9040afa0697f4c /backend/lib/Target | |
| parent | 125bee29ffbc64a5f8dc488d04cecf10ed26f98e (diff) | |
| download | rcc-project-103299abab6922f450671baa76e34ad746ac4312.tar.gz rcc-project-103299abab6922f450671baa76e34ad746ac4312.tar.xz | |
[RISCV][GlobalISel] Constrain core copies during selection
Diffstat (limited to 'backend/lib/Target')
| -rw-r--r-- | backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp b/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp index 898b366..bd46144 100644 --- a/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp +++ b/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp @@ -421,6 +421,8 @@ public: return std::unexpected(Generated.error()); if (*Generated) return {}; + if (Instruction.opcode() == opcode(GenericOpcode::COPY)) + return selectCopy(Instruction, Function, Target); auto Match = canSelect(Instruction, Function, Target); if (!Match) return std::unexpected(Match.error()); @@ -514,6 +516,19 @@ public: } private: + [[nodiscard]] Expected<void> selectCopy(MachineInstr &Instruction, MachineFunction &Function, + const TargetDescription &Target) const { + const MachineOperand *DestinationOperand = Instruction.operandAt(0); + const Register *Destination = + DestinationOperand == nullptr ? nullptr : DestinationOperand->getIf<Register>(); + if (Destination == nullptr) + return makeUnexpected(ErrorCode::VerificationError, + "RISC-V COPY selection requires a register destination"); + if (!Destination->isVirtual()) + return {}; + return RegisterBanks.constrainRegister(Function, *Destination, Target); + } + [[nodiscard]] Expected<Register> createTemporary(MachineFunction &Function, LowLevelType Type, const TargetDescription &Target, std::optional<RegisterBankID> Bank = std::nullopt) const { |
