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

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

Issue 1145223002: MIPS: Add float instructions and test coverage, part two (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Addressed comments Created 5 years, 7 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 | « src/mips64/simulator-mips64.cc ('k') | test/cctest/test-assembler-mips64.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 1900 matching lines...) Expand 10 before | Expand all | Expand 10 after
1911 Isolate* isolate = CcTest::i_isolate(); 1911 Isolate* isolate = CcTest::i_isolate();
1912 HandleScope scope(isolate); 1912 HandleScope scope(isolate);
1913 MacroAssembler assm(isolate, NULL, 0); 1913 MacroAssembler assm(isolate, NULL, 0);
1914 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); 1914 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult);
1915 typedef struct test_float { 1915 typedef struct test_float {
1916 double a; 1916 double a;
1917 float b; 1917 float b;
1918 int64_t c; // a trunc result 1918 int64_t c; // a trunc result
1919 int64_t d; // b trunc result 1919 int64_t d; // b trunc result
1920 }Test; 1920 }Test;
1921 const int tableLength = 16; 1921 const int tableLength = 15;
1922 double inputs_D[tableLength] = { 1922 double inputs_D[tableLength] = {
1923 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, 1923 2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
1924 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, 1924 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
1925 2147483648.0, 1925 2147483648.0,
1926 std::numeric_limits<double>::quiet_NaN(), 1926 std::numeric_limits<double>::quiet_NaN(),
1927 std::numeric_limits<double>::infinity(), 1927 std::numeric_limits<double>::infinity()
1928 9223372036854775808.0
1929 }; 1928 };
1930 float inputs_S[tableLength] = { 1929 float inputs_S[tableLength] = {
1931 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, 1930 2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
1932 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, 1931 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
1933 2147483648.0, 1932 2147483648.0,
1934 std::numeric_limits<float>::quiet_NaN(), 1933 std::numeric_limits<float>::quiet_NaN(),
1935 std::numeric_limits<float>::infinity(), 1934 std::numeric_limits<float>::infinity()
1936 9223372036854775808.0
1937 }; 1935 };
1938 double outputs[tableLength] = { 1936 double outputs[tableLength] = {
1939 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 1937 2.0, 2.0, 2.0, 3.0, 3.0, 3.0,
1940 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, 1938 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0,
1941 2147483648.0, dFPU64InvalidResult, 1939 2147483648.0, dFPU64InvalidResult,
1942 dFPU64InvalidResult, dFPU64InvalidResult}; 1940 dFPU64InvalidResult};
1943 1941
1944 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); 1942 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) );
1945 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); 1943 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) );
1946 __ trunc_l_d(f8, f4); 1944 __ trunc_l_d(f8, f4);
1947 __ trunc_l_s(f10, f6); 1945 __ trunc_l_s(f10, f6);
1948 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); 1946 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) );
1949 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); 1947 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) );
1950 __ jr(ra); 1948 __ jr(ra);
1951 __ nop(); 1949 __ nop();
1952 Test test; 1950 Test test;
(...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after
2348 Isolate* isolate = CcTest::i_isolate(); 2346 Isolate* isolate = CcTest::i_isolate();
2349 HandleScope scope(isolate); 2347 HandleScope scope(isolate);
2350 MacroAssembler assm(isolate, NULL, 0); 2348 MacroAssembler assm(isolate, NULL, 0);
2351 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); 2349 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult);
2352 typedef struct test_float { 2350 typedef struct test_float {
2353 double a; 2351 double a;
2354 float b; 2352 float b;
2355 int64_t c; 2353 int64_t c;
2356 int64_t d; 2354 int64_t d;
2357 }Test; 2355 }Test;
2358 const int tableLength = 16; 2356 const int tableLength = 15;
2359 double inputs_D[tableLength] = { 2357 double inputs_D[tableLength] = {
2360 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, 2358 2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
2361 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, 2359 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
2362 2147483648.0, 2360 2147483648.0,
2363 std::numeric_limits<double>::quiet_NaN(), 2361 std::numeric_limits<double>::quiet_NaN(),
2364 std::numeric_limits<double>::infinity(), 2362 std::numeric_limits<double>::infinity()
2365 9223372036854775808.0
2366 }; 2363 };
2367 float inputs_S[tableLength] = { 2364 float inputs_S[tableLength] = {
2368 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, 2365 2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
2369 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, 2366 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
2370 2147483648.0, 2367 2147483648.0,
2371 std::numeric_limits<float>::quiet_NaN(), 2368 std::numeric_limits<float>::quiet_NaN(),
2372 std::numeric_limits<float>::infinity(), 2369 std::numeric_limits<float>::infinity()
2373 9223372036854775808.0
2374 }; 2370 };
2375 double outputs[tableLength] = { 2371 double outputs[tableLength] = {
2376 2.0, 3.0, 2.0, 3.0, 4.0, 4.0, 2372 2.0, 3.0, 2.0, 3.0, 4.0, 4.0,
2377 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0, 2373 -2.0, -3.0, -2.0, -3.0, -4.0, -4.0,
2378 2147483648.0, dFPU64InvalidResult, 2374 2147483648.0, dFPU64InvalidResult,
2379 dFPU64InvalidResult, dFPU64InvalidResult}; 2375 dFPU64InvalidResult};
2380 2376
2381 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); 2377 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) );
2382 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); 2378 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) );
2383 __ round_l_d(f8, f4); 2379 __ round_l_d(f8, f4);
2384 __ round_l_s(f10, f6); 2380 __ round_l_s(f10, f6);
2385 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); 2381 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) );
2386 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); 2382 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) );
2387 __ jr(ra); 2383 __ jr(ra);
2388 __ nop(); 2384 __ nop();
2389 Test test; 2385 Test test;
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
2797 Isolate* isolate = CcTest::i_isolate(); 2793 Isolate* isolate = CcTest::i_isolate();
2798 HandleScope scope(isolate); 2794 HandleScope scope(isolate);
2799 MacroAssembler assm(isolate, NULL, 0); 2795 MacroAssembler assm(isolate, NULL, 0);
2800 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); 2796 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult);
2801 typedef struct test_float { 2797 typedef struct test_float {
2802 double a; 2798 double a;
2803 float b; 2799 float b;
2804 int64_t c; 2800 int64_t c;
2805 int64_t d; 2801 int64_t d;
2806 }Test; 2802 }Test;
2807 const int tableLength = 16; 2803 const int tableLength = 15;
2808 double inputs_D[tableLength] = { 2804 double inputs_D[tableLength] = {
2809 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, 2805 2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
2810 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, 2806 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
2811 2147483648.0, 2807 2147483648.0,
2812 std::numeric_limits<double>::quiet_NaN(), 2808 std::numeric_limits<double>::quiet_NaN(),
2813 std::numeric_limits<double>::infinity(), 2809 std::numeric_limits<double>::infinity()
2814 9223372036854775808.0
2815 }; 2810 };
2816 float inputs_S[tableLength] = { 2811 float inputs_S[tableLength] = {
2817 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, 2812 2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
2818 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, 2813 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
2819 2147483648.0, 2814 2147483648.0,
2820 std::numeric_limits<float>::quiet_NaN(), 2815 std::numeric_limits<float>::quiet_NaN(),
2821 std::numeric_limits<float>::infinity(), 2816 std::numeric_limits<float>::infinity()
2822 9223372036854775808.0
2823 }; 2817 };
2824 double outputs[tableLength] = { 2818 double outputs[tableLength] = {
2825 2.0, 2.0, 2.0, 3.0, 3.0, 3.0, 2819 2.0, 2.0, 2.0, 3.0, 3.0, 3.0,
2826 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0, 2820 -3.0, -3.0, -3.0, -4.0, -4.0, -4.0,
2827 2147483648.0, dFPU64InvalidResult, 2821 2147483648.0, dFPU64InvalidResult,
2828 dFPU64InvalidResult, dFPU64InvalidResult}; 2822 dFPU64InvalidResult};
2829 2823
2830 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); 2824 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) );
2831 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); 2825 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) );
2832 __ floor_l_d(f8, f4); 2826 __ floor_l_d(f8, f4);
2833 __ floor_l_s(f10, f6); 2827 __ floor_l_s(f10, f6);
2834 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); 2828 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) );
2835 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); 2829 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) );
2836 __ jr(ra); 2830 __ jr(ra);
2837 __ nop(); 2831 __ nop();
2838 Test test; 2832 Test test;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2915 Isolate* isolate = CcTest::i_isolate(); 2909 Isolate* isolate = CcTest::i_isolate();
2916 HandleScope scope(isolate); 2910 HandleScope scope(isolate);
2917 MacroAssembler assm(isolate, NULL, 0); 2911 MacroAssembler assm(isolate, NULL, 0);
2918 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult); 2912 const double dFPU64InvalidResult = static_cast<double>(kFPU64InvalidResult);
2919 typedef struct test_float { 2913 typedef struct test_float {
2920 double a; 2914 double a;
2921 float b; 2915 float b;
2922 int64_t c; 2916 int64_t c;
2923 int64_t d; 2917 int64_t d;
2924 }Test; 2918 }Test;
2925 const int tableLength = 16; 2919 const int tableLength = 15;
2926 double inputs_D[tableLength] = { 2920 double inputs_D[tableLength] = {
2927 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, 2921 2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
2928 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, 2922 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
2929 2147483648.0, 2923 2147483648.0,
2930 std::numeric_limits<double>::quiet_NaN(), 2924 std::numeric_limits<double>::quiet_NaN(),
2931 std::numeric_limits<double>::infinity(), 2925 std::numeric_limits<double>::infinity()
2932 9223372036854775808.0
2933 }; 2926 };
2934 float inputs_S[tableLength] = { 2927 float inputs_S[tableLength] = {
2935 2.1, 2.6, 2.5, 3.1, 3.6, 3.5, 2928 2.1, 2.6, 2.5, 3.1, 3.6, 3.5,
2936 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5, 2929 -2.1, -2.6, -2.5, -3.1, -3.6, -3.5,
2937 2147483648.0, 2930 2147483648.0,
2938 std::numeric_limits<float>::quiet_NaN(), 2931 std::numeric_limits<float>::quiet_NaN(),
2939 std::numeric_limits<float>::infinity(), 2932 std::numeric_limits<float>::infinity()
2940 9223372036854775808.0
2941 }; 2933 };
2942 double outputs[tableLength] = { 2934 double outputs[tableLength] = {
2943 3.0, 3.0, 3.0, 4.0, 4.0, 4.0, 2935 3.0, 3.0, 3.0, 4.0, 4.0, 4.0,
2944 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0, 2936 -2.0, -2.0, -2.0, -3.0, -3.0, -3.0,
2945 2147483648.0, dFPU64InvalidResult, 2937 2147483648.0, dFPU64InvalidResult,
2946 dFPU64InvalidResult, dFPU64InvalidResult}; 2938 dFPU64InvalidResult};
2947 2939
2948 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) ); 2940 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, a)) );
2949 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) ); 2941 __ lwc1(f6, MemOperand(a0, OFFSET_OF(Test, b)) );
2950 __ ceil_l_d(f8, f4); 2942 __ ceil_l_d(f8, f4);
2951 __ ceil_l_s(f10, f6); 2943 __ ceil_l_s(f10, f6);
2952 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) ); 2944 __ sdc1(f8, MemOperand(a0, OFFSET_OF(Test, c)) );
2953 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) ); 2945 __ sdc1(f10, MemOperand(a0, OFFSET_OF(Test, d)) );
2954 __ jr(ra); 2946 __ jr(ra);
2955 __ nop(); 2947 __ nop();
2956 Test test; 2948 Test test;
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
3174 #ifdef OBJECT_PRINT 3166 #ifdef OBJECT_PRINT
3175 ::printf("f(%d) = ", i); 3167 ::printf("f(%d) = ", i);
3176 result->Print(std::cout); 3168 result->Print(std::cout);
3177 ::printf("\n"); 3169 ::printf("\n");
3178 #endif 3170 #endif
3179 CHECK(values[i].is_identical_to(result)); 3171 CHECK(values[i].is_identical_to(result));
3180 } 3172 }
3181 } 3173 }
3182 3174
3183 3175
3176 TEST(BITSWAP) {
3177 // Test BITSWAP
3178 if (IsMipsArchVariant(kMips32r6)) {
3179 CcTest::InitializeVM();
3180 Isolate* isolate = CcTest::i_isolate();
3181 HandleScope scope(isolate);
3182
3183 typedef struct {
3184 int32_t r1;
3185 int32_t r2;
3186 int32_t r3;
3187 int32_t r4;
3188 } T;
3189 T t;
3190
3191 Assembler assm(isolate, NULL, 0);
3192
3193 __ lw(a2, MemOperand(a0, OFFSET_OF(T, r1)));
3194 __ nop();
3195 __ bitswap(a1, a2);
3196 __ sw(a1, MemOperand(a0, OFFSET_OF(T, r1)));
3197
3198 __ lw(a2, MemOperand(a0, OFFSET_OF(T, r2)));
3199 __ nop();
3200 __ bitswap(a1, a2);
3201 __ sw(a1, MemOperand(a0, OFFSET_OF(T, r2)));
3202
3203 __ jr(ra);
3204 __ nop();
3205
3206 CodeDesc desc;
3207 assm.GetCode(&desc);
3208 Handle<Code> code = isolate->factory()->NewCode(
3209 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
3210 F3 f = FUNCTION_CAST<F3>(code->entry());
3211 t.r1 = 0x781A15C3;
3212 t.r2 = 0x8B71FCDE;
3213 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0);
3214 USE(dummy);
3215
3216 CHECK_EQ(static_cast<int32_t>(0x1E58A8C3), t.r1);
3217 CHECK_EQ(static_cast<int32_t>(0xD18E3F7B), t.r2);
3218 }
3219 }
3220
3221
3222 TEST(class_fmt) {
3223 if (IsMipsArchVariant(kMips32r6)) {
3224 // Test CLASS.fmt instruction.
3225 CcTest::InitializeVM();
3226 Isolate* isolate = CcTest::i_isolate();
3227 HandleScope scope(isolate);
3228
3229 typedef struct {
3230 double dSignalingNan;
3231 double dQuietNan;
3232 double dNegInf;
3233 double dNegNorm;
3234 double dNegSubnorm;
3235 double dNegZero;
3236 double dPosInf;
3237 double dPosNorm;
3238 double dPosSubnorm;
3239 double dPosZero;
3240 float fSignalingNan;
3241 float fQuietNan;
3242 float fNegInf;
3243 float fNegNorm;
3244 float fNegSubnorm;
3245 float fNegZero;
3246 float fPosInf;
3247 float fPosNorm;
3248 float fPosSubnorm;
3249 float fPosZero; } T;
3250 T t;
3251
3252 // Create a function that accepts &t, and loads, manipulates, and stores
3253 // the doubles t.a ... t.f.
3254 MacroAssembler assm(isolate, NULL, 0);
3255
3256 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, dSignalingNan)));
3257 __ class_d(f6, f4);
3258 __ sdc1(f6, MemOperand(a0, OFFSET_OF(T, dSignalingNan)));
3259
3260 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, dQuietNan)));
3261 __ class_d(f6, f4);
3262 __ sdc1(f6, MemOperand(a0, OFFSET_OF(T, dQuietNan)));
3263
3264 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, dNegInf)));
3265 __ class_d(f6, f4);
3266 __ sdc1(f6, MemOperand(a0, OFFSET_OF(T, dNegInf)));
3267
3268 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, dNegNorm)));
3269 __ class_d(f6, f4);
3270 __ sdc1(f6, MemOperand(a0, OFFSET_OF(T, dNegNorm)));
3271
3272 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, dNegSubnorm)));
3273 __ class_d(f6, f4);
3274 __ sdc1(f6, MemOperand(a0, OFFSET_OF(T, dNegSubnorm)));
3275
3276 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, dNegZero)));
3277 __ class_d(f6, f4);
3278 __ sdc1(f6, MemOperand(a0, OFFSET_OF(T, dNegZero)));
3279
3280 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, dPosInf)));
3281 __ class_d(f6, f4);
3282 __ sdc1(f6, MemOperand(a0, OFFSET_OF(T, dPosInf)));
3283
3284 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, dPosNorm)));
3285 __ class_d(f6, f4);
3286 __ sdc1(f6, MemOperand(a0, OFFSET_OF(T, dPosNorm)));
3287
3288 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, dPosSubnorm)));
3289 __ class_d(f6, f4);
3290 __ sdc1(f6, MemOperand(a0, OFFSET_OF(T, dPosSubnorm)));
3291
3292 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, dPosZero)));
3293 __ class_d(f6, f4);
3294 __ sdc1(f6, MemOperand(a0, OFFSET_OF(T, dPosZero)));
3295
3296 // Testing instruction CLASS.S
3297 __ lwc1(f4, MemOperand(a0, OFFSET_OF(T, fSignalingNan)));
3298 __ class_s(f6, f4);
3299 __ swc1(f6, MemOperand(a0, OFFSET_OF(T, fSignalingNan)));
3300
3301 __ lwc1(f4, MemOperand(a0, OFFSET_OF(T, fQuietNan)));
3302 __ class_s(f6, f4);
3303 __ swc1(f6, MemOperand(a0, OFFSET_OF(T, fQuietNan)));
3304
3305 __ lwc1(f4, MemOperand(a0, OFFSET_OF(T, fNegInf)));
3306 __ class_s(f6, f4);
3307 __ swc1(f6, MemOperand(a0, OFFSET_OF(T, fNegInf)));
3308
3309 __ lwc1(f4, MemOperand(a0, OFFSET_OF(T, fNegNorm)));
3310 __ class_s(f6, f4);
3311 __ swc1(f6, MemOperand(a0, OFFSET_OF(T, fNegNorm)));
3312
3313 __ lwc1(f4, MemOperand(a0, OFFSET_OF(T, fNegSubnorm)));
3314 __ class_s(f6, f4);
3315 __ swc1(f6, MemOperand(a0, OFFSET_OF(T, fNegSubnorm)));
3316
3317 __ lwc1(f4, MemOperand(a0, OFFSET_OF(T, fNegZero)));
3318 __ class_s(f6, f4);
3319 __ swc1(f6, MemOperand(a0, OFFSET_OF(T, fNegZero)));
3320
3321 __ lwc1(f4, MemOperand(a0, OFFSET_OF(T, fPosInf)));
3322 __ class_s(f6, f4);
3323 __ swc1(f6, MemOperand(a0, OFFSET_OF(T, fPosInf)));
3324
3325 __ lwc1(f4, MemOperand(a0, OFFSET_OF(T, fPosNorm)));
3326 __ class_s(f6, f4);
3327 __ swc1(f6, MemOperand(a0, OFFSET_OF(T, fPosNorm)));
3328
3329 __ lwc1(f4, MemOperand(a0, OFFSET_OF(T, fPosSubnorm)));
3330 __ class_s(f6, f4);
3331 __ swc1(f6, MemOperand(a0, OFFSET_OF(T, fPosSubnorm)));
3332
3333 __ lwc1(f4, MemOperand(a0, OFFSET_OF(T, fPosZero)));
3334 __ class_s(f6, f4);
3335 __ swc1(f6, MemOperand(a0, OFFSET_OF(T, fPosZero)));
3336
3337 __ jr(ra);
3338 __ nop();
3339
3340 CodeDesc desc;
3341 assm.GetCode(&desc);
3342 Handle<Code> code = isolate->factory()->NewCode(
3343 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
3344 F3 f = FUNCTION_CAST<F3>(code->entry());
3345
3346 t.dSignalingNan = std::numeric_limits<double>::signaling_NaN();
3347 t.dQuietNan = std::numeric_limits<double>::quiet_NaN();
3348 t.dNegInf = -1.0 / 0.0;
3349 t.dNegNorm = -5.0;
3350 t.dNegSubnorm = -DBL_MIN / 2.0;
3351 t.dNegZero = -0.0;
3352 t.dPosInf = 2.0 / 0.0;
3353 t.dPosNorm = 275.35;
3354 t.dPosSubnorm = DBL_MIN / 2.0;
3355 t.dPosZero = +0.0;
3356 // Float test values
3357
3358 t.fSignalingNan = std::numeric_limits<float>::signaling_NaN();
3359 t.fQuietNan = std::numeric_limits<float>::quiet_NaN();
3360 t.fNegInf = -0.5/0.0;
3361 t.fNegNorm = -FLT_MIN;
3362 t.fNegSubnorm = -FLT_MIN / 1.5;
3363 t.fNegZero = -0.0;
3364 t.fPosInf = 100000.0 / 0.0;
3365 t.fPosNorm = FLT_MAX;
3366 t.fPosSubnorm = FLT_MIN / 20.0;
3367 t.fPosZero = +0.0;
3368
3369 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0);
3370 USE(dummy);
3371 // Expected double results.
3372 CHECK_EQ(bit_cast<uint64_t>(t.dSignalingNan), 0x001);
3373 CHECK_EQ(bit_cast<uint64_t>(t.dQuietNan), 0x002);
3374 CHECK_EQ(bit_cast<uint64_t>(t.dNegInf), 0x004);
3375 CHECK_EQ(bit_cast<uint64_t>(t.dNegNorm), 0x008);
3376 CHECK_EQ(bit_cast<uint64_t>(t.dNegSubnorm), 0x010);
3377 CHECK_EQ(bit_cast<uint64_t>(t.dNegZero), 0x020);
3378 CHECK_EQ(bit_cast<uint64_t>(t.dPosInf), 0x040);
3379 CHECK_EQ(bit_cast<uint64_t>(t.dPosNorm), 0x080);
3380 CHECK_EQ(bit_cast<uint64_t>(t.dPosSubnorm), 0x100);
3381 CHECK_EQ(bit_cast<uint64_t>(t.dPosZero), 0x200);
3382
3383 // Expected float results.
3384 CHECK_EQ(bit_cast<uint32_t>(t.fSignalingNan), 0x001);
3385 CHECK_EQ(bit_cast<uint32_t>(t.fQuietNan), 0x002);
3386 CHECK_EQ(bit_cast<uint32_t>(t.fNegInf), 0x004);
3387 CHECK_EQ(bit_cast<uint32_t>(t.fNegNorm), 0x008);
3388 CHECK_EQ(bit_cast<uint32_t>(t.fNegSubnorm), 0x010);
3389 CHECK_EQ(bit_cast<uint32_t>(t.fNegZero), 0x020);
3390 CHECK_EQ(bit_cast<uint32_t>(t.fPosInf), 0x040);
3391 CHECK_EQ(bit_cast<uint32_t>(t.fPosNorm), 0x080);
3392 CHECK_EQ(bit_cast<uint32_t>(t.fPosSubnorm), 0x100);
3393 CHECK_EQ(bit_cast<uint32_t>(t.fPosZero), 0x200);
3394 }
3395 }
3396
3397
3398 TEST(ABS) {
3399 CcTest::InitializeVM();
3400 Isolate* isolate = CcTest::i_isolate();
3401 HandleScope scope(isolate);
3402 MacroAssembler assm(isolate, NULL, 0);
3403
3404 typedef struct test_float {
3405 int64_t fir;
3406 double a;
3407 float b;
3408 double fcsr;
3409 } TestFloat;
3410
3411 TestFloat test;
3412
3413 // Save FIR.
3414 __ cfc1(a1, FCSR);
3415 // Disable FPU exceptions.
3416 __ ctc1(zero_reg, FCSR);
3417
3418 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a)));
3419 __ abs_d(f10, f4);
3420 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, a)));
3421
3422 __ lwc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, b)));
3423 __ abs_s(f10, f4);
3424 __ swc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, b)));
3425
3426 // Restore FCSR.
3427 __ ctc1(a1, FCSR);
3428
3429 __ jr(ra);
3430 __ nop();
3431
3432 CodeDesc desc;
3433 assm.GetCode(&desc);
3434 Handle<Code> code = isolate->factory()->NewCode(
3435 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
3436 F3 f = FUNCTION_CAST<F3>(code->entry());
3437 test.a = -2.0;
3438 test.b = -2.0;
3439 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3440 CHECK_EQ(test.a, 2.0);
3441 CHECK_EQ(test.b, 2.0);
3442
3443 test.a = 2.0;
3444 test.b = 2.0;
3445 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3446 CHECK_EQ(test.a, 2.0);
3447 CHECK_EQ(test.b, 2.0);
3448
3449 // Testing biggest positive number
3450 test.a = std::numeric_limits<double>::max();
3451 test.b = std::numeric_limits<float>::max();
3452 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3453 CHECK_EQ(test.a, std::numeric_limits<double>::max());
3454 CHECK_EQ(test.b, std::numeric_limits<float>::max());
3455
3456 // Testing smallest negative number
3457 test.a = -std::numeric_limits<double>::lowest();
3458 test.b = -std::numeric_limits<float>::lowest();
3459 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3460 CHECK_EQ(test.a, std::numeric_limits<double>::max());
3461 CHECK_EQ(test.b, std::numeric_limits<float>::max());
3462
3463 // Testing smallest positive number
3464 test.a = -std::numeric_limits<double>::min();
3465 test.b = -std::numeric_limits<float>::min();
3466 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3467 CHECK_EQ(test.a, std::numeric_limits<double>::min());
3468 CHECK_EQ(test.b, std::numeric_limits<float>::min());
3469
3470 // Testing infinity
3471 test.a = -std::numeric_limits<double>::max()
3472 / std::numeric_limits<double>::min();
3473 test.b = -std::numeric_limits<float>::max()
3474 / std::numeric_limits<float>::min();
3475 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3476 CHECK_EQ(test.a, std::numeric_limits<double>::max()
3477 / std::numeric_limits<double>::min());
3478 CHECK_EQ(test.b, std::numeric_limits<float>::max()
3479 / std::numeric_limits<float>::min());
3480
3481 test.a = std::numeric_limits<double>::quiet_NaN();
3482 test.b = std::numeric_limits<float>::quiet_NaN();
3483 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3484 CHECK_EQ(std::isnan(test.a), true);
3485 CHECK_EQ(std::isnan(test.b), true);
3486
3487 test.a = std::numeric_limits<double>::signaling_NaN();
3488 test.b = std::numeric_limits<float>::signaling_NaN();
3489 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3490 CHECK_EQ(std::isnan(test.a), true);
3491 CHECK_EQ(std::isnan(test.b), true);
3492 }
3493
3494
3495 TEST(ADD_FMT) {
3496 CcTest::InitializeVM();
3497 Isolate* isolate = CcTest::i_isolate();
3498 HandleScope scope(isolate);
3499 MacroAssembler assm(isolate, NULL, 0);
3500
3501 typedef struct test_float {
3502 double a;
3503 double b;
3504 double c;
3505 float fa;
3506 float fb;
3507 float fc;
3508 } TestFloat;
3509
3510 TestFloat test;
3511
3512 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, a)));
3513 __ ldc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, b)));
3514 __ add_d(f10, f8, f4);
3515 __ sdc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, c)));
3516
3517 __ lwc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, fa)));
3518 __ lwc1(f8, MemOperand(a0, OFFSET_OF(TestFloat, fb)));
3519 __ add_s(f10, f8, f4);
3520 __ swc1(f10, MemOperand(a0, OFFSET_OF(TestFloat, fc)));
3521
3522 __ jr(ra);
3523 __ nop();
3524
3525 CodeDesc desc;
3526 assm.GetCode(&desc);
3527 Handle<Code> code = isolate->factory()->NewCode(
3528 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
3529 F3 f = FUNCTION_CAST<F3>(code->entry());
3530 test.a = 2.0;
3531 test.b = 3.0;
3532 test.fa = 2.0;
3533 test.fb = 3.0;
3534 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3535 CHECK_EQ(test.c, 5.0);
3536 CHECK_EQ(test.fc, 5.0);
3537
3538 test.a = std::numeric_limits<double>::max();
3539 test.b = std::numeric_limits<double>::lowest();
3540 test.fa = std::numeric_limits<float>::max();
3541 test.fb = std::numeric_limits<float>::lowest();
3542 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3543 CHECK_EQ(test.c, 0.0);
3544 CHECK_EQ(test.fc, 0.0);
3545
3546 test.a = std::numeric_limits<double>::max();
3547 test.b = std::numeric_limits<double>::max();
3548 test.fa = std::numeric_limits<float>::max();
3549 test.fb = std::numeric_limits<float>::max();
3550 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3551 CHECK_EQ(std::isfinite(test.c), false);
3552 CHECK_EQ(std::isfinite(test.fc), false);
3553
3554 test.a = 5.0;
3555 test.b = std::numeric_limits<double>::signaling_NaN();
3556 test.fa = 5.0;
3557 test.fb = std::numeric_limits<float>::signaling_NaN();
3558 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3559 CHECK_EQ(std::isnan(test.c), true);
3560 CHECK_EQ(std::isnan(test.fc), true);
3561 }
3562
3563
3564 TEST(C_COND_FMT) {
3565 if ((IsMipsArchVariant(kMips32r1)) || (IsMipsArchVariant(kMips32r2))) {
3566 CcTest::InitializeVM();
3567 Isolate* isolate = CcTest::i_isolate();
3568 HandleScope scope(isolate);
3569 MacroAssembler assm(isolate, NULL, 0);
3570
3571 typedef struct test_float {
3572 double dOp1;
3573 double dOp2;
3574 uint32_t dF;
3575 uint32_t dUn;
3576 uint32_t dEq;
3577 uint32_t dUeq;
3578 uint32_t dOlt;
3579 uint32_t dUlt;
3580 uint32_t dOle;
3581 uint32_t dUle;
3582 float fOp1;
3583 float fOp2;
3584 uint32_t fF;
3585 uint32_t fUn;
3586 uint32_t fEq;
3587 uint32_t fUeq;
3588 uint32_t fOlt;
3589 uint32_t fUlt;
3590 uint32_t fOle;
3591 uint32_t fUle;
3592 } TestFloat;
3593
3594 TestFloat test;
3595
3596 __ li(t1, 1);
3597
3598 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, dOp1)));
3599 __ ldc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, dOp2)));
3600
3601 __ lwc1(f14, MemOperand(a0, OFFSET_OF(TestFloat, fOp1)));
3602 __ lwc1(f16, MemOperand(a0, OFFSET_OF(TestFloat, fOp2)));
3603
3604 __ mov(t2, zero_reg);
3605 __ mov(t3, zero_reg);
3606 __ c_d(F, f4, f6, 0);
3607 __ c_s(F, f14, f16, 2);
3608 __ movt(t2, t1, 0);
3609 __ movt(t3, t1, 2);
3610 __ sw(t2, MemOperand(a0, OFFSET_OF(TestFloat, dF)) );
3611 __ sw(t3, MemOperand(a0, OFFSET_OF(TestFloat, fF)) );
3612
3613 __ mov(t2, zero_reg);
3614 __ mov(t3, zero_reg);
3615 __ c_d(UN, f4, f6, 2);
3616 __ c_s(UN, f14, f16, 4);
3617 __ movt(t2, t1, 2);
3618 __ movt(t3, t1, 4);
3619 __ sw(t2, MemOperand(a0, OFFSET_OF(TestFloat, dUn)) );
3620 __ sw(t3, MemOperand(a0, OFFSET_OF(TestFloat, fUn)) );
3621
3622 __ mov(t2, zero_reg);
3623 __ mov(t3, zero_reg);
3624 __ c_d(EQ, f4, f6, 4);
3625 __ c_s(EQ, f14, f16, 6);
3626 __ movt(t2, t1, 4);
3627 __ movt(t3, t1, 6);
3628 __ sw(t2, MemOperand(a0, OFFSET_OF(TestFloat, dEq)) );
3629 __ sw(t3, MemOperand(a0, OFFSET_OF(TestFloat, fEq)) );
3630
3631 __ mov(t2, zero_reg);
3632 __ mov(t3, zero_reg);
3633 __ c_d(UEQ, f4, f6, 6);
3634 __ c_s(UEQ, f14, f16, 0);
3635 __ movt(t2, t1, 6);
3636 __ movt(t3, t1, 0);
3637 __ sw(t2, MemOperand(a0, OFFSET_OF(TestFloat, dUeq)) );
3638 __ sw(t3, MemOperand(a0, OFFSET_OF(TestFloat, fUeq)) );
3639
3640 __ mov(t2, zero_reg);
3641 __ mov(t3, zero_reg);
3642 __ c_d(OLT, f4, f6, 0);
3643 __ c_s(OLT, f14, f16, 2);
3644 __ movt(t2, t1, 0);
3645 __ movt(t3, t1, 2);
3646 __ sw(t2, MemOperand(a0, OFFSET_OF(TestFloat, dOlt)) );
3647 __ sw(t3, MemOperand(a0, OFFSET_OF(TestFloat, fOlt)) );
3648
3649 __ mov(t2, zero_reg);
3650 __ mov(t3, zero_reg);
3651 __ c_d(ULT, f4, f6, 2);
3652 __ c_s(ULT, f14, f16, 4);
3653 __ movt(t2, t1, 2);
3654 __ movt(t3, t1, 4);
3655 __ sw(t2, MemOperand(a0, OFFSET_OF(TestFloat, dUlt)) );
3656 __ sw(t3, MemOperand(a0, OFFSET_OF(TestFloat, fUlt)) );
3657
3658 __ mov(t2, zero_reg);
3659 __ mov(t3, zero_reg);
3660 __ c_d(OLE, f4, f6, 4);
3661 __ c_s(OLE, f14, f16, 6);
3662 __ movt(t2, t1, 4);
3663 __ movt(t3, t1, 6);
3664 __ sw(t2, MemOperand(a0, OFFSET_OF(TestFloat, dOle)) );
3665 __ sw(t3, MemOperand(a0, OFFSET_OF(TestFloat, fOle)) );
3666
3667 __ mov(t2, zero_reg);
3668 __ mov(t3, zero_reg);
3669 __ c_d(ULE, f4, f6, 6);
3670 __ c_s(ULE, f14, f16, 0);
3671 __ movt(t2, t1, 6);
3672 __ movt(t3, t1, 0);
3673 __ sw(t2, MemOperand(a0, OFFSET_OF(TestFloat, dUle)) );
3674 __ sw(t3, MemOperand(a0, OFFSET_OF(TestFloat, fUle)) );
3675
3676 __ jr(ra);
3677 __ nop();
3678
3679 CodeDesc desc;
3680 assm.GetCode(&desc);
3681 Handle<Code> code = isolate->factory()->NewCode(
3682 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
3683 F3 f = FUNCTION_CAST<F3>(code->entry());
3684 test.dOp1 = 2.0;
3685 test.dOp2 = 3.0;
3686 test.fOp1 = 2.0;
3687 test.fOp2 = 3.0;
3688 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3689 CHECK_EQ(test.dF, 0);
3690 CHECK_EQ(test.dUn, 0);
3691 CHECK_EQ(test.dEq, 0);
3692 CHECK_EQ(test.dUeq, 0);
3693 CHECK_EQ(test.dOlt, 1);
3694 CHECK_EQ(test.dUlt, 1);
3695 CHECK_EQ(test.dOle, 1);
3696 CHECK_EQ(test.dUle, 1);
3697 CHECK_EQ(test.fF, 0);
3698 CHECK_EQ(test.fUn, 0);
3699 CHECK_EQ(test.fEq, 0);
3700 CHECK_EQ(test.fUeq, 0);
3701 CHECK_EQ(test.fOlt, 1);
3702 CHECK_EQ(test.fUlt, 1);
3703 CHECK_EQ(test.fOle, 1);
3704 CHECK_EQ(test.fUle, 1);
3705
3706 test.dOp1 = std::numeric_limits<double>::max();
3707 test.dOp2 = std::numeric_limits<double>::min();
3708 test.fOp1 = std::numeric_limits<float>::min();
3709 test.fOp2 = std::numeric_limits<float>::lowest();
3710 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3711 CHECK_EQ(test.dF, 0);
3712 CHECK_EQ(test.dUn, 0);
3713 CHECK_EQ(test.dEq, 0);
3714 CHECK_EQ(test.dUeq, 0);
3715 CHECK_EQ(test.dOlt, 0);
3716 CHECK_EQ(test.dUlt, 0);
3717 CHECK_EQ(test.dOle, 0);
3718 CHECK_EQ(test.dUle, 0);
3719 CHECK_EQ(test.fF, 0);
3720 CHECK_EQ(test.fUn, 0);
3721 CHECK_EQ(test.fEq, 0);
3722 CHECK_EQ(test.fUeq, 0);
3723 CHECK_EQ(test.fOlt, 0);
3724 CHECK_EQ(test.fUlt, 0);
3725 CHECK_EQ(test.fOle, 0);
3726 CHECK_EQ(test.fUle, 0);
3727
3728 test.dOp1 = std::numeric_limits<double>::lowest();
3729 test.dOp2 = std::numeric_limits<double>::lowest();
3730 test.fOp1 = std::numeric_limits<float>::max();
3731 test.fOp2 = std::numeric_limits<float>::max();
3732 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3733 CHECK_EQ(test.dF, 0);
3734 CHECK_EQ(test.dUn, 0);
3735 CHECK_EQ(test.dEq, 1);
3736 CHECK_EQ(test.dUeq, 1);
3737 CHECK_EQ(test.dOlt, 0);
3738 CHECK_EQ(test.dUlt, 0);
3739 CHECK_EQ(test.dOle, 1);
3740 CHECK_EQ(test.dUle, 1);
3741 CHECK_EQ(test.fF, 0);
3742 CHECK_EQ(test.fUn, 0);
3743 CHECK_EQ(test.fEq, 1);
3744 CHECK_EQ(test.fUeq, 1);
3745 CHECK_EQ(test.fOlt, 0);
3746 CHECK_EQ(test.fUlt, 0);
3747 CHECK_EQ(test.fOle, 1);
3748 CHECK_EQ(test.fUle, 1);
3749
3750 test.dOp1 = std::numeric_limits<double>::quiet_NaN();
3751 test.dOp2 = 0.0;
3752 test.fOp1 = std::numeric_limits<float>::quiet_NaN();
3753 test.fOp2 = 0.0;
3754 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3755 CHECK_EQ(test.dF, 0);
3756 CHECK_EQ(test.dUn, 1);
3757 CHECK_EQ(test.dEq, 0);
3758 CHECK_EQ(test.dUeq, 1);
3759 CHECK_EQ(test.dOlt, 0);
3760 CHECK_EQ(test.dUlt, 1);
3761 CHECK_EQ(test.dOle, 0);
3762 CHECK_EQ(test.dUle, 1);
3763 CHECK_EQ(test.fF, 0);
3764 CHECK_EQ(test.fUn, 1);
3765 CHECK_EQ(test.fEq, 0);
3766 CHECK_EQ(test.fUeq, 1);
3767 CHECK_EQ(test.fOlt, 0);
3768 CHECK_EQ(test.fUlt, 1);
3769 CHECK_EQ(test.fOle, 0);
3770 CHECK_EQ(test.fUle, 1);
3771 }
3772 }
3773
3774
3775 TEST(CMP_COND_FMT) {
3776 if (IsMipsArchVariant(kMips32r6)) {
3777 CcTest::InitializeVM();
3778 Isolate* isolate = CcTest::i_isolate();
3779 HandleScope scope(isolate);
3780 MacroAssembler assm(isolate, NULL, 0);
3781
3782 typedef struct test_float {
3783 double dOp1;
3784 double dOp2;
3785 double dF;
3786 double dUn;
3787 double dEq;
3788 double dUeq;
3789 double dOlt;
3790 double dUlt;
3791 double dOle;
3792 double dUle;
3793 double dOr;
3794 double dUne;
3795 double dNe;
3796 float fOp1;
3797 float fOp2;
3798 float fF;
3799 float fUn;
3800 float fEq;
3801 float fUeq;
3802 float fOlt;
3803 float fUlt;
3804 float fOle;
3805 float fUle;
3806 float fOr;
3807 float fUne;
3808 float fNe;
3809 } TestFloat;
3810
3811 TestFloat test;
3812
3813 __ li(t1, 1);
3814
3815 __ ldc1(f4, MemOperand(a0, OFFSET_OF(TestFloat, dOp1)));
3816 __ ldc1(f6, MemOperand(a0, OFFSET_OF(TestFloat, dOp2)));
3817
3818 __ lwc1(f14, MemOperand(a0, OFFSET_OF(TestFloat, fOp1)));
3819 __ lwc1(f16, MemOperand(a0, OFFSET_OF(TestFloat, fOp2)));
3820
3821 __ cmp_d(F, f2, f4, f6);
3822 __ cmp_s(F, f12, f14, f16);
3823 __ sdc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, dF)) );
3824 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, fF)) );
3825
3826 __ cmp_d(UN, f2, f4, f6);
3827 __ cmp_s(UN, f12, f14, f16);
3828 __ sdc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, dUn)) );
3829 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, fUn)) );
3830
3831 __ cmp_d(EQ, f2, f4, f6);
3832 __ cmp_s(EQ, f12, f14, f16);
3833 __ sdc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, dEq)) );
3834 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, fEq)) );
3835
3836 __ cmp_d(UEQ, f2, f4, f6);
3837 __ cmp_s(UEQ, f12, f14, f16);
3838 __ sdc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, dUeq)) );
3839 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, fUeq)) );
3840
3841 __ cmp_d(LT, f2, f4, f6);
3842 __ cmp_s(LT, f12, f14, f16);
3843 __ sdc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, dOlt)) );
3844 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, fOlt)) );
3845
3846 __ cmp_d(ULT, f2, f4, f6);
3847 __ cmp_s(ULT, f12, f14, f16);
3848 __ sdc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, dUlt)) );
3849 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, fUlt)) );
3850
3851 __ cmp_d(LE, f2, f4, f6);
3852 __ cmp_s(LE, f12, f14, f16);
3853 __ sdc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, dOle)) );
3854 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, fOle)) );
3855
3856 __ cmp_d(ULE, f2, f4, f6);
3857 __ cmp_s(ULE, f12, f14, f16);
3858 __ sdc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, dUle)) );
3859 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, fUle)) );
3860
3861 __ cmp_d(ORD, f2, f4, f6);
3862 __ cmp_s(ORD, f12, f14, f16);
3863 __ sdc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, dOr)) );
3864 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, fOr)) );
3865
3866 __ cmp_d(UNE, f2, f4, f6);
3867 __ cmp_s(UNE, f12, f14, f16);
3868 __ sdc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, dUne)) );
3869 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, fUne)) );
3870
3871 __ cmp_d(NE, f2, f4, f6);
3872 __ cmp_s(NE, f12, f14, f16);
3873 __ sdc1(f2, MemOperand(a0, OFFSET_OF(TestFloat, dNe)) );
3874 __ swc1(f12, MemOperand(a0, OFFSET_OF(TestFloat, fNe)) );
3875
3876 __ jr(ra);
3877 __ nop();
3878
3879 CodeDesc desc;
3880 assm.GetCode(&desc);
3881 Handle<Code> code = isolate->factory()->NewCode(
3882 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
3883 F3 f = FUNCTION_CAST<F3>(code->entry());
3884 uint64_t dTrue = 0xFFFFFFFFFFFFFFFF;
3885 uint64_t dFalse = 0x0000000000000000;
3886 uint32_t fTrue = 0xFFFFFFFF;
3887 uint32_t fFalse = 0x00000000;
3888
3889 test.dOp1 = 2.0;
3890 test.dOp2 = 3.0;
3891 test.fOp1 = 2.0;
3892 test.fOp2 = 3.0;
3893 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3894 CHECK_EQ(bit_cast<uint64_t>(test.dF), dFalse);
3895 CHECK_EQ(bit_cast<uint64_t>(test.dUn), dFalse);
3896 CHECK_EQ(bit_cast<uint64_t>(test.dEq), dFalse);
3897 CHECK_EQ(bit_cast<uint64_t>(test.dUeq), dFalse);
3898 CHECK_EQ(bit_cast<uint64_t>(test.dOlt), dTrue);
3899 CHECK_EQ(bit_cast<uint64_t>(test.dUlt), dTrue);
3900 CHECK_EQ(bit_cast<uint64_t>(test.dOle), dTrue);
3901 CHECK_EQ(bit_cast<uint64_t>(test.dUle), dTrue);
3902 CHECK_EQ(bit_cast<uint64_t>(test.dOr), dTrue);
3903 CHECK_EQ(bit_cast<uint64_t>(test.dUne), dTrue);
3904 CHECK_EQ(bit_cast<uint64_t>(test.dNe), dTrue);
3905 CHECK_EQ(bit_cast<uint32_t>(test.fF), fFalse);
3906 CHECK_EQ(bit_cast<uint32_t>(test.fUn), fFalse);
3907 CHECK_EQ(bit_cast<uint32_t>(test.fEq), fFalse);
3908 CHECK_EQ(bit_cast<uint32_t>(test.fUeq), fFalse);
3909 CHECK_EQ(bit_cast<uint32_t>(test.fOlt), fTrue);
3910 CHECK_EQ(bit_cast<uint32_t>(test.fUlt), fTrue);
3911 CHECK_EQ(bit_cast<uint32_t>(test.fOle), fTrue);
3912 CHECK_EQ(bit_cast<uint32_t>(test.fUle), fTrue);
3913
3914 test.dOp1 = std::numeric_limits<double>::max();
3915 test.dOp2 = std::numeric_limits<double>::min();
3916 test.fOp1 = std::numeric_limits<float>::min();
3917 test.fOp2 = std::numeric_limits<float>::lowest();
3918 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3919 CHECK_EQ(bit_cast<uint64_t>(test.dF), dFalse);
3920 CHECK_EQ(bit_cast<uint64_t>(test.dUn), dFalse);
3921 CHECK_EQ(bit_cast<uint64_t>(test.dEq), dFalse);
3922 CHECK_EQ(bit_cast<uint64_t>(test.dUeq), dFalse);
3923 CHECK_EQ(bit_cast<uint64_t>(test.dOlt), dFalse);
3924 CHECK_EQ(bit_cast<uint64_t>(test.dUlt), dFalse);
3925 CHECK_EQ(bit_cast<uint64_t>(test.dOle), dFalse);
3926 CHECK_EQ(bit_cast<uint64_t>(test.dUle), dFalse);
3927 CHECK_EQ(bit_cast<uint64_t>(test.dOr), dTrue);
3928 CHECK_EQ(bit_cast<uint64_t>(test.dUne), dTrue);
3929 CHECK_EQ(bit_cast<uint64_t>(test.dNe), dTrue);
3930 CHECK_EQ(bit_cast<uint32_t>(test.fF), fFalse);
3931 CHECK_EQ(bit_cast<uint32_t>(test.fUn), fFalse);
3932 CHECK_EQ(bit_cast<uint32_t>(test.fEq), fFalse);
3933 CHECK_EQ(bit_cast<uint32_t>(test.fUeq), fFalse);
3934 CHECK_EQ(bit_cast<uint32_t>(test.fOlt), fFalse);
3935 CHECK_EQ(bit_cast<uint32_t>(test.fUlt), fFalse);
3936 CHECK_EQ(bit_cast<uint32_t>(test.fOle), fFalse);
3937 CHECK_EQ(bit_cast<uint32_t>(test.fUle), fFalse);
3938
3939 test.dOp1 = std::numeric_limits<double>::lowest();
3940 test.dOp2 = std::numeric_limits<double>::lowest();
3941 test.fOp1 = std::numeric_limits<float>::max();
3942 test.fOp2 = std::numeric_limits<float>::max();
3943 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3944 CHECK_EQ(bit_cast<uint64_t>(test.dF), dFalse);
3945 CHECK_EQ(bit_cast<uint64_t>(test.dUn), dFalse);
3946 CHECK_EQ(bit_cast<uint64_t>(test.dEq), dTrue);
3947 CHECK_EQ(bit_cast<uint64_t>(test.dUeq), dTrue);
3948 CHECK_EQ(bit_cast<uint64_t>(test.dOlt), dFalse);
3949 CHECK_EQ(bit_cast<uint64_t>(test.dUlt), dFalse);
3950 CHECK_EQ(bit_cast<uint64_t>(test.dOle), dTrue);
3951 CHECK_EQ(bit_cast<uint64_t>(test.dUle), dTrue);
3952 CHECK_EQ(bit_cast<uint64_t>(test.dOr), dTrue);
3953 CHECK_EQ(bit_cast<uint64_t>(test.dUne), dFalse);
3954 CHECK_EQ(bit_cast<uint64_t>(test.dNe), dFalse);
3955 CHECK_EQ(bit_cast<uint32_t>(test.fF), fFalse);
3956 CHECK_EQ(bit_cast<uint32_t>(test.fUn), fFalse);
3957 CHECK_EQ(bit_cast<uint32_t>(test.fEq), fTrue);
3958 CHECK_EQ(bit_cast<uint32_t>(test.fUeq), fTrue);
3959 CHECK_EQ(bit_cast<uint32_t>(test.fOlt), fFalse);
3960 CHECK_EQ(bit_cast<uint32_t>(test.fUlt), fFalse);
3961 CHECK_EQ(bit_cast<uint32_t>(test.fOle), fTrue);
3962 CHECK_EQ(bit_cast<uint32_t>(test.fUle), fTrue);
3963
3964 test.dOp1 = std::numeric_limits<double>::quiet_NaN();
3965 test.dOp2 = 0.0;
3966 test.fOp1 = std::numeric_limits<float>::quiet_NaN();
3967 test.fOp2 = 0.0;
3968 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
3969 CHECK_EQ(bit_cast<uint64_t>(test.dF), dFalse);
3970 CHECK_EQ(bit_cast<uint64_t>(test.dUn), dTrue);
3971 CHECK_EQ(bit_cast<uint64_t>(test.dEq), dFalse);
3972 CHECK_EQ(bit_cast<uint64_t>(test.dUeq), dTrue);
3973 CHECK_EQ(bit_cast<uint64_t>(test.dOlt), dFalse);
3974 CHECK_EQ(bit_cast<uint64_t>(test.dUlt), dTrue);
3975 CHECK_EQ(bit_cast<uint64_t>(test.dOle), dFalse);
3976 CHECK_EQ(bit_cast<uint64_t>(test.dUle), dTrue);
3977 CHECK_EQ(bit_cast<uint64_t>(test.dOr), dFalse);
3978 CHECK_EQ(bit_cast<uint64_t>(test.dUne), dTrue);
3979 CHECK_EQ(bit_cast<uint64_t>(test.dNe), dFalse);
3980 CHECK_EQ(bit_cast<uint32_t>(test.fF), fFalse);
3981 CHECK_EQ(bit_cast<uint32_t>(test.fUn), fTrue);
3982 CHECK_EQ(bit_cast<uint32_t>(test.fEq), fFalse);
3983 CHECK_EQ(bit_cast<uint32_t>(test.fUeq), fTrue);
3984 CHECK_EQ(bit_cast<uint32_t>(test.fOlt), fFalse);
3985 CHECK_EQ(bit_cast<uint32_t>(test.fUlt), fTrue);
3986 CHECK_EQ(bit_cast<uint32_t>(test.fOle), fFalse);
3987 CHECK_EQ(bit_cast<uint32_t>(test.fUle), fTrue);
3988 }
3989 }
3990
3991
3992 TEST(CVT) {
3993 CcTest::InitializeVM();
3994 Isolate* isolate = CcTest::i_isolate();
3995 HandleScope scope(isolate);
3996 MacroAssembler assm(isolate, NULL, 0);
3997
3998 typedef struct test_float {
3999 float cvt_d_s_in;
4000 double cvt_d_s_out;
4001 int32_t cvt_d_w_in;
4002 double cvt_d_w_out;
4003 int64_t cvt_d_l_in;
4004 double cvt_d_l_out;
4005
4006 float cvt_l_s_in;
4007 int64_t cvt_l_s_out;
4008 double cvt_l_d_in;
4009 int64_t cvt_l_d_out;
4010
4011 double cvt_s_d_in;
4012 float cvt_s_d_out;
4013 int32_t cvt_s_w_in;
4014 float cvt_s_w_out;
4015 int64_t cvt_s_l_in;
4016 float cvt_s_l_out;
4017
4018 float cvt_w_s_in;
4019 int32_t cvt_w_s_out;
4020 double cvt_w_d_in;
4021 int32_t cvt_w_d_out;
4022 } TestFloat;
4023
4024 TestFloat test;
4025
4026 // Save FCSR.
4027 __ cfc1(a1, FCSR);
4028 // Disable FPU exceptions.
4029 __ ctc1(zero_reg, FCSR);
4030
4031 #define GENERATE_CVT_TEST(x, y, z) \
4032 __ y##c1(f0, MemOperand(a0, OFFSET_OF(TestFloat, x##_in))); \
4033 __ x(f0, f0); \
4034 __ nop(); \
4035 __ z##c1(f0, MemOperand(a0, OFFSET_OF(TestFloat, x##_out)));
4036
4037 GENERATE_CVT_TEST(cvt_d_s, lw, sd)
4038 GENERATE_CVT_TEST(cvt_d_w, lw, sd)
4039 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
4040 GENERATE_CVT_TEST(cvt_d_l, ld, sd)
4041 }
4042
4043 if (IsFp64Mode()) {
4044 GENERATE_CVT_TEST(cvt_l_s, lw, sd)
4045 GENERATE_CVT_TEST(cvt_l_d, ld, sd)
4046 }
4047
4048 GENERATE_CVT_TEST(cvt_s_d, ld, sw)
4049 GENERATE_CVT_TEST(cvt_s_w, lw, sw)
4050 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
4051 GENERATE_CVT_TEST(cvt_s_l, ld, sw)
4052 }
4053
4054 GENERATE_CVT_TEST(cvt_w_s, lw, sw)
4055 GENERATE_CVT_TEST(cvt_w_d, ld, sw)
4056
4057 // Restore FCSR.
4058 __ ctc1(a1, FCSR);
4059
4060 __ jr(ra);
4061 __ nop();
4062
4063 CodeDesc desc;
4064 assm.GetCode(&desc);
4065 Handle<Code> code = isolate->factory()->NewCode(
4066 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
4067 F3 f = FUNCTION_CAST<F3>(code->entry());
4068
4069 test.cvt_d_s_in = -0.51;
4070 test.cvt_d_w_in = -1;
4071 test.cvt_d_l_in = -1;
4072 test.cvt_l_s_in = -0.51;
4073 test.cvt_l_d_in = -0.51;
4074 test.cvt_s_d_in = -0.51;
4075 test.cvt_s_w_in = -1;
4076 test.cvt_s_l_in = -1;
4077 test.cvt_w_s_in = -0.51;
4078 test.cvt_w_d_in = -0.51;
4079
4080 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
4081 CHECK_EQ(test.cvt_d_s_out, static_cast<double>(test.cvt_d_s_in));
4082 CHECK_EQ(test.cvt_d_w_out, static_cast<double>(test.cvt_d_w_in));
4083 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
4084 CHECK_EQ(test.cvt_d_l_out, static_cast<double>(test.cvt_d_l_in));
4085 }
4086 if (IsFp64Mode()) {
4087 CHECK_EQ(test.cvt_l_s_out, -1);
4088 CHECK_EQ(test.cvt_l_d_out, -1);
4089 }
4090 CHECK_EQ(test.cvt_s_d_out, static_cast<float>(test.cvt_s_d_in));
4091 CHECK_EQ(test.cvt_s_w_out, static_cast<float>(test.cvt_s_w_in));
4092 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
4093 CHECK_EQ(test.cvt_s_l_out, static_cast<float>(test.cvt_s_l_in));
4094 }
4095 CHECK_EQ(test.cvt_w_s_out, -1);
4096 CHECK_EQ(test.cvt_w_d_out, -1);
4097
4098
4099 test.cvt_d_s_in = 0.49;
4100 test.cvt_d_w_in = 1;
4101 test.cvt_d_l_in = 1;
4102 test.cvt_l_s_in = 0.49;
4103 test.cvt_l_d_in = 0.49;
4104 test.cvt_s_d_in = 0.49;
4105 test.cvt_s_w_in = 1;
4106 test.cvt_s_l_in = 1;
4107 test.cvt_w_s_in = 0.49;
4108 test.cvt_w_d_in = 0.49;
4109
4110 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
4111 CHECK_EQ(test.cvt_d_s_out, static_cast<double>(test.cvt_d_s_in));
4112 CHECK_EQ(test.cvt_d_w_out, static_cast<double>(test.cvt_d_w_in));
4113 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
4114 CHECK_EQ(test.cvt_d_l_out, static_cast<double>(test.cvt_d_l_in));
4115 }
4116 if (IsFp64Mode()) {
4117 CHECK_EQ(test.cvt_l_s_out, 0);
4118 CHECK_EQ(test.cvt_l_d_out, 0);
4119 }
4120 CHECK_EQ(test.cvt_s_d_out, static_cast<float>(test.cvt_s_d_in));
4121 CHECK_EQ(test.cvt_s_w_out, static_cast<float>(test.cvt_s_w_in));
4122 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
4123 CHECK_EQ(test.cvt_s_l_out, static_cast<float>(test.cvt_s_l_in));
4124 }
4125 CHECK_EQ(test.cvt_w_s_out, 0);
4126 CHECK_EQ(test.cvt_w_d_out, 0);
4127
4128 test.cvt_d_s_in = std::numeric_limits<float>::max();
4129 test.cvt_d_w_in = std::numeric_limits<int32_t>::max();
4130 test.cvt_d_l_in = std::numeric_limits<int64_t>::max();
4131 test.cvt_l_s_in = std::numeric_limits<float>::max();
4132 test.cvt_l_d_in = std::numeric_limits<double>::max();
4133 test.cvt_s_d_in = std::numeric_limits<double>::max();
4134 test.cvt_s_w_in = std::numeric_limits<int32_t>::max();
4135 test.cvt_s_l_in = std::numeric_limits<int64_t>::max();
4136 test.cvt_w_s_in = std::numeric_limits<float>::max();
4137 test.cvt_w_d_in = std::numeric_limits<double>::max();
4138
4139 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
4140 CHECK_EQ(test.cvt_d_s_out, static_cast<double>(test.cvt_d_s_in));
4141 CHECK_EQ(test.cvt_d_w_out, static_cast<double>(test.cvt_d_w_in));
4142 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
4143 CHECK_EQ(test.cvt_d_l_out, static_cast<double>(test.cvt_d_l_in));
4144 }
4145 if (IsFp64Mode()) {
4146 CHECK_EQ(test.cvt_l_s_out, std::numeric_limits<int64_t>::max());
4147 CHECK_EQ(test.cvt_l_d_out, std::numeric_limits<int64_t>::max());
4148 }
4149 CHECK_EQ(test.cvt_s_d_out, static_cast<float>(test.cvt_s_d_in));
4150 CHECK_EQ(test.cvt_s_w_out, static_cast<float>(test.cvt_s_w_in));
4151 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
4152 CHECK_EQ(test.cvt_s_l_out, static_cast<float>(test.cvt_s_l_in));
4153 }
4154 CHECK_EQ(test.cvt_w_s_out, std::numeric_limits<int32_t>::max());
4155 CHECK_EQ(test.cvt_w_d_out, std::numeric_limits<int32_t>::max());
4156
4157
4158 test.cvt_d_s_in = std::numeric_limits<float>::lowest();
4159 test.cvt_d_w_in = std::numeric_limits<int32_t>::lowest();
4160 test.cvt_d_l_in = std::numeric_limits<int64_t>::lowest();
4161 test.cvt_l_s_in = std::numeric_limits<float>::lowest();
4162 test.cvt_l_d_in = std::numeric_limits<double>::lowest();
4163 test.cvt_s_d_in = std::numeric_limits<double>::lowest();
4164 test.cvt_s_w_in = std::numeric_limits<int32_t>::lowest();
4165 test.cvt_s_l_in = std::numeric_limits<int64_t>::lowest();
4166 test.cvt_w_s_in = std::numeric_limits<float>::lowest();
4167 test.cvt_w_d_in = std::numeric_limits<double>::lowest();
4168
4169 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
4170 CHECK_EQ(test.cvt_d_s_out, static_cast<double>(test.cvt_d_s_in));
4171 CHECK_EQ(test.cvt_d_w_out, static_cast<double>(test.cvt_d_w_in));
4172 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
4173 CHECK_EQ(test.cvt_d_l_out, static_cast<double>(test.cvt_d_l_in));
4174 }
4175 // The returned value when converting from fixed-point to float-point
4176 // is not consistent between board, simulator and specification
4177 // in this test case, therefore modifying the test
4178 if (IsFp64Mode()) {
4179 CHECK(test.cvt_l_s_out == std::numeric_limits<int64_t>::min() ||
4180 test.cvt_l_s_out == std::numeric_limits<int64_t>::max());
4181 CHECK(test.cvt_l_d_out == std::numeric_limits<int64_t>::min() ||
4182 test.cvt_l_d_out == std::numeric_limits<int64_t>::max());
4183 }
4184 CHECK_EQ(test.cvt_s_d_out, static_cast<float>(test.cvt_s_d_in));
4185 CHECK_EQ(test.cvt_s_w_out, static_cast<float>(test.cvt_s_w_in));
4186 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
4187 CHECK_EQ(test.cvt_s_l_out, static_cast<float>(test.cvt_s_l_in));
4188 }
4189 CHECK(test.cvt_w_s_out == std::numeric_limits<int32_t>::min() ||
4190 test.cvt_w_s_out == std::numeric_limits<int32_t>::max());
4191 CHECK(test.cvt_w_d_out == std::numeric_limits<int32_t>::min() ||
4192 test.cvt_w_d_out == std::numeric_limits<int32_t>::max());
4193
4194
4195 test.cvt_d_s_in = std::numeric_limits<float>::min();
4196 test.cvt_d_w_in = std::numeric_limits<int32_t>::min();
4197 test.cvt_d_l_in = std::numeric_limits<int64_t>::min();
4198 test.cvt_l_s_in = std::numeric_limits<float>::min();
4199 test.cvt_l_d_in = std::numeric_limits<double>::min();
4200 test.cvt_s_d_in = std::numeric_limits<double>::min();
4201 test.cvt_s_w_in = std::numeric_limits<int32_t>::min();
4202 test.cvt_s_l_in = std::numeric_limits<int64_t>::min();
4203 test.cvt_w_s_in = std::numeric_limits<float>::min();
4204 test.cvt_w_d_in = std::numeric_limits<double>::min();
4205
4206 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
4207 CHECK_EQ(test.cvt_d_s_out, static_cast<double>(test.cvt_d_s_in));
4208 CHECK_EQ(test.cvt_d_w_out, static_cast<double>(test.cvt_d_w_in));
4209 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
4210 CHECK_EQ(test.cvt_d_l_out, static_cast<double>(test.cvt_d_l_in));
4211 }
4212 if (IsFp64Mode()) {
4213 CHECK_EQ(test.cvt_l_s_out, 0);
4214 CHECK_EQ(test.cvt_l_d_out, 0);
4215 }
4216 CHECK_EQ(test.cvt_s_d_out, static_cast<float>(test.cvt_s_d_in));
4217 CHECK_EQ(test.cvt_s_w_out, static_cast<float>(test.cvt_s_w_in));
4218 if (IsMipsArchVariant(kMips32r2) || IsMipsArchVariant(kMips32r6)) {
4219 CHECK_EQ(test.cvt_s_l_out, static_cast<float>(test.cvt_s_l_in));
4220 }
4221 CHECK_EQ(test.cvt_w_s_out, 0);
4222 CHECK_EQ(test.cvt_w_d_out, 0);
4223 }
4224
4225
4226 TEST(DIV_FMT) {
4227 CcTest::InitializeVM();
4228 Isolate* isolate = CcTest::i_isolate();
4229 HandleScope scope(isolate);
4230 MacroAssembler assm(isolate, NULL, 0);
4231
4232 typedef struct test {
4233 double dOp1;
4234 double dOp2;
4235 double dRes;
4236 float fOp1;
4237 float fOp2;
4238 float fRes;
4239 } Test;
4240
4241 Test test;
4242
4243 // Save FCSR.
4244 __ cfc1(a1, FCSR);
4245 // Disable FPU exceptions.
4246 __ ctc1(zero_reg, FCSR);
4247
4248 __ ldc1(f4, MemOperand(a0, OFFSET_OF(Test, dOp1)) );
4249 __ ldc1(f2, MemOperand(a0, OFFSET_OF(Test, dOp2)) );
4250 __ nop();
4251 __ div_d(f6, f4, f2);
4252 __ sdc1(f6, MemOperand(a0, OFFSET_OF(Test, dRes)) );
4253
4254 __ lwc1(f4, MemOperand(a0, OFFSET_OF(Test, fOp1)) );
4255 __ lwc1(f2, MemOperand(a0, OFFSET_OF(Test, fOp2)) );
4256 __ nop();
4257 __ div_s(f6, f4, f2);
4258 __ swc1(f6, MemOperand(a0, OFFSET_OF(Test, fRes)) );
4259
4260 // Restore FCSR.
4261 __ ctc1(a1, FCSR);
4262
4263 __ jr(ra);
4264 __ nop();
4265 CodeDesc desc;
4266 assm.GetCode(&desc);
4267 Handle<Code> code = isolate->factory()->NewCode(
4268 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
4269 F3 f = FUNCTION_CAST<F3>(code->entry());
4270
4271 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
4272
4273 const int test_size = 3;
4274
4275 double dOp1[test_size] = {
4276 5.0,
4277 DBL_MAX,
4278 DBL_MAX,
4279 };
4280 double dOp2[test_size] = {
4281 2.0,
4282 2.0,
4283 -DBL_MAX,
4284 };
4285 double dRes[test_size] = {
4286 2.5,
4287 DBL_MAX / 2.0,
4288 -1.0,
4289 };
4290 float fOp1[test_size] = {
4291 5.0,
4292 FLT_MAX,
4293 FLT_MAX,
4294 };
4295 float fOp2[test_size] = {
4296 2.0,
4297 2.0,
4298 -FLT_MAX,
4299 };
4300 float fRes[test_size] = {
4301 2.5,
4302 FLT_MAX / 2.0,
4303 -1.0,
4304 };
4305
4306 for (int i = 0; i < test_size; i++) {
4307 test.dOp1 = dOp1[i];
4308 test.dOp2 = dOp2[i];
4309 test.fOp1 = fOp1[i];
4310 test.fOp2 = fOp2[i];
4311
4312 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
4313 CHECK_EQ(test.dRes, dRes[i]);
4314 CHECK_EQ(test.fRes, fRes[i]);
4315 }
4316
4317 test.dOp1 = DBL_MAX;
4318 test.dOp2 = -0.0;
4319 test.fOp1 = FLT_MAX;
4320 test.fOp2 = -0.0;
4321
4322 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
4323 CHECK_EQ(false, std::isfinite(test.dRes));
4324 CHECK_EQ(false, std::isfinite(test.fRes));
4325
4326 test.dOp1 = 0.0;
4327 test.dOp2 = -0.0;
4328 test.fOp1 = 0.0;
4329 test.fOp2 = -0.0;
4330
4331 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
4332 CHECK_EQ(true, std::isnan(test.dRes));
4333 CHECK_EQ(true, std::isnan(test.fRes));
4334
4335 test.dOp1 = std::numeric_limits<double>::quiet_NaN();
4336 test.dOp2 = -5.0;
4337 test.fOp1 = std::numeric_limits<float>::quiet_NaN();
4338 test.fOp2 = -5.0;
4339
4340 (CALL_GENERATED_CODE(f, &test, 0, 0, 0, 0));
4341 CHECK_EQ(true, std::isnan(test.dRes));
4342 CHECK_EQ(true, std::isnan(test.fRes));
4343 }
4344
4345
3184 #undef __ 4346 #undef __
OLDNEW
« no previous file with comments | « src/mips64/simulator-mips64.cc ('k') | test/cctest/test-assembler-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698