Move the Attributes::Builder outside of the Attributes class and into its own class...
[oota-llvm.git] / include / llvm / Instructions.h
index dba852fc848ccde49bb0463b0ea60d12f9100501..97612b6f8506cfe62589f519775d01d5273d0e97 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:
@@ -1272,7 +1281,7 @@ public:
   /// @brief Return true if the call should not be inlined.
   bool isNoInline() const { return hasFnAttr(Attributes::NoInline); }
   void setIsNoInline() {
-    Attributes::Builder B;
+    AttrBuilder B;
     B.addAttribute(Attributes::NoInline);
     addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
@@ -1282,7 +1291,7 @@ public:
     return hasFnAttr(Attributes::ReturnsTwice);
   }
   void setCanReturnTwice() {
-    Attributes::Builder B;
+    AttrBuilder B;
     B.addAttribute(Attributes::ReturnsTwice);
     addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
@@ -1292,7 +1301,7 @@ public:
     return hasFnAttr(Attributes::ReadNone);
   }
   void setDoesNotAccessMemory() {
-    Attributes::Builder B;
+    AttrBuilder B;
     B.addAttribute(Attributes::ReadNone);
     addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
@@ -1302,7 +1311,7 @@ public:
     return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly);
   }
   void setOnlyReadsMemory() {
-    Attributes::Builder B;
+    AttrBuilder B;
     B.addAttribute(Attributes::ReadOnly);
     addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
@@ -1310,7 +1319,7 @@ public:
   /// @brief Determine if the call cannot return.
   bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); }
   void setDoesNotReturn() {
-    Attributes::Builder B;
+    AttrBuilder B;
     B.addAttribute(Attributes::NoReturn);
     addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
@@ -1318,7 +1327,7 @@ public:
   /// @brief Determine if the call cannot unwind.
   bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); }
   void setDoesNotThrow() {
-    Attributes::Builder B;
+    AttrBuilder B;
     B.addAttribute(Attributes::NoUnwind);
     addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
@@ -3027,7 +3036,7 @@ public:
   /// @brief Return true if the call should not be inlined.
   bool isNoInline() const { return hasFnAttr(Attributes::NoInline); }
   void setIsNoInline() {
-    Attributes::Builder B;
+    AttrBuilder B;
     B.addAttribute(Attributes::NoInline);
     addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
@@ -3037,7 +3046,7 @@ public:
     return hasFnAttr(Attributes::ReadNone);
   }
   void setDoesNotAccessMemory() {
-    Attributes::Builder B;
+    AttrBuilder B;
     B.addAttribute(Attributes::ReadNone);
     addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
@@ -3047,7 +3056,7 @@ public:
     return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly);
   }
   void setOnlyReadsMemory() {
-    Attributes::Builder B;
+    AttrBuilder B;
     B.addAttribute(Attributes::ReadOnly);
     addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
@@ -3055,7 +3064,7 @@ public:
   /// @brief Determine if the call cannot return.
   bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); }
   void setDoesNotReturn() {
-    Attributes::Builder B;
+    AttrBuilder B;
     B.addAttribute(Attributes::NoReturn);
     addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
@@ -3063,7 +3072,7 @@ public:
   /// @brief Determine if the call cannot unwind.
   bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); }
   void setDoesNotThrow() {
-    Attributes::Builder B;
+    AttrBuilder B;
     B.addAttribute(Attributes::NoUnwind);
     addAttribute(AttrListPtr::FunctionIndex, Attributes::get(getContext(), B));
   }
@@ -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: