1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-24 19:52:54 +01:00

[RegisterBankInfo] Change the implementation for the default mapping.

Do not give that much importance to the current register bank of an
operand. This is likely just a side effect of the current execution and
it is properly wise to prefer a register bank that can be extracted from
the information available statically (like encoding constraints and
type).

llvm-svn: 265810
This commit is contained in:
Quentin Colombet 2016-04-08 16:59:50 +00:00
parent 08e9ca8730
commit d094c81fdc

View File

@ -250,7 +250,16 @@ RegisterBankInfo::getInstrMappingImpl(const MachineInstr &MI) const {
unsigned Reg = MO.getReg(); unsigned Reg = MO.getReg();
if (!Reg) if (!Reg)
continue; continue;
const RegisterBank *CurRegBank = getRegBank(Reg, MRI, TRI); // The register bank of Reg is just a side effect of the current
// excution and in particular, there is no reason to believe this
// is the best default mapping for the current instruction. Keep
// it as an alternative register bank if we cannot figure out
// something.
const RegisterBank *AltRegBank = getRegBank(Reg, MRI, TRI);
// For copy-like instruction, we want to reuse the register bank
// that is already set on Reg, if any, since those instructions do
// not have any constraints.
const RegisterBank *CurRegBank = isCopyLike ? AltRegBank : nullptr;
if (!CurRegBank) { if (!CurRegBank) {
// If this is a target specific instruction, we can deduce // If this is a target specific instruction, we can deduce
// the register bank from the encoding constraints. // the register bank from the encoding constraints.
@ -262,6 +271,10 @@ RegisterBankInfo::getInstrMappingImpl(const MachineInstr &MI) const {
if (MITy) if (MITy)
CurRegBank = getRegBankForType( CurRegBank = getRegBankForType(
MVT::getVT(MITy, /*HandleUnknown*/ true).SimpleTy); MVT::getVT(MITy, /*HandleUnknown*/ true).SimpleTy);
if (!CurRegBank)
// Use the current assigned register bank.
// That may not make much sense though.
CurRegBank = AltRegBank;
if (!CurRegBank) { if (!CurRegBank) {
// All our attempts failed, give up. // All our attempts failed, give up.
CompleteMapping = false; CompleteMapping = false;