aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSzabolcs Nagy <szabolcs.nagy@arm.com>2015-06-02 16:21:18 +0000
committerSzabolcs Nagy <nsz@gcc.gnu.org>2015-06-02 16:21:18 +0000
commitddda05980f4f5b083d77b7c35555bd9dc03592d9 (patch)
tree9a4cc46a42becaf700f1738a27b1f0817e439448
parent755afe2e51be1cae4d92b3bd3da93ea2a20fbb90 (diff)
downloadgcc-ddda05980f4f5b083d77b7c35555bd9dc03592d9.zip
gcc-ddda05980f4f5b083d77b7c35555bd9dc03592d9.tar.gz
gcc-ddda05980f4f5b083d77b7c35555bd9dc03592d9.tar.bz2
[AArch64][PR 66136] rewrite geniterators.sh in awk
2015-06-02 Szabolcs Nagy <szabolcs.nagy@arm.com> PR target/66136 * config/aarch64/geniterators.sh: Rewrite in awk. From-SVN: r224031
-rw-r--r--gcc/ChangeLog5
-rw-r--r--gcc/config/aarch64/geniterators.sh67
2 files changed, 52 insertions, 20 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index d7f1dc7..f187588 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,3 +1,8 @@
+2015-06-02 Szabolcs Nagy <szabolcs.nagy@arm.com>
+
+ PR target/66136
+ * config/aarch64/geniterators.sh: Rewrite in awk.
+
2015-06-02 Martin Liska <mliska@suse.cz>
* alloc-pool.h (pool_allocator::pool_allocator): Set implicit
diff --git a/gcc/config/aarch64/geniterators.sh b/gcc/config/aarch64/geniterators.sh
index f908e89..5a51d29 100644
--- a/gcc/config/aarch64/geniterators.sh
+++ b/gcc/config/aarch64/geniterators.sh
@@ -22,25 +22,52 @@
# Generate aarch64-builtin-iterators.h, a file containing a series of
# BUILTIN_<ITERATOR> macros, which expand to VAR<N> Macros covering the
# same set of modes as the iterator in iterators.md
-
-echo "/* -*- buffer-read-only: t -*- */"
-echo "/* Generated automatically by geniterators.sh from iterators.md. */"
-echo "#ifndef GCC_AARCH64_ITERATORS_H"
-echo "#define GCC_AARCH64_ITERATORS_H"
-
-# Strip newlines, create records marked ITERATOR, and strip junk (anything
-# which does not have a matching brace because it contains characters we
+#
+# 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).
-export LC_ALL=C
-cat $1 | tr "\n" " " \
- | sed 's/(define_mode_iterator \([A-Za-z0-9_]*\) \([]\[A-Z0-9 \t]*\)/\n#define BUILTIN_\1(T, N, MAP) \\ \2\n/g' \
- | grep '#define [A-Z0-9_(), \\]* \[[A-Z0-9[:space:]]*]' \
- | sed 's/\t//g' \
- | sed 's/ */ /g' \
- | sed 's/ \[\([A-Z0-9 ]*\)]/\n\1/' \
- | awk ' BEGIN { FS = " " ; OFS = ", "} \
- /#/ { print } \
- ! /#/ { $1 = $1 ; printf " VAR%d (T, N, MAP, %s)\n", NF, tolower($0) }'
-
-echo "#endif /* GCC_AARCH64_ITERATORS_H */"
+LC_ALL=C awk '
+BEGIN {
+ print "/* -*- buffer-read-only: t -*- */"
+ print "/* Generated automatically by geniterators.sh from iterators.md. */"
+ print "#ifndef GCC_AARCH64_ITERATORS_H"
+ print "#define GCC_AARCH64_ITERATORS_H"
+}
+
+{
+ sub(/;.*/, "")
+}
+
+iterdef {
+ s = s " " $0
+}
+
+!iterdef && /\(define_mode_iterator/ {
+ iterdef = 1
+ s = $0
+ sub(/.*\(define_mode_iterator/, "", s)
+}
+
+iterdef && s ~ /\)/ {
+ iterdef = 0
+
+ gsub(/[ \t]+/, " ", s)
+ sub(/ *\).*/, "", s)
+ sub(/^ /, "", s)
+ if (s !~ /^[A-Za-z0-9_]+ \[[A-Z0-9 ]*\]$/)
+ next
+ sub(/\[ */, "", s)
+ sub(/ *\]/, "", s)
+
+ n = split(s, a)
+ printf "#define BUILTIN_" a[1] "(T, N, MAP) \\\n"
+ printf " VAR" (n-1) " (T, N, MAP"
+ for (i = 2; i <= n; i++)
+ printf ", " tolower(a[i])
+ printf ")\n"
+}
+
+END {
+ print "#endif /* GCC_AARCH64_ITERATORS_H */"
+}' $1