1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "src/base/cpu.h"
6 #include "testing/gtest/include/gtest/gtest.h"
7 
8 namespace v8 {
9 namespace base {
10 
TEST(CPUTest,FeatureImplications)11 TEST(CPUTest, FeatureImplications) {
12   CPU cpu;
13 
14   // ia32 and x64 features
15   EXPECT_TRUE(!cpu.has_sse() || cpu.has_mmx());
16   EXPECT_TRUE(!cpu.has_sse2() || cpu.has_sse());
17   EXPECT_TRUE(!cpu.has_sse3() || cpu.has_sse2());
18   EXPECT_TRUE(!cpu.has_ssse3() || cpu.has_sse3());
19   EXPECT_TRUE(!cpu.has_sse41() || cpu.has_sse3());
20   EXPECT_TRUE(!cpu.has_sse42() || cpu.has_sse41());
21   EXPECT_TRUE(!cpu.has_avx() || cpu.has_sse2());
22   EXPECT_TRUE(!cpu.has_fma3() || cpu.has_avx());
23 
24   // arm features
25   EXPECT_TRUE(!cpu.has_vfp3_d32() || cpu.has_vfp3());
26 }
27 
28 
TEST(CPUTest,RequiredFeatures)29 TEST(CPUTest, RequiredFeatures) {
30   CPU cpu;
31 
32 #if V8_HOST_ARCH_ARM
33   EXPECT_TRUE(cpu.has_fpu());
34 #endif
35 
36 #if V8_HOST_ARCH_IA32
37   EXPECT_TRUE(cpu.has_fpu());
38   EXPECT_TRUE(cpu.has_sahf());
39 #endif
40 
41 #if V8_HOST_ARCH_X64
42   EXPECT_TRUE(cpu.has_fpu());
43   EXPECT_TRUE(cpu.has_cmov());
44   EXPECT_TRUE(cpu.has_mmx());
45   EXPECT_TRUE(cpu.has_sse());
46   EXPECT_TRUE(cpu.has_sse2());
47 #endif
48 }
49 
50 }  // namespace base
51 }  // namespace v8
52