X-Git-Url: http://demsky.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FCodeGen%2FPhysRegTracker.h;h=1f10c4bdaf9ccc48bff2e527e9e9408db837b49e;hb=ae099d54428f4113f8a71c53314975fb8a8e8bbc;hp=36128c65a8806256f8fa96454721ab3bda52fe7a;hpb=888b1a6ccdd0b12a71a38c6318b9e773006d5564;p=oota-llvm.git diff --git a/lib/CodeGen/PhysRegTracker.h b/lib/CodeGen/PhysRegTracker.h index 36128c65a88..1f10c4bdaf9 100644 --- a/lib/CodeGen/PhysRegTracker.h +++ b/lib/CodeGen/PhysRegTracker.h @@ -1,74 +1,68 @@ -//===-- llvm/CodeGen/LiveInterval.h - Live Interval Analysis ----*- C++ -*-===// +//===-- llvm/CodeGen/PhysRegTracker.h - Physical Register Tracker -*- C++ -*-=// // // 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. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // // 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 +#include "llvm/Target/TargetRegisterInfo.h" namespace llvm { class PhysRegTracker { - private: - const MRegisterInfo* mri_; + const TargetRegisterInfo* tri_; std::vector regUse_; public: - PhysRegTracker(MachineFunction* mf) - : mri_(mf ? mf->getTarget().getRegisterInfo() : NULL) { - if (mri_) { - regUse_.assign(mri_->getNumRegs(), 0); - } + explicit PhysRegTracker(const TargetRegisterInfo& tri) + : tri_(&tri), + regUse_(tri_->getNumRegs(), 0) { } PhysRegTracker(const PhysRegTracker& rhs) - : mri_(rhs.mri_), + : tri_(rhs.tri_), regUse_(rhs.regUse_) { } const PhysRegTracker& operator=(const PhysRegTracker& rhs) { - mri_ = rhs.mri_; + tri_ = rhs.tri_; regUse_ = rhs.regUse_; return *this; } void addRegUse(unsigned physReg) { - assert(MRegisterInfo::isPhysicalRegister(physReg) && + assert(TargetRegisterInfo::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 = tri_->getAliasSet(physReg); *as; ++as) + ++regUse_[*as]; } void delRegUse(unsigned physReg) { - assert(MRegisterInfo::isPhysicalRegister(physReg) && + assert(TargetRegisterInfo::isPhysicalRegister(physReg) && "should be physical register!"); assert(regUse_[physReg] != 0); --regUse_[physReg]; - for (const unsigned* as = mri_->getAliasSet(physReg); *as; ++as) { - physReg = *as; - assert(regUse_[physReg] != 0); - --regUse_[physReg]; + for (const unsigned* as = tri_->getAliasSet(physReg); *as; ++as) { + assert(regUse_[*as] != 0); + --regUse_[*as]; } } - bool isPhysRegAvail(unsigned physReg) const { - assert(MRegisterInfo::isPhysicalRegister(physReg) && + bool isRegAvail(unsigned physReg) const { + assert(TargetRegisterInfo::isPhysicalRegister(physReg) && "should be physical register!"); return regUse_[physReg] == 0; }