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

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: Created 6 years, 10 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 2782 matching lines...) Expand 10 before | Expand all | Expand 10 after
2801 2802
2802 2803
2803 ASSEMBLER_TEST_RUN(Orpd, test) { 2804 ASSEMBLER_TEST_RUN(Orpd, test) {
2804 typedef double (*OrpdCode)(double d); 2805 typedef double (*OrpdCode)(double d);
2805 double res = reinterpret_cast<OrpdCode>(test->entry())(12.56e3); 2806 double res = reinterpret_cast<OrpdCode>(test->entry())(12.56e3);
2806 EXPECT_FLOAT_EQ(-12.56e3, res, 0.0); 2807 EXPECT_FLOAT_EQ(-12.56e3, res, 0.0);
2807 } 2808 }
2808 2809
2809 2810
2810 ASSEMBLER_TEST_GENERATE(Pextrd0, assembler) { 2811 ASSEMBLER_TEST_GENERATE(Pextrd0, assembler) {
2811 if (CPUFeatures::sse4_1_supported()) { 2812 if (TargetCPUFeatures::sse4_1_supported()) {
2812 __ movsd(XMM0, Address(ESP, kWordSize)); 2813 __ movsd(XMM0, Address(ESP, kWordSize));
2813 __ pextrd(EAX, XMM0, Immediate(0)); 2814 __ pextrd(EAX, XMM0, Immediate(0));
2814 } 2815 }
2815 __ ret(); 2816 __ ret();
2816 } 2817 }
2817 2818
2818 2819
2819 ASSEMBLER_TEST_RUN(Pextrd0, test) { 2820 ASSEMBLER_TEST_RUN(Pextrd0, test) {
2820 if (CPUFeatures::sse4_1_supported()) { 2821 if (TargetCPUFeatures::sse4_1_supported()) {
2821 typedef int32_t (*PextrdCode0)(double d); 2822 typedef int32_t (*PextrdCode0)(double d);
2822 int32_t res = reinterpret_cast<PextrdCode0>(test->entry())(123456789); 2823 int32_t res = reinterpret_cast<PextrdCode0>(test->entry())(123456789);
2823 EXPECT_EQ(0x54000000, res); 2824 EXPECT_EQ(0x54000000, res);
2824 } 2825 }
2825 } 2826 }
2826 2827
2827 2828
2828 ASSEMBLER_TEST_GENERATE(Pextrd1, assembler) { 2829 ASSEMBLER_TEST_GENERATE(Pextrd1, assembler) {
2829 if (CPUFeatures::sse4_1_supported()) { 2830 if (TargetCPUFeatures::sse4_1_supported()) {
2830 __ movsd(XMM0, Address(ESP, kWordSize)); 2831 __ movsd(XMM0, Address(ESP, kWordSize));
2831 __ pextrd(EAX, XMM0, Immediate(1)); 2832 __ pextrd(EAX, XMM0, Immediate(1));
2832 } 2833 }
2833 __ ret(); 2834 __ ret();
2834 } 2835 }
2835 2836
2836 2837
2837 ASSEMBLER_TEST_RUN(Pextrd1, test) { 2838 ASSEMBLER_TEST_RUN(Pextrd1, test) {
2838 if (CPUFeatures::sse4_1_supported()) { 2839 if (TargetCPUFeatures::sse4_1_supported()) {
2839 typedef int32_t (*PextrdCode1)(double d); 2840 typedef int32_t (*PextrdCode1)(double d);
2840 int32_t res = reinterpret_cast<PextrdCode1>(test->entry())(123456789); 2841 int32_t res = reinterpret_cast<PextrdCode1>(test->entry())(123456789);
2841 EXPECT_EQ(0x419d6f34, res); 2842 EXPECT_EQ(0x419d6f34, res);
2842 } 2843 }
2843 } 2844 }
2844 2845
2845 2846
2846 ASSEMBLER_TEST_GENERATE(Pmovsxdq, assembler) { 2847 ASSEMBLER_TEST_GENERATE(Pmovsxdq, assembler) {
2847 if (CPUFeatures::sse4_1_supported()) { 2848 if (TargetCPUFeatures::sse4_1_supported()) {
2848 __ movsd(XMM0, Address(ESP, kWordSize)); 2849 __ movsd(XMM0, Address(ESP, kWordSize));
2849 __ pmovsxdq(XMM0, XMM0); 2850 __ pmovsxdq(XMM0, XMM0);
2850 __ pextrd(EAX, XMM0, Immediate(1)); 2851 __ pextrd(EAX, XMM0, Immediate(1));
2851 } 2852 }
2852 __ ret(); 2853 __ ret();
2853 } 2854 }
2854 2855
2855 2856
2856 ASSEMBLER_TEST_RUN(Pmovsxdq, test) { 2857 ASSEMBLER_TEST_RUN(Pmovsxdq, test) {
2857 if (CPUFeatures::sse4_1_supported()) { 2858 if (TargetCPUFeatures::sse4_1_supported()) {
2858 typedef int32_t (*PmovsxdqCode)(double d); 2859 typedef int32_t (*PmovsxdqCode)(double d);
2859 int32_t res = reinterpret_cast<PmovsxdqCode>(test->entry())(123456789); 2860 int32_t res = reinterpret_cast<PmovsxdqCode>(test->entry())(123456789);
2860 EXPECT_EQ(0, res); 2861 EXPECT_EQ(0, res);
2861 } 2862 }
2862 } 2863 }
2863 2864
2864 2865
2865 ASSEMBLER_TEST_GENERATE(Pcmpeqq, assembler) { 2866 ASSEMBLER_TEST_GENERATE(Pcmpeqq, assembler) {
2866 if (CPUFeatures::sse4_1_supported()) { 2867 if (TargetCPUFeatures::sse4_1_supported()) {
2867 __ movsd(XMM0, Address(ESP, kWordSize)); 2868 __ movsd(XMM0, Address(ESP, kWordSize));
2868 __ xorpd(XMM1, XMM1); 2869 __ xorpd(XMM1, XMM1);
2869 __ pcmpeqq(XMM0, XMM1); 2870 __ pcmpeqq(XMM0, XMM1);
2870 __ movd(EAX, XMM0); 2871 __ movd(EAX, XMM0);
2871 } 2872 }
2872 __ ret(); 2873 __ ret();
2873 } 2874 }
2874 2875
2875 2876
2876 ASSEMBLER_TEST_RUN(Pcmpeqq, test) { 2877 ASSEMBLER_TEST_RUN(Pcmpeqq, test) {
2877 if (CPUFeatures::sse4_1_supported()) { 2878 if (TargetCPUFeatures::sse4_1_supported()) {
2878 typedef int32_t (*PcmpeqqCode)(double d); 2879 typedef int32_t (*PcmpeqqCode)(double d);
2879 int32_t res = reinterpret_cast<PcmpeqqCode>(test->entry())(0); 2880 int32_t res = reinterpret_cast<PcmpeqqCode>(test->entry())(0);
2880 EXPECT_EQ(-1, res); 2881 EXPECT_EQ(-1, res);
2881 } 2882 }
2882 } 2883 }
2883 2884
2884 2885
2885 ASSEMBLER_TEST_GENERATE(AndPd, assembler) { 2886 ASSEMBLER_TEST_GENERATE(AndPd, assembler) {
2886 __ movsd(XMM0, Address(ESP, kWordSize)); 2887 __ movsd(XMM0, Address(ESP, kWordSize));
2887 __ andpd(XMM0, XMM0); 2888 __ andpd(XMM0, XMM0);
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after
3192 FieldAddress(ECX, GrowableObjectArray::data_offset()), 3193 FieldAddress(ECX, GrowableObjectArray::data_offset()),
3193 EAX); 3194 EAX);
3194 __ popl(EAX); 3195 __ popl(EAX);
3195 __ popl(CTX); 3196 __ popl(CTX);
3196 __ ret(); 3197 __ ret();
3197 } 3198 }
3198 3199
3199 } // namespace dart 3200 } // namespace dart
3200 3201
3201 #endif // defined TARGET_ARCH_IA32 3202 #endif // defined TARGET_ARCH_IA32
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698