//===- DAGISelEmitter.cpp - Generate an instruction selector --------------===// // // 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 tablegen backend emits a DAG instruction selector. // //===----------------------------------------------------------------------===// #include "Common/CodeGenDAGPatterns.h" #include "Common/CodeGenInstruction.h" #include "Common/CodeGenTarget.h" #include "Common/DAGISelMatcher.h" #include "llvm/Support/Debug.h" #include "llvm/TableGen/Record.h" #include "llvm/TableGen/TableGenBackend.h" usingnamespacellvm; #define DEBUG_TYPE … namespace { /// DAGISelEmitter - The top-level class which coordinates construction /// and emission of the instruction selector. class DAGISelEmitter { … }; } // End anonymous namespace //===----------------------------------------------------------------------===// // DAGISelEmitter Helper methods // /// Compute the number of instructions for this pattern. /// This is a temporary hack. We should really include the instruction /// latencies in this calculation. static unsigned getResultPatternCost(TreePatternNode &P, const CodeGenDAGPatterns &CGP) { … } /// getResultPatternCodeSize - Compute the code size of instructions for this /// pattern. static unsigned getResultPatternSize(TreePatternNode &P, const CodeGenDAGPatterns &CGP) { … } namespace { // PatternSortingPredicate - return true if we prefer to match LHS before RHS. // In particular, we want to match maximal patterns first and lowest cost within // a particular complexity first. struct PatternSortingPredicate { … }; } // End anonymous namespace void DAGISelEmitter::run(raw_ostream &OS) { … } static TableGen::Emitter::OptClass<DAGISelEmitter> X("gen-dag-isel", "Generate a DAG instruction selector");