LLVM API Documentation

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
llvm::GetElementPtrInst Class Reference

#include <Instructions.h>

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

Public Member Functions

 DECLARE_TRANSPARENT_OPERAND_ACCESSORS (Value)
 Transparently provide more efficient getOperand methods. More...
 
SequentialTypegetType () const
 
unsigned getAddressSpace () const
 Returns the address space of this instruction's pointer type. More...
 
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
 
unsigned getPointerAddressSpace () const
 Returns the address space of the pointer operand. More...
 
unsigned getNumIndices () const
 
bool hasIndices () const
 
bool hasAllZeroIndices () const
 
bool hasAllConstantIndices () const
 
void setIsInBounds (bool b=true)
 
bool isInBounds () const
 isInBounds - Determine whether the GEP has the inbounds flag. More...
 
bool accumulateConstantOffset (const DataLayout &DL, APInt &Offset) const
 Accumulate the constant address offset of this GEP if possible. More...
 
- Public Member Functions inherited from llvm::Instruction
 ~Instruction ()
 
Instructionuse_back ()
 
const Instructionuse_back () const
 
const BasicBlockgetParent () const
 
BasicBlockgetParent ()
 
void removeFromParent ()
 
void eraseFromParent ()
 
void insertBefore (Instruction *InsertPos)
 
void insertAfter (Instruction *InsertPos)
 
void moveBefore (Instruction *MovePos)
 
unsigned getOpcode () const
 getOpcode() returns a member of one of the enums like Instruction::Add. More...
 
const char * getOpcodeName () const
 
bool isTerminator () const
 
bool isBinaryOp () const
 
bool isShift ()
 
bool isCast () const
 
bool isLogicalShift () const
 
bool isArithmeticShift () const
 isArithmeticShift - Return true if this is an arithmetic shift right. More...
 
bool hasMetadata () const
 
bool hasMetadataOtherThanDebugLoc () const
 
MDNodegetMetadata (unsigned KindID) const
 
MDNodegetMetadata (StringRef Kind) const
 
