2002-11-20 00:53:10 +00:00
|
|
|
//===-- llvm/CodeGen/SSARegMap.h --------------------------------*- C++ -*-===//
|
2004-02-13 18:07:06 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file was developed by the LLVM research group and is distributed under
|
|
|
|
// the University of Illinois Open Source License. See LICENSE.TXT for details.
|
2004-02-13 18:07:06 +00:00
|
|
|
//
|
2003-10-20 20:19:47 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
2004-02-13 18:07:06 +00:00
|
|
|
//
|
2002-11-20 00:53:10 +00:00
|
|
|
// 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.
|
2004-02-13 18:07:06 +00:00
|
|
|
//
|
2002-11-20 00:53:10 +00:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_CODEGEN_SSAREGMAP_H
|
|
|
|
#define LLVM_CODEGEN_SSAREGMAP_H
|
|
|
|
|
|
|
|
#include "llvm/Target/MRegisterInfo.h"
|
2004-09-01 22:55:40 +00:00
|
|
|
#include "llvm/ADT/DenseMap.h"
|
2003-06-30 21:59:07 +00:00
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
namespace llvm {
|
|
|
|
|
2002-11-20 00:53:10 +00:00
|
|
|
class TargetRegisterClass;
|
|
|
|
|
|
|
|
class SSARegMap {
|
2004-02-25 21:55:45 +00:00
|
|
|
DenseMap<const TargetRegisterClass*, VirtReg2IndexFunctor> RegClassMap;
|
|
|
|
unsigned NextRegNum;
|
2002-11-20 00:53:10 +00:00
|
|
|
|
|
|
|
public:
|
2004-02-25 21:55:45 +00:00
|
|
|
SSARegMap() : NextRegNum(MRegisterInfo::FirstVirtualRegister) { }
|
|
|
|
|
2002-11-20 00:53:10 +00:00
|
|
|
const TargetRegisterClass* getRegClass(unsigned Reg) {
|
2004-02-25 21:55:45 +00:00
|
|
|
return RegClassMap[Reg];
|
2002-11-20 00:53:10 +00:00
|
|
|
}
|
|
|
|
|
2003-01-13 00:19:18 +00:00
|
|
|
/// createVirtualRegister - Create and return a new virtual register in the
|
|
|
|
/// function with the specified register class.
|
|
|
|
///
|
|
|
|
unsigned createVirtualRegister(const TargetRegisterClass *RegClass) {
|
2005-01-05 16:27:34 +00:00
|
|
|
assert(RegClass && "Cannot create register without RegClass!");
|
2004-02-25 21:55:45 +00:00
|
|
|
RegClassMap.grow(NextRegNum);
|
|
|
|
RegClassMap[NextRegNum] = RegClass;
|
|
|
|
return NextRegNum++;
|
2002-11-20 00:53:10 +00:00
|
|
|
}
|
2004-02-13 18:07:06 +00:00
|
|
|
|
2004-02-25 21:55:45 +00:00
|
|
|
unsigned getLastVirtReg() const {
|
|
|
|
return NextRegNum - 1;
|
2004-02-13 18:07:06 +00:00
|
|
|
}
|
2002-11-20 00:53:10 +00:00
|
|
|
};
|
|
|
|
|
2003-11-11 22:41:34 +00:00
|
|
|
} // End llvm namespace
|
|
|
|
|
2002-11-20 00:53:10 +00:00
|
|
|
#endif
|