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) { |
| 5938 if (kArchVariant == kMips64r2) { |
| 5939 CcTest::InitializeVM(); |
| 5940 Isolate* isolate = CcTest::i_isolate(); |
| 5941 HandleScope scope(isolate); |
| 5942 MacroAssembler assm(isolate, NULL, 0, |
| 5943 v8::internal::CodeObjectRequired::kYes); |
| 5944 |
| 5945 struct TestCase { |
| 5946 float fr, fs, ft, fd_add, fd_sub; |
| 5947 }; |
| 5948 |
| 5949 float x = sqrtf(2.0); |
| 5950 float y = sqrtf(3.0); |
| 5951 float z = sqrtf(5.0); |
| 5952 float x2 = 11.11, y2 = 22.22, z2 = 33.33; |
| 5953 TestCase 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 __ lwc1(f4, MemOperand(a0, offsetof(TestCase, fr))); |
| 5975 __ lwc1(f6, MemOperand(a0, offsetof(TestCase, fs))); |
| 5976 __ lwc1(f8, MemOperand(a0, offsetof(TestCase, ft))); |
| 5977 __ lwc1(f16, MemOperand(a0, offsetof(TestCase, fr))); |
| 5978 |
| 5979 __ madd_s(f10, f4, f6, f8); |
| 5980 __ swc1(f10, MemOperand(a0, offsetof(TestCase, fd_add))); |
| 5981 __ msub_s(f16, f4, f6, f8); |
| 5982 __ swc1(f16, MemOperand(a0, offsetof(TestCase, fd_sub))); |
| 5983 |
| 5984 __ jr(ra); |
| 5985 __ nop(); |
| 5986 |
| 5987 CodeDesc desc; |
| 5988 assm.GetCode(&desc); |
| 5989 Handle<Code> code = isolate->factory()->NewCode( |
| 5990 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 5991 F3 f = FUNCTION_CAST<F3>(code->entry()); |
| 5992 |
| 5993 const size_t kTableLength = sizeof(test_cases) / sizeof(TestCase); |
| 5994 TestCase tc; |
| 5995 for (size_t i = 0; i < kTableLength; i++) { |
| 5996 tc.fr = test_cases[i].fr; |
| 5997 tc.fs = test_cases[i].fs; |
| 5998 tc.ft = test_cases[i].ft; |
| 5999 |
| 6000 (CALL_GENERATED_CODE(isolate, f, &tc, 0, 0, 0, 0)); |
| 6001 |
| 6002 float res_add = tc.fr + (tc.fs * tc.ft); |
| 6003 float res_sub = (tc.fs * tc.ft) - tc.fr; |
| 6004 CHECK_EQ(tc.fd_add, res_add); |
| 6005 CHECK_EQ(tc.fd_sub, res_sub); |
| 6006 } |
| 6007 } |
| 6008 } |
| 6009 |
| 6010 TEST(maddf_s_msubf_s) { |
| 6011 if (kArchVariant == kMips64r6) { |
| 6012 CcTest::InitializeVM(); |
| 6013 Isolate* isolate = CcTest::i_isolate(); |
| 6014 HandleScope scope(isolate); |
| 6015 MacroAssembler assm(isolate, NULL, 0, |
| 6016 v8::internal::CodeObjectRequired::kYes); |
| 6017 |
| 6018 struct TestCase { |
| 6019 float fr, fs, ft, fd_add, fd_sub; |
| 6020 }; |
| 6021 |
| 6022 float x = sqrtf(2.0); |
| 6023 float y = sqrtf(3.0); |
| 6024 float z = sqrtf(5.0); |
| 6025 float x2 = 11.11, y2 = 22.22, z2 = 33.33; |
| 6026 TestCase test_cases[] = { |
| 6027 {x, y, z, 0.0, 0.0}, |
| 6028 {x, y, -z, 0.0, 0.0}, |
| 6029 {x, -y, z, 0.0, 0.0}, |
| 6030 {x, -y, -z, 0.0, 0.0}, |
| 6031 {-x, y, z, 0.0, 0.0}, |
| 6032 {-x, y, -z, 0.0, 0.0}, |
| 6033 {-x, -y, z, 0.0, 0.0}, |
| 6034 {-x, -y, -z, 0.0, 0.0}, |
| 6035 {-3.14, 0.2345, -123.000056, 0.0, 0.0}, |
| 6036 {7.3, -23.257, -357.1357, 0.0, 0.0}, |
| 6037 {x2, y2, z2, 0.0, 0.0}, |
| 6038 {x2, y2, -z2, 0.0, 0.0}, |
| 6039 {x2, -y2, z2, 0.0, 0.0}, |
| 6040 {x2, -y2, -z2, 0.0, 0.0}, |
| 6041 {-x2, y2, z2, 0.0, 0.0}, |
| 6042 {-x2, y2, -z2, 0.0, 0.0}, |
| 6043 {-x2, -y2, z2, 0.0, 0.0}, |
| 6044 {-x2, -y2, -z2, 0.0, 0.0}, |
| 6045 }; |
| 6046 |
| 6047 __ lwc1(f4, MemOperand(a0, offsetof(TestCase, fr))); |
| 6048 __ lwc1(f6, MemOperand(a0, offsetof(TestCase, fs))); |
| 6049 __ lwc1(f8, MemOperand(a0, offsetof(TestCase, ft))); |
| 6050 __ lwc1(f16, MemOperand(a0, offsetof(TestCase, fr))); |
| 6051 |
| 6052 __ maddf_s(f4, f6, f8); |
| 6053 __ swc1(f4, MemOperand(a0, offsetof(TestCase, fd_add))); |
| 6054 __ msubf_s(f16, f6, f8); |
| 6055 __ swc1(f16, MemOperand(a0, offsetof(TestCase, fd_sub))); |
| 6056 |
| 6057 __ jr(ra); |
| 6058 __ nop(); |
| 6059 |
| 6060 CodeDesc desc; |
| 6061 assm.GetCode(&desc); |
| 6062 Handle<Code> code = isolate->factory()->NewCode( |
| 6063 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 6064 F3 f = FUNCTION_CAST<F3>(code->entry()); |
| 6065 |
| 6066 const size_t kTableLength = sizeof(test_cases) / sizeof(TestCase); |
| 6067 TestCase tc; |
| 6068 for (size_t i = 0; i < kTableLength; i++) { |
| 6069 tc.fr = test_cases[i].fr; |
| 6070 tc.fs = test_cases[i].fs; |
| 6071 tc.ft = test_cases[i].ft; |
| 6072 |
| 6073 (CALL_GENERATED_CODE(isolate, f, &tc, 0, 0, 0, 0)); |
| 6074 |
| 6075 float res_add = tc.fr + (tc.fs * tc.ft); |
| 6076 float res_sub = tc.fr - (tc.fs * tc.ft); |
| 6077 CHECK_EQ(tc.fd_add, res_add); |
| 6078 CHECK_EQ(tc.fd_sub, res_sub); |
| 6079 } |
| 6080 } |
| 6081 } |
| 6082 |
| 6083 TEST(madd_d_msub_d) { |
| 6084 if (kArchVariant == kMips64r2) { |
| 6085 CcTest::InitializeVM(); |
| 6086 Isolate* isolate = CcTest::i_isolate(); |
| 6087 HandleScope scope(isolate); |
| 6088 MacroAssembler assm(isolate, NULL, 0, |
| 6089 v8::internal::CodeObjectRequired::kYes); |
| 6090 |
| 6091 struct TestCase { |
| 6092 double fr, fs, ft, fd_add, fd_sub; |
| 6093 }; |
| 6094 |
| 6095 double x = sqrt(2.0); |
| 6096 double y = sqrt(3.0); |
| 6097 double z = sqrt(5.0); |
| 6098 double x2 = 11.11, y2 = 22.22, z2 = 33.33; |
| 6099 TestCase test_cases[] = { |
| 6100 {x, y, z, 0.0, 0.0}, |
| 6101 {x, y, -z, 0.0, 0.0}, |
| 6102 {x, -y, z, 0.0, 0.0}, |
| 6103 {x, -y, -z, 0.0, 0.0}, |
| 6104 {-x, y, z, 0.0, 0.0}, |
| 6105 {-x, y, -z, 0.0, 0.0}, |
| 6106 {-x, -y, z, 0.0, 0.0}, |
| 6107 {-x, -y, -z, 0.0, 0.0}, |
| 6108 {-3.14, 0.2345, -123.000056, 0.0, 0.0}, |
| 6109 {7.3, -23.257, -357.1357, 0.0, 0.0}, |
| 6110 {x2, y2, z2, 0.0, 0.0}, |
| 6111 {x2, y2, -z2, 0.0, 0.0}, |
| 6112 {x2, -y2, z2, 0.0, 0.0}, |
| 6113 {x2, -y2, -z2, 0.0, 0.0}, |
| 6114 {-x2, y2, z2, 0.0, 0.0}, |
| 6115 {-x2, y2, -z2, 0.0, 0.0}, |
| 6116 {-x2, -y2, z2, 0.0, 0.0}, |
| 6117 {-x2, -y2, -z2, 0.0, 0.0}, |
| 6118 }; |
| 6119 |
| 6120 __ ldc1(f4, MemOperand(a0, offsetof(TestCase, fr))); |
| 6121 __ ldc1(f6, MemOperand(a0, offsetof(TestCase, fs))); |
| 6122 __ ldc1(f8, MemOperand(a0, offsetof(TestCase, ft))); |
| 6123 __ ldc1(f16, MemOperand(a0, offsetof(TestCase, fr))); |
| 6124 |
| 6125 __ madd_d(f10, f4, f6, f8); |
| 6126 __ sdc1(f10, MemOperand(a0, offsetof(TestCase, fd_add))); |
| 6127 __ msub_d(f16, f4, f6, f8); |
| 6128 __ sdc1(f16, MemOperand(a0, offsetof(TestCase, fd_sub))); |
| 6129 |
| 6130 __ jr(ra); |
| 6131 __ nop(); |
| 6132 |
| 6133 CodeDesc desc; |
| 6134 assm.GetCode(&desc); |
| 6135 Handle<Code> code = isolate->factory()->NewCode( |
| 6136 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 6137 F3 f = FUNCTION_CAST<F3>(code->entry()); |
| 6138 |
| 6139 const size_t kTableLength = sizeof(test_cases) / sizeof(TestCase); |
| 6140 TestCase tc; |
| 6141 for (size_t i = 0; i < kTableLength; i++) { |
| 6142 tc.fr = test_cases[i].fr; |
| 6143 tc.fs = test_cases[i].fs; |
| 6144 tc.ft = test_cases[i].ft; |
| 6145 |
| 6146 (CALL_GENERATED_CODE(isolate, f, &tc, 0, 0, 0, 0)); |
| 6147 |
| 6148 double res_add = tc.fr + (tc.fs * tc.ft); |
| 6149 double res_sub = (tc.fs * tc.ft) - tc.fr; |
| 6150 CHECK_EQ(tc.fd_add, res_add); |
| 6151 CHECK_EQ(tc.fd_sub, res_sub); |
| 6152 } |
| 6153 } |
| 6154 } |
| 6155 |
| 6156 TEST(maddf_d_msubf_d) { |
| 6157 if (kArchVariant == kMips64r6) { |
| 6158 CcTest::InitializeVM(); |
| 6159 Isolate* isolate = CcTest::i_isolate(); |
| 6160 HandleScope scope(isolate); |
| 6161 MacroAssembler assm(isolate, NULL, 0, |
| 6162 v8::internal::CodeObjectRequired::kYes); |
| 6163 |
| 6164 struct TestCase { |
| 6165 double fr, fs, ft, fd_add, fd_sub; |
| 6166 }; |
| 6167 |
| 6168 double x = sqrt(2.0); |
| 6169 double y = sqrt(3.0); |
| 6170 double z = sqrt(5.0); |
| 6171 double x2 = 11.11, y2 = 22.22, z2 = 33.33; |
| 6172 TestCase test_cases[] = { |
| 6173 {x, y, z, 0.0, 0.0}, |
| 6174 {x, y, -z, 0.0, 0.0}, |
| 6175 {x, -y, z, 0.0, 0.0}, |
| 6176 {x, -y, -z, 0.0, 0.0}, |
| 6177 {-x, y, z, 0.0, 0.0}, |
| 6178 {-x, y, -z, 0.0, 0.0}, |
| 6179 {-x, -y, z, 0.0, 0.0}, |
| 6180 {-x, -y, -z, 0.0, 0.0}, |
| 6181 {-3.14, 0.2345, -123.000056, 0.0, 0.0}, |
| 6182 {7.3, -23.257, -357.1357, 0.0, 0.0}, |
| 6183 {x2, y2, z2, 0.0, 0.0}, |
| 6184 {x2, y2, -z2, 0.0, 0.0}, |
| 6185 {x2, -y2, z2, 0.0, 0.0}, |
| 6186 {x2, -y2, -z2, 0.0, 0.0}, |
| 6187 {-x2, y2, z2, 0.0, 0.0}, |
| 6188 {-x2, y2, -z2, 0.0, 0.0}, |
| 6189 {-x2, -y2, z2, 0.0, 0.0}, |
| 6190 {-x2, -y2, -z2, 0.0, 0.0}, |
| 6191 }; |
| 6192 |
| 6193 __ ldc1(f4, MemOperand(a0, offsetof(TestCase, fr))); |
| 6194 __ ldc1(f6, MemOperand(a0, offsetof(TestCase, fs))); |
| 6195 __ ldc1(f8, MemOperand(a0, offsetof(TestCase, ft))); |
| 6196 __ ldc1(f16, MemOperand(a0, offsetof(TestCase, fr))); |
| 6197 |
| 6198 __ maddf_d(f4, f6, f8); |
| 6199 __ sdc1(f4, MemOperand(a0, offsetof(TestCase, fd_add))); |
| 6200 __ msubf_d(f16, f6, f8); |
| 6201 __ sdc1(f16, MemOperand(a0, offsetof(TestCase, fd_sub))); |
| 6202 |
| 6203 __ jr(ra); |
| 6204 __ nop(); |
| 6205 |
| 6206 CodeDesc desc; |
| 6207 assm.GetCode(&desc); |
| 6208 Handle<Code> code = isolate->factory()->NewCode( |
| 6209 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
| 6210 F3 f = FUNCTION_CAST<F3>(code->entry()); |
| 6211 |
| 6212 const size_t kTableLength = sizeof(test_cases) / sizeof(TestCase); |
| 6213 TestCase tc; |
| 6214 for (size_t i = 0; i < kTableLength; i++) { |
| 6215 tc.fr = test_cases[i].fr; |
| 6216 tc.fs = test_cases[i].fs; |
| 6217 tc.ft = test_cases[i].ft; |
| 6218 |
| 6219 (CALL_GENERATED_CODE(isolate, f, &tc, 0, 0, 0, 0)); |
| 6220 |
| 6221 double res_add = tc.fr + (tc.fs * tc.ft); |
| 6222 double res_sub = tc.fr - (tc.fs * tc.ft); |
| 6223 CHECK_EQ(tc.fd_add, res_add); |
| 6224 CHECK_EQ(tc.fd_sub, res_sub); |
| 6225 } |
| 6226 } |
| 6227 } |
5937 | 6228 |
5938 #undef __ | 6229 #undef __ |
OLD | NEW |