]> gcc.gnu.org Git - gcc.git/blame - gcc/genmultilib
flow.c (flow_delete_insn): Use INSN_DELETED_P for marking insn as deleted.
[gcc.git] / gcc / genmultilib
CommitLineData
08b28cd3
DE
1#!/bin/sh
2# Generates multilib.h.
699a42a6 3# Copyright (C) 1994, 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
08b28cd3
DE
4
5#This file is part of GNU CC.
6
7#GNU CC is free software; you can redistribute it and/or modify
8#it under the terms of the GNU General Public License as published by
9#the Free Software Foundation; either version 2, or (at your option)
10#any later version.
11
12#GNU CC is distributed in the hope that it will be useful,
13#but WITHOUT ANY WARRANTY; without even the implied warranty of
14#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15#GNU General Public License for more details.
16
17#You should have received a copy of the GNU General Public License
18#along with GNU CC; see the file COPYING. If not, write to
de18aff3
RK
19#the Free Software Foundation, 59 Temple Place - Suite 330,
20#Boston, MA 02111-1307, USA.
08b28cd3
DE
21
22# This shell script produces a header file which the gcc driver
23# program uses to pick which library to use based on the machine
24# specific options that it is given.
25
26# The first argument is a list of sets of options. The elements in
27# the list are separated by spaces. Within an element, the options
699a42a6
JJ
28# are separated by slashes or pipes. No leading dash is used on the
29# options.
30# Each option in a set separated by slashes is mutually incompatible
31# with all other options
08b28cd3 32# in the set.
699a42a6
JJ
33# Each option in a set separated by pipes will be used for the library
34# compilation and any of the options in the set will be sufficient
35# for it to be triggered.
08b28cd3
DE
36
37# The optional second argument is a list of subdirectory names. If
38# the second argument is non-empty, there must be as many elements in
39# the second argument as there are options in the first argument. The
40# elements in the second list are separated by spaces. If the second
41# argument is empty, the option names will be used as the directory
42# names.
43
44# The optional third argument is a list of options which are
45# identical. The elements in the list are separated by spaces. Each
46# element must be of the form OPTION=OPTION. The first OPTION should
47# appear in the first argument, and the second should be a synonym for
75814ad4 48# it. Question marks are replaced with equal signs in both options.
08b28cd3 49
e09150c7
MM
50# The optional fourth argument is a list of multilib directory
51# combinations that should not be built.
52
961b7009
MM
53# The optional fifth argument is a list of options that should be
54# used whenever building multilib libraries.
55
0a8d6618
BC
56# The optional sixth argument is a list of exclusions used internally by
57# the compiler similar to exceptions. The difference being that exclusions
58# allow matching default options that genmultilib does not know about and
59# is done at runtime as opposed to being sorted out at compile time.
60# Each element in the list is a seperate exclusion rule. Each rule is
61# a list of options (sans preceding '-') seperated by a '/'. The options
62# on the rule are grouped as an AND operation, and all options much match
63# for the rule to exclude a set. Options can be preceded with a '!' to
64# match a logical NOT.
65
08b28cd3
DE
66# The output looks like
67# #define MULTILIB_MATCHES "\
68# SUBDIRECTORY OPTIONS;\
69# ...
70# "
71# The SUBDIRECTORY is the subdirectory to use. The OPTIONS are
72# multiple options separated by spaces. Each option may start with an
73# exclamation point. gcc will consider each line in turn. If none of
74# the options beginning with an exclamation point are present, and all
75# of the other options are present, that subdirectory will be used.
76# The order of the subdirectories is such that they can be created in
77# order; that is, a subdirectory is preceded by all its parents.
78
0a8d6618
BC
79# Here is an example (this is from the actual sparc64 case):
80# genmultilib 'm64/m32 mno-app-regs|mcmodel=medany' '64 32 alt'
81# 'mcmodel?medany=mcmodel?medmid' 'm32/mno-app-regs* m32/mcmodel=*'
82# 'm32/!m64/mno-app-regs m32/!m64/mcmodel=medany'
08b28cd3 83# This produces:
0a8d6618
BC
84# ". !m64 !m32 !mno-app-regs !mcmodel=medany;",
85# "64 m64 !m32 !mno-app-regs !mcmodel=medany;",
86# "32 !m64 m32 !mno-app-regs !mcmodel=medany;",
87# "alt !m64 !m32 mno-app-regs mcmodel=medany;",
88# "alt !m64 !m32 mno-app-regs !mcmodel=medany;",
89# "alt !m64 !m32 !mno-app-regs mcmodel=medany;",
90# "64/alt m64 !m32 mno-app-regs mcmodel=medany;",
91# "64/alt m64 !m32 mno-app-regs !mcmodel=medany;",
92# "64/alt m64 !m32 !mno-app-regs mcmodel=medany;",
87e24276 93#
0a8d6618
BC
94# The effect is that `gcc -mno-app-regs' (for example) will append "alt"
95# to the directory name when searching for libraries or startup files and
96# `gcc -m32 -mcmodel=medany' (for example) will append "32/alt". Also note
97# that exclusion above is moot, unless the compiler had a default of -m32,
98# which would mean that all of the "alt" directories (not the 64/alt ones)
99# would be ignored (not generated, nor used) since the exclusion also
100# matches the multilib_default args.
08b28cd3
DE
101
102# Copy the positional parameters into variables.
103options=$1
104dirnames=$2
105matches=$3
e09150c7 106exceptions=$4
961b7009 107extra=$5
0a8d6618 108exclusions=$6
961b7009
MM
109
110echo "static char *multilib_raw[] = {"
08b28cd3
DE
111
112# What we want to do is select all combinations of the sets in
113# options. Each combination which includes a set of mutually
114# exclusive options must then be output multiple times, once for each
115# item in the set. Selecting combinations is a recursive process.
116# Since not all versions of sh support functions, we achieve recursion
117# by creating a temporary shell script which invokes itself.
118rm -f tmpmultilib
119cat >tmpmultilib <<\EOF
120#!/bin/sh
121# This recursive script basically outputs all combinations of its
122# input arguments, handling mutually exclusive sets of options by
123# repetition. When the script is called, ${initial} is the list of
124# options which should appear before all combinations this will
125# output. The output looks like a list of subdirectory names with
126# leading and trailing slashes.
127if [ "$#" != "0" ]; then
128 first=$1
129 shift
699a42a6
JJ
130 case "$first" in
131 *\|*)
132 all=${initial}`echo $first | sed -e 's_|_/_'g`
133 first=`echo $first | sed -e 's_|_ _'g`
134 echo ${all}/
135 initial="${initial}${all}/" ./tmpmultilib $@
136 ./tmpmultilib $first $@ | grep -v "^${all}"
137 ;;
138 *)
139 for opt in `echo $first | sed -e 's|/| |'g`; do
140 echo ${initial}${opt}/
141 done
142 ./tmpmultilib $@
143 for opt in `echo $first | sed -e 's|/| |'g`; do
144 initial="${initial}${opt}/" ./tmpmultilib $@
145 done
146 esac
08b28cd3
DE
147fi
148EOF
149chmod +x tmpmultilib
150
151combinations=`initial=/ ./tmpmultilib ${options}`
152
153rm -f tmpmultilib
154
e09150c7
MM
155# If there exceptions, weed them out now
156if [ -n "${exceptions}" ]; then
157 rm -f tmpmultilib2
158 cat >tmpmultilib2 <<\EOF
159#!/bin/sh
160# This recursive script weeds out any combination of multilib
161# switches that should not be generated. The output looks like
162# a list of subdirectory names with leading and trailing slashes.
163
164 for opt in $@; do
165 case "$opt" in
166EOF
167
168 for except in ${exceptions}; do
169 echo " /${except}/) : ;;" >> tmpmultilib2
170 done
171
172cat >>tmpmultilib2 <<\EOF
173 *) echo ${opt};;
174 esac
175 done
176EOF
177 chmod +x tmpmultilib2
178 combinations=`./tmpmultilib2 ${combinations}`
179 rm -f ./tmpmultilib2
180fi
181
08b28cd3
DE
182# Construct a sed pattern which will convert option names to directory
183# names.
184todirnames=
185if [ -n "${dirnames}" ]; then
186 set x ${dirnames}
187 shift
188 for set in ${options}; do
699a42a6
JJ
189 for opts in `echo ${set} | sed -e 's|/| |'g`; do
190 patt="/"
191 for opt in `echo ${opts} | sed -e 's_|_ _'g`; do
192 if [ "$1" != "${opt}" ]; then
193 todirnames="${todirnames} -e s|/${opt}/|/${1}/|g"
194 patt="${patt}${1}/"
195 if [ "${patt}" != "/${1}/" ]; then
196 todirnames="${todirnames} -e s|${patt}|/${1}/|g"
197 fi
198 fi
199 done
08b28cd3
DE
200 shift
201 done
202 done
203fi
204
08b28cd3
DE
205# We need another recursive shell script to correctly handle positive
206# matches. If we are invoked as
207# genmultilib "opt1 opt2" "" "opt1=nopt1 opt2=nopt2"
208# we must output
209# opt1/opt2 opt1 opt2
210# opt1/opt2 nopt1 opt2
211# opt1/opt2 opt1 nopt2
212# opt1/opt2 nopt1 nopt2
213# In other words, we must output all combinations of matches.
214rm -f tmpmultilib2
215cat >tmpmultilib2 <<\EOF
216#!/bin/sh
217# The positional parameters are a list of matches to consider.
218# ${dirout} is the directory name and ${optout} is the current list of
219# options.
220if [ "$#" = "0" ]; then
87e24276 221 echo "\"${dirout} ${optout};\","
08b28cd3
DE
222else
223 first=$1
224 shift
225 dirout="${dirout}" optout="${optout}" ./tmpmultilib2 $@
75814ad4
MM
226 l=`echo ${first} | sed -e 's/=.*$//' -e 's/?/=/g'`
227 r=`echo ${first} | sed -e 's/^.*=//' -e 's/?/=/g'`
eedea0f2 228 if expr " ${optout} " : ".* ${l} .*" > /dev/null; then
08b28cd3
DE
229 newopt=`echo " ${optout} " | sed -e "s/ ${l} / ${r} /" -e 's/^ //' -e 's/ $//'`
230 dirout="${dirout}" optout="${newopt}" ./tmpmultilib2 $@
eedea0f2 231 fi
08b28cd3
DE
232fi
233EOF
234chmod +x tmpmultilib2
235
08b28cd3
DE
236# Start with the current directory, which includes only negations.
237optout=
238for set in ${options}; do
699a42a6 239 for opt in `echo ${set} | sed -e 's_[/|]_ _g'`; do
08b28cd3
DE
240 optout="${optout} !${opt}"
241 done
242done
243optout=`echo ${optout} | sed -e 's/^ //'`
87e24276 244echo "\". ${optout};\","
08b28cd3
DE
245
246# Work over the list of combinations. We have to translate each one
247# to use the directory names rather than the option names, we have to
248# include the information in matches, and we have to generate the
249# correct list of options and negations.
250for combo in ${combinations}; do
251 # Use the directory names rather than the option names.
252 if [ -n "${todirnames}" ]; then
253 dirout=`echo ${combo} | sed ${todirnames}`
254 else
255 dirout=${combo}
256 fi
257 # Remove the leading and trailing slashes.
258 dirout=`echo ${dirout} | sed -e 's|^/||' -e 's|/$||g'`
259
260 # Look through the options. We must output each option that is
fb685388 261 # present, and negate each option that is not present.
08b28cd3
DE
262 optout=
263 for set in ${options}; do
699a42a6 264 setopts=`echo ${set} | sed -e 's_[/|]_ _g'`
08b28cd3 265 for opt in ${setopts}; do
eedea0f2 266 if expr "${combo} " : ".*/${opt}/.*" > /dev/null; then
08b28cd3 267 optout="${optout} ${opt}"
fb685388
RK
268 else
269 optout="${optout} !${opt}"
eedea0f2 270 fi
08b28cd3 271 done
08b28cd3
DE
272 done
273 optout=`echo ${optout} | sed -e 's/^ //'`
274
08b28cd3 275 # Output the line with all appropriate matches.
961b7009 276 dirout="${dirout}" optout="${optout}" ./tmpmultilib2
08b28cd3
DE
277done
278
87e24276
JW
279# Terminate the list of string.
280echo "NULL"
961b7009
MM
281echo "};"
282
283# Output all of the matches now as option and that is the same as that, with
31031edd 284# a semicolon trailer. Include all of the normal options as well.
961b7009
MM
285# Note, the format of the matches is reversed compared
286# to what we want, so switch them around.
287echo ""
288echo "static char *multilib_matches_raw[] = {"
289for match in ${matches}; do
290 l=`echo ${match} | sed -e 's/=.*$//' -e 's/?/=/g'`
291 r=`echo ${match} | sed -e 's/^.*=//' -e 's/?/=/g'`
292 echo "\"${r} ${l};\","
293done
294for set in ${options}; do
699a42a6 295 for opt in `echo ${set} | sed -e 's_[/|]_ _'g`; do
961b7009
MM
296 echo "\"${opt} ${opt};\","
297 done
298done
299echo "NULL"
300echo "};"
08b28cd3 301
961b7009
MM
302# Output the default options now
303echo ""
304echo "static char *multilib_extra = \"${extra}\";"
0a8d6618
BC
305
306# Output the exclusion rules now
307echo ""
308echo "static char *multilib_exclusions_raw[] = {"
309for rule in ${exclusions}; do
310 s=`echo ${rule} | sed -e 's,/, ,g'`
311 echo "\"${s};\","
312done
313echo "NULL"
314echo "};"
315
87e24276 316rm -f tmpmultilib2
08b28cd3
DE
317
318exit 0
This page took 0.741772 seconds and 5 git commands to generate.