aboutsummaryrefslogtreecommitdiff
path: root/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
diff options
context:
space:
mode:
authorRichard-Qin-X <richard.qin.001@gmail.com>2026-08-15 23:39:45 +0800
committerRichard-Qin-X <richard.qin.001@gmail.com>2026-08-15 23:39:45 +0800
commit94124b0d5604d6d6a6e1b923411e97287fa51e8b (patch)
tree42b2f857ba201060a983b43750e23277c4dc12ff /backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
parent1fe32a79cee5cae6dea6fbb1d9f15f7db817a356 (diff)
downloadrcc-project-94124b0d5604d6d6a6e1b923411e97287fa51e8b.tar.gz
rcc-project-94124b0d5604d6d6a6e1b923411e97287fa51e8b.tar.xz
[RISCV][GlobalISel] Select word shift pseudos
Diffstat (limited to 'backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp')
-rw-r--r--backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp10
1 files changed, 8 insertions, 2 deletions
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<void> 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<LowLevelType> Type = resultType(Function, Instruction);
const std::optional<LowLevelType> Left = operandType(Function, Instruction, 1);
const std::optional<LowLevelType> Right = operandType(Function, Instruction, 2);
@@ -165,7 +167,7 @@ public:
*Left == *Type && *Right == *Type
? Expected<void>{}
: 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<GenericOpcode>(Instruction.opcode().value());
const std::optional<LowLevelType> Type = resultType(Function, Instruction);