| 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 936 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 947 template <typename RegType> | 947 template <typename RegType> |
| 948 bool is8BitRegisterRequiringRex(const Type Ty, const RegType Reg) { | 948 bool is8BitRegisterRequiringRex(const Type Ty, const RegType Reg) { |
| 949 static constexpr bool IsGPR = | 949 static constexpr bool IsGPR = |
| 950 std::is_same<typename std::decay<RegType>::type, | 950 std::is_same<typename std::decay<RegType>::type, |
| 951 typename Traits::ByteRegister>::value || | 951 typename Traits::ByteRegister>::value || |
| 952 std::is_same<typename std::decay<RegType>::type, | 952 std::is_same<typename std::decay<RegType>::type, |
| 953 typename Traits::GPRRegister>::value; | 953 typename Traits::GPRRegister>::value; |
| 954 | 954 |
| 955 return IsGPR && (Reg & 0x04) != 0 && (Reg & 0x08) == 0 && | 955 return IsGPR && (Reg & 0x04) != 0 && (Reg & 0x08) == 0 && |
| 956 isByteSizedType(Ty); | 956 isByteSizedType(Ty); |
| 957 }; | 957 } |
| 958 | 958 |
| 959 // assembleAndEmitRex is used for determining which (if any) rex prefix should | 959 // assembleAndEmitRex is used for determining which (if any) rex prefix should |
| 960 // be emitted for the current instruction. It allows different types for Reg | 960 // be emitted for the current instruction. It allows different types for Reg |
| 961 // and Rm because they could be of different types (e.g., in mov[sz]x | 961 // and Rm because they could be of different types (e.g., in mov[sz]x |
| 962 // instrutions.) If Addr is not nullptr, then Rm is ignored, and Rex.B is | 962 // instrutions.) If Addr is not nullptr, then Rm is ignored, and Rex.B is |
| 963 // determined by Addr instead. TyRm is still used to determine Addr's size. | 963 // determined by Addr instead. TyRm is still used to determine Addr's size. |
| 964 template <typename RegType, typename RmType, typename T = Traits> | 964 template <typename RegType, typename RmType, typename T = Traits> |
| 965 typename std::enable_if<T::Is64Bit, void>::type | 965 typename std::enable_if<T::Is64Bit, void>::type |
| 966 assembleAndEmitRex(const Type TyReg, const RegType Reg, const Type TyRm, | 966 assembleAndEmitRex(const Type TyReg, const RegType Reg, const Type TyRm, |
| 967 const RmType Rm, | 967 const RmType Rm, |
| 968 const typename T::Address *Addr = nullptr) { | 968 const typename T::Address *Addr = nullptr) { |
| 969 const uint8_t W = (TyReg == IceType_i64 || TyRm == IceType_i64) | 969 const uint8_t W = (TyReg == IceType_i64 || TyRm == IceType_i64) |
| 970 ? T::Operand::RexW | 970 ? T::Operand::RexW |
| 971 : T::Operand::RexNone; | 971 : T::Operand::RexNone; |
| 972 const uint8_t R = (Reg & 0x08) ? T::Operand::RexR : T::Operand::RexNone; | 972 const uint8_t R = (Reg & 0x08) ? T::Operand::RexR : T::Operand::RexNone; |
| 973 const uint8_t X = (Addr != nullptr) ? Addr->rexX() : T::Operand::RexNone; | 973 const uint8_t X = (Addr != nullptr) |
| 974 ? (typename T::Operand::RexBits)Addr->rexX() |
| 975 : T::Operand::RexNone; |
| 974 const uint8_t B = | 976 const uint8_t B = |
| 975 (Addr != nullptr) ? Addr->rexB() : (Rm & 0x08) ? T::Operand::RexB | 977 (Addr != nullptr) |
| 976 : T::Operand::RexNone; | 978 ? (typename T::Operand::RexBits)Addr->rexB() |
| 979 : (Rm & 0x08) ? T::Operand::RexB : T::Operand::RexNone; |
| 977 const uint8_t Prefix = W | R | X | B; | 980 const uint8_t Prefix = W | R | X | B; |
| 978 if (Prefix != T::Operand::RexNone) { | 981 if (Prefix != T::Operand::RexNone) { |
| 979 emitUint8(Prefix); | 982 emitUint8(Prefix); |
| 980 } else if (is8BitRegisterRequiringRex(TyReg, Reg) || | 983 } else if (is8BitRegisterRequiringRex(TyReg, Reg) || |
| 981 (Addr == nullptr && is8BitRegisterRequiringRex(TyRm, Rm))) { | 984 (Addr == nullptr && is8BitRegisterRequiringRex(TyRm, Rm))) { |
| 982 emitUint8(T::Operand::RexBase); | 985 emitUint8(T::Operand::RexBase); |
| 983 } | 986 } |
| 984 } | 987 } |
| 985 | 988 |
| 986 template <typename RegType, typename RmType, typename T = Traits> | 989 template <typename RegType, typename RmType, typename T = Traits> |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1062 emitUint8(0x66); | 1065 emitUint8(0x66); |
| 1063 } | 1066 } |
| 1064 | 1067 |
| 1065 } // end of namespace X86Internal | 1068 } // end of namespace X86Internal |
| 1066 | 1069 |
| 1067 } // end of namespace Ice | 1070 } // end of namespace Ice |
| 1068 | 1071 |
| 1069 #include "IceAssemblerX86BaseImpl.h" | 1072 #include "IceAssemblerX86BaseImpl.h" |
| 1070 | 1073 |
| 1071 #endif // SUBZERO_SRC_ICEASSEMBLERX86BASE_H | 1074 #endif // SUBZERO_SRC_ICEASSEMBLERX86BASE_H |
| OLD | NEW |