class GetElementPtrInst

Declaration

class GetElementPtrInst : public Instruction { /* full declaration omitted */ };

Description

an instruction for type-safe pointer arithmetic to access elements of arrays and structs

Declared at: llvm/include/llvm/IR/Instructions.h:929

Inherits from: Instruction

Member Variables

private llvm::Type* SourceElementType
private llvm::Type* ResultElementType

Inherited from Value:

protected SubclassOptionalData
protected NumUserOperands
protected IsUsedByMD
protected HasName
protected HasMetadata
protected HasHungOffUses
protected HasDescriptor
public static MaxAlignmentExponent = 32
public static MaximumAlignment = 1ULL << MaxAlignmentExponent

Method Overview

  • public static llvm::GetElementPtrInst * Create(llvm::Type * PointeeType, llvm::Value * Ptr, ArrayRef<llvm::Value *> IdxList, const llvm::Twine & NameStr = "", llvm::Instruction * InsertBefore = nullptr)
  • public static llvm::GetElementPtrInst * Create(llvm::Type * PointeeType, llvm::Value * Ptr, ArrayRef<llvm::Value *> IdxList, const llvm::Twine & NameStr, llvm::BasicBlock * InsertAtEnd)
  • public static llvm::GetElementPtrInst * CreateInBounds(llvm::Type * PointeeType, llvm::Value * Ptr, ArrayRef<llvm::Value *> IdxList, const llvm::Twine & NameStr = "", llvm::Instruction * InsertBefore = nullptr)
  • public static llvm::GetElementPtrInst * CreateInBounds(llvm::Type * PointeeType, llvm::Value * Ptr, ArrayRef<llvm::Value *> IdxList, const llvm::Twine & NameStr, llvm::BasicBlock * InsertAtEnd)
  • private inline GetElementPtrInst(llvm::Type * PointeeType, llvm::Value * Ptr, ArrayRef<llvm::Value *> IdxList, unsigned int Values, const llvm::Twine & NameStr, llvm::Instruction * InsertBefore)
  • private inline GetElementPtrInst(llvm::Type * PointeeType, llvm::Value * Ptr, ArrayRef<llvm::Value *> IdxList, unsigned int Values, const llvm::Twine & NameStr, llvm::BasicBlock * InsertAtEnd)
  • private GetElementPtrInst(const llvm::GetElementPtrInst & GEPI)
  • public bool accumulateConstantOffset(const llvm::DataLayout & DL, llvm::APInt & Offset) const
  • public static bool classof(const llvm::Value * V)
  • public static bool classof(const llvm::Instruction * I)
  • protected llvm::GetElementPtrInst * cloneImpl() const
  • public bool collectOffset(const llvm::DataLayout & DL, unsigned int BitWidth, MapVector<llvm::Value *, llvm::APInt> & VariableOffsets, llvm::APInt & ConstantOffset) const
  • public unsigned int getAddressSpace() const
  • public static llvm::Type * getGEPReturnType(llvm::Type * ElTy, llvm::Value * Ptr, ArrayRef<llvm::Value *> IdxList)
  • public static llvm::Type * getIndexedType(llvm::Type * Ty, ArrayRef<llvm::Value *> IdxList)
  • public static llvm::Type * getIndexedType(llvm::Type * Ty, ArrayRef<llvm::Constant *> IdxList)
  • public static llvm::Type * getIndexedType(llvm::Type * Ty, ArrayRef<uint64_t> IdxList)
  • public unsigned int getNumIndices() const
  • public unsigned int getPointerAddressSpace() const
  • public const llvm::Value * getPointerOperand() const
  • public llvm::Value * getPointerOperand()
  • public static unsigned int getPointerOperandIndex()
  • public llvm::Type * getPointerOperandType() const
  • public llvm::Type * getResultElementType() const
  • public llvm::Type * getSourceElementType() const
  • public static llvm::Type * getTypeAtIndex(llvm::Type * Ty, uint64_t Idx)
  • public static llvm::Type * getTypeAtIndex(llvm::Type * Ty, llvm::Value * Idx)
  • public bool hasAllConstantIndices() const
  • public bool hasAllZeroIndices() const
  • public bool hasIndices() const
  • public inline llvm::User::const_op_iterator idx_begin() const
  • public inline llvm::User::op_iterator idx_begin()
  • public inline llvm::User::const_op_iterator idx_end() const
  • public inline llvm::User::op_iterator idx_end()
  • public inline iterator_range<llvm::User::const_op_iterator> indices() const
  • public inline iterator_range<llvm::User::op_iterator> indices()
  • private void init(llvm::Value * Ptr, ArrayRef<llvm::Value *> IdxList, const llvm::Twine & NameStr)
  • public bool isInBounds() const
  • public void setIsInBounds(bool b = true)
  • public void setResultElementType(llvm::Type * Ty)
  • public void setSourceElementType(llvm::Type * Ty)

