1*572fc7d2SAndre Vieira //===- AArch64MachineScheduler.cpp - MI Scheduler for AArch64 -------------===//
2*572fc7d2SAndre Vieira //
3*572fc7d2SAndre Vieira // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*572fc7d2SAndre Vieira // See https://llvm.org/LICENSE.txt for license information.
5*572fc7d2SAndre Vieira // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*572fc7d2SAndre Vieira //
7*572fc7d2SAndre Vieira //===----------------------------------------------------------------------===//
8*572fc7d2SAndre Vieira 
9*572fc7d2SAndre Vieira #include "AArch64MachineScheduler.h"
10*572fc7d2SAndre Vieira #include "MCTargetDesc/AArch64MCTargetDesc.h"
11*572fc7d2SAndre Vieira 
12*572fc7d2SAndre Vieira using namespace llvm;
13*572fc7d2SAndre Vieira 
14*572fc7d2SAndre Vieira bool AArch64PostRASchedStrategy::tryCandidate(SchedCandidate &Cand,
15*572fc7d2SAndre Vieira                                               SchedCandidate &TryCand) {
16*572fc7d2SAndre Vieira   bool OriginalResult = PostGenericScheduler::tryCandidate(Cand, TryCand);
17*572fc7d2SAndre Vieira 
18*572fc7d2SAndre Vieira   if (Cand.isValid()) {
19*572fc7d2SAndre Vieira     MachineInstr *Instr0 = TryCand.SU->getInstr();
20*572fc7d2SAndre Vieira     MachineInstr *Instr1 = Cand.SU->getInstr();
21*572fc7d2SAndre Vieira     // When dealing with two STPqi's.
22*572fc7d2SAndre Vieira     if (Instr0 && Instr1 && Instr0->getOpcode() == Instr1->getOpcode () &&
23*572fc7d2SAndre Vieira         Instr0->getOpcode() == AArch64::STPQi)
24*572fc7d2SAndre Vieira     {
25*572fc7d2SAndre Vieira       MachineOperand &Base0 = Instr0->getOperand(2);
26*572fc7d2SAndre Vieira       MachineOperand &Base1 = Instr1->getOperand(2);
27*572fc7d2SAndre Vieira       int64_t Off0 = Instr0->getOperand(3).getImm();
28*572fc7d2SAndre Vieira       int64_t Off1 = Instr1->getOperand(3).getImm();
29*572fc7d2SAndre Vieira       // With the same base address and non-overlapping writes.
30*572fc7d2SAndre Vieira       if (Base0.isIdenticalTo(Base1) && llabs (Off0 - Off1) >= 2) {
31*572fc7d2SAndre Vieira         TryCand.Reason = NodeOrder;
32*572fc7d2SAndre Vieira         // Order them by ascending offsets.
33*572fc7d2SAndre Vieira         return Off0 < Off1;
34*572fc7d2SAndre Vieira       }
35*572fc7d2SAndre Vieira     }
36*572fc7d2SAndre Vieira   }
37*572fc7d2SAndre Vieira 
38*572fc7d2SAndre Vieira   return OriginalResult;
39*572fc7d2SAndre Vieira }
40