Don't attribute in file headers anymore. See llvmdev for the
[oota-llvm.git] / include / llvm / CodeGen / SSARegMap.h
1 //===-- llvm/CodeGen/SSARegMap.h --------------------------------*- C++ -*-===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // 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 #include "llvm/ADT/IndexedMap.h"
22
23 namespace llvm {
24
25 class TargetRegisterClass;
26
27 class SSARegMap {
28   IndexedMap<const TargetRegisterClass*, VirtReg2IndexFunctor> RegClassMap;
29   unsigned NextRegNum;
30
31  public:
32   SSARegMap() : NextRegNum(MRegisterInfo::FirstVirtualRegister) { }
33
34   const TargetRegisterClass* getRegClass(unsigned Reg) {
35     return RegClassMap[Reg];
36   }
37
38   /// createVirtualRegister - Create and return a new virtual register in the
39   /// function with the specified register class.
40   ///
41   unsigned createVirtualRegister(const TargetRegisterClass *RegClass) {
42     assert(RegClass && "Cannot create register without RegClass!");
43     RegClassMap.grow(NextRegNum);
44     RegClassMap[NextRegNum] = RegClass;
45     return NextRegNum++;
46   }
47
48   unsigned getLastVirtReg() const {
49     return NextRegNum - 1;
50   }
51 };
52
53 } // End llvm namespace
54
55 #endif