aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp3
-rw-r--r--backend/lib/Target/RISCV/RISCVGISelInteger.rccdesc10
-rw-r--r--backend/utils/TableGen/Common/CodeGenSelection.cpp15
3 files changed, 20 insertions, 8 deletions
diff --git a/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp b/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
index bd46144..cde2c8d 100644
--- a/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
+++ b/backend/lib/Target/RISCV/GISel/RISCVInstructionSelector.cpp
@@ -405,7 +405,6 @@ public:
case GenericOpcode::G_DEBUGTRAP:
case GenericOpcode::G_UBSANTRAP:
case GenericOpcode::G_PHI:
- case GenericOpcode::G_IMPLICIT_DEF:
return {};
default:
return makeUnexpected(ErrorCode::Unsupported,
@@ -493,8 +492,6 @@ public:
return selectTrap(Instruction);
case GenericOpcode::G_PHI:
return Instruction.setOpcode(opcode(GenericOpcode::PHI));
- case GenericOpcode::G_IMPLICIT_DEF:
- return Instruction.setOpcode(opcode(GenericOpcode::IMPLICIT_DEF));
case GenericOpcode::COPY:
case GenericOpcode::IMPLICIT_DEF:
case GenericOpcode::PHI:
diff --git a/backend/lib/Target/RISCV/RISCVGISelInteger.rccdesc b/backend/lib/Target/RISCV/RISCVGISelInteger.rccdesc
index 1667f66..f40e5d4 100644
--- a/backend/lib/Target/RISCV/RISCVGISelInteger.rccdesc
+++ b/backend/lib/Target/RISCV/RISCVGISelInteger.rccdesc
@@ -1,5 +1,15 @@
selection_rules:
-
+ id: select_g_implicit_def
+ priority: 100
+ match:
+ opcode: G_IMPLICIT_DEF
+ apply:
+ instructions:
+ - opcode: IMPLICIT_DEF
+ root: true
+ operands: [{ operand: 0 }]
+ -
id: select_g_sext_s64_s32
priority: 500
match:
diff --git a/backend/utils/TableGen/Common/CodeGenSelection.cpp b/backend/utils/TableGen/Common/CodeGenSelection.cpp
index d3bc299..95a924f 100644
--- a/backend/utils/TableGen/Common/CodeGenSelection.cpp
+++ b/backend/utils/TableGen/Common/CodeGenSelection.cpp
@@ -416,10 +416,14 @@ bool CodeGenTarget::normalizeSelectionRules(NormalizedTargetModel &Result) {
const auto ResultOpcode = resolveOpcode(Result, Action.ResultOpcodeSymbol);
const NormalizedInstruction *ResultInstruction =
findInstructionBySymbol(Result, Action.ResultOpcodeSymbol);
- if (!ResultOpcode || ResultInstruction == nullptr ||
- isGenericOpcode(Opcode::fromValue(*ResultOpcode)) ||
- std::ranges::contains(ResultInstruction->Flags, "Generic")) {
- fail(Action.Range, "selection instruction opcode must name a declared target instruction");
+ const bool IsCorePseudo =
+ ResultOpcode && isCorePseudoOpcode(Opcode::fromValue(*ResultOpcode));
+ if (!ResultOpcode || (ResultInstruction == nullptr && !IsCorePseudo) ||
+ (ResultInstruction != nullptr &&
+ (isGenericOpcode(Opcode::fromValue(*ResultOpcode)) ||
+ std::ranges::contains(ResultInstruction->Flags, "Generic")))) {
+ fail(Action.Range,
+ "selection instruction opcode must name a declared target instruction or core pseudo");
return false;
}
if (Action.ReplacesRoot == HasRootAction || (Action.ReplacesRoot && ActionIndex != 0)) {
@@ -428,7 +432,8 @@ bool CodeGenTarget::normalizeSelectionRules(NormalizedTargetModel &Result) {
return false;
}
HasRootAction |= Action.ReplacesRoot;
- if (ResultInstruction->Operands.size() != Action.OperandRenderers.size()) {
+ if (ResultInstruction != nullptr &&
+ ResultInstruction->Operands.size() != Action.OperandRenderers.size()) {
fail(Action.Range, "selection instruction has an incompatible operand count");
return false;
}