]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/llvm-project/llvm/lib/Target/AArch64/AArch64SchedExynosM4.td
MFV r361280:
[FreeBSD/FreeBSD.git] / contrib / llvm-project / llvm / lib / Target / AArch64 / AArch64SchedExynosM4.td
1 //=- AArch64SchedExynosM4.td - Samsung Exynos M4 Sched 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 // This file defines the machine model for the Samsung Exynos M4 to support
10 // instruction scheduling and other instruction cost heuristics.
11 //
12 //===----------------------------------------------------------------------===//
13
14 //===----------------------------------------------------------------------===//
15 // The Exynos-M4 is an advanced superscalar microprocessor with a 6-wide
16 // in-order stage for decode and dispatch and a wider issue stage.
17 // The execution units and loads and stores are out-of-order.
18
19 def ExynosM4Model : SchedMachineModel {
20   let IssueWidth            =   6; // Up to 6 uops per cycle.
21   let MicroOpBufferSize     = 228; // ROB size.
22   let LoopMicroOpBufferSize =  48; // Based on the instruction queue size.
23   let LoadLatency           =   4; // Optimistic load cases.
24   let MispredictPenalty     =  16; // Minimum branch misprediction penalty.
25   let CompleteModel         =   1; // Use the default model otherwise.
26
27   list<Predicate> UnsupportedFeatures = SVEUnsupported.F;
28 }
29
30 //===----------------------------------------------------------------------===//
31 // Define each kind of processor resource and number available on the Exynos-M4.
32
33 let SchedModel = ExynosM4Model in {
34
35 def M4UnitA  : ProcResource<2>; // Simple integer
36 def M4UnitC  : ProcResource<2>; // Simple and complex integer
37 let Super =  M4UnitC, BufferSize = 1 in
38 def M4UnitD  : ProcResource<1>; // Integer division (inside C0, serialized)
39 let Super =  M4UnitC in
40 def M4UnitE  : ProcResource<1>; // CRC (inside C0)
41 def M4UnitB  : ProcResource<2>; // Branch
42 def M4UnitL0 : ProcResource<1>; // Load
43 def M4UnitS0 : ProcResource<1>; // Store
44 def M4PipeLS : ProcResource<1>; // Load/Store
45 let Super = M4PipeLS in {
46   def M4UnitL1 : ProcResource<1>;
47   def M4UnitS1 : ProcResource<1>;
48 }
49 def M4PipeF0 : ProcResource<1>; // FP #0
50 let Super = M4PipeF0 in {
51   def M4UnitFMAC0 : ProcResource<1>; // FP multiplication
52   def M4UnitFADD0 : ProcResource<1>; // Simple FP
53   def M4UnitFCVT0 : ProcResource<1>; // FP conversion
54   def M4UnitNALU0 : ProcResource<1>; // Simple vector
55   def M4UnitNHAD  : ProcResource<1>; // Horizontal vector
56   def M4UnitNMSC  : ProcResource<1>; // FP and vector miscellanea
57   def M4UnitNMUL0 : ProcResource<1>; // Vector multiplication
58   def M4UnitNSHT0 : ProcResource<1>; // Vector shifting
59   def M4UnitNSHF0 : ProcResource<1>; // Vector shuffling
60   def M4UnitNCRY0 : ProcResource<1>; // Cryptographic
61 }
62 def M4PipeF1 : ProcResource<1>; // FP #1
63 let Super = M4PipeF1 in {
64   def M4UnitFMAC1 : ProcResource<1>; // FP multiplication
65   def M4UnitFADD1 : ProcResource<1>; // Simple FP
66   def M4UnitFDIV0 : ProcResource<2>; // FP division (serialized)
67   def M4UnitFSQR0 : ProcResource<2>; // FP square root (serialized)
68   def M4UnitFST0  : ProcResource<1>; // FP store
69   def M4UnitNALU1 : ProcResource<1>; // Simple vector
70   def M4UnitNSHT1 : ProcResource<1>; // Vector shifting
71   def M4UnitNSHF1 : ProcResource<1>; // Vector shuffling
72 }
73 def M4PipeF2 : ProcResource<1>; // FP #2
74 let Super = M4PipeF2 in {
75   def M4UnitFMAC2 : ProcResource<1>; // FP multiplication
76   def M4UnitFADD2 : ProcResource<1>; // Simple FP
77   def M4UnitFCVT1 : ProcResource<1>; // FP conversion
78   def M4UnitFDIV1 : ProcResource<2>; // FP division (serialized)
79   def M4UnitFSQR1 : ProcResource<2>; // FP square root (serialized)
80   def M4UnitFST1  : ProcResource<1>; // FP store
81   def M4UnitNALU2 : ProcResource<1>; // Simple vector
82   def M4UnitNMUL1 : ProcResource<1>; // Vector multiplication
83   def M4UnitNSHT2 : ProcResource<1>; // Vector shifting
84   def M4UnitNCRY1 : ProcResource<1>; // Cryptographic
85 }
86
87 def M4UnitALU   : ProcResGroup<[M4UnitA,
88                                 M4UnitC]>;
89 def M4UnitL     : ProcResGroup<[M4UnitL0,
90                                 M4UnitL1]>;
91 def M4UnitS     : ProcResGroup<[M4UnitS0,
92                                 M4UnitS1]>;
93 def M4UnitFMAC  : ProcResGroup<[M4UnitFMAC0,
94                                 M4UnitFMAC1,
95                                 M4UnitFMAC2]>;
96 def M4UnitFMACH : ProcResGroup<[M4UnitFMAC0,
97                                 M4UnitFMAC1]>;
98 def M4UnitFADD  : ProcResGroup<[M4UnitFADD0,
99                                 M4UnitFADD1,
100                                 M4UnitFADD2]>;
101 def M4UnitFADDH : ProcResGroup<[M4UnitFADD0,
102                                 M4UnitFADD1]>;
103 def M4UnitFCVT  : ProcResGroup<[M4UnitFCVT0,
104                                 M4UnitFCVT1]>;
105 def M4UnitFCVTH : ProcResGroup<[M4UnitFCVT0]>;
106 def M4UnitFDIV  : ProcResGroup<[M4UnitFDIV0,
107                                 M4UnitFDIV1]>;
108 def M4UnitFDIVH : ProcResGroup<[M4UnitFDIV0]>;
109 def M4UnitFSQR  : ProcResGroup<[M4UnitFSQR0,
110                                 M4UnitFSQR1]>;
111 def M4UnitFSQRH : ProcResGroup<[M4UnitFSQR0]>;
112 def M4UnitFST   : ProcResGroup<[M4UnitFST0,
113                                 M4UnitFST1]>;
114 def M4UnitNALU  : ProcResGroup<[M4UnitNALU0,
115                                 M4UnitNALU1,
116                                 M4UnitNALU2]>;
117 def M4UnitNALUH : ProcResGroup<[M4UnitNALU0,
118                                 M4UnitNALU1]>;
119 def M4UnitNMUL  : ProcResGroup<[M4UnitNMUL0,
120                                 M4UnitNMUL1]>;
121 def M4UnitNSHT  : ProcResGroup<[M4UnitNSHT0,
122                                 M4UnitNSHT1,
123                                 M4UnitNSHT2]>;
124 def M4UnitNSHF  : ProcResGroup<[M4UnitNSHF0,
125                                 M4UnitNSHF1]>;
126 def M4UnitNSHFH : ProcResGroup<[M4UnitNSHF0]>;
127 def M4UnitNCRY  : ProcResGroup<[M4UnitNCRY0,
128                                 M4UnitNCRY1]>;
129
130 //===----------------------------------------------------------------------===//
131 // Resources details.
132
133 def M4WriteZ0 : SchedWriteRes<[]> { let Latency = 0; }
134 def M4WriteZ1 : SchedWriteRes<[]> { let Latency = 1;
135                                     let NumMicroOps = 0; }
136 def M4WriteZ4 : SchedWriteRes<[]> { let Latency = 4;
137                                     let NumMicroOps = 0; }
138
139 def M4WriteA1 : SchedWriteRes<[M4UnitALU]> { let Latency = 1; }
140 def M4WriteA2 : SchedWriteRes<[M4UnitALU]> { let Latency = 2; }
141 def M4WriteAA : SchedWriteRes<[M4UnitALU]> { let Latency = 2;
142                                              let ResourceCycles = [2]; }
143 def M4WriteAB : SchedWriteRes<[M4UnitALU,
144                                M4UnitC]>   { let Latency = 2;
145                                              let NumMicroOps = 2; }
146 def M4WriteAC : SchedWriteRes<[M4UnitALU,
147                                M4UnitALU,
148                                M4UnitC]>   { let Latency = 3;
149                                              let NumMicroOps = 3; }
150 def M4WriteAD : SchedWriteRes<[M4UnitALU,
151                                M4UnitC]>   { let Latency = 2;
152                                              let NumMicroOps = 2; }
153 def M4WriteAF : SchedWriteRes<[M4UnitALU]> { let Latency = 2;
154                                              let NumMicroOps = 2; }
155 def M4WriteAU : SchedWriteVariant<[SchedVar<IsCopyIdiomPred,   [M4WriteZ0]>,
156                                    SchedVar<ExynosArithPred,   [M4WriteA1]>,
157                                    SchedVar<ExynosLogicExPred, [M4WriteA1]>,
158                                    SchedVar<NoSchedPred,       [M4WriteAA]>]>;
159 def M4WriteAV : SchedWriteVariant<[SchedVar<ExynosResetPred,   [M4WriteZ0]>,
160                                    SchedVar<ExynosArithPred,   [M4WriteA1]>,
161                                    SchedVar<ExynosLogicExPred, [M4WriteA1]>,
162                                    SchedVar<NoSchedPred,       [M4WriteAA]>]>;
163 def M4WriteAX : SchedWriteVariant<[SchedVar<ExynosArithPred,   [M4WriteA1]>,
164                                    SchedVar<ExynosLogicExPred, [M4WriteA1]>,
165                                    SchedVar<NoSchedPred,       [M4WriteAA]>]>;
166 def M4WriteAY : SchedWriteVariant<[SchedVar<ExynosRotateRightImmPred, [M4WriteA1]>,
167                                    SchedVar<NoSchedPred,              [M4WriteAF]>]>;
168
169 def M4WriteB1 : SchedWriteRes<[M4UnitB]> { let Latency = 1; }
170 def M4WriteBX : SchedWriteVariant<[SchedVar<ExynosBranchLinkLRPred, [M4WriteAC]>,
171                                    SchedVar<NoSchedPred,            [M4WriteAB]>]>;
172
173 def M4WriteC1 : SchedWriteRes<[M4UnitC]> { let Latency = 1; }
174 def M4WriteC3 : SchedWriteRes<[M4UnitC]> { let Latency = 3; }
175 def M4WriteCA : SchedWriteRes<[M4UnitC]> { let Latency = 4;
176                                            let ResourceCycles = [2]; }
177
178 def M4WriteD12 : SchedWriteRes<[M4UnitD]> { let Latency = 12;
179                                             let ResourceCycles = [12]; }
180 def M4WriteD21 : SchedWriteRes<[M4UnitD]> { let Latency = 21;
181                                             let ResourceCycles = [21]; }
182
183 def M4WriteE2 : SchedWriteRes<[M4UnitE]> { let Latency = 2; }
184
185 def M4WriteL4 : SchedWriteRes<[M4UnitL]> { let Latency = 4; }
186 def M4WriteL5 : SchedWriteRes<[M4UnitL]> { let Latency = 5; }
187 def M4WriteLA : SchedWriteRes<[M4UnitL,
188                                M4UnitL]> { let Latency = 5;
189                                            let NumMicroOps = 1; }
190 def M4WriteLB : SchedWriteRes<[M4UnitA,
191                                M4UnitL]> { let Latency = 5;
192                                            let NumMicroOps = 2; }
193 def M4WriteLC : SchedWriteRes<[M4UnitA,
194                                M4UnitL,
195                                M4UnitL]> { let Latency = 5;
196                                            let NumMicroOps = 2; }
197 def M4WriteLD : SchedWriteRes<[M4UnitA,
198                                M4UnitL]> { let Latency = 4;
199                                            let NumMicroOps = 2; }
200 def M4WriteLE : SchedWriteRes<[M4UnitA,
201                                M4UnitL]> { let Latency = 6;
202                                            let NumMicroOps = 2; }
203 def M4WriteLH : SchedWriteRes<[]>        { let Latency = 5;
204                                            let NumMicroOps = 0; }
205 def M4WriteLX : SchedWriteVariant<[SchedVar<ExynosScaledIdxPred, [M4WriteL5]>,
206                                    SchedVar<NoSchedPred,         [M4WriteL4]>]>;
207 def M4WriteLY : SchedWriteVariant<[SchedVar<ExynosScaledIdxPred, [M4WriteLE]>,
208                                    SchedVar<NoSchedPred,         [M4WriteL5]>]>;
209
210 def M4WriteS1 : SchedWriteRes<[M4UnitS]>  { let Latency = 1; }
211 def M4WriteSA : SchedWriteRes<[M4UnitS0]> { let Latency = 3; }
212 def M4WriteSB : SchedWriteRes<[M4UnitA,
213                                M4UnitS]>  { let Latency = 2;
214                                             let NumMicroOps = 1; }
215 def M4WriteSX : SchedWriteVariant<[SchedVar<ExynosScaledIdxPred, [M4WriteSB]>,
216                                    SchedVar<NoSchedPred,         [M4WriteS1]>]>;
217
218 def M4ReadAdrBase : SchedReadVariant<[SchedVar<
219                                         MCSchedPredicate<
220                                           CheckAny<
221                                             [ScaledIdxFn,
222                                              ExynosScaledIdxFn]>>, [ReadDefault]>,
223                                       SchedVar<NoSchedPred,        [ReadDefault]>]>;
224
225 def M4WriteNEONA   : SchedWriteRes<[M4UnitNSHF,
226                                     M4UnitFADD]>  { let Latency = 3;
227                                                     let NumMicroOps = 2; }
228 def M4WriteNEONB   : SchedWriteRes<[M4UnitNALU,
229                                     M4UnitS0]>    { let Latency = 5;
230                                                     let NumMicroOps = 2; }
231 def M4WriteNEOND   : SchedWriteRes<[M4UnitNSHF,
232                                     M4UnitFST]>   { let Latency = 6;
233                                                     let NumMicroOps = 2; }
234 def M4WriteNEONH   : SchedWriteRes<[M4UnitNALU,
235                                     M4UnitS0]>    { let Latency = 5;
236                                                     let NumMicroOps = 2; }
237 def M4WriteNEONI   : SchedWriteRes<[M4UnitNSHF,
238                                     M4UnitS0]>    { let Latency = 2;
239                                                     let NumMicroOps = 2; }
240 def M4WriteNEONJ   : SchedWriteRes<[M4UnitNMSC,
241                                     M4UnitS0]>    { let Latency = 4; }
242 def M4WriteNEONK   : SchedWriteRes<[M4UnitNSHF,
243                                     M4UnitNMSC,
244                                     M4UnitS0]>    { let Latency = 5;
245                                                     let NumMicroOps = 2; }
246 def M4WriteNEONL   : SchedWriteRes<[M4UnitNMUL]>  { let Latency = 3; }
247 def M4WriteNEONN   : SchedWriteRes<[M4UnitNMSC,
248                                     M4UnitNMSC]>  { let Latency = 5;
249                                                     let NumMicroOps = 2; }
250 def M4WriteNEONO   : SchedWriteRes<[M4UnitNMSC,
251                                     M4UnitNMSC,
252                                     M4UnitNMSC]>  { let Latency = 8;
253                                                     let NumMicroOps = 3; }
254 def M4WriteNEONP   : SchedWriteRes<[M4UnitNSHF,
255                                     M4UnitNMSC]>  { let Latency = 4;
256                                                     let NumMicroOps = 2; }
257 def M4WriteNEONQ   : SchedWriteRes<[M4UnitNMSC,
258                                     M4UnitC]>     { let Latency = 3;
259                                                     let NumMicroOps = 1; }
260 def M4WriteNEONR   : SchedWriteRes<[M4UnitFCVT0,
261                                     M4UnitS0]>    { let Latency = 4;
262                                                     let NumMicroOps = 1; }
263 def M4WriteNEONV   : SchedWriteRes<[M4UnitFDIV,
264                                     M4UnitFDIV]>  { let Latency = 7;
265                                                     let ResourceCycles = [6, 6]; }
266 def M4WriteNEONVH  : SchedWriteRes<[M4UnitFDIVH,
267                                     M4UnitFDIVH]> { let Latency = 7;
268                                                     let ResourceCycles = [6, 6]; }
269 def M4WriteNEONW   : SchedWriteRes<[M4UnitFDIV,
270                                     M4UnitFDIV]>  { let Latency = 12;
271                                                     let ResourceCycles = [9, 9]; }
272 def M4WriteNEONX   : SchedWriteRes<[M4UnitFSQR,
273                                     M4UnitFSQR]>  { let Latency = 8;
274                                                     let ResourceCycles = [7, 7]; }
275 def M4WriteNEONXH  : SchedWriteRes<[M4UnitFSQRH,
276                                     M4UnitFSQRH]> { let Latency = 7;
277                                                     let ResourceCycles = [6, 6]; }
278 def M4WriteNEONY   : SchedWriteRes<[M4UnitFSQR,
279                                     M4UnitFSQR]>  { let Latency = 12;
280                                                     let ResourceCycles = [9, 9]; }
281 def M4WriteNEONZ   : SchedWriteVariant<[SchedVar<ExynosQFormPred, [M4WriteNEONO]>,
282                                         SchedVar<NoSchedPred,     [M4WriteNEONN]>]>;
283
284 def M4WriteFADD2   : SchedWriteRes<[M4UnitFADD]>  { let Latency = 2; }
285 def M4WriteFADD2H  : SchedWriteRes<[M4UnitFADDH]> { let Latency = 2; }
286
287 def M4WriteFCVT2   : SchedWriteRes<[M4UnitFCVT]>  { let Latency = 2; }
288 def M4WriteFCVT2A  : SchedWriteRes<[M4UnitFCVT0]> { let Latency = 2; }
289 def M4WriteFCVT2H  : SchedWriteRes<[M4UnitFCVTH]> { let Latency = 2; }
290 def M4WriteFCVT3   : SchedWriteRes<[M4UnitFCVT]>  { let Latency = 3; }
291 def M4WriteFCVT3A  : SchedWriteRes<[M4UnitFCVT0]> { let Latency = 3; }
292 def M4WriteFCVT3H  : SchedWriteRes<[M4UnitFCVTH]> { let Latency = 3; }
293 def M4WriteFCVT4   : SchedWriteRes<[M4UnitFCVT]>  { let Latency = 4; }
294 def M4WriteFCVT4A  : SchedWriteRes<[M4UnitFCVT0]> { let Latency = 4; }
295 def M4WriteFCVT6A  : SchedWriteRes<[M4UnitFCVT0]> { let Latency = 6; }
296
297 def M4WriteFDIV7   : SchedWriteRes<[M4UnitFDIV]>  { let Latency = 7;
298                                                     let ResourceCycles = [6]; }
299 def M4WriteFDIV7H  : SchedWriteRes<[M4UnitFDIVH]> { let Latency = 7;
300                                                     let ResourceCycles = [6]; }
301 def M4WriteFDIV12  : SchedWriteRes<[M4UnitFDIV]>  { let Latency = 12;
302                                                     let ResourceCycles = [9]; }
303
304 def M4WriteFMAC2H  : SchedWriteRes<[M4UnitFMACH]> { let Latency = 2; }
305 def M4WriteFMAC3H  : SchedWriteRes<[M4UnitFMACH]> { let Latency = 3; }
306 def M4WriteFMAC3   : SchedWriteRes<[M4UnitFMAC]>  { let Latency = 3; }
307 def M4WriteFMAC4   : SchedWriteRes<[M4UnitFMAC]>  { let Latency = 4; }
308 def M4WriteFMAC4H  : SchedWriteRes<[M4UnitFMACH]> { let Latency = 4; }
309 def M4WriteFMAC5   : SchedWriteRes<[M4UnitFMAC]>  { let Latency = 5; }
310
311 def M4WriteFSQR7H  : SchedWriteRes<[M4UnitFSQRH]> { let Latency = 7;
312                                                     let ResourceCycles = [6]; }
313 def M4WriteFSQR8   : SchedWriteRes<[M4UnitFSQR]>  { let Latency = 8;
314                                                     let ResourceCycles = [7]; }
315 def M4WriteFSQR12  : SchedWriteRes<[M4UnitFSQR]>  { let Latency = 12;
316                                                     let ResourceCycles = [9]; }
317
318 def M4WriteNALU1   : SchedWriteRes<[M4UnitNALU]>  { let Latency = 1; }
319 def M4WriteNALU1H  : SchedWriteRes<[M4UnitNALUH]> { let Latency = 1; }
320
321 def M4WriteNCRY1   : SchedWriteRes<[M4UnitNCRY]>  { let Latency = 1; }
322 def M4WriteNCRY1A  : SchedWriteRes<[M4UnitNCRY0]> { let Latency = 1; }
323 def M4WriteNCRY3A  : SchedWriteRes<[M4UnitNCRY0]> { let Latency = 3; }
324 def M4WriteNCRY5A  : SchedWriteRes<[M4UnitNCRY]>  { let Latency = 5; }
325
326 def M4WriteNHAD1   : SchedWriteRes<[M4UnitNHAD]>  { let Latency = 1; }
327 def M4WriteNHAD3   : SchedWriteRes<[M4UnitNHAD]>  { let Latency = 3; }
328
329 def M4WriteNMSC1   : SchedWriteRes<[M4UnitNMSC]>  { let Latency = 1; }
330 def M4WriteNMSC2   : SchedWriteRes<[M4UnitNMSC]>  { let Latency = 2; }
331 def M4WriteNMSC3   : SchedWriteRes<[M4UnitNMSC]>  { let Latency = 3; }
332
333 def M4WriteNMUL3   : SchedWriteRes<[M4UnitNMUL]>  { let Latency = 3; }
334
335 def M4WriteNSHF1   : SchedWriteRes<[M4UnitNSHF]>  { let Latency = 1; }
336 def M4WriteNSHF1H  : SchedWriteRes<[M4UnitNSHFH]> { let Latency = 1; }
337 def M4WriteNSHF3   : SchedWriteRes<[M4UnitNSHF]>  { let Latency = 3; }
338 def M4WriteNSHFA   : SchedWriteRes<[M4UnitNSHF]>  { let Latency = 1;
339                                                     let ResourceCycles = [2]; }
340 def M4WriteNSHFB   : SchedWriteRes<[M4UnitNSHF]>  { let Latency = 2;
341                                                     let NumMicroOps = 2;
342                                                     let ResourceCycles = [2]; }
343 def M4WriteNSHFC   : SchedWriteRes<[M4UnitNSHF]>  { let Latency = 3;
344                                                     let NumMicroOps = 3;
345                                                     let ResourceCycles = [4]; }
346 def M4WriteNSHFD   : SchedWriteRes<[M4UnitNSHF]>  { let Latency = 4;
347                                                     let NumMicroOps = 4;
348                                                     let ResourceCycles = [4]; }
349
350 def M4WriteNSHT1   : SchedWriteRes<[M4UnitNSHT]>  { let Latency = 1; }
351 def M4WriteNSHT2   : SchedWriteRes<[M4UnitNSHT]>  { let Latency = 2; }
352 def M4WriteNSHT3   : SchedWriteRes<[M4UnitNSHT]>  { let Latency = 3; }
353 def M4WriteNSHT4A  : SchedWriteRes<[M4UnitNSHT1]> { let Latency = 4; }
354
355 def M4WriteVLDA    : SchedWriteRes<[M4UnitL,
356                                     M4UnitL]>     { let Latency = 5;
357                                                     let NumMicroOps = 2; }
358 def M4WriteVLDB    : SchedWriteRes<[M4UnitL,
359                                     M4UnitL,
360                                     M4UnitL]>     { let Latency = 6;
361                                                     let NumMicroOps = 3; }
362 def M4WriteVLDC    : SchedWriteRes<[M4UnitL,
363                                     M4UnitL,
364                                     M4UnitL,
365                                     M4UnitL]>     { let Latency = 6;
366                                                     let NumMicroOps = 4; }
367 def M4WriteVLDD    : SchedWriteRes<[M4UnitL,
368                                     M4UnitNSHF]>  { let Latency = 6;
369                                                     let NumMicroOps = 2;
370                                                     let ResourceCycles = [2, 1]; }
371 def M4WriteVLDF    : SchedWriteRes<[M4UnitL,
372                                     M4UnitL]>     { let Latency = 10;
373                                                     let NumMicroOps = 2;
374                                                     let ResourceCycles = [3, 3]; }
375 def M4WriteVLDG    : SchedWriteRes<[M4UnitL,
376                                     M4UnitNSHF,
377                                     M4UnitNSHF]>  { let Latency = 6;
378                                                     let NumMicroOps = 3;
379                                                     let ResourceCycles = [2, 1, 1]; }
380 def M4WriteVLDI    : SchedWriteRes<[M4UnitL,
381                                     M4UnitL,
382                                     M4UnitL]>     { let Latency = 12;
383                                                     let NumMicroOps = 3;
384                                                     let ResourceCycles = [3, 3, 3]; }
385 def M4WriteVLDJ    : SchedWriteRes<[M4UnitL,
386                                     M4UnitNSHF,
387                                     M4UnitNSHF,
388                                     M4UnitNSHF]>  { let Latency = 7;
389                                                     let NumMicroOps = 4;
390                                                     let ResourceCycles = [3, 1, 1, 1]; }
391 def M4WriteVLDK    : SchedWriteRes<[M4UnitL,
392                                     M4UnitNSHF,
393                                     M4UnitNSHF,
394                                     M4UnitNSHF,
395                                     M4UnitNSHF]>  { let Latency = 7;
396                                                     let NumMicroOps = 5;
397                                                     let ResourceCycles = [3, 1, 1, 1, 1]; }
398 def M4WriteVLDL    : SchedWriteRes<[M4UnitL,
399                                     M4UnitNSHF,
400                                     M4UnitNSHF,
401                                     M4UnitL,
402                                     M4UnitNSHF]>  { let Latency = 7;
403                                                     let NumMicroOps = 5;
404                                                     let ResourceCycles = [3, 1, 1, 6, 1]; }
405 def M4WriteVLDM    : SchedWriteRes<[M4UnitL,
406                                     M4UnitNSHF,
407                                     M4UnitNSHF,
408                                     M4UnitL,
409                                     M4UnitNSHF,
410                                     M4UnitNSHF]>  { let Latency = 7;
411                                                     let NumMicroOps = 6;
412                                                     let ResourceCycles = [3, 1, 1, 3, 1, 1]; }
413 def M4WriteVLDN    : SchedWriteRes<[M4UnitL,
414                                     M4UnitL,
415                                     M4UnitL,
416                                     M4UnitL]>     { let Latency = 14;
417                                                     let NumMicroOps = 4;
418                                                     let ResourceCycles = [3, 3, 3, 3]; }
419
420 def M4WriteVST1    : SchedWriteRes<[M4UnitS,
421                                     M4UnitFST]>  { let Latency = 1;
422                                                    let NumMicroOps = 1; }
423 def M4WriteVSTA    : WriteSequence<[WriteVST], 2>;
424 def M4WriteVSTB    : WriteSequence<[WriteVST], 3>;
425 def M4WriteVSTC    : WriteSequence<[WriteVST], 4>;
426 def M4WriteVSTD    : SchedWriteRes<[M4UnitS,
427                                     M4UnitFST]>   { let Latency = 2; }
428 def M4WriteVSTE    : SchedWriteRes<[M4UnitS,
429                                     M4UnitFST,
430                                     M4UnitS,
431                                     M4UnitFST]>   { let Latency = 2;
432                                                     let NumMicroOps = 2; }
433 def M4WriteVSTF    : SchedWriteRes<[M4UnitNSHF,
434                                     M4UnitS,
435                                     M4UnitFST,
436                                     M4UnitS,
437                                     M4UnitFST]>   { let Latency = 4;
438                                                     let NumMicroOps = 4;
439                                                     let ResourceCycles = [1, 2, 1, 2, 1]; }
440 def M4WriteVSTG    : SchedWriteRes<[M4UnitNSHF,
441                                     M4UnitNSHF,
442                                     M4UnitNSHF,
443                                     M4UnitS,
444                                     M4UnitFST,
445                                     M4UnitS,
446                                     M4UnitFST,
447                                     M4UnitS,
448                                     M4UnitFST]>   { let Latency = 5;
449                                                     let NumMicroOps = 6;
450                                                     let ResourceCycles = [1, 1, 1, 2, 1, 2, 1, 2, 1]; }
451 def M4WriteVSTI    : SchedWriteRes<[M4UnitNSHF,
452                                     M4UnitNSHF,
453                                     M4UnitNSHF,
454                                     M4UnitNSHF,
455                                     M4UnitS,
456                                     M4UnitFST,
457                                     M4UnitS,
458                                     M4UnitFST,
459                                     M4UnitS,
460                                     M4UnitFST,
461                                     M4UnitS,
462                                     M4UnitFST]>   { let Latency = 8;
463                                                     let NumMicroOps = 5;
464                                                     let ResourceCycles = [1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1]; }
465 def M4WriteVSTJ    : SchedWriteRes<[M4UnitA,
466                                     M4UnitS,
467                                     M4UnitFST,
468                                     M4UnitS,
469                                     M4UnitFST]>   { let Latency = 1;
470                                                     let NumMicroOps = 2; }
471 def M4WriteVSTK    : SchedWriteRes<[M4UnitA,
472                                     M4UnitS,
473                                     M4UnitFST]>   { let Latency = 3;
474                                                     let NumMicroOps = 2; }
475 def M4WriteVSTL    : SchedWriteRes<[M4UnitNSHF,
476                                     M4UnitNSHF,
477                                     M4UnitS,
478                                     M4UnitFST,
479                                     M4UnitS,
480                                     M4UnitFST]>   { let Latency = 4;
481                                                     let NumMicroOps = 4;
482                                                     let ResourceCycles = [1, 1, 2, 1, 2, 1]; }
483 def M4WriteVSTY    : SchedWriteVariant<[SchedVar<ExynosScaledIdxPred, [M4WriteVSTK]>,
484                                         SchedVar<NoSchedPred,         [WriteVST]>]>;
485
486 // Special cases.
487 def M4WriteCOPY    : SchedWriteVariant<[SchedVar<ExynosFPPred, [M4WriteNALU1]>,
488                                         SchedVar<NoSchedPred,  [M4WriteZ0]>]>;
489 def M4WriteMOVI    : SchedWriteVariant<[SchedVar<IsZeroFPIdiomPred, [M4WriteZ0]>,
490                                         SchedVar<NoSchedPred,       [M4WriteNALU1]>]>;
491
492 // Fast forwarding.
493 def M4ReadAESM1    : SchedReadAdvance<+1, [M4WriteNCRY1]>;
494 def M4ReadFMACM1   : SchedReadAdvance<+1, [M4WriteFMAC4,
495                                            M4WriteFMAC4H,
496                                            M4WriteFMAC5]>;
497 def M4ReadNMULM1   : SchedReadAdvance<+1, [M4WriteNMUL3]>;
498 def M4ReadNMULP2   : SchedReadAdvance<-2, [M4WriteNMUL3]>;
499
500
501 //===----------------------------------------------------------------------===//
502 // Coarse scheduling model.
503
504 // Branch instructions.
505 def : SchedAlias<WriteBr,    M4WriteZ0>;
506 def : SchedAlias<WriteBrReg, M4WriteC1>;
507
508 // Arithmetic and logical integer instructions.
509 def : SchedAlias<WriteI,     M4WriteA1>;
510 def : SchedAlias<WriteIEReg, M4WriteAA>; // FIXME: M4WriteAX crashes TableGen.
511 def : SchedAlias<WriteISReg, M4WriteAA>; // FIXME: M4WriteAX crashes TableGen.
512 def : SchedAlias<WriteIS,    M4WriteA1>;
513
514 // Move instructions.
515 def : SchedAlias<WriteImm, M4WriteA1>;
516
517 // Divide and multiply instructions.
518 def : SchedAlias<WriteID32, M4WriteD12>;
519 def : SchedAlias<WriteID64, M4WriteD21>;
520 def : SchedAlias<WriteIM32, M4WriteC3>;
521 def : SchedAlias<WriteIM64, M4WriteCA>;
522
523 // Miscellaneous instructions.
524 def : SchedAlias<WriteExtr, M4WriteAY>;
525
526 // Addressing modes.
527 def : SchedAlias<WriteAdr,    M4WriteZ1>;
528 def : SchedAlias<ReadAdrBase, M4ReadAdrBase>;
529
530 // Load instructions.
531 def : SchedAlias<WriteLD,    M4WriteL4>;
532 def : SchedAlias<WriteLDHi,  M4WriteZ4>;
533 def : SchedAlias<WriteLDIdx, M4WriteLX>;
534
535 // Store instructions.
536 def : SchedAlias<WriteST,    M4WriteS1>;
537 def : SchedAlias<WriteSTP,   M4WriteS1>;
538 def : SchedAlias<WriteSTX,   M4WriteS1>;
539 def : SchedAlias<WriteSTIdx, M4WriteSX>;
540
541 // FP data instructions.
542 def : SchedAlias<WriteF,    M4WriteFADD2>;
543 def : SchedAlias<WriteFCmp, M4WriteNMSC2>;
544 def : SchedAlias<WriteFDiv, M4WriteFDIV12>;
545 def : SchedAlias<WriteFMul, M4WriteFMAC3>;
546
547 // FP miscellaneous instructions.
548 def : SchedAlias<WriteFCvt,  M4WriteFCVT2>;
549 def : SchedAlias<WriteFImm,  M4WriteNALU1>;
550 def : SchedAlias<WriteFCopy, M4WriteNALU1>;
551
552 // FP load instructions.
553 def : SchedAlias<WriteVLD, M4WriteL5>;
554
555 // FP store instructions.
556 def : SchedAlias<WriteVST, M4WriteVST1>;
557
558 // ASIMD FP instructions.
559 def : SchedAlias<WriteV, M4WriteNALU1>;
560
561 // Other miscellaneous instructions.
562 def : WriteRes<WriteAtomic,  []> { let Unsupported = 1; }
563 def : WriteRes<WriteBarrier, []> { let Latency = 1; }
564 def : WriteRes<WriteHint,    []> { let Latency = 1; }
565 def : WriteRes<WriteSys,     []> { let Latency = 1; }
566
567 //===----------------------------------------------------------------------===//
568 // Generic fast forwarding.
569
570 // TODO: Add FP register forwarding rules.
571
572 def : ReadAdvance<ReadI,       0>;
573 def : ReadAdvance<ReadISReg,   0>;
574 def : ReadAdvance<ReadIEReg,   0>;
575 def : ReadAdvance<ReadIM,      0>;
576 // TODO: The forwarding for 32 bits actually saves 2 cycles.
577 def : ReadAdvance<ReadIMA,     3, [WriteIM32, WriteIM64]>;
578 def : ReadAdvance<ReadID,      0>;
579 def : ReadAdvance<ReadExtrHi,  0>;
580 def : ReadAdvance<ReadAdrBase, 0>;
581 def : ReadAdvance<ReadVLD,     0>;
582
583 //===----------------------------------------------------------------------===//
584 // Finer scheduling model.
585
586 // Branch instructions
587 def : InstRW<[M4WriteB1], (instrs Bcc)>;
588 def : InstRW<[M4WriteAF], (instrs BL)>;
589 def : InstRW<[M4WriteBX], (instrs BLR)>;
590 def : InstRW<[M4WriteC1], (instregex "^CBN?Z[WX]")>;
591 def : InstRW<[M4WriteAD], (instregex "^TBN?Z[WX]")>;
592
593 // Arithmetic and logical integer instructions.
594 def : InstRW<[M4WriteAX], (instregex "^(ADD|AND|BIC|EON|EOR|ORN|SUB)[WX]rs$")>;
595 def : InstRW<[M4WriteAU], (instrs ORRWrs, ORRXrs)>;
596 def : InstRW<[M4WriteAX], (instregex "^(ADD|AND|BIC|SUB)S[WX]rs$")>;
597 def : InstRW<[M4WriteAX], (instregex "^(ADD|SUB)S?[WX]rx(64)?$")>;
598 def : InstRW<[M4WriteAV], (instrs ADDWri, ADDXri, ORRWri, ORRXri)>;
599
600 // Move instructions.
601 def : InstRW<[M4WriteCOPY], (instrs COPY)>;
602 def : InstRW<[M4WriteZ0],   (instrs ADR, ADRP)>;
603 def : InstRW<[M4WriteZ0],   (instregex "^MOV[NZ][WX]i")>;
604
605 // Divide and multiply instructions.
606
607 // Miscellaneous instructions.
608
609 // Load instructions.
610 def : InstRW<[M4WriteLD,
611               WriteLDHi,
612               WriteAdr],    (instregex "^LDP(SW|W|X)(post|pre)")>;
613 def : InstRW<[M4WriteL5,
614               ReadAdrBase], (instregex "^LDR(BB|SBW|SBX|HH|SHW|SHX|SW|W|X)roW")>;
615 def : InstRW<[WriteLDIdx,
616               ReadAdrBase], (instregex "^LDR(BB|SBW|SBX|HH|SHW|SHX|SW|W|X)roX")>;
617 def : InstRW<[M4WriteL5,
618               ReadAdrBase], (instrs PRFMroW)>;
619 def : InstRW<[WriteLDIdx,
620               ReadAdrBase], (instrs PRFMroX)>;
621
622 // Store instructions.
623 def : InstRW<[M4WriteSB,
624               ReadAdrBase], (instregex "^STR(BB|HH|W|X)roW")>;
625 def : InstRW<[WriteST,
626               ReadAdrBase], (instregex "^STR(BB|HH|W|X)roX")>;
627
628 // FP data instructions.
629 def : InstRW<[M4WriteNSHF1H], (instrs FABSHr)>;
630 def : InstRW<[M4WriteNSHF1],  (instregex "^FABS[SD]r")>;
631 def : InstRW<[M4WriteFADD2H], (instregex "^F(ADD|SUB)Hrr")>;
632 def : InstRW<[M4WriteFADD2],  (instregex "^F(ADD|SUB)[SD]rr")>;
633 def : InstRW<[M4WriteFADD2H], (instregex "^FADDPv.i16")>;
634 def : InstRW<[M4WriteFADD2],  (instregex "^FADDPv.i(32|64)")>;
635 def : InstRW<[M4WriteNEONQ],  (instregex "^FCCMPE?[HSD]rr")>;
636 def : InstRW<[M4WriteNMSC2],  (instregex "^FCMPE?[HSD]r[ir]")>;
637 def : InstRW<[M4WriteNMSC1],  (instregex "^F(AC|CM)(EQ|GE|GT|LE|LT)(16|32|64|v1)")>;
638 def : InstRW<[M4WriteFDIV7H], (instrs FDIVHrr)>;
639 def : InstRW<[M4WriteFDIV7],  (instrs FDIVSrr)>;
640 def : InstRW<[M4WriteFDIV12], (instrs FDIVDrr)>;
641 def : InstRW<[M4WriteNMSC1],  (instregex "^F(MAX|MIN)(NM)?[HSD]rr")>;
642 def : InstRW<[M4WriteFMAC3H], (instregex "^FN?MULHrr")>;
643 def : InstRW<[M4WriteFMAC3],  (instregex "^FN?MUL[SD]rr")>;
644 def : InstRW<[M4WriteFMAC3H], (instrs FMULX16)>;
645 def : InstRW<[M4WriteFMAC3],  (instregex "^FMULX(32|64)")>;
646 def : InstRW<[M4WriteFMAC4H,
647               M4ReadFMACM1],  (instregex "^FN?M(ADD|SUB)Hrrr")>;
648 def : InstRW<[M4WriteFMAC4,
649               M4ReadFMACM1],  (instregex "^FN?M(ADD|SUB)[SD]rrr")>;
650 def : InstRW<[M4WriteNALU1H], (instrs FNEGHr)>;
651 def : InstRW<[M4WriteNALU1],  (instregex "^FNEG[SD]r")>;
652 def : InstRW<[M4WriteFCVT3A], (instregex "^FRINT.+r")>;
653 def : InstRW<[M4WriteNEONH],  (instregex "^FCSEL[HSD]rrr")>;
654 def : InstRW<[M4WriteFSQR7H], (instrs FSQRTHr)>;
655 def : InstRW<[M4WriteFSQR8],  (instrs FSQRTSr)>;
656 def : InstRW<[M4WriteFSQR12], (instrs FSQRTDr)>;
657
658 // FP miscellaneous instructions.
659 def : InstRW<[M4WriteFCVT2H], (instregex "^FCVTH[SD]r")>;
660 def : InstRW<[M4WriteFCVT2H], (instregex "^FCVT[SD]Hr")>;
661 def : InstRW<[M4WriteFCVT2],  (instregex "^FCVT[SD][SD]r")>;
662 def : InstRW<[M4WriteFCVT6A], (instregex "^[SU]CVTF[SU][XW][HSD]ri")>;
663 def : InstRW<[M4WriteNEONR],  (instregex "^FCVT[AMNPZ][SU][SU][XW][HSD]r")>;
664 def : InstRW<[M4WriteNALU1],  (instregex "^FMOV[HSD][ir]")>;
665 def : InstRW<[M4WriteSA],     (instregex "^FMOV[WX][HSD]r")>;
666 def : InstRW<[M4WriteNEONJ],  (instregex "^FMOV[HSD][WX]r")>;
667 def : InstRW<[M4WriteNEONI],  (instregex "^FMOVXDHighr")>;
668 def : InstRW<[M4WriteNEONK],  (instregex "^FMOVDXHighr")>;
669 def : InstRW<[M4WriteFCVT3H], (instregex "^F(RECP|RSQRT)Ev1f16")>;
670 def : InstRW<[M4WriteFCVT3],  (instregex "^F(RECP|RSQRT)Ev1i(32|64)")>;
671 def : InstRW<[M4WriteNMSC1],  (instregex "^FRECPXv1")>;
672 def : InstRW<[M4WriteFMAC4H], (instregex "^F(RECP|RSQRT)S16")>;
673 def : InstRW<[M4WriteFMAC4],  (instregex "^F(RECP|RSQRT)S(32|64)")>;
674
675 // FP load instructions.
676 def : InstRW<[WriteVLD],    (instregex "^LDR[SDQ]l")>;
677 def : InstRW<[WriteVLD],    (instregex "^LDUR[BHSDQ]i")>;
678 def : InstRW<[WriteVLD,
679               WriteAdr],    (instregex "^LDR[BHSDQ](post|pre)")>;
680 def : InstRW<[WriteVLD],    (instregex "^LDR[BHSDQ]ui")>;
681 def : InstRW<[M4WriteLE,
682               ReadAdrBase], (instregex "^LDR[BHSDQ]roW")>;
683 def : InstRW<[WriteVLD,
684               ReadAdrBase], (instregex "^LDR[BHSD]roX")>;
685 def : InstRW<[M4WriteLY,
686               ReadAdrBase], (instrs LDRQroX)>;
687 def : InstRW<[WriteVLD,
688               M4WriteLH],   (instregex "^LDN?P[SD]i")>;
689 def : InstRW<[M4WriteLA,
690               M4WriteLH],   (instregex "^LDN?PQi")>;
691 def : InstRW<[M4WriteL5,
692               M4WriteLH,
693               WriteAdr],    (instregex "^LDP[SD]post")>;
694 def : InstRW<[M4WriteLB,
695               M4WriteLH,
696               WriteAdr],    (instrs LDPQpost)>;
697 def : InstRW<[M4WriteLB,
698               M4WriteLH,
699               WriteAdr],    (instregex "^LDP[SD]pre")>;
700 def : InstRW<[M4WriteLC,
701               M4WriteLH,
702               WriteAdr],    (instrs LDPQpre)>;
703
704 // FP store instructions.
705 def : InstRW<[WriteVST],    (instregex "^STUR[BHSDQ]i")>;
706 def : InstRW<[WriteVST,
707               WriteAdr],    (instregex "^STR[BHSDQ](post|pre)")>;
708 def : InstRW<[WriteVST],    (instregex "^STR[BHSDQ]ui")>;
709 def : InstRW<[M4WriteVSTK,
710               ReadAdrBase], (instregex "^STR[BHSD]roW")>;
711 def : InstRW<[M4WriteVSTK,
712               ReadAdrBase], (instrs STRQroW)>;
713 def : InstRW<[WriteVST,
714               ReadAdrBase], (instregex "^STR[BHSD]roX")>;
715 def : InstRW<[M4WriteVSTY,
716               ReadAdrBase], (instrs STRQroX)>;
717 def : InstRW<[WriteVST],    (instregex "^STN?P[SD]i")>;
718 def : InstRW<[M4WriteVSTJ], (instregex "^STN?PQi")>;
719 def : InstRW<[WriteVST,
720               WriteAdr],    (instregex "^STP[SD](post|pre)")>;
721 def : InstRW<[M4WriteVSTJ,
722               WriteAdr],    (instregex "^STPQ(post|pre)")>;
723
724 // ASIMD instructions.
725 def : InstRW<[M4WriteNHAD1],  (instregex "^[SU]ABDL?v")>;
726 def : InstRW<[M4WriteNHAD3],  (instregex "^[SU]ABAL?v")>;
727 def : InstRW<[M4WriteNMSC1],  (instregex "^ABSv")>;
728 def : InstRW<[M4WriteNALU1],  (instregex "^(ADD|NEG|SUB)v")>;
729 def : InstRW<[M4WriteNHAD3],  (instregex "^[SU]?ADDL?Pv")>;
730 def : InstRW<[M4WriteNHAD3],  (instregex "^[SU]H(ADD|SUB)v")>;
731 def : InstRW<[M4WriteNHAD3],  (instregex "^[SU](ADD|SUB)[LW]v")>;
732 def : InstRW<[M4WriteNHAD3],  (instregex "^R?(ADD|SUB)HN2?v")>;
733 def : InstRW<[M4WriteNHAD3],  (instregex "^[SU]Q(ADD|SUB)v")>;
734 def : InstRW<[M4WriteNHAD3],  (instregex "^(SU|US)QADDv")>;
735 def : InstRW<[M4WriteNHAD3],  (instregex "^[SU]RHADDv")>;
736 def : InstRW<[M4WriteNMSC1],  (instregex "^SQ(ABS|NEG)v")>;
737 def : InstRW<[M4WriteNHAD3],  (instregex "^[SU]?ADDL?Vv")>;
738 def : InstRW<[M4WriteNMSC1],  (instregex "^CM(EQ|GE|GT|HI|HS|LE|LT)v")>;
739 def : InstRW<[M4WriteNALU1],  (instregex "^CMTSTv")>;
740 def : InstRW<[M4WriteNALU1],  (instregex "^(AND|BIC|EOR|NOT|ORN|ORR)v")>;
741 def : InstRW<[M4WriteNMSC1],  (instregex "^[SU](MIN|MAX)v")>;
742 def : InstRW<[M4WriteNMSC2],  (instregex "^[SU](MIN|MAX)Pv")>;
743 def : InstRW<[M4WriteNHAD3],  (instregex "^[SU](MIN|MAX)Vv")>;
744 def : InstRW<[M4WriteNMUL3,
745               M4ReadNMULM1],  (instregex "^ML[AS]v")>;
746 def : InstRW<[M4WriteNMUL3,
747               M4ReadNMULM1],  (instregex "^(SQR?D)?MULH?v")>;
748 def : InstRW<[M4WriteNMUL3,
749               M4ReadNMULM1],  (instregex "^SQRDML[AS]H")>;
750 def : InstRW<[M4WriteNMUL3,
751               M4ReadNMULM1],  (instregex "^(S|U|SQD)ML[AS]L(v1(i32|i64)|v2i32|v4i16|v8i8)")>;
752 def : InstRW<[M4WriteNMUL3,
753               M4ReadNMULP2],  (instregex "^(S|U|SQD)ML[AS]L(v4i32|v8i16|v16i8)")>;
754 def : InstRW<[M4WriteNMUL3,
755               M4ReadNMULM1],  (instregex "^(S|U|SQD)MULL(v1(i32|i64)|v2i32|v4i16|v8i8)")>;
756 def : InstRW<[M4WriteNMUL3,
757               M4ReadNMULP2],  (instregex "^(S|U|SQD)MULL(v4i32|v8i16|v16i8)")>;
758 def : InstRW<[M4WriteNMUL3],  (instregex "^[SU]DOT(lane)?v")>;
759 def : InstRW<[M4WriteNHAD3],  (instregex "^[SU]ADALPv")>;
760 def : InstRW<[M4WriteNSHT4A], (instregex "^[SU]R?SRA[dv]")>;
761 def : InstRW<[M4WriteNSHT1],  (instregex "^SHL[dv]")>;
762 def : InstRW<[M4WriteNSHT1],  (instregex "^S[LR]I[dv]")>;
763 def : InstRW<[M4WriteNSHT1],  (instregex "^[SU]SH[LR][dv]")>;
764 def : InstRW<[M4WriteNSHT2],  (instregex "^[SU]?SHLLv")>;
765 def : InstRW<[M4WriteNSHT4A], (instregex "^[SU]?Q?R?SHRU?N[bhsv]")>;
766 def : InstRW<[M4WriteNSHT4A], (instregex "^[SU]RSH[LR][dv]")>;
767 def : InstRW<[M4WriteNSHT4A], (instregex "^[SU]QR?SHLU?[bhsdv]")>;
768
769 // ASIMD FP instructions.
770 def : InstRW<[M4WriteNSHF1H], (instregex "^FABSv.f16")>;
771 def : InstRW<[M4WriteNSHF1],  (instregex "^FABSv.f(32|64)")>;
772 def : InstRW<[M4WriteFADD2H], (instregex "^F(ABD|ADD|SUB)v.f16")>;
773 def : InstRW<[M4WriteFADD2],  (instregex "^F(ABD|ADD|SUB)v.f(32|64)")>;
774 def : InstRW<[M4WriteFADD2H], (instregex "^FADDPv.f16")>;
775 def : InstRW<[M4WriteFADD2],  (instregex "^FADDPv.f(32|64)")>;
776 def : InstRW<[M4WriteNMSC1],  (instregex "^F(AC|CM)(EQ|GE|GT|LE|LT)v[^1]")>;
777 def : InstRW<[M4WriteFCVT2],  (instregex "^FCVT(L|N|XN)v")>;
778 def : InstRW<[M4WriteFCVT2A], (instregex "^FCVT[AMNPZ][SU]v")>;
779 def : InstRW<[M4WriteFCVT2H], (instregex "^[SU]CVTFv.[fi]16")>;
780 def : InstRW<[M4WriteFCVT2],  (instregex "^[SU]CVTFv.[fi](32|64)")>;
781 def : InstRW<[M4WriteFDIV7H], (instrs FDIVv4f16)>;
782 def : InstRW<[M4WriteNEONVH], (instrs FDIVv8f16)>;
783 def : InstRW<[M4WriteFDIV7],  (instrs FDIVv2f32)>;
784 def : InstRW<[M4WriteNEONV],  (instrs FDIVv4f32)>;
785 def : InstRW<[M4WriteNEONW],  (instrs FDIVv2f64)>;
786 def : InstRW<[M4WriteNMSC1],  (instregex "^F(MAX|MIN)(NM)?v")>;
787 def : InstRW<[M4WriteNMSC2],  (instregex "^F(MAX|MIN)(NM)?Pv")>;
788 def : InstRW<[M4WriteNEONZ],  (instregex "^F(MAX|MIN)(NM)?Vv")>;
789 def : InstRW<[M4WriteFMAC2H], (instregex "^FMULX?v.[fi]16")>;
790 def : InstRW<[M4WriteFMAC3],  (instregex "^FMULX?v.[fi](32|64)")>;
791 def : InstRW<[M4WriteFMAC4H,
792               M4ReadFMACM1],  (instregex "^FML[AS]v.[fi]16")>;
793 def : InstRW<[M4WriteFMAC4,
794               M4ReadFMACM1],  (instregex "^FML[AS]v.[fi](32|64)")>;
795 def : InstRW<[M4WriteNALU1H], (instregex "^FNEGv.f16")>;
796 def : InstRW<[M4WriteNALU1],  (instregex "^FNEGv.f(32|64)")>;
797 def : InstRW<[M4WriteFCVT3A], (instregex "^FRINT[AIMNPXZ]v")>;
798 def : InstRW<[M4WriteFSQR7H], (instrs FSQRTv4f16)>;
799 def : InstRW<[M4WriteNEONXH], (instrs FSQRTv8f16)>;
800 def : InstRW<[M4WriteFSQR8],  (instrs FSQRTv2f32)>;
801 def : InstRW<[M4WriteNEONX],  (instrs FSQRTv4f32)>;
802 def : InstRW<[M4WriteNEONY],  (instrs FSQRTv2f64)>;
803
804 // ASIMD miscellaneous instructions.
805 def : InstRW<[M4WriteNALU1],  (instregex "^RBITv")>;
806 def : InstRW<[M4WriteNALU1],  (instregex "^(BIF|BIT|BSL)v")>;
807 def : InstRW<[M4WriteNALU1],  (instregex "^CL[STZ]v")>;
808 def : InstRW<[M4WriteNEONB],  (instregex "^DUPv.+gpr")>;
809 def : InstRW<[M4WriteNSHF1],  (instregex "^CPY")>;
810 def : InstRW<[M4WriteNSHF1],  (instregex "^DUPv.+lane")>;
811 def : InstRW<[M4WriteNSHF1],  (instregex "^EXTv")>;
812 def : InstRW<[M4WriteNSHT4A], (instregex "^XTNv")>;
813 def : InstRW<[M4WriteNSHT4A], (instregex "^[SU]?QXTU?Nv")>;
814 def : InstRW<[M4WriteNEONB],  (instregex "^INSv.+gpr")>;
815 def : InstRW<[M4WriteNSHF1],  (instregex "^INSv.+lane")>;
816 def : InstRW<[M4WriteMOVI],   (instregex "^(MOV|MVN)I")>;
817 def : InstRW<[M4WriteNALU1H], (instregex "^FMOVv.f16")>;
818 def : InstRW<[M4WriteNALU1],  (instregex "^FMOVv.f(32|64)")>;
819 def : InstRW<[M4WriteFCVT3H], (instregex "^F(RECP|RSQRT)Ev[248]f16")>;
820 def : InstRW<[M4WriteFCVT3],  (instregex "^F(RECP|RSQRT)Ev[248]f(32|64)")>;
821 def : InstRW<[M4WriteFCVT3],  (instregex "^U(RECP|RSQRT)Ev[24]i32")>;
822 def : InstRW<[M4WriteFMAC4H], (instregex "^F(RECP|RSQRT)Sv.f16")>;
823 def : InstRW<[M4WriteFMAC4],  (instregex "^F(RECP|RSQRT)Sv.f(32|64)")>;
824 def : InstRW<[M4WriteNSHF1],  (instregex "^REV(16|32|64)v")>;
825 def : InstRW<[M4WriteNSHFA],  (instregex "^TB[LX]v(8|16)i8One")>;
826 def : InstRW<[M4WriteNSHFB],  (instregex "^TB[LX]v(8|16)i8Two")>;
827 def : InstRW<[M4WriteNSHFC],  (instregex "^TB[LX]v(8|16)i8Three")>;
828 def : InstRW<[M4WriteNSHFD],  (instregex "^TB[LX]v(8|16)i8Four")>;
829 def : InstRW<[M4WriteNEONP],  (instregex "^[SU]MOVv")>;
830 def : InstRW<[M4WriteNSHF1],  (instregex "^(TRN|UZP|ZIP)[12]v")>;
831
832 // ASIMD load instructions.
833 def : InstRW<[WriteVLD],    (instregex "LD1Onev(8b|4h|2s|1d)$")>;
834 def : InstRW<[WriteVLD,
835               M4WriteA1],   (instregex "LD1Onev(8b|4h|2s|1d)_POST$")>;
836 def : InstRW<[WriteVLD],    (instregex "LD1Onev(16b|8h|4s|2d)$")>;
837 def : InstRW<[WriteVLD,
838               M4WriteA1],   (instregex "LD1Onev(16b|8h|4s|2d)_POST$")>;
839
840 def : InstRW<[M4WriteVLDA], (instregex "LD1Twov(8b|4h|2s|1d)$")>;
841 def : InstRW<[M4WriteVLDA,
842               M4WriteA1],   (instregex "LD1Twov(8b|4h|2s|1d)_POST$")>;
843 def : InstRW<[M4WriteVLDA], (instregex "LD1Twov(16b|8h|4s|2d)$")>;
844 def : InstRW<[M4WriteVLDA,
845               M4WriteA1],   (instregex "LD1Twov(16b|8h|4s|2d)_POST$")>;
846
847 def : InstRW<[M4WriteVLDB], (instregex "LD1Threev(8b|4h|2s|1d)$")>;
848 def : InstRW<[M4WriteVLDB,
849               M4WriteA1],   (instregex "LD1Threev(8b|4h|2s|1d)_POST$")>;
850 def : InstRW<[M4WriteVLDB], (instregex "LD1Threev(16b|8h|4s|2d)$")>;
851 def : InstRW<[M4WriteVLDB,
852               M4WriteA1],   (instregex "LD1Threev(16b|8h|4s|2d)_POST$")>;
853
854 def : InstRW<[M4WriteVLDC], (instregex "LD1Fourv(8b|4h|2s|1d)$")>;
855 def : InstRW<[M4WriteVLDC,
856               M4WriteA1],   (instregex "LD1Fourv(8b|4h|2s|1d)_POST$")>;
857 def : InstRW<[M4WriteVLDC], (instregex "LD1Fourv(16b|8h|4s|2d)$")>;
858 def : InstRW<[M4WriteVLDC,
859               M4WriteA1],   (instregex "LD1Fourv(16b|8h|4s|2d)_POST$")>;
860
861 def : InstRW<[M4WriteVLDD], (instregex "LD1i(8|16|32|64)$")>;
862 def : InstRW<[M4WriteVLDD,
863               M4WriteA1],   (instregex "LD1i(8|16|32|64)_POST$")>;
864
865 def : InstRW<[WriteVLD],    (instregex "LD1Rv(8b|4h|2s|1d)$")>;
866 def : InstRW<[WriteVLD,
867               M4WriteA1],   (instregex "LD1Rv(8b|4h|2s|1d)_POST$")>;
868 def : InstRW<[WriteVLD],    (instregex "LD1Rv(16b|8h|4s|2d)$")>;
869 def : InstRW<[WriteVLD,
870               M4WriteA1],   (instregex "LD1Rv(16b|8h|4s|2d)_POST$")>;
871
872 def : InstRW<[M4WriteVLDF], (instregex "LD2Twov(8b|4h|2s)$")>;
873 def : InstRW<[M4WriteVLDF,
874               M4WriteA1],   (instregex "LD2Twov(8b|4h|2s)_POST$")>;
875 def : InstRW<[M4WriteVLDF], (instregex "LD2Twov(16b|8h|4s|2d)$")>;
876 def : InstRW<[M4WriteVLDF,
877               M4WriteA1],   (instregex "LD2Twov(16b|8h|4s|2d)_POST$")>;
878
879 def : InstRW<[M4WriteVLDG], (instregex "LD2i(8|16|32|64)$")>;
880 def : InstRW<[M4WriteVLDG,
881               M4WriteA1],   (instregex "LD2i(8|16|32|64)_POST$")>;
882
883 def : InstRW<[M4WriteVLDA], (instregex "LD2Rv(8b|4h|2s|1d)$")>;
884 def : InstRW<[M4WriteVLDA,
885               M4WriteA1],   (instregex "LD2Rv(8b|4h|2s|1d)_POST$")>;
886 def : InstRW<[M4WriteVLDA], (instregex "LD2Rv(16b|8h|4s|2d)$")>;
887 def : InstRW<[M4WriteVLDA,
888               M4WriteA1],   (instregex "LD2Rv(16b|8h|4s|2d)_POST$")>;
889
890 def : InstRW<[M4WriteVLDI], (instregex "LD3Threev(8b|4h|2s)$")>;
891 def : InstRW<[M4WriteVLDI,
892               M4WriteA1],   (instregex "LD3Threev(8b|4h|2s)_POST$")>;
893 def : InstRW<[M4WriteVLDI], (instregex "LD3Threev(16b|8h|4s|2d)$")>;
894 def : InstRW<[M4WriteVLDI,
895               M4WriteA1],   (instregex "LD3Threev(16b|8h|4s|2d)_POST$")>;
896
897 def : InstRW<[M4WriteVLDJ], (instregex "LD3i(8|16|32)$")>;
898 def : InstRW<[M4WriteVLDJ,
899               M4WriteA1],   (instregex "LD3i(8|16|32)_POST$")>;
900 def : InstRW<[M4WriteVLDL], (instregex "LD3i64$")>;
901 def : InstRW<[M4WriteVLDL,
902               M4WriteA1],   (instregex "LD3i64_POST$")>;
903
904 def : InstRW<[M4WriteVLDB], (instregex "LD3Rv(8b|4h|2s|1d)$")>;
905 def : InstRW<[M4WriteVLDB,
906               M4WriteA1],   (instregex "LD3Rv(8b|4h|2s|1d)_POST$")>;
907 def : InstRW<[M4WriteVLDB], (instregex "LD3Rv(16b|8h|4s|2d)$")>;
908 def : InstRW<[M4WriteVLDB,
909               M4WriteA1],   (instregex "LD3Rv(16b|8h|4s|2d)_POST$")>;
910
911 def : InstRW<[M4WriteVLDN], (instregex "LD4Fourv(8b|4h|2s)$")>;
912 def : InstRW<[M4WriteVLDN,
913               M4WriteA1],   (instregex "LD4Fourv(8b|4h|2s)_POST$")>;
914 def : InstRW<[M4WriteVLDN], (instregex "LD4Fourv(16b|8h|4s|2d)$")>;
915 def : InstRW<[M4WriteVLDN,
916               M4WriteA1],   (instregex "LD4Fourv(16b|8h|4s|2d)_POST$")>;
917
918 def : InstRW<[M4WriteVLDK], (instregex "LD4i(8|16|32)$")>;
919 def : InstRW<[M4WriteVLDK,
920               M4WriteA1],   (instregex "LD4i(8|16|32)_POST$")>;
921 def : InstRW<[M4WriteVLDM], (instregex "LD4i64$")>;
922 def : InstRW<[M4WriteVLDM,
923               M4WriteA1],   (instregex "LD4i64_POST$")>;
924
925 def : InstRW<[M4WriteVLDC], (instregex "LD4Rv(8b|4h|2s|1d)$")>;
926 def : InstRW<[M4WriteVLDC,
927               M4WriteA1],   (instregex "LD4Rv(8b|4h|2s|1d)_POST$")>;
928 def : InstRW<[M4WriteVLDC], (instregex "LD4Rv(16b|8h|4s|2d)$")>;
929 def : InstRW<[M4WriteVLDC,
930               M4WriteA1],   (instregex "LD4Rv(16b|8h|4s|2d)_POST$")>;
931
932 // ASIMD store instructions.
933 def : InstRW<[WriteVST],    (instregex "ST1Onev(8b|4h|2s|1d)$")>;
934 def : InstRW<[WriteVST,
935               M4WriteA1],   (instregex "ST1Onev(8b|4h|2s|1d)_POST$")>;
936 def : InstRW<[WriteVST],    (instregex "ST1Onev(16b|8h|4s|2d)$")>;
937 def : InstRW<[WriteVST,
938               M4WriteA1],   (instregex "ST1Onev(16b|8h|4s|2d)_POST$")>;
939
940 def : InstRW<[M4WriteVSTA], (instregex "ST1Twov(8b|4h|2s|1d)$")>;
941 def : InstRW<[M4WriteVSTA,
942               M4WriteA1],   (instregex "ST1Twov(8b|4h|2s|1d)_POST$")>;
943 def : InstRW<[M4WriteVSTA], (instregex "ST1Twov(16b|8h|4s|2d)$")>;
944 def : InstRW<[M4WriteVSTA,
945               M4WriteA1],   (instregex "ST1Twov(16b|8h|4s|2d)_POST$")>;
946
947 def : InstRW<[M4WriteVSTB], (instregex "ST1Threev(8b|4h|2s|1d)$")>;
948 def : InstRW<[M4WriteVSTB,
949               M4WriteA1],   (instregex "ST1Threev(8b|4h|2s|1d)_POST$")>;
950 def : InstRW<[M4WriteVSTB], (instregex "ST1Threev(16b|8h|4s|2d)$")>;
951 def : InstRW<[M4WriteVSTB,
952               M4WriteA1],   (instregex "ST1Threev(16b|8h|4s|2d)_POST$")>;
953
954 def : InstRW<[M4WriteVSTC], (instregex "ST1Fourv(8b|4h|2s|1d)$")>;
955 def : InstRW<[M4WriteVSTC,
956               M4WriteA1],   (instregex "ST1Fourv(8b|4h|2s|1d)_POST$")>;
957 def : InstRW<[M4WriteVSTC], (instregex "ST1Fourv(16b|8h|4s|2d)$")>;
958 def : InstRW<[M4WriteVSTC,
959               M4WriteA1],   (instregex "ST1Fourv(16b|8h|4s|2d)_POST$")>;
960
961 def : InstRW<[WriteVST],    (instregex "ST1i(8|16|32|64)$")>;
962 def : InstRW<[WriteVST,
963               M4WriteA1],   (instregex "ST1i(8|16|32|64)_POST$")>;
964
965 def : InstRW<[M4WriteVSTD], (instregex "ST2Twov(8b|4h|2s)$")>;
966 def : InstRW<[M4WriteVSTD,
967               M4WriteA1],   (instregex "ST2Twov(8b|4h|2s)_POST$")>;
968 def : InstRW<[M4WriteVSTE], (instregex "ST2Twov(16b|8h|4s|2d)$")>;
969 def : InstRW<[M4WriteVSTE,
970               M4WriteA1],   (instregex "ST2Twov(16b|8h|4s|2d)_POST$")>;
971
972 def : InstRW<[M4WriteVSTD], (instregex "ST2i(8|16|32|64)$")>;
973 def : InstRW<[M4WriteVSTD,
974               M4WriteA1],   (instregex "ST2i(8|16|32|64)_POST$")>;
975
976 def : InstRW<[M4WriteVSTF], (instregex "ST3Threev(8b|4h|2s)$")>;
977 def : InstRW<[M4WriteVSTF,
978               M4WriteA1],   (instregex "ST3Threev(8b|4h|2s)_POST$")>;
979 def : InstRW<[M4WriteVSTG], (instregex "ST3Threev(16b|8h|4s|2d)$")>;
980 def : InstRW<[M4WriteVSTG,
981               M4WriteA1],   (instregex "ST3Threev(16b|8h|4s|2d)_POST$")>;
982
983 def : InstRW<[M4WriteVSTE], (instregex "ST3i(8|16|32|64)$")>;
984 def : InstRW<[M4WriteVSTE,
985               M4WriteA1],   (instregex "ST3i(8|16|32|64)_POST$")>;
986
987 def : InstRW<[M4WriteVSTL], (instregex "ST4Fourv(8b|4h|2s)$")>;
988 def : InstRW<[M4WriteVSTL,
989               M4WriteA1],   (instregex "ST4Fourv(8b|4h|2s)_POST$")>;
990 def : InstRW<[M4WriteVSTI], (instregex "ST4Fourv(16b|8h|4s|2d)$")>;
991 def : InstRW<[M4WriteVSTI,
992               M4WriteA1],   (instregex "ST4Fourv(16b|8h|4s|2d)_POST$")>;
993
994 def : InstRW<[M4WriteVSTE], (instregex "ST4i(8|16|32|64)$")>;
995 def : InstRW<[M4WriteVSTE,
996               M4WriteA1],   (instregex "ST4i(8|16|32|64)_POST$")>;
997
998 // Cryptography instructions.
999 def : InstRW<[M4WriteNCRY1],  (instregex "^AES[DE]")>;
1000 def : InstRW<[M4WriteNCRY1,
1001               M4ReadAESM1],   (instregex "^AESI?MC")>;
1002 def : InstRW<[M4WriteNCRY1A], (instregex "^PMULv")>;
1003 def : InstRW<[M4WriteNCRY1A], (instregex "^PMULLv(1|8)i")>;
1004 def : InstRW<[M4WriteNCRY3A], (instregex "^PMULLv(2|16)i")>;
1005 def : InstRW<[M4WriteNCRY1A], (instregex "^SHA1([CHMP]|SU[01])")>;
1006 def : InstRW<[M4WriteNCRY1A], (instrs SHA256SU0rr)>;
1007 def : InstRW<[M4WriteNCRY5A], (instrs SHA256SU1rrr)>;
1008 def : InstRW<[M4WriteNCRY5A], (instrs SHA256H2rrr)>;
1009
1010 // CRC instructions.
1011 def : InstRW<[M4WriteE2], (instregex "^CRC32C?[BHWX]rr$")>;
1012
1013 } // SchedModel = ExynosM4Model