@@ -31,6 +31,12 @@ foreach I = {0-3} in {
31
31
def CheckExtBy#I : CheckImmOperand<3, I>;
32
32
}
33
33
34
+ // Check for shifting in arithmetic and logic instructions.
35
+ foreach I = {0-4, 8} in {
36
+ let FunctionMapper = "AArch64_AM::getShiftValue" in
37
+ def CheckShiftBy#I : CheckImmOperand<3, I>;
38
+ }
39
+
34
40
// Check the extension type in the register offset addressing mode.
35
41
let FunctionMapper = "AArch64_AM::getMemExtendType" in {
36
42
def CheckMemExtUXTW : CheckImmOperand_s<3, "AArch64_AM::UXTW">;
@@ -52,12 +58,6 @@ let FunctionMapper = "AArch64_AM::getShiftType" in {
52
58
def CheckShiftMSL : CheckImmOperand_s<3, "AArch64_AM::MSL">;
53
59
}
54
60
55
- // Check for shifting in arithmetic and logic instructions.
56
- foreach I = {0-4, 8} in {
57
- let FunctionMapper = "AArch64_AM::getShiftValue" in
58
- def CheckShiftBy#I : CheckImmOperand<3, I>;
59
- }
60
-
61
61
// Generic predicates.
62
62
// Identify whether an instruction is NEON or floating point
63
63
def CheckFpOrNEON : CheckFunctionPredicateWithTII<
@@ -218,38 +218,6 @@ def IsLoadStoreRegOffsetOp : CheckOpcode<!listconcat(IsLoadRegOffsetOp.ValidOpco
218
218
219
219
// Target predicates.
220
220
221
- // Identify an instruction that effectively transfers a register to another.
222
- def IsCopyIdiomFn : TIIPredicate<"isCopyIdiom",
223
- MCOpcodeSwitchStatement<
224
- [// MOV {Rd, SP}, {SP, Rn} =>
225
- // ADD {Rd, SP}, {SP, Rn}, #0
226
- MCOpcodeSwitchCase<
227
- [ADDWri, ADDXri],
228
- MCReturnStatement<
229
- CheckAll<
230
- [CheckIsRegOperand<0>,
231
- CheckIsRegOperand<1>,
232
- CheckAny<
233
- [CheckRegOperand<0, WSP>,
234
- CheckRegOperand<0, SP>,
235
- CheckRegOperand<1, WSP>,
236
- CheckRegOperand<1, SP>]>,
237
- CheckZeroOperand<2>]>>>,
238
- // MOV Rd, Rm =>
239
- // ORR Rd, ZR, Rm, LSL #0
240
- MCOpcodeSwitchCase<
241
- [ORRWrs, ORRXrs],
242
- MCReturnStatement<
243
- CheckAll<
244
- [CheckIsRegOperand<1>,
245
- CheckIsRegOperand<2>,
246
- CheckAny<
247
- [CheckRegOperand<1, WZR>,
248
- CheckRegOperand<1, XZR>]>,
249
- CheckShiftBy0]>>>],
250
- MCReturnStatement<FalsePred>>>;
251
- def IsCopyIdiomPred : MCSchedPredicate<IsCopyIdiomFn>;
252
-
253
221
// Identify arithmetic instructions with an extended register.
254
222
def RegExtendedFn : TIIPredicate<"hasExtendedReg",
255
223
MCOpcodeSwitchStatement<
@@ -282,24 +250,52 @@ def ScaledIdxFn : TIIPredicate<"isScaledAddr",
282
250
MCReturnStatement<FalsePred>>>;
283
251
def ScaledIdxPred : MCSchedPredicate<ScaledIdxFn>;
284
252
285
- // Identify an instruction that effectively resets a FP register to zero.
286
- def IsZeroFPIdiomFn : TIIPredicate<"isZeroFPIdiom",
253
+ // Special cases.
254
+
255
+ // Check for LSL shift <= 4
256
+ def IsCheapLSL : MCSchedPredicate<
257
+ CheckAll<
258
+ [CheckShiftLSL,
259
+ CheckAny<
260
+ [CheckShiftBy0,
261
+ CheckShiftBy1,
262
+ CheckShiftBy2,
263
+ CheckShiftBy3,
264
+ CheckShiftBy4]>]>>;
265
+
266
+ // Idioms.
267
+
268
+ // Identify an instruction that effectively transfers a register to another.
269
+ def IsCopyIdiomFn : TIIPredicate<"isCopyIdiom",
287
270
MCOpcodeSwitchStatement<
288
- [// MOVI Vd, #0
271
+ [// MOV {Rd, SP}, {SP, Rn} =>
272
+ // ADD {Rd, SP}, {SP, Rn}, #0
289
273
MCOpcodeSwitchCase<
290
- [MOVIv8b_ns, MOVIv16b_ns,
291
- MOVID, MOVIv2d_ns],
292
- MCReturnStatement<CheckZeroOperand<1>>>,
293
- // MOVI Vd, #0, LSL #0
274
+ [ADDWri, ADDXri],
275
+ MCReturnStatement<
276
+ CheckAll<
277
+ [CheckIsRegOperand<0>,
278
+ CheckIsRegOperand<1>,
279
+ CheckAny<
280
+ [CheckRegOperand<0, WSP>,
281
+ CheckRegOperand<0, SP>,
282
+ CheckRegOperand<1, WSP>,
283
+ CheckRegOperand<1, SP>]>,
284
+ CheckZeroOperand<2>]>>>,
285
+ // MOV Rd, Rm =>
286
+ // ORR Rd, ZR, Rm, LSL #0
294
287
MCOpcodeSwitchCase<
295
- [MOVIv4i16, MOVIv8i16,
296
- MOVIv2i32, MOVIv4i32],
288
+ [ORRWrs, ORRXrs],
297
289
MCReturnStatement<
298
290
CheckAll<
299
- [CheckZeroOperand<1>,
300
- CheckZeroOperand<2>]>>>],
291
+ [CheckIsRegOperand<1>,
292
+ CheckIsRegOperand<2>,
293
+ CheckAny<
294
+ [CheckRegOperand<1, WZR>,
295
+ CheckRegOperand<1, XZR>]>,
296
+ CheckShiftBy0]>>>],
301
297
MCReturnStatement<FalsePred>>>;
302
- def IsZeroFPIdiomPred : MCSchedPredicate<IsZeroFPIdiomFn >;
298
+ def IsCopyIdiomPred : MCSchedPredicate<IsCopyIdiomFn >;
303
299
304
300
// Identify an instruction that effectively resets a GP register to zero.
305
301
def IsZeroIdiomFn : TIIPredicate<"isZeroIdiom",
@@ -317,6 +313,25 @@ def IsZeroIdiomFn : TIIPredicate<"isZeroIdiom",
317
313
MCReturnStatement<FalsePred>>>;
318
314
def IsZeroIdiomPred : MCSchedPredicate<IsZeroIdiomFn>;
319
315
316
+ // Identify an instruction that effectively resets a FP register to zero.
317
+ def IsZeroFPIdiomFn : TIIPredicate<"isZeroFPIdiom",
318
+ MCOpcodeSwitchStatement<
319
+ [// MOVI Vd, #0
320
+ MCOpcodeSwitchCase<
321
+ [MOVIv8b_ns, MOVIv16b_ns,
322
+ MOVID, MOVIv2d_ns],
323
+ MCReturnStatement<CheckZeroOperand<1>>>,
324
+ // MOVI Vd, #0, LSL #0
325
+ MCOpcodeSwitchCase<
326
+ [MOVIv4i16, MOVIv8i16,
327
+ MOVIv2i32, MOVIv4i32],
328
+ MCReturnStatement<
329
+ CheckAll<
330
+ [CheckZeroOperand<1>,
331
+ CheckZeroOperand<2>]>>>],
332
+ MCReturnStatement<FalsePred>>>;
333
+ def IsZeroFPIdiomPred : MCSchedPredicate<IsZeroFPIdiomFn>;
334
+
320
335
// Identify EXTR as the alias for ROR (immediate).
321
336
def IsRORImmIdiomPred : MCSchedPredicate<
322
337
CheckAll<[CheckOpcode<[EXTRWrri, EXTRXrri]>,
0 commit comments