gencheck.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* Generate check macros for tree codes.
  2. Copyright (C) 1998-2015 Free Software Foundation, Inc.
  3. This file is part of GCC.
  4. GCC is free software; you can redistribute it and/or modify it under
  5. the terms of the GNU General Public License as published by the Free
  6. Software Foundation; either version 3, or (at your option) any later
  7. version.
  8. GCC is distributed in the hope that it will be useful, but WITHOUT ANY
  9. WARRANTY; without even the implied warranty of MERCHANTABILITY or
  10. FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  11. for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GCC; see the file COPYING3. If not see
  14. <http://www.gnu.org/licenses/>. */
  15. /* We don't have insn-modes.h, but we include tm.h. */
  16. #define BITS_PER_UNIT 8
  17. #include "bconfig.h"
  18. #include "system.h"
  19. #include "coretypes.h"
  20. #include "tm.h"
  21. #define DEFTREECODE(SYM, NAME, TYPE, LEN) #SYM,
  22. #define END_OF_BASE_TREE_CODES
  23. static const char *const tree_codes[] = {
  24. #include "all-tree.def"
  25. (char*) 0
  26. };
  27. #undef DEFTREECODE
  28. #undef END_OF_BASE_TREE_CODES
  29. static void usage (void);
  30. static void
  31. usage (void)
  32. {
  33. fputs ("Usage: gencheck\n", stderr);
  34. }
  35. int
  36. main (int argc, char ** ARG_UNUSED (argv))
  37. {
  38. int i, j;
  39. switch (argc)
  40. {
  41. case 1:
  42. break;
  43. default:
  44. usage ();
  45. return (1);
  46. }
  47. puts ("/* This file is generated using gencheck. Do not edit. */\n");
  48. puts ("#ifndef GCC_TREE_CHECK_H");
  49. puts ("#define GCC_TREE_CHECK_H\n");
  50. /* Print macros for checks based on each of the tree code names. However,
  51. since we include the tree nodes from all languages, we must check
  52. for duplicate names to avoid defining the same macro twice. */
  53. for (i = 0; tree_codes[i]; i++)
  54. {
  55. for (j = 0; j < i; j++)
  56. if (strcmp (tree_codes[i], tree_codes[j]) == 0)
  57. break;
  58. if (i == j)
  59. printf ("#define %s_CHECK(t)\tTREE_CHECK (t, %s)\n",
  60. tree_codes[i], tree_codes[i]);
  61. }
  62. puts ("\n#endif /* GCC_TREE_CHECK_H */");
  63. return 0;
  64. }