beta-0.89.2
[luatex.git] / source / libs / gmp / gmp-src / mpn / m68k / t-m68k-defs.pl
blob91c21fa1f8ad987fd53ab5712d78eb1646bfe43d
1 #! /usr/bin/perl -w
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.
14 # or
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
18 # later version.
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
25 # for more details.
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.
39 use strict;
40 use Getopt::Std;
42 my %opt;
43 getopts('t', \%opt);
45 my %branch;
46 my %insn;
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);
51 while (<FD>) {
52 if (/^m68k_defbranch\(\s*(.*)\)/) { $branch{"b".$1} = 1; }
53 if (/^m68k_definsn\(\s*(.*),\s*(.*)\)/) { $insn{$1.$2} = 1; }
55 close(FD);
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: $!";
65 while (<FD>) {
66 if (/^[ \t]*C/) { next; };
67 if (/^\t([a-z0-9]+)/) {
68 my $opcode = $1;
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
81 # already a definsn)
82 if ($opcode =~ /^b/
83 && ! defined $insn{$opcode}
84 && ! defined $branch{$opcode})
86 print "$file: $.: missing m68k_defbranch: $opcode\n";
90 close(FD);