diff options
author | Mon P Wang <wangmp@apple.com> | 2009-02-24 23:17:49 +0000 |
---|---|---|
committer | Mon P Wang <wangmp@apple.com> | 2009-02-24 23:17:49 +0000 |
commit | b40249316122f33d68a9f230115611828ce48bfc (patch) | |
tree | ff43902b8799b813ebf5e28db6e794bf73f54e88 | |
parent | ab19ecad22e81649b09a63c7433a3baa5893bc22 (diff) | |
download | bcm5719-llvm-b40249316122f33d68a9f230115611828ce48bfc.tar.gz bcm5719-llvm-b40249316122f33d68a9f230115611828ce48bfc.zip |
Added support to have TableGen provide information if an intrinsic (core
or target) can be overloaded or not.
llvm-svn: 65404
-rw-r--r-- | llvm/include/llvm/Intrinsics.h | 4 | ||||
-rw-r--r-- | llvm/include/llvm/Target/TargetIntrinsicInfo.h | 15 | ||||
-rw-r--r-- | llvm/lib/VMCore/Function.cpp | 10 | ||||
-rw-r--r-- | llvm/utils/TableGen/IntrinsicEmitter.cpp | 22 | ||||
-rw-r--r-- | llvm/utils/TableGen/IntrinsicEmitter.h | 2 |
5 files changed, 51 insertions, 2 deletions
diff --git a/llvm/include/llvm/Intrinsics.h b/llvm/include/llvm/Intrinsics.h index 243359953bc..227eb5a5b70 100644 --- a/llvm/include/llvm/Intrinsics.h +++ b/llvm/include/llvm/Intrinsics.h @@ -49,6 +49,10 @@ namespace Intrinsic { /// const FunctionType *getType(ID id, const Type **Tys = 0, unsigned numTys = 0); + /// Intrinsic::isOverloaded(ID) - Returns true if the intrinsic can be + /// overloaded. + bool isOverloaded(ID id); + /// Intrinsic::getAttributes(ID) - Return the attributes for an intrinsic. /// AttrListPtr getAttributes(ID id); diff --git a/llvm/include/llvm/Target/TargetIntrinsicInfo.h b/llvm/include/llvm/Target/TargetIntrinsicInfo.h index 323e29afee7..c14275f52a4 100644 --- a/llvm/include/llvm/Target/TargetIntrinsicInfo.h +++ b/llvm/include/llvm/Target/TargetIntrinsicInfo.h @@ -18,6 +18,7 @@ namespace llvm { class Function; class Module; +class Type; //--------------------------------------------------------------------------- /// @@ -39,7 +40,19 @@ public: virtual Function *getDeclaration(Module *M, const char *BuiltinName) const { return 0; } - + + // Returns the Function declaration for intrinsic BuiltinName. If the + // intrinsic can be overloaded, uses Tys to return the correct function. + virtual Function *getDeclaration(Module *M, const char *BuiltinName, + const Type **Tys, unsigned numTys) const { + return 0; + } + + // Returns true if the Builtin can be overloaded. + virtual bool isOverloaded(Module *M, const char *BuiltinName) const { + return false; + } + virtual unsigned getIntrinsicID(Function *F) const { return 0; } }; diff --git a/llvm/lib/VMCore/Function.cpp b/llvm/lib/VMCore/Function.cpp index bc3b611820c..cff4457a418 100644 --- a/llvm/lib/VMCore/Function.cpp +++ b/llvm/lib/VMCore/Function.cpp @@ -356,6 +356,16 @@ const FunctionType *Intrinsic::getType(ID id, const Type **Tys, return FunctionType::get(ResultTy, ArgTys, IsVarArg); } +bool Intrinsic::isOverloaded(ID id) { + const bool OTable[] = { + false, +#define GET_INTRINSIC_OVERLOAD_TABLE +#include "llvm/Intrinsics.gen" +#undef GET_INTRINSIC_OVERLOAD_TABLE + }; + return OTable[id]; +} + /// This defines the "Intrinsic::getAttributes(ID id)" method. #define GET_INTRINSIC_ATTRIBUTES #include "llvm/Intrinsics.gen" diff --git a/llvm/utils/TableGen/IntrinsicEmitter.cpp b/llvm/utils/TableGen/IntrinsicEmitter.cpp index 37fc6702ede..8800a778164 100644 --- a/llvm/utils/TableGen/IntrinsicEmitter.cpp +++ b/llvm/utils/TableGen/IntrinsicEmitter.cpp @@ -35,7 +35,10 @@ void IntrinsicEmitter::run(std::ostream &OS) { // Emit the intrinsic ID -> name table. EmitIntrinsicToNameTable(Ints, OS); - + + // Emit the intrinsic ID -> overload table. + EmitIntrinsicToOverloadTable(Ints, OS); + // Emit the function name recognizer. EmitFnNameRecognizer(Ints, OS); @@ -120,6 +123,23 @@ EmitIntrinsicToNameTable(const std::vector<CodeGenIntrinsic> &Ints, OS << "#endif\n\n"; } +void IntrinsicEmitter:: +EmitIntrinsicToOverloadTable(const std::vector<CodeGenIntrinsic> &Ints, + std::ostream &OS) { + OS << "// Intrinsic ID to overload table\n"; + OS << "#ifdef GET_INTRINSIC_OVERLOAD_TABLE\n"; + OS << " // Note that entry #0 is the invalid intrinsic!\n"; + for (unsigned i = 0, e = Ints.size(); i != e; ++i) { + OS << " "; + if (Ints[i].isOverloaded) + OS << "true"; + else + OS << "false"; + OS << ",\n"; + } + OS << "#endif\n\n"; +} + static void EmitTypeForValueType(std::ostream &OS, MVT::SimpleValueType VT) { if (MVT(VT).isInteger()) { unsigned BitWidth = MVT(VT).getSizeInBits(); diff --git a/llvm/utils/TableGen/IntrinsicEmitter.h b/llvm/utils/TableGen/IntrinsicEmitter.h index 4a169ffd647..1619d022429 100644 --- a/llvm/utils/TableGen/IntrinsicEmitter.h +++ b/llvm/utils/TableGen/IntrinsicEmitter.h @@ -36,6 +36,8 @@ namespace llvm { std::ostream &OS); void EmitIntrinsicToNameTable(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS); + void EmitIntrinsicToOverloadTable(const std::vector<CodeGenIntrinsic> &Ints, + std::ostream &OS); void EmitVerifier(const std::vector<CodeGenIntrinsic> &Ints, std::ostream &OS); void EmitGenerator(const std::vector<CodeGenIntrinsic> &Ints, |