1 //===- IntrinsicEmitter.cpp - Generate intrinsic information --------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This tablegen backend emits information about intrinsic functions.
12 //===----------------------------------------------------------------------===//
14 #include "CodeGenTarget.h"
15 #include "IntrinsicEmitter.h"
17 #include "StringMatcher.h"
18 #include "llvm/ADT/StringExtras.h"
22 //===----------------------------------------------------------------------===//
23 // IntrinsicEmitter Implementation
24 //===----------------------------------------------------------------------===//
26 void IntrinsicEmitter::run(raw_ostream &OS) {
27 EmitSourceFileHeader("Intrinsic Function Source Fragment", OS);
29 std::vector<CodeGenIntrinsic> Ints = LoadIntrinsics(Records, TargetOnly);
31 if (TargetOnly && !Ints.empty())
32 TargetPrefix = Ints[0].TargetPrefix;
36 // Emit the enum information.
37 EmitEnumInfo(Ints, OS);
39 // Emit the intrinsic ID -> name table.
40 EmitIntrinsicToNameTable(Ints, OS);
42 // Emit the intrinsic ID -> overload table.
43 EmitIntrinsicToOverloadTable(Ints, OS);
45 // Emit the function name recognizer.
46 EmitFnNameRecognizer(Ints, OS);
48 // Emit the intrinsic verifier.
49 EmitVerifier(Ints, OS);
51 // Emit the intrinsic declaration generator.
52 EmitGenerator(Ints, OS);
54 // Emit the intrinsic parameter attributes.
55 EmitAttributes(Ints, OS);
57 // Emit intrinsic alias analysis mod/ref behavior.
58 EmitModRefBehavior(Ints, OS);
60 // Emit a list of intrinsics with corresponding GCC builtins.
61 EmitGCCBuiltinList(Ints, OS);
63 // Emit code to translate GCC builtins into LLVM intrinsics.
64 EmitIntrinsicToGCCBuiltinMap(Ints, OS);
69 void IntrinsicEmitter::EmitPrefix(raw_ostream &OS) {
70 OS << "// VisualStudio defines setjmp as _setjmp\n"
71 "#if defined(_MSC_VER) && defined(setjmp)\n"
72 "#define setjmp_undefined_for_visual_studio\n"
77 void IntrinsicEmitter::EmitSuffix(raw_ostream &OS) {
78 OS << "#if defined(_MSC_VER) && defined(setjmp_undefined_for_visual_studio)\n"
79 "// let's return it to _setjmp state\n"
80 "#define setjmp _setjmp\n"
84 void IntrinsicEmitter::EmitEnumInfo(const std::vector<CodeGenIntrinsic> &Ints,
86 OS << "// Enum values for Intrinsics.h\n";
87 OS << "#ifdef GET_INTRINSIC_ENUM_VALUES\n";
88 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
89 OS << " " << Ints[i].EnumName;
90 OS << ((i != e-1) ? ", " : " ");
91 OS << std::string(40-Ints[i].EnumName.size(), ' ')
92 << "// " << Ints[i].Name << "\n";
97 void IntrinsicEmitter::
98 EmitFnNameRecognizer(const std::vector<CodeGenIntrinsic> &Ints,
100 // Build a function name -> intrinsic name mapping.
101 std::map<std::string, unsigned> IntMapping;
102 for (unsigned i = 0, e = Ints.size(); i != e; ++i)
103 IntMapping[Ints[i].Name.substr(5)] = i;
105 OS << "// Function name -> enum value recognizer code.\n";
106 OS << "#ifdef GET_FUNCTION_RECOGNIZER\n";
107 OS << " Name += 5; Len -= 5; // Skip over 'llvm.'\n";
108 OS << " switch (*Name) { // Dispatch on first letter.\n";
110 // Emit the intrinsics in sorted order.
112 for (std::map<std::string, unsigned>::iterator I = IntMapping.begin(),
113 E = IntMapping.end(); I != E; ++I) {
114 if (I->first[0] != LastChar) {
115 LastChar = I->first[0];
117 OS << " case '" << LastChar << "':\n";
120 // For overloaded intrinsics, only the prefix needs to match
121 std::string TheStr = I->first;
122 if (Ints[I->second].isOverloaded) {
123 TheStr += '.'; // Require "bswap." instead of bswap.
124 OS << " if (Len > " << I->first.size();
126 OS << " if (Len == " << I->first.size();
129 OS << " && !memcmp(Name, \"" << TheStr << "\", "
130 << TheStr.size() << ")) return " << TargetPrefix << "Intrinsic::"
131 << Ints[I->second].EnumName << ";\n";
137 void IntrinsicEmitter::
138 EmitIntrinsicToNameTable(const std::vector<CodeGenIntrinsic> &Ints,
140 OS << "// Intrinsic ID to name table\n";
141 OS << "#ifdef GET_INTRINSIC_NAME_TABLE\n";
142 OS << " // Note that entry #0 is the invalid intrinsic!\n";
143 for (unsigned i = 0, e = Ints.size(); i != e; ++i)
144 OS << " \"" << Ints[i].Name << "\",\n";
148 void IntrinsicEmitter::
149 EmitIntrinsicToOverloadTable(const std::vector<CodeGenIntrinsic> &Ints,
151 OS << "// Intrinsic ID to overload table\n";
152 OS << "#ifdef GET_INTRINSIC_OVERLOAD_TABLE\n";
153 OS << " // Note that entry #0 is the invalid intrinsic!\n";
154 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
156 if (Ints[i].isOverloaded)
165 static void EmitTypeForValueType(raw_ostream &OS, MVT::SimpleValueType VT) {
166 if (EVT(VT).isInteger()) {
167 unsigned BitWidth = EVT(VT).getSizeInBits();
168 OS << "IntegerType::get(Context, " << BitWidth << ")";
169 } else if (VT == MVT::Other) {
170 // MVT::OtherVT is used to mean the empty struct type here.
171 OS << "StructType::get(Context)";
172 } else if (VT == MVT::f32) {
173 OS << "Type::getFloatTy(Context)";
174 } else if (VT == MVT::f64) {
175 OS << "Type::getDoubleTy(Context)";
176 } else if (VT == MVT::f80) {
177 OS << "Type::getX86_FP80Ty(Context)";
178 } else if (VT == MVT::f128) {
179 OS << "Type::getFP128Ty(Context)";
180 } else if (VT == MVT::ppcf128) {
181 OS << "Type::getPPC_FP128Ty(Context)";
182 } else if (VT == MVT::isVoid) {
183 OS << "Type::getVoidTy(Context)";
184 } else if (VT == MVT::Metadata) {
185 OS << "Type::getMetadataTy(Context)";
187 assert(false && "Unsupported ValueType!");
191 static void EmitTypeGenerate(raw_ostream &OS, const Record *ArgType,
194 static void EmitTypeGenerate(raw_ostream &OS,
195 const std::vector<Record*> &ArgTypes,
197 if (ArgTypes.empty())
198 return EmitTypeForValueType(OS, MVT::isVoid);
200 if (ArgTypes.size() == 1)
201 return EmitTypeGenerate(OS, ArgTypes.front(), ArgNo);
203 OS << "StructType::get(Context, ";
205 for (std::vector<Record*>::const_iterator
206 I = ArgTypes.begin(), E = ArgTypes.end(); I != E; ++I) {
207 EmitTypeGenerate(OS, *I, ArgNo);
214 static void EmitTypeGenerate(raw_ostream &OS, const Record *ArgType,
216 MVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT"));
218 if (ArgType->isSubClassOf("LLVMMatchType")) {
219 unsigned Number = ArgType->getValueAsInt("Number");
220 assert(Number < ArgNo && "Invalid matching number!");
221 if (ArgType->isSubClassOf("LLVMExtendedElementVectorType"))
222 OS << "VectorType::getExtendedElementVectorType"
223 << "(dyn_cast<VectorType>(Tys[" << Number << "]))";
224 else if (ArgType->isSubClassOf("LLVMTruncatedElementVectorType"))
225 OS << "VectorType::getTruncatedElementVectorType"
226 << "(dyn_cast<VectorType>(Tys[" << Number << "]))";
228 OS << "Tys[" << Number << "]";
229 } else if (VT == MVT::iAny || VT == MVT::fAny || VT == MVT::vAny) {
230 // NOTE: The ArgNo variable here is not the absolute argument number, it is
231 // the index of the "arbitrary" type in the Tys array passed to the
232 // Intrinsic::getDeclaration function. Consequently, we only want to
233 // increment it when we actually hit an overloaded type. Getting this wrong
234 // leads to very subtle bugs!
235 OS << "Tys[" << ArgNo++ << "]";
236 } else if (EVT(VT).isVector()) {
238 OS << "VectorType::get(";
239 EmitTypeForValueType(OS, VVT.getVectorElementType().getSimpleVT().SimpleTy);
240 OS << ", " << VVT.getVectorNumElements() << ")";
241 } else if (VT == MVT::iPTR) {
242 OS << "PointerType::getUnqual(";
243 EmitTypeGenerate(OS, ArgType->getValueAsDef("ElTy"), ArgNo);
245 } else if (VT == MVT::iPTRAny) {
246 // Make sure the user has passed us an argument type to overload. If not,
247 // treat it as an ordinary (not overloaded) intrinsic.
248 OS << "(" << ArgNo << " < numTys) ? Tys[" << ArgNo
249 << "] : PointerType::getUnqual(";
250 EmitTypeGenerate(OS, ArgType->getValueAsDef("ElTy"), ArgNo);
253 } else if (VT == MVT::isVoid) {
255 OS << "Type::getVoidTy(Context)";
257 // MVT::isVoid is used to mean varargs here.
260 EmitTypeForValueType(OS, VT);
264 /// RecordListComparator - Provide a deterministic comparator for lists of
267 typedef std::pair<std::vector<Record*>, std::vector<Record*> > RecPair;
268 struct RecordListComparator {
269 bool operator()(const RecPair &LHS,
270 const RecPair &RHS) const {
272 const std::vector<Record*> *LHSVec = &LHS.first;
273 const std::vector<Record*> *RHSVec = &RHS.first;
274 unsigned RHSSize = RHSVec->size();
275 unsigned LHSSize = LHSVec->size();
277 for (; i != LHSSize; ++i) {
278 if (i == RHSSize) return false; // RHS is shorter than LHS.
279 if ((*LHSVec)[i] != (*RHSVec)[i])
280 return (*LHSVec)[i]->getName() < (*RHSVec)[i]->getName();
283 if (i != RHSSize) return true;
286 LHSVec = &LHS.second;
287 RHSVec = &RHS.second;
288 RHSSize = RHSVec->size();
289 LHSSize = LHSVec->size();
291 for (i = 0; i != LHSSize; ++i) {
292 if (i == RHSSize) return false; // RHS is shorter than LHS.
293 if ((*LHSVec)[i] != (*RHSVec)[i])
294 return (*LHSVec)[i]->getName() < (*RHSVec)[i]->getName();
302 void IntrinsicEmitter::EmitVerifier(const std::vector<CodeGenIntrinsic> &Ints,
304 OS << "// Verifier::visitIntrinsicFunctionCall code.\n";
305 OS << "#ifdef GET_INTRINSIC_VERIFIER\n";
306 OS << " switch (ID) {\n";
307 OS << " default: assert(0 && \"Invalid intrinsic!\");\n";
309 // This checking can emit a lot of very common code. To reduce the amount of
310 // code that we emit, batch up cases that have identical types. This avoids
311 // problems where GCC can run out of memory compiling Verifier.cpp.
312 typedef std::map<RecPair, std::vector<unsigned>, RecordListComparator> MapTy;
313 MapTy UniqueArgInfos;
315 // Compute the unique argument type info.
316 for (unsigned i = 0, e = Ints.size(); i != e; ++i)
317 UniqueArgInfos[make_pair(Ints[i].IS.RetTypeDefs,
318 Ints[i].IS.ParamTypeDefs)].push_back(i);
320 // Loop through the array, emitting one comparison for each batch.
321 for (MapTy::iterator I = UniqueArgInfos.begin(),
322 E = UniqueArgInfos.end(); I != E; ++I) {
323 for (unsigned i = 0, e = I->second.size(); i != e; ++i)
324 OS << " case Intrinsic::" << Ints[I->second[i]].EnumName << ":\t\t// "
325 << Ints[I->second[i]].Name << "\n";
327 const RecPair &ArgTypes = I->first;
328 const std::vector<Record*> &RetTys = ArgTypes.first;
329 const std::vector<Record*> &ParamTys = ArgTypes.second;
330 std::vector<unsigned> OverloadedTypeIndices;
332 OS << " VerifyIntrinsicPrototype(ID, IF, " << RetTys.size() << ", "
335 // Emit return types.
336 for (unsigned j = 0, je = RetTys.size(); j != je; ++j) {
337 Record *ArgType = RetTys[j];
340 if (ArgType->isSubClassOf("LLVMMatchType")) {
341 unsigned Number = ArgType->getValueAsInt("Number");
342 assert(Number < OverloadedTypeIndices.size() &&
343 "Invalid matching number!");
344 Number = OverloadedTypeIndices[Number];
345 if (ArgType->isSubClassOf("LLVMExtendedElementVectorType"))
346 OS << "~(ExtendedElementVectorType | " << Number << ")";
347 else if (ArgType->isSubClassOf("LLVMTruncatedElementVectorType"))
348 OS << "~(TruncatedElementVectorType | " << Number << ")";
352 MVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT"));
353 OS << getEnumName(VT);
355 if (EVT(VT).isOverloaded())
356 OverloadedTypeIndices.push_back(j);
358 if (VT == MVT::isVoid && j != 0 && j != je - 1)
359 throw "Var arg type not last argument";
363 // Emit the parameter types.
364 for (unsigned j = 0, je = ParamTys.size(); j != je; ++j) {
365 Record *ArgType = ParamTys[j];
368 if (ArgType->isSubClassOf("LLVMMatchType")) {
369 unsigned Number = ArgType->getValueAsInt("Number");
370 assert(Number < OverloadedTypeIndices.size() &&
371 "Invalid matching number!");
372 Number = OverloadedTypeIndices[Number];
373 if (ArgType->isSubClassOf("LLVMExtendedElementVectorType"))
374 OS << "~(ExtendedElementVectorType | " << Number << ")";
375 else if (ArgType->isSubClassOf("LLVMTruncatedElementVectorType"))
376 OS << "~(TruncatedElementVectorType | " << Number << ")";
380 MVT::SimpleValueType VT = getValueType(ArgType->getValueAsDef("VT"));
381 OS << getEnumName(VT);
383 if (EVT(VT).isOverloaded())
384 OverloadedTypeIndices.push_back(j + RetTys.size());
386 if (VT == MVT::isVoid && j != 0 && j != je - 1)
387 throw "Var arg type not last argument";
398 void IntrinsicEmitter::EmitGenerator(const std::vector<CodeGenIntrinsic> &Ints,
400 OS << "// Code for generating Intrinsic function declarations.\n";
401 OS << "#ifdef GET_INTRINSIC_GENERATOR\n";
402 OS << " switch (id) {\n";
403 OS << " default: assert(0 && \"Invalid intrinsic!\");\n";
405 // Similar to GET_INTRINSIC_VERIFIER, batch up cases that have identical
407 typedef std::map<RecPair, std::vector<unsigned>, RecordListComparator> MapTy;
408 MapTy UniqueArgInfos;
410 // Compute the unique argument type info.
411 for (unsigned i = 0, e = Ints.size(); i != e; ++i)
412 UniqueArgInfos[make_pair(Ints[i].IS.RetTypeDefs,
413 Ints[i].IS.ParamTypeDefs)].push_back(i);
415 // Loop through the array, emitting one generator for each batch.
416 std::string IntrinsicStr = TargetPrefix + "Intrinsic::";
418 for (MapTy::iterator I = UniqueArgInfos.begin(),
419 E = UniqueArgInfos.end(); I != E; ++I) {
420 for (unsigned i = 0, e = I->second.size(); i != e; ++i)
421 OS << " case " << IntrinsicStr << Ints[I->second[i]].EnumName
422 << ":\t\t// " << Ints[I->second[i]].Name << "\n";
424 const RecPair &ArgTypes = I->first;
425 const std::vector<Record*> &RetTys = ArgTypes.first;
426 const std::vector<Record*> &ParamTys = ArgTypes.second;
428 unsigned N = ParamTys.size();
431 getValueType(ParamTys[N - 1]->getValueAsDef("VT")) == MVT::isVoid) {
432 OS << " IsVarArg = true;\n";
437 OS << " ResultTy = ";
438 EmitTypeGenerate(OS, RetTys, ArgNo);
441 for (unsigned j = 0; j != N; ++j) {
442 OS << " ArgTys.push_back(";
443 EmitTypeGenerate(OS, ParamTys[j], ArgNo);
454 /// EmitAttributes - This emits the Intrinsic::getAttributes method.
455 void IntrinsicEmitter::
456 EmitAttributes(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS) {
457 OS << "// Add parameter attributes that are not common to all intrinsics.\n";
458 OS << "#ifdef GET_INTRINSIC_ATTRIBUTES\n";
460 OS << "static AttrListPtr getAttributes(" << TargetPrefix
461 << "Intrinsic::ID id) {";
463 OS << "AttrListPtr Intrinsic::getAttributes(ID id) {";
464 OS << " // No intrinsic can throw exceptions.\n";
465 OS << " Attributes Attr = Attribute::NoUnwind;\n";
466 OS << " switch (id) {\n";
467 OS << " default: break;\n";
468 unsigned MaxArgAttrs = 0;
469 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
471 std::max(MaxArgAttrs, unsigned(Ints[i].ArgumentAttributes.size()));
472 switch (Ints[i].ModRef) {
474 case CodeGenIntrinsic::NoMem:
475 OS << " case " << TargetPrefix << "Intrinsic::" << Ints[i].EnumName
480 OS << " Attr |= Attribute::ReadNone; // These do not access memory.\n";
482 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
483 switch (Ints[i].ModRef) {
485 case CodeGenIntrinsic::ReadArgMem:
486 case CodeGenIntrinsic::ReadMem:
487 OS << " case " << TargetPrefix << "Intrinsic::" << Ints[i].EnumName
492 OS << " Attr |= Attribute::ReadOnly; // These do not write memory.\n";
495 OS << " AttributeWithIndex AWI[" << MaxArgAttrs+1 << "];\n";
496 OS << " unsigned NumAttrs = 0;\n";
497 OS << " switch (id) {\n";
498 OS << " default: break;\n";
500 // Add argument attributes for any intrinsics that have them.
501 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
502 if (Ints[i].ArgumentAttributes.empty()) continue;
504 OS << " case " << TargetPrefix << "Intrinsic::" << Ints[i].EnumName
507 std::vector<std::pair<unsigned, CodeGenIntrinsic::ArgAttribute> > ArgAttrs =
508 Ints[i].ArgumentAttributes;
509 // Sort by argument index.
510 std::sort(ArgAttrs.begin(), ArgAttrs.end());
512 unsigned NumArgsWithAttrs = 0;
514 while (!ArgAttrs.empty()) {
515 unsigned ArgNo = ArgAttrs[0].first;
517 OS << " AWI[" << NumArgsWithAttrs++ << "] = AttributeWithIndex::get("
520 while (!ArgAttrs.empty() && ArgAttrs[0].first == ArgNo) {
521 switch (ArgAttrs[0].second) {
522 default: assert(0 && "Unknown arg attribute");
523 case CodeGenIntrinsic::NoCapture:
524 OS << "|Attribute::NoCapture";
527 ArgAttrs.erase(ArgAttrs.begin());
532 OS << " NumAttrs = " << NumArgsWithAttrs << ";\n";
537 OS << " AWI[NumAttrs] = AttributeWithIndex::get(~0, Attr);\n";
538 OS << " return AttrListPtr::get(AWI, NumAttrs+1);\n";
540 OS << "#endif // GET_INTRINSIC_ATTRIBUTES\n\n";
543 /// EmitModRefBehavior - Determine intrinsic alias analysis mod/ref behavior.
544 void IntrinsicEmitter::
545 EmitModRefBehavior(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS){
546 OS << "// Determine intrinsic alias analysis mod/ref behavior.\n";
547 OS << "#ifdef GET_INTRINSIC_MODREF_BEHAVIOR\n";
548 OS << "switch (iid) {\n";
549 OS << "default:\n return UnknownModRefBehavior;\n";
550 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
551 if (Ints[i].ModRef == CodeGenIntrinsic::ReadWriteMem)
553 OS << "case " << TargetPrefix << "Intrinsic::" << Ints[i].EnumName
555 switch (Ints[i].ModRef) {
557 assert(false && "Unknown Mod/Ref type!");
558 case CodeGenIntrinsic::NoMem:
559 OS << " return DoesNotAccessMemory;\n";
561 case CodeGenIntrinsic::ReadArgMem:
562 case CodeGenIntrinsic::ReadMem:
563 OS << " return OnlyReadsMemory;\n";
565 case CodeGenIntrinsic::ReadWriteArgMem:
566 OS << " return AccessesArguments;\n";
571 OS << "#endif // GET_INTRINSIC_MODREF_BEHAVIOR\n\n";
574 void IntrinsicEmitter::
575 EmitGCCBuiltinList(const std::vector<CodeGenIntrinsic> &Ints, raw_ostream &OS){
576 OS << "// Get the GCC builtin that corresponds to an LLVM intrinsic.\n";
577 OS << "#ifdef GET_GCC_BUILTIN_NAME\n";
578 OS << " switch (F->getIntrinsicID()) {\n";
579 OS << " default: BuiltinName = \"\"; break;\n";
580 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
581 if (!Ints[i].GCCBuiltinName.empty()) {
582 OS << " case Intrinsic::" << Ints[i].EnumName << ": BuiltinName = \""
583 << Ints[i].GCCBuiltinName << "\"; break;\n";
590 /// EmitTargetBuiltins - All of the builtins in the specified map are for the
591 /// same target, and we already checked it.
592 static void EmitTargetBuiltins(const std::map<std::string, std::string> &BIM,
593 const std::string &TargetPrefix,
596 std::vector<StringMatcher::StringPair> Results;
598 for (std::map<std::string, std::string>::const_iterator I = BIM.begin(),
599 E = BIM.end(); I != E; ++I) {
600 std::string ResultCode =
601 "return " + TargetPrefix + "Intrinsic::" + I->second + ";";
602 Results.push_back(StringMatcher::StringPair(I->first, ResultCode));
605 StringMatcher("BuiltinName", Results, OS).Emit();
609 void IntrinsicEmitter::
610 EmitIntrinsicToGCCBuiltinMap(const std::vector<CodeGenIntrinsic> &Ints,
612 typedef std::map<std::string, std::map<std::string, std::string> > BIMTy;
614 for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
615 if (!Ints[i].GCCBuiltinName.empty()) {
616 // Get the map for this target prefix.
617 std::map<std::string, std::string> &BIM =BuiltinMap[Ints[i].TargetPrefix];
619 if (!BIM.insert(std::make_pair(Ints[i].GCCBuiltinName,
620 Ints[i].EnumName)).second)
621 throw "Intrinsic '" + Ints[i].TheDef->getName() +
622 "': duplicate GCC builtin name!";
626 OS << "// Get the LLVM intrinsic that corresponds to a GCC builtin.\n";
627 OS << "// This is used by the C front-end. The GCC builtin name is passed\n";
628 OS << "// in as BuiltinName, and a target prefix (e.g. 'ppc') is passed\n";
629 OS << "// in as TargetPrefix. The result is assigned to 'IntrinsicID'.\n";
630 OS << "#ifdef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN\n";
633 OS << "static " << TargetPrefix << "Intrinsic::ID "
634 << "getIntrinsicForGCCBuiltin(const char "
635 << "*TargetPrefixStr, const char *BuiltinNameStr) {\n";
637 OS << "Intrinsic::ID Intrinsic::getIntrinsicForGCCBuiltin(const char "
638 << "*TargetPrefixStr, const char *BuiltinNameStr) {\n";
641 OS << " StringRef BuiltinName(BuiltinNameStr);\n";
642 OS << " StringRef TargetPrefix(TargetPrefixStr);\n\n";
644 // Note: this could emit significantly better code if we cared.
645 for (BIMTy::iterator I = BuiltinMap.begin(), E = BuiltinMap.end();I != E;++I){
647 if (!I->first.empty())
648 OS << "if (TargetPrefix == \"" << I->first << "\") ";
650 OS << "/* Target Independent Builtins */ ";
653 // Emit the comparisons for this target prefix.
654 EmitTargetBuiltins(I->second, TargetPrefix, OS);
658 if (!TargetPrefix.empty())
659 OS << "(" << TargetPrefix << "Intrinsic::ID)";
660 OS << "Intrinsic::not_intrinsic;\n";