Go to the documentation of this file.
14 #ifndef LLVM_ANALYSIS_UTILS_LOCAL_H
15 #define LLVM_ANALYSIS_UTILS_LOCAL_H
28 template <
typename IRBuilderTy>
30 bool NoAssumptions =
false) {
32 Type *IntIdxTy =
DL.getIndexType(
GEP->getType());
33 Value *Result =
nullptr;
37 bool isInBounds = GEPOp->
isInBounds() && !NoAssumptions;
51 if (OpC->isZeroValue())
56 uint64_t OpValue = OpC->getUniqueInteger().getZExtValue();
57 Size =
DL.getStructLayout(STy)->getElementOffset(OpValue);
64 if (IntIdxTy->
isVectorTy() && !OpC->getType()->isVectorTy())
66 cast<VectorType>(IntIdxTy)->getElementCount(), OpC);
76 if (IntIdxTy->
isVectorTy() && !
Op->getType()->isVectorTy())
78 cast<FixedVectorType>(IntIdxTy)->getNumElements(),
Op);
81 if (
Op->getType() != IntIdxTy)
82 Op =
Builder->CreateIntCast(
Op, IntIdxTy,
true,
Op->getName().str()+
".c");
86 GEP->getName().str() +
".idx",
false ,
93 Result =
Builder->CreateAdd(Result, Offset,
GEP->getName().str()+
".offs",
103 #endif // LLVM_ANALYSIS_UTILS_LOCAL_H
This is an optimization pass for GlobalISel generic memory operations.
A parsed version of the target data layout string in and methods for querying it.
Type * getScalarType() const
If this is a vector type, return the element type, otherwise return 'this'.
The instances of the Type class are immutable: once they are created, they are never changed.
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
gep_type_iterator gep_type_begin(const User *GEP)
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...
bool isVectorTy() const
True if this is an instance of VectorType.
static Constant * getSplat(ElementCount EC, Constant *Elt)
Return a ConstantVector with the specified constant in each element.
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.
StructType * getStructTypeOrNull() const
unsigned getIntegerBitWidth() const
This is an important base class in LLVM.
Type * getIndexedType() const
Class to represent struct types.
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 * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
bool isInBounds() const
Test whether this is an inbounds GEP, as defined by LangRef.html.
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
LLVM Value Representation.
A Use represents the edge between a Value definition and its users.