[llvm-commits] CVS: llvm/utils/TableGen/CodeGenIntrinsics.h IntrinsicEmitter.cpp IntrinsicEmitter.h
Chris Lattner
lattner at cs.uiuc.edu
Mon Mar 13 15:08:56 PST 2006
Changes in directory llvm/utils/TableGen:
CodeGenIntrinsics.h updated: 1.4 -> 1.5
IntrinsicEmitter.cpp updated: 1.7 -> 1.8
IntrinsicEmitter.h updated: 1.5 -> 1.6
---
Log message:
emit a mapping from LLVM intrinsic -> GCC builtins.
---
Diffs of the changes: (+30 -8)
CodeGenIntrinsics.h | 3 ++-
IntrinsicEmitter.cpp | 33 ++++++++++++++++++++++++++-------
IntrinsicEmitter.h | 2 ++
3 files changed, 30 insertions(+), 8 deletions(-)
Index: llvm/utils/TableGen/CodeGenIntrinsics.h
diff -u llvm/utils/TableGen/CodeGenIntrinsics.h:1.4 llvm/utils/TableGen/CodeGenIntrinsics.h:1.5
--- llvm/utils/TableGen/CodeGenIntrinsics.h:1.4 Mon Mar 13 16:38:57 2006
+++ llvm/utils/TableGen/CodeGenIntrinsics.h Mon Mar 13 17:08:44 2006
@@ -25,7 +25,8 @@
Record *TheDef; // The actual record defining this instruction.
std::string Name; // The name of the LLVM function "llvm.bswap.i32"
std::string EnumName; // The name of the enum "bswap_i32"
-
+ std::string GCCBuiltinName;// Name of the corresponding GCC builtin, or "".
+
/// ArgTypes - The type primitive enum value for the return value and all
/// of the arguments. These are things like Type::UIntTyID.
std::vector<std::string> ArgTypes;
Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
diff -u llvm/utils/TableGen/IntrinsicEmitter.cpp:1.7 llvm/utils/TableGen/IntrinsicEmitter.cpp:1.8
--- llvm/utils/TableGen/IntrinsicEmitter.cpp:1.7 Mon Mar 13 16:38:57 2006
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp Mon Mar 13 17:08:44 2006
@@ -33,6 +33,7 @@
std::string(DefName.begin(), DefName.begin()+4) != "int_")
throw "Intrinsic '" + DefName + "' does not start with 'int_'!";
EnumName = std::string(DefName.begin()+4, DefName.end());
+ GCCBuiltinName = R->getValueAsString("GCCBuiltinName");
Name = R->getValueAsString("LLVMName");
if (Name == "") {
@@ -105,6 +106,9 @@
// Emit side effect info for each function.
EmitSideEffectInfo(Ints, OS);
+
+ // Emit a list of intrinsics with corresponding GCC builtins.
+ EmitGCCBuiltinList(Ints, OS);
}
void IntrinsicEmitter::EmitEnumInfo(const std::vector<CodeGenIntrinsic> &Ints,
@@ -221,16 +225,31 @@
OS << " default: break;\n";
for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
switch (Ints[i].ModRef) {
- default: break;
- case CodeGenIntrinsic::NoMem:
- case CodeGenIntrinsic::ReadArgMem:
- case CodeGenIntrinsic::ReadMem:
- OS << " case Intrinsic::" << Ints[i].EnumName << ":\n";
- break;
+ default: break;
+ case CodeGenIntrinsic::NoMem:
+ case CodeGenIntrinsic::ReadArgMem:
+ case CodeGenIntrinsic::ReadMem:
+ OS << " case Intrinsic::" << Ints[i].EnumName << ":\n";
+ break;
}
}
OS << " return true; // These intrinsics have no side effects.\n";
OS << " }\n";
OS << "#endif\n\n";
-
}
+
+void IntrinsicEmitter::
+EmitGCCBuiltinList(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS){
+ OS << "// Get the GCC builtin that corresponds to an LLVM intrinsic.\n";
+ OS << "#ifdef GET_GCC_BUILTIN_NAME\n";
+ OS << " switch (F->getIntrinsicID()) {\n";
+ OS << " default: BuiltinName = \"\"; break;\n";
+ for (unsigned i = 0, e = Ints.size(); i != e; ++i) {
+ if (!Ints[i].GCCBuiltinName.empty()) {
+ OS << " case Intrinsic::" << Ints[i].EnumName << ": BuiltinName = \""
+ << Ints[i].GCCBuiltinName << "\"; break;\n";
+ }
+ }
+ OS << " }\n";
+ OS << "#endif\n\n";
+}
\ No newline at end of file
Index: llvm/utils/TableGen/IntrinsicEmitter.h
diff -u llvm/utils/TableGen/IntrinsicEmitter.h:1.5 llvm/utils/TableGen/IntrinsicEmitter.h:1.6
--- llvm/utils/TableGen/IntrinsicEmitter.h:1.5 Thu Mar 9 16:37:52 2006
+++ llvm/utils/TableGen/IntrinsicEmitter.h Mon Mar 13 17:08:44 2006
@@ -37,6 +37,8 @@
std::ostream &OS);
void EmitSideEffectInfo(const std::vector<CodeGenIntrinsic> &Ints,
std::ostream &OS);
+ void EmitGCCBuiltinList(const std::vector<CodeGenIntrinsic> &Ints,
+ std::ostream &OS);
};
} // End llvm namespace
More information about the llvm-commits
mailing list