Add in some interfaces that will allow easier access to the pointer address space.
authorMicah Villmow <villmow@gmail.com>
Tue, 9 Oct 2012 22:27:29 +0000 (22:27 +0000)
committerMicah Villmow <villmow@gmail.com>
Tue, 9 Oct 2012 22:27:29 +0000 (22:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@165554 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/CodeGen/SelectionDAGNodes.h
include/llvm/Instructions.h
include/llvm/Operator.h

index fd89973263813f83049fd4b286482747d97ebbe1..63d47592650e7450a1dce2469fe2e84f9dba2ff0 100644 (file)
@@ -956,7 +956,12 @@ public:
   const MachinePointerInfo &getPointerInfo() const {
     return MMO->getPointerInfo();
   }
-  
+
+  /// getAddressSpace - Return the address space for the associated pointer
+  unsigned getAddressSpace() const {
+    return getPointerInfo().getAddrSpace();
+  }
+
   /// refineAlignment - Update this MemSDNode's MachineMemOperand information
   /// to reflect the alignment of NewMMO, if it has a greater alignment.
   /// This must only be used when the new alignment applies to all users of
index 17b75b077fb5950246a1e4b0261d3d77ce1ad8cd..877e46fe9f9810063db45bb42cef8ddb9a349474 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
@@ -3640,6 +3640,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) {
@@ -3677,6 +3682,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) {
index 459df2b289a13b0808e0965ecc95e87eaa0e9431..61ac163d4a153fd79318375cf06fd3d98e98d166 100644 (file)
@@ -16,6 +16,7 @@
 #define LLVM_OPERATOR_H
 
 #include "llvm/Constants.h"
+#include "llvm/DerivedTypes.h"
 #include "llvm/Instruction.h"
 #include "llvm/Type.h"
 
@@ -290,6 +291,12 @@ public:
     return getPointerOperand()->getType();
   }
 
+  /// getPointerAddressSpace - Method to return the address space of the
+  /// pointer operand.
+  unsigned getPointerAddressSpace() const {
+    return cast<PointerType>(getPointerOperandType())->getAddressSpace();
+  }
+
   unsigned getNumIndices() const {  // Note: always non-negative
     return getNumOperands() - 1;
   }