Austin Schuh | dace2a6 | 2020-08-18 10:56:48 -0700 | [diff] [blame] | 1 | #! /bin/sh |
| 2 | # |
| 3 | # Copyright 2000 Free Software Foundation, Inc. |
| 4 | # |
| 5 | # This file is part of the GNU MP Library. |
| 6 | # |
| 7 | # The GNU MP Library is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of either: |
| 9 | # |
| 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. |
| 13 | # |
| 14 | # or |
| 15 | # |
| 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. |
| 19 | # |
| 20 | # or both in parallel, as here. |
| 21 | # |
| 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. |
| 26 | # |
| 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/. |
| 30 | |
| 31 | |
| 32 | # Usage: cd $(builddir)/mpn |
| 33 | # $(srcdir)/x86/t-zdisp.sh |
| 34 | # |
| 35 | # Run the Zdisp() macro instructions through the assembler to check |
| 36 | # the encodings used. Mismatches are printed, no output means all ok. |
| 37 | # |
| 38 | # This program is only meant for use during development. It can be |
| 39 | # run in the mpn build directory of any x86 configuration. |
| 40 | # |
| 41 | # For this test the assembler needs to generate byte sized 0 |
| 42 | # displacements when given something like 0(%eax). Recent versions of |
| 43 | # gas are suitable (eg. 2.9.x or 2.10.x). |
| 44 | |
| 45 | set -e |
| 46 | |
| 47 | cat >tmp-zdisptest.asm <<\EOF |
| 48 | |
| 49 | include(`../config.m4') |
| 50 | |
| 51 | dnl Redefine Zdisp_match to output its pattern and encoding. |
| 52 | define(`Zdisp_match', |
| 53 | `define(`Zdisp_found',1)dnl |
| 54 | ifelse(`$2',0,` $1 $2$3, $4')`'dnl |
| 55 | ifelse(`$3',0,` $1 $2, $3$4')`'dnl |
| 56 | |
| 57 | .byte $5 |
| 58 | ') |
| 59 | .text |
| 60 | Zdisp() |
| 61 | EOF |
| 62 | |
| 63 | m4 tmp-zdisptest.asm >tmp-zdisptest.s |
| 64 | as -o tmp-zdisptest.o tmp-zdisptest.s |
| 65 | |
| 66 | # Demand duplicates from the instruction patterns and byte encodings. |
| 67 | objdump -d tmp-zdisptest.o | awk ' |
| 68 | /^ *[a-z0-9]+:/ { |
| 69 | sub(/^ *[a-z0-9]+:/,"") |
| 70 | print |
| 71 | }' | sort | uniq -u |