[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
This commit is contained in:
Quentin Colombet 2016-06-08 01:11:03 +00:00
parent 123a7a55e7
commit cfbdee2312
4 changed files with 19 additions and 8 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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:

View File

@ -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.
///