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

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

Bug fix for Multiplexing. Added ability to set the body of a If/While? node after creation.

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 * const block);
22    void processScopes(PabloFunction & function);
23    PabloBlock * processScopes(PabloFunction & f, PabloBlock * const block);
24    PabloBlock * processScope(PabloFunction & f, PabloBlock * const block);
25    void summarizeAST(PabloBlock * const block, Graph & G) const;
26    static void summarizeGraph(Graph & G, std::vector<Vertex> & mapping);
27    void resolveNestedUsages(const Vertex u, PabloAST * expr, PabloBlock * const block, Graph & G, Map & M, const Statement * const ignoreIfThis = nullptr) const;
28    void redistributeAST(Graph & G) const;
29    PabloBlock * rewriteAST(PabloFunction & f, PabloBlock * const block, Graph & G);
30    static PabloAST * createTree(const PabloBlock * const block, PabloBlock * const newScope, const Vertex u, Graph & G);
31    static Vertex getSummaryVertex(PabloAST * expr, Graph & G, Map & M, const PabloBlock * const 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.