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

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

Issue 2313623002: MIPS: Implement MADD.S, MSUB, MADDF and MSUBF. (Closed)
Patch Set: Added blocks and unreachable sections. Created 4 years, 3 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-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 5916 matching lines...) Expand 10 before | Expand all | Expand 10 after
5927 assm.GetCode(&desc); 5927 assm.GetCode(&desc);
5928 Handle<Code> code = isolate->factory()->NewCode( 5928 Handle<Code> code = isolate->factory()->NewCode(
5929 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 5929 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
5930 F2 f = FUNCTION_CAST<F2>(code->entry()); 5930 F2 f = FUNCTION_CAST<F2>(code->entry());
5931 5931
5932 int64_t res = reinterpret_cast<int64_t>( 5932 int64_t res = reinterpret_cast<int64_t>(
5933 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0)); 5933 CALL_GENERATED_CODE(isolate, f, 42, 42, 0, 0, 0));
5934 CHECK_EQ(res, 0); 5934 CHECK_EQ(res, 0);
5935 } 5935 }
5936 5936
5937 template <class T>
5938 struct TestCaseMaddMsub {
5939 T fr, fs, ft, fd_add, fd_sub;
5940 };
5941
5942 template <typename T, typename F>
5943 void helper_madd_msub_maddf_msubf(F func) {
5944 CcTest::InitializeVM();
5945 Isolate* isolate = CcTest::i_isolate();
5946 HandleScope scope(isolate);
5947 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes);
5948
5949 T x = std::sqrt(static_cast<T>(2.0));
5950 T y = std::sqrt(static_cast<T>(3.0));
5951 T z = std::sqrt(static_cast<T>(5.0));
5952 T x2 = 11.11, y2 = 22.22, z2 = 33.33;
5953 TestCaseMaddMsub<T> test_cases[] = {
5954 {x, y, z, 0.0, 0.0},
5955 {x, y, -z, 0.0, 0.0},
5956 {x, -y, z, 0.0, 0.0},
5957 {x, -y, -z, 0.0, 0.0},
5958 {-x, y, z, 0.0, 0.0},
5959 {-x, y, -z, 0.0, 0.0},
5960 {-x, -y, z, 0.0, 0.0},
5961 {-x, -y, -z, 0.0, 0.0},
5962 {-3.14, 0.2345, -123.000056, 0.0, 0.0},
5963 {7.3, -23.257, -357.1357, 0.0, 0.0},
5964 {x2, y2, z2, 0.0, 0.0},
5965 {x2, y2, -z2, 0.0, 0.0},
5966 {x2, -y2, z2, 0.0, 0.0},
5967 {x2, -y2, -z2, 0.0, 0.0},
5968 {-x2, y2, z2, 0.0, 0.0},
5969 {-x2, y2, -z2, 0.0, 0.0},
5970 {-x2, -y2, z2, 0.0, 0.0},
5971 {-x2, -y2, -z2, 0.0, 0.0},
5972 };
5973
5974 if (std::is_same<T, float>::value) {
5975 __ lwc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fr)));
5976 __ lwc1(f6, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fs)));
5977 __ lwc1(f8, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, ft)));
5978 __ lwc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fr)));
5979 } else if (std::is_same<T, double>::value) {
5980 __ ldc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fr)));
5981 __ ldc1(f6, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fs)));
5982 __ ldc1(f8, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, ft)));
5983 __ ldc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<T>, fr)));
5984 } else {
5985 UNREACHABLE();
5986 }
5987
5988 func(assm);
5989
5990 __ jr(ra);
5991 __ nop();
5992
5993 CodeDesc desc;
5994 assm.GetCode(&desc);
5995 Handle<Code> code = isolate->factory()->NewCode(
5996 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
5997 F3 f = FUNCTION_CAST<F3>(code->entry());
5998
5999 const size_t kTableLength = sizeof(test_cases) / sizeof(TestCaseMaddMsub<T>);
6000 TestCaseMaddMsub<T> tc;
6001 for (size_t i = 0; i < kTableLength; i++) {
6002 tc.fr = test_cases[i].fr;
6003 tc.fs = test_cases[i].fs;
6004 tc.ft = test_cases[i].ft;
6005
6006 (CALL_GENERATED_CODE(isolate, f, &tc, 0, 0, 0, 0));
6007
6008 T res_add = tc.fr + (tc.fs * tc.ft);
6009 T res_sub;
6010 if (kArchVariant != kMips64r6) {
6011 res_sub = (tc.fs * tc.ft) - tc.fr;
6012 } else {
6013 res_sub = tc.fr - (tc.fs * tc.ft);
6014 }
6015
6016 CHECK_EQ(tc.fd_add, res_add);
6017 CHECK_EQ(tc.fd_sub, res_sub);
6018 }
6019 }
6020
6021 TEST(madd_msub_s) {
6022 if (kArchVariant == kMips64r6) return;
6023 helper_madd_msub_maddf_msubf<float>([](MacroAssembler& assm) {
6024 __ madd_s(f10, f4, f6, f8);
6025 __ swc1(f10, MemOperand(a0, offsetof(TestCaseMaddMsub<float>, fd_add)));
6026 __ msub_s(f16, f4, f6, f8);
6027 __ swc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<float>, fd_sub)));
6028 });
6029 }
6030
6031 TEST(madd_msub_d) {
6032 if (kArchVariant == kMips64r6) return;
6033 helper_madd_msub_maddf_msubf<double>([](MacroAssembler& assm) {
6034 __ madd_d(f10, f4, f6, f8);
6035 __ sdc1(f10, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_add)));
6036 __ msub_d(f16, f4, f6, f8);
6037 __ sdc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_sub)));
6038 });
6039 }
6040
6041 TEST(maddf_msubf_s) {
6042 if (kArchVariant != kMips64r6) return;
6043 helper_madd_msub_maddf_msubf<float>([](MacroAssembler& assm) {
6044 __ maddf_s(f4, f6, f8);
6045 __ swc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<float>, fd_add)));
6046 __ msubf_s(f16, f6, f8);
6047 __ swc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<float>, fd_sub)));
6048 });
6049 }
6050
6051 TEST(maddf_msubf_d) {
6052 if (kArchVariant != kMips64r6) return;
6053 helper_madd_msub_maddf_msubf<double>([](MacroAssembler& assm) {
6054 __ maddf_d(f4, f6, f8);
6055 __ sdc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_add)));
6056 __ msubf_d(f16, f6, f8);
6057 __ sdc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_sub)));
6058 });
6059 }
5937 6060
5938 #undef __ 6061 #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