Commit caea1bbd authored by mbrandy's avatar mbrandy Committed by Commit bot

PPC64: [turbofan] Change TruncateFloat64ToUint64 to TryTruncateFloatToUint64.

Port c343f309

Original commit message:
    This operator now provides a second output which indicates whether the
    conversion from float64 to uint64 was successful or not. The second output
    returns 0 if the conversion fails, or something else if the conversion
    succeeds.

    The second output can be ignored, which means that the operator can be used
    the same as the original operator.

R=ahaas@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=

Review URL: https://codereview.chromium.org/1512963002

Cr-Commit-Position: refs/heads/master@{#32728}
parent cfef519a
......@@ -1188,11 +1188,24 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
break;
}
#if V8_TARGET_ARCH_PPC64
case kPPC_DoubleToUint64:
case kPPC_DoubleToUint64: {
bool check_conversion = (i.OutputCount() > 1);
if (check_conversion) {
__ mtfsb0(VXCVI); // clear FPSCR:VXCVI bit
}
__ ConvertDoubleToUnsignedInt64(i.InputDoubleRegister(0),
i.OutputRegister(), kScratchDoubleReg);
i.OutputRegister(0), kScratchDoubleReg);
if (check_conversion) {
// Set 2nd output to zero if conversion fails.
CRBit crbit = static_cast<CRBit>(VXCVI % CRWIDTH);
__ mcrfs(cr7, VXCVI); // extract FPSCR field containing VXCVI into cr7
__ li(i.OutputRegister(1), Operand(1));
__ isel(i.OutputRegister(1), r0, i.OutputRegister(1),
v8::internal::Assembler::encode_crbit(cr7, crbit));
}
DCHECK_EQ(LeaveRC, i.OutputRCBit());
break;
}
#endif
case kPPC_DoubleToFloat32:
ASSEMBLE_FLOAT_UNOP_RC(frsp);
......
......@@ -955,11 +955,19 @@ void InstructionSelector::VisitTruncateFloat32ToUint64(Node* node) {
void InstructionSelector::VisitTryTruncateFloat64ToUint64(Node* node) {
if (NodeProperties::FindProjection(node, 1)) {
// TODO(ppc): implement the second return value.
UNIMPLEMENTED();
PPCOperandGenerator g(this);
InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0))};
InstructionOperand outputs[2];
size_t output_count = 0;
outputs[output_count++] = g.DefineAsRegister(node);
Node* success_output = NodeProperties::FindProjection(node, 1);
if (success_output) {
outputs[output_count++] = g.DefineAsRegister(success_output);
}
VisitRR(this, kPPC_DoubleToUint64, node);
Emit(kPPC_DoubleToUint64, output_count, outputs, 1, inputs);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment