File: RISCVSchedSyntacoreSCR345.td

package info (click to toggle)
llvm-toolchain-20 1%3A20.1.8-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 2,111,388 kB
  • sloc: cpp: 7,438,767; ansic: 1,393,871; asm: 1,012,926; python: 241,728; f90: 86,635; objc: 75,411; lisp: 42,144; pascal: 17,286; sh: 10,027; ml: 5,082; perl: 4,730; awk: 3,523; makefile: 3,349; javascript: 2,251; xml: 892; fortran: 672
file content (450 lines) | stat: -rw-r--r-- 14,372 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
//==- RISCVSchedSyntacoreSCR345.td - SCR3/4/5 Sched Defs -----*- tablegen -*-=//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

//===----------------------------------------------------------------------===//

// This file covers scheduling models for Syntacore SCR3, SCR4 and SCR5
// processors.
// Configurations:
// * SCR3 rv32imc and rv64imac, overview https://syntacore.com/products/scr3
// * SCR4 rv32imfdc and rv64imafdc, overview https://syntacore.com/products/scr4
// * SCR5 rv32imafdc and rv64imafdc, overview
//   https://syntacore.com/products/scr5

// SCR3-5 are single-issue in-order processors
class SyntacoreSchedModel : SchedMachineModel {
  let MicroOpBufferSize = 0;
  let IssueWidth = 1;
  let MispredictPenalty = 3;
  let CompleteModel = 0;
  let UnsupportedFeatures = [HasStdExtZbkb, HasStdExtZbkc, HasStdExtZbkx,
                             HasStdExtZknd, HasStdExtZkne, HasStdExtZknh,
                             HasStdExtZksed, HasStdExtZksh, HasStdExtZkr,
                             HasVInstructions];
}

// Branching
multiclass SCR_Branching<ProcResourceKind BRU> {
  def : WriteRes<WriteJmp, [BRU]>;
  def : WriteRes<WriteJal, [BRU]>;
  def : WriteRes<WriteJalr, [BRU]>;
}

// Single-cycle integer arithmetic and logic
multiclass SCR_IntALU<ProcResourceKind ALU> {
  def : WriteRes<WriteIALU, [ALU]>;
  def : WriteRes<WriteIALU32, [ALU]>;
  def : WriteRes<WriteShiftImm, [ALU]>;
  def : WriteRes<WriteShiftImm32, [ALU]>;
  def : WriteRes<WriteShiftReg, [ALU]>;
  def : WriteRes<WriteShiftReg32, [ALU]>;
}

// Integer multiplication
multiclass SCR_IntMul<ProcResourceKind MUL> {
  let Latency = 2 in {
    def : WriteRes<WriteIMul, [MUL]>;
    def : WriteRes<WriteIMul32, [MUL]>;
  }
}

// Integer division
multiclass SCR_IntDiv<ProcResourceKind DIV, int DivLatency> {
  let Latency = DivLatency, ReleaseAtCycles = [DivLatency] in {
    def : WriteRes<WriteIDiv, [DIV]>;
    def : WriteRes<WriteIDiv32, [DIV]>;
    def : WriteRes<WriteIRem, [DIV]>;
    def : WriteRes<WriteIRem32, [DIV]>;
  }
}

// Load/store instructions
multiclass SCR_BasicMemory<ProcResourceKind LSU, int LoadStoreLatency> {
  let Latency = LoadStoreLatency in {
    def : WriteRes<WriteSTB, [LSU]>;
    def : WriteRes<WriteSTH, [LSU]>;
    def : WriteRes<WriteSTW, [LSU]>;
    def : WriteRes<WriteSTD, [LSU]>;
    def : WriteRes<WriteLDB, [LSU]>;
    def : WriteRes<WriteLDH, [LSU]>;
    def : WriteRes<WriteLDW, [LSU]>;
    def : WriteRes<WriteLDD, [LSU]>;
  }
}

// Floating-point load/store instructions
multiclass SCR_FPMemory<ProcResourceKind LSU, int FPLoadStoreLatency> {
  let Latency = FPLoadStoreLatency in {
    def : WriteRes<WriteFST32, [LSU]>;
    def : WriteRes<WriteFST64, [LSU]>;
    def : WriteRes<WriteFLD32, [LSU]>;
    def : WriteRes<WriteFLD64, [LSU]>;
  }
}

