#!/bin/perl -w while (defined($file = shift (@ARGV))) { $file=~/\/(\d+\.\w+)\//; print "Results for $1\n"; open (FILE,"<$file"); undef %count; while (defined($line=)) { #print $line; # freq op stuff if ($line=~/\s+\[\s*(\d+)\].*\:\s+([\w|\@\(\)]+)\S*\s+(.+)/) { $freq=$1; $op=$2; $stuff=$3; if ($stuff=~/\#sint\=/) {$imm="imm";}else{$imm="nimm";} if ($stuff=~/\#sint\=0/) {$imm="imm0";} if ($stuff=~/\S+\,\s+\S+\,\s\%g0/) {$g0="%g0";}else{$g0="no%g0";} if ($op=~/cc/) {$cc="cc";}else {$cc="nocc";} if ((($op=~/add/) || ($op=~/and/) || ($op=~/or/) || ($op=~/mul/) || ($op=~/div/) || ($op=~/sub/) || ($op=~/mov/))) { # print ("$freq $op $imm $g0 ($stuff)\n"); $count{$op}{$imm}{$g0}+=$freq; $imm_text{$imm}=1; $g0_text{$g0}=1; } } } close FILE; print "Instr "; foreach $imm (sort keys %imm_text) { foreach $g0 (sort keys %g0_text) { print "$imm-$g0 "; } } print "\n"; foreach $op (sort keys %count) { print "$op "; foreach $imm (sort keys %imm_text) { foreach $g0 (sort keys %g0_text) { if (defined($count{$op}{$imm}{$g0})) { print "$count{$op}{$imm}{$g0} "; } else { print "0 ";} } } print "\n"; } }