[llvm-commits] [llvm] r167229 - /llvm/trunk/include/llvm/Instructions.h

Chandler Carruth chandlerc at gmail.com
Thu Nov 1 04:25:55 PDT 2012


Author: chandlerc
Date: Thu Nov  1 06:25:55 2012
New Revision: 167229

URL: http://llvm.org/viewvc/llvm-project?rev=167229&view=rev
Log:
Add a getAddressSpace method to the GEP instruction to mirror that of
the inttoptr instruction. The conceptual model here is that
'getAddressSpace' refers to the address space of this instruction's
type. It just happens that for GEPs, that is always the same as the
pointer operand's address space. We want both names so that access
patterns can be consistent between different instruction types.

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

Modified: llvm/trunk/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=167229&r1=167228&r2=167229&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Instructions.h (original)
+++ llvm/trunk/include/llvm/Instructions.h Thu Nov  1 06:25:55 2012
@@ -766,6 +766,13 @@
     return reinterpret_cast<PointerType*>(Instruction::getType());
   }
 
+  /// \brief Returns the address space of this instruction's pointer type.
+  unsigned getAddressSpace() const {
+    // Note that this is always the same as the pointer operand's address space
+    // and that is cheaper to compute, so cheat here.
+    return getPointerAddressSpace();
+  }
+
   /// getIndexedType - Returns the type of the element that would be loaded with
   /// a load instruction with the specified parameters.
   ///
@@ -3606,7 +3613,7 @@
   /// \brief Clone an identical IntToPtrInst
   virtual IntToPtrInst *clone_impl() const;
 
-  /// \brief return the address space of the pointer.
+  /// \brief Returns the address space of this instruction's pointer type.
   unsigned getAddressSpace() const {
     return getType()->getPointerAddressSpace();
   }





More information about the llvm-commits mailing list