30#define DEBUG_TYPE "aarch64-fix-cortex-a53-835769"
32STATISTIC(NumNopsAdded,
"Number of Nops added to work around erratum 835769");
41 switch (
MI->getOpcode()) {
43 case AArch64::PRFMroW:
44 case AArch64::PRFMroX:
49 return MI->mayLoadOrStore();
58 switch (
MI->getOpcode()) {
61 case AArch64::MSUBXrrr:
62 case AArch64::MADDXrrr:
63 case AArch64::SMADDLrrr:
64 case AArch64::SMSUBLrrr:
65 case AArch64::UMADDLrrr:
66 case AArch64::UMSUBLrrr:
69 return MI->getOperand(3).getReg() != AArch64::XZR;
80 const TargetInstrInfo *TII;
84 explicit AArch64A53Fix835769() : MachineFunctionPass(ID) {}
86 bool runOnMachineFunction(MachineFunction &
F)
override;
88 MachineFunctionProperties getRequiredProperties()
const override {
89 return MachineFunctionProperties().setNoVRegs();
92 StringRef getPassName()
const override {
93 return "Workaround A53 erratum 835769 pass";
96 void getAnalysisUsage(AnalysisUsage &AU)
const override {
104char AArch64A53Fix835769::ID = 0;
109 "AArch64 fix for A53 erratum 835769",
false,
false)
118 if (!STI.fixCortexA53_835769())
122 TII = STI.getInstrInfo();
124 for (
auto &
MBB :
F) {
138 if (
MBBI ==
MBB->getParent()->begin())
146 if (S == PrevBB && !
TII->analyzeBranch(*PrevBB,
TBB, FBB,
Cond) && !
TBB &&
177 if (
MI == &
MBB.front()) {
179 assert(
I &&
"Expected instruction");
195 <<
" - scanning instructions...\n");
201 std::vector<MachineInstr*> Sequences;
203 MachineInstr *PrevInstr =
nullptr;
209 for (
auto &
MI :
MBB) {
210 MachineInstr *CurrInstr = &
MI;
214 <<
" CurrInstr: " << *CurrInstr
215 <<
" isFirstInstructionInSequence(PrevInstr): "
217 <<
" isSecondInstructionInSequence(CurrInstr): "
221 LLVM_DEBUG(
dbgs() <<
" ** pattern found at Idx " << Idx <<
"!\n");
223 Sequences.push_back(CurrInstr);
227 PrevInstr = CurrInstr;
232 <<
" occurrences of pattern found.\n");
235 for (
auto &
MI : Sequences) {
246 return new AArch64A53Fix835769();
static MachineBasicBlock * getBBFallenThrough(MachineBasicBlock *MBB, const TargetInstrInfo *TII)
static MachineInstr * getLastNonPseudo(MachineBasicBlock &MBB, const TargetInstrInfo *TII)
static void insertNopBeforeInstruction(MachineBasicBlock &MBB, MachineInstr *MI, const TargetInstrInfo *TII)
static bool isFirstInstructionInSequence(MachineInstr *MI)
static bool isSecondInstructionInSequence(MachineInstr *MI)
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
const HexagonInstrInfo * TII
static bool runOnBasicBlock(MachineBasicBlock *MBB, unsigned BasicBlockNum, VRegRenamer &Renamer)
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
const SmallVectorImpl< MachineOperand > & Cond
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
FunctionPass class - This class is used to implement most global optimizations.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
BasicBlockListType::iterator iterator
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
Representation of each machine instruction.
bool isPseudo(QueryType Type=IgnoreBundle) const
Return true if this is a pseudo instruction that doesn't correspond to a real machine instruction.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
TargetInstrInfo - Interface to description of machine instruction set.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
auto reverse(ContainerTy &&C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createAArch64A53Fix835769()