Skip to content

Commit

Permalink
[X86] Return more accurate getNumSupportedRegs() (NFC)
Browse files Browse the repository at this point in the history
llvm#70222 introduces a hook
to return a more accurate number of registers supported for a
specific subtarget (rather than target). However, while x86 registers
were reordered to allow using this, the implementation still always
returned NUM_TARGET_REGS.

Adjust it to return a smaller number of registers depending on
availability of avx/avx512/amx.
  • Loading branch information
nikic committed Nov 8, 2023
1 parent d687057 commit d218b6d
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion llvm/lib/Target/X86/X86RegisterInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -634,7 +634,15 @@ unsigned X86RegisterInfo::getNumSupportedRegs(const MachineFunction &MF) const {
(X86::K6_K7 + 1 == X86::TMMCFG) &&
(X86::TMM7 + 1 == X86::NUM_TARGET_REGS) &&
"Register number may be incorrect");
return X86::NUM_TARGET_REGS;

const X86Subtarget &ST = MF.getSubtarget<X86Subtarget>();
if (ST.hasAMXTILE())
return X86::TMM7 + 1;
if (ST.hasAVX512())
return X86::K6_K7 + 1;
if (ST.hasAVX())
return X86::YMM15 + 1;
return X86::R15WH + 1;
}

bool X86RegisterInfo::isArgumentRegister(const MachineFunction &MF,
Expand Down

0 comments on commit d218b6d

Please sign in to comment.