X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTarget%2FBlackfin%2FBlackfinIntrinsicInfo.cpp;h=34a8d3809ea23c0648738e3ae868c651aa4b0a72;hb=bb811a244567aa8a1522203f15588f4d001b7353;hp=544dc6824719920fd36f5beba5fd3518e543ef9e;hpb=6ad8c84d7023d639eda38105625adda060ef045c;p=oota-llvm.git diff --git a/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp b/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp index 544dc682471..34a8d3809ea 100644 --- a/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp +++ b/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp @@ -12,7 +12,11 @@ //===----------------------------------------------------------------------===// #include "BlackfinIntrinsicInfo.h" +#include "llvm/DerivedTypes.h" +#include "llvm/Function.h" #include "llvm/Intrinsics.h" +#include "llvm/Module.h" +#include "llvm/Type.h" #include "llvm/Support/raw_ostream.h" #include @@ -30,24 +34,71 @@ namespace bfinIntrinsic { } -const char *BlackfinIntrinsicInfo::getName(unsigned IntrID) const { +std::string BlackfinIntrinsicInfo::getName(unsigned IntrID, const Type **Tys, + unsigned numTys) const { static const char *const names[] = { #define GET_INTRINSIC_NAME_TABLE #include "BlackfinGenIntrinsics.inc" #undef GET_INTRINSIC_NAME_TABLE }; + assert(!isOverloaded(IntrID) && "Blackfin intrinsics are not overloaded"); if (IntrID < Intrinsic::num_intrinsics) return 0; assert(IntrID < bfinIntrinsic::num_bfin_intrinsics && "Invalid intrinsic ID"); - return names[IntrID - Intrinsic::num_intrinsics]; + std::string Result(names[IntrID - Intrinsic::num_intrinsics]); + return Result; } unsigned BlackfinIntrinsicInfo::lookupName(const char *Name, unsigned Len) const { + if (Len < 5 || Name[4] != '.' || Name[0] != 'l' || Name[1] != 'l' + || Name[2] != 'v' || Name[3] != 'm') + return 0; // All intrinsics start with 'llvm.' + #define GET_FUNCTION_RECOGNIZER #include "BlackfinGenIntrinsics.inc" #undef GET_FUNCTION_RECOGNIZER return 0; } + +bool BlackfinIntrinsicInfo::isOverloaded(unsigned IntrID) const { + // Overload Table + const bool OTable[] = { +#define GET_INTRINSIC_OVERLOAD_TABLE +#include "BlackfinGenIntrinsics.inc" +#undef GET_INTRINSIC_OVERLOAD_TABLE + }; + if (IntrID == 0) + return false; + else + return OTable[IntrID - Intrinsic::num_intrinsics]; +} + +/// This defines the "getAttributes(ID id)" method. +#define GET_INTRINSIC_ATTRIBUTES +#include "BlackfinGenIntrinsics.inc" +#undef GET_INTRINSIC_ATTRIBUTES + +static const FunctionType *getType(LLVMContext &Context, unsigned id) { + const Type *ResultTy = NULL; + std::vector ArgTys; + bool IsVarArg = false; + +#define GET_INTRINSIC_GENERATOR +#include "BlackfinGenIntrinsics.inc" +#undef GET_INTRINSIC_GENERATOR + + return FunctionType::get(ResultTy, ArgTys, IsVarArg); +} + +Function *BlackfinIntrinsicInfo::getDeclaration(Module *M, unsigned IntrID, + const Type **Tys, + unsigned numTy) const { + assert(!isOverloaded(IntrID) && "Blackfin intrinsics are not overloaded"); + AttrListPtr AList = getAttributes((bfinIntrinsic::ID) IntrID); + return cast(M->getOrInsertFunction(getName(IntrID), + getType(M->getContext(), IntrID), + AList)); +}