3 # Copyright 2001, 2003 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 by
9 # the Free Software Foundation; either version 3 of the License, or (at your
10 # 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: perl t-m68k-defs.pl [-t]
23 # Run this in the mpn/m68k source directory to check that m68k-defs.m4 has
24 # m68k_defbranch()s or m68k_definsn()s for each instruction used in *.asm
25 # and */*.asm. Print nothing if everything is ok. The -t option prints
26 # some diagnostic traces.
37 open(FD, "<m68k-defs.m4")
38 or die "Cannot open m68k-defs.m4: $!\nIs this the mpn/m68k source directory?\n";
39 my ($srcdir, $top_srcdir);
41 if (/^m68k_defbranch\(\s*(.*)\)/) { $branch{"b".$1} = 1; }
42 if (/^m68k_definsn\(\s*(.*),\s*(.*)\)/) { $insn{$1.$2} = 1; }
46 print "branches: ", join(" ",keys(%branch)), "\n" if $opt{'t'};
47 print "insns: ", join(" ",keys(%insn)), "\n" if $opt{'t'};
50 foreach my $file (glob("*.asm"), glob("*/*.asm")) {
51 print "file $file\n" if $opt{'t'};
53 open(FD, "<$file") or die "Cannot open $file: $!";
55 if (/^[ \t]*C/) { next; };
56 if (/^\t([a-z0-9]+)/) {
58 print "opcode $1\n" if $opt{'t'};
60 # instructions with an l, w or b suffix should have a definsn
61 # (unless they're already a defbranch)
62 if ($opcode =~ /[lwb]$/
63 && ! defined $insn{$opcode}
64 && ! defined $branch{$opcode})
66 print "$file: $.: missing m68k_definsn: $opcode\n";
69 # instructions bXX should have a defbranch (unless they're
72 && ! defined $insn{$opcode}
73 && ! defined $branch{$opcode})
75 print "$file: $.: missing m68k_defbranch: $opcode\n";