source: icGREP/icgrep-devel/icgrep/pablo/optimizers/pablo_codesinking.hpp @ 4532

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

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

File size: 978 bytes
Line 
1#ifndef PABLO_CODESINKING_HPP
2#define PABLO_CODESINKING_HPP
3
4#include <pablo/codegenstate.h>
5#include <vector>
6#include <algorithm>
7
8namespace pablo {
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
28public:
29    static bool optimize(PabloBlock & block);
30protected:
31    void sink(PabloBlock & block);
32    CodeSinking() { }
33private:
34    BlockSetVector mProcessed;
35};
36
37}
38
39#endif // PABLO_CODESINKING_HPP
Note: See TracBrowser for help on using the repository browser.