31#define DEBUG_TYPE "aarch64-fix-cortex-a53-835769"
33STATISTIC(NumNopsAdded,
"Number of Nops added to work around erratum 835769");
42 switch (
MI->getOpcode()) {
44 case AArch64::PRFMroW:
45 case AArch64::PRFMroX:
50 return MI->mayLoadOrStore();
59 switch (
MI->getOpcode()) {
62 case AArch64::MSUBXrrr:
63 case AArch64::MADDXrrr:
64 case AArch64::SMADDLrrr:
65 case AArch64::SMSUBLrrr:
66 case AArch64::UMADDLrrr:
67 case AArch64::UMSUBLrrr:
70 return MI->getOperand(3).getReg() != AArch64::XZR;
93 MachineFunctionProperties::Property::NoVRegs);
97 return "Workaround A53 erratum 835769 pass";
108char AArch64A53Fix835769::ID = 0;
113 "AArch64 fix for A53 erratum 835769",
false,
false)
122 if (!STI.fixCortexA53_835769())
125 bool Changed =
false;
126 TII = STI.getInstrInfo();
128 for (
auto &
MBB :
F) {
183 assert(
I &&
"Expected instruction");
197 bool Changed =
false;
199 <<
" - scanning instructions...\n");
205 std::vector<MachineInstr*> Sequences;
213 for (
auto &
MI :
MBB) {
218 <<
" CurrInstr: " << *CurrInstr
219 <<
" isFirstInstructionInSequence(PrevInstr): "
221 <<
" isSecondInstructionInSequence(CurrInstr): "
227 Sequences.push_back(CurrInstr);
231 PrevInstr = CurrInstr;
236 <<
" occurrences of pattern found.\n");
239 for (
auto &
MI : Sequences) {
250 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()