OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_DIAMOND_H_ | 5 #ifndef V8_COMPILER_DIAMOND_H_ |
6 #define V8_COMPILER_DIAMOND_H_ | 6 #define V8_COMPILER_DIAMOND_H_ |
7 | 7 |
8 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
9 #include "src/compiler/graph.h" | 9 #include "src/compiler/graph.h" |
10 #include "src/compiler/node.h" | 10 #include "src/compiler/node.h" |
11 #include "src/compiler/node-properties.h" | |
12 | 11 |
13 namespace v8 { | 12 namespace v8 { |
14 namespace internal { | 13 namespace internal { |
15 namespace compiler { | 14 namespace compiler { |
16 | 15 |
17 // A helper to make it easier to build diamond-shaped control patterns. | 16 // A helper to make it easier to build diamond-shaped control patterns. |
18 struct Diamond { | 17 struct Diamond { |
19 Graph* graph; | 18 Graph* graph; |
20 CommonOperatorBuilder* common; | 19 CommonOperatorBuilder* common; |
21 Node* branch; | 20 Node* branch; |
(...skipping 28 matching lines...) Expand all Loading... |
50 } | 49 } |
51 } | 50 } |
52 | 51 |
53 Node* Phi(MachineType machine_type, Node* tv, Node* fv) { | 52 Node* Phi(MachineType machine_type, Node* tv, Node* fv) { |
54 return graph->NewNode(common->Phi(machine_type, 2), tv, fv, merge); | 53 return graph->NewNode(common->Phi(machine_type, 2), tv, fv, merge); |
55 } | 54 } |
56 | 55 |
57 Node* EffectPhi(Node* tv, Node* fv) { | 56 Node* EffectPhi(Node* tv, Node* fv) { |
58 return graph->NewNode(common->EffectPhi(2), tv, fv, merge); | 57 return graph->NewNode(common->EffectPhi(2), tv, fv, merge); |
59 } | 58 } |
| 59 }; |
60 | 60 |
61 void OverwriteWithPhi(Node* node, MachineType machine_type, Node* tv, | 61 } // namespace compiler |
62 Node* fv) { | 62 } // namespace internal |
63 DCHECK(node->InputCount() >= 3); | 63 } // namespace v8 |
64 node->ReplaceInput(0, tv); | |
65 node->ReplaceInput(1, fv); | |
66 node->ReplaceInput(2, merge); | |
67 node->TrimInputCount(3); | |
68 NodeProperties::ChangeOp(node, common->Phi(machine_type, 2)); | |
69 } | |
70 | |
71 void OverwriteWithEffectPhi(Node* node, Node* te, Node* fe) { | |
72 DCHECK(node->InputCount() >= 3); | |
73 node->ReplaceInput(0, te); | |
74 node->ReplaceInput(1, fe); | |
75 node->ReplaceInput(2, merge); | |
76 node->TrimInputCount(3); | |
77 NodeProperties::ChangeOp(node, common->EffectPhi(2)); | |
78 } | |
79 }; | |
80 } | |
81 } | |
82 } // namespace v8::internal::compiler | |
83 | 64 |
84 #endif // V8_COMPILER_DIAMOND_H_ | 65 #endif // V8_COMPILER_DIAMOND_H_ |
OLD | NEW |