LLVM  3.7.0
Classes | Public Member Functions | Protected Member Functions | List of all members
llvm::TargetInstrInfo Class Reference

TargetInstrInfo - Interface to description of machine instruction set. More...

#include <TargetInstrInfo.h>

Inheritance diagram for llvm::TargetInstrInfo:
[legend]
Collaboration diagram for llvm::TargetInstrInfo:
[legend]

Classes

struct  MachineBranchPredicate
 Represents a predicate at the MachineFunction level. More...
 
struct  RegSubRegPair
 A pair composed of a register and a sub-register index. More...
 
struct  RegSubRegPairAndIdx
 A pair composed of a pair of a register and a sub-register index, and another sub-register index. More...
 

Public Member Functions

 TargetInstrInfo (unsigned CFSetupOpcode=~0u, unsigned CFDestroyOpcode=~0u)
 
virtual ~TargetInstrInfo ()
 
const TargetRegisterClassgetRegClass (const MCInstrDesc &TID, unsigned OpNum, const TargetRegisterInfo *TRI, const MachineFunction &MF) const
 Given a machine instruction descriptor, returns the register class constraint for OpNum, or NULL. More...
 
bool isTriviallyReMaterializable (const MachineInstr *MI, AliasAnalysis *AA=nullptr) const
 Return true if the instruction is trivially rematerializable, meaning it has no side effects and requires no operands that aren't always available. More...
 
unsigned getCallFrameSetupOpcode () const
 These methods return the opcode of the frame setup/destroy instructions if they exist (-1 otherwise). More...
 
unsigned getCallFrameDestroyOpcode () const
 
virtual int getSPAdjust (const MachineInstr *MI) const
 Returns the actual stack pointer adjustment made by an instruction as part of a call sequence. More...
 
virtual bool isCoalescableExtInstr (const MachineInstr &MI, unsigned &SrcReg, unsigned &DstReg, unsigned &SubIdx) const
 Return true if the instruction is a "coalescable" extension instruction. More...
 
virtual unsigned isLoadFromStackSlot (const MachineInstr *MI, int &FrameIndex) const
 If the specified machine instruction is a direct load from a stack slot, return the virtual or physical register number of the destination along with the FrameIndex of the loaded stack slot. More...
 
virtual unsigned isLoadFromStackSlotPostFE (const MachineInstr *MI, int &FrameIndex) const
 Check for post-frame ptr elimination stack locations as well. More...
 
virtual bool hasLoadFromStackSlot (const MachineInstr *MI, const MachineMemOperand *&MMO, int &FrameIndex) const
 If the specified machine instruction has a load from a stack slot, return true along with the FrameIndex of the loaded stack slot and the machine mem operand containing the reference. More...
 
virtual unsigned isStoreToStackSlot (const MachineInstr *MI, int &FrameIndex) const
 If the specified machine instruction is a direct store to a stack slot, return the virtual or physical register number of the source reg along with the FrameIndex of the loaded stack slot. More...
 
virtual unsigned isStoreToStackSlotPostFE (const MachineInstr *MI, int &FrameIndex) const
 Check for post-frame ptr elimination stack locations as well. More...
 
virtual bool hasStoreToStackSlot (const MachineInstr *MI, const MachineMemOperand *&MMO, int &FrameIndex) const
 If the specified machine instruction has a store to a stack slot, return true along with the FrameIndex of the loaded stack slot and the machine mem operand containing the reference. More...
 
virtual bool isStackSlotCopy (const MachineInstr *MI, int &DestFrameIndex, int &SrcFrameIndex) const
 Return true if the specified machine instruction is a copy of one stack slot to another and has no other effect. More...
 
virtual bool getStackSlotRange (const TargetRegisterClass *RC, unsigned SubIdx, unsigned &Size, unsigned &Offset, const MachineFunction &MF) const
 Compute the size in bytes and offset within a stack slot of a spilled register or subregister. More...
 
virtual bool isAsCheapAsAMove (const MachineInstr *MI) const
 Return true if the instruction is as cheap as a move instruction. More...
 
virtual void reMaterialize (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, unsigned SubIdx, const MachineInstr *Orig, const TargetRegisterInfo &TRI) const
 Re-issue the specified 'original' instruction at the specific location targeting a new destination register. More...
 
virtual MachineInstrduplicate (MachineInstr *Orig, MachineFunction &MF) const
 Create a duplicate of the Orig instruction in MF. More...
 
virtual MachineInstrconvertToThreeAddress (MachineFunction::iterator &MFI, MachineBasicBlock::iterator &MBBI, LiveVariables *LV) const
 This method must be implemented by targets that set the M_CONVERTIBLE_TO_3_ADDR flag. More...
 
virtual MachineInstrcommuteInstruction (MachineInstr *MI, bool NewMI=false) const
 If a target has any instructions that are commutable but require converting to different instructions or making non-trivial changes to commute them, this method can overloaded to do that. More...
 
virtual bool findCommutedOpIndices (MachineInstr *MI, unsigned &SrcOpIdx1, unsigned &SrcOpIdx2) const
 If specified MI is commutable, return the two operand indices that would swap value. More...
 
bool getRegSequenceInputs (const MachineInstr &MI, unsigned DefIdx, SmallVectorImpl< RegSubRegPairAndIdx > &InputRegs) const
 Build the equivalent inputs of a REG_SEQUENCE for the given MI and DefIdx. More...
 
bool getExtractSubregInputs (const MachineInstr &MI, unsigned DefIdx, RegSubRegPairAndIdx &InputReg) const
 Build the equivalent inputs of a EXTRACT_SUBREG for the given MI and DefIdx. More...
 
bool getInsertSubregInputs (const MachineInstr &MI, unsigned DefIdx, RegSubRegPair &BaseReg, RegSubRegPairAndIdx &InsertedReg) const
 Build the equivalent inputs of a INSERT_SUBREG for the given MI and DefIdx. More...
 
virtual bool produceSameValue (const MachineInstr *MI0, const MachineInstr *MI1, const MachineRegisterInfo *MRI=nullptr) const
 Return true if two machine instructions would produce identical values. More...
 
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.g. More...
 
virtual bool AnalyzeBranchPredicate (MachineBasicBlock &MBB, MachineBranchPredicate &MBP, bool AllowModify=false) const
 Analyze the branching code at the end of MBB and parse it into the MachineBranchPredicate structure if possible. More...
 
virtual unsigned RemoveBranch (MachineBasicBlock &MBB) const
 Remove the branching code at the end of the specific MBB. More...
 
virtual unsigned InsertBranch (MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, DebugLoc DL) const
 Insert branch code into the end of the specified MachineBasicBlock. More...
 
virtual void ReplaceTailWithBranchTo (MachineBasicBlock::iterator Tail, MachineBasicBlock *NewDest) const
 Delete the instruction OldInst and everything after it, replacing it with an unconditional branch to NewDest. More...
 
virtual void getUnconditionalBranch (MCInst &MI, const MCSymbolRefExpr *BranchTarget) const
 Get an instruction that performs an unconditional branch to the given symbol. More...
 
virtual void getTrap (MCInst &MI) const
 Get a machine trap instruction. More...
 
virtual unsigned getJumpInstrTableEntryBound () const
 Get a number of bytes that suffices to hold either the instruction returned by getUnconditionalBranch or the instruction returned by getTrap. More...
 
virtual bool isLegalToSplitMBBAt (MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI) const
 Return true if it's legal to split the given basic block at the specified instruction (i.e. More...
 
virtual bool isProfitableToIfCvt (MachineBasicBlock &MBB, unsigned NumCycles, unsigned ExtraPredCycles, const BranchProbability &Probability) const
 Return true if it's profitable to predicate instructions with accumulated instruction latency of "NumCycles" of the specified basic block, where the probability of the instructions being executed is given by Probability, and Confidence is a measure of our confidence that it will be properly predicted. More...
 
virtual bool isProfitableToIfCvt (MachineBasicBlock &TMBB, unsigned NumTCycles, unsigned ExtraTCycles, MachineBasicBlock &FMBB, unsigned NumFCycles, unsigned ExtraFCycles, const BranchProbability &Probability) const
 Second variant of isProfitableToIfCvt. More...
 
virtual bool isProfitableToDupForIfCvt (MachineBasicBlock &MBB, unsigned NumCycles, const BranchProbability &Probability) const
 Return true if it's profitable for if-converter to duplicate instructions of specified accumulated instruction latencies in the specified MBB to enable if-conversion. More...
 
virtual bool isProfitableToUnpredicate (MachineBasicBlock &TMBB, MachineBasicBlock &FMBB) const
 Return true if it's profitable to unpredicate one side of a 'diamond', i.e. More...
 
virtual bool canInsertSelect (const MachineBasicBlock &MBB, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg, int &CondCycles, int &TrueCycles, int &FalseCycles) const
 Return true if it is possible to insert a select instruction that chooses between TrueReg and FalseReg based on the condition code in Cond. More...
 
virtual void insertSelect (MachineBasicBlock &MBB, MachineBasicBlock::iterator I, DebugLoc DL, unsigned DstReg, ArrayRef< MachineOperand > Cond, unsigned TrueReg, unsigned FalseReg) const
 Insert a select instruction into MBB before I that will copy TrueReg to DstReg when Cond is true, and FalseReg to DstReg when Cond is false. More...
 
virtual bool analyzeSelect (const MachineInstr *MI, SmallVectorImpl< MachineOperand > &Cond, unsigned &TrueOp, unsigned &FalseOp, bool &Optimizable) const
 Analyze the given select instruction, returning true if it cannot be understood. More...
 
virtual MachineInstroptimizeSelect (MachineInstr *MI, SmallPtrSetImpl< MachineInstr * > &NewMIs, bool PreferFalse=false) const
 Given a select instruction that was understood by analyzeSelect and returned Optimizable = true, attempt to optimize MI by merging it with one of its operands. More...
 
