18#ifndef LLVM_ANALYSIS_TARGETFOLDER_H
19#define LLVM_ANALYSIS_TARGETFOLDER_H
42 virtual void anchor();
56 auto *LC = dyn_cast<Constant>(
LHS);
57 auto *RC = dyn_cast<Constant>(
RHS);
67 bool IsExact)
const override {
68 auto *LC = dyn_cast<Constant>(
LHS);
69 auto *RC = dyn_cast<Constant>(
RHS);
80 bool HasNUW,
bool HasNSW)
const override {
81 auto *LC = dyn_cast<Constant>(
LHS);
82 auto *RC = dyn_cast<Constant>(
RHS);
103 auto *LC = dyn_cast<Constant>(
LHS);
104 auto *RC = dyn_cast<Constant>(
RHS);
118 bool IsInBounds =
false)
const override {
122 if (
auto *PC = dyn_cast<Constant>(
Ptr)) {
124 if (
any_of(IdxList, [](
Value *V) {
return !isa<Constant>(V); }))
135 auto *
CC = dyn_cast<Constant>(
C);
136 auto *TC = dyn_cast<Constant>(True);
137 auto *FC = dyn_cast<Constant>(False);
146 if (
auto *CAgg = dyn_cast<Constant>(Agg))
153 auto *CAgg = dyn_cast<Constant>(Agg);
154 auto *CVal = dyn_cast<Constant>(Val);
161 auto *CVec = dyn_cast<Constant>(Vec);
162 auto *CIdx = dyn_cast<Constant>(
Idx);
170 auto *CVec = dyn_cast<Constant>(Vec);
171 auto *CNewElt = dyn_cast<Constant>(NewElt);
172 auto *CIdx = dyn_cast<Constant>(
Idx);
173 if (CVec && CNewElt && CIdx)
180 auto *C1 = dyn_cast<Constant>(V1);
181 auto *C2 = dyn_cast<Constant>(V2);
188 Type *DestTy)
const override {
189 if (
auto *
C = dyn_cast<Constant>(V))
199 if (
C->getType() == DestTy)
205 Type *DestTy)
const override {
206 if (
C->getType() == DestTy)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
static Constant * getExtractElement(Constant *Vec, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
static Constant * getInBoundsGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList)
Create an "inbounds" getelementptr.
static Constant * getPointerCast(Constant *C, Type *Ty)
Create a BitCast, AddrSpaceCast, or a PtrToInt cast constant expression.
static Constant * getPointerBitCastOrAddrSpaceCast(Constant *C, Type *Ty)
Create a BitCast or AddrSpaceCast for a pointer type depending on the address space.
static Constant * getInsertElement(Constant *Vec, Constant *Elt, Constant *Idx, Type *OnlyIfReducedTy=nullptr)
static Constant * getShuffleVector(Constant *V1, Constant *V2, ArrayRef< int > Mask, Type *OnlyIfReducedTy=nullptr)
static bool isSupportedGetElementPtr(const Type *SrcElemTy)
Whether creating a constant expression for this getelementptr type is supported.
static Constant * getGetElementPtr(Type *Ty, Constant *C, ArrayRef< Constant * > IdxList, bool InBounds=false, std::optional< unsigned > InRangeIndex=std::nullopt, Type *OnlyIfReducedTy=nullptr)
Getelementptr form.
static Constant * get(unsigned Opcode, Constant *C1, Constant *C2, unsigned Flags=0, Type *OnlyIfReducedTy=nullptr)
get - Return a binary or shift operator constant expression, folding if possible.
static bool isDesirableBinOp(unsigned Opcode)
Whether creating a constant expression for this binary operator is desirable.
static Constant * getCompare(unsigned short pred, Constant *C1, Constant *C2, bool OnlyIfReduced=false)
Return an ICmp or FCmp comparison operator constant expression.
This is an important base class in LLVM.
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
Convenience struct for specifying and reasoning about fast-math flags.
IRBuilderFolder - Interface for constant folding in IRBuilder.
TargetFolder - Create constants with target dependent folding.
Value * FoldICmp(CmpInst::Predicate P, Value *LHS, Value *RHS) const override
Constant * CreatePointerCast(Constant *C, Type *DestTy) const override
Value * FoldShuffleVector(Value *V1, Value *V2, ArrayRef< int > Mask) const override
TargetFolder(const DataLayout &DL)
Value * FoldInsertElement(Value *Vec, Value *NewElt, Value *Idx) const override
Value * FoldSelect(Value *C, Value *True, Value *False) const override
Constant * CreateFCmp(CmpInst::Predicate P, Constant *LHS, Constant *RHS) const override
Value * FoldExtractValue(Value *Agg, ArrayRef< unsigned > IdxList) const override
Value * FoldExactBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, bool IsExact) const override
Constant * CreatePointerBitCastOrAddrSpaceCast(Constant *C, Type *DestTy) const override
Value * FoldUnOpFMF(Instruction::UnaryOps Opc, Value *V, FastMathFlags FMF) const override
Value * FoldNoWrapBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, bool HasNUW, bool HasNSW) const override
Value * FoldBinOp(Instruction::BinaryOps Opc, Value *LHS, Value *RHS) const override
Value * FoldBinOpFMF(Instruction::BinaryOps Opc, Value *LHS, Value *RHS, FastMathFlags FMF) const override
Value * FoldGEP(Type *Ty, Value *Ptr, ArrayRef< Value * > IdxList, bool IsInBounds=false) const override
Value * FoldInsertValue(Value *Agg, Value *Val, ArrayRef< unsigned > IdxList) const override
Value * FoldExtractElement(Value *Vec, Value *Idx) const override
Value * FoldCast(Instruction::CastOps Op, Value *V, Type *DestTy) const override
The instances of the Type class are immutable: once they are created, they are never changed.
LLVM Value Representation.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
Constant * ConstantFoldSelectInstruction(Constant *Cond, Constant *V1, Constant *V2)
Attempt to constant fold a select instruction with the specified operands.
Constant * ConstantFoldExtractValueInstruction(Constant *Agg, ArrayRef< unsigned > Idxs)
Attempt to constant fold an extractvalue instruction with the specified operands and indices.
Constant * ConstantFoldConstant(const Constant *C, const DataLayout &DL, const TargetLibraryInfo *TLI=nullptr)
ConstantFoldConstant - Fold the constant using the specified DataLayout.
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 * ConstantFoldUnaryOpOperand(unsigned Opcode, Constant *Op, const DataLayout &DL)
Attempt to constant fold a unary operation with the specified operand.
Constant * ConstantFoldCastOperand(unsigned Opcode, Constant *C, Type *DestTy, const DataLayout &DL)
Attempt to constant fold a cast with the specified operand.
Constant * ConstantFoldBinaryOpOperands(unsigned Opcode, Constant *LHS, Constant *RHS, const DataLayout &DL)
Attempt to constant fold a binary operation with the specified operands.
Constant * ConstantFoldInsertValueInstruction(Constant *Agg, Constant *Val, ArrayRef< unsigned > Idxs)
ConstantFoldInsertValueInstruction - Attempt to constant fold an insertvalue instruction with the spe...