OLD | NEW |
1 //===- subzero/src/assembler_ia32.h - Assembler for x86-32 ------*- C++ -*-===// | 1 //===- subzero/src/assembler_ia32.h - Assembler for x86-32 ------*- C++ -*-===// |
2 // | 2 // |
3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 3 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
4 // for details. All rights reserved. Use of this source code is governed by a | 4 // for details. All rights reserved. Use of this source code is governed by a |
5 // BSD-style license that can be found in the LICENSE file. | 5 // BSD-style license that can be found in the LICENSE file. |
6 // | 6 // |
7 // Modified by the Subzero authors. | 7 // Modified by the Subzero authors. |
8 // | 8 // |
9 //===----------------------------------------------------------------------===// | 9 //===----------------------------------------------------------------------===// |
10 // | 10 // |
(...skipping 30 matching lines...) Expand all Loading... |
41 | 41 |
42 const int MAX_NOP_SIZE = 8; | 42 const int MAX_NOP_SIZE = 8; |
43 | 43 |
44 enum ScaleFactor { TIMES_1 = 0, TIMES_2 = 1, TIMES_4 = 2, TIMES_8 = 3 }; | 44 enum ScaleFactor { TIMES_1 = 0, TIMES_2 = 1, TIMES_4 = 2, TIMES_8 = 3 }; |
45 | 45 |
46 class Immediate { | 46 class Immediate { |
47 Immediate(const Immediate &) = delete; | 47 Immediate(const Immediate &) = delete; |
48 Immediate &operator=(const Immediate &) = delete; | 48 Immediate &operator=(const Immediate &) = delete; |
49 | 49 |
50 public: | 50 public: |
51 explicit Immediate(int32_t value) : value_(value), fixup_(nullptr) {} | 51 explicit Immediate(int32_t value) : value_(value) {} |
52 | 52 |
53 Immediate(RelocOffsetT offset, AssemblerFixup *fixup) | 53 Immediate(RelocOffsetT offset, AssemblerFixup *fixup) |
54 : value_(offset), fixup_(fixup) { | 54 : value_(offset), fixup_(fixup) { |
55 // Use the Offset in the "value" for now. If we decide to process fixups, | 55 // Use the Offset in the "value" for now. If we decide to process fixups, |
56 // we'll need to patch that offset with the true value. | 56 // we'll need to patch that offset with the true value. |
57 } | 57 } |
58 | 58 |
59 int32_t value() const { return value_; } | 59 int32_t value() const { return value_; } |
60 AssemblerFixup *fixup() const { return fixup_; } | 60 AssemblerFixup *fixup() const { return fixup_; } |
61 | 61 |
62 bool is_int8() const { | 62 bool is_int8() const { |
63 // We currently only allow 32-bit fixups, and they usually have value = 0, | 63 // We currently only allow 32-bit fixups, and they usually have value = 0, |
64 // so if fixup_ != nullptr, it shouldn't be classified as int8/16. | 64 // so if fixup_ != nullptr, it shouldn't be classified as int8/16. |
65 return fixup_ == nullptr && Utils::IsInt(8, value_); | 65 return fixup_ == nullptr && Utils::IsInt(8, value_); |
66 } | 66 } |
67 bool is_uint8() const { | 67 bool is_uint8() const { |
68 return fixup_ == nullptr && Utils::IsUint(8, value_); | 68 return fixup_ == nullptr && Utils::IsUint(8, value_); |
69 } | 69 } |
70 bool is_uint16() const { | 70 bool is_uint16() const { |
71 return fixup_ == nullptr && Utils::IsUint(16, value_); | 71 return fixup_ == nullptr && Utils::IsUint(16, value_); |
72 } | 72 } |
73 | 73 |
74 private: | 74 private: |
75 const int32_t value_; | 75 const int32_t value_; |
76 AssemblerFixup *fixup_; | 76 AssemblerFixup *fixup_ = nullptr; |
77 }; | 77 }; |
78 | 78 |
79 class Operand { | 79 class Operand { |
80 public: | 80 public: |
81 Operand(const Operand &other) : length_(other.length_), fixup_(other.fixup_) { | 81 Operand(const Operand &other) : length_(other.length_), fixup_(other.fixup_) { |
82 memmove(&encoding_[0], &other.encoding_[0], other.length_); | 82 memmove(&encoding_[0], &other.encoding_[0], other.length_); |
83 } | 83 } |
84 | 84 |
85 Operand &operator=(const Operand &other) { | 85 Operand &operator=(const Operand &other) { |
86 length_ = other.length_; | 86 length_ = other.length_; |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 // Use the Offset in the displacement for now. If we decide to process | 236 // Use the Offset in the displacement for now. If we decide to process |
237 // fixups later, we'll need to patch up the emitted displacement. | 237 // fixups later, we'll need to patch up the emitted displacement. |
238 result.SetDisp32(Offset); | 238 result.SetDisp32(Offset); |
239 result.SetFixup(fixup); | 239 result.SetFixup(fixup); |
240 return result; | 240 return result; |
241 } | 241 } |
242 | 242 |
243 static Address ofConstPool(Assembler *Asm, const Constant *Imm); | 243 static Address ofConstPool(Assembler *Asm, const Constant *Imm); |
244 | 244 |
245 private: | 245 private: |
246 Address() {} // Needed by Address::Absolute. | 246 Address() = default; // Needed by Address::Absolute. |
247 }; | 247 }; |
248 | 248 |
249 class Label { | 249 class Label { |
250 Label(const Label &) = delete; | 250 Label(const Label &) = delete; |
251 Label &operator=(const Label &) = delete; | 251 Label &operator=(const Label &) = delete; |
252 | 252 |
253 public: | 253 public: |
254 Label() : position_(0), num_unresolved_(0) { | 254 Label() { |
255 #ifndef NDEBUG | 255 #ifndef NDEBUG |
256 for (int i = 0; i < kMaxUnresolvedBranches; i++) { | 256 for (int i = 0; i < kMaxUnresolvedBranches; i++) { |
257 unresolved_near_positions_[i] = -1; | 257 unresolved_near_positions_[i] = -1; |
258 } | 258 } |
259 #endif // !NDEBUG | 259 #endif // !NDEBUG |
260 } | 260 } |
261 | 261 |
262 ~Label() {} | 262 ~Label() = default; |
263 | 263 |
264 void FinalCheck() const { | 264 void FinalCheck() const { |
265 // Assert if label is being destroyed with unresolved branches pending. | 265 // Assert if label is being destroyed with unresolved branches pending. |
266 assert(!IsLinked()); | 266 assert(!IsLinked()); |
267 assert(!HasNear()); | 267 assert(!HasNear()); |
268 } | 268 } |
269 | 269 |
270 // TODO(jvoung): why are labels offset by this? | 270 // TODO(jvoung): why are labels offset by this? |
271 static const uint32_t kWordSize = sizeof(uint32_t); | 271 static const uint32_t kWordSize = sizeof(uint32_t); |
272 | 272 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 } | 316 } |
317 | 317 |
318 void NearLinkTo(intptr_t position) { | 318 void NearLinkTo(intptr_t position) { |
319 assert(!IsBound()); | 319 assert(!IsBound()); |
320 assert(num_unresolved_ < kMaxUnresolvedBranches); | 320 assert(num_unresolved_ < kMaxUnresolvedBranches); |
321 unresolved_near_positions_[num_unresolved_++] = position; | 321 unresolved_near_positions_[num_unresolved_++] = position; |
322 } | 322 } |
323 | 323 |
324 static const int kMaxUnresolvedBranches = 20; | 324 static const int kMaxUnresolvedBranches = 20; |
325 | 325 |
326 intptr_t position_; | 326 intptr_t position_ = 0; |
327 intptr_t num_unresolved_; | 327 intptr_t num_unresolved_ = 0; |
328 // TODO(stichnot,jvoung): Can this instead be | 328 // TODO(stichnot,jvoung): Can this instead be |
329 // llvm::SmallVector<intptr_t, kMaxUnresolvedBranches> ? | 329 // llvm::SmallVector<intptr_t, kMaxUnresolvedBranches> ? |
330 intptr_t unresolved_near_positions_[kMaxUnresolvedBranches]; | 330 intptr_t unresolved_near_positions_[kMaxUnresolvedBranches]; |
331 | 331 |
332 friend class AssemblerX8632; | 332 friend class AssemblerX8632; |
333 }; | 333 }; |
334 | 334 |
335 class AssemblerX8632 : public Assembler { | 335 class AssemblerX8632 : public Assembler { |
336 AssemblerX8632(const AssemblerX8632 &) = delete; | 336 AssemblerX8632(const AssemblerX8632 &) = delete; |
337 AssemblerX8632 &operator=(const AssemblerX8632 &) = delete; | 337 AssemblerX8632 &operator=(const AssemblerX8632 &) = delete; |
(...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
915 inline void AssemblerX8632::emitFixup(AssemblerFixup *fixup) { | 915 inline void AssemblerX8632::emitFixup(AssemblerFixup *fixup) { |
916 Buffer.emitFixup(fixup); | 916 Buffer.emitFixup(fixup); |
917 } | 917 } |
918 | 918 |
919 inline void AssemblerX8632::emitOperandSizeOverride() { emitUint8(0x66); } | 919 inline void AssemblerX8632::emitOperandSizeOverride() { emitUint8(0x66); } |
920 | 920 |
921 } // end of namespace X8632 | 921 } // end of namespace X8632 |
922 } // end of namespace Ice | 922 } // end of namespace Ice |
923 | 923 |
924 #endif // SUBZERO_SRC_ICEASSEMBLERX8632_H | 924 #endif // SUBZERO_SRC_ICEASSEMBLERX8632_H |
OLD | NEW |