[llvm] r265741 - [RegisterBankInfo] Change the semantic of recordRegBankForType.

Quentin Colombet via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 7 16:02:00 PDT 2016


Author: qcolombet
Date: Thu Apr  7 18:02:00 2016
New Revision: 265741

URL: http://llvm.org/viewvc/llvm-project?rev=265741&view=rev
Log:
[RegisterBankInfo] Change the semantic of recordRegBankForType.

Now, recordRegBankForType records only the first register bank that
covers a type instead of the last. This behavior can, nevertheless, be
override with the additional Force parameter to force the update.

Modified:
    llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.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=265741&r1=265740&r2=265741&view=diff
==============================================================================
--- llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h (original)
+++ llvm/trunk/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h Thu Apr  7 18:02:00 2016
@@ -196,7 +196,7 @@ protected:
   /// be mapped to \p ID. Although this done by default, targets may want to
   /// disable it, espicially if a given type may be mapped on different
   /// register bank. Indeed, in such case, this method only records the
-  /// last register bank where the type matches.
+  /// first register bank where the type matches.
   /// This information is only used to provide default mapping
   /// (see getInstrMappingImpl).
   ///
@@ -227,18 +227,23 @@ protected:
     return VTToRegBank.get()[SVT];
   }
 
-  /// Add \p SVT to the type that \p RegBank covers.
+  /// Record \p RegBank as the register bank that covers \p SVT.
+  /// If a record was already set for \p SVT, the mapping is not
+  /// updated, unless \p Force == true
   ///
-  /// \post If \p SVT was covered by another register bank before that call,
-  ///       then this information is gone.
-  /// \post getRegBankForType(SVT) == &RegBank
+  /// \post if getRegBankForType(SVT)@pre == nullptr then
+  ///                       getRegBankForType(SVT) == &RegBank
+  /// \post if Force == true then getRegBankForType(SVT) == &RegBank
   void recordRegBankForType(const RegisterBank &RegBank,
-                            MVT::SimpleValueType SVT) {
+                            MVT::SimpleValueType SVT, bool Force = false) {
     if (!VTToRegBank)
       VTToRegBank.reset(
           new const RegisterBank *[MVT::SimpleValueType::LAST_VALUETYPE]);
     assert(SVT < MVT::SimpleValueType::LAST_VALUETYPE && "Out-of-bound access");
-    VTToRegBank.get()[SVT] = &RegBank;
+    // If we want to override the mapping or the mapping does not exits yet,
+    // set the register bank for SVT.
+    if (Force || !getRegBankForType(SVT))
+      VTToRegBank.get()[SVT] = &RegBank;
   }
 
   /// Try to get the mapping of \p MI.




More information about the llvm-commits mailing list