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
8namespace v8 {
9namespace base {
10
11TEST(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
22  // arm features
23  EXPECT_TRUE(!cpu.has_vfp3_d32() || cpu.has_vfp3());
24}
25
26
27TEST(CPUTest, RequiredFeatures) {
28  CPU cpu;
29
30#if V8_HOST_ARCH_ARM
31  EXPECT_TRUE(cpu.has_fpu());
32#endif
33
34#if V8_HOST_ARCH_IA32
35  EXPECT_TRUE(cpu.has_fpu());
36  EXPECT_TRUE(cpu.has_sahf());
37#endif
38
39#if V8_HOST_ARCH_X64
40  EXPECT_TRUE(cpu.has_fpu());
41  EXPECT_TRUE(cpu.has_cmov());
42  EXPECT_TRUE(cpu.has_mmx());
43  EXPECT_TRUE(cpu.has_sse());
44  EXPECT_TRUE(cpu.has_sse2());
45#endif
46}
47
48}  // namespace base
49}  // namespace v8
50