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;
92 MachineFunctionProperties::Property::NoVRegs);
96 return "Workaround A53 erratum 835769 pass";
107char AArch64A53Fix835769::ID = 0;
112 "AArch64 fix for A53 erratum 835769",
false,
false)
121 if (!STI.fixCortexA53_835769())
124 bool Changed =
false;
125 TII = STI.getInstrInfo();
127 for (
auto &
MBB :
F) {
182 assert(
I &&
"Expected instruction");
196 bool Changed =
false;
198 <<
" - scanning instructions...\n");
204 std::vector<MachineInstr*> Sequences;
212 for (
auto &
MI :
MBB) {
217 <<
" CurrInstr: " << *CurrInstr
218 <<
" isFirstInstructionInSequence(PrevInstr): "
220 <<
" isSecondInstructionInSequence(CurrInstr): "
226 Sequences.push_back(CurrInstr);
230 PrevInstr = CurrInstr;
235 <<
" occurrences of pattern found.\n");
238 for (
auto &
MI : Sequences) {
249 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)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
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
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
Represent the analysis usage information of a pass.
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.
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
Analyze the branching code at the end of MBB, returning true if it cannot be understood (e....
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
iterator_range< pred_iterator > predecessors()
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.
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
virtual MachineFunctionProperties getRequiredProperties() const
Properties which a MachineFunction may have at a given point in time.
MachineFunctionProperties & set(Property P)
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.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringRef - Represent a constant reference to a string, i.e.
TargetInstrInfo - Interface to description of machine instruction set.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
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)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
void initializeAArch64A53Fix835769Pass(PassRegistry &)
FunctionPass * createAArch64A53Fix835769()