virtual void copyPhysReg (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, DebugLoc DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const
 Emit instructions to copy a pair of physical registers. More...
 
virtual void storeRegToStackSlot (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const
 Store the specified register of the given register class to the specified stack frame index. More...
 
virtual void loadRegFromStackSlot (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const
 Load the specified register of the given register class from the specified stack frame index. More...
 
virtual bool expandPostRAPseudo (MachineBasicBlock::iterator MI) const
 This function is called for all pseudo instructions that remain after register allocation. More...
 
MachineInstrfoldMemoryOperand (MachineBasicBlock::iterator MI, ArrayRef< unsigned > Ops, int FrameIndex) const
 Attempt to fold a load or store of the specified stack slot into the specified machine instruction for the specified operand(s). More...
 
MachineInstrfoldMemoryOperand (MachineBasicBlock::iterator MI, ArrayRef< unsigned > Ops, MachineInstr *LoadMI) const
 Same as the previous version except it allows folding of any load and store from / to any address, not just from a specific stack slot. More...
 
virtual bool getMachineCombinerPatterns (MachineInstr &Root, SmallVectorImpl< MachineCombinerPattern::MC_PATTERN > &Pattern) const
 Return true when there is potentially a faster code sequence for an instruction chain ending in Root. More...
 
virtual void genAlternativeCodeSequence (MachineInstr &Root, MachineCombinerPattern::MC_PATTERN Pattern, SmallVectorImpl< MachineInstr * > &InsInstrs, SmallVectorImpl< MachineInstr * > &DelInstrs, DenseMap< unsigned, unsigned > &InstrIdxForVirtReg) const
 When getMachineCombinerPatterns() finds patterns, this function generates the instructions that could replace the original code sequence. More...
 
virtual bool useMachineCombiner () const
 Return true when a target supports MachineCombiner. More...
 
virtual bool canFoldMemoryOperand (const MachineInstr *MI, ArrayRef< unsigned > Ops) const
 Returns true for the specified load / store if folding is possible. More...
 
virtual bool unfoldMemoryOperand (MachineFunction &MF, MachineInstr *MI, unsigned Reg, bool UnfoldLoad, bool UnfoldStore, SmallVectorImpl< MachineInstr * > &NewMIs) const
 unfoldMemoryOperand - Separate a single instruction which folded a load or a store or a load and a store into two or more instruction. More...
 
virtual bool unfoldMemoryOperand (SelectionDAG &DAG, SDNode *N, SmallVectorImpl< SDNode * > &NewNodes) const
 
virtual unsigned getOpcodeAfterMemoryUnfold (unsigned Opc, bool UnfoldLoad, bool UnfoldStore, unsigned *LoadRegIndex=nullptr) const
 Returns the opcode of the would be new instruction after load / store are unfolded from an instruction of the specified opcode. More...
 
virtual bool areLoadsFromSameBasePtr (SDNode *Load1, SDNode *Load2, int64_t &Offset1, int64_t &Offset2) const
 This is used by the pre-regalloc scheduler to determine if two loads are loading from the same base address. More...
 
virtual bool shouldScheduleLoadsNear (SDNode *Load1, SDNode *Load2, int64_t Offset1, int64_t Offset2, unsigned NumLoads) const
 This is a used by the pre-regalloc scheduler to determine (in conjunction with areLoadsFromSameBasePtr) if two loads should be scheduled together. More...
 
virtual bool getMemOpBaseRegImmOfs (MachineInstr *MemOp, unsigned &BaseReg, unsigned &Offset, const TargetRegisterInfo *TRI) const
 Get the base register and byte offset of an instruction that reads/writes memory. More...
 
virtual bool enableClusterLoads () const
 
virtual bool shouldClusterLoads (MachineInstr *FirstLdSt, MachineInstr *SecondLdSt, unsigned NumLoads) const
 
virtual bool shouldScheduleAdjacent (MachineInstr *First, MachineInstr *Second) const
 Can this target fuse the given instructions if they are scheduled adjacent. More...
 
virtual bool ReverseBranchCondition (SmallVectorImpl< MachineOperand > &Cond) const
 Reverses the branch condition of the specified condition list, returning false on success and true if it cannot be reversed. More...
 
virtual void insertNoop (MachineBasicBlock &MBB, MachineBasicBlock::iterator MI) const
 Insert a noop into the instruction stream at the specified point. More...
 
virtual void getNoopForMachoTarget (MCInst &NopInst) const
 Return the noop instruction to use for a noop. More...
 
virtual bool isPredicated (const MachineInstr *MI) const
 Returns true if the instruction is already predicated. More...
 
virtual bool isUnpredicatedTerminator (const MachineInstr *MI) const
 Returns true if the instruction is a terminator instruction that has not been predicated. More...
 
virtual bool PredicateInstruction (MachineInstr *MI, ArrayRef< MachineOperand > Pred) const
 Convert the instruction into a predicated instruction. More...
 
virtual bool SubsumesPredicate (ArrayRef< MachineOperand > Pred1, ArrayRef< MachineOperand > Pred2) const
 Returns true if the first specified predicate subsumes the second, e.g. More...
 
virtual bool DefinesPredicate (MachineInstr *MI, std::vector< MachineOperand > &Pred) const
 If the specified instruction defines any predicate or condition code register(s) used for predication, returns true as well as the definition predicate(s) by reference. More...
 
virtual bool isPredicable (MachineInstr *MI) const
 Return true if the specified instruction can be predicated. More...
 
virtual bool isSafeToMoveRegClassDefs (const TargetRegisterClass *RC) const
 Return true if it's safe to move a machine instruction that defines the specified register class. More...
 
virtual bool isSchedulingBoundary (const MachineInstr *MI, const MachineBasicBlock *MBB, const MachineFunction &MF) const
 Test if the given instruction should be considered a scheduling boundary. More...
 
virtual unsigned getInlineAsmLength (const char *Str, const MCAsmInfo &MAI) const
 Measure the specified inline asm to determine an approximation of its length. More...
 
virtual ScheduleHazardRecognizerCreateTargetHazardRecognizer (const TargetSubtargetInfo *STI, const ScheduleDAG *DAG) const
 Allocate and return a hazard recognizer to use for this target when scheduling the machine instructions before register allocation. More...
 
virtual ScheduleHazardRecognizerCreateTargetMIHazardRecognizer (const InstrItineraryData *, const ScheduleDAG *DAG) const
 Allocate and return a hazard recognizer to use for this target when scheduling the machine instructions before register allocation. More...
 
virtual ScheduleHazardRecognizerCreateTargetPostRAHazardRecognizer (const InstrItineraryData *, const ScheduleDAG *DAG) const
 Allocate and return a hazard recognizer to use for this target when scheduling the machine instructions after register allocation. More...
 
bool usePreRAHazardRecognizer () const
 Provide a global flag for disabling the PreRA hazard recognizer that targets may choose to honor. More...
 
virtual bool analyzeCompare (const MachineInstr *MI, unsigned &SrcReg, unsigned &SrcReg2, int &Mask, int &Value) const
 For a comparison instruction, return the source registers in SrcReg and SrcReg2 if having two register operands, and the value it compares against in CmpValue. More...
 
virtual bool optimizeCompareInstr (MachineInstr *CmpInstr, unsigned SrcReg, unsigned SrcReg2, int Mask, int Value, const MachineRegisterInfo *MRI) const
 See if the comparison instruction can be converted into something more efficient. More...
 
virtual bool optimizeCondBranch (MachineInstr *MI) const
 
virtual MachineInstroptimizeLoadInstr (MachineInstr *MI, const MachineRegisterInfo *MRI, unsigned &FoldAsLoadDefReg, MachineInstr *&DefMI) const
 Try to remove the load by folding it to a register operand at the use. More...
 
virtual bool FoldImmediate (MachineInstr *UseMI, MachineInstr *DefMI, unsigned Reg, MachineRegisterInfo *MRI) const
 'Reg' is known to be defined by a move immediate instruction, try to fold the immediate into the use instruction. More...
 
virtual unsigned getNumMicroOps (const InstrItineraryData *ItinData, const MachineInstr *MI) const
 Return the number of u-operations the given machine instruction will be decoded to on the target cpu. More...
 
bool isZeroCost (unsigned Opcode) const
 Return true for pseudo instructions that don't consume any machine resources in their current form. More...
 
virtual int getOperandLatency (const InstrItineraryData *ItinData, SDNode *DefNode, unsigned DefIdx, SDNode *UseNode, unsigned UseIdx) const
 
virtual int getOperandLatency (const InstrItineraryData *ItinData, const MachineInstr *DefMI, unsigned DefIdx, const MachineInstr *UseMI, unsigned UseIdx) const
 Compute and return the use operand latency of a given pair of def and use. More...
 
unsigned computeOperandLatency (const InstrItineraryData *ItinData, const MachineInstr *DefMI, unsigned DefIdx, const MachineInstr *UseMI, unsigned UseIdx) const
 Compute and return the latency of the given data dependent def and use when the operand indices are already known. More...
 
virtual unsigned getInstrLatency (const InstrItineraryData *ItinData, const MachineInstr *MI, unsigned *PredCost=nullptr) const
 Compute the instruction latency of a given instruction. More...
 
virtual unsigned getPredicationCost (const MachineInstr *MI) const
 
virtual int getInstrLatency (const InstrItineraryData *ItinData, SDNode *Node) const
 
unsigned defaultDefLatency (const MCSchedModel &SchedModel, const MachineInstr *DefMI) const
 Return the default expected latency for a def based on it's opcode. More...
 
int computeDefOperandLatency (const InstrItineraryData *ItinData, const MachineInstr *DefMI) const
 If we can determine the operand latency from the def only, without itinerary lookup, do so. More...
 
virtual bool isHighLatencyDef (int opc) const
 Return true if this opcode has high latency to its result. More...
 
virtual bool hasHighOperandLatency (const TargetSchedModel &SchedModel, const MachineRegisterInfo *MRI, const MachineInstr *DefMI, unsigned DefIdx, const MachineInstr *UseMI, unsigned UseIdx) const
 Compute operand latency between a def of 'Reg' and a use in the current loop. More...
 
virtual bool hasLowDefLatency (const TargetSchedModel &SchedModel, const MachineInstr *DefMI, unsigned DefIdx) const
 Compute operand latency of a def of 'Reg'. More...
 
virtual bool verifyInstruction (const MachineInstr *MI, StringRef &ErrInfo) const
 Perform target-specific instruction verification. More...
 
virtual std::pair< uint16_t,
uint16_t > 
getExecutionDomain (const MachineInstr *MI) const
 Return the current execution domain and bit mask of possible domains for instruction. More...
 
virtual void setExecutionDomain (MachineInstr *MI, unsigned Domain) const
 Change the opcode of MI to execute in Domain. More...
 
virtual unsigned getPartialRegUpdateClearance (const MachineInstr *MI, unsigned OpNum, const TargetRegisterInfo *TRI) const
 Returns the preferred minimum clearance before an instruction with an unwanted partial register update. More...
 
virtual unsigned getUndefRegClearance (const MachineInstr *MI, unsigned &OpNum, const TargetRegisterInfo *TRI) const
 Return the minimum clearance before an instruction that reads an unused register. More...
 
virtual void breakPartialRegDependency (MachineBasicBlock::iterator MI, unsigned OpNum, const TargetRegisterInfo *TRI) const
 Insert a dependency-breaking instruction before MI to eliminate an unwanted dependency on OpNum. More...
 
virtual DFAPacketizerCreateTargetScheduleState (const TargetSubtargetInfo &) const
 Create machine specific model for scheduling. More...
 
virtual bool areMemAccessesTriviallyDisjoint (MachineInstr *MIa, MachineInstr *MIb, AliasAnalysis *AA=nullptr) const
 
virtual unsigned getMachineCSELookAheadLimit () const
 Return the value to use for the MachineCSE's LookAheadLimit, which is a heuristic used for CSE'ing phys reg defs. More...
 
- Public Member Functions inherited from llvm::MCInstrInfo
void InitMCInstrInfo (const MCInstrDesc *D, const unsigned *NI, const char *ND, unsigned NO)
 Initialize MCInstrInfo, called by TableGen auto-generated routines. More...
 
unsigned getNumOpcodes () const
 
const MCInstrDescget (unsigned Opcode) const
 Return the machine instruction descriptor that corresponds to the specified instruction opcode. More...
 
const char * getName (unsigned Opcode) const
 Returns the name for the instructions with the given opcode. More...
 

Protected Member Functions

virtual bool isReallyTriviallyReMaterializable (const MachineInstr *MI, AliasAnalysis *AA) const
 For instructions with opcodes for which the M_REMATERIALIZABLE flag is set, this hook lets the target specify whether the instruction is actually trivially rematerializable, taking into consideration its operands. More...
 
virtual MachineInstrfoldMemoryOperandImpl (MachineFunction &MF, MachineInstr *MI, ArrayRef< unsigned > Ops, MachineBasicBlock::iterator InsertPt, int FrameIndex) const
 Target-dependent implementation for foldMemoryOperand. More...
 
virtual MachineInstrfoldMemoryOperandImpl (MachineFunction &MF, MachineInstr *MI, ArrayRef< unsigned > Ops, MachineBasicBlock::iterator InsertPt, MachineInstr *LoadMI) const
 Target-dependent implementation for foldMemoryOperand. More...
 
virtual bool getRegSequenceLikeInputs (const MachineInstr &MI, unsigned DefIdx, SmallVectorImpl< RegSubRegPairAndIdx > &InputRegs) const
 Target-dependent implementation of getRegSequenceInputs. More...
 
virtual bool getExtractSubregLikeInputs (const MachineInstr &MI, unsigned DefIdx, RegSubRegPairAndIdx &InputReg) const
 Target-dependent implementation of getExtractSubregInputs. More...
 
virtual bool getInsertSubregLikeInputs (const MachineInstr &MI, unsigned DefIdx, RegSubRegPair &BaseReg, RegSubRegPairAndIdx &InsertedReg) const
 Target-dependent implementation of getInsertSubregInputs. More...
 

Detailed Description

TargetInstrInfo - Interface to description of machine instruction set.

Definition at line 53 of file TargetInstrInfo.h.

Constructor & Destructor Documentation

llvm::TargetInstrInfo::TargetInstrInfo ( unsigned  CFSetupOpcode = ~0u,
unsigned  CFDestroyOpcode = ~0u 
)
inline

Definition at line 57 of file TargetInstrInfo.h.

TargetInstrInfo::~TargetInstrInfo ( )
virtual

Definition at line 40 of file TargetInstrInfo.cpp.

Member Function Documentation

virtual bool llvm::TargetInstrInfo::AnalyzeBranch ( MachineBasicBlock MBB,
MachineBasicBlock *&  TBB,
MachineBasicBlock *&  FBB,
SmallVectorImpl< MachineOperand > &  Cond,
bool  AllowModify = false 
) const
inlinevirtual

Analyze the branching code at the end of MBB, returning true if it cannot be understood (e.g.

it's a switch dispatch or isn't implemented for a target). Upon success, this returns false and returns with the following information in various cases:

  1. If this block ends with no branches (it just falls through to its succ) just return false, leaving TBB/FBB null.
  2. If this block ends with only an unconditional branch, it sets TBB to be the destination block.
  3. If this block ends with a conditional branch and it falls through to a successor block, it sets TBB to be the branch destination block and a list of operands that evaluate the condition. These operands can be passed to other TargetInstrInfo methods to create new branches.
  4. If this block ends with a conditional branch followed by an unconditional branch, it returns the 'true' destination in TBB, the 'false' destination in FBB, and a list of operands that evaluate the condition. These operands can be passed to other TargetInstrInfo methods to create new branches.

Note that RemoveBranch and InsertBranch must be implemented to support cases where this method returns success.

If AllowModify is true, then this routine is allowed to modify the basic block (e.g. delete instructions after the unconditional branch).

Definition at line 383 of file TargetInstrInfo.h.

Referenced by llvm::MachineBasicBlock::canFallThrough(), FixTail(), getBBFallenThrough(), llvm::BranchFolder::OptimizeFunction(), llvm::MachineBasicBlock::SplitCriticalEdge(), and llvm::MachineBasicBlock::updateTerminator().

virtual bool llvm::TargetInstrInfo::AnalyzeBranchPredicate ( MachineBasicBlock MBB,
MachineBranchPredicate MBP,
bool  AllowModify = false 
) const
inlinevirtual

Analyze the branching code at the end of MBB and parse it into the MachineBranchPredicate structure if possible.

Returns false on success and true on failure.

If AllowModify is true, then this routine is allowed to modify the basic block (e.g. delete instructions after the unconditional branch).

Definition at line 429 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::analyzeCompare ( const MachineInstr MI,
unsigned SrcReg,
unsigned SrcReg2,
int Mask,
int Value 
) const
inlinevirtual

For a comparison instruction, return the source registers in SrcReg and SrcReg2 if having two register operands, and the value it compares against in CmpValue.

Return true if the comparison instruction can be analyzed.

Definition at line 995 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::analyzeSelect ( const MachineInstr MI,
SmallVectorImpl< MachineOperand > &  Cond,
unsigned TrueOp,
unsigned FalseOp,
bool Optimizable 
) const
inlinevirtual

Analyze the given select instruction, returning true if it cannot be understood.

It is assumed that MI->isSelect() is true.

When successful, return the controlling condition and the operands that determine the true and false result values.

Result = SELECT Cond, TrueOp, FalseOp

Some targets can optimize select instructions, for example by predicating the instruction defining one of the operands. Such targets should set Optimizable.

Parameters
MISelect instruction to analyze.
CondCondition controlling the select.
TrueOpOperand number of the value selected when Cond is true.
FalseOpOperand number of the value selected when Cond is false.
OptimizableReturned as true if MI is optimizable.
Returns
False on success.

Definition at line 626 of file TargetInstrInfo.h.

References llvm::MachineInstr::getDesc(), and llvm::MCInstrDesc::isSelect().

virtual bool llvm::TargetInstrInfo::areLoadsFromSameBasePtr ( SDNode Load1,
SDNode Load2,
int64_t &  Offset1,
int64_t &  Offset2 
) const
inlinevirtual

This is used by the pre-regalloc scheduler to determine if two loads are loading from the same base address.

It should only return true if the base pointers are the same and the only differences between the two addresses are the offset. It also returns the offsets by reference.

Definition at line 856 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::areMemAccessesTriviallyDisjoint ( MachineInstr MIa,
MachineInstr MIb,
AliasAnalysis AA = nullptr 
) const
inlinevirtual

Definition at line 1252 of file TargetInstrInfo.h.

References llvm::MachineInstr::mayLoad(), and llvm::MachineInstr::mayStore().

Referenced by MIsNeedChainEdge().

virtual void llvm::TargetInstrInfo::breakPartialRegDependency ( MachineBasicBlock::iterator  MI,
unsigned  OpNum,
const TargetRegisterInfo TRI 
) const
inlinevirtual

Insert a dependency-breaking instruction before MI to eliminate an unwanted dependency on OpNum.

If it wasn't possible to avoid a def in the last N instructions before MI (see getPartialRegUpdateClearance), this hook will be called to break the unwanted dependency.

On x86, an xorps instruction can be used as a dependency breaker:

addps xmm1, xmm0 movaps xmm0, (rax) xorps xmm0, xmm0 cvtsi2ss rbx, xmm0

An <imp-kill> operand should be added to MI if an instruction was inserted. This ties the instructions together in the post-ra scheduler.

Definition at line 1238 of file TargetInstrInfo.h.

bool TargetInstrInfo::canFoldMemoryOperand ( const MachineInstr MI,
ArrayRef< unsigned Ops 
) const
virtual

Returns true for the specified load / store if folding is possible.

Definition at line 387 of file TargetInstrInfo.cpp.

References canFoldCopy(), llvm::MachineInstr::isCopy(), and llvm::ArrayRef< T >::size().

Referenced by llvm::X86InstrInfo::canFoldMemoryOperand().

virtual bool llvm::TargetInstrInfo::canInsertSelect ( const MachineBasicBlock MBB,
ArrayRef< MachineOperand Cond,
unsigned  TrueReg,
unsigned  FalseReg,
int CondCycles,
int TrueCycles,
int FalseCycles 
) const
inlinevirtual

Return true if it is possible to insert a select instruction that chooses between TrueReg and FalseReg based on the condition code in Cond.

When successful, also return the latency in cycles from TrueReg, FalseReg, and Cond to the destination register. In most cases, a select instruction will be 1 cycle, so CondCycles = TrueCycles = FalseCycles = 1

Some x86 implementations have 2-cycle cmov instructions.

Parameters
MBBBlock where select instruction would be inserted.
CondCondition returned by AnalyzeBranch.
TrueRegVirtual register to select when Cond is true.
FalseRegVirtual register to select when Cond is false.
CondCyclesLatency from Cond+Branch to select output.
TrueCyclesLatency from TrueReg to select output.
FalseCyclesLatency from FalseReg to select output.

Definition at line 578 of file TargetInstrInfo.h.

MachineInstr * TargetInstrInfo::commuteInstruction ( MachineInstr MI,
bool  NewMI = false 
) const
virtual

If a target has any instructions that are commutable but require converting to different instructions or making non-trivial changes to commute them, this method can overloaded to do that.

The default implementation simply swaps the commutable operands. If NewMI is false, MI is modified in place and returned; otherwise, a new machine instruction is created and returned. Do not call this method for a non-commutable instruction, but there may be some cases where this method fails and returns null.

Definition at line 123 of file TargetInstrInfo.cpp.

References llvm::MachineFunction::CloneMachineInstr(), findCommutedOpIndices(), llvm::MachineInstr::getDesc(), llvm::MCInstrDesc::getNumDefs(), llvm::MachineInstr::getOperand(), llvm::MCInstrDesc::getOperandConstraint(), llvm::MachineInstr::getParent(), llvm::MachineBasicBlock::getParent(), llvm::MachineOperand::getReg(), llvm::MachineOperand::getSubReg(), llvm::MachineInstr::isCommutable(), llvm::MachineOperand::isInternalRead(), llvm::MachineOperand::isKill(), llvm::MachineOperand::isReg(), llvm::MachineOperand::isUndef(), llvm::AArch64CC::MI, llvm::MachineOperand::setIsInternalRead(), llvm::MachineOperand::setIsKill(), llvm::MachineOperand::setIsUndef(), llvm::MachineOperand::setReg(), llvm::MachineOperand::setSubReg(), and llvm::MCOI::TIED_TO.

Referenced by llvm::SIInstrInfo::commuteInstruction(), llvm::PPCInstrInfo::commuteInstruction(), llvm::ARMBaseInstrInfo::commuteInstruction(), and llvm::X86InstrInfo::commuteInstruction().

int TargetInstrInfo::computeDefOperandLatency ( const InstrItineraryData ItinData,
const MachineInstr DefMI 
) const

If we can determine the operand latency from the def only, without itinerary lookup, do so.

Otherwise return -1.

Definition at line 830 of file TargetInstrInfo.cpp.

References defaultDefLatency(), getInstrLatency(), llvm::InstrItineraryData::isEmpty(), and llvm::InstrItineraryData::SchedModel.

Referenced by computeOperandLatency().

unsigned TargetInstrInfo::computeOperandLatency ( const InstrItineraryData ItinData,
const MachineInstr DefMI,
unsigned  DefIdx,
const MachineInstr UseMI,
unsigned  UseIdx 
) const

Compute and return the latency of the given data dependent def and use when the operand indices are already known.

computeOperandLatency - Compute and return the latency of the given data dependent def and use when the operand indices are already known.

UseMI may be NULL for an unknown use.

FindMin may be set to get the minimum vs. expected latency. Minimum latency is used for scheduling groups, while expected latency is for instruction cost and critical path.

Depending on the subtarget's itinerary properties, this may or may not need to call getOperandLatency(). For most subtargets, we don't need DefIdx or UseIdx to compute min latency.

Definition at line 857 of file TargetInstrInfo.cpp.

References computeDefOperandLatency(), defaultDefLatency(), llvm::MachineInstr::getDesc(), getInstrLatency(), llvm::InstrItineraryData::getOperandCycle(), getOperandLatency(), llvm::MCInstrDesc::getSchedClass(), llvm::InstrItineraryData::isEmpty(), and llvm::InstrItineraryData::SchedModel.

virtual MachineInstr* llvm::TargetInstrInfo::convertToThreeAddress ( MachineFunction::iterator MFI,
MachineBasicBlock::iterator MBBI,
LiveVariables LV 
) const
inlinevirtual

This method must be implemented by targets that set the M_CONVERTIBLE_TO_3_ADDR flag.

When this flag is set, the target may be able to convert a two-address instruction into one or more true three-address instructions on demand. This allows the X86 target (for example) to convert ADD and SHL instructions into LEA instructions if they would require register copies due to two-addressness.

This method returns a null pointer if the transformation cannot be performed, otherwise it returns the last new instruction.

Definition at line 248 of file TargetInstrInfo.h.

virtual void llvm::TargetInstrInfo::copyPhysReg ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI,
DebugLoc  DL,
unsigned  DestReg,
unsigned  SrcReg,
bool  KillSrc 
) const
inlinevirtual

Emit instructions to copy a pair of physical registers.

This function should support copies within any legal register class as well as any cross-class copies created during instruction selection.

The source and destination registers may overlap, which may require a careful implementation when multiple copy instructions are required for large registers. See for example the ARM target.

Definition at line 664 of file TargetInstrInfo.h.

References llvm_unreachable.

Referenced by llvm::AArch64FrameLowering::emitPrologue(), and llvm::Mips16RegisterInfo::saveScavengerRegister().

ScheduleHazardRecognizer * TargetInstrInfo::CreateTargetHazardRecognizer ( const TargetSubtargetInfo STI,
const ScheduleDAG DAG 
) const
virtual

Allocate and return a hazard recognizer to use for this target when scheduling the machine instructions before register allocation.

Definition at line 703 of file TargetInstrInfo.cpp.

Referenced by llvm::PPCInstrInfo::CreateTargetHazardRecognizer(), and llvm::ARMBaseInstrInfo::CreateTargetHazardRecognizer().

ScheduleHazardRecognizer * TargetInstrInfo::CreateTargetMIHazardRecognizer ( const InstrItineraryData II,
const ScheduleDAG DAG 
) const
virtual

Allocate and return a hazard recognizer to use for this target when scheduling the machine instructions before register allocation.

Definition at line 711 of file TargetInstrInfo.cpp.

Referenced by llvm::ConvergingVLIWScheduler::initialize(), and llvm::PostGenericScheduler::initialize().

ScheduleHazardRecognizer * TargetInstrInfo::CreateTargetPostRAHazardRecognizer ( const InstrItineraryData II,
const ScheduleDAG DAG 
) const
virtual

Allocate and return a hazard recognizer to use for this target when scheduling the machine instructions after register allocation.

Definition at line 719 of file TargetInstrInfo.cpp.

Referenced by llvm::ARMBaseInstrInfo::CreateTargetPostRAHazardRecognizer().

virtual DFAPacketizer* llvm::TargetInstrInfo::CreateTargetScheduleState ( const TargetSubtargetInfo ) const
inlinevirtual
unsigned TargetInstrInfo::defaultDefLatency ( const MCSchedModel SchedModel,
const MachineInstr DefMI 
) const
virtual bool llvm::TargetInstrInfo::DefinesPredicate ( MachineInstr MI,
std::vector< MachineOperand > &  Pred 
) const
inlinevirtual

If the specified instruction defines any predicate or condition code register(s) used for predication, returns true as well as the definition predicate(s) by reference.

Definition at line 940 of file TargetInstrInfo.h.

MachineInstr * TargetInstrInfo::duplicate ( MachineInstr Orig,
MachineFunction MF 
) const
virtual

Create a duplicate of the Orig instruction in MF.

This is like MachineFunction::CloneMachineInstr(), but the target may update operands that are required to be unique.

The instruction must be duplicable as indicated by isNotDuplicable().

Definition at line 342 of file TargetInstrInfo.cpp.

References llvm::MachineFunction::CloneMachineInstr(), and llvm::MachineInstr::isNotDuplicable().

Referenced by llvm::ARMBaseInstrInfo::duplicate().

virtual bool llvm::TargetInstrInfo::enableClusterLoads ( ) const
inlinevirtual

Definition at line 883 of file TargetInstrInfo.h.

Referenced by createGenericSchedLive().

virtual bool llvm::TargetInstrInfo::expandPostRAPseudo ( MachineBasicBlock::iterator  MI) const
inlinevirtual

This function is called for all pseudo instructions that remain after register allocation.

Many pseudo instructions are created to help register allocation. This is the place to convert them into real instructions. The target can edit MI in place, or it can insert new instructions and erase MI. The function should return true if anything was changed.

Definition at line 702 of file TargetInstrInfo.h.

bool TargetInstrInfo::findCommutedOpIndices ( MachineInstr MI,
unsigned SrcOpIdx1,
unsigned SrcOpIdx2 
) const
virtual

If specified MI is commutable, return the two operand indices that would swap value.

findCommutedOpIndices - If specified MI is commutable, return the two operand indices that would swap value.

Return false if the instruction is not in a form which this routine understands.

Return true if the instruction is not in a form which this routine understands.

Definition at line 190 of file TargetInstrInfo.cpp.

References llvm::MachineInstr::getDesc(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::isBundle(), and llvm::MachineOperand::isReg().

Referenced by commuteInstruction(), llvm::PPCInstrInfo::findCommutedOpIndices(), and llvm::X86InstrInfo::findCommutedOpIndices().

virtual bool llvm::TargetInstrInfo::FoldImmediate ( MachineInstr UseMI,
MachineInstr DefMI,
unsigned  Reg,
MachineRegisterInfo MRI 
) const
inlinevirtual

'Reg' is known to be defined by a move immediate instruction, try to fold the immediate into the use instruction.

If MRI->hasOneNonDBGUse(Reg) is true, and this function returns true, then the caller may assume that DefMI has been erased from its parent block. The caller may assume that it will not be erased by this function otherwise.

Definition at line 1032 of file TargetInstrInfo.h.

MachineInstr * TargetInstrInfo::foldMemoryOperand ( MachineBasicBlock::iterator  MI,
ArrayRef< unsigned Ops,
int  FI 
) const

Attempt to fold a load or store of the specified stack slot into the specified machine instruction for the specified operand(s).

foldMemoryOperand - Attempt to fold a load or store of the specified stack slot into the specified machine instruction for the specified operand(s).

If this is possible, a new instruction is returned with the specified operand folded, otherwise NULL is returned. The new instruction is inserted before MI, and the client is responsible for removing the old instruction.

If this is possible, a new instruction is returned with the specified operand folded, otherwise NULL is returned. The client is responsible for removing the old instruction and adding the new one in the instruction stream.

Definition at line 454 of file TargetInstrInfo.cpp.

References llvm::MachineInstr::addMemOperand(), canFoldCopy(), foldMemoryOperandImpl(), foldPatchpoint(), llvm::MachinePointerInfo::getFixedStack(), llvm::MachineFunction::getFrameInfo(), llvm::MachineFunction::getMachineMemOperand(), llvm::MachineFrameInfo::getObjectAlignment(), llvm::MachineFrameInfo::getObjectOffset(), llvm::MachineFrameInfo::getObjectSize(), llvm::MachineBasicBlock::getParent(), llvm::MachineOperand::getReg(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::MachineFunction::getSubtarget(), llvm::MachineBasicBlock::insert(), llvm::MachineOperand::isKill(), loadRegFromStackSlot(), llvm::MachineInstr::mayLoad(), llvm::MachineInstr::mayStore(), llvm::AArch64CC::MI, llvm::MachineMemOperand::MOLoad, llvm::MachineMemOperand::MOStore, llvm::TargetOpcode::PATCHPOINT, llvm::MachineInstr::setMemRefs(), llvm::ArrayRef< T >::size(), llvm::TargetOpcode::STACKMAP, and storeRegToStackSlot().

MachineInstr * TargetInstrInfo::foldMemoryOperand ( MachineBasicBlock::iterator  MI,
ArrayRef< unsigned Ops,
MachineInstr LoadMI 
) const

Same as the previous version except it allows folding of any load and store from / to any address, not just from a specific stack slot.

foldMemoryOperand - Same as the previous version except it allows folding of any load and store from / to any address, not just from a specific stack slot.

Definition at line 523 of file TargetInstrInfo.cpp.

References llvm::MachineInstr::addMemOperand(), llvm::MachineInstr::canFoldAsLoad(), foldMemoryOperandImpl(), foldPatchpoint(), llvm::ISD::FrameIndex, llvm::MachineBasicBlock::getParent(), I, llvm::MachineBasicBlock::insert(), isLoadFromStackSlot(), llvm::MachineInstr::memoperands_begin(), llvm::MachineInstr::memoperands_end(), llvm::TargetOpcode::PATCHPOINT, llvm::MachineInstr::setMemRefs(), llvm::ArrayRef< T >::size(), and llvm::TargetOpcode::STACKMAP.

virtual MachineInstr* llvm::TargetInstrInfo::foldMemoryOperandImpl ( MachineFunction MF,
MachineInstr MI,
ArrayRef< unsigned Ops,
MachineBasicBlock::iterator  InsertPt,
int  FrameIndex 
) const
inlineprotectedvirtual

Target-dependent implementation for foldMemoryOperand.

Target-independent code in foldMemoryOperand will take care of adding a MachineMemOperand to the newly created instruction. The instruction and any auxiliary instructions necessary will be inserted at InsertPt.

Definition at line 761 of file TargetInstrInfo.h.

Referenced by foldMemoryOperand().

virtual MachineInstr* llvm::TargetInstrInfo::foldMemoryOperandImpl ( MachineFunction MF,
MachineInstr MI,
ArrayRef< unsigned Ops,
MachineBasicBlock::iterator  InsertPt,
MachineInstr LoadMI 
) const
inlineprotectedvirtual

Target-dependent implementation for foldMemoryOperand.

Target-independent code in foldMemoryOperand will take care of adding a MachineMemOperand to the newly created instruction. The instruction and any auxiliary instructions necessary will be inserted at InsertPt.

Definition at line 772 of file TargetInstrInfo.h.

virtual void llvm::TargetInstrInfo::genAlternativeCodeSequence ( MachineInstr Root,
MachineCombinerPattern::MC_PATTERN  Pattern,
SmallVectorImpl< MachineInstr * > &  InsInstrs,
SmallVectorImpl< MachineInstr * > &  DelInstrs,
DenseMap< unsigned, unsigned > &  InstrIdxForVirtReg 
) const
inlinevirtual

When getMachineCombinerPatterns() finds patterns, this function generates the instructions that could replace the original code sequence.

The client has to decide whether the actual replacement is beneficial or not.

Parameters
Root- Instruction that could be combined with one of its operands
Pattern- Combination pattern for Root
InsInstrs- Vector of new instructions that implement P
DelInstrs- Old instructions, including Root, that could be replaced by InsInstr
InstrIdxForVirtReg- map of virtual register to instruction in InsInstr that defines it

Definition at line 744 of file TargetInstrInfo.h.

unsigned llvm::TargetInstrInfo::getCallFrameDestroyOpcode ( ) const
inline
unsigned llvm::TargetInstrInfo::getCallFrameSetupOpcode ( ) const
inline

These methods return the opcode of the frame setup/destroy instructions if they exist (-1 otherwise).

Some targets use pseudo instructions in order to abstract away the difference between operating with a frame pointer and operating without, through the use of these two instructions.

Definition at line 111 of file TargetInstrInfo.h.

Referenced by FindCallSeqStart(), getSPAdjust(), IsChainDependent(), and llvm::FastISel::selectStackmap().

virtual std::pair<uint16_t, uint16_t> llvm::TargetInstrInfo::getExecutionDomain ( const MachineInstr MI) const
inlinevirtual

Return the current execution domain and bit mask of possible domains for instruction.

Some micro-architectures have multiple execution domains, and multiple opcodes that perform the same operation in different domains. For example, the x86 architecture provides the por, orps, and orpd instructions that all do the same thing. There is a latency penalty if a register is written in one domain and read in another.

This function returns a pair (domain, mask) containing the execution domain of MI, and a bit mask of possible domains. The setExecutionDomain function can be used to change the opcode to one of the domains in the bit mask. Instructions whose execution domain can't be changed should return a 0 mask.

The execution domain numbers don't have any special meaning except domain 0 is used for instructions that are not associated with any interesting execution domain.

Definition at line 1143 of file TargetInstrInfo.h.

bool TargetInstrInfo::getExtractSubregInputs ( const MachineInstr MI,
unsigned  DefIdx,
RegSubRegPairAndIdx InputReg 
) const

Build the equivalent inputs of a EXTRACT_SUBREG for the given MI and DefIdx.

[out] InputReg of the equivalent EXTRACT_SUBREG. E.g., EXTRACT_SUBREG vreg1:sub1, sub0, sub1 would produce:

  • vreg1:sub1, sub0
Returns
true if it is possible to build such an input sequence with the pair MI, DefIdx. False otherwise.
Precondition
MI.isExtractSubreg() or MI.isExtractSubregLike().
Note
The generic implementation does not provide any support for MI.isExtractSubregLike(). In other words, one has to override getExtractSubregLikeInputs for target specific instructions.

Definition at line 911 of file TargetInstrInfo.cpp.

References getExtractSubregLikeInputs(), llvm::MachineOperand::getImm(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::MachineOperand::getSubReg(), llvm::MachineInstr::isExtractSubreg(), llvm::MachineInstr::isExtractSubregLike(), llvm::MachineOperand::isImm(), llvm::TargetInstrInfo::RegSubRegPair::Reg, llvm::TargetInstrInfo::RegSubRegPairAndIdx::SubIdx, and llvm::TargetInstrInfo::RegSubRegPair::SubReg.

virtual bool llvm::TargetInstrInfo::getExtractSubregLikeInputs ( const MachineInstr MI,
unsigned  DefIdx,
RegSubRegPairAndIdx InputReg 
) const
inlineprotectedvirtual

Target-dependent implementation of getExtractSubregInputs.

Returns
true if it is possible to build the equivalent EXTRACT_SUBREG inputs with the pair MI, DefIdx. False otherwise.
Precondition
MI.isExtractSubregLike().
See Also
TargetInstrInfo::getExtractSubregInputs.

Definition at line 800 of file TargetInstrInfo.h.

Referenced by getExtractSubregInputs().

unsigned TargetInstrInfo::getInlineAsmLength ( const char *  Str,
const MCAsmInfo MAI 
) const
virtual

Measure the specified inline asm to determine an approximation of its length.

Comments (which run till the next SeparatorString or newline) do not count as an instruction. Any other non-whitespace text is considered an instruction, with multiple instructions separated by SeparatorString or newlines. Variable-length instructions are not handled here; this function may be overloaded in the target code to do that.

Definition at line 77 of file TargetInstrInfo.cpp.

References llvm::MCAsmInfo::getCommentString(), llvm::MCAsmInfo::getMaxInstLength(), and llvm::MCAsmInfo::getSeparatorString().

Referenced by llvm::MSP430InstrInfo::GetInstSizeInBytes().

bool TargetInstrInfo::getInsertSubregInputs ( const MachineInstr MI,
unsigned  DefIdx,
RegSubRegPair BaseReg,
RegSubRegPairAndIdx InsertedReg 
) const

Build the equivalent inputs of a INSERT_SUBREG for the given MI and DefIdx.

[out] BaseReg and [out] InsertedReg contain the equivalent inputs of INSERT_SUBREG. E.g., INSERT_SUBREG vreg0:sub0, vreg1:sub1, sub3 would produce:

  • BaseReg: vreg0:sub0
  • InsertedReg: vreg1:sub1, sub3
Returns
true if it is possible to build such an input sequence with the pair MI, DefIdx. False otherwise.
Precondition
MI.isInsertSubreg() or MI.isInsertSubregLike().
Note
The generic implementation does not provide any support for MI.isInsertSubregLike(). In other words, one has to override getInsertSubregLikeInputs for target specific instructions.

Definition at line 934 of file TargetInstrInfo.cpp.

References llvm::MachineOperand::getImm(), getInsertSubregLikeInputs(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), llvm::MachineOperand::getSubReg(), llvm::MachineOperand::isImm(), llvm::MachineInstr::isInsertSubreg(), llvm::MachineInstr::isInsertSubregLike(), llvm::TargetInstrInfo::RegSubRegPair::Reg, llvm::TargetInstrInfo::RegSubRegPairAndIdx::SubIdx, and llvm::TargetInstrInfo::RegSubRegPair::SubReg.

virtual bool llvm::TargetInstrInfo::getInsertSubregLikeInputs ( const MachineInstr MI,
unsigned  DefIdx,
RegSubRegPair BaseReg,
RegSubRegPairAndIdx InsertedReg 
) const
inlineprotectedvirtual

Target-dependent implementation of getInsertSubregInputs.

Returns
true if it is possible to build the equivalent INSERT_SUBREG inputs with the pair MI, DefIdx. False otherwise.
Precondition
MI.isInsertSubregLike().
See Also
TargetInstrInfo::getInsertSubregInputs.

Definition at line 815 of file TargetInstrInfo.h.

Referenced by getInsertSubregInputs().

unsigned TargetInstrInfo::getInstrLatency ( const InstrItineraryData ItinData,
const MachineInstr MI,
unsigned PredCost = nullptr 
) const
virtual
int TargetInstrInfo::getInstrLatency ( const InstrItineraryData ItinData,
SDNode Node 
) const
virtual
virtual unsigned llvm::TargetInstrInfo::getJumpInstrTableEntryBound ( ) const
inlinevirtual

Get a number of bytes that suffices to hold either the instruction returned by getUnconditionalBranch or the instruction returned by getTrap.

This only makes sense because getUnconditionalBranch returns a single, specific instruction. This information is needed by the jumptable construction code, since it must decide how many bytes to use for a jumptable entry so it can generate the right mask.

Note that if the jumptable instruction requires alignment, then that alignment should be factored into this required bound so that the resulting bound gives the right alignment for the instruction.

Definition at line 489 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::getMachineCombinerPatterns ( MachineInstr Root,
SmallVectorImpl< MachineCombinerPattern::MC_PATTERN > &  Pattern 
) const
inlinevirtual

Return true when there is potentially a faster code sequence for an instruction chain ending in Root.

All potential patterns are returned in the Pattern vector. Pattern should be sorted in priority order since the pattern evaluator stops checking as soon as it finds a faster sequence.

Parameters
Root- Instruction that could be combined with one of its operands
Pattern- Vector of possible combination patterns

Definition at line 728 of file TargetInstrInfo.h.

virtual unsigned llvm::TargetInstrInfo::getMachineCSELookAheadLimit ( ) const
inlinevirtual

Return the value to use for the MachineCSE's LookAheadLimit, which is a heuristic used for CSE'ing phys reg defs.

Definition at line 1263 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::getMemOpBaseRegImmOfs ( MachineInstr MemOp,
unsigned BaseReg,
unsigned Offset,
const TargetRegisterInfo TRI 
) const
inlinevirtual

Get the base register and byte offset of an instruction that reads/writes memory.

Definition at line 877 of file TargetInstrInfo.h.

void TargetInstrInfo::getNoopForMachoTarget ( MCInst NopInst) const
virtual

Return the noop instruction to use for a noop.

Definition at line 383 of file TargetInstrInfo.cpp.

References llvm_unreachable.

unsigned TargetInstrInfo::getNumMicroOps ( const InstrItineraryData ItinData,
const MachineInstr MI 
) const
virtual

Return the number of u-operations the given machine instruction will be decoded to on the target cpu.

The itinerary's IssueWidth is the number of microops that can be dispatched each cycle. An instruction with zero microops takes no dispatch resources.

Definition at line 762 of file TargetInstrInfo.cpp.

References llvm::Class, llvm::MachineInstr::getDesc(), llvm::MCInstrDesc::getSchedClass(), llvm::InstrItineraryData::isEmpty(), llvm::InstrItineraryData::Itineraries, and llvm::InstrItinerary::NumMicroOps.

Referenced by llvm::TargetSchedModel::getNumMicroOps().

virtual unsigned llvm::TargetInstrInfo::getOpcodeAfterMemoryUnfold ( unsigned  Opc,
bool  UnfoldLoad,
bool  UnfoldStore,
unsigned LoadRegIndex = nullptr 
) const
inlinevirtual

Returns the opcode of the would be new instruction after load / store are unfolded from an instruction of the specified opcode.

It returns zero if the specified unfolding is not possible. If LoadRegIndex is non-null, it is filled in with the operand index of the operand which will hold the register holding the loaded value.

Definition at line 846 of file TargetInstrInfo.h.

int TargetInstrInfo::getOperandLatency ( const InstrItineraryData ItinData,
SDNode DefNode,
unsigned  DefIdx,
SDNode UseNode,
unsigned  UseIdx 
) const
virtual
int TargetInstrInfo::getOperandLatency ( const InstrItineraryData ItinData,
const MachineInstr DefMI,
unsigned  DefIdx,
const MachineInstr UseMI,
unsigned  UseIdx 
) const
virtual

Compute and return the use operand latency of a given pair of def and use.

Both DefMI and UseMI must be valid.

In most cases, the static scheduling itinerary was enough to determine the operand latency. But it may not be possible for instructions with variable number of defs / uses.

This is a raw interface to the itinerary that may be directly overridden by a target. Use computeOperandLatency to get the best estimate of latency.

By default, call directly to the itinerary. This may be overriden by the target.

Definition at line 820 of file TargetInstrInfo.cpp.

References llvm::MachineInstr::getDesc(), llvm::InstrItineraryData::getOperandLatency(), and llvm::MCInstrDesc::getSchedClass().

virtual unsigned llvm::TargetInstrInfo::getPartialRegUpdateClearance ( const MachineInstr MI,
unsigned  OpNum,
const TargetRegisterInfo TRI 
) const
inlinevirtual

Returns the preferred minimum clearance before an instruction with an unwanted partial register update.

Some instructions only write part of a register, and implicitly need to read the other parts of the register. This may cause unwanted stalls preventing otherwise unrelated instructions from executing in parallel in an out-of-order CPU.

For example, the x86 instruction cvtsi2ss writes its result to bits [31:0] of the destination xmm register. Bits [127:32] are unaffected, so the instruction needs to wait for the old value of the register to become available:

addps xmm1, xmm0 movaps xmm0, (rax) cvtsi2ss rbx, xmm0

In the code above, the cvtsi2ss instruction needs to wait for the addps instruction before it can issue, even though the high bits of xmm0 probably aren't needed.

This hook returns the preferred clearance before MI, measured in instructions. Other defs of MI's operand OpNum are avoided in the last N instructions before MI. It should only return a positive value for unwanted dependencies. If the old bits of the defined register have useful values, or if MI is determined to otherwise read the dependency, the hook should return 0.

The unwanted dependency may be handled by:

  1. Allocating the same register for an MI def and use. That makes the unwanted dependency identical to a required dependency.
  2. Allocating a register for the def that has no defs in the previous N instructions.
  3. Calling breakPartialRegDependency() with the same arguments. This allows the target to insert a dependency breaking instruction.

Definition at line 1194 of file TargetInstrInfo.h.

unsigned TargetInstrInfo::getPredicationCost ( const MachineInstr MI) const
virtual

Definition at line 789 of file TargetInstrInfo.cpp.

const TargetRegisterClass * TargetInstrInfo::getRegClass ( const MCInstrDesc TID,
unsigned  OpNum,
const TargetRegisterInfo TRI,
const MachineFunction MF 
) const
bool TargetInstrInfo::getRegSequenceInputs ( const MachineInstr MI,
unsigned  DefIdx,
SmallVectorImpl< RegSubRegPairAndIdx > &  InputRegs 
) const

Build the equivalent inputs of a REG_SEQUENCE for the given MI and DefIdx.

[out] InputRegs of the equivalent REG_SEQUENCE. Each element of the list is modeled as <Reg:SubReg, SubIdx>. E.g., REG_SEQUENCE vreg1:sub1, sub0, vreg2, sub1 would produce two elements:

  • vreg1:sub1, sub0
  • vreg2<:0>, sub1
Returns
true if it is possible to build such an input sequence with the pair MI, DefIdx. False otherwise.
Precondition
MI.isRegSequence() or MI.isRegSequenceLike().
Note
The generic implementation does not provide any support for MI.isRegSequenceLike(). In other words, one has to override getRegSequenceLikeInputs for target specific instructions.

Definition at line 886 of file TargetInstrInfo.cpp.

References llvm::MachineOperand::getImm(), llvm::MachineInstr::getNumOperands(), llvm::MachineInstr::getOperand(), llvm::MachineOperand::getReg(), getRegSequenceLikeInputs(), llvm::MachineOperand::getSubReg(), llvm::MachineOperand::isImm(), llvm::MachineInstr::isRegSequence(), llvm::MachineInstr::isRegSequenceLike(), and llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back().

virtual bool llvm::TargetInstrInfo::getRegSequenceLikeInputs ( const MachineInstr MI,
unsigned  DefIdx,
SmallVectorImpl< RegSubRegPairAndIdx > &  InputRegs 
) const
inlineprotectedvirtual

Target-dependent implementation of getRegSequenceInputs.

Returns
true if it is possible to build the equivalent REG_SEQUENCE inputs with the pair MI, DefIdx. False otherwise.
Precondition
MI.isRegSequenceLike().
See Also
TargetInstrInfo::getRegSequenceInputs.

Definition at line 786 of file TargetInstrInfo.h.

Referenced by getRegSequenceInputs().

int TargetInstrInfo::getSPAdjust ( const MachineInstr MI) const
virtual

Returns the actual stack pointer adjustment made by an instruction as part of a call sequence.

By default, only call frame setup/destroy instructions adjust the stack, but targets may want to override this to enable more fine-grained adjustment, or adjust by a different value.

Definition at line 650 of file TargetInstrInfo.cpp.

References getCallFrameDestroyOpcode(), getCallFrameSetupOpcode(), llvm::TargetSubtargetInfo::getFrameLowering(), llvm::MachineOperand::getImm(), llvm::MachineInstr::getOpcode(), llvm::MachineInstr::getOperand(), llvm::MachineInstr::getParent(), llvm::MachineBasicBlock::getParent(), llvm::TargetFrameLowering::getStackGrowthDirection(), llvm::MachineFunction::getSubtarget(), and llvm::TargetFrameLowering::StackGrowsDown.

bool TargetInstrInfo::getStackSlotRange ( const TargetRegisterClass RC,
unsigned  SubIdx,
unsigned Size,
unsigned Offset,
const MachineFunction MF 
) const
virtual

Compute the size in bytes and offset within a stack slot of a spilled register or subregister.

Parameters
[out]Sizein bytes of the spilled value.
[out]Offsetin bytes within the stack slot.
Returns
true if both Size and Offset are successfully computed.

Not all subregisters have computable spill slots. For example, subregisters registers may not be byte-sized, and a pair of discontiguous subregisters has no single offset.

Targets with nontrivial bigendian implementations may need to override this, particularly to support spilled vector registers.

Definition at line 293 of file TargetInstrInfo.cpp.

References llvm::TargetMachine::getDataLayout(), llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::TargetRegisterClass::getSize(), llvm::MCRegisterInfo::getSubRegIdxOffset(), llvm::MCRegisterInfo::getSubRegIdxSize(), llvm::MachineFunction::getSubtarget(), llvm::MachineFunction::getTarget(), and llvm::DataLayout::isLittleEndian().

Referenced by foldPatchpoint().

virtual void llvm::TargetInstrInfo::getTrap ( MCInst MI) const
inlinevirtual

Get a machine trap instruction.

Definition at line 474 of file TargetInstrInfo.h.

References llvm_unreachable.

virtual void llvm::TargetInstrInfo::getUnconditionalBranch ( MCInst MI,
const MCSymbolRefExpr BranchTarget 
) const
inlinevirtual

Get an instruction that performs an unconditional branch to the given symbol.

Definition at line 467 of file TargetInstrInfo.h.

References llvm_unreachable.

virtual unsigned llvm::TargetInstrInfo::getUndefRegClearance ( const MachineInstr MI,
unsigned OpNum,
const TargetRegisterInfo TRI 
) const
inlinevirtual

Return the minimum clearance before an instruction that reads an unused register.

For example, AVX instructions may copy part of a register operand into the unused high bits of the destination register.

vcvtsi2sdq rax, xmm0<undef>, xmm14

In the code above, vcvtsi2sdq copies xmm0[127:64] into xmm14 creating a false dependence on any previous write to xmm0.

This hook works similarly to getPartialRegUpdateClearance, except that it does not take an operand index. Instead sets OpNum to the index of the unused register.

Definition at line 1214 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::hasHighOperandLatency ( const TargetSchedModel SchedModel,
const MachineRegisterInfo MRI,
const MachineInstr DefMI,
unsigned  DefIdx,
const MachineInstr UseMI,
unsigned  UseIdx 
) const
inlinevirtual

Compute operand latency between a def of 'Reg' and a use in the current loop.

Return true if the target considered it 'high'. This is used by optimization passes such as machine LICM to determine whether it makes sense to hoist an instruction out even in a high register pressure situation.

Definition at line 1104 of file TargetInstrInfo.h.

bool TargetInstrInfo::hasLoadFromStackSlot ( const MachineInstr MI,
const MachineMemOperand *&  MMO,
int FrameIndex 
) const
virtual

If the specified machine instruction has a load from a stack slot, return true along with the FrameIndex of the loaded stack slot and the machine mem operand containing the reference.

If not, return false. Unlike isLoadFromStackSlot, this returns true for any instructions that loads from the stack. This is just a hint, as some cases may be missed.

Definition at line 253 of file TargetInstrInfo.cpp.

References llvm::MachineInstr::memoperands_begin(), and llvm::MachineInstr::memoperands_end().

Referenced by emitComments().

bool TargetInstrInfo::hasLowDefLatency ( const TargetSchedModel SchedModel,
const MachineInstr DefMI,
unsigned  DefIdx 
) const
virtual

Compute operand latency of a def of 'Reg'.

Return true if the target considered it 'low'.

Definition at line 805 of file TargetInstrInfo.cpp.

References llvm::MachineInstr::getDesc(), llvm::TargetSchedModel::getInstrItineraries(), llvm::InstrItineraryData::getOperandCycle(), llvm::MCInstrDesc::getSchedClass(), and llvm::InstrItineraryData::isEmpty().

bool TargetInstrInfo::hasStoreToStackSlot ( const MachineInstr MI,
const MachineMemOperand *&  MMO,
int FrameIndex 
) const
virtual

If the specified machine instruction has a store to a stack slot, return true along with the FrameIndex of the loaded stack slot and the machine mem operand containing the reference.

If not, return false. Unlike isStoreToStackSlot, this returns true for any instructions that stores to the stack. This is just a hint, as some cases may be missed.

Definition at line 273 of file TargetInstrInfo.cpp.

References llvm::MachineInstr::memoperands_begin(), and llvm::MachineInstr::memoperands_end().

Referenced by emitComments().

virtual unsigned llvm::TargetInstrInfo::InsertBranch ( MachineBasicBlock MBB,
MachineBasicBlock TBB,
MachineBasicBlock FBB,
ArrayRef< MachineOperand Cond,
DebugLoc  DL 
) const
inlinevirtual

Insert branch code into the end of the specified MachineBasicBlock.

The operands to this method are the same as those returned by AnalyzeBranch. This is only invoked in cases where AnalyzeBranch returns success. It returns the number of instructions inserted.

It is also invoked by tail merging to add unconditional branches in cases where AnalyzeBranch doesn't apply because there was no original branch to analyze. At least this much must be implemented, else tail merging needs to be disabled.

Definition at line 452 of file TargetInstrInfo.h.

References llvm_unreachable.

Referenced by llvm::FastISel::fastEmitBranch(), FixTail(), InsertUncondBranch(), ReplaceTailWithBranchTo(), llvm::MachineBasicBlock::SplitCriticalEdge(), and llvm::MachineBasicBlock::updateTerminator().

void TargetInstrInfo::insertNoop ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI 
) const
virtual

Insert a noop into the instruction stream at the specified point.

insertNoop - Insert a noop into the instruction stream at the specified point.

Definition at line 64 of file TargetInstrInfo.cpp.

References llvm_unreachable.

Referenced by llvm::ScheduleDAGSDNodes::EmitSchedule().

virtual void llvm::TargetInstrInfo::insertSelect ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  I,
DebugLoc  DL,
unsigned  DstReg,
ArrayRef< MachineOperand Cond,
unsigned  TrueReg,
unsigned  FalseReg 
) const
inlinevirtual

Insert a select instruction into MBB before I that will copy TrueReg to DstReg when Cond is true, and FalseReg to DstReg when Cond is false.

This function can only be called after canInsertSelect() returned true. The condition in Cond comes from AnalyzeBranch, and it can be assumed that the same flags or registers required by Cond are available at the insertion point.

Parameters
MBBBlock where select instruction should be inserted.
IInsertion point.
DLSource location for debugging.
DstRegVirtual register to be defined by select instruction.
CondCondition as computed by AnalyzeBranch.
TrueRegVirtual register to copy when Cond is true.
FalseRegVirtual register to copy when Cons is false.

Definition at line 601 of file TargetInstrInfo.h.

References llvm_unreachable.

Referenced by llvm::PPCTargetLowering::EmitInstrWithCustomInserter().

virtual bool llvm::TargetInstrInfo::isAsCheapAsAMove ( const MachineInstr MI) const
inlinevirtual

Return true if the instruction is as cheap as a move instruction.

Targets for different archs need to override this, and different micro-architectures can also be finely tuned inside.

Definition at line 214 of file TargetInstrInfo.h.

References llvm::MachineInstr::isAsCheapAsAMove().

Referenced by llvm::LiveRangeEdit::canRematerializeAt().

virtual bool llvm::TargetInstrInfo::isCoalescableExtInstr ( const MachineInstr MI,
unsigned SrcReg,
unsigned DstReg,
unsigned SubIdx 
) const
inlinevirtual

Return true if the instruction is a "coalescable" extension instruction.

That is, it's like a copy where it's legal for the source to overlap the destination. e.g. X86::MOVSX64rr32. If this returns true, then it's expected the pre-extension value is available as a subreg of the result register. This also returns the sub-register index in SubIdx.

Definition at line 125 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::isHighLatencyDef ( int  opc) const
inlinevirtual

Return true if this opcode has high latency to its result.

Definition at line 1096 of file TargetInstrInfo.h.

Referenced by llvm::ScheduleDAGSDNodes::computeLatency(), and defaultDefLatency().

virtual bool llvm::TargetInstrInfo::isLegalToSplitMBBAt ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MBBI 
) const
inlinevirtual

Return true if it's legal to split the given basic block at the specified instruction (i.e.

instruction would be the start of a new basic block).

Definition at line 501 of file TargetInstrInfo.h.

virtual unsigned llvm::TargetInstrInfo::isLoadFromStackSlot ( const MachineInstr MI,
int FrameIndex 
) const
inlinevirtual

If the specified machine instruction is a direct load from a stack slot, return the virtual or physical register number of the destination along with the FrameIndex of the loaded stack slot.

If not, return 0. This predicate must return 0 if the instruction has any side effects other than loading from the stack slot.

Definition at line 136 of file TargetInstrInfo.h.

Referenced by foldMemoryOperand(), and MatchingStackOffset().

virtual unsigned llvm::TargetInstrInfo::isLoadFromStackSlotPostFE ( const MachineInstr MI,
int FrameIndex 
) const
inlinevirtual

Check for post-frame ptr elimination stack locations as well.

This uses a heuristic so it isn't reliable for correctness.

Definition at line 143 of file TargetInstrInfo.h.

Referenced by emitComments().

virtual bool llvm::TargetInstrInfo::isPredicable ( MachineInstr MI) const
inlinevirtual

Return true if the specified instruction can be predicated.

By default, this returns true for every instruction with a PredicateOperand.

Definition at line 948 of file TargetInstrInfo.h.

References llvm::MachineInstr::getDesc(), and llvm::MCInstrDesc::isPredicable().

virtual bool llvm::TargetInstrInfo::isPredicated ( const MachineInstr MI) const
inlinevirtual
virtual bool llvm::TargetInstrInfo::isProfitableToDupForIfCvt ( MachineBasicBlock MBB,
unsigned  NumCycles,
const BranchProbability Probability 
) const
inlinevirtual

Return true if it's profitable for if-converter to duplicate instructions of specified accumulated instruction latencies in the specified MBB to enable if-conversion.

The probability of the instructions being executed is given by Probability, and Confidence is a measure of our confidence that it will be properly predicted.

Definition at line 540 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::isProfitableToIfCvt ( MachineBasicBlock MBB,
unsigned  NumCycles,
unsigned  ExtraPredCycles,
const BranchProbability Probability 
) const
inlinevirtual

Return true if it's profitable to predicate instructions with accumulated instruction latency of "NumCycles" of the specified basic block, where the probability of the instructions being executed is given by Probability, and Confidence is a measure of our confidence that it will be properly predicted.

Definition at line 512 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::isProfitableToIfCvt ( MachineBasicBlock TMBB,
unsigned  NumTCycles,
unsigned  ExtraTCycles,
MachineBasicBlock FMBB,
unsigned  NumFCycles,
unsigned  ExtraFCycles,
const BranchProbability Probability 
) const
inlinevirtual

Second variant of isProfitableToIfCvt.

This one checks for the case where two basic blocks from true and false path of a if-then-else (diamond) are predicated on mutally exclusive predicates, where the probability of the true path being taken is given by Probability, and Confidence is a measure of our confidence that it will be properly predicted.

Definition at line 525 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::isProfitableToUnpredicate ( MachineBasicBlock TMBB,
MachineBasicBlock FMBB 
) const
inlinevirtual

Return true if it's profitable to unpredicate one side of a 'diamond', i.e.

two sides of if-else predicated on mutually exclusive predicates. e.g. subeq r0, r1, #1 addne r0, r1, #1 => sub r0, r1, #1 addne r0, r1, #1

This may be profitable is conditional instructions are always executed.

Definition at line 556 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::isReallyTriviallyReMaterializable ( const MachineInstr MI,
AliasAnalysis AA 
) const
inlineprotectedvirtual

For instructions with opcodes for which the M_REMATERIALIZABLE flag is set, this hook lets the target specify whether the instruction is actually trivially rematerializable, taking into consideration its operands.

This predicate must return false if the instruction has any side effects other than producing a value, or if it requres any address registers that are not always available. Requirements must be check as stated in isTriviallyReMaterializable() .

Definition at line 92 of file TargetInstrInfo.h.

Referenced by isTriviallyReMaterializable().

virtual bool llvm::TargetInstrInfo::isSafeToMoveRegClassDefs ( const TargetRegisterClass RC) const
inlinevirtual

Return true if it's safe to move a machine instruction that defines the specified register class.

Definition at line 954 of file TargetInstrInfo.h.

bool TargetInstrInfo::isSchedulingBoundary ( const MachineInstr MI,
const MachineBasicBlock MBB,
const MachineFunction MF 
) const
virtual

Test if the given instruction should be considered a scheduling boundary.

isSchedulingBoundary - Test if the given instruction should be considered a scheduling boundary.

This primarily includes labels and terminators.

Definition at line 675 of file TargetInstrInfo.cpp.

References llvm::TargetSubtargetInfo::getRegisterInfo(), llvm::TargetLoweringBase::getStackPointerRegisterToSaveRestore(), llvm::MachineFunction::getSubtarget(), llvm::TargetSubtargetInfo::getTargetLowering(), llvm::MachineInstr::isPosition(), llvm::MachineInstr::isTerminator(), and llvm::MachineInstr::modifiesRegister().

Referenced by isSchedBoundary().

virtual bool llvm::TargetInstrInfo::isStackSlotCopy ( const MachineInstr MI,
int DestFrameIndex,
int SrcFrameIndex 
) const
inlinevirtual

Return true if the specified machine instruction is a copy of one stack slot to another and has no other effect.

Provide the identity of the two frame indices.

Definition at line 188 of file TargetInstrInfo.h.

virtual unsigned llvm::TargetInstrInfo::isStoreToStackSlot ( const MachineInstr MI,
int FrameIndex 
) const
inlinevirtual

If the specified machine instruction is a direct store to a stack slot, return the virtual or physical register number of the source reg along with the FrameIndex of the loaded stack slot.

If not, return 0. This predicate must return 0 if the instruction has any side effects other than storing to the stack slot.

Definition at line 163 of file TargetInstrInfo.h.

Referenced by llvm::X86FrameLowering::emitPrologue().

virtual unsigned llvm::TargetInstrInfo::isStoreToStackSlotPostFE ( const MachineInstr MI,
int FrameIndex 
) const
inlinevirtual

Check for post-frame ptr elimination stack locations as well.

This uses a heuristic, so it isn't reliable for correctness.

Definition at line 170 of file TargetInstrInfo.h.

Referenced by emitComments().

bool llvm::TargetInstrInfo::isTriviallyReMaterializable ( const MachineInstr MI,
AliasAnalysis AA = nullptr 
) const
inline

Return true if the instruction is trivially rematerializable, meaning it has no side effects and requires no operands that aren't always available.

This means the only allowed uses are constants and unallocatable physical registers so that the instructions result is independent of the place in the function.

Definition at line 76 of file TargetInstrInfo.h.

References llvm::MachineInstr::getDesc(), llvm::MachineInstr::getOpcode(), llvm::TargetOpcode::IMPLICIT_DEF, isReallyTriviallyReMaterializable(), and llvm::MCInstrDesc::isRematerializable().

Referenced by llvm::LiveRangeEdit::checkRematerializable(), and isRematerializable().

bool TargetInstrInfo::isUnpredicatedTerminator ( const MachineInstr MI) const
virtual

Returns true if the instruction is a terminator instruction that has not been predicated.

Definition at line 212 of file TargetInstrInfo.cpp.

References llvm::MachineInstr::isBarrier(), llvm::MachineInstr::isBranch(), llvm::MachineInstr::isPredicable(), isPredicated(), and llvm::MachineInstr::isTerminator().

Referenced by findHoistingInsertPosAndDeps().

bool llvm::TargetInstrInfo::isZeroCost ( unsigned  Opcode) const
inline

Return true for pseudo instructions that don't consume any machine resources in their current form.

These are common cases that the scheduler should consider free, rather than conservatively handling them as instructions with no itinerary.

Definition at line 1048 of file TargetInstrInfo.h.

References llvm::TargetOpcode::COPY.

Referenced by llvm::ScoreboardHazardRecognizer::EmitInstruction().

virtual void llvm::TargetInstrInfo::loadRegFromStackSlot ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI,
unsigned  DestReg,
int  FrameIndex,
const TargetRegisterClass RC,
const TargetRegisterInfo TRI 
) const
inlinevirtual

