]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/llvm/lib/Target/X86/X86ScheduleSLM.td
zfs: merge openzfs/zfs@21bd76613 (zfs-2.1-release) into stable/13
[FreeBSD/FreeBSD.git] / contrib / llvm-project / llvm / lib / Target / X86 / X86ScheduleSLM.td
1 //=- X86ScheduleSLM.td - X86 Silvermont 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 Intel Silvermont to support
10 // instruction scheduling and other instruction cost heuristics.
11 //
12 //===----------------------------------------------------------------------===//
13
14 def SLMModel : SchedMachineModel {
15   // All x86 instructions are modeled as a single micro-op, and SLM can decode 2
16   // instructions per cycle.
17   let IssueWidth = 2;
18   let MicroOpBufferSize = 32; // Based on the reorder buffer.
19   let LoadLatency = 3;
20   let MispredictPenalty = 10;
21   let PostRAScheduler = 1;
22
23   // For small loops, expand by a small factor to hide the backedge cost.
24   let LoopMicroOpBufferSize = 10;
25
26   // FIXME: SSE4 is unimplemented. This flag is set to allow
27   // the scheduler to assign a default model to unrecognized opcodes.
28   let CompleteModel = 0;
29 }
30
31 let SchedModel = SLMModel in {
32
33 // Silvermont has 5 reservation stations for micro-ops
34 def SLM_IEC_RSV0 : ProcResource<1>;
35 def SLM_IEC_RSV1 : ProcResource<1>;
36 def SLM_FPC_RSV0 : ProcResource<1> { let BufferSize = 1; }
37 def SLM_FPC_RSV1 : ProcResource<1> { let BufferSize = 1; }
38 def SLM_MEC_RSV  : ProcResource<1>;
39
40 // Many micro-ops are capable of issuing on multiple ports.
41 def SLM_IEC_RSV01  : ProcResGroup<[SLM_IEC_RSV0, SLM_IEC_RSV1]>;
42 def SLM_FPC_RSV01  : ProcResGroup<[SLM_FPC_RSV0, SLM_FPC_RSV1]>;
43
44 def SLMDivider      : ProcResource<1>;
45 def SLMFPMultiplier : ProcResource<1>;
46 def SLMFPDivider    : ProcResource<1>;
47
48 // Loads are 3 cycles, so ReadAfterLd registers needn't be available until 3
49 // cycles after the memory operand.
50 def : ReadAdvance<ReadAfterLd, 3>;
51 def : ReadAdvance<ReadAfterVecLd, 3>;
52 def : ReadAdvance<ReadAfterVecXLd, 3>;
53 def : ReadAdvance<ReadAfterVecYLd, 3>;
54
55 def : ReadAdvance<ReadInt2Fpu, 0>;
56
57 // Many SchedWrites are defined in pairs with and without a folded load.
58 // Instructions with folded loads are usually micro-fused, so they only appear
59 // as two micro-ops when queued in the reservation station.
60 // This multiclass defines the resource usage for variants with and without
61 // folded loads.
62 multiclass SLMWriteResPair<X86FoldableSchedWrite SchedRW,
63                            list<ProcResourceKind> ExePorts,
64                            int Lat, list<int> Res = [1], int UOps = 1,
65                            int LoadUOps = 0, int LoadLat = 3> {
66   // Register variant is using a single cycle on ExePort.
67   def : WriteRes<SchedRW, ExePorts> {
68     let Latency = Lat;
69     let ResourceCycles = Res;
70     let NumMicroOps = UOps;
71   }
72
73   // Memory variant also uses a cycle on MEC_RSV and adds LoadLat cycles to
74   // the latency (default = 3).
75   def : WriteRes<SchedRW.Folded, !listconcat([SLM_MEC_RSV], ExePorts)> {
76     let Latency = !add(Lat, LoadLat);
77     let ResourceCycles = !listconcat([1], Res);
78     let NumMicroOps = !add(UOps, LoadUOps);
79   }
80 }
81
82 // A folded store needs a cycle on MEC_RSV for the store data (using the same uop),
83 // but it does not need an extra port cycle to recompute the address.
84 def : WriteRes<WriteRMW, [SLM_MEC_RSV]> { let NumMicroOps = 0; }
85
86 def : WriteRes<WriteStore,   [SLM_IEC_RSV01, SLM_MEC_RSV]>;
87 def : WriteRes<WriteStoreNT, [SLM_IEC_RSV01, SLM_MEC_RSV]>;
88 def : WriteRes<WriteLoad,    [SLM_MEC_RSV]> { let Latency = 3; }
89 def : WriteRes<WriteMove,    [SLM_IEC_RSV01]>;
90 def : WriteRes<WriteZero,    []>;
91 defm : X86WriteResUnsupported<WriteVecMaskedGatherWriteback>;
92
93 // Load/store MXCSR.
94 // FIXME: These are probably wrong. They are copy pasted from WriteStore/Load.
95 def : WriteRes<WriteSTMXCSR, [SLM_IEC_RSV01, SLM_MEC_RSV]>;
96 def : WriteRes<WriteLDMXCSR,  [SLM_MEC_RSV]> { let Latency = 3; }
97
98 // Treat misc copies as a move.
99 def : InstRW<[WriteMove], (instrs COPY)>;
100
101 defm : SLMWriteResPair<WriteALU,    [SLM_IEC_RSV01], 1>;
102 defm : SLMWriteResPair<WriteADC,    [SLM_IEC_RSV01], 1>;
103
104 defm : SLMWriteResPair<WriteIMul8,     [SLM_IEC_RSV1],  5, [5], 3>;
105 defm : SLMWriteResPair<WriteIMul16,    [SLM_IEC_RSV1],  5, [5], 4, 1>;
106 defm : SLMWriteResPair<WriteIMul16Imm, [SLM_IEC_RSV1],  4, [4], 2, 1>;
107 defm : SLMWriteResPair<WriteIMul16Reg, [SLM_IEC_RSV1],  4, [4], 2, 1>;
108 defm : SLMWriteResPair<WriteIMul32,    [SLM_IEC_RSV1],  5, [5], 3, 1>;
109 defm : SLMWriteResPair<WriteIMul32Imm, [SLM_IEC_RSV1],  3>;
110 defm : SLMWriteResPair<WriteIMul32Reg, [SLM_IEC_RSV1],  3>;
111 defm : SLMWriteResPair<WriteIMul64,    [SLM_IEC_RSV1],  7, [7], 3>;
112 defm : SLMWriteResPair<WriteIMul64Imm, [SLM_IEC_RSV1],  5, [2]>;
113 defm : SLMWriteResPair<WriteIMul64Reg, [SLM_IEC_RSV1],  5, [2]>;
114 defm : X86WriteResUnsupported<WriteIMulH>;
115 defm : X86WriteResUnsupported<WriteIMulHLd>;
116 defm : X86WriteResPairUnsupported<WriteMULX32>;
117 defm : X86WriteResPairUnsupported<WriteMULX64>;
118
119 defm : X86WriteRes<WriteBSWAP32, [SLM_IEC_RSV01], 1, [1], 1>;
120 defm : X86WriteRes<WriteBSWAP64, [SLM_IEC_RSV01], 1, [1], 1>;
121 defm : X86WriteRes<WriteCMPXCHG, [SLM_IEC_RSV01], 1, [1], 1>;
122 defm : X86WriteRes<WriteCMPXCHGRMW, [SLM_IEC_RSV01, SLM_MEC_RSV], 4, [1, 2], 2>;
123 defm : X86WriteRes<WriteXCHG,      [SLM_IEC_RSV01], 1, [1], 1>;
124
125 defm : SLMWriteResPair<WriteShift,    [SLM_IEC_RSV0],  1>;
126 defm : SLMWriteResPair<WriteShiftCL,  [SLM_IEC_RSV0],  1>;
127 defm : SLMWriteResPair<WriteRotate,   [SLM_IEC_RSV0],  1>;
128 defm : SLMWriteResPair<WriteRotateCL, [SLM_IEC_RSV0],  1>;
129
130 defm : X86WriteRes<WriteSHDrri, [SLM_IEC_RSV0],  1, [1], 1>;
131 defm : X86WriteRes<WriteSHDrrcl,[SLM_IEC_RSV0],  1, [1], 1>;
132 defm : X86WriteRes<WriteSHDmri, [SLM_MEC_RSV, SLM_IEC_RSV0], 4, [2, 1], 2>;
133 defm : X86WriteRes<WriteSHDmrcl,[SLM_MEC_RSV, SLM_IEC_RSV0], 4, [2, 1], 2>;
134
135 defm : SLMWriteResPair<WriteJump,   [SLM_IEC_RSV1],  1>;
136 defm : SLMWriteResPair<WriteCRC32,  [SLM_IEC_RSV1],  3>;
137
138 defm : SLMWriteResPair<WriteCMOV,  [SLM_IEC_RSV01], 2, [2]>;
139 defm : X86WriteRes<WriteFCMOV, [SLM_FPC_RSV1], 3, [1], 1>; // x87 conditional move.
140 def  : WriteRes<WriteSETCC, [SLM_IEC_RSV01]>;
141 def  : WriteRes<WriteSETCCStore, [SLM_IEC_RSV01, SLM_MEC_RSV]> {
142   // FIXME Latency and NumMicrOps?
143   let ResourceCycles = [2,1];
144 }
145 defm : X86WriteRes<WriteLAHFSAHF,        [SLM_IEC_RSV01], 1, [1], 1>;
146 defm : X86WriteRes<WriteBitTest,         [SLM_IEC_RSV0, SLM_IEC_RSV1], 1, [1,1], 1>;
147 defm : X86WriteRes<WriteBitTestImmLd,    [SLM_IEC_RSV0, SLM_IEC_RSV1, SLM_MEC_RSV], 4, [1,1,1], 1>;
148 defm : X86WriteRes<WriteBitTestRegLd,    [SLM_IEC_RSV0, SLM_IEC_RSV1, SLM_MEC_RSV], 4, [1,1,1], 7>;
149 defm : X86WriteRes<WriteBitTestSet,      [SLM_IEC_RSV0, SLM_IEC_RSV1], 1, [1,1], 1>;
150 defm : X86WriteRes<WriteBitTestSetImmLd, [SLM_IEC_RSV0, SLM_IEC_RSV1, SLM_MEC_RSV], 3, [1,1,1], 1>;
151 defm : X86WriteRes<WriteBitTestSetRegLd, [SLM_IEC_RSV0, SLM_IEC_RSV1, SLM_MEC_RSV], 3, [1,1,1], 7>;
152
153 // This is for simple LEAs with one or two input operands.
154 // The complex ones can only execute on port 1, and they require two cycles on
155 // the port to read all inputs. We don't model that.
156 def : WriteRes<WriteLEA, [SLM_IEC_RSV1]>;
157
158 // Bit counts.
159 defm : SLMWriteResPair<WriteBSF, [SLM_IEC_RSV0, SLM_IEC_RSV1], 10, [10,10], 10>;
160 defm : SLMWriteResPair<WriteBSR, [SLM_IEC_RSV0, SLM_IEC_RSV1], 10, [10,10], 10>;
161 defm : SLMWriteResPair<WriteLZCNT,          [SLM_IEC_RSV0], 3>;
162 defm : SLMWriteResPair<WriteTZCNT,          [SLM_IEC_RSV0], 3>;
163 defm : SLMWriteResPair<WritePOPCNT,         [SLM_IEC_RSV0], 3>;
164
165 // BMI1 BEXTR/BLS, BMI2 BZHI
166 defm : X86WriteResPairUnsupported<WriteBEXTR>;
167 defm : X86WriteResPairUnsupported<WriteBLS>;
168 defm : X86WriteResPairUnsupported<WriteBZHI>;
169
170 defm : SLMWriteResPair<WriteDiv8,   [SLM_IEC_RSV01, SLMDivider], 25, [1,25], 1, 0, 4>;
171 defm : SLMWriteResPair<WriteDiv16,  [SLM_IEC_RSV01, SLMDivider], 25, [1,25], 1, 0, 4>;
172 defm : SLMWriteResPair<WriteDiv32,  [SLM_IEC_RSV01, SLMDivider], 25, [1,25], 1, 0, 4>;
173 defm : SLMWriteResPair<WriteDiv64,  [SLM_IEC_RSV01, SLMDivider], 25, [1,25], 1, 0, 4>;
174 defm : SLMWriteResPair<WriteIDiv8,  [SLM_IEC_RSV01, SLMDivider], 25, [1,25], 1, 0, 4>;
175 defm : SLMWriteResPair<WriteIDiv16, [SLM_IEC_RSV01, SLMDivider], 25, [1,25], 1, 0, 4>;
176 defm : SLMWriteResPair<WriteIDiv32, [SLM_IEC_RSV01, SLMDivider], 25, [1,25], 1, 0, 4>;
177 defm : SLMWriteResPair<WriteIDiv64, [SLM_IEC_RSV01, SLMDivider], 25, [1,25], 1, 0, 4>;
178
179 // Scalar and vector floating point.
180 defm : X86WriteRes<WriteFLD0,       [SLM_FPC_RSV01], 1, [1], 1>;
181 defm : X86WriteRes<WriteFLD1,       [SLM_FPC_RSV01], 1, [1], 1>;
182 defm : X86WriteRes<WriteFLDC,       [SLM_FPC_RSV01], 1, [2], 2>;
183 def  : WriteRes<WriteFLoad,         [SLM_MEC_RSV]> { let Latency = 3; }
184 def  : WriteRes<WriteFLoadX,        [SLM_MEC_RSV]> { let Latency = 3; }
185 def  : WriteRes<WriteFLoadY,        [SLM_MEC_RSV]> { let Latency = 3; }
186 def  : WriteRes<WriteFMaskedLoad,   [SLM_MEC_RSV]> { let Latency = 3; }
187 def  : WriteRes<WriteFMaskedLoadY,  [SLM_MEC_RSV]> { let Latency = 3; }
188 def  : WriteRes<WriteFStore,        [SLM_MEC_RSV]>;
189 def  : WriteRes<WriteFStoreX,       [SLM_MEC_RSV]>;
190 def  : WriteRes<WriteFStoreY,       [SLM_MEC_RSV]>;
191 def  : WriteRes<WriteFStoreNT,      [SLM_MEC_RSV]>;
192 def  : WriteRes<WriteFStoreNTX,     [SLM_MEC_RSV]>;
193 def  : WriteRes<WriteFStoreNTY,     [SLM_MEC_RSV]>;
194
195 def  : WriteRes<WriteFMaskedStore32,    [SLM_MEC_RSV]>;
196 def  : WriteRes<WriteFMaskedStore32Y,   [SLM_MEC_RSV]>;
197 def  : WriteRes<WriteFMaskedStore64,    [SLM_MEC_RSV]>;
198 def  : WriteRes<WriteFMaskedStore64Y,   [SLM_MEC_RSV]>;
199
200 def  : WriteRes<WriteFMove,         [SLM_FPC_RSV01]>;
201 def  : WriteRes<WriteFMoveX,        [SLM_FPC_RSV01]>;
202 def  : WriteRes<WriteFMoveY,        [SLM_FPC_RSV01]>;
203 defm : X86WriteResUnsupported<WriteFMoveZ>;
204 defm : X86WriteRes<WriteEMMS,       [SLM_FPC_RSV01], 10, [10], 9>;
205
206 defm : SLMWriteResPair<WriteFAdd,     [SLM_FPC_RSV1], 3>;
207 defm : SLMWriteResPair<WriteFAddX,    [SLM_FPC_RSV1], 3>;
208 defm : SLMWriteResPair<WriteFAddY,    [SLM_FPC_RSV1], 3>;
209 defm : X86WriteResPairUnsupported<WriteFAddZ>;
210 defm : SLMWriteResPair<WriteFAdd64,   [SLM_FPC_RSV1], 3>;
211 defm : SLMWriteResPair<WriteFAdd64X,  [SLM_FPC_RSV1], 4, [2]>;
212 defm : SLMWriteResPair<WriteFAdd64Y,  [SLM_FPC_RSV1], 4, [2]>;
213 defm : X86WriteResPairUnsupported<WriteFAdd64Z>;
214 defm : SLMWriteResPair<WriteFCmp,     [SLM_FPC_RSV1], 3>;
215 defm : SLMWriteResPair<WriteFCmpX,    [SLM_FPC_RSV1], 3>;
216 defm : SLMWriteResPair<WriteFCmpY,    [SLM_FPC_RSV1], 3>;
217 defm : X86WriteResPairUnsupported<WriteFCmpZ>;
218 defm : SLMWriteResPair<WriteFCmp64,   [SLM_FPC_RSV1], 3>;
219 defm : SLMWriteResPair<WriteFCmp64X,  [SLM_FPC_RSV1], 3>;
220 defm : SLMWriteResPair<WriteFCmp64Y,  [SLM_FPC_RSV1], 3>;
221 defm : X86WriteResPairUnsupported<WriteFCmp64Z>;
222 defm : SLMWriteResPair<WriteFCom,     [SLM_FPC_RSV1], 3>;
223 defm : SLMWriteResPair<WriteFComX,    [SLM_FPC_RSV1], 3>;
224 defm : SLMWriteResPair<WriteFMul,     [SLM_FPC_RSV0, SLMFPMultiplier], 5, [1,2]>;
225 defm : SLMWriteResPair<WriteFMulX,    [SLM_FPC_RSV0, SLMFPMultiplier], 5, [1,2]>;
226 defm : SLMWriteResPair<WriteFMulY,    [SLM_FPC_RSV0, SLMFPMultiplier], 5, [1,2]>;
227 defm : X86WriteResPairUnsupported<WriteFMulZ>;
228 defm : SLMWriteResPair<WriteFMul64,   [SLM_FPC_RSV0, SLMFPMultiplier], 5, [1,2]>;
229 defm : SLMWriteResPair<WriteFMul64X,  [SLM_FPC_RSV0, SLMFPMultiplier], 7, [1,4]>;
230 defm : SLMWriteResPair<WriteFMul64Y,  [SLM_FPC_RSV0, SLMFPMultiplier], 7, [1,4]>;
231 defm : X86WriteResPairUnsupported<WriteFMul64Z>;
232 defm : X86WriteResPairUnsupported<WriteFMA>;
233 defm : X86WriteResPairUnsupported<WriteFMAX>;
234 defm : X86WriteResPairUnsupported<WriteFMAY>;
235 defm : X86WriteResPairUnsupported<WriteFMAZ>;
236 defm : SLMWriteResPair<WriteFDiv,     [SLM_FPC_RSV0, SLMFPDivider], 19, [1,17]>;
237 defm : SLMWriteResPair<WriteFDivX,    [SLM_FPC_RSV0, SLMFPDivider], 39, [1,39], 6, 1>;
238 defm : X86WriteResPairUnsupported<WriteFDivY>;
239 defm : X86WriteResPairUnsupported<WriteFDivZ>;
240 defm : SLMWriteResPair<WriteFDiv64,   [SLM_FPC_RSV0, SLMFPDivider], 34, [1,32]>;
241 defm : SLMWriteResPair<WriteFDiv64X,  [SLM_FPC_RSV0, SLMFPDivider], 69, [1,69], 6, 1>;
242 defm : X86WriteResPairUnsupported<WriteFDiv64Y>;
243 defm : X86WriteResPairUnsupported<WriteFDiv64Z>;
244 defm : SLMWriteResPair<WriteFRcp,     [SLM_FPC_RSV0], 4>;
245 defm : SLMWriteResPair<WriteFRcpX,    [SLM_FPC_RSV0], 9, [8], 5, 1>;
246 defm : X86WriteResPairUnsupported<WriteFRcpY>;
247 defm : X86WriteResPairUnsupported<WriteFRcpZ>;
248 defm : SLMWriteResPair<WriteFRsqrt,   [SLM_FPC_RSV0], 4>;
249 defm : SLMWriteResPair<WriteFRsqrtX,  [SLM_FPC_RSV0], 9, [8], 5, 1>;
250 defm : X86WriteResPairUnsupported<WriteFRsqrtY>;
251 defm : X86WriteResPairUnsupported<WriteFRsqrtZ>;
252 defm : SLMWriteResPair<WriteFSqrt,    [SLM_FPC_RSV0, SLMFPDivider], 20, [1,20]>;
253 defm : SLMWriteResPair<WriteFSqrtX,   [SLM_FPC_RSV0, SLMFPDivider], 41, [1,40], 5, 1>;
254 defm : X86WriteResPairUnsupported<WriteFSqrtY>;
255 defm : X86WriteResPairUnsupported<WriteFSqrtZ>;
256 defm : SLMWriteResPair<WriteFSqrt64,  [SLM_FPC_RSV0, SLMFPDivider], 35, [1,35]>;
257 defm : SLMWriteResPair<WriteFSqrt64X, [SLM_FPC_RSV0, SLMFPDivider], 71, [1,70], 5, 1>;
258 defm : X86WriteResPairUnsupported<WriteFSqrt64Y>;
259 defm : X86WriteResPairUnsupported<WriteFSqrt64Z>;
260 defm : SLMWriteResPair<WriteFSqrt80,  [SLM_FPC_RSV0,SLMFPDivider], 40, [1,40]>;
261 defm : SLMWriteResPair<WriteDPPD,   [SLM_FPC_RSV1], 12,  [8], 5, 1>;
262 defm : SLMWriteResPair<WriteDPPS,   [SLM_FPC_RSV1], 15, [12], 9, 1>;
263 defm : X86WriteResPairUnsupported<WriteDPPSY>;
264 defm : X86WriteResPairUnsupported<WriteDPPSZ>;
265 defm : SLMWriteResPair<WriteFSign,  [SLM_FPC_RSV01], 1>;
266 defm : SLMWriteResPair<WriteFRnd,   [SLM_FPC_RSV1], 3>;
267 defm : SLMWriteResPair<WriteFRndY,  [SLM_FPC_RSV1], 3>;
268 defm : X86WriteResPairUnsupported<WriteFRndZ>;
269 defm : SLMWriteResPair<WriteFLogic, [SLM_FPC_RSV01], 1>;
270 defm : SLMWriteResPair<WriteFLogicY, [SLM_FPC_RSV01], 1>;
271 defm : X86WriteResPairUnsupported<WriteFLogicZ>;
272 defm : SLMWriteResPair<WriteFTest,  [SLM_FPC_RSV01], 1>;
273 defm : SLMWriteResPair<WriteFTestY, [SLM_FPC_RSV01], 1>;
274 defm : X86WriteResPairUnsupported<WriteFTestZ>;
275 defm : SLMWriteResPair<WriteFShuffle,  [SLM_FPC_RSV0], 1>;
276 defm : SLMWriteResPair<WriteFShuffleY, [SLM_FPC_RSV0], 1>;
277 defm : X86WriteResPairUnsupported<WriteFShuffleZ>;
278 defm : SLMWriteResPair<WriteFVarShuffle, [SLM_FPC_RSV0],  1>;
279 defm : SLMWriteResPair<WriteFVarShuffleY,[SLM_FPC_RSV0],  1>;
280 defm : X86WriteResPairUnsupported<WriteFVarShuffleZ>;
281 defm : SLMWriteResPair<WriteFBlend,  [SLM_FPC_RSV0],  1>;
282 defm : X86WriteResPairUnsupported<WriteFBlendY>;
283 defm : X86WriteResPairUnsupported<WriteFBlendZ>;
284 defm : SLMWriteResPair<WriteFVarBlend, [SLM_FPC_RSV0], 4, [4], 2, 1>;
285 defm : X86WriteResPairUnsupported<WriteFVarBlendY>;
286 defm : X86WriteResPairUnsupported<WriteFVarBlendZ>;
287 defm : X86WriteResPairUnsupported<WriteFShuffle256>;
288 defm : X86WriteResPairUnsupported<WriteFVarShuffle256>;
289
290 // Conversion between integer and float.
291 defm : SLMWriteResPair<WriteCvtSS2I,   [SLM_FPC_RSV0], 5>;
292 defm : SLMWriteResPair<WriteCvtPS2I,   [SLM_FPC_RSV0], 5, [2]>;
293 defm : SLMWriteResPair<WriteCvtPS2IY,  [SLM_FPC_RSV0], 5, [2]>;
294 defm : X86WriteResPairUnsupported<WriteCvtPS2IZ>;
295 defm : SLMWriteResPair<WriteCvtSD2I,   [SLM_FPC_RSV0], 5>;
296 defm : SLMWriteResPair<WriteCvtPD2I,   [SLM_FPC_RSV0], 5, [2]>;
297 defm : SLMWriteResPair<WriteCvtPD2IY,  [SLM_FPC_RSV0], 5, [2]>;
298 defm : X86WriteResPairUnsupported<WriteCvtPD2IZ>;
299
300 defm : SLMWriteResPair<WriteCvtI2SS,   [SLM_FPC_RSV0], 5, [2]>;
301 defm : SLMWriteResPair<WriteCvtI2PS,   [SLM_FPC_RSV0], 5, [2]>;
302 defm : SLMWriteResPair<WriteCvtI2PSY,  [SLM_FPC_RSV0], 5, [2]>;
303 defm : X86WriteResPairUnsupported<WriteCvtI2PSZ>;
304 defm : SLMWriteResPair<WriteCvtI2SD,   [SLM_FPC_RSV0], 5, [2]>;
305 defm : SLMWriteResPair<WriteCvtI2PD,   [SLM_FPC_RSV0], 5, [2]>;
306 defm : SLMWriteResPair<WriteCvtI2PDY,  [SLM_FPC_RSV0], 5, [2]>;
307 defm : X86WriteResPairUnsupported<WriteCvtI2PDZ>;
308
309 defm : SLMWriteResPair<WriteCvtSS2SD,  [SLM_FPC_RSV0], 4, [2]>;
310 defm : SLMWriteResPair<WriteCvtPS2PD,  [SLM_FPC_RSV0], 5, [2]>;
311 defm : SLMWriteResPair<WriteCvtPS2PDY, [SLM_FPC_RSV0], 5, [2]>;
312 defm : X86WriteResPairUnsupported<WriteCvtPS2PDZ>;
313 defm : SLMWriteResPair<WriteCvtSD2SS,  [SLM_FPC_RSV0], 4, [2]>;
314 defm : SLMWriteResPair<WriteCvtPD2PS,  [SLM_FPC_RSV0], 5, [2]>;
315 defm : SLMWriteResPair<WriteCvtPD2PSY, [SLM_FPC_RSV0], 5, [2]>;
316 defm : X86WriteResPairUnsupported<WriteCvtPD2PSZ>;
317
318 defm : X86WriteResPairUnsupported<WriteCvtPH2PS>;
319 defm : X86WriteResPairUnsupported<WriteCvtPH2PSY>;
320 defm : X86WriteResPairUnsupported<WriteCvtPH2PSZ>;
321
322 defm : X86WriteResUnsupported<WriteCvtPS2PH>;
323 defm : X86WriteResUnsupported<WriteCvtPS2PHY>;
324 defm : X86WriteResUnsupported<WriteCvtPS2PHZ>;
325 defm : X86WriteResUnsupported<WriteCvtPS2PHSt>;
326 defm : X86WriteResUnsupported<WriteCvtPS2PHYSt>;
327 defm : X86WriteResUnsupported<WriteCvtPS2PHZSt>;
328
329 // Vector integer operations.
330 def  : WriteRes<WriteVecLoad,         [SLM_MEC_RSV]> { let Latency = 3; }
331 def  : WriteRes<WriteVecLoadX,        [SLM_MEC_RSV]> { let Latency = 3; }
332 def  : WriteRes<WriteVecLoadY,        [SLM_MEC_RSV]> { let Latency = 3; }
333 def  : WriteRes<WriteVecLoadNT,       [SLM_MEC_RSV]> { let Latency = 3; }
334 def  : WriteRes<WriteVecLoadNTY,      [SLM_MEC_RSV]> { let Latency = 3; }
335 def  : WriteRes<WriteVecMaskedLoad,   [SLM_MEC_RSV]> { let Latency = 3; }
336 def  : WriteRes<WriteVecMaskedLoadY,  [SLM_MEC_RSV]> { let Latency = 3; }
337 def  : WriteRes<WriteVecStore,        [SLM_MEC_RSV]>;
338 def  : WriteRes<WriteVecStoreX,       [SLM_MEC_RSV]>;
339 def  : WriteRes<WriteVecStoreY,       [SLM_MEC_RSV]>;
340 def  : WriteRes<WriteVecStoreNT,      [SLM_MEC_RSV]>;
341 def  : WriteRes<WriteVecStoreNTY,     [SLM_MEC_RSV]>;
342 def  : WriteRes<WriteVecMaskedStore32,    [SLM_MEC_RSV]>;
343 def  : WriteRes<WriteVecMaskedStore32Y,   [SLM_MEC_RSV]>;
344 def  : WriteRes<WriteVecMaskedStore64,    [SLM_MEC_RSV]>;
345 def  : WriteRes<WriteVecMaskedStore64Y,   [SLM_MEC_RSV]>;
346 def  : WriteRes<WriteVecMove,         [SLM_FPC_RSV01]>;
347 def  : WriteRes<WriteVecMoveX,        [SLM_FPC_RSV01]>;
348 def  : WriteRes<WriteVecMoveY,        [SLM_FPC_RSV01]>;
349 defm : X86WriteResUnsupported<WriteVecMoveZ>;
350 def  : WriteRes<WriteVecMoveToGpr,    [SLM_IEC_RSV01]>;
351 def  : WriteRes<WriteVecMoveFromGpr,  [SLM_IEC_RSV01]>;
352
353 defm : SLMWriteResPair<WriteVecShift,    [SLM_FPC_RSV0],  2, [2], 2>;
354 defm : SLMWriteResPair<WriteVecShiftX,   [SLM_FPC_RSV0],  2, [2], 2>;
355 defm : SLMWriteResPair<WriteVecShiftY,   [SLM_FPC_RSV0],  2, [2], 2>;
356 defm : X86WriteResPairUnsupported<WriteVecShiftZ>;
357 defm : SLMWriteResPair<WriteVecShiftImm, [SLM_FPC_RSV0],  1>;
358 defm : SLMWriteResPair<WriteVecShiftImmX,[SLM_FPC_RSV0],  1>;
359 defm : SLMWriteResPair<WriteVecShiftImmY,[SLM_FPC_RSV0],  1>;
360 defm : X86WriteResPairUnsupported<WriteVecShiftImmZ>;
361 defm : SLMWriteResPair<WriteVarVecShift,  [SLM_FPC_RSV0],  1>;
362 defm : X86WriteResPairUnsupported<WriteVarVecShiftY>;
363 defm : X86WriteResPairUnsupported<WriteVarVecShiftZ>;
364
365 defm : SLMWriteResPair<WriteVecLogic, [SLM_FPC_RSV01], 1>;
366 defm : SLMWriteResPair<WriteVecLogicX,[SLM_FPC_RSV01], 1>;
367 defm : SLMWriteResPair<WriteVecLogicY,[SLM_FPC_RSV01], 1>;
368 defm : X86WriteResPairUnsupported<WriteVecLogicZ>;
369 defm : SLMWriteResPair<WriteVecTest,  [SLM_FPC_RSV01], 1>;
370 defm : SLMWriteResPair<WriteVecTestY, [SLM_FPC_RSV01], 1>;
371 defm : X86WriteResPairUnsupported<WriteVecTestZ>;
372 defm : SLMWriteResPair<WriteVecALU,   [SLM_FPC_RSV01],  1>;
373 defm : SLMWriteResPair<WriteVecALUX,  [SLM_FPC_RSV01],  1>;
374 defm : SLMWriteResPair<WriteVecALUY,  [SLM_FPC_RSV01],  1>;
375 defm : X86WriteResPairUnsupported<WriteVecALUZ>;
376 defm : SLMWriteResPair<WriteVecIMul,  [SLM_FPC_RSV0],   4>;
377 defm : SLMWriteResPair<WriteVecIMulX, [SLM_FPC_RSV0],   5, [2]>;
378 defm : SLMWriteResPair<WriteVecIMulY, [SLM_FPC_RSV0],   5, [2]>;
379 defm : X86WriteResPairUnsupported<WriteVecIMulZ>;
380 // FIXME: The below is closer to correct, but caused some perf regressions.
381 //defm : SLMWriteResPair<WritePMULLD,  [SLM_FPC_RSV0],   11, [11], 7>;
382 defm : SLMWriteResPair<WritePMULLD,  [SLM_FPC_RSV0],   4>;
383 defm : SLMWriteResPair<WritePMULLDY, [SLM_FPC_RSV0],   4>;
384 defm : X86WriteResPairUnsupported<WritePMULLDZ>;
385 defm : SLMWriteResPair<WriteShuffle,  [SLM_FPC_RSV0],  1>;
386 defm : SLMWriteResPair<WriteShuffleY, [SLM_FPC_RSV0],  1>;
387 defm : X86WriteResPairUnsupported<WriteShuffleZ>;
388 defm : SLMWriteResPair<WriteShuffleX, [SLM_FPC_RSV0],  1>;
389 defm : SLMWriteResPair<WriteVarShuffle,  [SLM_FPC_RSV0],  1>;
390 defm : SLMWriteResPair<WriteVarShuffleX, [SLM_FPC_RSV0],  5, [5], 4, 1>;
391 defm : X86WriteResPairUnsupported<WriteVarShuffleY>;
392 defm : X86WriteResPairUnsupported<WriteVarShuffleZ>;
393 defm : SLMWriteResPair<WriteBlend,  [SLM_FPC_RSV0],  1>;
394 defm : SLMWriteResPair<WriteBlendY, [SLM_FPC_RSV0],  1>;
395 defm : X86WriteResPairUnsupported<WriteBlendZ>;
396 defm : SLMWriteResPair<WriteVarBlend, [SLM_FPC_RSV0], 4, [4], 2, 1>;
397 defm : X86WriteResPairUnsupported<WriteVarBlendY>;
398 defm : X86WriteResPairUnsupported<WriteVarBlendZ>;
399 defm : SLMWriteResPair<WriteMPSAD,  [SLM_FPC_RSV0],  7, [5], 3, 1>;
400 defm : X86WriteResPairUnsupported<WriteMPSADY>;
401 defm : X86WriteResPairUnsupported<WriteMPSADZ>;
402 defm : SLMWriteResPair<WritePSADBW,  [SLM_FPC_RSV0],  4>;
403 defm : SLMWriteResPair<WritePSADBWX, [SLM_FPC_RSV0],  5, [2]>;
404 defm : X86WriteResPairUnsupported<WritePSADBWY>;
405 defm : X86WriteResPairUnsupported<WritePSADBWZ>;
406 defm : SLMWriteResPair<WritePHMINPOS,  [SLM_FPC_RSV0],   4>;
407 defm : X86WriteResPairUnsupported<WriteShuffle256>;
408 defm : X86WriteResPairUnsupported<WriteVarShuffle256>;
409 defm : X86WriteResPairUnsupported<WriteVPMOV256>;
410
411 // Vector insert/extract operations.
412 defm : SLMWriteResPair<WriteVecInsert, [SLM_FPC_RSV0],  1>;
413
414 def  : WriteRes<WriteVecExtract, [SLM_FPC_RSV0]>;
415 def  : WriteRes<WriteVecExtractSt, [SLM_FPC_RSV0, SLM_MEC_RSV]> {
416   let Latency = 4;
417   let NumMicroOps = 2;
418   let ResourceCycles = [1, 2];
419 }
420
421 ////////////////////////////////////////////////////////////////////////////////
422 // Horizontal add/sub  instructions.
423 ////////////////////////////////////////////////////////////////////////////////
424
425 defm : SLMWriteResPair<WriteFHAdd,   [SLM_FPC_RSV1],  6, [6], 4, 1>;
426 defm : X86WriteResPairUnsupported<WriteFHAddY>;
427 defm : X86WriteResPairUnsupported<WriteFHAddZ>;
428 defm : SLMWriteResPair<WritePHAdd,   [SLM_FPC_RSV01], 6, [6], 3, 1>;
429 defm : SLMWriteResPair<WritePHAddX,  [SLM_FPC_RSV01], 6, [6], 3, 1>;
430 defm : X86WriteResPairUnsupported<WritePHAddY>;
431 defm : X86WriteResPairUnsupported<WritePHAddZ>;
432
433 // String instructions.
434 // Packed Compare Implicit Length Strings, Return Mask
435 defm : SLMWriteResPair<WritePCmpIStrM,  [SLM_FPC_RSV0], 13, [13], 5, 1>;
436
437 // Packed Compare Explicit Length Strings, Return Mask
438 defm : SLMWriteResPair<WritePCmpEStrM,  [SLM_FPC_RSV0], 17, [17], 8, 1>;
439
440 // Packed Compare Implicit Length Strings, Return Index
441 defm : SLMWriteResPair<WritePCmpIStrI,  [SLM_FPC_RSV0], 17, [17], 6, 1>;
442
443 // Packed Compare Explicit Length Strings, Return Index
444 defm : SLMWriteResPair<WritePCmpEStrI,  [SLM_FPC_RSV0], 21, [21], 9, 1>;
445
446 // MOVMSK Instructions.
447 def : WriteRes<WriteFMOVMSK,    [SLM_FPC_RSV1]> { let Latency = 4; }
448 def : WriteRes<WriteVecMOVMSK,  [SLM_FPC_RSV1]> { let Latency = 4; }
449 def : WriteRes<WriteVecMOVMSKY, [SLM_FPC_RSV1]> { let Latency = 4; }
450 def : WriteRes<WriteMMXMOVMSK,  [SLM_FPC_RSV1]> { let Latency = 4; }
451
452 // AES Instructions.
453 defm : SLMWriteResPair<WriteAESDecEnc, [SLM_FPC_RSV0], 8, [5]>;
454 defm : SLMWriteResPair<WriteAESIMC,    [SLM_FPC_RSV0], 8, [5]>;
455 defm : SLMWriteResPair<WriteAESKeyGen, [SLM_FPC_RSV0], 8, [5]>;
456
457 // Carry-less multiplication instructions.
458 defm : SLMWriteResPair<WriteCLMul, [SLM_FPC_RSV0], 10, [10], 8, 1>;
459
460 def : WriteRes<WriteSystem,     [SLM_FPC_RSV0]> { let Latency = 100; }
461 def : WriteRes<WriteMicrocoded, [SLM_FPC_RSV0]> { let Latency = 100; }
462 def : WriteRes<WriteFence, [SLM_MEC_RSV]>;
463 def : WriteRes<WriteNop, []>;
464
465 // Remaining SLM instrs.
466
467 def SLMWriteResGroup1rr : SchedWriteRes<[SLM_FPC_RSV01]> {
468   let Latency = 4;
469   let NumMicroOps = 2;
470   let ResourceCycles = [8];
471 }
472 def: InstRW<[SLMWriteResGroup1rr], (instrs MMX_PADDQrr, PADDQrr,
473                                            MMX_PSUBQrr, PSUBQrr,
474                                            PCMPEQQrr)>;
475
476 def SLMWriteResGroup1rm : SchedWriteRes<[SLM_MEC_RSV,SLM_FPC_RSV01]> {
477   let Latency = 7;
478   let NumMicroOps = 3;
479   let ResourceCycles = [1,8];
480 }
481 def: InstRW<[SLMWriteResGroup1rm], (instrs MMX_PADDQrm, PADDQrm,
482                                            MMX_PSUBQrm, PSUBQrm,
483                                            PCMPEQQrm)>;
484
485 ///////////////////////////////////////////////////////////////////////////////
486 // Dependency breaking instructions.
487 ///////////////////////////////////////////////////////////////////////////////
488
489 def : IsZeroIdiomFunction<[
490   // GPR Zero-idioms.
491   DepBreakingClass<[ XOR32rr ], ZeroIdiomPredicate>,
492
493   // SSE Zero-idioms.
494   DepBreakingClass<[
495     // fp variants.
496     XORPSrr, XORPDrr,
497
498     // int variants.
499     PXORrr,
500   ], ZeroIdiomPredicate>,
501 ]>;
502
503 } // SchedModel