|
5 | 5 | #include "cinderx/Common/concepts.h" |
6 | 6 | #include "cinderx/Jit/codegen/environ.h" |
7 | 7 | #include "cinderx/Jit/lir/block.h" |
8 | | -#include "cinderx/Jit/lir/printer.h" |
9 | 8 |
|
10 | 9 | #include <functional> |
11 | | -#include <memory> |
12 | 10 | #include <type_traits> |
13 | 11 | #include <utility> |
14 | 12 | #include <vector> |
@@ -42,23 +40,15 @@ using instruction_rewrite_t = function_type_t<instruction_rewrite_arg_t>; |
42 | 40 | // This class implements a framework for LIR rewrites. |
43 | 41 | class Rewrite { |
44 | 42 | public: |
45 | | - Rewrite(Function* func, codegen::Environ* env) : function_(func), env_(env) {} |
| 43 | + Rewrite(Function* func, codegen::Environ* env); |
46 | 44 |
|
47 | | - Function* function() { |
48 | | - return function_; |
49 | | - } |
50 | | - |
51 | | - const Function* function() const { |
52 | | - return function_; |
53 | | - } |
| 45 | + // Get the function being rewritten. |
| 46 | + Function* function(); |
| 47 | + const Function* function() const; |
54 | 48 |
|
55 | | - codegen::Environ* environment() { |
56 | | - return env_; |
57 | | - } |
58 | | - |
59 | | - const codegen::Environ* environment() const { |
60 | | - return env_; |
61 | | - } |
| 49 | + // Get the codegen environment. |
| 50 | + codegen::Environ* environment(); |
| 51 | + const codegen::Environ* environment() const; |
62 | 52 |
|
63 | 53 | template <typename T> |
64 | 54 | void registerOneRewriteFunction(RewriteResult (*rewrite)(T), int stage = 0) { |
@@ -114,14 +104,14 @@ class Rewrite { |
114 | 104 | template < |
115 | 105 | AnyOf<function_rewrite_t, basic_block_rewrite_t, instruction_rewrite_t> T, |
116 | 106 | typename V> |
117 | | - bool runOneTypeRewrites(const std::vector<T>& rewrites, V&& arg) { |
| 107 | + bool runOneTypeRewrites(const std::vector<T>& rewrites, const V& arg) { |
118 | 108 | bool changed = false; |
119 | 109 | bool loop_changed = false; |
120 | 110 |
|
121 | 111 | do { |
122 | 112 | loop_changed = false; |
123 | 113 | for (auto& rewrite : rewrites) { |
124 | | - auto r = rewrite(std::forward<V>(arg)); |
| 114 | + auto r = rewrite(arg); |
125 | 115 | loop_changed |= (r != kUnchanged); |
126 | 116 |
|
127 | 117 | if (r == kRemoved) { |
|
0 commit comments