2003-01-13 00:21:19 +00:00
|
|
|
//===-- llvm/Target/TargetInstrInfo.h - Instruction Info --------*- C++ -*-===//
|
2005-04-21 20:59:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 19:59:42 +00:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 20:59:05 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-09-18 12:38:31 +00:00
|
|
|
//
|
2008-07-16 16:02:59 +00:00
|
|
|
// This file describes the target machine instruction set to the code generator.
|
2001-09-18 12:38:31 +00:00
|
|
|
//
|
2002-12-03 05:41:32 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-09-18 12:38:31 +00:00
|
|
|
|
2003-01-14 22:00:31 +00:00
|
|
|
#ifndef LLVM_TARGET_TARGETINSTRINFO_H
|
|
|
|
#define LLVM_TARGET_TARGETINSTRINFO_H
|
2001-09-18 12:38:31 +00:00
|
|
|
|
2014-08-03 21:35:39 +00:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2015-01-14 11:23:27 +00:00
|
|
|
#include "llvm/ADT/SmallSet.h"
|
2014-08-03 21:35:39 +00:00
|
|
|
#include "llvm/CodeGen/MachineCombinerPattern.h"
|
2015-01-14 11:23:27 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2012-12-03 17:02:12 +00:00
|
|
|
#include "llvm/MC/MCInstrInfo.h"
|
2014-08-03 21:35:39 +00:00
|
|
|
#include "llvm/Target/TargetRegisterInfo.h"
|
2001-09-18 12:38:31 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2010-06-12 00:12:18 +00:00
|
|
|
class InstrItineraryData;
|
2010-03-03 01:44:33 +00:00
|
|
|
class LiveVariables;
|
|
|
|
class MCAsmInfo;
|
|
|
|
class MachineMemOperand;
|
2010-10-19 18:58:51 +00:00
|
|
|
class MachineRegisterInfo;
|
2010-04-26 07:38:55 +00:00
|
|
|
class MDNode;
|
2010-04-26 23:37:21 +00:00
|
|
|
class MCInst;
|
2014-09-02 17:43:54 +00:00
|
|
|
struct MCSchedModel;
|
2014-06-05 19:29:43 +00:00
|
|
|
class MCSymbolRefExpr;
|
2008-01-07 01:35:02 +00:00
|
|
|
class SDNode;
|
2010-06-12 00:12:18 +00:00
|
|
|
class ScheduleHazardRecognizer;
|
2008-01-07 01:35:02 +00:00
|
|
|
class SelectionDAG;
|
Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.
Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.
Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.
Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.
ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.
ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
class ScheduleDAG;
|
2010-03-03 01:44:33 +00:00
|
|
|
class TargetRegisterClass;
|
|
|
|
class TargetRegisterInfo;
|
2011-07-10 02:58:07 +00:00
|
|
|
class BranchProbability;
|
2014-06-13 22:38:52 +00:00
|
|
|
class TargetSubtargetInfo;
|
2014-10-14 01:13:53 +00:00
|
|
|
class DFAPacketizer;
|
2001-09-18 12:38:31 +00:00
|
|
|
|
2008-01-01 21:11:32 +00:00
|
|
|
template<class T> class SmallVectorImpl;
|
|
|
|
|
2001-09-18 12:38:31 +00:00
|
|
|
|
2003-01-14 22:00:31 +00:00
|
|
|
//---------------------------------------------------------------------------
|
2005-04-21 20:59:05 +00:00
|
|
|
///
|
2008-07-16 16:02:59 +00:00
|
|
|
/// TargetInstrInfo - Interface to description of machine instruction set
|
2005-04-21 20:59:05 +00:00
|
|
|
///
|
2011-06-28 19:10:37 +00:00
|
|
|
class TargetInstrInfo : public MCInstrInfo {
|
2012-09-17 06:59:23 +00:00
|
|
|
TargetInstrInfo(const TargetInstrInfo &) LLVM_DELETED_FUNCTION;
|
|
|
|
void operator=(const TargetInstrInfo &) LLVM_DELETED_FUNCTION;
|
2001-09-18 12:38:31 +00:00
|
|
|
public:
|
2011-07-01 17:57:27 +00:00
|
|
|
TargetInstrInfo(int CFSetupOpcode = -1, int CFDestroyOpcode = -1)
|
|
|
|
: CallFrameSetupOpcode(CFSetupOpcode),
|
|
|
|
CallFrameDestroyOpcode(CFDestroyOpcode) {
|
|
|
|
}
|
2011-09-21 02:20:46 +00:00
|
|
|
|
2003-01-13 00:21:19 +00:00
|
|
|
virtual ~TargetInstrInfo();
|
2002-12-15 22:16:08 +00:00
|
|
|
|
2011-06-27 21:26:13 +00:00
|
|
|
/// getRegClass - Givem a machine instruction descriptor, returns the register
|
|
|
|
/// class constraint for OpNum, or NULL.
|
2011-06-28 19:10:37 +00:00
|
|
|
const TargetRegisterClass *getRegClass(const MCInstrDesc &TID,
|
2011-06-27 21:26:13 +00:00
|
|
|
unsigned OpNum,
|
2012-05-07 22:10:26 +00:00
|
|
|
const TargetRegisterInfo *TRI,
|
|
|
|
const MachineFunction &MF) const;
|
2011-06-27 21:26:13 +00:00
|
|
|
|
2007-12-08 23:58:46 +00:00
|
|
|
/// isTriviallyReMaterializable - Return true if the instruction is trivially
|
2007-06-26 00:48:07 +00:00
|
|
|
/// rematerializable, meaning it has no side effects and requires no operands
|
|
|
|
/// that aren't always available.
|
2009-10-09 23:27:56 +00:00
|
|
|
bool isTriviallyReMaterializable(const MachineInstr *MI,
|
2014-04-14 00:51:57 +00:00
|
|
|
AliasAnalysis *AA = nullptr) const {
|
2010-02-09 19:54:29 +00:00
|
|
|
return MI->getOpcode() == TargetOpcode::IMPLICIT_DEF ||
|
2009-10-09 23:27:56 +00:00
|
|
|
(MI->getDesc().isRematerializable() &&
|
2009-10-10 00:34:18 +00:00
|
|
|
(isReallyTriviallyReMaterializable(MI, AA) ||
|
2009-10-09 23:27:56 +00:00
|
|
|
isReallyTriviallyReMaterializableGeneric(MI, AA)));
|
2007-06-26 00:48:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2007-12-08 23:58:46 +00:00
|
|
|
/// isReallyTriviallyReMaterializable - For instructions with opcodes for
|
2009-10-09 23:27:56 +00:00
|
|
|
/// 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.
|
2009-10-10 00:34:18 +00:00
|
|
|
virtual bool isReallyTriviallyReMaterializable(const MachineInstr *MI,
|
|
|
|
AliasAnalysis *AA) const {
|
2009-10-09 23:27:56 +00:00
|
|
|
return false;
|
2007-06-26 00:48:07 +00:00
|
|
|
}
|
|
|
|
|
2009-10-09 23:27:56 +00:00
|
|
|
private:
|
|
|
|
/// isReallyTriviallyReMaterializableGeneric - For instructions with opcodes
|
|
|
|
/// for which the M_REMATERIALIZABLE flag is set and the target hook
|
|
|
|
/// isReallyTriviallyReMaterializable returns false, this function does
|
|
|
|
/// target-independent tests to determine if the instruction is really
|
|
|
|
/// trivially rematerializable.
|
|
|
|
bool isReallyTriviallyReMaterializableGeneric(const MachineInstr *MI,
|
|
|
|
AliasAnalysis *AA) const;
|
|
|
|
|
2007-06-26 00:48:07 +00:00
|
|
|
public:
|
2011-06-28 21:14:33 +00:00
|
|
|
/// getCallFrameSetup/DestroyOpcode - 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.
|
|
|
|
///
|
|
|
|
int getCallFrameSetupOpcode() const { return CallFrameSetupOpcode; }
|
|
|
|
int getCallFrameDestroyOpcode() const { return CallFrameDestroyOpcode; }
|
|
|
|
|
2015-01-08 11:04:38 +00:00
|
|
|
/// 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.
|
|
|
|
virtual int getSPAdjust(const MachineInstr *MI) const;
|
|
|
|
|
2010-01-13 00:30:23 +00:00
|
|
|
/// isCoalescableExtInstr - 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.
|
|
|
|
virtual bool isCoalescableExtInstr(const MachineInstr &MI,
|
|
|
|
unsigned &SrcReg, unsigned &DstReg,
|
|
|
|
unsigned &SubIdx) const {
|
2010-01-12 00:09:37 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-02-02 20:11:55 +00:00
|
|
|
/// isLoadFromStackSlot - 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.
|
2008-11-18 19:49:32 +00:00
|
|
|
virtual unsigned isLoadFromStackSlot(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const {
|
2006-02-02 20:11:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2009-11-12 20:55:29 +00:00
|
|
|
|
2009-11-13 00:29:53 +00:00
|
|
|
/// isLoadFromStackSlotPostFE - Check for post-frame ptr elimination
|
|
|
|
/// stack locations as well. This uses a heuristic so it isn't
|
|
|
|
/// reliable for correctness.
|
|
|
|
virtual unsigned isLoadFromStackSlotPostFE(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-12 20:55:29 +00:00
|
|
|
/// hasLoadFromStackSlot - If the specified machine instruction has
|
|
|
|
/// a load from a stack slot, return true along with the FrameIndex
|
2009-12-04 23:00:50 +00:00
|
|
|
/// of the loaded stack slot and the machine mem operand containing
|
|
|
|
/// the reference. If not, return false. Unlike
|
2009-11-12 20:55:29 +00:00
|
|
|
/// isLoadFromStackSlot, this returns true for any instructions that
|
|
|
|
/// loads from the stack. This is just a hint, as some cases may be
|
|
|
|
/// missed.
|
|
|
|
virtual bool hasLoadFromStackSlot(const MachineInstr *MI,
|
2009-12-04 23:00:50 +00:00
|
|
|
const MachineMemOperand *&MMO,
|
2012-11-28 02:35:13 +00:00
|
|
|
int &FrameIndex) const;
|
2010-12-24 04:28:06 +00:00
|
|
|
|
2006-02-02 20:11:55 +00:00
|
|
|
/// isStoreToStackSlot - 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.
|
2008-11-18 19:49:32 +00:00
|
|
|
virtual unsigned isStoreToStackSlot(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const {
|
2006-02-02 20:11:55 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2003-12-28 17:35:08 +00:00
|
|
|
|
2009-11-13 00:29:53 +00:00
|
|
|
/// isStoreToStackSlotPostFE - Check for post-frame ptr elimination
|
|
|
|
/// stack locations as well. This uses a heuristic so it isn't
|
|
|
|
/// reliable for correctness.
|
|
|
|
virtual unsigned isStoreToStackSlotPostFE(const MachineInstr *MI,
|
2009-12-04 23:00:50 +00:00
|
|
|
int &FrameIndex) const {
|
2009-11-13 00:29:53 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-12 20:55:29 +00:00
|
|
|
/// hasStoreToStackSlot - If the specified machine instruction has a
|
|
|
|
/// store to a stack slot, return true along with the FrameIndex of
|
2009-12-04 23:00:50 +00:00
|
|
|
/// the loaded stack slot and the machine mem operand containing the
|
|
|
|
/// reference. If not, return false. Unlike isStoreToStackSlot,
|
2010-04-07 23:51:38 +00:00
|
|
|
/// this returns true for any instructions that stores to the
|
2009-12-04 23:00:50 +00:00
|
|
|
/// stack. This is just a hint, as some cases may be missed.
|
2009-11-12 20:55:29 +00:00
|
|
|
virtual bool hasStoreToStackSlot(const MachineInstr *MI,
|
2009-12-04 23:00:50 +00:00
|
|
|
const MachineMemOperand *&MMO,
|
2012-11-28 02:35:13 +00:00
|
|
|
int &FrameIndex) const;
|
2009-11-12 20:55:29 +00:00
|
|
|
|
2013-07-05 14:38:48 +00:00
|
|
|
/// isStackSlotCopy - 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.
|
|
|
|
virtual bool isStackSlotCopy(const MachineInstr *MI, int &DestFrameIndex,
|
|
|
|
int &SrcFrameIndex) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-11-17 01:36:23 +00:00
|
|
|
/// Compute the size in bytes and offset within a stack slot of a spilled
|
|
|
|
/// register or subregister.
|
|
|
|
///
|
|
|
|
/// \param [out] Size in bytes of the spilled value.
|
|
|
|
/// \param [out] Offset in 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.
|
|
|
|
virtual bool getStackSlotRange(const TargetRegisterClass *RC, unsigned SubIdx,
|
|
|
|
unsigned &Size, unsigned &Offset,
|
|
|
|
const TargetMachine *TM) const;
|
|
|
|
|
2014-07-29 01:55:19 +00:00
|
|
|
/// isAsCheapAsAMove - 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.
|
|
|
|
virtual bool isAsCheapAsAMove(const MachineInstr *MI) const {
|
|
|
|
return MI->isAsCheapAsAMove();
|
|
|
|
}
|
|
|
|
|
2008-03-31 20:40:39 +00:00
|
|
|
/// reMaterialize - Re-issue the specified 'original' instruction at the
|
|
|
|
/// specific location targeting a new destination register.
|
2010-06-02 22:47:25 +00:00
|
|
|
/// The register in Orig->getOperand(0).getReg() will be substituted by
|
|
|
|
/// DestReg:SubIdx. Any existing subreg index is preserved or composed with
|
|
|
|
/// SubIdx.
|
2008-03-31 20:40:39 +00:00
|
|
|
virtual void reMaterialize(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
2009-07-16 09:20:10 +00:00
|
|
|
unsigned DestReg, unsigned SubIdx,
|
2009-11-14 02:55:43 +00:00
|
|
|
const MachineInstr *Orig,
|
2012-11-28 02:35:13 +00:00
|
|
|
const TargetRegisterInfo &TRI) const;
|
2008-03-31 20:40:39 +00:00
|
|
|
|
2010-01-06 23:47:07 +00:00
|
|
|
/// duplicate - 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.
|
2010-01-07 00:51:04 +00:00
|
|
|
///
|
|
|
|
/// The instruction must be duplicable as indicated by isNotDuplicable().
|
2010-01-06 23:47:07 +00:00
|
|
|
virtual MachineInstr *duplicate(MachineInstr *Orig,
|
2012-11-28 02:35:13 +00:00
|
|
|
MachineFunction &MF) const;
|
2010-01-06 23:47:07 +00:00
|
|
|
|
2005-01-02 02:28:31 +00:00
|
|
|
/// convertToThreeAddress - This method must be implemented by targets that
|
|
|
|
/// set the M_CONVERTIBLE_TO_3_ADDR flag. When this flag is set, the target
|
2007-07-09 15:15:24 +00:00
|
|
|
/// may be able to convert a two-address instruction into one or more true
|
2006-12-01 21:46:55 +00:00
|
|
|
/// three-address instructions on demand. This allows the X86 target (for
|
2005-01-02 02:28:31 +00:00
|
|
|
/// 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
|
2006-12-01 21:46:55 +00:00
|
|
|
/// performed, otherwise it returns the last new instruction.
|
2005-01-02 02:28:31 +00:00
|
|
|
///
|
2006-12-01 21:46:55 +00:00
|
|
|
virtual MachineInstr *
|
|
|
|
convertToThreeAddress(MachineFunction::iterator &MFI,
|
2008-07-02 23:41:07 +00:00
|
|
|
MachineBasicBlock::iterator &MBBI, LiveVariables *LV) const {
|
2014-04-14 00:51:57 +00:00
|
|
|
return nullptr;
|
2005-01-02 02:28:31 +00:00
|
|
|
}
|
|
|
|
|
2010-06-24 16:48:26 +00:00
|
|
|
/// commuteInstruction - 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.
|
2008-06-16 07:33:11 +00:00
|
|
|
virtual MachineInstr *commuteInstruction(MachineInstr *MI,
|
2012-11-28 02:35:13 +00:00
|
|
|
bool NewMI = false) const;
|
2005-01-19 06:53:02 +00:00
|
|
|
|
2009-07-10 19:15:51 +00:00
|
|
|
/// findCommutedOpIndices - If specified MI is commutable, return the two
|
2010-06-24 16:48:26 +00:00
|
|
|
/// operand indices that would swap value. Return false if the instruction
|
2009-07-10 19:15:51 +00:00
|
|
|
/// is not in a form which this routine understands.
|
|
|
|
virtual bool findCommutedOpIndices(MachineInstr *MI, unsigned &SrcOpIdx1,
|
2012-11-28 02:35:13 +00:00
|
|
|
unsigned &SrcOpIdx2) const;
|
2008-02-15 18:21:33 +00:00
|
|
|
|
2014-08-11 22:17:14 +00:00
|
|
|
/// A pair composed of a register and a sub-register index.
|
|
|
|
/// Used to give some type checking when modeling Reg:SubReg.
|
|
|
|
struct RegSubRegPair {
|
|
|
|
unsigned Reg;
|
|
|
|
unsigned SubReg;
|
|
|
|
RegSubRegPair(unsigned Reg = 0, unsigned SubReg = 0)
|
|
|
|
: Reg(Reg), SubReg(SubReg) {}
|
|
|
|
};
|
|
|
|
/// A pair composed of a pair of a register and a sub-register index,
|
|
|
|
/// and another sub-register index.
|
|
|
|
/// Used to give some type checking when modeling Reg:SubReg1, SubReg2.
|
|
|
|
struct RegSubRegPairAndIdx : RegSubRegPair {
|
|
|
|
unsigned SubIdx;
|
|
|
|
RegSubRegPairAndIdx(unsigned Reg = 0, unsigned SubReg = 0,
|
|
|
|
unsigned SubIdx = 0)
|
|
|
|
: RegSubRegPair(Reg, SubReg), SubIdx(SubIdx) {}
|
|
|
|
};
|
|
|
|
|
|
|
|
/// Build the equivalent inputs of a REG_SEQUENCE for the given \p MI
|
|
|
|
/// and \p DefIdx.
|
|
|
|
/// \p [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 \p MI, \p DefIdx. False otherwise.
|
|
|
|
///
|
|
|
|
/// \pre 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.
|
|
|
|
bool
|
|
|
|
getRegSequenceInputs(const MachineInstr &MI, unsigned DefIdx,
|
|
|
|
SmallVectorImpl<RegSubRegPairAndIdx> &InputRegs) const;
|
|
|
|
|
2014-08-20 21:51:26 +00:00
|
|
|
/// Build the equivalent inputs of a EXTRACT_SUBREG for the given \p MI
|
|
|
|
/// and \p DefIdx.
|
|
|
|
/// \p [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 \p MI, \p DefIdx. False otherwise.
|
|
|
|
///
|
|
|
|
/// \pre 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.
|
|
|
|
bool
|
|
|
|
getExtractSubregInputs(const MachineInstr &MI, unsigned DefIdx,
|
|
|
|
RegSubRegPairAndIdx &InputReg) const;
|
|
|
|
|
2014-08-20 23:49:36 +00:00
|
|
|
/// Build the equivalent inputs of a INSERT_SUBREG for the given \p MI
|
|
|
|
/// and \p DefIdx.
|
|
|
|
/// \p [out] BaseReg and \p [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 \p MI, \p DefIdx. False otherwise.
|
|
|
|
///
|
|
|
|
/// \pre 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.
|
|
|
|
bool
|
|
|
|
getInsertSubregInputs(const MachineInstr &MI, unsigned DefIdx,
|
|
|
|
RegSubRegPair &BaseReg,
|
|
|
|
RegSubRegPairAndIdx &InsertedReg) const;
|
|
|
|
|
|
|
|
|
2010-03-03 01:44:33 +00:00
|
|
|
/// produceSameValue - Return true if two machine instructions would produce
|
|
|
|
/// identical values. By default, this is only true when the two instructions
|
2011-01-20 08:34:58 +00:00
|
|
|
/// 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.
|
2010-03-03 01:44:33 +00:00
|
|
|
virtual bool produceSameValue(const MachineInstr *MI0,
|
2011-01-20 08:34:58 +00:00
|
|
|
const MachineInstr *MI1,
|
2014-04-14 00:51:57 +00:00
|
|
|
const MachineRegisterInfo *MRI = nullptr) const;
|
2009-11-07 04:07:30 +00:00
|
|
|
|
2006-10-13 20:44:01 +00:00
|
|
|
/// AnalyzeBranch - 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:
|
|
|
|
///
|
2006-10-17 22:12:15 +00:00
|
|
|
/// 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
|
2006-10-13 20:44:01 +00:00
|
|
|
/// the destination block.
|
2009-12-14 06:51:19 +00:00
|
|
|
/// 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.
|
2009-08-20 01:33:25 +00:00
|
|
|
/// 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.
|
2006-10-13 20:44:01 +00:00
|
|
|
///
|
|
|
|
/// Note that RemoveBranch and InsertBranch must be implemented to support
|
|
|
|
/// cases where this method returns success.
|
|
|
|
///
|
2009-02-09 07:14:22 +00:00
|
|
|
/// If AllowModify is true, then this routine is allowed to modify the basic
|
|
|
|
/// block (e.g. delete instructions after the unconditional branch).
|
|
|
|
///
|
2006-10-13 20:44:01 +00:00
|
|
|
virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
|
|
|
MachineBasicBlock *&FBB,
|
2009-02-09 07:14:22 +00:00
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
bool AllowModify = false) const {
|
2006-10-13 20:44:01 +00:00
|
|
|
return true;
|
2004-07-31 08:52:30 +00:00
|
|
|
}
|
2009-08-20 01:33:25 +00:00
|
|
|
|
2006-10-13 20:44:01 +00:00
|
|
|
/// RemoveBranch - Remove the branching code at the end of the specific MBB.
|
2008-10-20 15:58:02 +00:00
|
|
|
/// This is only invoked in cases where AnalyzeBranch returns success. It
|
2007-05-18 00:05:48 +00:00
|
|
|
/// returns the number of instructions that were removed.
|
|
|
|
virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const {
|
2012-02-05 22:14:15 +00:00
|
|
|
llvm_unreachable("Target didn't implement TargetInstrInfo::RemoveBranch!");
|
2006-10-13 20:44:01 +00:00
|
|
|
}
|
2009-08-20 01:33:25 +00:00
|
|
|
|
|
|
|
/// InsertBranch - 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.
|
2009-02-19 19:40:21 +00:00
|
|
|
///
|
|
|
|
/// 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.
|
2007-05-18 00:05:48 +00:00
|
|
|
virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
|
2010-06-17 22:43:56 +00:00
|
|
|
MachineBasicBlock *FBB,
|
|
|
|
const SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
DebugLoc DL) const {
|
2012-02-05 22:14:15 +00:00
|
|
|
llvm_unreachable("Target didn't implement TargetInstrInfo::InsertBranch!");
|
2006-10-13 20:44:01 +00:00
|
|
|
}
|
2010-06-18 23:09:54 +00:00
|
|
|
|
|
|
|
/// 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.
|
|
|
|
virtual void ReplaceTailWithBranchTo(MachineBasicBlock::iterator Tail,
|
2012-11-28 02:35:13 +00:00
|
|
|
MachineBasicBlock *NewDest) const;
|
2010-06-22 01:18:16 +00:00
|
|
|
|
2014-06-05 19:29:43 +00:00
|
|
|
/// getUnconditionalBranch - Get an instruction that performs an unconditional
|
|
|
|
/// branch to the given symbol.
|
|
|
|
virtual void
|
|
|
|
getUnconditionalBranch(MCInst &MI,
|
|
|
|
const MCSymbolRefExpr *BranchTarget) const {
|
|
|
|
llvm_unreachable("Target didn't implement "
|
|
|
|
"TargetInstrInfo::getUnconditionalBranch!");
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getTrap - Get a machine trap instruction
|
|
|
|
virtual void getTrap(MCInst &MI) const {
|
|
|
|
llvm_unreachable("Target didn't implement TargetInstrInfo::getTrap!");
|
|
|
|
}
|
|
|
|
|
2014-11-11 21:08:02 +00:00
|
|
|
/// getJumpInstrTableEntryBound - 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.
|
|
|
|
virtual unsigned getJumpInstrTableEntryBound() const {
|
|
|
|
// This method gets called by LLVMTargetMachine always, so it can't fail
|
|
|
|
// just because there happens to be no implementation for this target.
|
|
|
|
// Any code that tries to use a jumptable annotation without defining
|
|
|
|
// getUnconditionalBranch on the appropriate Target will fail anyway, and
|
|
|
|
// the value returned here won't matter in that case.
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-22 01:18:16 +00:00
|
|
|
/// isLegalToSplitMBBAt - 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).
|
|
|
|
virtual bool isLegalToSplitMBBAt(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MBBI) const {
|
|
|
|
return true;
|
|
|
|
}
|
2010-06-25 22:42:03 +00:00
|
|
|
|
2010-11-03 00:45:17 +00:00
|
|
|
/// isProfitableToIfCvt - Return true if it's profitable to predicate
|
|
|
|
/// instructions with accumulated instruction latency of "NumCycles"
|
2010-09-28 18:32:13 +00:00
|
|
|
/// of the specified basic block, where the probability of the instructions
|
2010-10-01 22:45:50 +00:00
|
|
|
/// being executed is given by Probability, and Confidence is a measure
|
|
|
|
/// of our confidence that it will be properly predicted.
|
2010-06-25 22:42:03 +00:00
|
|
|
virtual
|
2012-06-13 15:53:04 +00:00
|
|
|
bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCycles,
|
2010-11-03 00:45:17 +00:00
|
|
|
unsigned ExtraPredCycles,
|
2011-07-10 02:58:07 +00:00
|
|
|
const BranchProbability &Probability) const {
|
2010-06-25 22:42:03 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-12-24 04:28:06 +00:00
|
|
|
|
2010-06-25 22:42:03 +00:00
|
|
|
/// isProfitableToIfCvt - 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
|
2010-09-28 18:32:13 +00:00
|
|
|
/// predicates, where the probability of the true path being taken is given
|
2010-10-01 22:45:50 +00:00
|
|
|
/// by Probability, and Confidence is a measure of our confidence that it
|
|
|
|
/// will be properly predicted.
|
2010-06-25 22:42:03 +00:00
|
|
|
virtual bool
|
2010-11-03 00:45:17 +00:00
|
|
|
isProfitableToIfCvt(MachineBasicBlock &TMBB,
|
|
|
|
unsigned NumTCycles, unsigned ExtraTCycles,
|
|
|
|
MachineBasicBlock &FMBB,
|
|
|
|
unsigned NumFCycles, unsigned ExtraFCycles,
|
2011-07-10 02:58:07 +00:00
|
|
|
const BranchProbability &Probability) const {
|
2010-06-25 22:42:03 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// isProfitableToDupForIfCvt - Return true if it's profitable for
|
2010-11-03 00:45:17 +00:00
|
|
|
/// 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.
|
2010-06-25 22:42:03 +00:00
|
|
|
virtual bool
|
2012-06-13 15:53:04 +00:00
|
|
|
isProfitableToDupForIfCvt(MachineBasicBlock &MBB, unsigned NumCycles,
|
2011-07-10 02:58:07 +00:00
|
|
|
const BranchProbability &Probability) const {
|
2010-06-25 22:42:03 +00:00
|
|
|
return false;
|
|
|
|
}
|
2010-12-24 04:28:06 +00:00
|
|
|
|
Add a if-conversion optimization that allows 'true' side of a diamond to be
unpredicated. That is, turn
subeq r0, r1, #1
addne r0, r1, #1
into
sub r0, r1, #1
addne r0, r1, #1
For targets where conditional instructions are always executed, this may be
beneficial. It may remove pseudo anti-dependency in out-of-order execution
CPUs. e.g.
op r1, ...
str r1, [r10] ; end-of-life of r1 as div result
cmp r0, #65
movne r1, #44 ; raw dependency on previous r1
moveq r1, #12
If movne is unpredicated, then
op r1, ...
str r1, [r10]
cmp r0, #65
mov r1, #44 ; r1 written unconditionally
moveq r1, #12
Both mov and moveq are no longer depdendent on the first instruction. This gives
the out-of-order execution engine more freedom to reorder them.
This has passed entire LLVM test suite. But it has not been enabled for any ARM
variant pending more performance evaluation.
rdar://8951196
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@146914 91177308-0d34-0410-b5e6-96231b3b80d8
2011-12-19 22:01:30 +00:00
|
|
|
/// isProfitableToUnpredicate - 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.
|
|
|
|
virtual bool isProfitableToUnpredicate(MachineBasicBlock &TMBB,
|
|
|
|
MachineBasicBlock &FMBB) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-07-04 00:09:54 +00:00
|
|
|
/// canInsertSelect - 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,
|
2013-04-05 01:25:41 +00:00
|
|
|
/// 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.
|
2012-07-04 00:09:54 +00:00
|
|
|
///
|
|
|
|
/// @param MBB Block where select instruction would be inserted.
|
|
|
|
/// @param Cond Condition returned by AnalyzeBranch.
|
|
|
|
/// @param TrueReg Virtual register to select when Cond is true.
|
|
|
|
/// @param FalseReg Virtual register to select when Cond is false.
|
|
|
|
/// @param CondCycles Latency from Cond+Branch to select output.
|
|
|
|
/// @param TrueCycles Latency from TrueReg to select output.
|
|
|
|
/// @param FalseCycles Latency from FalseReg to select output.
|
|
|
|
virtual bool canInsertSelect(const MachineBasicBlock &MBB,
|
|
|
|
const SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
unsigned TrueReg, unsigned FalseReg,
|
|
|
|
int &CondCycles,
|
|
|
|
int &TrueCycles, int &FalseCycles) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// insertSelect - 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.
|
|
|
|
///
|
|
|
|
/// @param MBB Block where select instruction should be inserted.
|
|
|
|
/// @param I Insertion point.
|
|
|
|
/// @param DL Source location for debugging.
|
|
|
|
/// @param DstReg Virtual register to be defined by select instruction.
|
|
|
|
/// @param Cond Condition as computed by AnalyzeBranch.
|
|
|
|
/// @param TrueReg Virtual register to copy when Cond is true.
|
|
|
|
/// @param FalseReg Virtual register to copy when Cons is false.
|
|
|
|
virtual void insertSelect(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator I, DebugLoc DL,
|
|
|
|
unsigned DstReg,
|
|
|
|
const SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
unsigned TrueReg, unsigned FalseReg) const {
|
|
|
|
llvm_unreachable("Target didn't implement TargetInstrInfo::insertSelect!");
|
|
|
|
}
|
|
|
|
|
2012-08-16 23:11:47 +00:00
|
|
|
/// analyzeSelect - 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.
|
|
|
|
///
|
|
|
|
/// @param MI Select instruction to analyze.
|
|
|
|
/// @param Cond Condition controlling the select.
|
|
|
|
/// @param TrueOp Operand number of the value selected when Cond is true.
|
|
|
|
/// @param FalseOp Operand number of the value selected when Cond is false.
|
|
|
|
/// @param Optimizable Returned as true if MI is optimizable.
|
|
|
|
/// @returns False on success.
|
|
|
|
virtual bool analyzeSelect(const MachineInstr *MI,
|
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
unsigned &TrueOp, unsigned &FalseOp,
|
|
|
|
bool &Optimizable) const {
|
2012-11-16 17:32:33 +00:00
|
|
|
assert(MI && MI->getDesc().isSelect() && "MI must be a select instruction");
|
2012-08-16 23:11:47 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// optimizeSelect - 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.
|
|
|
|
///
|
|
|
|
/// @param MI Optimizable select instruction.
|
2015-01-14 02:24:10 +00:00
|
|
|
/// @param NewMIs Set that record all MIs in the basic block up to \p
|
2015-01-13 07:07:13 +00:00
|
|
|
/// MI. Has to be updated with any newly created MI or deleted ones.
|
2012-08-16 23:11:47 +00:00
|
|
|
/// @param PreferFalse Try to optimize FalseOp instead of TrueOp.
|
|
|
|
/// @returns Optimized instruction or NULL.
|
|
|
|
virtual MachineInstr *optimizeSelect(MachineInstr *MI,
|
2015-01-13 07:07:13 +00:00
|
|
|
SmallPtrSetImpl<MachineInstr *> &NewMIs,
|
2012-08-16 23:11:47 +00:00
|
|
|
bool PreferFalse = false) const {
|
|
|
|
// This function must be implemented if Optimizable is ever set.
|
|
|
|
llvm_unreachable("Target must implement TargetInstrInfo::optimizeSelect!");
|
|
|
|
}
|
|
|
|
|
2010-07-08 05:01:41 +00:00
|
|
|
/// copyPhysReg - Emit instructions to copy a pair of physical registers.
|
2012-08-29 23:52:55 +00:00
|
|
|
///
|
|
|
|
/// 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.
|
2010-07-08 05:01:41 +00:00
|
|
|
virtual void copyPhysReg(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI, DebugLoc DL,
|
|
|
|
unsigned DestReg, unsigned SrcReg,
|
2010-07-11 17:01:17 +00:00
|
|
|
bool KillSrc) const {
|
2012-02-05 22:14:15 +00:00
|
|
|
llvm_unreachable("Target didn't implement TargetInstrInfo::copyPhysReg!");
|
2010-07-11 17:01:17 +00:00
|
|
|
}
|
2010-07-08 05:01:41 +00:00
|
|
|
|
2008-10-25 23:08:22 +00:00
|
|
|
/// storeRegToStackSlot - 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.
|
2008-01-01 21:11:32 +00:00
|
|
|
virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
unsigned SrcReg, bool isKill, int FrameIndex,
|
2010-05-06 19:06:44 +00:00
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const {
|
2012-02-05 22:14:15 +00:00
|
|
|
llvm_unreachable("Target didn't implement "
|
|
|
|
"TargetInstrInfo::storeRegToStackSlot!");
|
2008-01-01 21:11:32 +00:00
|
|
|
}
|
|
|
|
|
2008-10-25 23:08:22 +00:00
|
|
|
/// loadRegFromStackSlot - 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.
|
2008-01-01 21:11:32 +00:00
|
|
|
virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
unsigned DestReg, int FrameIndex,
|
2010-05-06 19:06:44 +00:00
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const {
|
2012-02-05 22:14:15 +00:00
|
|
|
llvm_unreachable("Target didn't implement "
|
|
|
|
"TargetInstrInfo::loadRegFromStackSlot!");
|
2008-01-01 21:11:32 +00:00
|
|
|
}
|
2008-01-04 23:57:37 +00:00
|
|
|
|
2011-09-25 19:21:35 +00:00
|
|
|
/// expandPostRAPseudo - 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.
|
2011-09-29 05:10:54 +00:00
|
|
|
virtual bool expandPostRAPseudo(MachineBasicBlock::iterator MI) const {
|
2011-09-25 19:21:35 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-01-07 01:35:02 +00:00
|
|
|
/// 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
|
2010-07-09 17:29:08 +00:00
|
|
|
/// operand folded, otherwise NULL is returned.
|
|
|
|
/// The new instruction is inserted before MI, and the client is responsible
|
|
|
|
/// for removing the old instruction.
|
|
|
|
MachineInstr* foldMemoryOperand(MachineBasicBlock::iterator MI,
|
2008-12-03 18:43:12 +00:00
|
|
|
const SmallVectorImpl<unsigned> &Ops,
|
|
|
|
int FrameIndex) const;
|
2008-01-07 01:35:02 +00:00
|
|
|
|
|
|
|
/// 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.
|
2010-07-09 17:29:08 +00:00
|
|
|
MachineInstr* foldMemoryOperand(MachineBasicBlock::iterator MI,
|
2008-12-03 18:43:12 +00:00
|
|
|
const SmallVectorImpl<unsigned> &Ops,
|
|
|
|
MachineInstr* LoadMI) const;
|
|
|
|
|
2014-08-03 21:35:39 +00:00
|
|
|
/// hasPattern - return true when there is potentially a faster code sequence
|
|
|
|
/// for an instruction chain ending in \p Root. All potential pattern are
|
|
|
|
/// returned in the \p Pattern vector. Pattern should be sorted in priority
|
|
|
|
/// order since the pattern evaluator stops checking as soon as it finds a
|
|
|
|
/// faster sequence.
|
|
|
|
/// \param Root - Instruction that could be combined with one of its operands
|
|
|
|
/// \param Pattern - Vector of possible combination pattern
|
|
|
|
|
|
|
|
virtual bool hasPattern(
|
|
|
|
MachineInstr &Root,
|
|
|
|
SmallVectorImpl<MachineCombinerPattern::MC_PATTERN> &Pattern) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// genAlternativeCodeSequence - when hasPattern() finds a pattern this
|
|
|
|
/// function generates the instructions that could replace the original code
|
|
|
|
/// sequence. The client has to decide whether the actual replacementment is
|
|
|
|
/// beneficial or not.
|
|
|
|
/// \param Root - Instruction that could be combined with one of its operands
|
|
|
|
/// \param P - Combination pattern for Root
|
2014-08-04 10:23:22 +00:00
|
|
|
/// \param InsInstrs - Vector of new instructions that implement P
|
|
|
|
/// \param DelInstrs - Old instructions, including Root, that could be replaced
|
2014-08-03 21:35:39 +00:00
|
|
|
/// by InsInstr
|
|
|
|
/// \param InstrIdxForVirtReg - map of virtual register to instruction in
|
|
|
|
/// InsInstr that defines it
|
|
|
|
virtual void genAlternativeCodeSequence(
|
|
|
|
MachineInstr &Root, MachineCombinerPattern::MC_PATTERN P,
|
|
|
|
SmallVectorImpl<MachineInstr *> &InsInstrs,
|
|
|
|
SmallVectorImpl<MachineInstr *> &DelInstrs,
|
|
|
|
DenseMap<unsigned, unsigned> &InstrIdxForVirtReg) const {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// useMachineCombiner - return true when a target supports MachineCombiner
|
2014-09-03 11:41:21 +00:00
|
|
|
virtual bool useMachineCombiner() const { return false; }
|
2014-08-03 21:35:39 +00:00
|
|
|
|
2008-12-03 18:43:12 +00:00
|
|
|
protected:
|
|
|
|
/// foldMemoryOperandImpl - Target-dependent implementation for
|
|
|
|
/// foldMemoryOperand. Target-independent code in foldMemoryOperand will
|
|
|
|
/// take care of adding a MachineMemOperand to the newly created instruction.
|
|
|
|
virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
|
2008-02-08 21:20:40 +00:00
|
|
|
MachineInstr* MI,
|
2008-10-16 01:49:15 +00:00
|
|
|
const SmallVectorImpl<unsigned> &Ops,
|
2008-12-03 18:43:12 +00:00
|
|
|
int FrameIndex) const {
|
2014-04-14 00:51:57 +00:00
|
|
|
return nullptr;
|
2008-12-03 18:43:12 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// foldMemoryOperandImpl - Target-dependent implementation for
|
|
|
|
/// foldMemoryOperand. Target-independent code in foldMemoryOperand will
|
|
|
|
/// take care of adding a MachineMemOperand to the newly created instruction.
|
|
|
|
virtual MachineInstr* foldMemoryOperandImpl(MachineFunction &MF,
|
|
|
|
MachineInstr* MI,
|
2010-07-15 07:49:30 +00:00
|
|
|
const SmallVectorImpl<unsigned> &Ops,
|
2008-12-03 18:43:12 +00:00
|
|
|
MachineInstr* LoadMI) const {
|
2014-04-14 00:51:57 +00:00
|
|
|
return nullptr;
|
2008-01-07 01:35:02 +00:00
|
|
|
}
|
|
|
|
|
2014-08-11 22:17:14 +00:00
|
|
|
/// \brief Target-dependent implementation of getRegSequenceInputs.
|
|
|
|
///
|
|
|
|
/// \returns true if it is possible to build the equivalent
|
|
|
|
/// REG_SEQUENCE inputs with the pair \p MI, \p DefIdx. False otherwise.
|
|
|
|
///
|
|
|
|
/// \pre MI.isRegSequenceLike().
|
|
|
|
///
|
|
|
|
/// \see TargetInstrInfo::getRegSequenceInputs.
|
|
|
|
virtual bool getRegSequenceLikeInputs(
|
|
|
|
const MachineInstr &MI, unsigned DefIdx,
|
|
|
|
SmallVectorImpl<RegSubRegPairAndIdx> &InputRegs) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-08-20 21:51:26 +00:00
|
|
|
/// \brief Target-dependent implementation of getExtractSubregInputs.
|
|
|
|
///
|
|
|
|
/// \returns true if it is possible to build the equivalent
|
|
|
|
/// EXTRACT_SUBREG inputs with the pair \p MI, \p DefIdx. False otherwise.
|
|
|
|
///
|
|
|
|
/// \pre MI.isExtractSubregLike().
|
|
|
|
///
|
|
|
|
/// \see TargetInstrInfo::getExtractSubregInputs.
|
|
|
|
virtual bool getExtractSubregLikeInputs(
|
|
|
|
const MachineInstr &MI, unsigned DefIdx,
|
|
|
|
RegSubRegPairAndIdx &InputReg) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2014-08-20 23:49:36 +00:00
|
|
|
/// \brief Target-dependent implementation of getInsertSubregInputs.
|
|
|
|
///
|
|
|
|
/// \returns true if it is possible to build the equivalent
|
|
|
|
/// INSERT_SUBREG inputs with the pair \p MI, \p DefIdx. False otherwise.
|
|
|
|
///
|
|
|
|
/// \pre MI.isInsertSubregLike().
|
|
|
|
///
|
|
|
|
/// \see TargetInstrInfo::getInsertSubregInputs.
|
|
|
|
virtual bool
|
|
|
|
getInsertSubregLikeInputs(const MachineInstr &MI, unsigned DefIdx,
|
|
|
|
RegSubRegPair &BaseReg,
|
|
|
|
RegSubRegPairAndIdx &InsertedReg) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2008-12-03 18:43:12 +00:00
|
|
|
public:
|
2008-12-15 17:26:50 +00:00
|
|
|
/// canFoldMemoryOperand - Returns true for the specified load / store if
|
2008-01-07 01:35:02 +00:00
|
|
|
/// folding is possible.
|
|
|
|
virtual
|
2008-10-16 01:49:15 +00:00
|
|
|
bool canFoldMemoryOperand(const MachineInstr *MI,
|
2012-11-28 02:35:13 +00:00
|
|
|
const SmallVectorImpl<unsigned> &Ops) const;
|
2008-01-07 01:35:02 +00:00
|
|
|
|
|
|
|
/// 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.
|
|
|
|
virtual bool unfoldMemoryOperand(MachineFunction &MF, MachineInstr *MI,
|
|
|
|
unsigned Reg, bool UnfoldLoad, bool UnfoldStore,
|
2009-05-03 18:32:42 +00:00
|
|
|
SmallVectorImpl<MachineInstr*> &NewMIs) const{
|
2008-01-07 01:35:02 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
virtual bool unfoldMemoryOperand(SelectionDAG &DAG, SDNode *N,
|
|
|
|
SmallVectorImpl<SDNode*> &NewNodes) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// getOpcodeAfterMemoryUnfold - 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
|
2009-10-30 22:18:41 +00:00
|
|
|
/// 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.
|
2008-01-07 01:35:02 +00:00
|
|
|
virtual unsigned getOpcodeAfterMemoryUnfold(unsigned Opc,
|
2009-10-30 22:18:41 +00:00
|
|
|
bool UnfoldLoad, bool UnfoldStore,
|
2014-04-14 00:51:57 +00:00
|
|
|
unsigned *LoadRegIndex = nullptr) const {
|
2008-01-07 01:35:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
2010-01-22 03:34:51 +00:00
|
|
|
|
|
|
|
/// areLoadsFromSameBasePtr - 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.
|
|
|
|
virtual bool areLoadsFromSameBasePtr(SDNode *Load1, SDNode *Load2,
|
2010-07-15 07:49:30 +00:00
|
|
|
int64_t &Offset1, int64_t &Offset2) const {
|
2010-01-22 03:34:51 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// shouldScheduleLoadsNear - This is a used by the pre-regalloc scheduler to
|
2011-04-15 05:18:47 +00:00
|
|
|
/// determine (in conjunction with areLoadsFromSameBasePtr) if two loads should
|
2010-01-22 03:34:51 +00:00
|
|
|
/// be scheduled togther. 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.
|
|
|
|
virtual bool shouldScheduleLoadsNear(SDNode *Load1, SDNode *Load2,
|
|
|
|
int64_t Offset1, int64_t Offset2,
|
|
|
|
unsigned NumLoads) const {
|
|
|
|
return false;
|
|
|
|
}
|
2010-12-24 04:28:06 +00:00
|
|
|
|
2012-11-12 19:40:10 +00:00
|
|
|
/// \brief Get the base register and byte offset of a load/store instr.
|
|
|
|
virtual bool getLdStBaseRegImmOfs(MachineInstr *LdSt,
|
|
|
|
unsigned &BaseReg, unsigned &Offset,
|
|
|
|
const TargetRegisterInfo *TRI) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2013-09-04 21:00:08 +00:00
|
|
|
virtual bool enableClusterLoads() const { return false; }
|
|
|
|
|
2012-11-12 21:28:10 +00:00
|
|
|
virtual bool shouldClusterLoads(MachineInstr *FirstLdSt,
|
|
|
|
MachineInstr *SecondLdSt,
|
|
|
|
unsigned NumLoads) const {
|
2012-11-12 19:40:10 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-11-12 19:52:20 +00:00
|
|
|
/// \brief Can this target fuse the given instructions if they are scheduled
|
|
|
|
/// adjacent.
|
|
|
|
virtual bool shouldScheduleAdjacent(MachineInstr* First,
|
|
|
|
MachineInstr *Second) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-10-13 20:59:31 +00:00
|
|
|
/// ReverseBranchCondition - Reverses the branch condition of the specified
|
|
|
|
/// condition list, returning false on success and true if it cannot be
|
|
|
|
/// reversed.
|
2008-08-14 22:49:33 +00:00
|
|
|
virtual
|
|
|
|
bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const {
|
2006-10-13 20:59:31 +00:00
|
|
|
return true;
|
2004-07-31 08:52:30 +00:00
|
|
|
}
|
2010-12-24 04:28:06 +00:00
|
|
|
|
2006-03-05 23:48:51 +00:00
|
|
|
/// insertNoop - Insert a noop into the instruction stream at the specified
|
|
|
|
/// point.
|
2010-12-24 04:28:06 +00:00
|
|
|
virtual void insertNoop(MachineBasicBlock &MBB,
|
2009-08-02 04:58:19 +00:00
|
|
|
MachineBasicBlock::iterator MI) const;
|
2010-12-24 04:28:06 +00:00
|
|
|
|
|
|
|
|
2014-09-15 18:32:58 +00:00
|
|
|
/// Return the noop instruction to use for a noop.
|
|
|
|
virtual void getNoopForMachoTarget(MCInst &NopInst) const;
|
2010-12-24 04:28:06 +00:00
|
|
|
|
|
|
|
|
2007-06-08 21:59:56 +00:00
|
|
|
/// isPredicated - Returns true if the instruction is already predicated.
|
2007-05-23 07:19:12 +00:00
|
|
|
///
|
2007-05-29 18:35:22 +00:00
|
|
|
virtual bool isPredicated(const MachineInstr *MI) const {
|
2007-05-23 07:19:12 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-06-08 21:59:56 +00:00
|
|
|
/// isUnpredicatedTerminator - Returns true if the instruction is a
|
|
|
|
/// terminator instruction that has not been predicated.
|
2012-11-28 02:35:13 +00:00
|
|
|
virtual bool isUnpredicatedTerminator(const MachineInstr *MI) const;
|
2007-06-08 21:59:56 +00:00
|
|
|
|
2007-05-16 01:58:56 +00:00
|
|
|
/// PredicateInstruction - Convert the instruction into a predicated
|
2007-05-16 21:53:07 +00:00
|
|
|
/// instruction. It returns true if the operation was successful.
|
2007-05-29 18:35:22 +00:00
|
|
|
virtual
|
|
|
|
bool PredicateInstruction(MachineInstr *MI,
|
2012-11-28 02:35:13 +00:00
|
|
|
const SmallVectorImpl<MachineOperand> &Pred) const;
|
2007-05-23 07:19:12 +00:00
|
|
|
|
2007-06-08 21:59:56 +00:00
|
|
|
/// SubsumesPredicate - Returns true if the first specified predicate
|
2007-05-23 07:19:12 +00:00
|
|
|
/// subsumes the second, e.g. GE subsumes GT.
|
2007-05-29 18:35:22 +00:00
|
|
|
virtual
|
2008-08-14 22:49:33 +00:00
|
|
|
bool SubsumesPredicate(const SmallVectorImpl<MachineOperand> &Pred1,
|
|
|
|
const SmallVectorImpl<MachineOperand> &Pred2) const {
|
2007-05-23 07:19:12 +00:00
|
|
|
return false;
|
|
|
|
}
|
2007-05-16 01:58:56 +00:00
|
|
|
|
2007-07-10 18:06:29 +00:00
|
|
|
/// DefinesPredicate - 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.
|
|
|
|
virtual bool DefinesPredicate(MachineInstr *MI,
|
|
|
|
std::vector<MachineOperand> &Pred) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-11-21 06:20:26 +00:00
|
|
|
/// isPredicable - Return true if the specified instruction can be predicated.
|
|
|
|
/// By default, this returns true for every instruction with a
|
|
|
|
/// PredicateOperand.
|
|
|
|
virtual bool isPredicable(MachineInstr *MI) const {
|
|
|
|
return MI->getDesc().isPredicable();
|
|
|
|
}
|
|
|
|
|
2009-02-06 17:17:30 +00:00
|
|
|
/// isSafeToMoveRegClassDefs - Return true if it's safe to move a machine
|
|
|
|
/// instruction that defines the specified register class.
|
|
|
|
virtual bool isSafeToMoveRegClassDefs(const TargetRegisterClass *RC) const {
|
2008-10-27 07:14:50 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-18 23:09:54 +00:00
|
|
|
/// isSchedulingBoundary - Test if the given instruction should be
|
|
|
|
/// considered a scheduling boundary. This primarily includes labels and
|
|
|
|
/// terminators.
|
|
|
|
virtual bool isSchedulingBoundary(const MachineInstr *MI,
|
|
|
|
const MachineBasicBlock *MBB,
|
2012-11-28 02:35:13 +00:00
|
|
|
const MachineFunction &MF) const;
|
2010-06-18 23:09:54 +00:00
|
|
|
|
2009-08-02 05:20:37 +00:00
|
|
|
/// Measure the specified inline asm to determine an approximation of its
|
|
|
|
/// length.
|
|
|
|
virtual unsigned getInlineAsmLength(const char *Str,
|
2009-08-22 21:43:10 +00:00
|
|
|
const MCAsmInfo &MAI) const;
|
2010-06-12 00:12:18 +00:00
|
|
|
|
2011-01-21 05:51:33 +00:00
|
|
|
/// CreateTargetHazardRecognizer - Allocate and return a hazard recognizer to
|
|
|
|
/// use for this target when scheduling the machine instructions before
|
|
|
|
/// register allocation.
|
2010-06-12 00:12:18 +00:00
|
|
|
virtual ScheduleHazardRecognizer*
|
2014-06-13 22:38:52 +00:00
|
|
|
CreateTargetHazardRecognizer(const TargetSubtargetInfo *STI,
|
2012-11-28 02:35:13 +00:00
|
|
|
const ScheduleDAG *DAG) const;
|
Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.
Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.
Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.
Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.
ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.
ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
|
2012-05-24 22:11:09 +00:00
|
|
|
/// CreateTargetMIHazardRecognizer - Allocate and return a hazard recognizer
|
|
|
|
/// to use for this target when scheduling the machine instructions before
|
|
|
|
/// register allocation.
|
|
|
|
virtual ScheduleHazardRecognizer*
|
|
|
|
CreateTargetMIHazardRecognizer(const InstrItineraryData*,
|
2012-11-28 02:35:13 +00:00
|
|
|
const ScheduleDAG *DAG) const;
|
2012-05-24 22:11:09 +00:00
|
|
|
|
Various bits of framework needed for precise machine-level selection
DAG scheduling during isel. Most new functionality is currently
guarded by -enable-sched-cycles and -enable-sched-hazard.
Added InstrItineraryData::IssueWidth field, currently derived from
ARM itineraries, but could be initialized differently on other targets.
Added ScheduleHazardRecognizer::MaxLookAhead to indicate whether it is
active, and if so how many cycles of state it holds.
Added SchedulingPriorityQueue::HasReadyFilter to allowing gating entry
into the scheduler's available queue.
ScoreboardHazardRecognizer now accesses the ScheduleDAG in order to
get information about it's SUnits, provides RecedeCycle for bottom-up
scheduling, correctly computes scoreboard depth, tracks IssueCount, and
considers potential stall cycles when checking for hazards.
ScheduleDAGRRList now models machine cycles and hazards (under
flags). It tracks MinAvailableCycle, drives the hazard recognizer and
priority queue's ready filter, manages a new PendingQueue, properly
accounts for stall cycles, etc.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@122541 91177308-0d34-0410-b5e6-96231b3b80d8
2010-12-24 05:03:26 +00:00
|
|
|
/// CreateTargetPostRAHazardRecognizer - Allocate and return a hazard
|
|
|
|
/// recognizer to use for this target when scheduling the machine instructions
|
|
|
|
/// after register allocation.
|
|
|
|
virtual ScheduleHazardRecognizer*
|
|
|
|
CreateTargetPostRAHazardRecognizer(const InstrItineraryData*,
|
2012-11-28 02:35:13 +00:00
|
|
|
const ScheduleDAG *DAG) const;
|
|
|
|
|
|
|
|
/// Provide a global flag for disabling the PreRA hazard recognizer that
|
|
|
|
/// targets may choose to honor.
|
|
|
|
bool usePreRAHazardRecognizer() const;
|
2010-08-06 01:32:48 +00:00
|
|
|
|
2012-06-29 21:33:59 +00:00
|
|
|
/// analyzeCompare - 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.
|
|
|
|
virtual bool analyzeCompare(const MachineInstr *MI,
|
|
|
|
unsigned &SrcReg, unsigned &SrcReg2,
|
|
|
|
int &Mask, int &Value) const {
|
2010-08-06 01:32:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2012-06-29 21:33:59 +00:00
|
|
|
/// optimizeCompareInstr - See if the comparison instruction can be converted
|
2010-09-11 00:13:50 +00:00
|
|
|
/// into something more efficient. E.g., on ARM most instructions can set the
|
2010-11-15 21:20:45 +00:00
|
|
|
/// flags register, obviating the need for a separate CMP.
|
2012-06-29 21:33:59 +00:00
|
|
|
virtual bool optimizeCompareInstr(MachineInstr *CmpInstr,
|
|
|
|
unsigned SrcReg, unsigned SrcReg2,
|
|
|
|
int Mask, int Value,
|
2010-11-15 21:20:45 +00:00
|
|
|
const MachineRegisterInfo *MRI) const {
|
2010-08-06 01:32:48 +00:00
|
|
|
return false;
|
|
|
|
}
|
[AAarch64] Optimize CSINC-branch sequence
Peephole optimization that generates a single conditional branch
for csinc-branch sequences like in the examples below. This is
possible when the csinc sets or clears a register based on a condition
code and the branch checks that register. Also the condition
code may not be modified between the csinc and the original branch.
Examples:
1. Convert csinc w9, wzr, wzr, <CC>;tbnz w9, #0, 0x44
to b.<invCC>
2. Convert csinc w9, wzr, wzr, <CC>; tbz w9, #0, 0x44
to b.<CC>
rdar://problem/18506500
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219742 91177308-0d34-0410-b5e6-96231b3b80d8
2014-10-14 23:07:53 +00:00
|
|
|
virtual bool optimizeCondBranch(MachineInstr *MI) const { return false; }
|
2010-12-24 04:28:06 +00:00
|
|
|
|
2012-08-02 00:56:42 +00:00
|
|
|
/// optimizeLoadInstr - 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
|
2012-08-02 19:37:32 +00:00
|
|
|
/// 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.
|
2012-08-02 00:56:42 +00:00
|
|
|
virtual MachineInstr* optimizeLoadInstr(MachineInstr *MI,
|
|
|
|
const MachineRegisterInfo *MRI,
|
|
|
|
unsigned &FoldAsLoadDefReg,
|
|
|
|
MachineInstr *&DefMI) const {
|
2014-04-14 00:51:57 +00:00
|
|
|
return nullptr;
|
2012-08-02 00:56:42 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 20:13:28 +00:00
|
|
|
/// FoldImmediate - 'Reg' is known to be defined by a move immediate
|
|
|
|
/// instruction, try to fold the immediate into the use instruction.
|
2013-04-06 19:30:20 +00:00
|
|
|
/// 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.
|
2010-11-17 20:13:28 +00:00
|
|
|
virtual bool FoldImmediate(MachineInstr *UseMI, MachineInstr *DefMI,
|
|
|
|
unsigned Reg, MachineRegisterInfo *MRI) const {
|
|
|
|
return false;
|
|
|
|
}
|
2010-09-09 18:18:55 +00:00
|
|
|
|
|
|
|
/// getNumMicroOps - Return the number of u-operations the given machine
|
2012-07-02 18:10:42 +00:00
|
|
|
/// 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.
|
2010-11-03 00:45:17 +00:00
|
|
|
virtual unsigned getNumMicroOps(const InstrItineraryData *ItinData,
|
2012-11-28 02:35:13 +00:00
|
|
|
const MachineInstr *MI) const;
|
2010-10-06 06:27:31 +00:00
|
|
|
|
2011-01-21 05:51:33 +00:00
|
|
|
/// isZeroCost - 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.
|
|
|
|
bool isZeroCost(unsigned Opcode) const {
|
|
|
|
return Opcode <= TargetOpcode::COPY;
|
|
|
|
}
|
|
|
|
|
2012-06-05 21:11:27 +00:00
|
|
|
virtual int getOperandLatency(const InstrItineraryData *ItinData,
|
|
|
|
SDNode *DefNode, unsigned DefIdx,
|
2012-11-28 02:35:13 +00:00
|
|
|
SDNode *UseNode, unsigned UseIdx) const;
|
2012-06-05 21:11:27 +00:00
|
|
|
|
2010-10-06 06:27:31 +00:00
|
|
|
/// getOperandLatency - Compute and return the use operand latency of a given
|
2010-11-03 00:45:17 +00:00
|
|
|
/// pair of def and use.
|
2010-10-06 06:27:31 +00:00
|
|
|
/// 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.
|
2012-06-05 21:11:27 +00:00
|
|
|
///
|
|
|
|
/// This is a raw interface to the itinerary that may be directly overriden by
|
|
|
|
/// a target. Use computeOperandLatency to get the best estimate of latency.
|
2010-11-03 00:45:17 +00:00
|
|
|
virtual int getOperandLatency(const InstrItineraryData *ItinData,
|
2012-06-05 21:11:27 +00:00
|
|
|
const MachineInstr *DefMI, unsigned DefIdx,
|
|
|
|
const MachineInstr *UseMI,
|
2012-11-28 02:35:13 +00:00
|
|
|
unsigned UseIdx) const;
|
2012-06-05 21:11:27 +00:00
|
|
|
|
2012-06-07 19:42:04 +00:00
|
|
|
/// computeOperandLatency - Compute and return the latency of the given data
|
|
|
|
/// dependent def and use when the operand indices are already known.
|
|
|
|
unsigned computeOperandLatency(const InstrItineraryData *ItinData,
|
|
|
|
const MachineInstr *DefMI, unsigned DefIdx,
|
2013-06-15 04:49:57 +00:00
|
|
|
const MachineInstr *UseMI, unsigned UseIdx)
|
|
|
|
const;
|
2012-06-07 19:42:04 +00:00
|
|
|
|
2010-11-03 00:45:17 +00:00
|
|
|
/// getInstrLatency - Compute the instruction latency of a given instruction.
|
|
|
|
/// If the instruction has higher cost when predicated, it's returned via
|
|
|
|
/// PredCost.
|
2012-06-05 21:11:27 +00:00
|
|
|
virtual unsigned getInstrLatency(const InstrItineraryData *ItinData,
|
|
|
|
const MachineInstr *MI,
|
2014-04-14 00:51:57 +00:00
|
|
|
unsigned *PredCost = nullptr) const;
|
2010-11-03 00:45:17 +00:00
|
|
|
|
2013-09-30 15:28:56 +00:00
|
|
|
virtual unsigned getPredicationCost(const MachineInstr *MI) const;
|
|
|
|
|
2010-11-03 00:45:17 +00:00
|
|
|
virtual int getInstrLatency(const InstrItineraryData *ItinData,
|
2012-11-28 02:35:13 +00:00
|
|
|
SDNode *Node) const;
|
2010-10-19 18:58:51 +00:00
|
|
|
|
2012-06-05 21:11:27 +00:00
|
|
|
/// Return the default expected latency for a def based on it's opcode.
|
2014-09-02 17:43:54 +00:00
|
|
|
unsigned defaultDefLatency(const MCSchedModel &SchedModel,
|
2012-06-05 21:11:27 +00:00
|
|
|
const MachineInstr *DefMI) const;
|
|
|
|
|
2012-09-18 04:03:34 +00:00
|
|
|
int computeDefOperandLatency(const InstrItineraryData *ItinData,
|
2013-06-15 04:49:57 +00:00
|
|
|
const MachineInstr *DefMI) const;
|
2012-09-18 04:03:34 +00:00
|
|
|
|
2011-03-05 08:00:22 +00:00
|
|
|
/// isHighLatencyDef - Return true if this opcode has high latency to its
|
|
|
|
/// result.
|
2011-03-05 08:39:45 +00:00
|
|
|
virtual bool isHighLatencyDef(int opc) const { return false; }
|
2011-03-05 08:00:22 +00:00
|
|
|
|
2010-10-19 18:58:51 +00:00
|
|
|
/// hasHighOperandLatency - Compute operand latency between a def of 'Reg'
|
|
|
|
/// and an 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
|
|
|
|
/// high register pressure situation.
|
|
|
|
virtual
|
|
|
|
bool hasHighOperandLatency(const InstrItineraryData *ItinData,
|
|
|
|
const MachineRegisterInfo *MRI,
|
|
|
|
const MachineInstr *DefMI, unsigned DefIdx,
|
|
|
|
const MachineInstr *UseMI, unsigned UseIdx) const {
|
|
|
|
return false;
|
|
|
|
}
|
2010-10-26 02:08:50 +00:00
|
|
|
|
|
|
|
/// hasLowDefLatency - Compute operand latency of a def of 'Reg', return true
|
|
|
|
/// if the target considered it 'low'.
|
|
|
|
virtual
|
|
|
|
bool hasLowDefLatency(const InstrItineraryData *ItinData,
|
2012-11-28 02:35:13 +00:00
|
|
|
const MachineInstr *DefMI, unsigned DefIdx) const;
|
2011-06-28 21:14:33 +00:00
|
|
|
|
2011-09-21 02:20:46 +00:00
|
|
|
/// verifyInstruction - Perform target specific instruction verification.
|
|
|
|
virtual
|
|
|
|
bool verifyInstruction(const MachineInstr *MI, StringRef &ErrInfo) const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2011-09-27 22:57:18 +00:00
|
|
|
/// getExecutionDomain - 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.
|
|
|
|
///
|
|
|
|
virtual std::pair<uint16_t, uint16_t>
|
|
|
|
getExecutionDomain(const MachineInstr *MI) const {
|
|
|
|
return std::make_pair(0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/// setExecutionDomain - Change the opcode of MI to execute in Domain.
|
|
|
|
///
|
|
|
|
/// The bit (1 << Domain) must be set in the mask returned from
|
|
|
|
/// getExecutionDomain(MI).
|
|
|
|
///
|
|
|
|
virtual void setExecutionDomain(MachineInstr *MI, unsigned Domain) const {}
|
|
|
|
|
2011-11-15 01:15:30 +00:00
|
|
|
|
|
|
|
/// getPartialRegUpdateClearance - 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.
|
|
|
|
///
|
|
|
|
virtual unsigned
|
|
|
|
getPartialRegUpdateClearance(const MachineInstr *MI, unsigned OpNum,
|
|
|
|
const TargetRegisterInfo *TRI) const {
|
|
|
|
// The default implementation returns 0 for no partial register dependency.
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-10-14 22:19:03 +00:00
|
|
|
/// \brief Return the minimum clearance before an instruction that reads an
|
|
|
|
/// unused register.
|
|
|
|
///
|
|
|
|
/// For example, AVX instructions may copy part of an 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 \p OpNum to the index of the
|
|
|
|
/// unused register.
|
|
|
|
virtual unsigned getUndefRegClearance(const MachineInstr *MI, unsigned &OpNum,
|
|
|
|
const TargetRegisterInfo *TRI) const {
|
|
|
|
// The default implementation returns 0 for no undef register dependency.
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2011-11-15 01:15:30 +00:00
|
|
|
/// breakPartialRegDependency - 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.
|
|
|
|
///
|
|
|
|
virtual void
|
|
|
|
breakPartialRegDependency(MachineBasicBlock::iterator MI, unsigned OpNum,
|
|
|
|
const TargetRegisterInfo *TRI) const {}
|
|
|
|
|
2012-02-01 22:13:57 +00:00
|
|
|
/// Create machine specific model for scheduling.
|
2014-10-09 01:59:35 +00:00
|
|
|
virtual DFAPacketizer *
|
|
|
|
CreateTargetScheduleState(const TargetSubtargetInfo &) const {
|
2014-04-14 00:51:57 +00:00
|
|
|
return nullptr;
|
2012-02-01 22:13:57 +00:00
|
|
|
}
|
|
|
|
|
2014-09-08 14:43:48 +00:00
|
|
|
// areMemAccessesTriviallyDisjoint - Sometimes, it is possible for the target
|
|
|
|
// to tell, even without aliasing information, that two MIs access different
|
|
|
|
// memory addresses. This function returns true if two MIs access different
|
|
|
|
// memory addresses, and false otherwise.
|
|
|
|
virtual bool
|
|
|
|
areMemAccessesTriviallyDisjoint(MachineInstr *MIa, MachineInstr *MIb,
|
|
|
|
AliasAnalysis *AA = nullptr) const {
|
|
|
|
assert(MIa && (MIa->mayLoad() || MIa->mayStore()) &&
|
|
|
|
"MIa must load from or modify a memory location");
|
|
|
|
assert(MIb && (MIb->mayLoad() || MIb->mayStore()) &&
|
|
|
|
"MIb must load from or modify a memory location");
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2011-06-28 21:14:33 +00:00
|
|
|
private:
|
|
|
|
int CallFrameSetupOpcode, CallFrameDestroyOpcode;
|
2001-09-18 12:38:31 +00:00
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-09-18 12:38:31 +00:00
|
|
|
#endif
|