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

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

Issue 555283004: [turbofan] Next step towards shared operators. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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/raw-machine-assembler.cc ('k') | src/compiler/simplified-lowering.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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
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(OpParameter<double>(node)); 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 const 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 }
(...skipping 17 matching lines...) Expand all
122 } else { 122 } else {
123 int32_t value = OpParameter<int32_t>(node); 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 const Operator* op;
133 if (output_type & kRepBit) { 133 if (output_type & kRepBit) {
134 return TypeError(node, output_type, kRepFloat64); 134 return TypeError(node, output_type, kRepFloat64);
135 } else if (output_type & rWord) { 135 } else if (output_type & rWord) {
136 if (output_type & kTypeUint32) { 136 if (output_type & kTypeUint32) {
137 op = machine()->ChangeUint32ToFloat64(); 137 op = machine()->ChangeUint32ToFloat64();
138 } else { 138 } else {
139 op = machine()->ChangeInt32ToFloat64(); 139 op = machine()->ChangeInt32ToFloat64();
140 } 140 }
141 } else if (output_type & kRepTagged) { 141 } else if (output_type & kRepTagged) {
142 op = simplified()->ChangeTaggedToFloat64(); 142 op = simplified()->ChangeTaggedToFloat64();
(...skipping 19 matching lines...) Expand all
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 }
168 default: 168 default:
169 break; 169 break;
170 } 170 }
171 // Select the correct X -> Word32 operator. 171 // Select the correct X -> Word32 operator.
172 Operator* op = NULL; 172 const Operator* op = NULL;
173 if (output_type & kRepFloat64) { 173 if (output_type & kRepFloat64) {
174 if (output_type & kTypeUint32 || use_unsigned) { 174 if (output_type & kTypeUint32 || use_unsigned) {
175 op = machine()->ChangeFloat64ToUint32(); 175 op = machine()->ChangeFloat64ToUint32();
176 } else { 176 } else {
177 op = machine()->ChangeFloat64ToInt32(); 177 op = machine()->ChangeFloat64ToInt32();
178 } 178 }
179 } else if (output_type & kRepTagged) { 179 } else if (output_type & kRepTagged) {
180 if (output_type & kTypeUint32 || use_unsigned) { 180 if (output_type & kTypeUint32 || use_unsigned) {
181 op = simplified()->ChangeTaggedToUint32(); 181 op = simplified()->ChangeTaggedToUint32();
182 } else { 182 } else {
(...skipping 17 matching lines...) Expand all
200 Handle<Object> handle = OpParameter<Unique<Object> >(node).handle(); 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 const Operator* op;
211 if (output_type & rWord) { 211 if (output_type & rWord) {
212 return node; // No change necessary. 212 return node; // No change necessary.
213 } else if (output_type & kRepWord64) { 213 } else if (output_type & kRepWord64) {
214 return node; // TODO(titzer): No change necessary, on 64-bit. 214 return node; // TODO(titzer): No change necessary, on 64-bit.
215 } else if (output_type & kRepTagged) { 215 } else if (output_type & kRepTagged) {
216 op = simplified()->ChangeBoolToBit(); 216 op = simplified()->ChangeBoolToBit();
217 } else { 217 } else {
218 return TypeError(node, output_type, kRepBit); 218 return TypeError(node, output_type, kRepBit);
219 } 219 }
220 return jsgraph()->graph()->NewNode(op, node); 220 return jsgraph()->graph()->NewNode(op, node);
221 } 221 }
222 222
223 Node* GetWord64RepresentationFor(Node* node, MachineTypeUnion output_type) { 223 Node* GetWord64RepresentationFor(Node* node, MachineTypeUnion output_type) {
224 if (output_type & kRepBit) { 224 if (output_type & kRepBit) {
225 return node; // Sloppy comparison -> word64 225 return node; // Sloppy comparison -> word64
226 } 226 }
227 // Can't really convert Word64 to anything else. Purported to be internal. 227 // Can't really convert Word64 to anything else. Purported to be internal.
228 return TypeError(node, output_type, kRepWord64); 228 return TypeError(node, output_type, kRepWord64);
229 } 229 }
230 230
231 Operator* Int32OperatorFor(IrOpcode::Value opcode) { 231 const Operator* Int32OperatorFor(IrOpcode::Value opcode) {
232 switch (opcode) { 232 switch (opcode) {
233 case IrOpcode::kNumberAdd: 233 case IrOpcode::kNumberAdd:
234 return machine()->Int32Add(); 234 return machine()->Int32Add();
235 case IrOpcode::kNumberSubtract: 235 case IrOpcode::kNumberSubtract:
236 return machine()->Int32Sub(); 236 return machine()->Int32Sub();
237 case IrOpcode::kNumberEqual: 237 case IrOpcode::kNumberEqual:
238 return machine()->Word32Equal(); 238 return machine()->Word32Equal();
239 case IrOpcode::kNumberLessThan: 239 case IrOpcode::kNumberLessThan:
240 return machine()->Int32LessThan(); 240 return machine()->Int32LessThan();
241 case IrOpcode::kNumberLessThanOrEqual: 241 case IrOpcode::kNumberLessThanOrEqual:
242 return machine()->Int32LessThanOrEqual(); 242 return machine()->Int32LessThanOrEqual();
243 default: 243 default:
244 UNREACHABLE(); 244 UNREACHABLE();
245 return NULL; 245 return NULL;
246 } 246 }
247 } 247 }
248 248
249 Operator* Uint32OperatorFor(IrOpcode::Value opcode) { 249 const Operator* Uint32OperatorFor(IrOpcode::Value opcode) {
250 switch (opcode) { 250 switch (opcode) {
251 case IrOpcode::kNumberAdd: 251 case IrOpcode::kNumberAdd:
252 return machine()->Int32Add(); 252 return machine()->Int32Add();
253 case IrOpcode::kNumberSubtract: 253 case IrOpcode::kNumberSubtract:
254 return machine()->Int32Sub(); 254 return machine()->Int32Sub();
255 case IrOpcode::kNumberEqual: 255 case IrOpcode::kNumberEqual:
256 return machine()->Word32Equal(); 256 return machine()->Word32Equal();
257 case IrOpcode::kNumberLessThan: 257 case IrOpcode::kNumberLessThan:
258 return machine()->Uint32LessThan(); 258 return machine()->Uint32LessThan();
259 case IrOpcode::kNumberLessThanOrEqual: 259 case IrOpcode::kNumberLessThanOrEqual:
260 return machine()->Uint32LessThanOrEqual(); 260 return machine()->Uint32LessThanOrEqual();
261 default: 261 default:
262 UNREACHABLE(); 262 UNREACHABLE();
263 return NULL; 263 return NULL;
264 } 264 }
265 } 265 }
266 266
267 Operator* Float64OperatorFor(IrOpcode::Value opcode) { 267 const Operator* Float64OperatorFor(IrOpcode::Value opcode) {
268 switch (opcode) { 268 switch (opcode) {
269 case IrOpcode::kNumberAdd: 269 case IrOpcode::kNumberAdd:
270 return machine()->Float64Add(); 270 return machine()->Float64Add();
271 case IrOpcode::kNumberSubtract: 271 case IrOpcode::kNumberSubtract:
272 return machine()->Float64Sub(); 272 return machine()->Float64Sub();
273 case IrOpcode::kNumberMultiply: 273 case IrOpcode::kNumberMultiply:
274 return machine()->Float64Mul(); 274 return machine()->Float64Mul();
275 case IrOpcode::kNumberDivide: 275 case IrOpcode::kNumberDivide:
276 return machine()->Float64Div(); 276 return machine()->Float64Div();
277 case IrOpcode::kNumberModulus: 277 case IrOpcode::kNumberModulus:
(...skipping 61 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/raw-machine-assembler.cc ('k') | src/compiler/simplified-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698