diff options
author | Quentin Colombet <qcolombet@apple.com> | 2016-06-08 01:11:03 +0000 |
---|---|---|
committer | Quentin Colombet <qcolombet@apple.com> | 2016-06-08 01:11:03 +0000 |
commit | cfbdee231270ce34e50c6e570e16974824aa8793 (patch) | |
tree | 4d71a7a5a3b35b7280d611e45fe186e0ab786746 | |
parent | 123a7a55e70ec295ec2262b6d3c256f039d71d32 (diff) | |
download | bcm5719-llvm-cfbdee231270ce34e50c6e570e16974824aa8793.tar.gz bcm5719-llvm-cfbdee231270ce34e50c6e570e16974824aa8793.zip |
[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.
llvm-svn: 272084
4 files changed, 19 insertions, 8 deletions
diff --git a/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h b/llvm/include/llvm/CodeGen/GlobalISel/RegisterBankInfo.h index 7ab2fa14a4b..cc2c80d186c 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 fc04f4e8a55..4890d45a6d3 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 a877b79c078..72097a9bbd8 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 156f9a0b7d5..69a21ec82cf 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. /// |