LLVM  mainline
Public Member Functions | Static Public Member Functions | Protected Member Functions | Friends
llvm::GetElementPtrInst Class Reference

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

#include <Instructions.h>

Inheritance diagram for llvm::GetElementPtrInst:
Inheritance graph
[legend]
Collaboration diagram for llvm::GetElementPtrInst:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Value)
 Transparently provide more efficient getOperand methods.
SequentialTypegetType () const
 All values are typed, get the type of this value.
TypegetSourceElementType () const
void setSourceElementType (Type *Ty)
void setResultElementType (Type *Ty)
TypegetResultElementType () const
unsigned getAddressSpace () const
 Returns the address space of this instruction's pointer type.
op_iterator idx_begin ()
const_op_iterator idx_begin () const
op_iterator idx_end ()
const_op_iterator idx_end () const
ValuegetPointerOperand ()
const ValuegetPointerOperand () const
TypegetPointerOperandType () const
 getPointerOperandType - Method to return the pointer operand as a PointerType.
unsigned getPointerAddressSpace () const
 Returns the address space of the pointer operand.
unsigned getNumIndices () const
bool hasIndices () const
bool hasAllZeroIndices () const
 hasAllZeroIndices - Return true if all of the indices of this GEP are zeros.
bool hasAllConstantIndices () const
 hasAllConstantIndices - Return true if all of the indices of this GEP are constant integers.
void setIsInBounds (bool b=true)
 setIsInBounds - Set or clear the inbounds flag on this GEP instruction.
bool isInBounds () const
 isInBounds - Determine whether the GEP has the inbounds flag.
bool accumulateConstantOffset (const DataLayout &DL, APInt &Offset) const
 Accumulate the constant address offset of this GEP if possible.

Static Public Member Functions

