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

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

Issue 2273003002: [arm] Add support for vminnm and vmaxnm. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase and cl format. Created 4 years, 3 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/arm/simulator-arm.cc ('k') | test/cctest/test-disasm-arm.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 2363 matching lines...) Expand 10 before | Expand all | Expand 10 after
2374 CHECK_VSEL(1, 0, 1, 1, kResultFail, kResultPass, kResultPass, kResultPass); 2374 CHECK_VSEL(1, 0, 1, 1, kResultFail, kResultPass, kResultPass, kResultPass);
2375 CHECK_VSEL(1, 1, 0, 0, kResultPass, kResultFail, kResultFail, kResultFail); 2375 CHECK_VSEL(1, 1, 0, 0, kResultPass, kResultFail, kResultFail, kResultFail);
2376 CHECK_VSEL(1, 1, 0, 1, kResultPass, kResultPass, kResultFail, kResultPass); 2376 CHECK_VSEL(1, 1, 0, 1, kResultPass, kResultPass, kResultFail, kResultPass);
2377 CHECK_VSEL(1, 1, 1, 0, kResultPass, kResultFail, kResultFail, kResultFail); 2377 CHECK_VSEL(1, 1, 1, 0, kResultPass, kResultFail, kResultFail, kResultFail);
2378 CHECK_VSEL(1, 1, 1, 1, kResultPass, kResultPass, kResultFail, kResultPass); 2378 CHECK_VSEL(1, 1, 1, 1, kResultPass, kResultPass, kResultFail, kResultPass);
2379 2379
2380 #undef CHECK_VSEL 2380 #undef CHECK_VSEL
2381 } 2381 }
2382 } 2382 }
2383 2383
2384 TEST(ARMv8_vminmax_f64) {
2385 // Test the vsel floating point instructions.
2386 CcTest::InitializeVM();
2387 Isolate* isolate = CcTest::i_isolate();
2388 HandleScope scope(isolate);
2389
2390 Assembler assm(isolate, NULL, 0);
2391
2392 struct Inputs {
2393 double left_;
2394 double right_;
2395 };
2396
2397 struct Results {
2398 double vminnm_;
2399 double vmaxnm_;
2400 };
2401
2402 if (CpuFeatures::IsSupported(ARMv8)) {
2403 CpuFeatureScope scope(&assm, ARMv8);
2404
2405 // Create a helper function:
2406 // void TestVminmax(const Inputs* inputs,
2407 // Results* results);
2408 __ vldr(d1, r0, offsetof(Inputs, left_));
2409 __ vldr(d2, r0, offsetof(Inputs, right_));
2410
2411 __ vminnm(d0, d1, d2);
2412 __ vstr(d0, r1, offsetof(Results, vminnm_));
2413 __ vmaxnm(d0, d1, d2);
2414 __ vstr(d0, r1, offsetof(Results, vmaxnm_));
2415
2416 __ bx(lr);
2417
2418 CodeDesc desc;
2419 assm.GetCode(&desc);
2420 Handle<Code> code = isolate->factory()->NewCode(
2421 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
2422 #ifdef DEBUG
2423 OFStream os(stdout);
2424 code->Print(os);
2425 #endif
2426 F4 f = FUNCTION_CAST<F4>(code->entry());
2427 Object* dummy = nullptr;
2428 USE(dummy);
2429
2430 #define CHECK_VMINMAX(left, right, vminnm, vmaxnm) \
2431 do { \
2432 Inputs inputs = {left, right}; \
2433 Results results; \
2434 dummy = CALL_GENERATED_CODE(isolate, f, &inputs, &results, 0, 0, 0); \
2435 /* Use a bit_cast to correctly identify -0.0 and NaNs. */ \
2436 CHECK_EQ(bit_cast<uint64_t>(vminnm), bit_cast<uint64_t>(results.vminnm_)); \
2437 CHECK_EQ(bit_cast<uint64_t>(vmaxnm), bit_cast<uint64_t>(results.vmaxnm_)); \
2438 } while (0);
2439
2440 double nan_a = bit_cast<double>(UINT64_C(0x7ff8000000000001));
2441 double nan_b = bit_cast<double>(UINT64_C(0x7ff8000000000002));
2442
2443 CHECK_VMINMAX(1.0, -1.0, -1.0, 1.0);
2444 CHECK_VMINMAX(-1.0, 1.0, -1.0, 1.0);
2445 CHECK_VMINMAX(0.0, -1.0, -1.0, 0.0);
2446 CHECK_VMINMAX(-1.0, 0.0, -1.0, 0.0);
2447 CHECK_VMINMAX(-0.0, -1.0, -1.0, -0.0);
2448 CHECK_VMINMAX(-1.0, -0.0, -1.0, -0.0);
2449 CHECK_VMINMAX(0.0, 1.0, 0.0, 1.0);
2450 CHECK_VMINMAX(1.0, 0.0, 0.0, 1.0);
2451
2452 CHECK_VMINMAX(0.0, 0.0, 0.0, 0.0);
2453 CHECK_VMINMAX(-0.0, -0.0, -0.0, -0.0);
2454 CHECK_VMINMAX(-0.0, 0.0, -0.0, 0.0);
2455 CHECK_VMINMAX(0.0, -0.0, -0.0, 0.0);
2456
2457 CHECK_VMINMAX(0.0, nan_a, 0.0, 0.0);
2458 CHECK_VMINMAX(nan_a, 0.0, 0.0, 0.0);
2459 CHECK_VMINMAX(nan_a, nan_b, nan_a, nan_a);
2460 CHECK_VMINMAX(nan_b, nan_a, nan_b, nan_b);
2461
2462 #undef CHECK_VMINMAX
2463 }
2464 }
2465
2466 TEST(ARMv8_vminmax_f32) {
2467 // Test the vsel floating point instructions.
2468 CcTest::InitializeVM();
2469 Isolate* isolate = CcTest::i_isolate();
2470 HandleScope scope(isolate);
2471
2472 Assembler assm(isolate, NULL, 0);
2473
2474 struct Inputs {
2475 float left_;
2476 float right_;
2477 };
2478
2479 struct Results {
2480 float vminnm_;
2481 float vmaxnm_;
2482 };
2483
2484 if (CpuFeatures::IsSupported(ARMv8)) {
2485 CpuFeatureScope scope(&assm, ARMv8);
2486
2487 // Create a helper function:
2488 // void TestVminmax(const Inputs* inputs,
2489 // Results* results);
2490 __ vldr(s1, r0, offsetof(Inputs, left_));
2491 __ vldr(s2, r0, offsetof(Inputs, right_));
2492
2493 __ vminnm(s0, s1, s2);
2494 __ vstr(s0, r1, offsetof(Results, vminnm_));
2495 __ vmaxnm(s0, s1, s2);
2496 __ vstr(s0, r1, offsetof(Results, vmaxnm_));
2497
2498 __ bx(lr);
2499
2500 CodeDesc desc;
2501 assm.GetCode(&desc);
2502 Handle<Code> code = isolate->factory()->NewCode(
2503 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
2504 #ifdef DEBUG
2505 OFStream os(stdout);
2506 code->Print(os);
2507 #endif
2508 F4 f = FUNCTION_CAST<F4>(code->entry());
2509 Object* dummy = nullptr;
2510 USE(dummy);
2511
2512 #define CHECK_VMINMAX(left, right, vminnm, vmaxnm) \
2513 do { \
2514 Inputs inputs = {left, right}; \
2515 Results results; \
2516 dummy = CALL_GENERATED_CODE(isolate, f, &inputs, &results, 0, 0, 0); \
2517 /* Use a bit_cast to correctly identify -0.0 and NaNs. */ \
2518 CHECK_EQ(bit_cast<uint32_t>(vminnm), bit_cast<uint32_t>(results.vminnm_)); \
2519 CHECK_EQ(bit_cast<uint32_t>(vmaxnm), bit_cast<uint32_t>(results.vmaxnm_)); \
2520 } while (0);
2521
2522 float nan_a = bit_cast<float>(UINT32_C(0x7fc00001));
2523 float nan_b = bit_cast<float>(UINT32_C(0x7fc00002));
2524
2525 CHECK_VMINMAX(1.0f, -1.0f, -1.0f, 1.0f);
2526 CHECK_VMINMAX(-1.0f, 1.0f, -1.0f, 1.0f);
2527 CHECK_VMINMAX(0.0f, -1.0f, -1.0f, 0.0f);
2528 CHECK_VMINMAX(-1.0f, 0.0f, -1.0f, 0.0f);
2529 CHECK_VMINMAX(-0.0f, -1.0f, -1.0f, -0.0f);
2530 CHECK_VMINMAX(-1.0f, -0.0f, -1.0f, -0.0f);
2531 CHECK_VMINMAX(0.0f, 1.0f, 0.0f, 1.0f);
2532 CHECK_VMINMAX(1.0f, 0.0f, 0.0f, 1.0f);
2533
2534 CHECK_VMINMAX(0.0f, 0.0f, 0.0f, 0.0f);
2535 CHECK_VMINMAX(-0.0f, -0.0f, -0.0f, -0.0f);
2536 CHECK_VMINMAX(-0.0f, 0.0f, -0.0f, 0.0f);
2537 CHECK_VMINMAX(0.0f, -0.0f, -0.0f, 0.0f);
2538
2539 CHECK_VMINMAX(0.0f, nan_a, 0.0f, 0.0f);
2540 CHECK_VMINMAX(nan_a, 0.0f, 0.0f, 0.0f);
2541 CHECK_VMINMAX(nan_a, nan_b, nan_a, nan_a);
2542 CHECK_VMINMAX(nan_b, nan_a, nan_b, nan_b);
2543
2544 #undef CHECK_VMINMAX
2545 }
2546 }
2547
2384 TEST(unaligned_loads) { 2548 TEST(unaligned_loads) {
2385 // All supported ARM targets allow unaligned accesses. 2549 // All supported ARM targets allow unaligned accesses.
2386 CcTest::InitializeVM(); 2550 CcTest::InitializeVM();
2387 Isolate* isolate = CcTest::i_isolate(); 2551 Isolate* isolate = CcTest::i_isolate();
2388 HandleScope scope(isolate); 2552 HandleScope scope(isolate);
2389 2553
2390 typedef struct { 2554 typedef struct {
2391 uint32_t ldrh; 2555 uint32_t ldrh;
2392 uint32_t ldrsh; 2556 uint32_t ldrsh;
2393 uint32_t ldr; 2557 uint32_t ldr;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
2546 HandleScope scope(isolate); 2710 HandleScope scope(isolate);
2547 2711
2548 Assembler assm(isolate, NULL, 0); 2712 Assembler assm(isolate, NULL, 0);
2549 __ mov(r0, Operand(isolate->factory()->infinity_value())); 2713 __ mov(r0, Operand(isolate->factory()->infinity_value()));
2550 __ BlockConstPoolFor(1019); 2714 __ BlockConstPoolFor(1019);
2551 for (int i = 0; i < 1019; ++i) __ nop(); 2715 for (int i = 0; i < 1019; ++i) __ nop();
2552 __ vldr(d0, MemOperand(r0, 0)); 2716 __ vldr(d0, MemOperand(r0, 0));
2553 } 2717 }
2554 2718
2555 #undef __ 2719 #undef __
OLDNEW
« no previous file with comments | « src/arm/simulator-arm.cc ('k') | test/cctest/test-disasm-arm.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698