blob: 5894d356cb033eccfc782e24cc0b52f5d38f3252 [file] [log] [blame]
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001// 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
3// found in the LICENSE file.
4
5#ifndef V8_COMPILER_SELECT_LOWERING_H_
6#define V8_COMPILER_SELECT_LOWERING_H_
7
8#include <map>
9
10#include "src/compiler/graph-reducer.h"
11#include "src/zone-allocator.h"
12
13namespace v8 {
14namespace internal {
15namespace compiler {
16
17// Forward declarations.
18class CommonOperatorBuilder;
19class Graph;
20
21
22// Lowers Select nodes to diamonds.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000023class SelectLowering final : public Reducer {
Emily Bernierd0a1eb72015-03-24 16:35:39 -040024 public:
25 SelectLowering(Graph* graph, CommonOperatorBuilder* common);
26 ~SelectLowering();
27
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000028 Reduction Reduce(Node* node) override;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040029
30 private:
31 typedef std::multimap<Node*, Node*, std::less<Node*>,
32 zone_allocator<std::pair<Node* const, Node*>>> Merges;
33
34 bool ReachableFrom(Node* const sink, Node* const source);
35
36 CommonOperatorBuilder* common() const { return common_; }
37 Graph* graph() const { return graph_; }
38
39 CommonOperatorBuilder* common_;
40 Graph* graph_;
41 Merges merges_;
42};
43
44} // namespace compiler
45} // namespace internal
46} // namespace v8
47
48#endif // V8_COMPILER_SELECT_LOWERING_H_