From 94124b0d5604d6d6a6e1b923411e97287fa51e8b Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Sat, 15 Aug 2026 23:39:45 +0800 Subject: [RISCV][GlobalISel] Select word shift pseudos --- backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp') diff --git a/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp b/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp index 0d68cc3..a7e5ecd 100644 --- a/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp +++ b/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp @@ -157,7 +157,9 @@ public: [[nodiscard]] Expected canSelect(const MachineInstr &Instruction, const MachineFunction &Function, const TargetDescription &Target) const override { - if (Instruction.opcode() == instructionOpcode(InstructionOpcode::G_SLLW)) { + if (Instruction.opcode() == instructionOpcode(InstructionOpcode::G_SLLW) || + Instruction.opcode() == instructionOpcode(InstructionOpcode::G_SRAW) || + Instruction.opcode() == instructionOpcode(InstructionOpcode::G_SRLW)) { const std::optional Type = resultType(Function, Instruction); const std::optional Left = operandType(Function, Instruction, 1); const std::optional Right = operandType(Function, Instruction, 2); @@ -165,7 +167,7 @@ public: *Left == *Type && *Right == *Type ? Expected{} : makeUnexpected(ErrorCode::Unsupported, - "RISC-V G_SLLW requires three 64-bit GPR operands"); + "RISC-V word shift pseudo requires three 64-bit GPR operands"); } if (!isGenericOpcode(Instruction.opcode())) return {}; @@ -317,6 +319,10 @@ public: return std::unexpected(Match.error()); if (Instruction.opcode() == instructionOpcode(InstructionOpcode::G_SLLW)) return Instruction.setOpcode(instructionOpcode(InstructionOpcode::SLLW)); + if (Instruction.opcode() == instructionOpcode(InstructionOpcode::G_SRAW)) + return Instruction.setOpcode(instructionOpcode(InstructionOpcode::SRAW)); + if (Instruction.opcode() == instructionOpcode(InstructionOpcode::G_SRLW)) + return Instruction.setOpcode(instructionOpcode(InstructionOpcode::SRLW)); const GenericOpcode Generic = static_cast(Instruction.opcode().value()); const std::optional Type = resultType(Function, Instruction); -- cgit v1.2.3