| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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_ASSEMBLER_ARM_H_ | 5 #ifndef VM_ASSEMBLER_ARM_H_ |
| 6 #define VM_ASSEMBLER_ARM_H_ | 6 #define VM_ASSEMBLER_ARM_H_ |
| 7 | 7 |
| 8 #ifndef VM_ASSEMBLER_H_ | 8 #ifndef VM_ASSEMBLER_H_ |
| 9 #error Do not include assembler_arm.h directly; use assembler.h instead. | 9 #error Do not include assembler_arm.h directly; use assembler.h instead. |
| 10 #endif | 10 #endif |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 | 152 |
| 153 uint32_t encoding() const { | 153 uint32_t encoding() const { |
| 154 ASSERT(is_valid()); | 154 ASSERT(is_valid()); |
| 155 return encoding_; | 155 return encoding_; |
| 156 } | 156 } |
| 157 | 157 |
| 158 uint32_t type_; // Encodes the type field (bits 27-25) in the instruction. | 158 uint32_t type_; // Encodes the type field (bits 27-25) in the instruction. |
| 159 uint32_t encoding_; | 159 uint32_t encoding_; |
| 160 | 160 |
| 161 friend class Assembler; | 161 friend class Assembler; |
| 162 friend class Address; |
| 162 }; | 163 }; |
| 163 | 164 |
| 164 | 165 |
| 165 enum LoadOperandType { | 166 enum LoadOperandType { |
| 166 kLoadSignedByte, | 167 kLoadSignedByte, |
| 167 kLoadUnsignedByte, | 168 kLoadUnsignedByte, |
| 168 kLoadSignedHalfword, | 169 kLoadSignedHalfword, |
| 169 kLoadUnsignedHalfword, | 170 kLoadUnsignedHalfword, |
| 170 kLoadWord, | 171 kLoadWord, |
| 171 kLoadWordPair, | 172 kLoadWordPair, |
| (...skipping 21 matching lines...) Expand all Loading... |
| 193 IB = (8|4|0) << 21, // increment before | 194 IB = (8|4|0) << 21, // increment before |
| 194 DA_W = (0|0|1) << 21, // decrement after with writeback to base | 195 DA_W = (0|0|1) << 21, // decrement after with writeback to base |
| 195 IA_W = (0|4|1) << 21, // increment after with writeback to base | 196 IA_W = (0|4|1) << 21, // increment after with writeback to base |
| 196 DB_W = (8|0|1) << 21, // decrement before with writeback to base | 197 DB_W = (8|0|1) << 21, // decrement before with writeback to base |
| 197 IB_W = (8|4|1) << 21 // increment before with writeback to base | 198 IB_W = (8|4|1) << 21 // increment before with writeback to base |
| 198 }; | 199 }; |
| 199 | 200 |
| 200 | 201 |
| 201 class Address : public ValueObject { | 202 class Address : public ValueObject { |
| 202 public: | 203 public: |
| 204 enum OffsetKind { |
| 205 Immediate, |
| 206 ShiftedRegister, |
| 207 }; |
| 208 |
| 203 // Memory operand addressing mode | 209 // Memory operand addressing mode |
| 204 enum Mode { | 210 enum Mode { |
| 205 // bit encoding P U W | 211 // bit encoding P U W |
| 206 Offset = (8|4|0) << 21, // offset (w/o writeback to base) | 212 Offset = (8|4|0) << 21, // offset (w/o writeback to base) |
| 207 PreIndex = (8|4|1) << 21, // pre-indexed addressing with writeback | 213 PreIndex = (8|4|1) << 21, // pre-indexed addressing with writeback |
| 208 PostIndex = (0|4|0) << 21, // post-indexed addressing with writeback | 214 PostIndex = (0|4|0) << 21, // post-indexed addressing with writeback |
| 209 NegOffset = (8|0|0) << 21, // negative offset (w/o writeback to base) | 215 NegOffset = (8|0|0) << 21, // negative offset (w/o writeback to base) |
| 210 NegPreIndex = (8|0|1) << 21, // negative pre-indexed with writeback | 216 NegPreIndex = (8|0|1) << 21, // negative pre-indexed with writeback |
| 211 NegPostIndex = (0|0|0) << 21 // negative post-indexed with writeback | 217 NegPostIndex = (0|0|0) << 21 // negative post-indexed with writeback |
| 212 }; | 218 }; |
| 213 | 219 |
| 214 Address(const Address& other) : ValueObject(), encoding_(other.encoding_) { } | 220 Address(const Address& other) |
| 221 : ValueObject(), encoding_(other.encoding_), kind_(other.kind_) { |
| 222 } |
| 215 | 223 |
| 216 Address& operator=(const Address& other) { | 224 Address& operator=(const Address& other) { |
| 217 encoding_ = other.encoding_; | 225 encoding_ = other.encoding_; |
| 226 kind_ = other.kind_; |
| 218 return *this; | 227 return *this; |
| 219 } | 228 } |
| 220 | 229 |
| 221 explicit Address(Register rn, int32_t offset = 0, Mode am = Offset) { | 230 explicit Address(Register rn, int32_t offset = 0, Mode am = Offset) { |
| 222 ASSERT(Utils::IsAbsoluteUint(12, offset)); | 231 ASSERT(Utils::IsAbsoluteUint(12, offset)); |
| 232 kind_ = Immediate; |
| 223 if (offset < 0) { | 233 if (offset < 0) { |
| 224 encoding_ = (am ^ (1 << kUShift)) | -offset; // Flip U to adjust sign. | 234 encoding_ = (am ^ (1 << kUShift)) | -offset; // Flip U to adjust sign. |
| 225 } else { | 235 } else { |
| 226 encoding_ = am | offset; | 236 encoding_ = am | offset; |
| 227 } | 237 } |
| 228 encoding_ |= static_cast<uint32_t>(rn) << kRnShift; | 238 encoding_ |= static_cast<uint32_t>(rn) << kRnShift; |
| 229 } | 239 } |
| 230 | 240 |
| 241 explicit Address(Register rn, Register rm, Shift shift = LSL, |
| 242 uint32_t shift_imm = 0, Mode am = Offset) { |
| 243 ShifterOperand so(rm, shift, shift_imm); |
| 244 |
| 245 kind_ = ShiftedRegister; |
| 246 encoding_ = so.encoding() | am | (static_cast<uint32_t>(rn) << kRnShift); |
| 247 } |
| 248 |
| 231 static bool CanHoldLoadOffset(LoadOperandType type, int offset); | 249 static bool CanHoldLoadOffset(LoadOperandType type, int offset); |
| 232 static bool CanHoldStoreOffset(StoreOperandType type, int offset); | 250 static bool CanHoldStoreOffset(StoreOperandType type, int offset); |
| 233 | 251 |
| 234 private: | 252 private: |
| 235 uint32_t encoding() const { return encoding_; } | 253 uint32_t encoding() const { return encoding_; } |
| 236 | 254 |
| 237 // Encoding for addressing mode 3. | 255 // Encoding for addressing mode 3. |
| 238 uint32_t encoding3() const; | 256 uint32_t encoding3() const; |
| 239 | 257 |
| 240 // Encoding for vfp load/store addressing. | 258 // Encoding for vfp load/store addressing. |
| 241 uint32_t vencoding() const; | 259 uint32_t vencoding() const; |
| 242 | 260 |
| 261 OffsetKind kind() const { return kind_; } |
| 262 |
| 243 uint32_t encoding_; | 263 uint32_t encoding_; |
| 244 | 264 |
| 265 OffsetKind kind_; |
| 266 |
| 245 friend class Assembler; | 267 friend class Assembler; |
| 246 }; | 268 }; |
| 247 | 269 |
| 248 | 270 |
| 249 class FieldAddress : public Address { | 271 class FieldAddress : public Address { |
| 250 public: | 272 public: |
| 251 FieldAddress(Register base, int32_t disp) | 273 FieldAddress(Register base, int32_t disp) |
| 252 : Address(base, disp - kHeapObjectTag) { } | 274 : Address(base, disp - kHeapObjectTag) { } |
| 253 | 275 |
| 254 FieldAddress(const FieldAddress& other) : Address(other) { } | 276 FieldAddress(const FieldAddress& other) : Address(other) { } |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 638 return *reg1 - *reg2; | 660 return *reg1 - *reg2; |
| 639 } | 661 } |
| 640 | 662 |
| 641 DISALLOW_ALLOCATION(); | 663 DISALLOW_ALLOCATION(); |
| 642 DISALLOW_COPY_AND_ASSIGN(Assembler); | 664 DISALLOW_COPY_AND_ASSIGN(Assembler); |
| 643 }; | 665 }; |
| 644 | 666 |
| 645 } // namespace dart | 667 } // namespace dart |
| 646 | 668 |
| 647 #endif // VM_ASSEMBLER_ARM_H_ | 669 #endif // VM_ASSEMBLER_ARM_H_ |
| OLD | NEW |