Chris Lattner | 9e493cf | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 1 | //===- IntrinsicEmitter.cpp - Generate intrinsic information --------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file was developed by Chris Lattner and is distributed under |
| 6 | // the University of Illinois Open Source License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This tablegen backend emits information about intrinsic functions. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "IntrinsicEmitter.h" |
| 15 | #include "Record.h" |
Chris Lattner | 18faf5d | 2006-03-13 22:38:57 +0000 | [diff] [blame] | 16 | #include "llvm/ADT/StringExtras.h" |
Jeff Cohen | 71c3bc3 | 2006-03-15 02:51:05 +0000 | [diff] [blame] | 17 | #include <algorithm> |
Chris Lattner | 9e493cf | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 18 | using namespace llvm; |
| 19 | |
| 20 | //===----------------------------------------------------------------------===// |
| 21 | // CodeGenIntrinsic Implementation |
| 22 | //===----------------------------------------------------------------------===// |
| 23 | |
| 24 | std::vector<CodeGenIntrinsic> llvm::LoadIntrinsics(const RecordKeeper &RC) { |
| 25 | std::vector<Record*> I = RC.getAllDerivedDefinitions("Intrinsic"); |
| 26 | return std::vector<CodeGenIntrinsic>(I.begin(), I.end()); |
| 27 | } |
| 28 | |
| 29 | CodeGenIntrinsic::CodeGenIntrinsic(Record *R) { |
| 30 | std::string DefName = R->getName(); |
Chris Lattner | 6448ee4 | 2006-03-09 22:30:49 +0000 | [diff] [blame] | 31 | ModRef = WriteMem; |
Chris Lattner | 9e493cf | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 32 | |
| 33 | if (DefName.size() <= 4 || |
| 34 | std::string(DefName.begin(), DefName.begin()+4) != "int_") |
| 35 | throw "Intrinsic '" + DefName + "' does not start with 'int_'!"; |
| 36 | EnumName = std::string(DefName.begin()+4, DefName.end()); |
Chris Lattner | 0da3130 | 2006-03-15 19:15:26 +0000 | [diff] [blame] | 37 | if (R->getValue("GCCBuiltinName")) // Ignore a missing GCCBuiltinName field. |
| 38 | GCCBuiltinName = R->getValueAsString("GCCBuiltinName"); |
Chris Lattner | 3f8b891 | 2006-03-15 01:33:26 +0000 | [diff] [blame] | 39 | TargetPrefix = R->getValueAsString("TargetPrefix"); |
Chris Lattner | 9e493cf | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 40 | Name = R->getValueAsString("LLVMName"); |
| 41 | if (Name == "") { |
| 42 | // If an explicit name isn't specified, derive one from the DefName. |
| 43 | Name = "llvm."; |
| 44 | for (unsigned i = 0, e = EnumName.size(); i != e; ++i) |
| 45 | if (EnumName[i] == '_') |
| 46 | Name += '.'; |
| 47 | else |
| 48 | Name += EnumName[i]; |
Chris Lattner | 3f8b891 | 2006-03-15 01:33:26 +0000 | [diff] [blame] | 49 | } else { |
| 50 | // Verify it starts with "llvm.". |
| 51 | if (Name.size() <= 5 || |
| 52 | std::string(Name.begin(), Name.begin()+5) != "llvm.") |
| 53 | throw "Intrinsic '" + DefName + "'s name does not start with 'llvm.'!"; |
| 54 | } |
| 55 | |
| 56 | // If TargetPrefix is specified, make sure that Name starts with |
| 57 | // "llvm.<targetprefix>.". |
| 58 | if (!TargetPrefix.empty()) { |
| 59 | if (Name.size() < 6+TargetPrefix.size() || |
| 60 | std::string(Name.begin()+5, Name.begin()+6+TargetPrefix.size()) |
| 61 | != (TargetPrefix+".")) |
| 62 | throw "Intrinsic '" + DefName + "' does not start with 'llvm." + |
| 63 | TargetPrefix + ".'!"; |
Chris Lattner | 9e493cf | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 64 | } |
Chris Lattner | f97a00e | 2006-03-09 22:05:04 +0000 | [diff] [blame] | 65 | |
| 66 | // Parse the list of argument types. |
| 67 | ListInit *TypeList = R->getValueAsListInit("Types"); |
| 68 | for (unsigned i = 0, e = TypeList->getSize(); i != e; ++i) { |
| 69 | DefInit *DI = dynamic_cast<DefInit*>(TypeList->getElement(i)); |
| 70 | assert(DI && "Invalid list type!"); |
| 71 | Record *TyEl = DI->getDef(); |
| 72 | assert(TyEl->isSubClassOf("LLVMType") && "Expected a type!"); |
| 73 | ArgTypes.push_back(TyEl->getValueAsString("TypeVal")); |
Chris Lattner | 18faf5d | 2006-03-13 22:38:57 +0000 | [diff] [blame] | 74 | ArgTypeDefs.push_back(TyEl); |
Chris Lattner | f97a00e | 2006-03-09 22:05:04 +0000 | [diff] [blame] | 75 | } |
| 76 | if (ArgTypes.size() == 0) |
| 77 | throw "Intrinsic '"+DefName+"' needs at least a type for the ret value!"; |
Chris Lattner | 6448ee4 | 2006-03-09 22:30:49 +0000 | [diff] [blame] | 78 | |
| 79 | // Parse the intrinsic properties. |
| 80 | ListInit *PropList = R->getValueAsListInit("Properties"); |
| 81 | for (unsigned i = 0, e = PropList->getSize(); i != e; ++i) { |
| 82 | DefInit *DI = dynamic_cast<DefInit*>(PropList->getElement(i)); |
| 83 | assert(DI && "Invalid list type!"); |
| 84 | Record *Property = DI->getDef(); |
| 85 | assert(Property->isSubClassOf("IntrinsicProperty") && |
| 86 | "Expected a property!"); |
| 87 | |
| 88 | if (Property->getName() == "InstrNoMem") |
| 89 | ModRef = NoMem; |
| 90 | else if (Property->getName() == "InstrReadArgMem") |
| 91 | ModRef = ReadArgMem; |
| 92 | else if (Property->getName() == "IntrReadMem") |
| 93 | ModRef = ReadMem; |
| 94 | else if (Property->getName() == "InstrWriteArgMem") |
| 95 | ModRef = WriteArgMem; |
| 96 | else if (Property->getName() == "IntrWriteMem") |
| 97 | ModRef = WriteMem; |
| 98 | else |
| 99 | assert(0 && "Unknown property!"); |
| 100 | } |
Chris Lattner | 9e493cf | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | //===----------------------------------------------------------------------===// |
| 104 | // IntrinsicEmitter Implementation |
| 105 | //===----------------------------------------------------------------------===// |
| 106 | |
| 107 | void IntrinsicEmitter::run(std::ostream &OS) { |
| 108 | EmitSourceFileHeader("Intrinsic Function Source Fragment", OS); |
| 109 | |
| 110 | std::vector<CodeGenIntrinsic> Ints = LoadIntrinsics(Records); |
| 111 | |
| 112 | // Emit the enum information. |
| 113 | EmitEnumInfo(Ints, OS); |
Chris Lattner | fda6aff | 2006-03-15 01:55:21 +0000 | [diff] [blame] | 114 | |
| 115 | // Emit the intrinsic ID -> name table. |
| 116 | EmitIntrinsicToNameTable(Ints, OS); |
Chris Lattner | 9b843b2 | 2006-03-09 20:34:19 +0000 | [diff] [blame] | 117 | |
| 118 | // Emit the function name recognizer. |
| 119 | EmitFnNameRecognizer(Ints, OS); |
Chris Lattner | fda6aff | 2006-03-15 01:55:21 +0000 | [diff] [blame] | 120 | |
Chris Lattner | f97a00e | 2006-03-09 22:05:04 +0000 | [diff] [blame] | 121 | // Emit the intrinsic verifier. |
| 122 | EmitVerifier(Ints, OS); |
Chris Lattner | 6448ee4 | 2006-03-09 22:30:49 +0000 | [diff] [blame] | 123 | |
| 124 | // Emit mod/ref info for each function. |
| 125 | EmitModRefInfo(Ints, OS); |
Chris Lattner | 4e5f359 | 2006-03-09 22:37:52 +0000 | [diff] [blame] | 126 | |
Chris Lattner | 7056de3 | 2006-03-24 01:13:55 +0000 | [diff] [blame] | 127 | // Emit table of non-memory accessing intrinsics. |
| 128 | EmitNoMemoryInfo(Ints, OS); |
| 129 | |
| 130 | // Emit side effect info for each intrinsic. |
Chris Lattner | 4e5f359 | 2006-03-09 22:37:52 +0000 | [diff] [blame] | 131 | EmitSideEffectInfo(Ints, OS); |
Chris Lattner | 022f64f | 2006-03-13 23:08:44 +0000 | [diff] [blame] | 132 | |
| 133 | // Emit a list of intrinsics with corresponding GCC builtins. |
| 134 | EmitGCCBuiltinList(Ints, OS); |
Chris Lattner | 3f8b891 | 2006-03-15 01:33:26 +0000 | [diff] [blame] | 135 | |
| 136 | // Emit code to translate GCC builtins into LLVM intrinsics. |
| 137 | EmitIntrinsicToGCCBuiltinMap(Ints, OS); |
Chris Lattner | 9e493cf | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | void IntrinsicEmitter::EmitEnumInfo(const std::vector<CodeGenIntrinsic> &Ints, |
| 141 | std::ostream &OS) { |
Chris Lattner | 9b843b2 | 2006-03-09 20:34:19 +0000 | [diff] [blame] | 142 | OS << "// Enum values for Intrinsics.h\n"; |
Chris Lattner | 9e493cf | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 143 | OS << "#ifdef GET_INTRINSIC_ENUM_VALUES\n"; |
| 144 | for (unsigned i = 0, e = Ints.size(); i != e; ++i) { |
| 145 | OS << " " << Ints[i].EnumName; |
| 146 | OS << ((i != e-1) ? ", " : " "); |
| 147 | OS << std::string(40-Ints[i].EnumName.size(), ' ') |
| 148 | << "// " << Ints[i].Name << "\n"; |
| 149 | } |
| 150 | OS << "#endif\n\n"; |
| 151 | } |
Chris Lattner | 9b843b2 | 2006-03-09 20:34:19 +0000 | [diff] [blame] | 152 | |
| 153 | void IntrinsicEmitter:: |
| 154 | EmitFnNameRecognizer(const std::vector<CodeGenIntrinsic> &Ints, |
| 155 | std::ostream &OS) { |
| 156 | // Build a function name -> intrinsic name mapping. |
| 157 | std::map<std::string, std::string> IntMapping; |
| 158 | for (unsigned i = 0, e = Ints.size(); i != e; ++i) |
| 159 | IntMapping[Ints[i].Name] = Ints[i].EnumName; |
| 160 | |
| 161 | OS << "// Function name -> enum value recognizer code.\n"; |
| 162 | OS << "#ifdef GET_FUNCTION_RECOGNIZER\n"; |
| 163 | OS << " switch (Name[5]) {\n"; |
Chris Lattner | f97a00e | 2006-03-09 22:05:04 +0000 | [diff] [blame] | 164 | OS << " default: break;\n"; |
Chris Lattner | 9b843b2 | 2006-03-09 20:34:19 +0000 | [diff] [blame] | 165 | // Emit the intrinsics in sorted order. |
| 166 | char LastChar = 0; |
| 167 | for (std::map<std::string, std::string>::iterator I = IntMapping.begin(), |
| 168 | E = IntMapping.end(); I != E; ++I) { |
Chris Lattner | 9b843b2 | 2006-03-09 20:34:19 +0000 | [diff] [blame] | 169 | if (I->first[5] != LastChar) { |
| 170 | LastChar = I->first[5]; |
| 171 | OS << " case '" << LastChar << "':\n"; |
| 172 | } |
| 173 | |
| 174 | OS << " if (Name == \"" << I->first << "\") return Intrinsic::" |
| 175 | << I->second << ";\n"; |
| 176 | } |
| 177 | OS << " }\n"; |
Chris Lattner | f97a00e | 2006-03-09 22:05:04 +0000 | [diff] [blame] | 178 | OS << " // The 'llvm.' namespace is reserved!\n"; |
| 179 | OS << " assert(0 && \"Unknown LLVM intrinsic function!\");\n"; |
| 180 | OS << "#endif\n\n"; |
| 181 | } |
| 182 | |
Chris Lattner | fda6aff | 2006-03-15 01:55:21 +0000 | [diff] [blame] | 183 | void IntrinsicEmitter:: |
| 184 | EmitIntrinsicToNameTable(const std::vector<CodeGenIntrinsic> &Ints, |
| 185 | std::ostream &OS) { |
| 186 | std::vector<std::string> Names; |
| 187 | for (unsigned i = 0, e = Ints.size(); i != e; ++i) |
| 188 | Names.push_back(Ints[i].Name); |
| 189 | std::sort(Names.begin(), Names.end()); |
| 190 | |
| 191 | OS << "// Intrinsic ID to name table\n"; |
| 192 | OS << "#ifdef GET_INTRINSIC_NAME_TABLE\n"; |
| 193 | OS << " // Note that entry #0 is the invalid intrinsic!\n"; |
| 194 | for (unsigned i = 0, e = Names.size(); i != e; ++i) |
| 195 | OS << " \"" << Names[i] << "\",\n"; |
| 196 | OS << "#endif\n\n"; |
| 197 | } |
| 198 | |
Chris Lattner | 18faf5d | 2006-03-13 22:38:57 +0000 | [diff] [blame] | 199 | static void EmitTypeVerify(std::ostream &OS, const std::string &Val, |
| 200 | Record *ArgType) { |
| 201 | OS << " Assert1(" << Val << "->getTypeID() == " |
| 202 | << ArgType->getValueAsString("TypeVal") << ",\n" |
| 203 | << " \"Illegal intrinsic type!\", IF);\n"; |
| 204 | |
| 205 | // If this is a packed type, check that the subtype and size are correct. |
| 206 | if (ArgType->isSubClassOf("LLVMPackedType")) { |
| 207 | Record *SubType = ArgType->getValueAsDef("ElTy"); |
| 208 | OS << " Assert1(cast<PackedType>(" << Val |
| 209 | << ")->getElementType()->getTypeID() == " |
| 210 | << SubType->getValueAsString("TypeVal") << ",\n" |
| 211 | << " \"Illegal intrinsic type!\", IF);\n"; |
| 212 | OS << " Assert1(cast<PackedType>(" << Val << ")->getNumElements() == " |
| 213 | << ArgType->getValueAsInt("NumElts") << ",\n" |
| 214 | << " \"Illegal intrinsic type!\", IF);\n"; |
| 215 | } |
| 216 | } |
| 217 | |
Chris Lattner | f97a00e | 2006-03-09 22:05:04 +0000 | [diff] [blame] | 218 | void IntrinsicEmitter::EmitVerifier(const std::vector<CodeGenIntrinsic> &Ints, |
| 219 | std::ostream &OS) { |
| 220 | OS << "// Verifier::visitIntrinsicFunctionCall code.\n"; |
| 221 | OS << "#ifdef GET_INTRINSIC_VERIFIER\n"; |
| 222 | OS << " switch (ID) {\n"; |
| 223 | OS << " default: assert(0 && \"Invalid intrinsic!\");\n"; |
| 224 | for (unsigned i = 0, e = Ints.size(); i != e; ++i) { |
| 225 | OS << " case Intrinsic::" << Ints[i].EnumName << ":\t\t// " |
| 226 | << Ints[i].Name << "\n"; |
| 227 | OS << " Assert1(FTy->getNumParams() == " << Ints[i].ArgTypes.size()-1 |
| 228 | << ",\n" |
| 229 | << " \"Illegal # arguments for intrinsic function!\", IF);\n"; |
Chris Lattner | 18faf5d | 2006-03-13 22:38:57 +0000 | [diff] [blame] | 230 | EmitTypeVerify(OS, "FTy->getReturnType()", Ints[i].ArgTypeDefs[0]); |
Chris Lattner | f97a00e | 2006-03-09 22:05:04 +0000 | [diff] [blame] | 231 | for (unsigned j = 1; j != Ints[i].ArgTypes.size(); ++j) |
Chris Lattner | 18faf5d | 2006-03-13 22:38:57 +0000 | [diff] [blame] | 232 | EmitTypeVerify(OS, "FTy->getParamType(" + utostr(j-1) + ")", |
| 233 | Ints[i].ArgTypeDefs[j]); |
Chris Lattner | f97a00e | 2006-03-09 22:05:04 +0000 | [diff] [blame] | 234 | OS << " break;\n"; |
| 235 | } |
| 236 | OS << " }\n"; |
| 237 | OS << "#endif\n\n"; |
Chris Lattner | 9b843b2 | 2006-03-09 20:34:19 +0000 | [diff] [blame] | 238 | } |
| 239 | |
Chris Lattner | 6448ee4 | 2006-03-09 22:30:49 +0000 | [diff] [blame] | 240 | void IntrinsicEmitter::EmitModRefInfo(const std::vector<CodeGenIntrinsic> &Ints, |
| 241 | std::ostream &OS) { |
| 242 | OS << "// BasicAliasAnalysis code.\n"; |
| 243 | OS << "#ifdef GET_MODREF_BEHAVIOR\n"; |
| 244 | for (unsigned i = 0, e = Ints.size(); i != e; ++i) { |
| 245 | switch (Ints[i].ModRef) { |
| 246 | default: break; |
| 247 | case CodeGenIntrinsic::NoMem: |
| 248 | OS << " NoMemoryTable.push_back(\"" << Ints[i].Name << "\");\n"; |
| 249 | break; |
| 250 | case CodeGenIntrinsic::ReadArgMem: |
| 251 | case CodeGenIntrinsic::ReadMem: |
| 252 | OS << " OnlyReadsMemoryTable.push_back(\"" << Ints[i].Name << "\");\n"; |
| 253 | break; |
| 254 | } |
| 255 | } |
| 256 | OS << "#endif\n\n"; |
| 257 | } |
Chris Lattner | 4e5f359 | 2006-03-09 22:37:52 +0000 | [diff] [blame] | 258 | |
| 259 | void IntrinsicEmitter:: |
Chris Lattner | 7056de3 | 2006-03-24 01:13:55 +0000 | [diff] [blame] | 260 | EmitNoMemoryInfo(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS) { |
| 261 | OS << "// SelectionDAGIsel code.\n"; |
| 262 | OS << "#ifdef GET_NO_MEMORY_INTRINSICS\n"; |
| 263 | OS << " switch (IntrinsicID) {\n"; |
| 264 | OS << " default: break;\n"; |
| 265 | for (unsigned i = 0, e = Ints.size(); i != e; ++i) { |
| 266 | switch (Ints[i].ModRef) { |
| 267 | default: break; |
| 268 | case CodeGenIntrinsic::NoMem: |
| 269 | OS << " case Intrinsic::" << Ints[i].EnumName << ":\n"; |
| 270 | break; |
| 271 | } |
| 272 | } |
| 273 | OS << " return true; // These intrinsics have no side effects.\n"; |
| 274 | OS << " }\n"; |
| 275 | OS << "#endif\n\n"; |
| 276 | } |
| 277 | |
| 278 | void IntrinsicEmitter:: |
Chris Lattner | 4e5f359 | 2006-03-09 22:37:52 +0000 | [diff] [blame] | 279 | EmitSideEffectInfo(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS){ |
| 280 | OS << "// isInstructionTriviallyDead code.\n"; |
| 281 | OS << "#ifdef GET_SIDE_EFFECT_INFO\n"; |
| 282 | OS << " switch (F->getIntrinsicID()) {\n"; |
| 283 | OS << " default: break;\n"; |
| 284 | for (unsigned i = 0, e = Ints.size(); i != e; ++i) { |
| 285 | switch (Ints[i].ModRef) { |
Chris Lattner | 022f64f | 2006-03-13 23:08:44 +0000 | [diff] [blame] | 286 | default: break; |
| 287 | case CodeGenIntrinsic::NoMem: |
| 288 | case CodeGenIntrinsic::ReadArgMem: |
| 289 | case CodeGenIntrinsic::ReadMem: |
| 290 | OS << " case Intrinsic::" << Ints[i].EnumName << ":\n"; |
| 291 | break; |
Chris Lattner | 4e5f359 | 2006-03-09 22:37:52 +0000 | [diff] [blame] | 292 | } |
| 293 | } |
| 294 | OS << " return true; // These intrinsics have no side effects.\n"; |
| 295 | OS << " }\n"; |
| 296 | OS << "#endif\n\n"; |
Chris Lattner | 4e5f359 | 2006-03-09 22:37:52 +0000 | [diff] [blame] | 297 | } |
Chris Lattner | 022f64f | 2006-03-13 23:08:44 +0000 | [diff] [blame] | 298 | |
| 299 | void IntrinsicEmitter:: |
| 300 | EmitGCCBuiltinList(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS){ |
| 301 | OS << "// Get the GCC builtin that corresponds to an LLVM intrinsic.\n"; |
| 302 | OS << "#ifdef GET_GCC_BUILTIN_NAME\n"; |
| 303 | OS << " switch (F->getIntrinsicID()) {\n"; |
| 304 | OS << " default: BuiltinName = \"\"; break;\n"; |
| 305 | for (unsigned i = 0, e = Ints.size(); i != e; ++i) { |
| 306 | if (!Ints[i].GCCBuiltinName.empty()) { |
| 307 | OS << " case Intrinsic::" << Ints[i].EnumName << ": BuiltinName = \"" |
| 308 | << Ints[i].GCCBuiltinName << "\"; break;\n"; |
| 309 | } |
| 310 | } |
| 311 | OS << " }\n"; |
| 312 | OS << "#endif\n\n"; |
Reid Spencer | 767a25b | 2006-03-14 05:59:52 +0000 | [diff] [blame] | 313 | } |
Chris Lattner | 3f8b891 | 2006-03-15 01:33:26 +0000 | [diff] [blame] | 314 | |
| 315 | void IntrinsicEmitter:: |
| 316 | EmitIntrinsicToGCCBuiltinMap(const std::vector<CodeGenIntrinsic> &Ints, |
| 317 | std::ostream &OS) { |
| 318 | typedef std::map<std::pair<std::string, std::string>, std::string> BIMTy; |
| 319 | BIMTy BuiltinMap; |
| 320 | for (unsigned i = 0, e = Ints.size(); i != e; ++i) { |
| 321 | if (!Ints[i].GCCBuiltinName.empty()) { |
| 322 | std::pair<std::string, std::string> Key(Ints[i].GCCBuiltinName, |
| 323 | Ints[i].TargetPrefix); |
| 324 | if (!BuiltinMap.insert(std::make_pair(Key, Ints[i].EnumName)).second) |
| 325 | throw "Intrinsic '" + Ints[i].TheDef->getName() + |
| 326 | "': duplicate GCC builtin name!"; |
| 327 | } |
| 328 | } |
| 329 | |
| 330 | OS << "// Get the LLVM intrinsic that corresponds to a GCC builtin.\n"; |
| 331 | OS << "// This is used by the C front-end. The GCC builtin name is passed\n"; |
| 332 | OS << "// in as BuiltinName, and a target prefix (e.g. 'ppc') is passed\n"; |
| 333 | OS << "// in as TargetPrefix. The result is assigned to 'IntrinsicID'.\n"; |
| 334 | OS << "#ifdef GET_LLVM_INTRINSIC_FOR_GCC_BUILTIN\n"; |
| 335 | OS << " if (0);\n"; |
| 336 | // Note: this could emit significantly better code if we cared. |
| 337 | for (BIMTy::iterator I = BuiltinMap.begin(), E = BuiltinMap.end();I != E;++I){ |
| 338 | OS << " else if ("; |
| 339 | if (!I->first.second.empty()) { |
| 340 | // Emit this as a strcmp, so it can be constant folded by the FE. |
| 341 | OS << "!strcmp(TargetPrefix, \"" << I->first.second << "\") &&\n" |
| 342 | << " "; |
| 343 | } |
| 344 | OS << "!strcmp(BuiltinName, \"" << I->first.first << "\"))\n"; |
Chris Lattner | ad45b00 | 2006-03-15 02:05:38 +0000 | [diff] [blame] | 345 | OS << " IntrinsicID = Intrinsic::" << I->second << ";\n"; |
Chris Lattner | 3f8b891 | 2006-03-15 01:33:26 +0000 | [diff] [blame] | 346 | } |
| 347 | OS << " else\n"; |
| 348 | OS << " IntrinsicID = Intrinsic::not_intrinsic;\n"; |
| 349 | OS << "#endif\n\n"; |
| 350 | } |