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

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: Corrections and added tests for truncate instructions. 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 | « test/cctest/test-macro-assembler-mips.cc ('k') | 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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseLsa); 515 size_t nr_test_cases = sizeof(tc) / sizeof(TestCaseLsa);
516 for (size_t i = 0; i < nr_test_cases; ++i) { 516 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); 517 uint64_t res = run_dlsa(tc[i].rt, tc[i].rs, tc[i].sa);
518 PrintF("0x%" PRIx64 " =? 0x%" PRIx64 " == Dlsa(v0, %" PRIx64 ", %" PRIx64 518 PrintF("0x%" PRIx64 " =? 0x%" PRIx64 " == Dlsa(v0, %" PRIx64 ", %" PRIx64
519 ", %hhu)\n", 519 ", %hhu)\n",
520 tc[i].expected_res, res, tc[i].rt, tc[i].rs, tc[i].sa); 520 tc[i].expected_res, res, tc[i].rt, tc[i].rs, tc[i].sa);
521 CHECK_EQ(tc[i].expected_res, res); 521 CHECK_EQ(tc[i].expected_res, res);
522 } 522 }
523 } 523 }
524 524
525 static const std::vector<uint32_t> uint32_test_values() {
526 static const uint32_t kValues[] = {0x00000000, 0x00000001, 0x00ffff00,
527 0x7fffffff, 0x80000000, 0x80000001,
528 0x80ffff00, 0x8fffffff, 0xffffffff};
529 return std::vector<uint32_t>(&kValues[0], &kValues[arraysize(kValues)]);
530 }
531
532 static const std::vector<int32_t> int32_test_values() {
533 static const int32_t kValues[] = {
534 static_cast<int32_t>(0x00000000), static_cast<int32_t>(0x00000001),
535 static_cast<int32_t>(0x00ffff00), static_cast<int32_t>(0x7fffffff),
536 static_cast<int32_t>(0x80000000), static_cast<int32_t>(0x80000001),
537 static_cast<int32_t>(0x80ffff00), static_cast<int32_t>(0x8fffffff),
538 static_cast<int32_t>(0xffffffff)};
539 return std::vector<int32_t>(&kValues[0], &kValues[arraysize(kValues)]);
540 }
541
542 static const std::vector<uint64_t> uint64_test_values() {
543 static const uint64_t kValues[] = {
544 0x0000000000000000, 0x0000000000000001, 0x0000ffffffff0000,
545 0x7fffffffffffffff, 0x8000000000000000, 0x8000000000000001,
546 0x8000ffffffff0000, 0x8fffffffffffffff, 0xffffffffffffffff};
547 return std::vector<uint64_t>(&kValues[0], &kValues[arraysize(kValues)]);
548 }
549
550 static const std::vector<int64_t> int64_test_values() {
551 static const int64_t kValues[] = {static_cast<int64_t>(0x0000000000000000),
552 static_cast<int64_t>(0x0000000000000001),
553 static_cast<int64_t>(0x0000ffffffff0000),
554 static_cast<int64_t>(0x7fffffffffffffff),
555 static_cast<int64_t>(0x8000000000000000),
556 static_cast<int64_t>(0x8000000000000001),
557 static_cast<int64_t>(0x8000ffffffff0000),
558 static_cast<int64_t>(0x8fffffffffffffff),
559 static_cast<int64_t>(0xffffffffffffffff)};
560 return std::vector<int64_t>(&kValues[0], &kValues[arraysize(kValues)]);
561 }
562
563 // Helper macros that can be used in FOR_INT32_INPUTS(i) { ... *i ... }
564 #define FOR_INPUTS(ctype, itype, var) \
565 std::vector<ctype> var##_vec = itype##_test_values(); \
566 for (std::vector<ctype>::iterator var = var##_vec.begin(); \
567 var != var##_vec.end(); ++var)
568
569 #define FOR_INT32_INPUTS(var) FOR_INPUTS(int32_t, int32, var)
570 #define FOR_INT64_INPUTS(var) FOR_INPUTS(int64_t, int64, var)
571 #define FOR_UINT32_INPUTS(var) FOR_INPUTS(uint32_t, uint32, var)
572 #define FOR_UINT64_INPUTS(var) FOR_INPUTS(uint64_t, uint64, var)
573
574 template <typename RET_TYPE, typename IN_TYPE, typename Func>
575 RET_TYPE run_Cvt(IN_TYPE x, Func GenerateConvertInstructionFunc) {
576 typedef RET_TYPE (*F_CVT)(IN_TYPE x0, int x1, int x2, int x3, int x4);
577
578 Isolate* isolate = CcTest::i_isolate();
579 HandleScope scope(isolate);
580 MacroAssembler assm(isolate, nullptr, 0,
581 v8::internal::CodeObjectRequired::kYes);
582 MacroAssembler* masm = &assm;
583
584 GenerateConvertInstructionFunc(masm);
585 __ dmfc1(v0, f2);
586 __ jr(ra);
587 __ nop();
588
589 CodeDesc desc;
590 assm.GetCode(&desc);
591 Handle<Code> code = isolate->factory()->NewCode(
592 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
593
594 F_CVT f = FUNCTION_CAST<F_CVT>(code->entry());
595
596 return reinterpret_cast<RET_TYPE>(
597 CALL_GENERATED_CODE(isolate, f, x, 0, 0, 0, 0));
598 }
599
600 TEST(Cvt_s_uw_Trunc_uw_s) {
601 CcTest::InitializeVM();
602 FOR_UINT32_INPUTS(i) {
603 uint32_t input = *i;
604 CHECK_EQ(static_cast<float>(input),
605 run_Cvt<uint64_t>(input, [](MacroAssembler* masm) {
606 __ Cvt_s_uw(f0, a0);
607 __ Trunc_uw_s(f2, f0, f1);
608 }));
609 }
610 }
611
612 TEST(Cvt_s_ul_Trunc_ul_s) {
613 CcTest::InitializeVM();
614 FOR_UINT64_INPUTS(i) {
615 uint64_t input = *i;
616 CHECK_EQ(static_cast<float>(input),
617 run_Cvt<uint64_t>(input, [](MacroAssembler* masm) {
618 __ Cvt_s_ul(f0, a0);
619 __ Trunc_ul_s(f2, f0, f1, v0);
620 }));
621 }
622 }
623
624 TEST(Cvt_d_ul_Trunc_ul_d) {
625 CcTest::InitializeVM();
626 FOR_UINT64_INPUTS(i) {
627 uint64_t input = *i;
628 CHECK_EQ(static_cast<double>(input),
629 run_Cvt<uint64_t>(input, [](MacroAssembler* masm) {
630 __ Cvt_d_ul(f0, a0);
631 __ Trunc_ul_d(f2, f0, f1, v0);
632 }));
633 }
634 }
635
636 TEST(cvt_d_l_Trunc_l_d) {
637 CcTest::InitializeVM();
638 FOR_INT64_INPUTS(i) {
639 int64_t input = *i;
640 CHECK_EQ(static_cast<double>(input),
641 run_Cvt<int64_t>(input, [](MacroAssembler* masm) {
642 __ dmtc1(a0, f4);
643 __ cvt_d_l(f0, f4);
644 __ Trunc_l_d(f2, f0);
645 }));
646 }
647 }
648
649 TEST(cvt_d_l_Trunc_l_ud) {
650 CcTest::InitializeVM();
651 FOR_INT64_INPUTS(i) {
652 int64_t input = *i;
653 uint64_t abs_input = (input < 0) ? -input : input;
654 CHECK_EQ(static_cast<double>(abs_input),
655 run_Cvt<uint64_t>(input, [](MacroAssembler* masm) {
656 __ dmtc1(a0, f4);
657 __ cvt_d_l(f0, f4);
658 __ Trunc_l_ud(f2, f0, f6);
659 }));
660 }
661 }
662
663 TEST(cvt_d_w_Trunc_w_d) {
664 CcTest::InitializeVM();
665 FOR_INT32_INPUTS(i) {
666 int32_t input = *i;
667 CHECK_EQ(static_cast<double>(input),
668 run_Cvt<int64_t>(input, [](MacroAssembler* masm) {
669 __ mtc1(a0, f4);
670 __ cvt_d_w(f0, f4);
671 __ Trunc_w_d(f2, f0);
672 __ mfc1(v1, f2);
673 __ dmtc1(v1, f2);
674 }));
675 }
676 }
677
525 #undef __ 678 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-macro-assembler-mips.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698