the lengths of the strings are known, just use memcmp
[oota-llvm.git] / utils / TableGen / IntrinsicEmitter.cpp
index 214f3104905bdb8654e0914df4255303c423420e..6247da2af5e6b135ea9cf406935e28dd9e0ec12a 100644 (file)
@@ -81,17 +81,19 @@ EmitFnNameRecognizer(const std::vector<CodeGenIntrinsic> &Ints,
   OS << "// Function name -> enum value recognizer code.\n";
   OS << "#ifdef GET_FUNCTION_RECOGNIZER\n";
   OS << "  switch (Name[5]) {\n";
-  OS << "  default: break;\n";
+  OS << "  default:\n";
   // Emit the intrinsics in sorted order.
   char LastChar = 0;
   for (std::map<std::string, std::string>::iterator I = IntMapping.begin(),
        E = IntMapping.end(); I != E; ++I) {
     if (I->first[5] != LastChar) {
       LastChar = I->first[5];
+      OS << "    break;\n";
       OS << "  case '" << LastChar << "':\n";
     }
     
-    OS << "    if (Name == \"" << I->first << "\") return Intrinsic::"
+    OS << "    if (Len == " << I->first.size()
+       << " && !memcmp(Name, \"" << I->first << "\", Len)) return Intrinsic::"
        << I->second << ";\n";
   }
   OS << "  }\n";
@@ -119,7 +121,7 @@ static bool EmitTypeVerify(std::ostream &OS, Record *ArgType) {
   if (ArgType->isSubClassOf("LLVMIntegerType"))
     OS << ArgType->getValueAsInt("Width") << ", ";
 
-  // If this is a packed type, check that the subtype and size are correct.
+  // If this is a vector type, check that the subtype and size are correct.
   else if (ArgType->isSubClassOf("LLVMVectorType")) {
     EmitTypeVerify(OS, ArgType->getValueAsDef("ElTy"));
     OS << ArgType->getValueAsInt("NumElts") << ", ";