diff options
Diffstat (limited to 'deps/v8/src/compiler/mips/instruction-selector-mips.cc')
-rw-r--r-- | deps/v8/src/compiler/mips/instruction-selector-mips.cc | 169 |
1 files changed, 51 insertions, 118 deletions
diff --git a/deps/v8/src/compiler/mips/instruction-selector-mips.cc b/deps/v8/src/compiler/mips/instruction-selector-mips.cc index 1053763f0d..35b8a2396d 100644 --- a/deps/v8/src/compiler/mips/instruction-selector-mips.cc +++ b/deps/v8/src/compiler/mips/instruction-selector-mips.cc @@ -36,7 +36,7 @@ class MipsOperandGenerator final : public OperandGenerator { InstructionOperand UseRegisterOrImmediateZero(Node* node) { if ((IsIntegerConstant(node) && (GetIntegerConstantValue(node) == 0)) || (IsFloatConstant(node) && - (bit_cast<int64_t>(GetFloatConstantValue(node)) == V8_INT64_C(0)))) { + (bit_cast<int64_t>(GetFloatConstantValue(node)) == 0))) { return UseImmediate(node); } return UseRegister(node); @@ -92,18 +92,6 @@ class MipsOperandGenerator final : public OperandGenerator { case kMipsSwc1: case kMipsLdc1: case kMipsSdc1: - case kCheckedLoadInt8: - case kCheckedLoadUint8: - case kCheckedLoadInt16: - case kCheckedLoadUint16: - case kCheckedLoadWord32: - case kCheckedStoreWord8: - case kCheckedStoreWord16: - case kCheckedStoreWord32: - case kCheckedLoadFloat32: - case kCheckedLoadFloat64: - case kCheckedStoreFloat32: - case kCheckedStoreFloat64: // true even for 32b values, offsets > 16b // are handled in assembler-mips.cc return is_int32(value); @@ -233,7 +221,8 @@ static void VisitBinop(InstructionSelector* selector, Node* node, opcode = cont->Encode(opcode); if (cont->IsDeoptimize()) { selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, - cont->kind(), cont->reason(), cont->frame_state()); + cont->kind(), cont->reason(), cont->feedback(), + cont->frame_state()); } else { selector->Emit(opcode, output_count, outputs, input_count, inputs); } @@ -432,7 +421,7 @@ void InstructionSelector::VisitWord32And(Node* node) { Int32BinopMatcher mleft(m.left().node()); if (mleft.right().HasValue()) { // Any shift value can match; int32 shifts use `value % 32`. - uint32_t lsb = mleft.right().Value() & 0x1f; + uint32_t lsb = mleft.right().Value() & 0x1F; // Ext cannot extract bits past the register size, however since // shifting the original value would have introduced some zeros we can @@ -531,7 +520,7 @@ void InstructionSelector::VisitWord32Shl(Node* node) { void InstructionSelector::VisitWord32Shr(Node* node) { Int32BinopMatcher m(node); if (m.left().IsWord32And() && m.right().HasValue()) { - uint32_t lsb = m.right().Value() & 0x1f; + uint32_t lsb = m.right().Value() & 0x1F; Int32BinopMatcher mleft(m.left().node()); if (mleft.right().HasValue() && mleft.right().Value() != 0) { // Select Ext for Shr(And(x, mask), imm) where the result of the mask is @@ -1181,8 +1170,8 @@ void InstructionSelector::EmitPrepareArguments( // Poke any stack arguments. int slot = kCArgSlotCount; for (PushParameter input : (*arguments)) { - if (input.node()) { - Emit(kMipsStoreToStackSlot, g.NoOutput(), g.UseRegister(input.node()), + if (input.node) { + Emit(kMipsStoreToStackSlot, g.NoOutput(), g.UseRegister(input.node), g.TempImmediate(slot << kPointerSizeLog2)); ++slot; } @@ -1191,19 +1180,53 @@ void InstructionSelector::EmitPrepareArguments( // Possibly align stack here for functions. int push_count = static_cast<int>(descriptor->StackParameterCount()); if (push_count > 0) { + // Calculate needed space + int stack_size = 0; + for (size_t n = 0; n < arguments->size(); ++n) { + PushParameter input = (*arguments)[n]; + if (input.node) { + stack_size += input.location.GetSizeInPointers(); + } + } Emit(kMipsStackClaim, g.NoOutput(), - g.TempImmediate(push_count << kPointerSizeLog2)); + g.TempImmediate(stack_size << kPointerSizeLog2)); } for (size_t n = 0; n < arguments->size(); ++n) { PushParameter input = (*arguments)[n]; - if (input.node()) { - Emit(kMipsStoreToStackSlot, g.NoOutput(), g.UseRegister(input.node()), + if (input.node) { + Emit(kMipsStoreToStackSlot, g.NoOutput(), g.UseRegister(input.node), g.TempImmediate(n << kPointerSizeLog2)); } } } } +void InstructionSelector::EmitPrepareResults(ZoneVector<PushParameter>* results, + const CallDescriptor* descriptor, + Node* node) { + MipsOperandGenerator g(this); + + int reverse_slot = 0; + for (PushParameter output : *results) { + if (!output.location.IsCallerFrameSlot()) continue; + ++reverse_slot; + // Skip any alignment holes in nodes. + if (output.node != nullptr) { + DCHECK(!descriptor->IsCFunctionCall()); + if (output.location.GetType() == MachineType::Float32()) { + MarkAsFloat32(output.node); + } else if (output.location.GetType() == MachineType::Float64()) { + MarkAsFloat64(output.node); + } + InstructionOperand result = g.DefineAsRegister(output.node); + Emit(kMipsPeek | MiscField::encode(reverse_slot), result); + } + if (output.location.GetType() == MachineType::Float64()) { + // Float64 require an implicit second slot. + ++reverse_slot; + } + } +} bool InstructionSelector::IsTailCallAddressImmediate() { return false; } @@ -1312,99 +1335,6 @@ void InstructionSelector::VisitUnalignedStore(Node* node) { } } -void InstructionSelector::VisitCheckedLoad(Node* node) { - CheckedLoadRepresentation load_rep = CheckedLoadRepresentationOf(node->op()); - MipsOperandGenerator g(this); - Node* const buffer = node->InputAt(0); - Node* const offset = node->InputAt(1); - Node* const length = node->InputAt(2); - ArchOpcode opcode = kArchNop; - switch (load_rep.representation()) { - case MachineRepresentation::kWord8: - opcode = load_rep.IsSigned() ? kCheckedLoadInt8 : kCheckedLoadUint8; - break; - case MachineRepresentation::kWord16: - opcode = load_rep.IsSigned() ? kCheckedLoadInt16 : kCheckedLoadUint16; - break; - case MachineRepresentation::kWord32: - opcode = kCheckedLoadWord32; - break; - case MachineRepresentation::kFloat32: - opcode = kCheckedLoadFloat32; - break; - case MachineRepresentation::kFloat64: - opcode = kCheckedLoadFloat64; - break; - case MachineRepresentation::kBit: // Fall through. - case MachineRepresentation::kTaggedSigned: // Fall through. - case MachineRepresentation::kTaggedPointer: // Fall through. - case MachineRepresentation::kTagged: // Fall through. - case MachineRepresentation::kWord64: // Fall through. - case MachineRepresentation::kSimd128: // Fall through. - case MachineRepresentation::kNone: - UNREACHABLE(); - return; - } - InstructionOperand offset_operand = g.CanBeImmediate(offset, opcode) - ? g.UseImmediate(offset) - : g.UseRegister(offset); - - InstructionOperand length_operand = (!g.CanBeImmediate(offset, opcode)) - ? g.CanBeImmediate(length, opcode) - ? g.UseImmediate(length) - : g.UseRegister(length) - : g.UseRegister(length); - - Emit(opcode | AddressingModeField::encode(kMode_MRI), - g.DefineAsRegister(node), offset_operand, length_operand, - g.UseRegister(buffer)); -} - - -void InstructionSelector::VisitCheckedStore(Node* node) { - MachineRepresentation rep = CheckedStoreRepresentationOf(node->op()); - MipsOperandGenerator g(this); - Node* const buffer = node->InputAt(0); - Node* const offset = node->InputAt(1); - Node* const length = node->InputAt(2); - Node* const value = node->InputAt(3); - ArchOpcode opcode = kArchNop; - switch (rep) { - case MachineRepresentation::kWord8: - opcode = kCheckedStoreWord8; - break; - case MachineRepresentation::kWord16: - opcode = kCheckedStoreWord16; - break; - case MachineRepresentation::kWord32: - opcode = kCheckedStoreWord32; - break; - case MachineRepresentation::kFloat32: - opcode = kCheckedStoreFloat32; - break; - case MachineRepresentation::kFloat64: - opcode = kCheckedStoreFloat64; - break; - default: - UNREACHABLE(); - return; - } - InstructionOperand offset_operand = g.CanBeImmediate(offset, opcode) - ? g.UseImmediate(offset) - : g.UseRegister(offset); - - InstructionOperand length_operand = (!g.CanBeImmediate(offset, opcode)) - ? g.CanBeImmediate(length, opcode) - ? g.UseImmediate(length) - : g.UseRegister(length) - : g.UseRegister(length); - - Emit(opcode | AddressingModeField::encode(kMode_MRI), g.NoOutput(), - offset_operand, length_operand, g.UseRegisterOrImmediateZero(value), - g.UseRegister(buffer)); -} - - namespace { // Shared routine for multiple compare operations. static void VisitCompare(InstructionSelector* selector, InstructionCode opcode, @@ -1417,7 +1347,8 @@ static void VisitCompare(InstructionSelector* selector, InstructionCode opcode, g.Label(cont->true_block()), g.Label(cont->false_block())); } else if (cont->IsDeoptimize()) { selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, cont->kind(), - cont->reason(), cont->frame_state()); + cont->reason(), cont->feedback(), + cont->frame_state()); } else if (cont->IsSet()) { selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); } else { @@ -1630,7 +1561,7 @@ void VisitWordCompareZero(InstructionSelector* selector, Node* user, } else if (cont->IsDeoptimize()) { selector->EmitDeoptimize(opcode, g.NoOutput(), value_operand, g.TempImmediate(0), cont->kind(), cont->reason(), - cont->frame_state()); + cont->feedback(), cont->frame_state()); } else if (cont->IsSet()) { selector->Emit(opcode, g.DefineAsRegister(cont->result()), value_operand, g.TempImmediate(0)); @@ -1652,14 +1583,14 @@ void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, void InstructionSelector::VisitDeoptimizeIf(Node* node) { DeoptimizeParameters p = DeoptimizeParametersOf(node->op()); FlagsContinuation cont = FlagsContinuation::ForDeoptimize( - kNotEqual, p.kind(), p.reason(), node->InputAt(1)); + kNotEqual, p.kind(), p.reason(), p.feedback(), node->InputAt(1)); VisitWordCompareZero(this, node, node->InputAt(0), &cont); } void InstructionSelector::VisitDeoptimizeUnless(Node* node) { DeoptimizeParameters p = DeoptimizeParametersOf(node->op()); FlagsContinuation cont = FlagsContinuation::ForDeoptimize( - kEqual, p.kind(), p.reason(), node->InputAt(1)); + kEqual, p.kind(), p.reason(), p.feedback(), node->InputAt(1)); VisitWordCompareZero(this, node, node->InputAt(0), &cont); } @@ -2057,6 +1988,8 @@ void InstructionSelector::VisitInt64AbsWithOverflow(Node* node) { UNREACHABLE(); } +void InstructionSelector::VisitSpeculationFence(Node* node) { UNREACHABLE(); } + #define SIMD_TYPE_LIST(V) \ V(F32x4) \ V(I32x4) \ |