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

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

Issue 1047213002: Finish 'MIPS: [turbofan] Add backend support for float32 operations.' (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix #1 Created 5 years, 8 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/disasm-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 28 matching lines...) Expand all
39 39
40 40
41 using namespace v8::internal; 41 using namespace v8::internal;
42 42
43 43
44 // Define these function prototypes to match JSEntryFunction in execution.cc. 44 // Define these function prototypes to match JSEntryFunction in execution.cc.
45 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4); 45 typedef Object* (*F1)(int x, int p1, int p2, int p3, int p4);
46 typedef Object* (*F2)(int x, int y, int p2, int p3, int p4); 46 typedef Object* (*F2)(int x, int y, int p2, int p3, int p4);
47 typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4); 47 typedef Object* (*F3)(void* p, int p1, int p2, int p3, int p4);
48 48
49 // clang-format off
jochen (gone - plz use gerrit) 2015/11/25 13:00:26 please don't do this. clang-format off is meant to
50
49 51
50 #define __ assm. 52 #define __ assm.
51 TEST(MIPS16) { 53 TEST(MIPS16) {
52 CcTest::InitializeVM(); 54 CcTest::InitializeVM();
53 Isolate* isolate = CcTest::i_isolate(); 55 Isolate* isolate = CcTest::i_isolate();
54 HandleScope scope(isolate); 56 HandleScope scope(isolate);
55 MacroAssembler assm(isolate, NULL, 0); 57 MacroAssembler assm(isolate, NULL, 0);
56 58
57 typedef struct test { 59 typedef struct test {
58 int a; 60 int a;
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
340 typedef struct { 342 typedef struct {
341 double a; 343 double a;
342 double b; 344 double b;
343 double c; 345 double c;
344 double d; 346 double d;
345 double e; 347 double e;
346 double f; 348 double f;
347 double g; 349 double g;
348 double h; 350 double h;
349 double i; 351 double i;
352 float fa;
353 float fb;
354 float fc;
355 float fd;
356 float fe;
357 float ff;
358 float fg;
350 } T; 359 } T;
351 T t; 360 T t;
352 361
353 // Create a function that accepts &t, and loads, manipulates, and stores 362 // Create a function that accepts &t, and loads, manipulates, and stores
354 // the doubles t.a ... t.f. 363 // the doubles t.a ... t.f.
355 MacroAssembler assm(isolate, NULL, 0); 364 MacroAssembler assm(isolate, NULL, 0);
356 Label L, C; 365 Label L, C;
357 366
367 // Double precision floating point instructions.
358 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, a)) ); 368 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, a)) );
359 __ ldc1(f6, MemOperand(a0, OFFSET_OF(T, b)) ); 369 __ ldc1(f6, MemOperand(a0, OFFSET_OF(T, b)) );
360 __ add_d(f8, f4, f6); 370 __ add_d(f8, f4, f6);
361 __ sdc1(f8, MemOperand(a0, OFFSET_OF(T, c)) ); // c = a + b. 371 __ sdc1(f8, MemOperand(a0, OFFSET_OF(T, c)) ); // c = a + b.
362 372
363 __ mov_d(f10, f8); // c 373 __ mov_d(f10, f8); // c
364 __ neg_d(f12, f6); // -b 374 __ neg_d(f12, f6); // -b
365 __ sub_d(f10, f10, f12); 375 __ sub_d(f10, f10, f12);
366 __ sdc1(f10, MemOperand(a0, OFFSET_OF(T, d)) ); // d = c - (-b). 376 __ sdc1(f10, MemOperand(a0, OFFSET_OF(T, d)) ); // d = c - (-b).
367 377
(...skipping 12 matching lines...) Expand all
380 __ sdc1(f14, MemOperand(a0, OFFSET_OF(T, g)) ); 390 __ sdc1(f14, MemOperand(a0, OFFSET_OF(T, g)) );
381 // g = sqrt(f) = 10.97451593465515908537 391 // g = sqrt(f) = 10.97451593465515908537
382 392
383 if (IsMipsArchVariant(kMips32r2)) { 393 if (IsMipsArchVariant(kMips32r2)) {
384 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, h)) ); 394 __ ldc1(f4, MemOperand(a0, OFFSET_OF(T, h)) );
385 __ ldc1(f6, MemOperand(a0, OFFSET_OF(T, i)) ); 395 __ ldc1(f6, MemOperand(a0, OFFSET_OF(T, i)) );
386 __ madd_d(f14, f6, f4, f6); 396 __ madd_d(f14, f6, f4, f6);
387 __ sdc1(f14, MemOperand(a0, OFFSET_OF(T, h)) ); 397 __ sdc1(f14, MemOperand(a0, OFFSET_OF(T, h)) );
388 } 398 }
389 399
400 // Single precision floating point instructions.
401 __ lwc1(f4, MemOperand(a0, OFFSET_OF(T, fa)) );
402 __ lwc1(f6, MemOperand(a0, OFFSET_OF(T, fb)) );
403 __ add_s(f8, f4, f6);
404 __ swc1(f8, MemOperand(a0, OFFSET_OF(T, fc)) ); // fc = fa + fb.
405
406 __ neg_s(f10, f6); // -fb
407 __ sub_s(f10, f8, f10);
408 __ swc1(f10, MemOperand(a0, OFFSET_OF(T, fd)) ); // fd = fc - (-fb).
409
410 __ swc1(f4, MemOperand(a0, OFFSET_OF(T, fb)) ); // fb = fa.
411
412 __ li(t0, 120);
413 __ mtc1(t0, f14);
414 __ cvt_s_w(f14, f14); // f14 = 120.0.
415 __ mul_s(f10, f10, f14);
416 __ swc1(f10, MemOperand(a0, OFFSET_OF(T, fe)) ); // fe = fd * 120
417
418 __ div_s(f12, f10, f4);
419 __ swc1(f12, MemOperand(a0, OFFSET_OF(T, ff)) ); // ff = fe / fa
420
421 __ sqrt_s(f14, f12);
422 __ swc1(f14, MemOperand(a0, OFFSET_OF(T, fg)) );
423
390 __ jr(ra); 424 __ jr(ra);
391 __ nop(); 425 __ nop();
392 426
393 CodeDesc desc; 427 CodeDesc desc;
394 assm.GetCode(&desc); 428 assm.GetCode(&desc);
395 Handle<Code> code = isolate->factory()->NewCode( 429 Handle<Code> code = isolate->factory()->NewCode(
396 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 430 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
397 F3 f = FUNCTION_CAST<F3>(code->entry()); 431 F3 f = FUNCTION_CAST<F3>(code->entry());
432 // Double test values.
398 t.a = 1.5e14; 433 t.a = 1.5e14;
399 t.b = 2.75e11; 434 t.b = 2.75e11;
400 t.c = 0.0; 435 t.c = 0.0;
401 t.d = 0.0; 436 t.d = 0.0;
402 t.e = 0.0; 437 t.e = 0.0;
403 t.f = 0.0; 438 t.f = 0.0;
404 t.h = 1.5; 439 t.h = 1.5;
405 t.i = 2.75; 440 t.i = 2.75;
441 // Single test values.
442 t.fa = 1.5e6;
443 t.fb = 2.75e4;
444 t.fc = 0.0;
445 t.fd = 0.0;
446 t.fe = 0.0;
447 t.ff = 0.0;
406 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0); 448 Object* dummy = CALL_GENERATED_CODE(f, &t, 0, 0, 0, 0);
407 USE(dummy); 449 USE(dummy);
450 // Expected double results.
408 CHECK_EQ(1.5e14, t.a); 451 CHECK_EQ(1.5e14, t.a);
409 CHECK_EQ(1.5e14, t.b); 452 CHECK_EQ(1.5e14, t.b);
410 CHECK_EQ(1.50275e14, t.c); 453 CHECK_EQ(1.50275e14, t.c);
411 CHECK_EQ(1.50550e14, t.d); 454 CHECK_EQ(1.50550e14, t.d);
412 CHECK_EQ(1.8066e16, t.e); 455 CHECK_EQ(1.8066e16, t.e);
413 CHECK_EQ(120.44, t.f); 456 CHECK_EQ(120.44, t.f);
414 CHECK_EQ(10.97451593465515908537, t.g); 457 CHECK_EQ(10.97451593465515908537, t.g);
415 if (IsMipsArchVariant(kMips32r2)) { 458 if (IsMipsArchVariant(kMips32r2)) {
416 CHECK_EQ(6.875, t.h); 459 CHECK_EQ(6.875, t.h);
417 } 460 }
461 // Expected single results.
462 CHECK_EQ(1.5e6, t.fa);
463 CHECK_EQ(1.5e6, t.fb);
464 CHECK_EQ(1.5275e06, t.fc);
465 CHECK_EQ(1.5550e06, t.fd);
466 CHECK_EQ(1.866e08, t.fe);
467 CHECK_EQ(124.40000152587890625, t.ff);
468 CHECK_EQ(11.1534748077392578125, t.fg);
418 } 469 }
419 470
420 471
421 TEST(MIPS4) { 472 TEST(MIPS4) {
422 // Test moves between floating point and integer registers. 473 // Test moves between floating point and integer registers.
423 CcTest::InitializeVM(); 474 CcTest::InitializeVM();
424 Isolate* isolate = CcTest::i_isolate(); 475 Isolate* isolate = CcTest::i_isolate();
425 HandleScope scope(isolate); 476 HandleScope scope(isolate);
426 477
427 typedef struct { 478 typedef struct {
(...skipping 1140 matching lines...) Expand 10 before | Expand all | Expand 10 after
1568 ::printf("f(%d) = ", i); 1619 ::printf("f(%d) = ", i);
1569 result->Print(std::cout); 1620 result->Print(std::cout);
1570 ::printf("\n"); 1621 ::printf("\n");
1571 #endif 1622 #endif
1572 CHECK(values[i].is_identical_to(result)); 1623 CHECK(values[i].is_identical_to(result));
1573 } 1624 }
1574 } 1625 }
1575 1626
1576 1627
1577 #undef __ 1628 #undef __
OLDNEW
« no previous file with comments | « src/mips64/disasm-mips64.cc ('k') | test/cctest/test-assembler-mips64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698