Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(932)

Side by Side Diff: src/IceAssemblerX86Base.h

Issue 1537703002: Subzero. x8664. Resurrects the Target. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Addresses comments. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
921 // The arith_int() methods factor out the commonality between the encodings 929 // The arith_int() methods factor out the commonality between the encodings
922 // of add(), Or(), adc(), sbb(), And(), sub(), Xor(), and cmp(). The Tag 930 // of add(), Or(), adc(), sbb(), And(), sub(), Xor(), and cmp(). The Tag
923 // parameter is statically asserted to be less than 8. 931 // parameter is statically asserted to be less than 8.
924 template <uint32_t Tag> 932 template <uint32_t Tag>
925 void arith_int(Type Ty, typename Traits::GPRRegister reg, 933 void arith_int(Type Ty, typename Traits::GPRRegister reg,
926 const Immediate &imm); 934 const Immediate &imm);
927 935
928 template <uint32_t Tag> 936 template <uint32_t Tag>
929 void arith_int(Type Ty, typename Traits::GPRRegister reg0, 937 void arith_int(Type Ty, typename Traits::GPRRegister reg0,
930 typename Traits::GPRRegister reg1); 938 typename Traits::GPRRegister reg1);
(...skipping 27 matching lines...) Expand all
958 } 966 }
959 967
960 template <typename RegType> 968 template <typename RegType>
961 bool is8BitRegisterRequiringRex(const Type Ty, const RegType Reg) { 969 bool is8BitRegisterRequiringRex(const Type Ty, const RegType Reg) {
962 static constexpr bool IsGPR = 970 static constexpr bool IsGPR =
963 std::is_same<typename std::decay<RegType>::type, 971 std::is_same<typename std::decay<RegType>::type,
964 typename Traits::ByteRegister>::value || 972 typename Traits::ByteRegister>::value ||
965 std::is_same<typename std::decay<RegType>::type, 973 std::is_same<typename std::decay<RegType>::type,
966 typename Traits::GPRRegister>::value; 974 typename Traits::GPRRegister>::value;
967 975
976 // At this point in the assembler, we have encoded regs, so it is not
977 // possible to distinguish between the "new" low byte registers introduced
978 // in x86-64 and the legacy [abcd]h registers. Because x86, we may still see
979 // ah (div) in the assembler, so we whitelist it here.
980 //
981 // The "local" uint32_t Encoded_Reg_ah is needed because RegType is an enum
982 // that is not necessarily the same type of
983 // Traits::RegisterSet::Encoded_Reg_ah.
984 constexpr uint32_t Encoded_Reg_ah = Traits::RegisterSet::Encoded_Reg_ah;
968 return IsGPR && (Reg & 0x04) != 0 && (Reg & 0x08) == 0 && 985 return IsGPR && (Reg & 0x04) != 0 && (Reg & 0x08) == 0 &&
969 isByteSizedType(Ty); 986 isByteSizedType(Ty) && (Reg != Encoded_Reg_ah);
970 } 987 }
971 988
972 // assembleAndEmitRex is used for determining which (if any) rex prefix 989 // assembleAndEmitRex is used for determining which (if any) rex prefix
973 // should be emitted for the current instruction. It allows different types 990 // 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 991 // 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 992 // 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. 993 // determined by Addr instead. TyRm is still used to determine Addr's size.
977 template <typename RegType, typename RmType, typename T = Traits> 994 template <typename RegType, typename RmType, typename T = Traits>
978 typename std::enable_if<T::Is64Bit, void>::type 995 typename std::enable_if<T::Is64Bit, void>::type
979 assembleAndEmitRex(const Type TyReg, const RegType Reg, const Type TyRm, 996 assembleAndEmitRex(const Type TyReg, const RegType Reg, const Type TyRm,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 emitUint8(0x66); 1090 emitUint8(0x66);
1074 } 1091 }
1075 1092
1076 } // end of namespace X86Internal 1093 } // end of namespace X86Internal
1077 1094
1078 } // end of namespace Ice 1095 } // end of namespace Ice
1079 1096
1080 #include "IceAssemblerX86BaseImpl.h" 1097 #include "IceAssemblerX86BaseImpl.h"
1081 1098
1082 #endif // SUBZERO_SRC_ICEASSEMBLERX86BASE_H 1099 #endif // SUBZERO_SRC_ICEASSEMBLERX86BASE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698