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 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
911 typename Traits::GPRRegister shifter); | 911 typename Traits::GPRRegister shifter); |
912 | 912 |
913 using LabelVector = std::vector<Label *>; | 913 using LabelVector = std::vector<Label *>; |
914 // A vector of pool-allocated x86 labels for CFG nodes. | 914 // A vector of pool-allocated x86 labels for CFG nodes. |
915 LabelVector CfgNodeLabels; | 915 LabelVector CfgNodeLabels; |
916 // A vector of pool-allocated x86 labels for Local labels. | 916 // A vector of pool-allocated x86 labels for Local labels. |
917 LabelVector LocalLabels; | 917 LabelVector LocalLabels; |
918 | 918 |
919 Label *getOrCreateLabel(SizeT Number, LabelVector &Labels); | 919 Label *getOrCreateLabel(SizeT Number, LabelVector &Labels); |
920 | 920 |
921 void emitAddrSizeOverridePrefix() { | |
922 if (!Traits::Is64Bit) { | |
923 return; | |
924 } | |
925 static constexpr uint8_t AddrSizeOverridePrefix = 0x67; | |
926 emitUint8(AddrSizeOverridePrefix); | |
927 } | |
928 | |
929 template <typename T = Traits> | |
930 typename std::enable_if<!T::Is64Bit, void>::type | |
Jim Stichnoth
2015/12/21 15:48:47
remove this
| |
931 emitAddrSizeOverridePrefix() {} | |
932 | |
921 // The arith_int() methods factor out the commonality between the encodings | 933 // The arith_int() methods factor out the commonality between the encodings |
922 // of add(), Or(), adc(), sbb(), And(), sub(), Xor(), and cmp(). The Tag | 934 // of add(), Or(), adc(), sbb(), And(), sub(), Xor(), and cmp(). The Tag |
923 // parameter is statically asserted to be less than 8. | 935 // parameter is statically asserted to be less than 8. |
924 template <uint32_t Tag> | 936 template <uint32_t Tag> |
925 void arith_int(Type Ty, typename Traits::GPRRegister reg, | 937 void arith_int(Type Ty, typename Traits::GPRRegister reg, |
926 const Immediate &imm); | 938 const Immediate &imm); |
927 | 939 |
928 template <uint32_t Tag> | 940 template <uint32_t Tag> |
929 void arith_int(Type Ty, typename Traits::GPRRegister reg0, | 941 void arith_int(Type Ty, typename Traits::GPRRegister reg0, |
930 typename Traits::GPRRegister reg1); | 942 typename Traits::GPRRegister reg1); |
(...skipping 27 matching lines...) Expand all Loading... | |
958 } | 970 } |
959 | 971 |
960 template <typename RegType> | 972 template <typename RegType> |
961 bool is8BitRegisterRequiringRex(const Type Ty, const RegType Reg) { | 973 bool is8BitRegisterRequiringRex(const Type Ty, const RegType Reg) { |
962 static constexpr bool IsGPR = | 974 static constexpr bool IsGPR = |
963 std::is_same<typename std::decay<RegType>::type, | 975 std::is_same<typename std::decay<RegType>::type, |
964 typename Traits::ByteRegister>::value || | 976 typename Traits::ByteRegister>::value || |
965 std::is_same<typename std::decay<RegType>::type, | 977 std::is_same<typename std::decay<RegType>::type, |
966 typename Traits::GPRRegister>::value; | 978 typename Traits::GPRRegister>::value; |
967 | 979 |
980 // At this point in the assembler, we have encoded regs, so it is not | |
981 // possible to distinguish between the "new" low byte registers introduced | |
982 // in x86-64 and the legacy [abcd]h registers. Because x86, we may still see | |
983 // ah (div) in the assembler, so we whitelist it here. | |
984 // | |
985 // The "local" uint32_t Encoded_Reg_ah is needed because RegType is an enum | |
986 // that is not necessarily the same type of | |
987 // Traits::RegisterSet::Encoded_Reg_ah. | |
988 constexpr uint32_t Encoded_Reg_ah = Traits::RegisterSet::Encoded_Reg_ah; | |
968 return IsGPR && (Reg & 0x04) != 0 && (Reg & 0x08) == 0 && | 989 return IsGPR && (Reg & 0x04) != 0 && (Reg & 0x08) == 0 && |
969 isByteSizedType(Ty); | 990 isByteSizedType(Ty) && (Reg != Encoded_Reg_ah); |
970 } | 991 } |
971 | 992 |
972 // assembleAndEmitRex is used for determining which (if any) rex prefix | 993 // assembleAndEmitRex is used for determining which (if any) rex prefix |
973 // should be emitted for the current instruction. It allows different types | 994 // should be emitted for the current instruction. It allows different types |
974 // for Reg and Rm because they could be of different types (e.g., in mov[sz]x | 995 // for Reg and Rm because they could be of different types (e.g., in mov[sz]x |
975 // instructions.) If Addr is not nullptr, then Rm is ignored, and Rex.B is | 996 // instructions.) If Addr is not nullptr, then Rm is ignored, and Rex.B is |
976 // determined by Addr instead. TyRm is still used to determine Addr's size. | 997 // determined by Addr instead. TyRm is still used to determine Addr's size. |
977 template <typename RegType, typename RmType, typename T = Traits> | 998 template <typename RegType, typename RmType, typename T = Traits> |
978 typename std::enable_if<T::Is64Bit, void>::type | 999 typename std::enable_if<T::Is64Bit, void>::type |
979 assembleAndEmitRex(const Type TyReg, const RegType Reg, const Type TyRm, | 1000 assembleAndEmitRex(const Type TyReg, const RegType Reg, const Type TyRm, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1073 emitUint8(0x66); | 1094 emitUint8(0x66); |
1074 } | 1095 } |
1075 | 1096 |
1076 } // end of namespace X86Internal | 1097 } // end of namespace X86Internal |
1077 | 1098 |
1078 } // end of namespace Ice | 1099 } // end of namespace Ice |
1079 | 1100 |
1080 #include "IceAssemblerX86BaseImpl.h" | 1101 #include "IceAssemblerX86BaseImpl.h" |
1081 | 1102 |
1082 #endif // SUBZERO_SRC_ICEASSEMBLERX86BASE_H | 1103 #endif // SUBZERO_SRC_ICEASSEMBLERX86BASE_H |
OLD | NEW |