Go to the documentation of this file.
13 #ifndef LLVM_TRANSFORMS_UTILS_EVALUATOR_H
14 #define LLVM_TRANSFORMS_UTILS_EVALUATOR_H
31 class TargetLibraryInfo;
38 struct MutableAggregate;
50 MutableValue(
const MutableValue &) =
delete;
51 MutableValue(MutableValue &&
Other) {
55 ~MutableValue() {
clear(); }
60 return Val.
get<MutableAggregate *>()->Ty;
66 return Val.
get<MutableAggregate *>()->toConstant();
73 struct MutableAggregate {
77 MutableAggregate(
Type *Ty) : Ty(Ty) {}
84 ValueStack.emplace_back();
88 for (
auto &Tmp : AllocaTmps)
92 if (!Tmp->use_empty())
104 for (
auto &Pair : MutatedMemory)
105 Result[Pair.first] = Pair.second.toConstant();
115 bool &StrippedPointerCastsForAliasAnalysis);
118 if (
Constant *CV = dyn_cast<Constant>(V))
return CV;
119 Constant *R = ValueStack.back().lookup(V);
120 assert(R &&
"Reference to an uncomputed value!");
124 void setVal(
Value *V, Constant *
C) {
125 ValueStack.back()[V] =
C;
132 Function *getCalleeWithFormalArgs(CallBase &CB,
133 SmallVectorImpl<Constant *> &Formals);
137 bool getFormalParams(CallBase &CB, Function *
F,
138 SmallVectorImpl<Constant *> &Formals);
140 Constant *ComputeLoadResult(Constant *
P, Type *Ty);
141 Constant *ComputeLoadResult(GlobalVariable *GV, Type *Ty,
142 const APInt &Offset);
147 std::deque<DenseMap<Value*, Constant*>> ValueStack;
151 SmallVector<Function*, 4> CallStack;
156 DenseMap<GlobalVariable *, MutableValue> MutatedMemory;
161 SmallVector<std::unique_ptr<GlobalVariable>, 32> AllocaTmps;
165 SmallPtrSet<GlobalVariable*, 8> Invariants;
169 SmallPtrSet<Constant*, 8> SimpleConstants;
171 const DataLayout &DL;
172 const TargetLibraryInfo *TLI;
177 #endif // LLVM_TRANSFORMS_UTILS_EVALUATOR_H
This is an optimization pass for GlobalISel generic memory operations.
bool EvaluateFunction(Function *F, Constant *&RetVal, const SmallVectorImpl< Constant * > &ActualArgs)
Evaluate a call to function F, returning true if successful, false if we can't evaluate it.
A parsed version of the target data layout string in and methods for querying it.
InstListType::iterator iterator
Instruction iterators...
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
Error write(MCStreamer &Out, ArrayRef< std::string > Inputs)
The instances of the Type class are immutable: once they are created, they are never changed.
T get() const
Returns the value of the specified pointer type.
LLVM Basic Block Representation.
static void clear(coro::Shape &Shape)
FunctionType * getType(LLVMContext &Context, ID id, ArrayRef< Type * > Tys=None)
Return the function type for an intrinsic.
Evaluator(const DataLayout &DL, const TargetLibraryInfo *TLI)
(vector float) vec_cmpeq(*A, *B) C
DenseMap< GlobalVariable *, Constant * > getMutatedInitializers() const
const SmallPtrSetImpl< GlobalVariable * > & getInvariants() const
This is an important base class in LLVM.
T dyn_cast() const
Returns the current pointer if it is of the specified pointer type, otherwise returns null.
This class evaluates LLVM IR, producing the Constant representing each SSA instruction.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Class for arbitrary precision integers.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
A discriminated union of two or more pointer types, with the discriminator in the low bit of the poin...
static Constant * getNullValue(Type *Ty)
Constructor to create a '0' constant of arbitrary type.
value_type read(const void *memory, endianness endian)
Read a value of a particular endianness from memory.
Provides information about what library functions are available for the current target.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
LLVM Value Representation.
Optional< std::vector< StOtherPiece > > Other