[llvm] r267450 - Add useful helpers to AddrSpaceCastInst

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 25 12:27:13 PDT 2016


Author: arsenm
Date: Mon Apr 25 14:27:13 2016
New Revision: 267450

URL: http://llvm.org/viewvc/llvm-project?rev=267450&view=rev
Log:
Add useful helpers to AddrSpaceCastInst

Modified:
    llvm/trunk/include/llvm/IR/Instructions.h

Modified: llvm/trunk/include/llvm/IR/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Instructions.h?rev=267450&r1=267449&r2=267450&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Instructions.h (original)
+++ llvm/trunk/include/llvm/IR/Instructions.h Mon Apr 25 14:27:13 2016
@@ -4848,6 +4848,31 @@ public:
   static inline bool classof(const Value *V) {
     return isa<Instruction>(V) && classof(cast<Instruction>(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




More information about the llvm-commits mailing list