static GetElementPtrInstCreate (Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static GetElementPtrInstCreate (Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr, BasicBlock *InsertAtEnd)
static GetElementPtrInstCreateInBounds (Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
 Create an "inbounds" getelementptr.
static GetElementPtrInstCreateInBounds (Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=nullptr)
static GetElementPtrInstCreateInBounds (Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr, BasicBlock *InsertAtEnd)
static GetElementPtrInstCreateInBounds (Type *PointeeType, Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr, BasicBlock *InsertAtEnd)
static TypegetIndexedType (Type *Ty, ArrayRef< Value * > IdxList)
 getIndexedType - Returns the type of the element that would be loaded with a load instruction with the specified parameters.
static TypegetIndexedType (Type *Ty, ArrayRef< Constant * > IdxList)
static TypegetIndexedType (Type *Ty, ArrayRef< uint64_t > IdxList)
static unsigned getPointerOperandIndex ()
static TypegetGEPReturnType (Value *Ptr, ArrayRef< Value * > IdxList)
 GetGEPReturnType - Returns the pointer type returned by the GEP instruction, which may be a vector of pointers.
static TypegetGEPReturnType (Type *ElTy, Value *Ptr, ArrayRef< Value * > IdxList)
static bool classof (const Instruction *I)
static bool classof (const Value *V)
 Methods for support type inquiry through isa, cast, and dyn_cast:

Protected Member Functions

GetElementPtrInstcloneImpl () const
 Create a copy of this instruction.

Friends

class Instruction

Detailed Description

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

Definition at line 838 of file Instructions.h.


Member Function Documentation

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.

Definition at line 1606 of file Instructions.cpp.

Referenced by llvm::detail::PtrUseVisitorBase::adjustOffsetForGEP(), and llvm::InstCombiner::visitGetElementPtrInst().

static bool llvm::GetElementPtrInst::classof ( const Instruction I) [inline, static]

Definition at line 1051 of file Instructions.h.

References llvm::Instruction::getOpcode().

Referenced by classof().

static bool llvm::GetElementPtrInst::classof ( const Value V) [inline, static]

Methods for support type inquiry through isa, cast, and dyn_cast:

Reimplemented from llvm::Instruction.

Definition at line 1054 of file Instructions.h.

References classof().

Create a copy of this instruction.

Reimplemented from llvm::Instruction.

Definition at line 3786 of file Instructions.cpp.

References llvm::User::getNumOperands().

static GetElementPtrInst* llvm::GetElementPtrInst::Create ( Type PointeeType,
Value Ptr,
ArrayRef< Value * >  IdxList,
const Twine NameStr = "",
Instruction InsertBefore = nullptr 
) [inline, static]
static GetElementPtrInst* llvm::GetElementPtrInst::Create ( Type PointeeType,
Value Ptr,
ArrayRef< Value * >  IdxList,
const Twine NameStr,
BasicBlock InsertAtEnd 
) [inline, static]
static GetElementPtrInst* llvm::GetElementPtrInst::CreateInBounds ( Value Ptr,
ArrayRef< Value * >  IdxList,
const Twine NameStr = "",
Instruction InsertBefore = nullptr 
) [inline, static]
static GetElementPtrInst* llvm::GetElementPtrInst::CreateInBounds ( Type PointeeType,
Value Ptr,
ArrayRef< Value * >  IdxList,
const Twine NameStr = "",
Instruction InsertBefore = nullptr 
) [inline, static]

Definition at line 904 of file Instructions.h.

References Create(), GEP, and setIsInBounds().

static GetElementPtrInst* llvm::GetElementPtrInst::CreateInBounds ( Value Ptr,
ArrayRef< Value * >  IdxList,
const Twine NameStr,
BasicBlock InsertAtEnd 
) [inline, static]

Definition at line 912 of file Instructions.h.

References CreateInBounds().

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

Definition at line 918 of file Instructions.h.

References Create(), GEP, and setIsInBounds().

Transparently provide more efficient getOperand methods.

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

Definition at line 948 of file Instructions.h.

References getPointerAddressSpace().

Referenced by llvm::AMDGPUTTIImpl::getUnrollingPreferences(), and llvm::InstCombiner::visitGetElementPtrInst().

static Type* llvm::GetElementPtrInst::getGEPReturnType ( Value Ptr,
ArrayRef< Value * >  IdxList 
) [inline, static]

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

Definition at line 992 of file Instructions.h.

References llvm::Type::getScalarType(), and llvm::Value::getType().

static Type* llvm::GetElementPtrInst::getGEPReturnType ( Type ElTy,
Value Ptr,
ArrayRef< Value * >  IdxList 
) [inline, static]
Type * GetElementPtrInst::getIndexedType ( Type Ty,
ArrayRef< Value * >  IdxList 
) [static]

getIndexedType - Returns the type of the element that would be loaded with a load instruction with the specified parameters.

Null is returned if the indices are invalid for the specified pointer type.

Definition at line 1560 of file Instructions.cpp.

References getIndexedTypeInternal().

Referenced by aliasSameBasePointerGEPs(), canReplaceGEPIdxWithZero(), CastGEPIndices(), ConstantFoldGetElementPtrImpl(), getGEPReturnType(), llvm::ConstantExpr::getGetElementPtr(), and SimplifyGEPInst().

Type * GetElementPtrInst::getIndexedType ( Type Ty,
ArrayRef< Constant * >  IdxList 
) [static]

Definition at line 1564 of file Instructions.cpp.

References getIndexedTypeInternal().

Type * GetElementPtrInst::getIndexedType ( Type Ty,
ArrayRef< uint64_t >  IdxList 
) [static]

Definition at line 1569 of file Instructions.cpp.

References getIndexedTypeInternal().

Definition at line 1015 of file Instructions.h.

References llvm::User::getNumOperands().

Referenced by llvm::InstCombiner::visitGetElementPtrInst().

Returns the address space of the pointer operand.

Definition at line 986 of file Instructions.h.

References llvm::Type::getPointerAddressSpace(), and getPointerOperandType().

Referenced by getAddressSpace(), isGEPFoldable(), and llvm::InstCombiner::visitGetElementPtrInst().

Definition at line 972 of file Instructions.h.

References llvm::User::getOperand().

Definition at line 975 of file Instructions.h.

getPointerOperandType - Method to return the pointer operand as a PointerType.

Definition at line 981 of file Instructions.h.

References getPointerOperand(), and llvm::Value::getType().

Referenced by getPointerAddressSpace(), and llvm::InstCombiner::visitGetElementPtrInst().

Definition at line 941 of file Instructions.h.

References getType().

Referenced by llvm::getGEPInductionOperand(), and isGEPFoldable().

All values are typed, get the type of this value.

Reimplemented from llvm::Value.

Definition at line 932 of file Instructions.h.

Referenced by llvm::InstCombiner::FoldCmpLoadFromIndexedGlobal(), getResultElementType(), and llvm::InstCombiner::visitGetElementPtrInst().

hasAllConstantIndices - 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.

Definition at line 1590 of file Instructions.cpp.

References llvm::User::getNumOperands(), and llvm::User::getOperand().

Referenced by isSafeAndProfitableToSinkLoad().

hasAllZeroIndices - 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.

Definition at line 1576 of file Instructions.cpp.

References llvm::User::getNumOperands(), and llvm::User::getOperand().

Definition at line 1019 of file Instructions.h.

References llvm::User::getNumOperands().

Definition at line 965 of file Instructions.h.

References llvm::User::op_begin().

Definition at line 967 of file Instructions.h.

References llvm::User::op_end().

isInBounds - Determine whether the GEP has the inbounds flag.

Definition at line 1602 of file Instructions.cpp.

Referenced by canReplaceGEPIdxWithZero(), llvm::InstCombiner::FoldCmpLoadFromIndexedGlobal(), and llvm::InstCombiner::visitGetElementPtrInst().

setIsInBounds - Set or clear the inbounds flag on this GEP instruction.

See LangRef.html for the meaning of inbounds on a getelementptr.

Definition at line 1598 of file Instructions.cpp.

Referenced by buildNew(), and CreateInBounds().

Definition at line 939 of file Instructions.h.

Definition at line 938 of file Instructions.h.

Referenced by llvm::InstCombiner::visitGetElementPtrInst().


Friends And Related Function Documentation

friend class Instruction [friend]

Definition at line 860 of file Instructions.h.


The documentation for this class was generated from the following files: