gcc/ada/
[official-gcc.git] / gcc / config / aarch64 / geniterators.sh
bloba5bd69082ff18a3dc4fd8a6dba8a722443038c6a
1 #!/bin/sh
3 # Copyright (C) 2014 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 echo "/* -*- buffer-read-only: t -*- */"
27 echo "/* Generated automatically by geniterators.sh from iterators.md. */"
28 echo "#ifndef GCC_AARCH64_ITERATORS_H"
29 echo "#define GCC_AARCH64_ITERATORS_H"
31 # Strip newlines, create records marked ITERATOR, and strip junk (anything
32 # which does not have a matching brace because it contains characters we
33 # don't want to or can't handle (e.g P, PTR iterators change depending on
34 # Pmode and ptr_mode).
35 cat $1 | tr "\n" " " \
36 | sed 's/(define_mode_iterator \([A-Za-z0-9_]*\) \([]\[A-Z0-9 \t]*\)/\n#define BUILTIN_\1(T, N, MAP) \\ \2\n/g' \
37 | grep '#define [A-Z0-9_(), \\]* \[[A-Z0-9[:space:]]*]' \
38 | sed 's/\t//g' \
39 | sed 's/ \+/ /g' \
40 | sed 's/ \[\([A-Z0-9 ]*\)]/\n\L\1/' \
41 | awk ' BEGIN { FS = " " ; OFS = ", "} \
42 /#/ { print } \
43 ! /#/ { $1 = $1 ; printf " VAR%d (T, N, MAP, %s)\n", NF, $0 }'
45 echo "#endif /* GCC_AARCH64_ITERATORS_H */"