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
RevLine 
[4736]1#ifndef BOOLEANREASSOCIATIONPASS_H
2#define BOOLEANREASSOCIATIONPASS_H
3
4#include <pablo/codegenstate.h>
[4753]5#include <boost/container/flat_map.hpp>
6#include <boost/graph/adjacency_list.hpp>
[4736]7
8namespace pablo {
9
[4753]10class BooleanReassociationPass {
[4754]11public:
[4769]12    using VertexData = std::pair<PabloAST::ClassTypeId, PabloAST *>;
13    using Graph = boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, VertexData, PabloAST *>;
[4756]14    using Vertex = Graph::vertex_descriptor;
[4764]15    using Map = std::unordered_map<const PabloAST *, Vertex>;
[4775]16    using ScopeMap = boost::container::flat_map<const PabloBlock *, Statement *>;
[4736]17    static bool optimize(PabloFunction & function);
18protected:
[4756]19    inline BooleanReassociationPass() {}
[4753]20    void resolveScopes(PabloFunction & function);
[4870]21    void resolveScopes(PabloBlock * const block);
[4753]22    void processScopes(PabloFunction & function);
[4870]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);
[4797]32    static Vertex addSummaryVertex(const PabloAST::ClassTypeId typeId, Graph & G);
[4753]33private:
[4775]34    ScopeMap mResolvedScopes;
[4736]35};
36
37}
38
39#endif // BOOLEANREASSOCIATIONPASS_H
Note: See TracBrowser for help on using the repository browser.