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

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: fix mips64 compilation error. Created 5 years 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-assembler-mips.cc ('k') | test/cctest/test-disasm-mips.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 4699 matching lines...) Expand 10 before | Expand all | Expand 10 after
4710 PC = 0; 4710 PC = 0;
4711 uint64_t res = run_auipc(tc[i].offset); 4711 uint64_t res = run_auipc(tc[i].offset);
4712 // Now, the program_counter (PC) is set. 4712 // Now, the program_counter (PC) is set.
4713 uint64_t expected_res = PC + (tc[i].offset << 16); 4713 uint64_t expected_res = PC + (tc[i].offset << 16);
4714 CHECK_EQ(expected_res, res); 4714 CHECK_EQ(expected_res, res);
4715 } 4715 }
4716 } 4716 }
4717 } 4717 }
4718 4718
4719 4719
4720 uint64_t run_aui(uint64_t rs, uint16_t offset) {
4721 Isolate* isolate = CcTest::i_isolate();
4722 HandleScope scope(isolate);
4723
4724 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
4725
4726 __ li(t0, rs);
4727 __ aui(v0, t0, offset);
4728 __ jr(ra);
4729 __ nop();
4730
4731 CodeDesc desc;
4732 assm.GetCode(&desc);
4733 Handle<Code> code = isolate->factory()->NewCode(
4734 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
4735
4736 F2 f = FUNCTION_CAST<F2>(code->entry());
4737
4738 uint64_t res =
4739 reinterpret_cast<uint64_t>
4740 (CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
4741
4742 return res;
4743 }
4744
4745
4746 uint64_t run_daui(uint64_t rs, uint16_t offset) {
4747 Isolate* isolate = CcTest::i_isolate();
4748 HandleScope scope(isolate);
4749
4750 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
4751
4752 __ li(t0, rs);
4753 __ daui(v0, t0, offset);
4754 __ jr(ra);
4755 __ nop();
4756
4757 CodeDesc desc;
4758 assm.GetCode(&desc);
4759 Handle<Code> code = isolate->factory()->NewCode(
4760 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
4761
4762 F2 f = FUNCTION_CAST<F2>(code->entry());
4763
4764 uint64_t res =
4765 reinterpret_cast<uint64_t>
4766 (CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
4767
4768 return res;
4769 }
4770
4771
4772 uint64_t run_dahi(uint64_t rs, uint16_t offset) {
4773 Isolate* isolate = CcTest::i_isolate();
4774 HandleScope scope(isolate);
4775
4776 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
4777
4778 __ li(v0, rs);
4779 __ dahi(v0, offset);
4780 __ jr(ra);
4781 __ nop();
4782
4783 CodeDesc desc;
4784 assm.GetCode(&desc);
4785 Handle<Code> code = isolate->factory()->NewCode(
4786 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
4787
4788 F2 f = FUNCTION_CAST<F2>(code->entry());
4789
4790 uint64_t res =
4791 reinterpret_cast<uint64_t>
4792 (CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
4793
4794 return res;
4795 }
4796
4797
4798 uint64_t run_dati(uint64_t rs, uint16_t offset) {
4799 Isolate* isolate = CcTest::i_isolate();
4800 HandleScope scope(isolate);
4801
4802 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
4803
4804 __ li(v0, rs);
4805 __ dati(v0, offset);
4806 __ jr(ra);
4807 __ nop();
4808
4809 CodeDesc desc;
4810 assm.GetCode(&desc);
4811 Handle<Code> code = isolate->factory()->NewCode(
4812 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
4813
4814 F2 f = FUNCTION_CAST<F2>(code->entry());
4815
4816 uint64_t res =
4817 reinterpret_cast<uint64_t>
4818 (CALL_GENERATED_CODE(isolate, f, 0, 0, 0, 0, 0));
4819
4820 return res;
4821 }
4822
4823
4824 TEST(r6_aui_family) {
4825 if (kArchVariant == kMips64r6) {
4826 CcTest::InitializeVM();
4827
4828 struct TestCaseAui {
4829 uint64_t rs;
4830 uint16_t offset;
4831 uint64_t ref_res;
4832 };
4833
4834 // AUI test cases.
4835 struct TestCaseAui aui_tc[] = {
4836 {0xfffeffff, 0x1, 0xffffffffffffffff},
4837 {0xffffffff, 0x0, 0xffffffffffffffff},
4838 {0, 0xffff, 0xffffffffffff0000},
4839 {0x0008ffff, 0xfff7, 0xffffffffffffffff},
4840 {32767, 32767, 0x000000007fff7fff},
4841 {0x00000000ffffffff, 0x1, 0x000000000000ffff},
4842 {0xffffffff, 0xffff, 0xfffffffffffeffff},
4843 };
4844
4845 size_t nr_test_cases = sizeof(aui_tc) / sizeof(TestCaseAui);
4846 for (size_t i = 0; i < nr_test_cases; ++i) {
4847 uint64_t res = run_aui(aui_tc[i].rs, aui_tc[i].offset);
4848 CHECK_EQ(aui_tc[i].ref_res, res);
4849 }
4850
4851 // DAUI test cases.
4852 struct TestCaseAui daui_tc[] = {
4853 {0xfffffffffffeffff, 0x1, 0xffffffffffffffff},
4854 {0xffffffffffffffff, 0x0, 0xffffffffffffffff},
4855 {0, 0xffff, 0xffffffffffff0000},
4856 {0x0008ffff, 0xfff7, 0xffffffffffffffff},
4857 {32767, 32767, 0x000000007fff7fff},
4858 {0x00000000ffffffff, 0x1, 0x000000010000ffff},
4859 {0xffffffff, 0xffff, 0x00000000fffeffff},
4860 };
4861
4862 nr_test_cases = sizeof(daui_tc) / sizeof(TestCaseAui);
4863 for (size_t i = 0; i < nr_test_cases; ++i) {
4864 uint64_t res = run_daui(daui_tc[i].rs, daui_tc[i].offset);
4865 CHECK_EQ(daui_tc[i].ref_res, res);
4866 }
4867
4868 // DATI test cases.
4869 struct TestCaseAui dati_tc[] = {
4870 {0xfffffffffffeffff, 0x1, 0x0000fffffffeffff},
4871 {0xffffffffffffffff, 0x0, 0xffffffffffffffff},
4872 {0, 0xffff, 0xffff000000000000},
4873 {0x0008ffff, 0xfff7, 0xfff700000008ffff},
4874 {32767, 32767, 0x7fff000000007fff},
4875 {0x00000000ffffffff, 0x1, 0x00010000ffffffff},
4876 {0xffffffffffff, 0xffff, 0xffffffffffffffff},
4877 };
4878
4879 nr_test_cases = sizeof(dati_tc) / sizeof(TestCaseAui);
4880 for (size_t i = 0; i < nr_test_cases; ++i) {
4881 uint64_t res = run_dati(dati_tc[i].rs, dati_tc[i].offset);
4882 CHECK_EQ(dati_tc[i].ref_res, res);
4883 }
4884
4885 // DAHI test cases.
4886 struct TestCaseAui dahi_tc[] = {
4887 {0xfffffffeffffffff, 0x1, 0xffffffffffffffff},
4888 {0xffffffffffffffff, 0x0, 0xffffffffffffffff},
4889 {0, 0xffff, 0xffffffff00000000},
4890 };
4891
4892 nr_test_cases = sizeof(dahi_tc) / sizeof(TestCaseAui);
4893 for (size_t i = 0; i < nr_test_cases; ++i) {
4894 uint64_t res = run_dahi(dahi_tc[i].rs, dahi_tc[i].offset);
4895 CHECK_EQ(dahi_tc[i].ref_res, res);
4896 }
4897 }
4898 }
4899
4900
4720 uint64_t run_lwpc(int offset) { 4901 uint64_t run_lwpc(int offset) {
4721 Isolate* isolate = CcTest::i_isolate(); 4902 Isolate* isolate = CcTest::i_isolate();
4722 HandleScope scope(isolate); 4903 HandleScope scope(isolate);
4723 4904
4724 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); 4905 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
4725 4906
4726 // 256k instructions; 2^8k 4907 // 256k instructions; 2^8k
4727 // addiu t3, a4, 0xffff; (0x250fffff) 4908 // addiu t3, a4, 0xffff; (0x250fffff)
4728 // ... 4909 // ...
4729 // addiu t0, a4, 0x0000; (0x250c0000) 4910 // addiu t0, a4, 0x0000; (0x250c0000)
(...skipping 804 matching lines...) Expand 10 before | Expand all | Expand 10 after
5534 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 5715 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
5535 F2 f = FUNCTION_CAST<F2>(code->entry()); 5716 F2 f = FUNCTION_CAST<F2>(code->entry());
5536 5717
5537 int64_t res = reinterpret_cast<int64_t>( 5718 int64_t res = reinterpret_cast<int64_t>(
5538 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0)); 5719 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0));
5539 CHECK_EQ(res, 0); 5720 CHECK_EQ(res, 0);
5540 } 5721 }
5541 5722
5542 5723
5543 #undef __ 5724 #undef __
OLDNEW
« no previous file with comments | « test/cctest/test-assembler-mips.cc ('k') | test/cctest/test-disasm-mips.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698