gcc/
authorYvan Roux <yvan.roux@linaro.org>
Fri, 2 Sep 2016 07:59:58 +0000 (09:59 +0200)
committerYvan Roux <yvan.roux@linaro.org>
Wed, 7 Sep 2016 20:08:26 +0000 (22:08 +0200)
Backport from trunk r237548.
2016-06-17  Szabolcs Nagy  <szabolcs.nagy@arm.com>

* config/aarch64/geniterators.sh: Handle parenthesised conditions.

Change-Id: I3eb6902dd41933cd2f41d1740f84f63a1921e0b2

gcc/config/aarch64/geniterators.sh

index ec1b1ea..8baa244 100644 (file)
 # BUILTIN_<ITERATOR> macros, which expand to VAR<N> Macros covering the
 # same set of modes as the iterator in iterators.md
 #
-# Find the <ITERATOR> definitions (may span several lines), skip the ones
-# which does not have a simple format because it contains characters we
-# don't want to or can't handle (e.g P, PTR iterators change depending on
-# Pmode and ptr_mode).
+# Find the <ITERATOR> definitions (may span several lines).
 LC_ALL=C awk '
 BEGIN {
        print "/* -*- buffer-read-only: t -*- */"
@@ -49,12 +46,24 @@ iterdef {
        sub(/.*\(define_mode_iterator/, "", s)
 }
 
-iterdef && s ~ /\)/ {
+iterdef {
+       # Count the parentheses, the iterator definition ends
+       # if there are more closing ones than opening ones.
+       nopen = gsub(/\(/, "(", s)
+       nclose = gsub(/\)/, ")", s)
+       if (nopen >= nclose)
+               next
+
        iterdef = 0
 
        gsub(/[ \t]+/, " ", s)
-       sub(/ *\).*/, "", s)
+       sub(/ *\)[^)]*$/, "", s)
        sub(/^ /, "", s)
+
+       # Drop the conditions.
+       gsub(/ *"[^"]*" *\)/, "", s)
+       gsub(/\( */, "", s)
+
        if (s !~ /^[A-Za-z0-9_]+ \[[A-Z0-9 ]*\]$/)
                next
        sub(/\[ */, "", s)