Inherited from Instruction:

Inherited from User:

Inherited from Value:

Methods

static llvm::GetElementPtrInst* Create(
    llvm::Type* PointeeType,
    llvm::Value* Ptr,
    ArrayRef<llvm::Value*> IdxList,
    const llvm::Twine& NameStr = "",
    llvm::Instruction* InsertBefore = nullptr)

Declared at: llvm/include/llvm/IR/Instructions.h:955

Parameters

llvm::Type* PointeeType
llvm::Value* Ptr
ArrayRef<llvm::Value*> IdxList
const llvm::Twine& NameStr = ""
llvm::Instruction* InsertBefore = nullptr

static llvm::GetElementPtrInst* Create(
    llvm::Type* PointeeType,
    llvm::Value* Ptr,
    ArrayRef<llvm::Value*> IdxList,
    const llvm::Twine& NameStr,
    llvm::BasicBlock* InsertAtEnd)

Declared at: llvm/include/llvm/IR/Instructions.h:967

Parameters

llvm::Type* PointeeType
llvm::Value* Ptr
ArrayRef<llvm::Value*> IdxList
const llvm::Twine& NameStr
llvm::BasicBlock* InsertAtEnd

static llvm::GetElementPtrInst* CreateInBounds(
    llvm::Type* PointeeType,
    llvm::Value* Ptr,
    ArrayRef<llvm::Value*> IdxList,
    const llvm::Twine& NameStr = "",
    llvm::Instruction* InsertBefore = nullptr)

Description

Create an "inbounds" getelementptr. See the documentation for the "inbounds" flag in LangRef.html for details.

Declared at: llvm/include/llvm/IR/Instructions.h:982

Parameters

llvm::Type* PointeeType
llvm::Value* Ptr
ArrayRef<llvm::Value*> IdxList
const llvm::Twine& NameStr = ""
llvm::Instruction* InsertBefore = nullptr

static llvm::GetElementPtrInst* CreateInBounds(
    llvm::Type* PointeeType,
    llvm::Value* Ptr,
    ArrayRef<llvm::Value*> IdxList,
    const llvm::Twine& NameStr,
    llvm::BasicBlock* InsertAtEnd)

Declared at: llvm/include/llvm/IR/Instructions.h:991

Parameters

llvm::Type* PointeeType
llvm::Value* Ptr
ArrayRef<llvm::Value*> IdxList
const llvm::Twine& NameStr
llvm::BasicBlock* InsertAtEnd

inline GetElementPtrInst(
    llvm::Type* PointeeType,
    llvm::Value* Ptr,
    ArrayRef<llvm::Value*> IdxList,
    unsigned int Values,
    const llvm::Twine& NameStr,
    llvm::Instruction* InsertBefore)

Description

Constructors - Create a getelementptr instruction with a base pointer an list of indices. The first ctor can optionally insert before an existing instruction, the second appends the new instruction to the specified BasicBlock.

Declared at: llvm/include/llvm/IR/Instructions.h:939

Parameters

llvm::Type* PointeeType
llvm::Value* Ptr
ArrayRef<llvm::Value*> IdxList
unsigned int Values
const llvm::Twine& NameStr
llvm::Instruction* InsertBefore

