//===- DAGISelMatcherOpt.cpp - Optimize a DAG Matcher ---------------------===// // // 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 // //===----------------------------------------------------------------------===// // // This file implements the DAG Matcher optimizer. // //===----------------------------------------------------------------------===// #include "Basic/SDNodeProperties.h" #include "Common/CodeGenDAGPatterns.h" #include "Common/DAGISelMatcher.h" #include "llvm/ADT/StringSet.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" usingnamespacellvm; #define DEBUG_TYPE … /// ContractNodes - Turn multiple matcher node patterns like 'MoveChild+Record' /// into single compound nodes like RecordChild. static void ContractNodes(std::unique_ptr<Matcher> &MatcherPtr, const CodeGenDAGPatterns &CGP) { … } /// FindNodeWithKind - Scan a series of matchers looking for a matcher with a /// specified kind. Return null if we didn't find one otherwise return the /// matcher. static Matcher *FindNodeWithKind(Matcher *M, Matcher::KindTy Kind) { … } /// FactorNodes - Turn matches like this: /// Scope /// OPC_CheckType i32 /// ABC /// OPC_CheckType i32 /// XYZ /// into: /// OPC_CheckType i32 /// Scope /// ABC /// XYZ /// static void FactorNodes(std::unique_ptr<Matcher> &InputMatcherPtr) { … } void llvm::OptimizeMatcher(std::unique_ptr<Matcher> &MatcherPtr, const CodeGenDAGPatterns &CGP) { … }