1 //=- X86SchedSandyBridge.td - X86 Sandy Bridge Scheduling ----*- tablegen -*-=//
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
7 //===----------------------------------------------------------------------===//
9 // This file defines the machine model for Sandy Bridge to support instruction
10 // scheduling and other instruction cost heuristics.
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`.
16 //===----------------------------------------------------------------------===//
18 def 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.
23 let MicroOpBufferSize = 168; // Based on the reorder buffer.
25 let MispredictPenalty = 16;
27 // Based on the LSD (loop-stream detector) queue size.
28 let LoopMicroOpBufferSize = 28;
30 // This flag is set to allow the scheduler to assign
31 // a default model to unrecognized opcodes.
32 let CompleteModel = 0;
35 let SchedModel = SandyBridgeModel in {
37 // Sandy Bridge can issue micro-ops to 6 different ports in one cycle.
39 // Ports 0, 1, and 5 handle all computation.
40 def SBPort0 : ProcResource<1>;
41 def SBPort1 : ProcResource<1>;
42 def SBPort5 : ProcResource<1>;
44 // Ports 2 and 3 are identical. They handle loads and the address half of
46 def SBPort23 : ProcResource<2>;
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
51 def SBPort4 : ProcResource<1>;
53 // Many micro-ops are capable of issuing on multiple ports.
54 def SBPort01 : ProcResGroup<[SBPort0, SBPort1]>;
55 def SBPort05 : ProcResGroup<[SBPort0, SBPort5]>;
56 def SBPort15 : ProcResGroup<[SBPort1, SBPort5]>;
57 def SBPort015 : ProcResGroup<[SBPort0, SBPort1, SBPort5]>;
59 // 54 Entry Unified Scheduler
60 def SBPortAny : ProcResGroup<[SBPort0, SBPort1, SBPort23, SBPort4, SBPort5]> {
64 // Integer division issued on port 0.
65 def SBDivider : ProcResource<1>;
66 // FP division and sqrt on port 0.
67 def SBFPDivider : ProcResource<1>;
69 // Integer loads are 5 cycles, so ReadAfterLd registers needn't be available until 5
70 // cycles after the memory operand.
71 def : ReadAdvance<ReadAfterLd, 5>;
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.
75 def : ReadAdvance<ReadAfterVecLd, 5>;
76 def : ReadAdvance<ReadAfterVecXLd, 6>;
77 def : ReadAdvance<ReadAfterVecYLd, 7>;
79 def : ReadAdvance<ReadInt2Fpu, 0>;
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
86 multiclass SBWriteResPair<X86FoldableSchedWrite SchedRW,
87 list<ProcResourceKind> ExePorts,
88 int Lat, list<int> Res = [1], int UOps = 1,
90 // Register variant is using a single cycle on ExePort.
91 def : WriteRes<SchedRW, ExePorts> {
93 let ResourceCycles = Res;
94 let NumMicroOps = UOps;
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);
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.
108 def : WriteRes<WriteRMW, [SBPort23,SBPort4]>;
110 def : WriteRes<WriteStore, [SBPort23, SBPort4]>;
111 def : WriteRes<WriteStoreNT, [SBPort23, SBPort4]>;
112 def : WriteRes<WriteLoad, [SBPort23]> { let Latency = 5; }
113 def : WriteRes<WriteMove, [SBPort015]>;
114 def : WriteRes<WriteZero, []>;
117 defm : SBWriteResPair<WriteALU, [SBPort015], 1>;
118 defm : SBWriteResPair<WriteADC, [SBPort05,SBPort015], 2, [1,1], 2>;
120 defm : SBWriteResPair<WriteIMul8, [SBPort1], 3>;
121 defm : SBWriteResPair<WriteIMul16, [SBPort1,SBPort05,SBPort015], 4, [1,1,2], 4>;
122 defm : X86WriteRes<WriteIMul16Imm, [SBPort1,SBPort015], 4, [1,1], 2>;
123 defm : X86WriteRes<WriteIMul16ImmLd, [SBPort1,SBPort015,SBPort23], 8, [1,1,1], 3>;
124 defm : SBWriteResPair<WriteIMul16Reg, [SBPort1], 3>;
125 defm : SBWriteResPair<WriteIMul32, [SBPort1,SBPort05,SBPort015], 4, [1,1,1], 3>;
126 defm : SBWriteResPair<WriteIMul32Imm, [SBPort1], 3>;
127 defm : SBWriteResPair<WriteIMul32Reg, [SBPort1], 3>;
128 defm : SBWriteResPair<WriteIMul64, [SBPort1,SBPort0], 4, [1,1], 2>;
129 defm : SBWriteResPair<WriteIMul64Imm, [SBPort1], 3>;
130 defm : SBWriteResPair<WriteIMul64Reg, [SBPort1], 3>;
131 def : WriteRes<WriteIMulH, []> { let Latency = 3; }
133 defm : X86WriteRes<WriteXCHG, [SBPort015], 2, [3], 3>;
134 defm : X86WriteRes<WriteBSWAP32, [SBPort1], 1, [1], 1>;
135 defm : X86WriteRes<WriteBSWAP64, [SBPort1, SBPort05], 2, [1,1], 2>;
136 defm : X86WriteRes<WriteCMPXCHG, [SBPort05, SBPort015], 5, [1,3], 4>;
137 defm : X86WriteRes<WriteCMPXCHGRMW,[SBPort015, SBPort5, SBPort23, SBPort4], 8, [1, 2, 2, 1], 6>;
139 defm : SBWriteResPair<WriteDiv8, [SBPort0, SBDivider], 25, [1, 10]>;
140 defm : SBWriteResPair<WriteDiv16, [SBPort0, SBDivider], 25, [1, 10]>;
141 defm : SBWriteResPair<WriteDiv32, [SBPort0, SBDivider], 25, [1, 10]>;
142 defm : SBWriteResPair<WriteDiv64, [SBPort0, SBDivider], 25, [1, 10]>;
143 defm : SBWriteResPair<WriteIDiv8, [SBPort0, SBDivider], 25, [1, 10]>;
144 defm : SBWriteResPair<WriteIDiv16, [SBPort0, SBDivider], 25, [1, 10]>;
145 defm : SBWriteResPair<WriteIDiv32, [SBPort0, SBDivider], 25, [1, 10]>;
146 defm : SBWriteResPair<WriteIDiv64, [SBPort0, SBDivider], 25, [1, 10]>;
149 defm : X86WriteRes<WriteSHDrri, [SBPort05, SBPort015], 2, [1, 1], 2>;
150 defm : X86WriteRes<WriteSHDrrcl,[SBPort05, SBPort015], 4, [3, 1], 4>;
151 defm : X86WriteRes<WriteSHDmri, [SBPort4,SBPort23,SBPort05,SBPort015], 8, [1, 2, 1, 1], 5>;
152 defm : X86WriteRes<WriteSHDmrcl,[SBPort4,SBPort23,SBPort05,SBPort015], 10, [1, 2, 3, 1], 7>;
154 defm : SBWriteResPair<WriteShift, [SBPort05], 1>;
155 defm : SBWriteResPair<WriteShiftCL, [SBPort05], 3, [3], 3>;
156 defm : SBWriteResPair<WriteRotate, [SBPort05], 2, [2], 2>;
157 defm : SBWriteResPair<WriteRotateCL, [SBPort05], 3, [3], 3>;
159 defm : SBWriteResPair<WriteJump, [SBPort5], 1>;
160 defm : SBWriteResPair<WriteCRC32, [SBPort1], 3, [1], 1, 5>;
162 defm : SBWriteResPair<WriteCMOV, [SBPort05,SBPort015], 2, [1,1], 2>; // Conditional move.
163 defm : X86WriteRes<WriteFCMOV, [SBPort5,SBPort05], 3, [2,1], 3>; // x87 conditional move.
164 def : WriteRes<WriteSETCC, [SBPort05]>; // Setcc.
165 def : WriteRes<WriteSETCCStore, [SBPort05,SBPort4,SBPort23]> {
170 defm : X86WriteRes<WriteLAHFSAHF, [SBPort05], 1, [1], 1>;
171 defm : X86WriteRes<WriteBitTest, [SBPort05], 1, [1], 1>;
172 defm : X86WriteRes<WriteBitTestImmLd, [SBPort05,SBPort23], 6, [1,1], 2>;
173 //defm : X86WriteRes<WriteBitTestRegLd, [SBPort05,SBPort23], 6, [1,1], 2>;
174 defm : X86WriteRes<WriteBitTestSet, [SBPort05], 1, [1], 1>;
175 defm : X86WriteRes<WriteBitTestSetImmLd, [SBPort05,SBPort23], 6, [1,1], 3>;
176 defm : X86WriteRes<WriteBitTestSetRegLd, [SBPort05,SBPort23,SBPort5,SBPort015], 8, [1,1,1,1], 5>;
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.
181 def : WriteRes<WriteLEA, [SBPort01]>;
184 defm : SBWriteResPair<WriteBSF, [SBPort1], 3, [1], 1, 5>;
185 defm : SBWriteResPair<WriteBSR, [SBPort1], 3, [1], 1, 5>;
186 defm : SBWriteResPair<WriteLZCNT, [SBPort1], 3, [1], 1, 5>;
187 defm : SBWriteResPair<WriteTZCNT, [SBPort1], 3, [1], 1, 5>;
188 defm : SBWriteResPair<WritePOPCNT, [SBPort1], 3, [1], 1, 6>;
190 // BMI1 BEXTR/BLS, BMI2 BZHI
191 // NOTE: These don't exist on Sandy Bridge. Ports are guesses.
192 defm : SBWriteResPair<WriteBEXTR, [SBPort05,SBPort1], 2, [1,1], 2>;
193 defm : SBWriteResPair<WriteBLS, [SBPort015], 1>;
194 defm : SBWriteResPair<WriteBZHI, [SBPort1], 1>;
196 // Scalar and vector floating point.
197 defm : X86WriteRes<WriteFLD0, [SBPort5], 1, [1], 1>;
198 defm : X86WriteRes<WriteFLD1, [SBPort0,SBPort5], 1, [1,1], 2>;
199 defm : X86WriteRes<WriteFLDC, [SBPort0,SBPort1], 1, [1,1], 2>;
200 defm : X86WriteRes<WriteFLoad, [SBPort23], 5, [1], 1>;
201 defm : X86WriteRes<WriteFLoadX, [SBPort23], 6, [1], 1>;
202 defm : X86WriteRes<WriteFLoadY, [SBPort23], 7, [1], 1>;
203 defm : X86WriteRes<WriteFMaskedLoad, [SBPort23,SBPort05], 8, [1,2], 3>;
204 defm : X86WriteRes<WriteFMaskedLoadY, [SBPort23,SBPort05], 9, [1,2], 3>;
205 defm : X86WriteRes<WriteFStore, [SBPort23,SBPort4], 1, [1,1], 1>;
206 defm : X86WriteRes<WriteFStoreX, [SBPort23,SBPort4], 1, [1,1], 1>;
207 defm : X86WriteRes<WriteFStoreY, [SBPort23,SBPort4], 1, [1,1], 1>;
208 defm : X86WriteRes<WriteFStoreNT, [SBPort23,SBPort4], 1, [1,1], 1>;
209 defm : X86WriteRes<WriteFStoreNTX, [SBPort23,SBPort4], 1, [1,1], 1>;
210 defm : X86WriteRes<WriteFStoreNTY, [SBPort23,SBPort4], 1, [1,1], 1>;
212 defm : X86WriteRes<WriteFMaskedStore32, [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
213 defm : X86WriteRes<WriteFMaskedStore32Y, [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
214 defm : X86WriteRes<WriteFMaskedStore64, [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
215 defm : X86WriteRes<WriteFMaskedStore64Y, [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
217 defm : X86WriteRes<WriteFMove, [SBPort5], 1, [1], 1>;
218 defm : X86WriteRes<WriteFMoveX, [SBPort5], 1, [1], 1>;
219 defm : X86WriteRes<WriteFMoveY, [SBPort5], 1, [1], 1>;
220 defm : X86WriteRes<WriteEMMS, [SBPort015], 31, [31], 31>;
222 defm : SBWriteResPair<WriteFAdd, [SBPort1], 3, [1], 1, 6>;
223 defm : SBWriteResPair<WriteFAddX, [SBPort1], 3, [1], 1, 6>;
224 defm : SBWriteResPair<WriteFAddY, [SBPort1], 3, [1], 1, 7>;
225 defm : SBWriteResPair<WriteFAddZ, [SBPort1], 3, [1], 1, 7>; // Unsupported = 1
226 defm : SBWriteResPair<WriteFAdd64, [SBPort1], 3, [1], 1, 6>;
227 defm : SBWriteResPair<WriteFAdd64X, [SBPort1], 3, [1], 1, 6>;
228 defm : SBWriteResPair<WriteFAdd64Y, [SBPort1], 3, [1], 1, 7>;
229 defm : SBWriteResPair<WriteFAdd64Z, [SBPort1], 3, [1], 1, 7>; // Unsupported = 1
231 defm : SBWriteResPair<WriteFCmp, [SBPort1], 3, [1], 1, 6>;
232 defm : SBWriteResPair<WriteFCmpX, [SBPort1], 3, [1], 1, 6>;
233 defm : SBWriteResPair<WriteFCmpY, [SBPort1], 3, [1], 1, 7>;
234 defm : SBWriteResPair<WriteFCmpZ, [SBPort1], 3, [1], 1, 7>; // Unsupported = 1
235 defm : SBWriteResPair<WriteFCmp64, [SBPort1], 3, [1], 1, 6>;
236 defm : SBWriteResPair<WriteFCmp64X, [SBPort1], 3, [1], 1, 6>;
237 defm : SBWriteResPair<WriteFCmp64Y, [SBPort1], 3, [1], 1, 7>;
238 defm : SBWriteResPair<WriteFCmp64Z, [SBPort1], 3, [1], 1, 7>; // Unsupported = 1
240 defm : SBWriteResPair<WriteFCom, [SBPort1], 3>;
242 defm : SBWriteResPair<WriteFMul, [SBPort0], 5, [1], 1, 6>;
243 defm : SBWriteResPair<WriteFMulX, [SBPort0], 5, [1], 1, 6>;
244 defm : SBWriteResPair<WriteFMulY, [SBPort0], 5, [1], 1, 7>;
245 defm : SBWriteResPair<WriteFMulZ, [SBPort0], 5, [1], 1, 7>; // Unsupported = 1
246 defm : SBWriteResPair<WriteFMul64, [SBPort0], 5, [1], 1, 6>;
247 defm : SBWriteResPair<WriteFMul64X, [SBPort0], 5, [1], 1, 6>;
248 defm : SBWriteResPair<WriteFMul64Y, [SBPort0], 5, [1], 1, 7>;
249 defm : SBWriteResPair<WriteFMul64Z, [SBPort0], 5, [1], 1, 7>; // Unsupported = 1
251 defm : SBWriteResPair<WriteFDiv, [SBPort0,SBFPDivider], 14, [1,14], 1, 6>;
252 defm : SBWriteResPair<WriteFDivX, [SBPort0,SBFPDivider], 14, [1,14], 1, 6>;
253 defm : SBWriteResPair<WriteFDivY, [SBPort0,SBPort05,SBFPDivider], 29, [2,1,28], 3, 7>;
254 defm : SBWriteResPair<WriteFDivZ, [SBPort0,SBPort05,SBFPDivider], 29, [2,1,28], 3, 7>; // Unsupported = 1
255 defm : SBWriteResPair<WriteFDiv64, [SBPort0,SBFPDivider], 22, [1,22], 1, 6>;
256 defm : SBWriteResPair<WriteFDiv64X, [SBPort0,SBFPDivider], 22, [1,22], 1, 6>;
257 defm : SBWriteResPair<WriteFDiv64Y, [SBPort0,SBPort05,SBFPDivider], 45, [2,1,44], 3, 7>;
258 defm : SBWriteResPair<WriteFDiv64Z, [SBPort0,SBPort05,SBFPDivider], 45, [2,1,44], 3, 7>; // Unsupported = 1
260 defm : SBWriteResPair<WriteFRcp, [SBPort0], 5, [1], 1, 6>;
261 defm : SBWriteResPair<WriteFRcpX, [SBPort0], 5, [1], 1, 6>;
262 defm : SBWriteResPair<WriteFRcpY, [SBPort0,SBPort05], 7, [2,1], 3, 7>;
263 defm : SBWriteResPair<WriteFRcpZ, [SBPort0,SBPort05], 7, [2,1], 3, 7>; // Unsupported = 1
265 defm : SBWriteResPair<WriteFRsqrt, [SBPort0], 5, [1], 1, 6>;
266 defm : SBWriteResPair<WriteFRsqrtX,[SBPort0], 5, [1], 1, 6>;
267 defm : SBWriteResPair<WriteFRsqrtY,[SBPort0,SBPort05], 7, [2,1], 3, 7>;
268 defm : SBWriteResPair<WriteFRsqrtZ,[SBPort0,SBPort05], 7, [2,1], 3, 7>; // Unsupported = 1
270 defm : SBWriteResPair<WriteFSqrt, [SBPort0,SBFPDivider], 14, [1,14], 1, 6>;
271 defm : SBWriteResPair<WriteFSqrtX, [SBPort0,SBFPDivider], 14, [1,14], 1, 6>;
272 defm : SBWriteResPair<WriteFSqrtY, [SBPort0,SBPort05,SBFPDivider], 29, [2,1,28], 3, 7>;
273 defm : SBWriteResPair<WriteFSqrtZ, [SBPort0,SBPort05,SBFPDivider], 29, [2,1,28], 3, 7>; // Unsupported = 1
274 defm : SBWriteResPair<WriteFSqrt64, [SBPort0,SBFPDivider], 21, [1,21], 1, 6>;
275 defm : SBWriteResPair<WriteFSqrt64X, [SBPort0,SBFPDivider], 21, [1,21], 1, 6>;
276 defm : SBWriteResPair<WriteFSqrt64Y, [SBPort0,SBPort05,SBFPDivider], 45, [2,1,44], 3, 7>;
277 defm : SBWriteResPair<WriteFSqrt64Z, [SBPort0,SBPort05,SBFPDivider], 45, [2,1,44], 3, 7>; // Unsupported = 1
278 defm : SBWriteResPair<WriteFSqrt80, [SBPort0,SBFPDivider], 24, [1,24], 1, 6>;
280 defm : SBWriteResPair<WriteDPPD, [SBPort0,SBPort1,SBPort5], 9, [1,1,1], 3, 6>;
281 defm : SBWriteResPair<WriteDPPS, [SBPort0,SBPort1,SBPort5], 12, [1,2,1], 4, 6>;
282 defm : SBWriteResPair<WriteDPPSY, [SBPort0,SBPort1,SBPort5], 12, [1,2,1], 4, 7>;
283 defm : SBWriteResPair<WriteDPPSZ, [SBPort0,SBPort1,SBPort5], 12, [1,2,1], 4, 7>; // Unsupported = 1
284 defm : SBWriteResPair<WriteFSign, [SBPort5], 1>;
285 defm : SBWriteResPair<WriteFRnd, [SBPort1], 3, [1], 1, 6>;
286 defm : SBWriteResPair<WriteFRndY, [SBPort1], 3, [1], 1, 7>;
287 defm : SBWriteResPair<WriteFRndZ, [SBPort1], 3, [1], 1, 7>; // Unsupported = 1
288 defm : SBWriteResPair<WriteFLogic, [SBPort5], 1, [1], 1, 6>;
289 defm : SBWriteResPair<WriteFLogicY, [SBPort5], 1, [1], 1, 7>;
290 defm : SBWriteResPair<WriteFLogicZ, [SBPort5], 1, [1], 1, 7>; // Unsupported = 1
291 defm : SBWriteResPair<WriteFTest, [SBPort0], 1, [1], 1, 6>;
292 defm : SBWriteResPair<WriteFTestY, [SBPort0], 1, [1], 1, 7>;
293 defm : SBWriteResPair<WriteFTestZ, [SBPort0], 1, [1], 1, 7>; // Unsupported = 1
294 defm : SBWriteResPair<WriteFShuffle, [SBPort5], 1, [1], 1, 6>;
295 defm : SBWriteResPair<WriteFShuffleY,[SBPort5], 1, [1], 1, 7>;
296 defm : SBWriteResPair<WriteFShuffleZ,[SBPort5], 1, [1], 1, 7>; // Unsupported = 1
297 defm : SBWriteResPair<WriteFVarShuffle, [SBPort5], 1, [1], 1, 6>;
298 defm : SBWriteResPair<WriteFVarShuffleY,[SBPort5], 1, [1], 1, 7>;
299 defm : SBWriteResPair<WriteFVarShuffleZ,[SBPort5], 1, [1], 1, 7>; // Unsupported = 1
300 defm : SBWriteResPair<WriteFBlend, [SBPort05], 1, [1], 1, 6>;
301 defm : SBWriteResPair<WriteFBlendY, [SBPort05], 1, [1], 1, 7>;
302 defm : SBWriteResPair<WriteFBlendZ, [SBPort05], 1, [1], 1, 7>; // Unsupported = 1
303 defm : SBWriteResPair<WriteFVarBlend, [SBPort05], 2, [2], 2, 6>;
304 defm : SBWriteResPair<WriteFVarBlendY,[SBPort05], 2, [2], 2, 7>;
305 defm : SBWriteResPair<WriteFVarBlendZ,[SBPort05], 2, [2], 2, 7>; // Unsupported = 1
307 // Conversion between integer and float.
308 defm : SBWriteResPair<WriteCvtSS2I, [SBPort0,SBPort1], 5, [1,1], 2>;
309 defm : SBWriteResPair<WriteCvtPS2I, [SBPort1], 3, [1], 1, 6>;
310 defm : SBWriteResPair<WriteCvtPS2IY, [SBPort1], 3, [1], 1, 7>;
311 defm : SBWriteResPair<WriteCvtPS2IZ, [SBPort1], 3, [1], 1, 7>; // Unsupported = 1
312 defm : SBWriteResPair<WriteCvtSD2I, [SBPort0,SBPort1], 5, [1,1], 2>;
313 defm : SBWriteResPair<WriteCvtPD2I, [SBPort1,SBPort5], 4, [1,1], 2, 6>;
314 defm : X86WriteRes<WriteCvtPD2IY, [SBPort1,SBPort5], 4, [1,1], 2>;
315 defm : X86WriteRes<WriteCvtPD2IZ, [SBPort1,SBPort5], 4, [1,1], 2>; // Unsupported = 1
316 defm : X86WriteRes<WriteCvtPD2IYLd, [SBPort1,SBPort5,SBPort23], 11, [1,1,1], 3>;
317 defm : X86WriteRes<WriteCvtPD2IZLd, [SBPort1,SBPort5,SBPort23], 11, [1,1,1], 3>; // Unsupported = 1
319 defm : X86WriteRes<WriteCvtI2SS, [SBPort1,SBPort5], 5, [1,2], 3>;
320 defm : X86WriteRes<WriteCvtI2SSLd, [SBPort1,SBPort5,SBPort23], 10, [1,1,1], 3>;
321 defm : SBWriteResPair<WriteCvtI2PS, [SBPort1], 3, [1], 1, 6>;
322 defm : SBWriteResPair<WriteCvtI2PSY, [SBPort1], 3, [1], 1, 7>;
323 defm : SBWriteResPair<WriteCvtI2PSZ, [SBPort1], 3, [1], 1, 7>; // Unsupported = 1
324 defm : X86WriteRes<WriteCvtI2SD, [SBPort1,SBPort5], 4, [1,1], 2>;
325 defm : X86WriteRes<WriteCvtI2PD, [SBPort1,SBPort5], 4, [1,1], 2>;
326 defm : X86WriteRes<WriteCvtI2PDY, [SBPort1,SBPort5], 4, [1,1], 2>;
327 defm : X86WriteRes<WriteCvtI2PDZ, [SBPort1,SBPort5], 4, [1,1], 2>; // Unsupported = 1
328 defm : X86WriteRes<WriteCvtI2SDLd, [SBPort1,SBPort23], 9, [1,1], 2>;
329 defm : X86WriteRes<WriteCvtI2PDLd, [SBPort1,SBPort5,SBPort23], 10, [1,1,1], 3>;
330 defm : X86WriteRes<WriteCvtI2PDYLd, [SBPort1,SBPort5,SBPort23], 10, [1,1,1], 3>;
331 defm : X86WriteRes<WriteCvtI2PDZLd, [SBPort1,SBPort5,SBPort23], 10, [1,1,1], 3>; // Unsupported = 1
333 defm : SBWriteResPair<WriteCvtSS2SD, [SBPort0], 1, [1], 1, 6>;
334 defm : X86WriteRes<WriteCvtPS2PD, [SBPort0,SBPort5], 2, [1,1], 2>;
335 defm : X86WriteRes<WriteCvtPS2PDY, [SBPort0,SBPort5], 2, [1,1], 2>;
336 defm : X86WriteRes<WriteCvtPS2PDZ, [SBPort0,SBPort5], 2, [1,1], 2>; // Unsupported = 1
337 defm : X86WriteRes<WriteCvtPS2PDLd, [SBPort0,SBPort23], 7, [1,1], 2>;
338 defm : X86WriteRes<WriteCvtPS2PDYLd, [SBPort0,SBPort23], 7, [1,1], 2>;
339 defm : X86WriteRes<WriteCvtPS2PDZLd, [SBPort0,SBPort23], 7, [1,1], 2>; // Unsupported = 1
340 defm : SBWriteResPair<WriteCvtSD2SS, [SBPort1,SBPort5], 4, [1,1], 2, 6>;
341 defm : SBWriteResPair<WriteCvtPD2PS, [SBPort1,SBPort5], 4, [1,1], 2, 6>;
342 defm : SBWriteResPair<WriteCvtPD2PSY, [SBPort1,SBPort5], 4, [1,1], 2, 7>;
343 defm : SBWriteResPair<WriteCvtPD2PSZ, [SBPort1,SBPort5], 4, [1,1], 2, 7>; // Unsupported = 1
345 defm : SBWriteResPair<WriteCvtPH2PS, [SBPort1], 3>;
346 defm : SBWriteResPair<WriteCvtPH2PSY, [SBPort1], 3>;
347 defm : SBWriteResPair<WriteCvtPH2PSZ, [SBPort1], 3>; // Unsupported = 1
349 defm : X86WriteRes<WriteCvtPS2PH, [SBPort1], 3, [1], 1>;
350 defm : X86WriteRes<WriteCvtPS2PHY, [SBPort1], 3, [1], 1>;
351 defm : X86WriteRes<WriteCvtPS2PHZ, [SBPort1], 3, [1], 1>; // Unsupported = 1
352 defm : X86WriteRes<WriteCvtPS2PHSt, [SBPort1, SBPort23, SBPort4], 4, [1,1,1], 1>;
353 defm : X86WriteRes<WriteCvtPS2PHYSt, [SBPort1, SBPort23, SBPort4], 4, [1,1,1], 1>;
354 defm : X86WriteRes<WriteCvtPS2PHZSt, [SBPort1, SBPort23, SBPort4], 4, [1,1,1], 1>; // Unsupported = 1
356 // Vector integer operations.
357 defm : X86WriteRes<WriteVecLoad, [SBPort23], 5, [1], 1>;
358 defm : X86WriteRes<WriteVecLoadX, [SBPort23], 6, [1], 1>;
359 defm : X86WriteRes<WriteVecLoadY, [SBPort23], 7, [1], 1>;
360 defm : X86WriteRes<WriteVecLoadNT, [SBPort23], 6, [1], 1>;
361 defm : X86WriteRes<WriteVecLoadNTY, [SBPort23], 7, [1], 1>;
362 defm : X86WriteRes<WriteVecMaskedLoad, [SBPort23,SBPort05], 8, [1,2], 3>;
363 defm : X86WriteRes<WriteVecMaskedLoadY, [SBPort23,SBPort05], 9, [1,2], 3>;
364 defm : X86WriteRes<WriteVecStore, [SBPort23,SBPort4], 1, [1,1], 1>;
365 defm : X86WriteRes<WriteVecStoreX, [SBPort23,SBPort4], 1, [1,1], 1>;
366 defm : X86WriteRes<WriteVecStoreY, [SBPort23,SBPort4], 1, [1,1], 1>;
367 defm : X86WriteRes<WriteVecStoreNT, [SBPort23,SBPort4], 1, [1,1], 1>;
368 defm : X86WriteRes<WriteVecStoreNTY, [SBPort23,SBPort4], 1, [1,1], 1>;
369 defm : X86WriteRes<WriteVecMaskedStore, [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
370 defm : X86WriteRes<WriteVecMaskedStoreY, [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
371 defm : X86WriteRes<WriteVecMove, [SBPort05], 1, [1], 1>;
372 defm : X86WriteRes<WriteVecMoveX, [SBPort015], 1, [1], 1>;
373 defm : X86WriteRes<WriteVecMoveY, [SBPort05], 1, [1], 1>;
374 defm : X86WriteRes<WriteVecMoveToGpr, [SBPort0], 2, [1], 1>;
375 defm : X86WriteRes<WriteVecMoveFromGpr, [SBPort5], 1, [1], 1>;
377 defm : SBWriteResPair<WriteVecLogic, [SBPort015], 1, [1], 1, 5>;
378 defm : SBWriteResPair<WriteVecLogicX,[SBPort015], 1, [1], 1, 6>;
379 defm : SBWriteResPair<WriteVecLogicY,[SBPort015], 1, [1], 1, 7>;
380 defm : SBWriteResPair<WriteVecLogicZ,[SBPort015], 1, [1], 1, 7>; // Unsupported = 1
381 defm : SBWriteResPair<WriteVecTest, [SBPort0,SBPort5], 2, [1,1], 2, 6>;
382 defm : SBWriteResPair<WriteVecTestY, [SBPort0,SBPort5], 2, [1,1], 2, 7>;
383 defm : SBWriteResPair<WriteVecTestZ, [SBPort0,SBPort5], 2, [1,1], 2, 7>; // Unsupported = 1
384 defm : SBWriteResPair<WriteVecALU, [SBPort1], 3, [1], 1, 5>;
385 defm : SBWriteResPair<WriteVecALUX, [SBPort15], 1, [1], 1, 6>;
386 defm : SBWriteResPair<WriteVecALUY, [SBPort15], 1, [1], 1, 7>;
387 defm : SBWriteResPair<WriteVecALUZ, [SBPort15], 1, [1], 1, 7>; // Unsupported = 1
388 defm : SBWriteResPair<WriteVecIMul, [SBPort0], 5, [1], 1, 5>;
389 defm : SBWriteResPair<WriteVecIMulX, [SBPort0], 5, [1], 1, 6>;
390 defm : SBWriteResPair<WriteVecIMulY, [SBPort0], 5, [1], 1, 7>;
391 defm : SBWriteResPair<WriteVecIMulZ, [SBPort0], 5, [1], 1, 7>; // Unsupported = 1
392 defm : SBWriteResPair<WritePMULLD, [SBPort0], 5, [1], 1, 6>;
393 defm : SBWriteResPair<WritePMULLDY, [SBPort0], 5, [1], 1, 7>; // TODO this is probably wrong for 256/512-bit for the "generic" model
394 defm : SBWriteResPair<WritePMULLDZ, [SBPort0], 5, [1], 1, 7>; // Unsupported = 1
395 defm : SBWriteResPair<WriteShuffle, [SBPort5], 1, [1], 1, 5>;
396 defm : SBWriteResPair<WriteShuffleX, [SBPort15], 1, [1], 1, 6>;
397 defm : SBWriteResPair<WriteShuffleY, [SBPort5], 1, [1], 1, 7>;
398 defm : SBWriteResPair<WriteShuffleZ, [SBPort5], 1, [1], 1, 7>; // Unsupported = 1
399 defm : SBWriteResPair<WriteVarShuffle, [SBPort15], 1, [1], 1, 5>;
400 defm : SBWriteResPair<WriteVarShuffleX, [SBPort15], 1, [1], 1, 6>;
401 defm : SBWriteResPair<WriteVarShuffleY, [SBPort15], 1, [1], 1, 7>;
402 defm : SBWriteResPair<WriteVarShuffleZ, [SBPort15], 1, [1], 1, 7>; // Unsupported = 1
403 defm : SBWriteResPair<WriteBlend, [SBPort15], 1, [1], 1, 6>;
404 defm : SBWriteResPair<WriteBlendY, [SBPort15], 1, [1], 1, 7>;
405 defm : SBWriteResPair<WriteBlendZ, [SBPort15], 1, [1], 1, 7>; // Unsupported = 1
406 defm : SBWriteResPair<WriteVarBlend, [SBPort15], 2, [2], 2, 6>;
407 defm : SBWriteResPair<WriteVarBlendY,[SBPort15], 2, [2], 2, 7>;
408 defm : SBWriteResPair<WriteVarBlendZ,[SBPort15], 2, [2], 2, 7>; // Unsupported = 1
409 defm : SBWriteResPair<WriteMPSAD, [SBPort0, SBPort15], 7, [1,2], 3, 6>;
410 defm : SBWriteResPair<WriteMPSADY, [SBPort0, SBPort15], 7, [1,2], 3, 7>;
411 defm : SBWriteResPair<WriteMPSADZ, [SBPort0, SBPort15], 7, [1,2], 3, 7>; // Unsupported = 1
412 defm : SBWriteResPair<WritePSADBW, [SBPort0], 5, [1], 1, 5>;
413 defm : SBWriteResPair<WritePSADBWX, [SBPort0], 5, [1], 1, 6>;
414 defm : SBWriteResPair<WritePSADBWY, [SBPort0], 5, [1], 1, 7>;
415 defm : SBWriteResPair<WritePSADBWZ, [SBPort0], 5, [1], 1, 7>; // Unsupported = 1
416 defm : SBWriteResPair<WritePHMINPOS, [SBPort0], 5, [1], 1, 6>;
418 // Vector integer shifts.
419 defm : SBWriteResPair<WriteVecShift, [SBPort5], 1, [1], 1, 5>;
420 defm : SBWriteResPair<WriteVecShiftX, [SBPort0,SBPort15], 2, [1,1], 2, 6>;
421 defm : SBWriteResPair<WriteVecShiftY, [SBPort0,SBPort15], 4, [1,1], 2, 7>;
422 defm : SBWriteResPair<WriteVecShiftZ, [SBPort0,SBPort15], 4, [1,1], 2, 7>; // Unsupported = 1
423 defm : SBWriteResPair<WriteVecShiftImm, [SBPort5], 1, [1], 1, 5>;
424 defm : SBWriteResPair<WriteVecShiftImmX, [SBPort0], 1, [1], 1, 6>;
425 defm : SBWriteResPair<WriteVecShiftImmY, [SBPort0], 1, [1], 1, 7>;
426 defm : SBWriteResPair<WriteVecShiftImmZ, [SBPort0], 1, [1], 1, 7>; // Unsupported = 1
427 defm : SBWriteResPair<WriteVarVecShift, [SBPort0], 1, [1], 1, 6>;
428 defm : SBWriteResPair<WriteVarVecShiftY, [SBPort0], 1, [1], 1, 7>;
429 defm : SBWriteResPair<WriteVarVecShiftZ, [SBPort0], 1, [1], 1, 7>; // Unsupported = 1
431 // Vector insert/extract operations.
432 def : WriteRes<WriteVecInsert, [SBPort5,SBPort15]> {
436 def : WriteRes<WriteVecInsertLd, [SBPort23,SBPort15]> {
441 def : WriteRes<WriteVecExtract, [SBPort0,SBPort15]> {
445 def : WriteRes<WriteVecExtractSt, [SBPort4,SBPort23,SBPort15]> {
450 ////////////////////////////////////////////////////////////////////////////////
451 // Horizontal add/sub instructions.
452 ////////////////////////////////////////////////////////////////////////////////
454 defm : SBWriteResPair<WriteFHAdd, [SBPort1,SBPort5], 5, [1,2], 3, 6>;
455 defm : SBWriteResPair<WriteFHAddY, [SBPort1,SBPort5], 5, [1,2], 3, 7>;
456 defm : SBWriteResPair<WriteFHAddZ, [SBPort1,SBPort5], 5, [1,2], 3, 7>; // Unsupported = 1
457 defm : SBWriteResPair<WritePHAdd, [SBPort15], 3, [3], 3, 5>;
458 defm : SBWriteResPair<WritePHAddX, [SBPort15], 3, [3], 3, 6>;
459 defm : SBWriteResPair<WritePHAddY, [SBPort15], 3, [3], 3, 7>;
460 defm : SBWriteResPair<WritePHAddZ, [SBPort15], 3, [3], 3, 7>; // Unsupported = 1
462 ////////////////////////////////////////////////////////////////////////////////
463 // String instructions.
464 ////////////////////////////////////////////////////////////////////////////////
466 // Packed Compare Implicit Length Strings, Return Mask
467 def : WriteRes<WritePCmpIStrM, [SBPort0]> {
470 let ResourceCycles = [3];
472 def : WriteRes<WritePCmpIStrMLd, [SBPort0, SBPort23]> {
475 let ResourceCycles = [3,1];
478 // Packed Compare Explicit Length Strings, Return Mask
479 def : WriteRes<WritePCmpEStrM, [SBPort015]> {
481 let ResourceCycles = [8];
483 def : WriteRes<WritePCmpEStrMLd, [SBPort015, SBPort23]> {
485 let ResourceCycles = [7, 1];
488 // Packed Compare Implicit Length Strings, Return Index
489 def : WriteRes<WritePCmpIStrI, [SBPort0]> {
492 let ResourceCycles = [3];
494 def : WriteRes<WritePCmpIStrILd, [SBPort0,SBPort23]> {
497 let ResourceCycles = [3,1];
500 // Packed Compare Explicit Length Strings, Return Index
501 def : WriteRes<WritePCmpEStrI, [SBPort015]> {
503 let ResourceCycles = [8];
505 def : WriteRes<WritePCmpEStrILd, [SBPort015, SBPort23]> {
507 let ResourceCycles = [7, 1];
510 // MOVMSK Instructions.
511 def : WriteRes<WriteFMOVMSK, [SBPort0]> { let Latency = 2; }
512 def : WriteRes<WriteVecMOVMSK, [SBPort0]> { let Latency = 2; }
513 def : WriteRes<WriteVecMOVMSKY, [SBPort0]> { let Latency = 2; }
514 def : WriteRes<WriteMMXMOVMSK, [SBPort0]> { let Latency = 1; }
517 def : WriteRes<WriteAESDecEnc, [SBPort5,SBPort015]> {
520 let ResourceCycles = [1,1];
522 def : WriteRes<WriteAESDecEncLd, [SBPort5,SBPort23,SBPort015]> {
525 let ResourceCycles = [1,1,1];
528 def : WriteRes<WriteAESIMC, [SBPort5]> {
531 let ResourceCycles = [2];
533 def : WriteRes<WriteAESIMCLd, [SBPort5,SBPort23]> {
536 let ResourceCycles = [2,1];
539 def : WriteRes<WriteAESKeyGen, [SBPort015]> {
541 let ResourceCycles = [11];
543 def : WriteRes<WriteAESKeyGenLd, [SBPort015, SBPort23]> {
545 let ResourceCycles = [10, 1];
548 // Carry-less multiplication instructions.
549 def : WriteRes<WriteCLMul, [SBPort015]> {
551 let ResourceCycles = [18];
553 def : WriteRes<WriteCLMulLd, [SBPort015, SBPort23]> {
555 let ResourceCycles = [17, 1];
559 // FIXME: This is probably wrong. Only STMXCSR should require Port4.
560 def : WriteRes<WriteLDMXCSR, [SBPort0,SBPort4,SBPort5,SBPort23]> { let Latency = 5; let NumMicroOps = 4; let ResourceCycles = [1,1,1,1]; }
561 def : WriteRes<WriteSTMXCSR, [SBPort0,SBPort4,SBPort5,SBPort23]> { let Latency = 5; let NumMicroOps = 4; let ResourceCycles = [1,1,1,1]; }
563 def : WriteRes<WriteSystem, [SBPort015]> { let Latency = 100; }
564 def : WriteRes<WriteMicrocoded, [SBPort015]> { let Latency = 100; }
565 def : WriteRes<WriteFence, [SBPort23, SBPort4]>;
566 def : WriteRes<WriteNop, []>;
568 // AVX2/FMA is not supported on that architecture, but we should define the basic
569 // scheduling resources anyway.
570 defm : SBWriteResPair<WriteFShuffle256, [SBPort5], 1, [1], 1, 7>;
571 defm : SBWriteResPair<WriteFVarShuffle256, [SBPort5], 1, [1], 1, 7>;
572 defm : SBWriteResPair<WriteShuffle256, [SBPort5], 1, [1], 1, 7>;
573 defm : SBWriteResPair<WriteVarShuffle256, [SBPort5], 1, [1], 1, 7>;
574 defm : SBWriteResPair<WriteFMA, [SBPort01], 5>;
575 defm : SBWriteResPair<WriteFMAX, [SBPort01], 5>;
576 defm : SBWriteResPair<WriteFMAY, [SBPort01], 5>;
577 defm : SBWriteResPair<WriteFMAZ, [SBPort01], 5>; // Unsupported = 1
579 // Remaining SNB instrs.
581 def SBWriteResGroup1 : SchedWriteRes<[SBPort1]> {
584 let ResourceCycles = [1];
586 def: InstRW<[SBWriteResGroup1], (instrs COMP_FST0r,
591 def SBWriteResGroup2 : SchedWriteRes<[SBPort5]> {
594 let ResourceCycles = [1];
596 def: InstRW<[SBWriteResGroup2], (instrs FDECSTP, FINCSTP, FFREE, FFREEP, FNOP,
597 LD_Frr, ST_Frr, ST_FPrr)>;
598 def: InstRW<[SBWriteResGroup2], (instrs LOOP, LOOPE, LOOPNE)>; // FIXME: This seems wrong compared to other Intel CPUs.
599 def: InstRW<[SBWriteResGroup2], (instrs RETQ)>;
601 def SBWriteResGroup4 : SchedWriteRes<[SBPort05]> {
604 let ResourceCycles = [1];
606 def: InstRW<[SBWriteResGroup4], (instrs CDQ, CQO)>;
608 def SBWriteResGroup5 : SchedWriteRes<[SBPort15]> {
611 let ResourceCycles = [1];
613 def: InstRW<[SBWriteResGroup5], (instrs MMX_PABSBrr,
622 def SBWriteResGroup11 : SchedWriteRes<[SBPort015]> {
625 let ResourceCycles = [2];
627 def: InstRW<[SBWriteResGroup11], (instrs SCASB,
632 def SBWriteResGroup12 : SchedWriteRes<[SBPort0,SBPort1]> {
635 let ResourceCycles = [1,1];
637 def: InstRW<[SBWriteResGroup12], (instregex "(V?)(U?)COMI(SD|SS)rr")>;
639 def SBWriteResGroup15 : SchedWriteRes<[SBPort0,SBPort015]> {
642 let ResourceCycles = [1,1];
644 def: InstRW<[SBWriteResGroup15], (instrs CWD,
647 def SBWriteResGroup18 : SchedWriteRes<[SBPort5,SBPort015]> {
650 let ResourceCycles = [1,1];
652 def: InstRW<[SBWriteResGroup18], (instrs JCXZ, JECXZ, JRCXZ,
655 def SBWriteResGroup21 : SchedWriteRes<[SBPort1]> {
658 let ResourceCycles = [1];
660 def: InstRW<[SBWriteResGroup21], (instrs PUSHFS64)>;
662 def SBWriteResGroup22 : SchedWriteRes<[SBPort0,SBPort5]> {
665 let ResourceCycles = [1,1];
667 def: InstRW<[SBWriteResGroup22], (instregex "(V?)EXTRACTPSrr")>;
669 def SBWriteResGroup23 : SchedWriteRes<[SBPort05]> {
672 let ResourceCycles = [3];
674 def: InstRW<[SBWriteResGroup23], (instregex "RCL(8|16|32|64)r1",
675 "RCR(8|16|32|64)r1")>;
677 def SBWriteResGroup25_1 : SchedWriteRes<[SBPort23,SBPort015]> {
680 let ResourceCycles = [1,2];
682 def: InstRW<[SBWriteResGroup25_1], (instrs LEAVE, LEAVE64)>;
684 def SBWriteResGroup26_2 : SchedWriteRes<[SBPort0,SBPort1,SBPort5]> {
687 let ResourceCycles = [1,1,1];
689 def: InstRW<[SBWriteResGroup26_2], (instrs COM_FIPr, COM_FIr, UCOM_FIPr, UCOM_FIr)>;
691 def SBWriteResGroup29 : SchedWriteRes<[SBPort1,SBPort015]> {
694 let ResourceCycles = [1,1];
696 def: InstRW<[SBWriteResGroup29], (instrs MOV64sr)>;
698 def SBWriteResGroup29_2 : SchedWriteRes<[SBPort5,SBPort015]> {
701 let ResourceCycles = [1,3];
703 def: InstRW<[SBWriteResGroup29_2], (instrs PAUSE)>;
705 def SBWriteResGroup31 : SchedWriteRes<[SBPort23]> {
708 let ResourceCycles = [1];
710 def: InstRW<[SBWriteResGroup31], (instregex "MOVSX(16|32|64)rm(8|16|32)",
711 "MOVZX(16|32|64)rm(8|16)")>;
713 def SBWriteResGroup76 : SchedWriteRes<[SBPort05]> {
716 let ResourceCycles = [8];
718 def: InstRW<[SBWriteResGroup76], (instregex "RCL(8|16|32|64)r(i|CL)",
719 "RCR(8|16|32|64)r(i|CL)")>;
721 def SBWriteResGroup33 : SchedWriteRes<[SBPort4,SBPort23]> {
724 let ResourceCycles = [1,1];
726 def: InstRW<[SBWriteResGroup33], (instregex "PUSH(16r|32r|64r|64i8)")>;
728 def SBWriteResGroup35 : SchedWriteRes<[SBPort1,SBPort5]> {
731 let ResourceCycles = [1,2];
733 def: InstRW<[SBWriteResGroup35], (instrs CLI)>;
735 def SBWriteResGroup35_2 : SchedWriteRes<[SBPort1,SBPort4,SBPort23]> {
738 let ResourceCycles = [1,1,1];
740 def: InstRW<[SBWriteResGroup35_2], (instrs PUSHGS64)>;
741 def: InstRW<[SBWriteResGroup35_2], (instregex "ISTT_FP(16|32|64)m")>;
743 def SBWriteResGroup36 : SchedWriteRes<[SBPort4,SBPort5,SBPort23]> {
746 let ResourceCycles = [1,1,1];
748 def: InstRW<[SBWriteResGroup36], (instrs CALL64pcrel32)>;
749 def: InstRW<[SBWriteResGroup36], (instregex "CALL(16|32|64)r",
752 def SBWriteResGroup40 : SchedWriteRes<[SBPort4,SBPort23,SBPort015]> {
755 let ResourceCycles = [1,1,1];
757 def: InstRW<[SBWriteResGroup40], (instrs STOSB, STOSL, STOSQ, STOSW)>;
759 def SBWriteResGroup41 : SchedWriteRes<[SBPort5,SBPort015]> {
762 let ResourceCycles = [1,3];
764 def: InstRW<[SBWriteResGroup41], (instrs FNINIT)>;
766 def SBWriteResGroup45 : SchedWriteRes<[SBPort0,SBPort4,SBPort23,SBPort15]> {
769 let ResourceCycles = [1,1,1,1];
771 def: InstRW<[SBWriteResGroup45], (instregex "(V?)PEXTR(D|Q)mr",
774 def SBWriteResGroup46 : SchedWriteRes<[SBPort4,SBPort5,SBPort01,SBPort23]> {
777 let ResourceCycles = [1,1,1,1];
779 def: InstRW<[SBWriteResGroup46], (instregex "CLFLUSH")>;
781 def SBWriteResGroup47 : SchedWriteRes<[SBPort4,SBPort5,SBPort01,SBPort23]> {
784 let ResourceCycles = [1,2,1,1];
786 def: InstRW<[SBWriteResGroup47], (instregex "FXRSTOR")>;
788 def SBWriteResGroup48 : SchedWriteRes<[SBPort23]> {
791 let ResourceCycles = [1];
793 def: InstRW<[SBWriteResGroup48], (instrs MMX_MOVD64from64rm,
795 def: InstRW<[SBWriteResGroup48], (instregex "POP(16|32|64)r",
805 def SBWriteResGroup49 : SchedWriteRes<[SBPort5,SBPort23]> {
808 let ResourceCycles = [1,1];
810 def: InstRW<[SBWriteResGroup49], (instrs MOV16sm)>;
812 def SBWriteResGroup51 : SchedWriteRes<[SBPort23,SBPort15]> {
815 let ResourceCycles = [1,1];
817 def: InstRW<[SBWriteResGroup51], (instrs MMX_PABSBrm,
825 def SBWriteResGroup52 : SchedWriteRes<[SBPort23,SBPort015]> {
828 let ResourceCycles = [1,1];
830 def: InstRW<[SBWriteResGroup52], (instrs LODSL, LODSQ)>;
832 def SBWriteResGroup53 : SchedWriteRes<[SBPort4,SBPort23]> {
835 let ResourceCycles = [1,2];
837 def: InstRW<[SBWriteResGroup53], (instregex "ST_F(32|64)m",
838 "ST_FP(32|64|80)m")>;
840 def SBWriteResGroup54 : SchedWriteRes<[SBPort23]> {
843 let ResourceCycles = [1];
845 def: InstRW<[SBWriteResGroup54], (instrs VBROADCASTSDYrm,
851 def SBWriteResGroup58 : SchedWriteRes<[SBPort23,SBPort05]> {
854 let ResourceCycles = [1,1];
856 def: InstRW<[SBWriteResGroup58], (instrs VINSERTF128rm)>;
858 def SBWriteResGroup59 : SchedWriteRes<[SBPort23,SBPort15]> {
861 let ResourceCycles = [1,1];
863 def: InstRW<[SBWriteResGroup59], (instrs MMX_PADDQirm)>;
865 def SBWriteResGroup62 : SchedWriteRes<[SBPort5,SBPort23]> {
868 let ResourceCycles = [2,1];
870 def: InstRW<[SBWriteResGroup62], (instrs VERRm, VERWm)>;
872 def SBWriteResGroup63 : SchedWriteRes<[SBPort23,SBPort015]> {
875 let ResourceCycles = [1,2];
877 def: InstRW<[SBWriteResGroup63], (instrs LODSB, LODSW)>;
879 def SBWriteResGroup64 : SchedWriteRes<[SBPort5,SBPort01,SBPort23]> {
882 let ResourceCycles = [1,1,1];
884 def: InstRW<[SBWriteResGroup64], (instrs FARJMP64)>;
886 def SBWriteResGroup66 : SchedWriteRes<[SBPort0,SBPort4,SBPort23]> {
889 let ResourceCycles = [1,1,2];
891 def: InstRW<[SBWriteResGroup66], (instrs FNSTSWm)>;
893 def SBWriteResGroup67 : SchedWriteRes<[SBPort1,SBPort5,SBPort015]> {
896 let ResourceCycles = [1,2,1];
898 def: InstRW<[SBWriteResGroup67], (instregex "SLDT(16|32|64)r",
901 def SBWriteResGroup68 : SchedWriteRes<[SBPort4,SBPort5,SBPort23]> {
904 let ResourceCycles = [1,1,2];
906 def: InstRW<[SBWriteResGroup68], (instrs FNSTCW16m)>;
907 def: InstRW<[SBWriteResGroup68], (instregex "CALL(16|32|64)m")>;
909 def SBWriteResGroup69 : SchedWriteRes<[SBPort4,SBPort23,SBPort05]> {
912 let ResourceCycles = [1,2,1];
914 def: InstRW<[SBWriteResGroup69], (instregex "SAR(8|16|32|64)m(1|i)",
915 "SHL(8|16|32|64)m(1|i)",
916 "SHR(8|16|32|64)m(1|i)")>;
918 def SBWriteResGroup77 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> {
921 let ResourceCycles = [1,1,1];
923 def: InstRW<[SBWriteResGroup77], (instregex "(V?)(U?)COMI(SD|SS)rm")>;
925 def SBWriteResGroup81 : SchedWriteRes<[SBPort4, SBPort23, SBPort015]> {
928 let ResourceCycles = [1, 2, 1];
930 def: InstRW<[SBWriteResGroup81], (instregex "CMPXCHG(8|16)B")>;
932 def SBWriteResGroup83 : SchedWriteRes<[SBPort23,SBPort015]> {
935 let ResourceCycles = [2,3];
937 def: InstRW<[SBWriteResGroup83], (instrs CMPSB,
942 def SBWriteResGroup84 : SchedWriteRes<[SBPort4,SBPort5,SBPort23]> {
945 let ResourceCycles = [1,2,2];
947 def: InstRW<[SBWriteResGroup84], (instrs FLDCW16m)>;
949 def SBWriteResGroup85 : SchedWriteRes<[SBPort4,SBPort23,SBPort05]> {
952 let ResourceCycles = [1,2,2];
954 def: InstRW<[SBWriteResGroup85], (instregex "ROL(8|16|32|64)m(1|i)",
955 "ROR(8|16|32|64)m(1|i)")>;
957 def SBWriteResGroup86 : SchedWriteRes<[SBPort4,SBPort23,SBPort015]> {
960 let ResourceCycles = [1,2,2];
962 def: InstRW<[SBWriteResGroup86], (instrs MOVSB, MOVSL, MOVSQ, MOVSW)>;
963 def: InstRW<[SBWriteResGroup86], (instregex "XADD(8|16|32|64)rm")>;
965 def SBWriteResGroup87 : SchedWriteRes<[SBPort4,SBPort5,SBPort01,SBPort23]> {
968 let ResourceCycles = [1,1,1,2];
970 def: InstRW<[SBWriteResGroup87], (instrs FARCALL64)>;
972 def SBWriteResGroup93 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> {
975 let ResourceCycles = [1,1,1];
977 def: InstRW<[SBWriteResGroup93], (instregex "CVT(T?)(SD|SS)2SI(64)?rm")>;
979 def SBWriteResGroup95 : SchedWriteRes<[SBPort5,SBPort01,SBPort23]> {
982 let ResourceCycles = [1,1,1];
984 def: InstRW<[SBWriteResGroup95], (instregex "LD_F(32|64|80)m")>;
986 def SBWriteResGroup97 : SchedWriteRes<[SBPort1,SBPort4,SBPort23]> {
989 let ResourceCycles = [1,1,2];
991 def: InstRW<[SBWriteResGroup97], (instregex "IST_F(16|32)m",
992 "IST_FP(16|32|64)m")>;
994 def SBWriteResGroup97_2 : SchedWriteRes<[SBPort4,SBPort23,SBPort05]> {
997 let ResourceCycles = [1,2,3];
999 def: InstRW<[SBWriteResGroup97_2], (instregex "ROL(8|16|32|64)mCL",
1000 "ROR(8|16|32|64)mCL",
1001 "SAR(8|16|32|64)mCL",
1002 "SHL(8|16|32|64)mCL",
1003 "SHR(8|16|32|64)mCL")>;
1005 def SBWriteResGroup98 : SchedWriteRes<[SBPort4,SBPort23,SBPort015]> {
1007 let NumMicroOps = 6;
1008 let ResourceCycles = [1,2,3];
1010 def: SchedAlias<WriteADCRMW, SBWriteResGroup98>;
1012 def SBWriteResGroup99 : SchedWriteRes<[SBPort4,SBPort23,SBPort05,SBPort015]> {
1014 let NumMicroOps = 6;
1015 let ResourceCycles = [1,2,2,1];
1017 def: InstRW<[SBWriteResGroup99, ReadAfterLd], (instrs ADC8mr, ADC16mr, ADC32mr, ADC64mr,
1018 SBB8mr, SBB16mr, SBB32mr, SBB64mr)>;
1020 def SBWriteResGroup100 : SchedWriteRes<[SBPort4,SBPort5,SBPort23,SBPort05,SBPort015]> {
1022 let NumMicroOps = 6;
1023 let ResourceCycles = [1,1,2,1,1];
1025 def : SchedAlias<WriteBitTestRegLd, SBWriteResGroup100>; // TODO - this is incorrect - no RMW
1027 def SBWriteResGroup101 : SchedWriteRes<[SBPort1,SBPort23]> {
1029 let NumMicroOps = 2;
1030 let ResourceCycles = [1,1];
1032 def: InstRW<[SBWriteResGroup101], (instregex "(ADD|SUB|SUBR)_F(32|64)m",
1033 "ILD_F(16|32|64)m")>;
1035 def SBWriteResGroup104 : SchedWriteRes<[SBPort0,SBPort23]> {
1037 let NumMicroOps = 2;
1038 let ResourceCycles = [1,1];
1040 def: InstRW<[SBWriteResGroup104], (instregex "(V?)PCMPGTQrm")>;
1042 def SBWriteResGroup106 : SchedWriteRes<[SBPort1,SBPort23]> {
1044 let NumMicroOps = 3;
1045 let ResourceCycles = [2,1];
1047 def: InstRW<[SBWriteResGroup106], (instregex "FICOM(P?)(16|32)m")>;
1049 def SBWriteResGroup108 : SchedWriteRes<[SBPort05,SBPort23]> {
1051 let NumMicroOps = 11;
1052 let ResourceCycles = [7,4];
1054 def: InstRW<[SBWriteResGroup108], (instregex "RCL(8|16|32|64)m",
1055 "RCR(8|16|32|64)m")>;
1057 def SBWriteResGroup111 : SchedWriteRes<[SBPort0,SBPort23]> {
1059 let NumMicroOps = 2;
1060 let ResourceCycles = [1,1];
1062 def: InstRW<[SBWriteResGroup111], (instregex "MUL_F(32|64)m")>;
1064 def SBWriteResGroup114 : SchedWriteRes<[SBPort1,SBPort23]> {
1066 let NumMicroOps = 3;
1067 let ResourceCycles = [2,1];
1069 def: InstRW<[SBWriteResGroup114], (instregex "(ADD|SUB|SUBR)_FI(16|32)m")>;
1071 def SBWriteResGroup119 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> {
1073 let NumMicroOps = 3;
1074 let ResourceCycles = [1,1,1];
1076 def: InstRW<[SBWriteResGroup119], (instregex "MUL_FI(16|32)m")>;
1078 def SBWriteResGroup130 : SchedWriteRes<[SBPort0,SBPort23]> {
1080 let NumMicroOps = 2;
1081 let ResourceCycles = [1,1];
1083 def: InstRW<[SBWriteResGroup130], (instregex "DIV(R?)_F(32|64)m")>;
1085 def SBWriteResGroup131 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> {
1087 let NumMicroOps = 3;
1088 let ResourceCycles = [1,1,1];
1090 def: InstRW<[SBWriteResGroup131], (instregex "DIV(R?)_FI(16|32)m")>;
1092 def SBWriteResGroupVzeroall : SchedWriteRes<[SBPort5]> {
1094 let NumMicroOps = 20;
1095 let ResourceCycles = [2];
1097 def: InstRW<[SBWriteResGroupVzeroall], (instrs VZEROALL)>;
1099 def SBWriteResGroupVzeroupper : SchedWriteRes<[]> {
1101 let NumMicroOps = 4;
1102 let ResourceCycles = [];
1104 def: InstRW<[SBWriteResGroupVzeroupper], (instrs VZEROUPPER)>;
1106 def: InstRW<[WriteZero], (instrs CLC)>;
1108 // Intruction variants handled by the renamer. These might not need execution
1109 // ports in certain conditions.
1110 // See Agner's Fog "The microarchitecture of Intel, AMD and VIA CPUs",
1111 // section "Sandy Bridge and Ivy Bridge Pipeline" > "Register allocation and
1113 // These can be investigated with llvm-exegesis, e.g.
1114 // echo 'pxor %mm0, %mm0' | /tmp/llvm-exegesis -mode=uops -snippets-file=-
1115 // echo 'vxorpd %xmm0, %xmm0, %xmm1' | /tmp/llvm-exegesis -mode=uops -snippets-file=-
1117 def SBWriteZeroLatency : SchedWriteRes<[]> {
1121 def SBWriteZeroIdiom : SchedWriteVariant<[
1122 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1123 SchedVar<NoSchedPred, [WriteALU]>
1125 def : InstRW<[SBWriteZeroIdiom], (instrs SUB32rr, SUB64rr,
1128 def SBWriteFZeroIdiom : SchedWriteVariant<[
1129 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1130 SchedVar<NoSchedPred, [WriteFLogic]>
1132 def : InstRW<[SBWriteFZeroIdiom], (instrs XORPSrr, VXORPSrr, XORPDrr,
1135 def SBWriteFZeroIdiomY : SchedWriteVariant<[
1136 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1137 SchedVar<NoSchedPred, [WriteFLogicY]>
1139 def : InstRW<[SBWriteFZeroIdiomY], (instrs VXORPSYrr, VXORPDYrr)>;
1141 def SBWriteVZeroIdiomLogicX : SchedWriteVariant<[
1142 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1143 SchedVar<NoSchedPred, [WriteVecLogicX]>
1145 def : InstRW<[SBWriteVZeroIdiomLogicX], (instrs PXORrr, VPXORrr)>;
1147 def SBWriteVZeroIdiomALUX : SchedWriteVariant<[
1148 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1149 SchedVar<NoSchedPred, [WriteVecALUX]>
1151 def : InstRW<[SBWriteVZeroIdiomALUX], (instrs PSUBBrr, VPSUBBrr,
1155 PCMPGTBrr, VPCMPGTBrr,
1156 PCMPGTDrr, VPCMPGTDrr,
1157 PCMPGTWrr, VPCMPGTWrr)>;
1159 def SBWritePCMPGTQ : SchedWriteRes<[SBPort0]> {
1161 let NumMicroOps = 1;
1162 let ResourceCycles = [1];
1165 def SBWriteVZeroIdiomPCMPGTQ : SchedWriteVariant<[
1166 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1167 SchedVar<NoSchedPred, [SBWritePCMPGTQ]>
1169 def : InstRW<[SBWriteVZeroIdiomPCMPGTQ], (instrs PCMPGTQrr, VPCMPGTQrr)>;
1171 // CMOVs that use both Z and C flag require an extra uop.
1172 def SBWriteCMOVA_CMOVBErr : SchedWriteRes<[SBPort05,SBPort015]> {
1174 let ResourceCycles = [2,1];
1175 let NumMicroOps = 3;
1178 def SBWriteCMOVA_CMOVBErm : SchedWriteRes<[SBPort23,SBPort05,SBPort015]> {
1180 let ResourceCycles = [1,2,1];
1181 let NumMicroOps = 4;
1184 def SBCMOVA_CMOVBErr : SchedWriteVariant<[
1185 SchedVar<MCSchedPredicate<IsCMOVArr_Or_CMOVBErr>, [SBWriteCMOVA_CMOVBErr]>,
1186 SchedVar<NoSchedPred, [WriteCMOV]>
1189 def SBCMOVA_CMOVBErm : SchedWriteVariant<[
1190 SchedVar<MCSchedPredicate<IsCMOVArm_Or_CMOVBErm>, [SBWriteCMOVA_CMOVBErm]>,
1191 SchedVar<NoSchedPred, [WriteCMOV.Folded]>
1194 def : InstRW<[SBCMOVA_CMOVBErr], (instrs CMOV16rr, CMOV32rr, CMOV64rr)>;
1195 def : InstRW<[SBCMOVA_CMOVBErm], (instrs CMOV16rm, CMOV32rm, CMOV64rm)>;
1197 // SETCCs that use both Z and C flag require an extra uop.
1198 def SBWriteSETA_SETBEr : SchedWriteRes<[SBPort05]> {
1200 let ResourceCycles = [2];
1201 let NumMicroOps = 2;
1204 def SBWriteSETA_SETBEm : SchedWriteRes<[SBPort4,SBPort23,SBPort05]> {
1206 let ResourceCycles = [1,1,2];
1207 let NumMicroOps = 4;
1210 def SBSETA_SETBErr : SchedWriteVariant<[
1211 SchedVar<MCSchedPredicate<IsSETAr_Or_SETBEr>, [SBWriteSETA_SETBEr]>,
1212 SchedVar<NoSchedPred, [WriteSETCC]>
1215 def SBSETA_SETBErm : SchedWriteVariant<[
1216 SchedVar<MCSchedPredicate<IsSETAm_Or_SETBEm>, [SBWriteSETA_SETBEm]>,
1217 SchedVar<NoSchedPred, [WriteSETCCStore]>
1220 def : InstRW<[SBSETA_SETBErr], (instrs SETCCr)>;
1221 def : InstRW<[SBSETA_SETBErm], (instrs SETCCm)>;