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 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
357 intptr_t unresolved_near_positions_[kMaxUnresolvedBranches]; | 357 intptr_t unresolved_near_positions_[kMaxUnresolvedBranches]; |
358 | 358 |
359 friend class AssemblerX86; | 359 friend class AssemblerX86; |
360 }; | 360 }; |
361 | 361 |
362 class AssemblerX86 : public Assembler { | 362 class AssemblerX86 : public Assembler { |
363 AssemblerX86(const AssemblerX86 &) = delete; | 363 AssemblerX86(const AssemblerX86 &) = delete; |
364 AssemblerX86 &operator=(const AssemblerX86 &) = delete; | 364 AssemblerX86 &operator=(const AssemblerX86 &) = delete; |
365 | 365 |
366 public: | 366 public: |
367 explicit AssemblerX86(bool use_far_branches = false) : buffer_(*this) { | 367 explicit AssemblerX86(bool use_far_branches = false) : Assembler() { |
368 // This mode is only needed and implemented for MIPS and ARM. | 368 // This mode is only needed and implemented for MIPS and ARM. |
369 assert(!use_far_branches); | 369 assert(!use_far_branches); |
370 (void)use_far_branches; | 370 (void)use_far_branches; |
371 } | 371 } |
372 ~AssemblerX86() override; | 372 ~AssemblerX86() override; |
373 | 373 |
374 static const bool kNearJump = true; | 374 static const bool kNearJump = true; |
375 static const bool kFarJump = false; | 375 static const bool kFarJump = false; |
376 | 376 |
377 Label *GetOrCreateCfgNodeLabel(SizeT NodeNumber); | 377 Label *GetOrCreateCfgNodeLabel(SizeT NodeNumber); |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 intptr_t PreferredLoopAlignment() { return 16; } | 822 intptr_t PreferredLoopAlignment() { return 16; } |
823 void Align(intptr_t alignment, intptr_t offset); | 823 void Align(intptr_t alignment, intptr_t offset); |
824 void Bind(Label *label); | 824 void Bind(Label *label); |
825 | 825 |
826 intptr_t CodeSize() const { return buffer_.Size(); } | 826 intptr_t CodeSize() const { return buffer_.Size(); } |
827 | 827 |
828 void FinalizeInstructions(const MemoryRegion ®ion) { | 828 void FinalizeInstructions(const MemoryRegion ®ion) { |
829 buffer_.FinalizeInstructions(region); | 829 buffer_.FinalizeInstructions(region); |
830 } | 830 } |
831 | 831 |
832 // Expose the buffer, for bringup... | |
833 intptr_t GetPosition() const { return buffer_.GetPosition(); } | |
834 template <typename T> T LoadBuffer(intptr_t position) const { | |
835 return buffer_.Load<T>(position); | |
836 } | |
837 AssemblerFixup *GetLatestFixup(intptr_t position) const { | |
838 return buffer_.GetLatestFixup(position); | |
839 } | |
840 | |
841 private: | 832 private: |
842 inline void EmitUint8(uint8_t value); | 833 inline void EmitUint8(uint8_t value); |
843 inline void EmitInt16(int16_t value); | 834 inline void EmitInt16(int16_t value); |
844 inline void EmitInt32(int32_t value); | 835 inline void EmitInt32(int32_t value); |
845 inline void EmitRegisterOperand(int rm, int reg); | 836 inline void EmitRegisterOperand(int rm, int reg); |
846 inline void EmitXmmRegisterOperand(int rm, XmmRegister reg); | 837 inline void EmitXmmRegisterOperand(int rm, XmmRegister reg); |
847 inline void EmitFixup(AssemblerFixup *fixup); | 838 inline void EmitFixup(AssemblerFixup *fixup); |
848 inline void EmitOperandSizeOverride(); | 839 inline void EmitOperandSizeOverride(); |
849 | 840 |
850 void EmitOperand(int rm, const Operand &operand); | 841 void EmitOperand(int rm, const Operand &operand); |
(...skipping 10 matching lines...) Expand all Loading... |
861 void EmitGenericShift(int rm, Type Ty, const Operand &operand, | 852 void EmitGenericShift(int rm, Type Ty, const Operand &operand, |
862 GPRRegister shifter); | 853 GPRRegister shifter); |
863 | 854 |
864 typedef std::vector<Label *> LabelVector; | 855 typedef std::vector<Label *> LabelVector; |
865 // A vector of pool-allocated x86 labels for CFG nodes. | 856 // A vector of pool-allocated x86 labels for CFG nodes. |
866 LabelVector CfgNodeLabels; | 857 LabelVector CfgNodeLabels; |
867 // A vector of pool-allocated x86 labels for Local labels. | 858 // A vector of pool-allocated x86 labels for Local labels. |
868 LabelVector LocalLabels; | 859 LabelVector LocalLabels; |
869 | 860 |
870 Label *GetOrCreateLabel(SizeT Number, LabelVector &Labels); | 861 Label *GetOrCreateLabel(SizeT Number, LabelVector &Labels); |
871 | |
872 AssemblerBuffer buffer_; | |
873 }; | 862 }; |
874 | 863 |
875 inline void AssemblerX86::EmitUint8(uint8_t value) { | 864 inline void AssemblerX86::EmitUint8(uint8_t value) { |
876 buffer_.Emit<uint8_t>(value); | 865 buffer_.Emit<uint8_t>(value); |
877 } | 866 } |
878 | 867 |
879 inline void AssemblerX86::EmitInt16(int16_t value) { | 868 inline void AssemblerX86::EmitInt16(int16_t value) { |
880 buffer_.Emit<int16_t>(value); | 869 buffer_.Emit<int16_t>(value); |
881 } | 870 } |
882 | 871 |
(...skipping 13 matching lines...) Expand all Loading... |
896 inline void AssemblerX86::EmitFixup(AssemblerFixup *fixup) { | 885 inline void AssemblerX86::EmitFixup(AssemblerFixup *fixup) { |
897 buffer_.EmitFixup(fixup); | 886 buffer_.EmitFixup(fixup); |
898 } | 887 } |
899 | 888 |
900 inline void AssemblerX86::EmitOperandSizeOverride() { EmitUint8(0x66); } | 889 inline void AssemblerX86::EmitOperandSizeOverride() { EmitUint8(0x66); } |
901 | 890 |
902 } // end of namespace x86 | 891 } // end of namespace x86 |
903 } // end of namespace Ice | 892 } // end of namespace Ice |
904 | 893 |
905 #endif // SUBZERO_SRC_ASSEMBLER_IA32_H_ | 894 #endif // SUBZERO_SRC_ASSEMBLER_IA32_H_ |
OLD | NEW |