Lines Matching refs:OS
26 void IntrinsicEmitter::run(raw_ostream &OS) { in run() argument
27 EmitSourceFileHeader("Intrinsic Function Source Fragment", OS); in run()
34 EmitPrefix(OS); in run()
37 EmitEnumInfo(Ints, OS); in run()
40 EmitIntrinsicToNameTable(Ints, OS); in run()
43 EmitIntrinsicToOverloadTable(Ints, OS); in run()
46 EmitFnNameRecognizer(Ints, OS); in run()
49 EmitVerifier(Ints, OS); in run()
52 EmitGenerator(Ints, OS); in run()
55 EmitAttributes(Ints, OS); in run()
58 EmitModRefBehavior(Ints, OS); in run()
61 EmitGCCBuiltinList(Ints, OS); in run()
64 EmitIntrinsicToGCCBuiltinMap(Ints, OS); in run()
66 EmitSuffix(OS); in run()
69 void IntrinsicEmitter::EmitPrefix(raw_ostream &OS) { in EmitPrefix() argument
70 OS << "// VisualStudio defines setjmp as _setjmp\n" in EmitPrefix()
79 void IntrinsicEmitter::EmitSuffix(raw_ostream &OS) { in EmitSuffix() argument
80 OS << "#if defined(_MSC_VER) && defined(setjmp_undefined_for_msvc)\n" in EmitSuffix()
88 raw_ostream &OS) { in EmitEnumInfo() argument
89 OS << "// Enum values for Intrinsics.h\n"; in EmitEnumInfo()
90 OS << "#ifdef GET_INTRINSIC_ENUM_VALUES\n"; in EmitEnumInfo()
92 OS << " " << Ints[i].EnumName; in EmitEnumInfo()
93 OS << ((i != e-1) ? ", " : " "); in EmitEnumInfo()
94 OS << std::string(40-Ints[i].EnumName.size(), ' ') in EmitEnumInfo()
97 OS << "#endif\n\n"; in EmitEnumInfo()
102 raw_ostream &OS) { in EmitFnNameRecognizer() argument
108 OS << "// Function name -> enum value recognizer code.\n"; in EmitFnNameRecognizer()
109 OS << "#ifdef GET_FUNCTION_RECOGNIZER\n"; in EmitFnNameRecognizer()
110 OS << " StringRef NameR(Name+6, Len-6); // Skip over 'llvm.'\n"; in EmitFnNameRecognizer()
111 OS << " switch (Name[5]) { // Dispatch on first letter.\n"; in EmitFnNameRecognizer()
112 OS << " default: break;\n"; in EmitFnNameRecognizer()
116 OS << " case '" << I->first << "':\n"; in EmitFnNameRecognizer()
136 OS << " if (NameR.startswith(\"" << TheStr << "\")) " in EmitFnNameRecognizer()
141 StringMatcher("NameR", MatchTable, OS).Emit(1); in EmitFnNameRecognizer()
142 OS << " break; // end of '" << I->first << "' case.\n"; in EmitFnNameRecognizer()
145 OS << " }\n"; in EmitFnNameRecognizer()
146 OS << "#endif\n\n"; in EmitFnNameRecognizer()
151 raw_ostream &OS) { in EmitIntrinsicToNameTable() argument
152 OS << "// Intrinsic ID to name table\n"; in EmitIntrinsicToNameTable()
153 OS << "#ifdef GET_INTRINSIC_NAME_TABLE\n"; in EmitIntrinsicToNameTable()
154 OS << " // Note that entry #0 is the invalid intrinsic!\n"; in EmitIntrinsicToNameTable()
156 OS << " \"" << Ints[i].Name << "\",\n"; in EmitIntrinsicToNameTable()
157 OS << "#endif\n\n"; in EmitIntrinsicToNameTable()
162 raw_ostream &OS) { in EmitIntrinsicToOverloadTable() argument
163 OS << "// Intrinsic ID to overload table\n"; in EmitIntrinsicToOverloadTable()
164 OS << "#ifdef GET_INTRINSIC_OVERLOAD_TABLE\n"; in EmitIntrinsicToOverloadTable()
165 OS << " // Note that entry #0 is the invalid intrinsic!\n"; in EmitIntrinsicToOverloadTable()
167 OS << " "; in EmitIntrinsicToOverloadTable()
169 OS << "true"; in EmitIntrinsicToOverloadTable()
171 OS << "false"; in EmitIntrinsicToOverloadTable()
172 OS << ",\n"; in EmitIntrinsicToOverloadTable()
174 OS << "#endif\n\n"; in EmitIntrinsicToOverloadTable()
177 static void EmitTypeForValueType(raw_ostream &OS, MVT::SimpleValueType VT) { in EmitTypeForValueType() argument
180 OS << "IntegerType::get(Context, " << BitWidth << ")"; in EmitTypeForValueType()
183 OS << "StructType::get(Context)"; in EmitTypeForValueType()
185 OS << "Type::getFloatTy(Context)"; in EmitTypeForValueType()
187 OS << "Type::getDoubleTy(Context)"; in EmitTypeForValueType()
189 OS << "Type::getX86_FP80Ty(Context)"; in EmitTypeForValueType()
191 OS << "Type::getFP128Ty(Context)"; in EmitTypeForValueType()
193 OS << "Type::getPPC_FP128Ty(Context)"; in EmitTypeForValueType()
195 OS << "Type::getVoidTy(Context)"; in EmitTypeForValueType()
197 OS << "Type::getMetadataTy(Context)"; in EmitTypeForValueType()
199 OS << "Type::getX86_MMXTy(Context)"; in EmitTypeForValueType()
205 static void EmitTypeGenerate(raw_ostream &OS, const Record *ArgType,
208 static void EmitTypeGenerate(raw_ostream &OS, in EmitTypeGenerate() argument
212 return EmitTypeForValueType(OS, MVT::isVoid); in EmitTypeGenerate()
215 return EmitTypeGenerate(OS, ArgTypes.front(), ArgNo); in EmitTypeGenerate()
217 OS << "StructType::get("; in EmitTypeGenerate()
221 EmitTypeGenerate(OS, *I, ArgNo); in EmitTypeGenerate()
222 OS << ", "; in EmitTypeGenerate()
225 OS << " NULL)"; in EmitTypeGenerate()
228 static void EmitTypeGenerate(raw_ostream &OS, const Record *ArgType, in EmitTypeGenerate() argument
236 OS << "VectorType::getExtendedElementVectorType" in EmitTypeGenerate()
239 OS << "VectorType::getTruncatedElementVectorType" in EmitTypeGenerate()
242 OS << "Tys[" << Number << "]"; in EmitTypeGenerate()
249 OS << "Tys[" << ArgNo++ << "]"; in EmitTypeGenerate()
252 OS << "VectorType::get("; in EmitTypeGenerate()
253 EmitTypeForValueType(OS, VVT.getVectorElementType().getSimpleVT().SimpleTy); in EmitTypeGenerate()
254 OS << ", " << VVT.getVectorNumElements() << ")"; in EmitTypeGenerate()
256 OS << "PointerType::getUnqual("; in EmitTypeGenerate()
257 EmitTypeGenerate(OS, ArgType->getValueAsDef("ElTy"), ArgNo); in EmitTypeGenerate()
258 OS << ")"; in EmitTypeGenerate()
262 OS << "(" << ArgNo << " < Tys.size()) ? Tys[" << ArgNo in EmitTypeGenerate()
264 EmitTypeGenerate(OS, ArgType->getValueAsDef("ElTy"), ArgNo); in EmitTypeGenerate()
265 OS << ")"; in EmitTypeGenerate()
269 OS << "Type::getVoidTy(Context)"; in EmitTypeGenerate()
272 OS << "..."; in EmitTypeGenerate()
274 EmitTypeForValueType(OS, VT); in EmitTypeGenerate()
317 raw_ostream &OS) { in EmitVerifier() argument
318 OS << "// Verifier::visitIntrinsicFunctionCall code.\n"; in EmitVerifier()
319 OS << "#ifdef GET_INTRINSIC_VERIFIER\n"; in EmitVerifier()
320 OS << " switch (ID) {\n"; in EmitVerifier()
321 OS << " default: assert(0 && \"Invalid intrinsic!\");\n"; in EmitVerifier()
338 OS << " case Intrinsic::" << Ints[I->second[i]].EnumName << ":\t\t// " in EmitVerifier()
346 OS << " VerifyIntrinsicPrototype(ID, IF, " << RetTys.size() << ", " in EmitVerifier()
352 OS << ", "; in EmitVerifier()
360 OS << "~(ExtendedElementVectorType | " << Number << ")"; in EmitVerifier()
362 OS << "~(TruncatedElementVectorType | " << Number << ")"; in EmitVerifier()
364 OS << "~" << Number; in EmitVerifier()
367 OS << getEnumName(VT); in EmitVerifier()
380 OS << ", "; in EmitVerifier()
388 OS << "~(ExtendedElementVectorType | " << Number << ")"; in EmitVerifier()
390 OS << "~(TruncatedElementVectorType | " << Number << ")"; in EmitVerifier()
392 OS << "~" << Number; in EmitVerifier()
395 OS << getEnumName(VT); in EmitVerifier()
405 OS << ");\n"; in EmitVerifier()
406 OS << " break;\n"; in EmitVerifier()
408 OS << " }\n"; in EmitVerifier()
409 OS << "#endif\n\n"; in EmitVerifier()
413 raw_ostream &OS) { in EmitGenerator() argument
414 OS << "// Code for generating Intrinsic function declarations.\n"; in EmitGenerator()
415 OS << "#ifdef GET_INTRINSIC_GENERATOR\n"; in EmitGenerator()
416 OS << " switch (id) {\n"; in EmitGenerator()
417 OS << " default: assert(0 && \"Invalid intrinsic!\");\n"; in EmitGenerator()
435 OS << " case " << IntrinsicStr << Ints[I->second[i]].EnumName in EmitGenerator()
446 OS << " IsVarArg = true;\n"; in EmitGenerator()
451 OS << " ResultTy = "; in EmitGenerator()
452 EmitTypeGenerate(OS, RetTys, ArgNo); in EmitGenerator()
453 OS << ";\n"; in EmitGenerator()
456 OS << " ArgTys.push_back("; in EmitGenerator()
457 EmitTypeGenerate(OS, ParamTys[j], ArgNo); in EmitGenerator()
458 OS << ");\n"; in EmitGenerator()
461 OS << " break;\n"; in EmitGenerator()
464 OS << " }\n"; in EmitGenerator()
465 OS << "#endif\n\n"; in EmitGenerator()
510 EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS) { in EmitAttributes() argument
511 OS << "// Add parameter attributes that are not common to all intrinsics.\n"; in EmitAttributes()
512 OS << "#ifdef GET_INTRINSIC_ATTRIBUTES\n"; in EmitAttributes()
514 OS << "static AttrListPtr getAttributes(" << TargetPrefix in EmitAttributes()
517 OS << "AttrListPtr Intrinsic::getAttributes(ID id) {\n"; in EmitAttributes()
532 OS << " AttributeWithIndex AWI[" << maxArgAttrs+1 << "];\n"; in EmitAttributes()
533 OS << " unsigned NumAttrs = 0;\n"; in EmitAttributes()
534 OS << " switch (id) {\n"; in EmitAttributes()
535 OS << " default: break;\n"; in EmitAttributes()
543 OS << " case " << TargetPrefix << "Intrinsic::" in EmitAttributes()
558 OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get(" in EmitAttributes()
564 if (moreThanOne) OS << '|'; in EmitAttributes()
568 OS << "Attribute::NoCapture"; in EmitAttributes()
576 OS << ");\n"; in EmitAttributes()
582 OS << " AWI[" << numAttrs++ << "] = AttributeWithIndex::get(~0, "; in EmitAttributes()
584 OS << "Attribute::NoUnwind"; in EmitAttributes()
585 if (modRef) OS << '|'; in EmitAttributes()
589 case MRK_readonly: OS << "Attribute::ReadOnly"; break; in EmitAttributes()
590 case MRK_readnone: OS << "Attribute::ReadNone"; break; in EmitAttributes()
592 OS << ");\n"; in EmitAttributes()
596 OS << " NumAttrs = " << numAttrs << ";\n"; in EmitAttributes()
597 OS << " break;\n"; in EmitAttributes()
599 OS << " return AttrListPtr();\n"; in EmitAttributes()
603 OS << " }\n"; in EmitAttributes()
604 OS << " return AttrListPtr::get(AWI, NumAttrs);\n"; in EmitAttributes()
605 OS << "}\n"; in EmitAttributes()
606 OS << "#endif // GET_INTRINSIC_ATTRIBUTES\n\n"; in EmitAttributes()
611 EmitModRefBehavior(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS){ in EmitModRefBehavior() argument
612 OS << "// Determine intrinsic alias analysis mod/ref behavior.\n"; in EmitModRefBehavior()
613 OS << "#ifdef GET_INTRINSIC_MODREF_BEHAVIOR\n"; in EmitModRefBehavior()
614 OS << "switch (iid) {\n"; in EmitModRefBehavior()
615 OS << "default:\n return UnknownModRefBehavior;\n"; in EmitModRefBehavior()
619 OS << "case " << TargetPrefix << "Intrinsic::" << Ints[i].EnumName in EmitModRefBehavior()
625 OS << " return DoesNotAccessMemory;\n"; in EmitModRefBehavior()
628 OS << " return OnlyReadsArgumentPointees;\n"; in EmitModRefBehavior()
631 OS << " return OnlyReadsMemory;\n"; in EmitModRefBehavior()
634 OS << " return OnlyAccessesArgumentPointees;\n"; in EmitModRefBehavior()
638 OS << "}\n"; in EmitModRefBehavior()
639 OS << "#endif // GET_INTRINSIC_MODREF_BEHAVIOR\n\n"; in EmitModRefBehavior()
643 EmitGCCBuiltinList(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS){ in EmitGCCBuiltinList() argument
644 OS << "// Get the GCC builtin that corresponds to an LLVM intrinsic.\n"; in EmitGCCBuiltinList()
645 OS << "#ifdef GET_GCC_BUILTIN_NAME\n"; in EmitGCCBuiltinList()
646 OS << " switch (F->getIntrinsicID()) {\n"; in EmitGCCBuiltinList()
647 OS << " default: BuiltinName = \"\"; break;\n"; in EmitGCCBuiltinList()
650 OS << " case Intrinsic::" << Ints[i].EnumName << ": BuiltinName = \"" in EmitGCCBuiltinList()
654 OS << " }\n"; in EmitGCCBuiltinList()
655 OS << "#endif\n\n"; in EmitGCCBuiltinList()
662 raw_ostream &OS) { in EmitTargetBuiltins() argument
673 StringMatcher("BuiltinName", Results, OS).Emit(); in EmitTargetBuiltins()
679 raw_ostream &OS) { in EmitIntrinsicToGCCBuiltinMap() argument
694 OS << "// Get the LLVM intrinsic that corresponds to a GCC builtin.\n"; in EmitIntrinsicToGCCBuiltinMap()
695 OS << "// This is used by the C front-end. The GCC builtin name is passed\n"; in EmitIntrinsicToGCCBuiltinMap()
696 OS << "// in as BuiltinName, and a target prefix (e.g. 'ppc') is passed\n"; in EmitIntrinsicToGCCBuiltinMap()
697 OS << "// in as TargetPrefix. The result is assigned to 'IntrinsicID'.\n"; in EmitIntrinsicToGCCBuiltinMap()
698 OS << "#ifdef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN\n"; in EmitIntrinsicToGCCBuiltinMap()
701 OS << "static " << TargetPrefix << "Intrinsic::ID " in EmitIntrinsicToGCCBuiltinMap()
705 OS << "Intrinsic::ID Intrinsic::getIntrinsicForGCCBuiltin(const char " in EmitIntrinsicToGCCBuiltinMap()
709 OS << " StringRef BuiltinName(BuiltinNameStr);\n"; in EmitIntrinsicToGCCBuiltinMap()
710 OS << " StringRef TargetPrefix(TargetPrefixStr);\n\n"; in EmitIntrinsicToGCCBuiltinMap()
714 OS << " "; in EmitIntrinsicToGCCBuiltinMap()
716 OS << "if (TargetPrefix == \"" << I->first << "\") "; in EmitIntrinsicToGCCBuiltinMap()
718 OS << "/* Target Independent Builtins */ "; in EmitIntrinsicToGCCBuiltinMap()
719 OS << "{\n"; in EmitIntrinsicToGCCBuiltinMap()
722 EmitTargetBuiltins(I->second, TargetPrefix, OS); in EmitIntrinsicToGCCBuiltinMap()
723 OS << " }\n"; in EmitIntrinsicToGCCBuiltinMap()
725 OS << " return "; in EmitIntrinsicToGCCBuiltinMap()
727 OS << "(" << TargetPrefix << "Intrinsic::ID)"; in EmitIntrinsicToGCCBuiltinMap()
728 OS << "Intrinsic::not_intrinsic;\n"; in EmitIntrinsicToGCCBuiltinMap()
729 OS << "}\n"; in EmitIntrinsicToGCCBuiltinMap()
730 OS << "#endif\n\n"; in EmitIntrinsicToGCCBuiltinMap()