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