Home | History | Annotate | Line # | Download | only in x86
t-zdisp.sh revision 1.1.1.2
      1      1.1  mrg #! /bin/sh
      2      1.1  mrg #
      3      1.1  mrg # Copyright 2000 Free Software Foundation, Inc.
      4      1.1  mrg #
      5  1.1.1.2  mrg #  This file is part of the GNU MP Library.
      6      1.1  mrg #
      7  1.1.1.2  mrg #  The GNU MP Library is free software; you can redistribute it and/or modify
      8  1.1.1.2  mrg #  it under the terms of either:
      9      1.1  mrg #
     10  1.1.1.2  mrg #    * the GNU Lesser General Public License as published by the Free
     11  1.1.1.2  mrg #      Software Foundation; either version 3 of the License, or (at your
     12  1.1.1.2  mrg #      option) any later version.
     13  1.1.1.2  mrg #
     14  1.1.1.2  mrg #  or
     15  1.1.1.2  mrg #
     16  1.1.1.2  mrg #    * the GNU General Public License as published by the Free Software
     17  1.1.1.2  mrg #      Foundation; either version 2 of the License, or (at your option) any
     18  1.1.1.2  mrg #      later version.
     19  1.1.1.2  mrg #
     20  1.1.1.2  mrg #  or both in parallel, as here.
     21  1.1.1.2  mrg #
     22  1.1.1.2  mrg #  The GNU MP Library is distributed in the hope that it will be useful, but
     23  1.1.1.2  mrg #  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
     24  1.1.1.2  mrg #  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
     25  1.1.1.2  mrg #  for more details.
     26  1.1.1.2  mrg #
     27  1.1.1.2  mrg #  You should have received copies of the GNU General Public License and the
     28  1.1.1.2  mrg #  GNU Lesser General Public License along with the GNU MP Library.  If not,
     29  1.1.1.2  mrg #  see https://www.gnu.org/licenses/.
     30      1.1  mrg 
     31      1.1  mrg 
     32      1.1  mrg # Usage: cd $(builddir)/mpn
     33      1.1  mrg #        $(srcdir)/x86/t-zdisp.sh
     34      1.1  mrg #
     35      1.1  mrg # Run the Zdisp() macro instructions through the assembler to check
     36      1.1  mrg # the encodings used.  Mismatches are printed, no output means all ok.
     37      1.1  mrg #
     38      1.1  mrg # This program is only meant for use during development.  It can be
     39      1.1  mrg # run in the mpn build directory of any x86 configuration.
     40      1.1  mrg #
     41      1.1  mrg # For this test the assembler needs to generate byte sized 0
     42      1.1  mrg # displacements when given something like 0(%eax).  Recent versions of
     43      1.1  mrg # gas are suitable (eg. 2.9.x or 2.10.x).
     44      1.1  mrg 
     45      1.1  mrg set -e
     46      1.1  mrg 
     47      1.1  mrg cat >tmp-zdisptest.asm <<\EOF
     48      1.1  mrg 
     49      1.1  mrg include(`../config.m4')
     50      1.1  mrg 
     51      1.1  mrg dnl  Redefine Zdisp_match to output its pattern and encoding.
     52      1.1  mrg define(`Zdisp_match',
     53      1.1  mrg `define(`Zdisp_found',1)dnl
     54      1.1  mrg ifelse(`$2',0,`	$1	$2$3, $4')`'dnl
     55      1.1  mrg ifelse(`$3',0,`	$1	$2, $3$4')`'dnl
     56      1.1  mrg 
     57      1.1  mrg 	.byte	$5
     58      1.1  mrg ')
     59      1.1  mrg 	.text
     60      1.1  mrg 	Zdisp()
     61      1.1  mrg EOF
     62      1.1  mrg 
     63      1.1  mrg m4 tmp-zdisptest.asm >tmp-zdisptest.s
     64      1.1  mrg as -o tmp-zdisptest.o tmp-zdisptest.s
     65      1.1  mrg 
     66      1.1  mrg # Demand duplicates from the instruction patterns and byte encodings.
     67      1.1  mrg objdump -d tmp-zdisptest.o | awk '
     68      1.1  mrg /^ *[a-z0-9]+:/ {
     69      1.1  mrg 	sub(/^ *[a-z0-9]+:/,"")
     70      1.1  mrg         print
     71      1.1  mrg }' | sort | uniq -u
     72