Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(242)

Side by Side Diff: src/compiler/simplified-operator-reducer.cc

Issue 1202263006: [turbofan] Revive the useful parts of the SimplifiedOperatorReducer. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Reordered reducers. REBASE Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "src/compiler/simplified-operator-reducer.h"
6
7 #include "src/compiler/js-graph.h"
8 #include "src/compiler/machine-operator.h"
9 #include "src/compiler/node-matchers.h"
10 #include "src/compiler/operator-properties.h"
11
12 namespace v8 {
13 namespace internal {
14 namespace compiler {
15
16 SimplifiedOperatorReducer::SimplifiedOperatorReducer(JSGraph* jsgraph)
17 : jsgraph_(jsgraph), simplified_(jsgraph->zone()) {}
18
19
20 SimplifiedOperatorReducer::~SimplifiedOperatorReducer() {}
21
22
23 Reduction SimplifiedOperatorReducer::Reduce(Node* node) {
24 switch (node->opcode()) {
25 case IrOpcode::kBooleanNot: {
26 HeapObjectMatcher m(node->InputAt(0));
27 if (m.HasValue()) {
28 return Replace(
29 jsgraph()->BooleanConstant(!m.Value().handle()->BooleanValue()));
30 }
31 if (m.IsBooleanNot()) return Replace(m.InputAt(0));
32 break;
33 }
34 case IrOpcode::kChangeBitToBool: {
35 Int32Matcher m(node->InputAt(0));
36 if (m.Is(0)) return Replace(jsgraph()->FalseConstant());
37 if (m.Is(1)) return Replace(jsgraph()->TrueConstant());
38 if (m.IsChangeBoolToBit()) return Replace(m.InputAt(0));
39 break;
40 }
41 case IrOpcode::kChangeBoolToBit: {
42 HeapObjectMatcher m(node->InputAt(0));
43 if (m.HasValue()) return ReplaceInt32(m.Value().handle()->BooleanValue());
44 if (m.IsChangeBitToBool()) return Replace(m.InputAt(0));
45 break;
46 }
47 case IrOpcode::kChangeFloat64ToTagged: {
48 Float64Matcher m(node->InputAt(0));
49 if (m.HasValue()) return ReplaceNumber(m.Value());
50 break;
51 }
52 case IrOpcode::kChangeInt32ToTagged: {
53 Int32Matcher m(node->InputAt(0));
54 if (m.HasValue()) return ReplaceNumber(m.Value());
55 break;
56 }
57 case IrOpcode::kChangeTaggedToFloat64: {
58 NumberMatcher m(node->InputAt(0));
59 if (m.HasValue()) return ReplaceFloat64(m.Value());
60 if (m.IsChangeFloat64ToTagged()) return Replace(m.node()->InputAt(0));
61 if (m.IsChangeInt32ToTagged()) {
62 return Change(node, machine()->ChangeInt32ToFloat64(), m.InputAt(0));
63 }
64 if (m.IsChangeUint32ToTagged()) {
65 return Change(node, machine()->ChangeUint32ToFloat64(), m.InputAt(0));
66 }
67 break;
68 }
69 case IrOpcode::kChangeTaggedToInt32: {
70 NumberMatcher m(node->InputAt(0));
71 if (m.HasValue()) return ReplaceInt32(DoubleToInt32(m.Value()));
72 if (m.IsChangeFloat64ToTagged()) {
73 return Change(node, machine()->ChangeFloat64ToInt32(), m.InputAt(0));
74 }
75 if (m.IsChangeInt32ToTagged()) return Replace(m.InputAt(0));
76 break;
77 }
78 case IrOpcode::kChangeTaggedToUint32: {
79 NumberMatcher m(node->InputAt(0));
80 if (m.HasValue()) return ReplaceUint32(DoubleToUint32(m.Value()));
81 if (m.IsChangeFloat64ToTagged()) {
82 return Change(node, machine()->ChangeFloat64ToUint32(), m.InputAt(0));
83 }
84 if (m.IsChangeUint32ToTagged()) return Replace(m.InputAt(0));
85 break;
86 }
87 case IrOpcode::kChangeUint32ToTagged: {
88 Uint32Matcher m(node->InputAt(0));
89 if (m.HasValue()) return ReplaceNumber(FastUI2D(m.Value()));
90 break;
91 }
92 default:
93 break;
94 }
95 return NoChange();
96 }
97
98
99 Reduction SimplifiedOperatorReducer::Change(Node* node, const Operator* op,
100 Node* a) {
101 DCHECK_EQ(node->InputCount(), OperatorProperties::GetTotalInputCount(op));
102 DCHECK_LE(1, node->InputCount());
103 node->set_op(op);
104 node->ReplaceInput(0, a);
105 return Changed(node);
106 }
107
108
109 Reduction SimplifiedOperatorReducer::ReplaceFloat64(double value) {
110 return Replace(jsgraph()->Float64Constant(value));
111 }
112
113
114 Reduction SimplifiedOperatorReducer::ReplaceInt32(int32_t value) {
115 return Replace(jsgraph()->Int32Constant(value));
116 }
117
118
119 Reduction SimplifiedOperatorReducer::ReplaceNumber(double value) {
120 return Replace(jsgraph()->Constant(value));
121 }
122
123
124 Reduction SimplifiedOperatorReducer::ReplaceNumber(int32_t value) {
125 return Replace(jsgraph()->Constant(value));
126 }
127
128
129 Graph* SimplifiedOperatorReducer::graph() const { return jsgraph()->graph(); }
130
131
132 MachineOperatorBuilder* SimplifiedOperatorReducer::machine() const {
133 return jsgraph()->machine();
134 }
135
136 } // namespace compiler
137 } // namespace internal
138 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/simplified-operator-reducer.h ('k') | test/unittests/compiler/simplified-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698