Load the specified register of the given register class from the specified stack frame index.

The load instruction is to be added to the given machine basic block before the specified machine instruction.

Definition at line 687 of file TargetInstrInfo.h.

References llvm_unreachable.

Referenced by foldMemoryOperand(), llvm::SystemZFrameLowering::restoreCalleeSavedRegisters(), llvm::XCoreFrameLowering::restoreCalleeSavedRegisters(), llvm::X86FrameLowering::restoreCalleeSavedRegisters(), and llvm::RegScavenger::scavengeRegister().

virtual bool llvm::TargetInstrInfo::optimizeCompareInstr ( MachineInstr CmpInstr,
unsigned  SrcReg,
unsigned  SrcReg2,
int  Mask,
int  Value,
const MachineRegisterInfo MRI 
) const
inlinevirtual

See if the comparison instruction can be converted into something more efficient.

E.g., on ARM most instructions can set the flags register, obviating the need for a separate CMP.

Definition at line 1004 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::optimizeCondBranch ( MachineInstr MI) const
inlinevirtual

Definition at line 1010 of file TargetInstrInfo.h.

virtual MachineInstr* llvm::TargetInstrInfo::optimizeLoadInstr ( MachineInstr MI,
const MachineRegisterInfo MRI,
unsigned FoldAsLoadDefReg,
MachineInstr *&  DefMI 
) const
inlinevirtual