// Atomic memory
multiclass SCR_AtomicMemory<ProcResourceKind LSU> {
  let Latency = 20 in {
    def : WriteRes<WriteAtomicLDW, [LSU]>;
    def : WriteRes<WriteAtomicLDD, [LSU]>;
    def : WriteRes<WriteAtomicW, [LSU]>;
    def : WriteRes<WriteAtomicD, [LSU]>;
    def : WriteRes<WriteAtomicSTW, [LSU]>;
    def : WriteRes<WriteAtomicSTD, [LSU]>;
  }
}

// Floating-point unit (without division and SQRT)
multiclass SCR_FPU<ProcResourceKind FPU> {
  // Single and double-precision computational instructions
  def : WriteRes<WriteFAdd32, [FPU]> { let Latency = 3; }
  def : WriteRes<WriteFAdd64, [FPU]> { let Latency = 3; }
  def : WriteRes<WriteFMul32, [FPU]> { let Latency = 4; }
  def : WriteRes<WriteFMul64, [FPU]> { let Latency = 4; }
  def : WriteRes<WriteFMA32, [FPU]> { let Latency = 4; }
  def : WriteRes<WriteFMA64, [FPU]> { let Latency = 4; }
  def : WriteRes<WriteFSGNJ32, [FPU]> { let Latency = 2; }
  def : WriteRes<WriteFSGNJ64, [FPU]> { let Latency = 2; }
  def : WriteRes<WriteFMinMax32, [FPU]> { let Latency = 2; }
  def : WriteRes<WriteFMinMax64, [FPU]> { let Latency = 2; }

  // Conversion and move instructions
  let Latency = 3 in {
    def : WriteRes<WriteFCvtI32ToF32, [FPU]>;
    def : WriteRes<WriteFCvtI32ToF64, [FPU]>;
    def : WriteRes<WriteFCvtI64ToF32, [FPU]>;
    def : WriteRes<WriteFCvtI64ToF64, [FPU]>;
    def : WriteRes<WriteFCvtF32ToF64, [FPU]>;
    def : WriteRes<WriteFCvtF64ToF32, [FPU]>;
  }

  let Latency = 2 in {
    def : WriteRes<WriteFCvtF32ToI32, [FPU]>;
    def : WriteRes<WriteFCvtF64ToI32, [FPU]>;
    def : WriteRes<WriteFCvtF32ToI64, [FPU]>;
    def : WriteRes<WriteFCvtF64ToI64, [FPU]>;
  }

  let Latency = 2 in {
    def : WriteRes<WriteFMovI32ToF32, [FPU]>;
    def : WriteRes<WriteFMovF32ToI32, [FPU]>;
    def : WriteRes<WriteFMovI64ToF64, [FPU]>;
    def : WriteRes<WriteFMovF64ToI64, [FPU]>;
  }

  let Latency = 2 in {
    def : WriteRes<WriteFClass32, [FPU]>;
    def : WriteRes<WriteFClass64, [FPU]>;
  }

  // Comparisons
  let Latency = 2 in {
    def : WriteRes<WriteFCmp32, [FPU]>;
    def : WriteRes<WriteFCmp64, [FPU]>;
  }
}

// FP division and SQRT is not pipelined
multiclass SCR_FDU<ProcResourceKind FDU> {
  def : WriteRes<WriteFDiv32, [FDU]> {
    let Latency = 10;
    let ReleaseAtCycles = [8];
  }
  def : WriteRes<WriteFDiv64, [FDU]> {
    let Latency = 17;
    let ReleaseAtCycles = [15];
  }

  def : WriteRes<WriteFSqrt32, [FDU]> {
    let Latency = 19;
    let ReleaseAtCycles = [19];
  }
  def : WriteRes<WriteFSqrt64, [FDU]> {
    let Latency = 33;
    let ReleaseAtCycles = [33];
  }
}

// Others
multiclass SCR_Other {
  def : WriteRes<WriteCSR, []>;
  def : WriteRes<WriteNop, []>;

  def : InstRW<[WriteIALU], (instrs COPY)>;
}

// Unsupported scheduling classes for SCR3-5.
multiclass SCR_Unsupported :
  UnsupportedSchedSFB,
  UnsupportedSchedV,
  UnsupportedSchedXsfvcp,
  UnsupportedSchedZabha,
  UnsupportedSchedZba,
  UnsupportedSchedZbb,
  UnsupportedSchedZbc,
  UnsupportedSchedZbs,
  UnsupportedSchedZbkb,
  UnsupportedSchedZbkx,
  UnsupportedSchedZfa,
  UnsupportedSchedZvk;

