Lines Matching full:os
60 void run(raw_ostream &OS);
63 void emitEnums(raw_ostream &OS);
81 void emitTIIHelperMethods(raw_ostream &OS, StringRef TargetName,
86 void emitMCIIHelperMethods(raw_ostream &OS, StringRef TargetName);
89 void emitFeatureVerifier(raw_ostream &OS, const CodeGenTarget &Target);
93 const OperandInfoMapTy &OperandInfo, raw_ostream &OS);
95 raw_ostream &OS, const CodeGenTarget &Target,
103 raw_ostream &OS, const CodeGenTarget &Target,
107 raw_ostream &OS, StringRef Namespace,
110 raw_ostream &OS, StringRef Namespace,
116 void EmitOperandInfo(raw_ostream &OS, OperandInfoListTy &OperandInfoList);
229 void InstrInfoEmitter::EmitOperandInfo(raw_ostream &OS,
233 OS << " /* " << Offset << " */";
235 OS << " { " << Info << " },";
236 OS << '\n';
283 raw_ostream &OS, const CodeGenTarget &Target,
294 OS << "#ifdef GET_INSTRINFO_OPERAND_ENUM\n";
295 OS << "#undef GET_INSTRINFO_OPERAND_ENUM\n";
296 OS << "namespace llvm {\n";
297 OS << "namespace " << Namespace << " {\n";
298 OS << "namespace " << OpNameNS << " {\n";
299 OS << "enum {\n";
301 OS << " " << Op.first << " = " << Op.second << ",\n";
303 OS << " OPERAND_LAST";
304 OS << "\n};\n";
305 OS << "} // end namespace OpName\n";
306 OS << "} // end namespace " << Namespace << "\n";
307 OS << "} // end namespace llvm\n";
308 OS << "#endif //GET_INSTRINFO_OPERAND_ENUM\n\n";
310 OS << "#ifdef GET_INSTRINFO_NAMED_OPS\n";
311 OS << "#undef GET_INSTRINFO_NAMED_OPS\n";
312 OS << "namespace llvm {\n";
313 OS << "namespace " << Namespace << " {\n";
314 OS << "LLVM_READONLY\n";
315 OS << "int16_t getNamedOperandIdx(uint16_t Opcode, uint16_t NamedIdx) {\n";
317 OS << " static const int16_t OperandMap [][" << Operands.size()
321 OS << "{";
325 OS << (OpList.count(i) == 0 ? -1 : (int)OpList.find(i)->second) << ", ";
327 OS << "},\n";
329 OS << "};\n";
331 OS << " switch(Opcode) {\n";
335 OS << " case " << Name << ":\n";
337 OS << " return OperandMap[" << TableIndex++ << "][NamedIdx];\n";
339 OS << " default: return -1;\n";
340 OS << " }\n";
343 OS << " return -1;\n";
345 OS << "}\n";
346 OS << "} // end namespace " << Namespace << "\n";
347 OS << "} // end namespace llvm\n";
348 OS << "#endif //GET_INSTRINFO_NAMED_OPS\n\n";
355 raw_ostream &OS, const CodeGenTarget &Target,
365 OS << "#ifdef GET_INSTRINFO_OPERAND_TYPES_ENUM\n";
366 OS << "#undef GET_INSTRINFO_OPERAND_TYPES_ENUM\n";
367 OS << "namespace llvm {\n";
368 OS << "namespace " << Namespace << " {\n";
369 OS << "namespace OpTypes {\n";
370 OS << "enum OperandType {\n";
377 OS << " " << Op->getName() << " = " << EnumVal << ",\n";
382 OS << " OPERAND_TYPE_LIST_END"
384 OS << "} // end namespace OpTypes\n";
385 OS << "} // end namespace " << Namespace << "\n";
386 OS << "} // end namespace llvm\n";
387 OS << "#endif // GET_INSTRINFO_OPERAND_TYPES_ENUM\n\n";
389 OS << "#ifdef GET_INSTRINFO_OPERAND_TYPE\n";
390 OS << "#undef GET_INSTRINFO_OPERAND_TYPE\n";
391 OS << "namespace llvm {\n";
392 OS << "namespace " << Namespace << " {\n";
393 OS << "LLVM_READONLY\n";
394 OS << "static int getOperandType(uint16_t Opcode, uint16_t OpIdx) {\n";
424 OS << " static const " << getMinimalTypeForRange(OperandRecords.size());
425 OS << " Offsets[] = {\n";
427 OS << " /* " << getInstrName(I) << " */\n";
428 OS << " " << OperandOffsets[I] << ",\n";
430 OS << " };\n";
439 OS << "\n using namespace OpTypes;\n";
440 OS << " static";
441 OS << ((EnumVal <= INT8_MAX) ? " const int8_t" : " const int16_t");
442 OS << " OpcodeOperandTypes[] = {\n ";
446 OS << "\n /* " << getInstrName(CurOffset) << " */\n ";
448 OS << "/* " << getInstrName(CurOffset) << " */\n ";
455 OS << OpR->getName();
457 OS << -1;
458 OS << ", ";
460 OS << "\n };\n";
462 OS << " return OpcodeOperandTypes[Offsets[Opcode] + OpIdx];\n";
464 OS << " llvm_unreachable(\"No instructions defined\");\n";
466 OS << "}\n";
467 OS << "} // end namespace " << Namespace << "\n";
468 OS << "} // end namespace llvm\n";
469 OS << "#endif // GET_INSTRINFO_OPERAND_TYPE\n\n";
471 OS << "#ifdef GET_INSTRINFO_MEM_OPERAND_SIZE\n";
472 OS << "#undef GET_INSTRINFO_MEM_OPERAND_SIZE\n";
473 OS << "namespace llvm {\n";
474 OS << "namespace " << Namespace << " {\n";
475 OS << "LLVM_READONLY\n";
476 OS << "static int getMemOperandSize(int OpType) {\n";
477 OS << " switch (OpType) {\n";
485 OS << " default: return 0;\n";
488 OS << " case OpTypes::" << OperandName << ":\n";
489 OS << " return " << KV.first << ";\n\n";
491 OS << " }\n}\n";
492 OS << "} // end namespace " << Namespace << "\n";
493 OS << "} // end namespace llvm\n";
494 OS << "#endif // GET_INSTRINFO_MEM_OPERAND_SIZE\n\n";
498 raw_ostream &OS, StringRef Namespace,
526 OS << "#ifdef GET_INSTRINFO_LOGICAL_OPERAND_SIZE_MAP\n";
527 OS << "#undef GET_INSTRINFO_LOGICAL_OPERAND_SIZE_MAP\n";
528 OS << "namespace llvm {\n";
529 OS << "namespace " << Namespace << " {\n";
530 OS << "LLVM_READONLY static unsigned\n";
531 OS << "getLogicalOperandSize(uint16_t Opcode, uint16_t LogicalOpIdx) {\n";
538 OS << " static const unsigned SizeMap[][" << LogicalOpListSize
542 OS << " {";
545 OS << Row[i] << ", ";
548 OS << "0, ";
550 OS << "}, ";
551 OS << "\n";
553 OS << " };\n";
555 OS << " switch (Opcode) {\n";
556 OS << " default: return LogicalOpIdx;\n";
561 OS << " case " << Inst << ":\n";
563 OS << " return SizeMap[" << OpMapIdx << "][LogicalOpIdx];\n";
565 OS << " }\n";
567 OS << " return LogicalOpIdx;\n";
569 OS << "}\n";
571 OS << "LLVM_READONLY static inline unsigned\n";
572 OS << "getLogicalOperandIdx(uint16_t Opcode, uint16_t LogicalOpIdx) {\n";
573 OS << " auto S = 0U;\n";
574 OS << " for (auto i = 0U; i < LogicalOpIdx; ++i)\n";
575 OS << " S += getLogicalOperandSize(Opcode, i);\n";
576 OS << " return S;\n";
577 OS << "}\n";
579 OS << "} // end namespace " << Namespace << "\n";
580 OS << "} // end namespace llvm\n";
581 OS << "#endif // GET_INSTRINFO_LOGICAL_OPERAND_SIZE_MAP\n\n";
585 raw_ostream &OS, StringRef Namespace,
619 OS << "#ifdef GET_INSTRINFO_LOGICAL_OPERAND_TYPE_MAP\n";
620 OS << "#undef GET_INSTRINFO_LOGICAL_OPERAND_TYPE_MAP\n";
621 OS << "namespace llvm {\n";
622 OS << "namespace " << Namespace << " {\n";
623 OS << "LLVM_READONLY static int\n";
624 OS << "getLogicalOperandType(uint16_t Opcode, uint16_t LogicalOpIdx) {\n";
631 OS << " static const int TypeMap[][" << OpTypeListSize << "] = {\n";
634 OS << " {";
638 OS << ", ";
639 OS << Row[i];
643 OS << ", ";
644 OS << "-1";
646 OS << "}";
648 OS << ",";
649 OS << "\n";
651 OS << " };\n";
653 OS << " switch (Opcode) {\n";
654 OS << " default: return -1;\n";
659 OS << " case " << Inst << ":\n";
661 OS << " return TypeMap[" << OpMapIdx << "][LogicalOpIdx];\n";
663 OS << " }\n";
665 OS << " return -1;\n";
667 OS << "}\n";
668 OS << "} // end namespace " << Namespace << "\n";
669 OS << "} // end namespace llvm\n";
670 OS << "#endif // GET_INSTRINFO_LOGICAL_OPERAND_TYPE_MAP\n\n";
673 void InstrInfoEmitter::emitMCIIHelperMethods(raw_ostream &OS,
677 OS << "#ifdef GET_INSTRINFO_MC_HELPER_DECLS\n";
678 OS << "#undef GET_INSTRINFO_MC_HELPER_DECLS\n\n";
680 OS << "namespace llvm {\n";
681 OS << "class MCInst;\n";
682 OS << "class FeatureBitset;\n\n";
684 OS << "namespace " << TargetName << "_MC {\n\n";
687 OS << "bool " << Rec->getValueAsString("FunctionName")
691 OS << "void verifyInstructionPredicates(unsigned Opcode, const FeatureBitset "
694 OS << "\n} // end namespace " << TargetName << "_MC\n";
695 OS << "} // end namespace llvm\n\n";
697 OS << "#endif // GET_INSTRINFO_MC_HELPER_DECLS\n\n";
699 OS << "#ifdef GET_INSTRINFO_MC_HELPERS\n";
700 OS << "#undef GET_INSTRINFO_MC_HELPERS\n\n";
702 OS << "namespace llvm {\n";
703 OS << "namespace " << TargetName << "_MC {\n\n";
709 OS << "bool " << Rec->getValueAsString("FunctionName");
710 OS << "(const MCInst &MI) {\n";
712 OS.indent(PE.getIndentLevel() * 2);
713 PE.expandStatement(OS, Rec->getValueAsDef("Body"));
714 OS << "\n}\n\n";
717 OS << "} // end namespace " << TargetName << "_MC\n";
718 OS << "} // end namespace llvm\n\n";
720 OS << "#endif // GET_GENISTRINFO_MC_HELPERS\n\n";
731 void InstrInfoEmitter::emitFeatureVerifier(raw_ostream &OS,
737 OS << "#if (defined(ENABLE_INSTR_PREDICATE_VERIFIER) && !defined(NDEBUG)) "
742 OS << "#ifdef GET_COMPUTE_FEATURES\n"
749 OS);
751 OS << "inline ";
753 Target.getName(), "", "computeAvailableFeatures", SubtargetFeatures, OS);
780 OS << "inline FeatureBitset computeRequiredFeatures(unsigned Opcode) {\n"
786 OS << " " << getNameForFeatureBitset(FeatureBitset) << ",\n";
788 OS << " };\n\n"
794 OS << " {";
798 OS << I->second.getEnumBitName() << ", ";
800 OS << "},\n";
802 OS << " };\n"
807 OS << " CEFBS";
812 OS << '_' << I->second.TheDef->getName();
817 OS << "_None";
818 OS << ", // " << Inst->TheDef->getName() << " = " << InstIdx << "\n";
821 OS << " };\n\n"
826 OS << "} // end namespace " << Target.getName() << "_MC\n"
830 OS << "#ifdef GET_AVAILABLE_OPCODE_CHECKER\n"
834 OS << "bool isOpcodeAvailable("
845 OS << "} // end namespace " << Target.getName() << "_MC\n"
849 OS << "#ifdef ENABLE_INSTR_PREDICATE_VERIFIER\n"
853 OS << "namespace llvm {\n";
854 OS << "namespace " << Target.getName() << "_MC {\n\n";
857 OS << "#ifndef NDEBUG\n";
858 SubtargetFeatureInfo::emitNameTable(SubtargetFeatures, OS);
859 OS << "#endif // NDEBUG\n\n";
862 OS << "void verifyInstructionPredicates(\n"
865 OS << " FeatureBitset AvailableFeatures = "
867 OS << " FeatureBitset RequiredFeatures = "
869 OS << " FeatureBitset MissingFeatures =\n"
884 OS << "}\n";
885 OS << "} // end namespace " << Target.getName() << "_MC\n";
886 OS << "} // end namespace llvm\n";
887 OS << "#endif // ENABLE_INSTR_PREDICATE_VERIFIER\n\n";
890 void InstrInfoEmitter::emitTIIHelperMethods(raw_ostream &OS,
901 OS << (ExpandDefinition ? "" : "static ") << "bool ";
903 OS << TargetName << "InstrInfo::";
904 OS << Rec->getValueAsString("FunctionName");
905 OS << "(const MachineInstr &MI)";
907 OS << ";\n";
911 OS << " {\n";
912 OS.indent(PE.getIndentLevel() * 2);
913 PE.expandStatement(OS, Rec->getValueAsDef("Body"));
914 OS << "\n}\n\n";
923 void InstrInfoEmitter::run(raw_ostream &OS) {
924 emitSourceFileHeader("Target Instruction Enum Values and Descriptors", OS);
925 emitEnums(OS);
954 OS << "#if defined(GET_INSTRINFO_MC_DESC) || "
956 OS << "namespace llvm {\n\n";
958 OS << "struct " << TargetName << "InstrTable {\n";
959 OS << " MCInstrDesc Insts[" << NumberedInstructions.size() << "];\n";
960 OS << " static_assert(alignof(MCInstrDesc) >= alignof(MCOperandInfo), "
962 OS << " MCOperandInfo OperandInfo[" << OperandInfoSize << "];\n";
963 OS << " static_assert(alignof(MCOperandInfo) >= alignof(MCPhysReg), "
965 OS << " MCPhysReg ImplicitOps[" << std::max(ImplicitListSize, 1U) << "];\n";
966 OS << "};\n\n";
968 OS << "} // end namespace llvm\n";
969 OS << "#endif // defined(GET_INSTRINFO_MC_DESC) || "
972 OS << "#ifdef GET_INSTRINFO_MC_DESC\n";
973 OS << "#undef GET_INSTRINFO_MC_DESC\n";
974 OS << "namespace llvm {\n\n";
978 OS << "static_assert(sizeof(MCOperandInfo) % sizeof(MCPhysReg) == 0);\n";
979 OS << "static constexpr unsigned " << TargetName << "ImpOpBase = sizeof "
982 OS << "extern const " << TargetName << "InstrTable " << TargetName
990 emitRecord(*Inst, --Num, InstrInfo, EmittedLists, OperandInfoMap, OS);
993 OS << " }, {\n";
997 EmitOperandInfo(OS, OperandInfoList);
999 OS << " }, {\n";
1004 OS << " /* " << EmittedLists[List] << " */";
1006 OS << ' ' << getQualifiedName(Reg) << ',';
1007 OS << '\n';
1010 OS << " }\n};\n\n";
1015 InstrNames.emitStringLiteralDef(OS, Twine("extern const char ") + TargetName +
1018 OS << "extern const unsigned " << TargetName << "InstrNameIndices[] = {";
1023 OS << "\n ";
1024 OS << InstrNames.get(std::string(Inst->TheDef->getName())) << "U, ";
1027 OS << "\n};\n\n";
1035 OS << "extern const uint8_t " << TargetName
1040 OS << "\n ";
1043 OS << Target.getInstNamespace() << "::" << Inst->DeprecatedReason
1046 OS << "uint8_t(-1), ";
1049 OS << "\n};\n\n";
1057 OS << "extern const MCInstrInfo::ComplexDeprecationPredicate " << TargetName
1062 OS << "\n ";
1065 OS << "&get" << Inst->DeprecatedReason << "DeprecationInfo, ";
1067 OS << "nullptr, ";
1070 OS << "\n};\n\n";
1075 OS << "static inline void Init" << TargetName
1077 OS << " II->InitMCInstrInfo(" << TargetName << "Descs.Insts, " << TargetName
1080 OS << TargetName << "InstrDeprecationFeatures, ";
1082 OS << "nullptr, ";
1084 OS << TargetName << "InstrComplexDeprecationInfos, ";
1086 OS << "nullptr, ";
1087 OS << NumberedInstructions.size() << ");\n}\n\n";
1089 OS << "} // end namespace llvm\n";
1091 OS << "#endif // GET_INSTRINFO_MC_DESC\n\n";
1094 OS << "#ifdef GET_INSTRINFO_HEADER\n";
1095 OS << "#undef GET_INSTRINFO_HEADER\n";
1098 OS << "namespace llvm {\n";
1099 OS << "struct " << ClassName << " : public TargetInstrInfo {\n"
1105 OS << "\n};\n} // end namespace llvm\n";
1107 OS << "#endif // GET_INSTRINFO_HEADER\n\n";
1109 OS << "#ifdef GET_INSTRINFO_HELPER_DECLS\n";
1110 OS << "#undef GET_INSTRINFO_HELPER_DECLS\n\n";
1111 emitTIIHelperMethods(OS, TargetName, /* ExpandDefinition = */ false);
1112 OS << "\n";
1113 OS << "#endif // GET_INSTRINFO_HELPER_DECLS\n\n";
1115 OS << "#ifdef GET_INSTRINFO_HELPERS\n";
1116 OS << "#undef GET_INSTRINFO_HELPERS\n\n";
1117 emitTIIHelperMethods(OS, TargetName, /* ExpandDefinition = */ true);
1118 OS << "#endif // GET_INSTRINFO_HELPERS\n\n";
1120 OS << "#ifdef GET_INSTRINFO_CTOR_DTOR\n";
1121 OS << "#undef GET_INSTRINFO_CTOR_DTOR\n";
1123 OS << "namespace llvm {\n";
1124 OS << "extern const " << TargetName << "InstrTable " << TargetName
1126 OS << "extern const unsigned " << TargetName << "InstrNameIndices[];\n";
1127 OS << "extern const char " << TargetName << "InstrNameData[];\n";
1129 OS << "extern const uint8_t " << TargetName
1132 OS << "extern const MCInstrInfo::ComplexDeprecationPredicate " << TargetName
1134 OS << ClassName << "::" << ClassName
1142 OS << TargetName << "InstrDeprecationFeatures, ";
1144 OS << "nullptr, ";
1146 OS << TargetName << "InstrComplexDeprecationInfos, ";
1148 OS << "nullptr, ";
1149 OS << NumberedInstructions.size() << ");\n}\n";
1150 OS << "} // end namespace llvm\n";
1152 OS << "#endif // GET_INSTRINFO_CTOR_DTOR\n\n";
1155 emitOperandNameMappings(OS, Target, NumberedInstructions);
1158 emitOperandTypeMappings(OS, Target, NumberedInstructions);
1161 emitLogicalOperandSizeMappings(OS, TargetName, NumberedInstructions);
1164 emitLogicalOperandTypeMappings(OS, TargetName, NumberedInstructions);
1167 emitMCIIHelperMethods(OS, TargetName);
1170 emitFeatureVerifier(OS, Target);
1176 const OperandInfoMapTy &OperandInfoMap, raw_ostream &OS) {
1189 OS << " { ";
1190 OS << Num << ",\t" << MinOperands << ",\t" << DefOperands << ",\t"
1197 OS << Inst.ImplicitUses.size() << ",\t" << Inst.ImplicitDefs.size() << ",\t";
1200 OS << Target.getName() << "ImpOpBase + " << EmittedLists[ImplicitOps]
1205 OS << OperandInfoMap.find(OperandInfo)->second << ",\t0";
1209 OS << "|(1ULL<<MCID::PreISelOpcode)";
1211 OS << "|(1ULL<<MCID::Pseudo)";
1213 OS << "|(1ULL<<MCID::Meta)";
1215 OS << "|(1ULL<<MCID::Return)";
1217 OS << "|(1ULL<<MCID::EHScopeReturn)";
1219 OS << "|(1ULL<<MCID::Branch)";
1221 OS << "|(1ULL<<MCID::IndirectBranch)";
1223 OS << "|(1ULL<<MCID::Compare)";
1225 OS << "|(1ULL<<MCID::MoveImm)";
1227 OS << "|(1ULL<<MCID::MoveReg)";
1229 OS << "|(1ULL<<MCID::Bitcast)";
1231 OS << "|(1ULL<<MCID::Add)";
1233 OS << "|(1ULL<<MCID::Trap)";
1235 OS << "|(1ULL<<MCID::Select)";
1237 OS << "|(1ULL<<MCID::Barrier)";
1239 OS << "|(1ULL<<MCID::DelaySlot)";
1241 OS << "|(1ULL<<MCID::Call)";
1243 OS << "|(1ULL<<MCID::FoldableAsLoad)";
1245 OS << "|(1ULL<<MCID::MayLoad)";
1247 OS << "|(1ULL<<MCID::MayStore)";
1249 OS << "|(1ULL<<MCID::MayRaiseFPException)";
1251 OS << "|(1ULL<<MCID::Predicable)";
1253 OS << "|(1ULL<<MCID::ConvertibleTo3Addr)";
1255 OS << "|(1ULL<<MCID::Commutable)";
1257 OS << "|(1ULL<<MCID::Terminator)";
1259 OS << "|(1ULL<<MCID::Rematerializable)";
1261 OS << "|(1ULL<<MCID::NotDuplicable)";
1263 OS << "|(1ULL<<MCID::HasOptionalDef)";
1265 OS << "|(1ULL<<MCID::UsesCustomInserter)";
1267 OS << "|(1ULL<<MCID::HasPostISelHook)";
1269 OS << "|(1ULL<<MCID::Variadic)";
1271 OS << "|(1ULL<<MCID::UnmodeledSideEffects)";
1273 OS << "|(1ULL<<MCID::CheapAsAMove)";
1275 OS << "|(1ULL<<MCID::ExtraSrcRegAllocReq)";
1277 OS << "|(1ULL<<MCID::ExtraDefRegAllocReq)";
1279 OS << "|(1ULL<<MCID::RegSequence)";
1281 OS << "|(1ULL<<MCID::ExtractSubreg)";
1283 OS << "|(1ULL<<MCID::InsertSubreg)";
1285 OS << "|(1ULL<<MCID::Convergent)";
1287 OS << "|(1ULL<<MCID::VariadicOpsAreDefs)";
1289 OS << "|(1ULL<<MCID::Authenticated)";
1303 OS << ", 0x";
1304 OS.write_hex(Value);
1305 OS << "ULL";
1307 OS << " }, // Inst #" << Num << " = " << Inst.TheDef->getName() << "\n";
1311 void InstrInfoEmitter::emitEnums(raw_ostream &OS) {
1312 OS << "#ifdef GET_INSTRINFO_ENUM\n";
1313 OS << "#undef GET_INSTRINFO_ENUM\n";
1315 OS << "namespace llvm {\n\n";
1325 OS << "namespace " << Namespace << " {\n";
1326 OS << " enum {\n";
1329 OS << " " << Inst->TheDef->getName()
1331 OS << " INSTRUCTION_LIST_END = " << Num + 1 << "\n";
1332 OS << " };\n\n";
1333 OS << "} // end namespace " << Namespace << "\n";
1334 OS << "} // end namespace llvm\n";
1335 OS << "#endif // GET_INSTRINFO_ENUM\n\n";
1337 OS << "#ifdef GET_INSTRINFO_SCHED_ENUM\n";
1338 OS << "#undef GET_INSTRINFO_SCHED_ENUM\n";
1339 OS << "namespace llvm {\n\n";
1340 OS << "namespace " << Namespace << " {\n";
1341 OS << "namespace Sched {\n";
1342 OS << " enum {\n";
1345 OS << " " << Class.Name << "\t= " << Num++ << ",\n";
1346 OS << " SCHED_LIST_END = " << Num << "\n";
1347 OS << " };\n";
1348 OS << "} // end namespace Sched\n";
1349 OS << "} // end namespace " << Namespace << "\n";
1350 OS << "} // end namespace llvm\n";
1352 OS << "#endif // GET_INSTRINFO_SCHED_ENUM\n\n";
1355 static void EmitInstrInfo(RecordKeeper &RK, raw_ostream &OS) {
1357 InstrInfoEmitter(RK).run(OS);
1359 EmitMapTable(RK, OS);