add nocapture attribute to llvm.mem* intrinsics and have tblgen
authorChris Lattner <sabre@nondot.org>
Mon, 12 Jan 2009 01:12:03 +0000 (01:12 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 12 Jan 2009 01:12:03 +0000 (01:12 +0000)
parse them.  tblgen doesn't yet do anything with this info though.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@62065 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Intrinsics.td
utils/TableGen/CodeGenIntrinsics.h
utils/TableGen/CodeGenTarget.cpp

index a641caa91aab28df99c4037be9ad5d809fe1481a..8145700f3997c6c28d12eb9c21d011b43a434e42 100644 (file)
@@ -51,6 +51,11 @@ def IntrWriteMem : IntrinsicProperty;
 // Commutative - This intrinsic is commutative: X op Y == Y op X.
 def Commutative : IntrinsicProperty;
 
+// NoCapture - The specified argument pointer is not captured by the intrinsic.
+class NoCapture<int argNo> : IntrinsicProperty {
+  int ArgNo = argNo;
+}
+
 //===----------------------------------------------------------------------===//
 // Types used by intrinsics.
 //===----------------------------------------------------------------------===//
@@ -199,17 +204,18 @@ def int_stackprotector : Intrinsic<[llvm_void_ty],
 //===------------------- Standard C Library Intrinsics --------------------===//
 //
 
-let Properties = [IntrWriteArgMem] in {
-  def int_memcpy  : Intrinsic<[llvm_void_ty],
-                               [llvm_ptr_ty, llvm_ptr_ty,
-                                llvm_anyint_ty, llvm_i32_ty]>;
-  def int_memmove : Intrinsic<[llvm_void_ty],
-                                  [llvm_ptr_ty, llvm_ptr_ty,
-                                   llvm_anyint_ty, llvm_i32_ty]>;
-  def int_memset  : Intrinsic<[llvm_void_ty],
-                               [llvm_ptr_ty, llvm_i8_ty,
-                                llvm_anyint_ty, llvm_i32_ty]>;
-}
+def int_memcpy  : Intrinsic<[llvm_void_ty],
+                             [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty,
+                              llvm_i32_ty],
+                            [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>;
+def int_memmove : Intrinsic<[llvm_void_ty],
+                            [llvm_ptr_ty, llvm_ptr_ty, llvm_anyint_ty,
+                             llvm_i32_ty],
+                            [IntrWriteArgMem, NoCapture<0>, NoCapture<1>]>;
+def int_memset  : Intrinsic<[llvm_void_ty],
+                            [llvm_ptr_ty, llvm_i8_ty, llvm_anyint_ty,
+                             llvm_i32_ty],
+                            [IntrWriteArgMem, NoCapture<0>]>;
 
 // These functions do not actually read memory, but they are sensitive to the
 // rounding mode.  This needs to be modelled separately; in the meantime
index 1170da0f35994fc0a25efd1ea3989baf7091e405..dd99e319d6c77e089f47f007ce8883b48fc09235 100644 (file)
@@ -63,13 +63,17 @@ namespace llvm {
       NoMem, ReadArgMem, ReadMem, WriteArgMem, WriteMem
     } ModRef;
 
-    // This is set to true if the intrinsic is overloaded by its argument
-    // types.
+    /// This is set to true if the intrinsic is overloaded by its argument
+    /// types.
     bool isOverloaded;
 
-    // isCommutative - True if the intrinsic is commutative.
-    //
+    /// isCommutative - True if the intrinsic is commutative.
     bool isCommutative;
+    
+    enum ArgAttribute {
+      NoCapture
+    };
+    std::vector<std::pair<unsigned, ArgAttribute> > ArgumentAttributes;
 
     CodeGenIntrinsic(Record *R);
   };
index 0039a894972293612f3b783ce0a294cac7faa504..274cc78c35b0114ff142d2db19af30058629b1a9 100644 (file)
@@ -546,7 +546,10 @@ CodeGenIntrinsic::CodeGenIntrinsic(Record *R) {
       ModRef = WriteMem;
     else if (Property->getName() == "Commutative")
       isCommutative = true;
-    else
+    else if (Property->isSubClassOf("NoCapture")) {
+      unsigned ArgNo = Property->getValueAsInt("ArgNo");
+      ArgumentAttributes.push_back(std::make_pair(ArgNo, NoCapture));
+    } else
       assert(0 && "Unknown property!");
   }
 }