[llvm] r260468 - [GlobalISel] Remember the size of generic virtual registers

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 10 15:43:48 PST 2016


Author: qcolombet
Date: Wed Feb 10 17:43:48 2016
New Revision: 260468

URL: http://llvm.org/viewvc/llvm-project?rev=260468&view=rev
Log:
[GlobalISel] Remember the size of generic virtual registers

Modified:
    llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h
    llvm/trunk/lib/CodeGen/MachineInstr.cpp
    llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp

Modified: llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h?rev=260468&r1=260467&r2=260468&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/MachineRegisterInfo.h Wed Feb 10 17:43:48 2016
@@ -105,6 +105,11 @@ private:
   /// started.
   BitVector ReservedRegs;
 
+#ifdef LLVM_BUILD_GLOBAL_ISEL
+  /// Map generic virtual registers to their actual size.
+  DenseMap<unsigned, unsigned> VRegToSize;
+#endif
+
   /// Keep track of the physical registers that are live in to the function.
   /// Live in values are typically arguments in registers.  LiveIn values are
   /// allowed to have virtual registers associated with them, stored in the
@@ -587,6 +592,12 @@ public:
   ///
   unsigned createVirtualRegister(const TargetRegisterClass *RegClass);
 
+#ifdef LLVM_BUILD_GLOBAL_ISEL
+  /// Get the size of \p VReg or 0 if VReg is not a generic
+  /// (target independent) virtual register.
+  unsigned getSize(unsigned VReg) const;
+#endif
+
   /// getNumVirtRegs - Return the number of virtual registers created.
   ///
   unsigned getNumVirtRegs() const { return VRegInfo.size(); }

Modified: llvm/trunk/lib/CodeGen/MachineInstr.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineInstr.cpp?rev=260468&r1=260467&r2=260468&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineInstr.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineInstr.cpp Wed Feb 10 17:43:48 2016
@@ -1657,8 +1657,15 @@ void MachineInstr::print(raw_ostream &OS
     if (StartOp != 0) OS << ", ";
     getOperand(StartOp).print(OS, MST, TRI);
     unsigned Reg = getOperand(StartOp).getReg();
-    if (TargetRegisterInfo::isVirtualRegister(Reg))
+    if (TargetRegisterInfo::isVirtualRegister(Reg)) {
       VirtRegs.push_back(Reg);
+#ifdef LLVM_BUILD_GLOBAL_ISEL
+      unsigned Size;
+      if (MRI && (Size = MRI->getSize(Reg))) {
+        OS << '(' << Size << ')';
+      }
+#endif
+    }
   }
 
   if (StartOp != 0)

Modified: llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp?rev=260468&r1=260467&r2=260468&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp (original)
+++ llvm/trunk/lib/CodeGen/MachineRegisterInfo.cpp Wed Feb 10 17:43:48 2016
@@ -103,6 +103,15 @@ MachineRegisterInfo::createVirtualRegist
   return Reg;
 }
 
+#ifdef LLVM_BUILD_GLOBAL_ISEL
+unsigned
+MachineRegisterInfo::getSize(unsigned VReg) const {
+  DenseMap<unsigned, unsigned>::const_iterator SizeIt =
+    VRegToSize.find(VReg);
+  return SizeIt != VRegToSize.end()? SizeIt->second: 0;
+}
+#endif // LLVM_BUILD_GLOBAL_ISEL
+
 /// clearVirtRegs - Remove all virtual registers (after physreg assignment).
 void MachineRegisterInfo::clearVirtRegs() {
 #ifndef NDEBUG




More information about the llvm-commits mailing list