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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 Label *getOrCreateLocalLabel(SizeT Number); | 156 Label *getOrCreateLocalLabel(SizeT Number); |
157 void bindLocalLabel(SizeT Number); | 157 void bindLocalLabel(SizeT Number); |
158 | 158 |
159 bool fixupIsPCRel(FixupKind Kind) const override { | 159 bool fixupIsPCRel(FixupKind Kind) const override { |
160 // Currently assuming this is the only PC-rel relocation type used. | 160 // Currently assuming this is the only PC-rel relocation type used. |
161 // TODO(jpp): Traits.PcRelTypes.count(Kind) != 0 | 161 // TODO(jpp): Traits.PcRelTypes.count(Kind) != 0 |
162 return Kind == Traits::PcRelFixup; | 162 return Kind == Traits::PcRelFixup; |
163 } | 163 } |
164 | 164 |
165 // Operations to emit GPR instructions (and dispatch on operand type). | 165 // Operations to emit GPR instructions (and dispatch on operand type). |
166 typedef void (AssemblerX86Base::*TypedEmitGPR)(Type, | 166 using TypedEmitGPR = void (AssemblerX86Base::*)(Type, |
167 typename Traits::GPRRegister); | 167 typename Traits::GPRRegister); |
168 typedef void (AssemblerX86Base::*TypedEmitAddr)( | 168 using TypedEmitAddr = |
169 Type, const typename Traits::Address &); | 169 void (AssemblerX86Base::*)(Type, const typename Traits::Address &); |
170 struct GPREmitterOneOp { | 170 struct GPREmitterOneOp { |
171 TypedEmitGPR Reg; | 171 TypedEmitGPR Reg; |
172 TypedEmitAddr Addr; | 172 TypedEmitAddr Addr; |
173 }; | 173 }; |
174 | 174 |
175 typedef void (AssemblerX86Base::*TypedEmitGPRGPR)( | 175 using TypedEmitGPRGPR = void (AssemblerX86Base::*)( |
176 Type, typename Traits::GPRRegister, typename Traits::GPRRegister); | 176 Type, typename Traits::GPRRegister, typename Traits::GPRRegister); |
177 typedef void (AssemblerX86Base::*TypedEmitGPRAddr)( | 177 using TypedEmitGPRAddr = void (AssemblerX86Base::*)( |
178 Type, typename Traits::GPRRegister, const typename Traits::Address &); | 178 Type, typename Traits::GPRRegister, const typename Traits::Address &); |
179 typedef void (AssemblerX86Base::*TypedEmitGPRImm)( | 179 using TypedEmitGPRImm = void (AssemblerX86Base::*)( |
180 Type, typename Traits::GPRRegister, const Immediate &); | 180 Type, typename Traits::GPRRegister, const Immediate &); |
181 struct GPREmitterRegOp { | 181 struct GPREmitterRegOp { |
182 TypedEmitGPRGPR GPRGPR; | 182 TypedEmitGPRGPR GPRGPR; |
183 TypedEmitGPRAddr GPRAddr; | 183 TypedEmitGPRAddr GPRAddr; |
184 TypedEmitGPRImm GPRImm; | 184 TypedEmitGPRImm GPRImm; |
185 }; | 185 }; |
186 | 186 |
187 struct GPREmitterShiftOp { | 187 struct GPREmitterShiftOp { |
188 // Technically, Addr/GPR and Addr/Imm are also allowed, but */Addr are not. | 188 // Technically, Addr/GPR and Addr/Imm are also allowed, but */Addr are not. |
189 // In practice, we always normalize the Dest to a Register first. | 189 // In practice, we always normalize the Dest to a Register first. |
190 TypedEmitGPRGPR GPRGPR; | 190 TypedEmitGPRGPR GPRGPR; |
191 TypedEmitGPRImm GPRImm; | 191 TypedEmitGPRImm GPRImm; |
192 }; | 192 }; |
193 | 193 |
194 typedef void (AssemblerX86Base::*TypedEmitGPRGPRImm)( | 194 using TypedEmitGPRGPRImm = void (AssemblerX86Base::*)( |
195 Type, typename Traits::GPRRegister, typename Traits::GPRRegister, | 195 Type, typename Traits::GPRRegister, typename Traits::GPRRegister, |
196 const Immediate &); | 196 const Immediate &); |
197 struct GPREmitterShiftD { | 197 struct GPREmitterShiftD { |
198 // Technically AddrGPR and AddrGPRImm are also allowed, but in practice | 198 // Technically AddrGPR and AddrGPRImm are also allowed, but in practice |
199 // we always normalize Dest to a Register first. | 199 // we always normalize Dest to a Register first. |
200 TypedEmitGPRGPR GPRGPR; | 200 TypedEmitGPRGPR GPRGPR; |
201 TypedEmitGPRGPRImm GPRGPRImm; | 201 TypedEmitGPRGPRImm GPRGPRImm; |
202 }; | 202 }; |
203 | 203 |
204 typedef void (AssemblerX86Base::*TypedEmitAddrGPR)( | 204 using TypedEmitAddrGPR = void (AssemblerX86Base::*)( |
205 Type, const typename Traits::Address &, typename Traits::GPRRegister); | 205 Type, const typename Traits::Address &, typename Traits::GPRRegister); |
206 typedef void (AssemblerX86Base::*TypedEmitAddrImm)( | 206 using TypedEmitAddrImm = void (AssemblerX86Base::*)( |
207 Type, const typename Traits::Address &, const Immediate &); | 207 Type, const typename Traits::Address &, const Immediate &); |
208 struct GPREmitterAddrOp { | 208 struct GPREmitterAddrOp { |
209 TypedEmitAddrGPR AddrGPR; | 209 TypedEmitAddrGPR AddrGPR; |
210 TypedEmitAddrImm AddrImm; | 210 TypedEmitAddrImm AddrImm; |
211 }; | 211 }; |
212 | 212 |
213 // Operations to emit XMM instructions (and dispatch on operand type). | 213 // Operations to emit XMM instructions (and dispatch on operand type). |
214 typedef void (AssemblerX86Base::*TypedEmitXmmXmm)( | 214 using TypedEmitXmmXmm = void (AssemblerX86Base::*)( |
215 Type, typename Traits::XmmRegister, typename Traits::XmmRegister); | 215 Type, typename Traits::XmmRegister, typename Traits::XmmRegister); |
216 typedef void (AssemblerX86Base::*TypedEmitXmmAddr)( | 216 using TypedEmitXmmAddr = void (AssemblerX86Base::*)( |
217 Type, typename Traits::XmmRegister, const typename Traits::Address &); | 217 Type, typename Traits::XmmRegister, const typename Traits::Address &); |
218 struct XmmEmitterRegOp { | 218 struct XmmEmitterRegOp { |
219 TypedEmitXmmXmm XmmXmm; | 219 TypedEmitXmmXmm XmmXmm; |
220 TypedEmitXmmAddr XmmAddr; | 220 TypedEmitXmmAddr XmmAddr; |
221 }; | 221 }; |
222 | 222 |
223 typedef void (AssemblerX86Base::*EmitXmmXmm)(typename Traits::XmmRegister, | 223 using EmitXmmXmm = void (AssemblerX86Base::*)(typename Traits::XmmRegister, |
224 typename Traits::XmmRegister); | 224 typename Traits::XmmRegister); |
225 typedef void (AssemblerX86Base::*EmitXmmAddr)( | 225 using EmitXmmAddr = void (AssemblerX86Base::*)( |
226 typename Traits::XmmRegister, const typename Traits::Address &); | 226 typename Traits::XmmRegister, const typename Traits::Address &); |
227 typedef void (AssemblerX86Base::*EmitAddrXmm)( | 227 using EmitAddrXmm = void (AssemblerX86Base::*)( |
228 const typename Traits::Address &, typename Traits::XmmRegister); | 228 const typename Traits::Address &, typename Traits::XmmRegister); |
229 struct XmmEmitterMovOps { | 229 struct XmmEmitterMovOps { |
230 EmitXmmXmm XmmXmm; | 230 EmitXmmXmm XmmXmm; |
231 EmitXmmAddr XmmAddr; | 231 EmitXmmAddr XmmAddr; |
232 EmitAddrXmm AddrXmm; | 232 EmitAddrXmm AddrXmm; |
233 }; | 233 }; |
234 | 234 |
235 typedef void (AssemblerX86Base::*TypedEmitXmmImm)( | 235 using TypedEmitXmmImm = void (AssemblerX86Base::*)( |
236 Type, typename Traits::XmmRegister, const Immediate &); | 236 Type, typename Traits::XmmRegister, const Immediate &); |
237 | 237 |
238 struct XmmEmitterShiftOp { | 238 struct XmmEmitterShiftOp { |
239 TypedEmitXmmXmm XmmXmm; | 239 TypedEmitXmmXmm XmmXmm; |
240 TypedEmitXmmAddr XmmAddr; | 240 TypedEmitXmmAddr XmmAddr; |
241 TypedEmitXmmImm XmmImm; | 241 TypedEmitXmmImm XmmImm; |
242 }; | 242 }; |
243 | 243 |
244 // Cross Xmm/GPR cast instructions. | 244 // Cross Xmm/GPR cast instructions. |
245 template <typename DReg_t, typename SReg_t> struct CastEmitterRegOp { | 245 template <typename DReg_t, typename SReg_t> struct CastEmitterRegOp { |
246 typedef void (AssemblerX86Base::*TypedEmitRegs)(Type, DReg_t, Type, SReg_t); | 246 using TypedEmitRegs = void (AssemblerX86Base::*)(Type, DReg_t, Type, |
247 typedef void (AssemblerX86Base::*TypedEmitAddr)( | 247 SReg_t); |
| 248 using TypedEmitAddr = void (AssemblerX86Base::*)( |
248 Type, DReg_t, Type, const typename Traits::Address &); | 249 Type, DReg_t, Type, const typename Traits::Address &); |
249 | 250 |
250 TypedEmitRegs RegReg; | 251 TypedEmitRegs RegReg; |
251 TypedEmitAddr RegAddr; | 252 TypedEmitAddr RegAddr; |
252 }; | 253 }; |
253 | 254 |
254 // Three operand (potentially) cross Xmm/GPR instructions. | 255 // Three operand (potentially) cross Xmm/GPR instructions. |
255 // The last operand must be an immediate. | 256 // The last operand must be an immediate. |
256 template <typename DReg_t, typename SReg_t> struct ThreeOpImmEmitter { | 257 template <typename DReg_t, typename SReg_t> struct ThreeOpImmEmitter { |
257 typedef void (AssemblerX86Base::*TypedEmitRegRegImm)(Type, DReg_t, SReg_t, | 258 using TypedEmitRegRegImm = void (AssemblerX86Base::*)(Type, DReg_t, SReg_t, |
258 const Immediate &); | 259 const Immediate &); |
259 typedef void (AssemblerX86Base::*TypedEmitRegAddrImm)( | 260 using TypedEmitRegAddrImm = void (AssemblerX86Base::*)( |
260 Type, DReg_t, const typename Traits::Address &, const Immediate &); | 261 Type, DReg_t, const typename Traits::Address &, const Immediate &); |
261 | 262 |
262 TypedEmitRegRegImm RegRegImm; | 263 TypedEmitRegRegImm RegRegImm; |
263 TypedEmitRegAddrImm RegAddrImm; | 264 TypedEmitRegAddrImm RegAddrImm; |
264 }; | 265 }; |
265 | 266 |
266 /* | 267 /* |
267 * Emit Machine Instructions. | 268 * Emit Machine Instructions. |
268 */ | 269 */ |
269 void call(typename Traits::GPRRegister reg); | 270 void call(typename Traits::GPRRegister reg); |
(...skipping 620 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 void emitLabel(Label *label, intptr_t instruction_size); | 891 void emitLabel(Label *label, intptr_t instruction_size); |
891 void emitLabelLink(Label *label); | 892 void emitLabelLink(Label *label); |
892 void emitNearLabelLink(Label *label); | 893 void emitNearLabelLink(Label *label); |
893 | 894 |
894 void emitGenericShift(int rm, Type Ty, typename Traits::GPRRegister reg, | 895 void emitGenericShift(int rm, Type Ty, typename Traits::GPRRegister reg, |
895 const Immediate &imm); | 896 const Immediate &imm); |
896 void emitGenericShift(int rm, Type Ty, | 897 void emitGenericShift(int rm, Type Ty, |
897 const typename Traits::Operand &operand, | 898 const typename Traits::Operand &operand, |
898 typename Traits::GPRRegister shifter); | 899 typename Traits::GPRRegister shifter); |
899 | 900 |
900 typedef std::vector<Label *> LabelVector; | 901 using LabelVector = std::vector<Label *>; |
901 // A vector of pool-allocated x86 labels for CFG nodes. | 902 // A vector of pool-allocated x86 labels for CFG nodes. |
902 LabelVector CfgNodeLabels; | 903 LabelVector CfgNodeLabels; |
903 // A vector of pool-allocated x86 labels for Local labels. | 904 // A vector of pool-allocated x86 labels for Local labels. |
904 LabelVector LocalLabels; | 905 LabelVector LocalLabels; |
905 | 906 |
906 Label *getOrCreateLabel(SizeT Number, LabelVector &Labels); | 907 Label *getOrCreateLabel(SizeT Number, LabelVector &Labels); |
907 | 908 |
908 // The arith_int() methods factor out the commonality between the encodings of | 909 // The arith_int() methods factor out the commonality between the encodings of |
909 // add(), Or(), adc(), sbb(), And(), sub(), Xor(), and cmp(). The Tag | 910 // add(), Or(), adc(), sbb(), And(), sub(), Xor(), and cmp(). The Tag |
910 // parameter is statically asserted to be less than 8. | 911 // parameter is statically asserted to be less than 8. |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1065 emitUint8(0x66); | 1066 emitUint8(0x66); |
1066 } | 1067 } |
1067 | 1068 |
1068 } // end of namespace X86Internal | 1069 } // end of namespace X86Internal |
1069 | 1070 |
1070 } // end of namespace Ice | 1071 } // end of namespace Ice |
1071 | 1072 |
1072 #include "IceAssemblerX86BaseImpl.h" | 1073 #include "IceAssemblerX86BaseImpl.h" |
1073 | 1074 |
1074 #endif // SUBZERO_SRC_ICEASSEMBLERX86BASE_H | 1075 #endif // SUBZERO_SRC_ICEASSEMBLERX86BASE_H |
OLD | NEW |