geniterators.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #!/bin/sh
  2. #
  3. # Copyright (C) 2014-2015 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. # Generate aarch64-builtin-iterators.h, a file containing a series of
  22. # BUILTIN_<ITERATOR> macros, which expand to VAR<N> Macros covering the
  23. # same set of modes as the iterator in iterators.md
  24. #
  25. # Find the <ITERATOR> definitions (may span several lines), skip the ones
  26. # which does not have a simple format because it contains characters we
  27. # don't want to or can't handle (e.g P, PTR iterators change depending on
  28. # Pmode and ptr_mode).
  29. LC_ALL=C awk '
  30. BEGIN {
  31. print "/* -*- buffer-read-only: t -*- */"
  32. print "/* Generated automatically by geniterators.sh from iterators.md. */"
  33. print "#ifndef GCC_AARCH64_ITERATORS_H"
  34. print "#define GCC_AARCH64_ITERATORS_H"
  35. }
  36. {
  37. sub(/;.*/, "")
  38. }
  39. iterdef {
  40. s = s " " $0
  41. }
  42. !iterdef && /\(define_mode_iterator/ {
  43. iterdef = 1
  44. s = $0
  45. sub(/.*\(define_mode_iterator/, "", s)
  46. }
  47. iterdef && s ~ /\)/ {
  48. iterdef = 0
  49. gsub(/[ \t]+/, " ", s)
  50. sub(/ *\).*/, "", s)
  51. sub(/^ /, "", s)
  52. if (s !~ /^[A-Za-z0-9_]+ \[[A-Z0-9 ]*\]$/)
  53. next
  54. sub(/\[ */, "", s)
  55. sub(/ *\]/, "", s)
  56. n = split(s, a)
  57. printf "#define BUILTIN_" a[1] "(T, N, MAP) \\\n"
  58. printf " VAR" (n-1) " (T, N, MAP"
  59. for (i = 2; i <= n; i++)
  60. printf ", " tolower(a[i])
  61. printf ")\n"
  62. }
  63. END {
  64. print "#endif /* GCC_AARCH64_ITERATORS_H */"
  65. }' $1