aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/CodeGen/SSARegMap.h
blob: b1b00ac049155311c6ebcc562cefce5bdb48d7c9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//===-- llvm/CodeGen/SSARegMap.h --------------------------------*- C++ -*-===//
// 
// Map register numbers to register classes that are correctly sized (typed) to
// hold the information. Assists register allocation. Contained by
// MachineFunction, should be deleted by register allocator when it is no
// longer needed.
//   
//===----------------------------------------------------------------------===//

#ifndef LLVM_CODEGEN_SSAREGMAP_H
#define LLVM_CODEGEN_SSAREGMAP_H

#include "llvm/Target/MRegisterInfo.h"
class TargetRegisterClass;

class SSARegMap {
  std::vector<const TargetRegisterClass*> RegClassMap;

  unsigned rescale(unsigned Reg) { 
    return Reg - MRegisterInfo::FirstVirtualRegister;
  }

 public:
  const TargetRegisterClass* getRegClass(unsigned Reg) {
    unsigned actualReg = rescale(Reg);
    assert(actualReg < RegClassMap.size() && "Register out of bounds");
    return RegClassMap[actualReg];
  }

  /// createVirtualRegister - Create and return a new virtual register in the
  /// function with the specified register class.
  ///
  unsigned createVirtualRegister(const TargetRegisterClass *RegClass) {
    RegClassMap.push_back(RegClass);
    return RegClassMap.size()+MRegisterInfo::FirstVirtualRegister-1;
  }
};

#endif