// SPDX-License-Identifier: GPL-3.0-or-later #ifndef RCC_CODEGEN_MACHINECOMBINERPATTERN_H #define RCC_CODEGEN_MACHINECOMBINERPATTERN_H #include "rcc/CodeGen/MachineIRTypes.h" #include "rcc/Support/Error.h" #include #include #include #include #include namespace rcc { struct MachineCombinerPattern final { std::string Name; Opcode RootOpcode; Opcode ProducerOpcode; Opcode ReplacementOpcode; std::size_t ProducerOperand = 0; std::size_t AddendOperand = 0; }; class TargetMachineCombinerInfo final { public: [[nodiscard]] static Expected create(std::vector Patterns); [[nodiscard]] std::span patterns(Opcode RootOpcode) const noexcept; private: explicit TargetMachineCombinerInfo(std::vector Patterns) : Patterns(std::move(Patterns)) {} std::vector Patterns; std::unordered_map> MatchTable; }; } // namespace rcc #endif // RCC_CODEGEN_MACHINECOMBINERPATTERN_H