| 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 { | 21 enum ARMVersion { |
| 22 ARMv5TE, |
| 22 ARMv6, | 23 ARMv6, |
| 23 ARMv7, | 24 ARMv7, |
| 24 ARMvUnknown, | 25 ARMvUnknown, |
| 25 }; | 26 }; |
| 26 | 27 |
| 27 class HostCPUFeatures: public AllStatic { | 28 class HostCPUFeatures: public AllStatic { |
| 28 public: | 29 public: |
| 29 static void InitOnce(); | 30 static void InitOnce(); |
| 30 static void Cleanup(); | 31 static void Cleanup(); |
| 31 static const char* hardware() { | 32 static const char* hardware() { |
| 32 DEBUG_ASSERT(initialized_); | 33 DEBUG_ASSERT(initialized_); |
| 33 return hardware_; | 34 return hardware_; |
| 34 } | 35 } |
| 35 static bool integer_division_supported() { | 36 static bool integer_division_supported() { |
| 36 DEBUG_ASSERT(initialized_); | 37 DEBUG_ASSERT(initialized_); |
| 37 return integer_division_supported_; | 38 return integer_division_supported_; |
| 38 } | 39 } |
| 40 static bool vfp_supported() { |
| 41 DEBUG_ASSERT(initialized_); |
| 42 return vfp_supported_; |
| 43 } |
| 39 static bool neon_supported() { | 44 static bool neon_supported() { |
| 40 DEBUG_ASSERT(initialized_); | 45 DEBUG_ASSERT(initialized_); |
| 41 return neon_supported_; | 46 return neon_supported_; |
| 42 } | 47 } |
| 43 static ARMVersion arm_version() { | 48 static ARMVersion arm_version() { |
| 44 DEBUG_ASSERT(initialized_); | 49 DEBUG_ASSERT(initialized_); |
| 45 return arm_version_; | 50 return arm_version_; |
| 46 } | 51 } |
| 47 | 52 |
| 48 #if !defined(HOST_ARCH_ARM) | 53 #if !defined(HOST_ARCH_ARM) |
| 49 static void set_integer_division_supported(bool supported) { | 54 static void set_integer_division_supported(bool supported) { |
| 50 DEBUG_ASSERT(initialized_); | 55 DEBUG_ASSERT(initialized_); |
| 51 integer_division_supported_ = supported; | 56 integer_division_supported_ = supported; |
| 52 } | 57 } |
| 58 static void set_vfp_supported(bool supported) { |
| 59 DEBUG_ASSERT(initialized_); |
| 60 vfp_supported_ = supported; |
| 61 } |
| 53 static void set_neon_supported(bool supported) { | 62 static void set_neon_supported(bool supported) { |
| 54 DEBUG_ASSERT(initialized_); | 63 DEBUG_ASSERT(initialized_); |
| 55 neon_supported_ = supported; | 64 neon_supported_ = supported; |
| 56 } | 65 } |
| 57 static void set_arm_version(ARMVersion version) { | 66 static void set_arm_version(ARMVersion version) { |
| 58 DEBUG_ASSERT(initialized_); | 67 DEBUG_ASSERT(initialized_); |
| 59 arm_version_ = version; | 68 arm_version_ = version; |
| 60 } | 69 } |
| 61 #endif // !defined(HOST_ARCH_ARM) | 70 #endif // !defined(HOST_ARCH_ARM) |
| 62 | 71 |
| 63 private: | 72 private: |
| 64 static const char* hardware_; | 73 static const char* hardware_; |
| 65 static bool integer_division_supported_; | 74 static bool integer_division_supported_; |
| 75 static bool vfp_supported_; |
| 66 static bool neon_supported_; | 76 static bool neon_supported_; |
| 67 static ARMVersion arm_version_; | 77 static ARMVersion arm_version_; |
| 68 #if defined(DEBUG) | 78 #if defined(DEBUG) |
| 69 static bool initialized_; | 79 static bool initialized_; |
| 70 #endif | 80 #endif |
| 71 }; | 81 }; |
| 72 | 82 |
| 73 class TargetCPUFeatures : public AllStatic { | 83 class TargetCPUFeatures : public AllStatic { |
| 74 public: | 84 public: |
| 75 static void InitOnce() { | 85 static void InitOnce() { |
| 76 HostCPUFeatures::InitOnce(); | 86 HostCPUFeatures::InitOnce(); |
| 77 } | 87 } |
| 78 static void Cleanup() { | 88 static void Cleanup() { |
| 79 HostCPUFeatures::Cleanup(); | 89 HostCPUFeatures::Cleanup(); |
| 80 } | 90 } |
| 81 static bool double_truncate_round_supported() { | 91 static bool double_truncate_round_supported() { |
| 82 return false; | 92 return false; |
| 83 } | 93 } |
| 84 static bool integer_division_supported() { | 94 static bool integer_division_supported() { |
| 85 return HostCPUFeatures::integer_division_supported(); | 95 return HostCPUFeatures::integer_division_supported(); |
| 86 } | 96 } |
| 97 static bool vfp_supported() { |
| 98 return HostCPUFeatures::vfp_supported(); |
| 99 } |
| 87 static bool neon_supported() { | 100 static bool neon_supported() { |
| 88 return HostCPUFeatures::neon_supported(); | 101 return HostCPUFeatures::neon_supported(); |
| 89 } | 102 } |
| 90 static const char* hardware() { | 103 static const char* hardware() { |
| 91 return HostCPUFeatures::hardware(); | 104 return HostCPUFeatures::hardware(); |
| 92 } | 105 } |
| 93 static ARMVersion arm_version() { | 106 static ARMVersion arm_version() { |
| 94 return HostCPUFeatures::arm_version(); | 107 return HostCPUFeatures::arm_version(); |
| 95 } | 108 } |
| 96 }; | 109 }; |
| 97 | 110 |
| 98 } // namespace dart | 111 } // namespace dart |
| 99 | 112 |
| 100 #endif // VM_CPU_ARM_H_ | 113 #endif // VM_CPU_ARM_H_ |
| OLD | NEW |