1//=- X86ScheduleZnver1.td - X86 Znver1 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 Znver1 to support instruction 10// scheduling and other instruction cost heuristics. 11// 12//===----------------------------------------------------------------------===// 13 14def Znver1Model : SchedMachineModel { 15 // Zen can decode 4 instructions per cycle. 16 let IssueWidth = 4; 17 // Based on the reorder buffer we define MicroOpBufferSize 18 let MicroOpBufferSize = 192; 19 let LoadLatency = 4; 20 let MispredictPenalty = 17; 21 let HighLatency = 25; 22 let PostRAScheduler = 1; 23 24 // FIXME: This variable is required for incomplete model. 25 // We haven't catered all instructions. 26 // So, we reset the value of this variable so as to 27 // say that the model is incomplete. 28 let CompleteModel = 0; 29} 30 31let SchedModel = Znver1Model in { 32 33// Zen can issue micro-ops to 10 different units in one cycle. 34// These are 35// * Four integer ALU units (ZALU0, ZALU1, ZALU2, ZALU3) 36// * Two AGU units (ZAGU0, ZAGU1) 37// * Four FPU units (ZFPU0, ZFPU1, ZFPU2, ZFPU3) 38// AGUs feed load store queues @two loads and 1 store per cycle. 39 40// Four ALU units are defined below 41def ZnALU0 : ProcResource<1>; 42def ZnALU1 : ProcResource<1>; 43def ZnALU2 : ProcResource<1>; 44def ZnALU3 : ProcResource<1>; 45 46// Two AGU units are defined below 47def ZnAGU0 : ProcResource<1>; 48def ZnAGU1 : ProcResource<1>; 49 50// Four FPU units are defined below 51def ZnFPU0 : ProcResource<1>; 52def ZnFPU1 : ProcResource<1>; 53def ZnFPU2 : ProcResource<1>; 54def ZnFPU3 : ProcResource<1>; 55 56// FPU grouping 57def ZnFPU013 : ProcResGroup<[ZnFPU0, ZnFPU1, ZnFPU3]>; 58def ZnFPU01 : ProcResGroup<[ZnFPU0, ZnFPU1]>; 59def ZnFPU12 : ProcResGroup<[ZnFPU1, ZnFPU2]>; 60def ZnFPU13 : ProcResGroup<[ZnFPU1, ZnFPU3]>; 61def ZnFPU23 : ProcResGroup<[ZnFPU2, ZnFPU3]>; 62def ZnFPU02 : ProcResGroup<[ZnFPU0, ZnFPU2]>; 63def ZnFPU03 : ProcResGroup<[ZnFPU0, ZnFPU3]>; 64 65// Below are the grouping of the units. 66// Micro-ops to be issued to multiple units are tackled this way. 67 68// ALU grouping 69// ZnALU03 - 0,3 grouping 70def ZnALU03: ProcResGroup<[ZnALU0, ZnALU3]>; 71 72// 56 Entry (14x4 entries) Int Scheduler 73def ZnALU : ProcResGroup<[ZnALU0, ZnALU1, ZnALU2, ZnALU3]> { 74 let BufferSize=56; 75} 76 77// 28 Entry (14x2) AGU group. AGUs can't be used for all ALU operations 78// but are relevant for some instructions 79def ZnAGU : ProcResGroup<[ZnAGU0, ZnAGU1]> { 80 let BufferSize=28; 81} 82 83// Integer Multiplication issued on ALU1. 84def ZnMultiplier : ProcResource<1>; 85 86// Integer division issued on ALU2. 87def ZnDivider : ProcResource<1>; 88 89// 4 Cycles integer load-to use Latency is captured 90def : ReadAdvance<ReadAfterLd, 4>; 91 92// 8 Cycles vector load-to use Latency is captured 93def : ReadAdvance<ReadAfterVecLd, 8>; 94def : ReadAdvance<ReadAfterVecXLd, 8>; 95def : ReadAdvance<ReadAfterVecYLd, 8>; 96 97def : ReadAdvance<ReadInt2Fpu, 0>; 98 99// The Integer PRF for Zen is 168 entries, and it holds the architectural and 100// speculative version of the 64-bit integer registers. 101// Reference: "Software Optimization Guide for AMD Family 17h Processors" 102def ZnIntegerPRF : RegisterFile<168, [GR64, CCR]>; 103 104// 36 Entry (9x4 entries) floating-point Scheduler 105def ZnFPU : ProcResGroup<[ZnFPU0, ZnFPU1, ZnFPU2, ZnFPU3]> { 106let BufferSize=36; 107} 108 109// The Zen FP Retire Queue renames SIMD and FP uOps onto a pool of 160 128-bit 110// registers. Operations on 256-bit data types are cracked into two COPs. 111// Reference: "Software Optimization Guide for AMD Family 17h Processors" 112def ZnFpuPRF: RegisterFile<160, [VR64, VR128, VR256], [1, 1, 2]>; 113 114// The unit can track up to 192 macro ops in-flight. 115// The retire unit handles in-order commit of up to 8 macro ops per cycle. 116// Reference: "Software Optimization Guide for AMD Family 17h Processors" 117// To be noted, the retire unit is shared between integer and FP ops. 118// In SMT mode it is 96 entry per thread. But, we do not use the conservative 119// value here because there is currently no way to fully mode the SMT mode, 120// so there is no point in trying. 121def ZnRCU : RetireControlUnit<192, 8>; 122 123// FIXME: there are 72 read buffers and 44 write buffers. 124 125// (a folded load is an instruction that loads and does some operation) 126// Ex: ADDPD xmm,[mem]-> This instruction has two micro-ops 127// Instructions with folded loads are usually micro-fused, so they only appear 128// as two micro-ops. 129// a. load and 130// b. addpd 131// This multiclass is for folded loads for integer units. 132multiclass ZnWriteResPair<X86FoldableSchedWrite SchedRW, 133 list<ProcResourceKind> ExePorts, 134 int Lat, list<int> Res = [], int UOps = 1, 135 int LoadLat = 4, int LoadUOps = 1> { 136 // Register variant takes 1-cycle on Execution Port. 137 def : WriteRes<SchedRW, ExePorts> { 138 let Latency = Lat; 139 let ResourceCycles = Res; 140 let NumMicroOps = UOps; 141 } 142 143 // Memory variant also uses a cycle on ZnAGU 144 // adds LoadLat cycles to the latency (default = 4). 145 def : WriteRes<SchedRW.Folded, !listconcat([ZnAGU], ExePorts)> { 146 let Latency = !add(Lat, LoadLat); 147 let ResourceCycles = !if(!empty(Res), [], !listconcat([1], Res)); 148 let NumMicroOps = !add(UOps, LoadUOps); 149 } 150} 151 152// This multiclass is for folded loads for floating point units. 153multiclass ZnWriteResFpuPair<X86FoldableSchedWrite SchedRW, 154 list<ProcResourceKind> ExePorts, 155 int Lat, list<int> Res = [], int UOps = 1, 156 int LoadLat = 7, int LoadUOps = 0> { 157 // Register variant takes 1-cycle on Execution Port. 158 def : WriteRes<SchedRW, ExePorts> { 159 let Latency = Lat; 160 let ResourceCycles = Res; 161 let NumMicroOps = UOps; 162 } 163 164 // Memory variant also uses a cycle on ZnAGU 165 // adds LoadLat cycles to the latency (default = 7). 166 def : WriteRes<SchedRW.Folded, !listconcat([ZnAGU], ExePorts)> { 167 let Latency = !add(Lat, LoadLat); 168 let ResourceCycles = !if(!empty(Res), [], !listconcat([1], Res)); 169 let NumMicroOps = !add(UOps, LoadUOps); 170 } 171} 172 173// WriteRMW is set for instructions with Memory write 174// operation in codegen 175def : WriteRes<WriteRMW, [ZnAGU]>; 176 177def : WriteRes<WriteStore, [ZnAGU]>; 178def : WriteRes<WriteStoreNT, [ZnAGU]>; 179def : WriteRes<WriteMove, [ZnALU]>; 180def : WriteRes<WriteLoad, [ZnAGU]> { let Latency = 8; } 181 182def : WriteRes<WriteZero, []>; 183def : WriteRes<WriteLEA, [ZnALU]>; 184defm : ZnWriteResPair<WriteALU, [ZnALU], 1>; 185defm : ZnWriteResPair<WriteADC, [ZnALU], 1>; 186 187defm : ZnWriteResPair<WriteIMul8, [ZnALU1, ZnMultiplier], 4>; 188//defm : ZnWriteResPair<WriteIMul16, [ZnALU1, ZnMultiplier], 4>; 189//defm : ZnWriteResPair<WriteIMul16Imm, [ZnALU1, ZnMultiplier], 4>; 190//defm : ZnWriteResPair<WriteIMul16Reg, [ZnALU1, ZnMultiplier], 4>; 191//defm : ZnWriteResPair<WriteIMul32, [ZnALU1, ZnMultiplier], 4>; 192//defm : ZnWriteResPair<WriteIMul32Imm, [ZnALU1, ZnMultiplier], 4>; 193//defm : ZnWriteResPair<WriteIMul32Reg, [ZnALU1, ZnMultiplier], 4>; 194//defm : ZnWriteResPair<WriteIMul64, [ZnALU1, ZnMultiplier], 4, [1,1], 2>; 195//defm : ZnWriteResPair<WriteIMul64Imm, [ZnALU1, ZnMultiplier], 4, [1,1], 2>; 196//defm : ZnWriteResPair<WriteIMul64Reg, [ZnALU1, ZnMultiplier], 4, [1,1], 2>; 197 198defm : X86WriteRes<WriteBSWAP32, [ZnALU], 1, [4], 1>; 199defm : X86WriteRes<WriteBSWAP64, [ZnALU], 1, [4], 1>; 200defm : X86WriteRes<WriteCMPXCHG, [ZnALU], 1, [1], 1>; 201defm : X86WriteRes<WriteCMPXCHGRMW,[ZnALU,ZnAGU], 8, [1,1], 5>; 202defm : X86WriteRes<WriteXCHG, [ZnALU], 1, [2], 2>; 203 204defm : ZnWriteResPair<WriteShift, [ZnALU], 1>; 205defm : ZnWriteResPair<WriteShiftCL, [ZnALU], 1>; 206defm : ZnWriteResPair<WriteRotate, [ZnALU], 1>; 207defm : ZnWriteResPair<WriteRotateCL, [ZnALU], 1>; 208 209defm : X86WriteRes<WriteSHDrri, [ZnALU], 1, [1], 1>; 210defm : X86WriteResUnsupported<WriteSHDrrcl>; 211defm : X86WriteResUnsupported<WriteSHDmri>; 212defm : X86WriteResUnsupported<WriteSHDmrcl>; 213 214defm : ZnWriteResPair<WriteJump, [ZnALU], 1>; 215defm : ZnWriteResFpuPair<WriteCRC32, [ZnFPU0], 3>; 216 217defm : ZnWriteResPair<WriteCMOV, [ZnALU], 1>; 218def : WriteRes<WriteSETCC, [ZnALU]>; 219def : WriteRes<WriteSETCCStore, [ZnALU, ZnAGU]>; 220defm : X86WriteRes<WriteLAHFSAHF, [ZnALU], 2, [1], 2>; 221 222defm : X86WriteRes<WriteBitTest, [ZnALU], 1, [1], 1>; 223defm : X86WriteRes<WriteBitTestImmLd, [ZnALU,ZnAGU], 5, [1,1], 2>; 224defm : X86WriteRes<WriteBitTestRegLd, [ZnALU,ZnAGU], 5, [1,1], 2>; 225defm : X86WriteRes<WriteBitTestSet, [ZnALU], 2, [1], 2>; 226//defm : X86WriteRes<WriteBitTestSetImmLd, [ZnALU,ZnAGU], 5, [1,1], 2>; 227//defm : X86WriteRes<WriteBitTestSetRegLd, [ZnALU,ZnAGU], 5, [1,1], 2>; 228 229// Bit counts. 230defm : ZnWriteResPair<WriteBSF, [ZnALU], 3>; 231defm : ZnWriteResPair<WriteBSR, [ZnALU], 3>; 232defm : ZnWriteResPair<WriteLZCNT, [ZnALU], 2>; 233defm : ZnWriteResPair<WriteTZCNT, [ZnALU], 2>; 234defm : ZnWriteResPair<WritePOPCNT, [ZnALU], 1>; 235 236// Treat misc copies as a move. 237def : InstRW<[WriteMove], (instrs COPY)>; 238 239// BMI1 BEXTR/BLS, BMI2 BZHI 240defm : ZnWriteResPair<WriteBEXTR, [ZnALU], 1>; 241//defm : ZnWriteResPair<WriteBLS, [ZnALU], 2>; 242defm : ZnWriteResPair<WriteBZHI, [ZnALU], 1>; 243 244// IDIV 245defm : ZnWriteResPair<WriteDiv8, [ZnALU2, ZnDivider], 15, [1,15], 1>; 246defm : ZnWriteResPair<WriteDiv16, [ZnALU2, ZnDivider], 17, [1,17], 2>; 247defm : ZnWriteResPair<WriteDiv32, [ZnALU2, ZnDivider], 25, [1,25], 2>; 248defm : ZnWriteResPair<WriteDiv64, [ZnALU2, ZnDivider], 41, [1,41], 2>; 249defm : ZnWriteResPair<WriteIDiv8, [ZnALU2, ZnDivider], 15, [1,15], 1>; 250defm : ZnWriteResPair<WriteIDiv16, [ZnALU2, ZnDivider], 17, [1,17], 2>; 251defm : ZnWriteResPair<WriteIDiv32, [ZnALU2, ZnDivider], 25, [1,25], 2>; 252defm : ZnWriteResPair<WriteIDiv64, [ZnALU2, ZnDivider], 41, [1,41], 2>; 253 254// IMULH 255def : WriteRes<WriteIMulH, [ZnALU1, ZnMultiplier]>{ 256 let Latency = 4; 257} 258 259// Floating point operations 260defm : X86WriteRes<WriteFLoad, [ZnAGU], 8, [1], 1>; 261defm : X86WriteRes<WriteFLoadX, [ZnAGU], 8, [1], 1>; 262defm : X86WriteRes<WriteFLoadY, [ZnAGU], 8, [1], 1>; 263defm : X86WriteRes<WriteFMaskedLoad, [ZnAGU,ZnFPU01], 8, [1,1], 1>; 264defm : X86WriteRes<WriteFMaskedLoadY, [ZnAGU,ZnFPU01], 8, [1,2], 2>; 265defm : X86WriteRes<WriteFStore, [ZnAGU], 1, [1], 1>; 266defm : X86WriteRes<WriteFStoreX, [ZnAGU], 1, [1], 1>; 267defm : X86WriteRes<WriteFStoreY, [ZnAGU], 1, [1], 1>; 268defm : X86WriteRes<WriteFStoreNT, [ZnAGU,ZnFPU2], 8, [1,1], 1>; 269defm : X86WriteRes<WriteFStoreNTX, [ZnAGU], 1, [1], 1>; 270defm : X86WriteRes<WriteFStoreNTY, [ZnAGU], 1, [1], 1>; 271defm : X86WriteRes<WriteFMaskedStore, [ZnAGU,ZnFPU01], 4, [1,1], 1>; 272defm : X86WriteRes<WriteFMaskedStoreY, [ZnAGU,ZnFPU01], 5, [1,2], 2>; 273defm : X86WriteRes<WriteFMove, [ZnFPU], 1, [1], 1>; 274defm : X86WriteRes<WriteFMoveX, [ZnFPU], 1, [1], 1>; 275defm : X86WriteRes<WriteFMoveY, [ZnFPU], 1, [1], 1>; 276 277defm : ZnWriteResFpuPair<WriteFAdd, [ZnFPU0], 3>; 278defm : ZnWriteResFpuPair<WriteFAddX, [ZnFPU0], 3>; 279defm : ZnWriteResFpuPair<WriteFAddY, [ZnFPU0], 3>; 280defm : X86WriteResPairUnsupported<WriteFAddZ>; 281defm : ZnWriteResFpuPair<WriteFAdd64, [ZnFPU0], 3>; 282defm : ZnWriteResFpuPair<WriteFAdd64X, [ZnFPU0], 3>; 283defm : ZnWriteResFpuPair<WriteFAdd64Y, [ZnFPU0], 3>; 284defm : X86WriteResPairUnsupported<WriteFAdd64Z>; 285defm : ZnWriteResFpuPair<WriteFCmp, [ZnFPU0], 3>; 286defm : ZnWriteResFpuPair<WriteFCmpX, [ZnFPU0], 3>; 287defm : ZnWriteResFpuPair<WriteFCmpY, [ZnFPU0], 3>; 288defm : X86WriteResPairUnsupported<WriteFCmpZ>; 289defm : ZnWriteResFpuPair<WriteFCmp64, [ZnFPU0], 3>; 290defm : ZnWriteResFpuPair<WriteFCmp64X, [ZnFPU0], 3>; 291defm : ZnWriteResFpuPair<WriteFCmp64Y, [ZnFPU0], 3>; 292defm : X86WriteResPairUnsupported<WriteFCmp64Z>; 293defm : ZnWriteResFpuPair<WriteFCom, [ZnFPU0], 3>; 294defm : ZnWriteResFpuPair<WriteFBlend, [ZnFPU01], 1>; 295defm : ZnWriteResFpuPair<WriteFBlendY, [ZnFPU01], 1>; 296defm : X86WriteResPairUnsupported<WriteFBlendZ>; 297defm : ZnWriteResFpuPair<WriteFVarBlend, [ZnFPU01], 1>; 298defm : ZnWriteResFpuPair<WriteFVarBlendY,[ZnFPU01], 1>; 299defm : X86WriteResPairUnsupported<WriteFVarBlendZ>; 300defm : ZnWriteResFpuPair<WriteVarBlend, [ZnFPU0], 1>; 301defm : ZnWriteResFpuPair<WriteVarBlendY, [ZnFPU0], 1>; 302defm : X86WriteResPairUnsupported<WriteVarBlendZ>; 303defm : ZnWriteResFpuPair<WriteCvtSS2I, [ZnFPU3], 5>; 304defm : ZnWriteResFpuPair<WriteCvtPS2I, [ZnFPU3], 5>; 305defm : ZnWriteResFpuPair<WriteCvtPS2IY, [ZnFPU3], 5>; 306defm : X86WriteResPairUnsupported<WriteCvtPS2IZ>; 307defm : ZnWriteResFpuPair<WriteCvtSD2I, [ZnFPU3], 5>; 308defm : ZnWriteResFpuPair<WriteCvtPD2I, [ZnFPU3], 5>; 309defm : ZnWriteResFpuPair<WriteCvtPD2IY, [ZnFPU3], 5>; 310defm : X86WriteResPairUnsupported<WriteCvtPD2IZ>; 311defm : ZnWriteResFpuPair<WriteCvtI2SS, [ZnFPU3], 5>; 312defm : ZnWriteResFpuPair<WriteCvtI2PS, [ZnFPU3], 5>; 313defm : ZnWriteResFpuPair<WriteCvtI2PSY, [ZnFPU3], 5>; 314defm : X86WriteResPairUnsupported<WriteCvtI2PSZ>; 315defm : ZnWriteResFpuPair<WriteCvtI2SD, [ZnFPU3], 5>; 316defm : ZnWriteResFpuPair<WriteCvtI2PD, [ZnFPU3], 5>; 317defm : ZnWriteResFpuPair<WriteCvtI2PDY, [ZnFPU3], 5>; 318defm : X86WriteResPairUnsupported<WriteCvtI2PDZ>; 319defm : ZnWriteResFpuPair<WriteFDiv, [ZnFPU3], 15>; 320defm : ZnWriteResFpuPair<WriteFDivX, [ZnFPU3], 15>; 321//defm : ZnWriteResFpuPair<WriteFDivY, [ZnFPU3], 15>; 322defm : X86WriteResPairUnsupported<WriteFDivZ>; 323defm : ZnWriteResFpuPair<WriteFDiv64, [ZnFPU3], 15>; 324defm : ZnWriteResFpuPair<WriteFDiv64X, [ZnFPU3], 15>; 325//defm : ZnWriteResFpuPair<WriteFDiv64Y, [ZnFPU3], 15>; 326defm : X86WriteResPairUnsupported<WriteFDiv64Z>; 327defm : ZnWriteResFpuPair<WriteFSign, [ZnFPU3], 2>; 328defm : ZnWriteResFpuPair<WriteFRnd, [ZnFPU3], 4, [1], 1, 7, 1>; // FIXME: Should folds require 1 extra uops? 329defm : ZnWriteResFpuPair<WriteFRndY, [ZnFPU3], 4, [1], 1, 7, 1>; // FIXME: Should folds require 1 extra uops? 330defm : X86WriteResPairUnsupported<WriteFRndZ>; 331defm : ZnWriteResFpuPair<WriteFLogic, [ZnFPU], 1>; 332defm : ZnWriteResFpuPair<WriteFLogicY, [ZnFPU], 1>; 333defm : X86WriteResPairUnsupported<WriteFLogicZ>; 334defm : ZnWriteResFpuPair<WriteFTest, [ZnFPU], 1>; 335defm : ZnWriteResFpuPair<WriteFTestY, [ZnFPU], 1>; 336defm : X86WriteResPairUnsupported<WriteFTestZ>; 337defm : ZnWriteResFpuPair<WriteFShuffle, [ZnFPU12], 1>; 338defm : ZnWriteResFpuPair<WriteFShuffleY, [ZnFPU12], 1>; 339defm : X86WriteResPairUnsupported<WriteFShuffleZ>; 340defm : ZnWriteResFpuPair<WriteFVarShuffle, [ZnFPU12], 1>; 341defm : ZnWriteResFpuPair<WriteFVarShuffleY,[ZnFPU12], 1>; 342defm : X86WriteResPairUnsupported<WriteFVarShuffleZ>; 343defm : ZnWriteResFpuPair<WriteFMul, [ZnFPU01], 3, [1], 1, 7, 1>; 344defm : ZnWriteResFpuPair<WriteFMulX, [ZnFPU01], 3, [1], 1, 7, 1>; 345defm : ZnWriteResFpuPair<WriteFMulY, [ZnFPU01], 4, [1], 1, 7, 1>; 346defm : X86WriteResPairUnsupported<WriteFMulZ>; 347defm : ZnWriteResFpuPair<WriteFMul64, [ZnFPU01], 3, [1], 1, 7, 1>; 348defm : ZnWriteResFpuPair<WriteFMul64X, [ZnFPU01], 3, [1], 1, 7, 1>; 349defm : ZnWriteResFpuPair<WriteFMul64Y, [ZnFPU01], 4, [1], 1, 7, 1>; 350defm : X86WriteResPairUnsupported<WriteFMul64Z>; 351defm : ZnWriteResFpuPair<WriteFMA, [ZnFPU03], 5>; 352defm : ZnWriteResFpuPair<WriteFMAX, [ZnFPU03], 5>; 353defm : ZnWriteResFpuPair<WriteFMAY, [ZnFPU03], 5>; 354defm : X86WriteResPairUnsupported<WriteFMAZ>; 355defm : ZnWriteResFpuPair<WriteFRcp, [ZnFPU01], 5>; 356defm : ZnWriteResFpuPair<WriteFRcpX, [ZnFPU01], 5>; 357defm : ZnWriteResFpuPair<WriteFRcpY, [ZnFPU01], 5, [1], 1, 7, 2>; 358defm : X86WriteResPairUnsupported<WriteFRcpZ>; 359//defm : ZnWriteResFpuPair<WriteFRsqrt, [ZnFPU02], 5>; 360defm : ZnWriteResFpuPair<WriteFRsqrtX, [ZnFPU01], 5, [1], 1, 7, 1>; 361//defm : ZnWriteResFpuPair<WriteFRsqrtY, [ZnFPU01], 5, [2], 2>; 362defm : X86WriteResPairUnsupported<WriteFRsqrtZ>; 363defm : ZnWriteResFpuPair<WriteFSqrt, [ZnFPU3], 20, [20]>; 364defm : ZnWriteResFpuPair<WriteFSqrtX, [ZnFPU3], 20, [20]>; 365defm : ZnWriteResFpuPair<WriteFSqrtY, [ZnFPU3], 28, [28], 1, 7, 1>; 366defm : X86WriteResPairUnsupported<WriteFSqrtZ>; 367defm : ZnWriteResFpuPair<WriteFSqrt64, [ZnFPU3], 20, [20]>; 368defm : ZnWriteResFpuPair<WriteFSqrt64X, [ZnFPU3], 20, [20]>; 369defm : ZnWriteResFpuPair<WriteFSqrt64Y, [ZnFPU3], 40, [40], 1, 7, 1>; 370defm : X86WriteResPairUnsupported<WriteFSqrt64Z>; 371defm : ZnWriteResFpuPair<WriteFSqrt80, [ZnFPU3], 20, [20]>; 372 373// Vector integer operations which uses FPU units 374defm : X86WriteRes<WriteVecLoad, [ZnAGU], 8, [1], 1>; 375defm : X86WriteRes<WriteVecLoadX, [ZnAGU], 8, [1], 1>; 376defm : X86WriteRes<WriteVecLoadY, [ZnAGU], 8, [1], 1>; 377defm : X86WriteRes<WriteVecLoadNT, [ZnAGU], 8, [1], 1>; 378defm : X86WriteRes<WriteVecLoadNTY, [ZnAGU], 8, [1], 1>; 379defm : X86WriteRes<WriteVecMaskedLoad, [ZnAGU,ZnFPU01], 8, [1,2], 2>; 380defm : X86WriteRes<WriteVecMaskedLoadY, [ZnAGU,ZnFPU01], 9, [1,3], 2>; 381defm : X86WriteRes<WriteVecStore, [ZnAGU], 1, [1], 1>; 382defm : X86WriteRes<WriteVecStoreX, [ZnAGU], 1, [1], 1>; 383defm : X86WriteRes<WriteVecStoreY, [ZnAGU], 1, [1], 1>; 384defm : X86WriteRes<WriteVecStoreNT, [ZnAGU], 1, [1], 1>; 385defm : X86WriteRes<WriteVecStoreNTY, [ZnAGU], 1, [1], 1>; 386defm : X86WriteRes<WriteVecMaskedStore, [ZnAGU,ZnFPU01], 4, [1,1], 1>; 387defm : X86WriteRes<WriteVecMaskedStoreY, [ZnAGU,ZnFPU01], 5, [1,2], 2>; 388defm : X86WriteRes<WriteVecMove, [ZnFPU], 1, [1], 1>; 389defm : X86WriteRes<WriteVecMoveX, [ZnFPU], 1, [1], 1>; 390defm : X86WriteRes<WriteVecMoveY, [ZnFPU], 2, [1], 2>; 391defm : X86WriteRes<WriteVecMoveToGpr, [ZnFPU2], 2, [1], 1>; 392defm : X86WriteRes<WriteVecMoveFromGpr, [ZnFPU2], 3, [1], 1>; 393defm : X86WriteRes<WriteEMMS, [ZnFPU], 2, [1], 1>; 394 395defm : ZnWriteResFpuPair<WriteVecShift, [ZnFPU], 1>; 396defm : ZnWriteResFpuPair<WriteVecShiftX, [ZnFPU2], 1>; 397defm : ZnWriteResFpuPair<WriteVecShiftY, [ZnFPU2], 2>; 398defm : X86WriteResPairUnsupported<WriteVecShiftZ>; 399defm : ZnWriteResFpuPair<WriteVecShiftImm, [ZnFPU], 1>; 400defm : ZnWriteResFpuPair<WriteVecShiftImmX, [ZnFPU], 1>; 401defm : ZnWriteResFpuPair<WriteVecShiftImmY, [ZnFPU], 1>; 402defm : X86WriteResPairUnsupported<WriteVecShiftImmZ>; 403defm : ZnWriteResFpuPair<WriteVecLogic, [ZnFPU], 1>; 404defm : ZnWriteResFpuPair<WriteVecLogicX, [ZnFPU], 1>; 405defm : ZnWriteResFpuPair<WriteVecLogicY, [ZnFPU], 1>; 406defm : X86WriteResPairUnsupported<WriteVecLogicZ>; 407defm : ZnWriteResFpuPair<WriteVecTest, [ZnFPU12], 1, [2], 1, 7, 1>; 408defm : ZnWriteResFpuPair<WriteVecTestY, [ZnFPU12], 1, [2], 1, 7, 1>; 409defm : X86WriteResPairUnsupported<WriteVecTestZ>; 410defm : ZnWriteResFpuPair<WriteVecALU, [ZnFPU], 1>; 411defm : ZnWriteResFpuPair<WriteVecALUX, [ZnFPU], 1>; 412defm : ZnWriteResFpuPair<WriteVecALUY, [ZnFPU], 1>; 413defm : X86WriteResPairUnsupported<WriteVecALUZ>; 414defm : ZnWriteResFpuPair<WriteVecIMul, [ZnFPU0], 4>; 415defm : ZnWriteResFpuPair<WriteVecIMulX, [ZnFPU0], 4>; 416defm : ZnWriteResFpuPair<WriteVecIMulY, [ZnFPU0], 4>; 417defm : X86WriteResPairUnsupported<WriteVecIMulZ>; 418defm : ZnWriteResFpuPair<WritePMULLD, [ZnFPU0], 4, [1], 1, 7, 1>; // FIXME 419defm : ZnWriteResFpuPair<WritePMULLDY, [ZnFPU0], 5, [2], 1, 7, 1>; // FIXME 420defm : X86WriteResPairUnsupported<WritePMULLDZ>; 421defm : ZnWriteResFpuPair<WriteShuffle, [ZnFPU], 1>; 422defm : ZnWriteResFpuPair<WriteShuffleX, [ZnFPU], 1>; 423defm : ZnWriteResFpuPair<WriteShuffleY, [ZnFPU], 1>; 424defm : X86WriteResPairUnsupported<WriteShuffleZ>; 425defm : ZnWriteResFpuPair<WriteVarShuffle, [ZnFPU], 1>; 426defm : ZnWriteResFpuPair<WriteVarShuffleX,[ZnFPU], 1>; 427defm : ZnWriteResFpuPair<WriteVarShuffleY,[ZnFPU], 1>; 428defm : X86WriteResPairUnsupported<WriteVarShuffleZ>; 429defm : ZnWriteResFpuPair<WriteBlend, [ZnFPU01], 1>; 430defm : ZnWriteResFpuPair<WriteBlendY, [ZnFPU01], 1>; 431defm : X86WriteResPairUnsupported<WriteBlendZ>; 432defm : ZnWriteResFpuPair<WriteShuffle256, [ZnFPU], 2>; 433defm : ZnWriteResFpuPair<WriteVarShuffle256, [ZnFPU], 2>; 434defm : ZnWriteResFpuPair<WritePSADBW, [ZnFPU0], 3>; 435defm : ZnWriteResFpuPair<WritePSADBWX, [ZnFPU0], 3>; 436defm : ZnWriteResFpuPair<WritePSADBWY, [ZnFPU0], 3>; 437defm : X86WriteResPairUnsupported<WritePSADBWZ>; 438defm : ZnWriteResFpuPair<WritePHMINPOS, [ZnFPU0], 4>; 439 440// Vector Shift Operations 441defm : ZnWriteResFpuPair<WriteVarVecShift, [ZnFPU12], 1>; 442defm : ZnWriteResFpuPair<WriteVarVecShiftY, [ZnFPU12], 1>; 443defm : X86WriteResPairUnsupported<WriteVarVecShiftZ>; 444 445// Vector insert/extract operations. 446defm : ZnWriteResFpuPair<WriteVecInsert, [ZnFPU], 1>; 447 448def : WriteRes<WriteVecExtract, [ZnFPU12, ZnFPU2]> { 449 let Latency = 2; 450 let ResourceCycles = [1, 2]; 451} 452def : WriteRes<WriteVecExtractSt, [ZnAGU, ZnFPU12, ZnFPU2]> { 453 let Latency = 5; 454 let NumMicroOps = 2; 455 let ResourceCycles = [1, 2, 3]; 456} 457 458// MOVMSK Instructions. 459def : WriteRes<WriteFMOVMSK, [ZnFPU2]>; 460def : WriteRes<WriteMMXMOVMSK, [ZnFPU2]>; 461def : WriteRes<WriteVecMOVMSK, [ZnFPU2]>; 462 463def : WriteRes<WriteVecMOVMSKY, [ZnFPU2]> { 464 let NumMicroOps = 2; 465 let Latency = 2; 466 let ResourceCycles = [2]; 467} 468 469// AES Instructions. 470defm : ZnWriteResFpuPair<WriteAESDecEnc, [ZnFPU01], 4>; 471defm : ZnWriteResFpuPair<WriteAESIMC, [ZnFPU01], 4>; 472defm : ZnWriteResFpuPair<WriteAESKeyGen, [ZnFPU01], 4>; 473 474def : WriteRes<WriteFence, [ZnAGU]>; 475def : WriteRes<WriteNop, []>; 476 477// Following instructions with latency=100 are microcoded. 478// We set long latency so as to block the entire pipeline. 479defm : ZnWriteResFpuPair<WriteFShuffle256, [ZnFPU], 100>; 480defm : ZnWriteResFpuPair<WriteFVarShuffle256, [ZnFPU], 100>; 481 482// Microcoded Instructions 483def ZnWriteMicrocoded : SchedWriteRes<[]> { 484 let Latency = 100; 485} 486 487def : SchedAlias<WriteMicrocoded, ZnWriteMicrocoded>; 488def : SchedAlias<WriteFCMOV, ZnWriteMicrocoded>; 489def : SchedAlias<WriteSystem, ZnWriteMicrocoded>; 490def : SchedAlias<WriteMPSAD, ZnWriteMicrocoded>; 491def : SchedAlias<WriteMPSADY, ZnWriteMicrocoded>; 492def : SchedAlias<WriteMPSADLd, ZnWriteMicrocoded>; 493def : SchedAlias<WriteMPSADYLd, ZnWriteMicrocoded>; 494def : SchedAlias<WriteCLMul, ZnWriteMicrocoded>; 495def : SchedAlias<WriteCLMulLd, ZnWriteMicrocoded>; 496def : SchedAlias<WritePCmpIStrM, ZnWriteMicrocoded>; 497def : SchedAlias<WritePCmpIStrMLd, ZnWriteMicrocoded>; 498def : SchedAlias<WritePCmpEStrI, ZnWriteMicrocoded>; 499def : SchedAlias<WritePCmpEStrILd, ZnWriteMicrocoded>; 500def : SchedAlias<WritePCmpEStrM, ZnWriteMicrocoded>; 501def : SchedAlias<WritePCmpEStrMLd, ZnWriteMicrocoded>; 502def : SchedAlias<WritePCmpIStrI, ZnWriteMicrocoded>; 503def : SchedAlias<WritePCmpIStrILd, ZnWriteMicrocoded>; 504def : SchedAlias<WriteLDMXCSR, ZnWriteMicrocoded>; 505def : SchedAlias<WriteSTMXCSR, ZnWriteMicrocoded>; 506 507//=== Regex based InstRW ===// 508// Notation: 509// - r: register. 510// - m = memory. 511// - i = immediate 512// - mm: 64 bit mmx register. 513// - x = 128 bit xmm register. 514// - (x)mm = mmx or xmm register. 515// - y = 256 bit ymm register. 516// - v = any vector register. 517 518//=== Integer Instructions ===// 519//-- Move instructions --// 520// MOV. 521// r16,m. 522def : InstRW<[WriteALULd, ReadAfterLd], (instrs MOV16rm)>; 523 524// MOVSX, MOVZX. 525// r,m. 526def : InstRW<[WriteLoad], (instregex "MOV(S|Z)X32rm(8|16)")>; 527 528// XCHG. 529// r,m. 530def ZnWriteXCHGrm : SchedWriteRes<[ZnAGU, ZnALU]> { 531 let Latency = 5; 532 let NumMicroOps = 2; 533} 534def : InstRW<[ZnWriteXCHGrm, ReadAfterLd], (instregex "XCHG(8|16|32|64)rm")>; 535 536def : InstRW<[WriteMicrocoded], (instrs XLAT)>; 537 538// POP16. 539// r. 540def ZnWritePop16r : SchedWriteRes<[ZnAGU]>{ 541 let Latency = 5; 542 let NumMicroOps = 2; 543} 544def : InstRW<[ZnWritePop16r], (instrs POP16rmm)>; 545def : InstRW<[WriteMicrocoded], (instregex "POPF(16|32)")>; 546def : InstRW<[WriteMicrocoded], (instregex "POPA(16|32)")>; 547 548 549// PUSH. 550// r. Has default values. 551// m. 552def ZnWritePUSH : SchedWriteRes<[ZnAGU]>{ 553 let Latency = 4; 554} 555def : InstRW<[ZnWritePUSH], (instregex "PUSH(16|32)rmm")>; 556 557//PUSHF 558def : InstRW<[WriteMicrocoded], (instregex "PUSHF(16|32)")>; 559 560// PUSHA. 561def ZnWritePushA : SchedWriteRes<[ZnAGU]> { 562 let Latency = 8; 563} 564def : InstRW<[ZnWritePushA], (instregex "PUSHA(16|32)")>; 565 566//LAHF 567def : InstRW<[WriteMicrocoded], (instrs LAHF)>; 568 569// MOVBE. 570// r,m. 571def ZnWriteMOVBE : SchedWriteRes<[ZnAGU, ZnALU]> { 572 let Latency = 5; 573} 574def : InstRW<[ZnWriteMOVBE, ReadAfterLd], (instregex "MOVBE(16|32|64)rm")>; 575 576// m16,r16. 577def : InstRW<[ZnWriteMOVBE], (instregex "MOVBE(16|32|64)mr")>; 578 579//-- Arithmetic instructions --// 580 581// ADD SUB. 582// m,r/i. 583def : InstRW<[WriteALULd], (instregex "(ADD|SUB)(8|16|32|64)m(r|i)", 584 "(ADD|SUB)(8|16|32|64)mi8", 585 "(ADD|SUB)64mi32")>; 586 587// ADC SBB. 588// m,r/i. 589def : InstRW<[WriteALULd], 590 (instregex "(ADC|SBB)(8|16|32|64)m(r|i)", 591 "(ADC|SBB)(16|32|64)mi8", 592 "(ADC|SBB)64mi32")>; 593 594// INC DEC NOT NEG. 595// m. 596def : InstRW<[WriteALULd], 597 (instregex "(INC|DEC|NOT|NEG)(8|16|32|64)m")>; 598 599// MUL IMUL. 600// r16. 601def ZnWriteMul16 : SchedWriteRes<[ZnALU1, ZnMultiplier]> { 602 let Latency = 3; 603} 604def : SchedAlias<WriteIMul16, ZnWriteMul16>; 605def : SchedAlias<WriteIMul16Imm, ZnWriteMul16>; // TODO: is this right? 606def : SchedAlias<WriteIMul16Reg, ZnWriteMul16>; // TODO: is this right? 607def : SchedAlias<WriteIMul16ImmLd, ZnWriteMul16>; // TODO: this is definitely wrong but matches what the instregex did. 608def : SchedAlias<WriteIMul16RegLd, ZnWriteMul16>; // TODO: this is definitely wrong but matches what the instregex did. 609 610// m16. 611def ZnWriteMul16Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> { 612 let Latency = 8; 613} 614def : SchedAlias<WriteIMul16Ld, ZnWriteMul16Ld>; 615 616// r32. 617def ZnWriteMul32 : SchedWriteRes<[ZnALU1, ZnMultiplier]> { 618 let Latency = 3; 619} 620def : SchedAlias<WriteIMul32, ZnWriteMul32>; 621def : SchedAlias<WriteIMul32Imm, ZnWriteMul32>; // TODO: is this right? 622def : SchedAlias<WriteIMul32Reg, ZnWriteMul32>; // TODO: is this right? 623def : SchedAlias<WriteIMul32ImmLd, ZnWriteMul32>; // TODO: this is definitely wrong but matches what the instregex did. 624def : SchedAlias<WriteIMul32RegLd, ZnWriteMul32>; // TODO: this is definitely wrong but matches what the instregex did. 625 626// m32. 627def ZnWriteMul32Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> { 628 let Latency = 8; 629} 630def : SchedAlias<WriteIMul32Ld, ZnWriteMul32Ld>; 631 632// r64. 633def ZnWriteMul64 : SchedWriteRes<[ZnALU1, ZnMultiplier]> { 634 let Latency = 4; 635 let NumMicroOps = 2; 636} 637def : SchedAlias<WriteIMul64, ZnWriteMul64>; 638def : SchedAlias<WriteIMul64Imm, ZnWriteMul64>; // TODO: is this right? 639def : SchedAlias<WriteIMul64Reg, ZnWriteMul64>; // TODO: is this right? 640def : SchedAlias<WriteIMul64ImmLd, ZnWriteMul64>; // TODO: this is definitely wrong but matches what the instregex did. 641def : SchedAlias<WriteIMul64RegLd, ZnWriteMul64>; // TODO: this is definitely wrong but matches what the instregex did. 642 643// m64. 644def ZnWriteMul64Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> { 645 let Latency = 9; 646 let NumMicroOps = 2; 647} 648def : SchedAlias<WriteIMul64Ld, ZnWriteMul64Ld>; 649 650// MULX. 651// r32,r32,r32. 652def ZnWriteMulX32 : SchedWriteRes<[ZnALU1, ZnMultiplier]> { 653 let Latency = 3; 654 let ResourceCycles = [1, 2]; 655} 656def : InstRW<[ZnWriteMulX32], (instrs MULX32rr)>; 657 658// r32,r32,m32. 659def ZnWriteMulX32Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> { 660 let Latency = 8; 661 let ResourceCycles = [1, 2, 2]; 662} 663def : InstRW<[ZnWriteMulX32Ld, ReadAfterLd], (instrs MULX32rm)>; 664 665// r64,r64,r64. 666def ZnWriteMulX64 : SchedWriteRes<[ZnALU1]> { 667 let Latency = 3; 668} 669def : InstRW<[ZnWriteMulX64], (instrs MULX64rr)>; 670 671// r64,r64,m64. 672def ZnWriteMulX64Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> { 673 let Latency = 8; 674} 675def : InstRW<[ZnWriteMulX64Ld, ReadAfterLd], (instrs MULX64rm)>; 676 677//-- Control transfer instructions --// 678 679// J(E|R)CXZ. 680def ZnWriteJCXZ : SchedWriteRes<[ZnALU03]>; 681def : InstRW<[ZnWriteJCXZ], (instrs JCXZ, JECXZ, JRCXZ)>; 682 683// INTO 684def : InstRW<[WriteMicrocoded], (instrs INTO)>; 685 686// LOOP. 687def ZnWriteLOOP : SchedWriteRes<[ZnALU03]>; 688def : InstRW<[ZnWriteLOOP], (instrs LOOP)>; 689 690// LOOP(N)E, LOOP(N)Z 691def ZnWriteLOOPE : SchedWriteRes<[ZnALU03]>; 692def : InstRW<[ZnWriteLOOPE], (instrs LOOPE, LOOPNE)>; 693 694// CALL. 695// r. 696def ZnWriteCALLr : SchedWriteRes<[ZnAGU, ZnALU03]>; 697def : InstRW<[ZnWriteCALLr], (instregex "CALL(16|32)r")>; 698 699def : InstRW<[WriteMicrocoded], (instregex "CALL(16|32)m")>; 700 701// RET. 702def ZnWriteRET : SchedWriteRes<[ZnALU03]> { 703 let NumMicroOps = 2; 704} 705def : InstRW<[ZnWriteRET], (instregex "RET(L|Q|W)", "LRET(L|Q|W)", 706 "IRET(16|32|64)")>; 707 708//-- Logic instructions --// 709 710// AND OR XOR. 711// m,r/i. 712def : InstRW<[WriteALULd], 713 (instregex "(AND|OR|XOR)(8|16|32|64)m(r|i)", 714 "(AND|OR|XOR)(8|16|32|64)mi8", "(AND|OR|XOR)64mi32")>; 715 716// Define ALU latency variants 717def ZnWriteALULat2 : SchedWriteRes<[ZnALU]> { 718 let Latency = 2; 719} 720def ZnWriteALULat2Ld : SchedWriteRes<[ZnAGU, ZnALU]> { 721 let Latency = 6; 722} 723 724// BTR BTS BTC. 725// m,r,i. 726def ZnWriteBTRSCm : SchedWriteRes<[ZnAGU, ZnALU]> { 727 let Latency = 6; 728 let NumMicroOps = 2; 729} 730// m,r,i. 731def : SchedAlias<WriteBitTestSetImmRMW, ZnWriteBTRSCm>; 732def : SchedAlias<WriteBitTestSetRegRMW, ZnWriteBTRSCm>; 733 734// BLSI BLSMSK BLSR. 735// r,r. 736def : SchedAlias<WriteBLS, ZnWriteALULat2>; 737// r,m. 738def : SchedAlias<WriteBLSLd, ZnWriteALULat2Ld>; 739 740// CLD STD. 741def : InstRW<[WriteALU], (instrs STD, CLD)>; 742 743// PDEP PEXT. 744// r,r,r. 745def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rr", "PEXT(32|64)rr")>; 746// r,r,m. 747def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rm", "PEXT(32|64)rm")>; 748 749// RCR RCL. 750// m,i. 751def : InstRW<[WriteMicrocoded], (instregex "RC(R|L)(8|16|32|64)m(1|i|CL)")>; 752 753// SHR SHL SAR. 754// m,i. 755def : InstRW<[WriteShiftLd], (instregex "S(A|H)(R|L)(8|16|32|64)m(i|1)")>; 756 757// SHRD SHLD. 758// m,r 759def : InstRW<[WriteShiftLd], (instregex "SH(R|L)D(16|32|64)mri8")>; 760 761// r,r,cl. 762def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)rrCL")>; 763 764// m,r,cl. 765def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)mrCL")>; 766 767//-- Misc instructions --// 768// CMPXCHG8B. 769def ZnWriteCMPXCHG8B : SchedWriteRes<[ZnAGU, ZnALU]> { 770 let NumMicroOps = 18; 771} 772def : InstRW<[ZnWriteCMPXCHG8B], (instrs CMPXCHG8B)>; 773 774def : InstRW<[WriteMicrocoded], (instrs CMPXCHG16B)>; 775 776// LEAVE 777def ZnWriteLEAVE : SchedWriteRes<[ZnALU, ZnAGU]> { 778 let Latency = 8; 779 let NumMicroOps = 2; 780} 781def : InstRW<[ZnWriteLEAVE], (instregex "LEAVE")>; 782 783// PAUSE. 784def : InstRW<[WriteMicrocoded], (instrs PAUSE)>; 785 786// RDTSC. 787def : InstRW<[WriteMicrocoded], (instregex "RDTSC")>; 788 789// RDPMC. 790def : InstRW<[WriteMicrocoded], (instrs RDPMC)>; 791 792// RDRAND. 793def : InstRW<[WriteMicrocoded], (instrs RDRAND16r, RDRAND32r, RDRAND64r)>; 794 795// XGETBV. 796def : InstRW<[WriteMicrocoded], (instrs XGETBV)>; 797 798//-- String instructions --// 799// CMPS. 800def : InstRW<[WriteMicrocoded], (instregex "CMPS(B|L|Q|W)")>; 801 802// LODSB/W. 803def : InstRW<[WriteMicrocoded], (instregex "LODS(B|W)")>; 804 805// LODSD/Q. 806def : InstRW<[WriteMicrocoded], (instregex "LODS(L|Q)")>; 807 808// MOVS. 809def : InstRW<[WriteMicrocoded], (instregex "MOVS(B|L|Q|W)")>; 810 811// SCAS. 812def : InstRW<[WriteMicrocoded], (instregex "SCAS(B|W|L|Q)")>; 813 814// STOS 815def : InstRW<[WriteMicrocoded], (instregex "STOS(B|L|Q|W)")>; 816 817// XADD. 818def ZnXADD : SchedWriteRes<[ZnALU]>; 819def : InstRW<[ZnXADD], (instregex "XADD(8|16|32|64)rr")>; 820def : InstRW<[WriteMicrocoded], (instregex "XADD(8|16|32|64)rm")>; 821 822//=== Floating Point x87 Instructions ===// 823//-- Move instructions --// 824 825def ZnWriteFLDr : SchedWriteRes<[ZnFPU13]> ; 826 827def ZnWriteSTr: SchedWriteRes<[ZnFPU23]> { 828 let Latency = 5; 829 let NumMicroOps = 2; 830} 831 832// LD_F. 833// r. 834def : InstRW<[ZnWriteFLDr], (instrs LD_Frr)>; 835 836// m. 837def ZnWriteLD_F80m : SchedWriteRes<[ZnAGU, ZnFPU13]> { 838 let NumMicroOps = 2; 839} 840def : InstRW<[ZnWriteLD_F80m], (instrs LD_F80m)>; 841 842// FBLD. 843def : InstRW<[WriteMicrocoded], (instrs FBLDm)>; 844 845// FST(P). 846// r. 847def : InstRW<[ZnWriteSTr], (instregex "ST_(F|FP)rr")>; 848 849// m80. 850def ZnWriteST_FP80m : SchedWriteRes<[ZnAGU, ZnFPU23]> { 851 let Latency = 5; 852} 853def : InstRW<[ZnWriteST_FP80m], (instrs ST_FP80m)>; 854 855// FBSTP. 856// m80. 857def : InstRW<[WriteMicrocoded], (instrs FBSTPm)>; 858 859def ZnWriteFXCH : SchedWriteRes<[ZnFPU]>; 860 861// FXCHG. 862def : InstRW<[ZnWriteFXCH], (instrs XCH_F)>; 863 864// FILD. 865def ZnWriteFILD : SchedWriteRes<[ZnAGU, ZnFPU3]> { 866 let Latency = 11; 867 let NumMicroOps = 2; 868} 869def : InstRW<[ZnWriteFILD], (instregex "ILD_F(16|32|64)m")>; 870 871// FIST(P) FISTTP. 872def ZnWriteFIST : SchedWriteRes<[ZnAGU, ZnFPU23]> { 873 let Latency = 12; 874} 875def : InstRW<[ZnWriteFIST], (instregex "IS(T|TT)_(F|FP)(16|32|64)m")>; 876 877def ZnWriteFPU13 : SchedWriteRes<[ZnAGU, ZnFPU13]> { 878 let Latency = 8; 879} 880 881def ZnWriteFPU3 : SchedWriteRes<[ZnAGU, ZnFPU3]> { 882 let Latency = 11; 883} 884 885// FLDZ. 886def : SchedAlias<WriteFLD0, ZnWriteFPU13>; 887 888// FLD1. 889def : SchedAlias<WriteFLD1, ZnWriteFPU3>; 890 891// FLDPI FLDL2E etc. 892def : SchedAlias<WriteFLDC, ZnWriteFPU3>; 893 894// FNSTSW. 895// AX. 896def : InstRW<[WriteMicrocoded], (instrs FNSTSW16r)>; 897 898// m16. 899def : InstRW<[WriteMicrocoded], (instrs FNSTSWm)>; 900 901// FLDCW. 902def : InstRW<[WriteMicrocoded], (instrs FLDCW16m)>; 903 904// FNSTCW. 905def : InstRW<[WriteMicrocoded], (instrs FNSTCW16m)>; 906 907// FINCSTP FDECSTP. 908def : InstRW<[ZnWriteFPU3], (instrs FINCSTP, FDECSTP)>; 909 910// FFREE. 911def : InstRW<[ZnWriteFPU3], (instregex "FFREE")>; 912 913// FNSAVE. 914def : InstRW<[WriteMicrocoded], (instrs FSAVEm)>; 915 916// FRSTOR. 917def : InstRW<[WriteMicrocoded], (instrs FRSTORm)>; 918 919//-- Arithmetic instructions --// 920 921def ZnWriteFPU3Lat1 : SchedWriteRes<[ZnFPU3]> ; 922 923def ZnWriteFPU0Lat1 : SchedWriteRes<[ZnFPU0]> ; 924 925def ZnWriteFPU0Lat1Ld : SchedWriteRes<[ZnAGU, ZnFPU0]> { 926 let Latency = 8; 927} 928 929// FCHS. 930def : InstRW<[ZnWriteFPU3Lat1], (instregex "CHS_F")>; 931 932// FCOM(P) FUCOM(P). 933// r. 934def : InstRW<[ZnWriteFPU0Lat1], (instregex "COM(P?)_FST0r", "UCOM_F(P?)r")>; 935// m. 936def : InstRW<[ZnWriteFPU0Lat1Ld], (instregex "FCOM(P?)(32|64)m")>; 937 938// FCOMPP FUCOMPP. 939// r. 940def : InstRW<[ZnWriteFPU0Lat1], (instrs FCOMPP, UCOM_FPPr)>; 941 942def ZnWriteFPU02 : SchedWriteRes<[ZnAGU, ZnFPU02]> 943{ 944 let Latency = 9; 945} 946 947// FCOMI(P) FUCOMI(P). 948// m. 949def : InstRW<[ZnWriteFPU02], (instrs COM_FIPr, COM_FIr, UCOM_FIPr, UCOM_FIr)>; 950 951def ZnWriteFPU03 : SchedWriteRes<[ZnAGU, ZnFPU03]> 952{ 953 let Latency = 12; 954 let NumMicroOps = 2; 955 let ResourceCycles = [1,3]; 956} 957 958// FICOM(P). 959def : InstRW<[ZnWriteFPU03], (instregex "FICOM(P?)(16|32)m")>; 960 961// FTST. 962def : InstRW<[ZnWriteFPU0Lat1], (instregex "TST_F")>; 963 964// FXAM. 965def : InstRW<[ZnWriteFPU3Lat1], (instrs FXAM)>; 966 967// FPREM. 968def : InstRW<[WriteMicrocoded], (instrs FPREM)>; 969 970// FPREM1. 971def : InstRW<[WriteMicrocoded], (instrs FPREM1)>; 972 973// FRNDINT. 974def : InstRW<[WriteMicrocoded], (instrs FRNDINT)>; 975 976// FSCALE. 977def : InstRW<[WriteMicrocoded], (instrs FSCALE)>; 978 979// FXTRACT. 980def : InstRW<[WriteMicrocoded], (instrs FXTRACT)>; 981 982// FNOP. 983def : InstRW<[ZnWriteFPU0Lat1], (instrs FNOP)>; 984 985// WAIT. 986def : InstRW<[ZnWriteFPU0Lat1], (instrs WAIT)>; 987 988// FNCLEX. 989def : InstRW<[WriteMicrocoded], (instrs FNCLEX)>; 990 991// FNINIT. 992def : InstRW<[WriteMicrocoded], (instrs FNINIT)>; 993 994//=== Integer MMX and XMM Instructions ===// 995 996// PACKSSWB/DW. 997// mm <- mm. 998def ZnWriteFPU12 : SchedWriteRes<[ZnFPU12]> ; 999def ZnWriteFPU12Y : SchedWriteRes<[ZnFPU12]> { 1000 let NumMicroOps = 2; 1001} 1002def ZnWriteFPU12m : SchedWriteRes<[ZnAGU, ZnFPU12]> ; 1003def ZnWriteFPU12Ym : SchedWriteRes<[ZnAGU, ZnFPU12]> { 1004 let Latency = 8; 1005 let NumMicroOps = 2; 1006} 1007 1008def : InstRW<[ZnWriteFPU12], (instrs MMX_PACKSSDWirr, 1009 MMX_PACKSSWBirr, 1010 MMX_PACKUSWBirr)>; 1011def : InstRW<[ZnWriteFPU12m], (instrs MMX_PACKSSDWirm, 1012 MMX_PACKSSWBirm, 1013 MMX_PACKUSWBirm)>; 1014 1015// VPMOVSX/ZX BW BD BQ WD WQ DQ. 1016// y <- x. 1017def : InstRW<[ZnWriteFPU12Y], (instregex "VPMOV(SX|ZX)(BW|BD|BQ|WD|WQ|DQ)Yrr")>; 1018def : InstRW<[ZnWriteFPU12Ym], (instregex "VPMOV(SX|ZX)(BW|BD|BQ|WD|WQ|DQ)Yrm")>; 1019 1020def ZnWriteFPU013 : SchedWriteRes<[ZnFPU013]> ; 1021def ZnWriteFPU013Y : SchedWriteRes<[ZnFPU013]> { 1022 let Latency = 2; 1023} 1024def ZnWriteFPU013m : SchedWriteRes<[ZnAGU, ZnFPU013]> { 1025 let Latency = 8; 1026 let NumMicroOps = 2; 1027} 1028def ZnWriteFPU013Ld : SchedWriteRes<[ZnAGU, ZnFPU013]> { 1029 let Latency = 8; 1030 let NumMicroOps = 2; 1031} 1032def ZnWriteFPU013LdY : SchedWriteRes<[ZnAGU, ZnFPU013]> { 1033 let Latency = 9; 1034 let NumMicroOps = 2; 1035} 1036 1037// PBLENDW. 1038// x,x,i / v,v,v,i 1039def : InstRW<[ZnWriteFPU013], (instregex "(V?)PBLENDWrri")>; 1040// ymm 1041def : InstRW<[ZnWriteFPU013Y], (instrs VPBLENDWYrri)>; 1042 1043// x,m,i / v,v,m,i 1044def : InstRW<[ZnWriteFPU013Ld], (instregex "(V?)PBLENDWrmi")>; 1045// y,m,i 1046def : InstRW<[ZnWriteFPU013LdY], (instrs VPBLENDWYrmi)>; 1047 1048def ZnWriteFPU01 : SchedWriteRes<[ZnFPU01]> ; 1049def ZnWriteFPU01Y : SchedWriteRes<[ZnFPU01]> { 1050 let NumMicroOps = 2; 1051} 1052 1053// VPBLENDD. 1054// v,v,v,i. 1055def : InstRW<[ZnWriteFPU01], (instrs VPBLENDDrri)>; 1056// ymm 1057def : InstRW<[ZnWriteFPU01Y], (instrs VPBLENDDYrri)>; 1058 1059// v,v,m,i 1060def ZnWriteFPU01Op2 : SchedWriteRes<[ZnAGU, ZnFPU01]> { 1061 let NumMicroOps = 2; 1062 let Latency = 8; 1063 let ResourceCycles = [1, 2]; 1064} 1065def ZnWriteFPU01Op2Y : SchedWriteRes<[ZnAGU, ZnFPU01]> { 1066 let NumMicroOps = 2; 1067 let Latency = 9; 1068 let ResourceCycles = [1, 3]; 1069} 1070def : InstRW<[ZnWriteFPU01Op2], (instrs VPBLENDDrmi)>; 1071def : InstRW<[ZnWriteFPU01Op2Y], (instrs VPBLENDDYrmi)>; 1072 1073// MASKMOVQ. 1074def : InstRW<[WriteMicrocoded], (instregex "MMX_MASKMOVQ(64)?")>; 1075 1076// MASKMOVDQU. 1077def : InstRW<[WriteMicrocoded], (instregex "(V?)MASKMOVDQU(64)?")>; 1078 1079// VPMASKMOVD. 1080// ymm 1081def : InstRW<[WriteMicrocoded], 1082 (instregex "VPMASKMOVD(Y?)rm")>; 1083// m, v,v. 1084def : InstRW<[WriteMicrocoded], (instregex "VPMASKMOV(D|Q)(Y?)mr")>; 1085 1086// VPBROADCAST B/W. 1087// x, m8/16. 1088def ZnWriteVPBROADCAST128Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> { 1089 let Latency = 8; 1090 let NumMicroOps = 2; 1091 let ResourceCycles = [1, 2]; 1092} 1093def : InstRW<[ZnWriteVPBROADCAST128Ld], 1094 (instregex "VPBROADCAST(B|W)rm")>; 1095 1096// y, m8/16 1097def ZnWriteVPBROADCAST256Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> { 1098 let Latency = 8; 1099 let NumMicroOps = 2; 1100 let ResourceCycles = [1, 2]; 1101} 1102def : InstRW<[ZnWriteVPBROADCAST256Ld], 1103 (instregex "VPBROADCAST(B|W)Yrm")>; 1104 1105// VPGATHER. 1106def : InstRW<[WriteMicrocoded], (instregex "VPGATHER(Q|D)(Q|D)(Y?)rm")>; 1107 1108//-- Arithmetic instructions --// 1109 1110// HADD, HSUB PS/PD 1111// PHADD|PHSUB (S) W/D. 1112def : SchedAlias<WritePHAdd, ZnWriteMicrocoded>; 1113def : SchedAlias<WritePHAddLd, ZnWriteMicrocoded>; 1114def : SchedAlias<WritePHAddX, ZnWriteMicrocoded>; 1115def : SchedAlias<WritePHAddXLd, ZnWriteMicrocoded>; 1116def : SchedAlias<WritePHAddY, ZnWriteMicrocoded>; 1117def : SchedAlias<WritePHAddYLd, ZnWriteMicrocoded>; 1118 1119// PCMPGTQ. 1120def ZnWritePCMPGTQr : SchedWriteRes<[ZnFPU03]>; 1121def : InstRW<[ZnWritePCMPGTQr], (instregex "(V?)PCMPGTQ(Y?)rr")>; 1122 1123// x <- x,m. 1124def ZnWritePCMPGTQm : SchedWriteRes<[ZnAGU, ZnFPU03]> { 1125 let Latency = 8; 1126} 1127// ymm. 1128def ZnWritePCMPGTQYm : SchedWriteRes<[ZnAGU, ZnFPU03]> { 1129 let Latency = 8; 1130 let NumMicroOps = 2; 1131 let ResourceCycles = [1,2]; 1132} 1133def : InstRW<[ZnWritePCMPGTQm], (instregex "(V?)PCMPGTQrm")>; 1134def : InstRW<[ZnWritePCMPGTQYm], (instrs VPCMPGTQYrm)>; 1135 1136//-- Logic instructions --// 1137 1138// PSLL,PSRL,PSRA W/D/Q. 1139// x,x / v,v,x. 1140def ZnWritePShift : SchedWriteRes<[ZnFPU2]> ; 1141def ZnWritePShiftY : SchedWriteRes<[ZnFPU2]> { 1142 let Latency = 2; 1143} 1144 1145// PSLL,PSRL DQ. 1146def : InstRW<[ZnWritePShift], (instregex "(V?)PS(R|L)LDQri")>; 1147def : InstRW<[ZnWritePShiftY], (instregex "(V?)PS(R|L)LDQYri")>; 1148 1149//=== Floating Point XMM and YMM Instructions ===// 1150//-- Move instructions --// 1151 1152// VPERM2F128. 1153def : InstRW<[WriteMicrocoded], (instrs VPERM2F128rr)>; 1154def : InstRW<[WriteMicrocoded], (instrs VPERM2F128rm)>; 1155 1156def ZnWriteBROADCAST : SchedWriteRes<[ZnAGU, ZnFPU13]> { 1157 let NumMicroOps = 2; 1158 let Latency = 8; 1159} 1160// VBROADCASTF128. 1161def : InstRW<[ZnWriteBROADCAST], (instrs VBROADCASTF128)>; 1162 1163// EXTRACTPS. 1164// r32,x,i. 1165def ZnWriteEXTRACTPSr : SchedWriteRes<[ZnFPU12, ZnFPU2]> { 1166 let Latency = 2; 1167 let NumMicroOps = 2; 1168 let ResourceCycles = [1, 2]; 1169} 1170def : InstRW<[ZnWriteEXTRACTPSr], (instregex "(V?)EXTRACTPSrr")>; 1171 1172def ZnWriteEXTRACTPSm : SchedWriteRes<[ZnAGU,ZnFPU12, ZnFPU2]> { 1173 let Latency = 5; 1174 let NumMicroOps = 2; 1175 let ResourceCycles = [5, 1, 2]; 1176} 1177// m32,x,i. 1178def : InstRW<[ZnWriteEXTRACTPSm], (instregex "(V?)EXTRACTPSmr")>; 1179 1180// VEXTRACTF128. 1181// x,y,i. 1182def : InstRW<[ZnWriteFPU013], (instrs VEXTRACTF128rr)>; 1183 1184// m128,y,i. 1185def : InstRW<[ZnWriteFPU013m], (instrs VEXTRACTF128mr)>; 1186 1187def ZnWriteVINSERT128r: SchedWriteRes<[ZnFPU013]> { 1188 let Latency = 2; 1189 let ResourceCycles = [2]; 1190} 1191def ZnWriteVINSERT128Ld: SchedWriteRes<[ZnAGU,ZnFPU013]> { 1192 let Latency = 9; 1193 let NumMicroOps = 2; 1194 let ResourceCycles = [1, 2]; 1195} 1196// VINSERTF128. 1197// y,y,x,i. 1198def : InstRW<[ZnWriteVINSERT128r], (instrs VINSERTF128rr)>; 1199def : InstRW<[ZnWriteVINSERT128Ld], (instrs VINSERTF128rm)>; 1200 1201// VGATHER. 1202def : InstRW<[WriteMicrocoded], (instregex "VGATHER(Q|D)(PD|PS)(Y?)rm")>; 1203 1204//-- Conversion instructions --// 1205def ZnWriteCVTPD2PSr: SchedWriteRes<[ZnFPU3]> { 1206 let Latency = 4; 1207} 1208def ZnWriteCVTPD2PSYr: SchedWriteRes<[ZnFPU3]> { 1209 let Latency = 5; 1210} 1211 1212// CVTPD2PS. 1213// x,x. 1214def : SchedAlias<WriteCvtPD2PS, ZnWriteCVTPD2PSr>; 1215// y,y. 1216def : SchedAlias<WriteCvtPD2PSY, ZnWriteCVTPD2PSYr>; 1217// z,z. 1218defm : X86WriteResUnsupported<WriteCvtPD2PSZ>; 1219 1220def ZnWriteCVTPD2PSLd: SchedWriteRes<[ZnAGU,ZnFPU03]> { 1221 let Latency = 11; 1222 let NumMicroOps = 2; 1223 let ResourceCycles = [1,2]; 1224} 1225// x,m128. 1226def : SchedAlias<WriteCvtPD2PSLd, ZnWriteCVTPD2PSLd>; 1227 1228// x,m256. 1229def ZnWriteCVTPD2PSYLd : SchedWriteRes<[ZnAGU, ZnFPU3]> { 1230 let Latency = 11; 1231} 1232def : SchedAlias<WriteCvtPD2PSYLd, ZnWriteCVTPD2PSYLd>; 1233// z,m512 1234defm : X86WriteResUnsupported<WriteCvtPD2PSZLd>; 1235 1236// CVTSD2SS. 1237// x,x. 1238// Same as WriteCVTPD2PSr 1239def : SchedAlias<WriteCvtSD2SS, ZnWriteCVTPD2PSr>; 1240 1241// x,m64. 1242def : SchedAlias<WriteCvtSD2SSLd, ZnWriteCVTPD2PSLd>; 1243 1244// CVTPS2PD. 1245// x,x. 1246def ZnWriteCVTPS2PDr : SchedWriteRes<[ZnFPU3]> { 1247 let Latency = 3; 1248} 1249def : SchedAlias<WriteCvtPS2PD, ZnWriteCVTPS2PDr>; 1250 1251// x,m64. 1252// y,m128. 1253def ZnWriteCVTPS2PDLd : SchedWriteRes<[ZnAGU, ZnFPU3]> { 1254 let Latency = 10; 1255 let NumMicroOps = 2; 1256} 1257def : SchedAlias<WriteCvtPS2PDLd, ZnWriteCVTPS2PDLd>; 1258def : SchedAlias<WriteCvtPS2PDYLd, ZnWriteCVTPS2PDLd>; 1259defm : X86WriteResUnsupported<WriteCvtPS2PDZLd>; 1260 1261// y,x. 1262def ZnWriteVCVTPS2PDY : SchedWriteRes<[ZnFPU3]> { 1263 let Latency = 3; 1264} 1265def : SchedAlias<WriteCvtPS2PDY, ZnWriteVCVTPS2PDY>; 1266defm : X86WriteResUnsupported<WriteCvtPS2PDZ>; 1267 1268// CVTSS2SD. 1269// x,x. 1270def ZnWriteCVTSS2SDr : SchedWriteRes<[ZnFPU3]> { 1271 let Latency = 4; 1272} 1273def : SchedAlias<WriteCvtSS2SD, ZnWriteCVTSS2SDr>; 1274 1275// x,m32. 1276def ZnWriteCVTSS2SDLd : SchedWriteRes<[ZnAGU, ZnFPU3]> { 1277 let Latency = 11; 1278 let NumMicroOps = 2; 1279 let ResourceCycles = [1, 2]; 1280} 1281def : SchedAlias<WriteCvtSS2SDLd, ZnWriteCVTSS2SDLd>; 1282 1283def ZnWriteCVTDQ2PDr: SchedWriteRes<[ZnFPU12,ZnFPU3]> { 1284 let Latency = 5; 1285} 1286// CVTDQ2PD. 1287// x,x. 1288def : InstRW<[ZnWriteCVTDQ2PDr], (instregex "(V)?CVTDQ2PDrr")>; 1289 1290// Same as xmm 1291// y,x. 1292def : InstRW<[ZnWriteCVTDQ2PDr], (instrs VCVTDQ2PDYrr)>; 1293 1294def ZnWriteCVTPD2DQr: SchedWriteRes<[ZnFPU12, ZnFPU3]> { 1295 let Latency = 5; 1296} 1297// CVT(T)PD2DQ. 1298// x,x. 1299def : InstRW<[ZnWriteCVTDQ2PDr], (instregex "(V?)CVT(T?)PD2DQrr")>; 1300 1301def ZnWriteCVTPD2DQLd: SchedWriteRes<[ZnAGU,ZnFPU12,ZnFPU3]> { 1302 let Latency = 12; 1303 let NumMicroOps = 2; 1304} 1305// x,m128. 1306def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "(V?)CVT(T?)PD2DQrm")>; 1307// same as xmm handling 1308// x,y. 1309def : InstRW<[ZnWriteCVTPD2DQr], (instregex "VCVT(T?)PD2DQYrr")>; 1310// x,m256. 1311def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "VCVT(T?)PD2DQYrm")>; 1312 1313def ZnWriteCVTPS2PIr: SchedWriteRes<[ZnFPU3]> { 1314 let Latency = 4; 1315} 1316// CVT(T)PS2PI. 1317// mm,x. 1318def : InstRW<[ZnWriteCVTPS2PIr], (instregex "MMX_CVT(T?)PS2PIirr")>; 1319 1320// CVTPI2PD. 1321// x,mm. 1322def : InstRW<[ZnWriteCVTPS2PDr], (instrs MMX_CVTPI2PDirr)>; 1323 1324// CVT(T)PD2PI. 1325// mm,x. 1326def : InstRW<[ZnWriteCVTPS2PIr], (instregex "MMX_CVT(T?)PD2PIirr")>; 1327 1328def ZnWriteCVSTSI2SSr: SchedWriteRes<[ZnFPU3]> { 1329 let Latency = 5; 1330} 1331 1332// same as CVTPD2DQr 1333// CVT(T)SS2SI. 1334// r32,x. 1335def : InstRW<[ZnWriteCVTPD2DQr], (instregex "(V?)CVT(T?)SS2SI(64)?rr")>; 1336// same as CVTPD2DQm 1337// r32,m32. 1338def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "(V?)CVT(T?)SS2SI(64)?rm")>; 1339 1340def ZnWriteCVSTSI2SDr: SchedWriteRes<[ZnFPU013, ZnFPU3]> { 1341 let Latency = 5; 1342} 1343// CVTSI2SD. 1344// x,r32/64. 1345def : InstRW<[ZnWriteCVSTSI2SDr], (instregex "(V?)CVTSI(64)?2SDrr")>; 1346 1347 1348def ZnWriteCVSTSI2SIr: SchedWriteRes<[ZnFPU3, ZnFPU2]> { 1349 let Latency = 5; 1350} 1351def ZnWriteCVSTSI2SILd: SchedWriteRes<[ZnAGU, ZnFPU3, ZnFPU2]> { 1352 let Latency = 12; 1353} 1354// CVTSD2SI. 1355// r32/64 1356def : InstRW<[ZnWriteCVSTSI2SIr], (instregex "(V?)CVT(T?)SD2SI(64)?rr")>; 1357// r32,m32. 1358def : InstRW<[ZnWriteCVSTSI2SILd], (instregex "(V?)CVT(T?)SD2SI(64)?rm")>; 1359 1360// VCVTPS2PH. 1361// x,v,i. 1362def : SchedAlias<WriteCvtPS2PH, ZnWriteMicrocoded>; 1363def : SchedAlias<WriteCvtPS2PHY, ZnWriteMicrocoded>; 1364defm : X86WriteResUnsupported<WriteCvtPS2PHZ>; 1365// m,v,i. 1366def : SchedAlias<WriteCvtPS2PHSt, ZnWriteMicrocoded>; 1367def : SchedAlias<WriteCvtPS2PHYSt, ZnWriteMicrocoded>; 1368defm : X86WriteResUnsupported<WriteCvtPS2PHZSt>; 1369 1370// VCVTPH2PS. 1371// v,x. 1372def : SchedAlias<WriteCvtPH2PS, ZnWriteMicrocoded>; 1373def : SchedAlias<WriteCvtPH2PSY, ZnWriteMicrocoded>; 1374defm : X86WriteResUnsupported<WriteCvtPH2PSZ>; 1375// v,m. 1376def : SchedAlias<WriteCvtPH2PSLd, ZnWriteMicrocoded>; 1377def : SchedAlias<WriteCvtPH2PSYLd, ZnWriteMicrocoded>; 1378defm : X86WriteResUnsupported<WriteCvtPH2PSZLd>; 1379 1380//-- SSE4A instructions --// 1381// EXTRQ 1382def ZnWriteEXTRQ: SchedWriteRes<[ZnFPU12, ZnFPU2]> { 1383 let Latency = 2; 1384} 1385def : InstRW<[ZnWriteEXTRQ], (instregex "EXTRQ")>; 1386 1387// INSERTQ 1388def ZnWriteINSERTQ: SchedWriteRes<[ZnFPU03,ZnFPU1]> { 1389 let Latency = 4; 1390} 1391def : InstRW<[ZnWriteINSERTQ], (instregex "INSERTQ")>; 1392 1393//-- SHA instructions --// 1394// SHA256MSG2 1395def : InstRW<[WriteMicrocoded], (instregex "SHA256MSG2(Y?)r(r|m)")>; 1396 1397// SHA1MSG1, SHA256MSG1 1398// x,x. 1399def ZnWriteSHA1MSG1r : SchedWriteRes<[ZnFPU12]> { 1400 let Latency = 2; 1401 let ResourceCycles = [2]; 1402} 1403def : InstRW<[ZnWriteSHA1MSG1r], (instregex "SHA(1|256)MSG1rr")>; 1404// x,m. 1405def ZnWriteSHA1MSG1Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> { 1406 let Latency = 9; 1407 let ResourceCycles = [1,2]; 1408} 1409def : InstRW<[ZnWriteSHA1MSG1Ld], (instregex "SHA(1|256)MSG1rm")>; 1410 1411// SHA1MSG2 1412// x,x. 1413def ZnWriteSHA1MSG2r : SchedWriteRes<[ZnFPU12]> ; 1414def : InstRW<[ZnWriteSHA1MSG2r], (instrs SHA1MSG2rr)>; 1415// x,m. 1416def ZnWriteSHA1MSG2Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> { 1417 let Latency = 8; 1418} 1419def : InstRW<[ZnWriteSHA1MSG2Ld], (instrs SHA1MSG2rm)>; 1420 1421// SHA1NEXTE 1422// x,x. 1423def ZnWriteSHA1NEXTEr : SchedWriteRes<[ZnFPU1]> ; 1424def : InstRW<[ZnWriteSHA1NEXTEr], (instrs SHA1NEXTErr)>; 1425// x,m. 1426def ZnWriteSHA1NEXTELd : SchedWriteRes<[ZnAGU, ZnFPU1]> { 1427 let Latency = 8; 1428} 1429def : InstRW<[ZnWriteSHA1NEXTELd], (instrs SHA1NEXTErm)>; 1430 1431// SHA1RNDS4 1432// x,x. 1433def ZnWriteSHA1RNDS4r : SchedWriteRes<[ZnFPU1]> { 1434 let Latency = 6; 1435} 1436def : InstRW<[ZnWriteSHA1RNDS4r], (instrs SHA1RNDS4rri)>; 1437// x,m. 1438def ZnWriteSHA1RNDS4Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> { 1439 let Latency = 13; 1440} 1441def : InstRW<[ZnWriteSHA1RNDS4Ld], (instrs SHA1RNDS4rmi)>; 1442 1443// SHA256RNDS2 1444// x,x. 1445def ZnWriteSHA256RNDS2r : SchedWriteRes<[ZnFPU1]> { 1446 let Latency = 4; 1447} 1448def : InstRW<[ZnWriteSHA256RNDS2r], (instrs SHA256RNDS2rr)>; 1449// x,m. 1450def ZnWriteSHA256RNDS2Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> { 1451 let Latency = 11; 1452} 1453def : InstRW<[ZnWriteSHA256RNDS2Ld], (instrs SHA256RNDS2rm)>; 1454 1455//-- Arithmetic instructions --// 1456 1457// HADD, HSUB PS/PD 1458def : SchedAlias<WriteFHAdd, ZnWriteMicrocoded>; 1459def : SchedAlias<WriteFHAddLd, ZnWriteMicrocoded>; 1460def : SchedAlias<WriteFHAddY, ZnWriteMicrocoded>; 1461def : SchedAlias<WriteFHAddYLd, ZnWriteMicrocoded>; 1462 1463// VDIVPS. 1464// TODO - convert to ZnWriteResFpuPair 1465// y,y,y. 1466def ZnWriteVDIVPSYr : SchedWriteRes<[ZnFPU3]> { 1467 let Latency = 12; 1468 let ResourceCycles = [12]; 1469} 1470def : SchedAlias<WriteFDivY, ZnWriteVDIVPSYr>; 1471 1472// y,y,m256. 1473def ZnWriteVDIVPSYLd : SchedWriteRes<[ZnAGU, ZnFPU3]> { 1474 let Latency = 19; 1475 let NumMicroOps = 2; 1476 let ResourceCycles = [1, 19]; 1477} 1478def : SchedAlias<WriteFDivYLd, ZnWriteVDIVPSYLd>; 1479 1480// VDIVPD. 1481// TODO - convert to ZnWriteResFpuPair 1482// y,y,y. 1483def ZnWriteVDIVPDY : SchedWriteRes<[ZnFPU3]> { 1484 let Latency = 15; 1485 let ResourceCycles = [15]; 1486} 1487def : SchedAlias<WriteFDiv64Y, ZnWriteVDIVPDY>; 1488 1489// y,y,m256. 1490def ZnWriteVDIVPDYLd : SchedWriteRes<[ZnAGU, ZnFPU3]> { 1491 let Latency = 22; 1492 let NumMicroOps = 2; 1493 let ResourceCycles = [1,22]; 1494} 1495def : SchedAlias<WriteFDiv64YLd, ZnWriteVDIVPDYLd>; 1496 1497// DPPS. 1498// x,x,i / v,v,v,i. 1499def : SchedAlias<WriteDPPS, ZnWriteMicrocoded>; 1500def : SchedAlias<WriteDPPSY, ZnWriteMicrocoded>; 1501 1502// x,m,i / v,v,m,i. 1503def : SchedAlias<WriteDPPSLd, ZnWriteMicrocoded>; 1504def : SchedAlias<WriteDPPSYLd,ZnWriteMicrocoded>; 1505 1506// DPPD. 1507// x,x,i. 1508def : SchedAlias<WriteDPPD, ZnWriteMicrocoded>; 1509 1510// x,m,i. 1511def : SchedAlias<WriteDPPDLd, ZnWriteMicrocoded>; 1512 1513// RSQRTSS 1514// TODO - convert to ZnWriteResFpuPair 1515// x,x. 1516def ZnWriteRSQRTSSr : SchedWriteRes<[ZnFPU02]> { 1517 let Latency = 5; 1518} 1519def : SchedAlias<WriteFRsqrt, ZnWriteRSQRTSSr>; 1520 1521// x,m128. 1522def ZnWriteRSQRTSSLd: SchedWriteRes<[ZnAGU, ZnFPU02]> { 1523 let Latency = 12; 1524 let NumMicroOps = 2; 1525 let ResourceCycles = [1,2]; // FIXME: Is this right? 1526} 1527def : SchedAlias<WriteFRsqrtLd, ZnWriteRSQRTSSLd>; 1528 1529// RSQRTPS 1530// TODO - convert to ZnWriteResFpuPair 1531// y,y. 1532def ZnWriteRSQRTPSYr : SchedWriteRes<[ZnFPU01]> { 1533 let Latency = 5; 1534 let NumMicroOps = 2; 1535 let ResourceCycles = [2]; 1536} 1537def : SchedAlias<WriteFRsqrtY, ZnWriteRSQRTPSYr>; 1538 1539// y,m256. 1540def ZnWriteRSQRTPSYLd : SchedWriteRes<[ZnAGU, ZnFPU01]> { 1541 let Latency = 12; 1542 let NumMicroOps = 2; 1543} 1544def : SchedAlias<WriteFRsqrtYLd, ZnWriteRSQRTPSYLd>; 1545 1546//-- Other instructions --// 1547 1548// VZEROUPPER. 1549def : InstRW<[WriteMicrocoded], (instrs VZEROUPPER)>; 1550 1551// VZEROALL. 1552def : InstRW<[WriteMicrocoded], (instrs VZEROALL)>; 1553 1554} // SchedModel 1555