Change MachineInstrBuilder::addDisp to copy over target flags by default.
[oota-llvm.git] / include / llvm / Instructions.h
index ea3aaae9c6f6b456245da0a06386701eb0229005..6837608b2c08fd69463eccb735d2e5535c6605e0 100644 (file)
@@ -778,7 +778,7 @@ public:
   static Type *getIndexedType(Type *Ptr, ArrayRef<Constant *> IdxList);
   static Type *getIndexedType(Type *Ptr, ArrayRef<uint64_t> IdxList);
 
-  /// getIndexedType - Returns the address space used by the GEP pointer.
+  /// getAddressSpace - Returns the address space used by the GEP pointer.
   ///
   static unsigned getAddressSpace(Value *Ptr);
 
@@ -798,7 +798,7 @@ public:
   }
 
   unsigned getPointerAddressSpace() const {
-    return cast<PointerType>(getType())->getAddressSpace();
+    return cast<PointerType>(getPointerOperandType())->getAddressSpace();
   }
 
   /// getPointerOperandType - Method to return the pointer operand as a
@@ -1268,13 +1268,7 @@ public:
   void removeAttribute(unsigned i, Attributes attr);
 
   /// @brief Determine whether this call has the given attribute.
-  bool fnHasNoAliasAttr() const;
-  bool fnHasNoInlineAttr() const;
-  bool fnHasNoReturnAttr() const;
-  bool fnHasNoUnwindAttr() const;
-  bool fnHasReadNoneAttr() const;
-  bool fnHasReadOnlyAttr() const;
-  bool fnHasReturnsTwiceAttr() const;
+  bool hasFnAttr(Attributes::AttrVal A) const;
 
   /// @brief Determine whether the call or the callee has the given attributes.
   bool paramHasAttr(unsigned i, Attributes::AttrVal A) const;
@@ -1285,51 +1279,57 @@ public:
   }
 
   /// @brief Return true if the call should not be inlined.
-  bool isNoInline() const { return fnHasNoInlineAttr(); }
-  void setIsNoInline(bool Value = true) {
-    if (Value) addAttribute(~0, Attribute::NoInline);
-    else removeAttribute(~0, Attribute::NoInline);
+  bool isNoInline() const { return hasFnAttr(Attributes::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 fnHasReturnsTwiceAttr();
+    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 fnHasReadNoneAttr();
+    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() || fnHasReadOnlyAttr();
+    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 fnHasNoReturnAttr(); }
-  void setDoesNotReturn(bool DoesNotReturn = true) {
-    if (DoesNotReturn) addAttribute(~0, Attribute::NoReturn);
-    else removeAttribute(~0, Attribute::NoReturn);
+  bool doesNotReturn() const { return hasFnAttr(Attributes::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 fnHasNoUnwindAttr(); }
-  void setDoesNotThrow(bool DoesNotThrow = true) {
-    if (DoesNotThrow) addAttribute(~0, Attribute::NoUnwind);
-    else removeAttribute(~0, Attribute::NoUnwind);
+  bool doesNotThrow() const { return hasFnAttr(Attributes::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
@@ -3037,13 +3037,7 @@ public:
   void removeAttribute(unsigned i, Attributes attr);
 
   /// @brief Determine whether this call has the NoAlias attribute.
-  bool fnHasNoAliasAttr() const;
-  bool fnHasNoInlineAttr() const;
-  bool fnHasNoReturnAttr() const;
-  bool fnHasNoUnwindAttr() const;
-  bool fnHasReadNoneAttr() const;
-  bool fnHasReadOnlyAttr() const;
-  bool fnHasReturnsTwiceAttr() const;
+  bool hasFnAttr(Attributes::AttrVal A) const;
 
   /// @brief Determine whether the call or the callee has the given attributes.
   bool paramHasAttr(unsigned i, Attributes::AttrVal A) const;
@@ -3054,42 +3048,47 @@ public:
   }
 
   /// @brief Return true if the call should not be inlined.
-  bool isNoInline() const { return fnHasNoInlineAttr(); }
-  void setIsNoInline(bool Value = true) {
-    if (Value) addAttribute(~0, Attribute::NoInline);
-    else removeAttribute(~0, Attribute::NoInline);
+  bool isNoInline() const { return hasFnAttr(Attributes::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 fnHasReadNoneAttr();
+    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() || fnHasReadOnlyAttr();
+    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 fnHasNoReturnAttr(); }
-  void setDoesNotReturn(bool DoesNotReturn = true) {
-    if (DoesNotReturn) addAttribute(~0, Attribute::NoReturn);
-    else removeAttribute(~0, Attribute::NoReturn);
+  bool doesNotReturn() const { return hasFnAttr(Attributes::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 fnHasNoUnwindAttr(); }
-  void setDoesNotThrow(bool DoesNotThrow = true) {
-    if (DoesNotThrow) addAttribute(~0, Attribute::NoUnwind);
-    else removeAttribute(~0, Attribute::NoUnwind);
+  bool doesNotThrow() const { return hasFnAttr(Attributes::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
@@ -3652,6 +3651,11 @@ public:
   /// @brief Clone an identical IntToPtrInst
   virtual IntToPtrInst *clone_impl() const;
 
+  /// @brief return the address space of the pointer.
+  unsigned getAddressSpace() const {
+    return cast<PointerType>(getType())->getAddressSpace();
+  }
+
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const IntToPtrInst *) { return true; }
   static inline bool classof(const Instruction *I) {
@@ -3689,6 +3693,11 @@ public:
     BasicBlock *InsertAtEnd       ///< The block to insert the instruction into
   );
 
+  /// @brief return the address space of the pointer.
+  unsigned getPointerAddressSpace() const {
+    return cast<PointerType>(getOperand(0)->getType())->getAddressSpace();
+  }
+
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static inline bool classof(const PtrToIntInst *) { return true; }
   static inline bool classof(const Instruction *I) {