| 1 |
#!/bin/sh |
| 2 |
# |
| 3 |
# Copyright (C) 2014-2025 Free Software Foundation, Inc. |
| 4 |
# Contributed by ARM Ltd. |
| 5 |
# |
| 6 |
# This file is part of GCC. |
| 7 |
# |
| 8 |
# GCC is free software; you can redistribute it and/or modify |
| 9 |
# it under the terms of the GNU General Public License as published by |
| 10 |
# the Free Software Foundation; either version 3, or (at your option) |
| 11 |
# any later version. |
| 12 |
# |
| 13 |
# GCC is distributed in the hope that it will be useful, |
| 14 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
# GNU General Public License for more details. |
| 17 |
# |
| 18 |
# You should have received a copy of the GNU General Public License |
| 19 |
# along with GCC; see the file COPYING3. If not see |
| 20 |
# <http://www.gnu.org/licenses/>. |
| 21 |
|
| 22 |
# Generate aarch64-builtin-iterators.h, a file containing a series of |
| 23 |
# BUILTIN_<ITERATOR> macros, which expand to VAR<N> Macros covering the |
| 24 |
# same set of modes as the iterator in iterators.md |
| 25 |
# |
| 26 |
# Find the <ITERATOR> definitions (may span several lines). |
| 27 |
LC_ALL=C awk ' |
| 28 |
BEGIN { |
| 29 |
print "/* -*- buffer-read-only: t -*- */" |
| 30 |
print "/* Generated automatically by geniterators.sh from iterators.md. */" |
| 31 |
print "#ifndef GCC_AARCH64_ITERATORS_H" |
| 32 |
print "#define GCC_AARCH64_ITERATORS_H" |
| 33 |
} |
| 34 |
|
| 35 |
{ |
| 36 |
sub(/;.*/, "") |
| 37 |
} |
| 38 |
|
| 39 |
iterdef { |
| 40 |
s = s " " $0 |
| 41 |
} |
| 42 |
|
| 43 |
!iterdef && /\(define_mode_iterator/ { |
| 44 |
iterdef = 1 |
| 45 |
s = $0 |
| 46 |
sub(/.*\(define_mode_iterator/, "", s) |
| 47 |
} |
| 48 |
|
| 49 |
iterdef { |
| 50 |
# Count the parentheses, the iterator definition ends |
| 51 |
# if there are more closing ones than opening ones. |
| 52 |
nopen = gsub(/\(/, "(", s) |
| 53 |
nclose = gsub(/\)/, ")", s) |
| 54 |
if (nopen >= nclose) |
| 55 |
next |
| 56 |
|
| 57 |
iterdef = 0 |
| 58 |
|
| 59 |
gsub(/[ \t]+/, " ", s) |
| 60 |
sub(/ *\)[^)]*$/, "", s) |
| 61 |
sub(/^ /, "", s) |
| 62 |
|
| 63 |
# Drop the conditions. |
| 64 |
gsub(/ *"[^"]*" *\)/, "", s) |
| 65 |
gsub(/\( */, "", s) |
| 66 |
|
| 67 |
if (s !~ /^[A-Za-z0-9_]+ \[[A-Za-z0-9 ]*\]$/) |
| 68 |
next |
| 69 |
sub(/\[ */, "", s) |
| 70 |
sub(/ *\]/, "", s) |
| 71 |
|
| 72 |
n = split(s, a) |
| 73 |
printf "#define BUILTIN_" a[1] "(T, N, MAP, FLAG) \\\n" |
| 74 |
printf " VAR" (n-1) " (T, N, MAP, FLAG" |
| 75 |
for (i = 2; i <= n; i++) |
| 76 |
printf ", " tolower(a[i]) |
| 77 |
printf ")\n" |
| 78 |
} |
| 79 |
|
| 80 |
END { |
| 81 |
print "#endif /* GCC_AARCH64_ITERATORS_H */" |
| 82 |
}' $1 |