Try to remove the load by folding it to a register operand at the use.

We fold the load instructions if and only if the def and use are in the same BB. We only look at one load and see whether it can be folded into MI. FoldAsLoadDefReg is the virtual register defined by the load we are trying to fold. DefMI returns the machine instruction that defines FoldAsLoadDefReg, and the function returns the machine instruction generated due to folding.

Definition at line 1019 of file TargetInstrInfo.h.

virtual MachineInstr* llvm::TargetInstrInfo::optimizeSelect ( MachineInstr MI,
SmallPtrSetImpl< MachineInstr * > &  NewMIs,
bool  PreferFalse = false 
) const
inlinevirtual

Given a select instruction that was understood by analyzeSelect and returned Optimizable = true, attempt to optimize MI by merging it with one of its operands.

Returns NULL on failure.

When successful, returns the new select instruction. The client is responsible for deleting MI.

If both sides of the select can be optimized, PreferFalse is used to pick a side.

Parameters
MIOptimizable select instruction.
NewMIsSet that record all MIs in the basic block up to MI. Has to be updated with any newly created MI or deleted ones.
PreferFalseTry to optimize FalseOp instead of TrueOp.
Returns
Optimized instruction or NULL.

Definition at line 649 of file TargetInstrInfo.h.

References llvm_unreachable.

