xref: /freebsd/contrib/llvm-project/llvm/lib/Target/X86/X86SchedSandyBridge.td (revision ae41709ab46305df80f7f35bb478a3c8ebf22ebb)
1//=- X86SchedSandyBridge.td - X86 Sandy Bridge 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 Sandy Bridge to support instruction
10// scheduling and other instruction cost heuristics.
11//
12// Note that we define some instructions here that are not supported by SNB,
13// but we still have to define them because SNB is the default subtarget for
14// X86. These instructions are tagged with a comment `Unsupported = 1`.
15//
16//===----------------------------------------------------------------------===//
17
18def SandyBridgeModel : SchedMachineModel {
19  // All x86 instructions are modeled as a single micro-op, and SB can decode 4
20  // instructions per cycle.
21  // FIXME: Identify instructions that aren't a single fused micro-op.
22  let IssueWidth = 4;
23  let MicroOpBufferSize = 168; // Based on the reorder buffer.
24  let LoadLatency = 5;
25  let MispredictPenalty = 16;
26
27  // Based on the LSD (loop-stream detector) queue size.
28  let LoopMicroOpBufferSize = 28;
29
30  // This flag is set to allow the scheduler to assign
31  // a default model to unrecognized opcodes.
32  let CompleteModel = 0;
33}
34
35let SchedModel = SandyBridgeModel in {
36
37// Sandy Bridge can issue micro-ops to 6 different ports in one cycle.
38
39// Ports 0, 1, and 5 handle all computation.
40def SBPort0 : ProcResource<1>;
41def SBPort1 : ProcResource<1>;
42def SBPort5 : ProcResource<1>;
43
44// Ports 2 and 3 are identical. They handle loads and the address half of
45// stores.
46def SBPort23 : ProcResource<2>;
47
48// Port 4 gets the data half of stores. Store data can be available later than
49// the store address, but since we don't model the latency of stores, we can
50// ignore that.
51def SBPort4 : ProcResource<1>;
52
53// Many micro-ops are capable of issuing on multiple ports.
54def SBPort01  : ProcResGroup<[SBPort0, SBPort1]>;
55def SBPort05  : ProcResGroup<[SBPort0, SBPort5]>;
56def SBPort15  : ProcResGroup<[SBPort1, SBPort5]>;
57def SBPort015 : ProcResGroup<[SBPort0, SBPort1, SBPort5]>;
58
59// 54 Entry Unified Scheduler
60def SBPortAny : ProcResGroup<[SBPort0, SBPort1, SBPort23, SBPort4, SBPort5]> {
61  let BufferSize=54;
62}
63
64// Integer division issued on port 0.
65def SBDivider : ProcResource<1>;
66// FP division and sqrt on port 0.
67def SBFPDivider : ProcResource<1>;
68
69// Integer loads are 5 cycles, so ReadAfterLd registers needn't be available until 5
70// cycles after the memory operand.
71def : ReadAdvance<ReadAfterLd, 5>;
72
73// Vector loads are 5/6/7 cycles, so ReadAfterVec*Ld registers needn't be available
74// until 5/6/7 cycles after the memory operand.
75def : ReadAdvance<ReadAfterVecLd, 5>;
76def : ReadAdvance<ReadAfterVecXLd, 6>;
77def : ReadAdvance<ReadAfterVecYLd, 7>;
78
79def : ReadAdvance<ReadInt2Fpu, 0>;
80
81// Many SchedWrites are defined in pairs with and without a folded load.
82// Instructions with folded loads are usually micro-fused, so they only appear
83// as two micro-ops when queued in the reservation station.
84// This multiclass defines the resource usage for variants with and without
85// folded loads.
86multiclass SBWriteResPair<X86FoldableSchedWrite SchedRW,
87                          list<ProcResourceKind> ExePorts,
88                          int Lat, list<int> Res = [1], int UOps = 1,
89                          int LoadLat = 5> {
90  // Register variant is using a single cycle on ExePort.
91  def : WriteRes<SchedRW, ExePorts> {
92    let Latency = Lat;
93    let ResourceCycles = Res;
94    let NumMicroOps = UOps;
95  }
96
97  // Memory variant also uses a cycle on port 2/3 and adds LoadLat cycles to
98  // the latency (default = 5).
99  def : WriteRes<SchedRW.Folded, !listconcat([SBPort23], ExePorts)> {
100    let Latency = !add(Lat, LoadLat);
101    let ResourceCycles = !listconcat([1], Res);
102    let NumMicroOps = !add(UOps, 1);
103  }
104}
105
106// A folded store needs a cycle on port 4 for the store data, and an extra port
107// 2/3 cycle to recompute the address.
108def : WriteRes<WriteRMW, [SBPort23,SBPort4]>;
109
110def : WriteRes<WriteStore,   [SBPort23, SBPort4]>;
111def : WriteRes<WriteStoreNT, [SBPort23, SBPort4]>;
112def : WriteRes<WriteLoad,    [SBPort23]> { let Latency = 5; }
113def : WriteRes<WriteMove,    [SBPort015]>;
114def : WriteRes<WriteZero,    []>;
115
116// Arithmetic.
117defm : SBWriteResPair<WriteALU,    [SBPort015], 1>;
118defm : SBWriteResPair<WriteADC,    [SBPort05,SBPort015], 2, [1,1], 2>;
119
120defm : SBWriteResPair<WriteIMul8,     [SBPort1],   3>;
121defm : SBWriteResPair<WriteIMul16,    [SBPort1,SBPort05,SBPort015], 4, [1,1,2], 4>;
122defm : X86WriteRes<WriteIMul16Imm,    [SBPort1,SBPort015], 4, [1,1], 2>;
123defm : X86WriteRes<WriteIMul16ImmLd,  [SBPort1,SBPort015,SBPort23], 8, [1,1,1], 3>;
124defm : SBWriteResPair<WriteIMul16Reg, [SBPort1],   3>;
125defm : SBWriteResPair<WriteIMul32,    [SBPort1,SBPort05,SBPort015], 4, [1,1,1], 3>;
126defm : SBWriteResPair<WriteIMul32Imm, [SBPort1],   3>;
127defm : SBWriteResPair<WriteIMul32Reg, [SBPort1],   3>;
128defm : SBWriteResPair<WriteIMul64,    [SBPort1,SBPort0], 4, [1,1], 2>;
129defm : SBWriteResPair<WriteIMul64Imm, [SBPort1],   3>;
130defm : SBWriteResPair<WriteIMul64Reg, [SBPort1],   3>;
131def  : WriteRes<WriteIMulH, []> { let Latency = 3; }
132
133defm : X86WriteRes<WriteXCHG,      [SBPort015], 2, [3], 3>;
134defm : X86WriteRes<WriteBSWAP32,   [SBPort1], 1, [1], 1>;
135defm : X86WriteRes<WriteBSWAP64,   [SBPort1, SBPort05], 2, [1,1], 2>;
136defm : X86WriteRes<WriteCMPXCHG,   [SBPort05, SBPort015], 5, [1,3], 4>;
137defm : X86WriteRes<WriteCMPXCHGRMW,[SBPort015, SBPort5, SBPort23, SBPort4], 8, [1, 2, 2, 1], 6>;
138
139defm : SBWriteResPair<WriteDiv8,   [SBPort0, SBDivider], 25, [1, 10]>;
140defm : SBWriteResPair<WriteDiv16,  [SBPort0, SBDivider], 25, [1, 10]>;
141defm : SBWriteResPair<WriteDiv32,  [SBPort0, SBDivider], 25, [1, 10]>;
142defm : SBWriteResPair<WriteDiv64,  [SBPort0, SBDivider], 25, [1, 10]>;
143defm : SBWriteResPair<WriteIDiv8,  [SBPort0, SBDivider], 25, [1, 10]>;
144defm : SBWriteResPair<WriteIDiv16, [SBPort0, SBDivider], 25, [1, 10]>;
145defm : SBWriteResPair<WriteIDiv32, [SBPort0, SBDivider], 25, [1, 10]>;
146defm : SBWriteResPair<WriteIDiv64, [SBPort0, SBDivider], 25, [1, 10]>;
147
148// SHLD/SHRD.
149defm : X86WriteRes<WriteSHDrri, [SBPort05, SBPort015], 2, [1, 1], 2>;
150defm : X86WriteRes<WriteSHDrrcl,[SBPort05, SBPort015], 4, [3, 1], 4>;
151defm : X86WriteRes<WriteSHDmri, [SBPort4,SBPort23,SBPort05,SBPort015], 8, [1, 2, 1, 1], 5>;
152defm : X86WriteRes<WriteSHDmrcl,[SBPort4,SBPort23,SBPort05,SBPort015], 10, [1, 2, 3, 1], 7>;
153
154defm : SBWriteResPair<WriteShift,    [SBPort05],  1>;
155defm : SBWriteResPair<WriteShiftCL,  [SBPort05],  3, [3], 3>;
156defm : SBWriteResPair<WriteRotate,   [SBPort05],  2, [2], 2>;
157defm : SBWriteResPair<WriteRotateCL, [SBPort05],  3, [3], 3>;
158
159defm : SBWriteResPair<WriteJump,  [SBPort5],   1>;
160defm : SBWriteResPair<WriteCRC32, [SBPort1],   3, [1], 1, 5>;
161
162defm : SBWriteResPair<WriteCMOV,  [SBPort05,SBPort015], 2, [1,1], 2>; // Conditional move.
163defm : X86WriteRes<WriteFCMOV, [SBPort5,SBPort05], 3, [2,1], 3>; // x87 conditional move.
164def  : WriteRes<WriteSETCC, [SBPort05]>; // Setcc.
165def  : WriteRes<WriteSETCCStore, [SBPort05,SBPort4,SBPort23]> {
166  let Latency = 2;
167  let NumMicroOps = 3;
168}
169
170defm : X86WriteRes<WriteLAHFSAHF,        [SBPort05], 1, [1], 1>;
171defm : X86WriteRes<WriteBitTest,         [SBPort05], 1, [1], 1>;
172defm : X86WriteRes<WriteBitTestImmLd,    [SBPort05,SBPort23], 6, [1,1], 2>;
173//defm : X86WriteRes<WriteBitTestRegLd,    [SBPort05,SBPort23], 6, [1,1], 2>;
174defm : X86WriteRes<WriteBitTestSet,      [SBPort05], 1, [1], 1>;
175defm : X86WriteRes<WriteBitTestSetImmLd, [SBPort05,SBPort23], 6, [1,1], 3>;
176defm : X86WriteRes<WriteBitTestSetRegLd, [SBPort05,SBPort23,SBPort5,SBPort015], 8, [1,1,1,1], 5>;
177
178// This is for simple LEAs with one or two input operands.
179// The complex ones can only execute on port 1, and they require two cycles on
180// the port to read all inputs. We don't model that.
181def : WriteRes<WriteLEA, [SBPort01]>;
182
183// Bit counts.
184defm : SBWriteResPair<WriteBSF, [SBPort1], 3, [1], 1, 5>;
185defm : SBWriteResPair<WriteBSR, [SBPort1], 3, [1], 1, 5>;
186defm : SBWriteResPair<WriteLZCNT,          [SBPort1], 3, [1], 1, 5>;
187defm : SBWriteResPair<WriteTZCNT,          [SBPort1], 3, [1], 1, 5>;
188defm : SBWriteResPair<WritePOPCNT,         [SBPort1], 3, [1], 1, 6>;
189
190// BMI1 BEXTR/BLS, BMI2 BZHI
191// NOTE: These don't exist on Sandy Bridge. Ports are guesses.
192defm : SBWriteResPair<WriteBEXTR, [SBPort05,SBPort1], 2, [1,1], 2>;
193defm : SBWriteResPair<WriteBLS,   [SBPort015], 1>;
194defm : SBWriteResPair<WriteBZHI,  [SBPort1], 1>;
195
196// Scalar and vector floating point.
197defm : X86WriteRes<WriteFLD0,          [SBPort5], 1, [1], 1>;
198defm : X86WriteRes<WriteFLD1,          [SBPort0,SBPort5], 1, [1,1], 2>;
199defm : X86WriteRes<WriteFLDC,          [SBPort0,SBPort1], 1, [1,1], 2>;
200defm : X86WriteRes<WriteFLoad,         [SBPort23], 5, [1], 1>;
201defm : X86WriteRes<WriteFLoadX,        [SBPort23], 6, [1], 1>;
202defm : X86WriteRes<WriteFLoadY,        [SBPort23], 7, [1], 1>;
203defm : X86WriteRes<WriteFMaskedLoad,   [SBPort23,SBPort05], 8, [1,2], 3>;
204defm : X86WriteRes<WriteFMaskedLoadY,  [SBPort23,SBPort05], 9, [1,2], 3>;
205defm : X86WriteRes<WriteFStore,        [SBPort23,SBPort4], 1, [1,1], 1>;
206defm : X86WriteRes<WriteFStoreX,       [SBPort23,SBPort4], 1, [1,1], 1>;
207defm : X86WriteRes<WriteFStoreY,       [SBPort23,SBPort4], 1, [1,1], 1>;
208defm : X86WriteRes<WriteFStoreNT,      [SBPort23,SBPort4], 1, [1,1], 1>;
209defm : X86WriteRes<WriteFStoreNTX,     [SBPort23,SBPort4], 1, [1,1], 1>;
210defm : X86WriteRes<WriteFStoreNTY,     [SBPort23,SBPort4], 1, [1,1], 1>;
211
212defm : X86WriteRes<WriteFMaskedStore32,  [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
213defm : X86WriteRes<WriteFMaskedStore32Y, [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
214defm : X86WriteRes<WriteFMaskedStore64,  [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
215defm : X86WriteRes<WriteFMaskedStore64Y, [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
216
217defm : X86WriteRes<WriteFMove,         [SBPort5], 1, [1], 1>;
218defm : X86WriteRes<WriteFMoveX,        [SBPort5], 1, [1], 1>;
219defm : X86WriteRes<WriteFMoveY,        [SBPort5], 1, [1], 1>;
220defm : X86WriteRes<WriteEMMS,          [SBPort015], 31, [31], 31>;
221
222defm : SBWriteResPair<WriteFAdd,    [SBPort1],  3, [1], 1, 6>;
223defm : SBWriteResPair<WriteFAddX,   [SBPort1],  3, [1], 1, 6>;
224defm : SBWriteResPair<WriteFAddY,   [SBPort1],  3, [1], 1, 7>;
225defm : SBWriteResPair<WriteFAddZ,   [SBPort1],  3, [1], 1, 7>; // Unsupported = 1
226defm : SBWriteResPair<WriteFAdd64,  [SBPort1],  3, [1], 1, 6>;
227defm : SBWriteResPair<WriteFAdd64X, [SBPort1],  3, [1], 1, 6>;
228defm : SBWriteResPair<WriteFAdd64Y, [SBPort1],  3, [1], 1, 7>;
229defm : SBWriteResPair<WriteFAdd64Z, [SBPort1],  3, [1], 1, 7>; // Unsupported = 1
230
231defm : SBWriteResPair<WriteFCmp,    [SBPort1],  3, [1], 1, 6>;
232defm : SBWriteResPair<WriteFCmpX,   [SBPort1],  3, [1], 1, 6>;
233defm : SBWriteResPair<WriteFCmpY,   [SBPort1],  3, [1], 1, 7>;
234defm : SBWriteResPair<WriteFCmpZ,   [SBPort1],  3, [1], 1, 7>; // Unsupported = 1
235defm : SBWriteResPair<WriteFCmp64,  [SBPort1],  3, [1], 1, 6>;
236defm : SBWriteResPair<WriteFCmp64X, [SBPort1],  3, [1], 1, 6>;
237defm : SBWriteResPair<WriteFCmp64Y, [SBPort1],  3, [1], 1, 7>;
238defm : SBWriteResPair<WriteFCmp64Z, [SBPort1],  3, [1], 1, 7>; // Unsupported = 1
239
240defm : SBWriteResPair<WriteFCom,    [SBPort1],  3>;
241defm : SBWriteResPair<WriteFComX,   [SBPort1],  3>;
242
243defm : SBWriteResPair<WriteFMul,    [SBPort0],  5, [1], 1, 6>;
244defm : SBWriteResPair<WriteFMulX,   [SBPort0],  5, [1], 1, 6>;
245defm : SBWriteResPair<WriteFMulY,   [SBPort0],  5, [1], 1, 7>;
246defm : SBWriteResPair<WriteFMulZ,   [SBPort0],  5, [1], 1, 7>; // Unsupported = 1
247defm : SBWriteResPair<WriteFMul64,  [SBPort0],  5, [1], 1, 6>;
248defm : SBWriteResPair<WriteFMul64X, [SBPort0],  5, [1], 1, 6>;
249defm : SBWriteResPair<WriteFMul64Y, [SBPort0],  5, [1], 1, 7>;
250defm : SBWriteResPair<WriteFMul64Z, [SBPort0],  5, [1], 1, 7>; // Unsupported = 1
251
252defm : SBWriteResPair<WriteFDiv,    [SBPort0,SBFPDivider], 14, [1,14], 1, 6>;
253defm : SBWriteResPair<WriteFDivX,   [SBPort0,SBFPDivider], 14, [1,14], 1, 6>;
254defm : SBWriteResPair<WriteFDivY,   [SBPort0,SBPort05,SBFPDivider], 29, [2,1,28], 3, 7>;
255defm : SBWriteResPair<WriteFDivZ,   [SBPort0,SBPort05,SBFPDivider], 29, [2,1,28], 3, 7>; // Unsupported = 1
256defm : SBWriteResPair<WriteFDiv64,  [SBPort0,SBFPDivider], 22, [1,22], 1, 6>;
257defm : SBWriteResPair<WriteFDiv64X, [SBPort0,SBFPDivider], 22, [1,22], 1, 6>;
258defm : SBWriteResPair<WriteFDiv64Y, [SBPort0,SBPort05,SBFPDivider], 45, [2,1,44], 3, 7>;
259defm : SBWriteResPair<WriteFDiv64Z, [SBPort0,SBPort05,SBFPDivider], 45, [2,1,44], 3, 7>; // Unsupported = 1
260
261defm : SBWriteResPair<WriteFRcp,   [SBPort0],  5, [1], 1, 6>;
262defm : SBWriteResPair<WriteFRcpX,  [SBPort0],  5, [1], 1, 6>;
263defm : SBWriteResPair<WriteFRcpY,  [SBPort0,SBPort05],  7, [2,1], 3, 7>;
264defm : SBWriteResPair<WriteFRcpZ,  [SBPort0,SBPort05],  7, [2,1], 3, 7>; // Unsupported = 1
265
266defm : SBWriteResPair<WriteFRsqrt, [SBPort0],  5, [1], 1, 6>;
267defm : SBWriteResPair<WriteFRsqrtX,[SBPort0],  5, [1], 1, 6>;
268defm : SBWriteResPair<WriteFRsqrtY,[SBPort0,SBPort05],  7, [2,1], 3, 7>;
269defm : SBWriteResPair<WriteFRsqrtZ,[SBPort0,SBPort05],  7, [2,1], 3, 7>; // Unsupported = 1
270
271defm : SBWriteResPair<WriteFSqrt,    [SBPort0,SBFPDivider], 14, [1,14], 1, 6>;
272defm : SBWriteResPair<WriteFSqrtX,   [SBPort0,SBFPDivider], 14, [1,14], 1, 6>;
273defm : SBWriteResPair<WriteFSqrtY,   [SBPort0,SBPort05,SBFPDivider], 29, [2,1,28], 3, 7>;
274defm : SBWriteResPair<WriteFSqrtZ,   [SBPort0,SBPort05,SBFPDivider], 29, [2,1,28], 3, 7>; // Unsupported = 1
275defm : SBWriteResPair<WriteFSqrt64,  [SBPort0,SBFPDivider], 21, [1,21], 1, 6>;
276defm : SBWriteResPair<WriteFSqrt64X, [SBPort0,SBFPDivider], 21, [1,21], 1, 6>;
277defm : SBWriteResPair<WriteFSqrt64Y, [SBPort0,SBPort05,SBFPDivider], 45, [2,1,44], 3, 7>;
278defm : SBWriteResPair<WriteFSqrt64Z, [SBPort0,SBPort05,SBFPDivider], 45, [2,1,44], 3, 7>; // Unsupported = 1
279defm : SBWriteResPair<WriteFSqrt80,  [SBPort0,SBFPDivider], 24, [1,24], 1, 6>;
280
281defm : SBWriteResPair<WriteDPPD,   [SBPort0,SBPort1,SBPort5],  9, [1,1,1], 3, 6>;
282defm : SBWriteResPair<WriteDPPS,   [SBPort0,SBPort1,SBPort5], 12, [1,2,1], 4, 6>;
283defm : SBWriteResPair<WriteDPPSY,  [SBPort0,SBPort1,SBPort5], 12, [1,2,1], 4, 7>;
284defm : SBWriteResPair<WriteDPPSZ,  [SBPort0,SBPort1,SBPort5], 12, [1,2,1], 4, 7>; // Unsupported = 1
285defm : SBWriteResPair<WriteFSign,    [SBPort5], 1>;
286defm : SBWriteResPair<WriteFRnd,     [SBPort1], 3, [1], 1, 6>;
287defm : SBWriteResPair<WriteFRndY,    [SBPort1], 3, [1], 1, 7>;
288defm : SBWriteResPair<WriteFRndZ,    [SBPort1], 3, [1], 1, 7>; // Unsupported = 1
289defm : SBWriteResPair<WriteFLogic,   [SBPort5], 1, [1], 1, 6>;
290defm : SBWriteResPair<WriteFLogicY,  [SBPort5], 1, [1], 1, 7>;
291defm : SBWriteResPair<WriteFLogicZ,  [SBPort5], 1, [1], 1, 7>; // Unsupported = 1
292defm : SBWriteResPair<WriteFTest,    [SBPort0], 1, [1], 1, 6>;
293defm : SBWriteResPair<WriteFTestY,   [SBPort0], 1, [1], 1, 7>;
294defm : SBWriteResPair<WriteFTestZ,   [SBPort0], 1, [1], 1, 7>; // Unsupported = 1
295defm : SBWriteResPair<WriteFShuffle, [SBPort5], 1, [1], 1, 6>;
296defm : SBWriteResPair<WriteFShuffleY,[SBPort5], 1, [1], 1, 7>;
297defm : SBWriteResPair<WriteFShuffleZ,[SBPort5], 1, [1], 1, 7>; // Unsupported = 1
298defm : SBWriteResPair<WriteFVarShuffle, [SBPort5], 1, [1], 1, 6>;
299defm : SBWriteResPair<WriteFVarShuffleY,[SBPort5], 1, [1], 1, 7>;
300defm : SBWriteResPair<WriteFVarShuffleZ,[SBPort5], 1, [1], 1, 7>; // Unsupported = 1
301defm : SBWriteResPair<WriteFBlend,    [SBPort05], 1, [1], 1, 6>;
302defm : SBWriteResPair<WriteFBlendY,   [SBPort05], 1, [1], 1, 7>;
303defm : SBWriteResPair<WriteFBlendZ,   [SBPort05], 1, [1], 1, 7>; // Unsupported = 1
304defm : SBWriteResPair<WriteFVarBlend, [SBPort05], 2, [2], 2, 6>;
305defm : SBWriteResPair<WriteFVarBlendY,[SBPort05], 2, [2], 2, 7>;
306defm : SBWriteResPair<WriteFVarBlendZ,[SBPort05], 2, [2], 2, 7>; // Unsupported = 1
307
308// Conversion between integer and float.
309defm : SBWriteResPair<WriteCvtSS2I,   [SBPort0,SBPort1], 5, [1,1], 2>;
310defm : SBWriteResPair<WriteCvtPS2I,           [SBPort1], 3, [1], 1, 6>;
311defm : SBWriteResPair<WriteCvtPS2IY,          [SBPort1], 3, [1], 1, 7>;
312defm : SBWriteResPair<WriteCvtPS2IZ,          [SBPort1], 3, [1], 1, 7>; // Unsupported = 1
313defm : SBWriteResPair<WriteCvtSD2I,   [SBPort0,SBPort1], 5, [1,1], 2>;
314defm : SBWriteResPair<WriteCvtPD2I,   [SBPort1,SBPort5], 4, [1,1], 2, 6>;
315defm : X86WriteRes<WriteCvtPD2IY,     [SBPort1,SBPort5], 4, [1,1], 2>;
316defm : X86WriteRes<WriteCvtPD2IZ,     [SBPort1,SBPort5], 4, [1,1], 2>; // Unsupported = 1
317defm : X86WriteRes<WriteCvtPD2IYLd,   [SBPort1,SBPort5,SBPort23], 11, [1,1,1], 3>;
318defm : X86WriteRes<WriteCvtPD2IZLd,   [SBPort1,SBPort5,SBPort23], 11, [1,1,1], 3>; // Unsupported = 1
319
320defm : X86WriteRes<WriteCvtI2SS,      [SBPort1,SBPort5],  5, [1,2], 3>;
321defm : X86WriteRes<WriteCvtI2SSLd,    [SBPort1,SBPort5,SBPort23], 10, [1,1,1], 3>;
322defm : SBWriteResPair<WriteCvtI2PS,           [SBPort1],  3, [1], 1, 6>;
323defm : SBWriteResPair<WriteCvtI2PSY,          [SBPort1],  3, [1], 1, 7>;
324defm : SBWriteResPair<WriteCvtI2PSZ,          [SBPort1],  3, [1], 1, 7>; // Unsupported = 1
325defm : X86WriteRes<WriteCvtI2SD,      [SBPort1,SBPort5],  4, [1,1], 2>;
326defm : X86WriteRes<WriteCvtI2PD,      [SBPort1,SBPort5],  4, [1,1], 2>;
327defm : X86WriteRes<WriteCvtI2PDY,     [SBPort1,SBPort5],  4, [1,1], 2>;
328defm : X86WriteRes<WriteCvtI2PDZ,     [SBPort1,SBPort5],  4, [1,1], 2>; // Unsupported = 1
329defm : X86WriteRes<WriteCvtI2SDLd,   [SBPort1,SBPort23],  9, [1,1], 2>;
330defm : X86WriteRes<WriteCvtI2PDLd,   [SBPort1,SBPort5,SBPort23], 10, [1,1,1], 3>;
331defm : X86WriteRes<WriteCvtI2PDYLd,  [SBPort1,SBPort5,SBPort23], 10, [1,1,1], 3>;
332defm : X86WriteRes<WriteCvtI2PDZLd,  [SBPort1,SBPort5,SBPort23], 10, [1,1,1], 3>; // Unsupported = 1
333
334defm : SBWriteResPair<WriteCvtSS2SD,  [SBPort0], 1, [1], 1, 6>;
335defm : X86WriteRes<WriteCvtPS2PD,     [SBPort0,SBPort5], 2, [1,1], 2>;
336defm : X86WriteRes<WriteCvtPS2PDY,    [SBPort0,SBPort5], 2, [1,1], 2>;
337defm : X86WriteRes<WriteCvtPS2PDZ,    [SBPort0,SBPort5], 2, [1,1], 2>; // Unsupported = 1
338defm : X86WriteRes<WriteCvtPS2PDLd,  [SBPort0,SBPort23], 7, [1,1], 2>;
339defm : X86WriteRes<WriteCvtPS2PDYLd, [SBPort0,SBPort23], 7, [1,1], 2>;
340defm : X86WriteRes<WriteCvtPS2PDZLd, [SBPort0,SBPort23], 7, [1,1], 2>; // Unsupported = 1
341defm : SBWriteResPair<WriteCvtSD2SS,  [SBPort1,SBPort5], 4, [1,1], 2, 6>;
342defm : SBWriteResPair<WriteCvtPD2PS,  [SBPort1,SBPort5], 4, [1,1], 2, 6>;
343defm : SBWriteResPair<WriteCvtPD2PSY, [SBPort1,SBPort5], 4, [1,1], 2, 7>;
344defm : SBWriteResPair<WriteCvtPD2PSZ, [SBPort1,SBPort5], 4, [1,1], 2, 7>; // Unsupported = 1
345
346defm : SBWriteResPair<WriteCvtPH2PS,  [SBPort1], 3>;
347defm : SBWriteResPair<WriteCvtPH2PSY, [SBPort1], 3>;
348defm : SBWriteResPair<WriteCvtPH2PSZ, [SBPort1], 3>; // Unsupported = 1
349
350defm : X86WriteRes<WriteCvtPS2PH,    [SBPort1], 3, [1], 1>;
351defm : X86WriteRes<WriteCvtPS2PHY,   [SBPort1], 3, [1], 1>;
352defm : X86WriteRes<WriteCvtPS2PHZ,   [SBPort1], 3, [1], 1>; // Unsupported = 1
353defm : X86WriteRes<WriteCvtPS2PHSt,  [SBPort1, SBPort23, SBPort4], 4, [1,1,1], 1>;
354defm : X86WriteRes<WriteCvtPS2PHYSt, [SBPort1, SBPort23, SBPort4], 4, [1,1,1], 1>;
355defm : X86WriteRes<WriteCvtPS2PHZSt, [SBPort1, SBPort23, SBPort4], 4, [1,1,1], 1>; // Unsupported = 1
356
357// Vector integer operations.
358defm : X86WriteRes<WriteVecLoad,         [SBPort23], 5, [1], 1>;
359defm : X86WriteRes<WriteVecLoadX,        [SBPort23], 6, [1], 1>;
360defm : X86WriteRes<WriteVecLoadY,        [SBPort23], 7, [1], 1>;
361defm : X86WriteRes<WriteVecLoadNT,       [SBPort23], 6, [1], 1>;
362defm : X86WriteRes<WriteVecLoadNTY,      [SBPort23], 7, [1], 1>;
363defm : X86WriteRes<WriteVecMaskedLoad,   [SBPort23,SBPort05], 8, [1,2], 3>;
364defm : X86WriteRes<WriteVecMaskedLoadY,  [SBPort23,SBPort05], 9, [1,2], 3>;
365defm : X86WriteRes<WriteVecStore,        [SBPort23,SBPort4], 1, [1,1], 1>;
366defm : X86WriteRes<WriteVecStoreX,       [SBPort23,SBPort4], 1, [1,1], 1>;
367defm : X86WriteRes<WriteVecStoreY,       [SBPort23,SBPort4], 1, [1,1], 1>;
368defm : X86WriteRes<WriteVecStoreNT,      [SBPort23,SBPort4], 1, [1,1], 1>;
369defm : X86WriteRes<WriteVecStoreNTY,     [SBPort23,SBPort4], 1, [1,1], 1>;
370defm : X86WriteRes<WriteVecMaskedStore32,  [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
371defm : X86WriteRes<WriteVecMaskedStore32Y, [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
372defm : X86WriteRes<WriteVecMaskedStore64,  [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
373defm : X86WriteRes<WriteVecMaskedStore64Y, [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
374defm : X86WriteRes<WriteVecMove,         [SBPort05], 1, [1], 1>;
375defm : X86WriteRes<WriteVecMoveX,        [SBPort015], 1, [1], 1>;
376defm : X86WriteRes<WriteVecMoveY,        [SBPort05], 1, [1], 1>;
377defm : X86WriteRes<WriteVecMoveToGpr,    [SBPort0], 2, [1], 1>;
378defm : X86WriteRes<WriteVecMoveFromGpr,  [SBPort5], 1, [1], 1>;
379
380defm : SBWriteResPair<WriteVecLogic, [SBPort015], 1, [1], 1, 5>;
381defm : SBWriteResPair<WriteVecLogicX,[SBPort015], 1, [1], 1, 6>;
382defm : SBWriteResPair<WriteVecLogicY,[SBPort015], 1, [1], 1, 7>;
383defm : SBWriteResPair<WriteVecLogicZ,[SBPort015], 1, [1], 1, 7>; // Unsupported = 1
384defm : SBWriteResPair<WriteVecTest,  [SBPort0,SBPort5], 2, [1,1], 2, 6>;
385defm : SBWriteResPair<WriteVecTestY, [SBPort0,SBPort5], 2, [1,1], 2, 7>;
386defm : SBWriteResPair<WriteVecTestZ, [SBPort0,SBPort5], 2, [1,1], 2, 7>; // Unsupported = 1
387defm : SBWriteResPair<WriteVecALU,   [SBPort1],  3, [1], 1, 5>;
388defm : SBWriteResPair<WriteVecALUX,  [SBPort15], 1, [1], 1, 6>;
389defm : SBWriteResPair<WriteVecALUY,  [SBPort15], 1, [1], 1, 7>;
390defm : SBWriteResPair<WriteVecALUZ,  [SBPort15], 1, [1], 1, 7>; // Unsupported = 1
391defm : SBWriteResPair<WriteVecIMul,  [SBPort0], 5, [1], 1, 5>;
392defm : SBWriteResPair<WriteVecIMulX, [SBPort0], 5, [1], 1, 6>;
393defm : SBWriteResPair<WriteVecIMulY, [SBPort0], 5, [1], 1, 7>;
394defm : SBWriteResPair<WriteVecIMulZ, [SBPort0], 5, [1], 1, 7>; // Unsupported = 1
395defm : SBWriteResPair<WritePMULLD,   [SBPort0], 5, [1], 1, 6>;
396defm : SBWriteResPair<WritePMULLDY,  [SBPort0], 5, [1], 1, 7>; // TODO this is probably wrong for 256/512-bit for the "generic" model
397defm : SBWriteResPair<WritePMULLDZ,  [SBPort0], 5, [1], 1, 7>;  // Unsupported = 1
398defm : SBWriteResPair<WriteShuffle,  [SBPort5], 1, [1], 1, 5>;
399defm : SBWriteResPair<WriteShuffleX, [SBPort15], 1, [1], 1, 6>;
400defm : SBWriteResPair<WriteShuffleY, [SBPort5], 1, [1], 1, 7>;
401defm : SBWriteResPair<WriteShuffleZ, [SBPort5], 1, [1], 1, 7>; // Unsupported = 1
402defm : SBWriteResPair<WriteVarShuffle,  [SBPort15], 1, [1], 1, 5>;
403defm : SBWriteResPair<WriteVarShuffleX, [SBPort15], 1, [1], 1, 6>;
404defm : SBWriteResPair<WriteVarShuffleY, [SBPort15], 1, [1], 1, 7>;
405defm : SBWriteResPair<WriteVarShuffleZ, [SBPort15], 1, [1], 1, 7>; // Unsupported = 1
406defm : SBWriteResPair<WriteBlend,   [SBPort15], 1, [1], 1, 6>;
407defm : SBWriteResPair<WriteBlendY,  [SBPort15], 1, [1], 1, 7>;
408defm : SBWriteResPair<WriteBlendZ,  [SBPort15], 1, [1], 1, 7>; // Unsupported = 1
409defm : SBWriteResPair<WriteVarBlend, [SBPort15], 2, [2], 2, 6>;
410defm : SBWriteResPair<WriteVarBlendY,[SBPort15], 2, [2], 2, 7>;
411defm : SBWriteResPair<WriteVarBlendZ,[SBPort15], 2, [2], 2, 7>; // Unsupported = 1
412defm : SBWriteResPair<WriteMPSAD,  [SBPort0, SBPort15], 7, [1,2], 3, 6>;
413defm : SBWriteResPair<WriteMPSADY, [SBPort0, SBPort15], 7, [1,2], 3, 7>;
414defm : SBWriteResPair<WriteMPSADZ, [SBPort0, SBPort15], 7, [1,2], 3, 7>; // Unsupported = 1
415defm : SBWriteResPair<WritePSADBW,  [SBPort0], 5, [1], 1, 5>;
416defm : SBWriteResPair<WritePSADBWX, [SBPort0], 5, [1], 1, 6>;
417defm : SBWriteResPair<WritePSADBWY, [SBPort0], 5, [1], 1, 7>;
418defm : SBWriteResPair<WritePSADBWZ, [SBPort0], 5, [1], 1, 7>; // Unsupported = 1
419defm : SBWriteResPair<WritePHMINPOS,  [SBPort0], 5, [1], 1, 6>;
420
421// Vector integer shifts.
422defm : SBWriteResPair<WriteVecShift,     [SBPort5], 1, [1], 1, 5>;
423defm : SBWriteResPair<WriteVecShiftX,    [SBPort0,SBPort15], 2, [1,1], 2, 6>;
424defm : SBWriteResPair<WriteVecShiftY,    [SBPort0,SBPort15], 4, [1,1], 2, 7>;
425defm : SBWriteResPair<WriteVecShiftZ,    [SBPort0,SBPort15], 4, [1,1], 2, 7>; // Unsupported = 1
426defm : SBWriteResPair<WriteVecShiftImm,  [SBPort5], 1, [1], 1, 5>;
427defm : SBWriteResPair<WriteVecShiftImmX, [SBPort0], 1, [1], 1, 6>;
428defm : SBWriteResPair<WriteVecShiftImmY, [SBPort0], 1, [1], 1, 7>;
429defm : SBWriteResPair<WriteVecShiftImmZ, [SBPort0], 1, [1], 1, 7>; // Unsupported = 1
430defm : SBWriteResPair<WriteVarVecShift,  [SBPort0], 1, [1], 1, 6>;
431defm : SBWriteResPair<WriteVarVecShiftY, [SBPort0], 1, [1], 1, 7>;
432defm : SBWriteResPair<WriteVarVecShiftZ, [SBPort0], 1, [1], 1, 7>; // Unsupported = 1
433
434// Vector insert/extract operations.
435def : WriteRes<WriteVecInsert, [SBPort5,SBPort15]> {
436  let Latency = 2;
437  let NumMicroOps = 2;
438}
439def : WriteRes<WriteVecInsertLd, [SBPort23,SBPort15]> {
440  let Latency = 7;
441  let NumMicroOps = 2;
442}
443
444def : WriteRes<WriteVecExtract, [SBPort0,SBPort15]> {
445  let Latency = 3;
446  let NumMicroOps = 2;
447}
448def : WriteRes<WriteVecExtractSt, [SBPort4,SBPort23,SBPort15]> {
449  let Latency = 5;
450  let NumMicroOps = 3;
451}
452
453////////////////////////////////////////////////////////////////////////////////
454// Horizontal add/sub  instructions.
455////////////////////////////////////////////////////////////////////////////////
456
457defm : SBWriteResPair<WriteFHAdd,  [SBPort1,SBPort5], 5, [1,2], 3, 6>;
458defm : SBWriteResPair<WriteFHAddY, [SBPort1,SBPort5], 5, [1,2], 3, 7>;
459defm : SBWriteResPair<WriteFHAddZ, [SBPort1,SBPort5], 5, [1,2], 3, 7>; // Unsupported = 1
460defm : SBWriteResPair<WritePHAdd,  [SBPort15], 3, [3], 3, 5>;
461defm : SBWriteResPair<WritePHAddX, [SBPort15], 3, [3], 3, 6>;
462defm : SBWriteResPair<WritePHAddY, [SBPort15], 3, [3], 3, 7>;
463defm : SBWriteResPair<WritePHAddZ, [SBPort15], 3, [3], 3, 7>; // Unsupported = 1
464
465////////////////////////////////////////////////////////////////////////////////
466// String instructions.
467////////////////////////////////////////////////////////////////////////////////
468
469// Packed Compare Implicit Length Strings, Return Mask
470def : WriteRes<WritePCmpIStrM, [SBPort0]> {
471  let Latency = 11;
472  let NumMicroOps = 3;
473  let ResourceCycles = [3];
474}
475def : WriteRes<WritePCmpIStrMLd, [SBPort0, SBPort23]> {
476  let Latency = 17;
477  let NumMicroOps = 4;
478  let ResourceCycles = [3,1];
479}
480
481// Packed Compare Explicit Length Strings, Return Mask
482def : WriteRes<WritePCmpEStrM, [SBPort015]> {
483  let Latency = 11;
484  let ResourceCycles = [8];
485}
486def : WriteRes<WritePCmpEStrMLd, [SBPort015, SBPort23]> {
487  let Latency = 17;
488  let ResourceCycles = [7, 1];
489}
490
491// Packed Compare Implicit Length Strings, Return Index
492def : WriteRes<WritePCmpIStrI, [SBPort0]> {
493  let Latency = 11;
494  let NumMicroOps = 3;
495  let ResourceCycles = [3];
496}
497def : WriteRes<WritePCmpIStrILd, [SBPort0,SBPort23]> {
498  let Latency = 17;
499  let NumMicroOps = 4;
500  let ResourceCycles = [3,1];
501}
502
503// Packed Compare Explicit Length Strings, Return Index
504def : WriteRes<WritePCmpEStrI, [SBPort015]> {
505  let Latency = 4;
506  let ResourceCycles = [8];
507}
508def : WriteRes<WritePCmpEStrILd, [SBPort015, SBPort23]> {
509  let Latency = 10;
510  let ResourceCycles = [7, 1];
511}
512
513// MOVMSK Instructions.
514def : WriteRes<WriteFMOVMSK,    [SBPort0]> { let Latency = 2; }
515def : WriteRes<WriteVecMOVMSK,  [SBPort0]> { let Latency = 2; }
516def : WriteRes<WriteVecMOVMSKY, [SBPort0]> { let Latency = 2; }
517def : WriteRes<WriteMMXMOVMSK,  [SBPort0]> { let Latency = 1; }
518
519// AES Instructions.
520def : WriteRes<WriteAESDecEnc, [SBPort5,SBPort015]> {
521  let Latency = 7;
522  let NumMicroOps = 2;
523  let ResourceCycles = [1,1];
524}
525def : WriteRes<WriteAESDecEncLd, [SBPort5,SBPort23,SBPort015]> {
526  let Latency = 13;
527  let NumMicroOps = 3;
528  let ResourceCycles = [1,1,1];
529}
530
531def : WriteRes<WriteAESIMC, [SBPort5]> {
532  let Latency = 12;
533  let NumMicroOps = 2;
534  let ResourceCycles = [2];
535}
536def : WriteRes<WriteAESIMCLd, [SBPort5,SBPort23]> {
537  let Latency = 18;
538  let NumMicroOps = 3;
539  let ResourceCycles = [2,1];
540}
541
542def : WriteRes<WriteAESKeyGen, [SBPort015]> {
543  let Latency = 8;
544  let ResourceCycles = [11];
545}
546def : WriteRes<WriteAESKeyGenLd, [SBPort015, SBPort23]> {
547  let Latency = 14;
548  let ResourceCycles = [10, 1];
549}
550
551// Carry-less multiplication instructions.
552def : WriteRes<WriteCLMul, [SBPort015]> {
553  let Latency = 14;
554  let ResourceCycles = [18];
555}
556def : WriteRes<WriteCLMulLd, [SBPort015, SBPort23]> {
557  let Latency = 20;
558  let ResourceCycles = [17, 1];
559}
560
561// Load/store MXCSR.
562// FIXME: This is probably wrong. Only STMXCSR should require Port4.
563def : WriteRes<WriteLDMXCSR, [SBPort0,SBPort4,SBPort5,SBPort23]> { let Latency = 5; let NumMicroOps = 4; let ResourceCycles = [1,1,1,1]; }
564def : WriteRes<WriteSTMXCSR, [SBPort0,SBPort4,SBPort5,SBPort23]> { let Latency = 5; let NumMicroOps = 4; let ResourceCycles = [1,1,1,1]; }
565
566def : WriteRes<WriteSystem,     [SBPort015]> { let Latency = 100; }
567def : WriteRes<WriteMicrocoded, [SBPort015]> { let Latency = 100; }
568def : WriteRes<WriteFence, [SBPort23, SBPort4]>;
569def : WriteRes<WriteNop, []>;
570
571// AVX2/FMA is not supported on that architecture, but we should define the basic
572// scheduling resources anyway.
573defm : SBWriteResPair<WriteFShuffle256, [SBPort5], 1, [1], 1, 7>;
574defm : SBWriteResPair<WriteFVarShuffle256, [SBPort5], 1, [1], 1, 7>;
575defm : SBWriteResPair<WriteShuffle256, [SBPort5], 1, [1], 1, 7>;
576defm : SBWriteResPair<WriteVarShuffle256, [SBPort5], 1, [1], 1, 7>;
577defm : SBWriteResPair<WriteFMA,  [SBPort01],  5>;
578defm : SBWriteResPair<WriteFMAX, [SBPort01],  5>;
579defm : SBWriteResPair<WriteFMAY, [SBPort01],  5>;
580defm : SBWriteResPair<WriteFMAZ, [SBPort01],  5>;  // Unsupported = 1
581
582// Remaining SNB instrs.
583
584def SBWriteResGroup1 : SchedWriteRes<[SBPort1]> {
585  let Latency = 1;
586  let NumMicroOps = 1;
587  let ResourceCycles = [1];
588}
589def: InstRW<[SBWriteResGroup1], (instrs COMP_FST0r,
590                                        COM_FST0r,
591                                        UCOM_FPr,
592                                        UCOM_Fr)>;
593
594def SBWriteResGroup2 : SchedWriteRes<[SBPort5]> {
595  let Latency = 1;
596  let NumMicroOps = 1;
597  let ResourceCycles = [1];
598}
599def: InstRW<[SBWriteResGroup2], (instrs FDECSTP, FINCSTP, FFREE, FFREEP, FNOP,
600                                        LD_Frr, ST_Frr, ST_FPrr)>;
601def: InstRW<[SBWriteResGroup2], (instrs LOOP, LOOPE, LOOPNE)>; // FIXME: This seems wrong compared to other Intel CPUs.
602def: InstRW<[SBWriteResGroup2], (instrs RETQ)>;
603
604def SBWriteResGroup4 : SchedWriteRes<[SBPort05]> {
605  let Latency = 1;
606  let NumMicroOps = 1;
607  let ResourceCycles = [1];
608}
609def: InstRW<[SBWriteResGroup4], (instrs CDQ, CQO)>;
610
611def SBWriteResGroup5 : SchedWriteRes<[SBPort15]> {
612  let Latency = 1;
613  let NumMicroOps = 1;
614  let ResourceCycles = [1];
615}
616def: InstRW<[SBWriteResGroup5], (instrs MMX_PABSBrr,
617                                        MMX_PABSDrr,
618                                        MMX_PABSWrr,
619                                        MMX_PADDQirr,
620                                        MMX_PALIGNRrri,
621                                        MMX_PSIGNBrr,
622                                        MMX_PSIGNDrr,
623                                        MMX_PSIGNWrr)>;
624
625def SBWriteResGroup11 : SchedWriteRes<[SBPort015]> {
626  let Latency = 2;
627  let NumMicroOps = 2;
628  let ResourceCycles = [2];
629}
630def: InstRW<[SBWriteResGroup11], (instrs SCASB,
631                                         SCASL,
632                                         SCASQ,
633                                         SCASW)>;
634
635def SBWriteResGroup12 : SchedWriteRes<[SBPort0,SBPort1]> {
636  let Latency = 2;
637  let NumMicroOps = 2;
638  let ResourceCycles = [1,1];
639}
640def: InstRW<[SBWriteResGroup12], (instregex "(V?)(U?)COMI(SD|SS)rr")>;
641
642def SBWriteResGroup15 : SchedWriteRes<[SBPort0,SBPort015]> {
643  let Latency = 2;
644  let NumMicroOps = 2;
645  let ResourceCycles = [1,1];
646}
647def: InstRW<[SBWriteResGroup15], (instrs CWD,
648                                         FNSTSW16r)>;
649
650def SBWriteResGroup18 : SchedWriteRes<[SBPort5,SBPort015]> {
651  let Latency = 2;
652  let NumMicroOps = 2;
653  let ResourceCycles = [1,1];
654}
655def: InstRW<[SBWriteResGroup18], (instrs JCXZ, JECXZ, JRCXZ,
656                                         MMX_MOVDQ2Qrr)>;
657
658def SBWriteResGroup21 : SchedWriteRes<[SBPort1]> {
659  let Latency = 3;
660  let NumMicroOps = 1;
661  let ResourceCycles = [1];
662}
663def: InstRW<[SBWriteResGroup21], (instrs PUSHFS64)>;
664
665def SBWriteResGroup22 : SchedWriteRes<[SBPort0,SBPort5]> {
666  let Latency = 3;
667  let NumMicroOps = 2;
668  let ResourceCycles = [1,1];
669}
670def: InstRW<[SBWriteResGroup22], (instregex "(V?)EXTRACTPSrr")>;
671
672def SBWriteResGroup23 : SchedWriteRes<[SBPort05]> {
673  let Latency = 2;
674  let NumMicroOps = 3;
675  let ResourceCycles = [3];
676}
677def: InstRW<[SBWriteResGroup23], (instregex "RCL(8|16|32|64)r1",
678                                            "RCR(8|16|32|64)r1")>;
679
680def SBWriteResGroup25_1 : SchedWriteRes<[SBPort23,SBPort015]> {
681  let Latency = 7;
682  let NumMicroOps = 3;
683  let ResourceCycles = [1,2];
684}
685def: InstRW<[SBWriteResGroup25_1], (instrs LEAVE, LEAVE64)>;
686
687def SBWriteResGroup26_2 : SchedWriteRes<[SBPort0,SBPort1,SBPort5]> {
688  let Latency = 3;
689  let NumMicroOps = 3;
690  let ResourceCycles = [1,1,1];
691}
692def: InstRW<[SBWriteResGroup26_2], (instrs COM_FIPr, COM_FIr, UCOM_FIPr, UCOM_FIr)>;
693
694def SBWriteResGroup29 : SchedWriteRes<[SBPort1,SBPort015]> {
695  let Latency = 4;
696  let NumMicroOps = 2;
697  let ResourceCycles = [1,1];
698}
699def: InstRW<[SBWriteResGroup29], (instrs MOV64sr)>;
700
701def SBWriteResGroup29_2 : SchedWriteRes<[SBPort5,SBPort015]> {
702  let Latency = 4;
703  let NumMicroOps = 4;
704  let ResourceCycles = [1,3];
705}
706def: InstRW<[SBWriteResGroup29_2], (instrs PAUSE)>;
707
708def SBWriteResGroup31 : SchedWriteRes<[SBPort23]> {
709  let Latency = 5;
710  let NumMicroOps = 1;
711  let ResourceCycles = [1];
712}
713def: InstRW<[SBWriteResGroup31], (instregex "MOVSX(16|32|64)rm(8|16|32)",
714                                            "MOVZX(16|32|64)rm(8|16)")>;
715
716def SBWriteResGroup76 : SchedWriteRes<[SBPort05]> {
717  let Latency = 5;
718  let NumMicroOps = 8;
719  let ResourceCycles = [8];
720}
721def: InstRW<[SBWriteResGroup76], (instregex "RCL(8|16|32|64)r(i|CL)",
722                                            "RCR(8|16|32|64)r(i|CL)")>;
723
724def SBWriteResGroup33 : SchedWriteRes<[SBPort4,SBPort23]> {
725  let Latency = 5;
726  let NumMicroOps = 2;
727  let ResourceCycles = [1,1];
728}
729def: InstRW<[SBWriteResGroup33], (instregex "PUSH(16r|32r|64r|64i8)")>;
730
731def SBWriteResGroup35 : SchedWriteRes<[SBPort1,SBPort5]> {
732  let Latency = 5;
733  let NumMicroOps = 3;
734  let ResourceCycles = [1,2];
735}
736def: InstRW<[SBWriteResGroup35], (instrs CLI)>;
737
738def SBWriteResGroup35_2 : SchedWriteRes<[SBPort1,SBPort4,SBPort23]> {
739  let Latency = 5;
740  let NumMicroOps = 3;
741  let ResourceCycles = [1,1,1];
742}
743def: InstRW<[SBWriteResGroup35_2], (instrs PUSHGS64)>;
744def: InstRW<[SBWriteResGroup35_2], (instregex "ISTT_FP(16|32|64)m")>;
745
746def SBWriteResGroup36 : SchedWriteRes<[SBPort4,SBPort5,SBPort23]> {
747  let Latency = 5;
748  let NumMicroOps = 3;
749  let ResourceCycles = [1,1,1];
750}
751def: InstRW<[SBWriteResGroup36], (instrs CALL64pcrel32)>;
752def: InstRW<[SBWriteResGroup36], (instregex "CALL(16|32|64)r",
753                                            "(V?)EXTRACTPSmr")>;
754
755def SBWriteResGroup40 : SchedWriteRes<[SBPort4,SBPort23,SBPort015]> {
756  let Latency = 5;
757  let NumMicroOps = 3;
758  let ResourceCycles = [1,1,1];
759}
760def: InstRW<[SBWriteResGroup40], (instrs STOSB, STOSL, STOSQ, STOSW)>;
761
762def SBWriteResGroup41 : SchedWriteRes<[SBPort5,SBPort015]> {
763  let Latency = 5;
764  let NumMicroOps = 4;
765  let ResourceCycles = [1,3];
766}
767def: InstRW<[SBWriteResGroup41], (instrs FNINIT)>;
768
769def SBWriteResGroup45 : SchedWriteRes<[SBPort0,SBPort4,SBPort23,SBPort15]> {
770  let Latency = 5;
771  let NumMicroOps = 4;
772  let ResourceCycles = [1,1,1,1];
773}
774def: InstRW<[SBWriteResGroup45], (instregex "(V?)PEXTR(D|Q)mr",
775                                            "PUSHF(16|64)")>;
776
777def SBWriteResGroup46 : SchedWriteRes<[SBPort4,SBPort5,SBPort01,SBPort23]> {
778  let Latency = 5;
779  let NumMicroOps = 4;
780  let ResourceCycles = [1,1,1,1];
781}
782def: InstRW<[SBWriteResGroup46], (instregex "CLFLUSH")>;
783
784def SBWriteResGroup47 : SchedWriteRes<[SBPort4,SBPort5,SBPort01,SBPort23]> {
785  let Latency = 5;
786  let NumMicroOps = 5;
787  let ResourceCycles = [1,2,1,1];
788}
789def: InstRW<[SBWriteResGroup47], (instregex "FXRSTOR")>;
790
791def SBWriteResGroup48 : SchedWriteRes<[SBPort23]> {
792  let Latency = 6;
793  let NumMicroOps = 1;
794  let ResourceCycles = [1];
795}
796def: InstRW<[SBWriteResGroup48], (instrs MMX_MOVD64from64rm,
797                                         VBROADCASTSSrm)>;
798def: InstRW<[SBWriteResGroup48], (instregex "POP(16|32|64)r",
799                                            "(V?)MOV64toPQIrm",
800                                            "(V?)MOVDDUPrm",
801                                            "(V?)MOVDI2PDIrm",
802                                            "(V?)MOVQI2PQIrm",
803                                            "(V?)MOVSDrm",
804                                            "(V?)MOVSHDUPrm",
805                                            "(V?)MOVSLDUPrm",
806                                            "(V?)MOVSSrm")>;
807
808def SBWriteResGroup49 : SchedWriteRes<[SBPort5,SBPort23]> {
809  let Latency = 6;
810  let NumMicroOps = 2;
811  let ResourceCycles = [1,1];
812}
813def: InstRW<[SBWriteResGroup49], (instrs MOV16sm)>;
814
815def SBWriteResGroup51 : SchedWriteRes<[SBPort23,SBPort15]> {
816  let Latency = 6;
817  let NumMicroOps = 2;
818  let ResourceCycles = [1,1];
819}
820def: InstRW<[SBWriteResGroup51], (instrs MMX_PABSBrm,
821                                         MMX_PABSDrm,
822                                         MMX_PABSWrm,
823                                         MMX_PALIGNRrmi,
824                                         MMX_PSIGNBrm,
825                                         MMX_PSIGNDrm,
826                                         MMX_PSIGNWrm)>;
827
828def SBWriteResGroup52 : SchedWriteRes<[SBPort23,SBPort015]> {
829  let Latency = 6;
830  let NumMicroOps = 2;
831  let ResourceCycles = [1,1];
832}
833def: InstRW<[SBWriteResGroup52], (instrs LODSL, LODSQ)>;
834
835def SBWriteResGroup53 : SchedWriteRes<[SBPort4,SBPort23]> {
836  let Latency = 6;
837  let NumMicroOps = 3;
838  let ResourceCycles = [1,2];
839}
840def: InstRW<[SBWriteResGroup53], (instregex "ST_F(32|64)m",
841                                            "ST_FP(32|64|80)m")>;
842
843def SBWriteResGroup54 : SchedWriteRes<[SBPort23]> {
844  let Latency = 7;
845  let NumMicroOps = 1;
846  let ResourceCycles = [1];
847}
848def: InstRW<[SBWriteResGroup54], (instrs VBROADCASTSDYrm,
849                                         VBROADCASTSSYrm,
850                                         VMOVDDUPYrm,
851                                         VMOVSHDUPYrm,
852                                         VMOVSLDUPYrm)>;
853
854def SBWriteResGroup58 : SchedWriteRes<[SBPort23,SBPort05]> {
855  let Latency = 7;
856  let NumMicroOps = 2;
857  let ResourceCycles = [1,1];
858}
859def: InstRW<[SBWriteResGroup58], (instrs VINSERTF128rm)>;
860
861def SBWriteResGroup59 : SchedWriteRes<[SBPort23,SBPort15]> {
862  let Latency = 7;
863  let NumMicroOps = 2;
864  let ResourceCycles = [1,1];
865}
866def: InstRW<[SBWriteResGroup59], (instrs MMX_PADDQirm)>;
867
868def SBWriteResGroup62 : SchedWriteRes<[SBPort5,SBPort23]> {
869  let Latency = 7;
870  let NumMicroOps = 3;
871  let ResourceCycles = [2,1];
872}
873def: InstRW<[SBWriteResGroup62], (instrs VERRm, VERWm)>;
874
875def SBWriteResGroup63 : SchedWriteRes<[SBPort23,SBPort015]> {
876  let Latency = 7;
877  let NumMicroOps = 3;
878  let ResourceCycles = [1,2];
879}
880def: InstRW<[SBWriteResGroup63], (instrs LODSB, LODSW)>;
881
882def SBWriteResGroup64 : SchedWriteRes<[SBPort5,SBPort01,SBPort23]> {
883  let Latency = 7;
884  let NumMicroOps = 3;
885  let ResourceCycles = [1,1,1];
886}
887def: InstRW<[SBWriteResGroup64], (instrs FARJMP64m)>;
888
889def SBWriteResGroup66 : SchedWriteRes<[SBPort0,SBPort4,SBPort23]> {
890  let Latency = 7;
891  let NumMicroOps = 4;
892  let ResourceCycles = [1,1,2];
893}
894def: InstRW<[SBWriteResGroup66], (instrs FNSTSWm)>;
895
896def SBWriteResGroup67 : SchedWriteRes<[SBPort1,SBPort5,SBPort015]> {
897  let Latency = 7;
898  let NumMicroOps = 4;
899  let ResourceCycles = [1,2,1];
900}
901def: InstRW<[SBWriteResGroup67], (instregex "SLDT(16|32|64)r",
902                                            "STR(16|32|64)r")>;
903
904def SBWriteResGroup68 : SchedWriteRes<[SBPort4,SBPort5,SBPort23]> {
905  let Latency = 7;
906  let NumMicroOps = 4;
907  let ResourceCycles = [1,1,2];
908}
909def: InstRW<[SBWriteResGroup68], (instrs FNSTCW16m)>;
910def: InstRW<[SBWriteResGroup68], (instregex "CALL(16|32|64)m")>;
911
912def SBWriteResGroup69 : SchedWriteRes<[SBPort4,SBPort23,SBPort05]> {
913  let Latency = 7;
914  let NumMicroOps = 4;
915  let ResourceCycles = [1,2,1];
916}
917def: InstRW<[SBWriteResGroup69], (instregex "SAR(8|16|32|64)m(1|i)",
918                                            "SHL(8|16|32|64)m(1|i)",
919                                            "SHR(8|16|32|64)m(1|i)")>;
920
921def SBWriteResGroup77 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> {
922  let Latency = 8;
923  let NumMicroOps = 3;
924  let ResourceCycles = [1,1,1];
925}
926def: InstRW<[SBWriteResGroup77], (instregex "(V?)(U?)COMI(SD|SS)rm")>;
927
928def SBWriteResGroup81 : SchedWriteRes<[SBPort4, SBPort23, SBPort015]> {
929  let Latency = 6;
930  let NumMicroOps = 3;
931  let ResourceCycles = [1, 2, 1];
932}
933def: InstRW<[SBWriteResGroup81], (instregex "CMPXCHG(8|16)B")>;
934
935def SBWriteResGroup83 : SchedWriteRes<[SBPort23,SBPort015]> {
936  let Latency = 8;
937  let NumMicroOps = 5;
938  let ResourceCycles = [2,3];
939}
940def: InstRW<[SBWriteResGroup83], (instrs CMPSB,
941                                         CMPSL,
942                                         CMPSQ,
943                                         CMPSW)>;
944
945def SBWriteResGroup84 : SchedWriteRes<[SBPort4,SBPort5,SBPort23]> {
946  let Latency = 8;
947  let NumMicroOps = 5;
948  let ResourceCycles = [1,2,2];
949}
950def: InstRW<[SBWriteResGroup84], (instrs FLDCW16m)>;
951
952def SBWriteResGroup85 : SchedWriteRes<[SBPort4,SBPort23,SBPort05]> {
953  let Latency = 8;
954  let NumMicroOps = 5;
955  let ResourceCycles = [1,2,2];
956}
957def: InstRW<[SBWriteResGroup85], (instregex "ROL(8|16|32|64)m(1|i)",
958                                            "ROR(8|16|32|64)m(1|i)")>;
959
960def SBWriteResGroup86 : SchedWriteRes<[SBPort4,SBPort23,SBPort015]> {
961  let Latency = 8;
962  let NumMicroOps = 5;
963  let ResourceCycles = [1,2,2];
964}
965def: InstRW<[SBWriteResGroup86], (instrs MOVSB, MOVSL, MOVSQ, MOVSW)>;
966def: InstRW<[SBWriteResGroup86], (instregex "XADD(8|16|32|64)rm")>;
967
968def SBWriteResGroup87 : SchedWriteRes<[SBPort4,SBPort5,SBPort01,SBPort23]> {
969  let Latency = 8;
970  let NumMicroOps = 5;
971  let ResourceCycles = [1,1,1,2];
972}
973def: InstRW<[SBWriteResGroup87], (instrs FARCALL64m)>;
974
975def SBWriteResGroup93 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> {
976  let Latency = 9;
977  let NumMicroOps = 3;
978  let ResourceCycles = [1,1,1];
979}
980def: InstRW<[SBWriteResGroup93], (instregex "CVT(T?)(SD|SS)2SI(64)?rm")>;
981
982def SBWriteResGroup95 : SchedWriteRes<[SBPort5,SBPort01,SBPort23]> {
983  let Latency = 9;
984  let NumMicroOps = 3;
985  let ResourceCycles = [1,1,1];
986}
987def: InstRW<[SBWriteResGroup95], (instregex "LD_F(32|64|80)m")>;
988
989def SBWriteResGroup97 : SchedWriteRes<[SBPort1,SBPort4,SBPort23]> {
990  let Latency = 9;
991  let NumMicroOps = 4;
992  let ResourceCycles = [1,1,2];
993}
994def: InstRW<[SBWriteResGroup97], (instregex "IST_F(16|32)m",
995                                            "IST_FP(16|32|64)m")>;
996
997def SBWriteResGroup97_2 : SchedWriteRes<[SBPort4,SBPort23,SBPort05]> {
998  let Latency = 9;
999  let NumMicroOps = 6;
1000  let ResourceCycles = [1,2,3];
1001}
1002def: InstRW<[SBWriteResGroup97_2], (instregex "ROL(8|16|32|64)mCL",
1003                                              "ROR(8|16|32|64)mCL",
1004                                              "SAR(8|16|32|64)mCL",
1005                                              "SHL(8|16|32|64)mCL",
1006                                              "SHR(8|16|32|64)mCL")>;
1007
1008def SBWriteResGroup98 : SchedWriteRes<[SBPort4,SBPort23,SBPort015]> {
1009  let Latency = 9;
1010  let NumMicroOps = 6;
1011  let ResourceCycles = [1,2,3];
1012}
1013def: SchedAlias<WriteADCRMW, SBWriteResGroup98>;
1014
1015def SBWriteResGroup99 : SchedWriteRes<[SBPort4,SBPort23,SBPort05,SBPort015]> {
1016  let Latency = 9;
1017  let NumMicroOps = 6;
1018  let ResourceCycles = [1,2,2,1];
1019}
1020def: InstRW<[SBWriteResGroup99, ReadAfterLd], (instrs ADC8mr, ADC16mr, ADC32mr, ADC64mr,
1021                                                      SBB8mr, SBB16mr, SBB32mr, SBB64mr)>;
1022
1023def SBWriteResGroup100 : SchedWriteRes<[SBPort4,SBPort5,SBPort23,SBPort05,SBPort015]> {
1024  let Latency = 9;
1025  let NumMicroOps = 6;
1026  let ResourceCycles = [1,1,2,1,1];
1027}
1028def : SchedAlias<WriteBitTestRegLd, SBWriteResGroup100>; // TODO - this is incorrect - no RMW
1029
1030def SBWriteResGroup101 : SchedWriteRes<[SBPort1,SBPort23]> {
1031  let Latency = 10;
1032  let NumMicroOps = 2;
1033  let ResourceCycles = [1,1];
1034}
1035def: InstRW<[SBWriteResGroup101], (instregex "(ADD|SUB|SUBR)_F(32|64)m",
1036                                             "ILD_F(16|32|64)m")>;
1037
1038def SBWriteResGroup104 : SchedWriteRes<[SBPort0,SBPort23]> {
1039  let Latency = 11;
1040  let NumMicroOps = 2;
1041  let ResourceCycles = [1,1];
1042}
1043def: InstRW<[SBWriteResGroup104], (instregex "(V?)PCMPGTQrm")>;
1044
1045def SBWriteResGroup106 : SchedWriteRes<[SBPort1,SBPort23]> {
1046  let Latency = 11;
1047  let NumMicroOps = 3;
1048  let ResourceCycles = [2,1];
1049}
1050def: InstRW<[SBWriteResGroup106], (instregex "FICOM(P?)(16|32)m")>;
1051
1052def SBWriteResGroup108 : SchedWriteRes<[SBPort05,SBPort23]> {
1053  let Latency = 11;
1054  let NumMicroOps = 11;
1055  let ResourceCycles = [7,4];
1056}
1057def: InstRW<[SBWriteResGroup108], (instregex "RCL(8|16|32|64)m",
1058                                             "RCR(8|16|32|64)m")>;
1059
1060def SBWriteResGroup111 : SchedWriteRes<[SBPort0,SBPort23]> {
1061  let Latency = 12;
1062  let NumMicroOps = 2;
1063  let ResourceCycles = [1,1];
1064}
1065def: InstRW<[SBWriteResGroup111], (instregex "MUL_F(32|64)m")>;
1066
1067def SBWriteResGroup114 : SchedWriteRes<[SBPort1,SBPort23]> {
1068  let Latency = 13;
1069  let NumMicroOps = 3;
1070  let ResourceCycles = [2,1];
1071}
1072def: InstRW<[SBWriteResGroup114], (instregex "(ADD|SUB|SUBR)_FI(16|32)m")>;
1073
1074def SBWriteResGroup119 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> {
1075  let Latency = 15;
1076  let NumMicroOps = 3;
1077  let ResourceCycles = [1,1,1];
1078}
1079def: InstRW<[SBWriteResGroup119], (instregex "MUL_FI(16|32)m")>;
1080
1081def SBWriteResGroup130 : SchedWriteRes<[SBPort0,SBPort23]> {
1082  let Latency = 31;
1083  let NumMicroOps = 2;
1084  let ResourceCycles = [1,1];
1085}
1086def: InstRW<[SBWriteResGroup130], (instregex "DIV(R?)_F(32|64)m")>;
1087
1088def SBWriteResGroup131 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> {
1089  let Latency = 34;
1090  let NumMicroOps = 3;
1091  let ResourceCycles = [1,1,1];
1092}
1093def: InstRW<[SBWriteResGroup131], (instregex "DIV(R?)_FI(16|32)m")>;
1094
1095def SBWriteResGroupVzeroall : SchedWriteRes<[SBPort5]> {
1096  let Latency = 9;
1097  let NumMicroOps = 20;
1098  let ResourceCycles = [2];
1099}
1100def: InstRW<[SBWriteResGroupVzeroall], (instrs VZEROALL)>;
1101
1102def SBWriteResGroupVzeroupper : SchedWriteRes<[]> {
1103  let Latency = 1;
1104  let NumMicroOps = 4;
1105  let ResourceCycles = [];
1106}
1107def: InstRW<[SBWriteResGroupVzeroupper], (instrs VZEROUPPER)>;
1108
1109def: InstRW<[WriteZero], (instrs CLC)>;
1110
1111// Instruction variants handled by the renamer. These might not need execution
1112// ports in certain conditions.
1113// See Agner's Fog "The microarchitecture of Intel, AMD and VIA CPUs",
1114// section "Sandy Bridge and Ivy Bridge Pipeline" > "Register allocation and
1115// renaming".
1116// These can be investigated with llvm-exegesis, e.g.
1117// echo 'pxor %mm0, %mm0' | /tmp/llvm-exegesis -mode=uops -snippets-file=-
1118// echo 'vxorpd %xmm0, %xmm0, %xmm1' | /tmp/llvm-exegesis -mode=uops -snippets-file=-
1119
1120def SBWriteZeroLatency : SchedWriteRes<[]> {
1121  let Latency = 0;
1122}
1123
1124def SBWriteZeroIdiom : SchedWriteVariant<[
1125    SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1126    SchedVar<NoSchedPred,                          [WriteALU]>
1127]>;
1128def : InstRW<[SBWriteZeroIdiom], (instrs SUB32rr, SUB64rr,
1129                                         XOR32rr, XOR64rr)>;
1130
1131def SBWriteFZeroIdiom : SchedWriteVariant<[
1132    SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1133    SchedVar<NoSchedPred,                          [WriteFLogic]>
1134]>;
1135def : InstRW<[SBWriteFZeroIdiom], (instrs XORPSrr, VXORPSrr, XORPDrr,
1136                                          VXORPDrr)>;
1137
1138def SBWriteFZeroIdiomY : SchedWriteVariant<[
1139    SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1140    SchedVar<NoSchedPred,                          [WriteFLogicY]>
1141]>;
1142def : InstRW<[SBWriteFZeroIdiomY], (instrs VXORPSYrr, VXORPDYrr)>;
1143
1144def SBWriteVZeroIdiomLogicX : SchedWriteVariant<[
1145    SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1146    SchedVar<NoSchedPred,                          [WriteVecLogicX]>
1147]>;
1148def : InstRW<[SBWriteVZeroIdiomLogicX], (instrs PXORrr, VPXORrr)>;
1149
1150def SBWriteVZeroIdiomALUX : SchedWriteVariant<[
1151    SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1152    SchedVar<NoSchedPred,                          [WriteVecALUX]>
1153]>;
1154def : InstRW<[SBWriteVZeroIdiomALUX], (instrs PSUBBrr, VPSUBBrr,
1155                                              PSUBDrr, VPSUBDrr,
1156                                              PSUBQrr, VPSUBQrr,
1157                                              PSUBWrr, VPSUBWrr,
1158                                              PCMPGTBrr, VPCMPGTBrr,
1159                                              PCMPGTDrr, VPCMPGTDrr,
1160                                              PCMPGTWrr, VPCMPGTWrr)>;
1161
1162def SBWritePCMPGTQ : SchedWriteRes<[SBPort0]> {
1163  let Latency = 5;
1164  let NumMicroOps = 1;
1165  let ResourceCycles = [1];
1166}
1167
1168def SBWriteVZeroIdiomPCMPGTQ : SchedWriteVariant<[
1169    SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1170    SchedVar<NoSchedPred,                          [SBWritePCMPGTQ]>
1171]>;
1172def : InstRW<[SBWriteVZeroIdiomPCMPGTQ], (instrs PCMPGTQrr, VPCMPGTQrr)>;
1173
1174// CMOVs that use both Z and C flag require an extra uop.
1175def SBWriteCMOVA_CMOVBErr : SchedWriteRes<[SBPort05,SBPort015]> {
1176  let Latency = 3;
1177  let ResourceCycles = [2,1];
1178  let NumMicroOps = 3;
1179}
1180
1181def SBWriteCMOVA_CMOVBErm : SchedWriteRes<[SBPort23,SBPort05,SBPort015]> {
1182  let Latency = 8;
1183  let ResourceCycles = [1,2,1];
1184  let NumMicroOps = 4;
1185}
1186
1187def SBCMOVA_CMOVBErr :  SchedWriteVariant<[
1188  SchedVar<MCSchedPredicate<IsCMOVArr_Or_CMOVBErr>, [SBWriteCMOVA_CMOVBErr]>,
1189  SchedVar<NoSchedPred,                             [WriteCMOV]>
1190]>;
1191
1192def SBCMOVA_CMOVBErm :  SchedWriteVariant<[
1193  SchedVar<MCSchedPredicate<IsCMOVArm_Or_CMOVBErm>, [SBWriteCMOVA_CMOVBErm]>,
1194  SchedVar<NoSchedPred,                             [WriteCMOV.Folded]>
1195]>;
1196
1197def : InstRW<[SBCMOVA_CMOVBErr], (instrs CMOV16rr, CMOV32rr, CMOV64rr)>;
1198def : InstRW<[SBCMOVA_CMOVBErm], (instrs CMOV16rm, CMOV32rm, CMOV64rm)>;
1199
1200// SETCCs that use both Z and C flag require an extra uop.
1201def SBWriteSETA_SETBEr : SchedWriteRes<[SBPort05]> {
1202  let Latency = 2;
1203  let ResourceCycles = [2];
1204  let NumMicroOps = 2;
1205}
1206
1207def SBWriteSETA_SETBEm : SchedWriteRes<[SBPort4,SBPort23,SBPort05]> {
1208  let Latency = 3;
1209  let ResourceCycles = [1,1,2];
1210  let NumMicroOps = 4;
1211}
1212
1213def SBSETA_SETBErr :  SchedWriteVariant<[
1214  SchedVar<MCSchedPredicate<IsSETAr_Or_SETBEr>, [SBWriteSETA_SETBEr]>,
1215  SchedVar<NoSchedPred,                         [WriteSETCC]>
1216]>;
1217
1218def SBSETA_SETBErm :  SchedWriteVariant<[
1219  SchedVar<MCSchedPredicate<IsSETAm_Or_SETBEm>, [SBWriteSETA_SETBEm]>,
1220  SchedVar<NoSchedPred,                         [WriteSETCCStore]>
1221]>;
1222
1223def : InstRW<[SBSETA_SETBErr], (instrs SETCCr)>;
1224def : InstRW<[SBSETA_SETBErm], (instrs SETCCm)>;
1225
1226} // SchedModel
1227