1 //===-- llvm/CodeGen/SSARegMap.h --------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file was developed by the LLVM research group and is distributed under
6 // the University of Illinois Open Source License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // Map register numbers to register classes that are correctly sized (typed) to
11 // hold the information. Assists register allocation. Contained by
12 // MachineFunction, should be deleted by register allocator when it is no
15 //===----------------------------------------------------------------------===//
17 #ifndef LLVM_CODEGEN_SSAREGMAP_H
18 #define LLVM_CODEGEN_SSAREGMAP_H
20 #include "llvm/Target/MRegisterInfo.h"
22 class TargetRegisterClass;
25 std::vector<const TargetRegisterClass*> RegClassMap;
27 unsigned rescale(unsigned Reg) {
28 return Reg - MRegisterInfo::FirstVirtualRegister;
32 const TargetRegisterClass* getRegClass(unsigned Reg) {
33 unsigned actualReg = rescale(Reg);
34 assert(actualReg < RegClassMap.size() && "Register out of bounds");
35 return RegClassMap[actualReg];
38 /// createVirtualRegister - Create and return a new virtual register in the
39 /// function with the specified register class.
41 unsigned createVirtualRegister(const TargetRegisterClass *RegClass) {
42 RegClassMap.push_back(RegClass);
43 return RegClassMap.size()+MRegisterInfo::FirstVirtualRegister-1;