1 //===-- llvm/CodeGen/SSARegMap.h --------------------------------*- C++ -*-===//
3 // Map register numbers to register classes that are correctly sized (typed) to
4 // hold the information. Assists register allocation. Contained by
5 // MachineFunction, should be deleted by register allocator when it is no
8 //===----------------------------------------------------------------------===//
10 #ifndef LLVM_CODEGEN_SSAREGMAP_H
11 #define LLVM_CODEGEN_SSAREGMAP_H
13 #include "llvm/Target/MRegisterInfo.h"
17 class TargetRegisterClass;
20 std::vector<const TargetRegisterClass*> RegClassMap;
22 unsigned rescale(unsigned Reg) {
23 return Reg - MRegisterInfo::FirstVirtualRegister;
27 const TargetRegisterClass* getRegClass(unsigned Reg) {
28 unsigned actualReg = rescale(Reg);
29 assert(actualReg < RegClassMap.size() && "Register out of bounds");
30 return RegClassMap[actualReg];
33 /// createVirtualRegister - Create and return a new virtual register in the
34 /// function with the specified register class.
36 unsigned createVirtualRegister(const TargetRegisterClass *RegClass) {
37 RegClassMap.push_back(RegClass);
38 return RegClassMap.size()+MRegisterInfo::FirstVirtualRegister-1;