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 27 matching lines...) Expand all Loading... |
38 #include "test/cctest/cctest.h" | 38 #include "test/cctest/cctest.h" |
39 | 39 |
40 using namespace v8::internal; | 40 using namespace v8::internal; |
41 | 41 |
42 | 42 |
43 // Define these function prototypes to match JSEntryFunction in execution.cc. | 43 // Define these function prototypes to match JSEntryFunction in execution.cc. |
44 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); | 44 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); |
45 typedef Object* (*F2)(int x, int y, int p2, int p3, int p4); | 45 typedef Object* (*F2)(int x, int y, int p2, int p3, int p4); |
46 typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4); | 46 typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4); |
47 | 47 |
| 48 // clang-format off |
| 49 |
48 | 50 |
49 #define __ assm. | 51 #define __ assm. |
50 | 52 |
51 TEST(MIPS17) { | 53 TEST(MIPS17) { |
52 if (kArchVariant == kMips64r6) { | 54 if (kArchVariant == kMips64r6) { |
53 CcTest::InitializeVM(); | 55 CcTest::InitializeVM(); |
54 Isolate* isolate = CcTest::i_isolate(); | 56 Isolate* isolate = CcTest::i_isolate(); |
55 HandleScope scope(isolate); | 57 HandleScope scope(isolate); |
56 MacroAssembler assm(isolate, NULL, 0); | 58 MacroAssembler assm(isolate, NULL, 0); |
57 | 59 |
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 typedef struct { | 332 typedef struct { |
331 double a; | 333 double a; |
332 double b; | 334 double b; |
333 double c; | 335 double c; |
334 double d; | 336 double d; |
335 double e; | 337 double e; |
336 double f; | 338 double f; |
337 double g; | 339 double g; |
338 double h; | 340 double h; |
339 double i; | 341 double i; |
| 342 float fa; |
| 343 float fb; |
| 344 float fc; |
| 345 float fd; |
| 346 float fe; |
| 347 float ff; |
| 348 float fg; |
340 } T; | 349 } T; |
341 T t; | 350 T t; |
342 | 351 |
343 // Create a function that accepts &t, and loads, manipulates, and stores | 352 // Create a function that accepts &t, and loads, manipulates, and stores |
344 // the doubles t.a ... t.f. | 353 // the doubles t.a ... t.f. |
345 MacroAssembler assm(isolate, NULL, 0); | 354 MacroAssembler assm(isolate, NULL, 0); |
346 Label L, C; | 355 Label L, C; |
347 | 356 |
| 357 // Double precision floating point instructions. |
348 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, a)) ); | 358 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, a)) ); |
349 __ ldc1(f6, MemOperand(a0, OFFSET_OF(T, b)) ); | 359 __ ldc1(f6, MemOperand(a0, OFFSET_OF(T, b)) ); |
350 __ add_d(f8, f4, f6); | 360 __ add_d(f8, f4, f6); |
351 __ sdc1(f8, MemOperand(a0, OFFSET_OF(T, c)) ); // c = a + b. | 361 __ sdc1(f8, MemOperand(a0, OFFSET_OF(T, c)) ); // c = a + b. |
352 | 362 |
353 __ mov_d(f10, f8); // c | 363 __ mov_d(f10, f8); // c |
354 __ neg_d(f12, f6); // -b | 364 __ neg_d(f12, f6); // -b |
355 __ sub_d(f10, f10, f12); | 365 __ sub_d(f10, f10, f12); |
356 __ sdc1(f10, MemOperand(a0, OFFSET_OF(T, d)) ); // d = c - (-b). | 366 __ sdc1(f10, MemOperand(a0, OFFSET_OF(T, d)) ); // d = c - (-b). |
357 | 367 |
(...skipping 12 matching lines...) Expand all Loading... |
370 __ sdc1(f14, MemOperand(a0, OFFSET_OF(T, g)) ); | 380 __ sdc1(f14, MemOperand(a0, OFFSET_OF(T, g)) ); |
371 // g = sqrt(f) = 10.97451593465515908537 | 381 // g = sqrt(f) = 10.97451593465515908537 |
372 | 382 |
373 if (kArchVariant == kMips64r2) { | 383 if (kArchVariant == kMips64r2) { |
374 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, h)) ); | 384 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, h)) ); |
375 __ ldc1(f6, MemOperand(a0, OFFSET_OF(T, i)) ); | 385 __ ldc1(f6, MemOperand(a0, OFFSET_OF(T, i)) ); |
376 __ madd_d(f14, f6, f4, f6); | 386 __ madd_d(f14, f6, f4, f6); |
377 __ sdc1(f14, MemOperand(a0, OFFSET_OF(T, h)) ); | 387 __ sdc1(f14, MemOperand(a0, OFFSET_OF(T, h)) ); |
378 } | 388 } |
379 | 389 |
| 390 // Single precision floating point instructions. |
| 391 __ lwc1(f4, MemOperand(a0, OFFSET_OF(T, fa)) ); |
| 392 __ lwc1(f6, MemOperand(a0, OFFSET_OF(T, fb)) ); |
| 393 __ add_s(f8, f4, f6); |
| 394 __ swc1(f8, MemOperand(a0, OFFSET_OF(T, fc)) ); // fc = fa + fb. |
| 395 |
| 396 __ neg_s(f10, f6); // -fb |
| 397 __ sub_s(f10, f8, f10); |
| 398 __ swc1(f10, MemOperand(a0, OFFSET_OF(T, fd)) ); // fd = fc - (-fb). |
| 399 |
| 400 __ swc1(f4, MemOperand(a0, OFFSET_OF(T, fb)) ); // fb = fa. |
| 401 |
| 402 __ li(t0, 120); |
| 403 __ mtc1(t0, f14); |
| 404 __ cvt_s_w(f14, f14); // f14 = 120.0. |
| 405 __ mul_s(f10, f10, f14); |
| 406 __ swc1(f10, MemOperand(a0, OFFSET_OF(T, fe)) ); // fe = fd * 120 |
| 407 |
| 408 __ div_s(f12, f10, f4); |
| 409 __ swc1(f12, MemOperand(a0, OFFSET_OF(T, ff)) ); // ff = fe / fa |
| 410 |
| 411 __ sqrt_s(f14, f12); |
| 412 __ swc1(f14, MemOperand(a0, OFFSET_OF(T, fg)) ); |
| 413 |
380 __ jr(ra); | 414 __ jr(ra); |
381 __ nop(); | 415 __ nop(); |
382 | 416 |
383 CodeDesc desc; | 417 CodeDesc desc; |
384 assm.GetCode(&desc); | 418 assm.GetCode(&desc); |
385 Handle<Code> code = isolate->factory()->NewCode( | 419 Handle<Code> code = isolate->factory()->NewCode( |
386 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); | 420 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); |
387 F3 f = FUNCTION_CAST<F3>(code->entry()); | 421 F3 f = FUNCTION_CAST<F3>(code->entry()); |
| 422 // Double test values. |
388 t.a = 1.5e14; | 423 t.a = 1.5e14; |
389 t.b = 2.75e11; | 424 t.b = 2.75e11; |
390 t.c = 0.0; | 425 t.c = 0.0; |
391 t.d = 0.0; | 426 t.d = 0.0; |
392 t.e = 0.0; | 427 t.e = 0.0; |
393 t.f = 0.0; | 428 t.f = 0.0; |
394 t.h = 1.5; | 429 t.h = 1.5; |
395 t.i = 2.75; | 430 t.i = 2.75; |
| 431 // Single test values. |
| 432 t.fa = 1.5e6; |
| 433 t.fb = 2.75e4; |
| 434 t.fc = 0.0; |
| 435 t.fd = 0.0; |
| 436 t.fe = 0.0; |
| 437 t.ff = 0.0; |
396 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); | 438 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); |
397 USE(dummy); | 439 USE(dummy); |
| 440 // Expected double results. |
398 CHECK_EQ(1.5e14, t.a); | 441 CHECK_EQ(1.5e14, t.a); |
399 CHECK_EQ(1.5e14, t.b); | 442 CHECK_EQ(1.5e14, t.b); |
400 CHECK_EQ(1.50275e14, t.c); | 443 CHECK_EQ(1.50275e14, t.c); |
401 CHECK_EQ(1.50550e14, t.d); | 444 CHECK_EQ(1.50550e14, t.d); |
402 CHECK_EQ(1.8066e16, t.e); | 445 CHECK_EQ(1.8066e16, t.e); |
403 CHECK_EQ(120.44, t.f); | 446 CHECK_EQ(120.44, t.f); |
404 CHECK_EQ(10.97451593465515908537, t.g); | 447 CHECK_EQ(10.97451593465515908537, t.g); |
405 if (kArchVariant == kMips64r2) { | 448 if (kArchVariant == kMips64r2) { |
406 CHECK_EQ(6.875, t.h); | 449 CHECK_EQ(6.875, t.h); |
407 } | 450 } |
| 451 // Expected single results. |
| 452 CHECK_EQ(1.5e6, t.fa); |
| 453 CHECK_EQ(1.5e6, t.fb); |
| 454 CHECK_EQ(1.5275e06, t.fc); |
| 455 CHECK_EQ(1.5550e06, t.fd); |
| 456 CHECK_EQ(1.866e08, t.fe); |
| 457 CHECK_EQ(124.40000152587890625, t.ff); |
| 458 CHECK_EQ(11.1534748077392578125, t.fg); |
408 } | 459 } |
409 | 460 |
410 | 461 |
411 TEST(MIPS4) { | 462 TEST(MIPS4) { |
412 // Test moves between floating point and integer registers. | 463 // Test moves between floating point and integer registers. |
413 CcTest::InitializeVM(); | 464 CcTest::InitializeVM(); |
414 Isolate* isolate = CcTest::i_isolate(); | 465 Isolate* isolate = CcTest::i_isolate(); |
415 HandleScope scope(isolate); | 466 HandleScope scope(isolate); |
416 | 467 |
417 typedef struct { | 468 typedef struct { |
(...skipping 1251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1669 ::printf("f(%d) = ", i); | 1720 ::printf("f(%d) = ", i); |
1670 result->Print(std::cout); | 1721 result->Print(std::cout); |
1671 ::printf("\n"); | 1722 ::printf("\n"); |
1672 #endif | 1723 #endif |
1673 CHECK(values[i].is_identical_to(result)); | 1724 CHECK(values[i].is_identical_to(result)); |
1674 } | 1725 } |
1675 } | 1726 } |
1676 | 1727 |
1677 | 1728 |
1678 #undef __ | 1729 #undef __ |
OLD | NEW |