Lines Matching refs:OS

87                            unsigned StartIdx, raw_ostream &OS);
89 void EmitPredicateFunctions(raw_ostream &OS);
91 void EmitHistogram(const Matcher *N, raw_ostream &OS);
93 void EmitPatternMatchTable(raw_ostream &OS);
97 StringRef Decl, raw_ostream &OS);
100 raw_ostream &OS);
182 static uint64_t EmitVBRValue(uint64_t Val, raw_ostream &OS) { in EmitVBRValue() argument
184 OS << Val << ", "; in EmitVBRValue()
191 OS << (Val&127) << "|128,"; in EmitVBRValue()
195 OS << Val; in EmitVBRValue()
197 OS << "/*" << InVal << "*/"; in EmitVBRValue()
198 OS << ", "; in EmitVBRValue()
223 static void BeginEmitFunction(raw_ostream &OS, StringRef RetType, in BeginEmitFunction() argument
225 OS << "#ifdef GET_DAGISEL_DECL\n"; in BeginEmitFunction()
226 OS << RetType << ' ' << Decl; in BeginEmitFunction()
228 OS << " override"; in BeginEmitFunction()
229 OS << ";\n" in BeginEmitFunction()
232 OS << RetType << " DAGISEL_CLASS_COLONCOLON " << Decl << "\n"; in BeginEmitFunction()
234 OS << "#if DAGISEL_INLINE\n" in BeginEmitFunction()
240 static void EndEmitFunction(raw_ostream &OS) { in EndEmitFunction() argument
241 OS << "#endif // GET_DAGISEL_BODY\n\n"; in EndEmitFunction()
244 void MatcherTableEmitter::EmitPatternMatchTable(raw_ostream &OS) { in EmitPatternMatchTable() argument
251 BeginEmitFunction(OS, "StringRef", "getPatternForIndex(unsigned Index)", in EmitPatternMatchTable()
253 OS << "{\n"; in EmitPatternMatchTable()
254 OS << "static const char * PATTERN_MATCH_TABLE[] = {\n"; in EmitPatternMatchTable()
257 OS << "\"" << It.first << "\",\n"; in EmitPatternMatchTable()
260 OS << "\n};"; in EmitPatternMatchTable()
261 OS << "\nreturn StringRef(PATTERN_MATCH_TABLE[Index]);"; in EmitPatternMatchTable()
262 OS << "\n}"; in EmitPatternMatchTable()
263 EndEmitFunction(OS); in EmitPatternMatchTable()
265 BeginEmitFunction(OS, "StringRef", "getIncludePathForIndex(unsigned Index)", in EmitPatternMatchTable()
267 OS << "{\n"; in EmitPatternMatchTable()
268 OS << "static const char * INCLUDE_PATH_TABLE[] = {\n"; in EmitPatternMatchTable()
271 OS << "\"" << It << "\",\n"; in EmitPatternMatchTable()
274 OS << "\n};"; in EmitPatternMatchTable()
275 OS << "\nreturn StringRef(INCLUDE_PATH_TABLE[Index]);"; in EmitPatternMatchTable()
276 OS << "\n}"; in EmitPatternMatchTable()
277 EndEmitFunction(OS); in EmitPatternMatchTable()
284 raw_ostream &OS) { in EmitMatcher() argument
285 OS.indent(Indent*2); in EmitMatcher()
297 OS << "OPC_Scope, "; in EmitMatcher()
301 OS << "/*" << format_decimal(CurrentIdx, IndexWidth) << "*/"; in EmitMatcher()
302 OS.indent(Indent*2) << "/*Scope*/ "; in EmitMatcher()
304 OS.indent(Indent*2); in EmitMatcher()
319 raw_svector_ostream OS(TmpBuf); in EmitMatcher() local
321 CurrentIdx+VBRSize, OS); in EmitMatcher()
326 CurrentIdx += EmitVBRValue(ChildSize, OS); in EmitMatcher()
328 OS << "/*->" << CurrentIdx+ChildSize << "*/"; in EmitMatcher()
331 OS << " // " << SM->getNumChildren() << " children in Scope"; in EmitMatcher()
334 OS << '\n' << TmpBuf; in EmitMatcher()
340 OS << "/*" << format_decimal(CurrentIdx, IndexWidth) << "*/"; in EmitMatcher()
341 OS.indent(Indent*2) << "0, "; in EmitMatcher()
343 OS << "/*End of Scope*/"; in EmitMatcher()
344 OS << '\n'; in EmitMatcher()
349 OS << "OPC_RecordNode,"; in EmitMatcher()
351 OS << " // #" in EmitMatcher()
354 OS << '\n'; in EmitMatcher()
358 OS << "OPC_RecordChild" << cast<RecordChildMatcher>(N)->getChildNo() in EmitMatcher()
361 OS << " // #" in EmitMatcher()
364 OS << '\n'; in EmitMatcher()
368 OS << "OPC_RecordMemRef,\n"; in EmitMatcher()
372 OS << "OPC_CaptureGlueInput,\n"; in EmitMatcher()
378 OS << "OPC_MoveChild"; in EmitMatcher()
381 OS << ", "; in EmitMatcher()
382 OS << MCM->getChildNo() << ",\n"; in EmitMatcher()
387 OS << "OPC_MoveParent,\n"; in EmitMatcher()
391 OS << "OPC_CheckSame, " in EmitMatcher()
396 OS << "OPC_CheckChild" in EmitMatcher()
403 OS << "OPC_CheckPatternPredicate, " << getPatternPredicate(Pred) << ','; in EmitMatcher()
405 OS << " // " << Pred; in EmitMatcher()
406 OS << '\n'; in EmitMatcher()
415 OS << "OPC_CheckPredicateWithOperands, " << NumOps << "/*#Ops*/, "; in EmitMatcher()
417 OS << cast<CheckPredicateMatcher>(N)->getOperandNo(i) << ", "; in EmitMatcher()
420 OS << "OPC_CheckPredicate, "; in EmitMatcher()
423 OS << getNodePredicate(Pred) << ','; in EmitMatcher()
425 OS << " // " << Pred.getFnName(); in EmitMatcher()
426 OS << '\n'; in EmitMatcher()
431 OS << "OPC_CheckOpcode, TARGET_VAL(" in EmitMatcher()
441 OS << "OPC_SwitchOpcode "; in EmitMatcher()
444 OS << "OPC_SwitchType "; in EmitMatcher()
449 OS << "/*" << NumCases << " cases */"; in EmitMatcher()
450 OS << ", "; in EmitMatcher()
477 raw_svector_ostream OS(TmpBuf); in EmitMatcher() local
479 OS); in EmitMatcher()
486 OS << "/*" << format_decimal(CurrentIdx, IndexWidth) << "*/"; in EmitMatcher()
487 OS.indent(Indent*2); in EmitMatcher()
489 OS << (isa<SwitchOpcodeMatcher>(N) ? in EmitMatcher()
494 CurrentIdx += EmitVBRValue(ChildSize, OS); in EmitMatcher()
497 OS << "TARGET_VAL(" << SOM->getCaseOpcode(i).getEnumName() << "),"; in EmitMatcher()
499 OS << getEnumName(cast<SwitchTypeMatcher>(N)->getCaseType(i)) << ','; in EmitMatcher()
504 OS << "// ->" << CurrentIdx+ChildSize; in EmitMatcher()
505 OS << '\n'; in EmitMatcher()
506 OS << TmpBuf; in EmitMatcher()
512 OS << "/*" << format_decimal(CurrentIdx, IndexWidth) << "*/"; in EmitMatcher()
513 OS.indent(Indent*2) << "0,"; in EmitMatcher()
515 OS << (isa<SwitchOpcodeMatcher>(N) ? in EmitMatcher()
518 OS << '\n'; in EmitMatcher()
525 OS << "OPC_CheckType, " in EmitMatcher()
529 OS << "OPC_CheckTypeRes, " << cast<CheckTypeMatcher>(N)->getResNo() in EmitMatcher()
534 OS << "OPC_CheckChild" in EmitMatcher()
540 OS << "OPC_CheckInteger, "; in EmitMatcher()
541 unsigned Bytes=1+EmitVBRValue(cast<CheckIntegerMatcher>(N)->getValue(), OS); in EmitMatcher()
542 OS << '\n'; in EmitMatcher()
546 OS << "OPC_CheckChild" << cast<CheckChildIntegerMatcher>(N)->getChildNo() in EmitMatcher()
549 OS); in EmitMatcher()
550 OS << '\n'; in EmitMatcher()
554 OS << "OPC_CheckCondCode, ISD::" in EmitMatcher()
559 OS << "OPC_CheckValueType, MVT::" in EmitMatcher()
566 OS << "OPC_CheckComplexPat, /*CP*/" << getComplexPat(Pattern) << ", /*#*/" in EmitMatcher()
570 OS << " // " << Pattern.getSelectFunc(); in EmitMatcher()
571 OS << ":$" << CCPM->getName(); in EmitMatcher()
573 OS << " #" << CCPM->getFirstResult()+i; in EmitMatcher()
576 OS << " + chain result"; in EmitMatcher()
578 OS << '\n'; in EmitMatcher()
583 OS << "OPC_CheckAndImm, "; in EmitMatcher()
584 unsigned Bytes=1+EmitVBRValue(cast<CheckAndImmMatcher>(N)->getValue(), OS); in EmitMatcher()
585 OS << '\n'; in EmitMatcher()
590 OS << "OPC_CheckOrImm, "; in EmitMatcher()
591 unsigned Bytes = 1+EmitVBRValue(cast<CheckOrImmMatcher>(N)->getValue(), OS); in EmitMatcher()
592 OS << '\n'; in EmitMatcher()
597 OS << "OPC_CheckFoldableChainNode,\n"; in EmitMatcher()
602 OS << "OPC_EmitInteger, " in EmitMatcher()
604 unsigned Bytes = 2+EmitVBRValue(Val, OS); in EmitMatcher()
605 OS << '\n'; in EmitMatcher()
611 OS << "OPC_EmitInteger, " in EmitMatcher()
623 OS << "OPC_EmitRegister2, " << getEnumName(Matcher->getVT()) << ", "; in EmitMatcher()
624 OS << "TARGET_VAL(" << getQualifiedName(Reg->TheDef) << "),\n"; in EmitMatcher()
627 OS << "OPC_EmitRegister, " << getEnumName(Matcher->getVT()) << ", "; in EmitMatcher()
629 OS << getQualifiedName(Reg->TheDef) << ",\n"; in EmitMatcher()
631 OS << "0 "; in EmitMatcher()
633 OS << "/*zero_reg*/"; in EmitMatcher()
634 OS << ",\n"; in EmitMatcher()
641 OS << "OPC_EmitConvertToTarget, " in EmitMatcher()
651 OS << "OPC_EmitMergeInputChains1_" << MN->getNode(0) << ",\n"; in EmitMatcher()
655 OS << "OPC_EmitMergeInputChains, " << MN->getNumNodes() << ", "; in EmitMatcher()
657 OS << MN->getNode(i) << ", "; in EmitMatcher()
658 OS << '\n'; in EmitMatcher()
662 OS << "OPC_EmitCopyToReg, " in EmitMatcher()
669 OS << "OPC_EmitNodeXForm, " << getNodeXFormID(XF->getNodeXForm()) << ", " in EmitMatcher()
672 OS << " // "<<XF->getNodeXForm()->getName(); in EmitMatcher()
673 OS <<'\n'; in EmitMatcher()
683 OS << "OPC_Coverage, "; in EmitMatcher()
692 OS << "TARGET_VAL(" << Offset << "),\n"; in EmitMatcher()
693 OS.indent(FullIndexWidth + Indent * 2); in EmitMatcher()
697 OS << (isa<EmitNodeMatcher>(EN) ? "OPC_EmitNode" : "OPC_MorphNodeTo"); in EmitMatcher()
700 OS << EN->getNumVTs(); in EmitMatcher()
702 OS << ", TARGET_VAL(" << EN->getOpcodeName() << "), 0"; in EmitMatcher()
704 if (EN->hasChain()) OS << "|OPFL_Chain"; in EmitMatcher()
705 if (EN->hasInFlag()) OS << "|OPFL_GlueInput"; in EmitMatcher()
706 if (EN->hasOutFlag()) OS << "|OPFL_GlueOutput"; in EmitMatcher()
707 if (EN->hasMemRefs()) OS << "|OPFL_MemRefs"; in EmitMatcher()
709 OS << "|OPFL_Variadic" << EN->getNumFixedArityOperands(); in EmitMatcher()
710 OS << ",\n"; in EmitMatcher()
712 OS.indent(FullIndexWidth + Indent*2+4); in EmitMatcher()
714 OS << EN->getNumVTs(); in EmitMatcher()
716 OS << "/*#VTs*/"; in EmitMatcher()
717 OS << ", "; in EmitMatcher()
720 OS << getEnumName(EN->getVT(i)) << ", "; in EmitMatcher()
722 OS << EN->getNumOperands(); in EmitMatcher()
724 OS << "/*#Ops*/"; in EmitMatcher()
725 OS << ", "; in EmitMatcher()
728 NumOperandBytes += EmitVBRValue(EN->getOperand(i), OS); in EmitMatcher()
734 OS << " // Results ="; in EmitMatcher()
737 OS << " #" << First+i; in EmitMatcher()
740 OS << '\n'; in EmitMatcher()
743 OS.indent(FullIndexWidth + Indent*2) << "// Src: " in EmitMatcher()
746 OS.indent(FullIndexWidth + Indent*2) << "// Dst: " in EmitMatcher()
750 OS << '\n'; in EmitMatcher()
760 OS << "OPC_Coverage, "; in EmitMatcher()
769 OS << "TARGET_VAL(" << Offset << "),\n"; in EmitMatcher()
770 OS.indent(FullIndexWidth + Indent * 2); in EmitMatcher()
772 OS << "OPC_CompleteMatch, " << CM->getNumResults() << ", "; in EmitMatcher()
775 NumResultBytes += EmitVBRValue(CM->getResult(i), OS); in EmitMatcher()
776 OS << '\n'; in EmitMatcher()
778 OS.indent(FullIndexWidth + Indent*2) << " // Src: " in EmitMatcher()
781 OS.indent(FullIndexWidth + Indent*2) << " // Dst: " in EmitMatcher()
784 OS << '\n'; in EmitMatcher()
794 raw_ostream &OS) { in EmitMatcherList() argument
798 OS << "/*" << format_decimal(CurrentIdx, IndexWidth) << "*/"; in EmitMatcherList()
799 unsigned MatcherSize = EmitMatcher(N, Indent, CurrentIdx, OS); in EmitMatcherList()
812 raw_ostream &OS) { in EmitNodePredicatesFunction() argument
816 BeginEmitFunction(OS, "bool", Decl, true/*AddOverride*/); in EmitNodePredicatesFunction()
817 OS << "{\n"; in EmitNodePredicatesFunction()
818 OS << " switch (PredNo) {\n"; in EmitNodePredicatesFunction()
819 OS << " default: llvm_unreachable(\"Invalid predicate in table?\");\n"; in EmitNodePredicatesFunction()
825 OS << " case " << i << ": { \n"; in EmitNodePredicatesFunction()
828 OS << " // " << TreePredicateFn(SimilarPred).getFnName() <<'\n'; in EmitNodePredicatesFunction()
830 OS << PredFn.getCodeToRunOnSDNode() << "\n }\n"; in EmitNodePredicatesFunction()
832 OS << " }\n"; in EmitNodePredicatesFunction()
833 OS << "}\n"; in EmitNodePredicatesFunction()
834 EndEmitFunction(OS); in EmitNodePredicatesFunction()
837 void MatcherTableEmitter::EmitPredicateFunctions(raw_ostream &OS) { in EmitPredicateFunctions() argument
840 BeginEmitFunction(OS, "bool", in EmitPredicateFunctions()
842 OS << "{\n"; in EmitPredicateFunctions()
843 OS << " switch (PredNo) {\n"; in EmitPredicateFunctions()
844 OS << " default: llvm_unreachable(\"Invalid predicate in table?\");\n"; in EmitPredicateFunctions()
846 OS << " case " << i << ": return " << PatternPredicates[i] << ";\n"; in EmitPredicateFunctions()
847 OS << " }\n"; in EmitPredicateFunctions()
848 OS << "}\n"; in EmitPredicateFunctions()
849 EndEmitFunction(OS); in EmitPredicateFunctions()
855 OS); in EmitPredicateFunctions()
860 OS); in EmitPredicateFunctions()
865 BeginEmitFunction(OS, "bool", in EmitPredicateFunctions()
870 OS << "{\n"; in EmitPredicateFunctions()
871 OS << " unsigned NextRes = Result.size();\n"; in EmitPredicateFunctions()
872 OS << " switch (PatternNo) {\n"; in EmitPredicateFunctions()
873 OS << " default: llvm_unreachable(\"Invalid pattern # in table?\");\n"; in EmitPredicateFunctions()
881 OS << " case " << i << ":\n"; in EmitPredicateFunctions()
883 OS << " {\n"; in EmitPredicateFunctions()
884 OS << " Result.resize(NextRes+" << NumOps << ");\n"; in EmitPredicateFunctions()
886 OS << " bool Succeeded = " << P.getSelectFunc(); in EmitPredicateFunctions()
888 OS << " return " << P.getSelectFunc(); in EmitPredicateFunctions()
890 OS << "("; in EmitPredicateFunctions()
894 OS << "Root, "; in EmitPredicateFunctions()
899 OS << "Parent, "; in EmitPredicateFunctions()
901 OS << "N"; in EmitPredicateFunctions()
903 OS << ", Result[NextRes+" << i << "].first"; in EmitPredicateFunctions()
904 OS << ");\n"; in EmitPredicateFunctions()
906 OS << " if (Succeeded)\n"; in EmitPredicateFunctions()
907 OS << " dbgs() << \"\\nCOMPLEX_PATTERN: " << P.getSelectFunc() in EmitPredicateFunctions()
909 OS << " return Succeeded;\n"; in EmitPredicateFunctions()
910 OS << " }\n"; in EmitPredicateFunctions()
913 OS << " }\n"; in EmitPredicateFunctions()
914 OS << "}\n"; in EmitPredicateFunctions()
915 EndEmitFunction(OS); in EmitPredicateFunctions()
922 BeginEmitFunction(OS, "SDValue", in EmitPredicateFunctions()
924 OS << "{\n"; in EmitPredicateFunctions()
925 OS << " switch (XFormNo) {\n"; in EmitPredicateFunctions()
926 OS << " default: llvm_unreachable(\"Invalid xform # in table?\");\n"; in EmitPredicateFunctions()
936 OS << " case " << i << ": { "; in EmitPredicateFunctions()
938 OS << "// " << NodeXForms[i]->getName(); in EmitPredicateFunctions()
939 OS << '\n'; in EmitPredicateFunctions()
943 OS << " SDNode *N = V.getNode();\n"; in EmitPredicateFunctions()
945 OS << " " << ClassName << " *N = cast<" << ClassName in EmitPredicateFunctions()
947 OS << Code << "\n }\n"; in EmitPredicateFunctions()
949 OS << " }\n"; in EmitPredicateFunctions()
950 OS << "}\n"; in EmitPredicateFunctions()
951 EndEmitFunction(OS); in EmitPredicateFunctions()
1021 raw_ostream &OS) { in EmitHistogram() argument
1028 OS << " // Opcode Histogram:\n"; in EmitHistogram()
1030 OS << " // #" in EmitHistogram()
1034 OS << '\n'; in EmitHistogram()
1040 raw_ostream &OS) { in EmitMatcherTable() argument
1041 OS << "#if defined(GET_DAGISEL_DECL) && defined(GET_DAGISEL_BODY)\n"; in EmitMatcherTable()
1042 OS << "#error GET_DAGISEL_DECL and GET_DAGISEL_BODY cannot be both defined, "; in EmitMatcherTable()
1043 OS << "undef both for inline definitions\n"; in EmitMatcherTable()
1044 OS << "#endif\n\n"; in EmitMatcherTable()
1047 OS << "#ifdef GET_DAGISEL_BODY\n"; in EmitMatcherTable()
1048 OS << "#define LOCAL_DAGISEL_STRINGIZE(X) LOCAL_DAGISEL_STRINGIZE_(X)\n"; in EmitMatcherTable()
1049 OS << "#define LOCAL_DAGISEL_STRINGIZE_(X) #X\n"; in EmitMatcherTable()
1050 OS << "static_assert(sizeof(LOCAL_DAGISEL_STRINGIZE(GET_DAGISEL_BODY)) > 1," in EmitMatcherTable()
1052 OS << " \"GET_DAGISEL_BODY is empty: it should be defined with the class " in EmitMatcherTable()
1054 OS << "#undef LOCAL_DAGISEL_STRINGIZE_\n"; in EmitMatcherTable()
1055 OS << "#undef LOCAL_DAGISEL_STRINGIZE\n"; in EmitMatcherTable()
1056 OS << "#endif\n\n"; in EmitMatcherTable()
1058 OS << "#if !defined(GET_DAGISEL_DECL) && !defined(GET_DAGISEL_BODY)\n"; in EmitMatcherTable()
1059 OS << "#define DAGISEL_INLINE 1\n"; in EmitMatcherTable()
1060 OS << "#else\n"; in EmitMatcherTable()
1061 OS << "#define DAGISEL_INLINE 0\n"; in EmitMatcherTable()
1062 OS << "#endif\n\n"; in EmitMatcherTable()
1064 OS << "#if !DAGISEL_INLINE\n"; in EmitMatcherTable()
1065 OS << "#define DAGISEL_CLASS_COLONCOLON GET_DAGISEL_BODY ::\n"; in EmitMatcherTable()
1066 OS << "#else\n"; in EmitMatcherTable()
1067 OS << "#define DAGISEL_CLASS_COLONCOLON\n"; in EmitMatcherTable()
1068 OS << "#endif\n\n"; in EmitMatcherTable()
1070 BeginEmitFunction(OS, "void", "SelectCode(SDNode *N)", false/*AddOverride*/); in EmitMatcherTable()
1073 OS << "{\n"; in EmitMatcherTable()
1074 OS << " // Some target values are emitted as 2 bytes, TARGET_VAL handles\n"; in EmitMatcherTable()
1075 OS << " // this.\n"; in EmitMatcherTable()
1076 OS << " #define TARGET_VAL(X) X & 255, unsigned(X) >> 8\n"; in EmitMatcherTable()
1077 OS << " static const unsigned char MatcherTable[] = {\n"; in EmitMatcherTable()
1078 unsigned TotalSize = MatcherEmitter.EmitMatcherList(TheMatcher, 1, 0, OS); in EmitMatcherTable()
1079 OS << " 0\n }; // Total Array size is " << (TotalSize+1) << " bytes\n\n"; in EmitMatcherTable()
1081 MatcherEmitter.EmitHistogram(TheMatcher, OS); in EmitMatcherTable()
1083 OS << " #undef TARGET_VAL\n"; in EmitMatcherTable()
1084 OS << " SelectCodeCommon(N, MatcherTable,sizeof(MatcherTable));\n"; in EmitMatcherTable()
1085 OS << "}\n"; in EmitMatcherTable()
1086 EndEmitFunction(OS); in EmitMatcherTable()
1089 MatcherEmitter.EmitPredicateFunctions(OS); in EmitMatcherTable()
1092 MatcherEmitter.EmitPatternMatchTable(OS); in EmitMatcherTable()
1095 OS << "\n"; in EmitMatcherTable()
1096 OS << "#ifdef DAGISEL_INLINE\n"; in EmitMatcherTable()
1097 OS << "#undef DAGISEL_INLINE\n"; in EmitMatcherTable()
1098 OS << "#endif\n"; in EmitMatcherTable()
1099 OS << "#ifdef DAGISEL_CLASS_COLONCOLON\n"; in EmitMatcherTable()
1100 OS << "#undef DAGISEL_CLASS_COLONCOLON\n"; in EmitMatcherTable()
1101 OS << "#endif\n"; in EmitMatcherTable()
1102 OS << "#ifdef GET_DAGISEL_DECL\n"; in EmitMatcherTable()
1103 OS << "#undef GET_DAGISEL_DECL\n"; in EmitMatcherTable()
1104 OS << "#endif\n"; in EmitMatcherTable()
1105 OS << "#ifdef GET_DAGISEL_BODY\n"; in EmitMatcherTable()
1106 OS << "#undef GET_DAGISEL_BODY\n"; in EmitMatcherTable()
1107 OS << "#endif\n"; in EmitMatcherTable()