23 User *
GEP,
bool NoAssumptions) {
25 Type *IntIdxTy =
DL.getIndexType(
GEP->getType());
26 Value *Result =
nullptr;
30 bool isInBounds = GEPOp->
isInBounds() && !NoAssumptions;
35 std::numeric_limits<uint64_t>::max() >> (64 - IntPtrWidth);
43 if (
Constant *OpC = dyn_cast<Constant>(Op)) {
44 if (OpC->isZeroValue())
49 uint64_t OpValue = OpC->getUniqueInteger().getZExtValue();
50 Size =
DL.getStructLayout(STy)->getElementOffset(OpValue);
57 if (IntIdxTy->
isVectorTy() && !OpC->getType()->isVectorTy())
59 cast<VectorType>(IntIdxTy)->getElementCount(), OpC);
69 if (IntIdxTy->
isVectorTy() && !Op->getType()->isVectorTy())
70 Op =
Builder->CreateVectorSplat(
71 cast<FixedVectorType>(IntIdxTy)->getNumElements(), Op);
74 if (Op->getType() != IntIdxTy)
75 Op =
Builder->CreateIntCast(Op, IntIdxTy,
true, Op->getName() +
".c");
79 GEP->getName() +
".idx",
false ,
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static Constant * getIntegerCast(Constant *C, Type *Ty, bool IsSigned)
Create a ZExt, Bitcast or Trunc for integer -> integer casts.
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
static Constant * get(Type *Ty, uint64_t V, bool IsSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
static Constant * getSplat(ElementCount EC, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
This is an important base class in LLVM.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
A parsed version of the target data layout string in and methods for querying it.
bool isInBounds() const
Test whether this is an inbounds GEP, as defined by LangRef.html.
Common base class shared among various IRBuilders.
Class to represent struct types.
The instances of the Type class are immutable: once they are created, they are never changed.
unsigned getIntegerBitWidth() const
bool isVectorTy() const
True if this is an instance of VectorType.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
StructType * getStructTypeOrNull() const
Type * getIndexedType() const
This is an optimization pass for GlobalISel generic memory operations.
Value * emitGEPOffset(IRBuilderBase *Builder, const DataLayout &DL, User *GEP, bool NoAssumptions=false)
Given a getelementptr instruction/constantexpr, emit the code necessary to compute the offset from th...
gep_type_iterator gep_type_begin(const User *GEP)