source: icGREP/icgrep-devel/icgrep/pablo/optimizers/codemotionpass.h @ 4870

Last change on this file since 4870 was 4870, checked in by nmedfort, 3 years ago

Bug fix for Multiplexing. Added ability to set the body of a If/While? node after creation.

File size: 1.1 KB
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 CodeMotionPass {
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    static void process(PabloBlock * const block);
33    static bool isAcceptableTarget(Statement *stmt, ScopeSet & scopeSet, const PabloBlock * const block);
34    static void sink(PabloBlock * const block);
35    static void hoistLoopInvariants(While * loop);
36};
37
38}
39
40#endif // PABLO_CODESINKING_HPP
Note: See TracBrowser for help on using the repository browser.