| 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/adapters.h" | 5 #include "src/base/adapters.h" |
| 6 #include "src/base/bits.h" | 6 #include "src/base/bits.h" |
| 7 #include "src/compiler/instruction-selector-impl.h" | 7 #include "src/compiler/instruction-selector-impl.h" |
| 8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
| 10 | 10 |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 386 Emit(kMips64Ext, g.DefineAsRegister(node), dmul_operand, g.TempImmediate(0), | 386 Emit(kMips64Ext, g.DefineAsRegister(node), dmul_operand, g.TempImmediate(0), |
| 387 g.TempImmediate(32)); | 387 g.TempImmediate(32)); |
| 388 } | 388 } |
| 389 | 389 |
| 390 | 390 |
| 391 void InstructionSelector::VisitInt64Mul(Node* node) { | 391 void InstructionSelector::VisitInt64Mul(Node* node) { |
| 392 Mips64OperandGenerator g(this); | 392 Mips64OperandGenerator g(this); |
| 393 Int64BinopMatcher m(node); | 393 Int64BinopMatcher m(node); |
| 394 // TODO(dusmil): Add optimization for shifts larger than 32. | 394 // TODO(dusmil): Add optimization for shifts larger than 32. |
| 395 if (m.right().HasValue() && m.right().Value() > 0) { | 395 if (m.right().HasValue() && m.right().Value() > 0) { |
| 396 int64_t value = m.right().Value(); | 396 int32_t value = static_cast<int32_t>(m.right().Value()); |
| 397 if (base::bits::IsPowerOfTwo32(value)) { | 397 if (base::bits::IsPowerOfTwo32(value)) { |
| 398 Emit(kMips64Dshl | AddressingModeField::encode(kMode_None), | 398 Emit(kMips64Dshl | AddressingModeField::encode(kMode_None), |
| 399 g.DefineAsRegister(node), g.UseRegister(m.left().node()), | 399 g.DefineAsRegister(node), g.UseRegister(m.left().node()), |
| 400 g.TempImmediate(WhichPowerOf2(value))); | 400 g.TempImmediate(WhichPowerOf2(value))); |
| 401 return; | 401 return; |
| 402 } | 402 } |
| 403 if (base::bits::IsPowerOfTwo32(value - 1)) { | 403 if (base::bits::IsPowerOfTwo32(value - 1)) { |
| 404 InstructionOperand temp = g.TempRegister(); | 404 InstructionOperand temp = g.TempRegister(); |
| 405 Emit(kMips64Dshl | AddressingModeField::encode(kMode_None), temp, | 405 Emit(kMips64Dshl | AddressingModeField::encode(kMode_None), temp, |
| 406 g.UseRegister(m.left().node()), | 406 g.UseRegister(m.left().node()), |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 659 UNREACHABLE(); | 659 UNREACHABLE(); |
| 660 } | 660 } |
| 661 | 661 |
| 662 | 662 |
| 663 void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) { | 663 void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) { |
| 664 Mips64OperandGenerator g(this); | 664 Mips64OperandGenerator g(this); |
| 665 const CallDescriptor* descriptor = OpParameter<const CallDescriptor*>(node); | 665 const CallDescriptor* descriptor = OpParameter<const CallDescriptor*>(node); |
| 666 | 666 |
| 667 FrameStateDescriptor* frame_state_descriptor = nullptr; | 667 FrameStateDescriptor* frame_state_descriptor = nullptr; |
| 668 if (descriptor->NeedsFrameState()) { | 668 if (descriptor->NeedsFrameState()) { |
| 669 frame_state_descriptor = | 669 frame_state_descriptor = GetFrameStateDescriptor( |
| 670 GetFrameStateDescriptor(node->InputAt(descriptor->InputCount())); | 670 node->InputAt(static_cast<int>(descriptor->InputCount()))); |
| 671 } | 671 } |
| 672 | 672 |
| 673 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); | 673 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); |
| 674 | 674 |
| 675 // Compute InstructionOperands for inputs and outputs. | 675 // Compute InstructionOperands for inputs and outputs. |
| 676 InitializeCallBuffer(node, &buffer, true, false); | 676 InitializeCallBuffer(node, &buffer, true, false); |
| 677 | 677 |
| 678 int push_count = buffer.pushed_nodes.size(); | 678 const int32_t push_count = static_cast<int32_t>(buffer.pushed_nodes.size()); |
| 679 if (push_count > 0) { | 679 if (push_count > 0) { |
| 680 Emit(kMips64StackClaim, g.NoOutput(), | 680 Emit(kMips64StackClaim, g.NoOutput(), |
| 681 g.TempImmediate(push_count << kPointerSizeLog2)); | 681 g.TempImmediate(push_count << kPointerSizeLog2)); |
| 682 } | 682 } |
| 683 int slot = buffer.pushed_nodes.size() - 1; | 683 int32_t slot = push_count - 1; |
| 684 for (Node* node : base::Reversed(buffer.pushed_nodes)) { | 684 for (Node* node : base::Reversed(buffer.pushed_nodes)) { |
| 685 Emit(kMips64StoreToStackSlot, g.NoOutput(), g.UseRegister(node), | 685 Emit(kMips64StoreToStackSlot, g.NoOutput(), g.UseRegister(node), |
| 686 g.TempImmediate(slot << kPointerSizeLog2)); | 686 g.TempImmediate(slot << kPointerSizeLog2)); |
| 687 slot--; | 687 slot--; |
| 688 } | 688 } |
| 689 | 689 |
| 690 // Pass label of exception handler block. | 690 // Pass label of exception handler block. |
| 691 CallDescriptor::Flags flags = descriptor->flags(); | 691 CallDescriptor::Flags flags = descriptor->flags(); |
| 692 if (handler) { | 692 if (handler) { |
| 693 DCHECK_EQ(IrOpcode::kIfException, handler->front()->opcode()); | 693 DCHECK_EQ(IrOpcode::kIfException, handler->front()->opcode()); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 764 descriptor->NeedsFrameState() | 764 descriptor->NeedsFrameState() |
| 765 ? GetFrameStateDescriptor( | 765 ? GetFrameStateDescriptor( |
| 766 node->InputAt(static_cast<int>(descriptor->InputCount()))) | 766 node->InputAt(static_cast<int>(descriptor->InputCount()))) |
| 767 : nullptr; | 767 : nullptr; |
| 768 | 768 |
| 769 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); | 769 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); |
| 770 | 770 |
| 771 // Compute InstructionOperands for inputs and outputs. | 771 // Compute InstructionOperands for inputs and outputs. |
| 772 InitializeCallBuffer(node, &buffer, true, false); | 772 InitializeCallBuffer(node, &buffer, true, false); |
| 773 | 773 |
| 774 int push_count = buffer.pushed_nodes.size(); | 774 const int32_t push_count = static_cast<int32_t>(buffer.pushed_nodes.size()); |
| 775 if (push_count > 0) { | 775 if (push_count > 0) { |
| 776 Emit(kMips64StackClaim, g.NoOutput(), | 776 Emit(kMips64StackClaim, g.NoOutput(), |
| 777 g.TempImmediate(push_count << kPointerSizeLog2)); | 777 g.TempImmediate(push_count << kPointerSizeLog2)); |
| 778 } | 778 } |
| 779 int slot = buffer.pushed_nodes.size() - 1; | 779 int slot = push_count - 1; |
| 780 for (Node* node : base::Reversed(buffer.pushed_nodes)) { | 780 for (Node* node : base::Reversed(buffer.pushed_nodes)) { |
| 781 Emit(kMips64StoreToStackSlot, g.NoOutput(), g.UseRegister(node), | 781 Emit(kMips64StoreToStackSlot, g.NoOutput(), g.UseRegister(node), |
| 782 g.TempImmediate(slot << kPointerSizeLog2)); | 782 g.TempImmediate(slot << kPointerSizeLog2)); |
| 783 slot--; | 783 slot--; |
| 784 } | 784 } |
| 785 | 785 |
| 786 // Select the appropriate opcode based on the call type. | 786 // Select the appropriate opcode based on the call type. |
| 787 InstructionCode opcode; | 787 InstructionCode opcode; |
| 788 switch (descriptor->kind()) { | 788 switch (descriptor->kind()) { |
| 789 case CallDescriptor::kCallCodeObject: { | 789 case CallDescriptor::kCallCodeObject: { |
| (...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 MachineOperatorBuilder::kFloat32Min | | 1296 MachineOperatorBuilder::kFloat32Min | |
| 1297 MachineOperatorBuilder::kFloat64Max | | 1297 MachineOperatorBuilder::kFloat64Max | |
| 1298 MachineOperatorBuilder::kFloat64Min; | 1298 MachineOperatorBuilder::kFloat64Min; |
| 1299 } | 1299 } |
| 1300 return flags; | 1300 return flags; |
| 1301 } | 1301 } |
| 1302 | 1302 |
| 1303 } // namespace compiler | 1303 } // namespace compiler |
| 1304 } // namespace internal | 1304 } // namespace internal |
| 1305 } // namespace v8 | 1305 } // namespace v8 |
| OLD | NEW |