diff --git a/utils/TableGen/IntrinsicEmitter.cpp b/utils/TableGen/IntrinsicEmitter.cpp index 278a1eefb86..0ef93123ed7 100644 --- a/utils/TableGen/IntrinsicEmitter.cpp +++ b/utils/TableGen/IntrinsicEmitter.cpp @@ -109,10 +109,13 @@ void IntrinsicEmitter::run(std::ostream &OS) { // Emit the enum information. EmitEnumInfo(Ints, OS); + + // Emit the intrinsic ID -> name table. + EmitIntrinsicToNameTable(Ints, OS); // Emit the function name recognizer. EmitFnNameRecognizer(Ints, OS); - + // Emit the intrinsic verifier. EmitVerifier(Ints, OS); @@ -158,9 +161,6 @@ EmitFnNameRecognizer(const std::vector &Ints, char LastChar = 0; for (std::map::iterator I = IntMapping.begin(), E = IntMapping.end(); I != E; ++I) { - assert(I->first.size() > 5 && std::string(I->first.begin(), - I->first.begin()+5) == "llvm." && - "Invalid intrinsic name!"); if (I->first[5] != LastChar) { LastChar = I->first[5]; OS << " case '" << LastChar << "':\n"; @@ -175,6 +175,22 @@ EmitFnNameRecognizer(const std::vector &Ints, OS << "#endif\n\n"; } +void IntrinsicEmitter:: +EmitIntrinsicToNameTable(const std::vector &Ints, + std::ostream &OS) { + std::vector Names; + for (unsigned i = 0, e = Ints.size(); i != e; ++i) + Names.push_back(Ints[i].Name); + std::sort(Names.begin(), Names.end()); + + OS << "// Intrinsic ID to name table\n"; + OS << "#ifdef GET_INTRINSIC_NAME_TABLE\n"; + OS << " // Note that entry #0 is the invalid intrinsic!\n"; + for (unsigned i = 0, e = Names.size(); i != e; ++i) + OS << " \"" << Names[i] << "\",\n"; + OS << "#endif\n\n"; +} + static void EmitTypeVerify(std::ostream &OS, const std::string &Val, Record *ArgType) { OS << " Assert1(" << Val << "->getTypeID() == " diff --git a/utils/TableGen/IntrinsicEmitter.h b/utils/TableGen/IntrinsicEmitter.h index 7ab1ddfec73..fa7cf7ca0f6 100644 --- a/utils/TableGen/IntrinsicEmitter.h +++ b/utils/TableGen/IntrinsicEmitter.h @@ -31,6 +31,8 @@ namespace llvm { void EmitFnNameRecognizer(const std::vector &Ints, std::ostream &OS); + void EmitIntrinsicToNameTable(const std::vector &Ints, + std::ostream &OS); void EmitVerifier(const std::vector &Ints, std::ostream &OS); void EmitModRefInfo(const std::vector &Ints,