[committed] [RISC-V] Fix wrong patch application
[official-gcc.git] / gcc / config / aarch64 / geniterators.sh
blob7cc70a7a5fa2692ed5c1902cf1143f9ddbe58e8d
1 #!/bin/sh
3 # Copyright (C) 2014-2024 Free Software Foundation, Inc.
4 # Contributed by ARM Ltd.
6 # This file is part of GCC.
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.
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.
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/>.
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
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"
36 sub(/;.*/, "")
39 iterdef {
40 s = s " " $0
43 !iterdef && /\(define_mode_iterator/ {
44 iterdef = 1
45 s = $0
46 sub(/.*\(define_mode_iterator/, "", s)
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
57 iterdef = 0
59 gsub(/[ \t]+/, " ", s)
60 sub(/ *\)[^)]*$/, "", s)
61 sub(/^ /, "", s)
63 # Drop the conditions.
64 gsub(/ *"[^"]*" *\)/, "", s)
65 gsub(/\( */, "", s)
67 if (s !~ /^[A-Za-z0-9_]+ \[[A-Za-z0-9 ]*\]$/)
68 next
69 sub(/\[ */, "", s)
70 sub(/ *\]/, "", s)
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"
80 END {
81 print "#endif /* GCC_AARCH64_ITERATORS_H */"
82 }' $1