1//===-- ARMSchedule.td - ARM Scheduling Definitions --------*- tablegen -*-===//
2//
3//                     The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//===----------------------------------------------------------------------===//
10// Instruction scheduling annotations for out-of-order CPUs.
11// These annotations are independent of the itinerary class defined below.
12// Here we define the subtarget independent read/write per-operand resources.
13// The subtarget schedule definitions will then map these to the subtarget's
14// resource usages.
15// For example:
16// The instruction cycle timings table might contain an entry for an operation
17// like the following:
18// Rd <- ADD Rn, Rm, <shift> Rs
19//  Uops | Latency from register | Uops - resource requirements - latency
20//  2    | Rn: 1 Rm: 4 Rs: 4     | uop T0, Rm, Rs - P01 - 3
21//       |                       | uopc Rd, Rn, T0 -  P01 - 1
22// This is telling us that the result will be available in destination register
23// Rd after a minimum of three cycles after the result in Rm and Rs is available
24// and one cycle after the result in Rn is available. The micro-ops can execute
25// on resource P01.
26// To model this, we need to express that we need to dispatch two micro-ops,
27// that the resource P01 is needed and that the latency to Rn is different than
28// the latency to Rm and Rs. The scheduler can decrease Rn's producer latency by
29// two.
30// We will do this by assigning (abstract) resources to register defs/uses.
31// ARMSchedule.td:
32//   def WriteALUsr : SchedWrite;
33//   def ReadAdvanceALUsr : ScheRead;
34//
35// ARMInstrInfo.td:
36//   def ADDrs : I<>, Sched<[WriteALUsr, ReadAdvanceALUsr, ReadDefault,
37//                           ReadDefault]> { ...}
38// ReadAdvance read resources allow us to define "pipeline by-passes" or
39// shorter latencies to certain registers as needed in the example above.
40// The "ReadDefault" can be omitted.
41// Next, the subtarget td file assigns resources to the abstract resources
42// defined here.
43// ARMScheduleSubtarget.td:
44//  // Resources.
45//  def P01 : ProcResource<3>; // ALU unit (3 of it).
46//  ...
47//  // Resource usages.
48//  def : WriteRes<WriteALUsr, [P01, P01]> {
49//    Latency = 4; // Latency of 4.
50//    NumMicroOps = 2; // Dispatch 2 micro-ops.
51//    // The two instances of resource P01 are occupied for one cycle. It is one
52//    // cycle because these resources happen to be pipelined.
53//    ResourceCycles = [1, 1];
54//  }
55//  def : ReadAdvance<ReadAdvanceALUsr, 3>;
56
57// Basic ALU operation.
58def WriteALU : SchedWrite;
59def ReadALU : SchedRead;
60
61// Basic ALU with shifts.
62def WriteALUsi : SchedWrite; // Shift by immediate.
63def WriteALUsr : SchedWrite; // Shift by register.
64def WriteALUSsr : SchedWrite; // Shift by register (flag setting).
65def ReadALUsr : SchedRead; // Some operands are read later.
66
67// Compares.
68def WriteCMP : SchedWrite;
69def WriteCMPsi : SchedWrite;
70def WriteCMPsr : SchedWrite;
71
72// Division.
73def WriteDiv : SchedWrite;
74
75// Loads.
76def WriteLd : SchedWrite;
77def WritePreLd : SchedWrite;
78
79// Branches.
80def WriteBr : SchedWrite;
81def WriteBrL : SchedWrite;
82def WriteBrTbl : SchedWrite;
83
84// Fixpoint conversions.
85def WriteCvtFP : SchedWrite;
86
87// Noop.
88def WriteNoop : SchedWrite;
89
90// Define TII for use in SchedVariant Predicates.
91def : PredicateProlog<[{
92  const ARMBaseInstrInfo *TII =
93    static_cast<const ARMBaseInstrInfo*>(SchedModel->getInstrInfo());
94  (void)TII;
95}]>;
96
97def IsPredicatedPred : SchedPredicate<[{TII->isPredicated(MI)}]>;
98
99//===----------------------------------------------------------------------===//
100// Instruction Itinerary classes used for ARM
101//
102def IIC_iALUx      : InstrItinClass;
103def IIC_iALUi      : InstrItinClass;
104def IIC_iALUr      : InstrItinClass;
105def IIC_iALUsi     : InstrItinClass;
106def IIC_iALUsir    : InstrItinClass;
107def IIC_iALUsr     : InstrItinClass;
108def IIC_iBITi      : InstrItinClass;
109def IIC_iBITr      : InstrItinClass;
110def IIC_iBITsi     : InstrItinClass;
111def IIC_iBITsr     : InstrItinClass;
112def IIC_iUNAr      : InstrItinClass;
113def IIC_iUNAsi     : InstrItinClass;
114def IIC_iEXTr      : InstrItinClass;
115def IIC_iEXTAr     : InstrItinClass;
116def IIC_iEXTAsr    : InstrItinClass;
117def IIC_iCMPi      : InstrItinClass;
118def IIC_iCMPr      : InstrItinClass;
119def IIC_iCMPsi     : InstrItinClass;
120def IIC_iCMPsr     : InstrItinClass;
121def IIC_iTSTi      : InstrItinClass;
122def IIC_iTSTr      : InstrItinClass;
123def IIC_iTSTsi     : InstrItinClass;
124def IIC_iTSTsr     : InstrItinClass;
125def IIC_iMOVi      : InstrItinClass;
126def IIC_iMOVr      : InstrItinClass;
127def IIC_iMOVsi     : InstrItinClass;
128def IIC_iMOVsr     : InstrItinClass;
129def IIC_iMOVix2    : InstrItinClass;
130def IIC_iMOVix2addpc : InstrItinClass;
131def IIC_iMOVix2ld  : InstrItinClass;
132def IIC_iMVNi      : InstrItinClass;
133def IIC_iMVNr      : InstrItinClass;
134def IIC_iMVNsi     : InstrItinClass;
135def IIC_iMVNsr     : InstrItinClass;
136def IIC_iCMOVi     : InstrItinClass;
137def IIC_iCMOVr     : InstrItinClass;
138def IIC_iCMOVsi    : InstrItinClass;
139def IIC_iCMOVsr    : InstrItinClass;
140def IIC_iCMOVix2   : InstrItinClass;
141def IIC_iMUL16     : InstrItinClass;
142def IIC_iMAC16     : InstrItinClass;
143def IIC_iMUL32     : InstrItinClass;
144def IIC_iMAC32     : InstrItinClass;
145def IIC_iMUL64     : InstrItinClass;
146def IIC_iMAC64     : InstrItinClass;
147def IIC_iDIV     : InstrItinClass;
148def IIC_iLoad_i    : InstrItinClass;
149def IIC_iLoad_r    : InstrItinClass;
150def IIC_iLoad_si   : InstrItinClass;
151def IIC_iLoad_iu   : InstrItinClass;
152def IIC_iLoad_ru   : InstrItinClass;
153def IIC_iLoad_siu  : InstrItinClass;
154def IIC_iLoad_bh_i   : InstrItinClass;
155def IIC_iLoad_bh_r   : InstrItinClass;
156def IIC_iLoad_bh_si  : InstrItinClass;
157def IIC_iLoad_bh_iu  : InstrItinClass;
158def IIC_iLoad_bh_ru  : InstrItinClass;
159def IIC_iLoad_bh_siu : InstrItinClass;
160def IIC_iLoad_d_i  : InstrItinClass;
161def IIC_iLoad_d_r  : InstrItinClass;
162def IIC_iLoad_d_ru : InstrItinClass;
163def IIC_iLoad_m    : InstrItinClass;
164def IIC_iLoad_mu   : InstrItinClass;
165def IIC_iLoad_mBr  : InstrItinClass;
166def IIC_iPop       : InstrItinClass;
167def IIC_iPop_Br    : InstrItinClass;
168def IIC_iLoadiALU  : InstrItinClass;
169def IIC_iStore_i   : InstrItinClass;
170def IIC_iStore_r   : InstrItinClass;
171def IIC_iStore_si  : InstrItinClass;
172def IIC_iStore_iu  : InstrItinClass;
173def IIC_iStore_ru  : InstrItinClass;
174def IIC_iStore_siu : InstrItinClass;
175def IIC_iStore_bh_i   : InstrItinClass;
176def IIC_iStore_bh_r   : InstrItinClass;
177def IIC_iStore_bh_si  : InstrItinClass;
178def IIC_iStore_bh_iu  : InstrItinClass;
179def IIC_iStore_bh_ru  : InstrItinClass;
180def IIC_iStore_bh_siu : InstrItinClass;
181def IIC_iStore_d_i   : InstrItinClass;
182def IIC_iStore_d_r   : InstrItinClass;
183def IIC_iStore_d_ru  : InstrItinClass;
184def IIC_iStore_m   : InstrItinClass;
185def IIC_iStore_mu  : InstrItinClass;
186def IIC_Preload    : InstrItinClass;
187def IIC_Br         : InstrItinClass;
188def IIC_fpSTAT     : InstrItinClass;
189def IIC_fpUNA32    : InstrItinClass;
190def IIC_fpUNA64    : InstrItinClass;
191def IIC_fpCMP32    : InstrItinClass;
192def IIC_fpCMP64    : InstrItinClass;
193def IIC_fpCVTSD    : InstrItinClass;
194def IIC_fpCVTDS    : InstrItinClass;
195def IIC_fpCVTSH    : InstrItinClass;
196def IIC_fpCVTHS    : InstrItinClass;
197def IIC_fpCVTIS    : InstrItinClass;
198def IIC_fpCVTID    : InstrItinClass;
199def IIC_fpCVTSI    : InstrItinClass;
200def IIC_fpCVTDI    : InstrItinClass;
201def IIC_fpMOVIS    : InstrItinClass;
202def IIC_fpMOVID    : InstrItinClass;
203def IIC_fpMOVSI    : InstrItinClass;
204def IIC_fpMOVDI    : InstrItinClass;
205def IIC_fpALU32    : InstrItinClass;
206def IIC_fpALU64    : InstrItinClass;
207def IIC_fpMUL32    : InstrItinClass;
208def IIC_fpMUL64    : InstrItinClass;
209def IIC_fpMAC32    : InstrItinClass;
210def IIC_fpMAC64    : InstrItinClass;
211def IIC_fpFMAC32   : InstrItinClass;
212def IIC_fpFMAC64   : InstrItinClass;
213def IIC_fpDIV32    : InstrItinClass;
214def IIC_fpDIV64    : InstrItinClass;
215def IIC_fpSQRT32   : InstrItinClass;
216def IIC_fpSQRT64   : InstrItinClass;
217def IIC_fpLoad32   : InstrItinClass;
218def IIC_fpLoad64   : InstrItinClass;
219def IIC_fpLoad_m   : InstrItinClass;
220def IIC_fpLoad_mu  : InstrItinClass;
221def IIC_fpStore32  : InstrItinClass;
222def IIC_fpStore64  : InstrItinClass;
223def IIC_fpStore_m  : InstrItinClass;
224def IIC_fpStore_mu : InstrItinClass;
225def IIC_VLD1       : InstrItinClass;
226def IIC_VLD1x2     : InstrItinClass;
227def IIC_VLD1x3     : InstrItinClass;
228def IIC_VLD1x4     : InstrItinClass;
229def IIC_VLD1u      : InstrItinClass;
230def IIC_VLD1x2u    : InstrItinClass;
231def IIC_VLD1x3u    : InstrItinClass;
232def IIC_VLD1x4u    : InstrItinClass;
233def IIC_VLD1ln     : InstrItinClass;
234def IIC_VLD1lnu    : InstrItinClass;
235def IIC_VLD1dup    : InstrItinClass;
236def IIC_VLD1dupu   : InstrItinClass;
237def IIC_VLD2       : InstrItinClass;
238def IIC_VLD2x2     : InstrItinClass;
239def IIC_VLD2u      : InstrItinClass;
240def IIC_VLD2x2u    : InstrItinClass;
241def IIC_VLD2ln     : InstrItinClass;
242def IIC_VLD2lnu    : InstrItinClass;
243def IIC_VLD2dup    : InstrItinClass;
244def IIC_VLD2dupu   : InstrItinClass;
245def IIC_VLD3       : InstrItinClass;
246def IIC_VLD3ln     : InstrItinClass;
247def IIC_VLD3u      : InstrItinClass;
248def IIC_VLD3lnu    : InstrItinClass;
249def IIC_VLD3dup    : InstrItinClass;
250def IIC_VLD3dupu   : InstrItinClass;
251def IIC_VLD4       : InstrItinClass;
252def IIC_VLD4ln     : InstrItinClass;
253def IIC_VLD4u      : InstrItinClass;
254def IIC_VLD4lnu    : InstrItinClass;
255def IIC_VLD4dup    : InstrItinClass;
256def IIC_VLD4dupu   : InstrItinClass;
257def IIC_VST1       : InstrItinClass;
258def IIC_VST1x2     : InstrItinClass;
259def IIC_VST1x3     : InstrItinClass;
260def IIC_VST1x4     : InstrItinClass;
261def IIC_VST1u      : InstrItinClass;
262def IIC_VST1x2u    : InstrItinClass;
263def IIC_VST1x3u    : InstrItinClass;
264def IIC_VST1x4u    : InstrItinClass;
265def IIC_VST1ln     : InstrItinClass;
266def IIC_VST1lnu    : InstrItinClass;
267def IIC_VST2       : InstrItinClass;
268def IIC_VST2x2     : InstrItinClass;
269def IIC_VST2u      : InstrItinClass;
270def IIC_VST2x2u    : InstrItinClass;
271def IIC_VST2ln     : InstrItinClass;
272def IIC_VST2lnu    : InstrItinClass;
273def IIC_VST3       : InstrItinClass;
274def IIC_VST3u      : InstrItinClass;
275def IIC_VST3ln     : InstrItinClass;
276def IIC_VST3lnu    : InstrItinClass;
277def IIC_VST4       : InstrItinClass;
278def IIC_VST4u      : InstrItinClass;
279def IIC_VST4ln     : InstrItinClass;
280def IIC_VST4lnu    : InstrItinClass;
281def IIC_VUNAD      : InstrItinClass;
282def IIC_VUNAQ      : InstrItinClass;
283def IIC_VBIND      : InstrItinClass;
284def IIC_VBINQ      : InstrItinClass;
285def IIC_VPBIND     : InstrItinClass;
286def IIC_VFMULD     : InstrItinClass;
287def IIC_VFMULQ     : InstrItinClass;
288def IIC_VMOV       : InstrItinClass;
289def IIC_VMOVImm    : InstrItinClass;
290def IIC_VMOVD      : InstrItinClass;
291def IIC_VMOVQ      : InstrItinClass;
292def IIC_VMOVIS     : InstrItinClass;
293def IIC_VMOVID     : InstrItinClass;
294def IIC_VMOVISL    : InstrItinClass;
295def IIC_VMOVSI     : InstrItinClass;
296def IIC_VMOVDI     : InstrItinClass;
297def IIC_VMOVN      : InstrItinClass;
298def IIC_VPERMD     : InstrItinClass;
299def IIC_VPERMQ     : InstrItinClass;
300def IIC_VPERMQ3    : InstrItinClass;
301def IIC_VMACD      : InstrItinClass;
302def IIC_VMACQ      : InstrItinClass;
303def IIC_VFMACD     : InstrItinClass;
304def IIC_VFMACQ     : InstrItinClass;
305def IIC_VRECSD     : InstrItinClass;
306def IIC_VRECSQ     : InstrItinClass;
307def IIC_VCNTiD     : InstrItinClass;
308def IIC_VCNTiQ     : InstrItinClass;
309def IIC_VUNAiD     : InstrItinClass;
310def IIC_VUNAiQ     : InstrItinClass;
311def IIC_VQUNAiD    : InstrItinClass;
312def IIC_VQUNAiQ    : InstrItinClass;
313def IIC_VBINiD     : InstrItinClass;
314def IIC_VBINiQ     : InstrItinClass;
315def IIC_VSUBiD     : InstrItinClass;
316def IIC_VSUBiQ     : InstrItinClass;
317def IIC_VBINi4D    : InstrItinClass;
318def IIC_VBINi4Q    : InstrItinClass;
319def IIC_VSUBi4D    : InstrItinClass;
320def IIC_VSUBi4Q    : InstrItinClass;
321def IIC_VABAD      : InstrItinClass;
322def IIC_VABAQ      : InstrItinClass;
323def IIC_VSHLiD     : InstrItinClass;
324def IIC_VSHLiQ     : InstrItinClass;
325def IIC_VSHLi4D    : InstrItinClass;
326def IIC_VSHLi4Q    : InstrItinClass;
327def IIC_VPALiD     : InstrItinClass;
328def IIC_VPALiQ     : InstrItinClass;
329def IIC_VMULi16D   : InstrItinClass;
330def IIC_VMULi32D   : InstrItinClass;
331def IIC_VMULi16Q   : InstrItinClass;
332def IIC_VMULi32Q   : InstrItinClass;
333def IIC_VMACi16D   : InstrItinClass;
334def IIC_VMACi32D   : InstrItinClass;
335def IIC_VMACi16Q   : InstrItinClass;
336def IIC_VMACi32Q   : InstrItinClass;
337def IIC_VEXTD      : InstrItinClass;
338def IIC_VEXTQ      : InstrItinClass;
339def IIC_VTB1       : InstrItinClass;
340def IIC_VTB2       : InstrItinClass;
341def IIC_VTB3       : InstrItinClass;
342def IIC_VTB4       : InstrItinClass;
343def IIC_VTBX1      : InstrItinClass;
344def IIC_VTBX2      : InstrItinClass;
345def IIC_VTBX3      : InstrItinClass;
346def IIC_VTBX4      : InstrItinClass;
347
348//===----------------------------------------------------------------------===//
349// Processor instruction itineraries.
350
351include "ARMScheduleV6.td"
352include "ARMScheduleA8.td"
353include "ARMScheduleA9.td"
354include "ARMScheduleSwift.td"
355