]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/genattr-common.c
[Ada] Two typo fixes
[thirdparty/gcc.git] / gcc / genattr-common.c
CommitLineData
88a00ef7
JM
1/* Generate attribute information shared between driver and core
2 compilers (insn-attr-common.h) from machine description. Split out
3 of genattr.c.
8d9254fc 4 Copyright (C) 1991-2020 Free Software Foundation, Inc.
88a00ef7
JM
5
6This file is part of GCC.
7
8GCC is free software; you can redistribute it and/or modify it under
9the terms of the GNU General Public License as published by the Free
10Software Foundation; either version 3, or (at your option) any later
11version.
12
13GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14WARRANTY; without even the implied warranty of MERCHANTABILITY or
15FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16for more details.
17
18You should have received a copy of the GNU General Public License
19along with GCC; see the file COPYING3. If not see
20<http://www.gnu.org/licenses/>. */
21
22
23#include "bconfig.h"
24#include "system.h"
25#include "coretypes.h"
26#include "tm.h"
27#include "rtl.h"
28#include "errors.h"
29#include "read-md.h"
30#include "gensupport.h"
31
c344a866
JR
32static void
33write_upcase (const char *str)
34{
35 for (; *str; str++)
c3284718 36 putchar (TOUPPER (*str));
c344a866
JR
37}
38
39static void
5d2d3e43 40gen_attr (md_rtx_info *info)
c344a866
JR
41{
42 const char *p, *tag;
43
5d2d3e43 44 rtx attr = info->def;
c344a866
JR
45 p = XSTR (attr, 1);
46 if (*p != '\0')
47 {
48 printf ("enum attr_%s {", XSTR (attr, 0));
49
50 while ((tag = scan_comma_elt (&p)) != 0)
51 {
52 write_upcase (XSTR (attr, 0));
53 putchar ('_');
54 while (tag != p)
55 putchar (TOUPPER (*tag++));
56 if (*p == ',')
57 fputs (", ", stdout);
58 }
59 fputs ("};\n", stdout);
60 }
61}
62
88a00ef7 63int
66b0fe8f 64main (int argc, const char **argv)
88a00ef7 65{
88a00ef7
JM
66 bool have_delay = false;
67 bool have_sched = false;
68
69 progname = "genattr-common";
70
71 if (!init_rtx_reader_args (argc, argv))
72 return (FATAL_EXIT_CODE);
73
74 puts ("/* Generated automatically by the program `genattr-common'");
75 puts (" from the machine description file `md'. */\n");
76 puts ("#ifndef GCC_INSN_ATTR_COMMON_H");
77 puts ("#define GCC_INSN_ATTR_COMMON_H\n");
78
79 /* Read the machine description. */
80
5d2d3e43
RS
81 md_rtx_info info;
82 while (read_md_rtx (&info))
83 switch (GET_CODE (info.def))
84 {
85 case DEFINE_ATTR:
86 gen_attr (&info);
87 break;
88a00ef7 88
5d2d3e43 89 case DEFINE_DELAY:
e90bedf5 90 have_delay = true;
88a00ef7
JM
91 break;
92
5d2d3e43
RS
93 case DEFINE_INSN_RESERVATION:
94 if (!have_sched)
95 {
96 printf ("#define INSN_SCHEDULING\n");
97 have_sched = true;
98 }
99 break;
c344a866 100
5d2d3e43
RS
101 default:
102 break;
103 }
e90bedf5
TS
104
105 printf ("#define DELAY_SLOTS %d\n", have_delay);
88a00ef7
JM
106 puts ("\n#endif /* GCC_INSN_ATTR_COMMON_H */");
107
108 if (ferror (stdout) || fflush (stdout) || fclose (stdout))
109 return FATAL_EXIT_CODE;
110
111 return SUCCESS_EXIT_CODE;
112}