bool TargetInstrInfo::PredicateInstruction ( MachineInstr MI,
ArrayRef< MachineOperand Pred 
) const
virtual
bool TargetInstrInfo::produceSameValue ( const MachineInstr MI0,
const MachineInstr MI1,
const MachineRegisterInfo MRI = nullptr 
) const
virtual

Return true if two machine instructions would produce identical values.

By default, this is only true when the two instructions are deemed identical except for defs. If this function is called when the IR is still in SSA form, the caller can pass the MachineRegisterInfo for aggressive checks.

Definition at line 336 of file TargetInstrInfo.cpp.

References llvm::MachineInstr::IgnoreVRegDefs, and llvm::MachineInstr::isIdenticalTo().

void TargetInstrInfo::reMaterialize ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI,
unsigned  DestReg,
unsigned  SubIdx,
const MachineInstr Orig,
const TargetRegisterInfo TRI 
) const
virtual

Re-issue the specified 'original' instruction at the specific location targeting a new destination register.

The register in Orig->getOperand(0).getReg() will be substituted by DestReg:SubIdx. Any existing subreg index is preserved or composed with SubIdx.

Definition at line 324 of file TargetInstrInfo.cpp.

References llvm::MachineFunction::CloneMachineInstr(), llvm::MachineInstr::getOperand(), llvm::MachineBasicBlock::getParent(), llvm::MachineOperand::getReg(), llvm::MachineBasicBlock::insert(), llvm::AArch64CC::MI, and llvm::MachineInstr::substituteRegister().

