Chromium Code Reviews

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

Issue 1481493002: (mips) adding simulator support for AUI/DAUI/DAHI/DATI instructions. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: adding disasm tests. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
OLDNEW
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 4683 matching lines...)
4694 PC = 0; 4694 PC = 0;
4695 uint64_t res = run_auipc(tc[i].offset); 4695 uint64_t res = run_auipc(tc[i].offset);
4696 // Now, the program_counter (PC) is set. 4696 // Now, the program_counter (PC) is set.
4697 uint64_t expected_res = PC + (tc[i].offset << 16); 4697 uint64_t expected_res = PC + (tc[i].offset << 16);
4698 CHECK_EQ(expected_res, res); 4698 CHECK_EQ(expected_res, res);
4699 } 4699 }
4700 } 4700 }
4701 } 4701 }
4702 4702
4703 4703
4704 uint64_t run_aui(uint64_t rs, uint16_t offset) {
4705 Isolate* isolate = CcTest::i_isolate();
4706 HandleScope scope(isolate);
4707
4708 MacroAssembler assm(isolate, NULL, 0);
4709
4710 __ li(t0, rs);
4711 __ aui(v0, t0, offset);
4712 __ jr(ra);
4713 __ nop();
4714
4715 CodeDesc desc;
4716 assm.GetCode(&desc);
4717 Handle<Code> code = isolate->factory()->NewCode(
4718 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
4719
4720 F2 f = FUNCTION_CAST<F2>(code->entry());
4721
4722 uint64_t res =
4723 reinterpret_cast<uint64_t>
4724 (CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
4725
4726 return res;
4727 }
4728
4729
4730 uint64_t run_daui(uint64_t rs, uint16_t offset) {
4731 Isolate* isolate = CcTest::i_isolate();
4732 HandleScope scope(isolate);
4733
4734 MacroAssembler assm(isolate, NULL, 0);
4735
4736 __ li(t0, rs);
4737 __ daui(v0, t0, offset);
4738 __ jr(ra);
4739 __ nop();
4740
4741 CodeDesc desc;
4742 assm.GetCode(&desc);
4743 Handle<Code> code = isolate->factory()->NewCode(
4744 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
4745
4746 F2 f = FUNCTION_CAST<F2>(code->entry());
4747
4748 uint64_t res =
4749 reinterpret_cast<uint64_t>
4750 (CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
4751
4752 return res;
4753 }
4754
4755
4756 uint64_t run_dahi(uint64_t rs, uint16_t offset) {
4757 Isolate* isolate = CcTest::i_isolate();
4758 HandleScope scope(isolate);
4759
4760 MacroAssembler assm(isolate, NULL, 0);
4761
4762 __ li(v0, rs);
4763 __ dahi(v0, offset);
4764 __ jr(ra);
4765 __ nop();
4766
4767 CodeDesc desc;
4768 assm.GetCode(&desc);
4769 Handle<Code> code = isolate->factory()->NewCode(
4770 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
4771
4772 F2 f = FUNCTION_CAST<F2>(code->entry());
4773
4774 uint64_t res =
4775 reinterpret_cast<uint64_t>
4776 (CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
4777
4778 return res;
4779 }
4780
4781
4782 uint64_t run_dati(uint64_t rs, uint16_t offset) {
4783 Isolate* isolate = CcTest::i_isolate();
4784 HandleScope scope(isolate);
4785
4786 MacroAssembler assm(isolate, NULL, 0);
4787
4788 __ li(v0, rs);
4789 __ dati(v0, offset);
4790 __ jr(ra);
4791 __ nop();
4792
4793 CodeDesc desc;
4794 assm.GetCode(&desc);
4795 Handle<Code> code = isolate->factory()->NewCode(
4796 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
4797
4798 F2 f = FUNCTION_CAST<F2>(code->entry());
4799
4800 uint64_t res =
4801 reinterpret_cast<uint64_t>
4802 (CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
4803
4804 return res;
4805 }
4806
4807
4808 TEST(r6_aui_family) {
4809 if (kArchVariant == kMips64r6) {
4810 CcTest::InitializeVM();
4811
4812 struct TestCaseAui {
4813 uint64_t rs;
4814 uint16_t offset;
4815 uint64_t ref_res;
4816 };
4817
4818 // AUI test cases.
4819 struct TestCaseAui aui_tc[] = {
4820 {0xfffeffff, 0x1, 0xffffffffffffffff},
4821 {0xffffffff, 0x0, 0xffffffffffffffff},
4822 {0, 0xffff, 0xffffffffffff0000},
4823 {0x0008ffff, 0xfff7, 0xffffffffffffffff},
4824 {32767, 32767, 0x000000007fff7fff},
4825 {0x00000000ffffffff, 0x1, 0x000000000000ffff},
4826 {0xffffffff, 0xffff, 0xfffffffffffeffff},
4827 };
4828
4829 size_t nr_test_cases = sizeof(aui_tc) / sizeof(TestCaseAui);
4830 for (size_t i = 0; i < nr_test_cases; ++i) {
4831 uint64_t res = run_aui(aui_tc[i].rs, aui_tc[i].offset);
4832 CHECK_EQ(aui_tc[i].ref_res, res);
4833 }
4834
4835 // DAUI test cases.
4836 struct TestCaseAui daui_tc[] = {
4837 {0xfffffffffffeffff, 0x1, 0xffffffffffffffff},
4838 {0xffffffffffffffff, 0x0, 0xffffffffffffffff},
4839 {0, 0xffff, 0xffffffffffff0000},
4840 {0x0008ffff, 0xfff7, 0xffffffffffffffff},
4841 {32767, 32767, 0x000000007fff7fff},
4842 {0x00000000ffffffff, 0x1, 0x000000010000ffff},
4843 {0xffffffff, 0xffff, 0x00000000fffeffff},
4844 };
4845
4846 nr_test_cases = sizeof(daui_tc) / sizeof(TestCaseAui);
4847 for (size_t i = 0; i < nr_test_cases; ++i) {
4848 uint64_t res = run_daui(daui_tc[i].rs, daui_tc[i].offset);
4849 CHECK_EQ(daui_tc[i].ref_res, res);
4850 }
4851
4852 // DATI test cases.
4853 struct TestCaseAui dati_tc[] = {
4854 {0xfffffffffffeffff, 0x1, 0x0000fffffffeffff},
4855 {0xffffffffffffffff, 0x0, 0xffffffffffffffff},
4856 {0, 0xffff, 0xffff000000000000},
4857 {0x0008ffff, 0xfff7, 0xfff700000008ffff},
4858 {32767, 32767, 0x7fff000000007fff},
4859 {0x00000000ffffffff, 0x1, 0x00010000ffffffff},
4860 {0xffffffffffff, 0xffff, 0xffffffffffffffff},
4861 };
4862
4863 nr_test_cases = sizeof(dati_tc) / sizeof(TestCaseAui);
4864 for (size_t i = 0; i < nr_test_cases; ++i) {
4865 uint64_t res = run_dati(dati_tc[i].rs, dati_tc[i].offset);
4866 CHECK_EQ(dati_tc[i].ref_res, res);
4867 }
4868
4869 // DAHI test cases.
4870 struct TestCaseAui dahi_tc[] = {
4871 {0xfffffffeffffffff, 0x1, 0xffffffffffffffff},
4872 {0xffffffffffffffff, 0x0, 0xffffffffffffffff},
4873 {0, 0xffff, 0xffffffff00000000},
4874 };
4875
4876 nr_test_cases = sizeof(dahi_tc) / sizeof(TestCaseAui);
4877 for (size_t i = 0; i < nr_test_cases; ++i) {
4878 uint64_t res = run_dahi(dahi_tc[i].rs, dahi_tc[i].offset);
4879 CHECK_EQ(dahi_tc[i].ref_res, res);
4880 }
4881 }
4882 }
4883
4884
4704 uint64_t run_lwpc(int offset) { 4885 uint64_t run_lwpc(int offset) {
4705 Isolate* isolate = CcTest::i_isolate(); 4886 Isolate* isolate = CcTest::i_isolate();
4706 HandleScope scope(isolate); 4887 HandleScope scope(isolate);
4707 4888
4708 MacroAssembler assm(isolate, NULL, 0); 4889 MacroAssembler assm(isolate, NULL, 0);
4709 4890
4710 // 256k instructions; 2^8k 4891 // 256k instructions; 2^8k
4711 // addiu t3, a4, 0xffff; (0x250fffff) 4892 // addiu t3, a4, 0xffff; (0x250fffff)
4712 // ... 4893 // ...
4713 // addiu t0, a4, 0x0000; (0x250c0000) 4894 // addiu t0, a4, 0x0000; (0x250c0000)
(...skipping 803 matching lines...)
5517 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 5698 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
5518 F2 f = FUNCTION_CAST<F2>(code->entry()); 5699 F2 f = FUNCTION_CAST<F2>(code->entry());
5519 5700
5520 int64_t res = reinterpret_cast<int64_t>( 5701 int64_t res = reinterpret_cast<int64_t>(
5521 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0)); 5702 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0));
5522 CHECK_EQ(res, 0); 5703 CHECK_EQ(res, 0);
5523 } 5704 }
5524 5705
5525 5706
5526 #undef __ 5707 #undef __
OLDNEW

Powered by Google App Engine