in maxas/MaxAs/MaxAs.pm [1328:1375]
sub registerHealth
{
my ($reuseHistory, $reuseFlags, $capData, $instAddr, $inst, $nowarn) = @_;
my (@banks, @conflicts);
foreach my $slot (qw(r8 r20 r39))
{
my $r = $capData->{$slot} or next;
next if $r eq 'RZ';
my $slotHist = $reuseHistory->{$slot} ||= {};
$reuseHistory->{total}++;
# if this register is in active reuse then ignore for bank conflict checking.
if (exists $slotHist->{$r})
{
$reuseHistory->{reuse}++;
}
else
{
# extract number from reg and take the modulo-4 value. This is the bank id.
my $bank = substr($r,1) & 3;
# check for conflict
if ($banks[$bank] && $banks[$bank] ne $r)
{
push @conflicts, $banks[$bank] if !@conflicts;
push @conflicts, $r;
$reuseHistory->{conflicts}++;
}
$banks[$bank] = $r;
}
# update the history
if ($reuseFlags & $reuseSlots{$slot})
{ $slotHist->{$r} = 1; }
else
{ delete $slotHist->{$r}; }
}
if ($inst && @conflicts && !$nowarn)
{
printf "CONFLICT at 0x%04x (%s): $inst\n", $instAddr, join(',', @conflicts);
}
return scalar @conflicts;
}