Resubmit the changes to llvm core to update the functions to support different pointe...
[oota-llvm.git] / include / llvm / Instructions.h
index 7b68aef8747fafff6e1f7401fc34c1e6e3518ebc..458bd6ddb6712e0daac2b833578b36ff5eadfb1d 100644 (file)
@@ -348,7 +348,16 @@ public:
   static unsigned getPointerOperandIndex() { return 1U; }
 
   unsigned getPointerAddressSpace() const {
-    return cast<PointerType>(getPointerOperand()->getType())->getAddressSpace();
+    if (getPointerOperand()->getType()->isPointerTy())
+      return cast<PointerType>(getPointerOperand()->getType())
+        ->getAddressSpace();
+    if (getPointerOperand()->getType()->isVectorTy()
+        && cast<VectorType>(getPointerOperand()->getType())->isPointerTy())
+      return cast<PointerType>(cast<VectorType>(
+            getPointerOperand()->getType())->getElementType())
+        ->getAddressSpace();
+    llvm_unreachable("Only a vector of pointers or pointers can be used!");
+    return 0;
   }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -1274,7 +1283,7 @@ public:
   void setIsNoInline() {
     Attributes::Builder B;
     B.addAttribute(Attributes::NoInline);
-    addAttribute(~0, Attributes::get(getContext(), B));
+    addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
 
   /// @brief Return true if the call can return twice
@@ -1284,7 +1293,7 @@ public:
   void setCanReturnTwice() {
     Attributes::Builder B;
     B.addAttribute(Attributes::ReturnsTwice);
-    addAttribute(~0U, Attributes::get(getContext(), B));
+    addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
 
   /// @brief Determine if the call does not access memory.
@@ -1294,7 +1303,7 @@ public:
   void setDoesNotAccessMemory() {
     Attributes::Builder B;
     B.addAttribute(Attributes::ReadNone);
-    addAttribute(~0U, Attributes::get(getContext(), B));
+    addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
 
   /// @brief Determine if the call does not access or only reads memory.
@@ -1304,7 +1313,7 @@ public:
   void setOnlyReadsMemory() {
     Attributes::Builder B;
     B.addAttribute(Attributes::ReadOnly);
-    addAttribute(~0, Attributes::get(getContext(), B));
+    addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
 
   /// @brief Determine if the call cannot return.
@@ -1312,7 +1321,7 @@ public:
   void setDoesNotReturn() {
     Attributes::Builder B;
     B.addAttribute(Attributes::NoReturn);
-    addAttribute(~0, Attributes::get(getContext(), B));
+    addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
 
   /// @brief Determine if the call cannot unwind.
@@ -1320,7 +1329,7 @@ public:
   void setDoesNotThrow() {
     Attributes::Builder B;
     B.addAttribute(Attributes::NoUnwind);
-    addAttribute(~0, Attributes::get(getContext(), B));
+    addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
 
   /// @brief Determine if the call returns a structure through first
@@ -3029,7 +3038,7 @@ public:
   void setIsNoInline() {
     Attributes::Builder B;
     B.addAttribute(Attributes::NoInline);
-    addAttribute(~0, Attributes::get(getContext(), B));
+    addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
 
   /// @brief Determine if the call does not access memory.
@@ -3039,7 +3048,7 @@ public:
   void setDoesNotAccessMemory() {
     Attributes::Builder B;
     B.addAttribute(Attributes::ReadNone);
-    addAttribute(~0, Attributes::get(getContext(), B));
+    addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
 
   /// @brief Determine if the call does not access or only reads memory.
@@ -3049,7 +3058,7 @@ public:
   void setOnlyReadsMemory() {
     Attributes::Builder B;
     B.addAttribute(Attributes::ReadOnly);
-    addAttribute(~0, Attributes::get(getContext(), B));
+    addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
 
   /// @brief Determine if the call cannot return.
@@ -3057,7 +3066,7 @@ public:
   void setDoesNotReturn() {
     Attributes::Builder B;
     B.addAttribute(Attributes::NoReturn);
-    addAttribute(~0, Attributes::get(getContext(), B));
+    addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
 
   /// @brief Determine if the call cannot unwind.
@@ -3065,7 +3074,7 @@ public:
   void setDoesNotThrow() {
     Attributes::Builder B;
     B.addAttribute(Attributes::NoUnwind);
-    addAttribute(~0, Attributes::get(getContext(), B));
+    addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
 
   /// @brief Determine if the call returns a structure through first
@@ -3618,7 +3627,15 @@ public:
 
   /// @brief return the address space of the pointer.
   unsigned getAddressSpace() const {
-    return cast<PointerType>(getType())->getAddressSpace();
+    if (getType()->isPointerTy()) 
+      return cast<PointerType>(getType())->getAddressSpace();
+    if (getType()->isVectorTy() &&
+        cast<VectorType>(getType())->getElementType()->isPointerTy())
+      return cast<PointerType>(
+          cast<VectorType>(getType())->getElementType())
+        ->getAddressSpace();
+    llvm_unreachable("Must be a pointer or a vector of pointers.");
+    return 0;
   }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -3659,7 +3676,16 @@ public:
 
   /// @brief return the address space of the pointer.
   unsigned getPointerAddressSpace() const {
-    return cast<PointerType>(getOperand(0)->getType())->getAddressSpace();
+    Type *Ty = getOperand(0)->getType();
+    if (Ty->isPointerTy())
+      return cast<PointerType>(Ty)->getAddressSpace();
+    if (Ty->isVectorTy()
+        && cast<VectorType>(Ty)->getElementType()->isPointerTy())
+      return cast<PointerType>(
+          cast<VectorType>(Ty)->getElementType())
+        ->getAddressSpace();
+    llvm_unreachable("Must be a pointer or a vector of pointers.");
+    return 0;
   }
 
   // Methods for support type inquiry through isa, cast, and dyn_cast: