2003-01-13 01:21:19 +01:00
|
|
|
//===-- llvm/Target/TargetInstrInfo.h - Instruction Info --------*- C++ -*-===//
|
2005-04-21 22:59:05 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
2007-12-29 20:59:42 +01:00
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
2005-04-21 22:59:05 +02:00
|
|
|
//
|
2003-10-20 22:19:47 +02:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-09-18 14:38:31 +02:00
|
|
|
//
|
2008-07-16 18:02:59 +02:00
|
|
|
// This file describes the target machine instruction set to the code generator.
|
2001-09-18 14:38:31 +02:00
|
|
|
//
|
2002-12-03 06:41:32 +01:00
|
|
|
//===----------------------------------------------------------------------===//
|
2001-09-18 14:38:31 +02:00
|
|
|
|
2003-01-14 23:00:31 +01:00
|
|
|
#ifndef LLVM_TARGET_TARGETINSTRINFO_H
|
|
|
|
#define LLVM_TARGET_TARGETINSTRINFO_H
|
2001-09-18 14:38:31 +02:00
|
|
|
|
2008-01-07 08:33:08 +01:00
|
|
|
#include "llvm/Target/TargetInstrDesc.h"
|
2006-12-01 22:46:55 +01:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2001-09-18 14:38:31 +02:00
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
namespace llvm {
|
|
|
|
|
2010-06-12 02:12:18 +02:00
|
|
|
class InstrItineraryData;
|
2010-03-03 02:44:33 +01:00
|
|
|
class LiveVariables;
|
|
|
|
class MCAsmInfo;
|
|
|
|
class MachineMemOperand;
|
2010-10-19 20:58:51 +02:00
|
|
|
class MachineRegisterInfo;
|
2010-04-26 09:38:55 +02:00
|
|
|
class MDNode;
|
2010-04-27 01:37:21 +02:00
|
|
|
class MCInst;
|
2008-01-07 02:35:02 +01:00
|
|
|
class SDNode;
|
2010-06-12 02:12:18 +02:00
|
|
|
class ScheduleHazardRecognizer;
|
2008-01-07 02:35:02 +01: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.
llvm-svn: 122541
2010-12-24 06:03:26 +01:00
|
|
|
class ScheduleDAG;
|
2010-03-03 02:44:33 +01:00
|
|
|
class TargetRegisterClass;
|
|
|
|
class TargetRegisterInfo;
|
2001-09-18 14:38:31 +02:00
|
|
|
|
2008-01-01 22:11:32 +01:00
|
|
|
template<class T> class SmallVectorImpl;
|
|
|
|
|
2001-09-18 14:38:31 +02:00
|
|
|
|
2003-01-14 23:00:31 +01:00
|
|
|
//---------------------------------------------------------------------------
|
2005-04-21 22:59:05 +02:00
|
|
|
///
|
2008-07-16 18:02:59 +02:00
|
|
|
/// TargetInstrInfo - Interface to description of machine instruction set
|
2005-04-21 22:59:05 +02:00
|
|
|
///
|
2003-01-13 01:21:19 +01:00
|
|
|
class TargetInstrInfo {
|
2008-01-07 08:27:27 +01:00
|
|
|
const TargetInstrDesc *Descriptors; // Raw array to allow static init'n
|
|
|
|
unsigned NumOpcodes; // Number of entries in the desc array
|
2005-04-21 22:59:05 +02:00
|
|
|
|
2003-01-13 01:21:19 +01:00
|
|
|
TargetInstrInfo(const TargetInstrInfo &); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const TargetInstrInfo &); // DO NOT IMPLEMENT
|
2001-09-18 14:38:31 +02:00
|
|
|
public:
|
2008-01-07 08:27:27 +01:00
|
|
|
TargetInstrInfo(const TargetInstrDesc *desc, unsigned NumOpcodes);
|
2003-01-13 01:21:19 +01:00
|
|
|
virtual ~TargetInstrInfo();
|
2002-12-15 23:16:08 +01:00
|
|
|
|
2004-02-29 07:31:16 +01:00
|
|
|
unsigned getNumOpcodes() const { return NumOpcodes; }
|
2005-04-21 22:59:05 +02:00
|
|
|
|
2002-10-29 18:26:26 +01:00
|
|
|
/// get - Return the machine instruction descriptor that corresponds to the
|
|
|
|
/// specified instruction opcode.
|
|
|
|
///
|
2008-01-07 08:27:27 +01:00
|
|
|
const TargetInstrDesc &get(unsigned Opcode) const {
|
|
|
|
assert(Opcode < NumOpcodes && "Invalid opcode!");
|
|
|
|
return Descriptors[Opcode];
|
2001-09-18 14:38:31 +02:00
|
|
|
}
|
2002-10-29 18:35:09 +01:00
|
|
|
|
2007-12-09 00:58:46 +01:00
|
|
|
/// isTriviallyReMaterializable - Return true if the instruction is trivially
|
2007-06-26 02:48:07 +02:00
|
|
|
/// rematerializable, meaning it has no side effects and requires no operands
|
|
|
|
/// that aren't always available.
|
2009-10-10 01:27:56 +02:00
|
|
|
bool isTriviallyReMaterializable(const MachineInstr *MI,
|
|
|
|
AliasAnalysis *AA = 0) const {
|
2010-02-09 20:54:29 +01:00
|
|
|
return MI->getOpcode() == TargetOpcode::IMPLICIT_DEF ||
|
2009-10-10 01:27:56 +02:00
|
|
|
(MI->getDesc().isRematerializable() &&
|
2009-10-10 02:34:18 +02:00
|
|
|
(isReallyTriviallyReMaterializable(MI, AA) ||
|
2009-10-10 01:27:56 +02:00
|
|
|
isReallyTriviallyReMaterializableGeneric(MI, AA)));
|
2007-06-26 02:48:07 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2007-12-09 00:58:46 +01:00
|
|
|
/// isReallyTriviallyReMaterializable - For instructions with opcodes for
|
2009-10-10 01:27:56 +02: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 02:34:18 +02:00
|
|
|
virtual bool isReallyTriviallyReMaterializable(const MachineInstr *MI,
|
|
|
|
AliasAnalysis *AA) const {
|
2009-10-10 01:27:56 +02:00
|
|
|
return false;
|
2007-06-26 02:48:07 +02:00
|
|
|
}
|
|
|
|
|
2009-10-10 01:27:56 +02: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 02:48:07 +02:00
|
|
|
public:
|
2010-01-13 01:30:23 +01: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 01:09:37 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2006-02-02 21:11:55 +01: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 20:49:32 +01:00
|
|
|
virtual unsigned isLoadFromStackSlot(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const {
|
2006-02-02 21:11:55 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2009-11-12 21:55:29 +01:00
|
|
|
|
2009-11-13 01:29:53 +01: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 21:55:29 +01:00
|
|
|
/// hasLoadFromStackSlot - If the specified machine instruction has
|
|
|
|
/// a load from a stack slot, return true along with the FrameIndex
|
2009-12-05 00:00:50 +01:00
|
|
|
/// of the loaded stack slot and the machine mem operand containing
|
|
|
|
/// the reference. If not, return false. Unlike
|
2009-11-12 21:55:29 +01: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-05 00:00:50 +01:00
|
|
|
const MachineMemOperand *&MMO,
|
2009-11-12 21:55:29 +01:00
|
|
|
int &FrameIndex) const {
|
|
|
|
return 0;
|
|
|
|
}
|
2010-12-24 05:28:06 +01:00
|
|
|
|
2006-02-02 21:11:55 +01: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 20:49:32 +01:00
|
|
|
virtual unsigned isStoreToStackSlot(const MachineInstr *MI,
|
|
|
|
int &FrameIndex) const {
|
2006-02-02 21:11:55 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2003-12-28 18:35:08 +01:00
|
|
|
|
2009-11-13 01:29:53 +01: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-05 00:00:50 +01:00
|
|
|
int &FrameIndex) const {
|
2009-11-13 01:29:53 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-11-12 21:55:29 +01:00
|
|
|
/// hasStoreToStackSlot - If the specified machine instruction has a
|
|
|
|
/// store to a stack slot, return true along with the FrameIndex of
|
2009-12-05 00:00:50 +01:00
|
|
|
/// the loaded stack slot and the machine mem operand containing the
|
|
|
|
/// reference. If not, return false. Unlike isStoreToStackSlot,
|
2010-04-08 01:51:38 +02:00
|
|
|
/// this returns true for any instructions that stores to the
|
2009-12-05 00:00:50 +01:00
|
|
|
/// stack. This is just a hint, as some cases may be missed.
|
2009-11-12 21:55:29 +01:00
|
|
|
virtual bool hasStoreToStackSlot(const MachineInstr *MI,
|
2009-12-05 00:00:50 +01:00
|
|
|
const MachineMemOperand *&MMO,
|
2009-11-12 21:55:29 +01:00
|
|
|
int &FrameIndex) const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-03-31 22:40:39 +02:00
|
|
|
/// reMaterialize - Re-issue the specified 'original' instruction at the
|
|
|
|
/// specific location targeting a new destination register.
|
2010-06-03 00:47:25 +02: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 22:40:39 +02:00
|
|
|
virtual void reMaterialize(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
2009-07-16 11:20:10 +02:00
|
|
|
unsigned DestReg, unsigned SubIdx,
|
2009-11-14 03:55:43 +01:00
|
|
|
const MachineInstr *Orig,
|
2010-06-03 00:47:25 +02:00
|
|
|
const TargetRegisterInfo &TRI) const = 0;
|
2008-03-31 22:40:39 +02:00
|
|
|
|
2010-06-09 21:26:01 +02:00
|
|
|
/// scheduleTwoAddrSource - Schedule the copy / re-mat of the source of the
|
|
|
|
/// two-addrss instruction inserted by two-address pass.
|
|
|
|
virtual void scheduleTwoAddrSource(MachineInstr *SrcMI,
|
|
|
|
MachineInstr *UseMI,
|
|
|
|
const TargetRegisterInfo &TRI) const {
|
|
|
|
// Do nothing.
|
|
|
|
}
|
|
|
|
|
2010-01-07 00:47:07 +01: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 01:51:04 +01:00
|
|
|
///
|
|
|
|
/// The instruction must be duplicable as indicated by isNotDuplicable().
|
2010-01-07 00:47:07 +01:00
|
|
|
virtual MachineInstr *duplicate(MachineInstr *Orig,
|
|
|
|
MachineFunction &MF) const = 0;
|
|
|
|
|
2005-01-02 03:28:31 +01: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 17:15:24 +02:00
|
|
|
/// may be able to convert a two-address instruction into one or more true
|
2006-12-01 22:46:55 +01:00
|
|
|
/// three-address instructions on demand. This allows the X86 target (for
|
2005-01-02 03:28:31 +01: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 22:46:55 +01:00
|
|
|
/// performed, otherwise it returns the last new instruction.
|
2005-01-02 03:28:31 +01:00
|
|
|
///
|
2006-12-01 22:46:55 +01:00
|
|
|
virtual MachineInstr *
|
|
|
|
convertToThreeAddress(MachineFunction::iterator &MFI,
|
2008-07-03 01:41:07 +02:00
|
|
|
MachineBasicBlock::iterator &MBBI, LiveVariables *LV) const {
|
2005-01-02 03:28:31 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2010-06-24 18:48:26 +02: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 09:33:11 +02:00
|
|
|
virtual MachineInstr *commuteInstruction(MachineInstr *MI,
|
|
|
|
bool NewMI = false) const = 0;
|
2005-01-19 07:53:02 +01:00
|
|
|
|
2009-07-10 21:15:51 +02:00
|
|
|
/// findCommutedOpIndices - If specified MI is commutable, return the two
|
2010-06-24 18:48:26 +02:00
|
|
|
/// operand indices that would swap value. Return false if the instruction
|
2009-07-10 21:15:51 +02:00
|
|
|
/// is not in a form which this routine understands.
|
|
|
|
virtual bool findCommutedOpIndices(MachineInstr *MI, unsigned &SrcOpIdx1,
|
|
|
|
unsigned &SrcOpIdx2) const = 0;
|
2008-02-15 19:21:33 +01:00
|
|
|
|
2010-03-03 02:44:33 +01: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 09:34:58 +01: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 02:44:33 +01:00
|
|
|
virtual bool produceSameValue(const MachineInstr *MI0,
|
2011-01-20 09:34:58 +01:00
|
|
|
const MachineInstr *MI1,
|
|
|
|
const MachineRegisterInfo *MRI = 0) const = 0;
|
2009-11-07 05:07:30 +01:00
|
|
|
|
2006-10-13 22:44:01 +02: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-18 00:12:15 +02: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 22:44:01 +02:00
|
|
|
/// the destination block.
|
2009-12-14 07:51:19 +01: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 03:33:25 +02: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 22:44:01 +02:00
|
|
|
///
|
|
|
|
/// Note that RemoveBranch and InsertBranch must be implemented to support
|
|
|
|
/// cases where this method returns success.
|
|
|
|
///
|
2009-02-09 08:14:22 +01: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 22:44:01 +02:00
|
|
|
virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
|
|
|
MachineBasicBlock *&FBB,
|
2009-02-09 08:14:22 +01:00
|
|
|
SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
bool AllowModify = false) const {
|
2006-10-13 22:44:01 +02:00
|
|
|
return true;
|
2004-07-31 10:52:30 +02:00
|
|
|
}
|
2009-08-20 03:33:25 +02:00
|
|
|
|
2006-10-13 22:44:01 +02:00
|
|
|
/// RemoveBranch - Remove the branching code at the end of the specific MBB.
|
2008-10-20 17:58:02 +02:00
|
|
|
/// This is only invoked in cases where AnalyzeBranch returns success. It
|
2007-05-18 02:05:48 +02:00
|
|
|
/// returns the number of instructions that were removed.
|
|
|
|
virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const {
|
2010-12-24 05:28:06 +01:00
|
|
|
assert(0 && "Target didn't implement TargetInstrInfo::RemoveBranch!");
|
2007-05-18 02:05:48 +02:00
|
|
|
return 0;
|
2006-10-13 22:44:01 +02:00
|
|
|
}
|
2009-08-20 03:33:25 +02: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 20:40:21 +01: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 02:05:48 +02:00
|
|
|
virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
|
2010-06-18 00:43:56 +02:00
|
|
|
MachineBasicBlock *FBB,
|
|
|
|
const SmallVectorImpl<MachineOperand> &Cond,
|
|
|
|
DebugLoc DL) const {
|
2010-12-24 05:28:06 +01:00
|
|
|
assert(0 && "Target didn't implement TargetInstrInfo::InsertBranch!");
|
2007-05-18 02:05:48 +02:00
|
|
|
return 0;
|
2006-10-13 22:44:01 +02:00
|
|
|
}
|
2010-06-19 01:09:54 +02: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,
|
|
|
|
MachineBasicBlock *NewDest) const = 0;
|
2010-06-22 03:18:16 +02: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-26 00:42:03 +02:00
|
|
|
|
2010-11-03 01:45:17 +01:00
|
|
|
/// isProfitableToIfCvt - Return true if it's profitable to predicate
|
|
|
|
/// instructions with accumulated instruction latency of "NumCycles"
|
2010-09-28 20:32:13 +02:00
|
|
|
/// of the specified basic block, where the probability of the instructions
|
2010-10-02 00:45:50 +02:00
|
|
|
/// being executed is given by Probability, and Confidence is a measure
|
|
|
|
/// of our confidence that it will be properly predicted.
|
2010-06-26 00:42:03 +02:00
|
|
|
virtual
|
2010-11-03 01:45:17 +01:00
|
|
|
bool isProfitableToIfCvt(MachineBasicBlock &MBB, unsigned NumCyles,
|
|
|
|
unsigned ExtraPredCycles,
|
2010-10-02 00:45:50 +02:00
|
|
|
float Probability, float Confidence) const {
|
2010-06-26 00:42:03 +02:00
|
|
|
return false;
|
|
|
|
}
|
2010-12-24 05:28:06 +01:00
|
|
|
|
2010-06-26 00:42:03 +02: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 20:32:13 +02:00
|
|
|
/// predicates, where the probability of the true path being taken is given
|
2010-10-02 00:45:50 +02:00
|
|
|
/// by Probability, and Confidence is a measure of our confidence that it
|
|
|
|
/// will be properly predicted.
|
2010-06-26 00:42:03 +02:00
|
|
|
virtual bool
|
2010-11-03 01:45:17 +01:00
|
|
|
isProfitableToIfCvt(MachineBasicBlock &TMBB,
|
|
|
|
unsigned NumTCycles, unsigned ExtraTCycles,
|
|
|
|
MachineBasicBlock &FMBB,
|
|
|
|
unsigned NumFCycles, unsigned ExtraFCycles,
|
2010-10-02 00:45:50 +02:00
|
|
|
float Probability, float Confidence) const {
|
2010-06-26 00:42:03 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// isProfitableToDupForIfCvt - Return true if it's profitable for
|
2010-11-03 01:45:17 +01: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-26 00:42:03 +02:00
|
|
|
virtual bool
|
2010-11-03 01:45:17 +01:00
|
|
|
isProfitableToDupForIfCvt(MachineBasicBlock &MBB, unsigned NumCyles,
|
2010-10-02 00:45:50 +02:00
|
|
|
float Probability, float Confidence) const {
|
2010-06-26 00:42:03 +02:00
|
|
|
return false;
|
|
|
|
}
|
2010-12-24 05:28:06 +01:00
|
|
|
|
2010-07-08 07:01:41 +02:00
|
|
|
/// copyPhysReg - Emit instructions to copy a pair of physical registers.
|
|
|
|
virtual void copyPhysReg(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI, DebugLoc DL,
|
|
|
|
unsigned DestReg, unsigned SrcReg,
|
2010-07-11 19:01:17 +02:00
|
|
|
bool KillSrc) const {
|
|
|
|
assert(0 && "Target didn't implement TargetInstrInfo::copyPhysReg!");
|
|
|
|
}
|
2010-07-08 07:01:41 +02:00
|
|
|
|
2008-10-26 01:08:22 +02: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 22:11:32 +01:00
|
|
|
virtual void storeRegToStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
unsigned SrcReg, bool isKill, int FrameIndex,
|
2010-05-06 21:06:44 +02:00
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const {
|
2010-07-15 09:49:30 +02:00
|
|
|
assert(0 && "Target didn't implement TargetInstrInfo::storeRegToStackSlot!");
|
2008-01-01 22:11:32 +01:00
|
|
|
}
|
|
|
|
|
2008-10-26 01:08:22 +02: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 22:11:32 +01:00
|
|
|
virtual void loadRegFromStackSlot(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
unsigned DestReg, int FrameIndex,
|
2010-05-06 21:06:44 +02:00
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
const TargetRegisterInfo *TRI) const {
|
2010-07-15 09:49:30 +02:00
|
|
|
assert(0 && "Target didn't implement TargetInstrInfo::loadRegFromStackSlot!");
|
2008-01-01 22:11:32 +01:00
|
|
|
}
|
2008-01-05 00:57:37 +01:00
|
|
|
|
2010-04-26 09:38:55 +02:00
|
|
|
/// emitFrameIndexDebugValue - Emit a target-dependent form of
|
|
|
|
/// DBG_VALUE encoding the address of a frame index. Addresses would
|
|
|
|
/// normally be lowered the same way as other addresses on the target,
|
|
|
|
/// e.g. in load instructions. For targets that do not support this
|
|
|
|
/// the debug info is simply lost.
|
2010-04-26 22:05:01 +02:00
|
|
|
/// If you add this for a target you should handle this DBG_VALUE in the
|
|
|
|
/// target-specific AsmPrinter code as well; you will probably get invalid
|
|
|
|
/// assembly output if you don't.
|
2010-04-26 09:38:55 +02:00
|
|
|
virtual MachineInstr *emitFrameIndexDebugValue(MachineFunction &MF,
|
2010-04-29 03:13:30 +02:00
|
|
|
int FrameIx,
|
2010-04-26 09:38:55 +02:00
|
|
|
uint64_t Offset,
|
|
|
|
const MDNode *MDPtr,
|
|
|
|
DebugLoc dl) const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-01-07 02:35:02 +01: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 19:29:08 +02: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 19:43:12 +01:00
|
|
|
const SmallVectorImpl<unsigned> &Ops,
|
|
|
|
int FrameIndex) const;
|
2008-01-07 02:35:02 +01: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 19:29:08 +02:00
|
|
|
MachineInstr* foldMemoryOperand(MachineBasicBlock::iterator MI,
|
2008-12-03 19:43:12 +01:00
|
|
|
const SmallVectorImpl<unsigned> &Ops,
|
|
|
|
MachineInstr* LoadMI) const;
|
|
|
|
|
|
|
|
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 22:20:40 +01:00
|
|
|
MachineInstr* MI,
|
2008-10-16 03:49:15 +02:00
|
|
|
const SmallVectorImpl<unsigned> &Ops,
|
2008-12-03 19:43:12 +01:00
|
|
|
int FrameIndex) const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 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 09:49:30 +02:00
|
|
|
const SmallVectorImpl<unsigned> &Ops,
|
2008-12-03 19:43:12 +01:00
|
|
|
MachineInstr* LoadMI) const {
|
2008-01-07 02:35:02 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-03 19:43:12 +01:00
|
|
|
public:
|
2008-12-15 18:26:50 +01:00
|
|
|
/// canFoldMemoryOperand - Returns true for the specified load / store if
|
2008-01-07 02:35:02 +01:00
|
|
|
/// folding is possible.
|
|
|
|
virtual
|
2008-10-16 03:49:15 +02:00
|
|
|
bool canFoldMemoryOperand(const MachineInstr *MI,
|
2010-07-09 22:43:13 +02:00
|
|
|
const SmallVectorImpl<unsigned> &Ops) const =0;
|
2008-01-07 02:35:02 +01: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 20:32:42 +02:00
|
|
|
SmallVectorImpl<MachineInstr*> &NewMIs) const{
|
2008-01-07 02:35:02 +01: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 23:18:41 +01: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 02:35:02 +01:00
|
|
|
virtual unsigned getOpcodeAfterMemoryUnfold(unsigned Opc,
|
2009-10-30 23:18:41 +01:00
|
|
|
bool UnfoldLoad, bool UnfoldStore,
|
|
|
|
unsigned *LoadRegIndex = 0) const {
|
2008-01-07 02:35:02 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2010-01-22 04:34:51 +01: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 09:49:30 +02:00
|
|
|
int64_t &Offset1, int64_t &Offset2) const {
|
2010-01-22 04:34:51 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// shouldScheduleLoadsNear - This is a used by the pre-regalloc scheduler to
|
|
|
|
/// determine (in conjuction with areLoadsFromSameBasePtr) if two loads should
|
|
|
|
/// 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 05:28:06 +01:00
|
|
|
|
2006-10-13 22:59:31 +02:00
|
|
|
/// ReverseBranchCondition - Reverses the branch condition of the specified
|
|
|
|
/// condition list, returning false on success and true if it cannot be
|
|
|
|
/// reversed.
|
2008-08-15 00:49:33 +02:00
|
|
|
virtual
|
|
|
|
bool ReverseBranchCondition(SmallVectorImpl<MachineOperand> &Cond) const {
|
2006-10-13 22:59:31 +02:00
|
|
|
return true;
|
2004-07-31 10:52:30 +02:00
|
|
|
}
|
2010-12-24 05:28:06 +01:00
|
|
|
|
2006-03-06 00:48:51 +01:00
|
|
|
/// insertNoop - Insert a noop into the instruction stream at the specified
|
|
|
|
/// point.
|
2010-12-24 05:28:06 +01:00
|
|
|
virtual void insertNoop(MachineBasicBlock &MBB,
|
2009-08-02 06:58:19 +02:00
|
|
|
MachineBasicBlock::iterator MI) const;
|
2010-12-24 05:28:06 +01:00
|
|
|
|
|
|
|
|
2010-04-27 01:37:21 +02:00
|
|
|
/// getNoopForMachoTarget - Return the noop instruction to use for a noop.
|
|
|
|
virtual void getNoopForMachoTarget(MCInst &NopInst) const {
|
|
|
|
// Default to just using 'nop' string.
|
|
|
|
}
|
2010-12-24 05:28:06 +01:00
|
|
|
|
|
|
|
|
2007-06-08 23:59:56 +02:00
|
|
|
/// isPredicated - Returns true if the instruction is already predicated.
|
2007-05-23 09:19:12 +02:00
|
|
|
///
|
2007-05-29 20:35:22 +02:00
|
|
|
virtual bool isPredicated(const MachineInstr *MI) const {
|
2007-05-23 09:19:12 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2007-06-08 23:59:56 +02:00
|
|
|
/// isUnpredicatedTerminator - Returns true if the instruction is a
|
|
|
|
/// terminator instruction that has not been predicated.
|
2007-06-15 00:03:45 +02:00
|
|
|
virtual bool isUnpredicatedTerminator(const MachineInstr *MI) const;
|
2007-06-08 23:59:56 +02:00
|
|
|
|
2007-05-16 03:58:56 +02:00
|
|
|
/// PredicateInstruction - Convert the instruction into a predicated
|
2007-05-16 23:53:07 +02:00
|
|
|
/// instruction. It returns true if the operation was successful.
|
2007-05-29 20:35:22 +02:00
|
|
|
virtual
|
|
|
|
bool PredicateInstruction(MachineInstr *MI,
|
2008-08-15 00:49:33 +02:00
|
|
|
const SmallVectorImpl<MachineOperand> &Pred) const = 0;
|
2007-05-23 09:19:12 +02:00
|
|
|
|
2007-06-08 23:59:56 +02:00
|
|
|
/// SubsumesPredicate - Returns true if the first specified predicate
|
2007-05-23 09:19:12 +02:00
|
|
|
/// subsumes the second, e.g. GE subsumes GT.
|
2007-05-29 20:35:22 +02:00
|
|
|
virtual
|
2008-08-15 00:49:33 +02:00
|
|
|
bool SubsumesPredicate(const SmallVectorImpl<MachineOperand> &Pred1,
|
|
|
|
const SmallVectorImpl<MachineOperand> &Pred2) const {
|
2007-05-23 09:19:12 +02:00
|
|
|
return false;
|
|
|
|
}
|
2007-05-16 03:58:56 +02:00
|
|
|
|
2007-07-10 20:06:29 +02: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 07:20:26 +01: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 18:17:30 +01: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 08:14:50 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2010-06-19 01:09:54 +02: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,
|
|
|
|
const MachineFunction &MF) const = 0;
|
|
|
|
|
2009-08-02 07:20:37 +02:00
|
|
|
/// Measure the specified inline asm to determine an approximation of its
|
|
|
|
/// length.
|
|
|
|
virtual unsigned getInlineAsmLength(const char *Str,
|
2009-08-22 23:43:10 +02:00
|
|
|
const MCAsmInfo &MAI) const;
|
2010-06-12 02:12:18 +02: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.
llvm-svn: 122541
2010-12-24 06:03:26 +01:00
|
|
|
/// CreateTargetPreRAHazardRecognizer - Allocate and return a hazard
|
|
|
|
/// recognizer to use for this target when scheduling the machine instructions
|
|
|
|
/// before register allocation.
|
2010-06-12 02:12:18 +02:00
|
|
|
virtual ScheduleHazardRecognizer*
|
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.
llvm-svn: 122541
2010-12-24 06:03:26 +01:00
|
|
|
CreateTargetHazardRecognizer(const TargetMachine *TM,
|
|
|
|
const ScheduleDAG *DAG) const = 0;
|
|
|
|
|
|
|
|
/// 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*,
|
|
|
|
const ScheduleDAG *DAG) const = 0;
|
2010-08-06 03:32:48 +02:00
|
|
|
|
2010-08-08 07:04:59 +02:00
|
|
|
/// AnalyzeCompare - For a comparison instruction, return the source register
|
|
|
|
/// in SrcReg and the value it compares against in CmpValue. Return true if
|
|
|
|
/// the comparison instruction can be analyzed.
|
|
|
|
virtual bool AnalyzeCompare(const MachineInstr *MI,
|
2010-09-21 14:01:15 +02:00
|
|
|
unsigned &SrcReg, int &Mask, int &Value) const {
|
2010-08-06 03:32:48 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2010-09-11 02:13:50 +02:00
|
|
|
/// OptimizeCompareInstr - See if the comparison instruction can be converted
|
|
|
|
/// into something more efficient. E.g., on ARM most instructions can set the
|
2010-11-15 22:20:45 +01:00
|
|
|
/// flags register, obviating the need for a separate CMP.
|
2010-09-21 14:01:15 +02:00
|
|
|
virtual bool OptimizeCompareInstr(MachineInstr *CmpInstr,
|
|
|
|
unsigned SrcReg, int Mask, int Value,
|
2010-11-15 22:20:45 +01:00
|
|
|
const MachineRegisterInfo *MRI) const {
|
2010-08-06 03:32:48 +02:00
|
|
|
return false;
|
|
|
|
}
|
2010-12-24 05:28:06 +01:00
|
|
|
|
2010-11-17 21:13:28 +01:00
|
|
|
/// FoldImmediate - 'Reg' is known to be defined by a move immediate
|
|
|
|
/// instruction, try to fold the immediate into the use instruction.
|
|
|
|
virtual bool FoldImmediate(MachineInstr *UseMI, MachineInstr *DefMI,
|
|
|
|
unsigned Reg, MachineRegisterInfo *MRI) const {
|
|
|
|
return false;
|
|
|
|
}
|
2010-09-09 20:18:55 +02:00
|
|
|
|
|
|
|
/// getNumMicroOps - Return the number of u-operations the given machine
|
|
|
|
/// instruction will be decoded to on the target cpu.
|
2010-11-03 01:45:17 +01:00
|
|
|
virtual unsigned getNumMicroOps(const InstrItineraryData *ItinData,
|
|
|
|
const MachineInstr *MI) const;
|
2010-10-06 08:27:31 +02:00
|
|
|
|
|
|
|
/// getOperandLatency - Compute and return the use operand latency of a given
|
2010-11-03 01:45:17 +01:00
|
|
|
/// pair of def and use.
|
2010-10-06 08:27:31 +02: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.
|
2010-11-03 01:45:17 +01:00
|
|
|
virtual int getOperandLatency(const InstrItineraryData *ItinData,
|
|
|
|
const MachineInstr *DefMI, unsigned DefIdx,
|
|
|
|
const MachineInstr *UseMI, unsigned UseIdx) const;
|
|
|
|
|
|
|
|
virtual int getOperandLatency(const InstrItineraryData *ItinData,
|
|
|
|
SDNode *DefNode, unsigned DefIdx,
|
|
|
|
SDNode *UseNode, unsigned UseIdx) const;
|
|
|
|
|
|
|
|
/// getInstrLatency - Compute the instruction latency of a given instruction.
|
|
|
|
/// If the instruction has higher cost when predicated, it's returned via
|
|
|
|
/// PredCost.
|
|
|
|
virtual int getInstrLatency(const InstrItineraryData *ItinData,
|
|
|
|
const MachineInstr *MI,
|
|
|
|
unsigned *PredCost = 0) const;
|
|
|
|
|
|
|
|
virtual int getInstrLatency(const InstrItineraryData *ItinData,
|
|
|
|
SDNode *Node) const;
|
2010-10-19 20:58:51 +02: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 04:08:50 +02:00
|
|
|
|
|
|
|
/// hasLowDefLatency - Compute operand latency of a def of 'Reg', return true
|
|
|
|
/// if the target considered it 'low'.
|
|
|
|
virtual
|
|
|
|
bool hasLowDefLatency(const InstrItineraryData *ItinData,
|
|
|
|
const MachineInstr *DefMI, unsigned DefIdx) const;
|
2001-09-18 14:38:31 +02:00
|
|
|
};
|
|
|
|
|
2008-01-01 02:03:04 +01:00
|
|
|
/// TargetInstrInfoImpl - This is the default implementation of
|
|
|
|
/// TargetInstrInfo, which just provides a couple of default implementations
|
|
|
|
/// for various methods. This separated out because it is implemented in
|
|
|
|
/// libcodegen, not in libtarget.
|
|
|
|
class TargetInstrInfoImpl : public TargetInstrInfo {
|
|
|
|
protected:
|
2008-01-07 08:27:27 +01:00
|
|
|
TargetInstrInfoImpl(const TargetInstrDesc *desc, unsigned NumOpcodes)
|
2008-01-01 02:03:04 +01:00
|
|
|
: TargetInstrInfo(desc, NumOpcodes) {}
|
|
|
|
public:
|
2010-06-19 01:09:54 +02:00
|
|
|
virtual void ReplaceTailWithBranchTo(MachineBasicBlock::iterator OldInst,
|
|
|
|
MachineBasicBlock *NewDest) const;
|
2008-06-16 09:33:11 +02:00
|
|
|
virtual MachineInstr *commuteInstruction(MachineInstr *MI,
|
|
|
|
bool NewMI = false) const;
|
2009-07-10 21:15:51 +02:00
|
|
|
virtual bool findCommutedOpIndices(MachineInstr *MI, unsigned &SrcOpIdx1,
|
|
|
|
unsigned &SrcOpIdx2) const;
|
2010-07-09 22:43:13 +02:00
|
|
|
virtual bool canFoldMemoryOperand(const MachineInstr *MI,
|
|
|
|
const SmallVectorImpl<unsigned> &Ops) const;
|
2008-01-01 02:03:04 +01:00
|
|
|
virtual bool PredicateInstruction(MachineInstr *MI,
|
2008-08-15 00:49:33 +02:00
|
|
|
const SmallVectorImpl<MachineOperand> &Pred) const;
|
2008-03-31 22:40:39 +02:00
|
|
|
virtual void reMaterialize(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
2009-07-16 11:20:10 +02:00
|
|
|
unsigned DestReg, unsigned SubReg,
|
2009-11-14 03:55:43 +01:00
|
|
|
const MachineInstr *Orig,
|
2010-06-03 00:47:25 +02:00
|
|
|
const TargetRegisterInfo &TRI) const;
|
2010-01-07 00:47:07 +01:00
|
|
|
virtual MachineInstr *duplicate(MachineInstr *Orig,
|
|
|
|
MachineFunction &MF) const;
|
2010-03-03 02:44:33 +01:00
|
|
|
virtual bool produceSameValue(const MachineInstr *MI0,
|
2011-01-20 09:34:58 +01:00
|
|
|
const MachineInstr *MI1,
|
|
|
|
const MachineRegisterInfo *MRI) const;
|
2010-06-19 01:09:54 +02:00
|
|
|
virtual bool isSchedulingBoundary(const MachineInstr *MI,
|
|
|
|
const MachineBasicBlock *MBB,
|
|
|
|
const MachineFunction &MF) const;
|
2010-06-12 02:12:18 +02:00
|
|
|
|
|
|
|
virtual ScheduleHazardRecognizer *
|
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.
llvm-svn: 122541
2010-12-24 06:03:26 +01:00
|
|
|
CreateTargetHazardRecognizer(const TargetMachine*, const ScheduleDAG*) const;
|
|
|
|
|
|
|
|
virtual ScheduleHazardRecognizer *
|
|
|
|
CreateTargetPostRAHazardRecognizer(const InstrItineraryData*,
|
|
|
|
const ScheduleDAG*) const;
|
2008-01-01 02:03:04 +01:00
|
|
|
};
|
|
|
|
|
2003-11-11 23:41:34 +01:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-09-18 14:38:31 +02:00
|
|
|
#endif
|