OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 28 matching lines...) Expand all Loading... |
39 #include "test/cctest/cctest.h" | 39 #include "test/cctest/cctest.h" |
40 | 40 |
41 using namespace v8::internal; | 41 using namespace v8::internal; |
42 | 42 |
43 | 43 |
44 // Define these function prototypes to match JSEntryFunction in execution.cc. | 44 // Define these function prototypes to match JSEntryFunction in execution.cc. |
45 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); | 45 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); |
46 typedef Object* (*F2)(int x, int y, int p2, int p3, int p4); | 46 typedef Object* (*F2)(int x, int y, int p2, int p3, int p4); |
47 typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4); | 47 typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4); |
48 typedef Object* (*F4)(int64_t x, int64_t y, int64_t p2, int64_t p3, int64_t p4); | 48 typedef Object* (*F4)(int64_t x, int64_t y, int64_t p2, int64_t p3, int64_t p4); |
49 | 49 typedef Object* (*F5)(void* p0, void* p1, int p2, int p3, int p4); |
50 | 50 |
51 #define __ assm. | 51 #define __ assm. |
52 | 52 |
53 TEST(MIPS0) { | 53 TEST(MIPS0) { |
54 CcTest::InitializeVM(); | 54 CcTest::InitializeVM(); |
55 Isolate* isolate = CcTest::i_isolate(); | 55 Isolate* isolate = CcTest::i_isolate(); |
56 HandleScope scope(isolate); | 56 HandleScope scope(isolate); |
57 | 57 |
58 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | 58 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
59 | 59 |
(...skipping 6341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6401 {0x10000abcd, 0xabc1abc2abc3abc4, 32, 32, 0xabc3abc40000abcd}, | 6401 {0x10000abcd, 0xabc1abc2abc3abc4, 32, 32, 0xabc3abc40000abcd}, |
6402 }; | 6402 }; |
6403 | 6403 |
6404 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseDins); | 6404 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseDins); |
6405 for (size_t i = 0; i < nr_test_cases; ++i) { | 6405 for (size_t i = 0; i < nr_test_cases; ++i) { |
6406 CHECK_EQ(tc[i].expected_res, | 6406 CHECK_EQ(tc[i].expected_res, |
6407 run_Dins(tc[i].imm, tc[i].source, tc[i].pos, tc[i].size)); | 6407 run_Dins(tc[i].imm, tc[i].source, tc[i].pos, tc[i].size)); |
6408 } | 6408 } |
6409 } | 6409 } |
6410 | 6410 |
| 6411 TEST(MSA_fill_copy) { |
| 6412 CcTest::InitializeVM(); |
| 6413 Isolate* isolate = CcTest::i_isolate(); |
| 6414 HandleScope scope(isolate); |
| 6415 |
| 6416 typedef struct { |
| 6417 uint64_t u8; |
| 6418 uint64_t u16; |
| 6419 uint64_t u32; |
| 6420 uint64_t s8; |
| 6421 uint64_t s16; |
| 6422 uint64_t s32; |
| 6423 uint64_t s64; |
| 6424 } T; |
| 6425 T t; |
| 6426 |
| 6427 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
| 6428 if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) |
| 6429 return; |
| 6430 |
| 6431 { |
| 6432 CpuFeatureScope fscope(&assm, MIPS_SIMD); |
| 6433 |
| 6434 __ li(t0, 0x9e7689aca512b683); |
| 6435 |
| 6436 __ fill_b(w0, t0); |
| 6437 __ fill_h(w2, t0); |
| 6438 __ fill_w(w4, t0); |
| 6439 __ fill_d(w6, t0); |
| 6440 __ copy_u_b(t1, w0, 11); |
| 6441 __ sd(t1, MemOperand(a0, offsetof(T, u8))); |
| 6442 __ copy_u_h(t1, w2, 6); |
| 6443 __ sd(t1, MemOperand(a0, offsetof(T, u16))); |
| 6444 __ copy_u_w(t1, w4, 3); |
| 6445 __ sd(t1, MemOperand(a0, offsetof(T, u32))); |
| 6446 |
| 6447 __ copy_s_b(t1, w0, 8); |
| 6448 __ sd(t1, MemOperand(a0, offsetof(T, s8))); |
| 6449 __ copy_s_h(t1, w2, 5); |
| 6450 __ sd(t1, MemOperand(a0, offsetof(T, s16))); |
| 6451 __ copy_s_w(t1, w4, 1); |
| 6452 __ sd(t1, MemOperand(a0, offsetof(T, s32))); |
| 6453 __ copy_s_d(t1, w6, 0); |
| 6454 __ sd(t1, MemOperand(a0, offsetof(T, s64))); |
| 6455 |
| 6456 __ jr(ra); |
| 6457 __ nop(); |
| 6458 } |
| 6459 |
| 6460 CodeDesc desc; |
| 6461 assm.GetCode(&desc); |
| 6462 Handle<Code> code = isolate->factory()->NewCode( |
| 6463 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 6464 #ifdef OBJECT_PRINT |
| 6465 code->Print(std::cout); |
| 6466 #endif |
| 6467 F3 f = FUNCTION_CAST<F3>(code->entry()); |
| 6468 |
| 6469 Object* dummy = CALL_GENERATED_CODE(isolate, f, &t, 0, 0, 0, 0); |
| 6470 USE(dummy); |
| 6471 |
| 6472 CHECK_EQ(0x83u, t.u8); |
| 6473 CHECK_EQ(0xb683u, t.u16); |
| 6474 CHECK_EQ(0xa512b683u, t.u32); |
| 6475 CHECK_EQ(0xffffffffffffff83u, t.s8); |
| 6476 CHECK_EQ(0xffffffffffffb683u, t.s16); |
| 6477 CHECK_EQ(0xffffffffa512b683u, t.s32); |
| 6478 CHECK_EQ(0x9e7689aca512b683u, t.s64); |
| 6479 } |
| 6480 |
| 6481 TEST(MSA_fill_copy_2) { |
| 6482 // Similar to MSA_fill_copy test, but also check overlaping between MSA and |
| 6483 // FPU registers with same numbers |
| 6484 CcTest::InitializeVM(); |
| 6485 Isolate* isolate = CcTest::i_isolate(); |
| 6486 HandleScope scope(isolate); |
| 6487 |
| 6488 typedef struct { |
| 6489 uint64_t d0; |
| 6490 uint64_t d1; |
| 6491 } T; |
| 6492 T t[2]; |
| 6493 |
| 6494 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
| 6495 if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) |
| 6496 return; |
| 6497 |
| 6498 { |
| 6499 CpuFeatureScope fscope(&assm, MIPS_SIMD); |
| 6500 |
| 6501 __ li(t0, 0xaaaaaaaaaaaaaaaa); |
| 6502 __ li(t1, 0x5555555555555555); |
| 6503 |
| 6504 __ fill_d(w0, t0); |
| 6505 __ fill_d(w2, t0); |
| 6506 |
| 6507 __ Move(f0, t1); |
| 6508 __ Move(f2, t1); |
| 6509 |
| 6510 #define STORE_MSA_REG(w_reg, base, scratch) \ |
| 6511 __ copy_s_d(scratch, w_reg, 0); \ |
| 6512 __ sd(scratch, MemOperand(base, offsetof(T, d0))); \ |
| 6513 __ copy_s_d(scratch, w_reg, 1); \ |
| 6514 __ sd(scratch, MemOperand(base, offsetof(T, d1))); |
| 6515 |
| 6516 STORE_MSA_REG(w0, a0, t2) |
| 6517 STORE_MSA_REG(w2, a1, t2) |
| 6518 #undef STORE_MSA_REG |
| 6519 |
| 6520 __ jr(ra); |
| 6521 __ nop(); |
| 6522 } |
| 6523 |
| 6524 CodeDesc desc; |
| 6525 assm.GetCode(&desc); |
| 6526 Handle<Code> code = isolate->factory()->NewCode( |
| 6527 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 6528 #ifdef OBJECT_PRINT |
| 6529 code->Print(std::cout); |
| 6530 #endif |
| 6531 F5 f = FUNCTION_CAST<F5>(code->entry()); |
| 6532 |
| 6533 Object* dummy = CALL_GENERATED_CODE(isolate, f, &t[0], &t[1], 0, 0, 0); |
| 6534 USE(dummy); |
| 6535 |
| 6536 CHECK_EQ(0x5555555555555555, t[0].d0); |
| 6537 CHECK_EQ(0xaaaaaaaaaaaaaaaa, t[0].d1); |
| 6538 CHECK_EQ(0x5555555555555555, t[1].d0); |
| 6539 CHECK_EQ(0xaaaaaaaaaaaaaaaa, t[1].d1); |
| 6540 } |
| 6541 |
| 6542 TEST(MSA_fill_copy_3) { |
| 6543 // Similar to MSA_fill_copy test, but also check overlaping between MSA and |
| 6544 // FPU registers with same numbers |
| 6545 CcTest::InitializeVM(); |
| 6546 Isolate* isolate = CcTest::i_isolate(); |
| 6547 HandleScope scope(isolate); |
| 6548 |
| 6549 typedef struct { |
| 6550 uint64_t d0; |
| 6551 uint64_t d1; |
| 6552 } T; |
| 6553 T t[2]; |
| 6554 |
| 6555 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
| 6556 if ((kArchVariant != kMips64r6) || !CpuFeatures::IsSupported(MIPS_SIMD)) |
| 6557 return; |
| 6558 |
| 6559 { |
| 6560 CpuFeatureScope fscope(&assm, MIPS_SIMD); |
| 6561 |
| 6562 __ li(t0, 0xaaaaaaaaaaaaaaaa); |
| 6563 __ li(t1, 0x5555555555555555); |
| 6564 |
| 6565 __ Move(f0, t0); |
| 6566 __ Move(f2, t0); |
| 6567 |
| 6568 __ fill_d(w0, t1); |
| 6569 __ fill_d(w2, t1); |
| 6570 |
| 6571 __ Sdc1(f0, MemOperand(a0, offsetof(T, d0))); |
| 6572 __ Sdc1(f2, MemOperand(a1, offsetof(T, d0))); |
| 6573 |
| 6574 __ jr(ra); |
| 6575 __ nop(); |
| 6576 } |
| 6577 |
| 6578 CodeDesc desc; |
| 6579 assm.GetCode(&desc); |
| 6580 Handle<Code> code = isolate->factory()->NewCode( |
| 6581 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 6582 #ifdef OBJECT_PRINT |
| 6583 code->Print(std::cout); |
| 6584 #endif |
| 6585 F5 f = FUNCTION_CAST<F5>(code->entry()); |
| 6586 |
| 6587 Object* dummy = CALL_GENERATED_CODE(isolate, f, &t[0], &t[1], 0, 0, 0); |
| 6588 USE(dummy); |
| 6589 |
| 6590 CHECK_EQ(0x5555555555555555, t[0].d0); |
| 6591 CHECK_EQ(0x5555555555555555, t[1].d0); |
| 6592 } |
| 6593 |
6411 #undef __ | 6594 #undef __ |
OLD | NEW |