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

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

Merged PabloFunction? and PabloKernel? classes. Updated projects where necessary.

File size: 1.1 KB
Line 
1#ifndef PABLO_CODESINKING_HPP
2#define PABLO_CODESINKING_HPP
3
4#include <vector>
5#include <algorithm>
6
7namespace pablo {
8
9class PabloKernel;
10class PabloBlock;
11class Statement;
12class While;
13class Variadic;
14
15class CodeMotionPass {
16    struct ScopeSet : public std::vector<PabloBlock *> {
17        inline bool insert(PabloBlock * block) {
18            const auto i = std::lower_bound(begin(), end(), block);
19            if (i == end() || *i != block) {
20                std::vector<PabloBlock *>::insert(i, block);
21                return true;
22            }
23            return false;
24        }
25        inline bool count(PabloBlock * block) {
26            const auto i = std::lower_bound(begin(), end(), block);
27            return (i != end() && *i == block);
28        }
29    };
30public:
31    static bool optimize(PabloKernel * kernel);
32protected:
33    static void movement(PabloBlock * const block);
34    static bool isAcceptableTarget(Statement *stmt, ScopeSet & scopeSet, const PabloBlock * const block);
35    static void sink(PabloBlock * const block);
36    static void hoistLoopInvariants(While * loop);
37};
38
39}
40
41#endif // PABLO_CODESINKING_HPP
Note: See TracBrowser for help on using the repository browser.