OLD | NEW |
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/base/bits.h" | 5 #include "src/base/bits.h" |
6 #include "src/compiler/instruction-selector-impl.h" | 6 #include "src/compiler/instruction-selector-impl.h" |
7 #include "src/compiler/node-matchers.h" | 7 #include "src/compiler/node-matchers.h" |
| 8 #include "src/compiler/node-properties.h" |
8 | 9 |
9 namespace v8 { | 10 namespace v8 { |
10 namespace internal { | 11 namespace internal { |
11 namespace compiler { | 12 namespace compiler { |
12 | 13 |
13 #define TRACE_UNIMPL() \ | 14 #define TRACE_UNIMPL() \ |
14 PrintF("UNIMPLEMENTED instr_sel: %s at line %d\n", __FUNCTION__, __LINE__) | 15 PrintF("UNIMPLEMENTED instr_sel: %s at line %d\n", __FUNCTION__, __LINE__) |
15 | 16 |
16 #define TRACE() PrintF("instr_sel: %s at line %d\n", __FUNCTION__, __LINE__) | 17 #define TRACE() PrintF("instr_sel: %s at line %d\n", __FUNCTION__, __LINE__) |
17 | 18 |
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
641 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); | 642 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); |
642 | 643 |
643 // Compute InstructionOperands for inputs and outputs. | 644 // Compute InstructionOperands for inputs and outputs. |
644 InitializeCallBuffer(node, &buffer, true, false); | 645 InitializeCallBuffer(node, &buffer, true, false); |
645 | 646 |
646 int push_count = buffer.pushed_nodes.size(); | 647 int push_count = buffer.pushed_nodes.size(); |
647 if (push_count > 0) { | 648 if (push_count > 0) { |
648 Emit(kMips64StackClaim | MiscField::encode(push_count), NULL); | 649 Emit(kMips64StackClaim | MiscField::encode(push_count), NULL); |
649 } | 650 } |
650 int slot = buffer.pushed_nodes.size() - 1; | 651 int slot = buffer.pushed_nodes.size() - 1; |
651 for (NodeVectorRIter input = buffer.pushed_nodes.rbegin(); | 652 for (auto i = buffer.pushed_nodes.rbegin(); i != buffer.pushed_nodes.rend(); |
652 input != buffer.pushed_nodes.rend(); input++) { | 653 ++i) { |
653 Emit(kMips64StoreToStackSlot | MiscField::encode(slot), NULL, | 654 Emit(kMips64StoreToStackSlot | MiscField::encode(slot), nullptr, |
654 g.UseRegister(*input)); | 655 g.UseRegister(*i)); |
655 slot--; | 656 slot--; |
656 } | 657 } |
657 | 658 |
658 // Select the appropriate opcode based on the call type. | 659 // Select the appropriate opcode based on the call type. |
659 InstructionCode opcode; | 660 InstructionCode opcode; |
660 switch (descriptor->kind()) { | 661 switch (descriptor->kind()) { |
661 case CallDescriptor::kCallCodeObject: { | 662 case CallDescriptor::kCallCodeObject: { |
662 opcode = kArchCallCodeObject; | 663 opcode = kArchCallCodeObject; |
663 break; | 664 break; |
664 } | 665 } |
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
913 return VisitFloat64Compare(selector, value, cont); | 914 return VisitFloat64Compare(selector, value, cont); |
914 case IrOpcode::kFloat64LessThan: | 915 case IrOpcode::kFloat64LessThan: |
915 cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); | 916 cont->OverwriteAndNegateIfEqual(kUnsignedLessThan); |
916 return VisitFloat64Compare(selector, value, cont); | 917 return VisitFloat64Compare(selector, value, cont); |
917 case IrOpcode::kFloat64LessThanOrEqual: | 918 case IrOpcode::kFloat64LessThanOrEqual: |
918 cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); | 919 cont->OverwriteAndNegateIfEqual(kUnsignedLessThanOrEqual); |
919 return VisitFloat64Compare(selector, value, cont); | 920 return VisitFloat64Compare(selector, value, cont); |
920 case IrOpcode::kProjection: | 921 case IrOpcode::kProjection: |
921 // Check if this is the overflow output projection of an | 922 // Check if this is the overflow output projection of an |
922 // <Operation>WithOverflow node. | 923 // <Operation>WithOverflow node. |
923 if (OpParameter<size_t>(value) == 1u) { | 924 if (ProjectionIndexOf(value->op()) == 1u) { |
924 // We cannot combine the <Operation>WithOverflow with this branch | 925 // We cannot combine the <Operation>WithOverflow with this branch |
925 // unless the 0th projection (the use of the actual value of the | 926 // unless the 0th projection (the use of the actual value of the |
926 // <Operation> is either NULL, which means there's no use of the | 927 // <Operation> is either NULL, which means there's no use of the |
927 // actual value, or was already defined, which means it is scheduled | 928 // actual value, or was already defined, which means it is scheduled |
928 // *AFTER* this branch). | 929 // *AFTER* this branch). |
929 Node* node = value->InputAt(0); | 930 Node* const node = value->InputAt(0); |
930 Node* result = node->FindProjection(0); | 931 Node* const result = NodeProperties::FindProjection(node, 0); |
931 if (result == NULL || selector->IsDefined(result)) { | 932 if (result == NULL || selector->IsDefined(result)) { |
932 switch (node->opcode()) { | 933 switch (node->opcode()) { |
933 case IrOpcode::kInt32AddWithOverflow: | 934 case IrOpcode::kInt32AddWithOverflow: |
934 cont->OverwriteAndNegateIfEqual(kOverflow); | 935 cont->OverwriteAndNegateIfEqual(kOverflow); |
935 return VisitBinop(selector, node, kMips64Dadd, cont); | 936 return VisitBinop(selector, node, kMips64Dadd, cont); |
936 case IrOpcode::kInt32SubWithOverflow: | 937 case IrOpcode::kInt32SubWithOverflow: |
937 cont->OverwriteAndNegateIfEqual(kOverflow); | 938 cont->OverwriteAndNegateIfEqual(kOverflow); |
938 return VisitBinop(selector, node, kMips64Dsub, cont); | 939 return VisitBinop(selector, node, kMips64Dsub, cont); |
939 default: | 940 default: |
940 break; | 941 break; |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
993 } | 994 } |
994 | 995 |
995 | 996 |
996 void InstructionSelector::VisitUint32LessThanOrEqual(Node* node) { | 997 void InstructionSelector::VisitUint32LessThanOrEqual(Node* node) { |
997 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); | 998 FlagsContinuation cont(kUnsignedLessThanOrEqual, node); |
998 VisitWord32Compare(this, node, &cont); | 999 VisitWord32Compare(this, node, &cont); |
999 } | 1000 } |
1000 | 1001 |
1001 | 1002 |
1002 void InstructionSelector::VisitInt32AddWithOverflow(Node* node) { | 1003 void InstructionSelector::VisitInt32AddWithOverflow(Node* node) { |
1003 if (Node* ovf = node->FindProjection(1)) { | 1004 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { |
1004 FlagsContinuation cont(kOverflow, ovf); | 1005 FlagsContinuation cont(kOverflow, ovf); |
1005 return VisitBinop(this, node, kMips64Dadd, &cont); | 1006 return VisitBinop(this, node, kMips64Dadd, &cont); |
1006 } | 1007 } |
1007 FlagsContinuation cont; | 1008 FlagsContinuation cont; |
1008 VisitBinop(this, node, kMips64Dadd, &cont); | 1009 VisitBinop(this, node, kMips64Dadd, &cont); |
1009 } | 1010 } |
1010 | 1011 |
1011 | 1012 |
1012 void InstructionSelector::VisitInt32SubWithOverflow(Node* node) { | 1013 void InstructionSelector::VisitInt32SubWithOverflow(Node* node) { |
1013 if (Node* ovf = node->FindProjection(1)) { | 1014 if (Node* ovf = NodeProperties::FindProjection(node, 1)) { |
1014 FlagsContinuation cont(kOverflow, ovf); | 1015 FlagsContinuation cont(kOverflow, ovf); |
1015 return VisitBinop(this, node, kMips64Dsub, &cont); | 1016 return VisitBinop(this, node, kMips64Dsub, &cont); |
1016 } | 1017 } |
1017 FlagsContinuation cont; | 1018 FlagsContinuation cont; |
1018 VisitBinop(this, node, kMips64Dsub, &cont); | 1019 VisitBinop(this, node, kMips64Dsub, &cont); |
1019 } | 1020 } |
1020 | 1021 |
1021 | 1022 |
1022 void InstructionSelector::VisitWord64Equal(Node* const node) { | 1023 void InstructionSelector::VisitWord64Equal(Node* const node) { |
1023 FlagsContinuation cont(kEqual, node); | 1024 FlagsContinuation cont(kEqual, node); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1070 MachineOperatorBuilder::Flags | 1071 MachineOperatorBuilder::Flags |
1071 InstructionSelector::SupportedMachineOperatorFlags() { | 1072 InstructionSelector::SupportedMachineOperatorFlags() { |
1072 return MachineOperatorBuilder::kFloat64Floor | | 1073 return MachineOperatorBuilder::kFloat64Floor | |
1073 MachineOperatorBuilder::kFloat64Ceil | | 1074 MachineOperatorBuilder::kFloat64Ceil | |
1074 MachineOperatorBuilder::kFloat64RoundTruncate; | 1075 MachineOperatorBuilder::kFloat64RoundTruncate; |
1075 } | 1076 } |
1076 | 1077 |
1077 } // namespace compiler | 1078 } // namespace compiler |
1078 } // namespace internal | 1079 } // namespace internal |
1079 } // namespace v8 | 1080 } // namespace v8 |
OLD | NEW |