15 #ifndef LLVM_ANALYSIS_UTILS_LOCAL_H 16 #define LLVM_ANALYSIS_UTILS_LOCAL_H 28 template <
typename IRBuilderTy>
30 bool NoAssumptions =
false) {
37 bool isInBounds = GEPOp->
isInBounds() && !NoAssumptions;
40 unsigned IntPtrWidth = IntPtrTy->getScalarType()->getIntegerBitWidth();
41 uint64_t PtrSizeMask =
49 if (
Constant *OpC = dyn_cast<Constant>(Op)) {
50 if (OpC->isZeroValue())
55 if (OpC->getType()->isVectorTy())
56 OpC = OpC->getSplatValue();
58 uint64_t OpValue = cast<ConstantInt>(OpC)->getZExtValue();
71 Result = Builder->CreateAdd(Result, Scale, GEP->
getName()+
".offs");
76 Op = Builder->CreateIntCast(Op, IntPtrTy,
true, Op->
getName()+
".c");
80 GEP->
getName()+
".idx", isInBounds );
84 Result = Builder->CreateAdd(Op, Result, GEP->
getName()+
".offs");
91 #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. ...
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
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...
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.
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.
IntegerType * getIntPtrType(LLVMContext &C, unsigned AddressSpace=0) const
Returns an integer type with size at least as big as that of a pointer in the given address space...
The instances of the Type class are immutable: once they are created, they are never changed...
This is an important base class in LLVM.
Type * getIndexedType() const
StructType * getStructTypeOrNull() const
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 getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
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)