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

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

Issue 2313623002: MIPS: Implement MADD.S, MSUB, MADDF and MSUBF. (Closed)
Patch Set: Redesign implementation of the test. 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
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) {
ivica.bogosavljevic 2016/09/13 07:44:20 Same as in test-assembler-mips.cc
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 }
5985
5986 func(assm);
5987
5988 __ jr(ra);
5989 __ nop();
5990
5991 CodeDesc desc;
5992 assm.GetCode(&desc);
5993 Handle<Code> code = isolate->factory()->NewCode(
5994 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
5995 F3 f = FUNCTION_CAST<F3>(code->entry());
5996
5997 const size_t kTableLength = sizeof(test_cases) / sizeof(TestCaseMaddMsub<T>);
5998 TestCaseMaddMsub<T> tc;
5999 for (size_t i = 0; i < kTableLength; i++) {
6000 tc.fr = test_cases[i].fr;
6001 tc.fs = test_cases[i].fs;
6002 tc.ft = test_cases[i].ft;
6003
6004 (CALL_GENERATED_CODE(isolate, f, &tc, 0, 0, 0, 0));
6005
6006 T res_add = tc.fr + (tc.fs * tc.ft);
6007 T res_sub;
6008 if (kArchVariant != kMips64r6)
ivica.bogosavljevic 2016/09/13 07:44:20 Same as test-assembler-mips.cc
Ilija.Pavlovic1 2016/09/13 12:57:57 Done.
6009 res_sub = (tc.fs * tc.ft) - tc.fr;
6010 else
6011 res_sub = tc.fr - (tc.fs * tc.ft);
6012
6013 CHECK_EQ(tc.fd_add, res_add);
6014 CHECK_EQ(tc.fd_sub, res_sub);
6015 }
6016 }
6017
6018 TEST(madd_msub_s) {
6019 if (kArchVariant == kMips64r6) return;
6020 helper_madd_msub_maddf_msubf<float>([](MacroAssembler& assm) {
6021 __ madd_s(f10, f4, f6, f8);
6022 __ swc1(f10, MemOperand(a0, offsetof(TestCaseMaddMsub<float>, fd_add)));
6023 __ msub_s(f16, f4, f6, f8);
6024 __ swc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<float>, fd_sub)));
6025 });
6026 }
6027
6028 TEST(madd_msub_d) {
6029 if (kArchVariant == kMips64r6) return;
6030 helper_madd_msub_maddf_msubf<double>([](MacroAssembler& assm) {
6031 __ madd_d(f10, f4, f6, f8);
6032 __ sdc1(f10, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_add)));
6033 __ msub_d(f16, f4, f6, f8);
6034 __ sdc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_sub)));
6035 });
6036 }
6037
6038 TEST(maddf_msubf_s) {
6039 if (kArchVariant != kMips64r6) return;
6040 helper_madd_msub_maddf_msubf<float>([](MacroAssembler& assm) {
6041 __ maddf_s(f4, f6, f8);
6042 __ swc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<float>, fd_add)));
6043 __ msubf_s(f16, f6, f8);
6044 __ swc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<float>, fd_sub)));
6045 });
6046 }
6047
6048 TEST(maddf_msubf_d) {
6049 if (kArchVariant != kMips64r6) return;
6050 helper_madd_msub_maddf_msubf<double>([](MacroAssembler& assm) {
6051 __ maddf_d(f4, f6, f8);
6052 __ sdc1(f4, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_add)));
6053 __ msubf_d(f16, f6, f8);
6054 __ sdc1(f16, MemOperand(a0, offsetof(TestCaseMaddMsub<double>, fd_sub)));
6055 });
6056 }
5937 6057
5938 #undef __ 6058 #undef __
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698