llvm-6502/include/llvm/CodeGen/SSARegMap.h
Chris Lattner e836bae30c Simplify interface to creating a register
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@5211 91177308-0d34-0410-b5e6-96231b3b80d8
2003-01-13 00:19:18 +00:00

41 lines
1.2 KiB
C++

//===-- 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"
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];
}
/// createVirtualRegister - Create and return a new virtual register in the
/// function with the specified register class.
///
unsigned createVirtualRegister(const TargetRegisterClass *RegClass) {
RegClassMap.push_back(RegClass);
return RegClassMap.size()+MRegisterInfo::FirstVirtualRegister-1;
}
};
#endif