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"
15 class TargetRegisterClass;
18 std::vector<const TargetRegisterClass*> RegClassMap;
20 unsigned rescale(unsigned Reg) {
21 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 void addRegMap(unsigned Reg, const TargetRegisterClass* RegClass) {
34 assert(rescale(Reg) == RegClassMap.size() &&
35 "Register mapping not added in sequential order!");
36 RegClassMap.push_back(RegClass);