OLD | NEW |
| (Empty) |
1 #! /usr/bin/perl -w | |
2 | |
3 # Copyright 2001, 2003 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 3 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. If not, see http://www.gnu.org/licenses/. | |
19 | |
20 | |
21 # Usage: perl t-m68k-defs.pl [-t] | |
22 # | |
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. | |
27 | |
28 use strict; | |
29 use Getopt::Std; | |
30 | |
31 my %opt; | |
32 getopts('t', \%opt); | |
33 | |
34 my %branch; | |
35 my %insn; | |
36 | |
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); | |
40 while (<FD>) { | |
41 if (/^m68k_defbranch\(\s*(.*)\)/) { $branch{"b".$1} = 1; } | |
42 if (/^m68k_definsn\(\s*(.*),\s*(.*)\)/) { $insn{$1.$2} = 1; } | |
43 } | |
44 close(FD); | |
45 | |
46 print "branches: ", join(" ",keys(%branch)), "\n" if $opt{'t'}; | |
47 print "insns: ", join(" ",keys(%insn)), "\n" if $opt{'t'}; | |
48 | |
49 | |
50 foreach my $file (glob("*.asm"), glob("*/*.asm")) { | |
51 print "file $file\n" if $opt{'t'}; | |
52 | |
53 open(FD, "<$file") or die "Cannot open $file: $!"; | |
54 while (<FD>) { | |
55 if (/^[ \t]*C/) { next; }; | |
56 if (/^\t([a-z0-9]+)/) { | |
57 my $opcode = $1; | |
58 print "opcode $1\n" if $opt{'t'}; | |
59 | |
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}) | |
65 { | |
66 print "$file: $.: missing m68k_definsn: $opcode\n"; | |
67 } | |
68 | |
69 # instructions bXX should have a defbranch (unless they're | |
70 # already a definsn) | |
71 if ($opcode =~ /^b/ | |
72 && ! defined $insn{$opcode} | |
73 && ! defined $branch{$opcode}) | |
74 { | |
75 print "$file: $.: missing m68k_defbranch: $opcode\n"; | |
76 } | |
77 } | |
78 } | |
79 close(FD); | |
80 } | |
OLD | NEW |