[PATCH] D97891: Revert "[MC] Remove PhysRegSize from MCRegisterClass"

Rafael Auler via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 3 15:11:53 PST 2021


rafauler created this revision.
rafauler added reviewers: craig.topper, kparzysz, bjope, bogner, qcolombet.
Herald added a subscriber: hiraditya.
rafauler requested review of this revision.
Herald added a project: LLVM.

This reverts commit c8b782cec2da3b323036eba15850234b7e5427dd.

This commit offers no viable option to get register size information
outside of libTarget. We need this information to run analysis that
know the register size, hence the revert. This is necessary for
upstreaming BOLT.

Discussion D50285 <https://reviews.llvm.org/D50285> and D47199 <https://reviews.llvm.org/D47199>.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D97891

Files:
  llvm/include/llvm/MC/MCRegisterInfo.h
  llvm/lib/CodeGen/TargetInstrInfo.cpp
  llvm/utils/TableGen/RegisterInfoEmitter.cpp


Index: llvm/utils/TableGen/RegisterInfoEmitter.cpp
===================================================================
--- llvm/utils/TableGen/RegisterInfoEmitter.cpp
+++ llvm/utils/TableGen/RegisterInfoEmitter.cpp
@@ -1084,10 +1084,14 @@
 
   for (const auto &RC : RegisterClasses) {
     assert(isInt<8>(RC.CopyCost) && "Copy cost too large.");
+    uint32_t RegSize = 0;
+    if (RC.RSI.isSimple())
+      RegSize = RC.RSI.getSimple().RegSize;
     OS << "  { " << RC.getName() << ", " << RC.getName() << "Bits, "
        << RegClassStrings.get(RC.getName()) << ", "
        << RC.getOrder().size() << ", sizeof(" << RC.getName() << "Bits), "
        << RC.getQualifiedName() + "RegClassID" << ", "
+       << RegSize/8 << ", "
        << RC.CopyCost << ", "
        << ( RC.Allocatable ? "true" : "false" ) << " },\n";
   }
Index: llvm/lib/CodeGen/TargetInstrInfo.cpp
===================================================================
--- llvm/lib/CodeGen/TargetInstrInfo.cpp
+++ llvm/lib/CodeGen/TargetInstrInfo.cpp
@@ -397,7 +397,8 @@
     return true;
   }
   unsigned BitSize = TRI->getSubRegIdxSize(SubIdx);
-  // Convert bit size to byte size.
+  // Convert bit size to byte size to be consistent with
+  // MCRegisterClass::getSize().
   if (BitSize % 8)
     return false;
 
Index: llvm/include/llvm/MC/MCRegisterInfo.h
===================================================================
--- llvm/include/llvm/MC/MCRegisterInfo.h
+++ llvm/include/llvm/MC/MCRegisterInfo.h
@@ -39,6 +39,7 @@
   const uint16_t RegsSize;
   const uint16_t RegSetSize;
   const uint16_t ID;
+  const uint16_t PhysRegSize;
   const int8_t CopyCost;
   const bool Allocatable;
 
@@ -78,6 +79,11 @@
     return contains(Reg1) && contains(Reg2);
   }
 
+  /// Return the size of the physical register in bytes.
+  unsigned getPhysRegSize() const { return PhysRegSize; }
+  /// Temporary function to allow out-of-tree targets to switch.
+  unsigned getSize() const { return getPhysRegSize(); }
+
   /// getCopyCost - Return the cost of copying a value between two registers in
   /// this class. A negative number means the register class is very expensive
   /// to copy e.g. status flag register classes.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D97891.327940.patch
Type: text/x-patch
Size: 2194 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210303/30fb7bf5/attachment.bin>


More information about the llvm-commits mailing list