multiclass SCR3_Unsupported :
  SCR_Unsupported,
  UnsupportedSchedF;

multiclass SCR4_SCR5_Unsupported :
  SCR_Unsupported,
  UnsupportedSchedZfhmin;

// Bypasses (none)
multiclass SCR_NoReadAdvances {
  def : ReadAdvance<ReadJmp, 0>;
  def : ReadAdvance<ReadJalr, 0>;
  def : ReadAdvance<ReadCSR, 0>;
  def : ReadAdvance<ReadStoreData, 0>;
  def : ReadAdvance<ReadMemBase, 0>;
  def : ReadAdvance<ReadIALU, 0>;
  def : ReadAdvance<ReadIALU32, 0>;
  def : ReadAdvance<ReadShiftImm, 0>;
  def : ReadAdvance<ReadShiftImm32, 0>;
  def : ReadAdvance<ReadShiftReg, 0>;
  def : ReadAdvance<ReadShiftReg32, 0>;
  def : ReadAdvance<ReadIDiv, 0>;
  def : ReadAdvance<ReadIDiv32, 0>;
  def : ReadAdvance<ReadIRem, 0>;
  def : ReadAdvance<ReadIRem32, 0>;
  def : ReadAdvance<ReadIMul, 0>;
  def : ReadAdvance<ReadIMul32, 0>;
  def : ReadAdvance<ReadAtomicWA, 0>;
  def : ReadAdvance<ReadAtomicWD, 0>;
  def : ReadAdvance<ReadAtomicDA, 0>;
  def : ReadAdvance<ReadAtomicDD, 0>;
  def : ReadAdvance<ReadAtomicLDW, 0>;
  def : ReadAdvance<ReadAtomicLDD, 0>;
  def : ReadAdvance<ReadAtomicSTW, 0>;
  def : ReadAdvance<ReadAtomicSTD, 0>;
}

// Floating-point bypasses (none)
multiclass SCR4_SCR5_NoReadAdvances : SCR_NoReadAdvances {
  def : ReadAdvance<ReadFStoreData, 0>;
  def : ReadAdvance<ReadFMemBase, 0>;
  def : ReadAdvance<ReadFAdd32, 0>;
  def : ReadAdvance<ReadFAdd64, 0>;
  def : ReadAdvance<ReadFMul32, 0>;
  def : ReadAdvance<ReadFMul64, 0>;
  def : ReadAdvance<ReadFMA32, 0>;
  def : ReadAdvance<ReadFMA32Addend, 0>;
  def : ReadAdvance<ReadFMA64, 0>;
  def : ReadAdvance<ReadFMA64Addend, 0>;
  def : ReadAdvance<ReadFDiv32, 0>;
  def : ReadAdvance<ReadFDiv64, 0>;
  def : ReadAdvance<ReadFSqrt32, 0>;
  def : ReadAdvance<ReadFSqrt64, 0>;
  def : ReadAdvance<ReadFCmp32, 0>;
  def : ReadAdvance<ReadFCmp64, 0>;
  def : ReadAdvance<ReadFSGNJ32, 0>;
  def : ReadAdvance<ReadFSGNJ64, 0>;
  def : ReadAdvance<ReadFMinMax32, 0>;
  def : ReadAdvance<ReadFMinMax64, 0>;
  def : ReadAdvance<ReadFCvtF32ToI32, 0>;
  def : ReadAdvance<ReadFCvtF32ToI64, 0>;
  def : ReadAdvance<ReadFCvtF64ToI32, 0>;
  def : ReadAdvance<ReadFCvtF64ToI64, 0>;
  def : ReadAdvance<ReadFCvtI32ToF32, 0>;
  def : ReadAdvance<ReadFCvtI32ToF64, 0>;
  def : ReadAdvance<ReadFCvtI64ToF32, 0>;
  def : ReadAdvance<ReadFCvtI64ToF64, 0>;
  def : ReadAdvance<ReadFCvtF32ToF64, 0>;
  def : ReadAdvance<ReadFCvtF64ToF32, 0>;
  def : ReadAdvance<ReadFMovF32ToI32, 0>;
  def : ReadAdvance<ReadFMovI32ToF32, 0>;
  def : ReadAdvance<ReadFMovF64ToI64, 0>;
  def : ReadAdvance<ReadFMovI64ToF64, 0>;
  def : ReadAdvance<ReadFClass32, 0>;
  def : ReadAdvance<ReadFClass64, 0>;
}

