14 #ifndef LLVM_LIB_TARGET_AARCH64_AARCH64INSTRINFO_H
15 #define LLVM_LIB_TARGET_AARCH64_AARCH64INSTRINFO_H
22 #define GET_INSTRINFO_HEADER
23 #include "AArch64GenInstrInfo.inc"
27 class AArch64Subtarget;
28 class AArch64TargetMachine;
35 #define FALKOR_STRIDED_ACCESS_MD "falkor.strided.access"
54 unsigned &DstReg,
unsigned &SubIdx)
const override;
105 case AArch64::STRSui:
106 case AArch64::STRDui:
107 case AArch64::STRQui:
108 case AArch64::STRXui:
109 case AArch64::STRWui:
110 case AArch64::LDRSui:
111 case AArch64::LDRDui:
112 case AArch64::LDRQui:
113 case AArch64::LDRXui:
114 case AArch64::LDRWui:
115 case AArch64::LDRSWui:
117 case AArch64::STURSi:
118 case AArch64::STURDi:
119 case AArch64::STURQi:
120 case AArch64::STURWi:
121 case AArch64::STURXi:
122 case AArch64::LDURSi:
123 case AArch64::LDURDi:
124 case AArch64::LDURQi:
125 case AArch64::LDURWi:
126 case AArch64::LDURXi:
127 case AArch64::LDURSWi:
139 case AArch64::ADDWri: Is64Bit =
false;
return AArch64::ADDSWri;
140 case AArch64::ADDWrr: Is64Bit =
false;
return AArch64::ADDSWrr;
141 case AArch64::ADDWrs: Is64Bit =
false;
return AArch64::ADDSWrs;
142 case AArch64::ADDWrx: Is64Bit =
false;
return AArch64::ADDSWrx;
143 case AArch64::ANDWri: Is64Bit =
false;
return AArch64::ANDSWri;
144 case AArch64::ANDWrr: Is64Bit =
false;
return AArch64::ANDSWrr;
145 case AArch64::ANDWrs: Is64Bit =
false;
return AArch64::ANDSWrs;
146 case AArch64::BICWrr: Is64Bit =
false;
return AArch64::BICSWrr;
147 case AArch64::BICWrs: Is64Bit =
false;
return AArch64::BICSWrs;
148 case AArch64::SUBWri: Is64Bit =
false;
return AArch64::SUBSWri;
149 case AArch64::SUBWrr: Is64Bit =
false;
return AArch64::SUBSWrr;
150 case AArch64::SUBWrs: Is64Bit =
false;
return AArch64::SUBSWrs;
151 case AArch64::SUBWrx: Is64Bit =
false;
return AArch64::SUBSWrx;
153 case AArch64::ADDXri: Is64Bit =
true;
return AArch64::ADDSXri;
154 case AArch64::ADDXrr: Is64Bit =
true;
return AArch64::ADDSXrr;
155 case AArch64::ADDXrs: Is64Bit =
true;
return AArch64::ADDSXrs;
156 case AArch64::ADDXrx: Is64Bit =
true;
return AArch64::ADDSXrx;
157 case AArch64::ANDXri: Is64Bit =
true;
return AArch64::ANDSXri;
158 case AArch64::ANDXrr: Is64Bit =
true;
return AArch64::ANDSXrr;
159 case AArch64::ANDXrs: Is64Bit =
true;
return AArch64::ANDSXrs;
160 case AArch64::BICXrr: Is64Bit =
true;
return AArch64::BICSXrr;
161 case AArch64::BICXrs: Is64Bit =
true;
return AArch64::BICSXrs;
162 case AArch64::SUBXri: Is64Bit =
true;
return AArch64::SUBSXri;
163 case AArch64::SUBXrr: Is64Bit =
true;
return AArch64::SUBSXrr;
164 case AArch64::SUBXrs: Is64Bit =
true;
return AArch64::SUBSXrs;
165 case AArch64::SUBXrx: Is64Bit =
true;
return AArch64::SUBSXrx;
181 int64_t &
Offset,
unsigned &Width,
191 bool getMemOpInfo(
unsigned Opcode,
unsigned &Scale,
unsigned &Width,
192 int64_t &MinOffset, int64_t &MaxOffset)
const;
195 unsigned NumLoads)
const override;
202 const DebugLoc &
DL,
unsigned DestReg,
unsigned SrcReg,
203 bool KillSrc,
unsigned Opcode,
206 const DebugLoc &
DL,
unsigned DestReg,
unsigned SrcReg,
207 bool KillSrc)
const override;
234 int64_t BrOffset)
const override;
241 bool AllowModify =
false)
const override;
243 int *BytesRemoved =
nullptr)
const override;
247 int *BytesAdded =
nullptr)
const override;
251 unsigned,
unsigned,
int &,
int &,
int &)
const override;
255 unsigned FalseReg)
const override;
262 unsigned &SrcReg2,
int &CmpMask,
263 int &CmpValue)
const override;
267 unsigned SrcReg2,
int CmpMask,
int CmpValue,
296 std::pair<unsigned, unsigned>
307 bool CanBeTailCall)
const override;
308 AArch64GenInstrInfo::MachineOutlinerInstrType
312 bool IsTailCall)
const override;
315 bool isTailCall)
const override;
320 bool IsTailCall)
const override;
335 bool substituteCmpToZero(
MachineInstr &CmpInstr,
unsigned SrcReg,
344 const DebugLoc &
DL,
unsigned DestReg,
unsigned SrcReg,
347 bool SetNZCV =
false);
353 unsigned FrameReg,
int &
Offset,
354 const AArch64InstrInfo *
TII);
378 bool *OutUseUnscaledOp =
nullptr,
379 unsigned *OutUnscaledOp =
nullptr,
380 int *EmittableOffset =
nullptr);
ArrayRef< std::pair< unsigned, const char * > > getSerializableBitmaskMachineOperandTargetFlags() const override
const AArch64RegisterInfo & getRegisterInfo() const
getRegisterInfo - TargetInstrInfo is a superset of MRegister info.
bool isGPRZero(const MachineInstr &MI) const
Does this instruction set its full destination register to zero?
AArch64GenInstrInfo::MachineOutlinerInstrType getOutliningType(MachineInstr &MI) const override
bool getMemOpBaseRegImmOfs(MachineInstr &LdSt, unsigned &BaseReg, int64_t &Offset, const TargetRegisterInfo *TRI) const override
A Module instance is used to store all the information related to an LLVM module. ...
bool hasShiftedReg(const MachineInstr &MI) const
Returns true if there is a shiftable register and that the shift value is non-zero.
void suppressLdStPair(MachineInstr &MI) const
Hint that pairing the given load or store is unprofitable.
MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, MachineBasicBlock::iterator InsertPt, int FrameIndex, LiveIntervals *LIS=nullptr) const override
Offset can apply, at least partly.
MachineOperand & getMemOpBaseRegImmOfsOffsetOperand(MachineInstr &LdSt) const
Return the immediate offset of the base register in a load/store LdSt.
bool shouldClusterMemOps(MachineInstr &FirstLdSt, MachineInstr &SecondLdSt, unsigned NumLoads) const override
Detect opportunities for ldp/stp formation.
bool hasExtendedReg(const MachineInstr &MI) const
Returns true if there is an extendable register and that the extending value is non-zero.
bool isUnscaledLdSt(unsigned Opc) const
Return true if this is an unscaled load/store.
bool isAssociativeAndCommutative(const MachineInstr &Inst) const override
Return true when Inst is associative and commutative so that it can be reassociated.
const HexagonInstrInfo * TII
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
bool useMachineCombiner() const override
AArch64 supports MachineCombiner.
int isAArch64FrameOffsetLegal(const MachineInstr &MI, int &Offset, bool *OutUseUnscaledOp=nullptr, unsigned *OutUnscaledOp=nullptr, int *EmittableOffset=nullptr)
Check if the Offset is a valid frame offset for MI.
AArch64InstrInfo(const AArch64Subtarget &STI)
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
GetInstSize - Return the number of bytes of code the specified instruction may be.
virtual MachineInstr * foldMemoryOperandImpl(MachineFunction &MF, MachineInstr &MI, ArrayRef< unsigned > Ops, MachineBasicBlock::iterator InsertPt, int FrameIndex, LiveIntervals *LIS=nullptr) const
Target-dependent implementation for foldMemoryOperand.
bool canInsertSelect(const MachineBasicBlock &, ArrayRef< MachineOperand > Cond, unsigned, unsigned, int &, int &, int &) const override
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
static const MachineMemOperand::Flags MOSuppressPair
Instances of this class represent a single low-level machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
void emitFrameOffset(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, int Offset, const TargetInstrInfo *TII, MachineInstr::MIFlag=MachineInstr::NoFlags, bool SetNZCV=false)
emitFrameOffset - Emit instructions as needed to set DestReg to SrcReg plus Offset.
static bool isCondBranchOpcode(int Opc)
MachineInstrBundleIterator< MachineInstr > iterator
bool getMemOpInfo(unsigned Opcode, unsigned &Scale, unsigned &Width, int64_t &MinOffset, int64_t &MaxOffset) const
Returns true if opcode Opc is a memory operation.
Control flow instructions. These all have token chains.
unsigned getOutliningBenefit(size_t SequenceSize, size_t Occurrences, bool CanBeTailCall) const override
unsigned const MachineRegisterInfo * MRI
bool isFalkorShiftExtFast(const MachineInstr &MI) const
Returns true if the instruction has a shift by immediate that can be executed in one cycle less...
bool isFPRCopy(const MachineInstr &MI) const
Does this instruction rename an FPR without modifying bits?
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
MachineInstr * emitFrameIndexDebugValue(MachineFunction &MF, int FrameIx, uint64_t Offset, const MDNode *Var, const MDNode *Expr, const DebugLoc &DL) const
bool rewriteAArch64FrameIndex(MachineInstr &MI, unsigned FrameRegIdx, unsigned FrameReg, int &Offset, const AArch64InstrInfo *TII)
rewriteAArch64FrameIndex - Rewrite MI to access 'Offset' bytes from the FP.
static bool isPairableLdStInst(const MachineInstr &MI)
void insertOutlinerPrologue(MachineBasicBlock &MBB, MachineFunction &MF, bool isTailCall) const override
bool areMemAccessesTriviallyDisjoint(MachineInstr &MIa, MachineInstr &MIb, AliasAnalysis *AA=nullptr) const override
bool isBranchOffsetInRange(unsigned BranchOpc, int64_t BrOffset) const override
bool isAsCheapAsAMove(const MachineInstr &MI) const override
bool expandPostRAPseudo(MachineInstr &MI) const override
bool isThroughputPattern(MachineCombinerPattern Pattern) const override
Return true when a code sequence can improve throughput.
MachineCombinerPattern
These are instruction patterns matched by the machine combiner pass.
bool getMachineCombinerPatterns(MachineInstr &Root, SmallVectorImpl< MachineCombinerPattern > &Patterns) const override
Return true when there is potentially a faster code sequence for an instruction chain ending in Root...
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const override
void insertSelect(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, const DebugLoc &DL, unsigned DstReg, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg) const override
bool isCoalescableExtInstr(const MachineInstr &MI, unsigned &SrcReg, unsigned &DstReg, unsigned &SubIdx) const override
AArch64FrameOffsetStatus
Use to report the frame offset status in isAArch64FrameOffsetLegal.
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
ArrayRef< std::pair< MachineMemOperand::Flags, const char * > > getSerializableMachineMemOperandTargetFlags() const override
static bool isIndirectBranchOpcode(int Opc)
static bool isUncondBranchOpcode(int Opc)
void getNoop(MCInst &NopInst) const override
MachineBasicBlock::iterator insertOutlinedCall(Module &M, MachineBasicBlock &MBB, MachineBasicBlock::iterator &It, MachineFunction &MF, bool IsTailCall) const override
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
MachineOperand class - Representation of each machine instruction operand.
bool optimizeCondBranch(MachineInstr &MI) const override
Replace csincr-branch sequence by simple conditional branch.
unsigned isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool isSubregFoldable() const override
Flags
Flags values. These may be or'd together.
llvm_unreachable("Unknown RegBank!")
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
bool optimizeCompareInstr(MachineInstr &CmpInstr, unsigned SrcReg, unsigned SrcReg2, int CmpMask, int CmpValue, const MachineRegisterInfo *MRI) const override
optimizeCompareInstr - Convert the instruction supplying the argument to the comparison into one that...
static unsigned convertToFlagSettingOpc(unsigned Opc, bool &Is64Bit)
Return the opcode that set flags when possible.
bool analyzeCompare(const MachineInstr &MI, unsigned &SrcReg, unsigned &SrcReg2, int &CmpMask, int &CmpValue) const override
analyzeCompare - For a comparison instruction, return the source registers in SrcReg and SrcReg2...
bool isScaledAddr(const MachineInstr &MI) const
Return true if this is load/store scales or extends its register offset.
void insertOutlinerEpilogue(MachineBasicBlock &MBB, MachineFunction &MF, bool IsTailCall) const override
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
bool isLdStPairSuppressed(const MachineInstr &MI) const
Return true if pairing the given load or store is hinted to be unprofitable.
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
bool getMemOpBaseRegImmOfsWidth(MachineInstr &LdSt, unsigned &BaseReg, int64_t &Offset, unsigned &Width, const TargetRegisterInfo *TRI) const
bool isGPRCopy(const MachineInstr &MI) const
Does this instruction rename a GPR without modifying bits?
MachineBasicBlock * getBranchDestBlock(const MachineInstr &MI) const override
void copyPhysRegTuple(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, unsigned DestReg, unsigned SrcReg, bool KillSrc, unsigned Opcode, llvm::ArrayRef< unsigned > Indices) const
void genAlternativeCodeSequence(MachineInstr &Root, MachineCombinerPattern Pattern, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, DenseMap< unsigned, unsigned > &InstrIdxForVirtReg) const override
When getMachineCombinerPatterns() finds patterns, this function generates the instructions that could...
bool isFunctionSafeToOutlineFrom(MachineFunction &MF) const override
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
bool isStridedAccess(const MachineInstr &MI) const
Return true if the given load or store is a strided memory access.
bool isCandidateToMergeOrPair(MachineInstr &MI) const
Return true if this is a load/store that can be potentially paired/merged.
static const MachineMemOperand::Flags MOStridedAccess