3 # Copyright 2000, 2001, 2003-2005, 2011 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 either:
10 # * the GNU Lesser General Public License as published by the Free
11 # Software Foundation; either version 3 of the License, or (at your
12 # option) any later version.
16 # * the GNU General Public License as published by the Free Software
17 # Foundation; either version 2 of the License, or (at your option) any
20 # or both in parallel, as here.
22 # The GNU MP Library is distributed in the hope that it will be useful, but
23 # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
24 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
27 # You should have received copies of the GNU General Public License and the
28 # GNU Lesser General Public License along with the GNU MP Library. If not,
29 # see https://www.gnu.org/licenses/.
32 # Usage: slot.pl [filename.o]...
34 # Run "objdump" to produce a disassembly of the given object file(s) and
35 # annotate the output with "U" or "L" slotting which Alpha EV6 will use.
37 # When an instruction is E (ie. either U or L), an "eU" or "eL" is shown, as
38 # a reminder that it wasn't a fixed requirement that gave the U or L, but
39 # the octaword slotting rules.
41 # If an instruction is not recognised, that octaword does not get any U/L
42 # shown, only lower-case "u", "l" or "e" for the instructions which are
43 # known. Add any unknown instructions to %optable below.
48 # The U or L which various instructions demand, or E if either.
106 # Slottings used for a given pattern of U/L/E in an octaword. This is as
107 # per the "Ebox Slotting" section of the EV6 hardware reference manual.
197 # Check all combinations of U/L/E are present in %slottable.
199 foreach my $a ('U', 'L', 'E') {
200 foreach my $b ('U', 'L', 'E') {
201 foreach my $c ('U', 'L', 'E') {
202 foreach my $d ('U', 'L', 'E') {
203 my $x = $a . $b . $c . $d;
204 if (! defined $slottable{$x}) {
205 print "slottable missing: $x\n"
213 # Certain consistency checks for %slottable.
215 foreach my $x (keys %slottable) {
216 my $a = substr($x,0,1);
217 my $b = substr($x,1,1);
218 my $c = substr($x,2,1);
219 my $d = substr($x,3,1);
220 my $es = ($a eq 'E') + ($b eq 'E') + ($c eq 'E') + ($d eq 'E');
221 my $ls = ($a eq 'L') + ($b eq 'L') + ($c eq 'L') + ($d eq 'L');
222 my $us = ($a eq 'U') + ($b eq 'U') + ($c eq 'U') + ($d eq 'U');
224 my $got = $slottable{$x};
230 # when only one E, it's mapped to whichever of U or L is otherwise
238 # when two E's and two U, then the E's map to L; vice versa for two E
255 print "slottable $x want $want got $got\n";
263 open (IN
, "objdump -Srfh $file |") || die "Cannot open pipe from objdump\n";
265 my (%pre, %post, %type);
269 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]+).*)/) {
270 my ($this_pre, $addr, $this_post, $opcode) = ($1, $2, $3, $4);
272 my $this_type = $optable{$opcode};
273 if (! defined ($this_type)) { $this_type = ' '; }
275 $pre{$addr} = $this_pre;
276 $post{$addr} = $this_post;
277 $type{$addr} = $this_type;
280 my %slot = ('0'=>' ', '4'=>' ', '8'=>' ', 'c'=>' ');
282 my $str = $type{'c'} . $type{'8'} . $type{'4'} . $type{'0'};
283 $str = $slottable{$str};
285 $slot{'c'} = substr($str,0,1);
286 $slot{'8'} = substr($str,1,1);
287 $slot{'4'} = substr($str,2,1);
288 $slot{'0'} = substr($str,3,1);
291 foreach my $i ('0', '4', '8', 'c') {
292 if ($slot{$i} eq $type{$i}) { $type{$i} = ' '; }
293 print $pre{$i}, ' ', lc($type{$i}),$slot{$i}, ' ', $post{$i}, "\n";
303 close IN
|| die "Error from objdump (or objdump not available)\n";