void getAllMetadata (SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
 
void getAllMetadataOtherThanDebugLoc (SmallVectorImpl< std::pair< unsigned, MDNode * > > &MDs) const
 
void setMetadata (unsigned KindID, MDNode *Node)
 
void setMetadata (StringRef Kind, MDNode *Node)
 
void setDebugLoc (const DebugLoc &Loc)
 setDebugLoc - Set the debug location information for this instruction. More...
 
const DebugLocgetDebugLoc () const
 getDebugLoc - Return the debug location for this node as a DebugLoc. More...
 
void setHasUnsafeAlgebra (bool B)
 
void setHasNoNaNs (bool B)
 
void setHasNoInfs (bool B)
 
void setHasNoSignedZeros (bool B)
 
void setHasAllowReciprocal (bool B)
 
void setFastMathFlags (FastMathFlags FMF)
 
bool hasUnsafeAlgebra () const
 Determine whether the unsafe-algebra flag is set. More...
 
bool hasNoNaNs () const
 Determine whether the no-NaNs flag is set. More...
 
bool hasNoInfs () const
 Determine whether the no-infs flag is set. More...
 
bool hasNoSignedZeros () const
 Determine whether the no-signed-zeros flag is set. More...
 
bool hasAllowReciprocal () const
 Determine whether the allow-reciprocal flag is set. More...
 
FastMathFlags getFastMathFlags () const
 
void copyFastMathFlags (const Instruction *I)
 Copy I's fast-math flags. More...
 
bool isAssociative () const
 
bool isCommutative () const
 
bool isIdempotent () const
 
bool isNilpotent () const
 
bool mayWriteToMemory () const
 
bool mayReadFromMemory () const
 
bool mayReadOrWriteMemory () const
 
bool mayThrow () const
 
bool mayReturn () const
 
bool mayHaveSideEffects () const
 
Instructionclone () const
 
bool isIdenticalTo (const Instruction *I) const
 
bool isIdenticalToWhenDefined (const Instruction *I) const
 
bool isSameOperationAs (const Instruction *I, unsigned flags=0) const
 Determine if one instruction is the same operation as another. More...
 
bool isUsedOutsideOfBlock (const BasicBlock *BB) const
 
- Public Member Functions inherited from llvm::User
 ~User ()
 
void operator delete (void *Usr)
 operator delete - free memory allocated for User and Use objects More...
 
void operator delete (void *, unsigned)
 placement delete - required by std, but never called. More...
 
void operator delete (void *, unsigned, bool)
 placement delete - required by std, but never called. More...
 
ValuegetOperand (unsigned i) const
 
void setOperand (unsigned i, Value *Val)
 
const UsegetOperandUse (unsigned i) const
 
UsegetOperandUse (unsigned i)
 
unsigned getNumOperands () const
 
op_iterator op_begin ()
 
const_op_iterator op_begin () const
 
op_iterator op_end ()
 
const_op_iterator op_end () const
 
value_op_iterator value_op_begin ()
 
value_op_iterator value_op_end ()
 
void dropAllReferences ()
 
void replaceUsesOfWith (Value *From, Value *To)
 
- Public Member Functions inherited from llvm::Value
virtual ~Value ()
 
void dump () const
 dump - Support for debugging, callable in GDB: V->dump() More...
 
void print (raw_ostream &O, AssemblyAnnotationWriter *AAW=0) const
 
TypegetType () const
 
LLVMContextgetContext () const
 All values hold a context through their type. More...
 
bool hasName () const
 
ValueNamegetValueName () const
 
void setValueName (ValueName *VN)
 
StringRef getName () const
 
void setName (const Twine &Name)
 
void takeName (Value *V)
 
void replaceAllUsesWith (Value *V)
 
bool use_empty () const
 
use_iterator use_begin ()
 
const_use_iterator use_begin () const
 
use_iterator use_end ()
 
const_use_iterator use_end () const
 
Useruse_back ()
 
const Useruse_back () const
 
bool hasOneUse () const
 
bool hasNUses (unsigned N) const
 
bool hasNUsesOrMore (unsigned N) const
 
bool isUsedInBasicBlock (const BasicBlock *BB) const
 
unsigned getNumUses () const
 
void addUse (Use &U)
 
unsigned getValueID () const
 
unsigned getRawSubclassOptionalData () const
 
void clearSubclassOptionalData ()
 
bool hasSameSubclassOptionalData (const Value *V) const
 
void intersectOptionalDataWith (const Value *V)
 
bool hasValueHandle () const
 
ValuestripPointerCasts ()
 Strips off any unneeded pointer casts, all-zero GEPs and aliases from the specified value, returning the original uncasted value. More...
 
const ValuestripPointerCasts () const
 
ValuestripPointerCastsNoFollowAliases ()
 Strips off any unneeded pointer casts and all-zero GEPs from the specified value, returning the original uncasted value. More...
 
const ValuestripPointerCastsNoFollowAliases () const
 
ValuestripInBoundsConstantOffsets ()
 Strips off unneeded pointer casts and all-constant GEPs from the specified value, returning the original pointer value. More...
 
const ValuestripInBoundsConstantOffsets () const
 
ValuestripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset)
 Strips like stripInBoundsConstantOffsets but also accumulates the constant offset stripped. More...
 
const ValuestripAndAccumulateInBoundsConstantOffsets (const DataLayout &DL, APInt &Offset) const
 
ValuestripInBoundsOffsets ()
 Strips off unneeded pointer casts and any in-bounds offsets from the specified value, returning the original pointer value. More...
 
const ValuestripInBoundsOffsets () const
 
bool isDereferenceablePointer () const
 
ValueDoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB)
 
const ValueDoPHITranslation (const BasicBlock *CurBB, const BasicBlock *PredBB) const
 
void mutateType (Type *Ty)
 
- Public Member Functions inherited from llvm::ilist_node< Instruction >
InstructiongetPrevNode ()
 Get the previous node, or 0 for the list head. More...
 
const InstructiongetPrevNode () const
 Get the previous node, or 0 for the list head. More...
 
InstructiongetNextNode ()
 Get the next node, or 0 for the list tail. More...
 
const InstructiongetNextNode () const
 Get the next node, or 0 for the list tail. More...
 

Static Public Member Functions

static GetElementPtrInstCreate (Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=0)
 
static GetElementPtrInstCreate (Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr, BasicBlock *InsertAtEnd)
 
static GetElementPtrInstCreateInBounds (Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr="", Instruction *InsertBefore=0)
 
static GetElementPtrInstCreateInBounds (Value *Ptr, ArrayRef< Value * > IdxList, const Twine &NameStr, BasicBlock *InsertAtEnd)
 
static TypegetIndexedType (Type *Ptr, ArrayRef< Value * > IdxList)
 
static TypegetIndexedType (Type *Ptr, ArrayRef< Constant * > IdxList)
 
static TypegetIndexedType (Type *Ptr, ArrayRef< uint64_t > IdxList)
 
static unsigned getPointerOperandIndex ()
 
static TypegetGEPReturnType (Value *Ptr, ArrayRef< Value * > IdxList)
 
