3 # Copyright 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc.
5 # This file is part of the GNU MP Library.
7 # The GNU MP Library is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU Lesser General Public License as published
9 # by the Free Software Foundation; either version 3 of the License, or (at
10 # your option) any later version.
12 # The GNU MP Library is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
15 # License for more details.
17 # You should have received a copy of the GNU Lesser General Public License
18 # along with the GNU MP Library. If not, see http://www.gnu.org/licenses/.
21 # Usage: slot.pl [filename.o]...
23 # Run "objdump" to produce a disassembly of the given object file(s) and
24 # annotate the output with "U" or "L" slotting which Alpha EV6 will use.
26 # When an instruction is E (ie. either U or L), an "eU" or "eL" is shown, as
27 # a reminder that it wasn't a fixed requirement that gave the U or L, but
28 # the octaword slotting rules.
30 # If an instruction is not recognised, that octaword does not get any U/L
31 # shown, only lower-case "u", "l" or "e" for the instructions which are
32 # known. Add any unknown instructions to %optable below.
37 # The U or L which various instructions demand, or E if either.
91 # Slottings used for a given pattern of U/L/E in an octaword. This is as
92 # per the "Ebox Slotting" section of the EV6 hardware reference manual.
182 # Check all combinations of U/L/E are present in %slottable.
184 foreach my $a ('U', 'L', 'E') {
185 foreach my $b ('U', 'L', 'E') {
186 foreach my $c ('U', 'L', 'E') {
187 foreach my $d ('U', 'L', 'E') {
188 my $x = $a . $b . $c . $d;
189 if (! defined $slottable{$x}) {
190 print "slottable missing: $x\n"
198 # Certain consistency checks for %slottable.
200 foreach my $x (keys %slottable) {
201 my $a = substr($x,0,1);
202 my $b = substr($x,1,1);
203 my $c = substr($x,2,1);
204 my $d = substr($x,3,1);
205 my $es = ($a eq 'E') + ($b eq 'E') + ($c eq 'E') + ($d eq 'E');
206 my $ls = ($a eq 'L') + ($b eq 'L') + ($c eq 'L') + ($d eq 'L');
207 my $us = ($a eq 'U') + ($b eq 'U') + ($c eq 'U') + ($d eq 'U');
209 my $got = $slottable{$x};
215 # when only one E, it's mapped to whichever of U or L is otherwise
223 # when two E's and two U, then the E's map to L; vice versa for two E
240 print "slottable $x want $want got $got\n";
248 open (IN, "objdump -Srfh $file |") || die "Cannot open pipe from objdump\n";
250 my (%pre, %post, %type);
254 if ($line =~ /(^[ \t]*[0-9a-f]*([0-9a-f]):[ \t]*[0-9a-f][0-9a-f] [0-9a-f][0-9a-f] [0-9a-f][0-9a-f] [0-9a-f][0-9a-f] )\t(([a-z0-9]+).*)/) {
255 my ($this_pre, $addr, $this_post, $opcode) = ($1, $2, $3, $4);
257 my $this_type = $optable{$opcode};
258 if (! defined ($this_type)) { $this_type = ' '; }
260 $pre{$addr} = $this_pre;
261 $post{$addr} = $this_post;
262 $type{$addr} = $this_type;
265 my %slot = ('0'=>' ', '4'=>' ', '8'=>' ', 'c'=>' ');
267 my $str = $type{'c'} . $type{'8'} . $type{'4'} . $type{'0'};
268 $str = $slottable{$str};
270 $slot{'c'} = substr($str,0,1);
271 $slot{'8'} = substr($str,1,1);
272 $slot{'4'} = substr($str,2,1);
273 $slot{'0'} = substr($str,3,1);
276 foreach my $i ('0', '4', '8', 'c') {
277 if ($slot{$i} eq $type{$i}) { $type{$i} = ' '; }
278 print $pre{$i}, ' ', lc($type{$i}),$slot{$i}, ' ', $post{$i}, "\n";
288 close IN || die "Error from objdump (or objdump not available)\n";