Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(145)

Side by Side Diff: test/cctest/test-macro-assembler-arm.cc

Issue 2801183002: [WASM SIMD] Implement primitive shuffles. (Closed)
Patch Set: Fix non-ARM build. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/wasm/wasm-opcodes.cc ('k') | test/cctest/wasm/test-run-wasm-simd.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 398 }
399 for (int i = 0; i < 8; i++) { 399 for (int i = 0; i < 8; i++) {
400 CHECK_EQ(-i, t.i16x8_high[i]); 400 CHECK_EQ(-i, t.i16x8_high[i]);
401 } 401 }
402 for (int i = 0; i < 16; i++) { 402 for (int i = 0; i < 16; i++) {
403 CHECK_EQ(-i, t.i8x16_high[i]); 403 CHECK_EQ(-i, t.i8x16_high[i]);
404 } 404 }
405 } 405 }
406 } 406 }
407 407
408 #define CHECK_EQ_32X4(field, v0, v1, v2, v3) \
409 CHECK_EQ(v0, t.field[0]); \
410 CHECK_EQ(v1, t.field[1]); \
411 CHECK_EQ(v2, t.field[2]); \
412 CHECK_EQ(v3, t.field[3]);
413
414 TEST(Swizzle) {
415 if (!CpuFeatures::IsSupported(NEON)) return;
416
417 // Allocate an executable page of memory.
418 size_t actual_size;
419 byte* buffer = static_cast<byte*>(v8::base::OS::Allocate(
420 Assembler::kMinimalBufferSize, &actual_size, true));
421 CHECK(buffer);
422 Isolate* isolate = CcTest::i_isolate();
423 HandleScope handles(isolate);
424 MacroAssembler assembler(isolate, buffer, static_cast<int>(actual_size),
425 v8::internal::CodeObjectRequired::kYes);
426 MacroAssembler* masm = &assembler; // Create a pointer for the __ macro.
427
428 typedef struct {
429 int32_t _32x4_3210[4]; // identity
430 int32_t _32x4_1032[4]; // high / low swap
431 int32_t _32x4_0000[4]; // vdup's
432 int32_t _32x4_1111[4];
433 int32_t _32x4_2222[4];
434 int32_t _32x4_3333[4];
435 int32_t _32x4_2103[4]; // rotate left
436 int32_t _32x4_0321[4]; // rotate right
437 int32_t _32x4_1132[4]; // irregular
438 int32_t _32x4_1132_in_place[4]; // irregular, in-place
439 } T;
440 T t;
441
442 __ stm(db_w, sp, r4.bit() | r5.bit() | r6.bit() | r7.bit() | lr.bit());
443
444 const Register kScratch = r5;
445
446 // Make test vector [0, 1, 2, 3]
447 __ veor(q1, q1, q1); // Zero
448 for (int i = 0; i < 4; i++) {
449 __ mov(r4, Operand(i));
450 __ ReplaceLane(q1, q1, r4, NeonS32, i);
451 }
452 __ Swizzle(q0, q1, kScratch, Neon32, 0x3210);
453 __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_3210))));
454 __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
455
456 __ Swizzle(q0, q1, kScratch, Neon32, 0x1032);
457 __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_1032))));
458 __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
459
460 __ Swizzle(q0, q1, kScratch, Neon32, 0x0000);
461 __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_0000))));
462 __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
463
464 __ Swizzle(q0, q1, kScratch, Neon32, 0x1111);
465 __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_1111))));
466 __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
467
468 __ Swizzle(q0, q1, kScratch, Neon32, 0x2222);
469 __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_2222))));
470 __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
471
472 __ Swizzle(q0, q1, kScratch, Neon32, 0x3333);
473 __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_3333))));
474 __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
475
476 __ Swizzle(q0, q1, kScratch, Neon32, 0x2103);
477 __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_2103))));
478 __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
479
480 __ Swizzle(q0, q1, kScratch, Neon32, 0x0321);
481 __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_0321))));
482 __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
483
484 __ Swizzle(q0, q1, kScratch, Neon32, 0x1132);
485 __ add(r4, r0, Operand(static_cast<int32_t>(offsetof(T, _32x4_1132))));
486 __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
487
488 __ vmov(q0, q1);
489 __ Swizzle(q0, q0, kScratch, Neon32, 0x1132);
490 __ add(r4, r0,
491 Operand(static_cast<int32_t>(offsetof(T, _32x4_1132_in_place))));
492 __ vst1(Neon8, NeonListOperand(q0), NeonMemOperand(r4));
493
494 __ ldm(ia_w, sp, r4.bit() | r5.bit() | r6.bit() | r7.bit() | pc.bit());
495
496 CodeDesc desc;
497 masm->GetCode(&desc);
498 Handle<Code> code = isolate->factory()->NewCode(
499 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
500 #ifdef DEBUG
501 OFStream os(stdout);
502 code->Print(os);
503 #endif
504 F3 f = FUNCTION_CAST<F3>(code->entry());
505 Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0);
506 USE(dummy);
507 CHECK_EQ_32X4(_32x4_3210, 0, 1, 2, 3);
508 CHECK_EQ_32X4(_32x4_1032, 2, 3, 0, 1);
509 CHECK_EQ_32X4(_32x4_0000, 0, 0, 0, 0);
510 CHECK_EQ_32X4(_32x4_1111, 1, 1, 1, 1);
511 CHECK_EQ_32X4(_32x4_2222, 2, 2, 2, 2);
512 CHECK_EQ_32X4(_32x4_3333, 3, 3, 3, 3);
513 CHECK_EQ_32X4(_32x4_2103, 3, 0, 1, 2);
514 CHECK_EQ_32X4(_32x4_0321, 1, 2, 3, 0);
515 CHECK_EQ_32X4(_32x4_1132, 2, 3, 1, 1);
516 CHECK_EQ_32X4(_32x4_1132_in_place, 2, 3, 1, 1);
517 }
518
519 #undef __ 408 #undef __
OLDNEW
« no previous file with comments | « src/wasm/wasm-opcodes.cc ('k') | test/cctest/wasm/test-run-wasm-simd.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698