//===- DAGISelMatcher.h - Representation of DAG pattern matcher -*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// #ifndef LLVM_UTILS_TABLEGEN_COMMON_DAGISELMATCHER_H #define LLVM_UTILS_TABLEGEN_COMMON_DAGISELMATCHER_H #include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" #include "llvm/CodeGenTypes/MachineValueType.h" #include "llvm/Support/Casting.h" #include <cassert> #include <cstddef> #include <memory> #include <string> #include <utility> namespace llvm { class CodeGenRegister; class CodeGenDAGPatterns; class CodeGenInstruction; class Matcher; class PatternToMatch; class raw_ostream; class ComplexPattern; class Record; class SDNodeInfo; class TreePredicateFn; class TreePattern; Matcher *ConvertPatternToMatcher(const PatternToMatch &Pattern, unsigned Variant, const CodeGenDAGPatterns &CGP); void OptimizeMatcher(std::unique_ptr<Matcher> &Matcher, const CodeGenDAGPatterns &CGP); void EmitMatcherTable(Matcher *Matcher, const CodeGenDAGPatterns &CGP, raw_ostream &OS); /// Matcher - Base class for all the DAG ISel Matcher representation /// nodes. class Matcher { … }; /// ScopeMatcher - This attempts to match each of its children to find the first /// one that successfully matches. If one child fails, it tries the next child. /// If none of the children match then this check fails. It never has a 'next'. class ScopeMatcher : public Matcher { … }; /// RecordMatcher - Save the current node in the operand list. class RecordMatcher : public Matcher { … }; /// RecordChildMatcher - Save a numbered child of the current node, or fail /// the match if it doesn't exist. This is logically equivalent to: /// MoveChild N + RecordNode + MoveParent. class RecordChildMatcher : public Matcher { … }; /// RecordMemRefMatcher - Save the current node's memref. class RecordMemRefMatcher : public Matcher { … }; /// CaptureGlueInputMatcher - If the current record has a glue input, record /// it so that it is used as an input to the generated code. class CaptureGlueInputMatcher : public Matcher { … }; /// MoveChildMatcher - This tells the interpreter to move into the /// specified child node. class MoveChildMatcher : public Matcher { … }; /// MoveSiblingMatcher - This tells the interpreter to move into the /// specified sibling node. class MoveSiblingMatcher : public Matcher { … }; /// MoveParentMatcher - This tells the interpreter to move to the parent /// of the current node. class MoveParentMatcher : public Matcher { … }; /// CheckSameMatcher - This checks to see if this node is exactly the same /// node as the specified match that was recorded with 'Record'. This is used /// when patterns have the same name in them, like '(mul GPR:$in, GPR:$in)'. class CheckSameMatcher : public Matcher { … }; /// CheckChildSameMatcher - This checks to see if child node is exactly the same /// node as the specified match that was recorded with 'Record'. This is used /// when patterns have the same name in them, like '(mul GPR:$in, GPR:$in)'. class CheckChildSameMatcher : public Matcher { … }; /// CheckPatternPredicateMatcher - This checks the target-specific predicate /// to see if the entire pattern is capable of matching. This predicate does /// not take a node as input. This is used for subtarget feature checks etc. class CheckPatternPredicateMatcher : public Matcher { … }; /// CheckPredicateMatcher - This checks the target-specific predicate to /// see if the node is acceptable. class CheckPredicateMatcher : public Matcher { … }; /// CheckOpcodeMatcher - This checks to see if the current node has the /// specified opcode, if not it fails to match. class CheckOpcodeMatcher : public Matcher { … }; /// SwitchOpcodeMatcher - Switch based on the current node's opcode, dispatching /// to one matcher per opcode. If the opcode doesn't match any of the cases, /// then the match fails. This is semantically equivalent to a Scope node where /// every child does a CheckOpcode, but is much faster. class SwitchOpcodeMatcher : public Matcher { … }; /// CheckTypeMatcher - This checks to see if the current node has the /// specified type at the specified result, if not it fails to match. class CheckTypeMatcher : public Matcher { … }; /// SwitchTypeMatcher - Switch based on the current node's type, dispatching /// to one matcher per case. If the type doesn't match any of the cases, /// then the match fails. This is semantically equivalent to a Scope node where /// every child does a CheckType, but is much faster. class SwitchTypeMatcher : public Matcher { … }; /// CheckChildTypeMatcher - This checks to see if a child node has the /// specified type, if not it fails to match. class CheckChildTypeMatcher : public Matcher { … }; /// CheckIntegerMatcher - This checks to see if the current node is a /// ConstantSDNode with the specified integer value, if not it fails to match. class CheckIntegerMatcher : public Matcher { … }; /// CheckChildIntegerMatcher - This checks to see if the child node is a /// ConstantSDNode with a specified integer value, if not it fails to match. class CheckChildIntegerMatcher : public Matcher { … }; /// CheckCondCodeMatcher - This checks to see if the current node is a /// CondCodeSDNode with the specified condition, if not it fails to match. class CheckCondCodeMatcher : public Matcher { … }; /// CheckChild2CondCodeMatcher - This checks to see if child 2 node is a /// CondCodeSDNode with the specified condition, if not it fails to match. class CheckChild2CondCodeMatcher : public Matcher { … }; /// CheckValueTypeMatcher - This checks to see if the current node is a /// VTSDNode with the specified type, if not it fails to match. class CheckValueTypeMatcher : public Matcher { … }; /// CheckComplexPatMatcher - This node runs the specified ComplexPattern on /// the current node. class CheckComplexPatMatcher : public Matcher { … }; /// CheckAndImmMatcher - This checks to see if the current node is an 'and' /// with something equivalent to the specified immediate. class CheckAndImmMatcher : public Matcher { … }; /// CheckOrImmMatcher - This checks to see if the current node is an 'and' /// with something equivalent to the specified immediate. class CheckOrImmMatcher : public Matcher { … }; /// CheckImmAllOnesVMatcher - This checks if the current node is a build_vector /// or splat_vector of all ones. class CheckImmAllOnesVMatcher : public Matcher { … }; /// CheckImmAllZerosVMatcher - This checks if the current node is a /// build_vector or splat_vector of all zeros. class CheckImmAllZerosVMatcher : public Matcher { … }; /// CheckFoldableChainNodeMatcher - This checks to see if the current node /// (which defines a chain operand) is safe to fold into a larger pattern. class CheckFoldableChainNodeMatcher : public Matcher { … }; /// EmitIntegerMatcher - This creates a new TargetConstant. class EmitIntegerMatcher : public Matcher { … }; /// EmitStringIntegerMatcher - A target constant whose value is represented /// by a string. class EmitStringIntegerMatcher : public Matcher { … }; /// EmitRegisterMatcher - This creates a new TargetConstant. class EmitRegisterMatcher : public Matcher { … }; /// EmitConvertToTargetMatcher - Emit an operation that reads a specified /// recorded node and converts it from being a ISD::Constant to /// ISD::TargetConstant, likewise for ConstantFP. class EmitConvertToTargetMatcher : public Matcher { … }; /// EmitMergeInputChainsMatcher - Emit a node that merges a list of input /// chains together with a token factor. The list of nodes are the nodes in the /// matched pattern that have chain input/outputs. This node adds all input /// chains of these nodes if they are not themselves a node in the pattern. class EmitMergeInputChainsMatcher : public Matcher { … }; /// EmitCopyToRegMatcher - Emit a CopyToReg node from a value to a physreg, /// pushing the chain and glue results. /// class EmitCopyToRegMatcher : public Matcher { … }; /// EmitNodeXFormMatcher - Emit an operation that runs an SDNodeXForm on a /// recorded node and records the result. class EmitNodeXFormMatcher : public Matcher { … }; /// EmitNodeMatcherCommon - Common class shared between EmitNode and /// MorphNodeTo. class EmitNodeMatcherCommon : public Matcher { … }; /// EmitNodeMatcher - This signals a successful match and generates a node. class EmitNodeMatcher : public EmitNodeMatcherCommon { … }; class MorphNodeToMatcher : public EmitNodeMatcherCommon { … }; /// CompleteMatchMatcher - Complete a match by replacing the results of the /// pattern with the newly generated nodes. This also prints a comment /// indicating the source and dest patterns. class CompleteMatchMatcher : public Matcher { … }; } // end namespace llvm #endif // LLVM_UTILS_TABLEGEN_COMMON_DAGISELMATCHER_H