10b57cec5SDimitry Andric//===- AArch64SchedPredicates.td - AArch64 Sched Preds -----*- tablegen -*-===// 20b57cec5SDimitry Andric// 30b57cec5SDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 40b57cec5SDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 50b57cec5SDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 60b57cec5SDimitry Andric// 70b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 80b57cec5SDimitry Andric// 90b57cec5SDimitry Andric// This file defines scheduling predicate definitions that are used by the 100b57cec5SDimitry Andric// AArch64 subtargets. 110b57cec5SDimitry Andric// 120b57cec5SDimitry Andric//===----------------------------------------------------------------------===// 130b57cec5SDimitry Andric 140b57cec5SDimitry Andric// Function mappers. 150b57cec5SDimitry Andric 160b57cec5SDimitry Andric// Check the extension type in arithmetic instructions. 170b57cec5SDimitry Andriclet FunctionMapper = "AArch64_AM::getArithExtendType" in { 180b57cec5SDimitry Andric def CheckExtUXTB : CheckImmOperand_s<3, "AArch64_AM::UXTB">; 190b57cec5SDimitry Andric def CheckExtUXTH : CheckImmOperand_s<3, "AArch64_AM::UXTH">; 200b57cec5SDimitry Andric def CheckExtUXTW : CheckImmOperand_s<3, "AArch64_AM::UXTW">; 210b57cec5SDimitry Andric def CheckExtUXTX : CheckImmOperand_s<3, "AArch64_AM::UXTX">; 220b57cec5SDimitry Andric def CheckExtSXTB : CheckImmOperand_s<3, "AArch64_AM::SXTB">; 230b57cec5SDimitry Andric def CheckExtSXTH : CheckImmOperand_s<3, "AArch64_AM::SXTH">; 240b57cec5SDimitry Andric def CheckExtSXTW : CheckImmOperand_s<3, "AArch64_AM::SXTW">; 250b57cec5SDimitry Andric def CheckExtSXTX : CheckImmOperand_s<3, "AArch64_AM::SXTX">; 260b57cec5SDimitry Andric} 270b57cec5SDimitry Andric 280b57cec5SDimitry Andric// Check for shifting in extended arithmetic instructions. 290b57cec5SDimitry Andricforeach I = {0-3} in { 300b57cec5SDimitry Andric let FunctionMapper = "AArch64_AM::getArithShiftValue" in 310b57cec5SDimitry Andric def CheckExtBy#I : CheckImmOperand<3, I>; 320b57cec5SDimitry Andric} 330b57cec5SDimitry Andric 34*06c3fb27SDimitry Andric// Check for shifting in arithmetic and logic instructions. 35*06c3fb27SDimitry Andricforeach I = {0-4, 8} in { 36*06c3fb27SDimitry Andric let FunctionMapper = "AArch64_AM::getShiftValue" in 37*06c3fb27SDimitry Andric def CheckShiftBy#I : CheckImmOperand<3, I>; 38*06c3fb27SDimitry Andric} 39*06c3fb27SDimitry Andric 400b57cec5SDimitry Andric// Check the extension type in the register offset addressing mode. 410b57cec5SDimitry Andriclet FunctionMapper = "AArch64_AM::getMemExtendType" in { 420b57cec5SDimitry Andric def CheckMemExtUXTW : CheckImmOperand_s<3, "AArch64_AM::UXTW">; 430b57cec5SDimitry Andric def CheckMemExtLSL : CheckImmOperand_s<3, "AArch64_AM::UXTX">; 440b57cec5SDimitry Andric def CheckMemExtSXTW : CheckImmOperand_s<3, "AArch64_AM::SXTW">; 450b57cec5SDimitry Andric def CheckMemExtSXTX : CheckImmOperand_s<3, "AArch64_AM::SXTX">; 460b57cec5SDimitry Andric} 470b57cec5SDimitry Andric 480b57cec5SDimitry Andric// Check for scaling in the register offset addressing mode. 490b57cec5SDimitry Andriclet FunctionMapper = "AArch64_AM::getMemDoShift" in 50480093f4SDimitry Andricdef CheckMemScaled : CheckImmOperandSimple<4>; 510b57cec5SDimitry Andric 520b57cec5SDimitry Andric// Check the shifting type in arithmetic and logic instructions. 530b57cec5SDimitry Andriclet FunctionMapper = "AArch64_AM::getShiftType" in { 540b57cec5SDimitry Andric def CheckShiftLSL : CheckImmOperand_s<3, "AArch64_AM::LSL">; 550b57cec5SDimitry Andric def CheckShiftLSR : CheckImmOperand_s<3, "AArch64_AM::LSR">; 560b57cec5SDimitry Andric def CheckShiftASR : CheckImmOperand_s<3, "AArch64_AM::ASR">; 570b57cec5SDimitry Andric def CheckShiftROR : CheckImmOperand_s<3, "AArch64_AM::ROR">; 580b57cec5SDimitry Andric def CheckShiftMSL : CheckImmOperand_s<3, "AArch64_AM::MSL">; 590b57cec5SDimitry Andric} 600b57cec5SDimitry Andric 610b57cec5SDimitry Andric// Generic predicates. 62*06c3fb27SDimitry Andric 63*06c3fb27SDimitry Andric// Check for ZR in a register operand. 64*06c3fb27SDimitry Andricforeach I = {1-3} in { 65*06c3fb27SDimitry Andric def CheckIsReg#I#Zero : CheckAll< 66*06c3fb27SDimitry Andric [CheckIsRegOperand<I>, 67*06c3fb27SDimitry Andric CheckAny< 68*06c3fb27SDimitry Andric [CheckRegOperand<I, WZR>, 69*06c3fb27SDimitry Andric CheckRegOperand<I, XZR>]>]>; 70*06c3fb27SDimitry Andric} 71*06c3fb27SDimitry Andricdef IsReg1ZeroPred : MCSchedPredicate<CheckIsReg1Zero>; 72*06c3fb27SDimitry Andricdef IsReg2ZeroPred : MCSchedPredicate<CheckIsReg2Zero>; 73*06c3fb27SDimitry Andricdef IsReg3ZeroPred : MCSchedPredicate<CheckIsReg3Zero>; 74*06c3fb27SDimitry Andric 7581ad6265SDimitry Andric// Identify whether an instruction is NEON or floating point 7681ad6265SDimitry Andricdef CheckFpOrNEON : CheckFunctionPredicateWithTII< 7781ad6265SDimitry Andric "AArch64_MC::isFpOrNEON", 7881ad6265SDimitry Andric "AArch64InstrInfo::isFpOrNEON" 7981ad6265SDimitry Andric>; 800b57cec5SDimitry Andric 81*06c3fb27SDimitry Andric// Identify whether an instruction is the 16-bit NEON form based on its result. 82*06c3fb27SDimitry Andricdef CheckHForm : CheckFunctionPredicateWithTII< 83*06c3fb27SDimitry Andric "AArch64_MC::isHForm", 84*06c3fb27SDimitry Andric "AArch64InstrInfo::isHForm" 85*06c3fb27SDimitry Andric>; 86*06c3fb27SDimitry Andric 870b57cec5SDimitry Andric// Identify whether an instruction is the 128-bit NEON form based on its result. 8881ad6265SDimitry Andricdef CheckQForm : CheckFunctionPredicateWithTII< 8981ad6265SDimitry Andric "AArch64_MC::isQForm", 9081ad6265SDimitry Andric "AArch64InstrInfo::isQForm" 9181ad6265SDimitry Andric>; 920b57cec5SDimitry Andric 930b57cec5SDimitry Andric// Identify arithmetic instructions with extend. 940b57cec5SDimitry Andricdef IsArithExtOp : CheckOpcode<[ADDWrx, ADDXrx, ADDSWrx, ADDSXrx, 950b57cec5SDimitry Andric SUBWrx, SUBXrx, SUBSWrx, SUBSXrx, 960b57cec5SDimitry Andric ADDXrx64, ADDSXrx64, 970b57cec5SDimitry Andric SUBXrx64, SUBSXrx64]>; 980b57cec5SDimitry Andric 990b57cec5SDimitry Andric// Identify arithmetic immediate instructions. 1000b57cec5SDimitry Andricdef IsArithImmOp : CheckOpcode<[ADDWri, ADDXri, ADDSWri, ADDSXri, 1010b57cec5SDimitry Andric SUBWri, SUBXri, SUBSWri, SUBSXri]>; 1020b57cec5SDimitry Andric 1030b57cec5SDimitry Andric// Identify arithmetic instructions with shift. 1040b57cec5SDimitry Andricdef IsArithShiftOp : CheckOpcode<[ADDWrs, ADDXrs, ADDSWrs, ADDSXrs, 1050b57cec5SDimitry Andric SUBWrs, SUBXrs, SUBSWrs, SUBSXrs]>; 1060b57cec5SDimitry Andric 1070b57cec5SDimitry Andric// Identify arithmetic instructions without shift. 1080b57cec5SDimitry Andricdef IsArithUnshiftOp : CheckOpcode<[ADDWrr, ADDXrr, ADDSWrr, ADDSXrr, 1090b57cec5SDimitry Andric SUBWrr, SUBXrr, SUBSWrr, SUBSXrr]>; 1100b57cec5SDimitry Andric 1110b57cec5SDimitry Andric// Identify logic immediate instructions. 1120b57cec5SDimitry Andricdef IsLogicImmOp : CheckOpcode<[ANDWri, ANDXri, 1130b57cec5SDimitry Andric EORWri, EORXri, 1140b57cec5SDimitry Andric ORRWri, ORRXri]>; 1150b57cec5SDimitry Andric 1160b57cec5SDimitry Andric// Identify logic instructions with shift. 1170b57cec5SDimitry Andricdef IsLogicShiftOp : CheckOpcode<[ANDWrs, ANDXrs, ANDSWrs, ANDSXrs, 1180b57cec5SDimitry Andric BICWrs, BICXrs, BICSWrs, BICSXrs, 1190b57cec5SDimitry Andric EONWrs, EONXrs, 1200b57cec5SDimitry Andric EORWrs, EORXrs, 1210b57cec5SDimitry Andric ORNWrs, ORNXrs, 1220b57cec5SDimitry Andric ORRWrs, ORRXrs]>; 1230b57cec5SDimitry Andric 1240b57cec5SDimitry Andric// Identify logic instructions without shift. 1250b57cec5SDimitry Andricdef IsLogicUnshiftOp : CheckOpcode<[ANDWrr, ANDXrr, ANDSWrr, ANDSXrr, 1260b57cec5SDimitry Andric BICWrr, BICXrr, BICSWrr, BICSXrr, 1270b57cec5SDimitry Andric EONWrr, EONXrr, 1280b57cec5SDimitry Andric EORWrr, EORXrr, 1290b57cec5SDimitry Andric ORNWrr, ORNXrr, 1300b57cec5SDimitry Andric ORRWrr, ORRXrr]>; 1310b57cec5SDimitry Andric 1320b57cec5SDimitry Andric// Identify arithmetic and logic immediate instructions. 1330b57cec5SDimitry Andricdef IsArithLogicImmOp : CheckOpcode<!listconcat(IsArithImmOp.ValidOpcodes, 1340b57cec5SDimitry Andric IsLogicImmOp.ValidOpcodes)>; 1350b57cec5SDimitry Andric 1360b57cec5SDimitry Andric// Identify arithmetic and logic instructions with shift. 1370b57cec5SDimitry Andricdef IsArithLogicShiftOp : CheckOpcode<!listconcat(IsArithShiftOp.ValidOpcodes, 1380b57cec5SDimitry Andric IsLogicShiftOp.ValidOpcodes)>; 1390b57cec5SDimitry Andric 1400b57cec5SDimitry Andric// Identify arithmetic and logic instructions without shift. 1410b57cec5SDimitry Andricdef IsArithLogicUnshiftOp : CheckOpcode<!listconcat(IsArithUnshiftOp.ValidOpcodes, 1420b57cec5SDimitry Andric IsLogicUnshiftOp.ValidOpcodes)>; 1430b57cec5SDimitry Andric 1440b57cec5SDimitry Andric// Identify whether an instruction is an ASIMD 1450b57cec5SDimitry Andric// load using the post index addressing mode. 1460b57cec5SDimitry Andricdef IsLoadASIMDPostOp : CheckOpcode<[LD1Onev8b_POST, LD1Onev4h_POST, LD1Onev2s_POST, LD1Onev1d_POST, 1470b57cec5SDimitry Andric LD1Onev16b_POST, LD1Onev8h_POST, LD1Onev4s_POST, LD1Onev2d_POST, 1480b57cec5SDimitry Andric LD1Twov8b_POST, LD1Twov4h_POST, LD1Twov2s_POST, LD1Twov1d_POST, 1490b57cec5SDimitry Andric LD1Twov16b_POST, LD1Twov8h_POST, LD1Twov4s_POST, LD1Twov2d_POST, 1500b57cec5SDimitry Andric LD1Threev8b_POST, LD1Threev4h_POST, LD1Threev2s_POST, LD1Threev1d_POST, 1510b57cec5SDimitry Andric LD1Threev16b_POST, LD1Threev8h_POST, LD1Threev4s_POST, LD1Threev2d_POST, 1520b57cec5SDimitry Andric LD1Fourv8b_POST, LD1Fourv4h_POST, LD1Fourv2s_POST, LD1Fourv1d_POST, 1530b57cec5SDimitry Andric LD1Fourv16b_POST, LD1Fourv8h_POST, LD1Fourv4s_POST, LD1Fourv2d_POST, 1540b57cec5SDimitry Andric LD1i8_POST, LD1i16_POST, LD1i32_POST, LD1i64_POST, 1550b57cec5SDimitry Andric LD1Rv8b_POST, LD1Rv4h_POST, LD1Rv2s_POST, LD1Rv1d_POST, 1560b57cec5SDimitry Andric LD1Rv16b_POST, LD1Rv8h_POST, LD1Rv4s_POST, LD1Rv2d_POST, 1570b57cec5SDimitry Andric LD2Twov8b_POST, LD2Twov4h_POST, LD2Twov2s_POST, 1580b57cec5SDimitry Andric LD2Twov16b_POST, LD2Twov8h_POST, LD2Twov4s_POST, LD2Twov2d_POST, 1590b57cec5SDimitry Andric LD2i8_POST, LD2i16_POST, LD2i32_POST, LD2i64_POST, 1600b57cec5SDimitry Andric LD2Rv8b_POST, LD2Rv4h_POST, LD2Rv2s_POST, LD2Rv1d_POST, 1610b57cec5SDimitry Andric LD2Rv16b_POST, LD2Rv8h_POST, LD2Rv4s_POST, LD2Rv2d_POST, 1620b57cec5SDimitry Andric LD3Threev8b_POST, LD3Threev4h_POST, LD3Threev2s_POST, 1630b57cec5SDimitry Andric LD3Threev16b_POST, LD3Threev8h_POST, LD3Threev4s_POST, LD3Threev2d_POST, 1640b57cec5SDimitry Andric LD3i8_POST, LD3i16_POST, LD3i32_POST, LD3i64_POST, 1650b57cec5SDimitry Andric LD3Rv8b_POST, LD3Rv4h_POST, LD3Rv2s_POST, LD3Rv1d_POST, 1660b57cec5SDimitry Andric LD3Rv16b_POST, LD3Rv8h_POST, LD3Rv4s_POST, LD3Rv2d_POST, 1670b57cec5SDimitry Andric LD4Fourv8b_POST, LD4Fourv4h_POST, LD4Fourv2s_POST, 1680b57cec5SDimitry Andric LD4Fourv16b_POST, LD4Fourv8h_POST, LD4Fourv4s_POST, LD4Fourv2d_POST, 1690b57cec5SDimitry Andric LD4i8_POST, LD4i16_POST, LD4i32_POST, LD4i64_POST, 1700b57cec5SDimitry Andric LD4Rv8b_POST, LD4Rv4h_POST, LD4Rv2s_POST, LD4Rv1d_POST, 1710b57cec5SDimitry Andric LD4Rv16b_POST, LD4Rv8h_POST, LD4Rv4s_POST, LD4Rv2d_POST]>; 1720b57cec5SDimitry Andric 1730b57cec5SDimitry Andric// Identify whether an instruction is an ASIMD 1740b57cec5SDimitry Andric// store using the post index addressing mode. 1750b57cec5SDimitry Andricdef IsStoreASIMDPostOp : CheckOpcode<[ST1Onev8b_POST, ST1Onev4h_POST, ST1Onev2s_POST, ST1Onev1d_POST, 1760b57cec5SDimitry Andric ST1Onev16b_POST, ST1Onev8h_POST, ST1Onev4s_POST, ST1Onev2d_POST, 1770b57cec5SDimitry Andric ST1Twov8b_POST, ST1Twov4h_POST, ST1Twov2s_POST, ST1Twov1d_POST, 1780b57cec5SDimitry Andric ST1Twov16b_POST, ST1Twov8h_POST, ST1Twov4s_POST, ST1Twov2d_POST, 1790b57cec5SDimitry Andric ST1Threev8b_POST, ST1Threev4h_POST, ST1Threev2s_POST, ST1Threev1d_POST, 1800b57cec5SDimitry Andric ST1Threev16b_POST, ST1Threev8h_POST, ST1Threev4s_POST, ST1Threev2d_POST, 1810b57cec5SDimitry Andric ST1Fourv8b_POST, ST1Fourv4h_POST, ST1Fourv2s_POST, ST1Fourv1d_POST, 1820b57cec5SDimitry Andric ST1Fourv16b_POST, ST1Fourv8h_POST, ST1Fourv4s_POST, ST1Fourv2d_POST, 1830b57cec5SDimitry Andric ST1i8_POST, ST1i16_POST, ST1i32_POST, ST1i64_POST, 1840b57cec5SDimitry Andric ST2Twov8b_POST, ST2Twov4h_POST, ST2Twov2s_POST, 1850b57cec5SDimitry Andric ST2Twov16b_POST, ST2Twov8h_POST, ST2Twov4s_POST, ST2Twov2d_POST, 1860b57cec5SDimitry Andric ST2i8_POST, ST2i16_POST, ST2i32_POST, ST2i64_POST, 1870b57cec5SDimitry Andric ST3Threev8b_POST, ST3Threev4h_POST, ST3Threev2s_POST, 1880b57cec5SDimitry Andric ST3Threev16b_POST, ST3Threev8h_POST, ST3Threev4s_POST, ST3Threev2d_POST, 1890b57cec5SDimitry Andric ST3i8_POST, ST3i16_POST, ST3i32_POST, ST3i64_POST, 1900b57cec5SDimitry Andric ST4Fourv8b_POST, ST4Fourv4h_POST, ST4Fourv2s_POST, 1910b57cec5SDimitry Andric ST4Fourv16b_POST, ST4Fourv8h_POST, ST4Fourv4s_POST, ST4Fourv2d_POST, 1920b57cec5SDimitry Andric ST4i8_POST, ST4i16_POST, ST4i32_POST, ST4i64_POST]>; 1930b57cec5SDimitry Andric 1940b57cec5SDimitry Andric// Identify whether an instruction is an ASIMD load 1950b57cec5SDimitry Andric// or store using the post index addressing mode. 1960b57cec5SDimitry Andricdef IsLoadStoreASIMDPostOp : CheckOpcode<!listconcat(IsLoadASIMDPostOp.ValidOpcodes, 1970b57cec5SDimitry Andric IsStoreASIMDPostOp.ValidOpcodes)>; 1980b57cec5SDimitry Andric 1990b57cec5SDimitry Andric// Identify whether an instruction is a load 2000b57cec5SDimitry Andric// using the register offset addressing mode. 2010b57cec5SDimitry Andricdef IsLoadRegOffsetOp : CheckOpcode<[PRFMroW, PRFMroX, 2020b57cec5SDimitry Andric LDRBBroW, LDRBBroX, 2030b57cec5SDimitry Andric LDRSBWroW, LDRSBWroX, LDRSBXroW, LDRSBXroX, 2040b57cec5SDimitry Andric LDRHHroW, LDRHHroX, 2050b57cec5SDimitry Andric LDRSHWroW, LDRSHWroX, LDRSHXroW, LDRSHXroX, 2060b57cec5SDimitry Andric LDRWroW, LDRWroX, 2070b57cec5SDimitry Andric LDRSWroW, LDRSWroX, 2080b57cec5SDimitry Andric LDRXroW, LDRXroX, 2090b57cec5SDimitry Andric LDRBroW, LDRBroX, 2100b57cec5SDimitry Andric LDRHroW, LDRHroX, 2110b57cec5SDimitry Andric LDRSroW, LDRSroX, 212480093f4SDimitry Andric LDRDroW, LDRDroX, 213480093f4SDimitry Andric LDRQroW, LDRQroX]>; 2140b57cec5SDimitry Andric 215480093f4SDimitry Andric// Identify whether an instruction is a store 2160b57cec5SDimitry Andric// using the register offset addressing mode. 2170b57cec5SDimitry Andricdef IsStoreRegOffsetOp : CheckOpcode<[STRBBroW, STRBBroX, 2180b57cec5SDimitry Andric STRHHroW, STRHHroX, 2190b57cec5SDimitry Andric STRWroW, STRWroX, 2200b57cec5SDimitry Andric STRXroW, STRXroX, 2210b57cec5SDimitry Andric STRBroW, STRBroX, 2220b57cec5SDimitry Andric STRHroW, STRHroX, 2230b57cec5SDimitry Andric STRSroW, STRSroX, 224480093f4SDimitry Andric STRDroW, STRDroX, 225480093f4SDimitry Andric STRQroW, STRQroX]>; 2260b57cec5SDimitry Andric 2270b57cec5SDimitry Andric// Identify whether an instruction is a load or 2280b57cec5SDimitry Andric// store using the register offset addressing mode. 2290b57cec5SDimitry Andricdef IsLoadStoreRegOffsetOp : CheckOpcode<!listconcat(IsLoadRegOffsetOp.ValidOpcodes, 2300b57cec5SDimitry Andric IsStoreRegOffsetOp.ValidOpcodes)>; 2310b57cec5SDimitry Andric 2320b57cec5SDimitry Andric// Target predicates. 2330b57cec5SDimitry Andric 2340b57cec5SDimitry Andric// Identify arithmetic instructions with an extended register. 2350b57cec5SDimitry Andricdef RegExtendedFn : TIIPredicate<"hasExtendedReg", 2360b57cec5SDimitry Andric MCOpcodeSwitchStatement< 2370b57cec5SDimitry Andric [MCOpcodeSwitchCase< 2380b57cec5SDimitry Andric IsArithExtOp.ValidOpcodes, 2390b57cec5SDimitry Andric MCReturnStatement< 2400b57cec5SDimitry Andric CheckNot<CheckZeroOperand<3>>>>], 2410b57cec5SDimitry Andric MCReturnStatement<FalsePred>>>; 2420b57cec5SDimitry Andricdef RegExtendedPred : MCSchedPredicate<RegExtendedFn>; 2430b57cec5SDimitry Andric 2440b57cec5SDimitry Andric// Identify arithmetic and logic instructions with a shifted register. 2450b57cec5SDimitry Andricdef RegShiftedFn : TIIPredicate<"hasShiftedReg", 2460b57cec5SDimitry Andric MCOpcodeSwitchStatement< 2470b57cec5SDimitry Andric [MCOpcodeSwitchCase< 2480b57cec5SDimitry Andric IsArithLogicShiftOp.ValidOpcodes, 2490b57cec5SDimitry Andric MCReturnStatement< 2500b57cec5SDimitry Andric CheckNot<CheckZeroOperand<3>>>>], 2510b57cec5SDimitry Andric MCReturnStatement<FalsePred>>>; 2520b57cec5SDimitry Andricdef RegShiftedPred : MCSchedPredicate<RegShiftedFn>; 2530b57cec5SDimitry Andric 2540b57cec5SDimitry Andric// Identify a load or store using the register offset addressing mode 2550b57cec5SDimitry Andric// with an extended or scaled register. 2560b57cec5SDimitry Andricdef ScaledIdxFn : TIIPredicate<"isScaledAddr", 2570b57cec5SDimitry Andric MCOpcodeSwitchStatement< 2580b57cec5SDimitry Andric [MCOpcodeSwitchCase< 2590b57cec5SDimitry Andric IsLoadStoreRegOffsetOp.ValidOpcodes, 2600b57cec5SDimitry Andric MCReturnStatement< 2610b57cec5SDimitry Andric CheckAny<[CheckNot<CheckMemExtLSL>, 2620b57cec5SDimitry Andric CheckMemScaled]>>>], 2630b57cec5SDimitry Andric MCReturnStatement<FalsePred>>>; 2640b57cec5SDimitry Andricdef ScaledIdxPred : MCSchedPredicate<ScaledIdxFn>; 2650b57cec5SDimitry Andric 266*06c3fb27SDimitry Andric// Special cases. 267*06c3fb27SDimitry Andric 268*06c3fb27SDimitry Andric// Check for LSL shift <= 4 269*06c3fb27SDimitry Andricdef IsCheapLSL : MCSchedPredicate< 270*06c3fb27SDimitry Andric CheckAll< 271*06c3fb27SDimitry Andric [CheckShiftLSL, 272*06c3fb27SDimitry Andric CheckAny< 273*06c3fb27SDimitry Andric [CheckShiftBy0, 274*06c3fb27SDimitry Andric CheckShiftBy1, 275*06c3fb27SDimitry Andric CheckShiftBy2, 276*06c3fb27SDimitry Andric CheckShiftBy3, 277*06c3fb27SDimitry Andric CheckShiftBy4]>]>>; 278*06c3fb27SDimitry Andric 279*06c3fb27SDimitry Andric// Idioms. 280*06c3fb27SDimitry Andric 281*06c3fb27SDimitry Andric// Identify an instruction that effectively transfers a register to another. 282*06c3fb27SDimitry Andricdef IsCopyIdiomFn : TIIPredicate<"isCopyIdiom", 283*06c3fb27SDimitry Andric MCOpcodeSwitchStatement< 284*06c3fb27SDimitry Andric [// MOV {Rd, SP}, {SP, Rn} => 285*06c3fb27SDimitry Andric // ADD {Rd, SP}, {SP, Rn}, #0 286*06c3fb27SDimitry Andric MCOpcodeSwitchCase< 287*06c3fb27SDimitry Andric [ADDWri, ADDXri], 288*06c3fb27SDimitry Andric MCReturnStatement< 289*06c3fb27SDimitry Andric CheckAll< 290*06c3fb27SDimitry Andric [CheckIsRegOperand<0>, 291*06c3fb27SDimitry Andric CheckIsRegOperand<1>, 292*06c3fb27SDimitry Andric CheckAny< 293*06c3fb27SDimitry Andric [CheckRegOperand<0, WSP>, 294*06c3fb27SDimitry Andric CheckRegOperand<0, SP>, 295*06c3fb27SDimitry Andric CheckRegOperand<1, WSP>, 296*06c3fb27SDimitry Andric CheckRegOperand<1, SP>]>, 297*06c3fb27SDimitry Andric CheckZeroOperand<2>]>>>, 298*06c3fb27SDimitry Andric // MOV Rd, Rm => 299*06c3fb27SDimitry Andric // ORR Rd, ZR, Rm, LSL #0 300*06c3fb27SDimitry Andric MCOpcodeSwitchCase< 301*06c3fb27SDimitry Andric [ORRWrs, ORRXrs], 302*06c3fb27SDimitry Andric MCReturnStatement< 303*06c3fb27SDimitry Andric CheckAll< 304*06c3fb27SDimitry Andric [CheckIsReg1Zero, 305*06c3fb27SDimitry Andric CheckIsRegOperand<2>, 306*06c3fb27SDimitry Andric CheckShiftBy0]>>>], 307*06c3fb27SDimitry Andric MCReturnStatement<FalsePred>>>; 308*06c3fb27SDimitry Andricdef IsCopyIdiomPred : MCSchedPredicate<IsCopyIdiomFn>; 309*06c3fb27SDimitry Andric 310*06c3fb27SDimitry Andric// Identify an instruction that effectively resets a GP register to zero. 311*06c3fb27SDimitry Andricdef IsZeroIdiomFn : TIIPredicate<"isZeroIdiom", 312*06c3fb27SDimitry Andric MCOpcodeSwitchStatement< 313*06c3fb27SDimitry Andric [// ORR Rd, ZR, #0 314*06c3fb27SDimitry Andric MCOpcodeSwitchCase< 315*06c3fb27SDimitry Andric [ORRWri, ORRXri], 316*06c3fb27SDimitry Andric MCReturnStatement< 317*06c3fb27SDimitry Andric CheckAll< 318*06c3fb27SDimitry Andric [CheckIsReg1Zero, 319*06c3fb27SDimitry Andric CheckZeroOperand<2>]>>>], 320*06c3fb27SDimitry Andric MCReturnStatement<FalsePred>>>; 321*06c3fb27SDimitry Andricdef IsZeroIdiomPred : MCSchedPredicate<IsZeroIdiomFn>; 322*06c3fb27SDimitry Andric 3230b57cec5SDimitry Andric// Identify an instruction that effectively resets a FP register to zero. 3240b57cec5SDimitry Andricdef IsZeroFPIdiomFn : TIIPredicate<"isZeroFPIdiom", 3250b57cec5SDimitry Andric MCOpcodeSwitchStatement< 3260b57cec5SDimitry Andric [// MOVI Vd, #0 3270b57cec5SDimitry Andric MCOpcodeSwitchCase< 3280b57cec5SDimitry Andric [MOVIv8b_ns, MOVIv16b_ns, 3290b57cec5SDimitry Andric MOVID, MOVIv2d_ns], 3300b57cec5SDimitry Andric MCReturnStatement<CheckZeroOperand<1>>>, 3310b57cec5SDimitry Andric // MOVI Vd, #0, LSL #0 3320b57cec5SDimitry Andric MCOpcodeSwitchCase< 3330b57cec5SDimitry Andric [MOVIv4i16, MOVIv8i16, 3340b57cec5SDimitry Andric MOVIv2i32, MOVIv4i32], 3350b57cec5SDimitry Andric MCReturnStatement< 3360b57cec5SDimitry Andric CheckAll< 3370b57cec5SDimitry Andric [CheckZeroOperand<1>, 3380b57cec5SDimitry Andric CheckZeroOperand<2>]>>>], 3390b57cec5SDimitry Andric MCReturnStatement<FalsePred>>>; 3400b57cec5SDimitry Andricdef IsZeroFPIdiomPred : MCSchedPredicate<IsZeroFPIdiomFn>; 3410b57cec5SDimitry Andric 342*06c3fb27SDimitry Andric// Identify EXTR as the alias for ROR (immediate). 343*06c3fb27SDimitry Andricdef IsRORImmIdiomPred : MCSchedPredicate< // EXTR Rd, Rs, Rs, #Imm 344*06c3fb27SDimitry Andric CheckAll<[CheckOpcode<[EXTRWrri, EXTRXrri]>, 345*06c3fb27SDimitry Andric CheckSameRegOperand<1, 2>]>>; 346