source: icGREP/icgrep-devel/icgrep/pablo/passes/factorizedfg.h @ 4919

Last change on this file since 4919 was 4919, checked in by nmedfort, 3 years ago

Work on lowering + some timing and papi information that will be cleaned up later.

File size: 2.7 KB
Line 
1#ifndef FACTORIZEDFG_H
2#define FACTORIZEDFG_H
3
4#include <boost/container/flat_map.hpp>
5#include <boost/circular_buffer.hpp>
6#include <vector>
7#include <set>
8
9namespace pablo {
10
11class PabloFunction;
12class PabloBlock;
13class Variadic;
14class Not;
15class Statement;
16class PabloAST;
17
18class FactorizeDFG {
19    using ScopeDepth = boost::container::flat_map<const PabloBlock *, unsigned>;
20    using ScopeSet = std::vector<PabloBlock *>;
21    using NodeSet = std::vector<PabloAST *>;
22    // using Variadics = std::vector<Variadic *>;
23    using Variadics = boost::circular_buffer<Variadic *>;
24
25    using VertexSet = std::vector<PabloAST *>;
26    using Biclique = std::pair<VertexSet, VertexSet>; // [{Operands}, {Users}]
27    // using BicliqueSet = boost::container::flat_set<Biclique>;
28    using BicliqueSet = std::vector<Biclique>;
29    using CheckSet = boost::container::flat_set<PabloAST *>;
30public:
31    static void transform(PabloFunction & function);
32protected:   
33    void enumerateScopeDepth(const PabloFunction & function);
34    void enumerateScopeDepth(const PabloBlock * const block, const unsigned depth);
35    static void deMorgansExpansion(Not * const var, PabloBlock * const block);
36    static void deMorgansExpansion(PabloBlock * const block);
37    void factor(PabloFunction & function) const;
38    // static void factor(PabloBlock * const block, BicliqueSet & bicliques);
39    // static void enumerateBicliques(Variadic * const var, BicliqueSet & bicliques);
40    static BicliqueSet findAllFactoringsOf(Variadic * const var);
41    static void independentCliqueSets(BicliqueSet & bicliques);
42    void processBicliques(BicliqueSet & bicliques) const;
43    // void factor(PabloBlock * const block, BicliqueSet & vars) const;
44    void factor(PabloBlock * const block, Variadics & vars) const;
45    void factor(Variadic * const var, Variadics & Q) const;
46    PabloBlock * findInsertionScope(const NodeSet & users) const;
47    CheckSet makeCheckSet(PabloBlock * const scope, const NodeSet & values) const;
48    Statement * firstIn(PabloBlock * const scope, Statement * stmt, const NodeSet & operands) const;
49    Statement * lastIn(PabloBlock * const scope, Statement * stmt, const NodeSet & users) const;
50    PabloBlock * findInsertionPoint(const NodeSet & operands, const NodeSet & users) const;
51    void lower(PabloFunction & function) const;
52    void lower(PabloBlock * const block) const;
53    Statement * lower(Variadic * const var, PabloBlock * block) const;
54    unsigned scopeDepthOf(const PabloBlock * const block) const;
55    unsigned scopeDepthOf(const PabloAST * const expr) const;
56    static void ensureLegality(PabloBlock * const block);
57    FactorizeDFG() : mNumOfVariadics(0) {}
58private:
59    unsigned        mNumOfVariadics;
60    ScopeDepth      mScopeDepth;
61};
62
63}
64
65#endif // FACTORIZEDFG_H
Note: See TracBrowser for help on using the repository browser.