[llvm-commits] [llvm] r65406 - in /llvm/branches/Apple/Dib: include/llvm/Intrinsics.h include/llvm/Target/TargetIntrinsicInfo.h lib/VMCore/Function.cpp utils/TableGen/IntrinsicEmitter.cpp utils/TableGen/IntrinsicEmitter.h

Bill Wendling isanbard at gmail.com
Tue Feb 24 15:22:36 PST 2009


Author: void
Date: Tue Feb 24 17:22:35 2009
New Revision: 65406

URL: http://llvm.org/viewvc/llvm-project?rev=65406&view=rev
Log:
--- Merging (from foreign repository) r65404 into '.':
U    include/llvm/Target/TargetIntrinsicInfo.h
U    include/llvm/Intrinsics.h
U    utils/TableGen/IntrinsicEmitter.h
U    utils/TableGen/IntrinsicEmitter.cpp
U    lib/VMCore/Function.cpp

Added support to have TableGen provide information if an intrinsic (core
or target) can be overloaded or not.

Modified:
    llvm/branches/Apple/Dib/include/llvm/Intrinsics.h
    llvm/branches/Apple/Dib/include/llvm/Target/TargetIntrinsicInfo.h
    llvm/branches/Apple/Dib/lib/VMCore/Function.cpp
    llvm/branches/Apple/Dib/utils/TableGen/IntrinsicEmitter.cpp
    llvm/branches/Apple/Dib/utils/TableGen/IntrinsicEmitter.h

Modified: llvm/branches/Apple/Dib/include/llvm/Intrinsics.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/include/llvm/Intrinsics.h?rev=65406&r1=65405&r2=65406&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/include/llvm/Intrinsics.h (original)
+++ llvm/branches/Apple/Dib/include/llvm/Intrinsics.h Tue Feb 24 17:22:35 2009
@@ -49,6 +49,10 @@
   ///
   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);

Modified: llvm/branches/Apple/Dib/include/llvm/Target/TargetIntrinsicInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/include/llvm/Target/TargetIntrinsicInfo.h?rev=65406&r1=65405&r2=65406&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/include/llvm/Target/TargetIntrinsicInfo.h (original)
+++ llvm/branches/Apple/Dib/include/llvm/Target/TargetIntrinsicInfo.h Tue Feb 24 17:22:35 2009
@@ -18,6 +18,7 @@
 
 class Function;
 class Module;
+class Type;
 
 //---------------------------------------------------------------------------
 ///
@@ -39,7 +40,19 @@
   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; }
 };
 

Modified: llvm/branches/Apple/Dib/lib/VMCore/Function.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/lib/VMCore/Function.cpp?rev=65406&r1=65405&r2=65406&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/lib/VMCore/Function.cpp (original)
+++ llvm/branches/Apple/Dib/lib/VMCore/Function.cpp Tue Feb 24 17:22:35 2009
@@ -356,6 +356,16 @@
   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"

Modified: llvm/branches/Apple/Dib/utils/TableGen/IntrinsicEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/utils/TableGen/IntrinsicEmitter.cpp?rev=65406&r1=65405&r2=65406&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/utils/TableGen/IntrinsicEmitter.cpp (original)
+++ llvm/branches/Apple/Dib/utils/TableGen/IntrinsicEmitter.cpp Tue Feb 24 17:22:35 2009
@@ -35,7 +35,10 @@
 
   // 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);
   
@@ -117,6 +120,23 @@
   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();

Modified: llvm/branches/Apple/Dib/utils/TableGen/IntrinsicEmitter.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Dib/utils/TableGen/IntrinsicEmitter.h?rev=65406&r1=65405&r2=65406&view=diff

==============================================================================
--- llvm/branches/Apple/Dib/utils/TableGen/IntrinsicEmitter.h (original)
+++ llvm/branches/Apple/Dib/utils/TableGen/IntrinsicEmitter.h Tue Feb 24 17:22:35 2009
@@ -36,6 +36,8 @@
                               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, 





More information about the llvm-commits mailing list