Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 23 matching lines...) Expand all Loading... | |
| 34 #include "src/base/utils/random-number-generator.h" | 34 #include "src/base/utils/random-number-generator.h" |
| 35 #include "src/macro-assembler.h" | 35 #include "src/macro-assembler.h" |
| 36 #include "src/mips64/macro-assembler-mips64.h" | 36 #include "src/mips64/macro-assembler-mips64.h" |
| 37 #include "src/mips64/simulator-mips64.h" | 37 #include "src/mips64/simulator-mips64.h" |
| 38 | 38 |
| 39 | 39 |
| 40 using namespace v8::internal; | 40 using namespace v8::internal; |
| 41 | 41 |
| 42 typedef void* (*F)(int64_t x, int64_t y, int p2, int p3, int p4); | 42 typedef void* (*F)(int64_t x, int64_t y, int p2, int p3, int p4); |
| 43 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); | 43 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); |
| 44 typedef float (*F2)(uint32_t x0, int x1, int x2, int x3, int x4); | |
|
akos.palfi.imgtec
2016/03/04 09:02:07
Nit: These defs are not necessary anymore.
Ilija.Pavlovic1
2016/03/04 09:11:09
Done.
| |
| 45 typedef float (*F3)(uint64_t x0, int x1, int x2, int x3, int x4); | |
| 46 typedef double (*F4)(uint64_t x0, int x1, int x2, int x3, int x4); | |
| 44 | 47 |
| 45 #define __ masm-> | 48 #define __ masm-> |
| 46 | 49 |
| 47 | 50 |
| 48 static byte to_non_zero(int n) { | 51 static byte to_non_zero(int n) { |
| 49 return static_cast<unsigned>(n) % 255 + 1; | 52 return static_cast<unsigned>(n) % 255 + 1; |
| 50 } | 53 } |
| 51 | 54 |
| 52 | 55 |
| 53 static bool all_zeroes(const byte* beg, const byte* end) { | 56 static bool all_zeroes(const byte* beg, const byte* end) { |
| (...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 515 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseLsa); | 518 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseLsa); |
| 516 for (size_t i = 0; i < nr_test_cases; ++i) { | 519 for (size_t i = 0; i < nr_test_cases; ++i) { |
| 517 uint64_t res = run_dlsa(tc[i].rt, tc[i].rs, tc[i].sa); | 520 uint64_t res = run_dlsa(tc[i].rt, tc[i].rs, tc[i].sa); |
| 518 PrintF("0x%" PRIx64 " =? 0x%" PRIx64 " == Dlsa(v0, %" PRIx64 ", %" PRIx64 | 521 PrintF("0x%" PRIx64 " =? 0x%" PRIx64 " == Dlsa(v0, %" PRIx64 ", %" PRIx64 |
| 519 ", %hhu)\n", | 522 ", %hhu)\n", |
| 520 tc[i].expected_res, res, tc[i].rt, tc[i].rs, tc[i].sa); | 523 tc[i].expected_res, res, tc[i].rt, tc[i].rs, tc[i].sa); |
| 521 CHECK_EQ(tc[i].expected_res, res); | 524 CHECK_EQ(tc[i].expected_res, res); |
| 522 } | 525 } |
| 523 } | 526 } |
| 524 | 527 |
| 528 static const std::vector<uint32_t> uint32_test_values() { | |
| 529 static const uint32_t kValues[] = {0x00000000, 0x00000001, 0x00ffff00, | |
| 530 0x7fffffff, 0x80000000, 0x80000001, | |
| 531 0x80ffff00, 0x8fffffff, 0xffffffff}; | |
| 532 return std::vector<uint32_t>(&kValues[0], &kValues[arraysize(kValues)]); | |
| 533 } | |
| 534 | |
| 535 static const std::vector<uint64_t> uint64_test_values() { | |
| 536 static const uint64_t kValues[] = { | |
| 537 0x0000000000000000, 0x0000000000000001, 0x0000ffffffff0000, | |
| 538 0x7fffffffffffffff, 0x8000000000000000, 0x8000000000000001, | |
| 539 0x8000ffffffff0000, 0x8fffffffffffffff, 0xffffffffffffffff}; | |
| 540 return std::vector<uint64_t>(&kValues[0], &kValues[arraysize(kValues)]); | |
| 541 } | |
| 542 | |
| 543 // Helper macros that can be used in FOR_INT32_INPUTS(i) { ... *i ... } | |
| 544 #define FOR_INPUTS(ctype, itype, var) \ | |
| 545 std::vector<ctype> var##_vec = itype##_test_values(); \ | |
| 546 for (std::vector<ctype>::iterator var = var##_vec.begin(); \ | |
| 547 var != var##_vec.end(); ++var) | |
| 548 | |
| 549 #define FOR_UINT32_INPUTS(var) FOR_INPUTS(uint32_t, uint32, var) | |
| 550 #define FOR_UINT64_INPUTS(var) FOR_INPUTS(uint64_t, uint64, var) | |
| 551 | |
| 552 template <typename RET_TYPE, typename IN_TYPE, typename Func> | |
| 553 RET_TYPE run_Cvt(IN_TYPE x, Func GenerateConvertInstructionFunc) { | |
| 554 typedef RET_TYPE (*F_CVT)(IN_TYPE x0, int x1, int x2, int x3, int x4); | |
| 555 | |
| 556 Isolate* isolate = CcTest::i_isolate(); | |
| 557 HandleScope scope(isolate); | |
| 558 MacroAssembler assm(isolate, nullptr, 0, | |
| 559 v8::internal::CodeObjectRequired::kYes); | |
| 560 MacroAssembler* masm = &assm; | |
| 561 | |
| 562 GenerateConvertInstructionFunc(masm); | |
| 563 __ jr(ra); | |
| 564 __ nop(); | |
| 565 | |
| 566 CodeDesc desc; | |
| 567 assm.GetCode(&desc); | |
| 568 Handle<Code> code = isolate->factory()->NewCode( | |
| 569 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
| 570 | |
| 571 F_CVT f = FUNCTION_CAST<F_CVT>(code->entry()); | |
| 572 | |
| 573 return CALL_GENERATED_CODE(isolate, f, x, 0, 0, 0, 0); | |
| 574 } | |
| 575 | |
| 576 TEST(Cvt_s_uw) { | |
| 577 CcTest::InitializeVM(); | |
| 578 FOR_UINT32_INPUTS(i) { | |
| 579 uint32_t input = *i; | |
| 580 CHECK_EQ(static_cast<float>(input), | |
| 581 run_Cvt<float>( | |
| 582 input, [](MacroAssembler* masm) { masm->Cvt_s_uw(f0, a0); })); | |
| 583 } | |
| 584 } | |
| 585 | |
| 586 TEST(Cvt_s_ul) { | |
| 587 CcTest::InitializeVM(); | |
| 588 FOR_UINT64_INPUTS(i) { | |
| 589 uint64_t input = *i; | |
| 590 CHECK_EQ(static_cast<float>(input), | |
| 591 run_Cvt<float>( | |
| 592 input, [](MacroAssembler* masm) { masm->Cvt_s_ul(f0, a0); })); | |
| 593 } | |
| 594 } | |
| 595 | |
| 596 TEST(Cvt_d_ul) { | |
| 597 CcTest::InitializeVM(); | |
| 598 FOR_UINT64_INPUTS(i) { | |
| 599 uint64_t input = *i; | |
| 600 CHECK_EQ(static_cast<double>(input), | |
| 601 run_Cvt<double>( | |
| 602 input, [](MacroAssembler* masm) { masm->Cvt_d_ul(f0, a0); })); | |
| 603 } | |
| 604 } | |
| 605 | |
| 525 #undef __ | 606 #undef __ |
| OLD | NEW |