PPC/s390: [TurboFan] Use the FlagsContinuation more effectively

Port ab9ac99458

Original Commit Message:

    We can reduce boilerplate if we pass the continuation to
    some InstructionSelector::Emit.* methods.

R=mvstanton@chromium.org, joransiu@ca.ibm.com, michael_dawson@ca.ibm.com
BUG=
LOG=N

Change-Id: Ia9ddd0dcf5d6115ee9f8c35e1b05c10f9f0c4b39
Reviewed-on: https://chromium-review.googlesource.com/959441
Commit-Queue: Junliang Yan <jyan@ca.ibm.com>
Reviewed-by: Junliang Yan <jyan@ca.ibm.com>
Cr-Commit-Position: refs/heads/master@{#51948}
This commit is contained in:
Vasili Skurydzin 2018-03-14 13:24:43 -04:00 committed by Commit Bot
parent 410893e9a9
commit 3032a9ffb5
2 changed files with 12 additions and 134 deletions

View File

@ -129,11 +129,6 @@ void VisitBinop(InstructionSelector* selector, Node* node,
inputs[input_count++] = g.UseRegister(m.left().node()); inputs[input_count++] = g.UseRegister(m.left().node());
inputs[input_count++] = g.UseOperand(m.right().node(), operand_mode); inputs[input_count++] = g.UseOperand(m.right().node(), operand_mode);
if (cont->IsBranch()) {
inputs[input_count++] = g.Label(cont->true_block());
inputs[input_count++] = g.Label(cont->false_block());
}
if (cont->IsDeoptimize()) { if (cont->IsDeoptimize()) {
// If we can deoptimize as a result of the binop, we need to make sure that // If we can deoptimize as a result of the binop, we need to make sure that
// the deopt inputs are not overwritten by the binop result. One way // the deopt inputs are not overwritten by the binop result. One way
@ -142,26 +137,14 @@ void VisitBinop(InstructionSelector* selector, Node* node,
} else { } else {
outputs[output_count++] = g.DefineAsRegister(node); outputs[output_count++] = g.DefineAsRegister(node);
} }
if (cont->IsSet()) {
outputs[output_count++] = g.DefineAsRegister(cont->result());
}
DCHECK_NE(0u, input_count); DCHECK_NE(0u, input_count);
DCHECK_NE(0u, output_count); DCHECK_NE(0u, output_count);
DCHECK_GE(arraysize(inputs), input_count); DCHECK_GE(arraysize(inputs), input_count);
DCHECK_GE(arraysize(outputs), output_count); DCHECK_GE(arraysize(outputs), output_count);
opcode = cont->Encode(opcode); selector->EmitWithContinuation(opcode, output_count, outputs, input_count,
if (cont->IsDeoptimize()) { inputs, cont);
selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs,
cont->kind(), cont->reason(), cont->feedback(),
cont->frame_state());
} else if (cont->IsTrap()) {
inputs[input_count++] = g.UseImmediate(cont->trap_id());
selector->Emit(opcode, output_count, outputs, input_count, inputs);
} else {
selector->Emit(opcode, output_count, outputs, input_count, inputs);
}
} }
@ -1486,22 +1469,7 @@ namespace {
void VisitCompare(InstructionSelector* selector, InstructionCode opcode, void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
InstructionOperand left, InstructionOperand right, InstructionOperand left, InstructionOperand right,
FlagsContinuation* cont) { FlagsContinuation* cont) {
PPCOperandGenerator g(selector); selector->EmitWithContinuation(opcode, left, right, cont);
opcode = cont->Encode(opcode);
if (cont->IsBranch()) {
selector->Emit(opcode, g.NoOutput(), left, right,
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->feedback(),
cont->frame_state());
} else if (cont->IsSet()) {
selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right);
} else {
DCHECK(cont->IsTrap());
selector->Emit(opcode, g.NoOutput(), left, right,
g.UseImmediate(cont->trap_id()));
}
} }

View File

