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

Side by Side Diff: src/compiler/simplified-lowering.cc

Issue 596703004: [turbofan] Add backend support for float32. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: REBASE Created 6 years, 2 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
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 #include "src/compiler/simplified-lowering.h" 5 #include "src/compiler/simplified-lowering.h"
6 6
7 #include "src/base/bits.h" 7 #include "src/base/bits.h"
8 #include "src/code-factory.h" 8 #include "src/code-factory.h"
9 #include "src/compiler/common-operator.h" 9 #include "src/compiler/common-operator.h"
10 #include "src/compiler/graph-inl.h" 10 #include "src/compiler/graph-inl.h"
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 ProcessInput(node, iter.index(), values > 0 ? use : 0); 281 ProcessInput(node, iter.index(), values > 0 ? use : 0);
282 } 282 }
283 } 283 }
284 // Phis adapt to whatever output representation their uses demand, 284 // Phis adapt to whatever output representation their uses demand,
285 // pushing representation changes to their inputs. 285 // pushing representation changes to their inputs.
286 MachineTypeUnion use_rep = GetUseInfo(node) & kRepMask; 286 MachineTypeUnion use_rep = GetUseInfo(node) & kRepMask;
287 MachineTypeUnion use_type = GetUseInfo(node) & kTypeMask; 287 MachineTypeUnion use_type = GetUseInfo(node) & kTypeMask;
288 MachineTypeUnion rep = 0; 288 MachineTypeUnion rep = 0;
289 if (use_rep & kRepTagged) { 289 if (use_rep & kRepTagged) {
290 rep = kRepTagged; // Tagged overrides everything. 290 rep = kRepTagged; // Tagged overrides everything.
291 } else if (use_rep & kRepFloat32) {
292 rep = kRepFloat32;
291 } else if (use_rep & kRepFloat64) { 293 } else if (use_rep & kRepFloat64) {
292 rep = kRepFloat64; 294 rep = kRepFloat64;
293 } else if (use_rep & kRepWord64) { 295 } else if (use_rep & kRepWord64) {
294 rep = kRepWord64; 296 rep = kRepWord64;
295 } else if (use_rep & kRepWord32) { 297 } else if (use_rep & kRepWord32) {
296 rep = kRepWord32; 298 rep = kRepWord32;
297 } else if (use_rep & kRepBit) { 299 } else if (use_rep & kRepBit) {
298 rep = kRepBit; 300 rep = kRepBit;
299 } else { 301 } else {
300 // There was no representation associated with any of the uses. 302 // There was no representation associated with any of the uses.
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 } 344 }
343 345
344 const Operator* Uint32Op(Node* node) { 346 const Operator* Uint32Op(Node* node) {
345 return changer_->Uint32OperatorFor(node->opcode()); 347 return changer_->Uint32OperatorFor(node->opcode());
346 } 348 }
347 349
348 const Operator* Float64Op(Node* node) { 350 const Operator* Float64Op(Node* node) {
349 return changer_->Float64OperatorFor(node->opcode()); 351 return changer_->Float64OperatorFor(node->opcode());
350 } 352 }
351 353
352 static MachineType AssumeImplicitFloat32Change(MachineType type) {
353 // TODO(titzer): Assume loads of float32 change representation to float64.
354 // Fix this with full support for float32 representations.
355 if (type & kRepFloat32) {
356 return static_cast<MachineType>((type & ~kRepFloat32) | kRepFloat64);
357 }
358 return type;
359 }
360
361 // Dispatching routine for visiting the node {node} with the usage {use}. 354 // Dispatching routine for visiting the node {node} with the usage {use}.
362 // Depending on the operator, propagate new usage info to the inputs. 355 // Depending on the operator, propagate new usage info to the inputs.
363 void VisitNode(Node* node, MachineTypeUnion use, 356 void VisitNode(Node* node, MachineTypeUnion use,
364 SimplifiedLowering* lowering) { 357 SimplifiedLowering* lowering) {
365 switch (node->opcode()) { 358 switch (node->opcode()) {
366 //------------------------------------------------------------------ 359 //------------------------------------------------------------------
367 // Common operators. 360 // Common operators.
368 //------------------------------------------------------------------ 361 //------------------------------------------------------------------
369 case IrOpcode::kStart: 362 case IrOpcode::kStart:
370 case IrOpcode::kDead: 363 case IrOpcode::kDead:
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 } 565 }
573 case IrOpcode::kStringAdd: { 566 case IrOpcode::kStringAdd: {
574 VisitBinop(node, kMachAnyTagged, kMachAnyTagged); 567 VisitBinop(node, kMachAnyTagged, kMachAnyTagged);
575 if (lower()) lowering->DoStringAdd(node); 568 if (lower()) lowering->DoStringAdd(node);
576 break; 569 break;
577 } 570 }
578 case IrOpcode::kLoadField: { 571 case IrOpcode::kLoadField: {
579 FieldAccess access = FieldAccessOf(node->op()); 572 FieldAccess access = FieldAccessOf(node->op());
580 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); 573 ProcessInput(node, 0, changer_->TypeForBasePointer(access));
581 ProcessRemainingInputs(node, 1); 574 ProcessRemainingInputs(node, 1);
582 SetOutput(node, AssumeImplicitFloat32Change(access.machine_type)); 575 SetOutput(node, access.machine_type);
583 if (lower()) lowering->DoLoadField(node); 576 if (lower()) lowering->DoLoadField(node);
584 break; 577 break;
585 } 578 }
586 case IrOpcode::kStoreField: { 579 case IrOpcode::kStoreField: {
587 FieldAccess access = FieldAccessOf(node->op()); 580 FieldAccess access = FieldAccessOf(node->op());
588 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); 581 ProcessInput(node, 0, changer_->TypeForBasePointer(access));
589 ProcessInput(node, 1, AssumeImplicitFloat32Change(access.machine_type)); 582 ProcessInput(node, 1, access.machine_type);
590 ProcessRemainingInputs(node, 2); 583 ProcessRemainingInputs(node, 2);
591 SetOutput(node, 0); 584 SetOutput(node, 0);
592 if (lower()) lowering->DoStoreField(node); 585 if (lower()) lowering->DoStoreField(node);
593 break; 586 break;
594 } 587 }
595 case IrOpcode::kLoadElement: { 588 case IrOpcode::kLoadElement: {
596 ElementAccess access = ElementAccessOf(node->op()); 589 ElementAccess access = ElementAccessOf(node->op());
597 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); 590 ProcessInput(node, 0, changer_->TypeForBasePointer(access));
598 ProcessInput(node, 1, kMachInt32); // element index 591 ProcessInput(node, 1, kMachInt32); // element index
599 ProcessRemainingInputs(node, 2); 592 ProcessRemainingInputs(node, 2);
600 SetOutput(node, AssumeImplicitFloat32Change(access.machine_type)); 593 SetOutput(node, access.machine_type);
601 if (lower()) lowering->DoLoadElement(node); 594 if (lower()) lowering->DoLoadElement(node);
602 break; 595 break;
603 } 596 }
604 case IrOpcode::kStoreElement: { 597 case IrOpcode::kStoreElement: {
605 ElementAccess access = ElementAccessOf(node->op()); 598 ElementAccess access = ElementAccessOf(node->op());
606 ProcessInput(node, 0, changer_->TypeForBasePointer(access)); 599 ProcessInput(node, 0, changer_->TypeForBasePointer(access));
607 ProcessInput(node, 1, kMachInt32); // element index 600 ProcessInput(node, 1, kMachInt32); // element index
608 ProcessInput(node, 2, AssumeImplicitFloat32Change(access.machine_type)); 601 ProcessInput(node, 2, access.machine_type);
609 ProcessRemainingInputs(node, 3); 602 ProcessRemainingInputs(node, 3);
610 SetOutput(node, 0); 603 SetOutput(node, 0);
611 if (lower()) lowering->DoStoreElement(node); 604 if (lower()) lowering->DoStoreElement(node);
612 break; 605 break;
613 } 606 }
614 607
615 //------------------------------------------------------------------ 608 //------------------------------------------------------------------
616 // Machine-level operators. 609 // Machine-level operators.
617 //------------------------------------------------------------------ 610 //------------------------------------------------------------------
618 case IrOpcode::kLoad: { 611 case IrOpcode::kLoad: {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 return VisitBinop(node, kRepWord64, kRepWord64); 684 return VisitBinop(node, kRepWord64, kRepWord64);
692 case IrOpcode::kWord64Equal: 685 case IrOpcode::kWord64Equal:
693 return VisitBinop(node, kRepWord64, kRepBit); 686 return VisitBinop(node, kRepWord64, kRepBit);
694 687
695 case IrOpcode::kChangeInt32ToInt64: 688 case IrOpcode::kChangeInt32ToInt64:
696 return VisitUnop(node, kTypeInt32 | kRepWord32, 689 return VisitUnop(node, kTypeInt32 | kRepWord32,
697 kTypeInt32 | kRepWord64); 690 kTypeInt32 | kRepWord64);
698 case IrOpcode::kChangeUint32ToUint64: 691 case IrOpcode::kChangeUint32ToUint64:
699 return VisitUnop(node, kTypeUint32 | kRepWord32, 692 return VisitUnop(node, kTypeUint32 | kRepWord32,
700 kTypeUint32 | kRepWord64); 693 kTypeUint32 | kRepWord64);
694 case IrOpcode::kTruncateFloat64ToFloat32:
695 return VisitUnop(node, kTypeNumber | kRepFloat32,
696 kTypeNumber | kRepFloat64);
701 case IrOpcode::kTruncateInt64ToInt32: 697 case IrOpcode::kTruncateInt64ToInt32:
702 // TODO(titzer): Is kTypeInt32 correct here? 698 // TODO(titzer): Is kTypeInt32 correct here?
703 return VisitUnop(node, kTypeInt32 | kRepWord64, 699 return VisitUnop(node, kTypeInt32 | kRepWord64,
704 kTypeInt32 | kRepWord32); 700 kTypeInt32 | kRepWord32);
705 701
702 case IrOpcode::kChangeFloat32ToFloat64:
703 return VisitUnop(node, kTypeNumber | kRepFloat32,
704 kTypeNumber | kRepFloat64);
706 case IrOpcode::kChangeInt32ToFloat64: 705 case IrOpcode::kChangeInt32ToFloat64:
707 return VisitUnop(node, kTypeInt32 | kRepWord32, 706 return VisitUnop(node, kTypeInt32 | kRepWord32,
708 kTypeInt32 | kRepFloat64); 707 kTypeInt32 | kRepFloat64);
709 case IrOpcode::kChangeUint32ToFloat64: 708 case IrOpcode::kChangeUint32ToFloat64:
710 return VisitUnop(node, kTypeUint32 | kRepWord32, 709 return VisitUnop(node, kTypeUint32 | kRepWord32,
711 kTypeUint32 | kRepFloat64); 710 kTypeUint32 | kRepFloat64);
712 case IrOpcode::kChangeFloat64ToInt32: 711 case IrOpcode::kChangeFloat64ToInt32:
713 return VisitUnop(node, kTypeInt32 | kRepFloat64, 712 return VisitUnop(node, kTypeInt32 | kRepFloat64,
714 kTypeInt32 | kRepWord32); 713 kTypeInt32 | kRepWord32);
715 case IrOpcode::kChangeFloat64ToUint32: 714 case IrOpcode::kChangeFloat64ToUint32:
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) { 929 void SimplifiedLowering::DoStringLessThanOrEqual(Node* node) {
931 node->set_op(machine()->IntLessThanOrEqual()); 930 node->set_op(machine()->IntLessThanOrEqual());
932 node->ReplaceInput(0, StringComparison(node, true)); 931 node->ReplaceInput(0, StringComparison(node, true));
933 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL)); 932 node->ReplaceInput(1, jsgraph()->SmiConstant(EQUAL));
934 } 933 }
935 934
936 935
937 } // namespace compiler 936 } // namespace compiler
938 } // namespace internal 937 } // namespace internal
939 } // namespace v8 938 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698