2002-11-20 00:53:10 +00:00
|
|
|
//===-- llvm/CodeGen/SSARegMap.h --------------------------------*- C++ -*-===//
|
|
|
|
//
|
|
|
|
// Map register numbers to register classes that are correctly sized (typed) to
|
|
|
|
// hold the information. Assists register allocation. Contained by
|
|
|
|
// MachineFunction, should be deleted by register allocator when it is no
|
|
|
|
// longer needed.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CODEGEN_SSAREGMAP_H
|
|
|
|
#define LLVM_CODEGEN_SSAREGMAP_H
|
|
|
|
|
|
|
|
#include "llvm/Target/MRegisterInfo.h"
|
2003-06-30 21:59:07 +00:00
|
|
|
|
2002-11-20 00:53:10 +00:00
|
|
|
class TargetRegisterClass;
|
|
|
|
|
|
|
|
class SSARegMap {
|
|
|
|
std::vector<const TargetRegisterClass*> RegClassMap;
|
|
|
|
|
|
|
|
unsigned rescale(unsigned Reg) {
|
|
|
|
return Reg - MRegisterInfo::FirstVirtualRegister;
|
|
|
|
}
|
|
|
|
|
|
|
|
public:
|
|
|
|
const TargetRegisterClass* getRegClass(unsigned Reg) {
|
|
|
|
unsigned actualReg = rescale(Reg);
|
|
|
|
assert(actualReg < RegClassMap.size() && "Register out of bounds");
|
|
|
|
return RegClassMap[actualReg];
|
|
|
|
}
|
|
|
|
|
2003-01-13 00:19:18 +00:00
|
|
|
/// createVirtualRegister - Create and return a new virtual register in the
|
|
|
|
/// function with the specified register class.
|
|
|
|
///
|
|
|
|
unsigned createVirtualRegister(const TargetRegisterClass *RegClass) {
|
2002-11-20 00:53:10 +00:00
|
|
|
RegClassMap.push_back(RegClass);
|
2003-01-13 00:19:18 +00:00
|
|
|
return RegClassMap.size()+MRegisterInfo::FirstVirtualRegister-1;
|
2002-11-20 00:53:10 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|