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

Side by Side Diff: src/IceAssemblerX86Base.h

Issue 1419903002: Subzero: Refactor x86 register definitions to use the alias mechanism. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Add some comments Created 5 years, 1 month 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 llvm::SmallVector<intptr_t, 20> UnresolvedNearPositions; 108 llvm::SmallVector<intptr_t, 20> UnresolvedNearPositions;
109 109
110 template <class> friend class AssemblerX86Base; 110 template <class> friend class AssemblerX86Base;
111 }; 111 };
112 112
113 template <class Machine> class AssemblerX86Base : public Assembler { 113 template <class Machine> class AssemblerX86Base : public Assembler {
114 AssemblerX86Base(const AssemblerX86Base &) = delete; 114 AssemblerX86Base(const AssemblerX86Base &) = delete;
115 AssemblerX86Base &operator=(const AssemblerX86Base &) = delete; 115 AssemblerX86Base &operator=(const AssemblerX86Base &) = delete;
116 116
117 protected: 117 protected:
118 AssemblerX86Base(AssemblerKind Kind, GlobalContext *Ctx, 118 AssemblerX86Base(AssemblerKind Kind, bool use_far_branches)
119 bool use_far_branches) 119 : Assembler(Kind) {
120 : Assembler(Kind, Ctx) {
121 // This mode is only needed and implemented for MIPS and ARM. 120 // This mode is only needed and implemented for MIPS and ARM.
122 assert(!use_far_branches); 121 assert(!use_far_branches);
123 (void)use_far_branches; 122 (void)use_far_branches;
124 } 123 }
125 124
126 public: 125 public:
127 using Traits = MachineTraits<Machine>; 126 using Traits = MachineTraits<Machine>;
128 127
129 ~AssemblerX86Base() override; 128 ~AssemblerX86Base() override;
130 129
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 void popl(const typename Traits::Address &address); 280 void popl(const typename Traits::Address &address);
282 281
283 template <typename T = Traits, 282 template <typename T = Traits,
284 typename = typename std::enable_if<T::HasPusha>::type> 283 typename = typename std::enable_if<T::HasPusha>::type>
285 void pushal(); 284 void pushal();
286 template <typename T = Traits, 285 template <typename T = Traits,
287 typename = typename std::enable_if<T::HasPopa>::type> 286 typename = typename std::enable_if<T::HasPopa>::type>
288 void popal(); 287 void popal();
289 288
290 void setcc(typename Traits::Cond::BrCond condition, 289 void setcc(typename Traits::Cond::BrCond condition,
291 typename Traits::ByteRegister dst); 290 typename Traits::GPRRegister dst);
292 void setcc(typename Traits::Cond::BrCond condition, 291 void setcc(typename Traits::Cond::BrCond condition,
293 const typename Traits::Address &address); 292 const typename Traits::Address &address);
294 293
295 void mov(Type Ty, typename Traits::GPRRegister dst, const Immediate &src); 294 void mov(Type Ty, typename Traits::GPRRegister dst, const Immediate &src);
296 void mov(Type Ty, typename Traits::GPRRegister dst, 295 void mov(Type Ty, typename Traits::GPRRegister dst,
297 typename Traits::GPRRegister src); 296 typename Traits::GPRRegister src);
298 void mov(Type Ty, typename Traits::GPRRegister dst, 297 void mov(Type Ty, typename Traits::GPRRegister dst,
299 const typename Traits::Address &src); 298 const typename Traits::Address &src);
300 void mov(Type Ty, const typename Traits::Address &dst, 299 void mov(Type Ty, const typename Traits::Address &dst,
301 typename Traits::GPRRegister src); 300 typename Traits::GPRRegister src);
(...skipping 645 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 template <typename RegType, typename T = Traits> 946 template <typename RegType, typename T = Traits>
948 typename std::enable_if<!T::Is64Bit, typename T::GPRRegister>::type 947 typename std::enable_if<!T::Is64Bit, typename T::GPRRegister>::type
949 gprEncoding(const RegType Reg) { 948 gprEncoding(const RegType Reg) {
950 return static_cast<typename T::GPRRegister>(Reg); 949 return static_cast<typename T::GPRRegister>(Reg);
951 } 950 }
952 951
953 template <typename RegType> 952 template <typename RegType>
954 bool is8BitRegisterRequiringRex(const Type Ty, const RegType Reg) { 953 bool is8BitRegisterRequiringRex(const Type Ty, const RegType Reg) {
955 static constexpr bool IsGPR = 954 static constexpr bool IsGPR =
956 std::is_same<typename std::decay<RegType>::type, 955 std::is_same<typename std::decay<RegType>::type,
957 typename Traits::ByteRegister>::value ||
958 std::is_same<typename std::decay<RegType>::type,
959 typename Traits::GPRRegister>::value; 956 typename Traits::GPRRegister>::value;
960 957
961 return IsGPR && (Reg & 0x04) != 0 && (Reg & 0x08) == 0 && 958 return IsGPR && (Reg & 0x04) != 0 && (Reg & 0x08) == 0 &&
962 isByteSizedType(Ty); 959 isByteSizedType(Ty);
963 } 960 }
964 961
965 // assembleAndEmitRex is used for determining which (if any) rex prefix 962 // assembleAndEmitRex is used for determining which (if any) rex prefix
966 // should be emitted for the current instruction. It allows different types 963 // should be emitted for the current instruction. It allows different types
967 // for Reg and Rm because they could be of different types (e.g., in mov[sz]x 964 // for Reg and Rm because they could be of different types (e.g., in mov[sz]x
968 // instructions.) If Addr is not nullptr, then Rm is ignored, and Rex.B is 965 // instructions.) If Addr is not nullptr, then Rm is ignored, and Rex.B is
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
1066 emitUint8(0x66); 1063 emitUint8(0x66);
1067 } 1064 }
1068 1065
1069 } // end of namespace X86Internal 1066 } // end of namespace X86Internal
1070 1067
1071 } // end of namespace Ice 1068 } // end of namespace Ice
1072 1069
1073 #include "IceAssemblerX86BaseImpl.h" 1070 #include "IceAssemblerX86BaseImpl.h"
1074 1071
1075 #endif // SUBZERO_SRC_ICEASSEMBLERX86BASE_H 1072 #endif // SUBZERO_SRC_ICEASSEMBLERX86BASE_H
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698