| 1 | // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 | |
| 5 | #ifndef RUNTIME_VM_CPU_X64_H_ |
| 6 | #define RUNTIME_VM_CPU_X64_H_ |
| 7 | |
| 8 | #if !defined(RUNTIME_VM_CPU_H_) |
| 9 | #error Do not include cpu_x64.h directly; use cpu.h instead. |
| 10 | #endif |
| 11 | |
| 12 | #include "vm/allocation.h" |
| 13 | #include "vm/flags.h" |
| 14 | |
| 15 | namespace dart { |
| 16 | |
| 17 | DECLARE_FLAG(bool, use_sse41); |
| 18 | |
| 19 | class HostCPUFeatures : public AllStatic { |
| 20 | public: |
| 21 | static void Init(); |
| 22 | static void Cleanup(); |
| 23 | static const char* hardware() { |
| 24 | DEBUG_ASSERT(initialized_); |
| 25 | return hardware_; |
| 26 | } |
| 27 | static bool sse2_supported() { |
| 28 | DEBUG_ASSERT(initialized_); |
| 29 | return sse2_supported_; |
| 30 | } |
| 31 | static bool sse4_1_supported() { |
| 32 | DEBUG_ASSERT(initialized_); |
| 33 | return sse4_1_supported_ && FLAG_use_sse41; |
| 34 | } |
| 35 | static bool popcnt_supported() { |
| 36 | DEBUG_ASSERT(initialized_); |
| 37 | return popcnt_supported_; |
| 38 | } |
| 39 | static bool abm_supported() { |
| 40 | DEBUG_ASSERT(initialized_); |
| 41 | return abm_supported_; |
| 42 | } |
| 43 | |
| 44 | private: |
| 45 | static const char* hardware_; |
| 46 | static bool sse2_supported_; |
| 47 | static bool sse4_1_supported_; |
| 48 | static bool popcnt_supported_; |
| 49 | static bool abm_supported_; |
| 50 | #if defined(DEBUG) |
| 51 | static bool initialized_; |
| 52 | #endif |
| 53 | }; |
| 54 | |
| 55 | class TargetCPUFeatures : public AllStatic { |
| 56 | public: |
| 57 | static void Init() { HostCPUFeatures::Init(); } |
| 58 | static void Cleanup() { HostCPUFeatures::Cleanup(); } |
| 59 | static const char* hardware() { return HostCPUFeatures::hardware(); } |
| 60 | static bool sse2_supported() { return HostCPUFeatures::sse2_supported(); } |
| 61 | static bool sse4_1_supported() { return HostCPUFeatures::sse4_1_supported(); } |
| 62 | static bool popcnt_supported() { return HostCPUFeatures::popcnt_supported(); } |
| 63 | static bool abm_supported() { return HostCPUFeatures::abm_supported(); } |
| 64 | static bool double_truncate_round_supported() { return false; } |
| 65 | }; |
| 66 | |
| 67 | } // namespace dart |
| 68 | |
| 69 | #endif // RUNTIME_VM_CPU_X64_H_ |
| 70 | |