xref: /freebsd/contrib/llvm-project/llvm/lib/Target/X86/X86SchedHaswell.td (revision 59c8e88e72633afbc47a4ace0d2170d00d51f7dc)
1//=- X86SchedHaswell.td - X86 Haswell Scheduling -------------*- tablegen -*-=//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the machine model for Haswell to support instruction
10// scheduling and other instruction cost heuristics.
11//
12// Note that we define some instructions here that are not supported by haswell,
13// but we still have to define them because KNL uses the HSW model.
14// They are currently tagged with a comment `Unsupported = 1`.
15// FIXME: Use Unsupported = 1 once KNL has its own model.
16//
17//===----------------------------------------------------------------------===//
18
19def HaswellModel : SchedMachineModel {
20  // All x86 instructions are modeled as a single micro-op, and HW can decode 4
21  // instructions per cycle.
22  let IssueWidth = 4;
23  let MicroOpBufferSize = 192; // Based on the reorder buffer.
24  let LoadLatency = 5;
25  let MispredictPenalty = 16;
26
27  // Based on the LSD (loop-stream detector) queue size and benchmarking data.
28  let LoopMicroOpBufferSize = 50;
29
30  // This flag is set to allow the scheduler to assign a default model to
31  // unrecognized opcodes.
32  let CompleteModel = 0;
33}
34
35let SchedModel = HaswellModel in {
36
37// Haswell can issue micro-ops to 8 different ports in one cycle.
38
39// Ports 0, 1, 5, and 6 handle all computation.
40// Port 4 gets the data half of stores. Store data can be available later than
41// the store address, but since we don't model the latency of stores, we can
42// ignore that.
43// Ports 2 and 3 are identical. They handle loads and the address half of
44// stores. Port 7 can handle address calculations.
45def HWPort0 : ProcResource<1>;
46def HWPort1 : ProcResource<1>;
47def HWPort2 : ProcResource<1>;
48def HWPort3 : ProcResource<1>;
49def HWPort4 : ProcResource<1>;
50def HWPort5 : ProcResource<1>;
51def HWPort6 : ProcResource<1>;
52def HWPort7 : ProcResource<1>;
53
54// Many micro-ops are capable of issuing on multiple ports.
55def HWPort01  : ProcResGroup<[HWPort0, HWPort1]>;
56def HWPort23  : ProcResGroup<[HWPort2, HWPort3]>;
57def HWPort237 : ProcResGroup<[HWPort2, HWPort3, HWPort7]>;
58def HWPort04  : ProcResGroup<[HWPort0, HWPort4]>;
59def HWPort05  : ProcResGroup<[HWPort0, HWPort5]>;
60def HWPort06  : ProcResGroup<[HWPort0, HWPort6]>;
61def HWPort15  : ProcResGroup<[HWPort1, HWPort5]>;
62def HWPort16  : ProcResGroup<[HWPort1, HWPort6]>;
63def HWPort56  : ProcResGroup<[HWPort5, HWPort6]>;
64def HWPort015 : ProcResGroup<[HWPort0, HWPort1, HWPort5]>;
65def HWPort056 : ProcResGroup<[HWPort0, HWPort5, HWPort6]>;
66def HWPort0156: ProcResGroup<[HWPort0, HWPort1, HWPort5, HWPort6]>;
67
68// 60 Entry Unified Scheduler
69def HWPortAny : ProcResGroup<[HWPort0, HWPort1, HWPort2, HWPort3, HWPort4,
70                              HWPort5, HWPort6, HWPort7]> {
71  let BufferSize=60;
72}
73
74// Integer division issued on port 0.
75def HWDivider : ProcResource<1>;
76// FP division and sqrt on port 0.
77def HWFPDivider : ProcResource<1>;
78
79// Integer loads are 5 cycles, so ReadAfterLd registers needn't be available until 5
80// cycles after the memory operand.
81def : ReadAdvance<ReadAfterLd, 5>;
82
83// Vector loads are 5/6/7 cycles, so ReadAfterVec*Ld registers needn't be available
84// until 5/6/7 cycles after the memory operand.
85def : ReadAdvance<ReadAfterVecLd, 5>;
86def : ReadAdvance<ReadAfterVecXLd, 6>;
87def : ReadAdvance<ReadAfterVecYLd, 7>;
88
89def : ReadAdvance<ReadInt2Fpu, 0>;
90
91// Many SchedWrites are defined in pairs with and without a folded load.
92// Instructions with folded loads are usually micro-fused, so they only appear
93// as two micro-ops when queued in the reservation station.
94// This multiclass defines the resource usage for variants with and without
95// folded loads.
96multiclass HWWriteResPair<X86FoldableSchedWrite SchedRW,
97                          list<ProcResourceKind> ExePorts,
98                          int Lat, list<int> Res = [1], int UOps = 1,
99                          int LoadLat = 5, int LoadUOps = 1> {
100  // Register variant is using a single cycle on ExePort.
101  def : WriteRes<SchedRW, ExePorts> {
102    let Latency = Lat;
103    let ResourceCycles = Res;
104    let NumMicroOps = UOps;
105  }
106
107  // Memory variant also uses a cycle on port 2/3 and adds LoadLat cycles to
108  // the latency (default = 5).
109  def : WriteRes<SchedRW.Folded, !listconcat([HWPort23], ExePorts)> {
110    let Latency = !add(Lat, LoadLat);
111    let ResourceCycles = !listconcat([1], Res);
112    let NumMicroOps = !add(UOps, LoadUOps);
113  }
114}
115
116// A folded store needs a cycle on port 4 for the store data, and an extra port
117// 2/3/7 cycle to recompute the address.
118def : WriteRes<WriteRMW, [HWPort237,HWPort4]>;
119
120// Loads, stores, and moves, not folded with other operations.
121// Store_addr on 237.
122// Store_data on 4.
123defm : X86WriteRes<WriteStore,   [HWPort237, HWPort4], 1, [1,1], 1>;
124defm : X86WriteRes<WriteStoreNT, [HWPort237, HWPort4], 1, [1,1], 2>;
125defm : X86WriteRes<WriteLoad,    [HWPort23], 5, [1], 1>;
126defm : X86WriteRes<WriteMove,    [HWPort0156], 1, [1], 1>;
127
128// Idioms that clear a register, like xorps %xmm0, %xmm0.
129// These can often bypass execution ports completely.
130def  : WriteRes<WriteZero,       []>;
131
132// Model the effect of clobbering the read-write mask operand of the GATHER operation.
133// Does not cost anything by itself, only has latency, matching that of the WriteLoad,
134defm : X86WriteRes<WriteVecMaskedGatherWriteback, [], 5, [], 0>;
135
136// Arithmetic.
137defm : HWWriteResPair<WriteALU,    [HWPort0156], 1>;
138defm : HWWriteResPair<WriteADC,    [HWPort06, HWPort0156], 2, [1,1], 2>;
139
140// Integer multiplication.
141defm : HWWriteResPair<WriteIMul8,     [HWPort1],   3>;
142defm : HWWriteResPair<WriteIMul16,    [HWPort1,HWPort06,HWPort0156], 4, [1,1,2], 4>;
143defm : X86WriteRes<WriteIMul16Imm,    [HWPort1,HWPort0156], 4, [1,1], 2>;
144defm : X86WriteRes<WriteIMul16ImmLd,  [HWPort1,HWPort0156,HWPort23], 8, [1,1,1], 3>;
145defm : HWWriteResPair<WriteIMul16Reg, [HWPort1],   3>;
146defm : HWWriteResPair<WriteIMul32,    [HWPort1,HWPort06,HWPort0156], 4, [1,1,1], 3>;
147defm : HWWriteResPair<WriteMULX32,    [HWPort1,HWPort06,HWPort0156], 3, [1,1,1], 3>;
148defm : HWWriteResPair<WriteIMul32Imm, [HWPort1],   3>;
149defm : HWWriteResPair<WriteIMul32Reg, [HWPort1],   3>;
150defm : HWWriteResPair<WriteIMul64,    [HWPort1,HWPort6], 4, [1,1], 2>;
151defm : HWWriteResPair<WriteMULX64,    [HWPort1,HWPort6], 3, [1,1], 2>;
152defm : HWWriteResPair<WriteIMul64Imm, [HWPort1],   3>;
153defm : HWWriteResPair<WriteIMul64Reg, [HWPort1],   3>;
154def HWWriteIMulH : WriteRes<WriteIMulH, []> { let Latency = 4; }
155def  : WriteRes<WriteIMulHLd, []> {
156  let Latency = !add(HWWriteIMulH.Latency, HaswellModel.LoadLatency);
157}
158
159defm : X86WriteRes<WriteBSWAP32,   [HWPort15], 1, [1], 1>;
160defm : X86WriteRes<WriteBSWAP64,   [HWPort06, HWPort15], 2, [1,1], 2>;
161defm : X86WriteRes<WriteCMPXCHG,[HWPort06, HWPort0156], 5, [2,3], 5>;
162defm : X86WriteRes<WriteCMPXCHGRMW,[HWPort23,HWPort06,HWPort0156,HWPort237,HWPort4], 9, [1,2,1,1,1], 6>;
163defm : X86WriteRes<WriteXCHG, [HWPort0156], 2, [3], 3>;
164
165// Integer shifts and rotates.
166defm : HWWriteResPair<WriteShift,    [HWPort06],  1>;
167defm : HWWriteResPair<WriteShiftCL,  [HWPort06, HWPort0156],  3, [2,1], 3>;
168defm : HWWriteResPair<WriteRotate,   [HWPort06],  1, [1], 1>;
169defm : HWWriteResPair<WriteRotateCL, [HWPort06, HWPort0156],  3, [2,1], 3>;
170
171// SHLD/SHRD.
172defm : X86WriteRes<WriteSHDrri, [HWPort1], 3, [1], 1>;
173defm : X86WriteRes<WriteSHDrrcl,[HWPort1, HWPort06, HWPort0156], 6, [1, 1, 2], 4>;
174defm : X86WriteRes<WriteSHDmri, [HWPort1, HWPort23, HWPort237, HWPort0156], 10, [1, 1, 1, 1], 4>;
175defm : X86WriteRes<WriteSHDmrcl,[HWPort1, HWPort23, HWPort237, HWPort06, HWPort0156], 12, [1, 1, 1, 1, 2], 6>;
176
177// Branches don't produce values, so they have no latency, but they still
178// consume resources. Indirect branches can fold loads.
179defm : HWWriteResPair<WriteJump,   [HWPort06],  1>;
180
181defm : HWWriteResPair<WriteCRC32,  [HWPort1],   3>;
182
183defm : HWWriteResPair<WriteCMOV,  [HWPort06,HWPort0156], 2, [1,1], 2>; // Conditional move.
184defm : X86WriteRes<WriteFCMOV, [HWPort1], 3, [1], 1>; // x87 conditional move.
185
186def  : WriteRes<WriteSETCC, [HWPort06]>; // Setcc.
187def  : WriteRes<WriteSETCCStore, [HWPort06,HWPort4,HWPort237]> {
188  let Latency = 2;
189  let NumMicroOps = 3;
190}
191
192defm : X86WriteRes<WriteLAHFSAHF,        [HWPort06], 1, [1], 1>;
193defm : X86WriteRes<WriteBitTest,         [HWPort06], 1, [1], 1>;
194defm : X86WriteRes<WriteBitTestImmLd,    [HWPort06,HWPort23], 6, [1,1], 2>;
195defm : X86WriteRes<WriteBitTestRegLd,    [], 1, [], 10>;
196defm : X86WriteRes<WriteBitTestSet,      [HWPort06], 1, [1], 1>;
197defm : X86WriteRes<WriteBitTestSetImmLd, [HWPort06,HWPort23], 6, [1,1], 3>;
198//defm : X86WriteRes<WriteBitTestSetRegLd, [], 1, [], 11>;
199
200// This is for simple LEAs with one or two input operands.
201// The complex ones can only execute on port 1, and they require two cycles on
202// the port to read all inputs. We don't model that.
203def : WriteRes<WriteLEA, [HWPort15]>;
204
205// Bit counts.
206defm : HWWriteResPair<WriteBSF, [HWPort1], 3>;
207defm : HWWriteResPair<WriteBSR, [HWPort1], 3>;
208defm : HWWriteResPair<WriteLZCNT,          [HWPort1], 3>;
209defm : HWWriteResPair<WriteTZCNT,          [HWPort1], 3>;
210defm : HWWriteResPair<WritePOPCNT,         [HWPort1], 3>;
211
212// BMI1 BEXTR/BLS, BMI2 BZHI
213defm : HWWriteResPair<WriteBEXTR, [HWPort06,HWPort15], 2, [1,1], 2>;
214defm : HWWriteResPair<WriteBLS,   [HWPort15], 1>;
215defm : HWWriteResPair<WriteBZHI,  [HWPort15], 1>;
216
217// TODO: Why isn't the HWDivider used?
218defm : X86WriteRes<WriteDiv8,     [HWPort0,HWPort1,HWPort5,HWPort6], 22, [], 9>;
219defm : X86WriteRes<WriteDiv16,    [HWPort0,HWPort1,HWPort5,HWPort6,HWPort01,HWPort0156], 98, [7,7,3,3,1,11], 32>;
220defm : X86WriteRes<WriteDiv32,    [HWPort0,HWPort1,HWPort5,HWPort6,HWPort01,HWPort0156], 98, [7,7,3,3,1,11], 32>;
221defm : X86WriteRes<WriteDiv64,    [HWPort0,HWPort1,HWPort5,HWPort6,HWPort01,HWPort0156], 98, [7,7,3,3,1,11], 32>;
222defm : X86WriteRes<WriteDiv8Ld,   [HWPort0,HWPort23,HWDivider], 29, [1,1,10], 2>;
223defm : X86WriteRes<WriteDiv16Ld,  [HWPort0,HWPort23,HWDivider], 29, [1,1,10], 2>;
224defm : X86WriteRes<WriteDiv32Ld,  [HWPort0,HWPort23,HWDivider], 29, [1,1,10], 2>;
225defm : X86WriteRes<WriteDiv64Ld,  [HWPort0,HWPort23,HWDivider], 29, [1,1,10], 2>;
226
227defm : X86WriteRes<WriteIDiv8,    [HWPort0,HWPort1,HWPort5,HWPort6], 23, [], 9>;
228defm : X86WriteRes<WriteIDiv16,   [HWPort0,HWPort1,HWPort5,HWPort6,HWPort06,HWPort0156], 112, [4,2,4,8,14,34], 66>;
229defm : X86WriteRes<WriteIDiv32,   [HWPort0,HWPort1,HWPort5,HWPort6,HWPort06,HWPort0156], 112, [4,2,4,8,14,34], 66>;
230defm : X86WriteRes<WriteIDiv64,   [HWPort0,HWPort1,HWPort5,HWPort6,HWPort06,HWPort0156], 112, [4,2,4,8,14,34], 66>;
231defm : X86WriteRes<WriteIDiv8Ld,  [HWPort0,HWPort23,HWDivider], 29, [1,1,10], 2>;
232defm : X86WriteRes<WriteIDiv16Ld, [HWPort0,HWPort23,HWDivider], 29, [1,1,10], 2>;
233defm : X86WriteRes<WriteIDiv32Ld, [HWPort0,HWPort23,HWDivider], 29, [1,1,10], 2>;
234defm : X86WriteRes<WriteIDiv64Ld, [HWPort0,HWPort23,HWDivider], 29, [1,1,10], 2>;
235
236// Floating point. This covers both scalar and vector operations.
237defm : X86WriteRes<WriteFLD0,          [HWPort01], 1, [1], 1>;
238defm : X86WriteRes<WriteFLD1,          [HWPort01], 1, [2], 2>;
239defm : X86WriteRes<WriteFLDC,          [HWPort01], 1, [2], 2>;
240defm : X86WriteRes<WriteFLoad,         [HWPort23], 5, [1], 1>;
241defm : X86WriteRes<WriteFLoadX,        [HWPort23], 6, [1], 1>;
242defm : X86WriteRes<WriteFLoadY,        [HWPort23], 7, [1], 1>;
243defm : X86WriteRes<WriteFMaskedLoad,   [HWPort23,HWPort5], 8, [1,2], 3>;
244defm : X86WriteRes<WriteFMaskedLoadY,  [HWPort23,HWPort5], 9, [1,2], 3>;
245defm : X86WriteRes<WriteFStore,        [HWPort237,HWPort4], 1, [1,1], 2>;
246defm : X86WriteRes<WriteFStoreX,       [HWPort237,HWPort4], 1, [1,1], 2>;
247defm : X86WriteRes<WriteFStoreY,       [HWPort237,HWPort4], 1, [1,1], 2>;
248defm : X86WriteRes<WriteFStoreNT,      [HWPort237,HWPort4], 1, [1,1], 2>;
249defm : X86WriteRes<WriteFStoreNTX,     [HWPort237,HWPort4], 1, [1,1], 2>;
250defm : X86WriteRes<WriteFStoreNTY,     [HWPort237,HWPort4], 1, [1,1], 2>;
251
252defm : X86WriteRes<WriteFMaskedStore32,  [HWPort0,HWPort4,HWPort237,HWPort15], 5, [1,1,1,1], 4>;
253defm : X86WriteRes<WriteFMaskedStore32Y, [HWPort0,HWPort4,HWPort237,HWPort15], 5, [1,1,1,1], 4>;
254defm : X86WriteRes<WriteFMaskedStore64,  [HWPort0,HWPort4,HWPort237,HWPort15], 5, [1,1,1,1], 4>;
255defm : X86WriteRes<WriteFMaskedStore64Y, [HWPort0,HWPort4,HWPort237,HWPort15], 5, [1,1,1,1], 4>;
256
257defm : X86WriteRes<WriteFMove,         [HWPort5], 1, [1], 1>;
258defm : X86WriteRes<WriteFMoveX,        [HWPort5], 1, [1], 1>;
259defm : X86WriteRes<WriteFMoveY,        [HWPort5], 1, [1], 1>;
260defm : X86WriteRes<WriteFMoveZ,        [HWPort5], 1, [1], 1>; // Unsupported = 1
261defm : X86WriteRes<WriteEMMS,          [HWPort01,HWPort15,HWPort015,HWPort0156], 31, [8,1,21,1], 31>;
262
263defm : HWWriteResPair<WriteFAdd,    [HWPort1],  3, [1], 1, 5>;
264defm : HWWriteResPair<WriteFAddX,   [HWPort1],  3, [1], 1, 6>;
265defm : HWWriteResPair<WriteFAddY,   [HWPort1],  3, [1], 1, 7>;
266defm : HWWriteResPair<WriteFAddZ,   [HWPort1],  3, [1], 1, 7>; // Unsupported = 1
267defm : HWWriteResPair<WriteFAdd64,  [HWPort1],  3, [1], 1, 5>;
268defm : HWWriteResPair<WriteFAdd64X, [HWPort1],  3, [1], 1, 6>;
269defm : HWWriteResPair<WriteFAdd64Y, [HWPort1],  3, [1], 1, 7>;
270defm : HWWriteResPair<WriteFAdd64Z, [HWPort1],  3, [1], 1, 7>; // Unsupported = 1
271
272defm : HWWriteResPair<WriteFCmp,    [HWPort1],  3, [1], 1, 5>;
273defm : HWWriteResPair<WriteFCmpX,   [HWPort1],  3, [1], 1, 6>;
274defm : HWWriteResPair<WriteFCmpY,   [HWPort1],  3, [1], 1, 7>;
275defm : HWWriteResPair<WriteFCmpZ,   [HWPort1],  3, [1], 1, 7>; // Unsupported = 1
276defm : HWWriteResPair<WriteFCmp64,  [HWPort1],  3, [1], 1, 5>;
277defm : HWWriteResPair<WriteFCmp64X, [HWPort1],  3, [1], 1, 6>;
278defm : HWWriteResPair<WriteFCmp64Y, [HWPort1],  3, [1], 1, 7>;
279defm : HWWriteResPair<WriteFCmp64Z, [HWPort1],  3, [1], 1, 7>; // Unsupported = 1
280
281defm : HWWriteResPair<WriteFCom,    [HWPort1],  3>;
282defm : HWWriteResPair<WriteFComX,   [HWPort1],  3>;
283
284defm : HWWriteResPair<WriteFMul,    [HWPort01],  5, [1], 1, 5>;
285defm : HWWriteResPair<WriteFMulX,   [HWPort01],  5, [1], 1, 6>;
286defm : HWWriteResPair<WriteFMulY,   [HWPort01],  5, [1], 1, 7>;
287defm : HWWriteResPair<WriteFMulZ,   [HWPort01],  5, [1], 1, 7>; // Unsupported = 1
288defm : HWWriteResPair<WriteFMul64,  [HWPort01],  5, [1], 1, 5>;
289defm : HWWriteResPair<WriteFMul64X, [HWPort01],  5, [1], 1, 6>;
290defm : HWWriteResPair<WriteFMul64Y, [HWPort01],  5, [1], 1, 7>;
291defm : HWWriteResPair<WriteFMul64Z, [HWPort01],  5, [1], 1, 7>; // Unsupported = 1
292
293defm : HWWriteResPair<WriteFDiv,    [HWPort0,HWFPDivider], 13, [1,7], 1, 5>;
294defm : HWWriteResPair<WriteFDivX,   [HWPort0,HWFPDivider], 13, [1,7], 1, 6>;
295defm : HWWriteResPair<WriteFDivY,   [HWPort0,HWPort15,HWFPDivider], 21, [2,1,14], 3, 7>;
296defm : HWWriteResPair<WriteFDivZ,   [HWPort0,HWPort15,HWFPDivider], 21, [2,1,14], 3, 7>; // Unsupported = 1
297defm : HWWriteResPair<WriteFDiv64,  [HWPort0,HWFPDivider], 20, [1,14], 1, 5>;
298defm : HWWriteResPair<WriteFDiv64X, [HWPort0,HWFPDivider], 20, [1,14], 1, 6>;
299defm : HWWriteResPair<WriteFDiv64Y, [HWPort0,HWPort15,HWFPDivider], 35, [2,1,28], 3, 7>;
300defm : HWWriteResPair<WriteFDiv64Z, [HWPort0,HWPort15,HWFPDivider], 35, [2,1,28], 3, 7>; // Unsupported = 1
301
302defm : HWWriteResPair<WriteFRcp,   [HWPort0],  5, [1], 1, 5>;
303defm : HWWriteResPair<WriteFRcpX,  [HWPort0],  5, [1], 1, 6>;
304defm : HWWriteResPair<WriteFRcpY,  [HWPort0,HWPort015], 11, [2,1], 3, 7>;
305defm : HWWriteResPair<WriteFRcpZ,  [HWPort0,HWPort015], 11, [2,1], 3, 7>; // Unsupported = 1
306
307defm : HWWriteResPair<WriteFRsqrt, [HWPort0],  5, [1], 1, 5>;
308defm : HWWriteResPair<WriteFRsqrtX,[HWPort0],  5, [1], 1, 6>;
309defm : HWWriteResPair<WriteFRsqrtY,[HWPort0,HWPort015], 11, [2,1], 3, 7>;
310defm : HWWriteResPair<WriteFRsqrtZ,[HWPort0,HWPort015], 11, [2,1], 3, 7>; // Unsupported = 1
311
312defm : HWWriteResPair<WriteFSqrt,    [HWPort0,HWFPDivider], 11, [1,7], 1, 5>;
313defm : HWWriteResPair<WriteFSqrtX,   [HWPort0,HWFPDivider], 11, [1,7], 1, 6>;
314defm : HWWriteResPair<WriteFSqrtY,   [HWPort0,HWPort15,HWFPDivider], 21, [2,1,14], 3, 7>;
315defm : HWWriteResPair<WriteFSqrtZ,   [HWPort0,HWPort15,HWFPDivider], 21, [2,1,14], 3, 7>; // Unsupported = 1
316defm : HWWriteResPair<WriteFSqrt64,  [HWPort0,HWFPDivider], 16, [1,14], 1, 5>;
317defm : HWWriteResPair<WriteFSqrt64X, [HWPort0,HWFPDivider], 16, [1,14], 1, 6>;
318defm : HWWriteResPair<WriteFSqrt64Y, [HWPort0,HWPort15,HWFPDivider], 35, [2,1,28], 3, 7>;
319defm : HWWriteResPair<WriteFSqrt64Z, [HWPort0,HWPort15,HWFPDivider], 35, [2,1,28], 3, 7>; // Unsupported = 1
320defm : HWWriteResPair<WriteFSqrt80,  [HWPort0,HWFPDivider], 23, [1,17]>;
321
322defm : HWWriteResPair<WriteFMA,    [HWPort01], 5, [1], 1, 5>;
323defm : HWWriteResPair<WriteFMAX,   [HWPort01], 5, [1], 1, 6>;
324defm : HWWriteResPair<WriteFMAY,   [HWPort01], 5, [1], 1, 7>;
325defm : HWWriteResPair<WriteFMAZ,   [HWPort01], 5, [1], 1, 7>; // Unsupported = 1
326defm : HWWriteResPair<WriteDPPD,   [HWPort0,HWPort1,HWPort5],  9, [1,1,1], 3, 6>;
327defm : HWWriteResPair<WriteDPPS,   [HWPort0,HWPort1,HWPort5], 14, [2,1,1], 4, 6>;
328defm : HWWriteResPair<WriteDPPSY,  [HWPort0,HWPort1,HWPort5], 14, [2,1,1], 4, 7>;
329defm : HWWriteResPair<WriteFSign,  [HWPort0], 1>;
330defm : X86WriteRes<WriteFRnd,            [HWPort23],  6, [1],   1>;
331defm : X86WriteRes<WriteFRndY,           [HWPort23],  6, [1],   1>;
332defm : X86WriteRes<WriteFRndZ,           [HWPort23],  6, [1],   1>; // Unsupported = 1
333defm : X86WriteRes<WriteFRndLd,  [HWPort1,HWPort23], 12, [2,1], 3>;
334defm : X86WriteRes<WriteFRndYLd, [HWPort1,HWPort23], 13, [2,1], 3>;
335defm : X86WriteRes<WriteFRndZLd, [HWPort1,HWPort23], 13, [2,1], 3>; // Unsupported = 1
336defm : HWWriteResPair<WriteFLogic,  [HWPort5], 1, [1], 1, 6>;
337defm : HWWriteResPair<WriteFLogicY, [HWPort5], 1, [1], 1, 7>;
338defm : HWWriteResPair<WriteFLogicZ, [HWPort5], 1, [1], 1, 7>; // Unsupported = 1
339defm : HWWriteResPair<WriteFTest,   [HWPort0], 1, [1], 1, 6>;
340defm : HWWriteResPair<WriteFTestY,  [HWPort0], 1, [1], 1, 7>;
341defm : HWWriteResPair<WriteFTestZ,  [HWPort0], 1, [1], 1, 7>; // Unsupported = 1
342defm : HWWriteResPair<WriteFShuffle,  [HWPort5], 1, [1], 1, 6>;
343defm : HWWriteResPair<WriteFShuffleY, [HWPort5], 1, [1], 1, 7>;
344defm : HWWriteResPair<WriteFShuffleZ, [HWPort5], 1, [1], 1, 7>; // Unsupported = 1
345defm : HWWriteResPair<WriteFVarShuffle,  [HWPort5], 1, [1], 1, 6>;
346defm : HWWriteResPair<WriteFVarShuffleY, [HWPort5], 1, [1], 1, 7>;
347defm : HWWriteResPair<WriteFVarShuffleZ, [HWPort5], 1, [1], 1, 7>; // Unsupported = 1
348defm : HWWriteResPair<WriteFBlend,  [HWPort015], 1, [1], 1, 6>;
349defm : HWWriteResPair<WriteFBlendY, [HWPort015], 1, [1], 1, 7>;
350defm : HWWriteResPair<WriteFBlendZ, [HWPort015], 1, [1], 1, 7>; // Unsupported = 1
351defm : HWWriteResPair<WriteFShuffle256, [HWPort5], 3, [1], 1, 7>;
352defm : HWWriteResPair<WriteFVarShuffle256, [HWPort5], 3, [1], 1, 7>;
353defm : HWWriteResPair<WriteFVarBlend,  [HWPort5], 2, [2], 2, 6>;
354defm : HWWriteResPair<WriteFVarBlendY, [HWPort5], 2, [2], 2, 7>;
355defm : HWWriteResPair<WriteFVarBlendZ, [HWPort5], 2, [2], 2, 7>; // Unsupported = 1
356
357// Conversion between integer and float.
358defm : HWWriteResPair<WriteCvtSD2I,   [HWPort1,HWPort0], 4, [1,1], 2, 5>;
359defm : HWWriteResPair<WriteCvtPD2I,   [HWPort1,HWPort5], 4, [1,1], 2, 6>;
360defm : HWWriteResPair<WriteCvtPD2IY,  [HWPort1,HWPort5], 6, [1,1], 2, 6>;
361defm : HWWriteResPair<WriteCvtPD2IZ,  [HWPort1,HWPort5], 6, [1,1], 2, 6>; // Unsupported = 1
362defm : HWWriteResPair<WriteCvtSS2I,   [HWPort1,HWPort0], 4, [1,1], 2, 5>;
363defm : HWWriteResPair<WriteCvtPS2I,   [HWPort1], 3, [1], 1, 6>;
364defm : HWWriteResPair<WriteCvtPS2IY,  [HWPort1], 3, [1], 1, 7>;
365defm : HWWriteResPair<WriteCvtPS2IZ,  [HWPort1], 3, [1], 1, 7>; // Unsupported = 1
366
367defm : X86WriteRes<WriteCvtI2SD,      [HWPort1,HWPort5], 4, [1,1], 2>;
368defm : X86WriteRes<WriteCvtI2SDLd,   [HWPort1,HWPort23], 9, [1,1], 2>;
369defm : HWWriteResPair<WriteCvtI2PD,   [HWPort1,HWPort5], 4, [1,1], 2, 6>;
370defm : HWWriteResPair<WriteCvtI2PDY,  [HWPort1,HWPort5], 6, [1,1], 2, 6>;
371defm : HWWriteResPair<WriteCvtI2PDZ,  [HWPort1,HWPort5], 6, [1,1], 2, 6>; // Unsupported = 1
372defm : X86WriteRes<WriteCvtI2SS,      [HWPort1,HWPort5], 4, [1,1], 2>;
373defm : X86WriteRes<WriteCvtI2SSLd,   [HWPort1,HWPort23], 9, [1,1], 2>;
374defm : HWWriteResPair<WriteCvtI2PS,   [HWPort1], 3, [1], 1, 6>;
375defm : HWWriteResPair<WriteCvtI2PSY,  [HWPort1], 3, [1], 1, 7>;
376defm : HWWriteResPair<WriteCvtI2PSZ,  [HWPort1], 3, [1], 1, 7>; // Unsupported = 1
377
378defm : X86WriteRes<WriteCvtSS2SD,     [HWPort0,HWPort5], 2, [1,1], 2>;
379defm : X86WriteRes<WriteCvtSS2SDLd,  [HWPort0,HWPort23], 7, [1,1], 2>;
380defm : X86WriteRes<WriteCvtPS2PD,     [HWPort0,HWPort5], 2, [1,1], 2>;
381defm : X86WriteRes<WriteCvtPS2PDLd,  [HWPort0,HWPort23], 6, [1,1], 2>;
382defm : HWWriteResPair<WriteCvtPS2PDY, [HWPort0,HWPort5], 4, [1,1], 2, 6>;
383defm : HWWriteResPair<WriteCvtPS2PDZ, [HWPort0,HWPort5], 4, [1,1], 2, 6>; // Unsupported = 1
384defm : HWWriteResPair<WriteCvtSD2SS,  [HWPort1,HWPort5], 4, [1,1], 2, 5>;
385defm : HWWriteResPair<WriteCvtPD2PS,  [HWPort1,HWPort5], 4, [1,1], 2, 6>;
386defm : HWWriteResPair<WriteCvtPD2PSY, [HWPort1,HWPort5], 6, [1,1], 2, 6>;
387defm : HWWriteResPair<WriteCvtPD2PSZ, [HWPort1,HWPort5], 4, [1,1], 2, 6>; // Unsupported = 1
388
389defm : X86WriteRes<WriteCvtPH2PS,     [HWPort0,HWPort5], 2, [1,1], 2>;
390defm : X86WriteRes<WriteCvtPH2PSY,    [HWPort0,HWPort5], 2, [1,1], 2>;
391defm : X86WriteRes<WriteCvtPH2PSZ,    [HWPort0,HWPort5], 2, [1,1], 2>; // Unsupported = 1
392defm : X86WriteRes<WriteCvtPH2PSLd,  [HWPort0,HWPort23], 6, [1,1], 2>;
393defm : X86WriteRes<WriteCvtPH2PSYLd, [HWPort0,HWPort23], 7, [1,1], 2>;
394defm : X86WriteRes<WriteCvtPH2PSZLd, [HWPort0,HWPort23], 7, [1,1], 2>; // Unsupported = 1
395
396defm : X86WriteRes<WriteCvtPS2PH,    [HWPort1,HWPort5], 4, [1,1], 2>;
397defm : X86WriteRes<WriteCvtPS2PHY,   [HWPort1,HWPort5], 6, [1,1], 2>;
398defm : X86WriteRes<WriteCvtPS2PHZ,   [HWPort1,HWPort5], 6, [1,1], 2>; // Unsupported = 1
399defm : X86WriteRes<WriteCvtPS2PHSt,  [HWPort1,HWPort4,HWPort5,HWPort237], 5, [1,1,1,1], 4>;
400defm : X86WriteRes<WriteCvtPS2PHYSt, [HWPort1,HWPort4,HWPort5,HWPort237], 7, [1,1,1,1], 4>;
401defm : X86WriteRes<WriteCvtPS2PHZSt, [HWPort1,HWPort4,HWPort5,HWPort237], 7, [1,1,1,1], 4>; // Unsupported = 1
402
403// Vector integer operations.
404defm : X86WriteRes<WriteVecLoad,         [HWPort23], 5, [1], 1>;
405defm : X86WriteRes<WriteVecLoadX,        [HWPort23], 6, [1], 1>;
406defm : X86WriteRes<WriteVecLoadY,        [HWPort23], 7, [1], 1>;
407defm : X86WriteRes<WriteVecLoadNT,       [HWPort23], 6, [1], 1>;
408defm : X86WriteRes<WriteVecLoadNTY,      [HWPort23], 7, [1], 1>;
409defm : X86WriteRes<WriteVecMaskedLoad,   [HWPort23,HWPort5], 8, [1,2], 3>;
410defm : X86WriteRes<WriteVecMaskedLoadY,  [HWPort23,HWPort5], 9, [1,2], 3>;
411defm : X86WriteRes<WriteVecStore,        [HWPort237,HWPort4], 1, [1,1], 2>;
412defm : X86WriteRes<WriteVecStoreX,       [HWPort237,HWPort4], 1, [1,1], 2>;
413defm : X86WriteRes<WriteVecStoreY,       [HWPort237,HWPort4], 1, [1,1], 2>;
414defm : X86WriteRes<WriteVecStoreNT,      [HWPort237,HWPort4], 1, [1,1], 2>;
415defm : X86WriteRes<WriteVecStoreNTY,     [HWPort237,HWPort4], 1, [1,1], 2>;
416defm : X86WriteRes<WriteVecMaskedStore32,  [HWPort0,HWPort4,HWPort237,HWPort15], 5, [1,1,1,1], 4>;
417defm : X86WriteRes<WriteVecMaskedStore32Y, [HWPort0,HWPort4,HWPort237,HWPort15], 5, [1,1,1,1], 4>;
418defm : X86WriteRes<WriteVecMaskedStore64,  [HWPort0,HWPort4,HWPort237,HWPort15], 5, [1,1,1,1], 4>;
419defm : X86WriteRes<WriteVecMaskedStore64Y, [HWPort0,HWPort4,HWPort237,HWPort15], 5, [1,1,1,1], 4>;
420defm : X86WriteRes<WriteVecMove,         [HWPort015], 1, [1], 1>;
421defm : X86WriteRes<WriteVecMoveX,        [HWPort015], 1, [1], 1>;
422defm : X86WriteRes<WriteVecMoveY,        [HWPort015], 1, [1], 1>;
423defm : X86WriteRes<WriteVecMoveZ,        [HWPort015], 1, [1], 1>; // Unsupported = 1
424defm : X86WriteRes<WriteVecMoveToGpr,    [HWPort0], 1, [1], 1>;
425defm : X86WriteRes<WriteVecMoveFromGpr,  [HWPort5], 1, [1], 1>;
426
427defm : HWWriteResPair<WriteVecLogic, [HWPort015], 1, [1], 1, 5>;
428defm : HWWriteResPair<WriteVecLogicX,[HWPort015], 1, [1], 1, 6>;
429defm : HWWriteResPair<WriteVecLogicY,[HWPort015], 1, [1], 1, 7>;
430defm : HWWriteResPair<WriteVecLogicZ,[HWPort015], 1, [1], 1, 7>; // Unsupported = 1
431defm : HWWriteResPair<WriteVecTest,  [HWPort0,HWPort5], 2, [1,1], 2, 6>;
432defm : HWWriteResPair<WriteVecTestY, [HWPort0,HWPort5], 4, [1,1], 2, 7>;
433defm : HWWriteResPair<WriteVecTestZ, [HWPort0,HWPort5], 4, [1,1], 2, 7>; // Unsupported = 1
434defm : HWWriteResPair<WriteVecALU,   [HWPort15],  1, [1], 1, 5>;
435defm : HWWriteResPair<WriteVecALUX,  [HWPort15],  1, [1], 1, 6>;
436defm : HWWriteResPair<WriteVecALUY,  [HWPort15],  1, [1], 1, 7>;
437defm : HWWriteResPair<WriteVecALUZ,  [HWPort15],  1, [1], 1, 7>; // Unsupported = 1
438defm : HWWriteResPair<WriteVecIMul,  [HWPort0],  5, [1], 1, 5>;
439defm : HWWriteResPair<WriteVecIMulX, [HWPort0],  5, [1], 1, 6>;
440defm : HWWriteResPair<WriteVecIMulY, [HWPort0],  5, [1], 1, 7>;
441defm : HWWriteResPair<WriteVecIMulZ, [HWPort0],  5, [1], 1, 7>; // Unsupported = 1
442defm : HWWriteResPair<WritePMULLD,   [HWPort0], 10, [2], 2, 6>;
443defm : HWWriteResPair<WritePMULLDY,  [HWPort0], 10, [2], 2, 7>;
444defm : HWWriteResPair<WritePMULLDZ,  [HWPort0], 10, [2], 2, 7>; // Unsupported = 1
445defm : HWWriteResPair<WriteShuffle,  [HWPort5],  1, [1], 1, 5>;
446defm : HWWriteResPair<WriteShuffleX, [HWPort5],  1, [1], 1, 6>;
447defm : HWWriteResPair<WriteShuffleY, [HWPort5],  1, [1], 1, 7>;
448defm : HWWriteResPair<WriteShuffleZ, [HWPort5],  1, [1], 1, 7>; // Unsupported = 1
449defm : HWWriteResPair<WriteVarShuffle, [HWPort5], 1, [1], 1, 5>;
450defm : HWWriteResPair<WriteVarShuffleX,[HWPort5], 1, [1], 1, 6>;
451defm : HWWriteResPair<WriteVarShuffleY,[HWPort5], 1, [1], 1, 7>;
452defm : HWWriteResPair<WriteVarShuffleZ,[HWPort5], 1, [1], 1, 7>; // Unsupported = 1
453defm : HWWriteResPair<WriteBlend,  [HWPort5], 1, [1], 1, 6>;
454defm : HWWriteResPair<WriteBlendY, [HWPort5], 1, [1], 1, 7>;
455defm : HWWriteResPair<WriteBlendZ, [HWPort5], 1, [1], 1, 7>; // Unsupported = 1
456defm : HWWriteResPair<WriteShuffle256, [HWPort5], 3, [1], 1, 7>;
457defm : HWWriteResPair<WriteVPMOV256, [HWPort5], 3, [1], 1, 7>;
458defm : HWWriteResPair<WriteVarShuffle256, [HWPort5], 3, [1], 1, 7>;
459defm : HWWriteResPair<WriteVarBlend,  [HWPort5], 2, [2], 2, 6>;
460defm : HWWriteResPair<WriteVarBlendY, [HWPort5], 2, [2], 2, 7>;
461defm : HWWriteResPair<WriteVarBlendZ, [HWPort5], 2, [2], 2, 7>; // Unsupported = 1
462defm : HWWriteResPair<WriteMPSAD,  [HWPort0, HWPort5], 7, [1, 2], 3, 6>;
463defm : HWWriteResPair<WriteMPSADY, [HWPort0, HWPort5], 7, [1, 2], 3, 7>;
464defm : HWWriteResPair<WriteMPSADZ, [HWPort0, HWPort5], 7, [1, 2], 3, 7>; // Unsupported = 1
465defm : HWWriteResPair<WritePSADBW,  [HWPort0], 5, [1], 1, 5>;
466defm : HWWriteResPair<WritePSADBWX, [HWPort0], 5, [1], 1, 6>;
467defm : HWWriteResPair<WritePSADBWY, [HWPort0], 5, [1], 1, 7>;
468defm : HWWriteResPair<WritePSADBWZ, [HWPort0], 5, [1], 1, 7>; // Unsupported = 1
469defm : HWWriteResPair<WritePHMINPOS, [HWPort0],  5, [1], 1, 6>;
470
471// Vector integer shifts.
472defm : HWWriteResPair<WriteVecShift,     [HWPort0], 1, [1], 1, 5>;
473defm : HWWriteResPair<WriteVecShiftX,    [HWPort0,HWPort5],  2, [1,1], 2, 6>;
474defm : X86WriteRes<WriteVecShiftY,       [HWPort0,HWPort5],  4, [1,1], 2>;
475defm : X86WriteRes<WriteVecShiftZ,       [HWPort0,HWPort5],  4, [1,1], 2>; // Unsupported = 1
476defm : X86WriteRes<WriteVecShiftYLd,     [HWPort0,HWPort23], 8, [1,1], 2>;
477defm : X86WriteRes<WriteVecShiftZLd,     [HWPort0,HWPort23], 8, [1,1], 2>; // Unsupported = 1
478
479defm : HWWriteResPair<WriteVecShiftImm,  [HWPort0], 1, [1], 1, 5>;
480defm : HWWriteResPair<WriteVecShiftImmX, [HWPort0], 1, [1], 1, 6>;
481defm : HWWriteResPair<WriteVecShiftImmY, [HWPort0], 1, [1], 1, 7>;
482defm : HWWriteResPair<WriteVecShiftImmZ, [HWPort0], 1, [1], 1, 7>; // Unsupported = 1
483defm : HWWriteResPair<WriteVarVecShift,  [HWPort0, HWPort5], 3, [2,1], 3, 6>;
484defm : HWWriteResPair<WriteVarVecShiftY, [HWPort0, HWPort5], 3, [2,1], 3, 7>;
485defm : HWWriteResPair<WriteVarVecShiftZ, [HWPort0, HWPort5], 3, [2,1], 3, 7>; // Unsupported = 1
486
487// Vector insert/extract operations.
488def : WriteRes<WriteVecInsert, [HWPort5]> {
489  let Latency = 2;
490  let NumMicroOps = 2;
491  let ResourceCycles = [2];
492}
493def : WriteRes<WriteVecInsertLd, [HWPort5,HWPort23]> {
494  let Latency = 6;
495  let NumMicroOps = 2;
496}
497def: InstRW<[WriteVecInsertLd], (instregex "(V?)MOV(H|L)(PD|PS)rm")>;
498
499def : WriteRes<WriteVecExtract, [HWPort0,HWPort5]> {
500  let Latency = 2;
501  let NumMicroOps = 2;
502}
503def : WriteRes<WriteVecExtractSt, [HWPort4,HWPort5,HWPort237]> {
504  let Latency = 2;
505  let NumMicroOps = 3;
506}
507
508// String instructions.
509
510// Packed Compare Implicit Length Strings, Return Mask
511def : WriteRes<WritePCmpIStrM, [HWPort0]> {
512  let Latency = 11;
513  let NumMicroOps = 3;
514  let ResourceCycles = [3];
515}
516def : WriteRes<WritePCmpIStrMLd, [HWPort0, HWPort23]> {
517  let Latency = 17;
518  let NumMicroOps = 4;
519  let ResourceCycles = [3,1];
520}
521
522// Packed Compare Explicit Length Strings, Return Mask
523def : WriteRes<WritePCmpEStrM, [HWPort0, HWPort5, HWPort015, HWPort0156]> {
524  let Latency = 19;
525  let NumMicroOps = 9;
526  let ResourceCycles = [4,3,1,1];
527}
528def : WriteRes<WritePCmpEStrMLd, [HWPort0, HWPort5, HWPort23, HWPort015, HWPort0156]> {
529  let Latency = 25;
530  let NumMicroOps = 10;
531  let ResourceCycles = [4,3,1,1,1];
532}
533
534// Packed Compare Implicit Length Strings, Return Index
535def : WriteRes<WritePCmpIStrI, [HWPort0]> {
536  let Latency = 11;
537  let NumMicroOps = 3;
538  let ResourceCycles = [3];
539}
540def : WriteRes<WritePCmpIStrILd, [HWPort0, HWPort23]> {
541  let Latency = 17;
542  let NumMicroOps = 4;
543  let ResourceCycles = [3,1];
544}
545
546// Packed Compare Explicit Length Strings, Return Index
547def : WriteRes<WritePCmpEStrI, [HWPort0, HWPort5, HWPort0156]> {
548  let Latency = 18;
549  let NumMicroOps = 8;
550  let ResourceCycles = [4,3,1];
551}
552def : WriteRes<WritePCmpEStrILd, [HWPort0, HWPort5, HWPort23, HWPort0156]> {
553  let Latency = 24;
554  let NumMicroOps = 9;
555  let ResourceCycles = [4,3,1,1];
556}
557
558// MOVMSK Instructions.
559def : WriteRes<WriteFMOVMSK,    [HWPort0]> { let Latency = 3; }
560def : WriteRes<WriteVecMOVMSK,  [HWPort0]> { let Latency = 3; }
561def : WriteRes<WriteVecMOVMSKY, [HWPort0]> { let Latency = 3; }
562def : WriteRes<WriteMMXMOVMSK,  [HWPort0]> { let Latency = 1; }
563
564// AES Instructions.
565def : WriteRes<WriteAESDecEnc, [HWPort5]> {
566  let Latency = 7;
567  let NumMicroOps = 1;
568  let ResourceCycles = [1];
569}
570def : WriteRes<WriteAESDecEncLd, [HWPort5, HWPort23]> {
571  let Latency = 13;
572  let NumMicroOps = 2;
573  let ResourceCycles = [1,1];
574}
575
576def : WriteRes<WriteAESIMC, [HWPort5]> {
577  let Latency = 14;
578  let NumMicroOps = 2;
579  let ResourceCycles = [2];
580}
581def : WriteRes<WriteAESIMCLd, [HWPort5, HWPort23]> {
582  let Latency = 20;
583  let NumMicroOps = 3;
584  let ResourceCycles = [2,1];
585}
586
587def : WriteRes<WriteAESKeyGen, [HWPort0,HWPort5,HWPort015]> {
588  let Latency = 29;
589  let NumMicroOps = 11;
590  let ResourceCycles = [2,7,2];
591}
592def : WriteRes<WriteAESKeyGenLd, [HWPort0,HWPort5,HWPort23,HWPort015]> {
593  let Latency = 34;
594  let NumMicroOps = 11;
595  let ResourceCycles = [2,7,1,1];
596}
597
598// Carry-less multiplication instructions.
599def : WriteRes<WriteCLMul, [HWPort0, HWPort5]> {
600  let Latency = 11;
601  let NumMicroOps = 3;
602  let ResourceCycles = [2,1];
603}
604def : WriteRes<WriteCLMulLd, [HWPort0, HWPort5, HWPort23]> {
605  let Latency = 17;
606  let NumMicroOps = 4;
607  let ResourceCycles = [2,1,1];
608}
609
610// Load/store MXCSR.
611def : WriteRes<WriteLDMXCSR, [HWPort0,HWPort23,HWPort0156]> { let Latency = 7; let NumMicroOps = 3; let ResourceCycles = [1,1,1]; }
612def : WriteRes<WriteSTMXCSR, [HWPort4,HWPort5,HWPort237]> { let Latency = 2; let NumMicroOps = 3; let ResourceCycles = [1,1,1]; }
613
614// Catch-all for expensive system instructions.
615def : WriteRes<WriteSystem,     [HWPort0156]> { let Latency = 100; }
616
617// Old microcoded instructions that nobody use.
618def : WriteRes<WriteMicrocoded, [HWPort0156]> { let Latency = 100; }
619
620// Fence instructions.
621def : WriteRes<WriteFence,  [HWPort23, HWPort4]>;
622
623// Nop, not very useful expect it provides a model for nops!
624def : WriteRes<WriteNop, []>;
625
626////////////////////////////////////////////////////////////////////////////////
627// Horizontal add/sub  instructions.
628////////////////////////////////////////////////////////////////////////////////
629
630defm : HWWriteResPair<WriteFHAdd,   [HWPort1, HWPort5], 5, [1,2], 3, 6>;
631defm : HWWriteResPair<WriteFHAddY,  [HWPort1, HWPort5], 5, [1,2], 3, 7>;
632defm : HWWriteResPair<WritePHAdd,  [HWPort5, HWPort15], 3, [2,1], 3, 5>;
633defm : HWWriteResPair<WritePHAddX, [HWPort5, HWPort15], 3, [2,1], 3, 6>;
634defm : HWWriteResPair<WritePHAddY, [HWPort5, HWPort15], 3, [2,1], 3, 7>;
635
636//================ Exceptions ================//
637
638//-- Specific Scheduling Models --//
639
640// Starting with P0.
641def HWWriteP0 : SchedWriteRes<[HWPort0]>;
642
643def HWWriteP01 : SchedWriteRes<[HWPort01]>;
644
645def HWWrite2P01 : SchedWriteRes<[HWPort01]> {
646  let NumMicroOps = 2;
647}
648def HWWrite3P01 : SchedWriteRes<[HWPort01]> {
649  let NumMicroOps = 3;
650}
651
652def HWWriteP0156_P23 : SchedWriteRes<[HWPort0156, HWPort23]> {
653  let NumMicroOps = 2;
654}
655
656def HWWrite2P0156_P23 : SchedWriteRes<[HWPort0156, HWPort23]> {
657  let NumMicroOps = 3;
658  let ResourceCycles = [2, 1];
659}
660
661// Starting with P1.
662def HWWriteP1 : SchedWriteRes<[HWPort1]>;
663
664
665def HWWrite2P1 : SchedWriteRes<[HWPort1]> {
666  let NumMicroOps = 2;
667  let ResourceCycles = [2];
668}
669
670// Notation:
671// - r: register.
672// - mm: 64 bit mmx register.
673// - x = 128 bit xmm register.
674// - (x)mm = mmx or xmm register.
675// - y = 256 bit ymm register.
676// - v = any vector register.
677// - m = memory.
678
679//=== Integer Instructions ===//
680//-- Move instructions --//
681
682// XLAT.
683def HWWriteXLAT : SchedWriteRes<[]> {
684  let Latency = 7;
685  let NumMicroOps = 3;
686}
687def : InstRW<[HWWriteXLAT], (instrs XLAT)>;
688
689// PUSHA.
690def HWWritePushA : SchedWriteRes<[]> {
691  let NumMicroOps = 19;
692}
693def : InstRW<[HWWritePushA], (instregex "PUSHA(16|32)")>;
694
695// POPA.
696def HWWritePopA : SchedWriteRes<[]> {
697  let NumMicroOps = 18;
698}
699def : InstRW<[HWWritePopA], (instregex "POPA(16|32)")>;
700
701//-- Arithmetic instructions --//
702
703// BTR BTS BTC.
704// m,r.
705def HWWriteBTRSCmr : SchedWriteRes<[]> {
706  let NumMicroOps = 11;
707}
708def : SchedAlias<WriteBitTestSetRegRMW, HWWriteBTRSCmr>;
709
710//-- Control transfer instructions --//
711
712// CALL.
713// i.
714def HWWriteRETI : SchedWriteRes<[HWPort23, HWPort6, HWPort015]> {
715  let NumMicroOps = 4;
716  let ResourceCycles = [1, 2, 1];
717}
718def : InstRW<[HWWriteRETI], (instregex "RETI(16|32|64)", "LRETI(16|32|64)")>;
719
720// BOUND.
721// r,m.
722def HWWriteBOUND : SchedWriteRes<[]> {
723  let NumMicroOps = 15;
724}
725def : InstRW<[HWWriteBOUND], (instregex "BOUNDS(16|32)rm")>;
726
727// INTO.
728def HWWriteINTO : SchedWriteRes<[]> {
729  let NumMicroOps = 4;
730}
731def : InstRW<[HWWriteINTO], (instrs INTO)>;
732
733//-- String instructions --//
734
735// LODSB/W.
736def : InstRW<[HWWrite2P0156_P23], (instregex "LODS(B|W)")>;
737
738// LODSD/Q.
739def : InstRW<[HWWriteP0156_P23], (instregex "LODS(L|Q)")>;
740
741// MOVS.
742def HWWriteMOVS : SchedWriteRes<[HWPort23, HWPort4, HWPort0156]> {
743  let Latency = 4;
744  let NumMicroOps = 5;
745  let ResourceCycles = [2, 1, 2];
746}
747def : InstRW<[HWWriteMOVS], (instrs MOVSB, MOVSL, MOVSQ, MOVSW)>;
748
749// CMPS.
750def HWWriteCMPS : SchedWriteRes<[HWPort23, HWPort0156]> {
751  let Latency = 4;
752  let NumMicroOps = 5;
753  let ResourceCycles = [2, 3];
754}
755def : InstRW<[HWWriteCMPS], (instregex "CMPS(B|L|Q|W)")>;
756
757//-- Other --//
758
759// RDPMC.f
760def HWWriteRDPMC : SchedWriteRes<[]> {
761  let NumMicroOps = 34;
762}
763def : InstRW<[HWWriteRDPMC], (instrs RDPMC)>;
764
765// RDRAND.
766def HWWriteRDRAND : SchedWriteRes<[HWPort23, HWPort015]> {
767  let NumMicroOps = 17;
768  let ResourceCycles = [1, 16];
769}
770def : InstRW<[HWWriteRDRAND], (instrs RDRAND16r, RDRAND32r, RDRAND64r)>;
771
772//=== Floating Point x87 Instructions ===//
773//-- Move instructions --//
774
775// FLD.
776// m80.
777def : InstRW<[HWWriteP01], (instrs LD_Frr)>;
778
779// FBLD.
780// m80.
781def HWWriteFBLD : SchedWriteRes<[]> {
782  let Latency = 47;
783  let NumMicroOps = 43;
784}
785def : InstRW<[HWWriteFBLD], (instrs FBLDm)>;
786
787// FST(P).
788// r.
789def : InstRW<[HWWriteP01], (instregex "ST_(F|FP)rr")>;
790
791// FFREE.
792def : InstRW<[HWWriteP01], (instregex "FFREE")>;
793
794// FNSAVE.
795def HWWriteFNSAVE : SchedWriteRes<[]> {
796  let NumMicroOps = 147;
797}
798def : InstRW<[HWWriteFNSAVE], (instrs FSAVEm)>;
799
800// FRSTOR.
801def HWWriteFRSTOR : SchedWriteRes<[]> {
802  let NumMicroOps = 90;
803}
804def : InstRW<[HWWriteFRSTOR], (instrs FRSTORm)>;
805
806//-- Arithmetic instructions --//
807
808// FCOMPP FUCOMPP.
809// r.
810def : InstRW<[HWWrite2P01], (instrs FCOMPP, UCOM_FPPr)>;
811
812// FCOMI(P) FUCOMI(P).
813// m.
814def : InstRW<[HWWrite3P01], (instrs COM_FIPr, COM_FIr, UCOM_FIPr, UCOM_FIr)>;
815
816// FTST.
817def : InstRW<[HWWriteP1], (instregex "TST_F")>;
818
819// FXAM.
820def : InstRW<[HWWrite2P1], (instrs XAM_F)>;
821
822// FPREM.
823def HWWriteFPREM : SchedWriteRes<[]> {
824  let Latency = 19;
825  let NumMicroOps = 28;
826}
827def : InstRW<[HWWriteFPREM], (instrs FPREM)>;
828
829// FPREM1.
830def HWWriteFPREM1 : SchedWriteRes<[]> {
831  let Latency = 27;
832  let NumMicroOps = 41;
833}
834def : InstRW<[HWWriteFPREM1], (instrs FPREM1)>;
835
836// FRNDINT.
837def HWWriteFRNDINT : SchedWriteRes<[]> {
838  let Latency = 11;
839  let NumMicroOps = 17;
840}
841def : InstRW<[HWWriteFRNDINT], (instrs FRNDINT)>;
842
843//-- Math instructions --//
844
845// FSCALE.
846def HWWriteFSCALE : SchedWriteRes<[]> {
847  let Latency = 75; // 49-125
848  let NumMicroOps = 50; // 25-75
849}
850def : InstRW<[HWWriteFSCALE], (instrs FSCALE)>;
851
852// FXTRACT.
853def HWWriteFXTRACT : SchedWriteRes<[]> {
854  let Latency = 15;
855  let NumMicroOps = 17;
856}
857def : InstRW<[HWWriteFXTRACT], (instrs FXTRACT)>;
858
859//=== Floating Point XMM and YMM Instructions ===//
860
861// Remaining instrs.
862
863def HWWriteResGroup0 : SchedWriteRes<[HWPort23]> {
864  let Latency = 6;
865  let NumMicroOps = 1;
866  let ResourceCycles = [1];
867}
868def: InstRW<[HWWriteResGroup0], (instrs VBROADCASTSSrm)>;
869def: InstRW<[HWWriteResGroup0], (instregex "(V?)MOVSHDUPrm",
870                                           "(V?)MOVSLDUPrm",
871                                           "(V?)MOVDDUPrm",
872                                           "VPBROADCAST(D|Q)rm")>;
873
874def HWWriteResGroup0_1 : SchedWriteRes<[HWPort23]> {
875  let Latency = 7;
876  let NumMicroOps = 1;
877  let ResourceCycles = [1];
878}
879def: InstRW<[HWWriteResGroup0_1], (instrs VBROADCASTF128,
880                                          VBROADCASTI128,
881                                          VBROADCASTSDYrm,
882                                          VBROADCASTSSYrm,
883                                          VMOVDDUPYrm,
884                                          VMOVSHDUPYrm,
885                                          VMOVSLDUPYrm)>;
886def: InstRW<[HWWriteResGroup0_1], (instregex "LD_F(32|64|80)m",
887                                             "VPBROADCAST(D|Q)Yrm")>;
888
889def HWWriteResGroup1 : SchedWriteRes<[HWPort4,HWPort237]> {
890  let Latency = 1;
891  let NumMicroOps = 2;
892  let ResourceCycles = [1,1];
893}
894def: InstRW<[HWWriteResGroup1], (instrs FBSTPm, VMPTRSTm)>;
895def: InstRW<[HWWriteResGroup1], (instregex "ST_FP(32|64|80)m")>;
896
897def HWWriteResGroup2 : SchedWriteRes<[HWPort0]> {
898  let Latency = 1;
899  let NumMicroOps = 1;
900  let ResourceCycles = [1];
901}
902def: InstRW<[HWWriteResGroup2], (instregex "VPSLLVQ(Y?)rr",
903                                           "VPSRLVQ(Y?)rr")>;
904
905def HWWriteResGroup3 : SchedWriteRes<[HWPort1]> {
906  let Latency = 1;
907  let NumMicroOps = 1;
908  let ResourceCycles = [1];
909}
910def: InstRW<[HWWriteResGroup3], (instregex "COM(P?)_FST0r",
911                                           "UCOM_F(P?)r")>;
912
913def HWWriteResGroup4 : SchedWriteRes<[HWPort5]> {
914  let Latency = 1;
915  let NumMicroOps = 1;
916  let ResourceCycles = [1];
917}
918def: InstRW<[HWWriteResGroup4], (instrs MMX_MOVQ2DQrr)>;
919
920def HWWriteResGroup5 : SchedWriteRes<[HWPort6]> {
921  let Latency = 1;
922  let NumMicroOps = 1;
923  let ResourceCycles = [1];
924}
925def: InstRW<[HWWriteResGroup5], (instregex "JMP(16|32|64)r")>;
926
927def HWWriteResGroup6 : SchedWriteRes<[HWPort01]> {
928  let Latency = 1;
929  let NumMicroOps = 1;
930  let ResourceCycles = [1];
931}
932def: InstRW<[HWWriteResGroup6], (instrs FINCSTP, FNOP)>;
933
934def HWWriteResGroup7 : SchedWriteRes<[HWPort06]> {
935  let Latency = 1;
936  let NumMicroOps = 1;
937  let ResourceCycles = [1];
938}
939def: InstRW<[HWWriteResGroup7], (instrs CDQ, CQO)>;
940
941def HWWriteResGroup8 : SchedWriteRes<[HWPort15]> {
942  let Latency = 1;
943  let NumMicroOps = 1;
944  let ResourceCycles = [1];
945}
946def: InstRW<[HWWriteResGroup8], (instregex "ANDN(32|64)rr")>;
947
948def HWWriteResGroup9 : SchedWriteRes<[HWPort015]> {
949  let Latency = 1;
950  let NumMicroOps = 1;
951  let ResourceCycles = [1];
952}
953def: InstRW<[HWWriteResGroup9], (instregex "VPBLENDD(Y?)rri")>;
954
955def HWWriteResGroup10 : SchedWriteRes<[HWPort0156]> {
956  let Latency = 1;
957  let NumMicroOps = 1;
958  let ResourceCycles = [1];
959}
960def: InstRW<[HWWriteResGroup10], (instrs SGDT64m,
961                                         SIDT64m,
962                                         SMSW16m,
963                                         STRm,
964                                         SYSCALL)>;
965
966def HWWriteResGroup11_1 : SchedWriteRes<[HWPort0,HWPort23]> {
967  let Latency = 7;
968  let NumMicroOps = 2;
969  let ResourceCycles = [1,1];
970}
971def: InstRW<[HWWriteResGroup11_1], (instrs VPSLLVQrm, VPSRLVQrm)>;
972
973def HWWriteResGroup11_2 : SchedWriteRes<[HWPort0,HWPort23]> {
974  let Latency = 8;
975  let NumMicroOps = 2;
976  let ResourceCycles = [1,1];
977}
978def: InstRW<[HWWriteResGroup11_2], (instrs VPSLLVQYrm, VPSRLVQYrm)>;
979
980def HWWriteResGroup12 : SchedWriteRes<[HWPort1,HWPort23]> {
981  let Latency = 8;
982  let NumMicroOps = 2;
983  let ResourceCycles = [1,1];
984}
985def: InstRW<[HWWriteResGroup12], (instrs MMX_CVTPI2PSrm)>;
986def: InstRW<[HWWriteResGroup12], (instregex "P(DEP|EXT)(32|64)rm")>;
987
988def HWWriteResGroup13 : SchedWriteRes<[HWPort5,HWPort23]> {
989  let Latency = 6;
990  let NumMicroOps = 2;
991  let ResourceCycles = [1,1];
992}
993def: InstRW<[HWWriteResGroup13], (instregex "(V?)PMOV(SX|ZX)BDrm",
994                                            "(V?)PMOV(SX|ZX)BQrm",
995                                            "(V?)PMOV(SX|ZX)BWrm",
996                                            "(V?)PMOV(SX|ZX)DQrm",
997                                            "(V?)PMOV(SX|ZX)WDrm",
998                                            "(V?)PMOV(SX|ZX)WQrm")>;
999
1000def HWWriteResGroup13_1 : SchedWriteRes<[HWPort5,HWPort23]> {
1001  let Latency = 8;
1002  let NumMicroOps = 2;
1003  let ResourceCycles = [1,1];
1004}
1005def: InstRW<[HWWriteResGroup13_1], (instrs VPMOVSXBDYrm,
1006                                           VPMOVSXBQYrm,
1007                                           VPMOVSXWQYrm)>;
1008
1009def HWWriteResGroup14 : SchedWriteRes<[HWPort6,HWPort23]> {
1010  let Latency = 6;
1011  let NumMicroOps = 2;
1012  let ResourceCycles = [1,1];
1013}
1014def: InstRW<[HWWriteResGroup14], (instrs FARJMP64m)>;
1015def: InstRW<[HWWriteResGroup14], (instregex "JMP(16|32|64)m")>;
1016
1017def HWWriteResGroup16 : SchedWriteRes<[HWPort23,HWPort15]> {
1018  let Latency = 6;
1019  let NumMicroOps = 2;
1020  let ResourceCycles = [1,1];
1021}
1022def: InstRW<[HWWriteResGroup16], (instregex "ANDN(32|64)rm",
1023                                            "MOVBE(16|32|64)rm")>;
1024
1025def HWWriteResGroup17 : SchedWriteRes<[HWPort23,HWPort015]> {
1026  let Latency = 7;
1027  let NumMicroOps = 2;
1028  let ResourceCycles = [1,1];
1029}
1030def: InstRW<[HWWriteResGroup17], (instrs VINSERTF128rm,
1031                                         VINSERTI128rm,
1032                                         VPBLENDDrmi)>;
1033
1034def HWWriteResGroup17_2 : SchedWriteRes<[HWPort23,HWPort015]> {
1035  let Latency = 8;
1036  let NumMicroOps = 2;
1037  let ResourceCycles = [1,1];
1038}
1039def: InstRW<[HWWriteResGroup17_2], (instrs VPBLENDDYrmi)>;
1040
1041def HWWriteResGroup18 : SchedWriteRes<[HWPort23,HWPort0156]> {
1042  let Latency = 6;
1043  let NumMicroOps = 2;
1044  let ResourceCycles = [1,1];
1045}
1046def: InstRW<[HWWriteResGroup18], (instrs POP16r, POP32r, POP64r)>;
1047def: InstRW<[HWWriteResGroup18], (instregex "POP(16|32|64)rmr")>;
1048
1049def HWWriteResGroup19 : SchedWriteRes<[HWPort237,HWPort0156]> {
1050  let Latency = 2;
1051  let NumMicroOps = 2;
1052  let ResourceCycles = [1,1];
1053}
1054def: InstRW<[HWWriteResGroup19], (instrs SFENCE)>;
1055
1056def HWWriteResGroup21 : SchedWriteRes<[HWPort4,HWPort6,HWPort237]> {
1057  let Latency = 2;
1058  let NumMicroOps = 3;
1059  let ResourceCycles = [1,1,1];
1060}
1061def: InstRW<[HWWriteResGroup21], (instrs FNSTCW16m)>;
1062
1063def HWWriteResGroup23 : SchedWriteRes<[HWPort4,HWPort237,HWPort15]> {
1064  let Latency = 2;
1065  let NumMicroOps = 3;
1066  let ResourceCycles = [1,1,1];
1067}
1068def: InstRW<[HWWriteResGroup23], (instregex "MOVBE(32|64)mr")>;
1069
1070def HWWriteResGroup23_16 : SchedWriteRes<[HWPort06, HWPort237, HWPort4]> {
1071  let Latency = 2;
1072  let NumMicroOps = 3;
1073  let ResourceCycles = [1,1,1];
1074}
1075def: InstRW<[HWWriteResGroup23_16], (instrs MOVBE16mr)>;
1076
1077def HWWriteResGroup24 : SchedWriteRes<[HWPort4,HWPort237,HWPort0156]> {
1078  let Latency = 2;
1079  let NumMicroOps = 3;
1080  let ResourceCycles = [1,1,1];
1081}
1082def: InstRW<[HWWriteResGroup24], (instrs PUSH16r, PUSH32r, PUSH64r, PUSH64i8,
1083                                         STOSB, STOSL, STOSQ, STOSW)>;
1084def: InstRW<[HWWriteResGroup24], (instregex "PUSH(16|32|64)rmr")>;
1085
1086def HWWriteResGroup25 : SchedWriteRes<[HWPort4,HWPort23,HWPort237,HWPort06]> {
1087  let Latency = 7;
1088  let NumMicroOps = 4;
1089  let ResourceCycles = [1,1,1,1];
1090}
1091def: InstRW<[HWWriteResGroup25], (instregex "SAR(8|16|32|64)m(1|i)",
1092                                            "SHL(8|16|32|64)m(1|i)",
1093                                            "SHR(8|16|32|64)m(1|i)")>;
1094
1095def HWWriteResGroup26 : SchedWriteRes<[HWPort4,HWPort23,HWPort237,HWPort0156]> {
1096  let Latency = 7;
1097  let NumMicroOps = 4;
1098  let ResourceCycles = [1,1,1,1];
1099}
1100def: InstRW<[HWWriteResGroup26], (instregex "POP(16|32|64)rmm",
1101                                            "PUSH(16|32|64)rmm")>;
1102
1103def HWWriteResGroup28 : SchedWriteRes<[HWPort01]> {
1104  let Latency = 2;
1105  let NumMicroOps = 2;
1106  let ResourceCycles = [2];
1107}
1108def: InstRW<[HWWriteResGroup28], (instrs FDECSTP)>;
1109
1110def HWWriteResGroup30 : SchedWriteRes<[HWPort0156]> {
1111  let Latency = 2;
1112  let NumMicroOps = 2;
1113  let ResourceCycles = [2];
1114}
1115def: InstRW<[HWWriteResGroup30], (instrs LFENCE,
1116                                         MFENCE,
1117                                         WAIT,
1118                                         XGETBV)>;
1119
1120def HWWriteResGroup32 : SchedWriteRes<[HWPort6,HWPort0156]> {
1121  let Latency = 2;
1122  let NumMicroOps = 2;
1123  let ResourceCycles = [1,1];
1124}
1125def: InstRW<[HWWriteResGroup32], (instregex "CLFLUSH")>;
1126
1127def HWWriteResGroup33 : SchedWriteRes<[HWPort01,HWPort015]> {
1128  let Latency = 2;
1129  let NumMicroOps = 2;
1130  let ResourceCycles = [1,1];
1131}
1132def: InstRW<[HWWriteResGroup33], (instrs MMX_MOVDQ2Qrr)>;
1133
1134def HWWriteResGroup35 : SchedWriteRes<[HWPort06,HWPort0156]> {
1135  let Latency = 2;
1136  let NumMicroOps = 2;
1137  let ResourceCycles = [1,1];
1138}
1139def: InstRW<[HWWriteResGroup35], (instrs CWD, JCXZ, JECXZ, JRCXZ)>;
1140
1141def HWWriteResGroup36_2 : SchedWriteRes<[HWPort5,HWPort23]> {
1142  let Latency = 7;
1143  let NumMicroOps = 3;
1144  let ResourceCycles = [2,1];
1145}
1146def: InstRW<[HWWriteResGroup36_2], (instrs MMX_PACKSSDWrm,
1147                                           MMX_PACKSSWBrm,
1148                                           MMX_PACKUSWBrm)>;
1149
1150def HWWriteResGroup37 : SchedWriteRes<[HWPort23,HWPort0156]> {
1151  let Latency = 7;
1152  let NumMicroOps = 3;
1153  let ResourceCycles = [1,2];
1154}
1155def: InstRW<[HWWriteResGroup37], (instrs LEAVE, LEAVE64,
1156                                         SCASB, SCASL, SCASQ, SCASW)>;
1157
1158def HWWriteResGroup39 : SchedWriteRes<[HWPort0,HWPort01,HWPort23]> {
1159  let Latency = 7;
1160  let NumMicroOps = 3;
1161  let ResourceCycles = [1,1,1];
1162}
1163def: InstRW<[HWWriteResGroup39], (instrs FLDCW16m)>;
1164
1165def HWWriteResGroup41 : SchedWriteRes<[HWPort6,HWPort23,HWPort0156]> {
1166  let Latency = 7;
1167  let NumMicroOps = 3;
1168  let ResourceCycles = [1,1,1];
1169}
1170def: InstRW<[HWWriteResGroup41], (instrs LRET64, RET32, RET64)>;
1171
1172def HWWriteResGroup44 : SchedWriteRes<[HWPort4,HWPort6,HWPort237,HWPort0156]> {
1173  let Latency = 3;
1174  let NumMicroOps = 4;
1175  let ResourceCycles = [1,1,1,1];
1176}
1177def: InstRW<[HWWriteResGroup44], (instregex "CALL(16|32|64)r")>;
1178
1179def HWWriteResGroup45 : SchedWriteRes<[HWPort4,HWPort237,HWPort06,HWPort0156]> {
1180  let Latency = 3;
1181  let NumMicroOps = 4;
1182  let ResourceCycles = [1,1,1,1];
1183}
1184def: InstRW<[HWWriteResGroup45], (instrs CALL64pcrel32)>;
1185
1186def HWWriteResGroup46 : SchedWriteRes<[HWPort4,HWPort23,HWPort237,HWPort06]> {
1187  let Latency = 8;
1188  let NumMicroOps = 5;
1189  let ResourceCycles = [1,1,1,2];
1190}
1191def: InstRW<[HWWriteResGroup46], (instregex "ROL(8|16|32|64)m(1|i)",
1192                                            "ROR(8|16|32|64)m(1|i)")>;
1193
1194def HWWriteResGroup46_1 : SchedWriteRes<[HWPort06]> {
1195  let Latency = 2;
1196  let NumMicroOps = 2;
1197  let ResourceCycles = [2];
1198}
1199def: InstRW<[HWWriteResGroup46_1], (instrs ROL8r1, ROL16r1, ROL32r1, ROL64r1,
1200                                           ROR8r1, ROR16r1, ROR32r1, ROR64r1)>;
1201
1202def HWWriteResGroup47 : SchedWriteRes<[HWPort4,HWPort23,HWPort237,HWPort0156]> {
1203  let Latency = 8;
1204  let NumMicroOps = 5;
1205  let ResourceCycles = [1,1,1,2];
1206}
1207def: InstRW<[HWWriteResGroup47], (instregex "XADD(8|16|32|64)rm")>;
1208
1209def HWWriteResGroup48 : SchedWriteRes<[HWPort4,HWPort6,HWPort23,HWPort237,HWPort0156]> {
1210  let Latency = 8;
1211  let NumMicroOps = 5;
1212  let ResourceCycles = [1,1,1,1,1];
1213}
1214def: InstRW<[HWWriteResGroup48], (instregex "CALL(16|32|64)m")>;
1215def: InstRW<[HWWriteResGroup48], (instrs FARCALL64m)>;
1216
1217def HWWriteResGroup50 : SchedWriteRes<[HWPort1]> {
1218  let Latency = 3;
1219  let NumMicroOps = 1;
1220  let ResourceCycles = [1];
1221}
1222def: InstRW<[HWWriteResGroup50], (instregex "P(DEP|EXT)(32|64)rr")>;
1223
1224def HWWriteResGroup51 : SchedWriteRes<[HWPort5]> {
1225  let Latency = 3;
1226  let NumMicroOps = 1;
1227  let ResourceCycles = [1];
1228}
1229def: InstRW<[HWWriteResGroup51], (instregex "VPBROADCAST(B|W)rr")>;
1230
1231def HWWriteResGroup52_1 : SchedWriteRes<[HWPort1,HWPort23]> {
1232  let Latency = 10;
1233  let NumMicroOps = 2;
1234  let ResourceCycles = [1,1];
1235}
1236def: InstRW<[HWWriteResGroup52_1], (instregex "(ADD|SUB|SUBR)_F(32|64)m",
1237                                              "ILD_F(16|32|64)m")>;
1238
1239def HWWriteResGroup53_1 : SchedWriteRes<[HWPort5,HWPort23]> {
1240  let Latency = 9;
1241  let NumMicroOps = 2;
1242  let ResourceCycles = [1,1];
1243}
1244def: InstRW<[HWWriteResGroup53_1], (instrs VPMOVSXBWYrm,
1245                                           VPMOVSXDQYrm,
1246                                           VPMOVSXWDYrm,
1247                                           VPMOVZXWDYrm)>;
1248
1249def HWWriteResGroup57 : SchedWriteRes<[HWPort5,HWPort0156]> {
1250  let Latency = 3;
1251  let NumMicroOps = 3;
1252  let ResourceCycles = [2,1];
1253}
1254def: InstRW<[HWWriteResGroup57], (instrs MMX_PACKSSDWrr,
1255                                         MMX_PACKSSWBrr,
1256                                         MMX_PACKUSWBrr)>;
1257
1258def HWWriteResGroup58 : SchedWriteRes<[HWPort6,HWPort0156]> {
1259  let Latency = 3;
1260  let NumMicroOps = 3;
1261  let ResourceCycles = [1,2];
1262}
1263def: InstRW<[HWWriteResGroup58], (instregex "CLD")>;
1264
1265def HWWriteResGroup59 : SchedWriteRes<[HWPort06,HWPort0156]> {
1266  let Latency = 2;
1267  let NumMicroOps = 3;
1268  let ResourceCycles = [1,2];
1269}
1270def: InstRW<[HWWriteResGroup59], (instrs RCL8r1, RCL16r1, RCL32r1, RCL64r1,
1271                                         RCR8r1, RCR16r1, RCR32r1, RCR64r1)>;
1272
1273def HWWriteResGroup60 : SchedWriteRes<[HWPort1,HWPort06,HWPort0156]> {
1274  let Latency = 5;
1275  let NumMicroOps = 8;
1276  let ResourceCycles = [2,4,2];
1277}
1278def: InstRW<[HWWriteResGroup60], (instrs RCR8ri, RCR16ri, RCR32ri, RCR64ri)>;
1279
1280def HWWriteResGroup60b : SchedWriteRes<[HWPort1,HWPort06,HWPort0156]> {
1281  let Latency = 6;
1282  let NumMicroOps = 8;
1283  let ResourceCycles = [2,4,2];
1284}
1285def: InstRW<[HWWriteResGroup60b], (instrs RCL8ri, RCL16ri, RCL32ri, RCL64ri)>;
1286
1287def HWWriteResGroup61 : SchedWriteRes<[HWPort0,HWPort4,HWPort237]> {
1288  let Latency = 4;
1289  let NumMicroOps = 3;
1290  let ResourceCycles = [1,1,1];
1291}
1292def: InstRW<[HWWriteResGroup61], (instrs FNSTSWm)>;
1293
1294def HWWriteResGroup62 : SchedWriteRes<[HWPort1,HWPort4,HWPort237]> {
1295  let Latency = 4;
1296  let NumMicroOps = 3;
1297  let ResourceCycles = [1,1,1];
1298}
1299def: InstRW<[HWWriteResGroup62], (instregex "IST(T?)_FP(16|32|64)m",
1300                                            "IST_F(16|32)m")>;
1301
1302def HWWriteResGroup66 : SchedWriteRes<[HWPort23,HWPort237,HWPort06,HWPort0156]> {
1303  let Latency = 9;
1304  let NumMicroOps = 5;
1305  let ResourceCycles = [1,1,1,2];
1306}
1307def: InstRW<[HWWriteResGroup66], (instregex "RCL(8|16|32|64)m(1|i)",
1308                                            "RCR(8|16|32|64)m(1|i)")>;
1309
1310def HWWriteResGroup68 : SchedWriteRes<[HWPort4,HWPort23,HWPort237,HWPort0156]> {
1311  let Latency = 9;
1312  let NumMicroOps = 6;
1313  let ResourceCycles = [1,1,1,3];
1314}
1315def: InstRW<[HWWriteResGroup68], (instregex "XCHG(8|16|32|64)rm")>;
1316
1317def HWWriteResGroup69 : SchedWriteRes<[HWPort4,HWPort23,HWPort237,HWPort06,HWPort0156]> {
1318  let Latency = 9;
1319  let NumMicroOps = 6;
1320  let ResourceCycles = [1,1,1,2,1];
1321}
1322def: InstRW<[HWWriteResGroup69], (instregex "ROL(8|16|32|64)mCL",
1323                                            "ROR(8|16|32|64)mCL",
1324                                            "SAR(8|16|32|64)mCL",
1325                                            "SHL(8|16|32|64)mCL",
1326                                            "SHR(8|16|32|64)mCL")>;
1327def: SchedAlias<WriteADCRMW, HWWriteResGroup69>;
1328
1329def HWWriteResGroup72 : SchedWriteRes<[HWPort0,HWPort0156]> {
1330  let Latency = 4;
1331  let NumMicroOps = 2;
1332  let ResourceCycles = [1,1];
1333}
1334def: InstRW<[HWWriteResGroup72], (instrs FNSTSW16r)>;
1335
1336def HWWriteResGroup73 : SchedWriteRes<[HWPort1,HWPort5]> {
1337  let Latency = 4;
1338  let NumMicroOps = 2;
1339  let ResourceCycles = [1,1];
1340}
1341def: InstRW<[HWWriteResGroup73], (instrs MMX_CVTPS2PIrr,
1342                                         MMX_CVTTPS2PIrr)>;
1343
1344def HWWriteResGroup75 : SchedWriteRes<[HWPort1,HWPort23]> {
1345  let Latency = 11;
1346  let NumMicroOps = 3;
1347  let ResourceCycles = [2,1];
1348}
1349def: InstRW<[HWWriteResGroup75], (instregex "FICOM(P?)(16|32)m")>;
1350
1351def HWWriteResGroup78_1 : SchedWriteRes<[HWPort1,HWPort5,HWPort23]> {
1352  let Latency = 9;
1353  let NumMicroOps = 3;
1354  let ResourceCycles = [1,1,1];
1355}
1356def: InstRW<[HWWriteResGroup78_1], (instrs MMX_CVTPI2PDrm)>;
1357
1358def HWWriteResGroup80 : SchedWriteRes<[HWPort5,HWPort23,HWPort015]> {
1359  let Latency = 9;
1360  let NumMicroOps = 3;
1361  let ResourceCycles = [1,1,1];
1362}
1363def: InstRW<[HWWriteResGroup80], (instregex "VPBROADCAST(B|W)(Y?)rm")>;
1364
1365def HWWriteResGroup81 : SchedWriteRes<[HWPort0156]> {
1366  let Latency = 4;
1367  let NumMicroOps = 4;
1368  let ResourceCycles = [4];
1369}
1370def: InstRW<[HWWriteResGroup81], (instrs FNCLEX)>;
1371
1372def HWWriteResGroup82 : SchedWriteRes<[]> {
1373  let Latency = 0;
1374  let NumMicroOps = 4;
1375  let ResourceCycles = [];
1376}
1377def: InstRW<[HWWriteResGroup82], (instrs VZEROUPPER)>;
1378
1379def HWWriteResGroup83 : SchedWriteRes<[HWPort1,HWPort6,HWPort0156]> {
1380  let Latency = 4;
1381  let NumMicroOps = 4;
1382  let ResourceCycles = [1,1,2];
1383}
1384def: InstRW<[HWWriteResGroup83], (instregex "LAR(16|32|64)rr")>;
1385
1386def HWWriteResGroup87 : SchedWriteRes<[HWPort1,HWPort6,HWPort23,HWPort0156]> {
1387  let Latency = 9;
1388  let NumMicroOps = 5;
1389  let ResourceCycles = [1,2,1,1];
1390}
1391def: InstRW<[HWWriteResGroup87], (instregex "LAR(16|32|64)rm",
1392                                            "LSL(16|32|64)rm")>;
1393
1394def HWWriteResGroup88 : SchedWriteRes<[HWPort4,HWPort237,HWPort0156]> {
1395  let Latency = 5;
1396  let NumMicroOps = 6;
1397  let ResourceCycles = [1,1,4];
1398}
1399def: InstRW<[HWWriteResGroup88], (instregex "PUSHF(16|64)")>;
1400
1401def HWWriteResGroup89 : SchedWriteRes<[HWPort0]> {
1402  let Latency = 5;
1403  let NumMicroOps = 1;
1404  let ResourceCycles = [1];
1405}
1406def: InstRW<[HWWriteResGroup89], (instregex "MUL_(FPrST0|FST0r|FrST0)")>;
1407
1408def HWWriteResGroup91_2 : SchedWriteRes<[HWPort0,HWPort23]> {
1409  let Latency = 11;
1410  let NumMicroOps = 2;
1411  let ResourceCycles = [1,1];
1412}
1413def: InstRW<[HWWriteResGroup91_2], (instregex "(V?)PCMPGTQrm")>;
1414
1415def HWWriteResGroup91_3 : SchedWriteRes<[HWPort0,HWPort23]> {
1416  let Latency = 12;
1417  let NumMicroOps = 2;
1418  let ResourceCycles = [1,1];
1419}
1420def: InstRW<[HWWriteResGroup91_3], (instregex "MUL_F(32|64)m")>;
1421def: InstRW<[HWWriteResGroup91_3], (instrs VPCMPGTQYrm)>;
1422
1423def HWWriteResGroup93 : SchedWriteRes<[HWPort1,HWPort5]> {
1424  let Latency = 5;
1425  let NumMicroOps = 3;
1426  let ResourceCycles = [1,2];
1427}
1428def: InstRW<[HWWriteResGroup93], (instregex "(V?)CVTSI642SSrr")>;
1429
1430def HWWriteResGroup94 : SchedWriteRes<[HWPort1,HWPort6,HWPort06]> {
1431  let Latency = 5;
1432  let NumMicroOps = 3;
1433  let ResourceCycles = [1,1,1];
1434}
1435def: InstRW<[HWWriteResGroup94], (instregex "STR(16|32|64)r")>;
1436
1437def HWWriteResGroup99 : SchedWriteRes<[HWPort6,HWPort0156]> {
1438  let Latency = 5;
1439  let NumMicroOps = 5;
1440  let ResourceCycles = [1,4];
1441}
1442def: InstRW<[HWWriteResGroup99], (instrs PAUSE)>;
1443
1444def HWWriteResGroup100 : SchedWriteRes<[HWPort06,HWPort0156]> {
1445  let Latency = 5;
1446  let NumMicroOps = 5;
1447  let ResourceCycles = [1,4];
1448}
1449def: InstRW<[HWWriteResGroup100], (instrs XSETBV)>;
1450
1451def HWWriteResGroup103 : SchedWriteRes<[HWPort1,HWPort23]> {
1452  let Latency = 13;
1453  let NumMicroOps = 3;
1454  let ResourceCycles = [2,1];
1455}
1456def: InstRW<[HWWriteResGroup103], (instregex "(ADD|SUB|SUBR)_FI(16|32)m")>;
1457
1458def HWWriteResGroup107 : SchedWriteRes<[HWPort1,HWPort6,HWPort06,HWPort0156]> {
1459  let Latency = 6;
1460  let NumMicroOps = 4;
1461  let ResourceCycles = [1,1,1,1];
1462}
1463def: InstRW<[HWWriteResGroup107], (instregex "SLDT(16|32|64)r")>;
1464
1465def HWWriteResGroup108 : SchedWriteRes<[HWPort6,HWPort0156]> {
1466  let Latency = 6;
1467  let NumMicroOps = 6;
1468  let ResourceCycles = [1,5];
1469}
1470def: InstRW<[HWWriteResGroup108], (instrs STD)>;
1471
1472def HWWriteResGroup114 : SchedWriteRes<[HWPort6,HWPort06,HWPort15,HWPort0156]> {
1473  let Latency = 7;
1474  let NumMicroOps = 7;
1475  let ResourceCycles = [2,2,1,2];
1476}
1477def: InstRW<[HWWriteResGroup114], (instrs LOOP)>;
1478
1479def HWWriteResGroup115 : SchedWriteRes<[HWPort0,HWPort1,HWPort23]> {
1480  let Latency = 15;
1481  let NumMicroOps = 3;
1482  let ResourceCycles = [1,1,1];
1483}
1484def: InstRW<[HWWriteResGroup115], (instregex "MUL_FI(16|32)m")>;
1485
1486def HWWriteResGroup120 : SchedWriteRes<[HWPort1,HWPort23,HWPort237,HWPort06,HWPort15,HWPort0156]> {
1487  let Latency = 16;
1488  let NumMicroOps = 10;
1489  let ResourceCycles = [1,1,1,4,1,2];
1490}
1491def: InstRW<[HWWriteResGroup120], (instregex "RCL(8|16|32|64)mCL")>;
1492
1493def HWWriteResGroup129 : SchedWriteRes<[HWPort1,HWPort06,HWPort0156]> {
1494  let Latency = 11;
1495  let NumMicroOps = 7;
1496  let ResourceCycles = [2,2,3];
1497}
1498def: InstRW<[HWWriteResGroup129], (instregex "RCL(16|32|64)rCL",
1499                                             "RCR(16|32|64)rCL")>;
1500
1501def HWWriteResGroup130 : SchedWriteRes<[HWPort1,HWPort06,HWPort15,HWPort0156]> {
1502  let Latency = 11;
1503  let NumMicroOps = 9;
1504  let ResourceCycles = [1,4,1,3];
1505}
1506def: InstRW<[HWWriteResGroup130], (instrs RCL8rCL)>;
1507
1508def HWWriteResGroup131 : SchedWriteRes<[HWPort06,HWPort0156]> {
1509  let Latency = 11;
1510  let NumMicroOps = 11;
1511  let ResourceCycles = [2,9];
1512}
1513def: InstRW<[HWWriteResGroup131], (instrs LOOPE, LOOPNE)>;
1514
1515def HWWriteResGroup132 : SchedWriteRes<[HWPort4,HWPort23,HWPort237,HWPort06,HWPort15,HWPort0156]> {
1516  let Latency = 17;
1517  let NumMicroOps = 14;
1518  let ResourceCycles = [1,1,1,4,2,5];
1519}
1520def: InstRW<[HWWriteResGroup132], (instrs CMPXCHG8B)>;
1521
1522def HWWriteResGroup135 : SchedWriteRes<[HWPort1,HWPort23,HWPort237,HWPort06,HWPort15,HWPort0156]> {
1523  let Latency = 19;
1524  let NumMicroOps = 11;
1525  let ResourceCycles = [2,1,1,3,1,3];
1526}
1527def: InstRW<[HWWriteResGroup135], (instregex "RCR(8|16|32|64)mCL")>;
1528
1529def HWWriteResGroup142 : SchedWriteRes<[HWPort1,HWPort06,HWPort15,HWPort0156]> {
1530  let Latency = 14;
1531  let NumMicroOps = 10;
1532  let ResourceCycles = [2,3,1,4];
1533}
1534def: InstRW<[HWWriteResGroup142], (instrs RCR8rCL)>;
1535
1536def HWWriteResGroup143 : SchedWriteRes<[HWPort23,HWPort0156]> {
1537  let Latency = 19;
1538  let NumMicroOps = 15;
1539  let ResourceCycles = [1,14];
1540}
1541def: InstRW<[HWWriteResGroup143], (instrs POPF16)>;
1542
1543def HWWriteResGroup144 : SchedWriteRes<[HWPort4,HWPort5,HWPort6,HWPort23,HWPort237,HWPort06,HWPort0156]> {
1544  let Latency = 21;
1545  let NumMicroOps = 8;
1546  let ResourceCycles = [1,1,1,1,1,1,2];
1547}
1548def: InstRW<[HWWriteResGroup144], (instrs INSB, INSL, INSW)>;
1549
1550def HWWriteResGroup145 : SchedWriteRes<[HWPort5, HWPort6]> {
1551  let Latency = 8;
1552  let NumMicroOps = 20;
1553  let ResourceCycles = [1,1];
1554}
1555def: InstRW<[HWWriteResGroup145], (instrs VZEROALL)>;
1556
1557def HWWriteResGroup146 : SchedWriteRes<[HWPort0,HWPort4,HWPort5,HWPort23,HWPort237,HWPort06,HWPort0156]> {
1558  let Latency = 22;
1559  let NumMicroOps = 19;
1560  let ResourceCycles = [2,1,4,1,1,4,6];
1561}
1562def: InstRW<[HWWriteResGroup146], (instrs CMPXCHG16B)>;
1563
1564def HWWriteResGroup147 : SchedWriteRes<[HWPort0,HWPort1,HWPort5,HWPort6,HWPort01,HWPort0156]> {
1565  let Latency = 17;
1566  let NumMicroOps = 15;
1567  let ResourceCycles = [2,1,2,4,2,4];
1568}
1569def: InstRW<[HWWriteResGroup147], (instrs XCH_F)>;
1570
1571def HWWriteResGroup149 : SchedWriteRes<[HWPort5,HWPort6,HWPort06,HWPort0156]> {
1572  let Latency = 18;
1573  let NumMicroOps = 8;
1574  let ResourceCycles = [1,1,1,5];
1575}
1576def: InstRW<[HWWriteResGroup149], (instrs CPUID, RDTSC)>;
1577
1578def HWWriteResGroup151 : SchedWriteRes<[HWPort6,HWPort23,HWPort0156]> {
1579  let Latency = 23;
1580  let NumMicroOps = 19;
1581  let ResourceCycles = [3,1,15];
1582}
1583def: InstRW<[HWWriteResGroup151], (instregex "XRSTOR(64)?")>;
1584
1585def HWWriteResGroup154 : SchedWriteRes<[HWPort0]> {
1586  let Latency = 20;
1587  let NumMicroOps = 1;
1588  let ResourceCycles = [1];
1589}
1590def: InstRW<[HWWriteResGroup154], (instregex "DIV_(FPrST0|FST0r|FrST0)")>;
1591
1592def HWWriteResGroup155 : SchedWriteRes<[HWPort0,HWPort23]> {
1593  let Latency = 27;
1594  let NumMicroOps = 2;
1595  let ResourceCycles = [1,1];
1596}
1597def: InstRW<[HWWriteResGroup155], (instregex "DIVR_F(32|64)m")>;
1598
1599def HWWriteResGroup156 : SchedWriteRes<[HWPort5,HWPort6,HWPort0156]> {
1600  let Latency = 20;
1601  let NumMicroOps = 10;
1602  let ResourceCycles = [1,2,7];
1603}
1604def: InstRW<[HWWriteResGroup156], (instrs MWAITrr)>;
1605
1606def HWWriteResGroup161 : SchedWriteRes<[HWPort0,HWPort1,HWPort23]> {
1607  let Latency = 30;
1608  let NumMicroOps = 3;
1609  let ResourceCycles = [1,1,1];
1610}
1611def: InstRW<[HWWriteResGroup161], (instregex "DIVR_FI(16|32)m")>;
1612
1613def HWWriteResGroup162 : SchedWriteRes<[HWPort0]> {
1614  let Latency = 24;
1615  let NumMicroOps = 1;
1616  let ResourceCycles = [1];
1617}
1618def: InstRW<[HWWriteResGroup162], (instregex "DIVR_(FPrST0|FST0r|FrST0)")>;
1619
1620def HWWriteResGroup163 : SchedWriteRes<[HWPort0,HWPort23]> {
1621  let Latency = 31;
1622  let NumMicroOps = 2;
1623  let ResourceCycles = [1,1];
1624}
1625def: InstRW<[HWWriteResGroup163], (instregex "DIV_F(32|64)m")>;
1626
1627def HWWriteResGroup164 : SchedWriteRes<[HWPort4,HWPort6,HWPort23,HWPort237,HWPort0156]> {
1628  let Latency = 30;
1629  let NumMicroOps = 27;
1630  let ResourceCycles = [1,5,1,1,19];
1631}
1632def: InstRW<[HWWriteResGroup164], (instrs XSAVE64)>;
1633
1634def HWWriteResGroup165 : SchedWriteRes<[HWPort4,HWPort6,HWPort23,HWPort237,HWPort0156]> {
1635  let Latency = 31;
1636  let NumMicroOps = 28;
1637  let ResourceCycles = [1,6,1,1,19];
1638}
1639def: InstRW<[HWWriteResGroup165], (instrs XSAVE)>;
1640def: InstRW<[HWWriteResGroup165], (instregex "XSAVEC", "XSAVES", "XSAVEOPT")>;
1641
1642def HWWriteResGroup166 : SchedWriteRes<[HWPort0,HWPort1,HWPort23]> {
1643  let Latency = 34;
1644  let NumMicroOps = 3;
1645  let ResourceCycles = [1,1,1];
1646}
1647def: InstRW<[HWWriteResGroup166], (instregex "DIV_FI(16|32)m")>;
1648
1649def HWWriteResGroup170 : SchedWriteRes<[HWPort5,HWPort6,HWPort23,HWPort06,HWPort0156]> {
1650  let Latency = 35;
1651  let NumMicroOps = 23;
1652  let ResourceCycles = [1,5,3,4,10];
1653}
1654def: InstRW<[HWWriteResGroup170], (instregex "IN(8|16|32)ri",
1655                                             "IN(8|16|32)rr")>;
1656
1657def HWWriteResGroup171 : SchedWriteRes<[HWPort5,HWPort6,HWPort23,HWPort237,HWPort06,HWPort0156]> {
1658  let Latency = 36;
1659  let NumMicroOps = 23;
1660  let ResourceCycles = [1,5,2,1,4,10];
1661}
1662def: InstRW<[HWWriteResGroup171], (instregex "OUT(8|16|32)ir",
1663                                             "OUT(8|16|32)rr")>;
1664
1665def HWWriteResGroup175 : SchedWriteRes<[HWPort1,HWPort4,HWPort5,HWPort6,HWPort23,HWPort237,HWPort15,HWPort0156]> {
1666  let Latency = 41;
1667  let NumMicroOps = 18;
1668  let ResourceCycles = [1,1,2,3,1,1,1,8];
1669}
1670def: InstRW<[HWWriteResGroup175], (instrs VMCLEARm)>;
1671
1672def HWWriteResGroup176 : SchedWriteRes<[HWPort5,HWPort0156]> {
1673  let Latency = 42;
1674  let NumMicroOps = 22;
1675  let ResourceCycles = [2,20];
1676}
1677def: InstRW<[HWWriteResGroup176], (instrs RDTSCP)>;
1678
1679def HWWriteResGroup177 : SchedWriteRes<[HWPort0,HWPort01,HWPort23,HWPort05,HWPort06,HWPort015,HWPort0156]> {
1680  let Latency = 61;
1681  let NumMicroOps = 64;
1682  let ResourceCycles = [2,2,8,1,10,2,39];
1683}
1684def: InstRW<[HWWriteResGroup177], (instrs FLDENVm)>;
1685
1686def HWWriteResGroup178 : SchedWriteRes<[HWPort0,HWPort6,HWPort23,HWPort05,HWPort06,HWPort15,HWPort0156]> {
1687  let Latency = 64;
1688  let NumMicroOps = 88;
1689  let ResourceCycles = [4,4,31,1,2,1,45];
1690}
1691def: InstRW<[HWWriteResGroup178], (instrs FXRSTOR64)>;
1692
1693def HWWriteResGroup179 : SchedWriteRes<[HWPort0,HWPort6,HWPort23,HWPort05,HWPort06,HWPort15,HWPort0156]> {
1694  let Latency = 64;
1695  let NumMicroOps = 90;
1696  let ResourceCycles = [4,2,33,1,2,1,47];
1697}
1698def: InstRW<[HWWriteResGroup179], (instrs FXRSTOR)>;
1699
1700def HWWriteResGroup180 : SchedWriteRes<[HWPort5,HWPort01,HWPort0156]> {
1701  let Latency = 75;
1702  let NumMicroOps = 15;
1703  let ResourceCycles = [6,3,6];
1704}
1705def: InstRW<[HWWriteResGroup180], (instrs FNINIT)>;
1706
1707def HWWriteResGroup183 : SchedWriteRes<[HWPort0,HWPort1,HWPort4,HWPort5,HWPort6,HWPort237,HWPort06,HWPort0156]> {
1708  let Latency = 115;
1709  let NumMicroOps = 100;
1710  let ResourceCycles = [9,9,11,8,1,11,21,30];
1711}
1712def: InstRW<[HWWriteResGroup183], (instrs FSTENVm)>;
1713
1714def HWWriteResGroup184 : SchedWriteRes<[HWPort0,HWPort5,HWPort06,HWPort15,HWPort015,HWPort23]> {
1715  let Latency = 14;
1716  let NumMicroOps = 12;
1717  let ResourceCycles = [2,2,2,1,3,2];
1718}
1719def: InstRW<[HWWriteResGroup184], (instrs VGATHERDPDrm, VPGATHERDQrm)>;
1720
1721def HWWriteResGroup185 : SchedWriteRes<[HWPort0,HWPort5,HWPort06,HWPort15,HWPort015,HWPort23]> {
1722  let Latency = 17;
1723  let NumMicroOps = 20;
1724  let ResourceCycles = [3,3,4,1,5,4];
1725}
1726def: InstRW<[HWWriteResGroup185], (instrs VGATHERDPDYrm, VPGATHERDQYrm)>;
1727
1728def HWWriteResGroup186 : SchedWriteRes<[HWPort0,HWPort5,HWPort06,HWPort15,HWPort015,HWPort23]> {
1729  let Latency = 16;
1730  let NumMicroOps = 20;
1731  let ResourceCycles = [3,3,4,1,5,4];
1732}
1733def: InstRW<[HWWriteResGroup186], (instrs VGATHERDPSrm, VPGATHERDDrm)>;
1734
1735def HWWriteResGroup187 : SchedWriteRes<[HWPort0,HWPort5,HWPort06,HWPort15,HWPort015,HWPort23]> {
1736  let Latency = 22;
1737  let NumMicroOps = 34;
1738  let ResourceCycles = [5,3,8,1,9,8];
1739}
1740def: InstRW<[HWWriteResGroup187], (instrs VGATHERDPSYrm, VPGATHERDDYrm)>;
1741
1742def HWWriteResGroup188 : SchedWriteRes<[HWPort0,HWPort5,HWPort06,HWPort15,HWPort015,HWPort23]> {
1743  let Latency = 15;
1744  let NumMicroOps = 14;
1745  let ResourceCycles = [3,3,2,1,3,2];
1746}
1747def: InstRW<[HWWriteResGroup188], (instrs VGATHERQPDrm, VPGATHERQQrm)>;
1748
1749def HWWriteResGroup189 : SchedWriteRes<[HWPort0,HWPort5,HWPort06,HWPort15,HWPort015,HWPort23]> {
1750  let Latency = 17;
1751  let NumMicroOps = 22;
1752  let ResourceCycles = [5,3,4,1,5,4];
1753}
1754def: InstRW<[HWWriteResGroup189], (instrs VGATHERQPDYrm, VPGATHERQQYrm,
1755                                          VGATHERQPSYrm, VPGATHERQDYrm)>;
1756
1757def HWWriteResGroup190 : SchedWriteRes<[HWPort0,HWPort5,HWPort06,HWPort15,HWPort015,HWPort23]> {
1758  let Latency = 16;
1759  let NumMicroOps = 15;
1760  let ResourceCycles = [3,3,2,1,4,2];
1761}
1762def: InstRW<[HWWriteResGroup190], (instrs VGATHERQPSrm, VPGATHERQDrm)>;
1763
1764def: InstRW<[WriteZero], (instrs CLC)>;
1765
1766
1767// Instruction variants handled by the renamer. These might not need execution
1768// ports in certain conditions.
1769// See Agner's Fog "The microarchitecture of Intel, AMD and VIA CPUs",
1770// section "Haswell and Broadwell Pipeline" > "Register allocation and
1771// renaming".
1772// These can be investigated with llvm-exegesis, e.g.
1773// echo 'pxor %mm0, %mm0' | /tmp/llvm-exegesis -mode=uops -snippets-file=-
1774// echo 'vxorpd %xmm0, %xmm0, %xmm1' | /tmp/llvm-exegesis -mode=uops -snippets-file=-
1775
1776def HWWriteZeroLatency : SchedWriteRes<[]> {
1777  let Latency = 0;
1778}
1779
1780def HWWriteZeroIdiom : SchedWriteVariant<[
1781    SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [HWWriteZeroLatency]>,
1782    SchedVar<NoSchedPred,                          [WriteALU]>
1783]>;
1784def : InstRW<[HWWriteZeroIdiom], (instrs SUB32rr, SUB64rr,
1785                                         XOR32rr, XOR64rr)>;
1786
1787def HWWriteFZeroIdiom : SchedWriteVariant<[
1788    SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [HWWriteZeroLatency]>,
1789    SchedVar<NoSchedPred,                          [WriteFLogic]>
1790]>;
1791def : InstRW<[HWWriteFZeroIdiom], (instrs XORPSrr, VXORPSrr, XORPDrr,
1792                                          VXORPDrr)>;
1793
1794def HWWriteFZeroIdiomY : SchedWriteVariant<[
1795    SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [HWWriteZeroLatency]>,
1796    SchedVar<NoSchedPred,                          [WriteFLogicY]>
1797]>;
1798def : InstRW<[HWWriteFZeroIdiomY], (instrs VXORPSYrr, VXORPDYrr)>;
1799
1800def HWWriteVZeroIdiomLogicX : SchedWriteVariant<[
1801    SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [HWWriteZeroLatency]>,
1802    SchedVar<NoSchedPred,                          [WriteVecLogicX]>
1803]>;
1804def : InstRW<[HWWriteVZeroIdiomLogicX], (instrs PXORrr, VPXORrr)>;
1805
1806def HWWriteVZeroIdiomLogicY : SchedWriteVariant<[
1807    SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [HWWriteZeroLatency]>,
1808    SchedVar<NoSchedPred,                          [WriteVecLogicY]>
1809]>;
1810def : InstRW<[HWWriteVZeroIdiomLogicY], (instrs VPXORYrr)>;
1811
1812def HWWriteVZeroIdiomALUX : SchedWriteVariant<[
1813    SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [HWWriteZeroLatency]>,
1814    SchedVar<NoSchedPred,                          [WriteVecALUX]>
1815]>;
1816def : InstRW<[HWWriteVZeroIdiomALUX], (instrs PSUBBrr, VPSUBBrr,
1817                                              PSUBDrr, VPSUBDrr,
1818                                              PSUBQrr, VPSUBQrr,
1819                                              PSUBWrr, VPSUBWrr,
1820                                              PCMPGTBrr, VPCMPGTBrr,
1821                                              PCMPGTDrr, VPCMPGTDrr,
1822                                              PCMPGTWrr, VPCMPGTWrr)>;
1823
1824def HWWriteVZeroIdiomALUY : SchedWriteVariant<[
1825    SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [HWWriteZeroLatency]>,
1826    SchedVar<NoSchedPred,                          [WriteVecALUY]>
1827]>;
1828def : InstRW<[HWWriteVZeroIdiomALUY], (instrs VPSUBBYrr,
1829                                              VPSUBDYrr,
1830                                              VPSUBQYrr,
1831                                              VPSUBWYrr,
1832                                              VPCMPGTBYrr,
1833                                              VPCMPGTDYrr,
1834                                              VPCMPGTWYrr)>;
1835
1836def HWWritePCMPGTQ : SchedWriteRes<[HWPort0]> {
1837  let Latency = 5;
1838  let NumMicroOps = 1;
1839  let ResourceCycles = [1];
1840}
1841
1842def HWWriteVZeroIdiomPCMPGTQ : SchedWriteVariant<[
1843    SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [HWWriteZeroLatency]>,
1844    SchedVar<NoSchedPred,                          [HWWritePCMPGTQ]>
1845]>;
1846def : InstRW<[HWWriteVZeroIdiomPCMPGTQ], (instrs PCMPGTQrr, VPCMPGTQrr,
1847                                                 VPCMPGTQYrr)>;
1848
1849
1850// The 0x83 ADC/SBB opcodes have special support for immediate 0 to only require
1851// a single uop. It does not apply to the GR8 encoding. And only applies to the
1852// 8-bit immediate since using larger immediate for 0 would be silly.
1853// Unfortunately, this optimization does not apply to the AX/EAX/RAX short
1854// encodings we convert to in MCInstLowering so we exclude AX/EAX/RAX here since
1855// we schedule before that point.
1856// TODO: Should we disable using the short encodings on these CPUs?
1857def HWFastADC0 : MCSchedPredicate<
1858  CheckAll<[
1859    CheckImmOperand<2, 0>,              // Second MCOperand is Imm and has value 0.
1860    CheckNot<CheckRegOperand<1, AX>>,   // First MCOperand is not register AX
1861    CheckNot<CheckRegOperand<1, EAX>>,  // First MCOperand is not register EAX
1862    CheckNot<CheckRegOperand<1, RAX>>   // First MCOperand is not register RAX
1863  ]>
1864>;
1865
1866def HWWriteADC0 : SchedWriteRes<[HWPort06]> {
1867  let Latency = 1;
1868  let NumMicroOps = 1;
1869  let ResourceCycles = [1];
1870}
1871
1872def HWWriteADC : SchedWriteVariant<[
1873  SchedVar<HWFastADC0, [HWWriteADC0]>,
1874  SchedVar<NoSchedPred, [WriteADC]>
1875]>;
1876
1877def : InstRW<[HWWriteADC], (instrs ADC16ri8, ADC32ri8, ADC64ri8,
1878                                      SBB16ri8, SBB32ri8, SBB64ri8)>;
1879
1880// CMOVs that use both Z and C flag require an extra uop.
1881def HWWriteCMOVA_CMOVBErr : SchedWriteRes<[HWPort06,HWPort0156]> {
1882  let Latency = 3;
1883  let ResourceCycles = [1,2];
1884  let NumMicroOps = 3;
1885}
1886
1887def HWWriteCMOVA_CMOVBErm : SchedWriteRes<[HWPort23,HWPort06,HWPort0156]> {
1888  let Latency = 8;
1889  let ResourceCycles = [1,1,2];
1890  let NumMicroOps = 4;
1891}
1892
1893def HWCMOVA_CMOVBErr :  SchedWriteVariant<[
1894  SchedVar<MCSchedPredicate<IsCMOVArr_Or_CMOVBErr>, [HWWriteCMOVA_CMOVBErr]>,
1895  SchedVar<NoSchedPred,                             [WriteCMOV]>
1896]>;
1897
1898def HWCMOVA_CMOVBErm :  SchedWriteVariant<[
1899  SchedVar<MCSchedPredicate<IsCMOVArm_Or_CMOVBErm>, [HWWriteCMOVA_CMOVBErm]>,
1900  SchedVar<NoSchedPred,                             [WriteCMOV.Folded]>
1901]>;
1902
1903def : InstRW<[HWCMOVA_CMOVBErr], (instrs CMOV16rr, CMOV32rr, CMOV64rr)>;
1904def : InstRW<[HWCMOVA_CMOVBErm], (instrs CMOV16rm, CMOV32rm, CMOV64rm)>;
1905
1906// SETCCs that use both Z and C flag require an extra uop.
1907def HWWriteSETA_SETBEr : SchedWriteRes<[HWPort06,HWPort0156]> {
1908  let Latency = 2;
1909  let ResourceCycles = [1,1];
1910  let NumMicroOps = 2;
1911}
1912
1913def HWWriteSETA_SETBEm : SchedWriteRes<[HWPort4,HWPort237,HWPort06,HWPort0156]> {
1914  let Latency = 3;
1915  let ResourceCycles = [1,1,1,1];
1916  let NumMicroOps = 4;
1917}
1918
1919def HWSETA_SETBErr :  SchedWriteVariant<[
1920  SchedVar<MCSchedPredicate<IsSETAr_Or_SETBEr>, [HWWriteSETA_SETBEr]>,
1921  SchedVar<NoSchedPred,                         [WriteSETCC]>
1922]>;
1923
1924def HWSETA_SETBErm :  SchedWriteVariant<[
1925  SchedVar<MCSchedPredicate<IsSETAm_Or_SETBEm>, [HWWriteSETA_SETBEm]>,
1926  SchedVar<NoSchedPred,                         [WriteSETCCStore]>
1927]>;
1928
1929def : InstRW<[HWSETA_SETBErr], (instrs SETCCr)>;
1930def : InstRW<[HWSETA_SETBErm], (instrs SETCCm)>;
1931
1932///////////////////////////////////////////////////////////////////////////////
1933// Dependency breaking instructions.
1934///////////////////////////////////////////////////////////////////////////////
1935
1936def : IsZeroIdiomFunction<[
1937  // GPR Zero-idioms.
1938  DepBreakingClass<[ SUB32rr, SUB64rr, XOR32rr, XOR64rr ], ZeroIdiomPredicate>,
1939
1940  // SSE Zero-idioms.
1941  DepBreakingClass<[
1942    // fp variants.
1943    XORPSrr, XORPDrr,
1944
1945    // int variants.
1946    PXORrr,
1947    PSUBBrr, PSUBWrr, PSUBDrr, PSUBQrr,
1948    PCMPGTBrr, PCMPGTDrr, PCMPGTQrr, PCMPGTWrr
1949  ], ZeroIdiomPredicate>,
1950
1951  // AVX Zero-idioms.
1952  DepBreakingClass<[
1953    // xmm fp variants.
1954    VXORPSrr, VXORPDrr,
1955
1956    // xmm int variants.
1957    VPXORrr,
1958    VPSUBBrr, VPSUBWrr, VPSUBDrr, VPSUBQrr,
1959    VPCMPGTBrr, VPCMPGTWrr, VPCMPGTDrr, VPCMPGTQrr,
1960
1961    // ymm variants.
1962    VXORPSYrr, VXORPDYrr, VPXORYrr,
1963    VPSUBBYrr, VPSUBWYrr, VPSUBDYrr, VPSUBQYrr,
1964    VPCMPGTBYrr, VPCMPGTWYrr, VPCMPGTDYrr
1965  ], ZeroIdiomPredicate>,
1966]>;
1967
1968} // SchedModel
1969