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>; 271 272defm : X86WriteRes<WriteFMaskedStore32, [ZnAGU,ZnFPU01], 4, [1,1], 1>; 273defm : X86WriteRes<WriteFMaskedStore32Y, [ZnAGU,ZnFPU01], 5, [1,2], 2>; 274defm : X86WriteRes<WriteFMaskedStore64, [ZnAGU,ZnFPU01], 4, [1,1], 1>; 275defm : X86WriteRes<WriteFMaskedStore64Y, [ZnAGU,ZnFPU01], 5, [1,2], 2>; 276 277defm : X86WriteRes<WriteFMove, [ZnFPU], 1, [1], 1>; 278defm : X86WriteRes<WriteFMoveX, [ZnFPU], 1, [1], 1>; 279defm : X86WriteRes<WriteFMoveY, [ZnFPU], 1, [1], 1>; 280 281defm : ZnWriteResFpuPair<WriteFAdd, [ZnFPU0], 3>; 282defm : ZnWriteResFpuPair<WriteFAddX, [ZnFPU0], 3>; 283defm : ZnWriteResFpuPair<WriteFAddY, [ZnFPU0], 3>; 284defm : X86WriteResPairUnsupported<WriteFAddZ>; 285defm : ZnWriteResFpuPair<WriteFAdd64, [ZnFPU0], 3>; 286defm : ZnWriteResFpuPair<WriteFAdd64X, [ZnFPU0], 3>; 287defm : ZnWriteResFpuPair<WriteFAdd64Y, [ZnFPU0], 3>; 288defm : X86WriteResPairUnsupported<WriteFAdd64Z>; 289defm : ZnWriteResFpuPair<WriteFCmp, [ZnFPU0], 3>; 290defm : ZnWriteResFpuPair<WriteFCmpX, [ZnFPU0], 3>; 291defm : ZnWriteResFpuPair<WriteFCmpY, [ZnFPU0], 3>; 292defm : X86WriteResPairUnsupported<WriteFCmpZ>; 293defm : ZnWriteResFpuPair<WriteFCmp64, [ZnFPU0], 3>; 294defm : ZnWriteResFpuPair<WriteFCmp64X, [ZnFPU0], 3>; 295defm : ZnWriteResFpuPair<WriteFCmp64Y, [ZnFPU0], 3>; 296defm : X86WriteResPairUnsupported<WriteFCmp64Z>; 297defm : ZnWriteResFpuPair<WriteFCom, [ZnFPU0], 3>; 298defm : ZnWriteResFpuPair<WriteFBlend, [ZnFPU01], 1>; 299defm : ZnWriteResFpuPair<WriteFBlendY, [ZnFPU01], 1>; 300defm : X86WriteResPairUnsupported<WriteFBlendZ>; 301defm : ZnWriteResFpuPair<WriteFVarBlend, [ZnFPU01], 1>; 302defm : ZnWriteResFpuPair<WriteFVarBlendY,[ZnFPU01], 1>; 303defm : X86WriteResPairUnsupported<WriteFVarBlendZ>; 304defm : ZnWriteResFpuPair<WriteVarBlend, [ZnFPU0], 1>; 305defm : ZnWriteResFpuPair<WriteVarBlendY, [ZnFPU0], 1>; 306defm : X86WriteResPairUnsupported<WriteVarBlendZ>; 307defm : ZnWriteResFpuPair<WriteCvtSS2I, [ZnFPU3], 5>; 308defm : ZnWriteResFpuPair<WriteCvtPS2I, [ZnFPU3], 5>; 309defm : ZnWriteResFpuPair<WriteCvtPS2IY, [ZnFPU3], 5>; 310defm : X86WriteResPairUnsupported<WriteCvtPS2IZ>; 311defm : ZnWriteResFpuPair<WriteCvtSD2I, [ZnFPU3], 5>; 312defm : ZnWriteResFpuPair<WriteCvtPD2I, [ZnFPU3], 5>; 313defm : ZnWriteResFpuPair<WriteCvtPD2IY, [ZnFPU3], 5>; 314defm : X86WriteResPairUnsupported<WriteCvtPD2IZ>; 315defm : ZnWriteResFpuPair<WriteCvtI2SS, [ZnFPU3], 5>; 316defm : ZnWriteResFpuPair<WriteCvtI2PS, [ZnFPU3], 5>; 317defm : ZnWriteResFpuPair<WriteCvtI2PSY, [ZnFPU3], 5>; 318defm : X86WriteResPairUnsupported<WriteCvtI2PSZ>; 319defm : ZnWriteResFpuPair<WriteCvtI2SD, [ZnFPU3], 5>; 320defm : ZnWriteResFpuPair<WriteCvtI2PD, [ZnFPU3], 5>; 321defm : ZnWriteResFpuPair<WriteCvtI2PDY, [ZnFPU3], 5>; 322defm : X86WriteResPairUnsupported<WriteCvtI2PDZ>; 323defm : ZnWriteResFpuPair<WriteFDiv, [ZnFPU3], 15>; 324defm : ZnWriteResFpuPair<WriteFDivX, [ZnFPU3], 15>; 325//defm : ZnWriteResFpuPair<WriteFDivY, [ZnFPU3], 15>; 326defm : X86WriteResPairUnsupported<WriteFDivZ>; 327defm : ZnWriteResFpuPair<WriteFDiv64, [ZnFPU3], 15>; 328defm : ZnWriteResFpuPair<WriteFDiv64X, [ZnFPU3], 15>; 329//defm : ZnWriteResFpuPair<WriteFDiv64Y, [ZnFPU3], 15>; 330defm : X86WriteResPairUnsupported<WriteFDiv64Z>; 331defm : ZnWriteResFpuPair<WriteFSign, [ZnFPU3], 2>; 332defm : ZnWriteResFpuPair<WriteFRnd, [ZnFPU3], 4, [1], 1, 7, 1>; // FIXME: Should folds require 1 extra uops? 333defm : ZnWriteResFpuPair<WriteFRndY, [ZnFPU3], 4, [1], 1, 7, 1>; // FIXME: Should folds require 1 extra uops? 334defm : X86WriteResPairUnsupported<WriteFRndZ>; 335defm : ZnWriteResFpuPair<WriteFLogic, [ZnFPU], 1>; 336defm : ZnWriteResFpuPair<WriteFLogicY, [ZnFPU], 1>; 337defm : X86WriteResPairUnsupported<WriteFLogicZ>; 338defm : ZnWriteResFpuPair<WriteFTest, [ZnFPU], 1>; 339defm : ZnWriteResFpuPair<WriteFTestY, [ZnFPU], 1>; 340defm : X86WriteResPairUnsupported<WriteFTestZ>; 341defm : ZnWriteResFpuPair<WriteFShuffle, [ZnFPU12], 1>; 342defm : ZnWriteResFpuPair<WriteFShuffleY, [ZnFPU12], 1>; 343defm : X86WriteResPairUnsupported<WriteFShuffleZ>; 344defm : ZnWriteResFpuPair<WriteFVarShuffle, [ZnFPU12], 1>; 345defm : ZnWriteResFpuPair<WriteFVarShuffleY,[ZnFPU12], 1>; 346defm : X86WriteResPairUnsupported<WriteFVarShuffleZ>; 347defm : ZnWriteResFpuPair<WriteFMul, [ZnFPU01], 3, [1], 1, 7, 1>; 348defm : ZnWriteResFpuPair<WriteFMulX, [ZnFPU01], 3, [1], 1, 7, 1>; 349defm : ZnWriteResFpuPair<WriteFMulY, [ZnFPU01], 4, [1], 1, 7, 1>; 350defm : X86WriteResPairUnsupported<WriteFMulZ>; 351defm : ZnWriteResFpuPair<WriteFMul64, [ZnFPU01], 3, [1], 1, 7, 1>; 352defm : ZnWriteResFpuPair<WriteFMul64X, [ZnFPU01], 3, [1], 1, 7, 1>; 353defm : ZnWriteResFpuPair<WriteFMul64Y, [ZnFPU01], 4, [1], 1, 7, 1>; 354defm : X86WriteResPairUnsupported<WriteFMul64Z>; 355defm : ZnWriteResFpuPair<WriteFMA, [ZnFPU03], 5>; 356defm : ZnWriteResFpuPair<WriteFMAX, [ZnFPU03], 5>; 357defm : ZnWriteResFpuPair<WriteFMAY, [ZnFPU03], 5>; 358defm : X86WriteResPairUnsupported<WriteFMAZ>; 359defm : ZnWriteResFpuPair<WriteFRcp, [ZnFPU01], 5>; 360defm : ZnWriteResFpuPair<WriteFRcpX, [ZnFPU01], 5>; 361defm : ZnWriteResFpuPair<WriteFRcpY, [ZnFPU01], 5, [1], 1, 7, 2>; 362defm : X86WriteResPairUnsupported<WriteFRcpZ>; 363//defm : ZnWriteResFpuPair<WriteFRsqrt, [ZnFPU02], 5>; 364defm : ZnWriteResFpuPair<WriteFRsqrtX, [ZnFPU01], 5, [1], 1, 7, 1>; 365//defm : ZnWriteResFpuPair<WriteFRsqrtY, [ZnFPU01], 5, [2], 2>; 366defm : X86WriteResPairUnsupported<WriteFRsqrtZ>; 367defm : ZnWriteResFpuPair<WriteFSqrt, [ZnFPU3], 20, [20]>; 368defm : ZnWriteResFpuPair<WriteFSqrtX, [ZnFPU3], 20, [20]>; 369defm : ZnWriteResFpuPair<WriteFSqrtY, [ZnFPU3], 28, [28], 1, 7, 1>; 370defm : X86WriteResPairUnsupported<WriteFSqrtZ>; 371defm : ZnWriteResFpuPair<WriteFSqrt64, [ZnFPU3], 20, [20]>; 372defm : ZnWriteResFpuPair<WriteFSqrt64X, [ZnFPU3], 20, [20]>; 373defm : ZnWriteResFpuPair<WriteFSqrt64Y, [ZnFPU3], 40, [40], 1, 7, 1>; 374defm : X86WriteResPairUnsupported<WriteFSqrt64Z>; 375defm : ZnWriteResFpuPair<WriteFSqrt80, [ZnFPU3], 20, [20]>; 376 377// Vector integer operations which uses FPU units 378defm : X86WriteRes<WriteVecLoad, [ZnAGU], 8, [1], 1>; 379defm : X86WriteRes<WriteVecLoadX, [ZnAGU], 8, [1], 1>; 380defm : X86WriteRes<WriteVecLoadY, [ZnAGU], 8, [1], 1>; 381defm : X86WriteRes<WriteVecLoadNT, [ZnAGU], 8, [1], 1>; 382defm : X86WriteRes<WriteVecLoadNTY, [ZnAGU], 8, [1], 1>; 383defm : X86WriteRes<WriteVecMaskedLoad, [ZnAGU,ZnFPU01], 8, [1,2], 2>; 384defm : X86WriteRes<WriteVecMaskedLoadY, [ZnAGU,ZnFPU01], 9, [1,3], 2>; 385defm : X86WriteRes<WriteVecStore, [ZnAGU], 1, [1], 1>; 386defm : X86WriteRes<WriteVecStoreX, [ZnAGU], 1, [1], 1>; 387defm : X86WriteRes<WriteVecStoreY, [ZnAGU], 1, [1], 1>; 388defm : X86WriteRes<WriteVecStoreNT, [ZnAGU], 1, [1], 1>; 389defm : X86WriteRes<WriteVecStoreNTY, [ZnAGU], 1, [1], 1>; 390defm : X86WriteRes<WriteVecMaskedStore, [ZnAGU,ZnFPU01], 4, [1,1], 1>; 391defm : X86WriteRes<WriteVecMaskedStoreY, [ZnAGU,ZnFPU01], 5, [1,2], 2>; 392defm : X86WriteRes<WriteVecMove, [ZnFPU], 1, [1], 1>; 393defm : X86WriteRes<WriteVecMoveX, [ZnFPU], 1, [1], 1>; 394defm : X86WriteRes<WriteVecMoveY, [ZnFPU], 2, [1], 2>; 395defm : X86WriteRes<WriteVecMoveToGpr, [ZnFPU2], 2, [1], 1>; 396defm : X86WriteRes<WriteVecMoveFromGpr, [ZnFPU2], 3, [1], 1>; 397defm : X86WriteRes<WriteEMMS, [ZnFPU], 2, [1], 1>; 398 399defm : ZnWriteResFpuPair<WriteVecShift, [ZnFPU], 1>; 400defm : ZnWriteResFpuPair<WriteVecShiftX, [ZnFPU2], 1>; 401defm : ZnWriteResFpuPair<WriteVecShiftY, [ZnFPU2], 2>; 402defm : X86WriteResPairUnsupported<WriteVecShiftZ>; 403defm : ZnWriteResFpuPair<WriteVecShiftImm, [ZnFPU], 1>; 404defm : ZnWriteResFpuPair<WriteVecShiftImmX, [ZnFPU], 1>; 405defm : ZnWriteResFpuPair<WriteVecShiftImmY, [ZnFPU], 1>; 406defm : X86WriteResPairUnsupported<WriteVecShiftImmZ>; 407defm : ZnWriteResFpuPair<WriteVecLogic, [ZnFPU], 1>; 408defm : ZnWriteResFpuPair<WriteVecLogicX, [ZnFPU], 1>; 409defm : ZnWriteResFpuPair<WriteVecLogicY, [ZnFPU], 1>; 410defm : X86WriteResPairUnsupported<WriteVecLogicZ>; 411defm : ZnWriteResFpuPair<WriteVecTest, [ZnFPU12], 1, [2], 1, 7, 1>; 412defm : ZnWriteResFpuPair<WriteVecTestY, [ZnFPU12], 1, [2], 1, 7, 1>; 413defm : X86WriteResPairUnsupported<WriteVecTestZ>; 414defm : ZnWriteResFpuPair<WriteVecALU, [ZnFPU], 1>; 415defm : ZnWriteResFpuPair<WriteVecALUX, [ZnFPU], 1>; 416defm : ZnWriteResFpuPair<WriteVecALUY, [ZnFPU], 1>; 417defm : X86WriteResPairUnsupported<WriteVecALUZ>; 418defm : ZnWriteResFpuPair<WriteVecIMul, [ZnFPU0], 4>; 419defm : ZnWriteResFpuPair<WriteVecIMulX, [ZnFPU0], 4>; 420defm : ZnWriteResFpuPair<WriteVecIMulY, [ZnFPU0], 4>; 421defm : X86WriteResPairUnsupported<WriteVecIMulZ>; 422defm : ZnWriteResFpuPair<WritePMULLD, [ZnFPU0], 4, [1], 1, 7, 1>; // FIXME 423defm : ZnWriteResFpuPair<WritePMULLDY, [ZnFPU0], 5, [2], 1, 7, 1>; // FIXME 424defm : X86WriteResPairUnsupported<WritePMULLDZ>; 425defm : ZnWriteResFpuPair<WriteShuffle, [ZnFPU], 1>; 426defm : ZnWriteResFpuPair<WriteShuffleX, [ZnFPU], 1>; 427defm : ZnWriteResFpuPair<WriteShuffleY, [ZnFPU], 1>; 428defm : X86WriteResPairUnsupported<WriteShuffleZ>; 429defm : ZnWriteResFpuPair<WriteVarShuffle, [ZnFPU], 1>; 430defm : ZnWriteResFpuPair<WriteVarShuffleX,[ZnFPU], 1>; 431defm : ZnWriteResFpuPair<WriteVarShuffleY,[ZnFPU], 1>; 432defm : X86WriteResPairUnsupported<WriteVarShuffleZ>; 433defm : ZnWriteResFpuPair<WriteBlend, [ZnFPU01], 1>; 434defm : ZnWriteResFpuPair<WriteBlendY, [ZnFPU01], 1>; 435defm : X86WriteResPairUnsupported<WriteBlendZ>; 436defm : ZnWriteResFpuPair<WriteShuffle256, [ZnFPU], 2>; 437defm : ZnWriteResFpuPair<WriteVarShuffle256, [ZnFPU], 2>; 438defm : ZnWriteResFpuPair<WritePSADBW, [ZnFPU0], 3>; 439defm : ZnWriteResFpuPair<WritePSADBWX, [ZnFPU0], 3>; 440defm : ZnWriteResFpuPair<WritePSADBWY, [ZnFPU0], 3>; 441defm : X86WriteResPairUnsupported<WritePSADBWZ>; 442defm : ZnWriteResFpuPair<WritePHMINPOS, [ZnFPU0], 4>; 443 444// Vector Shift Operations 445defm : ZnWriteResFpuPair<WriteVarVecShift, [ZnFPU12], 1>; 446defm : ZnWriteResFpuPair<WriteVarVecShiftY, [ZnFPU12], 1>; 447defm : X86WriteResPairUnsupported<WriteVarVecShiftZ>; 448 449// Vector insert/extract operations. 450defm : ZnWriteResFpuPair<WriteVecInsert, [ZnFPU], 1>; 451 452def : WriteRes<WriteVecExtract, [ZnFPU12, ZnFPU2]> { 453 let Latency = 2; 454 let ResourceCycles = [1, 2]; 455} 456def : WriteRes<WriteVecExtractSt, [ZnAGU, ZnFPU12, ZnFPU2]> { 457 let Latency = 5; 458 let NumMicroOps = 2; 459 let ResourceCycles = [1, 2, 3]; 460} 461 462// MOVMSK Instructions. 463def : WriteRes<WriteFMOVMSK, [ZnFPU2]>; 464def : WriteRes<WriteMMXMOVMSK, [ZnFPU2]>; 465def : WriteRes<WriteVecMOVMSK, [ZnFPU2]>; 466 467def : WriteRes<WriteVecMOVMSKY, [ZnFPU2]> { 468 let NumMicroOps = 2; 469 let Latency = 2; 470 let ResourceCycles = [2]; 471} 472 473// AES Instructions. 474defm : ZnWriteResFpuPair<WriteAESDecEnc, [ZnFPU01], 4>; 475defm : ZnWriteResFpuPair<WriteAESIMC, [ZnFPU01], 4>; 476defm : ZnWriteResFpuPair<WriteAESKeyGen, [ZnFPU01], 4>; 477 478def : WriteRes<WriteFence, [ZnAGU]>; 479def : WriteRes<WriteNop, []>; 480 481// Following instructions with latency=100 are microcoded. 482// We set long latency so as to block the entire pipeline. 483defm : ZnWriteResFpuPair<WriteFShuffle256, [ZnFPU], 100>; 484defm : ZnWriteResFpuPair<WriteFVarShuffle256, [ZnFPU], 100>; 485 486// Microcoded Instructions 487def ZnWriteMicrocoded : SchedWriteRes<[]> { 488 let Latency = 100; 489} 490 491def : SchedAlias<WriteMicrocoded, ZnWriteMicrocoded>; 492def : SchedAlias<WriteFCMOV, ZnWriteMicrocoded>; 493def : SchedAlias<WriteSystem, ZnWriteMicrocoded>; 494def : SchedAlias<WriteMPSAD, ZnWriteMicrocoded>; 495def : SchedAlias<WriteMPSADY, ZnWriteMicrocoded>; 496def : SchedAlias<WriteMPSADLd, ZnWriteMicrocoded>; 497def : SchedAlias<WriteMPSADYLd, ZnWriteMicrocoded>; 498def : SchedAlias<WriteCLMul, ZnWriteMicrocoded>; 499def : SchedAlias<WriteCLMulLd, ZnWriteMicrocoded>; 500def : SchedAlias<WritePCmpIStrM, ZnWriteMicrocoded>; 501def : SchedAlias<WritePCmpIStrMLd, ZnWriteMicrocoded>; 502def : SchedAlias<WritePCmpEStrI, ZnWriteMicrocoded>; 503def : SchedAlias<WritePCmpEStrILd, ZnWriteMicrocoded>; 504def : SchedAlias<WritePCmpEStrM, ZnWriteMicrocoded>; 505def : SchedAlias<WritePCmpEStrMLd, ZnWriteMicrocoded>; 506def : SchedAlias<WritePCmpIStrI, ZnWriteMicrocoded>; 507def : SchedAlias<WritePCmpIStrILd, ZnWriteMicrocoded>; 508def : SchedAlias<WriteLDMXCSR, ZnWriteMicrocoded>; 509def : SchedAlias<WriteSTMXCSR, ZnWriteMicrocoded>; 510 511//=== Regex based InstRW ===// 512// Notation: 513// - r: register. 514// - m = memory. 515// - i = immediate 516// - mm: 64 bit mmx register. 517// - x = 128 bit xmm register. 518// - (x)mm = mmx or xmm register. 519// - y = 256 bit ymm register. 520// - v = any vector register. 521 522//=== Integer Instructions ===// 523//-- Move instructions --// 524// MOV. 525// r16,m. 526def : InstRW<[WriteALULd, ReadAfterLd], (instrs MOV16rm)>; 527 528// MOVSX, MOVZX. 529// r,m. 530def : InstRW<[WriteLoad], (instregex "MOV(S|Z)X32rm(8|16)")>; 531 532// XCHG. 533// r,m. 534def ZnWriteXCHGrm : SchedWriteRes<[ZnAGU, ZnALU]> { 535 let Latency = 5; 536 let NumMicroOps = 2; 537} 538def : InstRW<[ZnWriteXCHGrm, ReadAfterLd], (instregex "XCHG(8|16|32|64)rm")>; 539 540def : InstRW<[WriteMicrocoded], (instrs XLAT)>; 541 542// POP16. 543// r. 544def ZnWritePop16r : SchedWriteRes<[ZnAGU]>{ 545 let Latency = 5; 546 let NumMicroOps = 2; 547} 548def : InstRW<[ZnWritePop16r], (instrs POP16rmm)>; 549def : InstRW<[WriteMicrocoded], (instregex "POPF(16|32)")>; 550def : InstRW<[WriteMicrocoded], (instregex "POPA(16|32)")>; 551 552 553// PUSH. 554// r. Has default values. 555// m. 556def ZnWritePUSH : SchedWriteRes<[ZnAGU]>{ 557 let Latency = 4; 558} 559def : InstRW<[ZnWritePUSH], (instregex "PUSH(16|32)rmm")>; 560 561//PUSHF 562def : InstRW<[WriteMicrocoded], (instregex "PUSHF(16|32)")>; 563 564// PUSHA. 565def ZnWritePushA : SchedWriteRes<[ZnAGU]> { 566 let Latency = 8; 567} 568def : InstRW<[ZnWritePushA], (instregex "PUSHA(16|32)")>; 569 570//LAHF 571def : InstRW<[WriteMicrocoded], (instrs LAHF)>; 572 573// MOVBE. 574// r,m. 575def ZnWriteMOVBE : SchedWriteRes<[ZnAGU, ZnALU]> { 576 let Latency = 5; 577} 578def : InstRW<[ZnWriteMOVBE, ReadAfterLd], (instregex "MOVBE(16|32|64)rm")>; 579 580// m16,r16. 581def : InstRW<[ZnWriteMOVBE], (instregex "MOVBE(16|32|64)mr")>; 582 583//-- Arithmetic instructions --// 584 585// ADD SUB. 586// m,r/i. 587def : InstRW<[WriteALULd], (instregex "(ADD|SUB)(8|16|32|64)m(r|i)", 588 "(ADD|SUB)(8|16|32|64)mi8", 589 "(ADD|SUB)64mi32")>; 590 591// ADC SBB. 592// m,r/i. 593def : InstRW<[WriteALULd], 594 (instregex "(ADC|SBB)(8|16|32|64)m(r|i)", 595 "(ADC|SBB)(16|32|64)mi8", 596 "(ADC|SBB)64mi32")>; 597 598// INC DEC NOT NEG. 599// m. 600def : InstRW<[WriteALULd], 601 (instregex "(INC|DEC|NOT|NEG)(8|16|32|64)m")>; 602 603// MUL IMUL. 604// r16. 605def ZnWriteMul16 : SchedWriteRes<[ZnALU1, ZnMultiplier]> { 606 let Latency = 3; 607} 608def : SchedAlias<WriteIMul16, ZnWriteMul16>; 609def : SchedAlias<WriteIMul16Imm, ZnWriteMul16>; // TODO: is this right? 610def : SchedAlias<WriteIMul16Reg, ZnWriteMul16>; // TODO: is this right? 611def : SchedAlias<WriteIMul16ImmLd, ZnWriteMul16>; // TODO: this is definitely wrong but matches what the instregex did. 612def : SchedAlias<WriteIMul16RegLd, ZnWriteMul16>; // TODO: this is definitely wrong but matches what the instregex did. 613 614// m16. 615def ZnWriteMul16Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> { 616 let Latency = 8; 617} 618def : SchedAlias<WriteIMul16Ld, ZnWriteMul16Ld>; 619 620// r32. 621def ZnWriteMul32 : SchedWriteRes<[ZnALU1, ZnMultiplier]> { 622 let Latency = 3; 623} 624def : SchedAlias<WriteIMul32, ZnWriteMul32>; 625def : SchedAlias<WriteIMul32Imm, ZnWriteMul32>; // TODO: is this right? 626def : SchedAlias<WriteIMul32Reg, ZnWriteMul32>; // TODO: is this right? 627def : SchedAlias<WriteIMul32ImmLd, ZnWriteMul32>; // TODO: this is definitely wrong but matches what the instregex did. 628def : SchedAlias<WriteIMul32RegLd, ZnWriteMul32>; // TODO: this is definitely wrong but matches what the instregex did. 629 630// m32. 631def ZnWriteMul32Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> { 632 let Latency = 8; 633} 634def : SchedAlias<WriteIMul32Ld, ZnWriteMul32Ld>; 635 636// r64. 637def ZnWriteMul64 : SchedWriteRes<[ZnALU1, ZnMultiplier]> { 638 let Latency = 4; 639 let NumMicroOps = 2; 640} 641def : SchedAlias<WriteIMul64, ZnWriteMul64>; 642def : SchedAlias<WriteIMul64Imm, ZnWriteMul64>; // TODO: is this right? 643def : SchedAlias<WriteIMul64Reg, ZnWriteMul64>; // TODO: is this right? 644def : SchedAlias<WriteIMul64ImmLd, ZnWriteMul64>; // TODO: this is definitely wrong but matches what the instregex did. 645def : SchedAlias<WriteIMul64RegLd, ZnWriteMul64>; // TODO: this is definitely wrong but matches what the instregex did. 646 647// m64. 648def ZnWriteMul64Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> { 649 let Latency = 9; 650 let NumMicroOps = 2; 651} 652def : SchedAlias<WriteIMul64Ld, ZnWriteMul64Ld>; 653 654// MULX. 655// r32,r32,r32. 656def ZnWriteMulX32 : SchedWriteRes<[ZnALU1, ZnMultiplier]> { 657 let Latency = 3; 658 let ResourceCycles = [1, 2]; 659} 660def : InstRW<[ZnWriteMulX32], (instrs MULX32rr)>; 661 662// r32,r32,m32. 663def ZnWriteMulX32Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> { 664 let Latency = 8; 665 let ResourceCycles = [1, 2, 2]; 666} 667def : InstRW<[ZnWriteMulX32Ld, ReadAfterLd], (instrs MULX32rm)>; 668 669// r64,r64,r64. 670def ZnWriteMulX64 : SchedWriteRes<[ZnALU1]> { 671 let Latency = 3; 672} 673def : InstRW<[ZnWriteMulX64], (instrs MULX64rr)>; 674 675// r64,r64,m64. 676def ZnWriteMulX64Ld : SchedWriteRes<[ZnAGU, ZnALU1, ZnMultiplier]> { 677 let Latency = 8; 678} 679def : InstRW<[ZnWriteMulX64Ld, ReadAfterLd], (instrs MULX64rm)>; 680 681//-- Control transfer instructions --// 682 683// J(E|R)CXZ. 684def ZnWriteJCXZ : SchedWriteRes<[ZnALU03]>; 685def : InstRW<[ZnWriteJCXZ], (instrs JCXZ, JECXZ, JRCXZ)>; 686 687// INTO 688def : InstRW<[WriteMicrocoded], (instrs INTO)>; 689 690// LOOP. 691def ZnWriteLOOP : SchedWriteRes<[ZnALU03]>; 692def : InstRW<[ZnWriteLOOP], (instrs LOOP)>; 693 694// LOOP(N)E, LOOP(N)Z 695def ZnWriteLOOPE : SchedWriteRes<[ZnALU03]>; 696def : InstRW<[ZnWriteLOOPE], (instrs LOOPE, LOOPNE)>; 697 698// CALL. 699// r. 700def ZnWriteCALLr : SchedWriteRes<[ZnAGU, ZnALU03]>; 701def : InstRW<[ZnWriteCALLr], (instregex "CALL(16|32)r")>; 702 703def : InstRW<[WriteMicrocoded], (instregex "CALL(16|32)m")>; 704 705// RET. 706def ZnWriteRET : SchedWriteRes<[ZnALU03]> { 707 let NumMicroOps = 2; 708} 709def : InstRW<[ZnWriteRET], (instregex "RET(L|Q|W)", "LRET(L|Q|W)", 710 "IRET(16|32|64)")>; 711 712//-- Logic instructions --// 713 714// AND OR XOR. 715// m,r/i. 716def : InstRW<[WriteALULd], 717 (instregex "(AND|OR|XOR)(8|16|32|64)m(r|i)", 718 "(AND|OR|XOR)(8|16|32|64)mi8", "(AND|OR|XOR)64mi32")>; 719 720// Define ALU latency variants 721def ZnWriteALULat2 : SchedWriteRes<[ZnALU]> { 722 let Latency = 2; 723} 724def ZnWriteALULat2Ld : SchedWriteRes<[ZnAGU, ZnALU]> { 725 let Latency = 6; 726} 727 728// BTR BTS BTC. 729// m,r,i. 730def ZnWriteBTRSCm : SchedWriteRes<[ZnAGU, ZnALU]> { 731 let Latency = 6; 732 let NumMicroOps = 2; 733} 734// m,r,i. 735def : SchedAlias<WriteBitTestSetImmRMW, ZnWriteBTRSCm>; 736def : SchedAlias<WriteBitTestSetRegRMW, ZnWriteBTRSCm>; 737 738// BLSI BLSMSK BLSR. 739// r,r. 740def : SchedAlias<WriteBLS, ZnWriteALULat2>; 741// r,m. 742def : SchedAlias<WriteBLSLd, ZnWriteALULat2Ld>; 743 744// CLD STD. 745def : InstRW<[WriteALU], (instrs STD, CLD)>; 746 747// PDEP PEXT. 748// r,r,r. 749def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rr", "PEXT(32|64)rr")>; 750// r,r,m. 751def : InstRW<[WriteMicrocoded], (instregex "PDEP(32|64)rm", "PEXT(32|64)rm")>; 752 753// RCR RCL. 754// m,i. 755def : InstRW<[WriteMicrocoded], (instregex "RC(R|L)(8|16|32|64)m(1|i|CL)")>; 756 757// SHR SHL SAR. 758// m,i. 759def : InstRW<[WriteShiftLd], (instregex "S(A|H)(R|L)(8|16|32|64)m(i|1)")>; 760 761// SHRD SHLD. 762// m,r 763def : InstRW<[WriteShiftLd], (instregex "SH(R|L)D(16|32|64)mri8")>; 764 765// r,r,cl. 766def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)rrCL")>; 767 768// m,r,cl. 769def : InstRW<[WriteMicrocoded], (instregex "SH(R|L)D(16|32|64)mrCL")>; 770 771//-- Misc instructions --// 772// CMPXCHG8B. 773def ZnWriteCMPXCHG8B : SchedWriteRes<[ZnAGU, ZnALU]> { 774 let NumMicroOps = 18; 775} 776def : InstRW<[ZnWriteCMPXCHG8B], (instrs CMPXCHG8B)>; 777 778def : InstRW<[WriteMicrocoded], (instrs CMPXCHG16B)>; 779 780// LEAVE 781def ZnWriteLEAVE : SchedWriteRes<[ZnALU, ZnAGU]> { 782 let Latency = 8; 783 let NumMicroOps = 2; 784} 785def : InstRW<[ZnWriteLEAVE], (instregex "LEAVE")>; 786 787// PAUSE. 788def : InstRW<[WriteMicrocoded], (instrs PAUSE)>; 789 790// RDTSC. 791def : InstRW<[WriteMicrocoded], (instregex "RDTSC")>; 792 793// RDPMC. 794def : InstRW<[WriteMicrocoded], (instrs RDPMC)>; 795 796// RDRAND. 797def : InstRW<[WriteMicrocoded], (instrs RDRAND16r, RDRAND32r, RDRAND64r)>; 798 799// XGETBV. 800def : InstRW<[WriteMicrocoded], (instrs XGETBV)>; 801 802//-- String instructions --// 803// CMPS. 804def : InstRW<[WriteMicrocoded], (instregex "CMPS(B|L|Q|W)")>; 805 806// LODSB/W. 807def : InstRW<[WriteMicrocoded], (instregex "LODS(B|W)")>; 808 809// LODSD/Q. 810def : InstRW<[WriteMicrocoded], (instregex "LODS(L|Q)")>; 811 812// MOVS. 813def : InstRW<[WriteMicrocoded], (instregex "MOVS(B|L|Q|W)")>; 814 815// SCAS. 816def : InstRW<[WriteMicrocoded], (instregex "SCAS(B|W|L|Q)")>; 817 818// STOS 819def : InstRW<[WriteMicrocoded], (instregex "STOS(B|L|Q|W)")>; 820 821// XADD. 822def ZnXADD : SchedWriteRes<[ZnALU]>; 823def : InstRW<[ZnXADD], (instregex "XADD(8|16|32|64)rr")>; 824def : InstRW<[WriteMicrocoded], (instregex "XADD(8|16|32|64)rm")>; 825 826//=== Floating Point x87 Instructions ===// 827//-- Move instructions --// 828 829def ZnWriteFLDr : SchedWriteRes<[ZnFPU13]> ; 830 831def ZnWriteSTr: SchedWriteRes<[ZnFPU23]> { 832 let Latency = 5; 833 let NumMicroOps = 2; 834} 835 836// LD_F. 837// r. 838def : InstRW<[ZnWriteFLDr], (instrs LD_Frr)>; 839 840// m. 841def ZnWriteLD_F80m : SchedWriteRes<[ZnAGU, ZnFPU13]> { 842 let NumMicroOps = 2; 843} 844def : InstRW<[ZnWriteLD_F80m], (instrs LD_F80m)>; 845 846// FBLD. 847def : InstRW<[WriteMicrocoded], (instrs FBLDm)>; 848 849// FST(P). 850// r. 851def : InstRW<[ZnWriteSTr], (instregex "ST_(F|FP)rr")>; 852 853// m80. 854def ZnWriteST_FP80m : SchedWriteRes<[ZnAGU, ZnFPU23]> { 855 let Latency = 5; 856} 857def : InstRW<[ZnWriteST_FP80m], (instrs ST_FP80m)>; 858 859// FBSTP. 860// m80. 861def : InstRW<[WriteMicrocoded], (instrs FBSTPm)>; 862 863def ZnWriteFXCH : SchedWriteRes<[ZnFPU]>; 864 865// FXCHG. 866def : InstRW<[ZnWriteFXCH], (instrs XCH_F)>; 867 868// FILD. 869def ZnWriteFILD : SchedWriteRes<[ZnAGU, ZnFPU3]> { 870 let Latency = 11; 871 let NumMicroOps = 2; 872} 873def : InstRW<[ZnWriteFILD], (instregex "ILD_F(16|32|64)m")>; 874 875// FIST(P) FISTTP. 876def ZnWriteFIST : SchedWriteRes<[ZnAGU, ZnFPU23]> { 877 let Latency = 12; 878} 879def : InstRW<[ZnWriteFIST], (instregex "IS(T|TT)_(F|FP)(16|32|64)m")>; 880 881def ZnWriteFPU13 : SchedWriteRes<[ZnAGU, ZnFPU13]> { 882 let Latency = 8; 883} 884 885def ZnWriteFPU3 : SchedWriteRes<[ZnAGU, ZnFPU3]> { 886 let Latency = 11; 887} 888 889// FLDZ. 890def : SchedAlias<WriteFLD0, ZnWriteFPU13>; 891 892// FLD1. 893def : SchedAlias<WriteFLD1, ZnWriteFPU3>; 894 895// FLDPI FLDL2E etc. 896def : SchedAlias<WriteFLDC, ZnWriteFPU3>; 897 898// FNSTSW. 899// AX. 900def : InstRW<[WriteMicrocoded], (instrs FNSTSW16r)>; 901 902// m16. 903def : InstRW<[WriteMicrocoded], (instrs FNSTSWm)>; 904 905// FLDCW. 906def : InstRW<[WriteMicrocoded], (instrs FLDCW16m)>; 907 908// FNSTCW. 909def : InstRW<[WriteMicrocoded], (instrs FNSTCW16m)>; 910 911// FINCSTP FDECSTP. 912def : InstRW<[ZnWriteFPU3], (instrs FINCSTP, FDECSTP)>; 913 914// FFREE. 915def : InstRW<[ZnWriteFPU3], (instregex "FFREE")>; 916 917// FNSAVE. 918def : InstRW<[WriteMicrocoded], (instrs FSAVEm)>; 919 920// FRSTOR. 921def : InstRW<[WriteMicrocoded], (instrs FRSTORm)>; 922 923//-- Arithmetic instructions --// 924 925def ZnWriteFPU3Lat1 : SchedWriteRes<[ZnFPU3]> ; 926 927def ZnWriteFPU0Lat1 : SchedWriteRes<[ZnFPU0]> ; 928 929def ZnWriteFPU0Lat1Ld : SchedWriteRes<[ZnAGU, ZnFPU0]> { 930 let Latency = 8; 931} 932 933// FCHS. 934def : InstRW<[ZnWriteFPU3Lat1], (instregex "CHS_F")>; 935 936// FCOM(P) FUCOM(P). 937// r. 938def : InstRW<[ZnWriteFPU0Lat1], (instregex "COM(P?)_FST0r", "UCOM_F(P?)r")>; 939// m. 940def : InstRW<[ZnWriteFPU0Lat1Ld], (instregex "FCOM(P?)(32|64)m")>; 941 942// FCOMPP FUCOMPP. 943// r. 944def : InstRW<[ZnWriteFPU0Lat1], (instrs FCOMPP, UCOM_FPPr)>; 945 946def ZnWriteFPU02 : SchedWriteRes<[ZnAGU, ZnFPU02]> 947{ 948 let Latency = 9; 949} 950 951// FCOMI(P) FUCOMI(P). 952// m. 953def : InstRW<[ZnWriteFPU02], (instrs COM_FIPr, COM_FIr, UCOM_FIPr, UCOM_FIr)>; 954 955def ZnWriteFPU03 : SchedWriteRes<[ZnAGU, ZnFPU03]> 956{ 957 let Latency = 12; 958 let NumMicroOps = 2; 959 let ResourceCycles = [1,3]; 960} 961 962// FICOM(P). 963def : InstRW<[ZnWriteFPU03], (instregex "FICOM(P?)(16|32)m")>; 964 965// FTST. 966def : InstRW<[ZnWriteFPU0Lat1], (instregex "TST_F")>; 967 968// FXAM. 969def : InstRW<[ZnWriteFPU3Lat1], (instrs FXAM)>; 970 971// FPREM. 972def : InstRW<[WriteMicrocoded], (instrs FPREM)>; 973 974// FPREM1. 975def : InstRW<[WriteMicrocoded], (instrs FPREM1)>; 976 977// FRNDINT. 978def : InstRW<[WriteMicrocoded], (instrs FRNDINT)>; 979 980// FSCALE. 981def : InstRW<[WriteMicrocoded], (instrs FSCALE)>; 982 983// FXTRACT. 984def : InstRW<[WriteMicrocoded], (instrs FXTRACT)>; 985 986// FNOP. 987def : InstRW<[ZnWriteFPU0Lat1], (instrs FNOP)>; 988 989// WAIT. 990def : InstRW<[ZnWriteFPU0Lat1], (instrs WAIT)>; 991 992// FNCLEX. 993def : InstRW<[WriteMicrocoded], (instrs FNCLEX)>; 994 995// FNINIT. 996def : InstRW<[WriteMicrocoded], (instrs FNINIT)>; 997 998//=== Integer MMX and XMM Instructions ===// 999 1000// PACKSSWB/DW. 1001// mm <- mm. 1002def ZnWriteFPU12 : SchedWriteRes<[ZnFPU12]> ; 1003def ZnWriteFPU12Y : SchedWriteRes<[ZnFPU12]> { 1004 let NumMicroOps = 2; 1005} 1006def ZnWriteFPU12m : SchedWriteRes<[ZnAGU, ZnFPU12]> ; 1007def ZnWriteFPU12Ym : SchedWriteRes<[ZnAGU, ZnFPU12]> { 1008 let Latency = 8; 1009 let NumMicroOps = 2; 1010} 1011 1012def : InstRW<[ZnWriteFPU12], (instrs MMX_PACKSSDWirr, 1013 MMX_PACKSSWBirr, 1014 MMX_PACKUSWBirr)>; 1015def : InstRW<[ZnWriteFPU12m], (instrs MMX_PACKSSDWirm, 1016 MMX_PACKSSWBirm, 1017 MMX_PACKUSWBirm)>; 1018 1019// VPMOVSX/ZX BW BD BQ WD WQ DQ. 1020// y <- x. 1021def : InstRW<[ZnWriteFPU12Y], (instregex "VPMOV(SX|ZX)(BW|BD|BQ|WD|WQ|DQ)Yrr")>; 1022def : InstRW<[ZnWriteFPU12Ym], (instregex "VPMOV(SX|ZX)(BW|BD|BQ|WD|WQ|DQ)Yrm")>; 1023 1024def ZnWriteFPU013 : SchedWriteRes<[ZnFPU013]> ; 1025def ZnWriteFPU013Y : SchedWriteRes<[ZnFPU013]> { 1026 let Latency = 2; 1027} 1028def ZnWriteFPU013m : SchedWriteRes<[ZnAGU, ZnFPU013]> { 1029 let Latency = 8; 1030 let NumMicroOps = 2; 1031} 1032def ZnWriteFPU013Ld : SchedWriteRes<[ZnAGU, ZnFPU013]> { 1033 let Latency = 8; 1034 let NumMicroOps = 2; 1035} 1036def ZnWriteFPU013LdY : SchedWriteRes<[ZnAGU, ZnFPU013]> { 1037 let Latency = 9; 1038 let NumMicroOps = 2; 1039} 1040 1041// PBLENDW. 1042// x,x,i / v,v,v,i 1043def : InstRW<[ZnWriteFPU013], (instregex "(V?)PBLENDWrri")>; 1044// ymm 1045def : InstRW<[ZnWriteFPU013Y], (instrs VPBLENDWYrri)>; 1046 1047// x,m,i / v,v,m,i 1048def : InstRW<[ZnWriteFPU013Ld], (instregex "(V?)PBLENDWrmi")>; 1049// y,m,i 1050def : InstRW<[ZnWriteFPU013LdY], (instrs VPBLENDWYrmi)>; 1051 1052def ZnWriteFPU01 : SchedWriteRes<[ZnFPU01]> ; 1053def ZnWriteFPU01Y : SchedWriteRes<[ZnFPU01]> { 1054 let NumMicroOps = 2; 1055} 1056 1057// VPBLENDD. 1058// v,v,v,i. 1059def : InstRW<[ZnWriteFPU01], (instrs VPBLENDDrri)>; 1060// ymm 1061def : InstRW<[ZnWriteFPU01Y], (instrs VPBLENDDYrri)>; 1062 1063// v,v,m,i 1064def ZnWriteFPU01Op2 : SchedWriteRes<[ZnAGU, ZnFPU01]> { 1065 let NumMicroOps = 2; 1066 let Latency = 8; 1067 let ResourceCycles = [1, 2]; 1068} 1069def ZnWriteFPU01Op2Y : SchedWriteRes<[ZnAGU, ZnFPU01]> { 1070 let NumMicroOps = 2; 1071 let Latency = 9; 1072 let ResourceCycles = [1, 3]; 1073} 1074def : InstRW<[ZnWriteFPU01Op2], (instrs VPBLENDDrmi)>; 1075def : InstRW<[ZnWriteFPU01Op2Y], (instrs VPBLENDDYrmi)>; 1076 1077// MASKMOVQ. 1078def : InstRW<[WriteMicrocoded], (instregex "MMX_MASKMOVQ(64)?")>; 1079 1080// MASKMOVDQU. 1081def : InstRW<[WriteMicrocoded], (instregex "(V?)MASKMOVDQU(64)?")>; 1082 1083// VPMASKMOVD. 1084// ymm 1085def : InstRW<[WriteMicrocoded], 1086 (instregex "VPMASKMOVD(Y?)rm")>; 1087// m, v,v. 1088def : InstRW<[WriteMicrocoded], (instregex "VPMASKMOV(D|Q)(Y?)mr")>; 1089 1090// VPBROADCAST B/W. 1091// x, m8/16. 1092def ZnWriteVPBROADCAST128Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> { 1093 let Latency = 8; 1094 let NumMicroOps = 2; 1095 let ResourceCycles = [1, 2]; 1096} 1097def : InstRW<[ZnWriteVPBROADCAST128Ld], 1098 (instregex "VPBROADCAST(B|W)rm")>; 1099 1100// y, m8/16 1101def ZnWriteVPBROADCAST256Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> { 1102 let Latency = 8; 1103 let NumMicroOps = 2; 1104 let ResourceCycles = [1, 2]; 1105} 1106def : InstRW<[ZnWriteVPBROADCAST256Ld], 1107 (instregex "VPBROADCAST(B|W)Yrm")>; 1108 1109// VPGATHER. 1110def : InstRW<[WriteMicrocoded], (instregex "VPGATHER(Q|D)(Q|D)(Y?)rm")>; 1111 1112//-- Arithmetic instructions --// 1113 1114// HADD, HSUB PS/PD 1115// PHADD|PHSUB (S) W/D. 1116def : SchedAlias<WritePHAdd, ZnWriteMicrocoded>; 1117def : SchedAlias<WritePHAddLd, ZnWriteMicrocoded>; 1118def : SchedAlias<WritePHAddX, ZnWriteMicrocoded>; 1119def : SchedAlias<WritePHAddXLd, ZnWriteMicrocoded>; 1120def : SchedAlias<WritePHAddY, ZnWriteMicrocoded>; 1121def : SchedAlias<WritePHAddYLd, ZnWriteMicrocoded>; 1122 1123// PCMPGTQ. 1124def ZnWritePCMPGTQr : SchedWriteRes<[ZnFPU03]>; 1125def : InstRW<[ZnWritePCMPGTQr], (instregex "(V?)PCMPGTQ(Y?)rr")>; 1126 1127// x <- x,m. 1128def ZnWritePCMPGTQm : SchedWriteRes<[ZnAGU, ZnFPU03]> { 1129 let Latency = 8; 1130} 1131// ymm. 1132def ZnWritePCMPGTQYm : SchedWriteRes<[ZnAGU, ZnFPU03]> { 1133 let Latency = 8; 1134 let NumMicroOps = 2; 1135 let ResourceCycles = [1,2]; 1136} 1137def : InstRW<[ZnWritePCMPGTQm], (instregex "(V?)PCMPGTQrm")>; 1138def : InstRW<[ZnWritePCMPGTQYm], (instrs VPCMPGTQYrm)>; 1139 1140//-- Logic instructions --// 1141 1142// PSLL,PSRL,PSRA W/D/Q. 1143// x,x / v,v,x. 1144def ZnWritePShift : SchedWriteRes<[ZnFPU2]> ; 1145def ZnWritePShiftY : SchedWriteRes<[ZnFPU2]> { 1146 let Latency = 2; 1147} 1148 1149// PSLL,PSRL DQ. 1150def : InstRW<[ZnWritePShift], (instregex "(V?)PS(R|L)LDQri")>; 1151def : InstRW<[ZnWritePShiftY], (instregex "(V?)PS(R|L)LDQYri")>; 1152 1153//=== Floating Point XMM and YMM Instructions ===// 1154//-- Move instructions --// 1155 1156// VPERM2F128. 1157def : InstRW<[WriteMicrocoded], (instrs VPERM2F128rr)>; 1158def : InstRW<[WriteMicrocoded], (instrs VPERM2F128rm)>; 1159 1160def ZnWriteBROADCAST : SchedWriteRes<[ZnAGU, ZnFPU13]> { 1161 let NumMicroOps = 2; 1162 let Latency = 8; 1163} 1164// VBROADCASTF128. 1165def : InstRW<[ZnWriteBROADCAST], (instrs VBROADCASTF128)>; 1166 1167// EXTRACTPS. 1168// r32,x,i. 1169def ZnWriteEXTRACTPSr : SchedWriteRes<[ZnFPU12, ZnFPU2]> { 1170 let Latency = 2; 1171 let NumMicroOps = 2; 1172 let ResourceCycles = [1, 2]; 1173} 1174def : InstRW<[ZnWriteEXTRACTPSr], (instregex "(V?)EXTRACTPSrr")>; 1175 1176def ZnWriteEXTRACTPSm : SchedWriteRes<[ZnAGU,ZnFPU12, ZnFPU2]> { 1177 let Latency = 5; 1178 let NumMicroOps = 2; 1179 let ResourceCycles = [5, 1, 2]; 1180} 1181// m32,x,i. 1182def : InstRW<[ZnWriteEXTRACTPSm], (instregex "(V?)EXTRACTPSmr")>; 1183 1184// VEXTRACTF128. 1185// x,y,i. 1186def : InstRW<[ZnWriteFPU013], (instrs VEXTRACTF128rr)>; 1187 1188// m128,y,i. 1189def : InstRW<[ZnWriteFPU013m], (instrs VEXTRACTF128mr)>; 1190 1191def ZnWriteVINSERT128r: SchedWriteRes<[ZnFPU013]> { 1192 let Latency = 2; 1193 let ResourceCycles = [2]; 1194} 1195def ZnWriteVINSERT128Ld: SchedWriteRes<[ZnAGU,ZnFPU013]> { 1196 let Latency = 9; 1197 let NumMicroOps = 2; 1198 let ResourceCycles = [1, 2]; 1199} 1200// VINSERTF128. 1201// y,y,x,i. 1202def : InstRW<[ZnWriteVINSERT128r], (instrs VINSERTF128rr)>; 1203def : InstRW<[ZnWriteVINSERT128Ld], (instrs VINSERTF128rm)>; 1204 1205// VGATHER. 1206def : InstRW<[WriteMicrocoded], (instregex "VGATHER(Q|D)(PD|PS)(Y?)rm")>; 1207 1208//-- Conversion instructions --// 1209def ZnWriteCVTPD2PSr: SchedWriteRes<[ZnFPU3]> { 1210 let Latency = 4; 1211} 1212def ZnWriteCVTPD2PSYr: SchedWriteRes<[ZnFPU3]> { 1213 let Latency = 5; 1214} 1215 1216// CVTPD2PS. 1217// x,x. 1218def : SchedAlias<WriteCvtPD2PS, ZnWriteCVTPD2PSr>; 1219// y,y. 1220def : SchedAlias<WriteCvtPD2PSY, ZnWriteCVTPD2PSYr>; 1221// z,z. 1222defm : X86WriteResUnsupported<WriteCvtPD2PSZ>; 1223 1224def ZnWriteCVTPD2PSLd: SchedWriteRes<[ZnAGU,ZnFPU03]> { 1225 let Latency = 11; 1226 let NumMicroOps = 2; 1227 let ResourceCycles = [1,2]; 1228} 1229// x,m128. 1230def : SchedAlias<WriteCvtPD2PSLd, ZnWriteCVTPD2PSLd>; 1231 1232// x,m256. 1233def ZnWriteCVTPD2PSYLd : SchedWriteRes<[ZnAGU, ZnFPU3]> { 1234 let Latency = 11; 1235} 1236def : SchedAlias<WriteCvtPD2PSYLd, ZnWriteCVTPD2PSYLd>; 1237// z,m512 1238defm : X86WriteResUnsupported<WriteCvtPD2PSZLd>; 1239 1240// CVTSD2SS. 1241// x,x. 1242// Same as WriteCVTPD2PSr 1243def : SchedAlias<WriteCvtSD2SS, ZnWriteCVTPD2PSr>; 1244 1245// x,m64. 1246def : SchedAlias<WriteCvtSD2SSLd, ZnWriteCVTPD2PSLd>; 1247 1248// CVTPS2PD. 1249// x,x. 1250def ZnWriteCVTPS2PDr : SchedWriteRes<[ZnFPU3]> { 1251 let Latency = 3; 1252} 1253def : SchedAlias<WriteCvtPS2PD, ZnWriteCVTPS2PDr>; 1254 1255// x,m64. 1256// y,m128. 1257def ZnWriteCVTPS2PDLd : SchedWriteRes<[ZnAGU, ZnFPU3]> { 1258 let Latency = 10; 1259 let NumMicroOps = 2; 1260} 1261def : SchedAlias<WriteCvtPS2PDLd, ZnWriteCVTPS2PDLd>; 1262def : SchedAlias<WriteCvtPS2PDYLd, ZnWriteCVTPS2PDLd>; 1263defm : X86WriteResUnsupported<WriteCvtPS2PDZLd>; 1264 1265// y,x. 1266def ZnWriteVCVTPS2PDY : SchedWriteRes<[ZnFPU3]> { 1267 let Latency = 3; 1268} 1269def : SchedAlias<WriteCvtPS2PDY, ZnWriteVCVTPS2PDY>; 1270defm : X86WriteResUnsupported<WriteCvtPS2PDZ>; 1271 1272// CVTSS2SD. 1273// x,x. 1274def ZnWriteCVTSS2SDr : SchedWriteRes<[ZnFPU3]> { 1275 let Latency = 4; 1276} 1277def : SchedAlias<WriteCvtSS2SD, ZnWriteCVTSS2SDr>; 1278 1279// x,m32. 1280def ZnWriteCVTSS2SDLd : SchedWriteRes<[ZnAGU, ZnFPU3]> { 1281 let Latency = 11; 1282 let NumMicroOps = 2; 1283 let ResourceCycles = [1, 2]; 1284} 1285def : SchedAlias<WriteCvtSS2SDLd, ZnWriteCVTSS2SDLd>; 1286 1287def ZnWriteCVTDQ2PDr: SchedWriteRes<[ZnFPU12,ZnFPU3]> { 1288 let Latency = 5; 1289} 1290// CVTDQ2PD. 1291// x,x. 1292def : InstRW<[ZnWriteCVTDQ2PDr], (instregex "(V)?CVTDQ2PDrr")>; 1293 1294// Same as xmm 1295// y,x. 1296def : InstRW<[ZnWriteCVTDQ2PDr], (instrs VCVTDQ2PDYrr)>; 1297 1298def ZnWriteCVTPD2DQr: SchedWriteRes<[ZnFPU12, ZnFPU3]> { 1299 let Latency = 5; 1300} 1301// CVT(T)PD2DQ. 1302// x,x. 1303def : InstRW<[ZnWriteCVTDQ2PDr], (instregex "(V?)CVT(T?)PD2DQrr")>; 1304 1305def ZnWriteCVTPD2DQLd: SchedWriteRes<[ZnAGU,ZnFPU12,ZnFPU3]> { 1306 let Latency = 12; 1307 let NumMicroOps = 2; 1308} 1309// x,m128. 1310def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "(V?)CVT(T?)PD2DQrm")>; 1311// same as xmm handling 1312// x,y. 1313def : InstRW<[ZnWriteCVTPD2DQr], (instregex "VCVT(T?)PD2DQYrr")>; 1314// x,m256. 1315def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "VCVT(T?)PD2DQYrm")>; 1316 1317def ZnWriteCVTPS2PIr: SchedWriteRes<[ZnFPU3]> { 1318 let Latency = 4; 1319} 1320// CVT(T)PS2PI. 1321// mm,x. 1322def : InstRW<[ZnWriteCVTPS2PIr], (instregex "MMX_CVT(T?)PS2PIirr")>; 1323 1324// CVTPI2PD. 1325// x,mm. 1326def : InstRW<[ZnWriteCVTPS2PDr], (instrs MMX_CVTPI2PDirr)>; 1327 1328// CVT(T)PD2PI. 1329// mm,x. 1330def : InstRW<[ZnWriteCVTPS2PIr], (instregex "MMX_CVT(T?)PD2PIirr")>; 1331 1332def ZnWriteCVSTSI2SSr: SchedWriteRes<[ZnFPU3]> { 1333 let Latency = 5; 1334} 1335 1336// same as CVTPD2DQr 1337// CVT(T)SS2SI. 1338// r32,x. 1339def : InstRW<[ZnWriteCVTPD2DQr], (instregex "(V?)CVT(T?)SS2SI(64)?rr")>; 1340// same as CVTPD2DQm 1341// r32,m32. 1342def : InstRW<[ZnWriteCVTPD2DQLd], (instregex "(V?)CVT(T?)SS2SI(64)?rm")>; 1343 1344def ZnWriteCVSTSI2SDr: SchedWriteRes<[ZnFPU013, ZnFPU3]> { 1345 let Latency = 5; 1346} 1347// CVTSI2SD. 1348// x,r32/64. 1349def : InstRW<[ZnWriteCVSTSI2SDr], (instregex "(V?)CVTSI(64)?2SDrr")>; 1350 1351 1352def ZnWriteCVSTSI2SIr: SchedWriteRes<[ZnFPU3, ZnFPU2]> { 1353 let Latency = 5; 1354} 1355def ZnWriteCVSTSI2SILd: SchedWriteRes<[ZnAGU, ZnFPU3, ZnFPU2]> { 1356 let Latency = 12; 1357} 1358// CVTSD2SI. 1359// r32/64 1360def : InstRW<[ZnWriteCVSTSI2SIr], (instregex "(V?)CVT(T?)SD2SI(64)?rr")>; 1361// r32,m32. 1362def : InstRW<[ZnWriteCVSTSI2SILd], (instregex "(V?)CVT(T?)SD2SI(64)?rm")>; 1363 1364// VCVTPS2PH. 1365// x,v,i. 1366def : SchedAlias<WriteCvtPS2PH, ZnWriteMicrocoded>; 1367def : SchedAlias<WriteCvtPS2PHY, ZnWriteMicrocoded>; 1368defm : X86WriteResUnsupported<WriteCvtPS2PHZ>; 1369// m,v,i. 1370def : SchedAlias<WriteCvtPS2PHSt, ZnWriteMicrocoded>; 1371def : SchedAlias<WriteCvtPS2PHYSt, ZnWriteMicrocoded>; 1372defm : X86WriteResUnsupported<WriteCvtPS2PHZSt>; 1373 1374// VCVTPH2PS. 1375// v,x. 1376def : SchedAlias<WriteCvtPH2PS, ZnWriteMicrocoded>; 1377def : SchedAlias<WriteCvtPH2PSY, ZnWriteMicrocoded>; 1378defm : X86WriteResUnsupported<WriteCvtPH2PSZ>; 1379// v,m. 1380def : SchedAlias<WriteCvtPH2PSLd, ZnWriteMicrocoded>; 1381def : SchedAlias<WriteCvtPH2PSYLd, ZnWriteMicrocoded>; 1382defm : X86WriteResUnsupported<WriteCvtPH2PSZLd>; 1383 1384//-- SSE4A instructions --// 1385// EXTRQ 1386def ZnWriteEXTRQ: SchedWriteRes<[ZnFPU12, ZnFPU2]> { 1387 let Latency = 2; 1388} 1389def : InstRW<[ZnWriteEXTRQ], (instregex "EXTRQ")>; 1390 1391// INSERTQ 1392def ZnWriteINSERTQ: SchedWriteRes<[ZnFPU03,ZnFPU1]> { 1393 let Latency = 4; 1394} 1395def : InstRW<[ZnWriteINSERTQ], (instregex "INSERTQ")>; 1396 1397//-- SHA instructions --// 1398// SHA256MSG2 1399def : InstRW<[WriteMicrocoded], (instregex "SHA256MSG2(Y?)r(r|m)")>; 1400 1401// SHA1MSG1, SHA256MSG1 1402// x,x. 1403def ZnWriteSHA1MSG1r : SchedWriteRes<[ZnFPU12]> { 1404 let Latency = 2; 1405 let ResourceCycles = [2]; 1406} 1407def : InstRW<[ZnWriteSHA1MSG1r], (instregex "SHA(1|256)MSG1rr")>; 1408// x,m. 1409def ZnWriteSHA1MSG1Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> { 1410 let Latency = 9; 1411 let ResourceCycles = [1,2]; 1412} 1413def : InstRW<[ZnWriteSHA1MSG1Ld], (instregex "SHA(1|256)MSG1rm")>; 1414 1415// SHA1MSG2 1416// x,x. 1417def ZnWriteSHA1MSG2r : SchedWriteRes<[ZnFPU12]> ; 1418def : InstRW<[ZnWriteSHA1MSG2r], (instrs SHA1MSG2rr)>; 1419// x,m. 1420def ZnWriteSHA1MSG2Ld : SchedWriteRes<[ZnAGU, ZnFPU12]> { 1421 let Latency = 8; 1422} 1423def : InstRW<[ZnWriteSHA1MSG2Ld], (instrs SHA1MSG2rm)>; 1424 1425// SHA1NEXTE 1426// x,x. 1427def ZnWriteSHA1NEXTEr : SchedWriteRes<[ZnFPU1]> ; 1428def : InstRW<[ZnWriteSHA1NEXTEr], (instrs SHA1NEXTErr)>; 1429// x,m. 1430def ZnWriteSHA1NEXTELd : SchedWriteRes<[ZnAGU, ZnFPU1]> { 1431 let Latency = 8; 1432} 1433def : InstRW<[ZnWriteSHA1NEXTELd], (instrs SHA1NEXTErm)>; 1434 1435// SHA1RNDS4 1436// x,x. 1437def ZnWriteSHA1RNDS4r : SchedWriteRes<[ZnFPU1]> { 1438 let Latency = 6; 1439} 1440def : InstRW<[ZnWriteSHA1RNDS4r], (instrs SHA1RNDS4rri)>; 1441// x,m. 1442def ZnWriteSHA1RNDS4Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> { 1443 let Latency = 13; 1444} 1445def : InstRW<[ZnWriteSHA1RNDS4Ld], (instrs SHA1RNDS4rmi)>; 1446 1447// SHA256RNDS2 1448// x,x. 1449def ZnWriteSHA256RNDS2r : SchedWriteRes<[ZnFPU1]> { 1450 let Latency = 4; 1451} 1452def : InstRW<[ZnWriteSHA256RNDS2r], (instrs SHA256RNDS2rr)>; 1453// x,m. 1454def ZnWriteSHA256RNDS2Ld : SchedWriteRes<[ZnAGU, ZnFPU1]> { 1455 let Latency = 11; 1456} 1457def : InstRW<[ZnWriteSHA256RNDS2Ld], (instrs SHA256RNDS2rm)>; 1458 1459//-- Arithmetic instructions --// 1460 1461// HADD, HSUB PS/PD 1462def : SchedAlias<WriteFHAdd, ZnWriteMicrocoded>; 1463def : SchedAlias<WriteFHAddLd, ZnWriteMicrocoded>; 1464def : SchedAlias<WriteFHAddY, ZnWriteMicrocoded>; 1465def : SchedAlias<WriteFHAddYLd, ZnWriteMicrocoded>; 1466 1467// VDIVPS. 1468// TODO - convert to ZnWriteResFpuPair 1469// y,y,y. 1470def ZnWriteVDIVPSYr : SchedWriteRes<[ZnFPU3]> { 1471 let Latency = 12; 1472 let ResourceCycles = [12]; 1473} 1474def : SchedAlias<WriteFDivY, ZnWriteVDIVPSYr>; 1475 1476// y,y,m256. 1477def ZnWriteVDIVPSYLd : SchedWriteRes<[ZnAGU, ZnFPU3]> { 1478 let Latency = 19; 1479 let NumMicroOps = 2; 1480 let ResourceCycles = [1, 19]; 1481} 1482def : SchedAlias<WriteFDivYLd, ZnWriteVDIVPSYLd>; 1483 1484// VDIVPD. 1485// TODO - convert to ZnWriteResFpuPair 1486// y,y,y. 1487def ZnWriteVDIVPDY : SchedWriteRes<[ZnFPU3]> { 1488 let Latency = 15; 1489 let ResourceCycles = [15]; 1490} 1491def : SchedAlias<WriteFDiv64Y, ZnWriteVDIVPDY>; 1492 1493// y,y,m256. 1494def ZnWriteVDIVPDYLd : SchedWriteRes<[ZnAGU, ZnFPU3]> { 1495 let Latency = 22; 1496 let NumMicroOps = 2; 1497 let ResourceCycles = [1,22]; 1498} 1499def : SchedAlias<WriteFDiv64YLd, ZnWriteVDIVPDYLd>; 1500 1501// DPPS. 1502// x,x,i / v,v,v,i. 1503def : SchedAlias<WriteDPPS, ZnWriteMicrocoded>; 1504def : SchedAlias<WriteDPPSY, ZnWriteMicrocoded>; 1505 1506// x,m,i / v,v,m,i. 1507def : SchedAlias<WriteDPPSLd, ZnWriteMicrocoded>; 1508def : SchedAlias<WriteDPPSYLd,ZnWriteMicrocoded>; 1509 1510// DPPD. 1511// x,x,i. 1512def : SchedAlias<WriteDPPD, ZnWriteMicrocoded>; 1513 1514// x,m,i. 1515def : SchedAlias<WriteDPPDLd, ZnWriteMicrocoded>; 1516 1517// RSQRTSS 1518// TODO - convert to ZnWriteResFpuPair 1519// x,x. 1520def ZnWriteRSQRTSSr : SchedWriteRes<[ZnFPU02]> { 1521 let Latency = 5; 1522} 1523def : SchedAlias<WriteFRsqrt, ZnWriteRSQRTSSr>; 1524 1525// x,m128. 1526def ZnWriteRSQRTSSLd: SchedWriteRes<[ZnAGU, ZnFPU02]> { 1527 let Latency = 12; 1528 let NumMicroOps = 2; 1529 let ResourceCycles = [1,2]; // FIXME: Is this right? 1530} 1531def : SchedAlias<WriteFRsqrtLd, ZnWriteRSQRTSSLd>; 1532 1533// RSQRTPS 1534// TODO - convert to ZnWriteResFpuPair 1535// y,y. 1536def ZnWriteRSQRTPSYr : SchedWriteRes<[ZnFPU01]> { 1537 let Latency = 5; 1538 let NumMicroOps = 2; 1539 let ResourceCycles = [2]; 1540} 1541def : SchedAlias<WriteFRsqrtY, ZnWriteRSQRTPSYr>; 1542 1543// y,m256. 1544def ZnWriteRSQRTPSYLd : SchedWriteRes<[ZnAGU, ZnFPU01]> { 1545 let Latency = 12; 1546 let NumMicroOps = 2; 1547} 1548def : SchedAlias<WriteFRsqrtYLd, ZnWriteRSQRTPSYLd>; 1549 1550//-- Other instructions --// 1551 1552// VZEROUPPER. 1553def : InstRW<[WriteMicrocoded], (instrs VZEROUPPER)>; 1554 1555// VZEROALL. 1556def : InstRW<[WriteMicrocoded], (instrs VZEROALL)>; 1557 1558} // SchedModel 1559