Commit 83e66947 authored by bjaideep's avatar bjaideep Committed by Commit bot

PPC/s390: [wasm] Trim graph before scheduling.

Port 99023682

Original commit message:

    The scheduler expects a trimmed graph, so we have to trim the graph
    before scheduling.

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

BUG=
LOG=N

Review-Url: https://chromiumcodereview.appspot.com/2431093004
Cr-Commit-Position: refs/heads/master@{#40475}
parent 57b14b06
...@@ -1241,39 +1241,46 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1241,39 +1241,46 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ mulhwu(i.OutputRegister(1), i.InputRegister(0), i.InputRegister(2)); __ mulhwu(i.OutputRegister(1), i.InputRegister(0), i.InputRegister(2));
__ add(i.OutputRegister(1), i.OutputRegister(1), i.TempRegister(0)); __ add(i.OutputRegister(1), i.OutputRegister(1), i.TempRegister(0));
break; break;
case kPPC_ShiftLeftPair: case kPPC_ShiftLeftPair: {
Register second_output =
instr->OutputCount() >= 2 ? i.OutputRegister(1) : i.TempRegister(0);
if (instr->InputAt(2)->IsImmediate()) { if (instr->InputAt(2)->IsImmediate()) {
__ ShiftLeftPair(i.OutputRegister(0), i.OutputRegister(1), __ ShiftLeftPair(i.OutputRegister(0), second_output, i.InputRegister(0),
i.InputRegister(0), i.InputRegister(1), i.InputRegister(1), i.InputInt32(2));
i.InputInt32(2));
} else { } else {
__ ShiftLeftPair(i.OutputRegister(0), i.OutputRegister(1), __ ShiftLeftPair(i.OutputRegister(0), second_output, i.InputRegister(0),
i.InputRegister(0), i.InputRegister(1), kScratchReg, i.InputRegister(1), kScratchReg, i.InputRegister(2));
i.InputRegister(2));
} }
break; break;
case kPPC_ShiftRightPair: }
case kPPC_ShiftRightPair: {
Register second_output =
instr->OutputCount() >= 2 ? i.OutputRegister(1) : i.TempRegister(0);
if (instr->InputAt(2)->IsImmediate()) { if (instr->InputAt(2)->IsImmediate()) {
__ ShiftRightPair(i.OutputRegister(0), i.OutputRegister(1), __ ShiftRightPair(i.OutputRegister(0), second_output,
i.InputRegister(0), i.InputRegister(1), i.InputRegister(0), i.InputRegister(1),
i.InputInt32(2)); i.InputInt32(2));
} else { } else {
__ ShiftRightPair(i.OutputRegister(0), i.OutputRegister(1), __ ShiftRightPair(i.OutputRegister(0), second_output,
i.InputRegister(0), i.InputRegister(1), kScratchReg, i.InputRegister(0), i.InputRegister(1), kScratchReg,
i.InputRegister(2)); i.InputRegister(2));
} }
break; break;
case kPPC_ShiftRightAlgPair: }
case kPPC_ShiftRightAlgPair: {
Register second_output =
instr->OutputCount() >= 2 ? i.OutputRegister(1) : i.TempRegister(0);
if (instr->InputAt(2)->IsImmediate()) { if (instr->InputAt(2)->IsImmediate()) {
__ ShiftRightAlgPair(i.OutputRegister(0), i.OutputRegister(1), __ ShiftRightAlgPair(i.OutputRegister(0), second_output,
i.InputRegister(0), i.InputRegister(1), i.InputRegister(0), i.InputRegister(1),
i.InputInt32(2)); i.InputInt32(2));
} else { } else {
__ ShiftRightAlgPair(i.OutputRegister(0), i.OutputRegister(1), __ ShiftRightAlgPair(i.OutputRegister(0), second_output,
i.InputRegister(0), i.InputRegister(1), i.InputRegister(0), i.InputRegister(1),
kScratchReg, i.InputRegister(2)); kScratchReg, i.InputRegister(2));
} }
break; break;
}
#endif #endif
case kPPC_RotRight32: case kPPC_RotRight32:
if (HasRegisterInput(instr, 1)) { if (HasRegisterInput(instr, 1)) {
......
...@@ -810,49 +810,70 @@ void InstructionSelector::VisitWord32Sar(Node* node) { ...@@ -810,49 +810,70 @@ void InstructionSelector::VisitWord32Sar(Node* node) {
#if !V8_TARGET_ARCH_PPC64 #if !V8_TARGET_ARCH_PPC64
void VisitPairBinop(InstructionSelector* selector, InstructionCode opcode, void VisitPairBinop(InstructionSelector* selector, InstructionCode opcode,
Node* node) { InstructionCode opcode2, Node* node) {
PPCOperandGenerator g(selector); PPCOperandGenerator g(selector);
// We use UseUniqueRegister here to avoid register sharing with the output Node* projection1 = NodeProperties::FindProjection(node, 1);
// registers. if (projection1) {
InstructionOperand inputs[] = { // We use UseUniqueRegister here to avoid register sharing with the output
g.UseRegister(node->InputAt(0)), g.UseUniqueRegister(node->InputAt(1)), // registers.
g.UseRegister(node->InputAt(2)), g.UseUniqueRegister(node->InputAt(3))}; InstructionOperand inputs[] = {
g.UseRegister(node->InputAt(0)), g.UseUniqueRegister(node->InputAt(1)),
g.UseRegister(node->InputAt(2)), g.UseUniqueRegister(node->InputAt(3))};
InstructionOperand outputs[] = { InstructionOperand outputs[] = {
g.DefineAsRegister(node), g.DefineAsRegister(node),
g.DefineAsRegister(NodeProperties::FindProjection(node, 1))}; g.DefineAsRegister(NodeProperties::FindProjection(node, 1))};
selector->Emit(opcode, 2, outputs, 4, inputs); selector->Emit(opcode, 2, outputs, 4, inputs);
} else {
// The high word of the result is not used, so we emit the standard 32 bit
// instruction.
selector->Emit(opcode2, g.DefineSameAsFirst(node),
g.UseRegister(node->InputAt(0)),
g.UseRegister(node->InputAt(2)));
}
} }
void InstructionSelector::VisitInt32PairAdd(Node* node) { void InstructionSelector::VisitInt32PairAdd(Node* node) {
VisitPairBinop(this, kPPC_AddPair, node); VisitPairBinop(this, kPPC_AddPair, kPPC_Add, node);
} }
void InstructionSelector::VisitInt32PairSub(Node* node) { void InstructionSelector::VisitInt32PairSub(Node* node) {
VisitPairBinop(this, kPPC_SubPair, node); VisitPairBinop(this, kPPC_SubPair, kPPC_Sub, node);
} }
void InstructionSelector::VisitInt32PairMul(Node* node) { void InstructionSelector::VisitInt32PairMul(Node* node) {
PPCOperandGenerator g(this); PPCOperandGenerator g(this);
InstructionOperand inputs[] = {g.UseUniqueRegister(node->InputAt(0)), Node* projection1 = NodeProperties::FindProjection(node, 1);
g.UseUniqueRegister(node->InputAt(1)), if (projection1) {
g.UseUniqueRegister(node->InputAt(2)), InstructionOperand inputs[] = {g.UseUniqueRegister(node->InputAt(0)),
g.UseRegister(node->InputAt(3))}; g.UseUniqueRegister(node->InputAt(1)),
g.UseUniqueRegister(node->InputAt(2)),
g.UseUniqueRegister(node->InputAt(3))};
InstructionOperand outputs[] = { InstructionOperand outputs[] = {
g.DefineAsRegister(node), g.DefineAsRegister(node),
g.DefineAsRegister(NodeProperties::FindProjection(node, 1))}; g.DefineAsRegister(NodeProperties::FindProjection(node, 1))};
InstructionOperand temps[] = {g.TempRegister(), g.TempRegister()}; InstructionOperand temps[] = {g.TempRegister(), g.TempRegister()};
Emit(kPPC_MulPair, 2, outputs, 4, inputs, 2, temps); Emit(kPPC_MulPair, 2, outputs, 4, inputs, 2, temps);
} else {
// The high word of the result is not used, so we emit the standard 32 bit
// instruction.
Emit(kPPC_Mul32, g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)),
g.UseRegister(node->InputAt(2)));
}
} }
namespace {
// Shared routine for multiple shift operations.
void VisitPairShift(InstructionSelector* selector, InstructionCode opcode, void VisitPairShift(InstructionSelector* selector, InstructionCode opcode,
Node* node) { Node* node) {
PPCOperandGenerator g(selector); PPCOperandGenerator g(selector);
// We use g.UseUniqueRegister here to guarantee that there is
// no register aliasing of input registers with output registers.
Int32Matcher m(node->InputAt(2)); Int32Matcher m(node->InputAt(2));
InstructionOperand shift_operand; InstructionOperand shift_operand;
if (m.HasValue()) { if (m.HasValue()) {
...@@ -861,16 +882,27 @@ void VisitPairShift(InstructionSelector* selector, InstructionCode opcode, ...@@ -861,16 +882,27 @@ void VisitPairShift(InstructionSelector* selector, InstructionCode opcode,
shift_operand = g.UseUniqueRegister(m.node()); shift_operand = g.UseUniqueRegister(m.node());
} }
InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0)), InstructionOperand inputs[] = {g.UseUniqueRegister(node->InputAt(0)),
g.UseRegister(node->InputAt(1)), g.UseUniqueRegister(node->InputAt(1)),
shift_operand}; shift_operand};
InstructionOperand outputs[] = { Node* projection1 = NodeProperties::FindProjection(node, 1);
g.DefineSameAsFirst(node),
g.DefineAsRegister(NodeProperties::FindProjection(node, 1))};
selector->Emit(opcode, 2, outputs, 3, inputs); InstructionOperand outputs[2];
InstructionOperand temps[1];
int32_t output_count = 0;
int32_t temp_count = 0;
outputs[output_count++] = g.DefineAsRegister(node);
if (projection1) {
outputs[output_count++] = g.DefineAsRegister(projection1);
} else {
temps[temp_count++] = g.TempRegister();
}
selector->Emit(opcode, output_count, outputs, 3, inputs, temp_count, temps);
} }
} // namespace
void InstructionSelector::VisitWord32PairShl(Node* node) { void InstructionSelector::VisitWord32PairShl(Node* node) {
VisitPairShift(this, kPPC_ShiftLeftPair, node); VisitPairShift(this, kPPC_ShiftLeftPair, node);
......
...@@ -1159,39 +1159,46 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -1159,39 +1159,46 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ lr(i.OutputRegister(0), r1); __ lr(i.OutputRegister(0), r1);
__ srag(i.OutputRegister(1), r1, Operand(32)); __ srag(i.OutputRegister(1), r1, Operand(32));
break; break;
case kS390_ShiftLeftPair: case kS390_ShiftLeftPair: {
Register second_output =
instr->OutputCount() >= 2 ? i.OutputRegister(1) : i.TempRegister(0);
if (instr->InputAt(2)->IsImmediate()) { if (instr->InputAt(2)->IsImmediate()) {
__ ShiftLeftPair(i.OutputRegister(0), i.OutputRegister(1), __ ShiftLeftPair(i.OutputRegister(0), second_output, i.InputRegister(0),
i.InputRegister(0), i.InputRegister(1), i.InputRegister(1), i.InputInt32(2));
i.InputInt32(2));
} else { } else {
__ ShiftLeftPair(i.OutputRegister(0), i.OutputRegister(1), __ ShiftLeftPair(i.OutputRegister(0), second_output, i.InputRegister(0),
i.InputRegister(0), i.InputRegister(1), kScratchReg, i.InputRegister(1), kScratchReg, i.InputRegister(2));
i.InputRegister(2));
} }
break; break;
case kS390_ShiftRightPair: }
case kS390_ShiftRightPair: {
Register second_output =
instr->OutputCount() >= 2 ? i.OutputRegister(1) : i.TempRegister(0);
if (instr->InputAt(2)->IsImmediate()) { if (instr->InputAt(2)->IsImmediate()) {
__ ShiftRightPair(i.OutputRegister(0), i.OutputRegister(1), __ ShiftRightPair(i.OutputRegister(0), second_output,
i.InputRegister(0), i.InputRegister(1), i.InputRegister(0), i.InputRegister(1),
i.InputInt32(2)); i.InputInt32(2));
} else { } else {
__ ShiftRightPair(i.OutputRegister(0), i.OutputRegister(1), __ ShiftRightPair(i.OutputRegister(0), second_output,
i.InputRegister(0), i.InputRegister(1), kScratchReg, i.InputRegister(0), i.InputRegister(1), kScratchReg,
i.InputRegister(2)); i.InputRegister(2));
} }
break; break;
case kS390_ShiftRightArithPair: }
case kS390_ShiftRightArithPair: {
Register second_output =
instr->OutputCount() >= 2 ? i.OutputRegister(1) : i.TempRegister(0);
if (instr->InputAt(2)->IsImmediate()) { if (instr->InputAt(2)->IsImmediate()) {
__ ShiftRightArithPair(i.OutputRegister(0), i.OutputRegister(1), __ ShiftRightArithPair(i.OutputRegister(0), second_output,
i.InputRegister(0), i.InputRegister(1), i.InputRegister(0), i.InputRegister(1),
i.InputInt32(2)); i.InputInt32(2));
} else { } else {
__ ShiftRightArithPair(i.OutputRegister(0), i.OutputRegister(1), __ ShiftRightArithPair(i.OutputRegister(0), second_output,
i.InputRegister(0), i.InputRegister(1), i.InputRegister(0), i.InputRegister(1),
kScratchReg, i.InputRegister(2)); kScratchReg, i.InputRegister(2));
} }
break; break;
}
#endif #endif
case kS390_RotRight32: case kS390_RotRight32:
if (HasRegisterInput(instr, 1)) { if (HasRegisterInput(instr, 1)) {
......
...@@ -835,48 +835,69 @@ void InstructionSelector::VisitWord32Sar(Node* node) { ...@@ -835,48 +835,69 @@ void InstructionSelector::VisitWord32Sar(Node* node) {
} }
#if !V8_TARGET_ARCH_S390X #if !V8_TARGET_ARCH_S390X
void VisitPairBinop(InstructionSelector* selector, ArchOpcode opcode, void VisitPairBinop(InstructionSelector* selector, InstructionCode opcode,
Node* node) { InstructionCode opcode2, Node* node) {
S390OperandGenerator g(selector); S390OperandGenerator g(selector);
// We use UseUniqueRegister here to avoid register sharing with the output Node* projection1 = NodeProperties::FindProjection(node, 1);
// registers. if (projection1) {
InstructionOperand inputs[] = { // We use UseUniqueRegister here to avoid register sharing with the output
g.UseRegister(node->InputAt(0)), g.UseUniqueRegister(node->InputAt(1)), // registers.
g.UseRegister(node->InputAt(2)), g.UseUniqueRegister(node->InputAt(3))}; InstructionOperand inputs[] = {
g.UseRegister(node->InputAt(0)), g.UseUniqueRegister(node->InputAt(1)),
g.UseRegister(node->InputAt(2)), g.UseUniqueRegister(node->InputAt(3))};
InstructionOperand outputs[] = { InstructionOperand outputs[] = {
g.DefineAsRegister(node), g.DefineAsRegister(node),
g.DefineAsRegister(NodeProperties::FindProjection(node, 1))}; g.DefineAsRegister(NodeProperties::FindProjection(node, 1))};
selector->Emit(opcode, 2, outputs, 4, inputs); selector->Emit(opcode, 2, outputs, 4, inputs);
} else {
// The high word of the result is not used, so we emit the standard 32 bit
// instruction.
selector->Emit(opcode2, g.DefineSameAsFirst(node),
g.UseRegister(node->InputAt(0)),
g.UseRegister(node->InputAt(2)));
}
} }
void InstructionSelector::VisitInt32PairAdd(Node* node) { void InstructionSelector::VisitInt32PairAdd(Node* node) {
VisitPairBinop(this, kS390_AddPair, node); VisitPairBinop(this, kS390_AddPair, kS390_Add32, node);
} }
void InstructionSelector::VisitInt32PairSub(Node* node) { void InstructionSelector::VisitInt32PairSub(Node* node) {
VisitPairBinop(this, kS390_SubPair, node); VisitPairBinop(this, kS390_SubPair, kS390_Sub32, node);
} }
void InstructionSelector::VisitInt32PairMul(Node* node) { void InstructionSelector::VisitInt32PairMul(Node* node) {
S390OperandGenerator g(this); S390OperandGenerator g(this);
InstructionOperand inputs[] = {g.UseUniqueRegister(node->InputAt(0)), Node* projection1 = NodeProperties::FindProjection(node, 1);
g.UseUniqueRegister(node->InputAt(1)), if (projection1) {
g.UseUniqueRegister(node->InputAt(2)), InstructionOperand inputs[] = {g.UseUniqueRegister(node->InputAt(0)),
g.UseUniqueRegister(node->InputAt(3))}; g.UseUniqueRegister(node->InputAt(1)),
g.UseUniqueRegister(node->InputAt(2)),
InstructionOperand outputs[] = { g.UseUniqueRegister(node->InputAt(3))};
g.DefineAsRegister(node),
g.DefineAsRegister(NodeProperties::FindProjection(node, 1))}; InstructionOperand outputs[] = {
g.DefineAsRegister(node),
Emit(kS390_MulPair, 2, outputs, 4, inputs); g.DefineAsRegister(NodeProperties::FindProjection(node, 1))};
Emit(kS390_MulPair, 2, outputs, 4, inputs);
} else {
// The high word of the result is not used, so we emit the standard 32 bit
// instruction.
Emit(kS390_Mul32, g.DefineSameAsFirst(node),
g.UseRegister(node->InputAt(0)), g.UseRegister(node->InputAt(2)));
}
} }
void VisitPairShift(InstructionSelector* selector, ArchOpcode opcode, namespace {
// Shared routine for multiple shift operations.
void VisitPairShift(InstructionSelector* selector, InstructionCode opcode,
Node* node) { Node* node) {
S390OperandGenerator g(selector); S390OperandGenerator g(selector);
// We use g.UseUniqueRegister here to guarantee that there is
// no register aliasing of input registers with output registers.
Int32Matcher m(node->InputAt(2)); Int32Matcher m(node->InputAt(2));
InstructionOperand shift_operand; InstructionOperand shift_operand;
if (m.HasValue()) { if (m.HasValue()) {
...@@ -885,16 +906,27 @@ void VisitPairShift(InstructionSelector* selector, ArchOpcode opcode, ...@@ -885,16 +906,27 @@ void VisitPairShift(InstructionSelector* selector, ArchOpcode opcode,
shift_operand = g.UseUniqueRegister(m.node()); shift_operand = g.UseUniqueRegister(m.node());
} }
InstructionOperand inputs[] = {g.UseRegister(node->InputAt(0)), InstructionOperand inputs[] = {g.UseUniqueRegister(node->InputAt(0)),
g.UseRegister(node->InputAt(1)), g.UseUniqueRegister(node->InputAt(1)),
shift_operand}; shift_operand};
InstructionOperand outputs[] = { Node* projection1 = NodeProperties::FindProjection(node, 1);
g.DefineSameAsFirst(node),
g.DefineAsRegister(NodeProperties::FindProjection(node, 1))};
selector->Emit(opcode, 2, outputs, 3, inputs); InstructionOperand outputs[2];
InstructionOperand temps[1];
int32_t output_count = 0;
int32_t temp_count = 0;
outputs[output_count++] = g.DefineAsRegister(node);
if (projection1) {
outputs[output_count++] = g.DefineAsRegister(projection1);
} else {
temps[temp_count++] = g.TempRegister();
}
selector->Emit(opcode, output_count, outputs, 3, inputs, temp_count, temps);
} }
} // namespace
void InstructionSelector::VisitWord32PairShl(Node* node) { void InstructionSelector::VisitWord32PairShl(Node* node) {
VisitPairShift(this, kS390_ShiftLeftPair, node); VisitPairShift(this, kS390_ShiftLeftPair, node);
......
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