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) { in PrintDefList() argument
99 OS << "static const MCPhysReg ImplicitList" << Num << "[] = { "; in PrintDefList()
101 OS << getQualifiedName(U) << ", "; in PrintDefList()
102 OS << "0 };\n"; in PrintDefList()
199 void InstrInfoEmitter::EmitOperandInfo(raw_ostream &OS, in EmitOperandInfo() argument
205 OS << "\n"; in EmitOperandInfo()
213 OS << "static const MCOperandInfo OperandInfo" << N << "[] = { "; in EmitOperandInfo()
215 OS << "{ " << Info << " }, "; in EmitOperandInfo()
216 OS << "};\n"; in EmitOperandInfo()
262 void InstrInfoEmitter::emitOperandNameMappings(raw_ostream &OS, in emitOperandNameMappings() argument
274 OS << "#ifdef GET_INSTRINFO_OPERAND_ENUM\n"; in emitOperandNameMappings()
275 OS << "#undef GET_INSTRINFO_OPERAND_ENUM\n"; in emitOperandNameMappings()
276 OS << "namespace llvm {\n"; in emitOperandNameMappings()
277 OS << "namespace " << Namespace << " {\n"; in emitOperandNameMappings()
278 OS << "namespace " << OpNameNS << " {\n"; in emitOperandNameMappings()
279 OS << "enum {\n"; in emitOperandNameMappings()
281 OS << " " << Op.first << " = " << Op.second << ",\n"; in emitOperandNameMappings()
283 OS << " OPERAND_LAST"; in emitOperandNameMappings()
284 OS << "\n};\n"; in emitOperandNameMappings()
285 OS << "} // end namespace OpName\n"; in emitOperandNameMappings()
286 OS << "} // end namespace " << Namespace << "\n"; in emitOperandNameMappings()
287 OS << "} // end namespace llvm\n"; in emitOperandNameMappings()
288 OS << "#endif //GET_INSTRINFO_OPERAND_ENUM\n\n"; in emitOperandNameMappings()
290 OS << "#ifdef GET_INSTRINFO_NAMED_OPS\n"; in emitOperandNameMappings()
291 OS << "#undef GET_INSTRINFO_NAMED_OPS\n"; in emitOperandNameMappings()
292 OS << "namespace llvm {\n"; in emitOperandNameMappings()
293 OS << "namespace " << Namespace << " {\n"; in emitOperandNameMappings()
294 OS << "LLVM_READONLY\n"; in emitOperandNameMappings()
295 OS << "int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx) {\n"; in emitOperandNameMappings()
297 OS << " static const int16_t OperandMap [][" << Operands.size() in emitOperandNameMappings()
301 OS << "{"; in emitOperandNameMappings()
305 OS << (OpList.count(i) == 0 ? -1 : (int)OpList.find(i)->second) << ", "; in emitOperandNameMappings()
307 OS << "},\n"; in emitOperandNameMappings()
309 OS << "};\n"; in emitOperandNameMappings()
311 OS << " switch(Opcode) {\n"; in emitOperandNameMappings()
315 OS << " case " << Name << ":\n"; in emitOperandNameMappings()
317 OS << " return OperandMap[" << TableIndex++ << "][NamedIdx];\n"; in emitOperandNameMappings()
319 OS << " default: return -1;\n"; in emitOperandNameMappings()
320 OS << " }\n"; in emitOperandNameMappings()
323 OS << " return -1;\n"; in emitOperandNameMappings()
325 OS << "}\n"; in emitOperandNameMappings()
326 OS << "} // end namespace " << Namespace << "\n"; in emitOperandNameMappings()
327 OS << "} // end namespace llvm\n"; in emitOperandNameMappings()
328 OS << "#endif //GET_INSTRINFO_NAMED_OPS\n\n"; in emitOperandNameMappings()
335 raw_ostream &OS, const CodeGenTarget &Target, in emitOperandTypeMappings() argument
345 OS << "#ifdef GET_INSTRINFO_OPERAND_TYPES_ENUM\n"; in emitOperandTypeMappings()
346 OS << "#undef GET_INSTRINFO_OPERAND_TYPES_ENUM\n"; in emitOperandTypeMappings()
347 OS << "namespace llvm {\n"; in emitOperandTypeMappings()
348 OS << "namespace " << Namespace << " {\n"; in emitOperandTypeMappings()
349 OS << "namespace OpTypes {\n"; in emitOperandTypeMappings()
350 OS << "enum OperandType {\n"; in emitOperandTypeMappings()
357 OS << " " << Op->getName() << " = " << EnumVal << ",\n"; in emitOperandTypeMappings()
362 OS << " OPERAND_TYPE_LIST_END" << "\n};\n"; in emitOperandTypeMappings()
363 OS << "} // end namespace OpTypes\n"; in emitOperandTypeMappings()
364 OS << "} // end namespace " << Namespace << "\n"; in emitOperandTypeMappings()
365 OS << "} // end namespace llvm\n"; in emitOperandTypeMappings()
366 OS << "#endif // GET_INSTRINFO_OPERAND_TYPES_ENUM\n\n"; in emitOperandTypeMappings()
368 OS << "#ifdef GET_INSTRINFO_OPERAND_TYPE\n"; in emitOperandTypeMappings()
369 OS << "#undef GET_INSTRINFO_OPERAND_TYPE\n"; in emitOperandTypeMappings()
370 OS << "namespace llvm {\n"; in emitOperandTypeMappings()
371 OS << "namespace " << Namespace << " {\n"; in emitOperandTypeMappings()
372 OS << "LLVM_READONLY\n"; in emitOperandTypeMappings()
373 OS << "static int getOperandType(uint16_t Opcode, uint16_t OpIdx) {\n"; in emitOperandTypeMappings()
397 OS << " const int Offsets[] = {\n"; in emitOperandTypeMappings()
399 OS << " " << OperandOffsets[I] << ",\n"; in emitOperandTypeMappings()
400 OS << " };\n"; in emitOperandTypeMappings()
405 OS << " const int OpcodeOperandTypes[] = {\n "; in emitOperandTypeMappings()
409 OS << "\n "; in emitOperandTypeMappings()
412 OS << "/**/\n "; in emitOperandTypeMappings()
419 OS << "OpTypes::" << OpR->getName(); in emitOperandTypeMappings()
421 OS << -1; in emitOperandTypeMappings()
422 OS << ", "; in emitOperandTypeMappings()
424 OS << "\n };\n"; in emitOperandTypeMappings()
426 OS << " return OpcodeOperandTypes[Offsets[Opcode] + OpIdx];\n"; in emitOperandTypeMappings()
428 OS << " llvm_unreachable(\"No instructions defined\");\n"; in emitOperandTypeMappings()
430 OS << "}\n"; in emitOperandTypeMappings()
431 OS << "} // end namespace " << Namespace << "\n"; in emitOperandTypeMappings()
432 OS << "} // end namespace llvm\n"; in emitOperandTypeMappings()
433 OS << "#endif // GET_INSTRINFO_OPERAND_TYPE\n\n"; in emitOperandTypeMappings()
436 void InstrInfoEmitter::emitMCIIHelperMethods(raw_ostream &OS, in emitMCIIHelperMethods() argument
442 OS << "#ifdef GET_INSTRINFO_MC_HELPER_DECLS\n"; in emitMCIIHelperMethods()
443 OS << "#undef GET_INSTRINFO_MC_HELPER_DECLS\n\n"; in emitMCIIHelperMethods()
445 OS << "namespace llvm {\n"; in emitMCIIHelperMethods()
446 OS << "class MCInst;\n\n"; in emitMCIIHelperMethods()
448 OS << "namespace " << TargetName << "_MC {\n\n"; in emitMCIIHelperMethods()
451 OS << "bool " << Rec->getValueAsString("FunctionName") in emitMCIIHelperMethods()
455 OS << "\n} // end namespace " << TargetName << "_MC\n"; in emitMCIIHelperMethods()
456 OS << "} // end namespace llvm\n\n"; in emitMCIIHelperMethods()
458 OS << "#endif // GET_INSTRINFO_MC_HELPER_DECLS\n\n"; in emitMCIIHelperMethods()
460 OS << "#ifdef GET_INSTRINFO_MC_HELPERS\n"; in emitMCIIHelperMethods()
461 OS << "#undef GET_INSTRINFO_MC_HELPERS\n\n"; in emitMCIIHelperMethods()
463 OS << "namespace llvm {\n"; in emitMCIIHelperMethods()
464 OS << "namespace " << TargetName << "_MC {\n\n"; in emitMCIIHelperMethods()
470 OS << "bool " << Rec->getValueAsString("FunctionName"); in emitMCIIHelperMethods()
471 OS << "(const MCInst &MI) {\n"; in emitMCIIHelperMethods()
473 OS.indent(PE.getIndentLevel() * 2); in emitMCIIHelperMethods()
474 PE.expandStatement(OS, Rec->getValueAsDef("Body")); in emitMCIIHelperMethods()
475 OS << "\n}\n\n"; in emitMCIIHelperMethods()
478 OS << "} // end namespace " << TargetName << "_MC\n"; in emitMCIIHelperMethods()
479 OS << "} // end namespace llvm\n\n"; in emitMCIIHelperMethods()
481 OS << "#endif // GET_GENISTRINFO_MC_HELPERS\n"; in emitMCIIHelperMethods()
484 void InstrInfoEmitter::emitTIIHelperMethods(raw_ostream &OS, in emitTIIHelperMethods() argument
495 OS << (ExpandDefinition ? "" : "static ") << "bool "; in emitTIIHelperMethods()
497 OS << TargetName << "InstrInfo::"; in emitTIIHelperMethods()
498 OS << Rec->getValueAsString("FunctionName"); in emitTIIHelperMethods()
499 OS << "(const MachineInstr &MI)"; in emitTIIHelperMethods()
501 OS << ";\n"; in emitTIIHelperMethods()
505 OS << " {\n"; in emitTIIHelperMethods()
506 OS.indent(PE.getIndentLevel() * 2); in emitTIIHelperMethods()
507 PE.expandStatement(OS, Rec->getValueAsDef("Body")); in emitTIIHelperMethods()
508 OS << "\n}\n\n"; in emitTIIHelperMethods()
517 void InstrInfoEmitter::run(raw_ostream &OS) { in run() argument
518 emitSourceFileHeader("Target Instruction Enum Values and Descriptors", OS); in run()
519 emitEnums(OS); in run()
521 OS << "#ifdef GET_INSTRINFO_MC_DESC\n"; in run()
522 OS << "#undef GET_INSTRINFO_MC_DESC\n"; in run()
524 OS << "namespace llvm {\n\n"; in run()
541 if (!IL) PrintDefList(Uses, IL = ++ListNumber, OS); in run()
546 if (!IL) PrintDefList(Defs, IL = ++ListNumber, OS); in run()
554 EmitOperandInfo(OS, OperandInfoIDs); in run()
559 OS << "\nextern const MCInstrDesc " << TargetName << "Insts[] = {\n"; in run()
569 emitRecord(*Inst, Num++, InstrInfo, EmittedLists, OperandInfoIDs, OS); in run()
571 OS << "};\n\n"; in run()
576 InstrNames.emitStringLiteralDef(OS, Twine("extern const char ") + TargetName + in run()
579 OS << "extern const unsigned " << TargetName <<"InstrNameIndices[] = {"; in run()
584 OS << "\n "; in run()
585 OS << InstrNames.get(std::string(Inst->TheDef->getName())) << "U, "; in run()
588 OS << "\n};\n\n"; in run()
596 OS << "extern const uint8_t " << TargetName in run()
601 OS << "\n "; in run()
604 OS << Target.getInstNamespace() << "::" << Inst->DeprecatedReason in run()
607 OS << "uint8_t(-1), "; in run()
610 OS << "\n};\n\n"; in run()
618 OS << "extern const MCInstrInfo::ComplexDeprecationPredicate " << TargetName in run()
623 OS << "\n "; in run()
626 OS << "&get" << Inst->DeprecatedReason << "DeprecationInfo, "; in run()
628 OS << "nullptr, "; in run()
631 OS << "\n};\n\n"; in run()
636 OS << "static inline void Init" << TargetName in run()
638 OS << " II->InitMCInstrInfo(" << TargetName << "Insts, " << TargetName in run()
641 OS << TargetName << "InstrDeprecationFeatures, "; in run()
643 OS << "nullptr, "; in run()
645 OS << TargetName << "InstrComplexDeprecationInfos, "; in run()
647 OS << "nullptr, "; in run()
648 OS << NumberedInstructions.size() << ");\n}\n\n"; in run()
650 OS << "} // end namespace llvm\n"; in run()
652 OS << "#endif // GET_INSTRINFO_MC_DESC\n\n"; in run()
655 OS << "#ifdef GET_INSTRINFO_HEADER\n"; in run()
656 OS << "#undef GET_INSTRINFO_HEADER\n"; in run()
659 OS << "namespace llvm {\n"; in run()
660 OS << "struct " << ClassName << " : public TargetInstrInfo {\n" in run()
666 OS << "\n};\n} // end namespace llvm\n"; in run()
668 OS << "#endif // GET_INSTRINFO_HEADER\n\n"; in run()
670 OS << "#ifdef GET_INSTRINFO_HELPER_DECLS\n"; in run()
671 OS << "#undef GET_INSTRINFO_HELPER_DECLS\n\n"; in run()
672 emitTIIHelperMethods(OS, TargetName, /* ExpandDefintion = */false); in run()
673 OS << "\n"; in run()
674 OS << "#endif // GET_INSTRINFO_HELPER_DECLS\n\n"; in run()
676 OS << "#ifdef GET_INSTRINFO_HELPERS\n"; in run()
677 OS << "#undef GET_INSTRINFO_HELPERS\n\n"; in run()
678 emitTIIHelperMethods(OS, TargetName, /* ExpandDefintion = */true); in run()
679 OS << "#endif // GET_INSTRINFO_HELPERS\n\n"; in run()
681 OS << "#ifdef GET_INSTRINFO_CTOR_DTOR\n"; in run()
682 OS << "#undef GET_INSTRINFO_CTOR_DTOR\n"; in run()
684 OS << "namespace llvm {\n"; in run()
685 OS << "extern const MCInstrDesc " << TargetName << "Insts[];\n"; in run()
686 OS << "extern const unsigned " << TargetName << "InstrNameIndices[];\n"; in run()
687 OS << "extern const char " << TargetName << "InstrNameData[];\n"; in run()
689 OS << "extern const uint8_t " << TargetName in run()
692 OS << "extern const MCInstrInfo::ComplexDeprecationPredicate " << TargetName in run()
694 OS << ClassName << "::" << ClassName in run()
702 OS << TargetName << "InstrDeprecationFeatures, "; in run()
704 OS << "nullptr, "; in run()
706 OS << TargetName << "InstrComplexDeprecationInfos, "; in run()
708 OS << "nullptr, "; in run()
709 OS << NumberedInstructions.size() << ");\n}\n"; in run()
710 OS << "} // end namespace llvm\n"; in run()
712 OS << "#endif // GET_INSTRINFO_CTOR_DTOR\n\n"; in run()
715 emitOperandNameMappings(OS, Target, NumberedInstructions); in run()
718 emitOperandTypeMappings(OS, Target, NumberedInstructions); in run()
721 emitMCIIHelperMethods(OS, TargetName); in run()
728 raw_ostream &OS) { in emitRecord() argument
735 OS << " { "; in emitRecord()
736 OS << Num << ",\t" << MinOperands << ",\t" in emitRecord()
744 if (Inst.isPreISelOpcode) OS << "|(1ULL<<MCID::PreISelOpcode)"; in emitRecord()
745 if (Inst.isPseudo) OS << "|(1ULL<<MCID::Pseudo)"; in emitRecord()
746 if (Inst.isReturn) OS << "|(1ULL<<MCID::Return)"; in emitRecord()
747 if (Inst.isEHScopeReturn) OS << "|(1ULL<<MCID::EHScopeReturn)"; in emitRecord()
748 if (Inst.isBranch) OS << "|(1ULL<<MCID::Branch)"; in emitRecord()
749 if (Inst.isIndirectBranch) OS << "|(1ULL<<MCID::IndirectBranch)"; in emitRecord()
750 if (Inst.isCompare) OS << "|(1ULL<<MCID::Compare)"; in emitRecord()
751 if (Inst.isMoveImm) OS << "|(1ULL<<MCID::MoveImm)"; in emitRecord()
752 if (Inst.isMoveReg) OS << "|(1ULL<<MCID::MoveReg)"; in emitRecord()
753 if (Inst.isBitcast) OS << "|(1ULL<<MCID::Bitcast)"; in emitRecord()
754 if (Inst.isAdd) OS << "|(1ULL<<MCID::Add)"; in emitRecord()
755 if (Inst.isTrap) OS << "|(1ULL<<MCID::Trap)"; in emitRecord()
756 if (Inst.isSelect) OS << "|(1ULL<<MCID::Select)"; in emitRecord()
757 if (Inst.isBarrier) OS << "|(1ULL<<MCID::Barrier)"; in emitRecord()
758 if (Inst.hasDelaySlot) OS << "|(1ULL<<MCID::DelaySlot)"; in emitRecord()
759 if (Inst.isCall) OS << "|(1ULL<<MCID::Call)"; in emitRecord()
760 if (Inst.canFoldAsLoad) OS << "|(1ULL<<MCID::FoldableAsLoad)"; in emitRecord()
761 if (Inst.mayLoad) OS << "|(1ULL<<MCID::MayLoad)"; in emitRecord()
762 if (Inst.mayStore) OS << "|(1ULL<<MCID::MayStore)"; in emitRecord()
763 if (Inst.mayRaiseFPException) OS << "|(1ULL<<MCID::MayRaiseFPException)"; in emitRecord()
764 if (Inst.isPredicable) OS << "|(1ULL<<MCID::Predicable)"; in emitRecord()
765 if (Inst.isConvertibleToThreeAddress) OS << "|(1ULL<<MCID::ConvertibleTo3Addr)"; in emitRecord()
766 if (Inst.isCommutable) OS << "|(1ULL<<MCID::Commutable)"; in emitRecord()
767 if (Inst.isTerminator) OS << "|(1ULL<<MCID::Terminator)"; in emitRecord()
768 if (Inst.isReMaterializable) OS << "|(1ULL<<MCID::Rematerializable)"; in emitRecord()
769 if (Inst.isNotDuplicable) OS << "|(1ULL<<MCID::NotDuplicable)"; in emitRecord()
770 if (Inst.Operands.hasOptionalDef) OS << "|(1ULL<<MCID::HasOptionalDef)"; in emitRecord()
771 if (Inst.usesCustomInserter) OS << "|(1ULL<<MCID::UsesCustomInserter)"; in emitRecord()
772 if (Inst.hasPostISelHook) OS << "|(1ULL<<MCID::HasPostISelHook)"; in emitRecord()
773 if (Inst.Operands.isVariadic)OS << "|(1ULL<<MCID::Variadic)"; in emitRecord()
774 if (Inst.hasSideEffects) OS << "|(1ULL<<MCID::UnmodeledSideEffects)"; in emitRecord()
775 if (Inst.isAsCheapAsAMove) OS << "|(1ULL<<MCID::CheapAsAMove)"; in emitRecord()
777 OS << "|(1ULL<<MCID::ExtraSrcRegAllocReq)"; in emitRecord()
779 OS << "|(1ULL<<MCID::ExtraDefRegAllocReq)"; in emitRecord()
780 if (Inst.isRegSequence) OS << "|(1ULL<<MCID::RegSequence)"; in emitRecord()
781 if (Inst.isExtractSubreg) OS << "|(1ULL<<MCID::ExtractSubreg)"; in emitRecord()
782 if (Inst.isInsertSubreg) OS << "|(1ULL<<MCID::InsertSubreg)"; in emitRecord()
783 if (Inst.isConvergent) OS << "|(1ULL<<MCID::Convergent)"; in emitRecord()
784 if (Inst.variadicOpsAreDefs) OS << "|(1ULL<<MCID::VariadicOpsAreDefs)"; in emitRecord()
785 if (Inst.isAuthenticated) OS << "|(1ULL<<MCID::Authenticated)"; in emitRecord()
799 OS << ", 0x"; in emitRecord()
800 OS.write_hex(Value); in emitRecord()
801 OS << "ULL, "; in emitRecord()
806 OS << "nullptr, "; in emitRecord()
808 OS << "ImplicitList" << EmittedLists[UseList] << ", "; in emitRecord()
812 OS << "nullptr, "; in emitRecord()
814 OS << "ImplicitList" << EmittedLists[DefList] << ", "; in emitRecord()
819 OS << "nullptr"; in emitRecord()
821 OS << "OperandInfo" << OpInfo.find(OperandInfo)->second; in emitRecord()
823 OS << " }, // Inst #" << Num << " = " << Inst.TheDef->getName() << "\n"; in emitRecord()
827 void InstrInfoEmitter::emitEnums(raw_ostream &OS) { in emitEnums() argument
828 OS << "#ifdef GET_INSTRINFO_ENUM\n"; in emitEnums()
829 OS << "#undef GET_INSTRINFO_ENUM\n"; in emitEnums()
831 OS << "namespace llvm {\n\n"; in emitEnums()
841 OS << "namespace " << Namespace << " {\n"; in emitEnums()
842 OS << " enum {\n"; in emitEnums()
845 OS << " " << Inst->TheDef->getName() << "\t= " << Num++ << ",\n"; in emitEnums()
846 OS << " INSTRUCTION_LIST_END = " << Num << "\n"; in emitEnums()
847 OS << " };\n\n"; in emitEnums()
848 OS << "} // end namespace " << Namespace << "\n"; in emitEnums()
849 OS << "} // end namespace llvm\n"; in emitEnums()
850 OS << "#endif // GET_INSTRINFO_ENUM\n\n"; in emitEnums()
852 OS << "#ifdef GET_INSTRINFO_SCHED_ENUM\n"; in emitEnums()
853 OS << "#undef GET_INSTRINFO_SCHED_ENUM\n"; in emitEnums()
854 OS << "namespace llvm {\n\n"; in emitEnums()
855 OS << "namespace " << Namespace << " {\n"; in emitEnums()
856 OS << "namespace Sched {\n"; in emitEnums()
857 OS << " enum {\n"; in emitEnums()
860 OS << " " << Class.Name << "\t= " << Num++ << ",\n"; in emitEnums()
861 OS << " SCHED_LIST_END = " << Num << "\n"; in emitEnums()
862 OS << " };\n"; in emitEnums()
863 OS << "} // end namespace Sched\n"; in emitEnums()
864 OS << "} // end namespace " << Namespace << "\n"; in emitEnums()
865 OS << "} // end namespace llvm\n"; in emitEnums()
867 OS << "#endif // GET_INSTRINFO_SCHED_ENUM\n\n"; in emitEnums()
872 void EmitInstrInfo(RecordKeeper &RK, raw_ostream &OS) { in EmitInstrInfo() argument
874 InstrInfoEmitter(RK).run(OS); in EmitInstrInfo()
876 EmitMapTable(RK, OS); in EmitInstrInfo()