static bool classof (const Instruction *I)
 
static bool classof (const Value *V)
 
- Static Public Member Functions inherited from llvm::Instruction
static const char * getOpcodeName (unsigned OpCode)
 
static bool isTerminator (unsigned OpCode)
 
static bool isBinaryOp (unsigned Opcode)
 
static bool isShift (unsigned Opcode)
 Determine if the Opcode is one of the shift instructions. More...
 
static bool isCast (unsigned OpCode)
 Determine if the OpCode is one of the CastInst instructions. More...
 
static bool isAssociative (unsigned op)
 
static bool isCommutative (unsigned op)
 
static bool isIdempotent (unsigned op)
 
static bool isNilpotent (unsigned op)
 
static bool classof (const Value *V)
 Methods for support type inquiry through isa, cast, and dyn_cast: More...
 
- Static Public Member Functions inherited from llvm::User
static bool classof (const Value *V)
 

Protected Member Functions

virtual GetElementPtrInstclone_impl () const
 
- Protected Member Functions inherited from llvm::Instruction
void setInstructionSubclassData (unsigned short D)
 
unsigned getSubclassDataFromInstruction () const
 
 Instruction (Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, Instruction *InsertBefore=0)
 
 Instruction (Type *Ty, unsigned iType, Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd)
 
- Protected Member Functions inherited from llvm::User
void * operator new (size_t s, unsigned Us)
 
 User (Type *ty, unsigned vty, Use *OpList, unsigned NumOps)
 
UseallocHungoffUses (unsigned) const
 
void dropHungoffUses ()
 
template<int Idx>
UseOp ()
 
template<int Idx>
const UseOp () const
 
- Protected Member Functions inherited from llvm::Value
virtual void printCustom (raw_ostream &O) const
 
 Value (Type *Ty, unsigned scid)
 
unsigned short getSubclassDataFromValue () const
 
void setValueSubclassData (unsigned short D)
 
- Protected Member Functions inherited from llvm::ilist_node< Instruction >
 ilist_node ()
 

Additional Inherited Members

- Public Types inherited from llvm::Instruction
enum  OperationEquivalenceFlags { CompareIgnoringAlignment = 1<<0, CompareUsingScalarTypes = 1<<1 }
 
enum  TermOps
 
enum  BinaryOps
 
enum  MemoryOps
 
enum  CastOps
 
enum  OtherOps
 
- Public Types inherited from llvm::User
typedef Useop_iterator
 
typedef const Useconst_op_iterator
 
- Public Types inherited from llvm::Value
enum  ValueTy {
  ArgumentVal, BasicBlockVal, FunctionVal, GlobalAliasVal,
  GlobalVariableVal, UndefValueVal, BlockAddressVal, ConstantExprVal,
  ConstantAggregateZeroVal, ConstantDataArrayVal, ConstantDataVectorVal, ConstantIntVal,
  ConstantFPVal, ConstantArrayVal, ConstantStructVal, ConstantVectorVal,
  ConstantPointerNullVal, MDNodeVal, MDStringVal, InlineAsmVal,
  PseudoSourceValueVal, FixedStackPseudoSourceValueVal, InstructionVal, ConstantFirstVal = FunctionVal,
  ConstantLastVal = ConstantPointerNullVal
}
 
typedef value_use_iterator< Useruse_iterator
 
typedef value_use_iterator
< const User
const_use_iterator
 
- Static Public Attributes inherited from llvm::Value
static const unsigned MaximumAlignment = 1u << 29
 
- Static Protected Member Functions inherited from llvm::User
template<int Idx, typename U >
static UseOpFrom (const U *that)
 
- Protected Attributes inherited from llvm::User
UseOperandList
 
unsigned NumOperands
 
- Protected Attributes inherited from llvm::Value
unsigned char SubclassOptionalData: 7
 

Detailed Description

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

Definition at line 709 of file Instructions.h.

Member Function Documentation

bool GetElementPtrInst::accumulateConstantOffset ( const DataLayout DL,
APInt Offset 
) const

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 1430 of file Instructions.cpp.

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

static bool llvm::GetElementPtrInst::classof ( const Instruction I)
inlinestatic

Definition at line 863 of file Instructions.h.

References llvm::Instruction::getOpcode().

Referenced by classof().

static bool llvm::GetElementPtrInst::classof ( const Value V)
inlinestatic

Definition at line 866 of file Instructions.h.

References classof().

GetElementPtrInst * GetElementPtrInst::clone_impl ( ) const
protectedvirtual

Implements llvm::Instruction.

Definition at line 3511 of file Instructions.cpp.

References llvm::User::getNumOperands().

