From 7edfe5f6b2c6e71e2ccac83d4957e28a3f8b069b Mon Sep 17 00:00:00 2001 From: Micah Villmow Date: Tue, 9 Oct 2012 22:27:29 +0000 Subject: [PATCH] Add in some interfaces that will allow easier access to the pointer address space. llvm-svn: 165554 --- llvm/include/llvm/CodeGen/SelectionDAGNodes.h | 7 ++++++- llvm/include/llvm/Instructions.h | 14 ++++++++++++-- llvm/include/llvm/Operator.h | 7 +++++++ 3 files changed, 25 insertions(+), 3 deletions(-) diff --git a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h index fd89973..63d4759 100644 --- a/llvm/include/llvm/CodeGen/SelectionDAGNodes.h +++ b/llvm/include/llvm/CodeGen/SelectionDAGNodes.h @@ -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 diff --git a/llvm/include/llvm/Instructions.h b/llvm/include/llvm/Instructions.h index 17b75b0..877e46f 100644 --- a/llvm/include/llvm/Instructions.h +++ b/llvm/include/llvm/Instructions.h @@ -778,7 +778,7 @@ public: 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 @@ public: } unsigned getPointerAddressSpace() const { - return cast(getType())->getAddressSpace(); + return cast(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(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(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) { diff --git a/llvm/include/llvm/Operator.h b/llvm/include/llvm/Operator.h index 459df2b..61ac163 100644 --- a/llvm/include/llvm/Operator.h +++ b/llvm/include/llvm/Operator.h @@ -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(getPointerOperandType())->getAddressSpace(); + } + unsigned getNumIndices() const { // Note: always non-negative return getNumOperands() - 1; } -- 2.7.4