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