Index: include/llvm/Operator.h =================================================================== --- include/llvm/Operator.h (revision 165500) +++ include/llvm/Operator.h (working copy) @@ -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 @@ return getPointerOperand()->getType(); } + /// getAddressSpace - Method to return the address space of the + /// pointer operand. + unsigned getAddressSpace() const { + return dyn_cast(getPointerOperandType())->getAddressSpace(); + } + unsigned getNumIndices() const { // Note: always non-negative return getNumOperands() - 1; } Index: include/llvm/Instructions.h =================================================================== --- include/llvm/Instructions.h (revision 165500) +++ include/llvm/Instructions.h (working copy) @@ -778,7 +778,7 @@ static Type *getIndexedType(Type *Ptr, ArrayRef IdxList); static Type *getIndexedType(Type *Ptr, ArrayRef 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 @@ } unsigned getPointerAddressSpace() const { - return cast(getType())->getAddressSpace(); + return cast(getPointerOperandType())->getAddressSpace(); } /// getPointerOperandType - Method to return the pointer operand as a @@ -3666,6 +3666,11 @@ /// @brief Clone an identical IntToPtrInst virtual IntToPtrInst *clone_impl() const; + /// @brief return the address space of the pointer. + unsigned getAddressSpace() const { + return dyn_cast(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) { @@ -3703,6 +3708,11 @@ BasicBlock *InsertAtEnd ///< The block to insert the instruction into ); + /// @brief return the address space of the pointer. + unsigned getAddressSpace() const { + return dyn_cast(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: include/llvm/CodeGen/SelectionDAGNodes.h =================================================================== --- include/llvm/CodeGen/SelectionDAGNodes.h (revision 165500) +++ include/llvm/CodeGen/SelectionDAGNodes.h (working copy) @@ -956,7 +956,12 @@ 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