]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/config/aarch64/geniterators.sh
Update copyright years.
[thirdparty/gcc.git] / gcc / config / aarch64 / geniterators.sh
CommitLineData
f421c516
JG
1#!/bin/sh
2#
7adcbafe 3# Copyright (C) 2014-2022 Free Software Foundation, Inc.
f421c516
JG
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
ddda0598 25#
7c80a459 26# Find the <ITERATOR> definitions (may span several lines).
ddda0598
SN
27LC_ALL=C awk '
28BEGIN {
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
39iterdef {
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
7c80a459
SN
49iterdef {
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
ddda0598
SN
57 iterdef = 0
58
59 gsub(/[ \t]+/, " ", s)
7c80a459 60 sub(/ *\)[^)]*$/, "", s)
ddda0598 61 sub(/^ /, "", s)
7c80a459
SN
62
63 # Drop the conditions.
64 gsub(/ *"[^"]*" *\)/, "", s)
65 gsub(/\( */, "", s)
66
66f206b8 67 if (s !~ /^[A-Za-z0-9_]+ \[[A-Za-z0-9 ]*\]$/)
ddda0598
SN
68 next
69 sub(/\[ */, "", s)
70 sub(/ *\]/, "", s)
71
72 n = split(s, a)
bf592b2f 73 printf "#define BUILTIN_" a[1] "(T, N, MAP, FLAG) \\\n"
74 printf " VAR" (n-1) " (T, N, MAP, FLAG"
ddda0598
SN
75 for (i = 2; i <= n; i++)
76 printf ", " tolower(a[i])
77 printf ")\n"
78}
79
80END {
81 print "#endif /* GCC_AARCH64_ITERATORS_H */"
82}' $1