[LLVMdev] Problem with cross class joins in the	RegisterCoalescer
    Jakob Stoklund Olesen 
    stoklund at 2pi.dk
       
    Fri Jan 20 09:53:15 PST 2012
    
    
  
On Jan 20, 2012, at 1:19 AM, Patrik Hägglund H wrote:
> Our bug is now fixed.
Great!
> Our getMatchingSuperRegClass is huge (more than 300 lines), messy, and incomplete.
The versions I deleted from ARM and X86 weren't pretty either.
>> Or you could just rebase. On trunk, TableGen writes this difficult function for you.
> 
> That in itself would be a compelling reason to get the rebase to trunk done. I just curious how large the generated version will be. :-)
Probably not that bad. TableGen uses a table that takes advantage of the topological register class ordering.
The X86 version looks like this:
const TargetRegisterClass *X86GenRegisterInfo::getMatchingSuperRegClass(const TargetRegisterClass *A, const TargetRegisterClass *B, unsigned Idx) const {
  static const unsigned Table[58][7][2] = {
    ...
  };
  assert(A && B && "Missing regclass");
  --Idx;
  assert(Idx < 7 && "Bad subreg");
  const unsigned *TV = Table[B->getID()][Idx];
  const unsigned *SC = A->getSubClassMask();
  for (unsigned i = 0; i != 2; ++i)
    if (unsigned Common = TV[i] & SC[i])
      return getRegClass(32*i + CountTrailingZeros_32(Common));
  return 0;
}
The table is just over 3kB. It is quite sparse and could probably be compressed. Patches welcome!
/jakob
    
    
More information about the llvm-dev
mailing list