| Index: test/cctest/test-macro-assembler-arm.cc
|
| diff --git a/test/cctest/test-macro-assembler-arm.cc b/test/cctest/test-macro-assembler-arm.cc
|
| index 6b69296e11bdcae4311b153d0e4deb57e44408f5..63919a46ccb5c096ec5c46ee3d2603624d2432b7 100644
|
| --- a/test/cctest/test-macro-assembler-arm.cc
|
| +++ b/test/cctest/test-macro-assembler-arm.cc
|
| @@ -379,4 +379,115 @@ TEST(ReplaceLane) {
|
| }
|
| }
|
|
|
| +#define CHECK_EQ_32X4(field, v0, v1, v2, v3) \
|
| + CHECK_EQ(v0, t.field[0]); \
|
| + CHECK_EQ(v1, t.field[1]); \
|
| + CHECK_EQ(v2, t.field[2]); \
|
| + CHECK_EQ(v3, t.field[3]);
|
| +
|
| +TEST(Swizzle) {
|
| + if (!CpuFeatures::IsSupported(NEON)) return;
|
| +
|
| + // Allocate an executable page of memory.
|
| + size_t actual_size;
|
| + byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
|
| + Assembler::kMinimalBufferSize, &actual_size, true));
|
| + CHECK(buffer);
|
| + Isolate* isolate = CcTest::i_isolate();
|
| + HandleScope handles(isolate);
|
| + MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size),
|
| + v8::internal::CodeObjectRequired::kYes);
|
| + MacroAssembler* masm = &assembler; // Create a pointer for the __ macro.
|
| +
|
| + typedef struct {
|
| + int32_t _32x4_3210[4]; // identity
|
| + int32_t _32x4_1032[4]; // high / low swap
|
| + int32_t _32x4_0000[4]; // vdup's
|
| + int32_t _32x4_1111[4];
|
| + int32_t _32x4_2222[4];
|
| + int32_t _32x4_3333[4];
|
| + int32_t _32x4_2103[4]; // rotate left
|
| + int32_t _32x4_0321[4]; // rotate right
|
| + int32_t _32x4_1132[4]; // irregular
|
| + int32_t _32x4_1132_in_place[4]; // irregular, in-place
|
| + } T;
|
| + T t;
|
| +
|
| + __ stm(db_w, sp, r4.bit() | r5.bit() | r6.bit() | r7.bit() | lr.bit());
|
| +
|
| + const Register kScratch = r5;
|
| +
|
| + // Make test vector [0, 1, 2, 3]
|
| + __ veor(q1, q1, q1); // Zero
|
| + for (int i = 0; i < 4; i++) {
|
| + __ mov(r4, Operand(i));
|
| + __ ReplaceLane(q1, q1, r4, NeonS32, i);
|
| + }
|
| + __ Swizzle(q0, q1, kScratch, Neon32, 0x3210);
|
| + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_3210))));
|
| + __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
|
| +
|
| + __ Swizzle(q0, q1, kScratch, Neon32, 0x1032);
|
| + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_1032))));
|
| + __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
|
| +
|
| + __ Swizzle(q0, q1, kScratch, Neon32, 0x0000);
|
| + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_0000))));
|
| + __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
|
| +
|
| + __ Swizzle(q0, q1, kScratch, Neon32, 0x1111);
|
| + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_1111))));
|
| + __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
|
| +
|
| + __ Swizzle(q0, q1, kScratch, Neon32, 0x2222);
|
| + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_2222))));
|
| + __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
|
| +
|
| + __ Swizzle(q0, q1, kScratch, Neon32, 0x3333);
|
| + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_3333))));
|
| + __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
|
| +
|
| + __ Swizzle(q0, q1, kScratch, Neon32, 0x2103);
|
| + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_2103))));
|
| + __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
|
| +
|
| + __ Swizzle(q0, q1, kScratch, Neon32, 0x0321);
|
| + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_0321))));
|
| + __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
|
| +
|
| + __ Swizzle(q0, q1, kScratch, Neon32, 0x1132);
|
| + __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_1132))));
|
| + __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
|
| +
|
| + __ vmov(q0, q1);
|
| + __ Swizzle(q0, q0, kScratch, Neon32, 0x1132);
|
| + __ add(r4, r0,
|
| + Operand(static_cast<int32_t>(offsetof(T, _32x4_1132_in_place))));
|
| + __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
|
| +
|
| + __ ldm(ia_w, sp, r4.bit() | r5.bit() | r6.bit() | r7.bit() | pc.bit());
|
| +
|
| + CodeDesc desc;
|
| + masm->GetCode(&desc);
|
| + Handle<Code> code = isolate->factory()->NewCode(
|
| + desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
|
| +#ifdef DEBUG
|
| + OFStream os(stdout);
|
| + code->Print(os);
|
| +#endif
|
| + F3 f = FUNCTION_CAST<F3>(code->entry());
|
| + Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
|
| + USE(dummy);
|
| + CHECK_EQ_32X4(_32x4_3210, 0, 1, 2, 3);
|
| + CHECK_EQ_32X4(_32x4_1032, 2, 3, 0, 1);
|
| + CHECK_EQ_32X4(_32x4_0000, 0, 0, 0, 0);
|
| + CHECK_EQ_32X4(_32x4_1111, 1, 1, 1, 1);
|
| + CHECK_EQ_32X4(_32x4_2222, 2, 2, 2, 2);
|
| + CHECK_EQ_32X4(_32x4_3333, 3, 3, 3, 3);
|
| + CHECK_EQ_32X4(_32x4_2103, 3, 0, 1, 2);
|
| + CHECK_EQ_32X4(_32x4_0321, 1, 2, 3, 0);
|
| + CHECK_EQ_32X4(_32x4_1132, 2, 3, 1, 1);
|
| + CHECK_EQ_32X4(_32x4_1132_in_place, 2, 3, 1, 1);
|
| +}
|
| +
|
| #undef __
|
|
|