* Machine dependent work: All parts of the register coloring algorithm
except coloring of an individual node are machine independent.
-
- Register allocation must be done as:
-
- FunctionLiveVarInfo LVI(*FunctionI ); // compute LV info
- LVI.analyze();
-
- TargetMachine &target = ....
-
-
- PhyRegAlloc PRA(*FunctionI, target, &LVI); // allocate regs
- PRA.allocateRegisters();
*/
#ifndef PHY_REG_ALLOC_H
#include "llvm/CodeGen/RegClass.h"
#include "llvm/CodeGen/LiveRangeInfo.h"
-#include <deque>
-class MachineCodeForMethod;
+#include <map>
+
+class MachineFunction;
class MachineRegInfo;
class FunctionLiveVarInfo;
class MachineInstr;
-namespace cfg { class LoopInfo; }
+class LoopInfo;
//----------------------------------------------------------------------------
// Class AddedInstrns:
//----------------------------------------------------------------------------
struct AddedInstrns {
- std::deque<MachineInstr*> InstrnsBefore;// Added insts BEFORE an existing inst
- std::deque<MachineInstr*> InstrnsAfter; // Added insts AFTER an existing inst
+ std::vector<MachineInstr*> InstrnsBefore;//Insts added BEFORE an existing inst
+ std::vector<MachineInstr*> InstrnsAfter; //Insts added AFTER an existing inst
};
-typedef std::map<const MachineInstr *, AddedInstrns> AddedInstrMapType;
-
-
-
//----------------------------------------------------------------------------
// class PhyRegAlloc:
// Main class the register allocator. Call allocateRegisters() to allocate
// registers for a Function.
//----------------------------------------------------------------------------
-
class PhyRegAlloc: public NonCopyable {
-
std::vector<RegClass *> RegClassList; // vector of register classes
const TargetMachine &TM; // target machine
- const Function *Meth; // name of the function we work on
- MachineCodeForMethod &mcInfo; // descriptor for method's native code
- FunctionLiveVarInfo *const LVI; // LV information for this method
+ const Function *Fn; // name of the function we work on
+ MachineFunction &MF; // descriptor for method's native code
+ FunctionLiveVarInfo *const LVI; // LV information for this method
// (already computed for BBs)
LiveRangeInfo LRI; // LR info (will be computed)
const MachineRegInfo &MRI; // Machine Register information
const unsigned NumOfRegClasses; // recorded here for efficiency
- AddedInstrMapType AddedInstrMap; // to store instrns added in this phase
+ // AddedInstrMap - Used to store instrns added in this phase
+ std::map<const MachineInstr *, AddedInstrns> AddedInstrMap;
+
AddedInstrns AddedInstrAtEntry; // to store instrns added at entry
- cfg::LoopInfo *LoopDepthCalc; // to calculate loop depths
+ LoopInfo *LoopDepthCalc; // to calculate loop depths
ReservedColorListType ResColList; // A set of reserved regs if desired.
// currently not used
public:
PhyRegAlloc(Function *F, const TargetMachine& TM, FunctionLiveVarInfo *Lvi,
- cfg::LoopInfo *LoopDepthCalc);
+ LoopInfo *LoopDepthCalc);
~PhyRegAlloc();
// main method called for allocating registers
private:
-
-
-
- //------- ------------------ private methods---------------------------------
-
void addInterference(const Value *Def, const ValueSet *LVSet,
bool isCallInst);
void printLabel(const Value *const Val);
void printMachineCode();
- friend class UltraSparcRegInfo;
+ friend class UltraSparcRegInfo; // FIXME: remove this
- int getUsableUniRegAtMI(RegClass *RC, int RegType,
- const MachineInstr *MInst,
- const ValueSet *LVSetBef, MachineInstr *&MIBef,
- MachineInstr *&MIAft );
-
+ int getUsableUniRegAtMI(int RegType,
+ const ValueSet *LVSetBef,
+ MachineInstr *MInst,
+ std::vector<MachineInstr*>& MIBef,
+ std::vector<MachineInstr*>& MIAft);
+
int getUnusedUniRegAtMI(RegClass *RC, const MachineInstr *MInst,
- const ValueSet *LVSetBef);
+ const ValueSet *LVSetBef);
void setRelRegsUsedByThisInst(RegClass *RC, const MachineInstr *MInst );
int getUniRegNotUsedByThisInst(RegClass *RC, const MachineInstr *MInst);