Referenced by llvm::LiveRangeEdit::rematerializeAt().

virtual unsigned llvm::TargetInstrInfo::RemoveBranch ( MachineBasicBlock MBB) const
inlinevirtual

Remove the branching code at the end of the specific MBB.

This is only invoked in cases where AnalyzeBranch returns success. It returns the number of instructions that were removed.

Definition at line 438 of file TargetInstrInfo.h.

References llvm_unreachable.

Referenced by FixTail(), and llvm::MachineBasicBlock::updateTerminator().

void TargetInstrInfo::ReplaceTailWithBranchTo ( MachineBasicBlock::iterator  Tail,
MachineBasicBlock NewDest 
) const
virtual

Delete the instruction OldInst and everything after it, replacing it with an unconditional branch to NewDest.

ReplaceTailWithBranchTo - Delete the instruction OldInst and everything after it, replacing it with an unconditional branch to NewDest.

This is used by the tail merging pass.

Definition at line 103 of file TargetInstrInfo.cpp.

References llvm::MachineBasicBlock::addSuccessor(), llvm::MachineBasicBlock::end(), llvm::MachineBasicBlock::erase(), llvm::MachineBasicBlock::getParent(), InsertBranch(), llvm::MachineBasicBlock::removeSuccessor(), llvm::MachineBasicBlock::succ_begin(), and llvm::MachineBasicBlock::succ_empty().

