OSDN Git Service

libgo: Define CC_FOR_BUILD in Makefile.
[pf3gnuchains/gcc-fork.git] / gcc / genattr-common.c
1 /* Generate attribute information shared between driver and core
2    compilers (insn-attr-common.h) from machine description.  Split out
3    of genattr.c.
4    Copyright (C) 1991, 1994, 1996, 1998, 1999, 2000, 2003, 2004, 2007, 2008,
5    2010, 2011  Free Software Foundation, Inc.
6
7 This file is part of GCC.
8
9 GCC is free software; you can redistribute it and/or modify it under
10 the terms of the GNU General Public License as published by the Free
11 Software Foundation; either version 3, or (at your option) any later
12 version.
13
14 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
15 WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
17 for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with GCC; see the file COPYING3.  If not see
21 <http://www.gnu.org/licenses/>.  */
22
23
24 #include "bconfig.h"
25 #include "system.h"
26 #include "coretypes.h"
27 #include "tm.h"
28 #include "rtl.h"
29 #include "errors.h"
30 #include "read-md.h"
31 #include "gensupport.h"
32
33 int
34 main (int argc, char **argv)
35 {
36   rtx desc;
37   bool have_delay = false;
38   bool have_sched = false;
39
40   progname = "genattr-common";
41
42   if (!init_rtx_reader_args (argc, argv))
43     return (FATAL_EXIT_CODE);
44
45   puts ("/* Generated automatically by the program `genattr-common'");
46   puts ("   from the machine description file `md'.  */\n");
47   puts ("#ifndef GCC_INSN_ATTR_COMMON_H");
48   puts ("#define GCC_INSN_ATTR_COMMON_H\n");
49
50   /* Read the machine description.  */
51
52   while (1)
53     {
54       int line_no, insn_code_number;
55
56       desc = read_md_rtx (&line_no, &insn_code_number);
57       if (desc == NULL)
58         break;
59
60       if (GET_CODE (desc) == DEFINE_DELAY)
61         {
62           if (!have_delay)
63             {
64               printf ("#define DELAY_SLOTS\n");
65               have_delay = true;
66             }
67         }
68       else if (GET_CODE (desc) == DEFINE_INSN_RESERVATION)
69         {
70           if (!have_sched)
71             {
72               printf ("#define INSN_SCHEDULING\n");
73               have_sched = true;
74             }
75         }
76     }
77   puts ("\n#endif /* GCC_INSN_ATTR_COMMON_H */");
78
79   if (ferror (stdout) || fflush (stdout) || fclose (stdout))
80     return FATAL_EXIT_CODE;
81
82   return SUCCESS_EXIT_CODE;
83 }