OLD | NEW |
---|---|
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 Loading... | |
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 void run_madd_msub_maddf_msubf() { | |
5939 CcTest::InitializeVM(); | |
5940 Isolate* isolate = CcTest::i_isolate(); | |
5941 HandleScope scope(isolate); | |
5942 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); | |
5943 | |
5944 struct TestCase { | |
5945 T fr, fs, ft, fd_add, fd_sub; | |
5946 }; | |
5947 | |
5948 T x = std::sqrt(static_cast<T>(2.0)); | |
5949 T y = std::sqrt(static_cast<T>(3.0)); | |
5950 T z = std::sqrt(static_cast<T>(5.0)); | |
5951 T x2 = 11.11, y2 = 22.22, z2 = 33.33; | |
5952 TestCase test_cases[] = { | |
5953 {x, y, z, 0.0, 0.0}, | |
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 {-3.14, 0.2345, -123.000056, 0.0, 0.0}, | |
5962 {7.3, -23.257, -357.1357, 0.0, 0.0}, | |
5963 {x2, y2, z2, 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 }; | |
5972 | |
5973 if (std::is_same<T, float>::value) { | |
5974 __ lwc1(f4, MemOperand(a0, offsetof(TestCase, fr))); | |
5975 __ lwc1(f6, MemOperand(a0, offsetof(TestCase, fs))); | |
ivica.bogosavljevic
2016/09/12 12:39:52
Same comment as in test-assembler-mips.cc
Ilija.Pavlovic1
2016/09/12 13:41:35
These lines will remain unchanged.
Ack.
| |
5976 __ lwc1(f8, MemOperand(a0, offsetof(TestCase, ft))); | |
5977 __ lwc1(f16, MemOperand(a0, offsetof(TestCase, fr))); | |
5978 } else if (std::is_same<T, double>::value) { | |
5979 __ ldc1(f4, MemOperand(a0, offsetof(TestCase, fr))); | |
5980 __ ldc1(f6, MemOperand(a0, offsetof(TestCase, fs))); | |
5981 __ ldc1(f8, MemOperand(a0, offsetof(TestCase, ft))); | |
5982 __ ldc1(f16, MemOperand(a0, offsetof(TestCase, fr))); | |
5983 } | |
5984 | |
5985 if (kArchVariant != kMips64r6) { | |
5986 if (std::is_same<T, float>::value) { | |
5987 __ madd_s(f10, f4, f6, f8); | |
5988 __ swc1(f10, MemOperand(a0, offsetof(TestCase, fd_add))); | |
5989 __ msub_s(f16, f4, f6, f8); | |
5990 __ swc1(f16, MemOperand(a0, offsetof(TestCase, fd_sub))); | |
5991 } else if (std::is_same<T, double>::value) { | |
5992 __ madd_d(f10, f4, f6, f8); | |
5993 __ sdc1(f10, MemOperand(a0, offsetof(TestCase, fd_add))); | |
5994 __ msub_d(f16, f4, f6, f8); | |
5995 __ sdc1(f16, MemOperand(a0, offsetof(TestCase, fd_sub))); | |
5996 } | |
5997 } else { | |
5998 if (std::is_same<T, float>::value) { | |
5999 __ maddf_s(f4, f6, f8); | |
6000 __ swc1(f4, MemOperand(a0, offsetof(TestCase, fd_add))); | |
6001 __ msubf_s(f16, f6, f8); | |
6002 __ swc1(f16, MemOperand(a0, offsetof(TestCase, fd_sub))); | |
6003 } else if (std::is_same<T, double>::value) { | |
6004 __ maddf_d(f4, f6, f8); | |
6005 __ sdc1(f4, MemOperand(a0, offsetof(TestCase, fd_add))); | |
6006 __ msubf_d(f16, f6, f8); | |
6007 __ sdc1(f16, MemOperand(a0, offsetof(TestCase, fd_sub))); | |
6008 } | |
6009 } | |
6010 | |
6011 __ jr(ra); | |
6012 __ nop(); | |
6013 | |
6014 CodeDesc desc; | |
6015 assm.GetCode(&desc); | |
6016 Handle<Code> code = isolate->factory()->NewCode( | |
6017 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | |
6018 F3 f = FUNCTION_CAST<F3>(code->entry()); | |
6019 | |
6020 const size_t kTableLength = sizeof(test_cases) / sizeof(TestCase); | |
6021 TestCase tc; | |
6022 for (size_t i = 0; i < kTableLength; i++) { | |
6023 tc.fr = test_cases[i].fr; | |
6024 tc.fs = test_cases[i].fs; | |
6025 tc.ft = test_cases[i].ft; | |
6026 | |
6027 (CALL_GENERATED_CODE(isolate, f, &tc, 0, 0, 0, 0)); | |
6028 | |
6029 T res_add = tc.fr + (tc.fs * tc.ft); | |
6030 T res_sub; | |
6031 if (kArchVariant != kMips64r6) | |
6032 res_sub = (tc.fs * tc.ft) - tc.fr; | |
6033 else | |
6034 res_sub = tc.fr - (tc.fs * tc.ft); | |
6035 | |
6036 CHECK_EQ(tc.fd_add, res_add); | |
6037 CHECK_EQ(tc.fd_sub, res_sub); | |
6038 } | |
6039 } | |
6040 | |
6041 TEST(madd_msub_maddf_msubf_s) { run_madd_msub_maddf_msubf<float>(); } | |
6042 | |
6043 TEST(madd_msub_maddf_msubf_d) { run_madd_msub_maddf_msubf<double>(); } | |
5937 | 6044 |
5938 #undef __ | 6045 #undef __ |
OLD | NEW |