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/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 #include "src/compiler/node-properties.h" |
9 #include "src/ppc/frames-ppc.h" | 9 #include "src/ppc/frames-ppc.h" |
10 | 10 |
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1514 Emit(kPPC_StoreToStackSlot, g.NoOutput(), g.UseRegister(input), | 1514 Emit(kPPC_StoreToStackSlot, g.NoOutput(), g.UseRegister(input), |
1515 g.TempImmediate(slot)); | 1515 g.TempImmediate(slot)); |
1516 } | 1516 } |
1517 } | 1517 } |
1518 ++slot; | 1518 ++slot; |
1519 } | 1519 } |
1520 } | 1520 } |
1521 } | 1521 } |
1522 | 1522 |
1523 | 1523 |
1524 void InstructionSelector::VisitTailCall(Node* node) { | 1524 bool InstructionSelector::IsTailCallAddressImmediate() { return false; } |
1525 PPCOperandGenerator g(this); | |
1526 CallDescriptor const* descriptor = OpParameter<CallDescriptor const*>(node); | |
1527 DCHECK_NE(0, descriptor->flags() & CallDescriptor::kSupportsTailCalls); | |
1528 DCHECK_EQ(0, descriptor->flags() & CallDescriptor::kPatchableCallSite); | |
1529 DCHECK_EQ(0, descriptor->flags() & CallDescriptor::kNeedsNopAfterCall); | |
1530 | |
1531 // TODO(turbofan): Relax restriction for stack parameters. | |
1532 if (linkage()->GetIncomingDescriptor()->CanTailCall(node)) { | |
1533 CallBuffer buffer(zone(), descriptor, nullptr); | |
1534 | |
1535 // Compute InstructionOperands for inputs and outputs. | |
1536 // TODO(turbofan): on PPC it's probably better to use the code object in a | |
1537 // register if there are multiple uses of it. Improve constant pool and the | |
1538 // heuristics in the register allocator for where to emit constants. | |
1539 InitializeCallBuffer(node, &buffer, true, false); | |
1540 | |
1541 // Select the appropriate opcode based on the call type. | |
1542 InstructionCode opcode; | |
1543 switch (descriptor->kind()) { | |
1544 case CallDescriptor::kCallCodeObject: | |
1545 opcode = kArchTailCallCodeObject; | |
1546 break; | |
1547 case CallDescriptor::kCallJSFunction: | |
1548 opcode = kArchTailCallJSFunction; | |
1549 break; | |
1550 default: | |
1551 UNREACHABLE(); | |
1552 return; | |
1553 } | |
1554 opcode |= MiscField::encode(descriptor->flags()); | |
1555 | |
1556 // Emit the tailcall instruction. | |
1557 Emit(opcode, 0, nullptr, buffer.instruction_args.size(), | |
1558 &buffer.instruction_args.front()); | |
1559 } else { | |
1560 FrameStateDescriptor* frame_state_descriptor = nullptr; | |
1561 if (descriptor->NeedsFrameState()) { | |
1562 frame_state_descriptor = | |
1563 GetFrameStateDescriptor(node->InputAt(descriptor->InputCount())); | |
1564 } | |
1565 | |
1566 CallBuffer buffer(zone(), descriptor, frame_state_descriptor); | |
1567 | |
1568 // Compute InstructionOperands for inputs and outputs. | |
1569 // TODO(turbofan): on PPC it's probably better to use the code object in a | |
1570 // register if there are multiple uses of it. Improve constant pool and the | |
1571 // heuristics in the register allocator for where to emit constants. | |
1572 InitializeCallBuffer(node, &buffer, true, false); | |
1573 | |
1574 // Push any stack arguments. | |
1575 int num_slots = static_cast<int>(descriptor->StackParameterCount()); | |
1576 int slot = 0; | |
1577 for (Node* input : buffer.pushed_nodes) { | |
1578 if (slot == 0) { | |
1579 Emit(kPPC_PushFrame, g.NoOutput(), g.UseRegister(input), | |
1580 g.TempImmediate(num_slots)); | |
1581 } else { | |
1582 Emit(kPPC_StoreToStackSlot, g.NoOutput(), g.UseRegister(input), | |
1583 g.TempImmediate(slot)); | |
1584 } | |
1585 ++slot; | |
1586 } | |
1587 | |
1588 // Select the appropriate opcode based on the call type. | |
1589 InstructionCode opcode; | |
1590 switch (descriptor->kind()) { | |
1591 case CallDescriptor::kCallCodeObject: { | |
1592 opcode = kArchCallCodeObject; | |
1593 break; | |
1594 } | |
1595 case CallDescriptor::kCallJSFunction: | |
1596 opcode = kArchCallJSFunction; | |
1597 break; | |
1598 default: | |
1599 UNREACHABLE(); | |
1600 return; | |
1601 } | |
1602 opcode |= MiscField::encode(descriptor->flags()); | |
1603 | |
1604 // Emit the call instruction. | |
1605 size_t const output_count = buffer.outputs.size(); | |
1606 auto* outputs = output_count ? &buffer.outputs.front() : nullptr; | |
1607 Emit(opcode, output_count, outputs, buffer.instruction_args.size(), | |
1608 &buffer.instruction_args.front())->MarkAsCall(); | |
1609 Emit(kArchRet, 0, nullptr, output_count, outputs); | |
1610 } | |
1611 } | |
1612 | 1525 |
1613 | 1526 |
1614 void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) { | 1527 void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) { |
1615 PPCOperandGenerator g(this); | 1528 PPCOperandGenerator g(this); |
1616 Emit(kPPC_DoubleExtractLowWord32, g.DefineAsRegister(node), | 1529 Emit(kPPC_DoubleExtractLowWord32, g.DefineAsRegister(node), |
1617 g.UseRegister(node->InputAt(0))); | 1530 g.UseRegister(node->InputAt(0))); |
1618 } | 1531 } |
1619 | 1532 |
1620 | 1533 |
1621 void InstructionSelector::VisitFloat64ExtractHighWord32(Node* node) { | 1534 void InstructionSelector::VisitFloat64ExtractHighWord32(Node* node) { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1663 return MachineOperatorBuilder::kFloat64RoundDown | | 1576 return MachineOperatorBuilder::kFloat64RoundDown | |
1664 MachineOperatorBuilder::kFloat64RoundTruncate | | 1577 MachineOperatorBuilder::kFloat64RoundTruncate | |
1665 MachineOperatorBuilder::kFloat64RoundTiesAway | | 1578 MachineOperatorBuilder::kFloat64RoundTiesAway | |
1666 MachineOperatorBuilder::kWord32Popcnt; | 1579 MachineOperatorBuilder::kWord32Popcnt; |
1667 // We omit kWord32ShiftIsSafe as s[rl]w use 0x3f as a mask rather than 0x1f. | 1580 // We omit kWord32ShiftIsSafe as s[rl]w use 0x3f as a mask rather than 0x1f. |
1668 } | 1581 } |
1669 | 1582 |
1670 } // namespace compiler | 1583 } // namespace compiler |
1671 } // namespace internal | 1584 } // namespace internal |
1672 } // namespace v8 | 1585 } // namespace v8 |
OLD | NEW |