From 621d3675cbb422283e6e858d778d3c2abfd5b929 Mon Sep 17 00:00:00 2001 From: Matt Arsenault Date: Mon, 25 Apr 2016 19:27:13 +0000 Subject: [PATCH] Add useful helpers to AddrSpaceCastInst llvm-svn: 267450 --- llvm/include/llvm/IR/Instructions.h | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/llvm/include/llvm/IR/Instructions.h b/llvm/include/llvm/IR/Instructions.h index 312541c..ba20d77 100644 --- a/llvm/include/llvm/IR/Instructions.h +++ b/llvm/include/llvm/IR/Instructions.h @@ -4848,6 +4848,31 @@ public: static inline bool classof(const Value *V) { return isa(V) && classof(cast(V)); } + + /// \brief Gets the pointer operand. + Value *getPointerOperand() { + return getOperand(0); + } + + /// \brief Gets the pointer operand. + const Value *getPointerOperand() const { + return getOperand(0); + } + + /// \brief Gets the operand index of the pointer operand. + static unsigned getPointerOperandIndex() { + return 0U; + } + + /// \brief Returns the address space of the pointer operand. + unsigned getSrcAddressSpace() const { + return getPointerOperand()->getType()->getPointerAddressSpace(); + } + + /// \brief Returns the address space of the result. + unsigned getDestAddressSpace() const { + return getType()->getPointerAddressSpace(); + } }; } // End llvm namespace -- 2.7.4