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
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and 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
|
|
|
//
|
|
|
|
// This file describes the target machine instructions to the code generator.
|
|
|
|
//
|
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
|
|
|
|
2004-07-31 08:52:30 +00:00
|
|
|
#include "llvm/CodeGen/MachineBasicBlock.h"
|
2006-12-01 21:46:55 +00:00
|
|
|
#include "llvm/CodeGen/MachineFunction.h"
|
2004-09-01 22:55:40 +00:00
|
|
|
#include "llvm/Support/DataTypes.h"
|
2002-10-28 23:53:56 +00:00
|
|
|
#include <vector>
|
2003-07-25 17:58:41 +00:00
|
|
|
#include <cassert>
|
2001-09-18 12:38:31 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2001-10-18 00:02:06 +00:00
|
|
|
class MachineInstr;
|
2002-02-03 07:17:37 +00:00
|
|
|
class TargetMachine;
|
2002-05-19 15:43:31 +00:00
|
|
|
class MachineCodeForInstruction;
|
2005-08-19 16:56:26 +00:00
|
|
|
class TargetRegisterClass;
|
2006-12-01 21:46:55 +00:00
|
|
|
class LiveVariables;
|
2001-09-18 12:38:31 +00:00
|
|
|
|
2002-02-03 07:17:37 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// Data types used to define information about a single machine instruction
|
|
|
|
//---------------------------------------------------------------------------
|
2001-09-18 12:38:31 +00:00
|
|
|
|
2004-02-12 18:49:07 +00:00
|
|
|
typedef short MachineOpCode;
|
2002-10-28 04:53:18 +00:00
|
|
|
typedef unsigned InstrSchedClass;
|
2001-09-18 12:38:31 +00:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
2003-01-14 22:00:31 +00:00
|
|
|
// struct TargetInstrDescriptor:
|
2005-04-22 03:46:24 +00:00
|
|
|
// Predefined information about each machine instruction.
|
|
|
|
// Designed to initialized statically.
|
2003-01-14 22:00:31 +00:00
|
|
|
//
|
2001-09-18 12:38:31 +00:00
|
|
|
|
2006-04-20 18:32:02 +00:00
|
|
|
const unsigned M_BRANCH_FLAG = 1 << 0;
|
|
|
|
const unsigned M_CALL_FLAG = 1 << 1;
|
|
|
|
const unsigned M_RET_FLAG = 1 << 2;
|
|
|
|
const unsigned M_BARRIER_FLAG = 1 << 3;
|
|
|
|
const unsigned M_DELAY_SLOT_FLAG = 1 << 4;
|
|
|
|
const unsigned M_LOAD_FLAG = 1 << 5;
|
|
|
|
const unsigned M_STORE_FLAG = 1 << 6;
|
2005-01-02 02:28:31 +00:00
|
|
|
|
2006-11-09 02:22:54 +00:00
|
|
|
// M_CONVERTIBLE_TO_3_ADDR - This is a 2-address instruction which can be
|
2005-01-02 02:28:31 +00:00
|
|
|
// changed into a 3-address instruction if the first two operands cannot be
|
|
|
|
// assigned to the same register. The target must implement the
|
|
|
|
// TargetInstrInfo::convertToThreeAddress method for this instruction.
|
2006-11-09 02:22:54 +00:00
|
|
|
const unsigned M_CONVERTIBLE_TO_3_ADDR = 1 << 7;
|
2005-01-02 02:28:31 +00:00
|
|
|
|
|
|
|
// This M_COMMUTABLE - is a 2- or 3-address instruction (of the form X = op Y,
|
|
|
|
// Z), which produces the same result if Y and Z are exchanged.
|
2006-11-09 02:22:54 +00:00
|
|
|
const unsigned M_COMMUTABLE = 1 << 8;
|
2001-09-18 12:38:31 +00:00
|
|
|
|
2003-01-13 00:21:19 +00:00
|
|
|
// M_TERMINATOR_FLAG - Is this instruction part of the terminator for a basic
|
|
|
|
// block? Typically this is things like return and branch instructions.
|
|
|
|
// Various passes use this to insert code into the bottom of a basic block, but
|
|
|
|
// before control flow occurs.
|
2006-11-09 02:22:54 +00:00
|
|
|
const unsigned M_TERMINATOR_FLAG = 1 << 9;
|
2003-01-13 00:21:19 +00:00
|
|
|
|
2005-08-26 20:31:24 +00:00
|
|
|
// M_USES_CUSTOM_DAG_SCHED_INSERTION - Set if this instruction requires custom
|
|
|
|
// insertion support when the DAG scheduler is inserting it into a machine basic
|
|
|
|
// block.
|
2006-11-09 02:22:54 +00:00
|
|
|
const unsigned M_USES_CUSTOM_DAG_SCHED_INSERTION = 1 << 10;
|
2005-08-26 20:31:24 +00:00
|
|
|
|
2006-06-15 07:22:16 +00:00
|
|
|
// M_VARIABLE_OPS - Set if this instruction can have a variable number of extra
|
|
|
|
// operands in addition to the minimum number operands specified.
|
2006-11-09 02:22:54 +00:00
|
|
|
const unsigned M_VARIABLE_OPS = 1 << 11;
|
2006-06-15 07:22:16 +00:00
|
|
|
|
2007-05-16 20:43:42 +00:00
|
|
|
// M_PREDICABLE - Set if this instruction has a predicate operand that
|
|
|
|
// controls execution. It may be set to 'always'.
|
|
|
|
const unsigned M_PREDICABLE = 1 << 12;
|
2006-11-06 21:44:17 +00:00
|
|
|
|
2007-06-26 00:48:07 +00:00
|
|
|
// M_REMATERIALIZIBLE - Set if this instruction can be trivally re-materialized
|
|
|
|
// at any time, e.g. constant generation, load from constant pool.
|
|
|
|
const unsigned M_REMATERIALIZIBLE = 1 << 13;
|
|
|
|
|
2007-06-19 01:21:41 +00:00
|
|
|
// M_NOT_DUPLICABLE - Set if this instruction cannot be safely duplicated.
|
|
|
|
// (e.g. instructions with unique labels attached).
|
2007-07-10 18:06:29 +00:00
|
|
|
const unsigned M_NOT_DUPLICABLE = 1 << 14;
|
|
|
|
|
|
|
|
// M_HAS_OPTIONAL_DEF - Set if this instruction has an optional definition, e.g.
|
|
|
|
// ARM instructions which can set condition code if 's' bit is set.
|
|
|
|
const unsigned M_HAS_OPTIONAL_DEF = 1 << 15;
|
2007-06-19 01:21:41 +00:00
|
|
|
|
2006-05-18 20:42:07 +00:00
|
|
|
// Machine operand flags
|
|
|
|
// M_LOOK_UP_PTR_REG_CLASS - Set if this operand is a pointer value and it
|
|
|
|
// requires a callback to look up its register class.
|
|
|
|
const unsigned M_LOOK_UP_PTR_REG_CLASS = 1 << 0;
|
|
|
|
|
2007-05-15 01:21:27 +00:00
|
|
|
/// M_PREDICATE_OPERAND - Set if this is one of the operands that made up of the
|
|
|
|
/// predicate operand that controls an M_PREDICATED instruction.
|
2006-11-06 23:53:08 +00:00
|
|
|
const unsigned M_PREDICATE_OPERAND = 1 << 1;
|
|
|
|
|
2007-07-10 18:06:29 +00:00
|
|
|
/// M_OPTIONAL_DEF_OPERAND - Set if this operand is a optional def.
|
|
|
|
///
|
|
|
|
const unsigned M_OPTIONAL_DEF_OPERAND = 1 << 2;
|
|
|
|
|
2006-12-01 21:46:55 +00:00
|
|
|
namespace TOI {
|
|
|
|
// Operand constraints: only "tied_to" for now.
|
|
|
|
enum OperandConstraint {
|
|
|
|
TIED_TO = 0 // Must be allocated the same register as.
|
|
|
|
};
|
|
|
|
}
|
2006-11-06 23:53:08 +00:00
|
|
|
|
2005-08-19 16:56:26 +00:00
|
|
|
/// TargetOperandInfo - This holds information about one operand of a machine
|
|
|
|
/// instruction, indicating the register class for register operands, etc.
|
|
|
|
///
|
|
|
|
class TargetOperandInfo {
|
|
|
|
public:
|
2006-07-21 20:57:35 +00:00
|
|
|
/// RegClass - This specifies the register class enumeration of the operand
|
|
|
|
/// if the operand is a register. If not, this contains 0.
|
|
|
|
unsigned short RegClass;
|
|
|
|
unsigned short Flags;
|
2006-11-01 00:27:05 +00:00
|
|
|
/// Lower 16 bits are used to specify which constraints are set. The higher 16
|
|
|
|
/// bits are used to specify the value of constraints (4 bits each).
|
|
|
|
unsigned int Constraints;
|
2005-08-19 16:56:26 +00:00
|
|
|
/// Currently no other information.
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2004-10-27 16:14:51 +00:00
|
|
|
class TargetInstrDescriptor {
|
|
|
|
public:
|
2006-11-17 01:36:01 +00:00
|
|
|
MachineOpCode Opcode; // The opcode.
|
|
|
|
unsigned short numOperands; // Num of args (may be more if variable_ops).
|
2002-10-29 17:35:09 +00:00
|
|
|
const char * Name; // Assembly language mnemonic for the opcode.
|
2002-10-30 01:06:53 +00:00
|
|
|
InstrSchedClass schedClass; // enum identifying instr sched class
|
|
|
|
unsigned Flags; // flags identifying machine instr class
|
|
|
|
unsigned TSFlags; // Target Specific Flag values
|
2002-12-03 05:41:32 +00:00
|
|
|
const unsigned *ImplicitUses; // Registers implicitly read by this instr
|
|
|
|
const unsigned *ImplicitDefs; // Registers implicitly defined by this instr
|
2005-08-19 16:56:26 +00:00
|
|
|
const TargetOperandInfo *OpInfo; // 'numOperands' entries about operands.
|
2006-12-01 21:46:55 +00:00
|
|
|
|
|
|
|
/// getOperandConstraint - Returns the value of the specific constraint if
|
|
|
|
/// it is set. Returns -1 if it is not set.
|
|
|
|
int getOperandConstraint(unsigned OpNum,
|
|
|
|
TOI::OperandConstraint Constraint) const {
|
2006-12-15 06:37:08 +00:00
|
|
|
assert((OpNum < numOperands || (Flags & M_VARIABLE_OPS)) &&
|
|
|
|
"Invalid operand # of TargetInstrInfo");
|
|
|
|
if (OpNum < numOperands &&
|
|
|
|
(OpInfo[OpNum].Constraints & (1 << Constraint))) {
|
2006-12-01 21:46:55 +00:00
|
|
|
unsigned Pos = 16 + Constraint * 4;
|
|
|
|
return (int)(OpInfo[OpNum].Constraints >> Pos) & 0xf;
|
|
|
|
}
|
|
|
|
return -1;
|
|
|
|
}
|
2006-12-08 18:45:48 +00:00
|
|
|
|
|
|
|
/// findTiedToSrcOperand - Returns the operand that is tied to the specified
|
|
|
|
/// dest operand. Returns -1 if there isn't one.
|
|
|
|
int findTiedToSrcOperand(unsigned OpNum) const;
|
2001-09-18 12:38:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2003-01-14 22:00:31 +00:00
|
|
|
//---------------------------------------------------------------------------
|
2005-04-21 20:59:05 +00:00
|
|
|
///
|
2003-01-14 22:00:31 +00:00
|
|
|
/// TargetInstrInfo - Interface to description of machine instructions
|
2005-04-21 20:59:05 +00:00
|
|
|
///
|
2003-01-13 00:21:19 +00:00
|
|
|
class TargetInstrInfo {
|
|
|
|
const TargetInstrDescriptor* desc; // raw array to allow static init'n
|
2004-02-29 06:31:16 +00:00
|
|
|
unsigned NumOpcodes; // number of entries in the desc array
|
2003-01-13 00:21:19 +00:00
|
|
|
unsigned numRealOpCodes; // number of non-dummy op codes
|
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:
|
2004-02-29 06:31:16 +00:00
|
|
|
TargetInstrInfo(const TargetInstrDescriptor *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,
|
|
|
|
LABEL = 2
|
2006-01-26 23:27:02 +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.
|
|
|
|
///
|
2004-07-31 02:06:48 +00:00
|
|
|
const TargetInstrDescriptor& get(MachineOpCode Opcode) const {
|
|
|
|
assert((unsigned)Opcode < NumOpcodes);
|
|
|
|
return desc[Opcode];
|
2001-09-18 12:38:31 +00:00
|
|
|
}
|
2002-10-29 17:35:09 +00:00
|
|
|
|
2004-07-31 02:06:48 +00:00
|
|
|
const char *getName(MachineOpCode Opcode) const {
|
|
|
|
return get(Opcode).Name;
|
2002-10-29 17:35:09 +00:00
|
|
|
}
|
2005-04-21 20:59:05 +00:00
|
|
|
|
2004-07-31 02:06:48 +00:00
|
|
|
int getNumOperands(MachineOpCode Opcode) const {
|
|
|
|
return get(Opcode).numOperands;
|
2001-09-18 12:38:31 +00:00
|
|
|
}
|
2004-02-29 05:57:21 +00:00
|
|
|
|
2004-07-31 02:06:48 +00:00
|
|
|
InstrSchedClass getSchedClass(MachineOpCode Opcode) const {
|
|
|
|
return get(Opcode).schedClass;
|
2001-09-18 12:38:31 +00:00
|
|
|
}
|
2003-06-27 00:00:48 +00:00
|
|
|
|
2004-07-31 02:06:48 +00:00
|
|
|
const unsigned *getImplicitUses(MachineOpCode Opcode) const {
|
|
|
|
return get(Opcode).ImplicitUses;
|
2003-06-27 00:00:48 +00:00
|
|
|
}
|
|
|
|
|
2004-07-31 02:06:48 +00:00
|
|
|
const unsigned *getImplicitDefs(MachineOpCode Opcode) const {
|
|
|
|
return get(Opcode).ImplicitDefs;
|
2003-06-27 00:00:48 +00:00
|
|
|
}
|
|
|
|
|
2004-02-29 05:57:21 +00:00
|
|
|
|
2001-09-18 12:38:31 +00:00
|
|
|
//
|
|
|
|
// Query instruction class flags according to the machine-independent
|
|
|
|
// flags listed above.
|
2005-04-21 20:59:05 +00:00
|
|
|
//
|
2004-07-31 02:06:48 +00:00
|
|
|
bool isReturn(MachineOpCode Opcode) const {
|
|
|
|
return get(Opcode).Flags & M_RET_FLAG;
|
2001-09-18 12:38:31 +00:00
|
|
|
}
|
2004-02-29 05:57:21 +00:00
|
|
|
|
2006-05-12 01:58:24 +00:00
|
|
|
bool isCommutableInstr(MachineOpCode Opcode) const {
|
|
|
|
return get(Opcode).Flags & M_COMMUTABLE;
|
|
|
|
}
|
2007-05-22 01:21:58 +00:00
|
|
|
bool isTerminatorInstr(MachineOpCode Opcode) const {
|
2003-01-13 00:21:19 +00:00
|
|
|
return get(Opcode).Flags & M_TERMINATOR_FLAG;
|
|
|
|
}
|
2005-09-02 18:16:20 +00:00
|
|
|
|
|
|
|
bool isBranch(MachineOpCode Opcode) const {
|
|
|
|
return get(Opcode).Flags & M_BRANCH_FLAG;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// isBarrier - Returns true if the specified instruction stops control flow
|
|
|
|
/// from executing the instruction immediately following it. Examples include
|
|
|
|
/// unconditional branches and return instructions.
|
|
|
|
bool isBarrier(MachineOpCode Opcode) const {
|
|
|
|
return get(Opcode).Flags & M_BARRIER_FLAG;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isCall(MachineOpCode Opcode) const {
|
|
|
|
return get(Opcode).Flags & M_CALL_FLAG;
|
|
|
|
}
|
|
|
|
bool isLoad(MachineOpCode Opcode) const {
|
|
|
|
return get(Opcode).Flags & M_LOAD_FLAG;
|
|
|
|
}
|
|
|
|
bool isStore(MachineOpCode Opcode) const {
|
|
|
|
return get(Opcode).Flags & M_STORE_FLAG;
|
|
|
|
}
|
|
|
|
|
2006-10-13 20:44:01 +00:00
|
|
|
/// hasDelaySlot - Returns true if the specified instruction has a delay slot
|
|
|
|
/// which must be filled by the code generator.
|
2007-05-22 01:21:58 +00:00
|
|
|
bool hasDelaySlot(MachineOpCode Opcode) const {
|
2006-10-13 20:44:01 +00:00
|
|
|
return get(Opcode).Flags & M_DELAY_SLOT_FLAG;
|
|
|
|
}
|
|
|
|
|
2005-09-02 18:16:20 +00:00
|
|
|
/// usesCustomDAGSchedInsertionHook - Return true if this instruction requires
|
|
|
|
/// custom insertion support when the DAG scheduler is inserting it into a
|
|
|
|
/// machine basic block.
|
2007-05-22 01:21:58 +00:00
|
|
|
bool usesCustomDAGSchedInsertionHook(MachineOpCode Opcode) const {
|
2005-09-02 18:16:20 +00:00
|
|
|
return get(Opcode).Flags & M_USES_CUSTOM_DAG_SCHED_INSERTION;
|
|
|
|
}
|
2002-09-20 00:52:09 +00:00
|
|
|
|
2006-06-15 07:22:16 +00:00
|
|
|
bool hasVariableOperands(MachineOpCode Opcode) const {
|
|
|
|
return get(Opcode).Flags & M_VARIABLE_OPS;
|
|
|
|
}
|
|
|
|
|
2007-06-19 01:21:41 +00:00
|
|
|
bool isPredicable(MachineOpCode Opcode) const {
|
|
|
|
return get(Opcode).Flags & M_PREDICABLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isNotDuplicable(MachineOpCode Opcode) const {
|
|
|
|
return get(Opcode).Flags & M_NOT_DUPLICABLE;
|
|
|
|
}
|
|
|
|
|
2007-07-10 18:06:29 +00:00
|
|
|
bool hasOptionalDef(MachineOpCode Opcode) const {
|
|
|
|
return get(Opcode).Flags & M_HAS_OPTIONAL_DEF;
|
|
|
|
}
|
|
|
|
|
2007-06-26 00:48:07 +00:00
|
|
|
/// isTriviallyReMaterializable - Return true if the instruction is trivially
|
|
|
|
/// rematerializable, meaning it has no side effects and requires no operands
|
|
|
|
/// that aren't always available.
|
|
|
|
bool isTriviallyReMaterializable(MachineInstr *MI) const {
|
|
|
|
return (MI->getInstrDescriptor()->Flags & M_REMATERIALIZIBLE) &&
|
|
|
|
isReallyTriviallyReMaterializable(MI);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
/// 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.
|
|
|
|
virtual bool isReallyTriviallyReMaterializable(MachineInstr *MI) const {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
2006-11-01 00:27:05 +00:00
|
|
|
/// getOperandConstraint - Returns the value of the specific constraint if
|
|
|
|
/// it is set. Returns -1 if it is not set.
|
|
|
|
int getOperandConstraint(MachineOpCode Opcode, unsigned OpNum,
|
2006-12-01 21:46:55 +00:00
|
|
|
TOI::OperandConstraint Constraint) const {
|
|
|
|
return get(Opcode).getOperandConstraint(OpNum, Constraint);
|
2006-11-01 00:27:05 +00:00
|
|
|
}
|
|
|
|
|
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.
|
|
|
|
virtual unsigned isLoadFromStackSlot(MachineInstr *MI, int &FrameIndex) const{
|
|
|
|
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.
|
|
|
|
virtual unsigned isStoreToStackSlot(MachineInstr *MI, int &FrameIndex) const {
|
|
|
|
return 0;
|
|
|
|
}
|
2003-12-28 17:35:08 +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,
|
|
|
|
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.
|
|
|
|
///
|
|
|
|
virtual MachineInstr *commuteInstruction(MachineInstr *MI) const;
|
|
|
|
|
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,
|
|
|
|
std::vector<MachineOperand> &Cond) const {
|
|
|
|
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.
|
2007-05-18 00:05:48 +00:00
|
|
|
/// this is only invoked in cases where AnalyzeBranch returns success. It
|
|
|
|
/// 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,
|
|
|
|
const std::vector<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
|
|
|
}
|
|
|
|
|
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).
|
|
|
|
virtual bool BlockHasNoFallThrough(MachineBasicBlock &MBB) 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.
|
|
|
|
virtual bool ReverseBranchCondition(std::vector<MachineOperand> &Cond) const {
|
|
|
|
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,
|
|
|
|
const std::vector<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
|
|
|
|
bool SubsumesPredicate(const std::vector<MachineOperand> &Pred1,
|
|
|
|
const std::vector<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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
}
|
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
|