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

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

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