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"
|
2007-02-01 05:32:05 +00:00
|
|
|
#include "llvm/ADT/IndexedMap.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 {
|
2007-02-01 05:32:05 +00:00
|
|
|
IndexedMap<const TargetRegisterClass*, VirtReg2IndexFunctor> RegClassMap;
|
2007-10-12 08:50:34 +00:00
|
|
|
IndexedMap<std::pair<unsigned, unsigned>, VirtReg2IndexFunctor> RegSubIdxMap;
|
2004-02-25 21:55:45 +00:00
|
|
|
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;
|
2007-10-12 08:50:34 +00:00
|
|
|
RegSubIdxMap.grow(NextRegNum);
|
|
|
|
RegSubIdxMap[NextRegNum] = std::make_pair(0,0);
|
2004-02-25 21:55:45 +00:00
|
|
|
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
|
|
|
}
|
2007-10-12 08:50:34 +00:00
|
|
|
|
|
|
|
void setIsSubRegister(unsigned Reg, unsigned SuperReg, unsigned SubIdx) {
|
|
|
|
RegSubIdxMap[Reg] = std::make_pair(SuperReg, SubIdx);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool isSubRegister(unsigned Reg) const {
|
|
|
|
return RegSubIdxMap[Reg].first != 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned getSuperRegister(unsigned Reg) const {
|
|
|
|
return RegSubIdxMap[Reg].first;
|
|
|
|
}
|
|
|
|
|
|
|
|
unsigned getSubRegisterIndex(unsigned Reg) const {
|
|
|
|
return RegSubIdxMap[Reg].second;
|
|
|
|
}
|
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
|