From 4f7b41c3c711d6c6fa4e422f3eec8961c91eea7a Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Sun, 16 Aug 2026 15:39:45 +0800 Subject: tablegen: Generate GlobalISel match tables --- backend/utils/TableGen/Common/CodeGenTarget.h | 41 +++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) (limited to 'backend/utils/TableGen/Common/CodeGenTarget.h') diff --git a/backend/utils/TableGen/Common/CodeGenTarget.h b/backend/utils/TableGen/Common/CodeGenTarget.h index cbddd4a..929d3e7 100644 --- a/backend/utils/TableGen/Common/CodeGenTarget.h +++ b/backend/utils/TableGen/Common/CodeGenTarget.h @@ -163,6 +163,45 @@ struct NormalizedInstruction final { std::string Deadline; }; +enum class NormalizedSelectionTypeKind : std::uint8_t { + Any, + Scalar, + Pointer, +}; + +struct NormalizedSelectionTypePredicate final { + NormalizedSelectionTypeKind Kind = NormalizedSelectionTypeKind::Any; + std::uint32_t Bits = 0; +}; + +struct NormalizedSelectionOperandTypePredicate final { + std::uint32_t OperandIndex = 0; + NormalizedSelectionTypePredicate Type; +}; + +struct NormalizedSelectionOperandBankPredicate final { + std::uint32_t OperandIndex = 0; + std::uint32_t Bank = 0; +}; + +struct NormalizedSelectionOperandClassPredicate final { + std::uint32_t OperandIndex = 0; + std::uint32_t RegClass = 0; +}; + +struct NormalizedSelectionRule final { + std::string Symbol; + std::uint32_t Priority = 0; + std::uint32_t Specificity = 0; + std::uint32_t MatchOpcode = 0; + std::optional ResultType; + std::vector OperandTypes; + std::vector OperandBanks; + std::vector OperandClasses; + std::uint32_t ResultOpcode = 0; + std::vector AppendedImmediates; +}; + struct NormalizedTargetModel final { SourceTarget Target; std::vector RegisterUnits; @@ -178,6 +217,7 @@ struct NormalizedTargetModel final { std::vector EncodingCategories; std::vector AssemblyFormats; std::vector Instructions; + std::vector SelectionRules; }; [[nodiscard]] std::optional @@ -219,6 +259,7 @@ private: normalizeImplicitRegisters(const std::vector &InputRegisters, bool IsDef, std::vector &Result); [[nodiscard]] bool normalizeInstructions(NormalizedTargetModel &Result); + [[nodiscard]] bool normalizeSelectionRules(NormalizedTargetModel &Result); const DescriptionAST &Input; std::string SourceName; -- cgit v1.2.3