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 2.1 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; see the file COPYING.LIB. If not, write to
19
# the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
23
# Usage: perl t-m68k-defs.pl [-t]
25
# Run this in the mpn/m68k source directory to check that m68k-defs.m4 has
26
# m68k_defbranch()s or m68k_definsn()s for each instruction used in *.asm
27
# and */*.asm. Print nothing if everything is ok. The -t option prints
28
# some diagnostic traces.
39
open(FD, "<m68k-defs.m4")
40
or die "Cannot open m68k-defs.m4: $!\nIs this the mpn/m68k source directory?\n";
41
my ($srcdir, $top_srcdir);
43
if (/^m68k_defbranch\(\s*(.*)\)/) { $branch{"b".$1} = 1; }
44
if (/^m68k_definsn\(\s*(.*),\s*(.*)\)/) { $insn{$1.$2} = 1; }
48
print "branches: ", join(" ",keys(%branch)), "\n" if $opt{'t'};
49
print "insns: ", join(" ",keys(%insn)), "\n" if $opt{'t'};
52
foreach my $file (glob("*.asm"), glob("*/*.asm")) {
53
print "file $file\n" if $opt{'t'};
55
open(FD, "<$file") or die "Cannot open $file: $!";
57
if (/^[ \t]*C/) { next; };
58
if (/^\t([a-z0-9]+)/) {
60
print "opcode $1\n" if $opt{'t'};
62
# instructions with an l, w or b suffix should have a definsn
63
# (unless they're already a defbranch)
64
if ($opcode =~ /[lwb]$/
65
&& ! defined $insn{$opcode}
66
&& ! defined $branch{$opcode})
68
print "$file: $.: missing m68k_definsn: $opcode\n";
71
# instructions bXX should have a defbranch (unless they're
74
&& ! defined $insn{$opcode}
75
&& ! defined $branch{$opcode})
77
print "$file: $.: missing m68k_defbranch: $opcode\n";