1//==- RISCVSchedSiFive7.td - SiFive7 Scheduling Definitions --*- 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 11// SiFive7 machine model for scheduling and other instruction cost heuristics. 12def SiFive7Model : SchedMachineModel { 13 let MicroOpBufferSize = 0; // Explicitly set to zero since SiFive7 is in-order. 14 let IssueWidth = 2; // 2 micro-ops are dispatched per cycle. 15 let LoadLatency = 3; 16 let MispredictPenalty = 3; 17 let CompleteModel = 0; 18 let UnsupportedFeatures = [HasStdExtZbkb, HasStdExtZbkc, HasStdExtZbkx, 19 HasStdExtZknd, HasStdExtZkne, HasStdExtZknh, 20 HasStdExtZksed, HasStdExtZksh, HasStdExtZkr, 21 HasVInstructions]; 22} 23 24// The SiFive7 microarchitecture has two pipelines: A and B. 25// Pipe A can handle memory, integer alu and vector operations. 26// Pipe B can handle integer alu, control flow, integer multiply and divide, 27// and floating point computation. 28let SchedModel = SiFive7Model in { 29let BufferSize = 0 in { 30def SiFive7PipeA : ProcResource<1>; 31def SiFive7PipeB : ProcResource<1>; 32} 33 34let BufferSize = 1 in { 35def SiFive7IDiv : ProcResource<1> { let Super = SiFive7PipeB; } // Int Division 36def SiFive7FDiv : ProcResource<1> { let Super = SiFive7PipeB; } // FP Division/Sqrt 37} 38 39def SiFive7PipeAB : ProcResGroup<[SiFive7PipeA, SiFive7PipeB]>; 40 41// Branching 42def : WriteRes<WriteJmp, [SiFive7PipeB]>; 43def : WriteRes<WriteJal, [SiFive7PipeB]>; 44def : WriteRes<WriteJalr, [SiFive7PipeB]>; 45def : WriteRes<WriteJmpReg, [SiFive7PipeB]>; 46 47//Short forward branch 48def : WriteRes<WriteSFB, [SiFive7PipeA, SiFive7PipeB]> { 49 let Latency = 3; 50 let NumMicroOps = 2; 51} 52 53// Integer arithmetic and logic 54let Latency = 3 in { 55def : WriteRes<WriteIALU, [SiFive7PipeAB]>; 56def : WriteRes<WriteIALU32, [SiFive7PipeAB]>; 57def : WriteRes<WriteShiftImm, [SiFive7PipeAB]>; 58def : WriteRes<WriteShiftImm32, [SiFive7PipeAB]>; 59def : WriteRes<WriteShiftReg, [SiFive7PipeAB]>; 60def : WriteRes<WriteShiftReg32, [SiFive7PipeAB]>; 61} 62 63// Integer multiplication 64let Latency = 3 in { 65def : WriteRes<WriteIMul, [SiFive7PipeB]>; 66def : WriteRes<WriteIMul32, [SiFive7PipeB]>; 67} 68 69// Integer division 70def : WriteRes<WriteIDiv, [SiFive7PipeB, SiFive7IDiv]> { 71 let Latency = 16; 72 let ResourceCycles = [1, 15]; 73} 74def : WriteRes<WriteIDiv32, [SiFive7PipeB, SiFive7IDiv]> { 75 let Latency = 16; 76 let ResourceCycles = [1, 15]; 77} 78 79// Memory 80def : WriteRes<WriteSTB, [SiFive7PipeA]>; 81def : WriteRes<WriteSTH, [SiFive7PipeA]>; 82def : WriteRes<WriteSTW, [SiFive7PipeA]>; 83def : WriteRes<WriteSTD, [SiFive7PipeA]>; 84def : WriteRes<WriteFST32, [SiFive7PipeA]>; 85def : WriteRes<WriteFST64, [SiFive7PipeA]>; 86 87let Latency = 3 in { 88def : WriteRes<WriteLDB, [SiFive7PipeA]>; 89def : WriteRes<WriteLDH, [SiFive7PipeA]>; 90def : WriteRes<WriteLDW, [SiFive7PipeA]>; 91def : WriteRes<WriteLDD, [SiFive7PipeA]>; 92} 93 94let Latency = 2 in { 95def : WriteRes<WriteFLD32, [SiFive7PipeA]>; 96def : WriteRes<WriteFLD64, [SiFive7PipeA]>; 97} 98 99// Atomic memory 100def : WriteRes<WriteAtomicSTW, [SiFive7PipeA]>; 101def : WriteRes<WriteAtomicSTD, [SiFive7PipeA]>; 102 103let Latency = 3 in { 104def : WriteRes<WriteAtomicW, [SiFive7PipeA]>; 105def : WriteRes<WriteAtomicD, [SiFive7PipeA]>; 106def : WriteRes<WriteAtomicLDW, [SiFive7PipeA]>; 107def : WriteRes<WriteAtomicLDD, [SiFive7PipeA]>; 108} 109 110// Single precision. 111let Latency = 5 in { 112def : WriteRes<WriteFAdd32, [SiFive7PipeB]>; 113def : WriteRes<WriteFMul32, [SiFive7PipeB]>; 114def : WriteRes<WriteFMA32, [SiFive7PipeB]>; 115} 116let Latency = 3 in { 117def : WriteRes<WriteFSGNJ32, [SiFive7PipeB]>; 118def : WriteRes<WriteFMinMax32, [SiFive7PipeB]>; 119} 120 121def : WriteRes<WriteFDiv32, [SiFive7PipeB, SiFive7FDiv]> { let Latency = 27; 122 let ResourceCycles = [1, 26]; } 123def : WriteRes<WriteFSqrt32, [SiFive7PipeB, SiFive7FDiv]> { let Latency = 27; 124 let ResourceCycles = [1, 26]; } 125 126// Double precision 127let Latency = 7 in { 128def : WriteRes<WriteFAdd64, [SiFive7PipeB]>; 129def : WriteRes<WriteFMul64, [SiFive7PipeB]>; 130def : WriteRes<WriteFMA64, [SiFive7PipeB]>; 131} 132let Latency = 3 in { 133def : WriteRes<WriteFSGNJ64, [SiFive7PipeB]>; 134def : WriteRes<WriteFMinMax64, [SiFive7PipeB]>; 135} 136 137def : WriteRes<WriteFDiv64, [SiFive7PipeB, SiFive7FDiv]> { let Latency = 56; 138 let ResourceCycles = [1, 55]; } 139def : WriteRes<WriteFSqrt64, [SiFive7PipeB, SiFive7FDiv]> { let Latency = 56; 140 let ResourceCycles = [1, 55]; } 141 142// Conversions 143let Latency = 3 in { 144def : WriteRes<WriteFCvtI32ToF32, [SiFive7PipeB]>; 145def : WriteRes<WriteFCvtI32ToF64, [SiFive7PipeB]>; 146def : WriteRes<WriteFCvtI64ToF32, [SiFive7PipeB]>; 147def : WriteRes<WriteFCvtI64ToF64, [SiFive7PipeB]>; 148def : WriteRes<WriteFCvtF32ToI32, [SiFive7PipeB]>; 149def : WriteRes<WriteFCvtF32ToI64, [SiFive7PipeB]>; 150def : WriteRes<WriteFCvtF32ToF64, [SiFive7PipeB]>; 151def : WriteRes<WriteFCvtF64ToI32, [SiFive7PipeB]>; 152def : WriteRes<WriteFCvtF64ToI64, [SiFive7PipeB]>; 153def : WriteRes<WriteFCvtF64ToF32, [SiFive7PipeB]>; 154 155def : WriteRes<WriteFClass32, [SiFive7PipeB]>; 156def : WriteRes<WriteFClass64, [SiFive7PipeB]>; 157def : WriteRes<WriteFCmp32, [SiFive7PipeB]>; 158def : WriteRes<WriteFCmp64, [SiFive7PipeB]>; 159def : WriteRes<WriteFMovI32ToF32, [SiFive7PipeB]>; 160def : WriteRes<WriteFMovF32ToI32, [SiFive7PipeB]>; 161def : WriteRes<WriteFMovI64ToF64, [SiFive7PipeB]>; 162def : WriteRes<WriteFMovF64ToI64, [SiFive7PipeB]>; 163} 164 165// Others 166def : WriteRes<WriteCSR, [SiFive7PipeB]>; 167def : WriteRes<WriteNop, []>; 168 169def : InstRW<[WriteIALU], (instrs COPY)>; 170 171//===----------------------------------------------------------------------===// 172// Bypass and advance 173def : ReadAdvance<ReadJmp, 0>; 174def : ReadAdvance<ReadJalr, 0>; 175def : ReadAdvance<ReadCSR, 0>; 176def : ReadAdvance<ReadStoreData, 0>; 177def : ReadAdvance<ReadMemBase, 0>; 178def : ReadAdvance<ReadIALU, 0>; 179def : ReadAdvance<ReadIALU32, 0>; 180def : ReadAdvance<ReadShiftImm, 0>; 181def : ReadAdvance<ReadShiftImm32, 0>; 182def : ReadAdvance<ReadShiftReg, 0>; 183def : ReadAdvance<ReadShiftReg32, 0>; 184def : ReadAdvance<ReadIDiv, 0>; 185def : ReadAdvance<ReadIDiv32, 0>; 186def : ReadAdvance<ReadIMul, 0>; 187def : ReadAdvance<ReadIMul32, 0>; 188def : ReadAdvance<ReadAtomicWA, 0>; 189def : ReadAdvance<ReadAtomicWD, 0>; 190def : ReadAdvance<ReadAtomicDA, 0>; 191def : ReadAdvance<ReadAtomicDD, 0>; 192def : ReadAdvance<ReadAtomicLDW, 0>; 193def : ReadAdvance<ReadAtomicLDD, 0>; 194def : ReadAdvance<ReadAtomicSTW, 0>; 195def : ReadAdvance<ReadAtomicSTD, 0>; 196def : ReadAdvance<ReadFStoreData, 0>; 197def : ReadAdvance<ReadFMemBase, 0>; 198def : ReadAdvance<ReadFAdd32, 0>; 199def : ReadAdvance<ReadFAdd64, 0>; 200def : ReadAdvance<ReadFMul32, 0>; 201def : ReadAdvance<ReadFMul64, 0>; 202def : ReadAdvance<ReadFMA32, 0>; 203def : ReadAdvance<ReadFMA64, 0>; 204def : ReadAdvance<ReadFDiv32, 0>; 205def : ReadAdvance<ReadFDiv64, 0>; 206def : ReadAdvance<ReadFSqrt32, 0>; 207def : ReadAdvance<ReadFSqrt64, 0>; 208def : ReadAdvance<ReadFCmp32, 0>; 209def : ReadAdvance<ReadFCmp64, 0>; 210def : ReadAdvance<ReadFSGNJ32, 0>; 211def : ReadAdvance<ReadFSGNJ64, 0>; 212def : ReadAdvance<ReadFMinMax32, 0>; 213def : ReadAdvance<ReadFMinMax64, 0>; 214def : ReadAdvance<ReadFCvtF32ToI32, 0>; 215def : ReadAdvance<ReadFCvtF32ToI64, 0>; 216def : ReadAdvance<ReadFCvtF64ToI32, 0>; 217def : ReadAdvance<ReadFCvtF64ToI64, 0>; 218def : ReadAdvance<ReadFCvtI32ToF32, 0>; 219def : ReadAdvance<ReadFCvtI32ToF64, 0>; 220def : ReadAdvance<ReadFCvtI64ToF32, 0>; 221def : ReadAdvance<ReadFCvtI64ToF64, 0>; 222def : ReadAdvance<ReadFCvtF32ToF64, 0>; 223def : ReadAdvance<ReadFCvtF64ToF32, 0>; 224def : ReadAdvance<ReadFMovF32ToI32, 0>; 225def : ReadAdvance<ReadFMovI32ToF32, 0>; 226def : ReadAdvance<ReadFMovF64ToI64, 0>; 227def : ReadAdvance<ReadFMovI64ToF64, 0>; 228def : ReadAdvance<ReadFClass32, 0>; 229def : ReadAdvance<ReadFClass64, 0>; 230 231def : ReadAdvance<ReadSFB, 0>; 232 233//===----------------------------------------------------------------------===// 234// Unsupported extensions 235defm : UnsupportedSchedV; 236defm : UnsupportedSchedZba; 237defm : UnsupportedSchedZbb; 238defm : UnsupportedSchedZbc; 239defm : UnsupportedSchedZbs; 240defm : UnsupportedSchedZbkb; 241defm : UnsupportedSchedZbkx; 242defm : UnsupportedSchedZfh; 243} 244