From 53145c4020d237d2572b4109e0d425863dc34f9b Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Mon, 17 Aug 2026 02:56:45 +0800 Subject: [RISCV][GlobalISel] Generate implicit-def selection --- backend/utils/TableGen/Common/CodeGenSelection.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'backend/utils/TableGen') 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; } -- cgit v1.2.3