Go to the documentation of this file.
18 #ifndef LLVM_ANALYSIS_TARGETFOLDER_H
19 #define LLVM_ANALYSIS_TARGETFOLDER_H
41 virtual void anchor();
53 bool HasNSW =
false)
const override {
54 auto *LC = dyn_cast<Constant>(
LHS);
55 auto *RC = dyn_cast<Constant>(
RHS);
62 auto *LC = dyn_cast<Constant>(
LHS);
63 auto *RC = dyn_cast<Constant>(
RHS);
70 auto *LC = dyn_cast<Constant>(
LHS);
71 auto *RC = dyn_cast<Constant>(
RHS);
78 auto *LC = dyn_cast<Constant>(
LHS);
79 auto *RC = dyn_cast<Constant>(
RHS);
86 bool IsInBounds =
false)
const override {
87 if (
auto *PC = dyn_cast<Constant>(Ptr)) {
89 if (
any_of(IdxList, [](
Value *V) {
return !isa<Constant>(V); }))
100 auto *CC = dyn_cast<Constant>(
C);
101 auto *TC = dyn_cast<Constant>(True);
102 auto *
FC = dyn_cast<Constant>(False);
111 if (
auto *CAgg = dyn_cast<Constant>(Agg))
118 auto *CAgg = dyn_cast<Constant>(Agg);
119 auto *CVal = dyn_cast<Constant>(Val);
133 bool HasNUW =
false,
bool HasNSW =
false)
const override {
140 bool HasNUW =
false,
bool HasNSW =
false)
const override {
147 bool isExact =
false)
const override {
151 bool isExact =
false)
const override {
167 bool HasNUW =
false,
bool HasNSW =
false)
const override {
171 bool isExact =
false)
const override {
175 bool isExact =
false)
const override {
192 bool HasNUW =
false,
bool HasNSW =
false)
const override {
211 Type *DestTy)
const override {
212 if (
C->getType() == DestTy)
217 bool isSigned)
const override {
218 if (
C->getType() == DestTy)
223 if (
C->getType() == DestTy)
228 if (
C->getType() == DestTy)
233 return CreateCast(Instruction::BitCast,
C, DestTy);
236 return CreateCast(Instruction::IntToPtr,
C, DestTy);
239 return CreateCast(Instruction::PtrToInt,
C, DestTy);
242 if (
C->getType() == DestTy)
247 if (
C->getType() == DestTy)
252 if (
C->getType() == DestTy)
258 Type *DestTy)
const override {
259 if (
C->getType() == DestTy)
Value * FoldAnd(Value *LHS, Value *RHS) const override
Constant * CreateFSub(Constant *LHS, Constant *RHS) const override
Value * FoldExtractValue(Value *Agg, ArrayRef< unsigned > IdxList) const override
This is an optimization pass for GlobalISel generic memory operations.
static Constant * getFDiv(Constant *C1, Constant *C2)
static Constant * getExtractElement(Constant *Vec, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
static Constant * getNot(Constant *C)
static Constant * getZExtOrBitCast(Constant *C, Type *Ty)
A parsed version of the target data layout string in and methods for querying it.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
Value * FoldGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, bool IsInBounds=false) const override
Value * FoldICmp(CmpInst::Predicate P, Value *LHS, Value *RHS) const override
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
static Constant * getFRem(Constant *C1, Constant *C2)
Constant * CreateFRem(Constant *LHS, Constant *RHS) const override
static Constant * getFPCast(Constant *C, Type *Ty)
Create a FPExt, Bitcast or FPTrunc for fp -> fp casts.
IRBuilderFolder - Interface for constant folding in IRBuilder.
Constant * CreateFCmp(CmpInst::Predicate P, Constant *LHS, Constant *RHS) const override
Constant * CreatePtrToInt(Constant *C, Type *DestTy) const override
Constant * CreateXor(Constant *LHS, Constant *RHS) const override
static Constant * getSelect(Constant *C, Constant *V1, Constant *V2, Type *OnlyIfReducedTy=nullptr)
Select constant expr.
static Constant * getInsertValue(Constant *Agg, Constant *Val, ArrayRef< unsigned > Idxs, Type *OnlyIfReducedTy=nullptr)
The instances of the Type class are immutable: once they are created, they are never changed.
Constant * CreateSDiv(Constant *LHS, Constant *RHS, bool isExact=false) const override
Constant * CreateMul(Constant *LHS, Constant *RHS, bool HasNUW=false, bool HasNSW=false) const override
static Constant * getInBoundsGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList)
Create an "inbounds" getelementptr.
Constant * CreateNot(Constant *C) const override
Constant * CreateFAdd(Constant *LHS, Constant *RHS) const override
static Constant * getPointerCast(Constant *C, Type *Ty)
Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant expression.
static Constant * getSub(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
constexpr std::underlying_type_t< E > Mask()
Get a bitmask with 1s in all places up to the high-order bit of E's largest value.
(vector float) vec_cmpeq(*A, *B) C
Constant * CreateLShr(Constant *LHS, Constant *RHS, bool isExact=false) const override
static Constant * getUDiv(Constant *C1, Constant *C2, bool isExact=false)
static Constant * getXor(Constant *C1, Constant *C2)
static Constant * getURem(Constant *C1, Constant *C2)
Constant * CreateExtractElement(Constant *Vec, Constant *Idx) const override
Constant * CreatePointerCast(Constant *C, Type *DestTy) const override
static Constant * getFNeg(Constant *C)
Constant * CreateNeg(Constant *C, bool HasNUW=false, bool HasNSW=false) const override
static Constant * getAShr(Constant *C1, Constant *C2, bool isExact=false)
Constant * CreateBitCast(Constant *C, Type *DestTy) const override
static Constant * getShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask, Type *OnlyIfReducedTy=nullptr)
static Constant * getCompare(unsigned short pred, Constant *C1, Constant *C2, bool OnlyIfReduced=false)
Return an ICmp or FCmp comparison operator constant expression.
Constant * CreateFPCast(Constant *C, Type *DestTy) const override
This is an important base class in LLVM.
static Constant * get(unsigned Opcode, Constant *C1, unsigned Flags=0, Type *OnlyIfReducedTy=nullptr)
get - Return a unary operator constant expression, folding if possible.
Constant * CreateUDiv(Constant *LHS, Constant *RHS, bool isExact=false) const override
static Constant * getShl(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
static Constant * getFSub(Constant *C1, Constant *C2)
static Constant * getOr(Constant *C1, Constant *C2)
Constant * CreateUnOp(Instruction::UnaryOps Opc, Constant *C) const override
Value * FoldInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > IdxList) const override
Value * FoldSelect(Value *C, Value *True, Value *False) const override
static Constant * getCast(unsigned ops, Constant *C, Type *Ty, bool OnlyIfReduced=false)
Convenience function for getting a Cast operation.
static Constant * getTruncOrBitCast(Constant *C, Type *Ty)
Constant * CreateSRem(Constant *LHS, Constant *RHS) const override
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
Constant * CreatePointerBitCastOrAddrSpaceCast(Constant *C, Type *DestTy) const override
Value * FoldAdd(Value *LHS, Value *RHS, bool HasNUW=false, bool HasNSW=false) const override
static Constant * getSExtOrBitCast(Constant *C, Type *Ty)
Constant * CreateIntCast(Constant *C, Type *DestTy, bool isSigned) const override
Constant * CreateZExtOrBitCast(Constant *C, Type *DestTy) const override
Constant * CreateFMul(Constant *LHS, Constant *RHS) const override
static Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
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 * getFMul(Constant *C1, Constant *C2)
Constant * CreateCast(Instruction::CastOps Op, Constant *C, Type *DestTy) const override
Constant * CreateSExtOrBitCast(Constant *C, Type *DestTy) const override
Constant * CreateBinOp(Instruction::BinaryOps Opc, Constant *LHS, Constant *RHS) const override
static Constant * getSDiv(Constant *C1, Constant *C2, bool isExact=false)
TargetFolder - Create constants with target dependent folding.
TargetFolder(const DataLayout &DL)
static Constant * getNeg(Constant *C, bool HasNUW=false, bool HasNSW=false)
static Constant * getAdd(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
static Constant * getAnd(Constant *C1, Constant *C2)
static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, bool InBounds=false, Optional< unsigned > InRangeIndex=None, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
static Constant * getLShr(Constant *C1, Constant *C2, bool isExact=false)
Constant * CreateIntToPtr(Constant *C, Type *DestTy) const override
Constant * CreateFNeg(Constant *C) const override
Constant * CreateShl(Constant *LHS, Constant *RHS, bool HasNUW=false, bool HasNSW=false) const override
Constant * CreateShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask) const override
static Constant * getPointerBitCastOrAddrSpaceCast(Constant *C, Type *Ty)
Create a BitCast or AddrSpaceCast for a pointer type depending on the address space.
static Constant * getSRem(Constant *C1, Constant *C2)
static Constant * getMul(Constant *C1, Constant *C2, bool HasNUW=false, bool HasNSW=false)
Constant * ConstantFoldConstant(const Constant *C, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr)
ConstantFoldConstant - Fold the constant using the specified DataLayout.
Constant * CreateSub(Constant *LHS, Constant *RHS, bool HasNUW=false, bool HasNSW=false) const override
Value * FoldOr(Value *LHS, Value *RHS) const override
Constant * CreateTruncOrBitCast(Constant *C, Type *DestTy) const override
static Constant * getFAdd(Constant *C1, Constant *C2)
Constant * CreateURem(Constant *LHS, Constant *RHS) const override
Constant * CreateFDiv(Constant *LHS, Constant *RHS) const override
Constant * CreateAShr(Constant *LHS, Constant *RHS, bool isExact=false) const override
LLVM Value Representation.
static Constant * getExtractValue(Constant *Agg, ArrayRef< unsigned > Idxs, Type *OnlyIfReducedTy=nullptr)
Constant * CreateInsertElement(Constant *Vec, Constant *NewElt, Constant *Idx) const override