Ignore:
Timestamp:
Feb 26, 2015, 3:35:19 PM (5 years ago)
Author:
nmedfort
Message:

added code sinking module; disabled by default as it hurts performance unless if-insertions occur.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • icGREP/icgrep-devel/icgrep/pablo/optimizers/pablo_codesinking.hpp

    r4516 r4521  
    33
    44#include <pablo/codegenstate.h>
     5#include <vector>
     6#include <algorithm>
    57
    68namespace pablo {
    79
    8 class CodeSinking
    9 {
     10class CodeSinking {
     11
     12    struct BlockSetVector : public std::vector<PabloBlock *> {
     13        inline bool insert(PabloBlock * block) {
     14            const auto i = std::lower_bound(begin(), end(), block);
     15            if (i == end() || *i != block) {
     16                std::vector<PabloBlock *>::insert(i, block);
     17                assert (std::is_sorted(begin(), end()));
     18                return true;
     19            }
     20            return false;
     21        }
     22        inline bool count(PabloBlock * block) {
     23            const auto i = std::lower_bound(begin(), end(), block);
     24            return (i != end() && *i == block);
     25        }
     26    };
     27
    1028public:
    1129    static bool optimize(PabloBlock & block);
    1230protected:
    13     static void sink(PabloBlock & block);
    14     CodeSinking();
     31    void sink(PabloBlock & block);
     32    CodeSinking() { }
     33private:
     34    BlockSetVector mProcessed;
    1535};
    1636
Note: See TracChangeset for help on using the changeset viewer.