Referenced by llvm::Thumb2InstrInfo::ReplaceTailWithBranchTo().

virtual bool llvm::TargetInstrInfo::ReverseBranchCondition ( SmallVectorImpl< MachineOperand > &  Cond) const
inlinevirtual

Reverses the branch condition of the specified condition list, returning false on success and true if it cannot be reversed.

Definition at line 901 of file TargetInstrInfo.h.

Referenced by FixTail(), and llvm::MachineBasicBlock::updateTerminator().

virtual void llvm::TargetInstrInfo::setExecutionDomain ( MachineInstr MI,
unsigned  Domain 
) const
inlinevirtual

Change the opcode of MI to execute in Domain.

The bit (1 << Domain) must be set in the mask returned from getExecutionDomain(MI).

Definition at line 1151 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::shouldClusterLoads ( MachineInstr FirstLdSt,
MachineInstr SecondLdSt,
unsigned  NumLoads 
) const
inlinevirtual

Definition at line 885 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::shouldScheduleAdjacent ( MachineInstr First,
MachineInstr Second 
) const
inlinevirtual

Can this target fuse the given instructions if they are scheduled adjacent.

Definition at line 893 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::shouldScheduleLoadsNear ( SDNode Load1,
SDNode Load2,
int64_t  Offset1,
int64_t  Offset2,
unsigned  NumLoads 
) const
inlinevirtual