//===----------------------------------------------------------------------===//
// SCR3 scheduling model definition

def SyntacoreSCR3RV32Model : SyntacoreSchedModel {
  let LoadLatency = 2;
}

let SchedModel = SyntacoreSCR3RV32Model in {
  let BufferSize = 0 in {
    def SCR3RV32_ALU : ProcResource<1>;
    def SCR3RV32_MUL : ProcResource<1>;
    def SCR3RV32_DIV : ProcResource<1>;
    def SCR3RV32_LSU : ProcResource<1>;
    def SCR3RV32_CFU : ProcResource<1>;
  }

  defm : SCR_Branching<SCR3RV32_CFU>;
  defm : SCR_IntALU<SCR3RV32_ALU>;
  defm : SCR_IntMul<SCR3RV32_MUL>;
  defm : SCR_IntDiv<SCR3RV32_DIV, /* div latency = */ 8>;
  defm : SCR_BasicMemory<SCR3RV32_LSU, /* load & store latency = */ 2>;
  defm : SCR_AtomicMemory<SCR3RV32_LSU>;
  defm : SCR_Other;

  defm : SCR3_Unsupported;
  defm : SCR_NoReadAdvances;
}

def SyntacoreSCR3RV64Model : SyntacoreSchedModel {
  let LoadLatency = 2;
}

let SchedModel = SyntacoreSCR3RV64Model in {
  let BufferSize = 0 in {
    def SCR3RV64_ALU : ProcResource<1>;
    def SCR3RV64_MUL : ProcResource<1>;
    def SCR3RV64_DIV : ProcResource<1>;
    def SCR3RV64_LSU : ProcResource<1>;
    def SCR3RV64_CFU : ProcResource<1>;
  }

  defm : SCR_Branching<SCR3RV64_CFU>;
  defm : SCR_IntALU<SCR3RV64_ALU>;
  defm : SCR_IntMul<SCR3RV64_MUL>;
  defm : SCR_IntDiv<SCR3RV64_DIV, /* div latency = */ 11>;
  defm : SCR_BasicMemory<SCR3RV64_LSU, /* load & store latency = */ 2>;
  defm : SCR_AtomicMemory<SCR3RV64_LSU>;
  defm : SCR_Other;

  defm : SCR3_Unsupported;
  defm : SCR_NoReadAdvances;
}

//===----------------------------------------------------------------------===//
// SCR4 scheduling model definition

def SyntacoreSCR4RV32Model : SyntacoreSchedModel {
  let LoadLatency = 2;
}

let SchedModel = SyntacoreSCR4RV32Model in {
  let BufferSize = 0 in {
    def SCR4RV32_ALU : ProcResource<1>;
    def SCR4RV32_MUL : ProcResource<1>;
    def SCR4RV32_DIV : ProcResource<1>;
    def SCR4RV32_LSU : ProcResource<1>;
    def SCR4RV32_CFU : ProcResource<1>;
    def SCR4RV32_FPU : ProcResource<1>;
    def SCR4RV32_FDU : ProcResource<1>; // FP div and sqrt resource
  }

  defm : SCR_Branching<SCR4RV32_CFU>;
  defm : SCR_IntALU<SCR4RV32_ALU>;
  defm : SCR_IntMul<SCR4RV32_MUL>;
  defm : SCR_IntDiv<SCR4RV32_DIV, /* div latency = */ 8>;
  defm : SCR_BasicMemory<SCR4RV32_LSU, /* load & store latency = */ 2>;
  defm : SCR_FPMemory<SCR4RV32_LSU, /* load & store latency = */ 2>;
  defm : SCR_AtomicMemory<SCR4RV32_LSU>;
  defm : SCR_FPU<SCR4RV32_FPU>;
  defm : SCR_FDU<SCR4RV32_FDU>;
  defm : SCR_Other;

  defm : SCR4_SCR5_Unsupported;
  defm : SCR4_SCR5_NoReadAdvances;
}

def SyntacoreSCR4RV64Model : SyntacoreSchedModel {
  let LoadLatency = 2;
}

