From df7095e67ea06f7d6a81d99e70c804ce54ef950d Mon Sep 17 00:00:00 2001 From: Richard-Qin-X Date: Wed, 19 Aug 2026 05:13:13 +0800 Subject: [GlobalISel] Generate prelegalizer combiner rules --- backend/include/rcc/TableGen/Record.h | 44 +++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) (limited to 'backend/include/rcc/TableGen/Record.h') diff --git a/backend/include/rcc/TableGen/Record.h b/backend/include/rcc/TableGen/Record.h index b5abc23..9f3477f 100644 --- a/backend/include/rcc/TableGen/Record.h +++ b/backend/include/rcc/TableGen/Record.h @@ -334,6 +334,49 @@ struct SourceSelectionRule final { TextRange Range; }; +struct SourceCombinerOperandRenderer final { + enum class Kind : std::uint8_t { + RootOperand, + CapturedOperand, + CapturedTypeBits, + Immediate, + }; + + Kind SourceKind = Kind::RootOperand; + std::uint32_t OperandIndex = 0; + std::string CaptureSymbol; + std::int64_t Immediate = 0; + TextRange Range; +}; + +enum class SourceCombinerActionKind : std::uint8_t { + ReplaceRootWithCapturedOperand, + MutateRoot, +}; + +struct SourceCombinerAction final { + SourceCombinerActionKind Kind = SourceCombinerActionKind::ReplaceRootWithCapturedOperand; + std::string CapturedOperandSymbol; + std::string ResultOpcodeSymbol; + std::vector OperandRenderers; + std::vector ClearInstructionFlags; + TextRange Range; +}; + +struct SourceCombinerRule final { + std::string Symbol; + std::uint32_t Priority = 0; + std::string MatchOpcodeSymbol; + std::optional ResultType; + std::vector OperandTypes; + std::vector TargetPredicates; + std::vector InstructionFlags; + std::vector DefUsePredicates; + SourceCombinerAction Action; + std::vector EraseOperandDefinitions; + TextRange Range; +}; + struct DescriptionAST final { SourceTarget Target; std::vector RegisterUnits; @@ -350,6 +393,7 @@ struct DescriptionAST final { std::vector AssemblyFormats; std::vector Instructions; std::vector SelectionRules; + std::vector CombinerRules; }; [[nodiscard]] std::string lowerASCII(std::string_view Value); -- cgit v1.2.3