[llvm] r245977 - MachineBasicBlock: Use MCPhysReg instead of unsigned in livein API

Matthias Braun via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 25 15:05:55 PDT 2015


Author: matze
Date: Tue Aug 25 17:05:55 2015
New Revision: 245977

URL: http://llvm.org/viewvc/llvm-project?rev=245977&view=rev
Log:
MachineBasicBlock: Use MCPhysReg instead of unsigned in livein API

This is friendlier to the readers as it makes it clear that the API is
not meant for vregs but just for physregs.

Modified:
    llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h
    llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp

Modified: llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h?rev=245977&r1=245976&r2=245977&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h Tue Aug 25 17:05:55 2015
@@ -16,6 +16,7 @@
 
 #include "llvm/ADT/GraphTraits.h"
 #include "llvm/CodeGen/MachineInstr.h"
+#include "llvm/MC/MCRegisterInfo.h"
 #include "llvm/Support/DataTypes.h"
 #include <functional>
 
@@ -79,7 +80,8 @@ class MachineBasicBlock : public ilist_n
   typedef std::vector<uint32_t>::const_iterator const_weight_iterator;
 
   /// Keep track of the physical registers that are livein of the basicblock.
-  std::vector<unsigned> LiveIns;
+  typedef std::vector<MCPhysReg> LiveInVector;
+  LiveInVector LiveIns;
 
   /// Alignment of the basic block. Zero if the basic block does not need to be
   /// aligned. The alignment is specified as log2(bytes).
@@ -309,7 +311,7 @@ public:
   /// Adds the specified register as a live in. Note that it is an error to add
   /// the same register to the same set more than once unless the intention is
   /// to call sortUniqueLiveIns after all registers are added.
-  void addLiveIn(unsigned Reg) { LiveIns.push_back(Reg); }
+  void addLiveIn(MCPhysReg PhysReg) { LiveIns.push_back(PhysReg); }
 
   /// Sorts and uniques the LiveIns vector. It can be significantly faster to do
   /// this than repeatedly calling isLiveIn before calling addLiveIn for every
@@ -322,17 +324,17 @@ public:
   /// Add PhysReg as live in to this block, and ensure that there is a copy of
   /// PhysReg to a virtual register of class RC. Return the virtual register
   /// that is a copy of the live in PhysReg.
-  unsigned addLiveIn(unsigned PhysReg, const TargetRegisterClass *RC);
+  unsigned addLiveIn(MCPhysReg PhysReg, const TargetRegisterClass *RC);
 
   /// Remove the specified register from the live in set.
-  void removeLiveIn(unsigned Reg);
+  void removeLiveIn(MCPhysReg Reg);
 
   /// Return true if the specified register is in the live in set.
-  bool isLiveIn(unsigned Reg) const;
+  bool isLiveIn(MCPhysReg Reg) const;
 
   // Iteration support for live in sets.  These sets are kept in sorted
   // order by their register number.
-  typedef std::vector<unsigned>::const_iterator livein_iterator;
+  typedef LiveInVector::const_iterator livein_iterator;
   livein_iterator livein_begin() const { return LiveIns.begin(); }
   livein_iterator livein_end()   const { return LiveIns.end(); }
   bool            livein_empty() const { return LiveIns.empty(); }

Modified: llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp?rev=245977&r1=245976&r2=245977&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineBasicBlock.cpp Tue Aug 25 17:05:55 2015
@@ -322,20 +322,19 @@ void MachineBasicBlock::printAsOperand(r
   OS << "BB#" << getNumber();
 }
 
-void MachineBasicBlock::removeLiveIn(unsigned Reg) {
-  std::vector<unsigned>::iterator I
-    = std::find(LiveIns.begin(), LiveIns.end(), Reg);
+void MachineBasicBlock::removeLiveIn(MCPhysReg Reg) {
+  LiveInVector::iterator I = std::find(LiveIns.begin(), LiveIns.end(), Reg);
   if (I != LiveIns.end())
     LiveIns.erase(I);
 }
 
-bool MachineBasicBlock::isLiveIn(unsigned Reg) const {
+bool MachineBasicBlock::isLiveIn(MCPhysReg Reg) const {
   livein_iterator I = std::find(livein_begin(), livein_end(), Reg);
   return I != livein_end();
 }
 
 unsigned
-MachineBasicBlock::addLiveIn(unsigned PhysReg, const TargetRegisterClass *RC) {
+MachineBasicBlock::addLiveIn(MCPhysReg PhysReg, const TargetRegisterClass *RC) {
   assert(getParent() && "MBB must be inserted in function");
   assert(TargetRegisterInfo::isPhysicalRegister(PhysReg) && "Expected physreg");
   assert(RC && "Register class is required");




More information about the llvm-commits mailing list