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 TEST(madd_s_msub_s_maddf_s_msubf_s) { |
| 5938 CcTest::InitializeVM(); |
| 5939 Isolate* isolate = CcTest::i_isolate(); |
| 5940 HandleScope scope(isolate); |
| 5941 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
| 5942 |
| 5943 struct TestCase { |
| 5944 float fr, fs, ft, fd_add, fd_sub; |
| 5945 }; |
| 5946 |
| 5947 float x = sqrtf(2.0); |
| 5948 float y = sqrtf(3.0); |
| 5949 float z = sqrtf(5.0); |
| 5950 TestCase test_cases[] = { |
| 5951 {x, y, z, 0.0, 0.0}, {x, y, -z, 0.0, 0.0}, {x, -y, z, 0.0, 0.0}, |
| 5952 {x, -y, -z, 0.0, 0.0}, {-x, y, z, 0.0, 0.0}, {-x, y, -z, 0.0, 0.0}, |
| 5953 {-x, -y, z, 0.0, 0.0}, {-x, -y, -z, 0.0, 0.0}, |
| 5954 }; |
| 5955 |
| 5956 __ lwc1(f4, MemOperand(a0, offsetof(TestCase, fr))); |
| 5957 __ lwc1(f6, MemOperand(a0, offsetof(TestCase, fs))); |
| 5958 __ lwc1(f8, MemOperand(a0, offsetof(TestCase, ft))); |
| 5959 __ lwc1(f16, MemOperand(a0, offsetof(TestCase, fr))); |
| 5960 |
| 5961 if (kArchVariant == kMips64r2) { |
| 5962 __ madd_s(f10, f4, f6, f8); |
| 5963 __ swc1(f10, MemOperand(a0, offsetof(TestCase, fd_add))); |
| 5964 __ msub_s(f16, f4, f6, f8); |
| 5965 __ swc1(f16, MemOperand(a0, offsetof(TestCase, fd_sub))); |
| 5966 } |
| 5967 |
| 5968 if (kArchVariant == kMips64r6) { |
| 5969 __ maddf_s(f4, f6, f8); |
| 5970 __ swc1(f4, MemOperand(a0, offsetof(TestCase, fd_add))); |
| 5971 __ msubf_s(f16, f6, f8); |
| 5972 __ swc1(f16, MemOperand(a0, offsetof(TestCase, fd_sub))); |
| 5973 } |
| 5974 |
| 5975 __ jr(ra); |
| 5976 __ nop(); |
| 5977 |
| 5978 CodeDesc desc; |
| 5979 assm.GetCode(&desc); |
| 5980 Handle<Code> code = isolate->factory()->NewCode( |
| 5981 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 5982 F3 f = FUNCTION_CAST<F3>(code->entry()); |
| 5983 |
| 5984 const size_t kTableLength = sizeof(test_cases) / sizeof(TestCase); |
| 5985 TestCase tc; |
| 5986 for (size_t i = 0; i < kTableLength; i++) { |
| 5987 tc.fr = test_cases[i].fr; |
| 5988 tc.fs = test_cases[i].fs; |
| 5989 tc.ft = test_cases[i].ft; |
| 5990 |
| 5991 (CALL_GENERATED_CODE(isolate, f, &tc, 0, 0, 0, 0)); |
| 5992 |
| 5993 float res_add = tc.fr + (tc.fs * tc.ft); |
| 5994 float res_sub; |
| 5995 if (kArchVariant == kMips64r2) { |
| 5996 res_sub = (tc.fs * tc.ft) - tc.fr; |
| 5997 } else if (kArchVariant == kMips64r6) { |
| 5998 res_sub = tc.fr - (tc.fs * tc.ft); |
| 5999 } |
| 6000 |
| 6001 CHECK_EQ(tc.fd_add, res_add); |
| 6002 CHECK_EQ(tc.fd_sub, res_sub); |
| 6003 } |
| 6004 } |
| 6005 |
| 6006 TEST(madd_d_msub_d_maddf_d_msubf_d) { |
| 6007 CcTest::InitializeVM(); |
| 6008 Isolate* isolate = CcTest::i_isolate(); |
| 6009 HandleScope scope(isolate); |
| 6010 MacroAssembler assm(isolate, NULL, 0, v8::internal::CodeObjectRequired::kYes); |
| 6011 |
| 6012 struct TestCase { |
| 6013 double fr, fs, ft, fd_add, fd_sub; |
| 6014 }; |
| 6015 |
| 6016 double x = sqrt(2.0); |
| 6017 double y = sqrt(3.0); |
| 6018 double z = sqrt(5.0); |
| 6019 TestCase test_cases[] = {{x, y, z, 0.0, 0.0}, {x, y, -z, 0.0, 0.0}, |
| 6020 {x, -y, z, 0.0, 0.0}, {x, -y, -z, 0.0, 0.0}, |
| 6021 {-x, y, z, 0.0, 0.0}, {-x, y, -z, 0.0, 0.0}, |
| 6022 {-x, -y, z, 0.0, 0.0}, {-x, -y, -z, 0.0, 0.0}}; |
| 6023 |
| 6024 __ ldc1(f4, MemOperand(a0, offsetof(TestCase, fr))); |
| 6025 __ ldc1(f6, MemOperand(a0, offsetof(TestCase, fs))); |
| 6026 __ ldc1(f8, MemOperand(a0, offsetof(TestCase, ft))); |
| 6027 __ ldc1(f16, MemOperand(a0, offsetof(TestCase, fr))); |
| 6028 |
| 6029 if (kArchVariant == kMips64r2) { |
| 6030 __ madd_d(f10, f4, f6, f8); |
| 6031 __ sdc1(f10, MemOperand(a0, offsetof(TestCase, fd_add))); |
| 6032 __ msub_d(f16, f4, f6, f8); |
| 6033 __ sdc1(f16, MemOperand(a0, offsetof(TestCase, fd_sub))); |
| 6034 } |
| 6035 |
| 6036 if (kArchVariant == kMips64r6) { |
| 6037 __ maddf_d(f4, f6, f8); |
| 6038 __ sdc1(f4, MemOperand(a0, offsetof(TestCase, fd_add))); |
| 6039 __ msubf_d(f16, f6, f8); |
| 6040 __ sdc1(f16, MemOperand(a0, offsetof(TestCase, fd_sub))); |
| 6041 } |
| 6042 |
| 6043 __ jr(ra); |
| 6044 __ nop(); |
| 6045 |
| 6046 CodeDesc desc; |
| 6047 assm.GetCode(&desc); |
| 6048 Handle<Code> code = isolate->factory()->NewCode( |
| 6049 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 6050 F3 f = FUNCTION_CAST<F3>(code->entry()); |
| 6051 |
| 6052 const size_t kTableLength = sizeof(test_cases) / sizeof(TestCase); |
| 6053 TestCase tc; |
| 6054 for (size_t i = 0; i < kTableLength; i++) { |
| 6055 tc.fr = test_cases[i].fr; |
| 6056 tc.fs = test_cases[i].fs; |
| 6057 tc.ft = test_cases[i].ft; |
| 6058 |
| 6059 (CALL_GENERATED_CODE(isolate, f, &tc, 0, 0, 0, 0)); |
| 6060 |
| 6061 double res_add = tc.fr + (tc.fs * tc.ft); |
| 6062 double res_sub; |
| 6063 if (kArchVariant == kMips64r2) { |
| 6064 res_sub = (tc.fs * tc.ft) - tc.fr; |
| 6065 } else if (kArchVariant == kMips64r6) { |
| 6066 res_sub = tc.fr - (tc.fs * tc.ft); |
| 6067 } |
| 6068 |
| 6069 CHECK_EQ(tc.fd_add, res_add); |
| 6070 CHECK_EQ(tc.fd_sub, res_sub); |
| 6071 } |
| 6072 } |
5937 | 6073 |
5938 #undef __ | 6074 #undef __ |
OLD | NEW |