14 #ifndef LLVM_ANALYSIS_UTILS_LOCAL_H 15 #define LLVM_ANALYSIS_UTILS_LOCAL_H 28 template <
typename IRBuilderTy>
30 bool NoAssumptions =
false) {
37 bool isInBounds = GEPOp->
isInBounds() && !NoAssumptions;
40 unsigned IntPtrWidth = IntIdxTy->getScalarType()->getIntegerBitWidth();
41 uint64_t PtrSizeMask =
49 if (
Constant *OpC = dyn_cast<Constant>(Op)) {
50 if (OpC->isZeroValue())
55 uint64_t OpValue = OpC->getUniqueInteger().getZExtValue();
65 if (IntIdxTy->isVectorTy() && !OpC->getType()->isVectorTy())
73 Result = Builder->CreateAdd(Result, Scale, GEP->
getName()+
".offs");
79 Op = Builder->CreateVectorSplat(IntIdxTy->getVectorNumElements(),
Op);
83 Op = Builder->CreateIntCast(Op, IntIdxTy,
true, Op->
getName()+
".c");
87 GEP->
getName() +
".idx",
false ,
92 Result = Builder->CreateAdd(Op, Result, GEP->
getName()+
".offs");
99 #endif // LLVM_TRANSFORMS_UTILS_LOCAL_H Value * EmitGEPOffset(IRBuilderTy *Builder, const DataLayout &DL, User *GEP, bool NoAssumptions=false)
Given a getelementptr instruction/constantexpr, emit the code necessary to compute the offset from th...
A parsed version of the target data layout string in and methods for querying it. ...
This class represents lattice values for constants.
const StructLayout * getStructLayout(StructType *Ty) const
Returns a StructLayout object, indicating the alignment of the struct, its size, and the offsets of i...
bool isVectorTy() const
True if this is an instance of VectorType.
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
static Constant * getIntegerCast(Constant *C, Type *Ty, bool isSigned)
Create a ZExt, Bitcast or Trunc for integer -> integer casts.
Type * getIndexType(Type *PtrTy) const
Returns the type of a GEP index.
Class to represent struct types.
A Use represents the edge between a Value definition and its users.
Type * getType() const
All values are typed, get the type of this value.
bool isInBounds() const
Test whether this is an inbounds GEP, as defined by LangRef.html.
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important base class in LLVM.
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
Type * getIndexedType() const
static Constant * getSplat(unsigned NumElts, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
StructType * getStructTypeOrNull() const
Align max(MaybeAlign Lhs, Align Rhs)
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.
uint64_t getElementOffset(unsigned Idx) const
StringRef getName() const
Return a constant reference to the value's name.
LLVM Value Representation.
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
gep_type_iterator gep_type_begin(const User *GEP)