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