1 //===- DAGISelMatcherEmitter.cpp - Matcher Emitter ------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file contains code to generate C++ code a matcher.
12 //===----------------------------------------------------------------------===//
14 #include "DAGISelMatcher.h"
15 #include "CodeGenDAGPatterns.h"
17 #include "llvm/ADT/DenseMap.h"
18 #include "llvm/ADT/SmallString.h"
19 #include "llvm/ADT/StringMap.h"
20 #include "llvm/Support/FormattedStream.h"
28 class MatcherTableEmitter {
29 StringMap<unsigned> NodePredicateMap, PatternPredicateMap;
30 std::vector<std::string> NodePredicates, PatternPredicates;
32 DenseMap<const ComplexPattern*, unsigned> ComplexPatternMap;
33 std::vector<const ComplexPattern*> ComplexPatterns;
36 DenseMap<Record*, unsigned> NodeXFormMap;
37 std::vector<Record*> NodeXForms;
39 // Per opcode frequence count.
40 std::vector<unsigned> Histogram;
42 MatcherTableEmitter() {}
44 unsigned EmitMatcherList(const Matcher *N, unsigned Indent,
45 unsigned StartIdx, formatted_raw_ostream &OS);
47 void EmitPredicateFunctions(const CodeGenDAGPatterns &CGP,
48 formatted_raw_ostream &OS);
50 void EmitHistogram(formatted_raw_ostream &OS);
52 unsigned EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx,
53 formatted_raw_ostream &OS);
55 unsigned getNodePredicate(StringRef PredName) {
56 unsigned &Entry = NodePredicateMap[PredName];
58 NodePredicates.push_back(PredName.str());
59 Entry = NodePredicates.size();
63 unsigned getPatternPredicate(StringRef PredName) {
64 unsigned &Entry = PatternPredicateMap[PredName];
66 PatternPredicates.push_back(PredName.str());
67 Entry = PatternPredicates.size();
72 unsigned getComplexPat(const ComplexPattern &P) {
73 unsigned &Entry = ComplexPatternMap[&P];
75 ComplexPatterns.push_back(&P);
76 Entry = ComplexPatterns.size();
81 unsigned getNodeXFormID(Record *Rec) {
82 unsigned &Entry = NodeXFormMap[Rec];
84 NodeXForms.push_back(Rec);
85 Entry = NodeXForms.size();
91 } // end anonymous namespace.
93 static unsigned GetVBRSize(unsigned Val) {
94 if (Val <= 127) return 1;
96 unsigned NumBytes = 0;
104 /// EmitVBRValue - Emit the specified value as a VBR, returning the number of
106 static uint64_t EmitVBRValue(uint64_t Val, raw_ostream &OS) {
112 uint64_t InVal = Val;
113 unsigned NumBytes = 0;
115 OS << (Val&127) << "|128,";
119 OS << Val << "/*" << InVal << "*/, ";
123 /// EmitMatcherOpcodes - Emit bytes for the specified matcher and return
124 /// the number of bytes emitted.
125 unsigned MatcherTableEmitter::
126 EmitMatcher(const Matcher *N, unsigned Indent, unsigned CurrentIdx,
127 formatted_raw_ostream &OS) {
128 OS.PadToColumn(Indent*2);
130 switch (N->getKind()) {
131 case Matcher::Scope: {
132 const ScopeMatcher *SM = cast<ScopeMatcher>(N);
133 assert(SM->getNext() == 0 && "Shouldn't have next after scope");
135 unsigned StartIdx = CurrentIdx;
137 // Emit all of the children.
138 for (unsigned i = 0, e = SM->getNumChildren(); i != e; ++i) {
143 OS << "/*" << CurrentIdx << "*/";
144 OS.PadToColumn(Indent*2) << "/*Scope*/ ";
147 // We need to encode the child and the offset of the failure code before
148 // emitting either of them. Handle this by buffering the output into a
149 // string while we get the size. Unfortunately, the offset of the
150 // children depends on the VBR size of the child, so for large children we
151 // have to iterate a bit.
152 SmallString<128> TmpBuf;
153 unsigned ChildSize = 0;
154 unsigned VBRSize = 0;
156 VBRSize = GetVBRSize(ChildSize);
159 raw_svector_ostream OS(TmpBuf);
160 formatted_raw_ostream FOS(OS);
161 ChildSize = EmitMatcherList(cast<ScopeMatcher>(N)->getChild(i),
162 Indent+1, CurrentIdx+VBRSize, FOS);
163 } while (GetVBRSize(ChildSize) != VBRSize);
165 assert(ChildSize != 0 && "Should not have a zero-sized child!");
167 CurrentIdx += EmitVBRValue(ChildSize, OS);
168 OS << "/*->" << CurrentIdx+ChildSize << "*/";
171 OS.PadToColumn(CommentIndent) << "// " << SM->getNumChildren()
172 << " children in Scope";
174 OS << '\n' << TmpBuf.str();
175 CurrentIdx += ChildSize;
178 // Emit a zero as a sentinel indicating end of 'Scope'.
179 OS << "/*" << CurrentIdx << "*/";
180 OS.PadToColumn(Indent*2) << "0, /*End of Scope*/\n";
181 return CurrentIdx - StartIdx + 1;
184 case Matcher::RecordNode:
185 OS << "OPC_RecordNode,";
186 OS.PadToColumn(CommentIndent) << "// #"
187 << cast<RecordMatcher>(N)->getResultNo() << " = "
188 << cast<RecordMatcher>(N)->getWhatFor() << '\n';
191 case Matcher::RecordChild:
192 OS << "OPC_RecordChild" << cast<RecordChildMatcher>(N)->getChildNo()
194 OS.PadToColumn(CommentIndent) << "// #"
195 << cast<RecordChildMatcher>(N)->getResultNo() << " = "
196 << cast<RecordChildMatcher>(N)->getWhatFor() << '\n';
199 case Matcher::RecordMemRef:
200 OS << "OPC_RecordMemRef,\n";
203 case Matcher::CaptureFlagInput:
204 OS << "OPC_CaptureFlagInput,\n";
207 case Matcher::MoveChild:
208 OS << "OPC_MoveChild, " << cast<MoveChildMatcher>(N)->getChildNo() << ",\n";
211 case Matcher::MoveParent:
212 OS << "OPC_MoveParent,\n";
215 case Matcher::CheckSame:
216 OS << "OPC_CheckSame, "
217 << cast<CheckSameMatcher>(N)->getMatchNumber() << ",\n";
220 case Matcher::CheckPatternPredicate: {
221 StringRef Pred = cast<CheckPatternPredicateMatcher>(N)->getPredicate();
222 OS << "OPC_CheckPatternPredicate, " << getPatternPredicate(Pred) << ',';
223 OS.PadToColumn(CommentIndent) << "// " << Pred << '\n';
226 case Matcher::CheckPredicate: {
227 StringRef Pred = cast<CheckPredicateMatcher>(N)->getPredicateName();
228 OS << "OPC_CheckPredicate, " << getNodePredicate(Pred) << ',';
229 OS.PadToColumn(CommentIndent) << "// " << Pred << '\n';
233 case Matcher::CheckOpcode:
234 OS << "OPC_CheckOpcode, "
235 << cast<CheckOpcodeMatcher>(N)->getOpcode().getEnumName() << ",\n";
238 case Matcher::CheckMultiOpcode: {
239 const CheckMultiOpcodeMatcher *CMO = cast<CheckMultiOpcodeMatcher>(N);
240 OS << "OPC_CheckMultiOpcode, " << CMO->getNumOpcodes() << ", ";
241 for (unsigned i = 0, e = CMO->getNumOpcodes(); i != e; ++i)
242 OS << CMO->getOpcode(i).getEnumName() << ", ";
244 return 2 + CMO->getNumOpcodes();
247 case Matcher::CheckType:
248 OS << "OPC_CheckType, "
249 << getEnumName(cast<CheckTypeMatcher>(N)->getType()) << ",\n";
251 case Matcher::CheckChildType:
252 OS << "OPC_CheckChild"
253 << cast<CheckChildTypeMatcher>(N)->getChildNo() << "Type, "
254 << getEnumName(cast<CheckChildTypeMatcher>(N)->getType()) << ",\n";
257 case Matcher::CheckInteger:
258 OS << "OPC_CheckInteger, ";
259 return 1+EmitVBRValue(cast<CheckIntegerMatcher>(N)->getValue(), OS);
260 case Matcher::CheckCondCode:
261 OS << "OPC_CheckCondCode, ISD::"
262 << cast<CheckCondCodeMatcher>(N)->getCondCodeName() << ",\n";
265 case Matcher::CheckValueType:
266 OS << "OPC_CheckValueType, MVT::"
267 << cast<CheckValueTypeMatcher>(N)->getTypeName() << ",\n";
270 case Matcher::CheckComplexPat: {
271 const ComplexPattern &Pattern =
272 cast<CheckComplexPatMatcher>(N)->getPattern();
273 OS << "OPC_CheckComplexPat, " << getComplexPat(Pattern) << ',';
274 OS.PadToColumn(CommentIndent) << "// " << Pattern.getSelectFunc();
275 OS << ": " << Pattern.getNumOperands() << " operands";
276 if (Pattern.hasProperty(SDNPHasChain))
277 OS << " + chain result and input";
282 case Matcher::CheckAndImm:
283 OS << "OPC_CheckAndImm, ";
284 return 1+EmitVBRValue(cast<CheckAndImmMatcher>(N)->getValue(), OS);
286 case Matcher::CheckOrImm:
287 OS << "OPC_CheckOrImm, ";
288 return 1+EmitVBRValue(cast<CheckOrImmMatcher>(N)->getValue(), OS);
290 case Matcher::CheckFoldableChainNode:
291 OS << "OPC_CheckFoldableChainNode,\n";
293 case Matcher::CheckChainCompatible:
294 OS << "OPC_CheckChainCompatible, "
295 << cast<CheckChainCompatibleMatcher>(N)->getPreviousOp() << ",\n";
298 case Matcher::EmitInteger: {
299 int64_t Val = cast<EmitIntegerMatcher>(N)->getValue();
300 OS << "OPC_EmitInteger, "
301 << getEnumName(cast<EmitIntegerMatcher>(N)->getVT()) << ", ";
302 return 2+EmitVBRValue(Val, OS);
304 case Matcher::EmitStringInteger: {
305 const std::string &Val = cast<EmitStringIntegerMatcher>(N)->getValue();
306 // These should always fit into one byte.
307 OS << "OPC_EmitInteger, "
308 << getEnumName(cast<EmitStringIntegerMatcher>(N)->getVT()) << ", "
313 case Matcher::EmitRegister:
314 OS << "OPC_EmitRegister, "
315 << getEnumName(cast<EmitRegisterMatcher>(N)->getVT()) << ", ";
316 if (Record *R = cast<EmitRegisterMatcher>(N)->getReg())
317 OS << getQualifiedName(R) << ",\n";
319 OS << "0 /*zero_reg*/,\n";
322 case Matcher::EmitConvertToTarget:
323 OS << "OPC_EmitConvertToTarget, "
324 << cast<EmitConvertToTargetMatcher>(N)->getSlot() << ",\n";
327 case Matcher::EmitMergeInputChains: {
328 const EmitMergeInputChainsMatcher *MN =
329 cast<EmitMergeInputChainsMatcher>(N);
330 OS << "OPC_EmitMergeInputChains, " << MN->getNumNodes() << ", ";
331 for (unsigned i = 0, e = MN->getNumNodes(); i != e; ++i)
332 OS << MN->getNode(i) << ", ";
334 return 2+MN->getNumNodes();
336 case Matcher::EmitCopyToReg:
337 OS << "OPC_EmitCopyToReg, "
338 << cast<EmitCopyToRegMatcher>(N)->getSrcSlot() << ", "
339 << getQualifiedName(cast<EmitCopyToRegMatcher>(N)->getDestPhysReg())
342 case Matcher::EmitNodeXForm: {
343 const EmitNodeXFormMatcher *XF = cast<EmitNodeXFormMatcher>(N);
344 OS << "OPC_EmitNodeXForm, " << getNodeXFormID(XF->getNodeXForm()) << ", "
345 << XF->getSlot() << ',';
346 OS.PadToColumn(CommentIndent) << "// "<<XF->getNodeXForm()->getName()<<'\n';
350 case Matcher::EmitNode:
351 case Matcher::MorphNodeTo: {
352 const EmitNodeMatcherCommon *EN = cast<EmitNodeMatcherCommon>(N);
353 OS << (isa<EmitNodeMatcher>(EN) ? "OPC_EmitNode" : "OPC_MorphNodeTo");
354 OS << ", TARGET_OPCODE(" << EN->getOpcodeName() << "), 0";
356 if (EN->hasChain()) OS << "|OPFL_Chain";
357 if (EN->hasInFlag()) OS << "|OPFL_FlagInput";
358 if (EN->hasOutFlag()) OS << "|OPFL_FlagOutput";
359 if (EN->hasMemRefs()) OS << "|OPFL_MemRefs";
360 if (EN->getNumFixedArityOperands() != -1)
361 OS << "|OPFL_Variadic" << EN->getNumFixedArityOperands();
364 OS.PadToColumn(Indent*2+4) << EN->getNumVTs() << "/*#VTs*/, ";
365 for (unsigned i = 0, e = EN->getNumVTs(); i != e; ++i)
366 OS << getEnumName(EN->getVT(i)) << ", ";
368 OS << EN->getNumOperands() << "/*#Ops*/, ";
369 unsigned NumOperandBytes = 0;
370 for (unsigned i = 0, e = EN->getNumOperands(); i != e; ++i) {
371 // We emit the operand numbers in VBR encoded format, in case the number
372 // is too large to represent with a byte.
373 NumOperandBytes += EmitVBRValue(EN->getOperand(i), OS);
376 // Print the result #'s for EmitNode.
377 if (const EmitNodeMatcher *E = dyn_cast<EmitNodeMatcher>(EN)) {
378 if (unsigned NumResults = EN->getNumVTs()) {
379 OS.PadToColumn(CommentIndent) << "// Results = ";
380 unsigned First = E->getFirstResultSlot();
381 for (unsigned i = 0; i != NumResults; ++i)
382 OS << "#" << First+i << " ";
387 if (const MorphNodeToMatcher *SNT = dyn_cast<MorphNodeToMatcher>(N)) {
388 OS.PadToColumn(Indent*2) << "// Src: "
389 << *SNT->getPattern().getSrcPattern() << '\n';
390 OS.PadToColumn(Indent*2) << "// Dst: "
391 << *SNT->getPattern().getDstPattern() << '\n';
395 return 6+EN->getNumVTs()+NumOperandBytes;
397 case Matcher::MarkFlagResults: {
398 const MarkFlagResultsMatcher *CFR = cast<MarkFlagResultsMatcher>(N);
399 OS << "OPC_MarkFlagResults, " << CFR->getNumNodes() << ", ";
400 unsigned NumOperandBytes = 0;
401 for (unsigned i = 0, e = CFR->getNumNodes(); i != e; ++i)
402 NumOperandBytes += EmitVBRValue(CFR->getNode(i), OS);
404 return 2+NumOperandBytes;
406 case Matcher::CompleteMatch: {
407 const CompleteMatchMatcher *CM = cast<CompleteMatchMatcher>(N);
408 OS << "OPC_CompleteMatch, " << CM->getNumResults() << ", ";
409 unsigned NumResultBytes = 0;
410 for (unsigned i = 0, e = CM->getNumResults(); i != e; ++i)
411 NumResultBytes += EmitVBRValue(CM->getResult(i), OS);
413 OS.PadToColumn(Indent*2) << "// Src: "
414 << *CM->getPattern().getSrcPattern() << '\n';
415 OS.PadToColumn(Indent*2) << "// Dst: "
416 << *CM->getPattern().getDstPattern() << '\n';
417 return 2 + NumResultBytes;
420 assert(0 && "Unreachable");
424 /// EmitMatcherList - Emit the bytes for the specified matcher subtree.
425 unsigned MatcherTableEmitter::
426 EmitMatcherList(const Matcher *N, unsigned Indent, unsigned CurrentIdx,
427 formatted_raw_ostream &OS) {
430 if (unsigned(N->getKind()) >= Histogram.size())
431 Histogram.resize(N->getKind()+1);
432 Histogram[N->getKind()]++;
434 OS << "/*" << CurrentIdx << "*/";
435 unsigned MatcherSize = EmitMatcher(N, Indent, CurrentIdx, OS);
437 CurrentIdx += MatcherSize;
439 // If there are other nodes in this list, iterate to them, otherwise we're
446 void MatcherTableEmitter::EmitPredicateFunctions(const CodeGenDAGPatterns &CGP,
447 formatted_raw_ostream &OS) {
448 // FIXME: Don't build off the DAGISelEmitter's predicates, emit them directly
449 // here into the case stmts.
451 // Emit pattern predicates.
452 if (!PatternPredicates.empty()) {
453 OS << "bool CheckPatternPredicate(unsigned PredNo) const {\n";
454 OS << " switch (PredNo) {\n";
455 OS << " default: assert(0 && \"Invalid predicate in table?\");\n";
456 for (unsigned i = 0, e = PatternPredicates.size(); i != e; ++i)
457 OS << " case " << i << ": return " << PatternPredicates[i] << ";\n";
462 // Emit Node predicates.
463 // FIXME: Annoyingly, these are stored by name, which we never even emit. Yay?
464 StringMap<TreePattern*> PFsByName;
466 for (CodeGenDAGPatterns::pf_iterator I = CGP.pf_begin(), E = CGP.pf_end();
468 PFsByName[I->first->getName()] = I->second;
470 if (!NodePredicates.empty()) {
471 OS << "bool CheckNodePredicate(SDNode *Node, unsigned PredNo) const {\n";
472 OS << " switch (PredNo) {\n";
473 OS << " default: assert(0 && \"Invalid predicate in table?\");\n";
474 for (unsigned i = 0, e = NodePredicates.size(); i != e; ++i) {
475 // FIXME: Storing this by name is horrible.
476 TreePattern *P =PFsByName[NodePredicates[i].substr(strlen("Predicate_"))];
477 assert(P && "Unknown name?");
479 // Emit the predicate code corresponding to this pattern.
480 std::string Code = P->getRecord()->getValueAsCode("Predicate");
481 assert(!Code.empty() && "No code in this predicate");
482 OS << " case " << i << ": { // " << NodePredicates[i] << '\n';
483 std::string ClassName;
484 if (P->getOnlyTree()->isLeaf())
485 ClassName = "SDNode";
488 CGP.getSDNodeInfo(P->getOnlyTree()->getOperator()).getSDClassName();
489 if (ClassName == "SDNode")
490 OS << " SDNode *N = Node;\n";
492 OS << " " << ClassName << "*N = cast<" << ClassName << ">(Node);\n";
493 OS << Code << "\n }\n";
499 // Emit CompletePattern matchers.
500 // FIXME: This should be const.
501 if (!ComplexPatterns.empty()) {
502 OS << "bool CheckComplexPattern(SDNode *Root, SDValue N,\n";
503 OS << " unsigned PatternNo, SmallVectorImpl<SDValue> &Result) {\n";
504 OS << " switch (PatternNo) {\n";
505 OS << " default: assert(0 && \"Invalid pattern # in table?\");\n";
506 for (unsigned i = 0, e = ComplexPatterns.size(); i != e; ++i) {
507 const ComplexPattern &P = *ComplexPatterns[i];
508 unsigned NumOps = P.getNumOperands();
510 if (P.hasProperty(SDNPHasChain))
511 ++NumOps; // Get the chained node too.
513 OS << " case " << i << ":\n";
514 OS << " Result.resize(Result.size()+" << NumOps << ");\n";
515 OS << " return " << P.getSelectFunc();
517 // FIXME: Temporary hack until old isel dies.
518 if (P.hasProperty(SDNPHasChain))
522 for (unsigned i = 0; i != NumOps; ++i)
523 OS << ", Result[Result.size()-" << (NumOps-i) << ']';
531 // Emit SDNodeXForm handlers.
532 // FIXME: This should be const.
533 if (!NodeXForms.empty()) {
534 OS << "SDValue RunSDNodeXForm(SDValue V, unsigned XFormNo) {\n";
535 OS << " switch (XFormNo) {\n";
536 OS << " default: assert(0 && \"Invalid xform # in table?\");\n";
538 // FIXME: The node xform could take SDValue's instead of SDNode*'s.
539 for (unsigned i = 0, e = NodeXForms.size(); i != e; ++i) {
540 const CodeGenDAGPatterns::NodeXForm &Entry =
541 CGP.getSDNodeTransform(NodeXForms[i]);
543 Record *SDNode = Entry.first;
544 const std::string &Code = Entry.second;
546 OS << " case " << i << ": { // " << NodeXForms[i]->getName() << '\n';
548 std::string ClassName = CGP.getSDNodeInfo(SDNode).getSDClassName();
549 if (ClassName == "SDNode")
550 OS << " SDNode *N = V.getNode();\n";
552 OS << " " << ClassName << " *N = cast<" << ClassName
553 << ">(V.getNode());\n";
554 OS << Code << "\n }\n";
561 void MatcherTableEmitter::EmitHistogram(formatted_raw_ostream &OS) {
562 OS << " // Opcode Histogram:\n";
563 for (unsigned i = 0, e = Histogram.size(); i != e; ++i) {
565 switch ((Matcher::KindTy)i) {
566 case Matcher::Scope: OS << "OPC_Scope"; break;
567 case Matcher::RecordNode: OS << "OPC_RecordNode"; break;
568 case Matcher::RecordChild: OS << "OPC_RecordChild"; break;
569 case Matcher::RecordMemRef: OS << "OPC_RecordMemRef"; break;
570 case Matcher::CaptureFlagInput: OS << "OPC_CaptureFlagInput"; break;
571 case Matcher::MoveChild: OS << "OPC_MoveChild"; break;
572 case Matcher::MoveParent: OS << "OPC_MoveParent"; break;
573 case Matcher::CheckSame: OS << "OPC_CheckSame"; break;
574 case Matcher::CheckPatternPredicate:
575 OS << "OPC_CheckPatternPredicate"; break;
576 case Matcher::CheckPredicate: OS << "OPC_CheckPredicate"; break;
577 case Matcher::CheckOpcode: OS << "OPC_CheckOpcode"; break;
578 case Matcher::CheckMultiOpcode: OS << "OPC_CheckMultiOpcode"; break;
579 case Matcher::CheckType: OS << "OPC_CheckType"; break;
580 case Matcher::CheckChildType: OS << "OPC_CheckChildType"; break;
581 case Matcher::CheckInteger: OS << "OPC_CheckInteger"; break;
582 case Matcher::CheckCondCode: OS << "OPC_CheckCondCode"; break;
583 case Matcher::CheckValueType: OS << "OPC_CheckValueType"; break;
584 case Matcher::CheckComplexPat: OS << "OPC_CheckComplexPat"; break;
585 case Matcher::CheckAndImm: OS << "OPC_CheckAndImm"; break;
586 case Matcher::CheckOrImm: OS << "OPC_CheckOrImm"; break;
587 case Matcher::CheckFoldableChainNode:
588 OS << "OPC_CheckFoldableChainNode"; break;
589 case Matcher::CheckChainCompatible: OS << "OPC_CheckChainCompatible"; break;
590 case Matcher::EmitInteger: OS << "OPC_EmitInteger"; break;
591 case Matcher::EmitStringInteger: OS << "OPC_EmitStringInteger"; break;
592 case Matcher::EmitRegister: OS << "OPC_EmitRegister"; break;
593 case Matcher::EmitConvertToTarget: OS << "OPC_EmitConvertToTarget"; break;
594 case Matcher::EmitMergeInputChains: OS << "OPC_EmitMergeInputChains"; break;
595 case Matcher::EmitCopyToReg: OS << "OPC_EmitCopyToReg"; break;
596 case Matcher::EmitNode: OS << "OPC_EmitNode"; break;
597 case Matcher::MorphNodeTo: OS << "OPC_MorphNodeTo"; break;
598 case Matcher::EmitNodeXForm: OS << "OPC_EmitNodeXForm"; break;
599 case Matcher::MarkFlagResults: OS << "OPC_MarkFlagResults"; break;
600 case Matcher::CompleteMatch: OS << "OPC_CompleteMatch"; break;
603 OS.PadToColumn(40) << " = " << Histogram[i] << '\n';
609 void llvm::EmitMatcherTable(const Matcher *TheMatcher,
610 const CodeGenDAGPatterns &CGP, raw_ostream &O) {
611 formatted_raw_ostream OS(O);
613 OS << "// The main instruction selector code.\n";
614 OS << "SDNode *SelectCode(SDNode *N) {\n";
616 MatcherTableEmitter MatcherEmitter;
618 OS << " // Opcodes are emitted as 2 bytes, TARGET_OPCODE handles this.\n";
619 OS << " #define TARGET_OPCODE(X) X & 255, unsigned(X) >> 8\n";
620 OS << " static const unsigned char MatcherTable[] = {\n";
621 unsigned TotalSize = MatcherEmitter.EmitMatcherList(TheMatcher, 5, 0, OS);
622 OS << " 0\n }; // Total Array size is " << (TotalSize+1) << " bytes\n\n";
624 MatcherEmitter.EmitHistogram(OS);
626 OS << " #undef TARGET_OPCODE\n";
627 OS << " return SelectCodeCommon(N, MatcherTable,sizeof(MatcherTable));\n}\n";
630 // Next up, emit the function for node and pattern predicates:
631 MatcherEmitter.EmitPredicateFunctions(CGP, OS);