inline GetElementPtrInst(
    llvm::Type* PointeeType,
    llvm::Value* Ptr,
    ArrayRef<llvm::Value*> IdxList,
    unsigned int Values,
    const llvm::Twine& NameStr,
    llvm::BasicBlock* InsertAtEnd)

Declared at: llvm/include/llvm/IR/Instructions.h:942

Parameters

llvm::Type* PointeeType
llvm::Value* Ptr
ArrayRef<llvm::Value*> IdxList
unsigned int Values
const llvm::Twine& NameStr
llvm::BasicBlock* InsertAtEnd

GetElementPtrInst(
    const llvm::GetElementPtrInst& GEPI)

Declared at: llvm/include/llvm/IR/Instructions.h:933

Parameters

const llvm::GetElementPtrInst& GEPI

bool accumulateConstantOffset(
    const llvm::DataLayout& DL,
    llvm::APInt& Offset) const

Description

Accumulate the constant address offset of this GEP if possible. This routine accepts an APInt into which it will accumulate the constant offset of this GEP if the GEP is in fact constant. If the GEP is not all-constant, it returns false and the value of the offset APInt is undefined (it is *not* preserved!). The APInt passed into this routine must be at least as wide as the IntPtr type for the address space of the base GEP pointer.

Declared at: llvm/include/llvm/IR/Instructions.h:1130

Parameters

const llvm::DataLayout& DL
llvm::APInt& Offset

static bool classof(const llvm::Value* V)

Declared at: llvm/include/llvm/IR/Instructions.h:1138

Parameters

const llvm::Value* V

static bool classof(const llvm::Instruction* I)

Declared at: llvm/include/llvm/IR/Instructions.h:1135

Parameters

const llvm::Instruction* I

llvm::GetElementPtrInst* cloneImpl() const

Declared at: llvm/include/llvm/IR/Instructions.h:952

bool collectOffset(
    const llvm::DataLayout& DL,
    unsigned int BitWidth,
    MapVector<llvm::Value*, llvm::APInt>&
        VariableOffsets,
    llvm::APInt& ConstantOffset) const

Declared at: llvm/include/llvm/IR/Instructions.h:1131

Parameters

const llvm::DataLayout& DL
unsigned int BitWidth
MapVector<llvm::Value*, llvm::APInt>& VariableOffsets
llvm::APInt& ConstantOffset

unsigned int getAddressSpace() const

Description

Returns the address space of this instruction's pointer type.

Declared at: llvm/include/llvm/IR/Instructions.h:1016

static llvm::Type* getGEPReturnType(
    llvm::Type* ElTy,
    llvm::Value* Ptr,
    ArrayRef<llvm::Value*> IdxList)

Description

Returns the pointer type returned by the GEP instruction, which may be a vector of pointers.

Declared at: llvm/include/llvm/IR/Instructions.h:1075

Parameters

llvm::Type* ElTy
llvm::Value* Ptr
ArrayRef<llvm::Value*> IdxList

static llvm::Type* getIndexedType(
    llvm::Type* Ty,
    ArrayRef<llvm::Value*> IdxList)

Description

Returns the result type of a getelementptr with the given source element type and indexes. Null is returned if the indices are invalid for the specified source element type.

Declared at: llvm/include/llvm/IR/Instructions.h:1027

Parameters

llvm::Type* Ty
ArrayRef<llvm::Value*> IdxList

static llvm::Type* getIndexedType(
    llvm::Type* Ty,
    ArrayRef<llvm::Constant*> IdxList)

Declared at: llvm/include/llvm/IR/Instructions.h:1028

Parameters

llvm::Type* Ty
ArrayRef<llvm::Constant*> IdxList

static llvm::Type* getIndexedType(
    llvm::Type* Ty,
    ArrayRef<uint64_t> IdxList)

Declared at: llvm/include/llvm/IR/Instructions.h:1029

Parameters

llvm::Type* Ty
ArrayRef<uint64_t> IdxList

unsigned int getNumIndices() const

