blob: 7d7f938b765bbe8d1e96753a1168583525ce3ce1 [file] [log] [blame]
Ben Murdochc5610432016-08-08 18:44:38 +01001// Copyright 2016 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_EFFECT_CONTROL_LINEARIZER_H_
6#define V8_COMPILER_EFFECT_CONTROL_LINEARIZER_H_
7
8#include "src/compiler/common-operator.h"
9#include "src/compiler/node.h"
10#include "src/compiler/simplified-operator.h"
11
12namespace v8 {
13namespace internal {
14
15class Zone;
16
17namespace compiler {
18
19class CommonOperatorBuilder;
20class SimplifiedOperatorBuilder;
21class MachineOperatorBuilder;
22class JSGraph;
23class Graph;
24class Schedule;
25
26class EffectControlLinearizer {
27 public:
28 EffectControlLinearizer(JSGraph* graph, Schedule* schedule, Zone* temp_zone);
29
30 void Run();
31
32 private:
33 void ProcessNode(Node* node, Node** current_effect, Node** control);
34
35 struct ValueEffectControl {
36 Node* value;
37 Node* effect;
38 Node* control;
39 ValueEffectControl(Node* value, Node* effect, Node* control)
40 : value(value), effect(effect), control(control) {}
41 };
42
43 bool TryWireInStateEffect(Node* node, Node** effect, Node** control);
44 ValueEffectControl LowerTypeGuard(Node* node, Node* effect, Node* control);
45 ValueEffectControl LowerChangeBitToTagged(Node* node, Node* effect,
46 Node* control);
47 ValueEffectControl LowerChangeInt31ToTaggedSigned(Node* node, Node* effect,
48 Node* control);
49 ValueEffectControl LowerChangeInt32ToTagged(Node* node, Node* effect,
50 Node* control);
51 ValueEffectControl LowerChangeUint32ToTagged(Node* node, Node* effect,
52 Node* control);
53 ValueEffectControl LowerChangeFloat64ToTagged(Node* node, Node* effect,
54 Node* control);
55 ValueEffectControl LowerChangeTaggedSignedToInt32(Node* node, Node* effect,
56 Node* control);
57 ValueEffectControl LowerChangeTaggedToBit(Node* node, Node* effect,
58 Node* control);
59 ValueEffectControl LowerChangeTaggedToInt32(Node* node, Node* effect,
60 Node* control);
61 ValueEffectControl LowerChangeTaggedToUint32(Node* node, Node* effect,
62 Node* control);
63 ValueEffectControl LowerChangeTaggedToFloat64(Node* node, Node* effect,
64 Node* control);
65 ValueEffectControl LowerTruncateTaggedToWord32(Node* node, Node* effect,
66 Node* control);
67 ValueEffectControl LowerObjectIsCallable(Node* node, Node* effect,
68 Node* control);
69 ValueEffectControl LowerObjectIsNumber(Node* node, Node* effect,
70 Node* control);
71 ValueEffectControl LowerObjectIsReceiver(Node* node, Node* effect,
72 Node* control);
73 ValueEffectControl LowerObjectIsSmi(Node* node, Node* effect, Node* control);
74 ValueEffectControl LowerObjectIsString(Node* node, Node* effect,
75 Node* control);
76 ValueEffectControl LowerObjectIsUndetectable(Node* node, Node* effect,
77 Node* control);
78 ValueEffectControl AllocateHeapNumberWithValue(Node* node, Node* effect,
79 Node* control);
80
81 Node* ChangeInt32ToSmi(Node* value);
82 Node* ChangeUint32ToSmi(Node* value);
83 Node* ChangeInt32ToFloat64(Node* value);
84 Node* ChangeUint32ToFloat64(Node* value);
85 Node* ChangeSmiToInt32(Node* value);
86 Node* ObjectIsSmi(Node* value);
87
88 Node* SmiMaxValueConstant();
89 Node* SmiShiftBitsConstant();
90
91 JSGraph* jsgraph() const { return js_graph_; }
92 Graph* graph() const;
93 Schedule* schedule() const { return schedule_; }
94 Zone* temp_zone() const { return temp_zone_; }
95 CommonOperatorBuilder* common() const;
96 SimplifiedOperatorBuilder* simplified() const;
97 MachineOperatorBuilder* machine() const;
98
99 JSGraph* js_graph_;
100 Schedule* schedule_;
101 Zone* temp_zone_;
102};
103
104} // namespace compiler
105} // namespace internal
106} // namespace v8
107
108#endif // V8_COMPILER_EFFECT_CONTROL_LINEARIZER_H_