Ignore:
Timestamp:
Jan 29, 2016, 3:38:47 PM (4 years ago)
Author:
nmedfort
Message:

Incorporated a few common case boolean optimizations in the Simplifier.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/passes/factorizedfg.h

    r4919 r4922  
    22#define FACTORIZEDFG_H
    33
     4
     5#include <boost/container/flat_set.hpp>
    46#include <boost/container/flat_map.hpp>
    5 #include <boost/circular_buffer.hpp>
     7#include <pablo/pabloAST.h>
    68#include <vector>
    7 #include <set>
    89
    910namespace pablo {
     
    1213class PabloBlock;
    1314class Variadic;
    14 class Not;
    1515class Statement;
    1616class PabloAST;
    1717
    1818class FactorizeDFG {
     19
    1920    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>;
     21    using ObjectSet = std::vector<PabloAST *>;
     22    using ScopeUsers = std::pair<PabloBlock *, ObjectSet>;
     23    using Biclique = std::pair<ObjectSet, ObjectSet>; // [{Operands}, {Users}]
    2824    using BicliqueSet = std::vector<Biclique>;
    2925    using CheckSet = boost::container::flat_set<PabloAST *>;
     26    using TypeId = PabloAST::ClassTypeId;
    3027public:
    3128    static void transform(PabloFunction & function);
    3229protected:   
    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;
     30    void initialize(PabloFunction &function);
     31    void initialize(PabloBlock * const block, const unsigned depth);
     32
     33    unsigned scopeDepthOf(const PabloBlock * const block) const;
     34    unsigned scopeDepthOf(const PabloAST * const expr) const;
     35
     36    CheckSet makeCheckSet(PabloBlock * const scope, const ObjectSet & values) const;
     37    Statement * firstIn(PabloBlock * const scope, Statement * const initial, const ObjectSet & operands) const;
     38    Statement * lastIn(PabloBlock * const scope, Statement * const initial, const ObjectSet & users) const;
     39    Variadic * factorize(const TypeId typeId, PabloBlock * const scope, ObjectSet & operands, ObjectSet & users) const;
     40    static BicliqueSet independentFactoringSets(BicliqueSet && factoringSets, const unsigned side);
     41    static BicliqueSet enumerateFactoringSets(Variadic * const var);
     42    static BicliqueSet enumerateFactoringSets(ObjectSet params, PabloBlock * const entryScope, const TypeId typeId);
     43    bool processFactoringSets(const TypeId typeId, PabloBlock * const scope, BicliqueSet && factoringSets) const;
     44    PabloBlock * findInsertionScope(const ObjectSet & users) const;
     45    bool processFactoringSets(const TypeId typeId, BicliqueSet && factoringSets, ObjectSet & factorings) const;
     46    bool factor(PabloBlock * const block);
     47    void factor(PabloFunction & function, const TypeId typeId);
     48    void factor(PabloFunction & function);
     49
    5150    void lower(PabloFunction & function) const;
    5251    void lower(PabloBlock * const block) const;
    5352    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) {}
     53
     54    FactorizeDFG() = default;
     55
    5856private:
    59     unsigned        mNumOfVariadics;
    60     ScopeDepth      mScopeDepth;
     57    ScopeDepth              mScopeDepth;
    6158};
    6259
Note: See TracChangeset for help on using the changeset viewer.