32 #define DEBUG_TYPE "aarch64-fix-cortex-a53-835769"
34 STATISTIC(NumNopsAdded,
"Number of Nops added to work around erratum 835769");
45 case AArch64::PRFMroW:
46 case AArch64::PRFMroX:
63 case AArch64::MSUBXrrr:
64 case AArch64::MADDXrrr:
65 case AArch64::SMADDLrrr:
66 case AArch64::SMSUBLrrr:
67 case AArch64::UMADDLrrr:
68 case AArch64::UMSUBLrrr:
91 return "Workaround A53 erratum 835769 pass";
110 DEBUG(
dbgs() <<
"***** AArch64A53Fix835769 *****\n");
111 bool Changed =
false;
114 for (
auto &MBB : F) {
115 Changed |= runOnBasicBlock(MBB);
136 if (S == PrevBB && !TII->
AnalyzeBranch(*PrevBB, TBB, FBB, Cond) &&
154 for (
auto I = FMBB->
rbegin(), E = FMBB->
rend();
I != E; ++
I) {
168 if (MI == &MBB.
front()) {
170 assert(I &&
"Expected instruction");
176 BuildMI(MBB, MI, DL, TII->
get(AArch64::HINT)).addImm(0);
184 bool Changed =
false;
185 DEBUG(
dbgs() <<
"Running on MBB: " << MBB <<
" - scanning instructions...\n");
191 std::vector<MachineInstr*> Sequences;
199 for (
auto &
MI : MBB) {
203 DEBUG(
dbgs() <<
" PrevInstr: " << *PrevInstr
204 <<
" CurrInstr: " << *CurrInstr
205 <<
" isFirstInstructionInSequence(PrevInstr): "
207 <<
" isSecondInstructionInSequence(CurrInstr): "
211 DEBUG(
dbgs() <<
" ** pattern found at Idx " << Idx <<
"!\n");
212 Sequences.push_back(CurrInstr);
216 PrevInstr = CurrInstr;
220 DEBUG(
dbgs() <<
"Scan complete, "<< Sequences.size()
221 <<
" occurences of pattern found.\n");
224 for (
auto &
MI : Sequences) {
235 return new AArch64A53Fix835769();
const MachineFunction * getParent() const
getParent - Return the MachineFunction containing this basic block.
STATISTIC(NumFunctions,"Total number of functions")
static MachineBasicBlock * getBBFallenThrough(MachineBasicBlock *MBB, const TargetInstrInfo *TII)
bool isPseudo(QueryType Type=IgnoreBundle) const
Return true if this is a pseudo instruction that doesn't correspond to a real machine instruction...
static MachineInstr * getLastNonPseudo(MachineBasicBlock &MBB, const TargetInstrInfo *TII)
virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const
Analyze the branching code at the end of MBB, returning true if it cannot be understood (e...
virtual const char * getPassName() const
getPassName - Return a nice clean name for a pass.
static bool isSecondInstructionInSequence(MachineInstr *MI)
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
reverse_iterator rbegin()
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
TargetInstrInfo - Interface to description of machine instruction set.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const MachineOperand & getOperand(unsigned i) const
Represent the analysis usage information of a pass.
FunctionPass class - This class is used to implement most global optimizations.
iterator_range< pred_iterator > predecessors()
MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL, const MCInstrDesc &MCID)
BuildMI - Builder interface.
const MCInstrDesc & get(unsigned Opcode) const
Return the machine instruction descriptor that corresponds to the specified instruction opcode...
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
void setPreservesCFG()
This function should be called by the pass, iff they do not:
FunctionPass * createAArch64A53Fix835769()
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
Representation of each machine instruction.
bool mayLoadOrStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read or modify memory.
static bool isFirstInstructionInSequence(MachineInstr *MI)
unsigned getReg() const
getReg - Returns the register number.
virtual const TargetInstrInfo * getInstrInfo() const
BasicBlockListType::iterator iterator
static void insertNopBeforeInstruction(MachineBasicBlock &MBB, MachineInstr *MI, const TargetInstrInfo *TII)