let SchedModel = SyntacoreSCR4RV64Model in {
  let BufferSize = 0 in {
    def SCR4RV64_ALU : ProcResource<1>;
    def SCR4RV64_MUL : ProcResource<1>;
    def SCR4RV64_DIV : ProcResource<1>;
    def SCR4RV64_LSU : ProcResource<1>;
    def SCR4RV64_CFU : ProcResource<1>;
    def SCR4RV64_FPU : ProcResource<1>;
    def SCR4RV64_FDU : ProcResource<1>; // FP div and sqrt resource
  }

  defm : SCR_Branching<SCR4RV64_CFU>;
  defm : SCR_IntALU<SCR4RV64_ALU>;
  defm : SCR_IntMul<SCR4RV64_MUL>;
  defm : SCR_IntDiv<SCR4RV64_DIV, /* div latency = */ 11>;
  defm : SCR_BasicMemory<SCR4RV64_LSU, /* load & store latency = */ 2>;
  defm : SCR_FPMemory<SCR4RV64_LSU, /* load & store latency = */ 2>;
  defm : SCR_AtomicMemory<SCR4RV64_LSU>;
  defm : SCR_FPU<SCR4RV64_FPU>;
  defm : SCR_FDU<SCR4RV64_FDU>;
  defm : SCR_Other;

  defm : SCR4_SCR5_Unsupported;
  defm : SCR4_SCR5_NoReadAdvances;
}

//===----------------------------------------------------------------------===//
// SCR5 scheduling model definition

def SyntacoreSCR5RV32Model : SyntacoreSchedModel {
  let LoadLatency = 3;
}

let SchedModel = SyntacoreSCR5RV32Model in {
  let BufferSize = 0 in {
    def SCR5RV32_ALU : ProcResource<1>;
    def SCR5RV32_MUL : ProcResource<1>;
    def SCR5RV32_DIV : ProcResource<1>;
    def SCR5RV32_LSU : ProcResource<1>;
    def SCR5RV32_CFU : ProcResource<1>;
    def SCR5RV32_FPU : ProcResource<1>;
    def SCR5RV32_FDU : ProcResource<1>; // FP div and sqrt resource
  }

  defm : SCR_Branching<SCR5RV32_CFU>;
  defm : SCR_IntALU<SCR5RV32_ALU>;
  defm : SCR_IntMul<SCR5RV32_MUL>;
  defm : SCR_IntDiv<SCR5RV32_DIV, /* div latency = */ 8>;
  defm : SCR_BasicMemory<SCR5RV32_LSU, /* load & store latency = */ 3>;
  defm : SCR_FPMemory<SCR5RV32_LSU, /* load & store latency = */ 3>;
  defm : SCR_AtomicMemory<SCR5RV32_LSU>;
  defm : SCR_FPU<SCR5RV32_FPU>;
  defm : SCR_FDU<SCR5RV32_FDU>;
  defm : SCR_Other;

  defm : SCR4_SCR5_Unsupported;
  defm : SCR4_SCR5_NoReadAdvances;
}

def SyntacoreSCR5RV64Model : SyntacoreSchedModel {
  let LoadLatency = 3;
}

let SchedModel = SyntacoreSCR5RV64Model in {
  let BufferSize = 0 in {
    def SCR5RV64_ALU : ProcResource<1>;
    def SCR5RV64_MUL : ProcResource<1>;
    def SCR5RV64_DIV : ProcResource<1>;
    def SCR5RV64_LSU : ProcResource<1>;
    def SCR5RV64_CFU : ProcResource<1>;
    def SCR5RV64_FPU : ProcResource<1>;
    def SCR5RV64_FDU : ProcResource<1>; // FP div and sqrt resource
  }

  defm : SCR_Branching<SCR5RV64_CFU>;
  defm : SCR_IntALU<SCR5RV64_ALU>;
  defm : SCR_IntMul<SCR5RV64_MUL>;
  defm : SCR_IntDiv<SCR5RV64_DIV, /* div latency = */ 11>;
  defm : SCR_BasicMemory<SCR5RV64_LSU, /* load & store latency = */ 3>;
  defm : SCR_FPMemory<SCR5RV64_LSU, /* load & store latency = */ 3>;
  defm : SCR_AtomicMemory<SCR5RV64_LSU>;
  defm : SCR_FPU<SCR5RV64_FPU>;
  defm : SCR_FDU<SCR5RV64_FDU>;
  defm : SCR_Other;

  defm : SCR4_SCR5_Unsupported;
  defm : SCR4_SCR5_NoReadAdvances;
}