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