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>;
211 defm : X86WriteRes<WriteFMaskedStore, [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
212 defm : X86WriteRes<WriteFMaskedStoreY, [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
213 defm : X86WriteRes<WriteFMove, [SBPort5], 1, [1], 1>;
214 defm : X86WriteRes<WriteFMoveX, [SBPort5], 1, [1], 1>;
215 defm : X86WriteRes<WriteFMoveY, [SBPort5], 1, [1], 1>;
216 defm : X86WriteRes<WriteEMMS, [SBPort015], 31, [31], 31>;
218 defm : SBWriteResPair<WriteFAdd, [SBPort1], 3, [1], 1, 6>;
219 defm : SBWriteResPair<WriteFAddX, [SBPort1], 3, [1], 1, 6>;
220 defm : SBWriteResPair<WriteFAddY, [SBPort1], 3, [1], 1, 7>;
221 defm : SBWriteResPair<WriteFAddZ, [SBPort1], 3, [1], 1, 7>; // Unsupported = 1
222 defm : SBWriteResPair<WriteFAdd64, [SBPort1], 3, [1], 1, 6>;
223 defm : SBWriteResPair<WriteFAdd64X, [SBPort1], 3, [1], 1, 6>;
224 defm : SBWriteResPair<WriteFAdd64Y, [SBPort1], 3, [1], 1, 7>;
225 defm : SBWriteResPair<WriteFAdd64Z, [SBPort1], 3, [1], 1, 7>; // Unsupported = 1
227 defm : SBWriteResPair<WriteFCmp, [SBPort1], 3, [1], 1, 6>;
228 defm : SBWriteResPair<WriteFCmpX, [SBPort1], 3, [1], 1, 6>;
229 defm : SBWriteResPair<WriteFCmpY, [SBPort1], 3, [1], 1, 7>;
230 defm : SBWriteResPair<WriteFCmpZ, [SBPort1], 3, [1], 1, 7>; // Unsupported = 1
231 defm : SBWriteResPair<WriteFCmp64, [SBPort1], 3, [1], 1, 6>;
232 defm : SBWriteResPair<WriteFCmp64X, [SBPort1], 3, [1], 1, 6>;
233 defm : SBWriteResPair<WriteFCmp64Y, [SBPort1], 3, [1], 1, 7>;
234 defm : SBWriteResPair<WriteFCmp64Z, [SBPort1], 3, [1], 1, 7>; // Unsupported = 1
236 defm : SBWriteResPair<WriteFCom, [SBPort1], 3>;
238 defm : SBWriteResPair<WriteFMul, [SBPort0], 5, [1], 1, 6>;
239 defm : SBWriteResPair<WriteFMulX, [SBPort0], 5, [1], 1, 6>;
240 defm : SBWriteResPair<WriteFMulY, [SBPort0], 5, [1], 1, 7>;
241 defm : SBWriteResPair<WriteFMulZ, [SBPort0], 5, [1], 1, 7>; // Unsupported = 1
242 defm : SBWriteResPair<WriteFMul64, [SBPort0], 5, [1], 1, 6>;
243 defm : SBWriteResPair<WriteFMul64X, [SBPort0], 5, [1], 1, 6>;
244 defm : SBWriteResPair<WriteFMul64Y, [SBPort0], 5, [1], 1, 7>;
245 defm : SBWriteResPair<WriteFMul64Z, [SBPort0], 5, [1], 1, 7>; // Unsupported = 1
247 defm : SBWriteResPair<WriteFDiv, [SBPort0,SBFPDivider], 14, [1,14], 1, 6>;
248 defm : SBWriteResPair<WriteFDivX, [SBPort0,SBFPDivider], 14, [1,14], 1, 6>;
249 defm : SBWriteResPair<WriteFDivY, [SBPort0,SBPort05,SBFPDivider], 29, [2,1,28], 3, 7>;
250 defm : SBWriteResPair<WriteFDivZ, [SBPort0,SBPort05,SBFPDivider], 29, [2,1,28], 3, 7>; // Unsupported = 1
251 defm : SBWriteResPair<WriteFDiv64, [SBPort0,SBFPDivider], 22, [1,22], 1, 6>;
252 defm : SBWriteResPair<WriteFDiv64X, [SBPort0,SBFPDivider], 22, [1,22], 1, 6>;
253 defm : SBWriteResPair<WriteFDiv64Y, [SBPort0,SBPort05,SBFPDivider], 45, [2,1,44], 3, 7>;
254 defm : SBWriteResPair<WriteFDiv64Z, [SBPort0,SBPort05,SBFPDivider], 45, [2,1,44], 3, 7>; // Unsupported = 1
256 defm : SBWriteResPair<WriteFRcp, [SBPort0], 5, [1], 1, 6>;
257 defm : SBWriteResPair<WriteFRcpX, [SBPort0], 5, [1], 1, 6>;
258 defm : SBWriteResPair<WriteFRcpY, [SBPort0,SBPort05], 7, [2,1], 3, 7>;
259 defm : SBWriteResPair<WriteFRcpZ, [SBPort0,SBPort05], 7, [2,1], 3, 7>; // Unsupported = 1
261 defm : SBWriteResPair<WriteFRsqrt, [SBPort0], 5, [1], 1, 6>;
262 defm : SBWriteResPair<WriteFRsqrtX,[SBPort0], 5, [1], 1, 6>;
263 defm : SBWriteResPair<WriteFRsqrtY,[SBPort0,SBPort05], 7, [2,1], 3, 7>;
264 defm : SBWriteResPair<WriteFRsqrtZ,[SBPort0,SBPort05], 7, [2,1], 3, 7>; // Unsupported = 1
266 defm : SBWriteResPair<WriteFSqrt, [SBPort0,SBFPDivider], 14, [1,14], 1, 6>;
267 defm : SBWriteResPair<WriteFSqrtX, [SBPort0,SBFPDivider], 14, [1,14], 1, 6>;
268 defm : SBWriteResPair<WriteFSqrtY, [SBPort0,SBPort05,SBFPDivider], 29, [2,1,28], 3, 7>;
269 defm : SBWriteResPair<WriteFSqrtZ, [SBPort0,SBPort05,SBFPDivider], 29, [2,1,28], 3, 7>; // Unsupported = 1
270 defm : SBWriteResPair<WriteFSqrt64, [SBPort0,SBFPDivider], 21, [1,21], 1, 6>;
271 defm : SBWriteResPair<WriteFSqrt64X, [SBPort0,SBFPDivider], 21, [1,21], 1, 6>;
272 defm : SBWriteResPair<WriteFSqrt64Y, [SBPort0,SBPort05,SBFPDivider], 45, [2,1,44], 3, 7>;
273 defm : SBWriteResPair<WriteFSqrt64Z, [SBPort0,SBPort05,SBFPDivider], 45, [2,1,44], 3, 7>; // Unsupported = 1
274 defm : SBWriteResPair<WriteFSqrt80, [SBPort0,SBFPDivider], 24, [1,24], 1, 6>;
276 defm : SBWriteResPair<WriteDPPD, [SBPort0,SBPort1,SBPort5], 9, [1,1,1], 3, 6>;
277 defm : SBWriteResPair<WriteDPPS, [SBPort0,SBPort1,SBPort5], 12, [1,2,1], 4, 6>;
278 defm : SBWriteResPair<WriteDPPSY, [SBPort0,SBPort1,SBPort5], 12, [1,2,1], 4, 7>;
279 defm : SBWriteResPair<WriteDPPSZ, [SBPort0,SBPort1,SBPort5], 12, [1,2,1], 4, 7>; // Unsupported = 1
280 defm : SBWriteResPair<WriteFSign, [SBPort5], 1>;
281 defm : SBWriteResPair<WriteFRnd, [SBPort1], 3, [1], 1, 6>;
282 defm : SBWriteResPair<WriteFRndY, [SBPort1], 3, [1], 1, 7>;
283 defm : SBWriteResPair<WriteFRndZ, [SBPort1], 3, [1], 1, 7>; // Unsupported = 1
284 defm : SBWriteResPair<WriteFLogic, [SBPort5], 1, [1], 1, 6>;
285 defm : SBWriteResPair<WriteFLogicY, [SBPort5], 1, [1], 1, 7>;
286 defm : SBWriteResPair<WriteFLogicZ, [SBPort5], 1, [1], 1, 7>; // Unsupported = 1
287 defm : SBWriteResPair<WriteFTest, [SBPort0], 1, [1], 1, 6>;
288 defm : SBWriteResPair<WriteFTestY, [SBPort0], 1, [1], 1, 7>;
289 defm : SBWriteResPair<WriteFTestZ, [SBPort0], 1, [1], 1, 7>; // Unsupported = 1
290 defm : SBWriteResPair<WriteFShuffle, [SBPort5], 1, [1], 1, 6>;
291 defm : SBWriteResPair<WriteFShuffleY,[SBPort5], 1, [1], 1, 7>;
292 defm : SBWriteResPair<WriteFShuffleZ,[SBPort5], 1, [1], 1, 7>; // Unsupported = 1
293 defm : SBWriteResPair<WriteFVarShuffle, [SBPort5], 1, [1], 1, 6>;
294 defm : SBWriteResPair<WriteFVarShuffleY,[SBPort5], 1, [1], 1, 7>;
295 defm : SBWriteResPair<WriteFVarShuffleZ,[SBPort5], 1, [1], 1, 7>; // Unsupported = 1
296 defm : SBWriteResPair<WriteFBlend, [SBPort05], 1, [1], 1, 6>;
297 defm : SBWriteResPair<WriteFBlendY, [SBPort05], 1, [1], 1, 7>;
298 defm : SBWriteResPair<WriteFBlendZ, [SBPort05], 1, [1], 1, 7>; // Unsupported = 1
299 defm : SBWriteResPair<WriteFVarBlend, [SBPort05], 2, [2], 2, 6>;
300 defm : SBWriteResPair<WriteFVarBlendY,[SBPort05], 2, [2], 2, 7>;
301 defm : SBWriteResPair<WriteFVarBlendZ,[SBPort05], 2, [2], 2, 7>; // Unsupported = 1
303 // Conversion between integer and float.
304 defm : SBWriteResPair<WriteCvtSS2I, [SBPort0,SBPort1], 5, [1,1], 2>;
305 defm : SBWriteResPair<WriteCvtPS2I, [SBPort1], 3, [1], 1, 6>;
306 defm : SBWriteResPair<WriteCvtPS2IY, [SBPort1], 3, [1], 1, 7>;
307 defm : SBWriteResPair<WriteCvtPS2IZ, [SBPort1], 3, [1], 1, 7>; // Unsupported = 1
308 defm : SBWriteResPair<WriteCvtSD2I, [SBPort0,SBPort1], 5, [1,1], 2>;
309 defm : SBWriteResPair<WriteCvtPD2I, [SBPort1,SBPort5], 4, [1,1], 2, 6>;
310 defm : X86WriteRes<WriteCvtPD2IY, [SBPort1,SBPort5], 4, [1,1], 2>;
311 defm : X86WriteRes<WriteCvtPD2IZ, [SBPort1,SBPort5], 4, [1,1], 2>; // Unsupported = 1
312 defm : X86WriteRes<WriteCvtPD2IYLd, [SBPort1,SBPort5,SBPort23], 11, [1,1,1], 3>;
313 defm : X86WriteRes<WriteCvtPD2IZLd, [SBPort1,SBPort5,SBPort23], 11, [1,1,1], 3>; // Unsupported = 1
315 defm : X86WriteRes<WriteCvtI2SS, [SBPort1,SBPort5], 5, [1,2], 3>;
316 defm : X86WriteRes<WriteCvtI2SSLd, [SBPort1,SBPort5,SBPort23], 10, [1,1,1], 3>;
317 defm : SBWriteResPair<WriteCvtI2PS, [SBPort1], 3, [1], 1, 6>;
318 defm : SBWriteResPair<WriteCvtI2PSY, [SBPort1], 3, [1], 1, 7>;
319 defm : SBWriteResPair<WriteCvtI2PSZ, [SBPort1], 3, [1], 1, 7>; // Unsupported = 1
320 defm : X86WriteRes<WriteCvtI2SD, [SBPort1,SBPort5], 4, [1,1], 2>;
321 defm : X86WriteRes<WriteCvtI2PD, [SBPort1,SBPort5], 4, [1,1], 2>;
322 defm : X86WriteRes<WriteCvtI2PDY, [SBPort1,SBPort5], 4, [1,1], 2>;
323 defm : X86WriteRes<WriteCvtI2PDZ, [SBPort1,SBPort5], 4, [1,1], 2>; // Unsupported = 1
324 defm : X86WriteRes<WriteCvtI2SDLd, [SBPort1,SBPort23], 9, [1,1], 2>;
325 defm : X86WriteRes<WriteCvtI2PDLd, [SBPort1,SBPort5,SBPort23], 10, [1,1,1], 3>;
326 defm : X86WriteRes<WriteCvtI2PDYLd, [SBPort1,SBPort5,SBPort23], 10, [1,1,1], 3>;
327 defm : X86WriteRes<WriteCvtI2PDZLd, [SBPort1,SBPort5,SBPort23], 10, [1,1,1], 3>; // Unsupported = 1
329 defm : SBWriteResPair<WriteCvtSS2SD, [SBPort0], 1, [1], 1, 6>;
330 defm : X86WriteRes<WriteCvtPS2PD, [SBPort0,SBPort5], 2, [1,1], 2>;
331 defm : X86WriteRes<WriteCvtPS2PDY, [SBPort0,SBPort5], 2, [1,1], 2>;
332 defm : X86WriteRes<WriteCvtPS2PDZ, [SBPort0,SBPort5], 2, [1,1], 2>; // Unsupported = 1
333 defm : X86WriteRes<WriteCvtPS2PDLd, [SBPort0,SBPort23], 7, [1,1], 2>;
334 defm : X86WriteRes<WriteCvtPS2PDYLd, [SBPort0,SBPort23], 7, [1,1], 2>;
335 defm : X86WriteRes<WriteCvtPS2PDZLd, [SBPort0,SBPort23], 7, [1,1], 2>; // Unsupported = 1
336 defm : SBWriteResPair<WriteCvtSD2SS, [SBPort1,SBPort5], 4, [1,1], 2, 6>;
337 defm : SBWriteResPair<WriteCvtPD2PS, [SBPort1,SBPort5], 4, [1,1], 2, 6>;
338 defm : SBWriteResPair<WriteCvtPD2PSY, [SBPort1,SBPort5], 4, [1,1], 2, 7>;
339 defm : SBWriteResPair<WriteCvtPD2PSZ, [SBPort1,SBPort5], 4, [1,1], 2, 7>; // Unsupported = 1
341 defm : SBWriteResPair<WriteCvtPH2PS, [SBPort1], 3>;
342 defm : SBWriteResPair<WriteCvtPH2PSY, [SBPort1], 3>;
343 defm : SBWriteResPair<WriteCvtPH2PSZ, [SBPort1], 3>; // Unsupported = 1
345 defm : X86WriteRes<WriteCvtPS2PH, [SBPort1], 3, [1], 1>;
346 defm : X86WriteRes<WriteCvtPS2PHY, [SBPort1], 3, [1], 1>;
347 defm : X86WriteRes<WriteCvtPS2PHZ, [SBPort1], 3, [1], 1>; // Unsupported = 1
348 defm : X86WriteRes<WriteCvtPS2PHSt, [SBPort1, SBPort23, SBPort4], 4, [1,1,1], 1>;
349 defm : X86WriteRes<WriteCvtPS2PHYSt, [SBPort1, SBPort23, SBPort4], 4, [1,1,1], 1>;
350 defm : X86WriteRes<WriteCvtPS2PHZSt, [SBPort1, SBPort23, SBPort4], 4, [1,1,1], 1>; // Unsupported = 1
352 // Vector integer operations.
353 defm : X86WriteRes<WriteVecLoad, [SBPort23], 5, [1], 1>;
354 defm : X86WriteRes<WriteVecLoadX, [SBPort23], 6, [1], 1>;
355 defm : X86WriteRes<WriteVecLoadY, [SBPort23], 7, [1], 1>;
356 defm : X86WriteRes<WriteVecLoadNT, [SBPort23], 6, [1], 1>;
357 defm : X86WriteRes<WriteVecLoadNTY, [SBPort23], 7, [1], 1>;
358 defm : X86WriteRes<WriteVecMaskedLoad, [SBPort23,SBPort05], 8, [1,2], 3>;
359 defm : X86WriteRes<WriteVecMaskedLoadY, [SBPort23,SBPort05], 9, [1,2], 3>;
360 defm : X86WriteRes<WriteVecStore, [SBPort23,SBPort4], 1, [1,1], 1>;
361 defm : X86WriteRes<WriteVecStoreX, [SBPort23,SBPort4], 1, [1,1], 1>;
362 defm : X86WriteRes<WriteVecStoreY, [SBPort23,SBPort4], 1, [1,1], 1>;
363 defm : X86WriteRes<WriteVecStoreNT, [SBPort23,SBPort4], 1, [1,1], 1>;
364 defm : X86WriteRes<WriteVecStoreNTY, [SBPort23,SBPort4], 1, [1,1], 1>;
365 defm : X86WriteRes<WriteVecMaskedStore, [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
366 defm : X86WriteRes<WriteVecMaskedStoreY, [SBPort4,SBPort01,SBPort23], 5, [1,1,1], 3>;
367 defm : X86WriteRes<WriteVecMove, [SBPort05], 1, [1], 1>;
368 defm : X86WriteRes<WriteVecMoveX, [SBPort015], 1, [1], 1>;
369 defm : X86WriteRes<WriteVecMoveY, [SBPort05], 1, [1], 1>;
370 defm : X86WriteRes<WriteVecMoveToGpr, [SBPort0], 2, [1], 1>;
371 defm : X86WriteRes<WriteVecMoveFromGpr, [SBPort5], 1, [1], 1>;
373 defm : SBWriteResPair<WriteVecLogic, [SBPort015], 1, [1], 1, 5>;
374 defm : SBWriteResPair<WriteVecLogicX,[SBPort015], 1, [1], 1, 6>;
375 defm : SBWriteResPair<WriteVecLogicY,[SBPort015], 1, [1], 1, 7>;
376 defm : SBWriteResPair<WriteVecLogicZ,[SBPort015], 1, [1], 1, 7>; // Unsupported = 1
377 defm : SBWriteResPair<WriteVecTest, [SBPort0,SBPort5], 2, [1,1], 2, 6>;
378 defm : SBWriteResPair<WriteVecTestY, [SBPort0,SBPort5], 2, [1,1], 2, 7>;
379 defm : SBWriteResPair<WriteVecTestZ, [SBPort0,SBPort5], 2, [1,1], 2, 7>; // Unsupported = 1
380 defm : SBWriteResPair<WriteVecALU, [SBPort1], 3, [1], 1, 5>;
381 defm : SBWriteResPair<WriteVecALUX, [SBPort15], 1, [1], 1, 6>;
382 defm : SBWriteResPair<WriteVecALUY, [SBPort15], 1, [1], 1, 7>;
383 defm : SBWriteResPair<WriteVecALUZ, [SBPort15], 1, [1], 1, 7>; // Unsupported = 1
384 defm : SBWriteResPair<WriteVecIMul, [SBPort0], 5, [1], 1, 5>;
385 defm : SBWriteResPair<WriteVecIMulX, [SBPort0], 5, [1], 1, 6>;
386 defm : SBWriteResPair<WriteVecIMulY, [SBPort0], 5, [1], 1, 7>;
387 defm : SBWriteResPair<WriteVecIMulZ, [SBPort0], 5, [1], 1, 7>; // Unsupported = 1
388 defm : SBWriteResPair<WritePMULLD, [SBPort0], 5, [1], 1, 6>;
389 defm : SBWriteResPair<WritePMULLDY, [SBPort0], 5, [1], 1, 7>; // TODO this is probably wrong for 256/512-bit for the "generic" model
390 defm : SBWriteResPair<WritePMULLDZ, [SBPort0], 5, [1], 1, 7>; // Unsupported = 1
391 defm : SBWriteResPair<WriteShuffle, [SBPort5], 1, [1], 1, 5>;
392 defm : SBWriteResPair<WriteShuffleX, [SBPort15], 1, [1], 1, 6>;
393 defm : SBWriteResPair<WriteShuffleY, [SBPort5], 1, [1], 1, 7>;
394 defm : SBWriteResPair<WriteShuffleZ, [SBPort5], 1, [1], 1, 7>; // Unsupported = 1
395 defm : SBWriteResPair<WriteVarShuffle, [SBPort15], 1, [1], 1, 5>;
396 defm : SBWriteResPair<WriteVarShuffleX, [SBPort15], 1, [1], 1, 6>;
397 defm : SBWriteResPair<WriteVarShuffleY, [SBPort15], 1, [1], 1, 7>;
398 defm : SBWriteResPair<WriteVarShuffleZ, [SBPort15], 1, [1], 1, 7>; // Unsupported = 1
399 defm : SBWriteResPair<WriteBlend, [SBPort15], 1, [1], 1, 6>;
400 defm : SBWriteResPair<WriteBlendY, [SBPort15], 1, [1], 1, 7>;
401 defm : SBWriteResPair<WriteBlendZ, [SBPort15], 1, [1], 1, 7>; // Unsupported = 1
402 defm : SBWriteResPair<WriteVarBlend, [SBPort15], 2, [2], 2, 6>;
403 defm : SBWriteResPair<WriteVarBlendY,[SBPort15], 2, [2], 2, 7>;
404 defm : SBWriteResPair<WriteVarBlendZ,[SBPort15], 2, [2], 2, 7>; // Unsupported = 1
405 defm : SBWriteResPair<WriteMPSAD, [SBPort0, SBPort15], 7, [1,2], 3, 6>;
406 defm : SBWriteResPair<WriteMPSADY, [SBPort0, SBPort15], 7, [1,2], 3, 7>;
407 defm : SBWriteResPair<WriteMPSADZ, [SBPort0, SBPort15], 7, [1,2], 3, 7>; // Unsupported = 1
408 defm : SBWriteResPair<WritePSADBW, [SBPort0], 5, [1], 1, 5>;
409 defm : SBWriteResPair<WritePSADBWX, [SBPort0], 5, [1], 1, 6>;
410 defm : SBWriteResPair<WritePSADBWY, [SBPort0], 5, [1], 1, 7>;
411 defm : SBWriteResPair<WritePSADBWZ, [SBPort0], 5, [1], 1, 7>; // Unsupported = 1
412 defm : SBWriteResPair<WritePHMINPOS, [SBPort0], 5, [1], 1, 6>;
414 // Vector integer shifts.
415 defm : SBWriteResPair<WriteVecShift, [SBPort5], 1, [1], 1, 5>;
416 defm : SBWriteResPair<WriteVecShiftX, [SBPort0,SBPort15], 2, [1,1], 2, 6>;
417 defm : SBWriteResPair<WriteVecShiftY, [SBPort0,SBPort15], 4, [1,1], 2, 7>;
418 defm : SBWriteResPair<WriteVecShiftZ, [SBPort0,SBPort15], 4, [1,1], 2, 7>; // Unsupported = 1
419 defm : SBWriteResPair<WriteVecShiftImm, [SBPort5], 1, [1], 1, 5>;
420 defm : SBWriteResPair<WriteVecShiftImmX, [SBPort0], 1, [1], 1, 6>;
421 defm : SBWriteResPair<WriteVecShiftImmY, [SBPort0], 1, [1], 1, 7>;
422 defm : SBWriteResPair<WriteVecShiftImmZ, [SBPort0], 1, [1], 1, 7>; // Unsupported = 1
423 defm : SBWriteResPair<WriteVarVecShift, [SBPort0], 1, [1], 1, 6>;
424 defm : SBWriteResPair<WriteVarVecShiftY, [SBPort0], 1, [1], 1, 7>;
425 defm : SBWriteResPair<WriteVarVecShiftZ, [SBPort0], 1, [1], 1, 7>; // Unsupported = 1
427 // Vector insert/extract operations.
428 def : WriteRes<WriteVecInsert, [SBPort5,SBPort15]> {
432 def : WriteRes<WriteVecInsertLd, [SBPort23,SBPort15]> {
437 def : WriteRes<WriteVecExtract, [SBPort0,SBPort15]> {
441 def : WriteRes<WriteVecExtractSt, [SBPort4,SBPort23,SBPort15]> {
446 ////////////////////////////////////////////////////////////////////////////////
447 // Horizontal add/sub instructions.
448 ////////////////////////////////////////////////////////////////////////////////
450 defm : SBWriteResPair<WriteFHAdd, [SBPort1,SBPort5], 5, [1,2], 3, 6>;
451 defm : SBWriteResPair<WriteFHAddY, [SBPort1,SBPort5], 5, [1,2], 3, 7>;
452 defm : SBWriteResPair<WriteFHAddZ, [SBPort1,SBPort5], 5, [1,2], 3, 7>; // Unsupported = 1
453 defm : SBWriteResPair<WritePHAdd, [SBPort15], 3, [3], 3, 5>;
454 defm : SBWriteResPair<WritePHAddX, [SBPort15], 3, [3], 3, 6>;
455 defm : SBWriteResPair<WritePHAddY, [SBPort15], 3, [3], 3, 7>;
456 defm : SBWriteResPair<WritePHAddZ, [SBPort15], 3, [3], 3, 7>; // Unsupported = 1
458 ////////////////////////////////////////////////////////////////////////////////
459 // String instructions.
460 ////////////////////////////////////////////////////////////////////////////////
462 // Packed Compare Implicit Length Strings, Return Mask
463 def : WriteRes<WritePCmpIStrM, [SBPort0]> {
466 let ResourceCycles = [3];
468 def : WriteRes<WritePCmpIStrMLd, [SBPort0, SBPort23]> {
471 let ResourceCycles = [3,1];
474 // Packed Compare Explicit Length Strings, Return Mask
475 def : WriteRes<WritePCmpEStrM, [SBPort015]> {
477 let ResourceCycles = [8];
479 def : WriteRes<WritePCmpEStrMLd, [SBPort015, SBPort23]> {
481 let ResourceCycles = [7, 1];
484 // Packed Compare Implicit Length Strings, Return Index
485 def : WriteRes<WritePCmpIStrI, [SBPort0]> {
488 let ResourceCycles = [3];
490 def : WriteRes<WritePCmpIStrILd, [SBPort0,SBPort23]> {
493 let ResourceCycles = [3,1];
496 // Packed Compare Explicit Length Strings, Return Index
497 def : WriteRes<WritePCmpEStrI, [SBPort015]> {
499 let ResourceCycles = [8];
501 def : WriteRes<WritePCmpEStrILd, [SBPort015, SBPort23]> {
503 let ResourceCycles = [7, 1];
506 // MOVMSK Instructions.
507 def : WriteRes<WriteFMOVMSK, [SBPort0]> { let Latency = 2; }
508 def : WriteRes<WriteVecMOVMSK, [SBPort0]> { let Latency = 2; }
509 def : WriteRes<WriteVecMOVMSKY, [SBPort0]> { let Latency = 2; }
510 def : WriteRes<WriteMMXMOVMSK, [SBPort0]> { let Latency = 1; }
513 def : WriteRes<WriteAESDecEnc, [SBPort5,SBPort015]> {
516 let ResourceCycles = [1,1];
518 def : WriteRes<WriteAESDecEncLd, [SBPort5,SBPort23,SBPort015]> {
521 let ResourceCycles = [1,1,1];
524 def : WriteRes<WriteAESIMC, [SBPort5]> {
527 let ResourceCycles = [2];
529 def : WriteRes<WriteAESIMCLd, [SBPort5,SBPort23]> {
532 let ResourceCycles = [2,1];
535 def : WriteRes<WriteAESKeyGen, [SBPort015]> {
537 let ResourceCycles = [11];
539 def : WriteRes<WriteAESKeyGenLd, [SBPort015, SBPort23]> {
541 let ResourceCycles = [10, 1];
544 // Carry-less multiplication instructions.
545 def : WriteRes<WriteCLMul, [SBPort015]> {
547 let ResourceCycles = [18];
549 def : WriteRes<WriteCLMulLd, [SBPort015, SBPort23]> {
551 let ResourceCycles = [17, 1];
555 // FIXME: This is probably wrong. Only STMXCSR should require Port4.
556 def : WriteRes<WriteLDMXCSR, [SBPort0,SBPort4,SBPort5,SBPort23]> { let Latency = 5; let NumMicroOps = 4; let ResourceCycles = [1,1,1,1]; }
557 def : WriteRes<WriteSTMXCSR, [SBPort0,SBPort4,SBPort5,SBPort23]> { let Latency = 5; let NumMicroOps = 4; let ResourceCycles = [1,1,1,1]; }
559 def : WriteRes<WriteSystem, [SBPort015]> { let Latency = 100; }
560 def : WriteRes<WriteMicrocoded, [SBPort015]> { let Latency = 100; }
561 def : WriteRes<WriteFence, [SBPort23, SBPort4]>;
562 def : WriteRes<WriteNop, []>;
564 // AVX2/FMA is not supported on that architecture, but we should define the basic
565 // scheduling resources anyway.
566 defm : SBWriteResPair<WriteFShuffle256, [SBPort5], 1, [1], 1, 7>;
567 defm : SBWriteResPair<WriteFVarShuffle256, [SBPort5], 1, [1], 1, 7>;
568 defm : SBWriteResPair<WriteShuffle256, [SBPort5], 1, [1], 1, 7>;
569 defm : SBWriteResPair<WriteVarShuffle256, [SBPort5], 1, [1], 1, 7>;
570 defm : SBWriteResPair<WriteFMA, [SBPort01], 5>;
571 defm : SBWriteResPair<WriteFMAX, [SBPort01], 5>;
572 defm : SBWriteResPair<WriteFMAY, [SBPort01], 5>;
573 defm : SBWriteResPair<WriteFMAZ, [SBPort01], 5>; // Unsupported = 1
575 // Remaining SNB instrs.
577 def SBWriteResGroup1 : SchedWriteRes<[SBPort1]> {
580 let ResourceCycles = [1];
582 def: InstRW<[SBWriteResGroup1], (instrs COMP_FST0r,
587 def SBWriteResGroup2 : SchedWriteRes<[SBPort5]> {
590 let ResourceCycles = [1];
592 def: InstRW<[SBWriteResGroup2], (instrs FDECSTP, FINCSTP, FFREE, FFREEP, FNOP,
593 LD_Frr, ST_Frr, ST_FPrr)>;
594 def: InstRW<[SBWriteResGroup2], (instrs LOOP, LOOPE, LOOPNE)>; // FIXME: This seems wrong compared to other Intel CPUs.
595 def: InstRW<[SBWriteResGroup2], (instrs RETQ)>;
597 def SBWriteResGroup4 : SchedWriteRes<[SBPort05]> {
600 let ResourceCycles = [1];
602 def: InstRW<[SBWriteResGroup4], (instrs CDQ, CQO)>;
604 def SBWriteResGroup5 : SchedWriteRes<[SBPort15]> {
607 let ResourceCycles = [1];
609 def: InstRW<[SBWriteResGroup5], (instrs MMX_PABSBrr,
618 def SBWriteResGroup11 : SchedWriteRes<[SBPort015]> {
621 let ResourceCycles = [2];
623 def: InstRW<[SBWriteResGroup11], (instrs SCASB,
628 def SBWriteResGroup12 : SchedWriteRes<[SBPort0,SBPort1]> {
631 let ResourceCycles = [1,1];
633 def: InstRW<[SBWriteResGroup12], (instregex "(V?)(U?)COMI(SD|SS)rr")>;
635 def SBWriteResGroup15 : SchedWriteRes<[SBPort0,SBPort015]> {
638 let ResourceCycles = [1,1];
640 def: InstRW<[SBWriteResGroup15], (instrs CWD,
643 def SBWriteResGroup18 : SchedWriteRes<[SBPort5,SBPort015]> {
646 let ResourceCycles = [1,1];
648 def: InstRW<[SBWriteResGroup18], (instrs JCXZ, JECXZ, JRCXZ,
651 def SBWriteResGroup21 : SchedWriteRes<[SBPort1]> {
654 let ResourceCycles = [1];
656 def: InstRW<[SBWriteResGroup21], (instrs PUSHFS64)>;
658 def SBWriteResGroup22 : SchedWriteRes<[SBPort0,SBPort5]> {
661 let ResourceCycles = [1,1];
663 def: InstRW<[SBWriteResGroup22], (instregex "(V?)EXTRACTPSrr")>;
665 def SBWriteResGroup23 : SchedWriteRes<[SBPort05]> {
668 let ResourceCycles = [3];
670 def: InstRW<[SBWriteResGroup23], (instregex "RCL(8|16|32|64)r1",
671 "RCR(8|16|32|64)r1")>;
673 def SBWriteResGroup25_1 : SchedWriteRes<[SBPort23,SBPort015]> {
676 let ResourceCycles = [1,2];
678 def: InstRW<[SBWriteResGroup25_1], (instrs LEAVE, LEAVE64)>;
680 def SBWriteResGroup26_2 : SchedWriteRes<[SBPort0,SBPort1,SBPort5]> {
683 let ResourceCycles = [1,1,1];
685 def: InstRW<[SBWriteResGroup26_2], (instrs COM_FIPr, COM_FIr, UCOM_FIPr, UCOM_FIr)>;
687 def SBWriteResGroup29 : SchedWriteRes<[SBPort1,SBPort015]> {
690 let ResourceCycles = [1,1];
692 def: InstRW<[SBWriteResGroup29], (instrs MOV64sr)>;
694 def SBWriteResGroup29_2 : SchedWriteRes<[SBPort5,SBPort015]> {
697 let ResourceCycles = [1,3];
699 def: InstRW<[SBWriteResGroup29_2], (instrs PAUSE)>;
701 def SBWriteResGroup31 : SchedWriteRes<[SBPort23]> {
704 let ResourceCycles = [1];
706 def: InstRW<[SBWriteResGroup31], (instregex "MOVSX(16|32|64)rm(8|16|32)",
707 "MOVZX(16|32|64)rm(8|16)")>;
709 def SBWriteResGroup76 : SchedWriteRes<[SBPort05]> {
712 let ResourceCycles = [8];
714 def: InstRW<[SBWriteResGroup76], (instregex "RCL(8|16|32|64)r(i|CL)",
715 "RCR(8|16|32|64)r(i|CL)")>;
717 def SBWriteResGroup33 : SchedWriteRes<[SBPort4,SBPort23]> {
720 let ResourceCycles = [1,1];
722 def: InstRW<[SBWriteResGroup33], (instregex "PUSH(16r|32r|64r|64i8)")>;
724 def SBWriteResGroup35 : SchedWriteRes<[SBPort1,SBPort5]> {
727 let ResourceCycles = [1,2];
729 def: InstRW<[SBWriteResGroup35], (instrs CLI)>;
731 def SBWriteResGroup35_2 : SchedWriteRes<[SBPort1,SBPort4,SBPort23]> {
734 let ResourceCycles = [1,1,1];
736 def: InstRW<[SBWriteResGroup35_2], (instrs PUSHGS64)>;
737 def: InstRW<[SBWriteResGroup35_2], (instregex "ISTT_FP(16|32|64)m")>;
739 def SBWriteResGroup36 : SchedWriteRes<[SBPort4,SBPort5,SBPort23]> {
742 let ResourceCycles = [1,1,1];
744 def: InstRW<[SBWriteResGroup36], (instrs CALL64pcrel32)>;
745 def: InstRW<[SBWriteResGroup36], (instregex "CALL(16|32|64)r",
748 def SBWriteResGroup40 : SchedWriteRes<[SBPort4,SBPort23,SBPort015]> {
751 let ResourceCycles = [1,1,1];
753 def: InstRW<[SBWriteResGroup40], (instrs STOSB, STOSL, STOSQ, STOSW)>;
755 def SBWriteResGroup41 : SchedWriteRes<[SBPort5,SBPort015]> {
758 let ResourceCycles = [1,3];
760 def: InstRW<[SBWriteResGroup41], (instrs FNINIT)>;
762 def SBWriteResGroup45 : SchedWriteRes<[SBPort0,SBPort4,SBPort23,SBPort15]> {
765 let ResourceCycles = [1,1,1,1];
767 def: InstRW<[SBWriteResGroup45], (instregex "(V?)PEXTR(D|Q)mr",
770 def SBWriteResGroup46 : SchedWriteRes<[SBPort4,SBPort5,SBPort01,SBPort23]> {
773 let ResourceCycles = [1,1,1,1];
775 def: InstRW<[SBWriteResGroup46], (instregex "CLFLUSH")>;
777 def SBWriteResGroup47 : SchedWriteRes<[SBPort4,SBPort5,SBPort01,SBPort23]> {
780 let ResourceCycles = [1,2,1,1];
782 def: InstRW<[SBWriteResGroup47], (instregex "FXRSTOR")>;
784 def SBWriteResGroup48 : SchedWriteRes<[SBPort23]> {
787 let ResourceCycles = [1];
789 def: InstRW<[SBWriteResGroup48], (instrs MMX_MOVD64from64rm,
791 def: InstRW<[SBWriteResGroup48], (instregex "POP(16|32|64)r",
801 def SBWriteResGroup49 : SchedWriteRes<[SBPort5,SBPort23]> {
804 let ResourceCycles = [1,1];
806 def: InstRW<[SBWriteResGroup49], (instrs MOV16sm)>;
808 def SBWriteResGroup51 : SchedWriteRes<[SBPort23,SBPort15]> {
811 let ResourceCycles = [1,1];
813 def: InstRW<[SBWriteResGroup51], (instrs MMX_PABSBrm,
821 def SBWriteResGroup52 : SchedWriteRes<[SBPort23,SBPort015]> {
824 let ResourceCycles = [1,1];
826 def: InstRW<[SBWriteResGroup52], (instrs LODSL, LODSQ)>;
828 def SBWriteResGroup53 : SchedWriteRes<[SBPort4,SBPort23]> {
831 let ResourceCycles = [1,2];
833 def: InstRW<[SBWriteResGroup53], (instregex "ST_F(32|64)m",
834 "ST_FP(32|64|80)m")>;
836 def SBWriteResGroup54 : SchedWriteRes<[SBPort23]> {
839 let ResourceCycles = [1];
841 def: InstRW<[SBWriteResGroup54], (instrs VBROADCASTSDYrm,
847 def SBWriteResGroup58 : SchedWriteRes<[SBPort23,SBPort05]> {
850 let ResourceCycles = [1,1];
852 def: InstRW<[SBWriteResGroup58], (instrs VINSERTF128rm)>;
854 def SBWriteResGroup59 : SchedWriteRes<[SBPort23,SBPort15]> {
857 let ResourceCycles = [1,1];
859 def: InstRW<[SBWriteResGroup59], (instrs MMX_PADDQirm)>;
861 def SBWriteResGroup62 : SchedWriteRes<[SBPort5,SBPort23]> {
864 let ResourceCycles = [2,1];
866 def: InstRW<[SBWriteResGroup62], (instrs VERRm, VERWm)>;
868 def SBWriteResGroup63 : SchedWriteRes<[SBPort23,SBPort015]> {
871 let ResourceCycles = [1,2];
873 def: InstRW<[SBWriteResGroup63], (instrs LODSB, LODSW)>;
875 def SBWriteResGroup64 : SchedWriteRes<[SBPort5,SBPort01,SBPort23]> {
878 let ResourceCycles = [1,1,1];
880 def: InstRW<[SBWriteResGroup64], (instrs FARJMP64)>;
882 def SBWriteResGroup66 : SchedWriteRes<[SBPort0,SBPort4,SBPort23]> {
885 let ResourceCycles = [1,1,2];
887 def: InstRW<[SBWriteResGroup66], (instrs FNSTSWm)>;
889 def SBWriteResGroup67 : SchedWriteRes<[SBPort1,SBPort5,SBPort015]> {
892 let ResourceCycles = [1,2,1];
894 def: InstRW<[SBWriteResGroup67], (instregex "SLDT(16|32|64)r",
897 def SBWriteResGroup68 : SchedWriteRes<[SBPort4,SBPort5,SBPort23]> {
900 let ResourceCycles = [1,1,2];
902 def: InstRW<[SBWriteResGroup68], (instrs FNSTCW16m)>;
903 def: InstRW<[SBWriteResGroup68], (instregex "CALL(16|32|64)m")>;
905 def SBWriteResGroup69 : SchedWriteRes<[SBPort4,SBPort23,SBPort05]> {
908 let ResourceCycles = [1,2,1];
910 def: InstRW<[SBWriteResGroup69], (instregex "SAR(8|16|32|64)m(1|i)",
911 "SHL(8|16|32|64)m(1|i)",
912 "SHR(8|16|32|64)m(1|i)")>;
914 def SBWriteResGroup77 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> {
917 let ResourceCycles = [1,1,1];
919 def: InstRW<[SBWriteResGroup77], (instregex "(V?)(U?)COMI(SD|SS)rm")>;
921 def SBWriteResGroup81 : SchedWriteRes<[SBPort4, SBPort23, SBPort015]> {
924 let ResourceCycles = [1, 2, 1];
926 def: InstRW<[SBWriteResGroup81], (instregex "CMPXCHG(8|16)B")>;
928 def SBWriteResGroup83 : SchedWriteRes<[SBPort23,SBPort015]> {
931 let ResourceCycles = [2,3];
933 def: InstRW<[SBWriteResGroup83], (instrs CMPSB,
938 def SBWriteResGroup84 : SchedWriteRes<[SBPort4,SBPort5,SBPort23]> {
941 let ResourceCycles = [1,2,2];
943 def: InstRW<[SBWriteResGroup84], (instrs FLDCW16m)>;
945 def SBWriteResGroup85 : SchedWriteRes<[SBPort4,SBPort23,SBPort05]> {
948 let ResourceCycles = [1,2,2];
950 def: InstRW<[SBWriteResGroup85], (instregex "ROL(8|16|32|64)m(1|i)",
951 "ROR(8|16|32|64)m(1|i)")>;
953 def SBWriteResGroup86 : SchedWriteRes<[SBPort4,SBPort23,SBPort015]> {
956 let ResourceCycles = [1,2,2];
958 def: InstRW<[SBWriteResGroup86], (instrs MOVSB, MOVSL, MOVSQ, MOVSW)>;
959 def: InstRW<[SBWriteResGroup86], (instregex "XADD(8|16|32|64)rm")>;
961 def SBWriteResGroup87 : SchedWriteRes<[SBPort4,SBPort5,SBPort01,SBPort23]> {
964 let ResourceCycles = [1,1,1,2];
966 def: InstRW<[SBWriteResGroup87], (instrs FARCALL64)>;
968 def SBWriteResGroup93 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> {
971 let ResourceCycles = [1,1,1];
973 def: InstRW<[SBWriteResGroup93], (instregex "CVT(T?)(SD|SS)2SI(64)?rm")>;
975 def SBWriteResGroup95 : SchedWriteRes<[SBPort5,SBPort01,SBPort23]> {
978 let ResourceCycles = [1,1,1];
980 def: InstRW<[SBWriteResGroup95], (instregex "LD_F(32|64|80)m")>;
982 def SBWriteResGroup97 : SchedWriteRes<[SBPort1,SBPort4,SBPort23]> {
985 let ResourceCycles = [1,1,2];
987 def: InstRW<[SBWriteResGroup97], (instregex "IST_F(16|32)m",
988 "IST_FP(16|32|64)m")>;
990 def SBWriteResGroup97_2 : SchedWriteRes<[SBPort4,SBPort23,SBPort05]> {
993 let ResourceCycles = [1,2,3];
995 def: InstRW<[SBWriteResGroup97_2], (instregex "ROL(8|16|32|64)mCL",
996 "ROR(8|16|32|64)mCL",
997 "SAR(8|16|32|64)mCL",
998 "SHL(8|16|32|64)mCL",
999 "SHR(8|16|32|64)mCL")>;
1001 def SBWriteResGroup98 : SchedWriteRes<[SBPort4,SBPort23,SBPort015]> {
1003 let NumMicroOps = 6;
1004 let ResourceCycles = [1,2,3];
1006 def: SchedAlias<WriteADCRMW, SBWriteResGroup98>;
1008 def SBWriteResGroup99 : SchedWriteRes<[SBPort4,SBPort23,SBPort05,SBPort015]> {
1010 let NumMicroOps = 6;
1011 let ResourceCycles = [1,2,2,1];
1013 def: InstRW<[SBWriteResGroup99, ReadAfterLd], (instrs ADC8mr, ADC16mr, ADC32mr, ADC64mr,
1014 SBB8mr, SBB16mr, SBB32mr, SBB64mr)>;
1016 def SBWriteResGroup100 : SchedWriteRes<[SBPort4,SBPort5,SBPort23,SBPort05,SBPort015]> {
1018 let NumMicroOps = 6;
1019 let ResourceCycles = [1,1,2,1,1];
1021 def : SchedAlias<WriteBitTestRegLd, SBWriteResGroup100>; // TODO - this is incorrect - no RMW
1023 def SBWriteResGroup101 : SchedWriteRes<[SBPort1,SBPort23]> {
1025 let NumMicroOps = 2;
1026 let ResourceCycles = [1,1];
1028 def: InstRW<[SBWriteResGroup101], (instregex "(ADD|SUB|SUBR)_F(32|64)m",
1029 "ILD_F(16|32|64)m")>;
1031 def SBWriteResGroup104 : SchedWriteRes<[SBPort0,SBPort23]> {
1033 let NumMicroOps = 2;
1034 let ResourceCycles = [1,1];
1036 def: InstRW<[SBWriteResGroup104], (instregex "(V?)PCMPGTQrm")>;
1038 def SBWriteResGroup106 : SchedWriteRes<[SBPort1,SBPort23]> {
1040 let NumMicroOps = 3;
1041 let ResourceCycles = [2,1];
1043 def: InstRW<[SBWriteResGroup106], (instregex "FICOM(P?)(16|32)m")>;
1045 def SBWriteResGroup108 : SchedWriteRes<[SBPort05,SBPort23]> {
1047 let NumMicroOps = 11;
1048 let ResourceCycles = [7,4];
1050 def: InstRW<[SBWriteResGroup108], (instregex "RCL(8|16|32|64)m",
1051 "RCR(8|16|32|64)m")>;
1053 def SBWriteResGroup111 : SchedWriteRes<[SBPort0,SBPort23]> {
1055 let NumMicroOps = 2;
1056 let ResourceCycles = [1,1];
1058 def: InstRW<[SBWriteResGroup111], (instregex "MUL_F(32|64)m")>;
1060 def SBWriteResGroup114 : SchedWriteRes<[SBPort1,SBPort23]> {
1062 let NumMicroOps = 3;
1063 let ResourceCycles = [2,1];
1065 def: InstRW<[SBWriteResGroup114], (instregex "(ADD|SUB|SUBR)_FI(16|32)m")>;
1067 def SBWriteResGroup119 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> {
1069 let NumMicroOps = 3;
1070 let ResourceCycles = [1,1,1];
1072 def: InstRW<[SBWriteResGroup119], (instregex "MUL_FI(16|32)m")>;
1074 def SBWriteResGroup130 : SchedWriteRes<[SBPort0,SBPort23]> {
1076 let NumMicroOps = 2;
1077 let ResourceCycles = [1,1];
1079 def: InstRW<[SBWriteResGroup130], (instregex "DIV(R?)_F(32|64)m")>;
1081 def SBWriteResGroup131 : SchedWriteRes<[SBPort0,SBPort1,SBPort23]> {
1083 let NumMicroOps = 3;
1084 let ResourceCycles = [1,1,1];
1086 def: InstRW<[SBWriteResGroup131], (instregex "DIV(R?)_FI(16|32)m")>;
1088 def SBWriteResGroupVzeroall : SchedWriteRes<[SBPort5]> {
1090 let NumMicroOps = 20;
1091 let ResourceCycles = [2];
1093 def: InstRW<[SBWriteResGroupVzeroall], (instrs VZEROALL)>;
1095 def SBWriteResGroupVzeroupper : SchedWriteRes<[]> {
1097 let NumMicroOps = 4;
1098 let ResourceCycles = [];
1100 def: InstRW<[SBWriteResGroupVzeroupper], (instrs VZEROUPPER)>;
1102 def: InstRW<[WriteZero], (instrs CLC)>;
1104 // Intruction variants handled by the renamer. These might not need execution
1105 // ports in certain conditions.
1106 // See Agner's Fog "The microarchitecture of Intel, AMD and VIA CPUs",
1107 // section "Sandy Bridge and Ivy Bridge Pipeline" > "Register allocation and
1109 // These can be investigated with llvm-exegesis, e.g.
1110 // echo 'pxor %mm0, %mm0' | /tmp/llvm-exegesis -mode=uops -snippets-file=-
1111 // echo 'vxorpd %xmm0, %xmm0, %xmm1' | /tmp/llvm-exegesis -mode=uops -snippets-file=-
1113 def SBWriteZeroLatency : SchedWriteRes<[]> {
1117 def SBWriteZeroIdiom : SchedWriteVariant<[
1118 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1119 SchedVar<NoSchedPred, [WriteALU]>
1121 def : InstRW<[SBWriteZeroIdiom], (instrs SUB32rr, SUB64rr,
1124 def SBWriteFZeroIdiom : SchedWriteVariant<[
1125 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1126 SchedVar<NoSchedPred, [WriteFLogic]>
1128 def : InstRW<[SBWriteFZeroIdiom], (instrs XORPSrr, VXORPSrr, XORPDrr,
1131 def SBWriteFZeroIdiomY : SchedWriteVariant<[
1132 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1133 SchedVar<NoSchedPred, [WriteFLogicY]>
1135 def : InstRW<[SBWriteFZeroIdiomY], (instrs VXORPSYrr, VXORPDYrr)>;
1137 def SBWriteVZeroIdiomLogicX : SchedWriteVariant<[
1138 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1139 SchedVar<NoSchedPred, [WriteVecLogicX]>
1141 def : InstRW<[SBWriteVZeroIdiomLogicX], (instrs PXORrr, VPXORrr)>;
1143 def SBWriteVZeroIdiomALUX : SchedWriteVariant<[
1144 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1145 SchedVar<NoSchedPred, [WriteVecALUX]>
1147 def : InstRW<[SBWriteVZeroIdiomALUX], (instrs PSUBBrr, VPSUBBrr,
1151 PCMPGTBrr, VPCMPGTBrr,
1152 PCMPGTDrr, VPCMPGTDrr,
1153 PCMPGTWrr, VPCMPGTWrr)>;
1155 def SBWritePCMPGTQ : SchedWriteRes<[SBPort0]> {
1157 let NumMicroOps = 1;
1158 let ResourceCycles = [1];
1161 def SBWriteVZeroIdiomPCMPGTQ : SchedWriteVariant<[
1162 SchedVar<MCSchedPredicate<ZeroIdiomPredicate>, [SBWriteZeroLatency]>,
1163 SchedVar<NoSchedPred, [SBWritePCMPGTQ]>
1165 def : InstRW<[SBWriteVZeroIdiomPCMPGTQ], (instrs PCMPGTQrr, VPCMPGTQrr)>;
1167 // CMOVs that use both Z and C flag require an extra uop.
1168 def SBWriteCMOVA_CMOVBErr : SchedWriteRes<[SBPort05,SBPort015]> {
1170 let ResourceCycles = [2,1];
1171 let NumMicroOps = 3;
1174 def SBWriteCMOVA_CMOVBErm : SchedWriteRes<[SBPort23,SBPort05,SBPort015]> {
1176 let ResourceCycles = [1,2,1];
1177 let NumMicroOps = 4;
1180 def SBCMOVA_CMOVBErr : SchedWriteVariant<[
1181 SchedVar<MCSchedPredicate<IsCMOVArr_Or_CMOVBErr>, [SBWriteCMOVA_CMOVBErr]>,
1182 SchedVar<NoSchedPred, [WriteCMOV]>
1185 def SBCMOVA_CMOVBErm : SchedWriteVariant<[
1186 SchedVar<MCSchedPredicate<IsCMOVArm_Or_CMOVBErm>, [SBWriteCMOVA_CMOVBErm]>,
1187 SchedVar<NoSchedPred, [WriteCMOV.Folded]>
1190 def : InstRW<[SBCMOVA_CMOVBErr], (instrs CMOV16rr, CMOV32rr, CMOV64rr)>;
1191 def : InstRW<[SBCMOVA_CMOVBErm], (instrs CMOV16rm, CMOV32rm, CMOV64rm)>;
1193 // SETCCs that use both Z and C flag require an extra uop.
1194 def SBWriteSETA_SETBEr : SchedWriteRes<[SBPort05]> {
1196 let ResourceCycles = [2];
1197 let NumMicroOps = 2;
1200 def SBWriteSETA_SETBEm : SchedWriteRes<[SBPort4,SBPort23,SBPort05]> {
1202 let ResourceCycles = [1,1,2];
1203 let NumMicroOps = 4;
1206 def SBSETA_SETBErr : SchedWriteVariant<[
1207 SchedVar<MCSchedPredicate<IsSETAr_Or_SETBEr>, [SBWriteSETA_SETBEr]>,
1208 SchedVar<NoSchedPred, [WriteSETCC]>
1211 def SBSETA_SETBErm : SchedWriteVariant<[
1212 SchedVar<MCSchedPredicate<IsSETAm_Or_SETBEm>, [SBWriteSETA_SETBEm]>,
1213 SchedVar<NoSchedPred, [WriteSETCCStore]>
1216 def : InstRW<[SBSETA_SETBErr], (instrs SETCCr)>;
1217 def : InstRW<[SBSETA_SETBErm], (instrs SETCCm)>;