-//===-- llvm/CodeGen/LiveInterval.h - Live Interval Analysis ----*- C++ -*-===//
+//===-- llvm/CodeGen/PhysRegTracker.h - Physical Register Tracker -*- C++ -*-=//
//
// The LLVM Compiler Infrastructure
//
//===----------------------------------------------------------------------===//
//
// This file implements a physical register tracker. The tracker
-// tracks physical register usage through addPhysRegUse and
-// delPhysRegUse functions while abstracting away register aliases.
+// tracks physical register usage through addRegUse and
+// delRegUse. isRegAvail checks if a physical register is available or
+// not taking into consideration register aliases.
//
//===----------------------------------------------------------------------===//
#ifndef LLVM_CODEGEN_PHYSREGTRACKER_H
#define LLVM_CODEGEN_PHYSREGTRACKER_H
-#include "llvm/CodeGen/MachineFunction.h"
-#include <vector>
+#include "llvm/Target/MRegisterInfo.h"
namespace llvm {
class PhysRegTracker {
- private:
const MRegisterInfo* mri_;
std::vector<unsigned> regUse_;
public:
- PhysRegTracker(MachineFunction* mf)
- : mri_(mf ? mf->getTarget().getRegisterInfo() : NULL) {
- if (mri_) {
- regUse_.assign(mri_->getNumRegs(), 0);
- }
+ PhysRegTracker(const MRegisterInfo& mri)
+ : mri_(&mri),
+ regUse_(mri_->getNumRegs(), 0) {
}
PhysRegTracker(const PhysRegTracker& rhs)
assert(MRegisterInfo::isPhysicalRegister(physReg) &&
"should be physical register!");
++regUse_[physReg];
- for (const unsigned* as = mri_->getAliasSet(physReg); *as; ++as) {
- physReg = *as;
- ++regUse_[physReg];
- }
+ for (const unsigned* as = mri_->getAliasSet(physReg); *as; ++as)
+ ++regUse_[*as];
}
void delRegUse(unsigned physReg) {
assert(regUse_[physReg] != 0);
--regUse_[physReg];
for (const unsigned* as = mri_->getAliasSet(physReg); *as; ++as) {
- physReg = *as;
- assert(regUse_[physReg] != 0);
- --regUse_[physReg];
+ assert(regUse_[*as] != 0);
+ --regUse_[*as];
}
}
- bool isPhysRegAvail(unsigned physReg) const {
+ bool isRegAvail(unsigned physReg) const {
assert(MRegisterInfo::isPhysicalRegister(physReg) &&
"should be physical register!");
return regUse_[physReg] == 0;