OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_COMPILER_INSTRUCTION_SELECTOR_H_ | 5 #ifndef V8_COMPILER_INSTRUCTION_SELECTOR_H_ |
6 #define V8_COMPILER_INSTRUCTION_SELECTOR_H_ | 6 #define V8_COMPILER_INSTRUCTION_SELECTOR_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 | 9 |
10 #include "src/compiler/common-operator.h" | 10 #include "src/compiler/common-operator.h" |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 // =========================================================================== | 144 // =========================================================================== |
145 // ============ Architecture-independent graph covering methods. ============= | 145 // ============ Architecture-independent graph covering methods. ============= |
146 // =========================================================================== | 146 // =========================================================================== |
147 | 147 |
148 // Used in pattern matching during code generation. | 148 // Used in pattern matching during code generation. |
149 // Check if {node} can be covered while generating code for the current | 149 // Check if {node} can be covered while generating code for the current |
150 // instruction. A node can be covered if the {user} of the node has the only | 150 // instruction. A node can be covered if the {user} of the node has the only |
151 // edge and the two are in the same basic block. | 151 // edge and the two are in the same basic block. |
152 bool CanCover(Node* user, Node* node) const; | 152 bool CanCover(Node* user, Node* node) const; |
153 | 153 |
| 154 // Used in pattern matching during code generation. |
| 155 // This function checks that {node} and {user} are in the same basic block, |
| 156 // and that {user} is the only user of {node} in this basic block. This |
| 157 // check guarantees that there are no users of {node} scheduled between |
| 158 // {node} and {user}, and thus we can select a single instruction for both |
| 159 // nodes, if such an instruction exists. This check can be used for example |
| 160 // when selecting instructions for: |
| 161 // n = Int32Add(a, b) |
| 162 // c = Word32Compare(n, 0, cond) |
| 163 // Branch(c, true_label, false_label) |
| 164 // Here we can generate a flag-setting add instruction, even if the add has |
| 165 // uses in other basic blocks, since the flag-setting add instruction will |
| 166 // still generate the result of the addition and not just set the flags. |
| 167 // However, if we had uses of the add in the same basic block, we could have: |
| 168 // n = Int32Add(a, b) |
| 169 // o = OtherOp(n, ...) |
| 170 // c = Word32Compare(n, 0, cond) |
| 171 // Branch(c, true_label, false_label) |
| 172 // where we cannot select the add and the compare together. If we were to |
| 173 // select a flag-setting add instruction for Word32Compare and Int32Add while |
| 174 // visiting Word32Compare, we would then have to select an instruction for |
| 175 // OtherOp *afterwards*, which means we would attempt to use the result of |
| 176 // the add before we have defined it. |
| 177 bool IsOnlyUserOfNodeInSameBlock(Node* user, Node* node) const; |
| 178 |
154 // Checks if {node} was already defined, and therefore code was already | 179 // Checks if {node} was already defined, and therefore code was already |
155 // generated for it. | 180 // generated for it. |
156 bool IsDefined(Node* node) const; | 181 bool IsDefined(Node* node) const; |
157 | 182 |
158 // Checks if {node} has any uses, and therefore code has to be generated for | 183 // Checks if {node} has any uses, and therefore code has to be generated for |
159 // it. | 184 // it. |
160 bool IsUsed(Node* node) const; | 185 bool IsUsed(Node* node) const; |
161 | 186 |
162 // Checks if {node} is currently live. | 187 // Checks if {node} is currently live. |
163 bool IsLive(Node* node) const { return !IsDefined(node) && IsUsed(node); } | 188 bool IsLive(Node* node) const { return !IsDefined(node) && IsUsed(node); } |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 IntVector virtual_registers_; | 326 IntVector virtual_registers_; |
302 InstructionScheduler* scheduler_; | 327 InstructionScheduler* scheduler_; |
303 Frame* frame_; | 328 Frame* frame_; |
304 }; | 329 }; |
305 | 330 |
306 } // namespace compiler | 331 } // namespace compiler |
307 } // namespace internal | 332 } // namespace internal |
308 } // namespace v8 | 333 } // namespace v8 |
309 | 334 |
310 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_H_ | 335 #endif // V8_COMPILER_INSTRUCTION_SELECTOR_H_ |
OLD | NEW |