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

Last change on this file since 4727 was 4657, checked in by nmedfort, 4 years ago

Initial introduction of a PabloFunction? type.

File size: 1006 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 PabloFunction;
11
12class CodeSinking {
13
14    struct BlockSetVector : public std::vector<PabloBlock *> {
15        inline bool insert(PabloBlock * block) {
16            const auto i = std::lower_bound(begin(), end(), block);
17            if (i == end() || *i != block) {
18                std::vector<PabloBlock *>::insert(i, block);
19                assert (std::is_sorted(begin(), end()));
20                return true;
21            }
22            return false;
23        }
24        inline bool count(PabloBlock * block) {
25            const auto i = std::lower_bound(begin(), end(), block);
26            return (i != end() && *i == block);
27        }
28    };
29
30public:
31    static bool optimize(PabloFunction & function);
32protected:
33    void sink(PabloBlock & block);
34    CodeSinking() { }
35private:
36    BlockSetVector mProcessed;
37};
38
39}
40
41#endif // PABLO_CODESINKING_HPP
Note: See TracBrowser for help on using the repository browser.