[llvm-branch-commits] [llvm-branch] r86902 - in /llvm/branches/Apple/Leela-M1: include/llvm/Target/TargetIntrinsicInfo.h lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp lib/Target/Blackfin/BlackfinIntrinsicInfo.h

Bill Wendling isanbard at gmail.com
Wed Nov 11 15:54:14 PST 2009


Author: void
Date: Wed Nov 11 17:54:13 2009
New Revision: 86902

URL: http://llvm.org/viewvc/llvm-project?rev=86902&view=rev
Log:
$ svn merge -c 86114 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r86114 into '.':
U    include/llvm/Target/TargetIntrinsicInfo.h
U    lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp
U    lib/Target/Blackfin/BlackfinIntrinsicInfo.h


Modified:
    llvm/branches/Apple/Leela-M1/include/llvm/Target/TargetIntrinsicInfo.h
    llvm/branches/Apple/Leela-M1/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp
    llvm/branches/Apple/Leela-M1/lib/Target/Blackfin/BlackfinIntrinsicInfo.h

Modified: llvm/branches/Apple/Leela-M1/include/llvm/Target/TargetIntrinsicInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela-M1/include/llvm/Target/TargetIntrinsicInfo.h?rev=86902&r1=86901&r2=86902&view=diff

==============================================================================
--- llvm/branches/Apple/Leela-M1/include/llvm/Target/TargetIntrinsicInfo.h (original)
+++ llvm/branches/Apple/Leela-M1/include/llvm/Target/TargetIntrinsicInfo.h Wed Nov 11 17:54:13 2009
@@ -14,6 +14,8 @@
 #ifndef LLVM_TARGET_TARGETINTRINSICINFO_H
 #define LLVM_TARGET_TARGETINTRINSICINFO_H
 
+#include <string>
+
 namespace llvm {
 
 class Function;
@@ -32,7 +34,13 @@
   virtual ~TargetIntrinsicInfo();
 
   /// Return the name of a target intrinsic, e.g. "llvm.bfin.ssync".
-  virtual const char *getName(unsigned IntrID) const =0;
+  /// The Tys and numTys parameters are for intrinsics with overloaded types
+  /// (e.g., those using iAny or fAny). For a declaration for an overloaded
+  /// intrinsic, Tys should point to an array of numTys pointers to Type,
+  /// and must provide exactly one type for each overloaded type in the
+  /// intrinsic.
+  virtual std::string getName(unsigned IID, const Type **Tys = 0,
+                              unsigned numTys = 0) const = 0;
 
   /// Look up target intrinsic by name. Return intrinsic ID or 0 for unknown
   /// names.
@@ -40,6 +48,15 @@
 
   /// Return the target intrinsic ID of a function, or 0.
   virtual unsigned getIntrinsicID(Function *F) const;
+
+  /// Returns true if the intrinsic can be overloaded.
+  virtual bool isOverloaded(unsigned IID) const = 0;
+  
+  /// Create or insert an LLVM Function declaration for an intrinsic,
+  /// and return it. The Tys and numTys are for intrinsics with overloaded
+  /// types. See above for more information.
+  virtual Function *getDeclaration(Module *M, unsigned ID, const Type **Tys = 0,
+                                   unsigned numTys = 0) const = 0;
 };
 
 } // End llvm namespace

Modified: llvm/branches/Apple/Leela-M1/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela-M1/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp?rev=86902&r1=86901&r2=86902&view=diff

==============================================================================
--- llvm/branches/Apple/Leela-M1/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp (original)
+++ llvm/branches/Apple/Leela-M1/lib/Target/Blackfin/BlackfinIntrinsicInfo.cpp Wed Nov 11 17:54:13 2009
@@ -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 <cstring>
 
@@ -30,18 +34,21 @@
 
 }
 
-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
@@ -51,3 +58,44 @@
 #undef GET_FUNCTION_RECOGNIZER
   return 0;
 }
+
+bool BlackfinIntrinsicInfo::isOverloaded(unsigned IntrID) const {
+  // Overload Table
+  const bool OTable[] = {
+    false,  // illegal intrinsic
+#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<const Type*> 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<Function>(M->getOrInsertFunction(getName(IntrID),
+                                               getType(M->getContext(), IntrID),
+                                               AList));
+}

Modified: llvm/branches/Apple/Leela-M1/lib/Target/Blackfin/BlackfinIntrinsicInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Leela-M1/lib/Target/Blackfin/BlackfinIntrinsicInfo.h?rev=86902&r1=86901&r2=86902&view=diff

==============================================================================
--- llvm/branches/Apple/Leela-M1/lib/Target/Blackfin/BlackfinIntrinsicInfo.h (original)
+++ llvm/branches/Apple/Leela-M1/lib/Target/Blackfin/BlackfinIntrinsicInfo.h Wed Nov 11 17:54:13 2009
@@ -19,8 +19,12 @@
 
   class BlackfinIntrinsicInfo : public TargetIntrinsicInfo {
   public:
-    const char *getName(unsigned IntrID) const;
+    std::string getName(unsigned IntrID, const Type **Tys = 0,
+                        unsigned numTys = 0) const;
     unsigned lookupName(const char *Name, unsigned Len) const;
+    bool isOverloaded(unsigned IID) const;
+    Function *getDeclaration(Module *M, unsigned ID, const Type **Tys = 0,
+                             unsigned numTys = 0) const;
   };
 
 }





More information about the llvm-branch-commits mailing list