diff options
author | Chris Lattner <sabre@nondot.org> | 2006-03-13 23:08:44 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2006-03-13 23:08:44 +0000 |
commit | 022f64fbbc4669623e79b805379266fed519017d (patch) | |
tree | d3ab1d2f6f112793e7c9ce71aec26895650af82e | |
parent | 18faf5d9f7f89130b9e3304965b81e1c70ebb75c (diff) | |
download | external_llvm-022f64fbbc4669623e79b805379266fed519017d.zip external_llvm-022f64fbbc4669623e79b805379266fed519017d.tar.gz external_llvm-022f64fbbc4669623e79b805379266fed519017d.tar.bz2 |
emit a mapping from LLVM intrinsic -> GCC builtins.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@26736 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r-- | utils/TableGen/CodeGenIntrinsics.h | 3 | ||||
-rw-r--r-- | utils/TableGen/IntrinsicEmitter.cpp | 33 | ||||
-rw-r--r-- | utils/TableGen/IntrinsicEmitter.h | 2 |
3 files changed, 30 insertions, 8 deletions
diff --git a/utils/TableGen/CodeGenIntrinsics.h b/utils/TableGen/CodeGenIntrinsics.h index bca52bc..0c39d8e 100644 --- a/utils/TableGen/CodeGenIntrinsics.h +++ b/utils/TableGen/CodeGenIntrinsics.h @@ -25,7 +25,8 @@ namespace llvm { 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; diff --git a/utils/TableGen/IntrinsicEmitter.cpp b/utils/TableGen/IntrinsicEmitter.cpp index 9396bdf..074a8db 100644 --- a/utils/TableGen/IntrinsicEmitter.cpp +++ b/utils/TableGen/IntrinsicEmitter.cpp @@ -33,6 +33,7 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R) { 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 @@ void IntrinsicEmitter::run(std::ostream &OS) { // 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 @@ EmitSideEffectInfo(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS){ 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 diff --git a/utils/TableGen/IntrinsicEmitter.h b/utils/TableGen/IntrinsicEmitter.h index a8e1ffa..f410b53 100644 --- a/utils/TableGen/IntrinsicEmitter.h +++ b/utils/TableGen/IntrinsicEmitter.h @@ -37,6 +37,8 @@ namespace llvm { 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 |