blob: c12e339701c865a4fe7e4abcbc6a5fbe9570321f [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// 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());
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000021 EXPECT_TRUE(!cpu.has_avx() || cpu.has_sse2());
22 EXPECT_TRUE(!cpu.has_fma3() || cpu.has_avx());
Ben Murdochb8a8cc12014-11-26 15:28:44 +000023
24 // arm features
25 EXPECT_TRUE(!cpu.has_vfp3_d32() || cpu.has_vfp3());
26}
27
28
29TEST(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