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