From fda6affb95e9f68278cb5cf75dc3fd3406978255 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Wed, 15 Mar 2006 01:55:21 +0000 Subject: [PATCH] Autogenerate a table of intrinsic names, so we can map from intrinsic ID to LLVM intrinsic function name. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26771 91177308-0d34-0410-b5e6-96231b3b80d8 --- utils/TableGen/IntrinsicEmitter.cpp | 24 ++++++++++++++++++++---- utils/TableGen/IntrinsicEmitter.h | 2 ++ 2 files changed, 22 insertions(+), 4 deletions(-) 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, -- 2.34.1