Lines Matching refs:OS

49   void run(raw_ostream &OS);
52 void emitEnums(raw_ostream &OS);
68 void emitTIIHelperMethods(raw_ostream &OS, StringRef TargetName,
73 void emitMCIIHelperMethods(raw_ostream &OS, StringRef TargetName);
78 raw_ostream &OS);
80 raw_ostream &OS, const CodeGenTarget &Target,
87 void emitOperandNameMappings(raw_ostream &OS, const CodeGenTarget &Target,
91 void EmitOperandInfo(raw_ostream &OS, OperandInfoMapTy &OperandInfoIDs);
98 unsigned Num, raw_ostream &OS) {
99 OS << "static const MCPhysReg ImplicitList" << Num << "[] = { ";
101 OS << getQualifiedName(U) << ", ";
102 OS << "0 };\n";
199 void InstrInfoEmitter::EmitOperandInfo(raw_ostream &OS,
205 OS << "\n";
213 OS << "static const MCOperandInfo OperandInfo" << N << "[] = { ";
215 OS << "{ " << Info << " }, ";
216 OS << "};\n";
262 void InstrInfoEmitter::emitOperandNameMappings(raw_ostream &OS,
274 OS << "#ifdef GET_INSTRINFO_OPERAND_ENUM\n";
275 OS << "#undef GET_INSTRINFO_OPERAND_ENUM\n";
276 OS << "namespace llvm {\n";
277 OS << "namespace " << Namespace << " {\n";
278 OS << "namespace " << OpNameNS << " {\n";
279 OS << "enum {\n";
281 OS << " " << Op.first << " = " << Op.second << ",\n";
283 OS << "OPERAND_LAST";
284 OS << "\n};\n";
285 OS << "} // end namespace OpName\n";
286 OS << "} // end namespace " << Namespace << "\n";
287 OS << "} // end namespace llvm\n";
288 OS << "#endif //GET_INSTRINFO_OPERAND_ENUM\n\n";
290 OS << "#ifdef GET_INSTRINFO_NAMED_OPS\n";
291 OS << "#undef GET_INSTRINFO_NAMED_OPS\n";
292 OS << "namespace llvm {\n";
293 OS << "namespace " << Namespace << " {\n";
294 OS << "LLVM_READONLY\n";
295 OS << "int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx) {\n";
297 OS << " static const int16_t OperandMap [][" << Operands.size()
301 OS << "{";
305 OS << (OpList.count(i) == 0 ? -1 : (int)OpList.find(i)->second) << ", ";
307 OS << "},\n";
309 OS << "};\n";
311 OS << " switch(Opcode) {\n";
315 OS << " case " << Name << ":\n";
317 OS << " return OperandMap[" << TableIndex++ << "][NamedIdx];\n";
319 OS << " default: return -1;\n";
320 OS << " }\n";
323 OS << " return -1;\n";
325 OS << "}\n";
326 OS << "} // end namespace " << Namespace << "\n";
327 OS << "} // end namespace llvm\n";
328 OS << "#endif //GET_INSTRINFO_NAMED_OPS\n\n";
335 raw_ostream &OS, const CodeGenTarget &Target,
345 OS << "#ifdef GET_INSTRINFO_OPERAND_TYPES_ENUM\n";
346 OS << "#undef GET_INSTRINFO_OPERAND_TYPES_ENUM\n";
347 OS << "namespace llvm {\n";
348 OS << "namespace " << Namespace << " {\n";
349 OS << "namespace OpTypes {\n";
350 OS << "enum OperandType {\n";
357 OS << " " << Op->getName() << " = " << EnumVal << ",\n";
362 OS << " OPERAND_TYPE_LIST_END" << "\n};\n";
363 OS << "} // end namespace OpTypes\n";
364 OS << "} // end namespace " << Namespace << "\n";
365 OS << "} // end namespace llvm\n";
366 OS << "#endif // GET_INSTRINFO_OPERAND_TYPES_ENUM\n\n";
368 OS << "#ifdef GET_INSTRINFO_OPERAND_TYPE\n";
369 OS << "#undef GET_INSTRINFO_OPERAND_TYPE\n";
370 OS << "namespace llvm {\n";
371 OS << "namespace " << Namespace << " {\n";
372 OS << "LLVM_READONLY\n";
373 OS << "static int getOperandType(uint16_t Opcode, uint16_t OpIdx) {\n";
397 OS << " const int Offsets[] = {\n";
399 OS << " " << OperandOffsets[I] << ",\n";
400 OS << " };\n";
405 OS << " const int OpcodeOperandTypes[] = {\n ";
409 OS << "\n ";
412 OS << "/**/\n ";
419 OS << "OpTypes::" << OpR->getName();
421 OS << -1;
422 OS << ", ";
424 OS << "\n };\n";
426 OS << " return OpcodeOperandTypes[Offsets[Opcode] + OpIdx];\n";
428 OS << " llvm_unreachable(\"No instructions defined\");\n";
430 OS << "}\n";
431 OS << "} // end namespace " << Namespace << "\n";
432 OS << "} // end namespace llvm\n";
433 OS << "#endif // GET_INSTRINFO_OPERAND_TYPE\n\n";
436 void InstrInfoEmitter::emitMCIIHelperMethods(raw_ostream &OS,
442 OS << "#ifdef GET_INSTRINFO_MC_HELPER_DECLS\n";
443 OS << "#undef GET_INSTRINFO_MC_HELPER_DECLS\n\n";
445 OS << "namespace llvm {\n";
446 OS << "class MCInst;\n\n";
448 OS << "namespace " << TargetName << "_MC {\n\n";
451 OS << "bool " << Rec->getValueAsString("FunctionName")
455 OS << "\n} // end namespace " << TargetName << "_MC\n";
456 OS << "} // end namespace llvm\n\n";
458 OS << "#endif // GET_INSTRINFO_MC_HELPER_DECLS\n\n";
460 OS << "#ifdef GET_INSTRINFO_MC_HELPERS\n";
461 OS << "#undef GET_INSTRINFO_MC_HELPERS\n\n";
463 OS << "namespace llvm {\n";
464 OS << "namespace " << TargetName << "_MC {\n\n";
470 OS << "bool " << Rec->getValueAsString("FunctionName");
471 OS << "(const MCInst &MI) {\n";
473 OS.indent(PE.getIndentLevel() * 2);
474 PE.expandStatement(OS, Rec->getValueAsDef("Body"));
475 OS << "\n}\n\n";
478 OS << "} // end namespace " << TargetName << "_MC\n";
479 OS << "} // end namespace llvm\n\n";
481 OS << "#endif // GET_GENISTRINFO_MC_HELPERS\n";
484 void InstrInfoEmitter::emitTIIHelperMethods(raw_ostream &OS,
495 OS << (ExpandDefinition ? "" : "static ") << "bool ";
497 OS << TargetName << "InstrInfo::";
498 OS << Rec->getValueAsString("FunctionName");
499 OS << "(const MachineInstr &MI)";
501 OS << ";\n";
505 OS << " {\n";
506 OS.indent(PE.getIndentLevel() * 2);
507 PE.expandStatement(OS, Rec->getValueAsDef("Body"));
508 OS << "\n}\n\n";
517 void InstrInfoEmitter::run(raw_ostream &OS) {
518 emitSourceFileHeader("Target Instruction Enum Values and Descriptors", OS);
519 emitEnums(OS);
521 OS << "#ifdef GET_INSTRINFO_MC_DESC\n";
522 OS << "#undef GET_INSTRINFO_MC_DESC\n";
524 OS << "namespace llvm {\n\n";
540 if (!IL) PrintDefList(Uses, IL = ++ListNumber, OS);
545 if (!IL) PrintDefList(Defs, IL = ++ListNumber, OS);
552 EmitOperandInfo(OS, OperandInfoIDs);
556 OS << "\nextern const MCInstrDesc " << TargetName << "Insts[] = {\n";
566 emitRecord(*Inst, Num++, InstrInfo, EmittedLists, OperandInfoIDs, OS);
568 OS << "};\n\n";
572 OS << "extern const char " << TargetName << "InstrNameData[] = {\n";
573 InstrNames.emit(OS, printChar);
574 OS << "};\n\n";
576 OS << "extern const unsigned " << TargetName <<"InstrNameIndices[] = {";
581 OS << "\n ";
582 OS << InstrNames.get(Inst->TheDef->getName()) << "U, ";
586 OS << "\n};\n\n";
589 OS << "static inline void Init" << TargetName
591 OS << " II->InitMCInstrInfo(" << TargetName << "Insts, "
595 OS << "} // end namespace llvm\n";
597 OS << "#endif // GET_INSTRINFO_MC_DESC\n\n";
600 OS << "#ifdef GET_INSTRINFO_HEADER\n";
601 OS << "#undef GET_INSTRINFO_HEADER\n";
604 OS << "namespace llvm {\n";
605 OS << "struct " << ClassName << " : public TargetInstrInfo {\n"
611 OS << "\n};\n} // end namespace llvm\n";
613 OS << "#endif // GET_INSTRINFO_HEADER\n\n";
615 OS << "#ifdef GET_INSTRINFO_HELPER_DECLS\n";
616 OS << "#undef GET_INSTRINFO_HELPER_DECLS\n\n";
617 emitTIIHelperMethods(OS, TargetName, /* ExpandDefintion = */false);
618 OS << "\n";
619 OS << "#endif // GET_INSTRINFO_HELPER_DECLS\n\n";
621 OS << "#ifdef GET_INSTRINFO_HELPERS\n";
622 OS << "#undef GET_INSTRINFO_HELPERS\n\n";
623 emitTIIHelperMethods(OS, TargetName, /* ExpandDefintion = */true);
624 OS << "#endif // GET_INSTRINFO_HELPERS\n\n";
626 OS << "#ifdef GET_INSTRINFO_CTOR_DTOR\n";
627 OS << "#undef GET_INSTRINFO_CTOR_DTOR\n";
629 OS << "namespace llvm {\n";
630 OS << "extern const MCInstrDesc " << TargetName << "Insts[];\n";
631 OS << "extern const unsigned " << TargetName << "InstrNameIndices[];\n";
632 OS << "extern const char " << TargetName << "InstrNameData[];\n";
633 OS << ClassName << "::" << ClassName
639 OS << "} // end namespace llvm\n";
641 OS << "#endif // GET_INSTRINFO_CTOR_DTOR\n\n";
643 emitOperandNameMappings(OS, Target, NumberedInstructions);
645 emitOperandTypeMappings(OS, Target, NumberedInstructions);
647 emitMCIIHelperMethods(OS, TargetName);
654 raw_ostream &OS) {
661 OS << " { ";
662 OS << Num << ",\t" << MinOperands << ",\t"
670 if (Inst.isPreISelOpcode) OS << "|(1ULL<<MCID::PreISelOpcode)";
671 if (Inst.isPseudo) OS << "|(1ULL<<MCID::Pseudo)";
672 if (Inst.isReturn) OS << "|(1ULL<<MCID::Return)";
673 if (Inst.isEHScopeReturn) OS << "|(1ULL<<MCID::EHScopeReturn)";
674 if (Inst.isBranch) OS << "|(1ULL<<MCID::Branch)";
675 if (Inst.isIndirectBranch) OS << "|(1ULL<<MCID::IndirectBranch)";
676 if (Inst.isCompare) OS << "|(1ULL<<MCID::Compare)";
677 if (Inst.isMoveImm) OS << "|(1ULL<<MCID::MoveImm)";
678 if (Inst.isMoveReg) OS << "|(1ULL<<MCID::MoveReg)";
679 if (Inst.isBitcast) OS << "|(1ULL<<MCID::Bitcast)";
680 if (Inst.isAdd) OS << "|(1ULL<<MCID::Add)";
681 if (Inst.isTrap) OS << "|(1ULL<<MCID::Trap)";
682 if (Inst.isSelect) OS << "|(1ULL<<MCID::Select)";
683 if (Inst.isBarrier) OS << "|(1ULL<<MCID::Barrier)";
684 if (Inst.hasDelaySlot) OS << "|(1ULL<<MCID::DelaySlot)";
685 if (Inst.isCall) OS << "|(1ULL<<MCID::Call)";
686 if (Inst.canFoldAsLoad) OS << "|(1ULL<<MCID::FoldableAsLoad)";
687 if (Inst.mayLoad) OS << "|(1ULL<<MCID::MayLoad)";
688 if (Inst.mayStore) OS << "|(1ULL<<MCID::MayStore)";
689 if (Inst.mayRaiseFPException) OS << "|(1ULL<<MCID::MayRaiseFPException)";
690 if (Inst.isPredicable) OS << "|(1ULL<<MCID::Predicable)";
691 if (Inst.isConvertibleToThreeAddress) OS << "|(1ULL<<MCID::ConvertibleTo3Addr)";
692 if (Inst.isCommutable) OS << "|(1ULL<<MCID::Commutable)";
693 if (Inst.isTerminator) OS << "|(1ULL<<MCID::Terminator)";
694 if (Inst.isReMaterializable) OS << "|(1ULL<<MCID::Rematerializable)";
695 if (Inst.isNotDuplicable) OS << "|(1ULL<<MCID::NotDuplicable)";
696 if (Inst.Operands.hasOptionalDef) OS << "|(1ULL<<MCID::HasOptionalDef)";
697 if (Inst.usesCustomInserter) OS << "|(1ULL<<MCID::UsesCustomInserter)";
698 if (Inst.hasPostISelHook) OS << "|(1ULL<<MCID::HasPostISelHook)";
699 if (Inst.Operands.isVariadic)OS << "|(1ULL<<MCID::Variadic)";
700 if (Inst.hasSideEffects) OS << "|(1ULL<<MCID::UnmodeledSideEffects)";
701 if (Inst.isAsCheapAsAMove) OS << "|(1ULL<<MCID::CheapAsAMove)";
703 OS << "|(1ULL<<MCID::ExtraSrcRegAllocReq)";
705 OS << "|(1ULL<<MCID::ExtraDefRegAllocReq)";
706 if (Inst.isRegSequence) OS << "|(1ULL<<MCID::RegSequence)";
707 if (Inst.isExtractSubreg) OS << "|(1ULL<<MCID::ExtractSubreg)";
708 if (Inst.isInsertSubreg) OS << "|(1ULL<<MCID::InsertSubreg)";
709 if (Inst.isConvergent) OS << "|(1ULL<<MCID::Convergent)";
710 if (Inst.variadicOpsAreDefs) OS << "|(1ULL<<MCID::VariadicOpsAreDefs)";
711 if (Inst.isAuthenticated) OS << "|(1ULL<<MCID::Authenticated)";
725 OS << ", 0x";
726 OS.write_hex(Value);
727 OS << "ULL, ";
732 OS << "nullptr, ";
734 OS << "ImplicitList" << EmittedLists[UseList] << ", ";
738 OS << "nullptr, ";
740 OS << "ImplicitList" << EmittedLists[DefList] << ", ";
745 OS << "nullptr";
747 OS << "OperandInfo" << OpInfo.find(OperandInfo)->second;
751 OS << ", -1 "
755 OS << ", " << Target.getInstNamespace() << "::" << Inst.DeprecatedReason
759 OS << ", -1 ,nullptr";
761 OS << " }, // Inst #" << Num << " = " << Inst.TheDef->getName() << "\n";
765 void InstrInfoEmitter::emitEnums(raw_ostream &OS) {
766 OS << "#ifdef GET_INSTRINFO_ENUM\n";
767 OS << "#undef GET_INSTRINFO_ENUM\n";
769 OS << "namespace llvm {\n\n";
779 OS << "namespace " << Namespace << " {\n";
780 OS << " enum {\n";
783 OS << " " << Inst->TheDef->getName() << "\t= " << Num++ << ",\n";
784 OS << " INSTRUCTION_LIST_END = " << Num << "\n";
785 OS << " };\n\n";
786 OS << "} // end namespace " << Namespace << "\n";
787 OS << "} // end namespace llvm\n";
788 OS << "#endif // GET_INSTRINFO_ENUM\n\n";
790 OS << "#ifdef GET_INSTRINFO_SCHED_ENUM\n";
791 OS << "#undef GET_INSTRINFO_SCHED_ENUM\n";
792 OS << "namespace llvm {\n\n";
793 OS << "namespace " << Namespace << " {\n";
794 OS << "namespace Sched {\n";
795 OS << " enum {\n";
798 OS << " " << Class.Name << "\t= " << Num++ << ",\n";
799 OS << " SCHED_LIST_END = " << Num << "\n";
800 OS << " };\n";
801 OS << "} // end namespace Sched\n";
802 OS << "} // end namespace " << Namespace << "\n";
803 OS << "} // end namespace llvm\n";
805 OS << "#endif // GET_INSTRINFO_SCHED_ENUM\n\n";
810 void EmitInstrInfo(RecordKeeper &RK, raw_ostream &OS) {
811 InstrInfoEmitter(RK).run(OS);
812 EmitMapTable(RK, OS);