Annotation of OpenXM_contrib/gmp/mpn/m68k/t-m68k-defs.pl, Revision 1.1.1.1
1.1 ohara 1: #! /usr/bin/perl -w
2:
3: # Copyright 2001 Free Software Foundation, Inc.
4: #
5: # This file is part of the GNU MP Library.
6: #
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.
11: #
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.
16: #
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,
20: # MA 02111-1307, USA.
21:
22:
23: # Usage: perl t-m68k-defs.pl [-t]
24: #
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.
29:
30: use strict;
31: use Getopt::Std;
32:
33: my %opt;
34: getopts('t', \%opt);
35:
36: my %branch;
37: my %insn;
38:
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);
42: while (<FD>) {
43: if (/^m68k_defbranch\(\s*(.*)\)/) { %branch->{"b".$1}=1; }
44: if (/^m68k_definsn\(\s*(.*),\s*(.*)\)/) { %insn->{$1.$2}=1; }
45: }
46: close(FD);
47:
48: print "branches: ", join(" ",keys(%branch)), "\n" if $opt{'t'};
49: print "insns: ", join(" ",keys(%insn)), "\n" if $opt{'t'};
50:
51:
52: foreach my $file (glob("*.asm"), glob("*/*.asm")) {
53: print "file $file\n" if $opt{'t'};
54:
55: open(FD, "<$file") or die "Cannot open $file: $!";
56: while (<FD>) {
57: if (/^[ \t]*C/) { next; };
58: if (/^\t([a-z0-9]+)/) {
59: my $opcode = $1;
60: print "opcode $1\n" if $opt{'t'};
61:
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})
67: {
68: print "$file: $.: missing m68k_definsn: $opcode\n";
69: }
70:
71: # instructions bXX should have a defbranch (unless they're
72: # already a definsn)
73: if ($opcode =~ /^b/
74: && ! defined %insn->{$opcode}
75: && ! defined %branch->{$opcode})
76: {
77: print "$file: $.: missing m68k_defbranch: $opcode\n";
78: }
79: }
80: }
81: close(FD);
82: }
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>