2001-07-21 12:39:03 +00:00
|
|
|
// $Id$ -*-c++-*-
|
|
|
|
//***************************************************************************
|
|
|
|
// File:
|
|
|
|
// MachineInstr.h
|
|
|
|
//
|
|
|
|
// Purpose:
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// Strategy:
|
|
|
|
//
|
|
|
|
// History:
|
|
|
|
// 7/2/01 - Vikram Adve - Created
|
|
|
|
//**************************************************************************/
|
|
|
|
|
|
|
|
#ifndef LLVM_CODEGEN_MACHINEINSTR_H
|
|
|
|
#define LLVM_CODEGEN_MACHINEINSTR_H
|
|
|
|
|
2001-07-28 04:06:37 +00:00
|
|
|
#include <iterator>
|
2001-07-21 23:24:48 +00:00
|
|
|
#include "llvm/CodeGen/InstrForest.h"
|
2001-07-23 17:46:59 +00:00
|
|
|
#include "llvm/Support/DataTypes.h"
|
2001-07-23 18:26:21 +00:00
|
|
|
#include "llvm/Support/NonCopyable.h"
|
2001-09-18 12:41:43 +00:00
|
|
|
#include "llvm/Target/MachineInstrInfo.h"
|
2001-07-21 12:39:03 +00:00
|
|
|
|
2001-07-28 04:06:37 +00:00
|
|
|
template<class _MI, class _V> class ValOpIterator;
|
|
|
|
|
|
|
|
|
2001-07-21 12:39:03 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// class MachineOperand
|
|
|
|
//
|
|
|
|
// Purpose:
|
|
|
|
// Representation of each machine instruction operand.
|
|
|
|
// This class is designed so that you can allocate a vector of operands
|
|
|
|
// first and initialize each one later.
|
|
|
|
//
|
|
|
|
// E.g, for this VM instruction:
|
|
|
|
// ptr = alloca type, numElements
|
|
|
|
// we generate 2 machine instructions on the SPARC:
|
|
|
|
//
|
|
|
|
// mul Constant, Numelements -> Reg
|
|
|
|
// add %sp, Reg -> Ptr
|
|
|
|
//
|
|
|
|
// Each instruction has 3 operands, listed above. Of those:
|
|
|
|
// - Reg, NumElements, and Ptr are of operand type MO_Register.
|
|
|
|
// - Constant is of operand type MO_SignExtendedImmed on the SPARC.
|
|
|
|
//
|
|
|
|
// For the register operands, the virtual register type is as follows:
|
|
|
|
//
|
|
|
|
// - Reg will be of virtual register type MO_MInstrVirtualReg. The field
|
|
|
|
// MachineInstr* minstr will point to the instruction that computes reg.
|
|
|
|
//
|
|
|
|
// - %sp will be of virtual register type MO_MachineReg.
|
|
|
|
// The field regNum identifies the machine register.
|
|
|
|
//
|
|
|
|
// - NumElements will be of virtual register type MO_VirtualReg.
|
|
|
|
// The field Value* value identifies the value.
|
|
|
|
//
|
|
|
|
// - Ptr will also be of virtual register type MO_VirtualReg.
|
|
|
|
// Again, the field Value* value identifies the value.
|
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2001-09-15 00:33:26 +00:00
|
|
|
|
2001-07-21 12:39:03 +00:00
|
|
|
class MachineOperand {
|
|
|
|
public:
|
|
|
|
enum MachineOperandType {
|
2001-07-28 04:06:37 +00:00
|
|
|
MO_VirtualRegister, // virtual register for *value
|
|
|
|
MO_MachineRegister, // pre-assigned machine register `regNum'
|
2001-07-21 12:39:03 +00:00
|
|
|
MO_CCRegister,
|
|
|
|
MO_SignExtendedImmed,
|
|
|
|
MO_UnextendedImmed,
|
|
|
|
MO_PCRelativeDisp,
|
|
|
|
};
|
|
|
|
|
2001-07-28 04:06:37 +00:00
|
|
|
private:
|
|
|
|
MachineOperandType opType;
|
2001-07-21 12:39:03 +00:00
|
|
|
|
2001-07-28 04:06:37 +00:00
|
|
|
union {
|
|
|
|
Value* value; // BasicBlockVal for a label operand.
|
2001-07-21 12:39:03 +00:00
|
|
|
// ConstantVal for a non-address immediate.
|
2001-07-28 04:06:37 +00:00
|
|
|
// Virtual register for an SSA operand,
|
|
|
|
// including hidden operands required for
|
2001-09-15 20:16:41 +00:00
|
|
|
// the generated machine code.
|
2001-07-28 04:06:37 +00:00
|
|
|
int64_t immedVal; // constant value for an explicit constant
|
|
|
|
};
|
2001-08-07 20:14:30 +00:00
|
|
|
|
2001-09-18 22:54:47 +00:00
|
|
|
unsigned regNum; // register number for an explicit register
|
2001-09-15 20:16:41 +00:00
|
|
|
// will be set for a value after reg allocation
|
2001-08-09 19:18:33 +00:00
|
|
|
bool isDef; // is this a defition for the value
|
2001-07-21 12:39:03 +00:00
|
|
|
|
2001-07-28 04:06:37 +00:00
|
|
|
public:
|
2001-07-21 12:39:03 +00:00
|
|
|
/*ctor*/ MachineOperand ();
|
|
|
|
/*ctor*/ MachineOperand (MachineOperandType operandType,
|
|
|
|
Value* _val);
|
|
|
|
/*copy ctor*/ MachineOperand (const MachineOperand&);
|
|
|
|
/*dtor*/ ~MachineOperand () {}
|
|
|
|
|
2001-07-28 04:06:37 +00:00
|
|
|
// Accessor methods. Caller is responsible for checking the
|
|
|
|
// operand type before invoking the corresponding accessor.
|
|
|
|
//
|
2001-08-09 19:18:33 +00:00
|
|
|
inline MachineOperandType getOperandType () const {
|
2001-07-28 04:06:37 +00:00
|
|
|
return opType;
|
|
|
|
}
|
2001-08-09 19:18:33 +00:00
|
|
|
inline Value* getVRegValue () const {
|
2001-09-10 20:02:12 +00:00
|
|
|
assert(opType == MO_VirtualRegister || opType == MO_CCRegister ||
|
|
|
|
opType == MO_PCRelativeDisp);
|
2001-07-28 04:06:37 +00:00
|
|
|
return value;
|
|
|
|
}
|
2001-09-18 22:54:47 +00:00
|
|
|
inline unsigned int getMachineRegNum() const {
|
2001-07-28 04:06:37 +00:00
|
|
|
assert(opType == MO_MachineRegister);
|
|
|
|
return regNum;
|
|
|
|
}
|
2001-08-09 19:18:33 +00:00
|
|
|
inline int64_t getImmedValue () const {
|
2001-07-28 04:06:37 +00:00
|
|
|
assert(opType >= MO_SignExtendedImmed || opType <= MO_PCRelativeDisp);
|
|
|
|
return immedVal;
|
|
|
|
}
|
2001-08-09 19:18:33 +00:00
|
|
|
inline bool opIsDef () const {
|
|
|
|
return isDef;
|
|
|
|
}
|
2001-07-28 04:06:37 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
friend ostream& operator<<(ostream& os, const MachineOperand& mop);
|
2001-08-09 19:18:33 +00:00
|
|
|
|
2001-07-28 04:06:37 +00:00
|
|
|
|
|
|
|
private:
|
2001-07-21 12:39:03 +00:00
|
|
|
// These functions are provided so that a vector of operands can be
|
|
|
|
// statically allocated and individual ones can be initialized later.
|
2001-07-28 04:06:37 +00:00
|
|
|
// Give class MachineInstr gets access to these functions.
|
2001-07-21 12:39:03 +00:00
|
|
|
//
|
|
|
|
void Initialize (MachineOperandType operandType,
|
|
|
|
Value* _val);
|
|
|
|
void InitializeConst (MachineOperandType operandType,
|
|
|
|
int64_t intValue);
|
|
|
|
void InitializeReg (unsigned int regNum);
|
2001-07-28 04:06:37 +00:00
|
|
|
|
|
|
|
friend class MachineInstr;
|
2001-08-28 23:11:46 +00:00
|
|
|
friend class ValOpIterator<const MachineInstr, const Value>;
|
|
|
|
friend class ValOpIterator< MachineInstr, Value>;
|
2001-09-08 14:22:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2001-09-15 20:16:41 +00:00
|
|
|
// replaces the Value with its corresponding physical register afeter
|
|
|
|
// register allocation is complete
|
2001-09-18 22:54:47 +00:00
|
|
|
void setRegForValue(int reg) {
|
2001-09-15 20:16:41 +00:00
|
|
|
assert(opType == MO_VirtualRegister || opType == MO_CCRegister);
|
|
|
|
regNum = reg;
|
|
|
|
}
|
|
|
|
|
2001-09-15 21:11:48 +00:00
|
|
|
// used to get the reg number if when one is allocted (must be
|
|
|
|
// called only after reg alloc)
|
2001-09-18 22:54:47 +00:00
|
|
|
inline unsigned getAllocatedRegNum() const {
|
2001-09-15 21:11:48 +00:00
|
|
|
assert(opType == MO_VirtualRegister || opType == MO_CCRegister ||
|
|
|
|
opType == MO_MachineRegister);
|
|
|
|
return regNum;
|
|
|
|
}
|
|
|
|
|
2001-09-08 17:23:06 +00:00
|
|
|
|
2001-07-21 12:39:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
inline
|
|
|
|
MachineOperand::MachineOperand()
|
2001-07-28 04:06:37 +00:00
|
|
|
: opType(MO_VirtualRegister),
|
2001-07-21 12:39:03 +00:00
|
|
|
value(NULL),
|
|
|
|
regNum(0),
|
2001-08-07 20:14:30 +00:00
|
|
|
immedVal(0),
|
|
|
|
isDef(false)
|
2001-07-21 12:39:03 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
inline
|
|
|
|
MachineOperand::MachineOperand(MachineOperandType operandType,
|
|
|
|
Value* _val)
|
2001-07-28 04:06:37 +00:00
|
|
|
: opType(operandType),
|
2001-07-21 12:39:03 +00:00
|
|
|
value(_val),
|
|
|
|
regNum(0),
|
2001-08-07 20:14:30 +00:00
|
|
|
immedVal(0),
|
|
|
|
isDef(false)
|
2001-07-21 12:39:03 +00:00
|
|
|
{}
|
|
|
|
|
|
|
|
inline
|
|
|
|
MachineOperand::MachineOperand(const MachineOperand& mo)
|
2001-08-07 20:14:30 +00:00
|
|
|
: opType(mo.opType),
|
|
|
|
isDef(false)
|
2001-07-21 12:39:03 +00:00
|
|
|
{
|
2001-07-28 04:06:37 +00:00
|
|
|
switch(opType) {
|
|
|
|
case MO_VirtualRegister:
|
|
|
|
case MO_CCRegister: value = mo.value; break;
|
|
|
|
case MO_MachineRegister: regNum = mo.regNum; break;
|
|
|
|
case MO_SignExtendedImmed:
|
|
|
|
case MO_UnextendedImmed:
|
|
|
|
case MO_PCRelativeDisp: immedVal = mo.immedVal; break;
|
|
|
|
default: assert(0);
|
|
|
|
}
|
2001-07-21 12:39:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
MachineOperand::Initialize(MachineOperandType operandType,
|
|
|
|
Value* _val)
|
|
|
|
{
|
2001-07-28 04:06:37 +00:00
|
|
|
opType = operandType;
|
2001-07-21 12:39:03 +00:00
|
|
|
value = _val;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
MachineOperand::InitializeConst(MachineOperandType operandType,
|
|
|
|
int64_t intValue)
|
|
|
|
{
|
2001-07-28 04:06:37 +00:00
|
|
|
opType = operandType;
|
2001-07-21 12:39:03 +00:00
|
|
|
value = NULL;
|
|
|
|
immedVal = intValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline void
|
|
|
|
MachineOperand::InitializeReg(unsigned int _regNum)
|
|
|
|
{
|
2001-07-28 04:06:37 +00:00
|
|
|
opType = MO_MachineRegister;
|
2001-07-21 12:39:03 +00:00
|
|
|
value = NULL;
|
|
|
|
regNum = _regNum;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// class MachineInstr
|
|
|
|
//
|
|
|
|
// Purpose:
|
|
|
|
// Representation of each machine instruction.
|
|
|
|
//
|
|
|
|
// MachineOpCode must be an enum, defined separately for each target.
|
|
|
|
// E.g., It is defined in SparcInstructionSelection.h for the SPARC.
|
|
|
|
//
|
|
|
|
// opCodeMask is used to record variants of an instruction.
|
|
|
|
// E.g., each branch instruction on SPARC has 2 flags (i.e., 4 variants):
|
|
|
|
// ANNUL: if 1: Annul delay slot instruction.
|
|
|
|
// PREDICT-NOT-TAKEN: if 1: predict branch not taken.
|
|
|
|
// Instead of creating 4 different opcodes for BNZ, we create a single
|
|
|
|
// opcode and set bits in opCodeMask for each of these flags.
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
2001-07-23 18:26:21 +00:00
|
|
|
class MachineInstr : public NonCopyable {
|
2001-07-21 12:39:03 +00:00
|
|
|
private:
|
|
|
|
MachineOpCode opCode;
|
|
|
|
OpCodeMask opCodeMask; // extra bits for variants of an opcode
|
2001-07-28 04:06:37 +00:00
|
|
|
vector<MachineOperand> operands;
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef ValOpIterator<const MachineInstr, const Value> val_op_const_iterator;
|
2001-09-08 17:23:06 +00:00
|
|
|
typedef ValOpIterator<const MachineInstr, Value> val_op_iterator;
|
2001-07-21 12:39:03 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
/*ctor*/ MachineInstr (MachineOpCode _opCode,
|
|
|
|
OpCodeMask _opCodeMask = 0x0);
|
2001-07-31 21:49:28 +00:00
|
|
|
/*ctor*/ MachineInstr (MachineOpCode _opCode,
|
|
|
|
unsigned numOperands,
|
|
|
|
OpCodeMask _opCodeMask = 0x0);
|
2001-07-23 18:26:21 +00:00
|
|
|
inline ~MachineInstr () {}
|
2001-07-21 12:39:03 +00:00
|
|
|
|
|
|
|
const MachineOpCode getOpCode () const;
|
|
|
|
|
|
|
|
unsigned int getNumOperands () const;
|
|
|
|
|
|
|
|
const MachineOperand& getOperand (unsigned int i) const;
|
2001-07-28 04:06:37 +00:00
|
|
|
MachineOperand& getOperand (unsigned int i);
|
2001-07-21 12:39:03 +00:00
|
|
|
|
2001-08-28 23:11:46 +00:00
|
|
|
bool operandIsDefined(unsigned int i) const;
|
|
|
|
|
2001-08-07 21:01:23 +00:00
|
|
|
void dump (unsigned int indent = 0) const;
|
2001-09-08 14:22:50 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-07-21 12:39:03 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
friend ostream& operator<<(ostream& os, const MachineInstr& minstr);
|
2001-07-28 04:06:37 +00:00
|
|
|
friend val_op_const_iterator;
|
|
|
|
friend val_op_iterator;
|
2001-07-21 12:39:03 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
// Access to set the operands when building the machine instruction
|
|
|
|
void SetMachineOperand(unsigned int i,
|
|
|
|
MachineOperand::MachineOperandType operandType,
|
2001-08-07 20:14:30 +00:00
|
|
|
Value* _val, bool isDef=false);
|
2001-07-21 12:39:03 +00:00
|
|
|
void SetMachineOperand(unsigned int i,
|
|
|
|
MachineOperand::MachineOperandType operandType,
|
2001-08-07 20:14:30 +00:00
|
|
|
int64_t intValue, bool isDef=false);
|
2001-07-21 12:39:03 +00:00
|
|
|
void SetMachineOperand(unsigned int i,
|
2001-08-07 20:14:30 +00:00
|
|
|
unsigned int regNum,
|
|
|
|
bool isDef=false);
|
2001-07-21 12:39:03 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
inline const MachineOpCode
|
|
|
|
MachineInstr::getOpCode() const
|
|
|
|
{
|
|
|
|
return opCode;
|
|
|
|
}
|
|
|
|
|
|
|
|
inline unsigned int
|
|
|
|
MachineInstr::getNumOperands() const
|
|
|
|
{
|
|
|
|
return operands.size();
|
|
|
|
}
|
|
|
|
|
2001-07-28 04:06:37 +00:00
|
|
|
inline MachineOperand&
|
|
|
|
MachineInstr::getOperand(unsigned int i)
|
|
|
|
{
|
2001-07-31 21:49:28 +00:00
|
|
|
assert(i < operands.size() && "getOperand() out of range!");
|
2001-07-28 04:06:37 +00:00
|
|
|
return operands[i];
|
|
|
|
}
|
|
|
|
|
2001-07-21 12:39:03 +00:00
|
|
|
inline const MachineOperand&
|
|
|
|
MachineInstr::getOperand(unsigned int i) const
|
|
|
|
{
|
2001-07-31 21:49:28 +00:00
|
|
|
assert(i < operands.size() && "getOperand() out of range!");
|
2001-07-21 12:39:03 +00:00
|
|
|
return operands[i];
|
|
|
|
}
|
|
|
|
|
2001-08-28 23:11:46 +00:00
|
|
|
inline bool
|
|
|
|
MachineInstr::operandIsDefined(unsigned int i) const
|
|
|
|
{
|
|
|
|
return getOperand(i).opIsDef();
|
|
|
|
}
|
|
|
|
|
2001-07-21 12:39:03 +00:00
|
|
|
|
2001-07-28 04:06:37 +00:00
|
|
|
template<class _MI, class _V>
|
|
|
|
class ValOpIterator : public std::forward_iterator<_V, ptrdiff_t> {
|
|
|
|
private:
|
|
|
|
unsigned int i;
|
|
|
|
int resultPos;
|
2001-08-09 20:14:22 +00:00
|
|
|
_MI* minstr;
|
2001-08-09 19:18:33 +00:00
|
|
|
|
2001-07-28 04:06:37 +00:00
|
|
|
inline void skipToNextVal() {
|
2001-08-09 19:18:33 +00:00
|
|
|
while (i < minstr->getNumOperands() &&
|
|
|
|
! ((minstr->operands[i].opType == MachineOperand::MO_VirtualRegister
|
|
|
|
|| minstr->operands[i].opType == MachineOperand::MO_CCRegister)
|
|
|
|
&& minstr->operands[i].value != NULL))
|
2001-07-28 04:06:37 +00:00
|
|
|
++i;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
typedef ValOpIterator<_MI, _V> _Self;
|
|
|
|
|
|
|
|
inline ValOpIterator(_MI* _minstr) : i(0), minstr(_minstr) {
|
|
|
|
resultPos = TargetInstrDescriptors[minstr->opCode].resultPos;
|
|
|
|
skipToNextVal();
|
|
|
|
};
|
|
|
|
|
|
|
|
inline _V* operator*() const { return minstr->getOperand(i).getVRegValue();}
|
2001-09-15 00:33:26 +00:00
|
|
|
|
|
|
|
const MachineOperand & getMachineOperand() const { return minstr->getOperand(i); }
|
|
|
|
|
2001-07-28 04:06:37 +00:00
|
|
|
inline _V* operator->() const { return operator*(); }
|
2001-08-07 20:14:30 +00:00
|
|
|
// inline bool isDef () const { return (((int) i) == resultPos); }
|
2001-08-09 19:18:33 +00:00
|
|
|
|
2001-08-07 20:14:30 +00:00
|
|
|
inline bool isDef () const { return minstr->getOperand(i).isDef; }
|
2001-07-28 04:06:37 +00:00
|
|
|
inline bool done () const { return (i == minstr->getNumOperands()); }
|
|
|
|
|
|
|
|
inline _Self& operator++() { i++; skipToNextVal(); return *this; }
|
|
|
|
inline _Self operator++(int) { _Self tmp = *this; ++*this; return tmp; }
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-07-21 12:39:03 +00:00
|
|
|
//---------------------------------------------------------------------------
|
2001-07-30 18:49:07 +00:00
|
|
|
// class MachineCodeForVMInstr
|
2001-07-21 12:39:03 +00:00
|
|
|
//
|
|
|
|
// Purpose:
|
|
|
|
// Representation of the sequence of machine instructions created
|
2001-10-01 00:18:12 +00:00
|
|
|
// for a single VM instruction. Additionally records information
|
|
|
|
// about hidden and implicit values used by the machine instructions:
|
|
|
|
//
|
|
|
|
// (1) "Temporary values" are intermediate values used in the machine
|
|
|
|
// instruction sequence, but not in the VM instruction
|
|
|
|
// Note that such values should be treated as pure SSA values with
|
|
|
|
// no interpretation of their operands (i.e., as a TmpInstruction
|
|
|
|
// object which actually represents such a value).
|
|
|
|
//
|
|
|
|
// (2) "Implicit uses" are values used in the VM instruction but not in
|
|
|
|
// the machine instruction sequence
|
2001-07-21 12:39:03 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
class MachineCodeForVMInstr: public vector<MachineInstr*>
|
|
|
|
{
|
|
|
|
private:
|
2001-10-10 20:50:20 +00:00
|
|
|
vector<Value*> tempVec; // used by m/c instr but not VM instr
|
|
|
|
vector<Value*> implicitUses; // used by VM instr but not m/c instr
|
2001-07-21 12:39:03 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
/*ctor*/ MachineCodeForVMInstr () {}
|
|
|
|
/*ctor*/ ~MachineCodeForVMInstr ();
|
|
|
|
|
2001-10-10 20:50:20 +00:00
|
|
|
const vector<Value*>& getTempValues () const { return tempVec; }
|
|
|
|
vector<Value*>& getTempValues () { return tempVec; }
|
2001-10-01 00:18:12 +00:00
|
|
|
|
2001-10-10 20:50:20 +00:00
|
|
|
const vector<Value*>& getImplicitUses() const { return implicitUses; }
|
|
|
|
vector<Value*>& getImplicitUses() { return implicitUses; }
|
|
|
|
|
|
|
|
void addTempValue (Value* val) { tempVec.push_back(val); }
|
|
|
|
void addImplicitUse(Value* val) { implicitUses.push_back(val);}
|
2001-07-21 12:39:03 +00:00
|
|
|
|
|
|
|
// dropAllReferences() - This function drops all references within
|
|
|
|
// temporary (hidden) instructions created in implementing the original
|
|
|
|
// VM intruction. This ensures there are no remaining "uses" within
|
|
|
|
// these hidden instructions, before the values of a method are freed.
|
|
|
|
//
|
|
|
|
// Make this inline because it has to be called from class Instruction
|
|
|
|
// and inlining it avoids a serious circurality in link order.
|
|
|
|
inline void dropAllReferences() {
|
|
|
|
for (unsigned i=0, N=tempVec.size(); i < N; i++)
|
2001-10-01 16:18:37 +00:00
|
|
|
if (Instruction *I = dyn_cast<Instruction>(tempVec[i]))
|
2001-10-01 00:18:12 +00:00
|
|
|
I->dropAllReferences();
|
2001-07-21 12:39:03 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
inline
|
|
|
|
MachineCodeForVMInstr::~MachineCodeForVMInstr()
|
|
|
|
{
|
|
|
|
// Free the Value objects created to hold intermediate values
|
|
|
|
for (unsigned i=0, N=tempVec.size(); i < N; i++)
|
|
|
|
delete tempVec[i];
|
|
|
|
|
|
|
|
// Free the MachineInstr objects allocated, if any.
|
|
|
|
for (unsigned i=0, N=this->size(); i < N; i++)
|
|
|
|
delete (*this)[i];
|
|
|
|
}
|
|
|
|
|
2001-07-30 18:49:07 +00:00
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// class MachineCodeForBasicBlock
|
|
|
|
//
|
|
|
|
// Purpose:
|
|
|
|
// Representation of the sequence of machine instructions created
|
|
|
|
// for a basic block.
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2001-09-08 14:22:50 +00:00
|
|
|
class MachineCodeForBasicBlock: public vector<MachineInstr*> {
|
2001-07-30 18:49:07 +00:00
|
|
|
public:
|
2001-09-08 17:23:06 +00:00
|
|
|
typedef vector<MachineInstr*>::iterator iterator;
|
2001-09-08 14:32:00 +00:00
|
|
|
typedef vector<const MachineInstr*>::const_iterator const_iterator;
|
2001-07-30 18:49:07 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2001-07-21 12:39:03 +00:00
|
|
|
//---------------------------------------------------------------------------
|
2001-10-10 20:50:20 +00:00
|
|
|
// Debugging Support
|
2001-07-21 12:39:03 +00:00
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
2001-10-10 20:50:20 +00:00
|
|
|
ostream& operator<< (ostream& os, const MachineInstr& minstr);
|
|
|
|
|
|
|
|
|
|
|
|
ostream& operator<< (ostream& os, const MachineOperand& mop);
|
2001-07-21 12:39:03 +00:00
|
|
|
|
|
|
|
|
2001-10-10 20:50:20 +00:00
|
|
|
void PrintMachineInstructions(const Method *method);
|
2001-08-28 23:11:46 +00:00
|
|
|
|
|
|
|
|
2001-07-21 12:39:03 +00:00
|
|
|
//**************************************************************************/
|
|
|
|
|
|
|
|
#endif
|