xref: /freebsd/contrib/llvm-project/llvm/lib/Target/RISCV/RISCVSchedule.td (revision 47ef2a131091508e049ab10cad7f91a3c1342cd9)
1//===-- RISCVSchedule.td - RISC-V 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/// Define scheduler resources associated with def operands.
10def WriteIALU       : SchedWrite;    // 32 or 64-bit integer ALU operations
11def WriteIALU32     : SchedWrite;    // 32-bit integer ALU operations on RV64I
12def WriteShiftImm   : SchedWrite;    // 32 or 64-bit shift by immediate operations
13def WriteShiftImm32 : SchedWrite;    // 32-bit shift by immediate operations on RV64Ix
14def WriteShiftReg   : SchedWrite;    // 32 or 64-bit shift by immediate operations
15def WriteShiftReg32 : SchedWrite;    // 32-bit shift by immediate operations on RV64Ix
16def WriteIDiv       : SchedWrite;    // 32-bit or 64-bit divide
17def WriteIDiv32     : SchedWrite;    // 32-bit divide on RV64I
18def WriteIRem       : SchedWrite;    // 32-bit or 64-bit remainder
19def WriteIRem32     : SchedWrite;    // 32-bit remainder on RV64I
20def WriteIMul       : SchedWrite;    // 32-bit or 64-bit multiply
21def WriteIMul32     : SchedWrite;    // 32-bit multiply on RV64I
22def WriteJmp        : SchedWrite;    // Jump
23def WriteJal        : SchedWrite;    // Jump and link
24def WriteJalr       : SchedWrite;    // Jump and link register
25def WriteNop        : SchedWrite;
26def WriteLDB        : SchedWrite;    // Load byte
27def WriteLDH        : SchedWrite;    // Load half-word
28def WriteLDW        : SchedWrite;    // Load word
29def WriteLDD        : SchedWrite;    // Load double-word
30def WriteCSR        : SchedWrite;    // CSR instructions
31def WriteSTB        : SchedWrite;    // Store byte
32def WriteSTH        : SchedWrite;    // Store half-word
33def WriteSTW        : SchedWrite;    // Store word
34def WriteSTD        : SchedWrite;    // Store double-word
35def WriteAtomicB    : SchedWrite;    //Atomic memory operation byte size
36def WriteAtomicH    : SchedWrite;    //Atomic memory operation halfword size
37def WriteAtomicW    : SchedWrite;    //Atomic memory operation word size
38def WriteAtomicD    : SchedWrite;    //Atomic memory operation double word size
39def WriteAtomicLDW  : SchedWrite;    // Atomic load word
40def WriteAtomicLDD  : SchedWrite;    // Atomic load double word
41def WriteAtomicSTW  : SchedWrite;    // Atomic store word
42def WriteAtomicSTD  : SchedWrite;    // Atomic store double word
43def WriteFAdd16     : SchedWrite;    // 16-bit floating point addition/subtraction
44def WriteFAdd32     : SchedWrite;    // 32-bit floating point addition/subtraction
45def WriteFAdd64     : SchedWrite;    // 64-bit floating point addition/subtraction
46def WriteFMul16     : SchedWrite;    // 16-bit floating point multiply
47def WriteFMul32     : SchedWrite;    // 32-bit floating point multiply
48def WriteFMul64     : SchedWrite;    // 64-bit floating point multiply
49def WriteFMA16      : SchedWrite;    // 16-bit floating point fused multiply-add
50def WriteFMA32      : SchedWrite;    // 32-bit floating point fused multiply-add
51def WriteFMA64      : SchedWrite;    // 64-bit floating point fused multiply-add
52def WriteFDiv16     : SchedWrite;    // 16-bit floating point divide
53def WriteFDiv32     : SchedWrite;    // 32-bit floating point divide
54def WriteFDiv64     : SchedWrite;    // 64-bit floating point divide
55def WriteFSqrt16    : SchedWrite;    // 16-bit floating point sqrt
56def WriteFSqrt32    : SchedWrite;    // 32-bit floating point sqrt
57def WriteFSqrt64    : SchedWrite;    // 64-bit floating point sqrt
58
59// Integer to float conversions
60def WriteFCvtI32ToF16  : SchedWrite;
61def WriteFCvtI32ToF32  : SchedWrite;
62def WriteFCvtI32ToF64  : SchedWrite;
63def WriteFCvtI64ToF16  : SchedWrite;    // RV64I only
64def WriteFCvtI64ToF32  : SchedWrite;    // RV64I only
65def WriteFCvtI64ToF64  : SchedWrite;    // RV64I only
66
67//Float to integer conversions
68def WriteFCvtF16ToI32  : SchedWrite;
69def WriteFCvtF16ToI64  : SchedWrite;    // RV64I only
70def WriteFCvtF32ToI32  : SchedWrite;
71def WriteFCvtF32ToI64  : SchedWrite;    // RV64I only
72def WriteFCvtF64ToI32  : SchedWrite;
73def WriteFCvtF64ToI64  : SchedWrite;    // RV64I only
74
75// Float to float conversions
76def WriteFCvtF32ToF64  : SchedWrite;
77def WriteFCvtF64ToF32  : SchedWrite;
78def WriteFCvtF16ToF32  : SchedWrite;
79def WriteFCvtF32ToF16  : SchedWrite;
80def WriteFCvtF16ToF64  : SchedWrite;
81def WriteFCvtF64ToF16  : SchedWrite;
82
83// Zfa found instructions.
84def WriteFRoundF32     : SchedWrite;
85def WriteFRoundF64     : SchedWrite;
86def WriteFRoundF16     : SchedWrite;
87
88def WriteFClass16   : SchedWrite;    // 16-bit floating point classify
89def WriteFClass32   : SchedWrite;    // 32-bit floating point classify
90def WriteFClass64   : SchedWrite;    // 64-bit floating point classify
91def WriteFCmp16     : SchedWrite;    // 16-bit floating point compare
92def WriteFCmp32     : SchedWrite;    // 32-bit floating point compare
93def WriteFCmp64     : SchedWrite;    // 64-bit floating point compare
94def WriteFSGNJ16    : SchedWrite;    // 16-bit floating point sign-injection
95def WriteFSGNJ32    : SchedWrite;    // 32-bit floating point sign-injection
96def WriteFSGNJ64    : SchedWrite;    // 64-bit floating point sign-injection
97def WriteFMinMax16  : SchedWrite;    // 16-bit floating point min or max
98def WriteFMinMax32  : SchedWrite;    // 32-bit floating point min or max
99def WriteFMinMax64  : SchedWrite;    // 64-bit floating point min or max
100
101def WriteFMovF16ToI16     : SchedWrite;
102def WriteFMovI16ToF16     : SchedWrite;
103def WriteFMovF32ToI32     : SchedWrite;
104def WriteFMovI32ToF32     : SchedWrite;
105def WriteFMovF64ToI64     : SchedWrite;    // RV64I only
106def WriteFMovI64ToF64     : SchedWrite;    // RV64I only
107
108def WriteFLI16        : SchedWrite;    // Floating point constant load
109def WriteFLI32        : SchedWrite;    // Floating point constant load
110def WriteFLI64        : SchedWrite;    // Floating point constant load
111
112def WriteFLD16        : SchedWrite;    // Floating point sp load
113def WriteFLD32        : SchedWrite;    // Floating point sp load
114def WriteFLD64        : SchedWrite;    // Floating point dp load
115def WriteFST16        : SchedWrite;    // Floating point sp store
116def WriteFST32        : SchedWrite;    // Floating point sp store
117def WriteFST64        : SchedWrite;    // Floating point dp store
118
119// short forward branch for Bullet
120def WriteSFB        : SchedWrite;
121def ReadSFBJmp      : SchedRead;
122def ReadSFBALU      : SchedRead;
123
124/// Define scheduler resources associated with use operands.
125def ReadJmp         : SchedRead;
126def ReadJalr        : SchedRead;
127def ReadCSR         : SchedRead;
128def ReadMemBase     : SchedRead;
129def ReadFMemBase    : SchedRead;
130def ReadStoreData   : SchedRead;
131def ReadFStoreData  : SchedRead;
132def ReadIALU        : SchedRead;
133def ReadIALU32      : SchedRead;    // 32-bit integer ALU operations on RV64I
134def ReadShiftImm    : SchedRead;
135def ReadShiftImm32  : SchedRead;    // 32-bit shift by immediate operations on RV64Ix
136def ReadShiftReg    : SchedRead;
137def ReadShiftReg32  : SchedRead;    // 32-bit shift by register operations on RV64Ix
138def ReadIDiv        : SchedRead;
139def ReadIDiv32      : SchedRead;
140def ReadIRem        : SchedRead;
141def ReadIRem32      : SchedRead;
142def ReadIMul        : SchedRead;
143def ReadIMul32      : SchedRead;
144def ReadAtomicBA    : SchedRead;
145def ReadAtomicBD    : SchedRead;
146def ReadAtomicHA    : SchedRead;
147def ReadAtomicHD    : SchedRead;
148def ReadAtomicWA    : SchedRead;
149def ReadAtomicWD    : SchedRead;
150def ReadAtomicDA    : SchedRead;
151def ReadAtomicDD    : SchedRead;
152def ReadAtomicLDW   : SchedRead;    // Atomic load word
153def ReadAtomicLDD   : SchedRead;    // Atomic load double word
154def ReadAtomicSTW   : SchedRead;    // Atomic store word
155def ReadAtomicSTD   : SchedRead;    // Atomic store double word
156def ReadFAdd16      : SchedRead;    // 16-bit floating point addition/subtraction
157def ReadFAdd32      : SchedRead;    // 32-bit floating point addition/subtraction
158def ReadFAdd64      : SchedRead;    // 64-bit floating point addition/subtraction
159def ReadFMul16      : SchedRead;    // 16-bit floating point multiply
160def ReadFMul32      : SchedRead;    // 32-bit floating point multiply
161def ReadFMul64      : SchedRead;    // 64-bit floating point multiply
162def ReadFMA16       : SchedRead;    // 16-bit floating point fused multiply-add
163def ReadFMA16Addend : SchedRead;    // 16-bit floating point fused multiply-add (addend)
164def ReadFMA32       : SchedRead;    // 32-bit floating point fused multiply-add
165def ReadFMA32Addend : SchedRead;    // 32-bit floating point fused multiply-add (addend)
166def ReadFMA64       : SchedRead;    // 64-bit floating point fused multiply-add
167def ReadFMA64Addend : SchedRead;    // 64-bit floating point fused multiply-add (addend)
168def ReadFDiv16      : SchedRead;    // 16-bit floating point divide
169def ReadFDiv32      : SchedRead;    // 32-bit floating point divide
170def ReadFDiv64      : SchedRead;    // 64-bit floating point divide
171def ReadFSqrt16     : SchedRead;    // 16-bit floating point sqrt
172def ReadFSqrt32     : SchedRead;    // 32-bit floating point sqrt
173def ReadFSqrt64     : SchedRead;    // 64-bit floating point sqrt
174def ReadFCmp16      : SchedRead;
175def ReadFCmp32      : SchedRead;
176def ReadFCmp64      : SchedRead;
177def ReadFSGNJ16     : SchedRead;
178def ReadFSGNJ32     : SchedRead;
179def ReadFSGNJ64     : SchedRead;
180def ReadFMinMax16   : SchedRead;
181def ReadFMinMax32   : SchedRead;
182def ReadFMinMax64   : SchedRead;
183def ReadFCvtF16ToI32     : SchedRead;
184def ReadFCvtF16ToI64     : SchedRead;
185def ReadFCvtF32ToI32     : SchedRead;
186def ReadFCvtF32ToI64     : SchedRead;
187def ReadFCvtF64ToI32     : SchedRead;
188def ReadFCvtF64ToI64     : SchedRead;
189def ReadFCvtI32ToF16     : SchedRead;
190def ReadFCvtI32ToF32     : SchedRead;
191def ReadFCvtI32ToF64     : SchedRead;
192def ReadFCvtI64ToF16     : SchedRead;
193def ReadFCvtI64ToF32     : SchedRead;
194def ReadFCvtI64ToF64     : SchedRead;
195def ReadFMovF16ToI16     : SchedRead;
196def ReadFMovI16ToF16     : SchedRead;
197def ReadFMovF32ToI32     : SchedRead;
198def ReadFMovI32ToF32     : SchedRead;
199def ReadFMovF64ToI64     : SchedRead;
200def ReadFMovI64ToF64     : SchedRead;
201def ReadFCvtF32ToF64     : SchedRead;
202def ReadFCvtF64ToF32     : SchedRead;
203def ReadFCvtF16ToF32     : SchedRead;
204def ReadFCvtF32ToF16     : SchedRead;
205def ReadFCvtF16ToF64     : SchedRead;
206def ReadFCvtF64ToF16     : SchedRead;
207def ReadFRoundF16        : SchedRead;
208def ReadFRoundF32        : SchedRead;
209def ReadFRoundF64        : SchedRead;
210def ReadFClass16         : SchedRead;
211def ReadFClass32         : SchedRead;
212def ReadFClass64         : SchedRead;
213
214multiclass UnsupportedSchedZfh {
215let Unsupported = true in {
216def : WriteRes<WriteFAdd16, []>;
217def : WriteRes<WriteFClass16, []>;
218def : WriteRes<WriteFCvtF16ToF64, []>;
219def : WriteRes<WriteFCvtF64ToF16, []>;
220def : WriteRes<WriteFCvtI64ToF16, []>;
221def : WriteRes<WriteFCvtF32ToF16, []>;
222def : WriteRes<WriteFCvtI32ToF16, []>;
223def : WriteRes<WriteFCvtF16ToI64, []>;
224def : WriteRes<WriteFCvtF16ToF32, []>;
225def : WriteRes<WriteFCvtF16ToI32, []>;
226def : WriteRes<WriteFDiv16, []>;
227def : WriteRes<WriteFCmp16, []>;
228def : WriteRes<WriteFLD16, []>;
229def : WriteRes<WriteFMA16, []>;
230def : WriteRes<WriteFMinMax16, []>;
231def : WriteRes<WriteFMul16, []>;
232def : WriteRes<WriteFMovI16ToF16, []>;
233def : WriteRes<WriteFMovF16ToI16, []>;
234def : WriteRes<WriteFSGNJ16, []>;
235def : WriteRes<WriteFST16, []>;
236def : WriteRes<WriteFSqrt16, []>;
237
238def : ReadAdvance<ReadFAdd16, 0>;
239def : ReadAdvance<ReadFClass16, 0>;
240def : ReadAdvance<ReadFCvtF16ToF64, 0>;
241def : ReadAdvance<ReadFCvtF64ToF16, 0>;
242def : ReadAdvance<ReadFCvtI64ToF16, 0>;
243def : ReadAdvance<ReadFCvtF32ToF16, 0>;
244def : ReadAdvance<ReadFCvtI32ToF16, 0>;
245def : ReadAdvance<ReadFCvtF16ToI64, 0>;
246def : ReadAdvance<ReadFCvtF16ToF32, 0>;
247def : ReadAdvance<ReadFCvtF16ToI32, 0>;
248def : ReadAdvance<ReadFDiv16, 0>;
249def : ReadAdvance<ReadFCmp16, 0>;
250def : ReadAdvance<ReadFMA16, 0>;
251def : ReadAdvance<ReadFMinMax16, 0>;
252def : ReadAdvance<ReadFMul16, 0>;
253def : ReadAdvance<ReadFMovI16ToF16, 0>;
254def : ReadAdvance<ReadFMovF16ToI16, 0>;
255def : ReadAdvance<ReadFSGNJ16, 0>;
256def : ReadAdvance<ReadFSqrt16, 0>;
257} // Unsupported = true
258}
259
260multiclass UnsupportedSchedF {
261let Unsupported = true in {
262def : WriteRes<WriteFST32, []>;
263def : WriteRes<WriteFLD32, []>;
264def : WriteRes<WriteFAdd32, []>;
265def : WriteRes<WriteFSGNJ32, []>;
266def : WriteRes<WriteFMinMax32, []>;
267def : WriteRes<WriteFCvtI32ToF32, []>;
268def : WriteRes<WriteFCvtI64ToF32, []>;
269def : WriteRes<WriteFCvtF32ToI32, []>;
270def : WriteRes<WriteFCvtF32ToI64, []>;
271def : WriteRes<WriteFClass32, []>;
272def : WriteRes<WriteFCmp32, []>;
273def : WriteRes<WriteFMovF32ToI32, []>;
274def : WriteRes<WriteFMovI32ToF32, []>;
275def : WriteRes<WriteFMul32, []>;
276def : WriteRes<WriteFMA32, []>;
277def : WriteRes<WriteFDiv32, []>;
278def : WriteRes<WriteFSqrt32, []>;
279
280def : ReadAdvance<ReadFAdd32, 0>;
281def : ReadAdvance<ReadFMul32, 0>;
282def : ReadAdvance<ReadFMA32, 0>;
283def : ReadAdvance<ReadFMA32Addend, 0>;
284def : ReadAdvance<ReadFDiv32, 0>;
285def : ReadAdvance<ReadFSqrt32, 0>;
286def : ReadAdvance<ReadFCmp32, 0>;
287def : ReadAdvance<ReadFSGNJ32, 0>;
288def : ReadAdvance<ReadFMinMax32, 0>;
289def : ReadAdvance<ReadFCvtF32ToI32, 0>;
290def : ReadAdvance<ReadFCvtF32ToI64, 0>;
291def : ReadAdvance<ReadFCvtI32ToF32, 0>;
292def : ReadAdvance<ReadFCvtI64ToF32, 0>;
293def : ReadAdvance<ReadFMovF32ToI32, 0>;
294def : ReadAdvance<ReadFMovI32ToF32, 0>;
295def : ReadAdvance<ReadFClass32, 0>;
296def : ReadAdvance<ReadFStoreData, 0>;
297def : ReadAdvance<ReadFMemBase, 0>;
298} // Unsupported = true
299}
300
301multiclass UnsupportedSchedD {
302let Unsupported = true in {
303def : WriteRes<WriteFST64, []>;
304def : WriteRes<WriteFLD64, []>;
305def : WriteRes<WriteFAdd64, []>;
306def : WriteRes<WriteFSGNJ64, []>;
307def : WriteRes<WriteFMinMax64, []>;
308def : WriteRes<WriteFCvtI32ToF64, []>;
309def : WriteRes<WriteFCvtI64ToF64, []>;
310def : WriteRes<WriteFCvtF64ToI32, []>;
311def : WriteRes<WriteFCvtF64ToI64, []>;
312def : WriteRes<WriteFCvtF32ToF64, []>;
313def : WriteRes<WriteFCvtF64ToF32, []>;
314def : WriteRes<WriteFClass64, []>;
315def : WriteRes<WriteFCmp64, []>;
316def : WriteRes<WriteFMovF64ToI64, []>;
317def : WriteRes<WriteFMovI64ToF64, []>;
318def : WriteRes<WriteFMul64, []>;
319def : WriteRes<WriteFMA64, []>;
320def : WriteRes<WriteFDiv64, []>;
321def : WriteRes<WriteFSqrt64, []>;
322
323def : ReadAdvance<ReadFAdd64, 0>;
324def : ReadAdvance<ReadFMul64, 0>;
325def : ReadAdvance<ReadFMA64, 0>;
326def : ReadAdvance<ReadFMA64Addend, 0>;
327def : ReadAdvance<ReadFDiv64, 0>;
328def : ReadAdvance<ReadFSqrt64, 0>;
329def : ReadAdvance<ReadFCmp64, 0>;
330def : ReadAdvance<ReadFSGNJ64, 0>;
331def : ReadAdvance<ReadFMinMax64, 0>;
332def : ReadAdvance<ReadFCvtF64ToI32, 0>;
333def : ReadAdvance<ReadFCvtF64ToI64, 0>;
334def : ReadAdvance<ReadFCvtI32ToF64, 0>;
335def : ReadAdvance<ReadFCvtI64ToF64, 0>;
336def : ReadAdvance<ReadFCvtF32ToF64, 0>;
337def : ReadAdvance<ReadFCvtF64ToF32, 0>;
338def : ReadAdvance<ReadFMovF64ToI64, 0>;
339def : ReadAdvance<ReadFMovI64ToF64, 0>;
340def : ReadAdvance<ReadFClass64, 0>;
341} // Unsupported = true
342}
343
344multiclass UnsupportedSchedSFB {
345let Unsupported = true in {
346def : WriteRes<WriteSFB, []>;
347
348def : ReadAdvance<ReadSFBJmp, 0>;
349def : ReadAdvance<ReadSFBALU, 0>;
350} // Unsupported = true
351}
352
353multiclass UnsupportedSchedZfa {
354let Unsupported = true in {
355def : WriteRes<WriteFRoundF16, []>;
356def : WriteRes<WriteFRoundF32, []>;
357def : WriteRes<WriteFRoundF64, []>;
358def : WriteRes<WriteFLI16, []>;
359def : WriteRes<WriteFLI32, []>;
360def : WriteRes<WriteFLI64, []>;
361
362def : ReadAdvance<ReadFRoundF32, 0>;
363def : ReadAdvance<ReadFRoundF64, 0>;
364def : ReadAdvance<ReadFRoundF16, 0>;
365} // Unsupported = true
366}
367
368multiclass UnsupportedSchedZabha {
369let Unsupported = true in {
370def : WriteRes<WriteAtomicB, []>;
371def : WriteRes<WriteAtomicH, []>;
372
373def : ReadAdvance<ReadAtomicBA, 0>;
374def : ReadAdvance<ReadAtomicBD, 0>;
375def : ReadAdvance<ReadAtomicHA, 0>;
376def : ReadAdvance<ReadAtomicHD, 0>;
377} // Unsupported = true
378}
379
380multiclass UnsupportedSchedA {
381let Unsupported = true in {
382def : WriteRes<WriteAtomicW, []>;
383def : WriteRes<WriteAtomicD, []>;
384def : WriteRes<WriteAtomicLDW, []>;
385def : WriteRes<WriteAtomicLDD, []>;
386def : WriteRes<WriteAtomicSTW, []>;
387def : WriteRes<WriteAtomicSTD, []>;
388
389def : ReadAdvance<ReadAtomicWA, 0>;
390def : ReadAdvance<ReadAtomicWD, 0>;
391def : ReadAdvance<ReadAtomicDA, 0>;
392def : ReadAdvance<ReadAtomicDD, 0>;
393def : ReadAdvance<ReadAtomicLDW, 0>;
394def : ReadAdvance<ReadAtomicLDD, 0>;
395def : ReadAdvance<ReadAtomicSTW, 0>;
396def : ReadAdvance<ReadAtomicSTD, 0>;
397} // Unsupported = true
398}
399
400// Include the scheduler resources for other instruction extensions.
401include "RISCVScheduleZb.td"
402include "RISCVScheduleV.td"
403include "RISCVScheduleXSf.td"
404include "RISCVScheduleZvk.td"
405