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

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

Issue 1747863002: MIPS: Tests for convert and truncate instructions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 9 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 | « no previous file | no next file » | 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 23 matching lines...) Expand all
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);
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
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 float run_Cvt_s_uw(uint32_t x) {
529 Isolate* isolate = CcTest::i_isolate();
530 HandleScope scope(isolate);
531 MacroAssembler assembler(isolate, nullptr, 0,
532 v8::internal::CodeObjectRequired::kYes);
533 MacroAssembler* masm = &assembler;
534
535 __ Cvt_s_uw(f0, a0);
536 __ jr(ra);
537 __ nop();
538
539 CodeDesc desc;
540 assembler.GetCode(&desc);
541 Handle<Code> code = isolate->factory()->NewCode(
542 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
543
544 F2 f = FUNCTION_CAST<F2>(code->entry());
545
546 float res = CALL_GENERATED_CODE(isolate, f, x, 0, 0, 0, 0);
547
548 return res;
549 }
550
551 TEST(Cvt_s_uw) {
552 CcTest::InitializeVM();
553
554 struct TestCase {
555 uint32_t value;
556 float expected_res;
557 };
558
559 struct TestCase tc[] = {
akos.palfi.imgtec 2016/02/29 12:28:22 Rename this const array to uint32_test_values and
Ilija.Pavlovic1 2016/02/29 15:00:27 In all our test suites (test-assembler-mips*, test
Ilija.Pavlovic1 2016/03/04 08:02:52 Done.
560 // value, expected_res
561 {0x00000000, static_cast<float>(0x00000000)},
562 {0x00000001, static_cast<float>(0x00000001)},
563 {0x7fffffff, static_cast<float>(0x7fffffff)},
564 {0x80000000, static_cast<float>(0x80000000)},
565 {0x8fffffff, static_cast<float>(0x8fffffff)},
566 {0xffffffff, static_cast<float>(0xffffffff)},
567 };
568
569 size_t nr_test_cases = sizeof(tc) / sizeof(TestCase);
570 for (size_t i = 0; i < nr_test_cases; ++i) {
571 CHECK_EQ(tc[i].expected_res, run_Cvt_s_uw(tc[i].value));
572 }
573 }
574
575 float run_Cvt_s_ul(uint64_t x) {
576 Isolate* isolate = CcTest::i_isolate();
577 HandleScope scope(isolate);
578 MacroAssembler assembler(isolate, nullptr, 0,
579 v8::internal::CodeObjectRequired::kYes);
580 MacroAssembler* masm = &assembler;
581
582 __ Cvt_s_ul(f0, a0);
583 __ jr(ra);
584 __ nop();
585
586 CodeDesc desc;
587 assembler.GetCode(&desc);
588 Handle<Code> code = isolate->factory()->NewCode(
589 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
590
591 F3 f = FUNCTION_CAST<F3>(code->entry());
592
593 float res = CALL_GENERATED_CODE(isolate, f, x, 0, 0, 0, 0);
594
595 return res;
596 }
597
598 TEST(Cvt_s_ul) {
599 CcTest::InitializeVM();
600
601 struct TestCase {
602 uint64_t value;
603 float expected_res;
604 };
605
606 struct TestCase tc[] = {
akos.palfi.imgtec 2016/02/29 12:28:22 Same here, call it uint64_test_values.
Ilija.Pavlovic1 2016/03/04 08:02:52 Done.
607 // value, expected_res
608 {0x0000000000000000, static_cast<float>(0x0000000000000000)},
609 {0x0000000000000001, static_cast<float>(0x0000000000000001)},
610 {0x7fffffffffffffff, static_cast<float>(0x7fffffffffffffff)},
611 {0x8000000000000000, static_cast<float>(0x8000000000000000)},
612 {0x8fffffffffffffff, static_cast<float>(0x8fffffffffffffff)},
613 {0xffffffffffffffff, static_cast<float>(0xffffffffffffffff)},
614 };
615
616 size_t nr_test_cases = sizeof(tc) / sizeof(TestCase);
617 for (size_t i = 0; i < nr_test_cases; ++i) {
618 CHECK_EQ(tc[i].expected_res, run_Cvt_s_ul(tc[i].value));
619 }
620 }
621
622 double run_Cvt_d_ul(uint64_t x) {
623 Isolate* isolate = CcTest::i_isolate();
624 HandleScope scope(isolate);
625 MacroAssembler assembler(isolate, nullptr, 0,
626 v8::internal::CodeObjectRequired::kYes);
627 MacroAssembler* masm = &assembler;
628
629 __ Cvt_d_ul(f0, a0);
630 __ jr(ra);
631 __ nop();
632
633 CodeDesc desc;
634 assembler.GetCode(&desc);
635 Handle<Code> code = isolate->factory()->NewCode(
636 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
637
638 F4 f = FUNCTION_CAST<F4>(code->entry());
639
640 float res = CALL_GENERATED_CODE(isolate, f, x, 0, 0, 0, 0);
641
642 return res;
643 }
644
645 TEST(Cvt_d_ul) {
646 CcTest::InitializeVM();
647
648 struct TestCase {
649 uint64_t value;
650 double expected_res;
651 };
652
653 struct TestCase tc[] = {
akos.palfi.imgtec 2016/02/29 12:28:22 Same here.
Ilija.Pavlovic1 2016/03/04 08:02:52 Done.
654 // value, expected_res
655 {0x0000000000000000, static_cast<double>(0x0000000000000000)},
656 {0x0000000000000001, static_cast<double>(0x0000000000000001)},
657 {0x7fffffffffffffff, static_cast<double>(0x7fffffffffffffff)},
658 {0x8000000000000000, static_cast<double>(0x8000000000000000)},
659 {0x8fffffffffffffff, static_cast<double>(0x8fffffffffffffff)},
660 {0xffffffffffffffff, static_cast<double>(0xffffffffffffffff)},
661 };
662
663 size_t nr_test_cases = sizeof(tc) / sizeof(TestCase);
664 for (size_t i = 0; i < nr_test_cases; ++i) {
665 CHECK_EQ(tc[i].expected_res, run_Cvt_d_ul(tc[i].value));
666 }
667 }
668
525 #undef __ 669 #undef __
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698