Home | History | Annotate | Download | only in TableGen

Lines Matching refs:OS

222   void emitBinSearch(raw_ostream &OS, unsigned TableSize);
223 void emitTablesWithFunc(raw_ostream &OS);
224 unsigned emitBinSearchTable(raw_ostream &OS);
227 void emitMapFuncBody(raw_ostream &OS, unsigned TableSize);
361 unsigned MapTableEmitter::emitBinSearchTable(raw_ostream &OS) {
371 OS << "static const uint16_t "<<InstrMapDesc.getName();
374 OS << "Table[]["<< NumCol+1 << "] = {\n";
392 OS << " { " << TargetName << "::" << CurInstr->getName();
393 OS << OutStr <<" },\n";
399 OS << " { " << TargetName << "::" << "INSTRUCTION_LIST_END, ";
400 OS << TargetName << "::" << "INSTRUCTION_LIST_END }";
402 OS << "}; // End of " << InstrMapDesc.getName() << "Table\n\n";
411 void MapTableEmitter::emitBinSearch(raw_ostream &OS, unsigned TableSize) {
412 OS << " unsigned mid;\n";
413 OS << " unsigned start = 0;\n";
414 OS << " unsigned end = " << TableSize << ";\n";
415 OS << " while (start < end) {\n";
416 OS << " mid = start + (end - start)/2;\n";
417 OS << " if (Opcode == " << InstrMapDesc.getName() << "Table[mid][0]) {\n";
418 OS << " break;\n";
419 OS << " }\n";
420 OS << " if (Opcode < " << InstrMapDesc.getName() << "Table[mid][0])\n";
421 OS << " end = mid;\n";
422 OS << " else\n";
423 OS << " start = mid + 1;\n";
424 OS << " }\n";
425 OS << " if (start == end)\n";
426 OS << " return -1; // Instruction doesn't exist in this table.\n\n";
433 void MapTableEmitter::emitMapFuncBody(raw_ostream &OS,
442 emitBinSearch(OS, TableSize);
449 OS << " if (in" << ColName;
450 OS << " == ";
451 OS << ColName << "_" << ColumnI->getElement(j)->getAsUnquotedString();
452 if (j < ColumnI->getSize() - 1) OS << " && ";
453 else OS << ")\n";
455 OS << " return " << InstrMapDesc.getName();
456 OS << "Table[mid]["<<i+1<<"];\n";
458 OS << " return -1;";
461 OS << " return " << InstrMapDesc.getName() << "Table[mid][1];\n";
463 OS <<"}\n\n";
470 void MapTableEmitter::emitTablesWithFunc(raw_ostream &OS) {
479 OS << "// "<< InstrMapDesc.getName() << "\n";
480 OS << "int "<< InstrMapDesc.getName() << "(uint16_t Opcode";
484 OS << ", enum " << ColName << " in" << ColName << ") {\n";
486 } else { OS << ") {\n"; }
489 unsigned TableSize = emitBinSearchTable(OS);
492 emitMapFuncBody(OS, TableSize);
499 static void emitEnums(raw_ostream &OS, RecordKeeper &Records) {
548 OS << "enum " << (*II).first << " {\n";
550 OS << "\t" << (*II).first << "_" << FieldValues[i]->getAsUnquotedString();
552 OS << ",\n";
554 OS << "\n};\n\n";
565 void EmitMapTable(RecordKeeper &Records, raw_ostream &OS) {
574 OS << "#ifdef GET_INSTRMAP_INFO\n";
575 OS << "#undef GET_INSTRMAP_INFO\n";
576 OS << "namespace llvm {\n\n";
577 OS << "namespace " << TargetName << " {\n\n";
580 emitEnums(OS, Records);
598 IMap.emitTablesWithFunc(OS);
600 OS << "} // End " << TargetName << " namespace\n";
601 OS << "} // End llvm namespace\n";
602 OS << "#endif // GET_INSTRMAP_INFO\n\n";