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