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
|
|
|
|
2008-01-07 07:33:08 +00:00
|
|
|
#include "llvm/Target/TargetInstrDesc.h"
|
2006-12-01 21:46:55 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2001-09-18 12:38:31 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2005-08-19 16:56:26 +00:00
|
|
|
class TargetRegisterClass;
|
2006-12-01 21:46:55 +00:00
|
|
|
class LiveVariables;
|
2008-01-04 23:57:37 +00:00
|
|
|
class CalleeSavedInfo;
|
2008-01-07 01:35:02 +00:00
|
|
|
class SDNode;
|
|
|
|
class SelectionDAG;
|
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
|
|
|
///
|
2003-01-13 00:21:19 +00:00
|
|
|
class TargetInstrInfo {
|
2008-01-07 07:27:27 +00:00
|
|
|
const TargetInstrDesc *Descriptors; // Raw array to allow static init'n
|
|
|
|
unsigned NumOpcodes; // Number of entries in the desc array
|
2005-04-21 20:59:05 +00:00
|
|
|
|
2003-01-13 00:21:19 +00:00
|
|
|
TargetInstrInfo(const TargetInstrInfo &); // DO NOT IMPLEMENT
|
|
|
|
void operator=(const TargetInstrInfo &); // DO NOT IMPLEMENT
|
2001-09-18 12:38:31 +00:00
|
|
|
public:
|
2008-01-07 07:27:27 +00:00
|
|
|
TargetInstrInfo(const TargetInstrDesc *desc, unsigned NumOpcodes);
|
2003-01-13 00:21:19 +00:00
|
|
|
virtual ~TargetInstrInfo();
|
2002-12-15 22:16:08 +00:00
|
|
|
|
2006-01-26 23:27:02 +00:00
|
|
|
// Invariant opcodes: All instruction sets have these as their low opcodes.
|
|
|
|
enum {
|
|
|
|
PHI = 0,
|
2007-01-26 14:34:52 +00:00
|
|
|
INLINEASM = 1,
|
2008-07-01 00:05:16 +00:00
|
|
|
DBG_LABEL = 2,
|
|
|
|
EH_LABEL = 3,
|
|
|
|
GC_LABEL = 4,
|
|
|
|
DECLARE = 5,
|
|
|
|
EXTRACT_SUBREG = 6,
|
|
|
|
INSERT_SUBREG = 7,
|
|
|
|
IMPLICIT_DEF = 8,
|
|
|
|
SUBREG_TO_REG = 9
|
2008-03-13 05:47:01 +00:00
|
|
|
};
|
2005-04-21 20:59:05 +00:00
|
|
|
|
2004-02-29 06:31:16 +00:00
|
|
|
unsigned getNumOpcodes() const { return NumOpcodes; }
|
2005-04-21 20:59:05 +00:00
|
|
|
|
2002-10-29 17:26:26 +00:00
|
|
|
/// get - Return the machine instruction descriptor that corresponds to the
|
|
|
|
/// specified instruction opcode.
|
|
|
|
///
|
2008-01-07 07:27:27 +00:00
|
|
|
const TargetInstrDesc &get(unsigned Opcode) const {
|
|
|
|
assert(Opcode < NumOpcodes && "Invalid opcode!");
|
|
|
|
return Descriptors[Opcode];
|
2001-09-18 12:38:31 +00:00
|
|
|
}
|
2002-10-29 17:35:09 +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.
|
2008-05-12 20:54:26 +00:00
|
|
|
bool isTriviallyReMaterializable(const MachineInstr *MI) const {
|
2008-01-07 07:27:27 +00:00
|
|
|
return MI->getDesc().isRematerializable() &&
|
2007-12-08 23:58:46 +00:00
|
|
|
isReallyTriviallyReMaterializable(MI);
|
2007-06-26 00:48:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
2007-12-08 23:58:46 +00:00
|
|
|
/// isReallyTriviallyReMaterializable - For instructions with opcodes for
|
|
|
|
/// which the M_REMATERIALIZABLE flag is set, this function tests whether the
|
|
|
|
/// instruction itself is actually trivially rematerializable, considering
|
|
|
|
/// its operands. This is used for targets that have instructions that are
|
|
|
|
/// only trivially rematerializable for specific uses. 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.
|
2008-05-12 20:54:26 +00:00
|
|
|
virtual bool isReallyTriviallyReMaterializable(const MachineInstr *MI) const {
|
2007-06-26 00:48:07 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2004-07-31 08:57:27 +00:00
|
|
|
/// Return true if the instruction is a register to register move
|
|
|
|
/// and leave the source and dest operands in the passed parameters.
|
2003-12-28 17:35:08 +00:00
|
|
|
virtual bool isMoveInstr(const MachineInstr& MI,
|
|
|
|
unsigned& sourceReg,
|
|
|
|
unsigned& destReg) const {
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 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
|
|
|
|
2008-03-31 20:40:39 +00:00
|
|
|
/// reMaterialize - Re-issue the specified 'original' instruction at the
|
|
|
|
/// specific location targeting a new destination register.
|
|
|
|
virtual void reMaterialize(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
unsigned DestReg,
|
|
|
|
const MachineInstr *Orig) const = 0;
|
|
|
|
|
2008-01-10 23:08:24 +00:00
|
|
|
/// isInvariantLoad - Return true if the specified instruction (which is
|
|
|
|
/// marked mayLoad) is loading from a location whose value is invariant across
|
|
|
|
/// the function. For example, loading a value from the constant pool or from
|
|
|
|
/// from the argument area of a function if it does not change. This should
|
|
|
|
/// only return true of *all* loads the instruction does are invariant (if it
|
|
|
|
/// does multiple loads).
|
2008-11-18 19:49:32 +00:00
|
|
|
virtual bool isInvariantLoad(const MachineInstr *MI) const {
|
2008-01-10 23:08:24 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
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 {
|
2005-01-02 02:28:31 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-01-19 06:53:02 +00:00
|
|
|
/// commuteInstruction - If a target has any instructions that are commutable,
|
|
|
|
/// but require converting to a different instruction or making non-trivial
|
|
|
|
/// changes to commute them, this method can overloaded to do this. The
|
|
|
|
/// default implementation of this method simply swaps the first two operands
|
|
|
|
/// of MI and returns it.
|
|
|
|
///
|
|
|
|
/// If a target wants to make more aggressive changes, they can construct and
|
|
|
|
/// return a new machine instruction. If an instruction cannot commute, it
|
|
|
|
/// can also return null.
|
|
|
|
///
|
2008-06-16 07:33:11 +00:00
|
|
|
/// If NewMI is true, then a new machine instruction must be created.
|
|
|
|
///
|
|
|
|
virtual MachineInstr *commuteInstruction(MachineInstr *MI,
|
|
|
|
bool NewMI = false) const = 0;
|
2005-01-19 06:53:02 +00:00
|
|
|
|
2008-02-15 18:21:33 +00:00
|
|
|
/// CommuteChangesDestination - Return true if commuting the specified
|
|
|
|
/// instruction will also changes the destination operand. Also return the
|
|
|
|
/// current operand index of the would be new destination register by
|
|
|
|
/// reference. This can happen when the commutable instruction is also a
|
|
|
|
/// two-address instruction.
|
|
|
|
virtual bool CommuteChangesDestination(MachineInstr *MI,
|
|
|
|
unsigned &OpIdx) const = 0;
|
|
|
|
|
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.
|
2007-05-16 05:09:34 +00:00
|
|
|
/// 3. If this block ends with an conditional branch and it falls through to
|
|
|
|
/// an successor block, it sets TBB to be the branch destination block and a
|
|
|
|
/// list of operands that evaluate the condition. These
|
|
|
|
/// operands can be passed to other TargetInstrInfo methods to create new
|
|
|
|
/// branches.
|
|
|
|
/// 4. If this block ends with an conditional branch and an unconditional
|
|
|
|
/// block, 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.
|
|
|
|
///
|
|
|
|
virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB,
|
|
|
|
MachineBasicBlock *&FBB,
|
2008-08-14 22:49:33 +00:00
|
|
|
SmallVectorImpl<MachineOperand> &Cond) const {
|
2006-10-13 20:44:01 +00:00
|
|
|
return true;
|
2004-07-31 08:52:30 +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 {
|
2006-10-13 20:44:01 +00:00
|
|
|
assert(0 && "Target didn't implement TargetInstrInfo::RemoveBranch!");
|
2007-05-18 00:05:48 +00:00
|
|
|
return 0;
|
2006-10-13 20:44:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// InsertBranch - Insert a branch into the end of the specified
|
|
|
|
/// MachineBasicBlock. This operands to this method are the same as those
|
2006-10-24 17:41:22 +00:00
|
|
|
/// returned by AnalyzeBranch. This is invoked in cases where AnalyzeBranch
|
|
|
|
/// returns success and when an unconditional branch (TBB is non-null, FBB is
|
2007-05-18 00:05:48 +00:00
|
|
|
/// null, Cond is empty) needs to be inserted. It returns the number of
|
|
|
|
/// instructions inserted.
|
|
|
|
virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB,
|
2006-10-13 21:02:27 +00:00
|
|
|
MachineBasicBlock *FBB,
|
2008-08-14 22:49:33 +00:00
|
|
|
const SmallVectorImpl<MachineOperand> &Cond) const {
|
2006-10-24 14:47:28 +00:00
|
|
|
assert(0 && "Target didn't implement TargetInstrInfo::InsertBranch!");
|
2007-05-18 00:05:48 +00:00
|
|
|
return 0;
|
2006-10-13 20:44:01 +00:00
|
|
|
}
|
|
|
|
|
2008-10-13 17:30:56 +00:00
|
|
|
/// copyRegToReg - Emit instructions to copy between a pair of registers. It
|
|
|
|
/// returns false if the target does not how to copy between the specified
|
|
|
|
/// registers.
|
2008-08-26 18:03:31 +00:00
|
|
|
virtual bool copyRegToReg(MachineBasicBlock &MBB,
|
2007-12-31 06:32:00 +00:00
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
unsigned DestReg, unsigned SrcReg,
|
|
|
|
const TargetRegisterClass *DestRC,
|
|
|
|
const TargetRegisterClass *SrcRC) const {
|
|
|
|
assert(0 && "Target didn't implement TargetInstrInfo::copyRegToReg!");
|
2008-08-26 19:49:04 +00:00
|
|
|
return false;
|
2007-12-31 06:32:00 +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,
|
|
|
|
const TargetRegisterClass *RC) const {
|
|
|
|
assert(0 && "Target didn't implement TargetInstrInfo::storeRegToStackSlot!");
|
|
|
|
}
|
|
|
|
|
2008-10-25 23:08:22 +00:00
|
|
|
/// storeRegToAddr - Store the specified register of the given register class
|
|
|
|
/// to the specified address. 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 storeRegToAddr(MachineFunction &MF, unsigned SrcReg, bool isKill,
|
|
|
|
SmallVectorImpl<MachineOperand> &Addr,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
SmallVectorImpl<MachineInstr*> &NewMIs) const {
|
|
|
|
assert(0 && "Target didn't implement TargetInstrInfo::storeRegToAddr!");
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
const TargetRegisterClass *RC) const {
|
|
|
|
assert(0 && "Target didn't implement TargetInstrInfo::loadRegFromStackSlot!");
|
|
|
|
}
|
|
|
|
|
2008-10-25 23:08:22 +00:00
|
|
|
/// loadRegFromAddr - Load the specified register of the given register class
|
|
|
|
/// class from the specified address. 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 loadRegFromAddr(MachineFunction &MF, unsigned DestReg,
|
|
|
|
SmallVectorImpl<MachineOperand> &Addr,
|
|
|
|
const TargetRegisterClass *RC,
|
|
|
|
SmallVectorImpl<MachineInstr*> &NewMIs) const {
|
|
|
|
assert(0 && "Target didn't implement TargetInstrInfo::loadRegFromAddr!");
|
|
|
|
}
|
|
|
|
|
2008-01-04 23:57:37 +00:00
|
|
|
/// spillCalleeSavedRegisters - Issues instruction(s) to spill all callee
|
|
|
|
/// saved registers and returns true if it isn't possible / profitable to do
|
|
|
|
/// so by issuing a series of store instructions via
|
|
|
|
/// storeRegToStackSlot(). Returns false otherwise.
|
|
|
|
virtual bool spillCalleeSavedRegisters(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
const std::vector<CalleeSavedInfo> &CSI) const {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// restoreCalleeSavedRegisters - Issues instruction(s) to restore all callee
|
|
|
|
/// saved registers and returns true if it isn't possible / profitable to do
|
|
|
|
/// so by issuing a series of load instructions via loadRegToStackSlot().
|
|
|
|
/// Returns false otherwise.
|
|
|
|
virtual bool restoreCalleeSavedRegisters(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
const std::vector<CalleeSavedInfo> &CSI) const {
|
|
|
|
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
|
|
|
|
/// operand folded, otherwise NULL is returned. The client is responsible for
|
|
|
|
/// removing the old instruction and adding the new one in the instruction
|
|
|
|
/// stream.
|
2008-12-03 18:43:12 +00:00
|
|
|
MachineInstr* foldMemoryOperand(MachineFunction &MF,
|
|
|
|
MachineInstr* MI,
|
|
|
|
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.
|
2008-12-03 18:43:12 +00:00
|
|
|
MachineInstr* foldMemoryOperand(MachineFunction &MF,
|
|
|
|
MachineInstr* MI,
|
|
|
|
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 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 {
|
|
|
|
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,
|
|
|
|
const SmallVectorImpl<unsigned> &Ops,
|
|
|
|
MachineInstr* LoadMI) const {
|
2008-01-07 01:35:02 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
const SmallVectorImpl<unsigned> &Ops) const {
|
2008-01-07 01:35:02 +00:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// 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,
|
|
|
|
SmallVectorImpl<MachineInstr*> &NewMIs) const{
|
|
|
|
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
|
|
|
|
/// possible.
|
|
|
|
virtual unsigned getOpcodeAfterMemoryUnfold(unsigned Opc,
|
|
|
|
bool UnfoldLoad, bool UnfoldStore) const {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2006-10-28 17:29:57 +00:00
|
|
|
/// BlockHasNoFallThrough - Return true if the specified block does not
|
|
|
|
/// fall-through into its successor block. This is primarily used when a
|
|
|
|
/// branch is unanalyzable. It is useful for things like unconditional
|
|
|
|
/// indirect branches (jump tables).
|
2008-10-16 01:49:15 +00:00
|
|
|
virtual bool BlockHasNoFallThrough(const MachineBasicBlock &MBB) const {
|
2006-10-28 17:29:57 +00:00
|
|
|
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
|
|
|
}
|
2005-09-02 18:16:20 +00:00
|
|
|
|
2006-03-05 23:48:51 +00:00
|
|
|
/// insertNoop - Insert a noop into the instruction stream at the specified
|
|
|
|
/// point.
|
|
|
|
virtual void insertNoop(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI) const {
|
|
|
|
assert(0 && "Target didn't implement insertNoop!");
|
|
|
|
abort();
|
|
|
|
}
|
2006-05-18 20:42:07 +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.
|
2007-06-14 22:03:45 +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,
|
2008-08-14 22:49:33 +00:00
|
|
|
const SmallVectorImpl<MachineOperand> &Pred) const = 0;
|
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;
|
|
|
|
}
|
|
|
|
|
2008-10-27 07:14:50 +00:00
|
|
|
/// IgnoreRegisterClassBarriers - Returns true if pre-register allocation
|
|
|
|
/// live interval splitting pass should ignore barriers of the specified
|
|
|
|
/// register class.
|
|
|
|
virtual bool IgnoreRegisterClassBarriers(const TargetRegisterClass *RC) const{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2006-05-18 20:42:07 +00:00
|
|
|
/// getPointerRegClass - Returns a TargetRegisterClass used for pointer
|
|
|
|
/// values.
|
|
|
|
virtual const TargetRegisterClass *getPointerRegClass() const {
|
|
|
|
assert(0 && "Target didn't implement getPointerRegClass!");
|
|
|
|
abort();
|
2007-03-14 15:25:21 +00:00
|
|
|
return 0; // Must return a value in order to compile with VS 2005
|
2006-05-18 20:42:07 +00:00
|
|
|
}
|
2008-04-16 20:10:13 +00:00
|
|
|
|
|
|
|
/// GetInstSize - Returns the size of the specified Instruction.
|
|
|
|
///
|
|
|
|
virtual unsigned GetInstSizeInBytes(const MachineInstr *MI) const {
|
|
|
|
assert(0 && "Target didn't implement TargetInstrInfo::GetInstSize!");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// GetFunctionSizeInBytes - Returns the size of the specified MachineFunction.
|
|
|
|
///
|
|
|
|
virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const = 0;
|
2001-09-18 12:38:31 +00:00
|
|
|
};
|
|
|
|
|
2008-01-01 01:03:04 +00: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 07:27:27 +00:00
|
|
|
TargetInstrInfoImpl(const TargetInstrDesc *desc, unsigned NumOpcodes)
|
2008-01-01 01:03:04 +00:00
|
|
|
: TargetInstrInfo(desc, NumOpcodes) {}
|
|
|
|
public:
|
2008-06-16 07:33:11 +00:00
|
|
|
virtual MachineInstr *commuteInstruction(MachineInstr *MI,
|
|
|
|
bool NewMI = false) const;
|
2008-02-15 18:21:33 +00:00
|
|
|
virtual bool CommuteChangesDestination(MachineInstr *MI,
|
|
|
|
unsigned &OpIdx) const;
|
2008-01-01 01:03:04 +00:00
|
|
|
virtual bool PredicateInstruction(MachineInstr *MI,
|
2008-08-14 22:49:33 +00:00
|
|
|
const SmallVectorImpl<MachineOperand> &Pred) const;
|
2008-03-31 20:40:39 +00:00
|
|
|
virtual void reMaterialize(MachineBasicBlock &MBB,
|
|
|
|
MachineBasicBlock::iterator MI,
|
|
|
|
unsigned DestReg,
|
|
|
|
const MachineInstr *Orig) const;
|
2008-04-16 20:10:13 +00:00
|
|
|
virtual unsigned GetFunctionSizeInBytes(const MachineFunction &MF) const;
|
2008-01-01 01:03:04 +00:00
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2001-09-18 12:38:31 +00:00
|
|
|
#endif
|