Commit 3644cadf by Tamar Christina Committed by Tamar Christina

AArch64: Make processing less fragile in config.gcc

Due to config.gcc all the options need to be on one line because of the grep
lines which would select only the first line of the option.

This causes it not to select the right bits on options that are spread over
multiple lines when the --with-arch configure option is used.  The issue happens
silently and you just get a compiler with an incorrect set of default flags.

The current rules are quite rigid:

   1) No space between the AARCH64_OPT_EXTENSION and the opening (.
   2) No space between the opening ( and the extension name.
   3) No space after the extension name before the ,.
   4) Spaces are only allowed after a , and around |.

This patch makes this a lot less fragile by using the C pre-processor to flatten
the list and then provides much more flexible regex using group matching to
process the options instead of string replacement.  This removes all the
restrictions above and makes the code a bit more readable.

gcc/ChangeLog:

	PR target/89517
	* config.gcc: Relax parsing of AARCH64_OPT_EXTENSION.
	* config/aarch64/aarch64-option-extensions.def: Add new comments
	and restore easier to read options.

From-SVN: r273827
parent 8f5331b2
2019-07-26 Tamar Christina <tamar.christina@arm.com>
PR target/89517
* config.gcc: Relax parsing of AARCH64_OPT_EXTENSION.
* config/aarch64/aarch64-option-extensions.def: Add new comments
and restore easier to read options.
2019-07-26 Tamar Christina <tamar.christina@arm.com>
* convert.c (convert_to_real_1): Move part of conversion code...
* match.pd: ...To here.
......
......@@ -3902,32 +3902,40 @@ case "${target}" in
sed -e 's/,.*$//'`
fi
# Use the pre-processor to strip flatten the options.
# This makes the format less rigid than if we use
# grep and sed directly here.
opt_macro="AARCH64_OPT_EXTENSION(A, B, C, D, E, F)=A, B, C, D, E, F"
options_parsed="`$ac_cv_prog_CPP -D"$opt_macro" -x c \
${srcdir}/config/aarch64/aarch64-option-extensions.def`"
# Match one element inside AARCH64_OPT_EXTENSION, we
# consume anything that's not a ,.
elem="[ ]*\([^,]\+\)[ ]*"
# Repeat the pattern for the number of entries in the
# AARCH64_OPT_EXTENSION, currently 6 times.
sed_patt="^$elem,$elem,$elem,$elem,$elem,$elem"
while [ x"$ext_val" != x ]
do
ext_val=`echo $ext_val | sed -e 's/\+//'`
ext=`echo $ext_val | sed -e 's/\+.*//'`
base_ext=`echo $ext | sed -e 's/^no//'`
opt_line=`echo -e "$options_parsed" | \
grep "^\"$base_ext\""`
if [ x"$base_ext" = x ] \
|| grep "^AARCH64_OPT_EXTENSION(\"$base_ext\"," \
${srcdir}/config/aarch64/aarch64-option-extensions.def \
> /dev/null; then
ext_canon=`grep "^AARCH64_OPT_EXTENSION(\"$base_ext\"," \
${srcdir}/config/aarch64/aarch64-option-extensions.def | \
sed -e 's/^[^,]*,[ ]*//' | \
sed -e 's/,.*$//'`
ext_on=`grep "^AARCH64_OPT_EXTENSION(\"$base_ext\"," \
${srcdir}/config/aarch64/aarch64-option-extensions.def | \
sed -e 's/^[^,]*,[ ]*[^,]*,[ ]*//' | \
sed -e 's/,.*$//' | \
sed -e 's/).*$//'`
ext_off=`grep "^AARCH64_OPT_EXTENSION(\"$base_ext\"," \
${srcdir}/config/aarch64/aarch64-option-extensions.def | \
sed -e 's/^[^,]*,[ ]*[^,]*,[ ]*[^,]*,[ ]*//' | \
sed -e 's/,.*$//' | \
sed -e 's/).*$//'`
|| [[ -n $opt_line ]]; then
# These regexp extract the elements based on
# their group match index in the regexp.
ext_canon=`echo -e "$opt_line" | \
sed -e "s/$sed_patt/\2/"`
ext_on=`echo -e "$opt_line" | \
sed -e "s/$sed_patt/\3/"`
ext_off=`echo -e "$opt_line" | \
sed -e "s/$sed_patt/\4/"`
if [ $ext = $base_ext ]; then
# Adding extension
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment