blob: 8c41f9d77a776739d5643bf317e6c3c6233a5a0e [file] [log] [blame]
Ben Murdochb8a8cc12014-11-26 15:28:44 +00001// Copyright 2006-2013 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// This module contains the architecture-specific code. This make the rest of
6// the code less dependent on differences between different processor
7// architecture.
8// The classes have the same definition for all architectures. The
9// implementation for a particular architecture is put in cpu_<arch>.cc.
10// The build system then uses the implementation for the target architecture.
11//
12
13#ifndef V8_BASE_CPU_H_
14#define V8_BASE_CPU_H_
15
16#include "src/base/macros.h"
17
18namespace v8 {
19namespace base {
20
21// ----------------------------------------------------------------------------
22// CPU
23//
24// Query information about the processor.
25//
26// This class also has static methods for the architecture specific functions.
27// Add methods here to cope with differences between the supported
28// architectures. For each architecture the file cpu_<arch>.cc contains the
29// implementation of these static functions.
30
31class CPU FINAL {
32 public:
33 CPU();
34
35 // x86 CPUID information
36 const char* vendor() const { return vendor_; }
37 int stepping() const { return stepping_; }
38 int model() const { return model_; }
39 int ext_model() const { return ext_model_; }
40 int family() const { return family_; }
41 int ext_family() const { return ext_family_; }
42 int type() const { return type_; }
43
44 // arm implementer/part information
45 int implementer() const { return implementer_; }
46 static const int ARM = 0x41;
47 static const int NVIDIA = 0x4e;
48 static const int QUALCOMM = 0x51;
49 int architecture() const { return architecture_; }
Emily Bernierd0a1eb72015-03-24 16:35:39 -040050 int variant() const { return variant_; }
51 static const int NVIDIA_DENVER = 0x0;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000052 int part() const { return part_; }
53 static const int ARM_CORTEX_A5 = 0xc05;
54 static const int ARM_CORTEX_A7 = 0xc07;
55 static const int ARM_CORTEX_A8 = 0xc08;
56 static const int ARM_CORTEX_A9 = 0xc09;
57 static const int ARM_CORTEX_A12 = 0xc0c;
58 static const int ARM_CORTEX_A15 = 0xc0f;
59
60 // General features
61 bool has_fpu() const { return has_fpu_; }
62
63 // x86 features
64 bool has_cmov() const { return has_cmov_; }
65 bool has_sahf() const { return has_sahf_; }
66 bool has_mmx() const { return has_mmx_; }
67 bool has_sse() const { return has_sse_; }
68 bool has_sse2() const { return has_sse2_; }
69 bool has_sse3() const { return has_sse3_; }
70 bool has_ssse3() const { return has_ssse3_; }
71 bool has_sse41() const { return has_sse41_; }
72 bool has_sse42() const { return has_sse42_; }
Emily Bernierd0a1eb72015-03-24 16:35:39 -040073 bool has_avx() const { return has_avx_; }
74 bool has_fma3() const { return has_fma3_; }
Ben Murdochb8a8cc12014-11-26 15:28:44 +000075
76 // arm features
77 bool has_idiva() const { return has_idiva_; }
78 bool has_neon() const { return has_neon_; }
79 bool has_thumb2() const { return has_thumb2_; }
80 bool has_vfp() const { return has_vfp_; }
81 bool has_vfp3() const { return has_vfp3_; }
82 bool has_vfp3_d32() const { return has_vfp3_d32_; }
83
84 // mips features
85 bool is_fp64_mode() const { return is_fp64_mode_; }
86
87 private:
88 char vendor_[13];
89 int stepping_;
90 int model_;
91 int ext_model_;
92 int family_;
93 int ext_family_;
94 int type_;
95 int implementer_;
96 int architecture_;
Emily Bernierd0a1eb72015-03-24 16:35:39 -040097 int variant_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +000098 int part_;
99 bool has_fpu_;
100 bool has_cmov_;
101 bool has_sahf_;
102 bool has_mmx_;
103 bool has_sse_;
104 bool has_sse2_;
105 bool has_sse3_;
106 bool has_ssse3_;
107 bool has_sse41_;
108 bool has_sse42_;
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400109 bool has_avx_;
110 bool has_fma3_;
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000111 bool has_idiva_;
112 bool has_neon_;
113 bool has_thumb2_;
114 bool has_vfp_;
115 bool has_vfp3_;
116 bool has_vfp3_d32_;
117 bool is_fp64_mode_;
118};
119
120} } // namespace v8::base
121
122#endif // V8_BASE_CPU_H_