Lines Matching +full:two +full:- +full:wires
1 //===- GlobalISelCombinerMatchTableEmitter.cpp - --------------------------===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
27 //===----------------------------------------------------------------------===//
62 #define DEBUG_TYPE "gicombiner-emitter"
66 GICombinerEmitterCat("Options for -gen-global-isel-combiner");
68 "gicombiner-stop-after-parse",
75 "gicombiner-debug-cxxpreds",
78 cl::opt<bool> DebugTypeInfer("gicombiner-debug-typeinfer",
86 //===- CodeExpansions Helpers --------------------------------------------===//
103 "]->getOperand(" + to_string(OM.getOpIdx()) + ")"); in declareOperandExpansion()
111 //===- Misc. Helpers -----------------------------------------------------===//
114 return map_range(C, [](auto &Entry) -> auto & { return Entry.first; }); in keys()
118 return map_range(C, [](auto &Entry) -> auto & { return Entry.second; }); in values()
125 //===- MatchTable Helpers ------------------------------------------------===//
143 //===- PrettyStackTrace Helpers ------------------------------------------===//
179 OS << " [" << Pat->getKindName() << " '" << Pat->getName() << "']"; in print()
184 //===- CombineRuleOperandTypeChecker --------------------------------------===//
227 /// either immediates, or fancier operands used only post-ISel, so we don't
242 /// (G_BUILD_VECTOR $vec, $x, $y) ->
259 /// Tries to infer the type of the \p ImmOpIdx -th operand of \p IP using \p
325 for (unsigned K = 0; K < Pat->operands_size(); ++K) { in propagateAndInferTypes()
326 auto &Op = Pat->getOperand(K); in propagateAndInferTypes()
344 errs() << "INFER: " << Op.describe() << " -> " << Ty.str() << '\n'; in propagateAndInferTypes()
356 errs() << "INFER: " << Op.describe() << " -> " << Ty.str() << '\n'; in propagateAndInferTypes()
375 Pat->getName() + "' during Type Inference"); in propagateAndInferTypes()
384 Pat->print(errs(), /*PrintName*/ true); in propagateAndInferTypes()
397 if (!CGP || CGP->isIntrinsic()) in inferImmediateType()
470 Record *VarArgsTy = CGI.TheDef->isSubClassOf("GenericInstruction") in getMCOIOperandTypes()
471 ? CGI.TheDef->getValueAsOptionalDef("variadicOpsType") in getMCOIOperandTypes()
474 VarArgsTy ? ("MCOI::" + VarArgsTy->getValueAsString("OperandType")).str() in getMCOIOperandTypes()
489 int CGIOpOffset = int(CGI.Operands.NumDefs) - CGP.getNumInstDefs(); in getMCOIOperandTypes()
510 // - Getting the MCOI Operand Types. in getInstEqClasses()
511 // - Creating a Map of MCOI Type -> [Operand Indexes] in getInstEqClasses()
512 // - Iterating over the map, filtering types we don't like, and just adding in getInstEqClasses()
526 if (!CGP || CGP->isIntrinsic()) in getInstEqClasses()
591 // only print non-empty classes. in getRuleEqClasses()
609 //===- MatchData Handling -------------------------------------------------===//
624 //===- CombineRuleBuilder -------------------------------------------------===//
631 /// In most cases, there are two stages to a pattern's lifetime:
632 /// - Creation in a `parse` function
633 /// - The unique_ptr is stored in a variable, and may be destroyed if the
635 /// - Ownership transfer into a `PatternMap`
636 /// - Once a pattern is moved into either the map of Match or Apply
661 /// Debug-only verification of invariants.
831 switch (MatchRoot->getKind()) { in emitRuleMatchers()
871 PF->print(OS, /*Indent=*/" "); in print()
893 Pat->print(OS, /*PrintName=*/false); in print()
925 if (Name != Pat->getName()) { in verify()
926 Pat->dump(); in verify()
928 ", Pat name: " + Pat->getName()); in verify()
933 if (Name.data() != Pat->getName().data()) { in verify()
936 dbgs() << "Pat String: '" << Pat->getName() << "' @ " in verify()
937 << (const void *)Pat->getName().data() << '\n'; in verify()
967 return PatAndPerm.first->getName().str() + "[" + in print()
977 StringRef Name = Pat->getName(); in addApplyPattern()
996 CXXPat->setIsApply(); in addApplyPattern()
1003 StringRef Name = Pat->getName(); in addMatchPattern()
1011 PrintError("'" + BP->getInstName() + in addMatchPattern()
1041 IM->addPredicate<GenericInstructionPredicateMatcher>( in addCXXPredicate()
1054 return BP->getBuiltinKind() == BI_EraseRoot; in hasEraseRoot()
1082 if (IP->diagnoseAllSpecialTypes( in typecheckPatterns()
1100 // - We only allow a single one of them in the root. in buildPermutationsToEmit()
1101 // - They cannot be mixed with any other pattern other than C++ code. in buildPermutationsToEmit()
1105 NumAlts = PFP->getPatFrag().num_alternatives(); in buildPermutationsToEmit()
1153 if (!CXXPat->getRawCode().contains("return ")) in checkSemantics()
1160 if (auto *FI = CGP->getMIFlagsInfo()) { in checkSemantics()
1161 if (!FI->copy_flags().empty()) { in checkSemantics()
1164 PrintNote("MIFlags in '" + CGP->getName() + in checkSemantics()
1165 "' refer to: " + join(FI->copy_flags(), ", ")); in checkSemantics()
1208 if (auto *FI = CGP->getMIFlagsInfo()) { in checkSemantics()
1209 for (auto InstName : FI->copy_flags()) { in checkSemantics()
1213 "' referenced in MIFlags of '" + CGP->getName() + "'"); in checkSemantics()
1217 if (!isa<CodeGenInstructionPattern>(It->second.get())) { in checkSemantics()
1221 CGP->getName() + "'"); in checkSemantics()
1231 StringRef Name = BIP->getInstName(); in checkSemantics()
1235 switch (BIP->getBuiltinKind()) { in checkSemantics()
1249 if (IRoot->getNumInstDefs() != 0) { in checkSemantics()
1252 PrintNote("'" + IRoot->getInstName() + "' has " + in checkSemantics()
1253 Twine(IRoot->getNumInstDefs()) + " output operands"); in checkSemantics()
1260 // TODO: When we allow rewriting non-root instructions, also allow this. in checkSemantics()
1261 StringRef OldRegName = BIP->getOperand(0).getOperandName(); in checkSemantics()
1313 for (Init *PI : Preds->getValues()) { in addFeaturePredicates()
1318 Record *Def = Pred->getDef(); in addFeaturePredicates()
1319 if (!Def->isSubClassOf("Predicate")) { in addFeaturePredicates()
1324 if (Def->getValueAsString("CondString").empty()) in addFeaturePredicates()
1349 if (IPRoot->getNumInstDefs() == 0) { in findRoots()
1350 // No defs to work with -> find the root using the pattern name. in findRoots()
1357 auto *ApplyRoot = dyn_cast<InstructionPattern>(It->second.get()); in findRoots()
1370 const auto DefsNeeded = IPRoot->getApplyDefsNeeded(); in findRoots()
1385 if (find(ApplyRoots, It->second.get()) == ApplyRoots.end()) { in findRoots()
1400 MatchRoot = MatchPatIt->second.get(); in findRoots()
1414 PrintError("Cannot use live-in operand '" + RootName + in findRoots()
1449 if (Def.getOperatorAsDef(RuleDef.getLoc())->getName() != "defs") { in parseDefs()
1467 MatchDataRec->getValueAsString("Type")); in parseDefs()
1477 PrintError("Expected a subclass of GIDefKind or a sub-dag whose " in parseDefs()
1502 const auto FindOperandDef = [&](StringRef Op) -> InstructionPattern * { in emitMatchPattern()
1511 if (!PFP->getPatFrag().canBeMatchRoot()) { in emitMatchPattern()
1512 PrintError("cannot use '" + PFP->getInstName() + " as match root"); in emitMatchPattern()
1530 switch (Pat->getKind()) { in emitMatchPattern()
1544 cast<InstructionPattern>(Pat.get())->reportUnreachable(RuleDef.getLoc()); in emitMatchPattern()
1547 // Delay emission for top-level C++ matchers (which can use MatchDatas). in emitMatchPattern()
1571 CGI->TheDef->getName() + "'"); in emitMatchPattern()
1587 switch (Pat->getKind()) { in emitMatchPattern()
1603 cast<InstructionPattern>(Pat.get())->reportUnreachable( in emitMatchPattern()
1607 // Delay emission for top-level C++ matchers (which can use MatchDatas). in emitMatchPattern()
1668 [&](const InstructionOperand &O) -> InstructionOperand { in emitPatFragMatchPattern()
1679 if (PIdx == (unsigned)-1) { in emitPatFragMatchPattern()
1715 [&](StringRef Op) -> const InstructionPattern * { in emitPatFragMatchPattern()
1748 IP->reportUnreachable(PF.getLoc()); in emitPatFragMatchPattern()
1783 switch (Pat->getKind()) { in emitApplyPatterns()
1808 M.getInsnVarID(M.getInstructionMatcher(MatchRoot->getName())); in emitApplyPatterns()
1829 CodeExpander Expander(M->getRawCode(), CE, RuleDef.getLoc(), in emitCXXMatchApply()
1841 CodeExpander Expander(CXXPat->getRawCode(), CE, RuleDef.getLoc(), in emitCXXMatchApply()
1877 "': operand is not a live-in of the match pattern, and it " in emitInstructionApplyPattern()
1930 DstMI.addRenderer<TempRegRenderer>(It->second); in emitInstructionApplyPattern()
1933 // If it's a use of a temporary register, then we messed up somewhere - in emitInstructionApplyPattern()
1947 // live-in of the match pattern. in emitInstructionApplyPattern()
1948 PrintError("Cannot define live-in operand '" + OpName + in emitInstructionApplyPattern()
1974 TempRegID = It->second; in emitInstructionApplyPattern()
2003 for (StringRef InstName : FI->copy_flags()) in emitInstructionApplyPattern()
2005 for (StringRef F : FI->set_flags()) in emitInstructionApplyPattern()
2007 for (StringRef F : FI->unset_flags()) in emitInstructionApplyPattern()
2015 // to re-enable this. We'd then need to always clear MIFlags when mutating in emitInstructionApplyPattern()
2088 It->second); in emitBuiltinApplyPattern()
2107 StringRef InstName = CGP->getInst().TheDef->getName(); in isLiteralImm()
2140 assert(FI->copy_flags().empty()); in emitCodeGenInstructionMatchPattern()
2142 if (const auto &SetF = FI->set_flags(); !SetF.empty()) in emitCodeGenInstructionMatchPattern()
2144 if (const auto &UnsetF = FI->unset_flags(); !UnsetF.empty()) in emitCodeGenInstructionMatchPattern()
2222 PrintNote("'" + OpName + "' is defined by '" + DefPat->getName() + "'"); in emitCodeGenInstructionMatchPattern()
2229 OM.addPredicate<InstructionOperandMatcher>(M, DefPat->getName()); in emitCodeGenInstructionMatchPattern()
2231 // TODO: copy-pasted from GlobalISelEmitter.cpp. Is it still relevant in emitCodeGenInstructionMatchPattern()
2233 PrintError("Nested instruction '" + DefPat->getName() + in emitCodeGenInstructionMatchPattern()
2239 auto &IM = (*InstOpM)->getInsnMatcher(); in emitCodeGenInstructionMatchPattern()
2260 //===- GICombinerEmitter --------------------------------------------------===//
2266 /// static storage pools and wires them together to emit the match table &
2300 return Combiner->getValueAsString("Classname"); in getClassName()
2304 return Combiner->getValueAsString("CombineAllMethodName"); in getCombineAllMethodName()
2354 "RuleIdentifier.split('-');\n" in emitRuleConfigImpl()
2382 << " for (auto I = MaybeRange->first; I < MaybeRange->second; ++I)\n" in emitRuleConfigImpl()
2390 << " \"" << Name.lower() << "-disable-rule\",\n" in emitRuleConfigImpl()
2400 << " \"" << Name.lower() << "-only-enable-rule\",\n" in emitRuleConfigImpl()
2402 << " pass then re-enable the specified ones\"),\n" in emitRuleConfigImpl()
2454 [](const CXXPredicateCode *C) -> StringRef { return C->BaseEnumName; }, in emitMIPredicateFns()
2455 [](const CXXPredicateCode *C) -> StringRef { return C->Code; }); in emitMIPredicateFns()
2498 << " return RuleConfig.isRuleEnabled(Predicate - " in emitTestSimplePredicate()
2499 "GICXXPred_Invalid - " in emitTestSimplePredicate()
2511 OS << " " << CA->getEnumNameWithPrefix(CXXCustomActionPrefix) in emitRunCustomAction()
2525 OS << " case " << CA->getEnumNameWithPrefix(CXXCustomActionPrefix) in emitRunCustomAction()
2527 << " " << join(split(CA->Code, '\n'), "\n ") << '\n' in emitRunCustomAction()
2561 return std::make_tuple(OpcodeOrder[L->getOpcode()], L->getNumOperands()) < in buildMatchTable()
2562 std::make_tuple(OpcodeOrder[R->getOpcode()], R->getNumOperands()); in buildMatchTable()
2566 Rule->optimize(); in buildMatchTable()
2573 Rule->optimize(); in buildMatchTable()
2586 if (!Rec->isValueUnset("Rules")) { in gatherRules()
2587 gatherRules(ActiveRules, Rec->getValueAsListOfDefs("Rules")); in gatherRules()
2591 StringRef RuleName = Rec->getName(); in gatherRules()
2593 PrintWarning(Rec->getLoc(), in gatherRules()
2594 "skipping rule '" + Rec->getName() + in gatherRules()
2599 AllCombineRules.emplace_back(NextRuleID, Rec->getName().str()); in gatherRules()
2626 gatherRules(Rules, Combiner->getValueAsListOfDefs("Rules")); in run()
2628 PrintFatalError(Combiner->getLoc(), "Failed to parse one or more rules"); in run()
2698 //===----------------------------------------------------------------------===//
2705 PrintFatalError("No combiners selected with -combiners"); in EmitGICombiner()
2714 static TableGen::Emitter::Opt X("gen-global-isel-combiner", EmitGICombiner,