[llvm] r272084 - [RegisterBankInfo] Add a size argument for the cost of copy.

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 7 18:11:03 PDT 2016


Author: qcolombet
Date: Tue Jun  7 20:11:03 2016
New Revision: 272084

URL: http://llvm.org/viewvc/llvm-project?rev=272084&view=rev
Log:
[RegisterBankInfo] Add a size argument for the cost of copy.

The cost of a copy may be different based on how many bits we have to
copy around. E.g., a 8-bit copy may be different than a 32-bit copy.

Modified:
    llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
    llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp
    llvm/trunk/lib/Target/AArch64/AArch64RegisterBankInfo.cpp
    llvm/trunk/lib/Target/AArch64/AArch64RegisterBankInfo.h

Modified: llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h?rev=272084&r1=272083&r2=272084&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h Tue Jun  7 20:11:03 2016
@@ -352,9 +352,13 @@ public:
   }
 
   /// Get the cost of a copy from \p B to \p A, or put differently,
-  /// get the cost of A = COPY B.
-  virtual unsigned copyCost(const RegisterBank &A,
-                            const RegisterBank &B) const {
+  /// get the cost of A = COPY B. Since register banks may cover
+  /// different size, \p Size specifies what will be the size in bits
+  /// that will be copied around.
+  ///
+  /// \note Since this is a copy, both registers have the same size.
+  virtual unsigned copyCost(const RegisterBank &A, const RegisterBank &B,
+                            unsigned Size) const {
     return 0;
   }
 

Modified: llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp?rev=272084&r1=272083&r2=272084&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp (original)
+++ llvm/trunk/lib/CodeGen/GlobalISel/RegBankSelect.cpp Tue Jun  7 20:11:03 2016
@@ -163,7 +163,9 @@ uint64_t RegBankSelect::getRepairCost(
     // the repairing.
     if (MO.isDef())
       std::swap(CurRegBank, DesiredRegBrank);
-    unsigned Cost = RBI->copyCost(*DesiredRegBrank, *CurRegBank);
+    unsigned Cost =
+        RBI->copyCost(*DesiredRegBrank, *CurRegBank,
+                      RegisterBankInfo::getSizeInBits(MO.getReg(), *MRI, *TRI));
     // TODO: use a dedicated constant for ImpossibleCost.
     if (Cost != UINT_MAX)
       return Cost;

Modified: llvm/trunk/lib/Target/AArch64/AArch64RegisterBankInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64RegisterBankInfo.cpp?rev=272084&r1=272083&r2=272084&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64RegisterBankInfo.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64RegisterBankInfo.cpp Tue Jun  7 20:11:03 2016
@@ -64,7 +64,8 @@ AArch64RegisterBankInfo::AArch64Register
 }
 
 unsigned AArch64RegisterBankInfo::copyCost(const RegisterBank &A,
-                                           const RegisterBank &B) const {
+                                           const RegisterBank &B,
+                                           unsigned Size) const {
   // What do we do with different size?
   // copy are same size.
   // Will introduce other hooks for different size:

Modified: llvm/trunk/lib/Target/AArch64/AArch64RegisterBankInfo.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64RegisterBankInfo.h?rev=272084&r1=272083&r2=272084&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64RegisterBankInfo.h (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64RegisterBankInfo.h Tue Jun  7 20:11:03 2016
@@ -34,9 +34,13 @@ class AArch64RegisterBankInfo : public R
 public:
   AArch64RegisterBankInfo(const TargetRegisterInfo &TRI);
   /// Get the cost of a copy from \p B to \p A, or put differently,
-  /// get the cost of A = COPY B.
-  unsigned copyCost(const RegisterBank &A,
-                    const RegisterBank &B) const override;
+  /// get the cost of A = COPY B. Since register banks may cover
+  /// different size, \p Size specifies what will be the size in bits
+  /// that will be copied around.
+  ///
+  /// \note Since this is a copy, both registers have the same size.
+  unsigned copyCost(const RegisterBank &A, const RegisterBank &B,
+                    unsigned Size) const override;
 
   /// Get a register bank that covers \p RC.
   ///




More information about the llvm-commits mailing list