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 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: perl t-m68k-defs.pl [-t]
34 # Run this in the mpn/m68k source directory to check that m68k-defs.m4 has
35 # m68k_defbranch()s or m68k_definsn()s for each instruction used in *.asm
36 # and */*.asm. Print nothing if everything is ok. The -t option prints
37 # some diagnostic traces.
48 open(FD
, "<m68k-defs.m4")
49 or die "Cannot open m68k-defs.m4: $!\nIs this the mpn/m68k source directory?\n";
50 my ($srcdir, $top_srcdir);
52 if (/^m68k_defbranch\(\s*(.*)\)/) { $branch{"b".$1} = 1; }
53 if (/^m68k_definsn\(\s*(.*),\s*(.*)\)/) { $insn{$1.$2} = 1; }
57 print "branches: ", join(" ",keys(%branch)), "\n" if $opt{'t'};
58 print "insns: ", join(" ",keys(%insn)), "\n" if $opt{'t'};
61 foreach my $file (glob("*.asm"), glob("*/*.asm")) {
62 print "file $file\n" if $opt{'t'};
64 open(FD
, "<$file") or die "Cannot open $file: $!";
66 if (/^[ \t]*C/) { next; };
67 if (/^\t([a-z0-9]+)/) {
69 print "opcode $1\n" if $opt{'t'};
71 # instructions with an l, w or b suffix should have a definsn
72 # (unless they're already a defbranch)
73 if ($opcode =~ /[lwb]$/
74 && ! defined $insn{$opcode}
75 && ! defined $branch{$opcode})
77 print "$file: $.: missing m68k_definsn: $opcode\n";
80 # instructions bXX should have a defbranch (unless they're
83 && ! defined $insn{$opcode}
84 && ! defined $branch{$opcode})
86 print "$file: $.: missing m68k_defbranch: $opcode\n";