@@ -2440,11 +2440,10 @@ bool AArch64InstrInfo::isFPRCopy(const MachineInstr &MI) {
24402440 return false ;
24412441}
24422442
2443- Register AArch64InstrInfo::isLoadFromStackSlot (const MachineInstr &MI,
2444- int &FrameIndex) const {
2445- switch (MI.getOpcode ()) {
2443+ static bool isFrameLoadOpcode (int Opcode) {
2444+ switch (Opcode) {
24462445 default :
2447- break ;
2446+ return false ;
24482447 case AArch64::LDRWui:
24492448 case AArch64::LDRXui:
24502449 case AArch64::LDRBui:
@@ -2453,22 +2452,27 @@ Register AArch64InstrInfo::isLoadFromStackSlot(const MachineInstr &MI,
24532452 case AArch64::LDRDui:
24542453 case AArch64::LDRQui:
24552454 case AArch64::LDR_PXI:
2456- if (MI.getOperand (0 ).getSubReg () == 0 && MI.getOperand (1 ).isFI () &&
2457- MI.getOperand (2 ).isImm () && MI.getOperand (2 ).getImm () == 0 ) {
2458- FrameIndex = MI.getOperand (1 ).getIndex ();
2459- return MI.getOperand (0 ).getReg ();
2460- }
2461- break ;
2455+ return true ;
24622456 }
2457+ }
2458+
2459+ Register AArch64InstrInfo::isLoadFromStackSlot (const MachineInstr &MI,
2460+ int &FrameIndex) const {
2461+ if (!isFrameLoadOpcode (MI.getOpcode ()))
2462+ return Register ();
24632463
2464- return 0 ;
2464+ if (MI.getOperand (0 ).getSubReg () == 0 && MI.getOperand (1 ).isFI () &&
2465+ MI.getOperand (2 ).isImm () && MI.getOperand (2 ).getImm () == 0 ) {
2466+ FrameIndex = MI.getOperand (1 ).getIndex ();
2467+ return MI.getOperand (0 ).getReg ();
2468+ }
2469+ return Register ();
24652470}
24662471
2467- Register AArch64InstrInfo::isStoreToStackSlot (const MachineInstr &MI,
2468- int &FrameIndex) const {
2469- switch (MI.getOpcode ()) {
2472+ static bool isFrameStoreOpcode (int Opcode) {
2473+ switch (Opcode) {
24702474 default :
2471- break ;
2475+ return false ;
24722476 case AArch64::STRWui:
24732477 case AArch64::STRXui:
24742478 case AArch64::STRBui:
@@ -2477,14 +2481,57 @@ Register AArch64InstrInfo::isStoreToStackSlot(const MachineInstr &MI,
24772481 case AArch64::STRDui:
24782482 case AArch64::STRQui:
24792483 case AArch64::STR_PXI:
2480- if (MI.getOperand (0 ).getSubReg () == 0 && MI.getOperand (1 ).isFI () &&
2481- MI.getOperand (2 ).isImm () && MI.getOperand (2 ).getImm () == 0 ) {
2482- FrameIndex = MI.getOperand (1 ).getIndex ();
2483- return MI.getOperand (0 ).getReg ();
2484- }
2485- break ;
2484+ return true ;
24862485 }
2487- return 0 ;
2486+ }
2487+
2488+ Register AArch64InstrInfo::isStoreToStackSlot (const MachineInstr &MI,
2489+ int &FrameIndex) const {
2490+ if (!isFrameStoreOpcode (MI.getOpcode ()))
2491+ return Register ();
2492+
2493+ if (MI.getOperand (0 ).getSubReg () == 0 && MI.getOperand (1 ).isFI () &&
2494+ MI.getOperand (2 ).isImm () && MI.getOperand (2 ).getImm () == 0 ) {
2495+ FrameIndex = MI.getOperand (1 ).getIndex ();
2496+ return MI.getOperand (0 ).getReg ();
2497+ }
2498+ return Register ();
2499+ }
2500+
2501+ Register AArch64InstrInfo::isStoreToStackSlotPostFE (const MachineInstr &MI,
2502+ int &FrameIndex) const {
2503+ if (!isFrameStoreOpcode (MI.getOpcode ()))
2504+ return Register ();
2505+
2506+ if (Register Reg = isStoreToStackSlot (MI, FrameIndex))
2507+ return Reg;
2508+
2509+ SmallVector<const MachineMemOperand *, 1 > Accesses;
2510+ if (hasStoreToStackSlot (MI, Accesses)) {
2511+ FrameIndex =
2512+ cast<FixedStackPseudoSourceValue>(Accesses.front ()->getPseudoValue ())
2513+ ->getFrameIndex ();
2514+ return MI.getOperand (0 ).getReg ();
2515+ }
2516+ return Register ();
2517+ }
2518+
2519+ Register AArch64InstrInfo::isLoadFromStackSlotPostFE (const MachineInstr &MI,
2520+ int &FrameIndex) const {
2521+ if (!isFrameLoadOpcode (MI.getOpcode ()))
2522+ return Register ();
2523+
2524+ if (Register Reg = isLoadFromStackSlot (MI, FrameIndex))
2525+ return Reg;
2526+
2527+ SmallVector<const MachineMemOperand *, 1 > Accesses;
2528+ if (hasLoadFromStackSlot (MI, Accesses)) {
2529+ FrameIndex =
2530+ cast<FixedStackPseudoSourceValue>(Accesses.front ()->getPseudoValue ())
2531+ ->getFrameIndex ();
2532+ return MI.getOperand (0 ).getReg ();
2533+ }
2534+ return Register ();
24882535}
24892536
24902537// / Check all MachineMemOperands for a hint to suppress pairing.
0 commit comments