Put all LLVM code into the llvm namespace, as per bug 109.
[oota-llvm.git] / include / llvm / CodeGen / SSARegMap.h
1 //===-- llvm/CodeGen/SSARegMap.h --------------------------------*- C++ -*-===//
2 // 
3 //                     The LLVM Compiler Infrastructure
4 //
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.
7 // 
8 //===----------------------------------------------------------------------===//
9 // 
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
13 // longer needed.
14 //   
15 //===----------------------------------------------------------------------===//
16
17 #ifndef LLVM_CODEGEN_SSAREGMAP_H
18 #define LLVM_CODEGEN_SSAREGMAP_H
19
20 #include "llvm/Target/MRegisterInfo.h"
21
22 namespace llvm {
23
24 class TargetRegisterClass;
25
26 class SSARegMap {
27   std::vector<const TargetRegisterClass*> RegClassMap;
28
29   unsigned rescale(unsigned Reg) { 
30     return Reg - MRegisterInfo::FirstVirtualRegister;
31   }
32
33  public:
34   const TargetRegisterClass* getRegClass(unsigned Reg) {
35     unsigned actualReg = rescale(Reg);
36     assert(actualReg < RegClassMap.size() && "Register out of bounds");
37     return RegClassMap[actualReg];
38   }
39
40   /// createVirtualRegister - Create and return a new virtual register in the
41   /// function with the specified register class.
42   ///
43   unsigned createVirtualRegister(const TargetRegisterClass *RegClass) {
44     RegClassMap.push_back(RegClass);
45     return RegClassMap.size()+MRegisterInfo::FirstVirtualRegister-1;
46   }
47 };
48
49 } // End llvm namespace
50
51 #endif