Lines Matching refs:OS

55                            unsigned StartIdx, formatted_raw_ostream &OS);
57 void EmitPredicateFunctions(formatted_raw_ostream &OS);
59 void EmitHistogram(const Matcher *N, formatted_raw_ostream &OS);
62 formatted_raw_ostream &OS);
115 static uint64_t EmitVBRValue(uint64_t Val, raw_ostream &OS) {
117 OS << Val << ", ";
124 OS << (Val&127) << "|128,";
128 OS << Val;
130 OS << "/*" << InVal << "*/";
131 OS << ", ";
139 formatted_raw_ostream &OS) {
140 OS.PadToColumn(Indent*2);
152 OS << "OPC_Scope, ";
156 OS << "/*" << CurrentIdx << "*/";
157 OS.PadToColumn(Indent*2) << "/*Scope*/ ";
159 OS.PadToColumn(Indent*2);
174 raw_svector_ostream OS(TmpBuf);
175 formatted_raw_ostream FOS(OS);
182 CurrentIdx += EmitVBRValue(ChildSize, OS);
184 OS << "/*->" << CurrentIdx+ChildSize << "*/";
187 OS.PadToColumn(CommentIndent) << "// " << SM->getNumChildren()
191 OS << '\n' << TmpBuf.str();
197 OS << "/*" << CurrentIdx << "*/";
198 OS.PadToColumn(Indent*2) << "0, ";
200 OS << "/*End of Scope*/";
201 OS << '\n';
206 OS << "OPC_RecordNode,";
208 OS.PadToColumn(CommentIndent) << "// #"
211 OS << '\n';
215 OS << "OPC_RecordChild" << cast<RecordChildMatcher>(N)->getChildNo()
218 OS.PadToColumn(CommentIndent) << "// #"
221 OS << '\n';
225 OS << "OPC_RecordMemRef,\n";
229 OS << "OPC_CaptureGlueInput,\n";
233 OS << "OPC_MoveChild, " << cast<MoveChildMatcher>(N)->getChildNo() << ",\n";
237 OS << "OPC_MoveParent,\n";
241 OS << "OPC_CheckSame, "
247 OS << "OPC_CheckPatternPredicate, " << getPatternPredicate(Pred) << ',';
249 OS.PadToColumn(CommentIndent) << "// " << Pred;
250 OS << '\n';
255 OS << "OPC_CheckPredicate, " << getNodePredicate(Pred) << ',';
257 OS.PadToColumn(CommentIndent) << "// " << Pred.getFnName();
258 OS << '\n';
263 OS << "OPC_CheckOpcode, TARGET_VAL("
273 OS << "OPC_SwitchOpcode ";
276 OS << "OPC_SwitchType ";
281 OS << "/*" << NumCases << " cases */";
282 OS << ", ";
309 raw_svector_ostream OS(TmpBuf);
310 formatted_raw_ostream FOS(OS);
318 OS.PadToColumn(Indent*2);
320 OS << (isa<SwitchOpcodeMatcher>(N) ?
325 CurrentIdx += EmitVBRValue(ChildSize, OS);
327 OS << ' ';
329 OS << "TARGET_VAL(" << SOM->getCaseOpcode(i).getEnumName() << "),";
331 OS << getEnumName(cast<SwitchTypeMatcher>(N)->getCaseType(i)) << ',';
336 OS << "// ->" << CurrentIdx+ChildSize;
337 OS << '\n';
338 OS << TmpBuf.str();
343 OS.PadToColumn(Indent*2) << "0, ";
345 OS << (isa<SwitchOpcodeMatcher>(N) ?
348 OS << '\n';
356 OS << "OPC_CheckType, "
361 OS << "OPC_CheckChild"
367 OS << "OPC_CheckInteger, ";
368 unsigned Bytes=1+EmitVBRValue(cast<CheckIntegerMatcher>(N)->getValue(), OS);
369 OS << '\n';
373 OS << "OPC_CheckCondCode, ISD::"
378 OS << "OPC_CheckValueType, MVT::"
385 OS << "OPC_CheckComplexPat, /*CP*/" << getComplexPat(Pattern) << ", /*#*/"
389 OS.PadToColumn(CommentIndent) << "// " << Pattern.getSelectFunc();
390 OS << ":$" << CCPM->getName();
392 OS << " #" << CCPM->getFirstResult()+i;
395 OS << " + chain result";
397 OS << '\n';
402 OS << "OPC_CheckAndImm, ";
403 unsigned Bytes=1+EmitVBRValue(cast<CheckAndImmMatcher>(N)->getValue(), OS);
404 OS << '\n';
409 OS << "OPC_CheckOrImm, ";
410 unsigned Bytes = 1+EmitVBRValue(cast<CheckOrImmMatcher>(N)->getValue(), OS);
411 OS << '\n';
416 OS << "OPC_CheckFoldableChainNode,\n";
421 OS << "OPC_EmitInteger, "
423 unsigned Bytes = 2+EmitVBRValue(Val, OS);
424 OS << '\n';
430 OS << "OPC_EmitInteger, "
442 OS << "OPC_EmitRegister2, " << getEnumName(Matcher->getVT()) << ", ";
443 OS << "TARGET_VAL(" << getQualifiedName(Reg->TheDef) << "),\n";
446 OS << "OPC_EmitRegister, " << getEnumName(Matcher->getVT()) << ", ";
448 OS << getQualifiedName(Reg->TheDef) << ",\n";
450 OS << "0 ";
452 OS << "/*zero_reg*/";
453 OS << ",\n";
460 OS << "OPC_EmitConvertToTarget, "
470 OS << "OPC_EmitMergeInputChains1_" << MN->getNode(0) << ",\n";
474 OS << "OPC_EmitMergeInputChains, " << MN->getNumNodes() << ", ";
476 OS << MN->getNode(i) << ", ";
477 OS << '\n';
481 OS << "OPC_EmitCopyToReg, "
488 OS << "OPC_EmitNodeXForm, " << getNodeXFormID(XF->getNodeXForm()) << ", "
491 OS.PadToColumn(CommentIndent) << "// "<<XF->getNodeXForm()->getName();
492 OS <<'\n';
499 OS << (isa<EmitNodeMatcher>(EN) ? "OPC_EmitNode" : "OPC_MorphNodeTo");
500 OS << ", TARGET_VAL(" << EN->getOpcodeName() << "), 0";
502 if (EN->hasChain()) OS << "|OPFL_Chain";
503 if (EN->hasInFlag()) OS << "|OPFL_GlueInput";
504 if (EN->hasOutFlag()) OS << "|OPFL_GlueOutput";
505 if (EN->hasMemRefs()) OS << "|OPFL_MemRefs";
507 OS << "|OPFL_Variadic" << EN->getNumFixedArityOperands();
508 OS << ",\n";
510 OS.PadToColumn(Indent*2+4) << EN->getNumVTs();
512 OS << "/*#VTs*/";
513 OS << ", ";
515 OS << getEnumName(EN->getVT(i)) << ", ";
517 OS << EN->getNumOperands();
519 OS << "/*#Ops*/";
520 OS << ", ";
523 NumOperandBytes += EmitVBRValue(EN->getOperand(i), OS);
529 OS.PadToColumn(CommentIndent) << "// Results = ";
532 OS << "#" << First+i << " ";
535 OS << '\n';
538 OS.PadToColumn(Indent*2) << "// Src: "
541 OS.PadToColumn(Indent*2) << "// Dst: "
545 OS << '\n';
551 OS << "OPC_MarkGlueResults, " << CFR->getNumNodes() << ", ";
554 NumOperandBytes += EmitVBRValue(CFR->getNode(i), OS);
555 OS << '\n';
560 OS << "OPC_CompleteMatch, " << CM->getNumResults() << ", ";
563 NumResultBytes += EmitVBRValue(CM->getResult(i), OS);
564 OS << '\n';
566 OS.PadToColumn(Indent*2) << "// Src: "
569 OS.PadToColumn(Indent*2) << "// Dst: "
572 OS << '\n';
582 formatted_raw_ostream &OS) {
586 OS << "/*" << CurrentIdx << "*/";
587 unsigned MatcherSize = EmitMatcher(N, Indent, CurrentIdx, OS);
598 void MatcherTableEmitter::EmitPredicateFunctions(formatted_raw_ostream &OS) {
601 OS << "bool CheckPatternPredicate(unsigned PredNo) const {\n";
602 OS << " switch (PredNo) {\n";
603 OS << " default: llvm_unreachable(\"Invalid predicate in table?\");\n";
605 OS << " case " << i << ": return " << PatternPredicates[i] << ";\n";
606 OS << " }\n";
607 OS << "}\n\n";
619 OS << "bool CheckNodePredicate(SDNode *Node, unsigned PredNo) const {\n";
620 OS << " switch (PredNo) {\n";
621 OS << " default: llvm_unreachable(\"Invalid predicate in table?\");\n";
627 OS << " case " << i << ": { // " << NodePredicates[i].getFnName() <<'\n';
629 OS << PredFn.getCodeToRunOnSDNode() << "\n }\n";
631 OS << " }\n";
632 OS << "}\n\n";
638 OS << "bool CheckComplexPattern(SDNode *Root, SDNode *Parent, SDValue N,\n";
639 OS << " unsigned PatternNo,\n";
640 OS << " SmallVectorImpl<std::pair<SDValue, SDNode*> > &Result) {\n";
641 OS << " unsigned NextRes = Result.size();\n";
642 OS << " switch (PatternNo) {\n";
643 OS << " default: llvm_unreachable(\"Invalid pattern # in table?\");\n";
651 OS << " case " << i << ":\n";
652 OS << " Result.resize(NextRes+" << NumOps << ");\n";
653 OS << " return " << P.getSelectFunc();
655 OS << "(";
659 OS << "Root, ";
664 OS << "Parent, ";
666 OS << "N";
668 OS << ", Result[NextRes+" << i << "].first";
669 OS << ");\n";
671 OS << " }\n";
672 OS << "}\n\n";
679 OS << "SDValue RunSDNodeXForm(SDValue V, unsigned XFormNo) {\n";
680 OS << " switch (XFormNo) {\n";
681 OS << " default: llvm_unreachable(\"Invalid xform # in table?\");\n";
691 OS << " case " << i << ": { ";
693 OS << "// " << NodeXForms[i]->getName();
694 OS << '\n';
698 OS << " SDNode *N = V.getNode();\n";
700 OS << " " << ClassName << " *N = cast<" << ClassName
702 OS << Code << "\n }\n";
704 OS << " }\n";
705 OS << "}\n\n";
732 formatted_raw_ostream &OS) {
739 OS << " // Opcode Histogram:\n";
741 OS << " // #";
743 case Matcher::Scope: OS << "OPC_Scope"; break;
744 case Matcher::RecordNode: OS << "OPC_RecordNode"; break;
745 case Matcher::RecordChild: OS << "OPC_RecordChild"; break;
746 case Matcher::RecordMemRef: OS << "OPC_RecordMemRef"; break;
747 case Matcher::CaptureGlueInput: OS << "OPC_CaptureGlueInput"; break;
748 case Matcher::MoveChild: OS << "OPC_MoveChild"; break;
749 case Matcher::MoveParent: OS << "OPC_MoveParent"; break;
750 case Matcher::CheckSame: OS << "OPC_CheckSame"; break;
752 OS << "OPC_CheckPatternPredicate"; break;
753 case Matcher::CheckPredicate: OS << "OPC_CheckPredicate"; break;
754 case Matcher::CheckOpcode: OS << "OPC_CheckOpcode"; break;
755 case Matcher::SwitchOpcode: OS << "OPC_SwitchOpcode"; break;
756 case Matcher::CheckType: OS << "OPC_CheckType"; break;
757 case Matcher::SwitchType: OS << "OPC_SwitchType"; break;
758 case Matcher::CheckChildType: OS << "OPC_CheckChildType"; break;
759 case Matcher::CheckInteger: OS << "OPC_CheckInteger"; break;
760 case Matcher::CheckCondCode: OS << "OPC_CheckCondCode"; break;
761 case Matcher::CheckValueType: OS << "OPC_CheckValueType"; break;
762 case Matcher::CheckComplexPat: OS << "OPC_CheckComplexPat"; break;
763 case Matcher::CheckAndImm: OS << "OPC_CheckAndImm"; break;
764 case Matcher::CheckOrImm: OS << "OPC_CheckOrImm"; break;
766 OS << "OPC_CheckFoldableChainNode"; break;
767 case Matcher::EmitInteger: OS << "OPC_EmitInteger"; break;
768 case Matcher::EmitStringInteger: OS << "OPC_EmitStringInteger"; break;
769 case Matcher::EmitRegister: OS << "OPC_EmitRegister"; break;
770 case Matcher::EmitConvertToTarget: OS << "OPC_EmitConvertToTarget"; break;
771 case Matcher::EmitMergeInputChains: OS << "OPC_EmitMergeInputChains"; break;
772 case Matcher::EmitCopyToReg: OS << "OPC_EmitCopyToReg"; break;
773 case Matcher::EmitNode: OS << "OPC_EmitNode"; break;
774 case Matcher::MorphNodeTo: OS << "OPC_MorphNodeTo"; break;
775 case Matcher::EmitNodeXForm: OS << "OPC_EmitNodeXForm"; break;
776 case Matcher::MarkGlueResults: OS << "OPC_MarkGlueResults"; break;
777 case Matcher::CompleteMatch: OS << "OPC_CompleteMatch"; break;
780 OS.PadToColumn(40) << " = " << OpcodeFreq[i] << '\n';
782 OS << '\n';
789 formatted_raw_ostream OS(O);
791 OS << "// The main instruction selector code.\n";
792 OS << "SDNode *SelectCode(SDNode *N) {\n";
796 OS << " // Some target values are emitted as 2 bytes, TARGET_VAL handles\n";
797 OS << " // this.\n";
798 OS << " #define TARGET_VAL(X) X & 255, unsigned(X) >> 8\n";
799 OS << " static const unsigned char MatcherTable[] = {\n";
800 unsigned TotalSize = MatcherEmitter.EmitMatcherList(TheMatcher, 5, 0, OS);
801 OS << " 0\n }; // Total Array size is " << (TotalSize+1) << " bytes\n\n";
803 MatcherEmitter.EmitHistogram(TheMatcher, OS);
805 OS << " #undef TARGET_VAL\n";
806 OS << " return SelectCodeCommon(N, MatcherTable,sizeof(MatcherTable));\n}\n";
807 OS << '\n';
810 MatcherEmitter.EmitPredicateFunctions(OS);