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