diff --git a/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h b/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h index 7ab2fa14a4bf..cc2c80d186c1 100644 --- a/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h +++ b/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h @@ -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; } diff --git a/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp b/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp index fc04f4e8a55e..4890d45a6d3e 100644 --- a/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp +++ b/llvm/lib/CodeGen/GlobalISel/RegBankSelect.cpp @@ -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; diff --git a/llvm/lib/Target/AArch64/AArch64RegisterBankInfo.cpp b/llvm/lib/Target/AArch64/AArch64RegisterBankInfo.cpp index a877b79c0785..72097a9bbd82 100644 --- a/llvm/lib/Target/AArch64/AArch64RegisterBankInfo.cpp +++ b/llvm/lib/Target/AArch64/AArch64RegisterBankInfo.cpp @@ -64,7 +64,8 @@ AArch64RegisterBankInfo::AArch64RegisterBankInfo(const TargetRegisterInfo &TRI) } 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: diff --git a/llvm/lib/Target/AArch64/AArch64RegisterBankInfo.h b/llvm/lib/Target/AArch64/AArch64RegisterBankInfo.h index 156f9a0b7d57..69a21ec82cfa 100644 --- a/llvm/lib/Target/AArch64/AArch64RegisterBankInfo.h +++ b/llvm/lib/Target/AArch64/AArch64RegisterBankInfo.h @@ -34,9 +34,13 @@ class AArch64RegisterBankInfo : public RegisterBankInfo { 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. ///