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