Declared at: llvm/include/llvm/IR/Instructions.h:1097

unsigned int getPointerAddressSpace() const

Description

Returns the address space of the pointer operand.

Declared at: llvm/include/llvm/IR/Instructions.h:1069

const llvm::Value* getPointerOperand() const

Declared at: llvm/include/llvm/IR/Instructions.h:1055

llvm::Value* getPointerOperand()

Declared at: llvm/include/llvm/IR/Instructions.h:1052

static unsigned int getPointerOperandIndex()

Declared at: llvm/include/llvm/IR/Instructions.h:1058

llvm::Type* getPointerOperandType() const

Description

Method to return the pointer operand as a PointerType.

Declared at: llvm/include/llvm/IR/Instructions.h:1064

llvm::Type* getResultElementType() const

Declared at: llvm/include/llvm/IR/Instructions.h:1009

llvm::Type* getSourceElementType() const

Declared at: llvm/include/llvm/IR/Instructions.h:1004

static llvm::Type* getTypeAtIndex(llvm::Type* Ty,
                                  uint64_t Idx)

Declared at: llvm/include/llvm/IR/Instructions.h:1037

Parameters

llvm::Type* Ty
uint64_t Idx

static llvm::Type* getTypeAtIndex(
    llvm::Type* Ty,
    llvm::Value* Idx)

Description

Return the type of the element at the given index of an indexable type. This is equivalent to "getIndexedType(Agg, {Zero, Idx})". Returns null if the type can't be indexed, or the given index is not legal for the given type.

Declared at: llvm/include/llvm/IR/Instructions.h:1036

Parameters

llvm::Type* Ty
llvm::Value* Idx

bool hasAllConstantIndices() const

Description

Return true if all of the indices of this GEP are constant integers. If so, the result pointer and the first operand have a constant offset between them.

Declared at: llvm/include/llvm/IR/Instructions.h:1113

bool hasAllZeroIndices() const

Description

Return true if all of the indices of this GEP are zeros. If so, the result pointer and the first operand have the same value, just potentially different types.

Declared at: llvm/include/llvm/IR/Instructions.h:1108

bool hasIndices() const

Declared at: llvm/include/llvm/IR/Instructions.h:1101

inline llvm::User::const_op_iterator idx_begin()
    const

Declared at: llvm/include/llvm/IR/Instructions.h:1040

inline llvm::User::op_iterator idx_begin()

Declared at: llvm/include/llvm/IR/Instructions.h:1039

inline llvm::User::const_op_iterator idx_end()
    const

Declared at: llvm/include/llvm/IR/Instructions.h:1042

inline llvm::User::op_iterator idx_end()

Declared at: llvm/include/llvm/IR/Instructions.h:1041

inline iterator_range<
    llvm::User::const_op_iterator>
indices() const

Declared at: llvm/include/llvm/IR/Instructions.h:1048

inline iterator_range<llvm::User::op_iterator>
indices()

Declared at: llvm/include/llvm/IR/Instructions.h:1044

void init(llvm::Value* Ptr,
          ArrayRef<llvm::Value*> IdxList,
          const llvm::Twine& NameStr)

Declared at: llvm/include/llvm/IR/Instructions.h:946

Parameters

llvm::Value* Ptr
ArrayRef<llvm::Value*> IdxList
const llvm::Twine& NameStr

bool isInBounds() const

Description

Determine whether the GEP has the inbounds flag.

Declared at: llvm/include/llvm/IR/Instructions.h:1120

void setIsInBounds(bool b = true)

Description

Set or clear the inbounds flag on this GEP instruction. See LangRef.html for the meaning of inbounds on a getelementptr.

Declared at: llvm/include/llvm/IR/Instructions.h:1117

Parameters

bool b = true

void setResultElementType(llvm::Type* Ty)

Declared at: llvm/include/llvm/IR/Instructions.h:1007

Parameters

llvm::Type* Ty

void setSourceElementType(llvm::Type* Ty)

Declared at: llvm/include/llvm/IR/Instructions.h:1006

Parameters

llvm::Type* Ty