blob: 61efdd6c4fffddea3b5020a1e5263c9929a3f383 [file] [log] [blame]
Austin Schuhdace2a62020-08-18 10:56:48 -07001#! /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
45set -e
46
47cat >tmp-zdisptest.asm <<\EOF
48
49include(`../config.m4')
50
51dnl Redefine Zdisp_match to output its pattern and encoding.
52define(`Zdisp_match',
53`define(`Zdisp_found',1)dnl
54ifelse(`$2',0,` $1 $2$3, $4')`'dnl
55ifelse(`$3',0,` $1 $2, $3$4')`'dnl
56
57 .byte $5
58')
59 .text
60 Zdisp()
61EOF
62
63m4 tmp-zdisptest.asm >tmp-zdisptest.s
64as -o tmp-zdisptest.o tmp-zdisptest.s
65
66# Demand duplicates from the instruction patterns and byte encodings.
67objdump -d tmp-zdisptest.o | awk '
68/^ *[a-z0-9]+:/ {
69 sub(/^ *[a-z0-9]+:/,"")
70 print
71}' | sort | uniq -u