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

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: Beautifies the assembler. 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 template <typename T = Traits>
Jim Stichnoth 2015/12/20 19:27:37 Could you do something like this instead? void em
John 2015/12/21 13:41:31 Done.
922 typename std::enable_if<T::Is64Bit, void>::type emitAddrSizeOverridePrefix() {
923 static constexpr uint8_t AddrSizeOverridePrefix = 0x67;
924 emitUint8(AddrSizeOverridePrefix);
925 }
926
927 template <typename T = Traits>
928 typename std::enable_if<!T::Is64Bit, void>::type
929 emitAddrSizeOverridePrefix() {}
930
921 // The arith_int() methods factor out the commonality between the encodings 931 // The arith_int() methods factor out the commonality between the encodings
922 // of add(), Or(), adc(), sbb(), And(), sub(), Xor(), and cmp(). The Tag 932 // of add(), Or(), adc(), sbb(), And(), sub(), Xor(), and cmp(). The Tag
923 // parameter is statically asserted to be less than 8. 933 // parameter is statically asserted to be less than 8.
924 template <uint32_t Tag> 934 template <uint32_t Tag>
925 void arith_int(Type Ty, typename Traits::GPRRegister reg, 935 void arith_int(Type Ty, typename Traits::GPRRegister reg,
926 const Immediate &imm); 936 const Immediate &imm);
927 937
928 template <uint32_t Tag> 938 template <uint32_t Tag>
929 void arith_int(Type Ty, typename Traits::GPRRegister reg0, 939 void arith_int(Type Ty, typename Traits::GPRRegister reg0,
930 typename Traits::GPRRegister reg1); 940 typename Traits::GPRRegister reg1);
(...skipping 27 matching lines...) Expand all
958 } 968 }
959 969
960 template <typename RegType> 970 template <typename RegType>
961 bool is8BitRegisterRequiringRex(const Type Ty, const RegType Reg) { 971 bool is8BitRegisterRequiringRex(const Type Ty, const RegType Reg) {
962 static constexpr bool IsGPR = 972 static constexpr bool IsGPR =
963 std::is_same<typename std::decay<RegType>::type, 973 std::is_same<typename std::decay<RegType>::type,
964 typename Traits::ByteRegister>::value || 974 typename Traits::ByteRegister>::value ||
965 std::is_same<typename std::decay<RegType>::type, 975 std::is_same<typename std::decay<RegType>::type,
966 typename Traits::GPRRegister>::value; 976 typename Traits::GPRRegister>::value;
967 977
978 // At this point in the assembler, we have encoded regs, so it is not
979 // possible to distinguish between the the "new" low byte registers
Jim Stichnoth 2015/12/20 19:27:37 the the
John 2015/12/21 13:41:31 Done.
980 // introduced in x86-64 and the legacy [abcd]h registers. Because x86,
981 // we may still see ah (div) in the assembler, so we whitelist it here.
982 static uint32_t Encoded_ah = 0x04;
Jim Stichnoth 2015/12/20 19:27:37 constexpr
John 2015/12/21 13:41:31 Done.
968 return IsGPR && (Reg & 0x04) != 0 && (Reg & 0x08) == 0 && 983 return IsGPR && (Reg & 0x04) != 0 && (Reg & 0x08) == 0 &&
969 isByteSizedType(Ty); 984 isByteSizedType(Ty) && (Reg != Encoded_ah);
Jim Stichnoth 2015/12/20 19:27:37 Could you use something like Traits::RegisterSet::
John 2015/12/21 13:41:31 Sure. I still needed the local Encoded_ah (which I
970 } 985 }
971 986
972 // assembleAndEmitRex is used for determining which (if any) rex prefix 987 // assembleAndEmitRex is used for determining which (if any) rex prefix
973 // should be emitted for the current instruction. It allows different types 988 // 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 989 // 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 990 // 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. 991 // determined by Addr instead. TyRm is still used to determine Addr's size.
977 template <typename RegType, typename RmType, typename T = Traits> 992 template <typename RegType, typename RmType, typename T = Traits>
978 typename std::enable_if<T::Is64Bit, void>::type 993 typename std::enable_if<T::Is64Bit, void>::type
979 assembleAndEmitRex(const Type TyReg, const RegType Reg, const Type TyRm, 994 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); 1088 emitUint8(0x66);
1074 } 1089 }
1075 1090
1076 } // end of namespace X86Internal 1091 } // end of namespace X86Internal
1077 1092
1078 } // end of namespace Ice 1093 } // end of namespace Ice
1079 1094
1080 #include "IceAssemblerX86BaseImpl.h" 1095 #include "IceAssemblerX86BaseImpl.h"
1081 1096
1082 #endif // SUBZERO_SRC_ICEASSEMBLERX86BASE_H 1097 #endif // SUBZERO_SRC_ICEASSEMBLERX86BASE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698