| 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_CONSTANTS_ARM64_H_ | 5 #ifndef VM_CONSTANTS_ARM64_H_ |
| 6 #define VM_CONSTANTS_ARM64_H_ | 6 #define VM_CONSTANTS_ARM64_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 | 9 |
| 10 namespace dart { | 10 namespace dart { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 R8 = 8, | 22 R8 = 8, |
| 23 R9 = 9, | 23 R9 = 9, |
| 24 R10 = 10, | 24 R10 = 10, |
| 25 R11 = 11, | 25 R11 = 11, |
| 26 R12 = 12, | 26 R12 = 12, |
| 27 R13 = 13, | 27 R13 = 13, |
| 28 R14 = 14, | 28 R14 = 14, |
| 29 R15 = 15, | 29 R15 = 15, |
| 30 R16 = 16, // IP0 aka TMP | 30 R16 = 16, // IP0 aka TMP |
| 31 R17 = 17, // IP1 aka TMP2 | 31 R17 = 17, // IP1 aka TMP2 |
| 32 R18 = 18, | 32 R18 = 18, // SP in Dart code. |
| 33 R19 = 19, | 33 R19 = 19, |
| 34 R20 = 20, | 34 R20 = 20, |
| 35 R21 = 21, | 35 R21 = 21, |
| 36 R22 = 22, | 36 R22 = 22, |
| 37 R23 = 23, | 37 R23 = 23, |
| 38 R24 = 24, | 38 R24 = 24, |
| 39 R25 = 25, | 39 R25 = 25, |
| 40 R26 = 26, | 40 R26 = 26, |
| 41 kLastFreeCpuRegister = 26, | 41 kLastFreeCpuRegister = 26, |
| 42 R27 = 27, // PP | 42 R27 = 27, // PP |
| 43 R28 = 28, // CTX | 43 R28 = 28, // CTX |
| 44 R29 = 29, // FP | 44 R29 = 29, // FP |
| 45 R30 = 30, // LR | 45 R30 = 30, // LR |
| 46 R31 = 31, // ZR, SP | 46 R31 = 31, // ZR, CSP |
| 47 kNumberOfCpuRegisters = 32, | 47 kNumberOfCpuRegisters = 32, |
| 48 kNoRegister = -1, | 48 kNoRegister = -1, |
| 49 | 49 |
| 50 // These registers both use the encoding R31, but to avoid mistakes we give | 50 // These registers both use the encoding R31, but to avoid mistakes we give |
| 51 // them different values, and then translate before encoding. | 51 // them different values, and then translate before encoding. |
| 52 SP = 32, | 52 CSP = 32, |
| 53 ZR = 33, | 53 ZR = 33, |
| 54 | 54 |
| 55 // Aliases. | 55 // Aliases. |
| 56 IP0 = R16, | 56 IP0 = R16, |
| 57 IP1 = R17, | 57 IP1 = R17, |
| 58 SP = R18, |
| 58 FP = R29, | 59 FP = R29, |
| 59 LR = R30, | 60 LR = R30, |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 enum VRegister { | 63 enum VRegister { |
| 63 V0 = 0, | 64 V0 = 0, |
| 64 V1 = 1, | 65 V1 = 1, |
| 65 V2 = 2, | 66 V2 = 2, |
| 66 V3 = 3, | 67 V3 = 3, |
| 67 V4 = 4, | 68 V4 = 4, |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 const int kNumberOfFpuRegisters = kNumberOfVRegisters; | 106 const int kNumberOfFpuRegisters = kNumberOfVRegisters; |
| 106 const FpuRegister kNoFpuRegister = kNoVRegister; | 107 const FpuRegister kNoFpuRegister = kNoVRegister; |
| 107 | 108 |
| 108 // Register aliases. | 109 // Register aliases. |
| 109 const Register TMP = R16; // Used as scratch register by assembler. | 110 const Register TMP = R16; // Used as scratch register by assembler. |
| 110 const Register TMP2 = R17; | 111 const Register TMP2 = R17; |
| 111 const Register CTX = R28; // Caches current context in generated code. | 112 const Register CTX = R28; // Caches current context in generated code. |
| 112 const Register PP = R27; // Caches object pool pointer in generated code. | 113 const Register PP = R27; // Caches object pool pointer in generated code. |
| 113 const Register kNoPP = kNoRegister; | 114 const Register kNoPP = kNoRegister; |
| 114 const Register FPREG = FP; // Frame pointer register. | 115 const Register FPREG = FP; // Frame pointer register. |
| 115 const Register SPREG = R31; // Stack pointer register. | 116 const Register SPREG = R18; // Stack pointer register. |
| 116 const Register ICREG = R5; // IC data register. | 117 const Register ICREG = R5; // IC data register. |
| 117 | 118 |
| 118 // Exception object is passed in this register to the catch handlers when an | 119 // Exception object is passed in this register to the catch handlers when an |
| 119 // exception is thrown. | 120 // exception is thrown. |
| 120 const Register kExceptionObjectReg = R0; | 121 const Register kExceptionObjectReg = R0; |
| 121 | 122 |
| 122 // Stack trace object is passed in this register to the catch handlers when | 123 // Stack trace object is passed in this register to the catch handlers when |
| 123 // an exception is thrown. | 124 // an exception is thrown. |
| 124 const Register kStackTraceObjectReg = R1; | 125 const Register kStackTraceObjectReg = R1; |
| 125 | 126 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 148 const VRegister kAbiFirstPreservedFpuReg = V8; | 149 const VRegister kAbiFirstPreservedFpuReg = V8; |
| 149 const VRegister kAbiLastPreservedFpuReg = V15; | 150 const VRegister kAbiLastPreservedFpuReg = V15; |
| 150 const int kAbiPreservedFpuRegCount = 8; | 151 const int kAbiPreservedFpuRegCount = 8; |
| 151 | 152 |
| 152 // CPU registers available to Dart allocator. | 153 // CPU registers available to Dart allocator. |
| 153 const RegList kDartAvailableCpuRegs = | 154 const RegList kDartAvailableCpuRegs = |
| 154 (1 << R0) | (1 << R1) | (1 << R2) | (1 << R3) | | 155 (1 << R0) | (1 << R1) | (1 << R2) | (1 << R3) | |
| 155 (1 << R4) | (1 << R5) | (1 << R6) | (1 << R7) | | 156 (1 << R4) | (1 << R5) | (1 << R6) | (1 << R7) | |
| 156 (1 << R8) | (1 << R9) | (1 << R10) | (1 << R11) | | 157 (1 << R8) | (1 << R9) | (1 << R10) | (1 << R11) | |
| 157 (1 << R12) | (1 << R13) | (1 << R14) | (1 << R15) | | 158 (1 << R12) | (1 << R13) | (1 << R14) | (1 << R15) | |
| 158 (1 << R18) | (1 << R19) | (1 << R20) | (1 << R21) | | 159 (1 << R19) | (1 << R20) | (1 << R21) | (1 << R22) | |
| 159 (1 << R22) | (1 << R23) | (1 << R24) | (1 << R25) | | 160 (1 << R23) | (1 << R24) | (1 << R25) | (1 << R26); |
| 160 (1 << R26); | |
| 161 | 161 |
| 162 // Registers available to Dart that are not preserved by runtime calls. | 162 // Registers available to Dart that are not preserved by runtime calls. |
| 163 const RegList kDartVolatileCpuRegs = | 163 const RegList kDartVolatileCpuRegs = |
| 164 kDartAvailableCpuRegs & ~kAbiPreservedCpuRegs; | 164 kDartAvailableCpuRegs & ~kAbiPreservedCpuRegs; |
| 165 const Register kDartFirstVolatileCpuReg = R0; | 165 const Register kDartFirstVolatileCpuReg = R0; |
| 166 const Register kDartLastVolatileCpuReg = R18; | 166 const Register kDartLastVolatileCpuReg = R15; |
| 167 const int kDartVolatileCpuRegCount = 17; // Excluding R16 and R17. | 167 const int kDartVolatileCpuRegCount = 16; |
| 168 const int kDartVolatileFpuRegCount = 24; | 168 const int kDartVolatileFpuRegCount = 24; |
| 169 | 169 |
| 170 static inline Register ConcreteRegister(Register r) { | 170 static inline Register ConcreteRegister(Register r) { |
| 171 return ((r == ZR) || (r == SP)) ? R31 : r; | 171 return ((r == ZR) || (r == CSP)) ? R31 : r; |
| 172 } | 172 } |
| 173 | 173 |
| 174 // Values for the condition field as defined in section A3.2. | 174 // Values for the condition field as defined in section A3.2. |
| 175 enum Condition { | 175 enum Condition { |
| 176 kNoCondition = -1, | 176 kNoCondition = -1, |
| 177 EQ = 0, // equal | 177 EQ = 0, // equal |
| 178 NE = 1, // not equal | 178 NE = 1, // not equal |
| 179 CS = 2, // carry set/unsigned higher or same | 179 CS = 2, // carry set/unsigned higher or same |
| 180 CC = 3, // carry clear/unsigned lower | 180 CC = 3, // carry clear/unsigned lower |
| 181 MI = 4, // minus/negative | 181 MI = 4, // minus/negative |
| (...skipping 718 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 900 | 900 |
| 901 // Instruction identification. | 901 // Instruction identification. |
| 902 #define IS_OP(op) \ | 902 #define IS_OP(op) \ |
| 903 inline bool Is##op##Op() const { \ | 903 inline bool Is##op##Op() const { \ |
| 904 return ((InstructionBits() & op##Mask) == (op##Fixed & op##Mask)); } | 904 return ((InstructionBits() & op##Mask) == (op##Fixed & op##Mask)); } |
| 905 APPLY_OP_LIST(IS_OP) | 905 APPLY_OP_LIST(IS_OP) |
| 906 #undef IS_OP | 906 #undef IS_OP |
| 907 | 907 |
| 908 inline bool HasS() const { return (SField() == 1); } | 908 inline bool HasS() const { return (SField() == 1); } |
| 909 | 909 |
| 910 // Indicate whether Rd can be the SP or ZR. This does not check that the | 910 // Indicate whether Rd can be the CSP or ZR. This does not check that the |
| 911 // instruction actually has an Rd field. | 911 // instruction actually has an Rd field. |
| 912 R31Type RdMode() const { | 912 R31Type RdMode() const { |
| 913 // The following instructions use SP as Rd: | 913 // The following instructions use CSP as Rd: |
| 914 // Add/sub (immediate) when not setting the flags. | 914 // Add/sub (immediate) when not setting the flags. |
| 915 // Add/sub (extended) when not setting the flags. | 915 // Add/sub (extended) when not setting the flags. |
| 916 // Logical (immediate) when not setting the flags. | 916 // Logical (immediate) when not setting the flags. |
| 917 // Otherwise, R31 is the ZR. | 917 // Otherwise, R31 is the ZR. |
| 918 if (IsAddSubImmOp() || (IsAddSubShiftExtOp() && IsExtend())) { | 918 if (IsAddSubImmOp() || (IsAddSubShiftExtOp() && IsExtend())) { |
| 919 if (HasS()) { | 919 if (HasS()) { |
| 920 return R31IsZR; | 920 return R31IsZR; |
| 921 } else { | 921 } else { |
| 922 return R31IsSP; | 922 return R31IsSP; |
| 923 } | 923 } |
| 924 } | 924 } |
| 925 // TODO(zra): Handle for logical immediate operations. | 925 // TODO(zra): Handle for logical immediate operations. |
| 926 return R31IsZR; | 926 return R31IsZR; |
| 927 } | 927 } |
| 928 | 928 |
| 929 // Indicate whether Rn can be SP or ZR. This does not check that the | 929 // Indicate whether Rn can be CSP or ZR. This does not check that the |
| 930 // instruction actually has an Rn field. | 930 // instruction actually has an Rn field. |
| 931 R31Type RnMode() const { | 931 R31Type RnMode() const { |
| 932 // The following instructions use SP as Rn: | 932 // The following instructions use CSP as Rn: |
| 933 // All loads and stores. | 933 // All loads and stores. |
| 934 // Add/sub (immediate). | 934 // Add/sub (immediate). |
| 935 // Add/sub (extended). | 935 // Add/sub (extended). |
| 936 // Otherwise, r31 is ZR. | 936 // Otherwise, r31 is ZR. |
| 937 if (IsLoadStoreOp() || | 937 if (IsLoadStoreOp() || |
| 938 IsAddSubImmOp() || | 938 IsAddSubImmOp() || |
| 939 (IsAddSubShiftExtOp() && IsExtend())) { | 939 (IsAddSubShiftExtOp() && IsExtend())) { |
| 940 return R31IsSP; | 940 return R31IsSP; |
| 941 } | 941 } |
| 942 return R31IsZR; | 942 return R31IsZR; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 static Instr* At(uword pc) { return reinterpret_cast<Instr*>(pc); } | 1016 static Instr* At(uword pc) { return reinterpret_cast<Instr*>(pc); } |
| 1017 | 1017 |
| 1018 private: | 1018 private: |
| 1019 DISALLOW_ALLOCATION(); | 1019 DISALLOW_ALLOCATION(); |
| 1020 DISALLOW_IMPLICIT_CONSTRUCTORS(Instr); | 1020 DISALLOW_IMPLICIT_CONSTRUCTORS(Instr); |
| 1021 }; | 1021 }; |
| 1022 | 1022 |
| 1023 } // namespace dart | 1023 } // namespace dart |
| 1024 | 1024 |
| 1025 #endif // VM_CONSTANTS_ARM64_H_ | 1025 #endif // VM_CONSTANTS_ARM64_H_ |
| OLD | NEW |