| 1 | // Copyright (c) 2018, 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_CONSTANTS_H_ | 
|---|
| 6 | #define RUNTIME_VM_CONSTANTS_H_ | 
|---|
| 7 |  | 
|---|
| 8 | #if defined(TARGET_ARCH_IA32) | 
|---|
| 9 | #include "vm/constants_ia32.h" | 
|---|
| 10 | #elif defined(TARGET_ARCH_X64) | 
|---|
| 11 | #include "vm/constants_x64.h" | 
|---|
| 12 | #elif defined(TARGET_ARCH_ARM) | 
|---|
| 13 | #include "vm/constants_arm.h" | 
|---|
| 14 | #elif defined(TARGET_ARCH_ARM64) | 
|---|
| 15 | #include "vm/constants_arm64.h" | 
|---|
| 16 | #else | 
|---|
| 17 | #error Unknown architecture. | 
|---|
| 18 | #endif | 
|---|
| 19 |  | 
|---|
| 20 | namespace dart { | 
|---|
| 21 |  | 
|---|
| 22 | class RegisterNames { | 
|---|
| 23 | public: | 
|---|
| 24 | static const char* RegisterName(Register reg) { | 
|---|
| 25 | ASSERT((0 <= reg) && (reg < kNumberOfCpuRegisters)); | 
|---|
| 26 | return cpu_reg_names[reg]; | 
|---|
| 27 | } | 
|---|
| 28 | static const char* FpuRegisterName(FpuRegister reg) { | 
|---|
| 29 | ASSERT((0 <= reg) && (reg < kNumberOfFpuRegisters)); | 
|---|
| 30 | return fpu_reg_names[reg]; | 
|---|
| 31 | } | 
|---|
| 32 | #if defined(TARGET_ARCH_ARM) | 
|---|
| 33 | static const char* FpuSRegisterName(SRegister reg) { | 
|---|
| 34 | ASSERT((0 <= reg) && (reg < kNumberOfSRegisters)); | 
|---|
| 35 | return fpu_s_reg_names[reg]; | 
|---|
| 36 | } | 
|---|
| 37 | static const char* FpuDRegisterName(DRegister reg) { | 
|---|
| 38 | ASSERT((0 <= reg) && (reg < kNumberOfDRegisters)); | 
|---|
| 39 | return fpu_d_reg_names[reg]; | 
|---|
| 40 | } | 
|---|
| 41 | #endif  // defined(TARGET_ARCH_ARM) | 
|---|
| 42 | }; | 
|---|
| 43 |  | 
|---|
| 44 | static constexpr bool IsArgumentRegister(Register reg) { | 
|---|
| 45 | return ((1 << reg) & CallingConventions::kArgumentRegisters) != 0; | 
|---|
| 46 | } | 
|---|
| 47 |  | 
|---|
| 48 | static constexpr bool IsFpuArgumentRegister(FpuRegister reg) { | 
|---|
| 49 | return ((1 << reg) & CallingConventions::kFpuArgumentRegisters) != 0; | 
|---|
| 50 | } | 
|---|
| 51 |  | 
|---|
| 52 | static constexpr bool IsCalleeSavedRegister(Register reg) { | 
|---|
| 53 | return ((1 << reg) & CallingConventions::kCalleeSaveCpuRegisters) != 0; | 
|---|
| 54 | } | 
|---|
| 55 |  | 
|---|
| 56 | }  // namespace dart | 
|---|
| 57 |  | 
|---|
| 58 | #endif  // RUNTIME_VM_CONSTANTS_H_ | 
|---|
| 59 |  | 
|---|