source: icGREP/icgrep-devel/icgrep/pablo/optimizers/booleanreassociationpass.h @ 4768

Last change on this file since 4768 was 4768, checked in by nmedfort, 4 years ago

More reassociation pass work.

File size: 1.3 KB
Line 
1#ifndef BOOLEANREASSOCIATIONPASS_H
2#define BOOLEANREASSOCIATIONPASS_H
3
4#include <pablo/codegenstate.h>
5#include <boost/container/flat_map.hpp>
6#include <boost/graph/adjacency_list.hpp>
7
8namespace pablo {
9
10class BooleanReassociationPass {
11public:
12    using Graph = boost::adjacency_list<boost::hash_setS, boost::vecS, boost::bidirectionalS, PabloAST *, PabloAST *>;
13    using Vertex = Graph::vertex_descriptor;
14    using Map = std::unordered_map<const PabloAST *, Vertex>;
15
16    static bool optimize(PabloFunction & function);
17protected:
18    inline BooleanReassociationPass() {}
19    void resolveScopes(PabloFunction & function);
20    void resolveScopes(PabloBlock &block);
21    void processScopes(PabloFunction & function);
22    void processScopes(PabloFunction & function, PabloBlock & block);
23    void processScope(PabloFunction & function, PabloBlock & block);
24    void summarizeAST(PabloBlock & block, Graph & G) const;
25    static bool summarizeGraph(PabloBlock & block, Graph & G);
26    void resolveUsages(const Vertex u, PabloAST * expr, PabloBlock & block, Graph & G, Map & M, Statement * ignoreIfThis = nullptr) const;
27    bool redistributeAST(PabloBlock & block, Graph & G) const;
28private:
29    boost::container::flat_map<PabloBlock *, Statement *> mResolvedScopes;
30};
31
32}
33
34#endif // BOOLEANREASSOCIATIONPASS_H
Note: See TracBrowser for help on using the repository browser.