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 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.
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
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
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: cd $(builddir)/mpn
33 # $(srcdir)/x86/t-zdisp2.pl
35 # Grep for any "0(reg...)" addressing modes coming out of the x86 .asm
36 # files. Additive expressions like "12+4-16" are recognised too.
38 # Old gas doesn't preserve the "0" displacement, so if it's wanted then
39 # Zdisp ought to be used to give explicit .byte sequences. See
42 # No output means everything is ok. All the asm files are put through m4 in
43 # PIC and non-PIC modes, and in each multi-function form, all of which can
44 # take a while to run.
46 # This program is only meant for use during development.
58 open IN
, '<Makefile' or die;
60 if (/^srcdir[ \t]*=[ \t]*(.*)/) {
66 defined $srcdir or die "Cannot find \$srcdir in Makefile\n";
70 my $tempfile = 't-zdisp2.tmp';
71 open KARA
, ">$tempfile" or die;
74 find
({ wanted
=> \
&process
, preprocess
=> \
&process_mparam
, no_chdir
=> 1 },
78 if (/gmp-mparam.h$/) {
85 # Ensure we're using the right SQR_TOOM2_THRESHOLD for the part of the
86 # tree being processed.
88 my $file = "$File::Find::dir/gmp-mparam.h";
90 print "$file\n" if $opt{'t'};
91 open MPARAM
, "<$file" or die;
93 if (/^#define SQR_TOOM2_THRESHOLD[ \t]*([0-9][0-9]*)/) {
94 open KARA
, ">$tempfile" or die;
95 print KARA
"define(\`SQR_TOOM2_THRESHOLD',$1)\n\n";
96 print "define(\`SQR_TOOM2_THRESHOLD',$1)\n" if $opt{'t'};
108 my $base = basename
($file, '.asm');
111 if ($base eq 'aors_n') { @funs = qw(add_n sub_n); }
112 elsif ($base eq 'aorsmul_1') { @funs = qw(addmul_1 submul_1); }
113 elsif ($base eq 'popham') { @funs = qw(popcount hamdist); }
114 elsif ($base eq 'logops_n') { @funs = qw(and_n andn_n nand_n ior_n iorn_n nior_n xor_n xnor_n); }
115 elsif ($base eq 'lorrshift') { @funs = qw(lshift rshift); }
116 else { @funs = ($base); }
118 foreach my $fun (@funs) {
119 foreach my $pic ('', ' -DPIC') {
120 my $header = "$file: 0: $pic\n";
123 my $m4 = "m4 -DHAVE_HOST_CPU_athlon -DOPERATION_$fun $pic ../config.m4 $tempfile $file";
124 print "$m4\n" if $opt{'t'};
126 open IN
, "$m4 |" or die;
128 next unless /([0-9+-][0-9 \t+-]*)\(%/;
141 print "total $filecount processed\n";
146 # perl-indent-level: 2