3 # Copyright 2001, 2002 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
9 # by the Free Software Foundation; either version 3 of the License, or (at
10 # your 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. If not, see http://www.gnu.org/licenses/.
21 # Usage: cd $(builddir)/mpn
22 # $(srcdir)/x86/t-zdisp2.pl
24 # Grep for any "0(reg...)" addressing modes coming out of the x86 .asm
25 # files. Additive expressions like "12+4-16" are recognised too.
27 # Old gas doesn't preserve the "0" displacement, so if it's wanted then
28 # Zdisp ought to be used to give explicit .byte sequences. See
31 # No output means everything is ok. All the asm files are put through m4 in
32 # PIC and non-PIC modes, and in each multi-function form, all of which can
33 # take a while to run.
35 # This program is only meant for use during development.
47 open IN, '<Makefile' or die;
49 if (/^srcdir[ \t]*=[ \t]*(.*)/) {
55 defined $srcdir or die "Cannot find \$srcdir in Makefile\n";
59 my $tempfile = 't-zdisp2.tmp';
60 open KARA, ">$tempfile" or die;
63 find({ wanted => \&process, preprocess => \&process_mparam, no_chdir => 1 },
67 if (/gmp-mparam.h$/) {
74 # Ensure we're using the right SQR_TOOM2_THRESHOLD for the part of the
75 # tree being processed.
77 my $file = "$File::Find::dir/gmp-mparam.h";
79 print "$file\n" if $opt{'t'};
80 open MPARAM, "<$file" or die;
82 if (/^#define SQR_TOOM2_THRESHOLD[ \t]*([0-9][0-9]*)/) {
83 open KARA, ">$tempfile" or die;
84 print KARA "define(\`SQR_TOOM2_THRESHOLD',$1)\n\n";
85 print "define(\`SQR_TOOM2_THRESHOLD',$1)\n" if $opt{'t'};
97 my $base = basename ($file, '.asm');
100 if ($base eq 'aors_n') { @funs = qw(add_n sub_n); }
101 elsif ($base eq 'aorsmul_1') { @funs = qw(addmul_1 submul_1); }
102 elsif ($base eq 'popham') { @funs = qw(popcount hamdist); }
103 elsif ($base eq 'logops_n') { @funs = qw(and_n andn_n nand_n ior_n iorn_n nior_n xor_n xnor_n); }
104 elsif ($base eq 'lorrshift') { @funs = qw(lshift rshift); }
105 else { @funs = ($base); }
107 foreach my $fun (@funs) {
108 foreach my $pic ('', ' -DPIC') {
109 my $header = "$file: 0: $pic\n";
112 my $m4 = "m4 -DHAVE_HOST_CPU_athlon -DOPERATION_$fun $pic ../config.m4 $tempfile $file";
113 print "$m4\n" if $opt{'t'};
115 open IN, "$m4 |" or die;
117 next unless /([0-9+-][0-9 \t+-]*)\(%/;
130 print "total $filecount processed\n";
135 # perl-indent-level: 2