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

Side by Side Diff: src/compiler/representation-change.h

Issue 552653003: [turbofan] Fix the node matchers. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address nit. Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler/operator.h ('k') | src/compiler/simplified-operator-reducer.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 the V8 project authors. All rights reserved. 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 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_REPRESENTATION_CHANGE_H_ 5 #ifndef V8_COMPILER_REPRESENTATION_CHANGE_H_
6 #define V8_COMPILER_REPRESENTATION_CHANGE_H_ 6 #define V8_COMPILER_REPRESENTATION_CHANGE_H_
7 7
8 #include "src/base/bits.h" 8 #include "src/base/bits.h"
9 #include "src/compiler/js-graph.h" 9 #include "src/compiler/js-graph.h"
10 #include "src/compiler/machine-operator.h" 10 #include "src/compiler/machine-operator.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 67 }
68 68
69 Node* GetTaggedRepresentationFor(Node* node, MachineTypeUnion output_type) { 69 Node* GetTaggedRepresentationFor(Node* node, MachineTypeUnion output_type) {
70 // Eagerly fold representation changes for constants. 70 // Eagerly fold representation changes for constants.
71 switch (node->opcode()) { 71 switch (node->opcode()) {
72 case IrOpcode::kNumberConstant: 72 case IrOpcode::kNumberConstant:
73 case IrOpcode::kHeapConstant: 73 case IrOpcode::kHeapConstant:
74 return node; // No change necessary. 74 return node; // No change necessary.
75 case IrOpcode::kInt32Constant: 75 case IrOpcode::kInt32Constant:
76 if (output_type & kTypeUint32) { 76 if (output_type & kTypeUint32) {
77 uint32_t value = ValueOf<uint32_t>(node->op()); 77 uint32_t value = OpParameter<uint32_t>(node);
78 return jsgraph()->Constant(static_cast<double>(value)); 78 return jsgraph()->Constant(static_cast<double>(value));
79 } else if (output_type & kTypeInt32) { 79 } else if (output_type & kTypeInt32) {
80 int32_t value = ValueOf<int32_t>(node->op()); 80 int32_t value = OpParameter<int32_t>(node);
81 return jsgraph()->Constant(value); 81 return jsgraph()->Constant(value);
82 } else if (output_type & kRepBit) { 82 } else if (output_type & kRepBit) {
83 return ValueOf<int32_t>(node->op()) == 0 ? jsgraph()->FalseConstant() 83 return OpParameter<int32_t>(node) == 0 ? jsgraph()->FalseConstant()
84 : jsgraph()->TrueConstant(); 84 : jsgraph()->TrueConstant();
85 } else { 85 } else {
86 return TypeError(node, output_type, kRepTagged); 86 return TypeError(node, output_type, kRepTagged);
87 } 87 }
88 case IrOpcode::kFloat64Constant: 88 case IrOpcode::kFloat64Constant:
89 return jsgraph()->Constant(ValueOf<double>(node->op())); 89 return jsgraph()->Constant(OpParameter<double>(node));
90 default: 90 default:
91 break; 91 break;
92 } 92 }
93 // Select the correct X -> Tagged operator. 93 // Select the correct X -> Tagged operator.
94 Operator* op; 94 Operator* op;
95 if (output_type & kRepBit) { 95 if (output_type & kRepBit) {
96 op = simplified()->ChangeBitToBool(); 96 op = simplified()->ChangeBitToBool();
97 } else if (output_type & rWord) { 97 } else if (output_type & rWord) {
98 if (output_type & kTypeUint32) { 98 if (output_type & kTypeUint32) {
99 op = simplified()->ChangeUint32ToTagged(); 99 op = simplified()->ChangeUint32ToTagged();
100 } else if (output_type & kTypeInt32) { 100 } else if (output_type & kTypeInt32) {
101 op = simplified()->ChangeInt32ToTagged(); 101 op = simplified()->ChangeInt32ToTagged();
102 } else { 102 } else {
103 return TypeError(node, output_type, kRepTagged); 103 return TypeError(node, output_type, kRepTagged);
104 } 104 }
105 } else if (output_type & kRepFloat64) { 105 } else if (output_type & kRepFloat64) {
106 op = simplified()->ChangeFloat64ToTagged(); 106 op = simplified()->ChangeFloat64ToTagged();
107 } else { 107 } else {
108 return TypeError(node, output_type, kRepTagged); 108 return TypeError(node, output_type, kRepTagged);
109 } 109 }
110 return jsgraph()->graph()->NewNode(op, node); 110 return jsgraph()->graph()->NewNode(op, node);
111 } 111 }
112 112
113 Node* GetFloat64RepresentationFor(Node* node, MachineTypeUnion output_type) { 113 Node* GetFloat64RepresentationFor(Node* node, MachineTypeUnion output_type) {
114 // Eagerly fold representation changes for constants. 114 // Eagerly fold representation changes for constants.
115 switch (node->opcode()) { 115 switch (node->opcode()) {
116 case IrOpcode::kNumberConstant: 116 case IrOpcode::kNumberConstant:
117 return jsgraph()->Float64Constant(ValueOf<double>(node->op())); 117 return jsgraph()->Float64Constant(OpParameter<double>(node));
118 case IrOpcode::kInt32Constant: 118 case IrOpcode::kInt32Constant:
119 if (output_type & kTypeUint32) { 119 if (output_type & kTypeUint32) {
120 uint32_t value = ValueOf<uint32_t>(node->op()); 120 uint32_t value = OpParameter<uint32_t>(node);
121 return jsgraph()->Float64Constant(static_cast<double>(value)); 121 return jsgraph()->Float64Constant(static_cast<double>(value));
122 } else { 122 } else {
123 int32_t value = ValueOf<int32_t>(node->op()); 123 int32_t value = OpParameter<int32_t>(node);
124 return jsgraph()->Float64Constant(value); 124 return jsgraph()->Float64Constant(value);
125 } 125 }
126 case IrOpcode::kFloat64Constant: 126 case IrOpcode::kFloat64Constant:
127 return node; // No change necessary. 127 return node; // No change necessary.
128 default: 128 default:
129 break; 129 break;
130 } 130 }
131 // Select the correct X -> Float64 operator. 131 // Select the correct X -> Float64 operator.
132 Operator* op; 132 Operator* op;
133 if (output_type & kRepBit) { 133 if (output_type & kRepBit) {
(...skipping 13 matching lines...) Expand all
147 } 147 }
148 148
149 Node* GetWord32RepresentationFor(Node* node, MachineTypeUnion output_type, 149 Node* GetWord32RepresentationFor(Node* node, MachineTypeUnion output_type,
150 bool use_unsigned) { 150 bool use_unsigned) {
151 // Eagerly fold representation changes for constants. 151 // Eagerly fold representation changes for constants.
152 switch (node->opcode()) { 152 switch (node->opcode()) {
153 case IrOpcode::kInt32Constant: 153 case IrOpcode::kInt32Constant:
154 return node; // No change necessary. 154 return node; // No change necessary.
155 case IrOpcode::kNumberConstant: 155 case IrOpcode::kNumberConstant:
156 case IrOpcode::kFloat64Constant: { 156 case IrOpcode::kFloat64Constant: {
157 double value = ValueOf<double>(node->op()); 157 double value = OpParameter<double>(node);
158 if (value < 0) { 158 if (value < 0) {
159 DCHECK(IsInt32Double(value)); 159 DCHECK(IsInt32Double(value));
160 int32_t iv = static_cast<int32_t>(value); 160 int32_t iv = static_cast<int32_t>(value);
161 return jsgraph()->Int32Constant(iv); 161 return jsgraph()->Int32Constant(iv);
162 } else { 162 } else {
163 DCHECK(IsUint32Double(value)); 163 DCHECK(IsUint32Double(value));
164 int32_t iv = static_cast<int32_t>(static_cast<uint32_t>(value)); 164 int32_t iv = static_cast<int32_t>(static_cast<uint32_t>(value));
165 return jsgraph()->Int32Constant(iv); 165 return jsgraph()->Int32Constant(iv);
166 } 166 }
167 } 167 }
(...skipping 17 matching lines...) Expand all
185 } else { 185 } else {
186 return TypeError(node, output_type, kRepWord32); 186 return TypeError(node, output_type, kRepWord32);
187 } 187 }
188 return jsgraph()->graph()->NewNode(op, node); 188 return jsgraph()->graph()->NewNode(op, node);
189 } 189 }
190 190
191 Node* GetBitRepresentationFor(Node* node, MachineTypeUnion output_type) { 191 Node* GetBitRepresentationFor(Node* node, MachineTypeUnion output_type) {
192 // Eagerly fold representation changes for constants. 192 // Eagerly fold representation changes for constants.
193 switch (node->opcode()) { 193 switch (node->opcode()) {
194 case IrOpcode::kInt32Constant: { 194 case IrOpcode::kInt32Constant: {
195 int32_t value = ValueOf<int32_t>(node->op()); 195 int32_t value = OpParameter<int32_t>(node);
196 if (value == 0 || value == 1) return node; 196 if (value == 0 || value == 1) return node;
197 return jsgraph()->OneConstant(); // value != 0 197 return jsgraph()->OneConstant(); // value != 0
198 } 198 }
199 case IrOpcode::kHeapConstant: { 199 case IrOpcode::kHeapConstant: {
200 Handle<Object> handle = ValueOf<Handle<Object> >(node->op()); 200 Handle<Object> handle = OpParameter<Unique<Object> >(node).handle();
201 DCHECK(*handle == isolate()->heap()->true_value() || 201 DCHECK(*handle == isolate()->heap()->true_value() ||
202 *handle == isolate()->heap()->false_value()); 202 *handle == isolate()->heap()->false_value());
203 return jsgraph()->Int32Constant( 203 return jsgraph()->Int32Constant(
204 *handle == isolate()->heap()->true_value() ? 1 : 0); 204 *handle == isolate()->heap()->true_value() ? 1 : 0);
205 } 205 }
206 default: 206 default:
207 break; 207 break;
208 } 208 }
209 // Select the correct X -> Bit operator. 209 // Select the correct X -> Bit operator.
210 Operator* op; 210 Operator* op;
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 JSGraph* jsgraph() { return jsgraph_; } 339 JSGraph* jsgraph() { return jsgraph_; }
340 Isolate* isolate() { return isolate_; } 340 Isolate* isolate() { return isolate_; }
341 SimplifiedOperatorBuilder* simplified() { return simplified_; } 341 SimplifiedOperatorBuilder* simplified() { return simplified_; }
342 MachineOperatorBuilder* machine() { return machine_; } 342 MachineOperatorBuilder* machine() { return machine_; }
343 }; 343 };
344 } 344 }
345 } 345 }
346 } // namespace v8::internal::compiler 346 } // namespace v8::internal::compiler
347 347
348 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_ 348 #endif // V8_COMPILER_REPRESENTATION_CHANGE_H_
OLDNEW
« no previous file with comments | « src/compiler/operator.h ('k') | src/compiler/simplified-operator-reducer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698