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 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 2 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file |
3 // for details. All rights reserved. Use of this source code is governed by a | 3 // for details. All rights reserved. Use of this source code is governed by a |
4 // BSD-style license that can be found in the LICENSE file. | 4 // BSD-style license that can be found in the LICENSE file. |
5 // | 5 // |
6 // Modified by the Subzero authors. | 6 // Modified by the Subzero authors. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 // | 9 // |
10 // The Subzero Code Generator | 10 // The Subzero Code Generator |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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_; |
327 intptr_t num_unresolved_; | 327 intptr_t num_unresolved_; |
| 328 // TODO(stichnot,jvoung): Can this instead be |
| 329 // llvm::SmallVector<intptr_t, kMaxUnresolvedBranches> ? |
328 intptr_t unresolved_near_positions_[kMaxUnresolvedBranches]; | 330 intptr_t unresolved_near_positions_[kMaxUnresolvedBranches]; |
329 | 331 |
330 friend class AssemblerX86; | 332 friend class AssemblerX86; |
331 }; | 333 }; |
332 | 334 |
333 class AssemblerX86 : public Assembler { | 335 class AssemblerX86 : public Assembler { |
334 AssemblerX86(const AssemblerX86 &) = delete; | 336 AssemblerX86(const AssemblerX86 &) = delete; |
335 AssemblerX86 &operator=(const AssemblerX86 &) = delete; | 337 AssemblerX86 &operator=(const AssemblerX86 &) = delete; |
336 | 338 |
337 public: | 339 public: |
338 explicit AssemblerX86(bool use_far_branches = false) : Assembler() { | 340 explicit AssemblerX86(bool use_far_branches = false) : Assembler() { |
339 // This mode is only needed and implemented for MIPS and ARM. | 341 // This mode is only needed and implemented for MIPS and ARM. |
340 assert(!use_far_branches); | 342 assert(!use_far_branches); |
341 (void)use_far_branches; | 343 (void)use_far_branches; |
342 } | 344 } |
343 ~AssemblerX86() override; | 345 ~AssemblerX86() override; |
344 | 346 |
345 static const bool kNearJump = true; | 347 static const bool kNearJump = true; |
346 static const bool kFarJump = false; | 348 static const bool kFarJump = false; |
347 | 349 |
348 void alignFunction() override; | 350 void alignFunction() override; |
349 | 351 |
350 SizeT getBundleAlignLog2Bytes() const override { return 5; } | 352 SizeT getBundleAlignLog2Bytes() const override { return 5; } |
351 | 353 |
352 llvm::ArrayRef<uint8_t> getNonExecBundlePadding() const override { | 354 llvm::ArrayRef<uint8_t> getNonExecBundlePadding() const override { |
353 static const uint8_t Padding[] = {0xF4}; | 355 static const uint8_t Padding[] = {0xF4}; |
354 return llvm::ArrayRef<uint8_t>(Padding, 1); | 356 return llvm::ArrayRef<uint8_t>(Padding, 1); |
355 } | 357 } |
356 | 358 |
| 359 void padWithNop(intptr_t Padding) override { |
| 360 while (Padding > MAX_NOP_SIZE) { |
| 361 nop(MAX_NOP_SIZE); |
| 362 Padding -= MAX_NOP_SIZE; |
| 363 } |
| 364 if (Padding) |
| 365 nop(Padding); |
| 366 } |
| 367 |
357 Label *GetOrCreateCfgNodeLabel(SizeT NodeNumber); | 368 Label *GetOrCreateCfgNodeLabel(SizeT NodeNumber); |
358 void BindCfgNodeLabel(SizeT NodeNumber) override; | 369 void BindCfgNodeLabel(SizeT NodeNumber) override; |
359 Label *GetOrCreateLocalLabel(SizeT Number); | 370 Label *GetOrCreateLocalLabel(SizeT Number); |
360 void BindLocalLabel(SizeT Number); | 371 void BindLocalLabel(SizeT Number); |
361 | 372 |
362 bool fixupIsPCRel(FixupKind Kind) const override { | 373 bool fixupIsPCRel(FixupKind Kind) const override { |
363 // Currently assuming this is the only PC-rel relocation type used. | 374 // Currently assuming this is the only PC-rel relocation type used. |
364 return Kind == llvm::ELF::R_386_PC32; | 375 return Kind == llvm::ELF::R_386_PC32; |
365 } | 376 } |
366 | 377 |
(...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
866 inline void AssemblerX86::EmitFixup(AssemblerFixup *fixup) { | 877 inline void AssemblerX86::EmitFixup(AssemblerFixup *fixup) { |
867 buffer_.EmitFixup(fixup); | 878 buffer_.EmitFixup(fixup); |
868 } | 879 } |
869 | 880 |
870 inline void AssemblerX86::EmitOperandSizeOverride() { EmitUint8(0x66); } | 881 inline void AssemblerX86::EmitOperandSizeOverride() { EmitUint8(0x66); } |
871 | 882 |
872 } // end of namespace x86 | 883 } // end of namespace x86 |
873 } // end of namespace Ice | 884 } // end of namespace Ice |
874 | 885 |
875 #endif // SUBZERO_SRC_ASSEMBLER_IA32_H_ | 886 #endif // SUBZERO_SRC_ASSEMBLER_IA32_H_ |
OLD | NEW |