1 //===-- llvm/CodeGen/SSARegMap.h --------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file defines the SSARegMap class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CODEGEN_SSAREGMAP_H
15 #define LLVM_CODEGEN_SSAREGMAP_H
17 #include "llvm/Target/MRegisterInfo.h"
22 /// SSARegMap - Keep track of information for each virtual register, including
23 /// its register class.
25 /// VRegInfo - Information we keep for each virtual register. The entries in
26 /// this vector are actually converted to vreg numbers by adding the
27 /// MRegisterInfo::FirstVirtualRegister delta to their index.
28 std::vector<const TargetRegisterClass*> VRegInfo;
32 VRegInfo.reserve(256);
35 /// getRegClass - Return the register class of the specified virtual register.
36 const TargetRegisterClass *getRegClass(unsigned Reg) {
37 Reg -= MRegisterInfo::FirstVirtualRegister;
38 assert(Reg < VRegInfo.size() && "Invalid vreg!");
42 /// createVirtualRegister - Create and return a new virtual register in the
43 /// function with the specified register class.
45 unsigned createVirtualRegister(const TargetRegisterClass *RegClass) {
46 assert(RegClass && "Cannot create register without RegClass!");
47 VRegInfo.push_back(RegClass);
48 return getLastVirtReg();
51 /// getLastVirtReg - Return the highest currently assigned virtual register.
53 unsigned getLastVirtReg() const {
54 return VRegInfo.size()+MRegisterInfo::FirstVirtualRegister-1;
58 } // End llvm namespace