| OLD | NEW |
| 1 //===- subzero/src/IceAssemblerX86Base.h - base x86 assembler -*- C++ -*---===// | 1 //===- subzero/src/IceAssemblerX86Base.h - base x86 assembler -*- 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 26 matching lines...) Expand all Loading... |
| 37 #endif | 37 #endif |
| 38 | 38 |
| 39 namespace X86NAMESPACE { | 39 namespace X86NAMESPACE { |
| 40 | 40 |
| 41 template <typename TraitsType> | 41 template <typename TraitsType> |
| 42 class AssemblerX86Base : public ::Ice::Assembler { | 42 class AssemblerX86Base : public ::Ice::Assembler { |
| 43 AssemblerX86Base(const AssemblerX86Base &) = delete; | 43 AssemblerX86Base(const AssemblerX86Base &) = delete; |
| 44 AssemblerX86Base &operator=(const AssemblerX86Base &) = delete; | 44 AssemblerX86Base &operator=(const AssemblerX86Base &) = delete; |
| 45 | 45 |
| 46 protected: | 46 protected: |
| 47 explicit AssemblerX86Base(bool use_far_branches = false) | 47 explicit AssemblerX86Base(bool EmitAddrSizeOverridePrefix = Traits::Is64Bit) |
| 48 : Assembler(Traits::AsmKind) { | 48 : Assembler(Traits::AsmKind), |
| 49 // This mode is only needed and implemented for MIPS and ARM. | 49 EmitAddrSizeOverridePrefix(EmitAddrSizeOverridePrefix) { |
| 50 assert(!use_far_branches); | 50 assert(Traits::Is64Bit || !EmitAddrSizeOverridePrefix); |
| 51 (void)use_far_branches; | |
| 52 } | 51 } |
| 53 | 52 |
| 54 public: | 53 public: |
| 55 using Traits = TraitsType; | 54 using Traits = TraitsType; |
| 56 using Address = typename Traits::Address; | 55 using Address = typename Traits::Address; |
| 57 using ByteRegister = typename Traits::ByteRegister; | 56 using ByteRegister = typename Traits::ByteRegister; |
| 58 using BrCond = typename Traits::Cond::BrCond; | 57 using BrCond = typename Traits::Cond::BrCond; |
| 59 using CmppsCond = typename Traits::Cond::CmppsCond; | 58 using CmppsCond = typename Traits::Cond::CmppsCond; |
| 60 using GPRRegister = typename Traits::GPRRegister; | 59 using GPRRegister = typename Traits::GPRRegister; |
| 61 using Operand = typename Traits::Operand; | 60 using Operand = typename Traits::Operand; |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 * Emit Machine Instructions. | 280 * Emit Machine Instructions. |
| 282 */ | 281 */ |
| 283 void call(GPRRegister reg); | 282 void call(GPRRegister reg); |
| 284 void call(const Address &address); | 283 void call(const Address &address); |
| 285 void call(const ConstantRelocatable *label); // not testable. | 284 void call(const ConstantRelocatable *label); // not testable. |
| 286 void call(const Immediate &abs_address); | 285 void call(const Immediate &abs_address); |
| 287 | 286 |
| 288 static const intptr_t kCallExternalLabelSize = 5; | 287 static const intptr_t kCallExternalLabelSize = 5; |
| 289 | 288 |
| 290 void pushl(GPRRegister reg); | 289 void pushl(GPRRegister reg); |
| 290 void pushl(const Immediate &Imm); |
| 291 void pushl(const ConstantRelocatable *Label); |
| 291 | 292 |
| 292 void popl(GPRRegister reg); | 293 void popl(GPRRegister reg); |
| 293 void popl(const Address &address); | 294 void popl(const Address &address); |
| 294 | 295 |
| 295 template <typename T = Traits, | 296 template <typename T = Traits, |
| 296 typename = typename std::enable_if<T::HasPusha>::type> | 297 typename = typename std::enable_if<T::HasPusha>::type> |
| 297 void pushal(); | 298 void pushal(); |
| 298 template <typename T = Traits, | 299 template <typename T = Traits, |
| 299 typename = typename std::enable_if<T::HasPopa>::type> | 300 typename = typename std::enable_if<T::HasPopa>::type> |
| 300 void popal(); | 301 void popal(); |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 704 void bind(Label *label); | 705 void bind(Label *label); |
| 705 | 706 |
| 706 intptr_t CodeSize() const { return Buffer.size(); } | 707 intptr_t CodeSize() const { return Buffer.size(); } |
| 707 | 708 |
| 708 protected: | 709 protected: |
| 709 inline void emitUint8(uint8_t value); | 710 inline void emitUint8(uint8_t value); |
| 710 | 711 |
| 711 private: | 712 private: |
| 712 ENABLE_MAKE_UNIQUE; | 713 ENABLE_MAKE_UNIQUE; |
| 713 | 714 |
| 715 // EmidAddrSizeOverridePrefix directs the emission of the 0x67 prefix to |
| 716 // force 32-bit registers when accessing memory. This is only used in native |
| 717 // 64-bit. |
| 718 const bool EmitAddrSizeOverridePrefix; |
| 719 |
| 714 static constexpr Type RexTypeIrrelevant = IceType_i32; | 720 static constexpr Type RexTypeIrrelevant = IceType_i32; |
| 715 static constexpr Type RexTypeForceRexW = IceType_i64; | 721 static constexpr Type RexTypeForceRexW = IceType_i64; |
| 716 static constexpr GPRRegister RexRegIrrelevant = | 722 static constexpr GPRRegister RexRegIrrelevant = |
| 717 Traits::GPRRegister::Encoded_Reg_eax; | 723 Traits::GPRRegister::Encoded_Reg_eax; |
| 718 | 724 |
| 719 inline void emitInt16(int16_t value); | 725 inline void emitInt16(int16_t value); |
| 720 inline void emitInt32(int32_t value); | 726 inline void emitInt32(int32_t value); |
| 721 inline void emitRegisterOperand(int rm, int reg); | 727 inline void emitRegisterOperand(int rm, int reg); |
| 722 template <typename RegType, typename RmType> | 728 template <typename RegType, typename RmType> |
| 723 inline void emitXmmRegisterOperand(RegType reg, RmType rm); | 729 inline void emitXmmRegisterOperand(RegType reg, RmType rm); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 739 | 745 |
| 740 using LabelVector = std::vector<Label *>; | 746 using LabelVector = std::vector<Label *>; |
| 741 // A vector of pool-allocated x86 labels for CFG nodes. | 747 // A vector of pool-allocated x86 labels for CFG nodes. |
| 742 LabelVector CfgNodeLabels; | 748 LabelVector CfgNodeLabels; |
| 743 // A vector of pool-allocated x86 labels for Local labels. | 749 // A vector of pool-allocated x86 labels for Local labels. |
| 744 LabelVector LocalLabels; | 750 LabelVector LocalLabels; |
| 745 | 751 |
| 746 Label *getOrCreateLabel(SizeT Number, LabelVector &Labels); | 752 Label *getOrCreateLabel(SizeT Number, LabelVector &Labels); |
| 747 | 753 |
| 748 void emitAddrSizeOverridePrefix() { | 754 void emitAddrSizeOverridePrefix() { |
| 749 if (!Traits::Is64Bit) { | 755 if (!Traits::Is64Bit || !EmitAddrSizeOverridePrefix) { |
| 750 return; | 756 return; |
| 751 } | 757 } |
| 752 static constexpr uint8_t AddrSizeOverridePrefix = 0x67; | 758 static constexpr uint8_t AddrSizeOverridePrefix = 0x67; |
| 753 emitUint8(AddrSizeOverridePrefix); | 759 emitUint8(AddrSizeOverridePrefix); |
| 754 } | 760 } |
| 755 | 761 |
| 756 // The arith_int() methods factor out the commonality between the encodings | 762 // The arith_int() methods factor out the commonality between the encodings |
| 757 // of add(), Or(), adc(), sbb(), And(), sub(), Xor(), and cmp(). The Tag | 763 // of add(), Or(), adc(), sbb(), And(), sub(), Xor(), and cmp(). The Tag |
| 758 // parameter is statically asserted to be less than 8. | 764 // parameter is statically asserted to be less than 8. |
| 759 template <uint32_t Tag> | 765 template <uint32_t Tag> |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 emitUint8(0x66); | 915 emitUint8(0x66); |
| 910 } | 916 } |
| 911 | 917 |
| 912 } // end of namespace X86NAMESPACE | 918 } // end of namespace X86NAMESPACE |
| 913 | 919 |
| 914 } // end of namespace Ice | 920 } // end of namespace Ice |
| 915 | 921 |
| 916 #include "IceAssemblerX86BaseImpl.h" | 922 #include "IceAssemblerX86BaseImpl.h" |
| 917 | 923 |
| 918 #endif // SUBZERO_SRC_ICEASSEMBLERX86BASE_H | 924 #endif // SUBZERO_SRC_ICEASSEMBLERX86BASE_H |
| OLD | NEW |