003 File Manager
Current Path:
/usr/src/contrib/llvm-project/llvm/utils/TableGen
usr
/
src
/
contrib
/
llvm-project
/
llvm
/
utils
/
TableGen
/
📁
..
📄
AsmMatcherEmitter.cpp
(149.98 KB)
📄
AsmWriterEmitter.cpp
(46.29 KB)
📄
AsmWriterInst.cpp
(7.57 KB)
📄
AsmWriterInst.h
(3.83 KB)
📄
Attributes.cpp
(3.12 KB)
📄
CTagsEmitter.cpp
(2.52 KB)
📄
CallingConvEmitter.cpp
(11.74 KB)
📄
CodeEmitterGen.cpp
(22.5 KB)
📄
CodeGenDAGPatterns.cpp
(168.72 KB)
📄
CodeGenDAGPatterns.h
(47.85 KB)
📄
CodeGenHwModes.cpp
(3.45 KB)
📄
CodeGenHwModes.h
(1.84 KB)
📄
CodeGenInstruction.cpp
(30.97 KB)
📄
CodeGenInstruction.h
(13.7 KB)
📄
CodeGenIntrinsics.h
(6.6 KB)
📄
CodeGenMapTable.cpp
(23.38 KB)
📄
CodeGenRegisters.cpp
(90.68 KB)
📄
CodeGenRegisters.h
(29.9 KB)
📄
CodeGenSchedule.cpp
(84.92 KB)
📄
CodeGenSchedule.h
(23.14 KB)
📄
CodeGenTarget.cpp
(32.63 KB)
📄
CodeGenTarget.h
(7.22 KB)
📄
DAGISelEmitter.cpp
(6.92 KB)
📄
DAGISelMatcher.cpp
(13.53 KB)
📄
DAGISelMatcher.h
(37.72 KB)
📄
DAGISelMatcherEmitter.cpp
(37.44 KB)
📄
DAGISelMatcherGen.cpp
(44.06 KB)
📄
DAGISelMatcherOpt.cpp
(17.35 KB)
📄
DFAEmitter.cpp
(13.11 KB)
📄
DFAEmitter.h
(3.96 KB)
📄
DFAPacketizerEmitter.cpp
(13.02 KB)
📄
DirectiveEmitter.cpp
(20.15 KB)
📄
DisassemblerEmitter.cpp
(7.02 KB)
📄
ExegesisEmitter.cpp
(7.39 KB)
📄
FastISelEmitter.cpp
(30.83 KB)
📄
FixedLenDecoderEmitter.cpp
(90.04 KB)
📄
GICombinerEmitter.cpp
(40.12 KB)
📁
GlobalISel
📄
GlobalISelEmitter.cpp
(215.56 KB)
📄
InfoByHwMode.cpp
(6.69 KB)
📄
InfoByHwMode.h
(5.74 KB)
📄
InstrDocsEmitter.cpp
(7.05 KB)
📄
InstrInfoEmitter.cpp
(31.52 KB)
📄
IntrinsicEmitter.cpp
(32.87 KB)
📄
OptEmitter.cpp
(2.9 KB)
📄
OptEmitter.h
(575 B)
📄
OptParserEmitter.cpp
(15.16 KB)
📄
OptRSTEmitter.cpp
(2.71 KB)
📄
PredicateExpander.cpp
(17.39 KB)
📄
PredicateExpander.h
(5.19 KB)
📄
PseudoLoweringEmitter.cpp
(11.8 KB)
📄
RISCVCompressInstEmitter.cpp
(39.23 KB)
📄
RegisterBankEmitter.cpp
(12.52 KB)
📄
RegisterInfoEmitter.cpp
(61.32 KB)
📄
SDNodeProperties.cpp
(1.9 KB)
📄
SDNodeProperties.h
(985 B)
📄
SearchableTableEmitter.cpp
(26.81 KB)
📄
SequenceToOffsetTable.h
(8.49 KB)
📄
SubtargetEmitter.cpp
(70.77 KB)
📄
SubtargetFeatureInfo.cpp
(5.72 KB)
📄
SubtargetFeatureInfo.h
(4.05 KB)
📄
TableGen.cpp
(9.7 KB)
📄
TableGenBackends.h
(4.62 KB)
📄
Types.cpp
(1.46 KB)
📄
Types.h
(900 B)
📄
WebAssemblyDisassemblerEmitter.cpp
(6.79 KB)
📄
WebAssemblyDisassemblerEmitter.h
(980 B)
📄
X86DisassemblerShared.h
(1.88 KB)
📄
X86DisassemblerTables.cpp
(42.64 KB)
📄
X86DisassemblerTables.h
(11.7 KB)
📄
X86EVEX2VEXTablesEmitter.cpp
(8.77 KB)
📄
X86FoldTablesEmitter.cpp
(26.09 KB)
📄
X86ModRMFilters.cpp
(636 B)
📄
X86ModRMFilters.h
(4.69 KB)
📄
X86RecognizableInstr.cpp
(47.05 KB)
📄
X86RecognizableInstr.h
(14.13 KB)
Editing: DAGISelEmitter.cpp
//===- 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 "CodeGenDAGPatterns.h" #include "DAGISelMatcher.h" #include "llvm/Support/Debug.h" #include "llvm/TableGen/Record.h" #include "llvm/TableGen/TableGenBackend.h" using namespace llvm; #define DEBUG_TYPE "dag-isel-emitter" namespace { /// DAGISelEmitter - The top-level class which coordinates construction /// and emission of the instruction selector. class DAGISelEmitter { CodeGenDAGPatterns CGP; public: explicit DAGISelEmitter(RecordKeeper &R) : CGP(R) {} void run(raw_ostream &OS); }; } // End anonymous namespace //===----------------------------------------------------------------------===// // DAGISelEmitter Helper methods // /// getResultPatternCost - 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, CodeGenDAGPatterns &CGP) { if (P->isLeaf()) return 0; unsigned Cost = 0; Record *Op = P->getOperator(); if (Op->isSubClassOf("Instruction")) { Cost++; CodeGenInstruction &II = CGP.getTargetInfo().getInstruction(Op); if (II.usesCustomInserter) Cost += 10; } for (unsigned i = 0, e = P->getNumChildren(); i != e; ++i) Cost += getResultPatternCost(P->getChild(i), CGP); return Cost; } /// getResultPatternCodeSize - Compute the code size of instructions for this /// pattern. static unsigned getResultPatternSize(TreePatternNode *P, CodeGenDAGPatterns &CGP) { if (P->isLeaf()) return 0; unsigned Cost = 0; Record *Op = P->getOperator(); if (Op->isSubClassOf("Instruction")) { Cost += Op->getValueAsInt("CodeSize"); } for (unsigned i = 0, e = P->getNumChildren(); i != e; ++i) Cost += getResultPatternSize(P->getChild(i), CGP); return Cost; } 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 { PatternSortingPredicate(CodeGenDAGPatterns &cgp) : CGP(cgp) {} CodeGenDAGPatterns &CGP; bool operator()(const PatternToMatch *LHS, const PatternToMatch *RHS) { const TreePatternNode *LT = LHS->getSrcPattern(); const TreePatternNode *RT = RHS->getSrcPattern(); MVT LHSVT = LT->getNumTypes() != 0 ? LT->getSimpleType(0) : MVT::Other; MVT RHSVT = RT->getNumTypes() != 0 ? RT->getSimpleType(0) : MVT::Other; if (LHSVT.isVector() != RHSVT.isVector()) return RHSVT.isVector(); if (LHSVT.isFloatingPoint() != RHSVT.isFloatingPoint()) return RHSVT.isFloatingPoint(); // Otherwise, if the patterns might both match, sort based on complexity, // which means that we prefer to match patterns that cover more nodes in the // input over nodes that cover fewer. int LHSSize = LHS->getPatternComplexity(CGP); int RHSSize = RHS->getPatternComplexity(CGP); if (LHSSize > RHSSize) return true; // LHS -> bigger -> less cost if (LHSSize < RHSSize) return false; // If the patterns have equal complexity, compare generated instruction cost unsigned LHSCost = getResultPatternCost(LHS->getDstPattern(), CGP); unsigned RHSCost = getResultPatternCost(RHS->getDstPattern(), CGP); if (LHSCost < RHSCost) return true; if (LHSCost > RHSCost) return false; unsigned LHSPatSize = getResultPatternSize(LHS->getDstPattern(), CGP); unsigned RHSPatSize = getResultPatternSize(RHS->getDstPattern(), CGP); if (LHSPatSize < RHSPatSize) return true; if (LHSPatSize > RHSPatSize) return false; // Sort based on the UID of the pattern, to reflect source order. // Note that this is not guaranteed to be unique, since a single source // pattern may have been resolved into multiple match patterns due to // alternative fragments. To ensure deterministic output, always use // std::stable_sort with this predicate. return LHS->ID < RHS->ID; } }; } // End anonymous namespace void DAGISelEmitter::run(raw_ostream &OS) { emitSourceFileHeader("DAG Instruction Selector for the " + CGP.getTargetInfo().getName().str() + " target", OS); OS << "// *** NOTE: This file is #included into the middle of the target\n" << "// *** instruction selector class. These functions are really " << "methods.\n\n"; OS << "// If GET_DAGISEL_DECL is #defined with any value, only function\n" "// declarations will be included when this file is included.\n" "// If GET_DAGISEL_BODY is #defined, its value should be the name of\n" "// the instruction selector class. Function bodies will be emitted\n" "// and each function's name will be qualified with the name of the\n" "// class.\n" "//\n" "// When neither of the GET_DAGISEL* macros is defined, the functions\n" "// are emitted inline.\n\n"; LLVM_DEBUG(errs() << "\n\nALL PATTERNS TO MATCH:\n\n"; for (CodeGenDAGPatterns::ptm_iterator I = CGP.ptm_begin(), E = CGP.ptm_end(); I != E; ++I) { errs() << "PATTERN: "; I->getSrcPattern()->dump(); errs() << "\nRESULT: "; I->getDstPattern()->dump(); errs() << "\n"; }); // Add all the patterns to a temporary list so we can sort them. std::vector<const PatternToMatch*> Patterns; for (CodeGenDAGPatterns::ptm_iterator I = CGP.ptm_begin(), E = CGP.ptm_end(); I != E; ++I) Patterns.push_back(&*I); // We want to process the matches in order of minimal cost. Sort the patterns // so the least cost one is at the start. std::stable_sort(Patterns.begin(), Patterns.end(), PatternSortingPredicate(CGP)); // Convert each variant of each pattern into a Matcher. std::vector<Matcher*> PatternMatchers; for (unsigned i = 0, e = Patterns.size(); i != e; ++i) { for (unsigned Variant = 0; ; ++Variant) { if (Matcher *M = ConvertPatternToMatcher(*Patterns[i], Variant, CGP)) PatternMatchers.push_back(M); else break; } } std::unique_ptr<Matcher> TheMatcher = std::make_unique<ScopeMatcher>(PatternMatchers); OptimizeMatcher(TheMatcher, CGP); //Matcher->dump(); EmitMatcherTable(TheMatcher.get(), CGP, OS); } namespace llvm { void EmitDAGISel(RecordKeeper &RK, raw_ostream &OS) { DAGISelEmitter(RK).run(OS); } } // End llvm namespace
Upload File
Create Folder