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

Side by Side Diff: runtime/vm/assembler_ia32_test.cc

Issue 120723003: Refactors CPU feature detection. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Fixed cpu service field names. Created 6 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "vm/globals.h" 5 #include "vm/globals.h"
6 #if defined(TARGET_ARCH_IA32) 6 #if defined(TARGET_ARCH_IA32)
7 7
8 #include "vm/assembler.h" 8 #include "vm/assembler.h"
9 #include "vm/cpu.h"
9 #include "vm/os.h" 10 #include "vm/os.h"
10 #include "vm/unit_test.h" 11 #include "vm/unit_test.h"
11 #include "vm/virtual_memory.h" 12 #include "vm/virtual_memory.h"
12 13
13 namespace dart { 14 namespace dart {
14 15
15 #define __ assembler-> 16 #define __ assembler->
16 17
17 18
18 ASSEMBLER_TEST_GENERATE(Simple, assembler) { 19 ASSEMBLER_TEST_GENERATE(Simple, assembler) {
(...skipping 2488 matching lines...) Expand 10 before | Expand all | Expand 10 after
2507 2508
2508 2509
2509 ASSEMBLER_TEST_RUN(Orpd, test) { 2510 ASSEMBLER_TEST_RUN(Orpd, test) {
2510 typedef double (*OrpdCode)(double d); 2511 typedef double (*OrpdCode)(double d);
2511 double res = reinterpret_cast<OrpdCode>(test->entry())(12.56e3); 2512 double res = reinterpret_cast<OrpdCode>(test->entry())(12.56e3);
2512 EXPECT_FLOAT_EQ(-12.56e3, res, 0.0); 2513 EXPECT_FLOAT_EQ(-12.56e3, res, 0.0);
2513 } 2514 }
2514 2515
2515 2516
2516 ASSEMBLER_TEST_GENERATE(Pextrd0, assembler) { 2517 ASSEMBLER_TEST_GENERATE(Pextrd0, assembler) {
2517 if (CPUFeatures::sse4_1_supported()) { 2518 if (TargetCPUFeatures::sse4_1_supported()) {
2518 __ movsd(XMM0, Address(ESP, kWordSize)); 2519 __ movsd(XMM0, Address(ESP, kWordSize));
2519 __ pextrd(EAX, XMM0, Immediate(0)); 2520 __ pextrd(EAX, XMM0, Immediate(0));
2520 } 2521 }
2521 __ ret(); 2522 __ ret();
2522 } 2523 }
2523 2524
2524 2525
2525 ASSEMBLER_TEST_RUN(Pextrd0, test) { 2526 ASSEMBLER_TEST_RUN(Pextrd0, test) {
2526 if (CPUFeatures::sse4_1_supported()) { 2527 if (TargetCPUFeatures::sse4_1_supported()) {
2527 typedef int32_t (*PextrdCode0)(double d); 2528 typedef int32_t (*PextrdCode0)(double d);
2528 int32_t res = reinterpret_cast<PextrdCode0>(test->entry())(123456789); 2529 int32_t res = reinterpret_cast<PextrdCode0>(test->entry())(123456789);
2529 EXPECT_EQ(0x54000000, res); 2530 EXPECT_EQ(0x54000000, res);
2530 } 2531 }
2531 } 2532 }
2532 2533
2533 2534
2534 ASSEMBLER_TEST_GENERATE(Pextrd1, assembler) { 2535 ASSEMBLER_TEST_GENERATE(Pextrd1, assembler) {
2535 if (CPUFeatures::sse4_1_supported()) { 2536 if (TargetCPUFeatures::sse4_1_supported()) {
2536 __ movsd(XMM0, Address(ESP, kWordSize)); 2537 __ movsd(XMM0, Address(ESP, kWordSize));
2537 __ pextrd(EAX, XMM0, Immediate(1)); 2538 __ pextrd(EAX, XMM0, Immediate(1));
2538 } 2539 }
2539 __ ret(); 2540 __ ret();
2540 } 2541 }
2541 2542
2542 2543
2543 ASSEMBLER_TEST_RUN(Pextrd1, test) { 2544 ASSEMBLER_TEST_RUN(Pextrd1, test) {
2544 if (CPUFeatures::sse4_1_supported()) { 2545 if (TargetCPUFeatures::sse4_1_supported()) {
2545 typedef int32_t (*PextrdCode1)(double d); 2546 typedef int32_t (*PextrdCode1)(double d);
2546 int32_t res = reinterpret_cast<PextrdCode1>(test->entry())(123456789); 2547 int32_t res = reinterpret_cast<PextrdCode1>(test->entry())(123456789);
2547 EXPECT_EQ(0x419d6f34, res); 2548 EXPECT_EQ(0x419d6f34, res);
2548 } 2549 }
2549 } 2550 }
2550 2551
2551 2552
2552 ASSEMBLER_TEST_GENERATE(Pmovsxdq, assembler) { 2553 ASSEMBLER_TEST_GENERATE(Pmovsxdq, assembler) {
2553 if (CPUFeatures::sse4_1_supported()) { 2554 if (TargetCPUFeatures::sse4_1_supported()) {
2554 __ movsd(XMM0, Address(ESP, kWordSize)); 2555 __ movsd(XMM0, Address(ESP, kWordSize));
2555 __ pmovsxdq(XMM0, XMM0); 2556 __ pmovsxdq(XMM0, XMM0);
2556 __ pextrd(EAX, XMM0, Immediate(1)); 2557 __ pextrd(EAX, XMM0, Immediate(1));
2557 } 2558 }
2558 __ ret(); 2559 __ ret();
2559 } 2560 }
2560 2561
2561 2562
2562 ASSEMBLER_TEST_RUN(Pmovsxdq, test) { 2563 ASSEMBLER_TEST_RUN(Pmovsxdq, test) {
2563 if (CPUFeatures::sse4_1_supported()) { 2564 if (TargetCPUFeatures::sse4_1_supported()) {
2564 typedef int32_t (*PmovsxdqCode)(double d); 2565 typedef int32_t (*PmovsxdqCode)(double d);
2565 int32_t res = reinterpret_cast<PmovsxdqCode>(test->entry())(123456789); 2566 int32_t res = reinterpret_cast<PmovsxdqCode>(test->entry())(123456789);
2566 EXPECT_EQ(0, res); 2567 EXPECT_EQ(0, res);
2567 } 2568 }
2568 } 2569 }
2569 2570
2570 2571
2571 ASSEMBLER_TEST_GENERATE(Pcmpeqq, assembler) { 2572 ASSEMBLER_TEST_GENERATE(Pcmpeqq, assembler) {
2572 if (CPUFeatures::sse4_1_supported()) { 2573 if (TargetCPUFeatures::sse4_1_supported()) {
2573 __ movsd(XMM0, Address(ESP, kWordSize)); 2574 __ movsd(XMM0, Address(ESP, kWordSize));
2574 __ xorpd(XMM1, XMM1); 2575 __ xorpd(XMM1, XMM1);
2575 __ pcmpeqq(XMM0, XMM1); 2576 __ pcmpeqq(XMM0, XMM1);
2576 __ movd(EAX, XMM0); 2577 __ movd(EAX, XMM0);
2577 } 2578 }
2578 __ ret(); 2579 __ ret();
2579 } 2580 }
2580 2581
2581 2582
2582 ASSEMBLER_TEST_RUN(Pcmpeqq, test) { 2583 ASSEMBLER_TEST_RUN(Pcmpeqq, test) {
2583 if (CPUFeatures::sse4_1_supported()) { 2584 if (TargetCPUFeatures::sse4_1_supported()) {
2584 typedef int32_t (*PcmpeqqCode)(double d); 2585 typedef int32_t (*PcmpeqqCode)(double d);
2585 int32_t res = reinterpret_cast<PcmpeqqCode>(test->entry())(0); 2586 int32_t res = reinterpret_cast<PcmpeqqCode>(test->entry())(0);
2586 EXPECT_EQ(-1, res); 2587 EXPECT_EQ(-1, res);
2587 } 2588 }
2588 } 2589 }
2589 2590
2590 2591
2591 ASSEMBLER_TEST_GENERATE(AndPd, assembler) { 2592 ASSEMBLER_TEST_GENERATE(AndPd, assembler) {
2592 __ movsd(XMM0, Address(ESP, kWordSize)); 2593 __ movsd(XMM0, Address(ESP, kWordSize));
2593 __ andpd(XMM0, XMM0); 2594 __ andpd(XMM0, XMM0);
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
2898 FieldAddress(ECX, GrowableObjectArray::data_offset()), 2899 FieldAddress(ECX, GrowableObjectArray::data_offset()),
2899 EAX); 2900 EAX);
2900 __ popl(EAX); 2901 __ popl(EAX);
2901 __ popl(CTX); 2902 __ popl(CTX);
2902 __ ret(); 2903 __ ret();
2903 } 2904 }
2904 2905
2905 } // namespace dart 2906 } // namespace dart
2906 2907
2907 #endif // defined TARGET_ARCH_IA32 2908 #endif // defined TARGET_ARCH_IA32
OLDNEW
« no previous file with comments | « runtime/vm/assembler_ia32.cc ('k') | runtime/vm/assembler_mips.h » ('j') | runtime/vm/cpu_mips.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698