LLVM API Documentation
00001 //===-- llvm/CodeGen/PhysRegTracker.h - Physical Register Tracker -*- C++ -*-=// 00002 // 00003 // The LLVM Compiler Infrastructure 00004 // 00005 // This file is distributed under the University of Illinois Open Source 00006 // License. See LICENSE.TXT for details. 00007 // 00008 //===----------------------------------------------------------------------===// 00009 // 00010 // This file implements a physical register tracker. The tracker 00011 // tracks physical register usage through addRegUse and 00012 // delRegUse. isRegAvail checks if a physical register is available or 00013 // not taking into consideration register aliases. 00014 // 00015 //===----------------------------------------------------------------------===// 00016 00017 #ifndef LLVM_CODEGEN_PHYSREGTRACKER_H 00018 #define LLVM_CODEGEN_PHYSREGTRACKER_H 00019 00020 #include "llvm/Target/TargetRegisterInfo.h" 00021 00022 namespace llvm { 00023 00024 class PhysRegTracker { 00025 const TargetRegisterInfo* tri_; 00026 std::vector<unsigned> regUse_; 00027 00028 public: 00029 explicit PhysRegTracker(const TargetRegisterInfo& tri) 00030 : tri_(&tri), 00031 regUse_(tri_->getNumRegs(), 0) { 00032 } 00033 00034 PhysRegTracker(const PhysRegTracker& rhs) 00035 : tri_(rhs.tri_), 00036 regUse_(rhs.regUse_) { 00037 } 00038 00039 const PhysRegTracker& operator=(const PhysRegTracker& rhs) { 00040 tri_ = rhs.tri_; 00041 regUse_ = rhs.regUse_; 00042 return *this; 00043 } 00044 00045 void addRegUse(unsigned physReg) { 00046 assert(TargetRegisterInfo::isPhysicalRegister(physReg) && 00047 "should be physical register!"); 00048 ++regUse_[physReg]; 00049 for (const unsigned* as = tri_->getAliasSet(physReg); *as; ++as) 00050 ++regUse_[*as]; 00051 } 00052 00053 void delRegUse(unsigned physReg) { 00054 assert(TargetRegisterInfo::isPhysicalRegister(physReg) && 00055 "should be physical register!"); 00056 assert(regUse_[physReg] != 0); 00057 --regUse_[physReg]; 00058 for (const unsigned* as = tri_->getAliasSet(physReg); *as; ++as) { 00059 assert(regUse_[*as] != 0); 00060 --regUse_[*as]; 00061 } 00062 } 00063 00064 bool isRegAvail(unsigned physReg) const { 00065 assert(TargetRegisterInfo::isPhysicalRegister(physReg) && 00066 "should be physical register!"); 00067 return regUse_[physReg] == 0; 00068 } 00069 }; 00070 00071 } // End llvm namespace 00072 00073 #endif
This web site is hosted by the Computer Science Department at the University of Illinois at Urbana-Champaign.