1//==- RISCVSchedSiFiveP400.td - SiFiveP400 Scheduling Defs ---*- 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//===----------------------------------------------------------------------===// 10 11def SiFiveP400Model : SchedMachineModel { 12 let IssueWidth = 3; // 3 micro-ops are dispatched per cycle. 13 let MicroOpBufferSize = 56; // Max micro-ops that can be buffered. 14 let LoadLatency = 4; // Cycles for loads to access the cache. 15 let MispredictPenalty = 9; // Extra cycles for a mispredicted branch. 16 let UnsupportedFeatures = [HasStdExtZbkb, HasStdExtZbkc, HasStdExtZbkx, 17 HasStdExtZcmt, HasStdExtZknd, HasStdExtZkne, 18 HasStdExtZknh, HasStdExtZksed, HasStdExtZksh, 19 HasStdExtZkr]; 20 let CompleteModel = false; 21} 22 23// The SiFiveP400 microarchitecure has 6 pipelines: 24// Three pipelines for integer operations. 25// One pipeline for FPU operations. 26// One pipeline for Load operations. 27// One pipeline for Store operations. 28let SchedModel = SiFiveP400Model in { 29 30def SiFiveP400IEXQ0 : ProcResource<1>; 31def SiFiveP400IEXQ1 : ProcResource<1>; 32def SiFiveP400IEXQ2 : ProcResource<1>; 33def SiFiveP400FEXQ0 : ProcResource<1>; 34def SiFiveP400Load : ProcResource<1>; 35def SiFiveP400Store : ProcResource<1>; 36 37def SiFiveP400IntArith : ProcResGroup<[SiFiveP400IEXQ0, SiFiveP400IEXQ1, SiFiveP400IEXQ2]>; 38defvar SiFiveP400Branch = SiFiveP400IEXQ0; 39defvar SiFiveP400SYS = SiFiveP400IEXQ1; 40defvar SiFiveP400MulDiv = SiFiveP400IEXQ2; 41defvar SiFiveP400I2F = SiFiveP400IEXQ2; 42def SiFiveP400Div : ProcResource<1>; 43 44defvar SiFiveP400FloatArith = SiFiveP400FEXQ0; 45defvar SiFiveP400F2I = SiFiveP400FEXQ0; 46def SiFiveP400FloatDiv : ProcResource<1>; 47 48let Latency = 1 in { 49// Integer arithmetic and logic 50def : WriteRes<WriteIALU, [SiFiveP400IntArith]>; 51def : WriteRes<WriteIALU32, [SiFiveP400IntArith]>; 52def : WriteRes<WriteShiftImm, [SiFiveP400IntArith]>; 53def : WriteRes<WriteShiftImm32, [SiFiveP400IntArith]>; 54def : WriteRes<WriteShiftReg, [SiFiveP400IntArith]>; 55def : WriteRes<WriteShiftReg32, [SiFiveP400IntArith]>; 56// Branching 57def : WriteRes<WriteJmp, [SiFiveP400Branch]>; 58def : WriteRes<WriteJal, [SiFiveP400Branch]>; 59def : WriteRes<WriteJalr, [SiFiveP400Branch]>; 60} 61 62// CMOV 63def P400WriteCMOV : SchedWriteRes<[SiFiveP400Branch, SiFiveP400IEXQ1]> { 64 let Latency = 2; 65 let NumMicroOps = 2; 66} 67def : InstRW<[P400WriteCMOV], (instrs PseudoCCMOVGPRNoX0)>; 68 69let Latency = 3 in { 70// Integer multiplication 71def : WriteRes<WriteIMul, [SiFiveP400MulDiv]>; 72def : WriteRes<WriteIMul32, [SiFiveP400MulDiv]>; 73// cpop[w] look exactly like multiply. 74def : WriteRes<WriteCPOP, [SiFiveP400MulDiv]>; 75def : WriteRes<WriteCPOP32, [SiFiveP400MulDiv]>; 76} 77 78// Integer division 79def : WriteRes<WriteIDiv, [SiFiveP400MulDiv, SiFiveP400Div]> { 80 let Latency = 35; 81 let ReleaseAtCycles = [1, 34]; 82} 83def : WriteRes<WriteIDiv32, [SiFiveP400MulDiv, SiFiveP400Div]> { 84 let Latency = 20; 85 let ReleaseAtCycles = [1, 19]; 86} 87 88// Integer remainder 89def : WriteRes<WriteIRem, [SiFiveP400MulDiv, SiFiveP400Div]> { 90 let Latency = 35; 91 let ReleaseAtCycles = [1, 34]; 92} 93def : WriteRes<WriteIRem32, [SiFiveP400MulDiv, SiFiveP400Div]> { 94 let Latency = 20; 95 let ReleaseAtCycles = [1, 19]; 96} 97 98let Latency = 1 in { 99// Bitmanip 100def : WriteRes<WriteRotateImm, [SiFiveP400IntArith]>; 101def : WriteRes<WriteRotateImm32, [SiFiveP400IntArith]>; 102def : WriteRes<WriteRotateReg, [SiFiveP400IntArith]>; 103def : WriteRes<WriteRotateReg32, [SiFiveP400IntArith]>; 104 105def : WriteRes<WriteCLZ, [SiFiveP400IntArith]>; 106def : WriteRes<WriteCLZ32, [SiFiveP400IntArith]>; 107def : WriteRes<WriteCTZ, [SiFiveP400IntArith]>; 108def : WriteRes<WriteCTZ32, [SiFiveP400IntArith]>; 109 110def : WriteRes<WriteORCB, [SiFiveP400IntArith]>; 111def : WriteRes<WriteIMinMax, [SiFiveP400IntArith]>; 112 113def : WriteRes<WriteREV8, [SiFiveP400IntArith]>; 114 115def : WriteRes<WriteSHXADD, [SiFiveP400IntArith]>; 116def : WriteRes<WriteSHXADD32, [SiFiveP400IntArith]>; 117 118def : WriteRes<WriteSingleBit, [SiFiveP400IntArith]>; 119def : WriteRes<WriteSingleBitImm, [SiFiveP400IntArith]>; 120def : WriteRes<WriteBEXT, [SiFiveP400IntArith]>; 121def : WriteRes<WriteBEXTI, [SiFiveP400IntArith]>; 122} 123 124// Memory 125let Latency = 1 in { 126def : WriteRes<WriteSTB, [SiFiveP400Store]>; 127def : WriteRes<WriteSTH, [SiFiveP400Store]>; 128def : WriteRes<WriteSTW, [SiFiveP400Store]>; 129def : WriteRes<WriteSTD, [SiFiveP400Store]>; 130def : WriteRes<WriteFST16, [SiFiveP400Store]>; 131def : WriteRes<WriteFST32, [SiFiveP400Store]>; 132def : WriteRes<WriteFST64, [SiFiveP400Store]>; 133} 134let Latency = 4 in { 135def : WriteRes<WriteLDB, [SiFiveP400Load]>; 136def : WriteRes<WriteLDH, [SiFiveP400Load]>; 137} 138let Latency = 4 in { 139def : WriteRes<WriteLDW, [SiFiveP400Load]>; 140def : WriteRes<WriteLDD, [SiFiveP400Load]>; 141} 142 143let Latency = 5 in { 144def : WriteRes<WriteFLD16, [SiFiveP400Load]>; 145def : WriteRes<WriteFLD32, [SiFiveP400Load]>; 146def : WriteRes<WriteFLD64, [SiFiveP400Load]>; 147} 148 149// Atomic memory 150let Latency = 3 in { 151def : WriteRes<WriteAtomicSTW, [SiFiveP400Store]>; 152def : WriteRes<WriteAtomicSTD, [SiFiveP400Store]>; 153def : WriteRes<WriteAtomicW, [SiFiveP400Load]>; 154def : WriteRes<WriteAtomicD, [SiFiveP400Load]>; 155def : WriteRes<WriteAtomicLDW, [SiFiveP400Load]>; 156def : WriteRes<WriteAtomicLDD, [SiFiveP400Load]>; 157} 158 159// Floating point 160let Latency = 4 in { 161def : WriteRes<WriteFAdd16, [SiFiveP400FloatArith]>; 162def : WriteRes<WriteFAdd32, [SiFiveP400FloatArith]>; 163def : WriteRes<WriteFAdd64, [SiFiveP400FloatArith]>; 164 165def : WriteRes<WriteFMul16, [SiFiveP400FloatArith]>; 166def : WriteRes<WriteFMul32, [SiFiveP400FloatArith]>; 167def : WriteRes<WriteFMul64, [SiFiveP400FloatArith]>; 168 169def : WriteRes<WriteFMA16, [SiFiveP400FloatArith]>; 170def : WriteRes<WriteFMA32, [SiFiveP400FloatArith]>; 171def : WriteRes<WriteFMA64, [SiFiveP400FloatArith]>; 172} 173 174let Latency = 2 in { 175def : WriteRes<WriteFSGNJ16, [SiFiveP400FloatArith]>; 176def : WriteRes<WriteFSGNJ32, [SiFiveP400FloatArith]>; 177def : WriteRes<WriteFSGNJ64, [SiFiveP400FloatArith]>; 178 179def : WriteRes<WriteFMinMax16, [SiFiveP400FloatArith]>; 180def : WriteRes<WriteFMinMax32, [SiFiveP400FloatArith]>; 181def : WriteRes<WriteFMinMax64, [SiFiveP400FloatArith]>; 182} 183 184// Half precision. 185def : WriteRes<WriteFDiv16, [SiFiveP400FEXQ0, SiFiveP400FloatDiv]> { 186 let Latency = 19; 187 let ReleaseAtCycles = [1, 18]; 188} 189def : WriteRes<WriteFSqrt16, [SiFiveP400FEXQ0, SiFiveP400FloatDiv]> { 190 let Latency = 18; 191 let ReleaseAtCycles = [1, 17]; 192} 193 194// Single precision. 195def : WriteRes<WriteFDiv32, [SiFiveP400FEXQ0, SiFiveP400FloatDiv]> { 196 let Latency = 19; 197 let ReleaseAtCycles = [1, 18]; 198} 199def : WriteRes<WriteFSqrt32, [SiFiveP400FEXQ0, SiFiveP400FloatDiv]> { 200 let Latency = 18; 201 let ReleaseAtCycles = [1, 17]; 202} 203 204// Double precision 205def : WriteRes<WriteFDiv64, [SiFiveP400FEXQ0, SiFiveP400FloatDiv]> { 206 let Latency = 33; 207 let ReleaseAtCycles = [1, 32]; 208} 209def : WriteRes<WriteFSqrt64, [SiFiveP400FEXQ0, SiFiveP400FloatDiv]> { 210 let Latency = 33; 211 let ReleaseAtCycles = [1, 32]; 212} 213 214// Conversions 215let Latency = 2 in { 216def : WriteRes<WriteFCvtI32ToF16, [SiFiveP400I2F]>; 217def : WriteRes<WriteFCvtI32ToF32, [SiFiveP400I2F]>; 218def : WriteRes<WriteFCvtI32ToF64, [SiFiveP400I2F]>; 219def : WriteRes<WriteFCvtI64ToF16, [SiFiveP400I2F]>; 220def : WriteRes<WriteFCvtI64ToF32, [SiFiveP400I2F]>; 221def : WriteRes<WriteFCvtI64ToF64, [SiFiveP400I2F]>; 222def : WriteRes<WriteFCvtF16ToI32, [SiFiveP400F2I]>; 223def : WriteRes<WriteFCvtF16ToI64, [SiFiveP400F2I]>; 224def : WriteRes<WriteFCvtF16ToF32, [SiFiveP400FloatArith]>; 225def : WriteRes<WriteFCvtF16ToF64, [SiFiveP400FloatArith]>; 226def : WriteRes<WriteFCvtF32ToI32, [SiFiveP400F2I]>; 227def : WriteRes<WriteFCvtF32ToI64, [SiFiveP400F2I]>; 228def : WriteRes<WriteFCvtF32ToF16, [SiFiveP400FloatArith]>; 229def : WriteRes<WriteFCvtF32ToF64, [SiFiveP400FloatArith]>; 230def : WriteRes<WriteFCvtF64ToI32, [SiFiveP400F2I]>; 231def : WriteRes<WriteFCvtF64ToI64, [SiFiveP400F2I]>; 232def : WriteRes<WriteFCvtF64ToF16, [SiFiveP400FloatArith]>; 233def : WriteRes<WriteFCvtF64ToF32, [SiFiveP400FloatArith]>; 234 235def : WriteRes<WriteFClass16, [SiFiveP400F2I]>; 236def : WriteRes<WriteFClass32, [SiFiveP400F2I]>; 237def : WriteRes<WriteFClass64, [SiFiveP400F2I]>; 238def : WriteRes<WriteFCmp16, [SiFiveP400F2I]>; 239def : WriteRes<WriteFCmp32, [SiFiveP400F2I]>; 240def : WriteRes<WriteFCmp64, [SiFiveP400F2I]>; 241def : WriteRes<WriteFMovI16ToF16, [SiFiveP400I2F]>; 242def : WriteRes<WriteFMovF16ToI16, [SiFiveP400F2I]>; 243def : WriteRes<WriteFMovI32ToF32, [SiFiveP400I2F]>; 244def : WriteRes<WriteFMovF32ToI32, [SiFiveP400F2I]>; 245def : WriteRes<WriteFMovI64ToF64, [SiFiveP400I2F]>; 246def : WriteRes<WriteFMovF64ToI64, [SiFiveP400F2I]>; 247} 248 249// Others 250def : WriteRes<WriteCSR, [SiFiveP400SYS]>; 251def : WriteRes<WriteNop, []>; 252 253// FIXME: This could be better modeled by looking at the regclasses of the operands. 254def : InstRW<[WriteIALU, ReadIALU], (instrs COPY)>; 255 256//===----------------------------------------------------------------------===// 257// Bypass and advance 258def : ReadAdvance<ReadJmp, 0>; 259def : ReadAdvance<ReadJalr, 0>; 260def : ReadAdvance<ReadCSR, 0>; 261def : ReadAdvance<ReadStoreData, 0>; 262def : ReadAdvance<ReadMemBase, 0>; 263def : ReadAdvance<ReadIALU, 0>; 264def : ReadAdvance<ReadIALU32, 0>; 265def : ReadAdvance<ReadShiftImm, 0>; 266def : ReadAdvance<ReadShiftImm32, 0>; 267def : ReadAdvance<ReadShiftReg, 0>; 268def : ReadAdvance<ReadShiftReg32, 0>; 269def : ReadAdvance<ReadIDiv, 0>; 270def : ReadAdvance<ReadIDiv32, 0>; 271def : ReadAdvance<ReadIRem, 0>; 272def : ReadAdvance<ReadIRem32, 0>; 273def : ReadAdvance<ReadIMul, 0>; 274def : ReadAdvance<ReadIMul32, 0>; 275def : ReadAdvance<ReadAtomicWA, 0>; 276def : ReadAdvance<ReadAtomicWD, 0>; 277def : ReadAdvance<ReadAtomicDA, 0>; 278def : ReadAdvance<ReadAtomicDD, 0>; 279def : ReadAdvance<ReadAtomicLDW, 0>; 280def : ReadAdvance<ReadAtomicLDD, 0>; 281def : ReadAdvance<ReadAtomicSTW, 0>; 282def : ReadAdvance<ReadAtomicSTD, 0>; 283def : ReadAdvance<ReadFStoreData, 0>; 284def : ReadAdvance<ReadFMemBase, 0>; 285def : ReadAdvance<ReadFAdd16, 0>; 286def : ReadAdvance<ReadFAdd32, 0>; 287def : ReadAdvance<ReadFAdd64, 0>; 288def : ReadAdvance<ReadFMul16, 0>; 289def : ReadAdvance<ReadFMA16, 0>; 290def : ReadAdvance<ReadFMA16Addend, 0>; 291def : ReadAdvance<ReadFMul32, 0>; 292def : ReadAdvance<ReadFMA32, 0>; 293def : ReadAdvance<ReadFMA32Addend, 0>; 294def : ReadAdvance<ReadFMul64, 0>; 295def : ReadAdvance<ReadFMA64, 0>; 296def : ReadAdvance<ReadFMA64Addend, 0>; 297def : ReadAdvance<ReadFDiv16, 0>; 298def : ReadAdvance<ReadFDiv32, 0>; 299def : ReadAdvance<ReadFDiv64, 0>; 300def : ReadAdvance<ReadFSqrt16, 0>; 301def : ReadAdvance<ReadFSqrt32, 0>; 302def : ReadAdvance<ReadFSqrt64, 0>; 303def : ReadAdvance<ReadFCmp16, 0>; 304def : ReadAdvance<ReadFCmp32, 0>; 305def : ReadAdvance<ReadFCmp64, 0>; 306def : ReadAdvance<ReadFSGNJ16, 0>; 307def : ReadAdvance<ReadFSGNJ32, 0>; 308def : ReadAdvance<ReadFSGNJ64, 0>; 309def : ReadAdvance<ReadFMinMax16, 0>; 310def : ReadAdvance<ReadFMinMax32, 0>; 311def : ReadAdvance<ReadFMinMax64, 0>; 312def : ReadAdvance<ReadFCvtF16ToI32, 0>; 313def : ReadAdvance<ReadFCvtF16ToI64, 0>; 314def : ReadAdvance<ReadFCvtF32ToI32, 0>; 315def : ReadAdvance<ReadFCvtF32ToI64, 0>; 316def : ReadAdvance<ReadFCvtF64ToI32, 0>; 317def : ReadAdvance<ReadFCvtF64ToI64, 0>; 318def : ReadAdvance<ReadFCvtI32ToF16, 0>; 319def : ReadAdvance<ReadFCvtI32ToF32, 0>; 320def : ReadAdvance<ReadFCvtI32ToF64, 0>; 321def : ReadAdvance<ReadFCvtI64ToF16, 0>; 322def : ReadAdvance<ReadFCvtI64ToF32, 0>; 323def : ReadAdvance<ReadFCvtI64ToF64, 0>; 324def : ReadAdvance<ReadFCvtF32ToF64, 0>; 325def : ReadAdvance<ReadFCvtF64ToF32, 0>; 326def : ReadAdvance<ReadFCvtF16ToF32, 0>; 327def : ReadAdvance<ReadFCvtF32ToF16, 0>; 328def : ReadAdvance<ReadFCvtF16ToF64, 0>; 329def : ReadAdvance<ReadFCvtF64ToF16, 0>; 330def : ReadAdvance<ReadFMovF16ToI16, 0>; 331def : ReadAdvance<ReadFMovI16ToF16, 0>; 332def : ReadAdvance<ReadFMovF32ToI32, 0>; 333def : ReadAdvance<ReadFMovI32ToF32, 0>; 334def : ReadAdvance<ReadFMovF64ToI64, 0>; 335def : ReadAdvance<ReadFMovI64ToF64, 0>; 336def : ReadAdvance<ReadFClass16, 0>; 337def : ReadAdvance<ReadFClass32, 0>; 338def : ReadAdvance<ReadFClass64, 0>; 339 340// Bitmanip 341def : ReadAdvance<ReadRotateImm, 0>; 342def : ReadAdvance<ReadRotateImm32, 0>; 343def : ReadAdvance<ReadRotateReg, 0>; 344def : ReadAdvance<ReadRotateReg32, 0>; 345def : ReadAdvance<ReadCLZ, 0>; 346def : ReadAdvance<ReadCLZ32, 0>; 347def : ReadAdvance<ReadCTZ, 0>; 348def : ReadAdvance<ReadCTZ32, 0>; 349def : ReadAdvance<ReadCPOP, 0>; 350def : ReadAdvance<ReadCPOP32, 0>; 351def : ReadAdvance<ReadORCB, 0>; 352def : ReadAdvance<ReadIMinMax, 0>; 353def : ReadAdvance<ReadREV8, 0>; 354def : ReadAdvance<ReadSHXADD, 0>; 355def : ReadAdvance<ReadSHXADD32, 0>; 356def : ReadAdvance<ReadSingleBit, 0>; 357def : ReadAdvance<ReadSingleBitImm, 0>; 358 359//===----------------------------------------------------------------------===// 360// Unsupported extensions 361defm : UnsupportedSchedZabha; 362defm : UnsupportedSchedZbc; 363defm : UnsupportedSchedZbkb; 364defm : UnsupportedSchedZbkx; 365defm : UnsupportedSchedSFB; 366defm : UnsupportedSchedZfa; 367defm : UnsupportedSchedV; 368defm : UnsupportedSchedXsfvcp; 369defm : UnsupportedSchedZvk; 370} 371