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

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

Progress on multi-target UCD compilation

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