static GetElementPtrInst* llvm::GetElementPtrInst::Create ( Value Ptr,
ArrayRef< Value * >  IdxList,
const Twine NameStr = "",
Instruction InsertBefore = 0 
)
inlinestatic
static GetElementPtrInst* llvm::GetElementPtrInst::Create ( Value Ptr,
ArrayRef< Value * >  IdxList,
const Twine NameStr,
BasicBlock InsertAtEnd 
)
inlinestatic

Definition at line 733 of file Instructions.h.

References llvm::ArrayRef< T >::size().

static GetElementPtrInst* llvm::GetElementPtrInst::CreateInBounds ( Value Ptr,
ArrayRef< Value * >  IdxList,
const Twine NameStr = "",
Instruction InsertBefore = 0 
)
inlinestatic
static GetElementPtrInst* llvm::GetElementPtrInst::CreateInBounds ( Value Ptr,
ArrayRef< Value * >  IdxList,
const Twine NameStr,
BasicBlock InsertAtEnd 
)
inlinestatic

Definition at line 751 of file Instructions.h.

References Create(), and setIsInBounds().

llvm::GetElementPtrInst::DECLARE_TRANSPARENT_OPERAND_ACCESSORS ( Value  )

Transparently provide more efficient getOperand methods.

unsigned llvm::GetElementPtrInst::getAddressSpace ( ) const
inline

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

Definition at line 769 of file Instructions.h.

References getPointerAddressSpace().

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

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

Definition at line 813 of file Instructions.h.

References llvm::checkGEPType(), llvm::VectorType::get(), llvm::PointerType::get(), getIndexedType(), llvm::Type::getPointerAddressSpace(), llvm::Value::getType(), and llvm::Type::isVectorTy().

Type * GetElementPtrInst::getIndexedType ( Type Ptr,
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 1384 of file Instructions.cpp.

References getIndexedTypeInternal().

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

Type * GetElementPtrInst::getIndexedType ( Type Ptr,
ArrayRef< Constant * >  IdxList 
)
static

Definition at line 1388 of file Instructions.cpp.

References getIndexedTypeInternal().

Type * GetElementPtrInst::getIndexedType ( Type Ptr,
ArrayRef< uint64_t >  IdxList 
)
static

Definition at line 1393 of file Instructions.cpp.

References getIndexedTypeInternal().

unsigned llvm::GetElementPtrInst::getNumIndices ( ) const
inline

Definition at line 827 of file Instructions.h.

References llvm::User::getNumOperands().

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

unsigned llvm::GetElementPtrInst::getPointerAddressSpace ( ) const
inline

Returns the address space of the pointer operand.

Definition at line 807 of file Instructions.h.

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

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

Value* llvm::GetElementPtrInst::getPointerOperand ( )
inline
const Value* llvm::GetElementPtrInst::getPointerOperand ( ) const
inline

Definition at line 793 of file Instructions.h.

References llvm::User::getOperand().

static unsigned llvm::GetElementPtrInst::getPointerOperandIndex ( )
inlinestatic

Definition at line 796 of file Instructions.h.

Type* llvm::GetElementPtrInst::getPointerOperandType ( ) const
inline

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

Definition at line 802 of file Instructions.h.

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

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

SequentialType* llvm::GetElementPtrInst::getType ( ) const
inline
bool GetElementPtrInst::hasAllConstantIndices ( ) const

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 1414 of file Instructions.cpp.

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

Referenced by isSafeAndProfitableToSinkLoad().

bool GetElementPtrInst::hasAllZeroIndices ( ) const

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 1400 of file Instructions.cpp.

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

bool llvm::GetElementPtrInst::hasIndices ( ) const
inline

Definition at line 831 of file Instructions.h.

References llvm::User::getNumOperands().

op_iterator llvm::GetElementPtrInst::idx_begin ( )
inline

Definition at line 785 of file Instructions.h.

References llvm::User::op_begin().

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

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

Definition at line 786 of file Instructions.h.

References llvm::User::op_begin().

op_iterator llvm::GetElementPtrInst::idx_end ( )
inline

Definition at line 787 of file Instructions.h.

References llvm::User::op_end().

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

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

Definition at line 788 of file Instructions.h.

References llvm::User::op_end().

bool GetElementPtrInst::isInBounds ( ) const

isInBounds - Determine whether the GEP has the inbounds flag.

Definition at line 1426 of file Instructions.cpp.

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

void GetElementPtrInst::setIsInBounds ( bool  b = true)

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 1422 of file Instructions.cpp.

Referenced by BuildNew(), and CreateInBounds().


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