Commit 5033993f authored by Bill Budge's avatar Bill Budge Committed by Commit Bot

[arm] Use correct addressing mode in Neon loads/stores.

- Adds CodeGenerator::NeonInputOperand method for arm.
- Specifies addressing mode when selecting Neon load/store.

Bug: 
Change-Id: Iac0bb566c32882e6b9605d2978588af05493a5c7
Reviewed-on: https://chromium-review.googlesource.com/716714
Commit-Queue: Bill Budge <bbudge@chromium.org>
Reviewed-by: 's avatarBen Titzer <titzer@chromium.org>
Reviewed-by: 's avatarMartyn Capewell <martyn.capewell@arm.com>
Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#48562}
parent a3de183f
......@@ -134,6 +134,20 @@ class ArmOperandConverter final : public InstructionOperandConverter {
FrameOffset offset = frame_access_state()->GetFrameOffset(slot);
return MemOperand(offset.from_stack_pointer() ? sp : fp, offset.offset());
}
NeonMemOperand NeonInputOperand(size_t first_index) {
const size_t index = first_index;
switch (AddressingModeField::decode(instr_->opcode())) {
case kMode_Offset_RR:
return NeonMemOperand(InputRegister(index + 0),
InputRegister(index + 1));
case kMode_Operand2_R:
return NeonMemOperand(InputRegister(index + 0));
default:
break;
}
UNREACHABLE();
}
};
namespace {
......@@ -1536,22 +1550,22 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break;
case kArmVld1F64: {
__ vld1(Neon8, NeonListOperand(i.OutputDoubleRegister()),
NeonMemOperand(i.InputRegister(0)));
i.NeonInputOperand(0));
break;
}
case kArmVst1F64: {
__ vst1(Neon8, NeonListOperand(i.InputDoubleRegister(0)),
NeonMemOperand(i.InputRegister(1)));
i.NeonInputOperand(1));
break;
}
case kArmVld1S128: {
__ vld1(Neon8, NeonListOperand(i.OutputSimd128Register()),
NeonMemOperand(i.InputRegister(0)));
i.NeonInputOperand(0));
break;
}
case kArmVst1S128: {
__ vst1(Neon8, NeonListOperand(i.InputSimd128Register(0)),
NeonMemOperand(i.InputRegister(1)));
i.NeonInputOperand(1));
break;
}
case kArmVldrF64:
......
......@@ -606,9 +606,10 @@ void InstructionSelector::VisitUnalignedLoad(Node* node) {
if (CpuFeatures::IsSupported(NEON)) {
// With NEON we can load directly from the calculated address.
ArchOpcode op = load_rep == MachineRepresentation::kFloat64
? kArmVld1F64
: kArmVld1S128;
InstructionCode op = load_rep == MachineRepresentation::kFloat64
? kArmVld1F64
: kArmVld1S128;
op |= AddressingModeField::encode(kMode_Operand2_R);
Emit(op, g.DefineAsRegister(node), addr);
} else {
DCHECK_NE(MachineRepresentation::kSimd128, load_rep);
......@@ -680,9 +681,10 @@ void InstructionSelector::VisitUnalignedStore(Node* node) {
inputs[input_count++] = g.UseRegister(value);
inputs[input_count++] = address;
ArchOpcode op = store_rep == MachineRepresentation::kFloat64
? kArmVst1F64
: kArmVst1S128;
InstructionCode op = store_rep == MachineRepresentation::kFloat64
? kArmVst1F64
: kArmVst1S128;
op |= AddressingModeField::encode(kMode_Operand2_R);
Emit(op, 0, nullptr, input_count, inputs);
} else {
DCHECK_NE(MachineRepresentation::kSimd128, store_rep);
......
......@@ -2277,14 +2277,15 @@ WASM_SIMD_TEST(SimdF32x4SetGlobal) {
V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
WASM_SIMD_COMPILED_TEST(SimdLoadStoreLoad) {
WasmRunner<int32_t> r(execution_mode);
int32_t* memory = r.builder().AddMemoryElems<int32_t>(4);
BUILD(r, WASM_SIMD_STORE_MEM(WASM_ZERO, WASM_SIMD_LOAD_MEM(WASM_ZERO)),
WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_SIMD_LOAD_MEM(WASM_ZERO)));
int32_t* memory = r.builder().AddMemoryElems<int32_t>(8);
// Load memory, store it, then reload it and extract the first lane. Use a
// non-zero offset into the memory of 1 lane (4 bytes) to test indexing.
BUILD(r, WASM_SIMD_STORE_MEM(WASM_I32V(4), WASM_SIMD_LOAD_MEM(WASM_I32V(4))),
WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_SIMD_LOAD_MEM(WASM_I32V(4))));
FOR_INT32_INPUTS(i) {
int32_t expected = *i;
r.builder().WriteMemory(&memory[0], expected);
r.builder().WriteMemory(&memory[1], expected);
CHECK_EQ(expected, r.Call());
}
}
......
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