LLVM API Documentation
00001 //===-- llvm/CodeGen/SSARegMap.h --------------------------------*- C++ -*-===// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file was developed by the LLVM research group and is distributed under 00006 // the University of Illinois Open Source License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // Map register numbers to register classes that are correctly sized (typed) to 00011 // hold the information. Assists register allocation. Contained by 00012 // MachineFunction, should be deleted by register allocator when it is no 00013 // longer needed. 00014 // 00015 //===----------------------------------------------------------------------===// 00016 00017 #ifndef LLVM_CODEGEN_SSAREGMAP_H 00018 #define LLVM_CODEGEN_SSAREGMAP_H 00019 00020 #include "llvm/Target/MRegisterInfo.h" 00021 #include "llvm/ADT/DenseMap.h" 00022 00023 namespace llvm { 00024 00025 class TargetRegisterClass; 00026 00027 class SSARegMap { 00028 DenseMap<const TargetRegisterClass*, VirtReg2IndexFunctor> RegClassMap; 00029 unsigned NextRegNum; 00030 00031 public: 00032 SSARegMap() : NextRegNum(MRegisterInfo::FirstVirtualRegister) { } 00033 00034 const TargetRegisterClass* getRegClass(unsigned Reg) { 00035 return RegClassMap[Reg]; 00036 } 00037 00038 /// createVirtualRegister - Create and return a new virtual register in the 00039 /// function with the specified register class. 00040 /// 00041 unsigned createVirtualRegister(const TargetRegisterClass *RegClass) { 00042 RegClassMap.grow(NextRegNum); 00043 RegClassMap[NextRegNum] = RegClass; 00044 return NextRegNum++; 00045 } 00046 00047 unsigned getLastVirtReg() const { 00048 return NextRegNum - 1; 00049 } 00050 }; 00051 00052 } // End llvm namespace 00053 00054 #endif