@ -583,11 +583,6 @@ void VisitUnaryOp(InstructionSelector* selector, Node* node,
inputs[input_count++] = g.TempImmediate(!canEliminateZeroExt); inputs[input_count++] = g.TempImmediate(!canEliminateZeroExt);
} }
if (cont->IsBranch()) {
inputs[input_count++] = g.Label(cont->true_block());
inputs[input_count++] = g.Label(cont->false_block());
}
if (!cont->IsDeoptimize()) { if (!cont->IsDeoptimize()) {
// If we can deoptimize as a result of the binop, we need to make sure // If we can deoptimize as a result of the binop, we need to make sure
// that the deopt inputs are not overwritten by the binop result. One way // that the deopt inputs are not overwritten by the binop result. One way
@ -602,27 +597,13 @@ void VisitUnaryOp(InstructionSelector* selector, Node* node,
outputs[output_count++] = g.DefineSameAsFirst(node); outputs[output_count++] = g.DefineSameAsFirst(node);
} }
if (cont->IsSet()) {
outputs[output_count++] = g.DefineAsRegister(cont->result());
}
DCHECK_NE(0u, input_count); DCHECK_NE(0u, input_count);
DCHECK_NE(0u, output_count); DCHECK_NE(0u, output_count);
DCHECK_GE(arraysize(inputs), input_count); DCHECK_GE(arraysize(inputs), input_count);
DCHECK_GE(arraysize(outputs), output_count); DCHECK_GE(arraysize(outputs), output_count);
opcode = cont->Encode(opcode); selector->EmitWithContinuation(opcode, output_count, outputs, input_count,
inputs, cont);
if (cont->IsDeoptimize()) {
selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs,
cont->kind(), cont->reason(), cont->feedback(),
cont->frame_state());
} else if (cont->IsTrap()) {
inputs[input_count++] = g.UseImmediate(cont->trap_id());
selector->Emit(opcode, output_count, outputs, input_count, inputs);
} else {
selector->Emit(opcode, output_count, outputs, input_count, inputs);
}
} }
template <class CanCombineWithLoad> template <class CanCombineWithLoad>
@ -658,11 +639,6 @@ void VisitBinOp(InstructionSelector* selector, Node* node,
inputs[input_count++] = g.TempImmediate(!canEliminateZeroExt); inputs[input_count++] = g.TempImmediate(!canEliminateZeroExt);
} }
if (cont->IsBranch()) {
inputs[input_count++] = g.Label(cont->true_block());
inputs[input_count++] = g.Label(cont->false_block());
}
if ((operand_mode & OperandMode::kAllowDistinctOps) && if ((operand_mode & OperandMode::kAllowDistinctOps) &&
// If we can deoptimize as a result of the binop, we need to make sure // If we can deoptimize as a result of the binop, we need to make sure
// that the deopt inputs are not overwritten by the binop result. One way // that the deopt inputs are not overwritten by the binop result. One way
@ -678,27 +654,13 @@ void VisitBinOp(InstructionSelector* selector, Node* node,
outputs[output_count++] = g.DefineSameAsFirst(node); outputs[output_count++] = g.DefineSameAsFirst(node);
} }
if (cont->IsSet()) {
outputs[output_count++] = g.DefineAsRegister(cont->result());
}
DCHECK_NE(0u, input_count); DCHECK_NE(0u, input_count);
DCHECK_NE(0u, output_count); DCHECK_NE(0u, output_count);
DCHECK_GE(arraysize(inputs), input_count); DCHECK_GE(arraysize(inputs), input_count);
DCHECK_GE(arraysize(outputs), output_count); DCHECK_GE(arraysize(outputs), output_count);
opcode = cont->Encode(opcode); selector->EmitWithContinuation(opcode, output_count, outputs, input_count,
inputs, cont);
if (cont->IsDeoptimize()) {
selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs,
cont->kind(), cont->reason(), cont->feedback(),
cont->frame_state());
} else if (cont->IsTrap()) {
inputs[input_count++] = g.UseImmediate(cont->trap_id());
selector->Emit(opcode, output_count, outputs, input_count, inputs);
} else {
selector->Emit(opcode, output_count, outputs, input_count, inputs);
}
} }
} // namespace } // namespace
@ -1651,22 +1613,7 @@ namespace {
void VisitCompare(InstructionSelector* selector, InstructionCode opcode, void VisitCompare(InstructionSelector* selector, InstructionCode opcode,
InstructionOperand left, InstructionOperand right, InstructionOperand left, InstructionOperand right,
FlagsContinuation* cont) { FlagsContinuation* cont) {
S390OperandGenerator g(selector); selector->EmitWithContinuation(opcode, left, right, cont);
opcode = cont->Encode(opcode);
if (cont->IsBranch()) {
selector->Emit(opcode, g.NoOutput(), left, right,
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->feedback(),
cont->frame_state());
} else if (cont->IsSet()) {
selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right);
} else {
DCHECK(cont->IsTrap());
selector->Emit(opcode, g.NoOutput(), left, right,
g.UseImmediate(cont->trap_id()));
}
} }
void VisitLoadAndTest(InstructionSelector* selector, InstructionCode opcode, void VisitLoadAndTest(InstructionSelector* selector, InstructionCode opcode,
@ -1727,27 +1674,9 @@ void VisitWordCompare(InstructionSelector* selector, Node* node,
inputs[input_count++] = g.UseAnyExceptImmediate(right); inputs[input_count++] = g.UseAnyExceptImmediate(right);
} }
opcode = cont->Encode(opcode);
if (cont->IsBranch()) {
inputs[input_count++] = g.Label(cont->true_block());
inputs[input_count++] = g.Label(cont->false_block());
} else if (cont->IsSet()) {
outputs[output_count++] = g.DefineAsRegister(cont->result());
} else if (cont->IsTrap()) {
inputs[input_count++] = g.UseImmediate(cont->trap_id());
} else {
DCHECK(cont->IsDeoptimize());
// nothing to do
}
DCHECK(input_count <= 8 && output_count <= 1); DCHECK(input_count <= 8 && output_count <= 1);
if (cont->IsDeoptimize()) { selector->EmitWithContinuation(opcode, output_count, outputs, input_count,
selector->EmitDeoptimize(opcode, 0, nullptr, input_count, inputs, inputs, cont);
cont->kind(), cont->reason(), cont->feedback(),
cont->frame_state());
} else {
selector->Emit(opcode, output_count, outputs, input_count, inputs);
}
} }
void VisitWord32Compare(InstructionSelector* selector, Node* node, void VisitWord32Compare(InstructionSelector* selector, Node* node,
@ -1832,28 +1761,9 @@ void VisitLoadAndTest(InstructionSelector* selector, InstructionCode opcode,
outputs[output_count++] = g.DefineAsRegister(value); outputs[output_count++] = g.DefineAsRegister(value);
} }
opcode = cont->Encode(opcode);
if (cont->IsBranch()) {
inputs[input_count++] = g.Label(cont->true_block());
inputs[input_count++] = g.Label(cont->false_block());
} else if (cont->IsSet()) {
outputs[output_count++] = g.DefineAsRegister(cont->result());
} else if (cont->IsTrap()) {
inputs[input_count++] = g.UseImmediate(cont->trap_id());
} else {
DCHECK(cont->IsDeoptimize());
// nothing to do
}
DCHECK(input_count <= 8 && output_count <= 2); DCHECK(input_count <= 8 && output_count <= 2);
opcode = cont->Encode(opcode); selector->EmitWithContinuation(opcode, output_count, outputs, input_count,
if (cont->IsDeoptimize()) { inputs, cont);
selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs,
cont->kind(), cont->reason(), cont->feedback(),
cont->frame_state());
} else {
selector->Emit(opcode, output_count, outputs, input_count, inputs);
}
} }
} // namespace } // namespace