| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_CPU_ARM_H_ | 5 #ifndef VM_CPU_ARM_H_ |
| 6 #define VM_CPU_ARM_H_ | 6 #define VM_CPU_ARM_H_ |
| 7 | 7 |
| 8 #include "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/simulator.h" | 9 #include "vm/simulator.h" |
| 10 | 10 |
| 11 namespace dart { | 11 namespace dart { |
| 12 | 12 |
| 13 // TargetCPUFeatures gives CPU features for the architecture that we are | 13 // TargetCPUFeatures gives CPU features for the architecture that we are |
| 14 // generating code for. HostCPUFeatures gives the CPU features for the | 14 // generating code for. HostCPUFeatures gives the CPU features for the |
| 15 // architecture that we are actually running on. When the architectures | 15 // architecture that we are actually running on. When the architectures |
| 16 // are the same, TargetCPUFeatures will query HostCPUFeatures. When they are | 16 // are the same, TargetCPUFeatures will query HostCPUFeatures. When they are |
| 17 // different (i.e. we are running in a simulator), HostCPUFeatures will | 17 // different (i.e. we are running in a simulator), HostCPUFeatures will |
| 18 // additionally mock the options needed for the target architecture so that | 18 // additionally mock the options needed for the target architecture so that |
| 19 // they may be altered for testing. | 19 // they may be altered for testing. |
| 20 | 20 |
| 21 enum ARMVersion { |
| 22 ARMv6, |
| 23 ARMv7, |
| 24 ARMvUnknown, |
| 25 }; |
| 26 |
| 21 class HostCPUFeatures: public AllStatic { | 27 class HostCPUFeatures: public AllStatic { |
| 22 public: | 28 public: |
| 23 static void InitOnce(); | 29 static void InitOnce(); |
| 24 static void Cleanup(); | 30 static void Cleanup(); |
| 25 static const char* hardware() { | 31 static const char* hardware() { |
| 26 DEBUG_ASSERT(initialized_); | 32 DEBUG_ASSERT(initialized_); |
| 27 return hardware_; | 33 return hardware_; |
| 28 } | 34 } |
| 29 static bool integer_division_supported() { | 35 static bool integer_division_supported() { |
| 30 DEBUG_ASSERT(initialized_); | 36 DEBUG_ASSERT(initialized_); |
| 31 return integer_division_supported_; | 37 return integer_division_supported_; |
| 32 } | 38 } |
| 33 static bool neon_supported() { | 39 static bool neon_supported() { |
| 34 DEBUG_ASSERT(initialized_); | 40 DEBUG_ASSERT(initialized_); |
| 35 return neon_supported_; | 41 return neon_supported_; |
| 36 } | 42 } |
| 43 static ARMVersion arm_version() { |
| 44 DEBUG_ASSERT(initialized_); |
| 45 return arm_version_; |
| 46 } |
| 37 | 47 |
| 38 #if !defined(HOST_ARCH_ARM) | 48 #if !defined(HOST_ARCH_ARM) |
| 39 static void set_integer_division_supported(bool supported) { | 49 static void set_integer_division_supported(bool supported) { |
| 40 DEBUG_ASSERT(initialized_); | 50 DEBUG_ASSERT(initialized_); |
| 41 integer_division_supported_ = supported; | 51 integer_division_supported_ = supported; |
| 42 } | 52 } |
| 43 static void set_neon_supported(bool supported) { | 53 static void set_neon_supported(bool supported) { |
| 44 DEBUG_ASSERT(initialized_); | 54 DEBUG_ASSERT(initialized_); |
| 45 neon_supported_ = supported; | 55 neon_supported_ = supported; |
| 46 } | 56 } |
| 57 static void set_arm_version(ARMVersion version) { |
| 58 DEBUG_ASSERT(initialized_); |
| 59 arm_version_ = version; |
| 60 } |
| 47 #endif // !defined(HOST_ARCH_ARM) | 61 #endif // !defined(HOST_ARCH_ARM) |
| 48 | 62 |
| 49 private: | 63 private: |
| 50 static const char* hardware_; | 64 static const char* hardware_; |
| 51 static bool integer_division_supported_; | 65 static bool integer_division_supported_; |
| 52 static bool neon_supported_; | 66 static bool neon_supported_; |
| 67 static ARMVersion arm_version_; |
| 53 #if defined(DEBUG) | 68 #if defined(DEBUG) |
| 54 static bool initialized_; | 69 static bool initialized_; |
| 55 #endif | 70 #endif |
| 56 }; | 71 }; |
| 57 | 72 |
| 58 class TargetCPUFeatures : public AllStatic { | 73 class TargetCPUFeatures : public AllStatic { |
| 59 public: | 74 public: |
| 60 static void InitOnce() { | 75 static void InitOnce() { |
| 61 HostCPUFeatures::InitOnce(); | 76 HostCPUFeatures::InitOnce(); |
| 62 } | 77 } |
| 63 static void Cleanup() { | 78 static void Cleanup() { |
| 64 HostCPUFeatures::Cleanup(); | 79 HostCPUFeatures::Cleanup(); |
| 65 } | 80 } |
| 66 static bool double_truncate_round_supported() { | 81 static bool double_truncate_round_supported() { |
| 67 return false; | 82 return false; |
| 68 } | 83 } |
| 69 static bool integer_division_supported() { | 84 static bool integer_division_supported() { |
| 70 return HostCPUFeatures::integer_division_supported(); | 85 return HostCPUFeatures::integer_division_supported(); |
| 71 } | 86 } |
| 72 static bool neon_supported() { | 87 static bool neon_supported() { |
| 73 return HostCPUFeatures::neon_supported(); | 88 return HostCPUFeatures::neon_supported(); |
| 74 } | 89 } |
| 75 static const char* hardware() { | 90 static const char* hardware() { |
| 76 return HostCPUFeatures::hardware(); | 91 return HostCPUFeatures::hardware(); |
| 77 } | 92 } |
| 93 static ARMVersion arm_version() { |
| 94 return HostCPUFeatures::arm_version(); |
| 95 } |
| 78 }; | 96 }; |
| 79 | 97 |
| 80 } // namespace dart | 98 } // namespace dart |
| 81 | 99 |
| 82 #endif // VM_CPU_ARM_H_ | 100 #endif // VM_CPU_ARM_H_ |
| OLD | NEW |