2001-09-18 12:38:31 +00:00
|
|
|
//===-- llvm/Target/RegInfo.h - Target Register Information ------*- C++ -*-==//
|
|
|
|
//
|
|
|
|
// This file is used to describe the register system of a target to the
|
|
|
|
// register allocator.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_TARGET_MACHINEREGINFO_H
|
|
|
|
#define LLVM_TARGET_MACHINEREGINFO_H
|
|
|
|
|
2001-11-27 00:03:19 +00:00
|
|
|
#include "Support/NonCopyable.h"
|
2001-09-18 12:38:31 +00:00
|
|
|
#include <hash_map>
|
|
|
|
#include <string>
|
|
|
|
|
2001-11-08 05:22:43 +00:00
|
|
|
class TargetMachine;
|
2001-09-18 12:38:31 +00:00
|
|
|
class IGNode;
|
|
|
|
class Value;
|
|
|
|
class LiveRangeInfo;
|
|
|
|
class Method;
|
|
|
|
class Instruction;
|
|
|
|
class LiveRange;
|
|
|
|
class AddedInstrns;
|
|
|
|
class MachineInstr;
|
2001-09-30 23:19:09 +00:00
|
|
|
class RegClass;
|
|
|
|
class CallInst;
|
|
|
|
class ReturnInst;
|
2001-10-28 18:14:15 +00:00
|
|
|
class PhyRegAlloc;
|
|
|
|
class BasicBlock;
|
2001-09-18 12:38:31 +00:00
|
|
|
|
|
|
|
//-----------------------------------------------------------------------------
|
|
|
|
// class MachineRegClassInfo
|
|
|
|
//
|
|
|
|
// Purpose:
|
|
|
|
// Interface to description of machine register class (e.g., int reg class
|
|
|
|
// float reg class etc)
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
class MachineRegClassInfo {
|
|
|
|
protected:
|
|
|
|
|
|
|
|
const unsigned RegClassID; // integer ID of a reg class
|
|
|
|
const unsigned NumOfAvailRegs; // # of avail for coloring -without SP etc.
|
|
|
|
const unsigned NumOfAllRegs; // # of all registers -including SP,g0 etc.
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
inline unsigned getRegClassID() const { return RegClassID; }
|
|
|
|
inline unsigned getNumOfAvailRegs() const { return NumOfAvailRegs; }
|
|
|
|
inline unsigned getNumOfAllRegs() const { return NumOfAllRegs; }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// This method should find a color which is not used by neighbors
|
|
|
|
// (i.e., a false position in IsColorUsedArr) and
|
|
|
|
virtual void colorIGNode(IGNode * Node, bool IsColorUsedArr[] ) const = 0;
|
2001-10-16 01:23:19 +00:00
|
|
|
virtual bool isRegVolatile(const int Reg) const = 0;
|
2001-09-18 12:38:31 +00:00
|
|
|
|
|
|
|
MachineRegClassInfo(const unsigned ID, const unsigned NVR,
|
|
|
|
const unsigned NAR): RegClassID(ID), NumOfAvailRegs(NVR),
|
2001-11-08 05:22:43 +00:00
|
|
|
NumOfAllRegs(NAR)
|
2001-09-18 12:38:31 +00:00
|
|
|
{ } // empty constructor
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
// class MachineRegInfo
|
|
|
|
//
|
|
|
|
// Purpose:
|
|
|
|
// Interface to register info of target machine
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef hash_map<const MachineInstr *, AddedInstrns *> AddedInstrMapType;
|
|
|
|
|
|
|
|
// A vector of all machine register classes
|
|
|
|
typedef vector<const MachineRegClassInfo *> MachineRegClassArrayType;
|
|
|
|
|
|
|
|
|
|
|
|
class MachineRegInfo : public NonCopyableV {
|
2001-11-08 05:22:43 +00:00
|
|
|
public:
|
|
|
|
const TargetMachine& target;
|
2001-09-18 12:38:31 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
|
2001-09-18 22:57:47 +00:00
|
|
|
MachineRegClassArrayType MachineRegClassArr;
|
|
|
|
|
2001-09-18 12:38:31 +00:00
|
|
|
public:
|
|
|
|
|
2001-09-18 22:57:47 +00:00
|
|
|
|
2001-09-18 12:38:31 +00:00
|
|
|
// According the definition of a MachineOperand class, a Value in a
|
|
|
|
// machine instruction can go into either a normal register or a
|
|
|
|
// condition code register. If isCCReg is true below, the ID of the condition
|
|
|
|
// code regiter class will be returned. Otherwise, the normal register
|
|
|
|
// class (eg. int, float) must be returned.
|
|
|
|
virtual unsigned getRegClassIDOfValue (const Value *const Val,
|
|
|
|
bool isCCReg = false) const =0;
|
|
|
|
|
|
|
|
|
|
|
|
inline unsigned int getNumOfRegClasses() const {
|
|
|
|
return MachineRegClassArr.size();
|
|
|
|
}
|
|
|
|
|
|
|
|
const MachineRegClassInfo *const getMachineRegClass(unsigned i) const {
|
|
|
|
return MachineRegClassArr[i];
|
|
|
|
}
|
|
|
|
|
2001-09-18 22:57:47 +00:00
|
|
|
// returns the register that is hardwired to zero if any (-1 if none)
|
|
|
|
virtual inline int getZeroRegNum() const = 0;
|
2001-09-18 12:38:31 +00:00
|
|
|
|
|
|
|
//virtual unsigned getRegClassIDOfValue (const Value *const Val) const = 0;
|
|
|
|
// this method must give the exact register class of a machine operand
|
|
|
|
// e.g, Int, Float, Int CC, Float CC
|
|
|
|
//virtual unsigned getRCIDOfMachineOp (const MachineOperand &MO) const = 0;
|
|
|
|
|
|
|
|
|
2001-09-30 23:19:09 +00:00
|
|
|
virtual void suggestRegs4MethodArgs(const Method *const Meth,
|
2001-09-18 12:38:31 +00:00
|
|
|
LiveRangeInfo & LRI) const = 0;
|
|
|
|
|
2001-10-15 16:23:48 +00:00
|
|
|
virtual void suggestRegs4CallArgs(const MachineInstr *const CallI,
|
2001-09-30 23:19:09 +00:00
|
|
|
LiveRangeInfo& LRI, vector<RegClass *> RCL) const = 0;
|
2001-09-18 12:38:31 +00:00
|
|
|
|
2001-10-15 16:23:48 +00:00
|
|
|
virtual void suggestReg4RetValue(const MachineInstr *const RetI,
|
2001-09-30 23:19:09 +00:00
|
|
|
LiveRangeInfo& LRI) const = 0;
|
2001-09-18 22:57:47 +00:00
|
|
|
|
2001-09-30 23:19:09 +00:00
|
|
|
virtual void colorMethodArgs(const Method *const Meth, LiveRangeInfo& LRI,
|
|
|
|
AddedInstrns *const FirstAI) const = 0;
|
|
|
|
|
2001-10-15 16:23:48 +00:00
|
|
|
virtual void colorCallArgs(const MachineInstr *const CalI,
|
2001-10-28 18:14:15 +00:00
|
|
|
LiveRangeInfo& LRI, AddedInstrns *const CallAI,
|
2002-01-07 19:17:41 +00:00
|
|
|
PhyRegAlloc &PRA, const BasicBlock *BB) const = 0;
|
2001-09-30 23:19:09 +00:00
|
|
|
|
2001-10-15 16:23:48 +00:00
|
|
|
virtual void colorRetValue(const MachineInstr *const RetI,LiveRangeInfo& LRI,
|
|
|
|
AddedInstrns *const RetAI) const = 0;
|
2001-09-30 23:19:09 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-10-16 01:23:19 +00:00
|
|
|
virtual MachineInstr *
|
|
|
|
cpReg2RegMI(const unsigned SrcReg, const unsigned DestReg,
|
|
|
|
const int RegType) const=0;
|
|
|
|
|
2001-11-03 17:14:13 +00:00
|
|
|
virtual MachineInstr *
|
|
|
|
cpReg2MemMI(const unsigned SrcReg, const unsigned DestPtrReg,
|
2001-10-16 01:23:19 +00:00
|
|
|
const int Offset, const int RegType) const=0;
|
|
|
|
|
2001-11-03 17:14:13 +00:00
|
|
|
virtual MachineInstr *
|
2001-10-16 01:23:19 +00:00
|
|
|
cpMem2RegMI(const unsigned SrcPtrReg, const int Offset,
|
|
|
|
const unsigned DestReg, const int RegType) const=0;
|
|
|
|
|
2001-11-03 17:14:13 +00:00
|
|
|
virtual MachineInstr *cpValue2Value( Value *Src, Value *Dest) const=0;
|
|
|
|
|
|
|
|
|
2001-10-16 01:23:19 +00:00
|
|
|
virtual bool isRegVolatile(const int RegClassID, const int Reg) const=0;
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-10-15 16:23:48 +00:00
|
|
|
//virtual bool handleSpecialMInstr(const MachineInstr * MInst,
|
|
|
|
// LiveRangeInfo& LRI, vector<RegClass *> RCL) const = 0;
|
2001-09-30 23:19:09 +00:00
|
|
|
|
2001-09-18 22:57:47 +00:00
|
|
|
// returns the reg used for pushing the address when a method is called.
|
|
|
|
// This can be used for other purposes between calls
|
|
|
|
virtual unsigned getCallAddressReg() const = 0;
|
|
|
|
|
|
|
|
// and when we return from a method. It should be made sure that this
|
|
|
|
// register contains the return value when a return instruction is reached.
|
|
|
|
virtual unsigned getReturnAddressReg() const = 0;
|
|
|
|
|
2001-09-18 12:38:31 +00:00
|
|
|
virtual int getUnifiedRegNum(int RegClassID, int reg) const = 0;
|
|
|
|
|
|
|
|
virtual const string getUnifiedRegName(int UnifiedRegNum) const = 0;
|
|
|
|
|
2001-10-16 01:23:19 +00:00
|
|
|
virtual int getRegType(const LiveRange *const LR) const=0;
|
|
|
|
|
2001-10-21 16:43:41 +00:00
|
|
|
virtual const Value * getCallInstRetVal(const MachineInstr *CallMI) const=0;
|
2001-10-16 01:23:19 +00:00
|
|
|
|
|
|
|
inline virtual unsigned getFramePointer() const=0;
|
|
|
|
|
|
|
|
inline virtual unsigned getStackPointer() const=0;
|
|
|
|
|
|
|
|
inline virtual int getInvalidRegNum() const=0;
|
|
|
|
|
|
|
|
|
2001-10-28 18:14:15 +00:00
|
|
|
virtual void insertCallerSavingCode(const MachineInstr *MInst,
|
|
|
|
const BasicBlock *BB,
|
|
|
|
PhyRegAlloc &PRA ) const = 0;
|
|
|
|
|
2002-01-07 19:17:41 +00:00
|
|
|
virtual inline int getSpilledRegSize(const int RegType) const = 0;
|
2001-09-18 22:57:47 +00:00
|
|
|
|
2001-11-08 05:22:43 +00:00
|
|
|
MachineRegInfo(const TargetMachine& tgt) : target(tgt) { }
|
2001-09-18 22:57:47 +00:00
|
|
|
|
2001-09-18 12:38:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2001-09-18 22:57:47 +00:00
|
|
|
#endif
|
2001-09-18 12:38:31 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
2001-09-18 22:57:47 +00:00
|
|
|
|