Chromium Code Reviews| Index: src/compiler/node-matchers.cc |
| diff --git a/src/compiler/node-matchers.cc b/src/compiler/node-matchers.cc |
| index c6ae39000c025ae98f6f1b8a0ad67faf148c185e..e7b5d1b97fedc801d88987b6d748f52796be4ea7 100644 |
| --- a/src/compiler/node-matchers.cc |
| +++ b/src/compiler/node-matchers.cc |
| @@ -12,6 +12,50 @@ bool NodeMatcher::IsComparison() const { |
| return IrOpcode::IsComparisonOpcode(opcode()); |
| } |
| + |
| +BranchMatcher::BranchMatcher(Node* branch) |
| + : NodeMatcher(branch), if_true_(nullptr), if_false_(nullptr) { |
| + if (branch->opcode() != IrOpcode::kBranch) return; |
| + for (Node* use : branch->uses()) { |
| + if (use->opcode() == IrOpcode::kIfTrue) { |
| + DCHECK_NULL(if_true_); |
| + if_true_ = use; |
| + } else if (use->opcode() == IrOpcode::kIfFalse) { |
| + DCHECK_NULL(if_false_); |
| + if_false_ = use; |
| + } |
| + } |
| +} |
| + |
| + |
| +DiamondMatcher::DiamondMatcher(Node* merge) |
| + : NodeMatcher(merge), |
| + branch_(nullptr), |
| + if_true_(nullptr), |
| + if_false_(nullptr) { |
| + if (merge->InputCount() != 2) return; |
| + if (merge->opcode() != IrOpcode::kMerge) return; |
| + Node* input0 = merge->InputAt(0); |
| + if (input0->InputCount() != 1) return; |
| + Node* input1 = merge->InputAt(1); |
| + if (input1->InputCount() != 1) return; |
| + Node* branch = input0->InputAt(0); |
| + if (branch != input1->InputAt(0)) return; |
| + if (branch->opcode() != IrOpcode::kBranch) return; |
| + if (input0->opcode() == IrOpcode::kIfTrue && |
| + input1->opcode() == IrOpcode::kIfFalse) { |
| + branch_ = branch; |
| + if_true_ = input0; |
| + if_false_ = input1; |
| + } |
| + if (input0->opcode() == IrOpcode::kIfFalse && |
|
Benedikt Meurer
2015/04/07 07:19:01
Nit: Use else if.
titzer
2015/04/07 08:41:00
Done.
|
| + input1->opcode() == IrOpcode::kIfTrue) { |
| + branch_ = branch; |
| + if_true_ = input1; |
| + if_false_ = input0; |
| + } |
| +} |
| + |
| } // namespace compiler |
| } // namespace internal |
| } // namespace v8 |