Lines Matching refs:OS
60 unsigned StartIdx, formatted_raw_ostream &OS);
62 void EmitPredicateFunctions(formatted_raw_ostream &OS);
64 void EmitHistogram(const Matcher *N, formatted_raw_ostream &OS);
67 formatted_raw_ostream &OS);
133 static uint64_t EmitVBRValue(uint64_t Val, raw_ostream &OS) { in EmitVBRValue() argument
135 OS << Val << ", "; in EmitVBRValue()
142 OS << (Val&127) << "|128,"; in EmitVBRValue()
146 OS << Val; in EmitVBRValue()
148 OS << "/*" << InVal << "*/"; in EmitVBRValue()
149 OS << ", "; in EmitVBRValue()
157 formatted_raw_ostream &OS) { in EmitMatcher() argument
158 OS.PadToColumn(Indent*2); in EmitMatcher()
170 OS << "OPC_Scope, "; in EmitMatcher()
174 OS << "/*" << CurrentIdx << "*/"; in EmitMatcher()
175 OS.PadToColumn(Indent*2) << "/*Scope*/ "; in EmitMatcher()
177 OS.PadToColumn(Indent*2); in EmitMatcher()
192 raw_svector_ostream OS(TmpBuf); in EmitMatcher() local
193 formatted_raw_ostream FOS(OS); in EmitMatcher()
200 CurrentIdx += EmitVBRValue(ChildSize, OS); in EmitMatcher()
202 OS << "/*->" << CurrentIdx+ChildSize << "*/"; in EmitMatcher()
205 OS.PadToColumn(CommentIndent) << "// " << SM->getNumChildren() in EmitMatcher()
209 OS << '\n' << TmpBuf; in EmitMatcher()
215 OS << "/*" << CurrentIdx << "*/"; in EmitMatcher()
216 OS.PadToColumn(Indent*2) << "0, "; in EmitMatcher()
218 OS << "/*End of Scope*/"; in EmitMatcher()
219 OS << '\n'; in EmitMatcher()
224 OS << "OPC_RecordNode,"; in EmitMatcher()
226 OS.PadToColumn(CommentIndent) << "// #" in EmitMatcher()
229 OS << '\n'; in EmitMatcher()
233 OS << "OPC_RecordChild" << cast<RecordChildMatcher>(N)->getChildNo() in EmitMatcher()
236 OS.PadToColumn(CommentIndent) << "// #" in EmitMatcher()
239 OS << '\n'; in EmitMatcher()
243 OS << "OPC_RecordMemRef,\n"; in EmitMatcher()
247 OS << "OPC_CaptureGlueInput,\n"; in EmitMatcher()
251 OS << "OPC_MoveChild, " << cast<MoveChildMatcher>(N)->getChildNo() << ",\n"; in EmitMatcher()
255 OS << "OPC_MoveParent,\n"; in EmitMatcher()
259 OS << "OPC_CheckSame, " in EmitMatcher()
264 OS << "OPC_CheckChild" in EmitMatcher()
271 OS << "OPC_CheckPatternPredicate, " << getPatternPredicate(Pred) << ','; in EmitMatcher()
273 OS.PadToColumn(CommentIndent) << "// " << Pred; in EmitMatcher()
274 OS << '\n'; in EmitMatcher()
279 OS << "OPC_CheckPredicate, " << getNodePredicate(Pred) << ','; in EmitMatcher()
281 OS.PadToColumn(CommentIndent) << "// " << Pred.getFnName(); in EmitMatcher()
282 OS << '\n'; in EmitMatcher()
287 OS << "OPC_CheckOpcode, TARGET_VAL(" in EmitMatcher()
297 OS << "OPC_SwitchOpcode "; in EmitMatcher()
300 OS << "OPC_SwitchType "; in EmitMatcher()
305 OS << "/*" << NumCases << " cases */"; in EmitMatcher()
306 OS << ", "; in EmitMatcher()
333 raw_svector_ostream OS(TmpBuf); in EmitMatcher() local
334 formatted_raw_ostream FOS(OS); in EmitMatcher()
343 OS << "/*" << CurrentIdx << "*/"; in EmitMatcher()
344 OS.PadToColumn(Indent*2); in EmitMatcher()
346 OS << (isa<SwitchOpcodeMatcher>(N) ? in EmitMatcher()
351 CurrentIdx += EmitVBRValue(ChildSize, OS); in EmitMatcher()
354 OS << "TARGET_VAL(" << SOM->getCaseOpcode(i).getEnumName() << "),"; in EmitMatcher()
356 OS << getEnumName(cast<SwitchTypeMatcher>(N)->getCaseType(i)) << ','; in EmitMatcher()
361 OS << "// ->" << CurrentIdx+ChildSize; in EmitMatcher()
362 OS << '\n'; in EmitMatcher()
363 OS << TmpBuf; in EmitMatcher()
369 OS << "/*" << CurrentIdx << "*/"; in EmitMatcher()
370 OS.PadToColumn(Indent*2) << "0, "; in EmitMatcher()
372 OS << (isa<SwitchOpcodeMatcher>(N) ? in EmitMatcher()
375 OS << '\n'; in EmitMatcher()
383 OS << "OPC_CheckType, " in EmitMatcher()
388 OS << "OPC_CheckChild" in EmitMatcher()
394 OS << "OPC_CheckInteger, "; in EmitMatcher()
395 unsigned Bytes=1+EmitVBRValue(cast<CheckIntegerMatcher>(N)->getValue(), OS); in EmitMatcher()
396 OS << '\n'; in EmitMatcher()
400 OS << "OPC_CheckChild" << cast<CheckChildIntegerMatcher>(N)->getChildNo() in EmitMatcher()
403 OS); in EmitMatcher()
404 OS << '\n'; in EmitMatcher()
408 OS << "OPC_CheckCondCode, ISD::" in EmitMatcher()
413 OS << "OPC_CheckValueType, MVT::" in EmitMatcher()
420 OS << "OPC_CheckComplexPat, /*CP*/" << getComplexPat(Pattern) << ", /*#*/" in EmitMatcher()
424 OS.PadToColumn(CommentIndent) << "// " << Pattern.getSelectFunc(); in EmitMatcher()
425 OS << ":$" << CCPM->getName(); in EmitMatcher()
427 OS << " #" << CCPM->getFirstResult()+i; in EmitMatcher()
430 OS << " + chain result"; in EmitMatcher()
432 OS << '\n'; in EmitMatcher()
437 OS << "OPC_CheckAndImm, "; in EmitMatcher()
438 unsigned Bytes=1+EmitVBRValue(cast<CheckAndImmMatcher>(N)->getValue(), OS); in EmitMatcher()
439 OS << '\n'; in EmitMatcher()
444 OS << "OPC_CheckOrImm, "; in EmitMatcher()
445 unsigned Bytes = 1+EmitVBRValue(cast<CheckOrImmMatcher>(N)->getValue(), OS); in EmitMatcher()
446 OS << '\n'; in EmitMatcher()
451 OS << "OPC_CheckFoldableChainNode,\n"; in EmitMatcher()
456 OS << "OPC_EmitInteger, " in EmitMatcher()
458 unsigned Bytes = 2+EmitVBRValue(Val, OS); in EmitMatcher()
459 OS << '\n'; in EmitMatcher()
465 OS << "OPC_EmitInteger, " in EmitMatcher()
477 OS << "OPC_EmitRegister2, " << getEnumName(Matcher->getVT()) << ", "; in EmitMatcher()
478 OS << "TARGET_VAL(" << getQualifiedName(Reg->TheDef) << "),\n"; in EmitMatcher()
481 OS << "OPC_EmitRegister, " << getEnumName(Matcher->getVT()) << ", "; in EmitMatcher()
483 OS << getQualifiedName(Reg->TheDef) << ",\n"; in EmitMatcher()
485 OS << "0 "; in EmitMatcher()
487 OS << "/*zero_reg*/"; in EmitMatcher()
488 OS << ",\n"; in EmitMatcher()
495 OS << "OPC_EmitConvertToTarget, " in EmitMatcher()
505 OS << "OPC_EmitMergeInputChains1_" << MN->getNode(0) << ",\n"; in EmitMatcher()
509 OS << "OPC_EmitMergeInputChains, " << MN->getNumNodes() << ", "; in EmitMatcher()
511 OS << MN->getNode(i) << ", "; in EmitMatcher()
512 OS << '\n'; in EmitMatcher()
516 OS << "OPC_EmitCopyToReg, " in EmitMatcher()
523 OS << "OPC_EmitNodeXForm, " << getNodeXFormID(XF->getNodeXForm()) << ", " in EmitMatcher()
526 OS.PadToColumn(CommentIndent) << "// "<<XF->getNodeXForm()->getName(); in EmitMatcher()
527 OS <<'\n'; in EmitMatcher()
534 OS << (isa<EmitNodeMatcher>(EN) ? "OPC_EmitNode" : "OPC_MorphNodeTo"); in EmitMatcher()
535 OS << ", TARGET_VAL(" << EN->getOpcodeName() << "), 0"; in EmitMatcher()
537 if (EN->hasChain()) OS << "|OPFL_Chain"; in EmitMatcher()
538 if (EN->hasInFlag()) OS << "|OPFL_GlueInput"; in EmitMatcher()
539 if (EN->hasOutFlag()) OS << "|OPFL_GlueOutput"; in EmitMatcher()
540 if (EN->hasMemRefs()) OS << "|OPFL_MemRefs"; in EmitMatcher()
542 OS << "|OPFL_Variadic" << EN->getNumFixedArityOperands(); in EmitMatcher()
543 OS << ",\n"; in EmitMatcher()
545 OS.PadToColumn(Indent*2+4) << EN->getNumVTs(); in EmitMatcher()
547 OS << "/*#VTs*/"; in EmitMatcher()
548 OS << ", "; in EmitMatcher()
550 OS << getEnumName(EN->getVT(i)) << ", "; in EmitMatcher()
552 OS << EN->getNumOperands(); in EmitMatcher()
554 OS << "/*#Ops*/"; in EmitMatcher()
555 OS << ", "; in EmitMatcher()
558 NumOperandBytes += EmitVBRValue(EN->getOperand(i), OS); in EmitMatcher()
564 OS.PadToColumn(CommentIndent) << "// Results ="; in EmitMatcher()
567 OS << " #" << First+i; in EmitMatcher()
570 OS << '\n'; in EmitMatcher()
573 OS.PadToColumn(Indent*2) << "// Src: " in EmitMatcher()
576 OS.PadToColumn(Indent*2) << "// Dst: " in EmitMatcher()
580 OS << '\n'; in EmitMatcher()
586 OS << "OPC_MarkGlueResults, " << CFR->getNumNodes() << ", "; in EmitMatcher()
589 NumOperandBytes += EmitVBRValue(CFR->getNode(i), OS); in EmitMatcher()
590 OS << '\n'; in EmitMatcher()
595 OS << "OPC_CompleteMatch, " << CM->getNumResults() << ", "; in EmitMatcher()
598 NumResultBytes += EmitVBRValue(CM->getResult(i), OS); in EmitMatcher()
599 OS << '\n'; in EmitMatcher()
601 OS.PadToColumn(Indent*2) << "// Src: " in EmitMatcher()
604 OS.PadToColumn(Indent*2) << "// Dst: " in EmitMatcher()
607 OS << '\n'; in EmitMatcher()
617 formatted_raw_ostream &OS) { in EmitMatcherList() argument
621 OS << "/*" << CurrentIdx << "*/"; in EmitMatcherList()
622 unsigned MatcherSize = EmitMatcher(N, Indent, CurrentIdx, OS); in EmitMatcherList()
633 void MatcherTableEmitter::EmitPredicateFunctions(formatted_raw_ostream &OS) { in EmitPredicateFunctions() argument
636 OS << "bool CheckPatternPredicate(unsigned PredNo) const override {\n"; in EmitPredicateFunctions()
637 OS << " switch (PredNo) {\n"; in EmitPredicateFunctions()
638 OS << " default: llvm_unreachable(\"Invalid predicate in table?\");\n"; in EmitPredicateFunctions()
640 OS << " case " << i << ": return " << PatternPredicates[i] << ";\n"; in EmitPredicateFunctions()
641 OS << " }\n"; in EmitPredicateFunctions()
642 OS << "}\n\n"; in EmitPredicateFunctions()
647 OS << "bool CheckNodePredicate(SDNode *Node,\n"; in EmitPredicateFunctions()
648 OS << " unsigned PredNo) const override {\n"; in EmitPredicateFunctions()
649 OS << " switch (PredNo) {\n"; in EmitPredicateFunctions()
650 OS << " default: llvm_unreachable(\"Invalid predicate in table?\");\n"; in EmitPredicateFunctions()
656 OS << " case " << i << ": { \n"; in EmitPredicateFunctions()
659 OS << " // " << TreePredicateFn(SimilarPred).getFnName() <<'\n'; in EmitPredicateFunctions()
661 OS << PredFn.getCodeToRunOnSDNode() << "\n }\n"; in EmitPredicateFunctions()
663 OS << " }\n"; in EmitPredicateFunctions()
664 OS << "}\n\n"; in EmitPredicateFunctions()
670 OS << "bool CheckComplexPattern(SDNode *Root, SDNode *Parent,\n"; in EmitPredicateFunctions()
671 OS << " SDValue N, unsigned PatternNo,\n"; in EmitPredicateFunctions()
672 OS << " SmallVectorImpl<std::pair<SDValue, SDNode*> > &Result) override {\n"; in EmitPredicateFunctions()
673 OS << " unsigned NextRes = Result.size();\n"; in EmitPredicateFunctions()
674 OS << " switch (PatternNo) {\n"; in EmitPredicateFunctions()
675 OS << " default: llvm_unreachable(\"Invalid pattern # in table?\");\n"; in EmitPredicateFunctions()
683 OS << " case " << i << ":\n"; in EmitPredicateFunctions()
684 OS << " Result.resize(NextRes+" << NumOps << ");\n"; in EmitPredicateFunctions()
685 OS << " return " << P.getSelectFunc(); in EmitPredicateFunctions()
687 OS << "("; in EmitPredicateFunctions()
691 OS << "Root, "; in EmitPredicateFunctions()
696 OS << "Parent, "; in EmitPredicateFunctions()
698 OS << "N"; in EmitPredicateFunctions()
700 OS << ", Result[NextRes+" << i << "].first"; in EmitPredicateFunctions()
701 OS << ");\n"; in EmitPredicateFunctions()
703 OS << " }\n"; in EmitPredicateFunctions()
704 OS << "}\n\n"; in EmitPredicateFunctions()
711 OS << "SDValue RunSDNodeXForm(SDValue V, unsigned XFormNo) override {\n"; in EmitPredicateFunctions()
712 OS << " switch (XFormNo) {\n"; in EmitPredicateFunctions()
713 OS << " default: llvm_unreachable(\"Invalid xform # in table?\");\n"; in EmitPredicateFunctions()
723 OS << " case " << i << ": { "; in EmitPredicateFunctions()
725 OS << "// " << NodeXForms[i]->getName(); in EmitPredicateFunctions()
726 OS << '\n'; in EmitPredicateFunctions()
730 OS << " SDNode *N = V.getNode();\n"; in EmitPredicateFunctions()
732 OS << " " << ClassName << " *N = cast<" << ClassName in EmitPredicateFunctions()
734 OS << Code << "\n }\n"; in EmitPredicateFunctions()
736 OS << " }\n"; in EmitPredicateFunctions()
737 OS << "}\n\n"; in EmitPredicateFunctions()
764 formatted_raw_ostream &OS) { in EmitHistogram() argument
771 OS << " // Opcode Histogram:\n"; in EmitHistogram()
773 OS << " // #"; in EmitHistogram()
775 case Matcher::Scope: OS << "OPC_Scope"; break; in EmitHistogram()
776 case Matcher::RecordNode: OS << "OPC_RecordNode"; break; in EmitHistogram()
777 case Matcher::RecordChild: OS << "OPC_RecordChild"; break; in EmitHistogram()
778 case Matcher::RecordMemRef: OS << "OPC_RecordMemRef"; break; in EmitHistogram()
779 case Matcher::CaptureGlueInput: OS << "OPC_CaptureGlueInput"; break; in EmitHistogram()
780 case Matcher::MoveChild: OS << "OPC_MoveChild"; break; in EmitHistogram()
781 case Matcher::MoveParent: OS << "OPC_MoveParent"; break; in EmitHistogram()
782 case Matcher::CheckSame: OS << "OPC_CheckSame"; break; in EmitHistogram()
783 case Matcher::CheckChildSame: OS << "OPC_CheckChildSame"; break; in EmitHistogram()
785 OS << "OPC_CheckPatternPredicate"; break; in EmitHistogram()
786 case Matcher::CheckPredicate: OS << "OPC_CheckPredicate"; break; in EmitHistogram()
787 case Matcher::CheckOpcode: OS << "OPC_CheckOpcode"; break; in EmitHistogram()
788 case Matcher::SwitchOpcode: OS << "OPC_SwitchOpcode"; break; in EmitHistogram()
789 case Matcher::CheckType: OS << "OPC_CheckType"; break; in EmitHistogram()
790 case Matcher::SwitchType: OS << "OPC_SwitchType"; break; in EmitHistogram()
791 case Matcher::CheckChildType: OS << "OPC_CheckChildType"; break; in EmitHistogram()
792 case Matcher::CheckInteger: OS << "OPC_CheckInteger"; break; in EmitHistogram()
793 case Matcher::CheckChildInteger: OS << "OPC_CheckChildInteger"; break; in EmitHistogram()
794 case Matcher::CheckCondCode: OS << "OPC_CheckCondCode"; break; in EmitHistogram()
795 case Matcher::CheckValueType: OS << "OPC_CheckValueType"; break; in EmitHistogram()
796 case Matcher::CheckComplexPat: OS << "OPC_CheckComplexPat"; break; in EmitHistogram()
797 case Matcher::CheckAndImm: OS << "OPC_CheckAndImm"; break; in EmitHistogram()
798 case Matcher::CheckOrImm: OS << "OPC_CheckOrImm"; break; in EmitHistogram()
800 OS << "OPC_CheckFoldableChainNode"; break; in EmitHistogram()
801 case Matcher::EmitInteger: OS << "OPC_EmitInteger"; break; in EmitHistogram()
802 case Matcher::EmitStringInteger: OS << "OPC_EmitStringInteger"; break; in EmitHistogram()
803 case Matcher::EmitRegister: OS << "OPC_EmitRegister"; break; in EmitHistogram()
804 case Matcher::EmitConvertToTarget: OS << "OPC_EmitConvertToTarget"; break; in EmitHistogram()
805 case Matcher::EmitMergeInputChains: OS << "OPC_EmitMergeInputChains"; break; in EmitHistogram()
806 case Matcher::EmitCopyToReg: OS << "OPC_EmitCopyToReg"; break; in EmitHistogram()
807 case Matcher::EmitNode: OS << "OPC_EmitNode"; break; in EmitHistogram()
808 case Matcher::MorphNodeTo: OS << "OPC_MorphNodeTo"; break; in EmitHistogram()
809 case Matcher::EmitNodeXForm: OS << "OPC_EmitNodeXForm"; break; in EmitHistogram()
810 case Matcher::MarkGlueResults: OS << "OPC_MarkGlueResults"; break; in EmitHistogram()
811 case Matcher::CompleteMatch: OS << "OPC_CompleteMatch"; break; in EmitHistogram()
814 OS.PadToColumn(40) << " = " << OpcodeFreq[i] << '\n'; in EmitHistogram()
816 OS << '\n'; in EmitHistogram()
823 formatted_raw_ostream OS(O); in EmitMatcherTable() local
825 OS << "// The main instruction selector code.\n"; in EmitMatcherTable()
826 OS << "SDNode *SelectCode(SDNode *N) {\n"; in EmitMatcherTable()
830 OS << " // Some target values are emitted as 2 bytes, TARGET_VAL handles\n"; in EmitMatcherTable()
831 OS << " // this.\n"; in EmitMatcherTable()
832 OS << " #define TARGET_VAL(X) X & 255, unsigned(X) >> 8\n"; in EmitMatcherTable()
833 OS << " static const unsigned char MatcherTable[] = {\n"; in EmitMatcherTable()
834 unsigned TotalSize = MatcherEmitter.EmitMatcherList(TheMatcher, 6, 0, OS); in EmitMatcherTable()
835 OS << " 0\n }; // Total Array size is " << (TotalSize+1) << " bytes\n\n"; in EmitMatcherTable()
837 MatcherEmitter.EmitHistogram(TheMatcher, OS); in EmitMatcherTable()
839 OS << " #undef TARGET_VAL\n"; in EmitMatcherTable()
840 OS << " return SelectCodeCommon(N, MatcherTable,sizeof(MatcherTable));\n}\n"; in EmitMatcherTable()
841 OS << '\n'; in EmitMatcherTable()
844 MatcherEmitter.EmitPredicateFunctions(OS); in EmitMatcherTable()