[llvm-commits] CVS: llvm/utils/TableGen/IntrinsicEmitter.cpp IntrinsicEmitter.h
Chris Lattner
lattner at cs.uiuc.edu
Tue Mar 14 17:55:33 PST 2006
Changes in directory llvm/utils/TableGen:
IntrinsicEmitter.cpp updated: 1.10 -> 1.11
IntrinsicEmitter.h updated: 1.7 -> 1.8
---
Log message:
Autogenerate a table of intrinsic names, so we can map from intrinsic ID to
LLVM intrinsic function name.
---
Diffs of the changes: (+22 -4)
IntrinsicEmitter.cpp | 24 ++++++++++++++++++++----
IntrinsicEmitter.h | 2 ++
2 files changed, 22 insertions(+), 4 deletions(-)
Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
diff -u llvm/utils/TableGen/IntrinsicEmitter.cpp:1.10 llvm/utils/TableGen/IntrinsicEmitter.cpp:1.11
--- llvm/utils/TableGen/IntrinsicEmitter.cpp:1.10 Tue Mar 14 19:33:26 2006
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp Tue Mar 14 19:55:21 2006
@@ -109,10 +109,13 @@
// 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 @@
char LastChar = 0;
for (std::map<std::string, std::string>::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 @@
OS << "#endif\n\n";
}
+void IntrinsicEmitter::
+EmitIntrinsicToNameTable(const std::vector<CodeGenIntrinsic> &Ints,
+ std::ostream &OS) {
+ std::vector<std::string> 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() == "
Index: llvm/utils/TableGen/IntrinsicEmitter.h
diff -u llvm/utils/TableGen/IntrinsicEmitter.h:1.7 llvm/utils/TableGen/IntrinsicEmitter.h:1.8
--- llvm/utils/TableGen/IntrinsicEmitter.h:1.7 Tue Mar 14 19:33:26 2006
+++ llvm/utils/TableGen/IntrinsicEmitter.h Tue Mar 14 19:55:21 2006
@@ -31,6 +31,8 @@
void EmitFnNameRecognizer(const std::vector<CodeGenIntrinsic> &Ints,
std::ostream &OS);
+ void EmitIntrinsicToNameTable(const std::vector<CodeGenIntrinsic> &Ints,
+ std::ostream &OS);
void EmitVerifier(const std::vector<CodeGenIntrinsic> &Ints,
std::ostream &OS);
void EmitModRefInfo(const std::vector<CodeGenIntrinsic> &Ints,
More information about the llvm-commits
mailing list