llir-opt
0.0.1
Low-Level Post-Link Optimiser for OCaml and C
|
9 #include <unordered_map>
11 #include <llvm/ADT/iterator.h>
12 #include <llvm/ADT/iterator_range.h>
15 #include "core/func.h"
16 #include "passes/pre_eval/symbolic_value.h"
19 class SymbolicFrameObject;
21 class MemoryStoreInst;
32 using ObjectMap = std::map<unsigned, ID<SymbolicObject>>;
37 , ObjectMap::const_iterator
38 , std::random_access_iterator_tag
43 : iterator_adaptor_base(it)
57 llvm::ArrayRef<SymbolicValue> args,
69 Func *
GetFunc() {
return func_ ? &func_->GetFunc() :
nullptr; }
113 std::set<DAGBlock *> &
nodes,
114 std::set<SymbolicContext *> &ctx,
121 std::set<DAGBlock *> &
nodes,
122 std::set<SymbolicContext *> &ctx,
159 llvm::iterator_range<DAGFunc::node_iterator>
nodes()
161 return llvm::make_range(func_->begin(), func_->end());
166 object_iterator object_end() {
return object_iterator(objects_.end()); }
167 llvm::iterator_range<object_iterator> objects()
182 std::vector<SymbolicValue> args_;
190 std::unordered_map<DAGBlock *, std::shared_ptr<SymbolicContext>> bypass_;
192 std::set<Block *> executed_;
194 std::unordered_map<Block *, unsigned> counts_;
std::map< unsigned, ID< SymbolicObject > > ObjectMap
Mapping from indices to frame objects.
Definition: symbolic_frame.h:32
Definition: symbolic_context.h:28
bool Limited(Block *block)
Check whether the counter of a loop expired.
Definition: symbolic_frame.cpp:163
SymbolicFrame(SymbolicSummary &ctx, DAGFunc &func, unsigned index, llvm::ArrayRef< SymbolicValue > args, llvm::ArrayRef< ID< SymbolicObject >> objects)
Create a new frame.
Definition: symbolic_frame.cpp:22
Definition: symbolic_value.h:24
const Func * GetFunc() const
Return the function.
Definition: symbolic_frame.h:71
bool IsExecuted(Block *block)
Check whether the nodes was executed.
Definition: symbolic_frame.h:151
void Approximate(Block *block)
Mask a node as approximated.
Definition: symbolic_frame.h:153
bool FindBypassed(std::set< DAGBlock * > &nodes, std::set< SymbolicContext * > &ctx, Block *start, Block *end)
Find bypasses for a node pair.
Definition: symbolic_frame.h:120
void Leave()
De-activate the frame.
Definition: symbolic_frame.cpp:58
DAGBlock * GetNode(Block *block)
Return the node for a block.
Definition: symbolic_frame.h:136
bool IsBypassed(Block *node)
Check whether the node was bypassed.
Definition: symbolic_frame.h:147
Definition: symbolic_summary.h:17
const SymbolicValue & Arg(unsigned index)
Return the value of an argument.
Definition: symbolic_frame.h:100
bool IsValid() const
Check if the frame is valid.
Definition: symbolic_frame.h:82
bool IsBypassed(DAGBlock *node)
Check whether the node was bypassed.
Definition: symbolic_frame.h:149
unsigned GetNumArgs() const
Returns the number of arguments.
Definition: symbolic_frame.h:97
const SymbolicValue & Find(ConstRef< Inst > inst)
Return the value an instruction was mapped to.
Definition: symbolic_frame.cpp:86
llvm::iterator_range< DAGFunc::node_iterator > nodes()
Iterator over the nodes of the function.
Definition: symbolic_frame.h:159
Iterator over objects.
Definition: symbolic_frame.h:35
SymbolicContext * GetBypass(DAGBlock *node)
Return the bypassed context for the current node.
Definition: symbolic_frame.cpp:156
bool Set(Ref< Inst > i, const SymbolicValue &value)
Definition: symbolic_frame.cpp:68
ID< SymbolicObject > GetObject(unsigned object)
Return a specific object.
Definition: symbolic_frame.cpp:105
bool FindBypassed(std::set< DAGBlock * > &nodes, std::set< SymbolicContext * > &ctx, DAGBlock *start, DAGBlock *end)
Definition: symbolic_frame.cpp:128
Definition: symbolic_frame.h:29
void Continue(Block *node)
Enter a node for execution.
Definition: symbolic_frame.cpp:169
const SymbolicValue * FindOpt(ConstRef< Inst > inst)
Return the value, if it was already defined.
Definition: symbolic_frame.cpp:94
void Bypass(DAGBlock *node, const SymbolicContext &ctx)
Bypass a node.
Definition: symbolic_frame.cpp:176
ID< SymbolicFrame > GetIndex() const
Return the index.
Definition: symbolic_frame.h:77
object_iterator object_begin()
Iterator over objects.
Definition: symbolic_frame.h:165
void Merge(const SymbolicFrame &that)
Merges another frame into this one.
Definition: symbolic_frame.cpp:113
DAGBlock * Find(Block *block)
Find the node which contains a block.
Definition: symbolic_frame.h:156
Block * GetCurrentBlock() const
Return the current node.
Definition: symbolic_frame.h:133
Func * GetFunc()
Return the function.
Definition: symbolic_frame.h:69