This is a used by the pre-regalloc scheduler to determine (in conjunction with areLoadsFromSameBasePtr) if two loads should be scheduled together.

On some targets if two loads are loading from addresses in the same cache line, it's better if they are scheduled together. This function takes two integers that represent the load offsets from the common base address. It returns true if it decides it's desirable to schedule the two loads together. "NumLoads" is the number of loads that have already been scheduled after Load1.

Definition at line 869 of file TargetInstrInfo.h.

virtual void llvm::TargetInstrInfo::storeRegToStackSlot ( MachineBasicBlock MBB,
MachineBasicBlock::iterator  MI,
unsigned  SrcReg,
bool  isKill,
int  FrameIndex,
const TargetRegisterClass RC,
const TargetRegisterInfo TRI 
) const
inlinevirtual

Store the specified register of the given register class to the specified stack frame index.

The store instruction is to be added to the given machine basic block before the specified machine instruction. If isKill is true, the register operand is the last use and must be marked kill.

Definition at line 675 of file TargetInstrInfo.h.

References llvm_unreachable.

Referenced by foldMemoryOperand(), llvm::RegScavenger::scavengeRegister(), llvm::MipsSEFrameLowering::spillCalleeSavedRegisters(), llvm::SystemZFrameLowering::spillCalleeSavedRegisters(), llvm::XCoreFrameLowering::spillCalleeSavedRegisters(), and llvm::X86FrameLowering::spillCalleeSavedRegisters().

virtual bool llvm::TargetInstrInfo::SubsumesPredicate ( ArrayRef< MachineOperand Pred1,
ArrayRef< MachineOperand Pred2 
) const
inlinevirtual

Returns true if the first specified predicate subsumes the second, e.g.

GE subsumes GT.

Definition at line 932 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::unfoldMemoryOperand ( MachineFunction MF,
MachineInstr MI,
unsigned  Reg,
bool  UnfoldLoad,
bool  UnfoldStore,
SmallVectorImpl< MachineInstr * > &  NewMIs 
) const
inlinevirtual

unfoldMemoryOperand - Separate a single instruction which folded a load or a store or a load and a store into two or more instruction.

If this is possible, returns true as well as the new instructions by reference.

Definition at line 829 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::unfoldMemoryOperand ( SelectionDAG DAG,
SDNode N,
SmallVectorImpl< SDNode * > &  NewNodes 
) const
inlinevirtual

Definition at line 835 of file TargetInstrInfo.h.

virtual bool llvm::TargetInstrInfo::useMachineCombiner ( ) const
inlinevirtual

Return true when a target supports MachineCombiner.

Definition at line 753 of file TargetInstrInfo.h.

bool TargetInstrInfo::usePreRAHazardRecognizer ( ) const

Provide a global flag for disabling the PreRA hazard recognizer that targets may choose to honor.

Definition at line 697 of file TargetInstrInfo.cpp.

References DisableHazardRecognizer.

virtual bool llvm::TargetInstrInfo::verifyInstruction ( const MachineInstr MI,
StringRef ErrInfo 
) const
inlinevirtual

Perform target-specific instruction verification.

Definition at line 1119 of file TargetInstrInfo.h.


The documentation for this class was generated from the following files: