Commit 7c25cfcf authored by Milad Fa's avatar Milad Fa Committed by V8 LUCI CQ

PPC/S390: Fix load ops in the instruction selector

This is addition to https://crrev.com/c/3108289 to
fix load ops for atomic and regular ops.

Change-Id: I1107e0571eb40d858562b12646308b9fe46cc88d
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3114025Reviewed-by: 's avatarJunliang Yan <junyan@redhat.com>
Commit-Queue: Milad Fa <mfarazma@redhat.com>
Cr-Commit-Position: refs/heads/main@{#76437}
parent 1b02d21a
...@@ -167,9 +167,9 @@ void InstructionSelector::VisitAbortCSAAssert(Node* node) { ...@@ -167,9 +167,9 @@ void InstructionSelector::VisitAbortCSAAssert(Node* node) {
Emit(kArchAbortCSAAssert, g.NoOutput(), g.UseFixed(node->InputAt(0), r4)); Emit(kArchAbortCSAAssert, g.NoOutput(), g.UseFixed(node->InputAt(0), r4));
} }
void InstructionSelector::VisitLoad(Node* node) { static void VisitLoadCommon(InstructionSelector* selector, Node* node,
LoadRepresentation load_rep = LoadRepresentationOf(node->op()); LoadRepresentation load_rep) {
PPCOperandGenerator g(this); PPCOperandGenerator g(selector);
Node* base = node->InputAt(0); Node* base = node->InputAt(0);
Node* offset = node->InputAt(1); Node* offset = node->InputAt(1);
InstructionCode opcode = kArchNop; InstructionCode opcode = kArchNop;
...@@ -233,20 +233,25 @@ void InstructionSelector::VisitLoad(Node* node) { ...@@ -233,20 +233,25 @@ void InstructionSelector::VisitLoad(Node* node) {
node->opcode() == IrOpcode::kWord64AtomicLoad); node->opcode() == IrOpcode::kWord64AtomicLoad);
if (g.CanBeImmediate(offset, mode)) { if (g.CanBeImmediate(offset, mode)) {
Emit(opcode | AddressingModeField::encode(kMode_MRI), selector->Emit(opcode | AddressingModeField::encode(kMode_MRI),
g.DefineAsRegister(node), g.UseRegister(base), g.UseImmediate(offset), g.DefineAsRegister(node), g.UseRegister(base),
g.UseImmediate(is_atomic)); g.UseImmediate(offset), g.UseImmediate(is_atomic));
} else if (g.CanBeImmediate(base, mode)) { } else if (g.CanBeImmediate(base, mode)) {
Emit(opcode | AddressingModeField::encode(kMode_MRI), selector->Emit(opcode | AddressingModeField::encode(kMode_MRI),
g.DefineAsRegister(node), g.UseRegister(offset), g.UseImmediate(base), g.DefineAsRegister(node), g.UseRegister(offset),
g.UseImmediate(is_atomic)); g.UseImmediate(base), g.UseImmediate(is_atomic));
} else { } else {
Emit(opcode | AddressingModeField::encode(kMode_MRR), selector->Emit(opcode | AddressingModeField::encode(kMode_MRR),
g.DefineAsRegister(node), g.UseRegister(base), g.UseRegister(offset), g.DefineAsRegister(node), g.UseRegister(base),
g.UseImmediate(is_atomic)); g.UseRegister(offset), g.UseImmediate(is_atomic));
} }
} }
void InstructionSelector::VisitLoad(Node* node) {
LoadRepresentation load_rep = LoadRepresentationOf(node->op());
VisitLoadCommon(this, node, load_rep);
}
void InstructionSelector::VisitProtectedLoad(Node* node) { void InstructionSelector::VisitProtectedLoad(Node* node) {
// TODO(eholk) // TODO(eholk)
UNIMPLEMENTED(); UNIMPLEMENTED();
...@@ -1953,9 +1958,17 @@ void InstructionSelector::VisitMemoryBarrier(Node* node) { ...@@ -1953,9 +1958,17 @@ void InstructionSelector::VisitMemoryBarrier(Node* node) {
Emit(kPPC_Sync, g.NoOutput()); Emit(kPPC_Sync, g.NoOutput());
} }
void InstructionSelector::VisitWord32AtomicLoad(Node* node) { VisitLoad(node); } void InstructionSelector::VisitWord32AtomicLoad(Node* node) {
AtomicLoadParameters atomic_load_params = AtomicLoadParametersOf(node->op());
LoadRepresentation load_rep = atomic_load_params.representation();
VisitLoadCommon(this, node, load_rep);
}
void InstructionSelector::VisitWord64AtomicLoad(Node* node) { VisitLoad(node); } void InstructionSelector::VisitWord64AtomicLoad(Node* node) {
AtomicLoadParameters atomic_load_params = AtomicLoadParametersOf(node->op());
LoadRepresentation load_rep = atomic_load_params.representation();
VisitLoadCommon(this, node, load_rep);
}
void InstructionSelector::VisitWord32AtomicStore(Node* node) { void InstructionSelector::VisitWord32AtomicStore(Node* node) {
AtomicStoreParameters store_params = AtomicStoreParametersOf(node->op()); AtomicStoreParameters store_params = AtomicStoreParametersOf(node->op());
......
...@@ -272,8 +272,7 @@ bool S390OpcodeOnlySupport12BitDisp(InstructionCode op) { ...@@ -272,8 +272,7 @@ bool S390OpcodeOnlySupport12BitDisp(InstructionCode op) {
(S390OpcodeOnlySupport12BitDisp(op) ? OperandMode::kUint12Imm \ (S390OpcodeOnlySupport12BitDisp(op) ? OperandMode::kUint12Imm \
: OperandMode::kInt20Imm) : OperandMode::kInt20Imm)
ArchOpcode SelectLoadOpcode(Node* node) { ArchOpcode SelectLoadOpcode(LoadRepresentation load_rep) {
LoadRepresentation load_rep = LoadRepresentationOf(node->op());
ArchOpcode opcode; ArchOpcode opcode;
switch (load_rep.representation()) { switch (load_rep.representation()) {
case MachineRepresentation::kFloat32: case MachineRepresentation::kFloat32:
...@@ -466,7 +465,8 @@ void GenerateRightOperands(InstructionSelector* selector, Node* node, ...@@ -466,7 +465,8 @@ void GenerateRightOperands(InstructionSelector* selector, Node* node,
} else if (*operand_mode & OperandMode::kAllowMemoryOperand) { } else if (*operand_mode & OperandMode::kAllowMemoryOperand) {
NodeMatcher mright(right); NodeMatcher mright(right);
if (mright.IsLoad() && selector->CanCover(node, right) && if (mright.IsLoad() && selector->CanCover(node, right) &&
canCombineWithLoad(SelectLoadOpcode(right))) { canCombineWithLoad(
SelectLoadOpcode(LoadRepresentationOf(right->op())))) {
AddressingMode mode = g.GetEffectiveAddressMemoryOperand( AddressingMode mode = g.GetEffectiveAddressMemoryOperand(
right, inputs, input_count, OpcodeImmMode(*opcode)); right, inputs, input_count, OpcodeImmMode(*opcode));
*opcode |= AddressingModeField::encode(mode); *opcode |= AddressingModeField::encode(mode);
...@@ -695,18 +695,24 @@ void InstructionSelector::VisitAbortCSAAssert(Node* node) { ...@@ -695,18 +695,24 @@ void InstructionSelector::VisitAbortCSAAssert(Node* node) {
Emit(kArchAbortCSAAssert, g.NoOutput(), g.UseFixed(node->InputAt(0), r3)); Emit(kArchAbortCSAAssert, g.NoOutput(), g.UseFixed(node->InputAt(0), r3));
} }
void InstructionSelector::VisitLoad(Node* node) { void InstructionSelector::VisitLoad(Node* node, Node* value,
InstructionCode opcode) {
S390OperandGenerator g(this); S390OperandGenerator g(this);
InstructionCode opcode = SelectLoadOpcode(node);
InstructionOperand outputs[] = {g.DefineAsRegister(node)}; InstructionOperand outputs[] = {g.DefineAsRegister(node)};
InstructionOperand inputs[3]; InstructionOperand inputs[3];
size_t input_count = 0; size_t input_count = 0;
AddressingMode mode = AddressingMode mode =
g.GetEffectiveAddressMemoryOperand(node, inputs, &input_count); g.GetEffectiveAddressMemoryOperand(value, inputs, &input_count);
opcode |= AddressingModeField::encode(mode); opcode |= AddressingModeField::encode(mode);
Emit(opcode, 1, outputs, input_count, inputs); Emit(opcode, 1, outputs, input_count, inputs);
} }
void InstructionSelector::VisitLoad(Node* node) {
LoadRepresentation load_rep = LoadRepresentationOf(node->op());
InstructionCode opcode = SelectLoadOpcode(load_rep);
VisitLoad(node, node, opcode);
}
void InstructionSelector::VisitProtectedLoad(Node* node) { void InstructionSelector::VisitProtectedLoad(Node* node) {
// TODO(eholk) // TODO(eholk)
UNIMPLEMENTED(); UNIMPLEMENTED();
...@@ -2147,12 +2153,9 @@ void InstructionSelector::VisitMemoryBarrier(Node* node) { ...@@ -2147,12 +2153,9 @@ void InstructionSelector::VisitMemoryBarrier(Node* node) {
bool InstructionSelector::IsTailCallAddressImmediate() { return false; } bool InstructionSelector::IsTailCallAddressImmediate() { return false; }
void InstructionSelector::VisitWord32AtomicLoad(Node* node) { void InstructionSelector::VisitWord32AtomicLoad(Node* node) {
LoadRepresentation load_rep = LoadRepresentationOf(node->op()); AtomicLoadParameters atomic_load_params = AtomicLoadParametersOf(node->op());
DCHECK(load_rep.representation() == MachineRepresentation::kWord8 || LoadRepresentation load_rep = atomic_load_params.representation();
load_rep.representation() == MachineRepresentation::kWord16 || VisitLoad(node, node, SelectLoadOpcode(load_rep));
load_rep.representation() == MachineRepresentation::kWord32);
USE(load_rep);
VisitLoad(node);
} }
void InstructionSelector::VisitWord32AtomicStore(Node* node) { void InstructionSelector::VisitWord32AtomicStore(Node* node) {
...@@ -2389,9 +2392,9 @@ VISIT_ATOMIC64_BINOP(Xor) ...@@ -2389,9 +2392,9 @@ VISIT_ATOMIC64_BINOP(Xor)
#undef VISIT_ATOMIC64_BINOP #undef VISIT_ATOMIC64_BINOP
void InstructionSelector::VisitWord64AtomicLoad(Node* node) { void InstructionSelector::VisitWord64AtomicLoad(Node* node) {
LoadRepresentation load_rep = LoadRepresentationOf(node->op()); AtomicLoadParameters atomic_load_params = AtomicLoadParametersOf(node->op());
USE(load_rep); LoadRepresentation load_rep = atomic_load_params.representation();
VisitLoad(node); VisitLoad(node, node, SelectLoadOpcode(load_rep));
} }
void InstructionSelector::VisitWord64AtomicStore(Node* node) { void InstructionSelector::VisitWord64AtomicStore(Node* 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