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

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

Work on better scheduling in reassociation pass.

File size: 1.8 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 VertexData = std::pair<PabloAST::ClassTypeId, PabloAST *>;
13    using Graph = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, VertexData, PabloAST *>;
14    using Vertex = Graph::vertex_descriptor;
15    using Map = std::unordered_map<const PabloAST *, Vertex>;
16    using WrittenAt = boost::container::flat_map<const PabloAST *, unsigned>;
17    using ScopeMap = boost::container::flat_map<const PabloBlock *, Statement *>;
18    static bool optimize(PabloFunction & function);
19protected:
20    inline BooleanReassociationPass() {}
21    void resolveScopes(PabloFunction & function);
22    void resolveScopes(PabloBlock &block);
23    void processScopes(PabloFunction & function);
24    void processScopes(PabloFunction & function, PabloBlock & block);
25    void processScope(PabloFunction &, PabloBlock & block);
26    void summarizeAST(PabloBlock & block, Graph & G, Map & M) const;
27    static void summarizeGraph(const PabloBlock & block, Graph & G, std::vector<Vertex> & mapping, Map &M);
28    void resolveUsages(const Vertex u, PabloAST * expr, PabloBlock & block, Graph & G, Map & M, const Statement * const ignoreIfThis = nullptr) const;
29    void redistributeAST(const PabloBlock & block, Graph & G, Map & M) const;
30    void rewriteAST(PabloBlock & block, Graph & G);
31    static PabloAST * createTree(PabloBlock & block, const Vertex u, Graph & G);
32    static Vertex getSummaryVertex(PabloAST * expr, Graph & G, Map & M, const PabloBlock & block);
33    static Vertex addSummaryVertex(const PabloAST::ClassTypeId typeId, Graph & G);
34private:
35    ScopeMap mResolvedScopes;
36};
37
38}
39
40#endif // BOOLEANREASSOCIATIONPASS_H
Note: See TracBrowser for help on using the repository browser.