Add in the first iteration of support for llvm/clang/lldb to allow variable per addre...
[oota-llvm.git] / include / llvm / Instructions.h
index 877e46fe9f9810063db45bb42cef8ddb9a349474..9c526bd97bbb1087ce545fcf1d965f7d011b44ad 100644 (file)
@@ -350,7 +350,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:
@@ -1280,50 +1289,56 @@ public:
 
   /// @brief Return true if the call should not be inlined.
   bool isNoInline() const { return hasFnAttr(Attributes::NoInline); }
-  void setIsNoInline(bool Value = true) {
-    if (Value) addAttribute(~0, Attribute::NoInline);
-    else removeAttribute(~0, Attribute::NoInline);
+  void setIsNoInline() {
+    Attributes::Builder B;
+    B.addAttribute(Attributes::NoInline);
+    addAttribute(~0, Attributes::get(B));
   }
 
   /// @brief Return true if the call can return twice
   bool canReturnTwice() const {
     return hasFnAttr(Attributes::ReturnsTwice);
   }
-  void setCanReturnTwice(bool Value = true) {
-    if (Value) addAttribute(~0, Attribute::ReturnsTwice);
-    else removeAttribute(~0, Attribute::ReturnsTwice);
+  void setCanReturnTwice() {
+    Attributes::Builder B;
+    B.addAttribute(Attributes::ReturnsTwice);
+    addAttribute(~0U, Attributes::get(B));
   }
 
   /// @brief Determine if the call does not access memory.
   bool doesNotAccessMemory() const {
     return hasFnAttr(Attributes::ReadNone);
   }
-  void setDoesNotAccessMemory(bool NotAccessMemory = true) {
-    if (NotAccessMemory) addAttribute(~0, Attribute::ReadNone);
-    else removeAttribute(~0, Attribute::ReadNone);
+  void setDoesNotAccessMemory() {
+    Attributes::Builder B;
+    B.addAttribute(Attributes::ReadNone);
+    addAttribute(~0U, Attributes::get(B));
   }
 
   /// @brief Determine if the call does not access or only reads memory.
   bool onlyReadsMemory() const {
     return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly);
   }
-  void setOnlyReadsMemory(bool OnlyReadsMemory = true) {
-    if (OnlyReadsMemory) addAttribute(~0, Attribute::ReadOnly);
-    else removeAttribute(~0, Attribute::ReadOnly | Attribute::ReadNone);
+  void setOnlyReadsMemory() {
+    Attributes::Builder B;
+    B.addAttribute(Attributes::ReadOnly);
+    addAttribute(~0, Attributes::get(B));
   }
 
   /// @brief Determine if the call cannot return.
   bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); }
-  void setDoesNotReturn(bool DoesNotReturn = true) {
-    if (DoesNotReturn) addAttribute(~0, Attribute::NoReturn);
-    else removeAttribute(~0, Attribute::NoReturn);
+  void setDoesNotReturn() {
+    Attributes::Builder B;
+    B.addAttribute(Attributes::NoReturn);
+    addAttribute(~0, Attributes::get(B));
   }
 
   /// @brief Determine if the call cannot unwind.
   bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); }
-  void setDoesNotThrow(bool DoesNotThrow = true) {
-    if (DoesNotThrow) addAttribute(~0, Attribute::NoUnwind);
-    else removeAttribute(~0, Attribute::NoUnwind);
+  void setDoesNotThrow() {
+    Attributes::Builder B;
+    B.addAttribute(Attributes::NoUnwind);
+    addAttribute(~0, Attributes::get(B));
   }
 
   /// @brief Determine if the call returns a structure through first
@@ -3043,41 +3058,46 @@ public:
 
   /// @brief Return true if the call should not be inlined.
   bool isNoInline() const { return hasFnAttr(Attributes::NoInline); }
-  void setIsNoInline(bool Value = true) {
-    if (Value) addAttribute(~0, Attribute::NoInline);
-    else removeAttribute(~0, Attribute::NoInline);
+  void setIsNoInline() {
+    Attributes::Builder B;
+    B.addAttribute(Attributes::NoInline);
+    addAttribute(~0, Attributes::get(B));
   }
 
   /// @brief Determine if the call does not access memory.
   bool doesNotAccessMemory() const {
     return hasFnAttr(Attributes::ReadNone);
   }
-  void setDoesNotAccessMemory(bool NotAccessMemory = true) {
-    if (NotAccessMemory) addAttribute(~0, Attribute::ReadNone);
-    else removeAttribute(~0, Attribute::ReadNone);
+  void setDoesNotAccessMemory() {
+    Attributes::Builder B;
+    B.addAttribute(Attributes::ReadNone);
+    addAttribute(~0, Attributes::get(B));
   }
 
   /// @brief Determine if the call does not access or only reads memory.
   bool onlyReadsMemory() const {
     return doesNotAccessMemory() || hasFnAttr(Attributes::ReadOnly);
   }
-  void setOnlyReadsMemory(bool OnlyReadsMemory = true) {
-    if (OnlyReadsMemory) addAttribute(~0, Attribute::ReadOnly);
-    else removeAttribute(~0, Attribute::ReadOnly | Attribute::ReadNone);
+  void setOnlyReadsMemory() {
+    Attributes::Builder B;
+    B.addAttribute(Attributes::ReadOnly);
+    addAttribute(~0, Attributes::get(B));
   }
 
   /// @brief Determine if the call cannot return.
   bool doesNotReturn() const { return hasFnAttr(Attributes::NoReturn); }
-  void setDoesNotReturn(bool DoesNotReturn = true) {
-    if (DoesNotReturn) addAttribute(~0, Attribute::NoReturn);
-    else removeAttribute(~0, Attribute::NoReturn);
+  void setDoesNotReturn() {
+    Attributes::Builder B;
+    B.addAttribute(Attributes::NoReturn);
+    addAttribute(~0, Attributes::get(B));
   }
 
   /// @brief Determine if the call cannot unwind.
   bool doesNotThrow() const { return hasFnAttr(Attributes::NoUnwind); }
-  void setDoesNotThrow(bool DoesNotThrow = true) {
-    if (DoesNotThrow) addAttribute(~0, Attribute::NoUnwind);
-    else removeAttribute(~0, Attribute::NoUnwind);
+  void setDoesNotThrow() {
+    Attributes::Builder B;
+    B.addAttribute(Attributes::NoUnwind);
+    addAttribute(~0, Attributes::get(B));
   }
 
   /// @brief Determine if the call returns a structure through first
@@ -3642,7 +3662,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:
@@ -3684,7 +3712,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: