annotate gcc/read-md.h @ 138:fc828634a951

merge
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 08 Nov 2018 14:17:14 +0900
parents 84e7813d76e9
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* MD reader definitions.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2 Copyright (C) 1987-2018 Free Software Foundation, Inc.
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 This file is part of GCC.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 GCC is free software; you can redistribute it and/or modify it under
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 the terms of the GNU General Public License as published by the Free
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 Software Foundation; either version 3, or (at your option) any later
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 version.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 for more details.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 along with GCC; see the file COPYING3. If not see
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
111
kono
parents: 68
diff changeset
20 #ifndef GCC_READ_MD_H
kono
parents: 68
diff changeset
21 #define GCC_READ_MD_H
kono
parents: 68
diff changeset
22
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #include "obstack.h"
111
kono
parents: 68
diff changeset
24
kono
parents: 68
diff changeset
25 /* Records a position in the file. */
kono
parents: 68
diff changeset
26 struct file_location {
kono
parents: 68
diff changeset
27 file_location () {}
kono
parents: 68
diff changeset
28 file_location (const char *, int, int);
kono
parents: 68
diff changeset
29
kono
parents: 68
diff changeset
30 const char *filename;
kono
parents: 68
diff changeset
31 int lineno;
kono
parents: 68
diff changeset
32 int colno;
kono
parents: 68
diff changeset
33 };
kono
parents: 68
diff changeset
34
kono
parents: 68
diff changeset
35 inline file_location::file_location (const char *filename_in, int lineno_in, int colno_in)
kono
parents: 68
diff changeset
36 : filename (filename_in), lineno (lineno_in), colno (colno_in) {}
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38 /* Holds one symbol or number in the .md file. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
39 struct md_name {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
40 /* The name as it appeared in the .md file. Names are syntactically
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 limited to the length of this buffer. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42 char buffer[256];
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
43
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
44 /* The name that should actually be used by the generator programs.
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 This is an expansion of NAME, after things like constant substitution. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 char *string;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 };
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 /* This structure represents a constant defined by define_constant,
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 define_enum, or such-like. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51 struct md_constant {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 /* The name of the constant. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
53 char *name;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 /* The string to which the constants expands. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 char *value;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58 /* If the constant is associated with a enumeration, this field
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 points to that enumeration, otherwise it is null. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 struct enum_type *parent_enum;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61 };
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 /* This structure represents one value in an enum_type. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
64 struct enum_value {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
65 /* The next value in the enum, or null if this is the last. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 struct enum_value *next;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 /* The name of the value as it appears in the .md file. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 char *name;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71 /* The definition of the related C value. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 struct md_constant *def;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 };
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 /* This structure represents an enum defined by define_enum or the like. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76 struct enum_type {
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
77 /* The C name of the enumeration. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
78 char *name;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
79
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 /* True if this is an md-style enum (DEFINE_ENUM) rather than
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 a C-style enum (DEFINE_C_ENUM). */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82 bool md_p;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
83
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
84 /* The values of the enumeration. There is always at least one. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
85 struct enum_value *values;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
86
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
87 /* A pointer to the null terminator in VALUES. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
88 struct enum_value **tail_ptr;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90 /* The number of enumeration values. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
91 unsigned int num_values;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
92 };
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
93
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
94 /* Describes one instance of an overloaded_name. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
95 struct overloaded_instance {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
96 /* The next instance in the chain, or null if none. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
97 overloaded_instance *next;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
98
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
99 /* The values that the overloaded_name arguments should have for this
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
100 instance to be chosen. Each value is a C token. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
101 vec<const char *> arg_values;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
102
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
103 /* The full (non-overloaded) name of the pattern. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
104 const char *name;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
105
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
106 /* The corresponding define_expand or define_insn. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
107 rtx insn;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
108 };
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
109
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
110 /* Describes a define_expand or define_insn whose name was preceded by '@'.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
111 Overloads are uniquely determined by their name and the types of their
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
112 arguments; it's possible to have overloads with the same name but
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
113 different argument types. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
114 struct overloaded_name {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
115 /* The next overloaded name in the chain. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
116 overloaded_name *next;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
117
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
118 /* The overloaded name (i.e. the name with "@" character and
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
119 "<...>" placeholders removed). */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
120 const char *name;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
121
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
122 /* The C types of the iterators that determine the underlying pattern,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
123 in the same order as in the pattern name. E.g. "<mode>" in the
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
124 pattern name would give a "machine_mode" argument here. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
125 vec<const char *> arg_types;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
126
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
127 /* The first instance associated with this overloaded_name. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
128 overloaded_instance *first_instance;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
129
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
130 /* Where to chain new overloaded_instances. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
131 overloaded_instance **next_instance_ptr;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
132 };
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
133
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
134 struct mapping;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
135
111
kono
parents: 68
diff changeset
136 /* A class for reading .md files and RTL dump files.
kono
parents: 68
diff changeset
137
kono
parents: 68
diff changeset
138 Implemented in read-md.c.
kono
parents: 68
diff changeset
139
kono
parents: 68
diff changeset
140 This class has responsibility for reading chars from input files, and
kono
parents: 68
diff changeset
141 for certain common top-level directives including the "include"
kono
parents: 68
diff changeset
142 directive.
kono
parents: 68
diff changeset
143
kono
parents: 68
diff changeset
144 It does not handle parsing the hierarchically-nested expressions of
kono
parents: 68
diff changeset
145 rtl.def; for that see the rtx_reader subclass below (implemented in
kono
parents: 68
diff changeset
146 read-rtl.c). */
kono
parents: 68
diff changeset
147
kono
parents: 68
diff changeset
148 class md_reader
kono
parents: 68
diff changeset
149 {
kono
parents: 68
diff changeset
150 public:
kono
parents: 68
diff changeset
151 md_reader (bool compact);
kono
parents: 68
diff changeset
152 virtual ~md_reader ();
kono
parents: 68
diff changeset
153
kono
parents: 68
diff changeset
154 bool read_md_files (int, const char **, bool (*) (const char *));
kono
parents: 68
diff changeset
155 bool read_file (const char *filename);
kono
parents: 68
diff changeset
156 bool read_file_fragment (const char *filename,
kono
parents: 68
diff changeset
157 int first_line,
kono
parents: 68
diff changeset
158 int last_line);
kono
parents: 68
diff changeset
159
kono
parents: 68
diff changeset
160 /* A hook that handles a single .md-file directive, up to but not
kono
parents: 68
diff changeset
161 including the closing ')'. It takes two arguments: the file position
kono
parents: 68
diff changeset
162 at which the directive started, and the name of the directive. The next
kono
parents: 68
diff changeset
163 unread character is the optional space after the directive name. */
kono
parents: 68
diff changeset
164 virtual void handle_unknown_directive (file_location, const char *) = 0;
kono
parents: 68
diff changeset
165
kono
parents: 68
diff changeset
166 file_location get_current_location () const;
kono
parents: 68
diff changeset
167
kono
parents: 68
diff changeset
168 bool is_compact () const { return m_compact; }
kono
parents: 68
diff changeset
169
kono
parents: 68
diff changeset
170 /* Defined in read-md.c. */
kono
parents: 68
diff changeset
171 int read_char (void);
kono
parents: 68
diff changeset
172 void unread_char (int ch);
kono
parents: 68
diff changeset
173 file_location read_name (struct md_name *name);
kono
parents: 68
diff changeset
174 file_location read_name_or_nil (struct md_name *);
kono
parents: 68
diff changeset
175 void read_escape ();
kono
parents: 68
diff changeset
176 char *read_quoted_string ();
kono
parents: 68
diff changeset
177 char *read_braced_string ();
kono
parents: 68
diff changeset
178 char *read_string (int star_if_braced);
kono
parents: 68
diff changeset
179 void read_skip_construct (int depth, file_location loc);
kono
parents: 68
diff changeset
180 void require_char (char expected);
kono
parents: 68
diff changeset
181 void require_char_ws (char expected);
kono
parents: 68
diff changeset
182 void require_word_ws (const char *expected);
kono
parents: 68
diff changeset
183 int peek_char (void);
kono
parents: 68
diff changeset
184
kono
parents: 68
diff changeset
185 void set_md_ptr_loc (const void *ptr, const char *filename, int lineno);
kono
parents: 68
diff changeset
186 const struct ptr_loc *get_md_ptr_loc (const void *ptr);
kono
parents: 68
diff changeset
187 void copy_md_ptr_loc (const void *new_ptr, const void *old_ptr);
kono
parents: 68
diff changeset
188 void fprint_md_ptr_loc (FILE *outf, const void *ptr);
kono
parents: 68
diff changeset
189 void print_md_ptr_loc (const void *ptr);
kono
parents: 68
diff changeset
190
kono
parents: 68
diff changeset
191 struct enum_type *lookup_enum_type (const char *name);
kono
parents: 68
diff changeset
192 void traverse_enum_types (htab_trav callback, void *info);
kono
parents: 68
diff changeset
193
kono
parents: 68
diff changeset
194 void handle_constants ();
kono
parents: 68
diff changeset
195 void traverse_md_constants (htab_trav callback, void *info);
kono
parents: 68
diff changeset
196 void handle_enum (file_location loc, bool md_p);
kono
parents: 68
diff changeset
197
kono
parents: 68
diff changeset
198 const char *join_c_conditions (const char *cond1, const char *cond2);
kono
parents: 68
diff changeset
199 void fprint_c_condition (FILE *outf, const char *cond);
kono
parents: 68
diff changeset
200 void print_c_condition (const char *cond);
kono
parents: 68
diff changeset
201
kono
parents: 68
diff changeset
202 /* Defined in read-rtl.c. */
kono
parents: 68
diff changeset
203 const char *apply_iterator_to_string (const char *string);
kono
parents: 68
diff changeset
204 rtx copy_rtx_for_iterators (rtx original);
kono
parents: 68
diff changeset
205 void read_conditions ();
kono
parents: 68
diff changeset
206 void record_potential_iterator_use (struct iterator_group *group,
kono
parents: 68
diff changeset
207 rtx x, unsigned int index,
kono
parents: 68
diff changeset
208 const char *name);
kono
parents: 68
diff changeset
209 struct mapping *read_mapping (struct iterator_group *group, htab_t table);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
210 overloaded_name *handle_overloaded_name (rtx, vec<mapping *> *);
111
kono
parents: 68
diff changeset
211
kono
parents: 68
diff changeset
212 const char *get_top_level_filename () const { return m_toplevel_fname; }
kono
parents: 68
diff changeset
213 const char *get_filename () const { return m_read_md_filename; }
kono
parents: 68
diff changeset
214 int get_lineno () const { return m_read_md_lineno; }
kono
parents: 68
diff changeset
215 int get_colno () const { return m_read_md_colno; }
kono
parents: 68
diff changeset
216
kono
parents: 68
diff changeset
217 struct obstack *get_string_obstack () { return &m_string_obstack; }
kono
parents: 68
diff changeset
218 htab_t get_md_constants () { return m_md_constants; }
kono
parents: 68
diff changeset
219
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
220 overloaded_name *get_overloads () const { return m_first_overload; }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
221
111
kono
parents: 68
diff changeset
222 private:
kono
parents: 68
diff changeset
223 /* A singly-linked list of filenames. */
kono
parents: 68
diff changeset
224 struct file_name_list {
kono
parents: 68
diff changeset
225 struct file_name_list *next;
kono
parents: 68
diff changeset
226 const char *fname;
kono
parents: 68
diff changeset
227 };
kono
parents: 68
diff changeset
228
kono
parents: 68
diff changeset
229 private:
kono
parents: 68
diff changeset
230 void handle_file ();
kono
parents: 68
diff changeset
231 void handle_toplevel_file ();
kono
parents: 68
diff changeset
232 void handle_include (file_location loc);
kono
parents: 68
diff changeset
233 void add_include_path (const char *arg);
kono
parents: 68
diff changeset
234
kono
parents: 68
diff changeset
235 bool read_name_1 (struct md_name *name, file_location *out_loc);
kono
parents: 68
diff changeset
236
kono
parents: 68
diff changeset
237 private:
kono
parents: 68
diff changeset
238 /* Are we reading a compact dump? */
kono
parents: 68
diff changeset
239 bool m_compact;
kono
parents: 68
diff changeset
240
kono
parents: 68
diff changeset
241 /* The name of the toplevel file that indirectly included
kono
parents: 68
diff changeset
242 m_read_md_file. */
kono
parents: 68
diff changeset
243 const char *m_toplevel_fname;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
244
111
kono
parents: 68
diff changeset
245 /* The directory part of m_toplevel_fname
kono
parents: 68
diff changeset
246 NULL if m_toplevel_fname is a bare filename. */
kono
parents: 68
diff changeset
247 char *m_base_dir;
kono
parents: 68
diff changeset
248
kono
parents: 68
diff changeset
249 /* The file we are reading. */
kono
parents: 68
diff changeset
250 FILE *m_read_md_file;
kono
parents: 68
diff changeset
251
kono
parents: 68
diff changeset
252 /* The filename of m_read_md_file. */
kono
parents: 68
diff changeset
253 const char *m_read_md_filename;
kono
parents: 68
diff changeset
254
kono
parents: 68
diff changeset
255 /* The current line number in m_read_md_file. */
kono
parents: 68
diff changeset
256 int m_read_md_lineno;
kono
parents: 68
diff changeset
257
kono
parents: 68
diff changeset
258 /* The current column number in m_read_md_file. */
kono
parents: 68
diff changeset
259 int m_read_md_colno;
kono
parents: 68
diff changeset
260
kono
parents: 68
diff changeset
261 /* The column number before the last newline, so that
kono
parents: 68
diff changeset
262 we can handle unread_char ('\n') at least once whilst
kono
parents: 68
diff changeset
263 retaining column information. */
kono
parents: 68
diff changeset
264 int m_last_line_colno;
kono
parents: 68
diff changeset
265
kono
parents: 68
diff changeset
266 /* The first directory to search. */
kono
parents: 68
diff changeset
267 file_name_list *m_first_dir_md_include;
kono
parents: 68
diff changeset
268
kono
parents: 68
diff changeset
269 /* A pointer to the null terminator of the md include chain. */
kono
parents: 68
diff changeset
270 file_name_list **m_last_dir_md_include_ptr;
kono
parents: 68
diff changeset
271
kono
parents: 68
diff changeset
272 /* Obstack used for allocating MD strings. */
kono
parents: 68
diff changeset
273 struct obstack m_string_obstack;
kono
parents: 68
diff changeset
274
kono
parents: 68
diff changeset
275 /* A table of ptr_locs, hashed on the PTR field. */
kono
parents: 68
diff changeset
276 htab_t m_ptr_locs;
kono
parents: 68
diff changeset
277
kono
parents: 68
diff changeset
278 /* An obstack for the above. Plain xmalloc is a bit heavyweight for a
kono
parents: 68
diff changeset
279 small structure like ptr_loc. */
kono
parents: 68
diff changeset
280 struct obstack m_ptr_loc_obstack;
kono
parents: 68
diff changeset
281
kono
parents: 68
diff changeset
282 /* A hash table of triples (A, B, C), where each of A, B and C is a condition
kono
parents: 68
diff changeset
283 and A is equivalent to "B && C". This is used to keep track of the source
kono
parents: 68
diff changeset
284 of conditions that are made up of separate MD strings (such as the split
kono
parents: 68
diff changeset
285 condition of a define_insn_and_split). */
kono
parents: 68
diff changeset
286 htab_t m_joined_conditions;
kono
parents: 68
diff changeset
287
kono
parents: 68
diff changeset
288 /* An obstack for allocating joined_conditions entries. */
kono
parents: 68
diff changeset
289 struct obstack m_joined_conditions_obstack;
kono
parents: 68
diff changeset
290
kono
parents: 68
diff changeset
291 /* A table of md_constant structures, hashed by name. Null if no
kono
parents: 68
diff changeset
292 constant expansion should occur. */
kono
parents: 68
diff changeset
293 htab_t m_md_constants;
kono
parents: 68
diff changeset
294
kono
parents: 68
diff changeset
295 /* A table of enum_type structures, hashed by name. */
kono
parents: 68
diff changeset
296 htab_t m_enum_types;
kono
parents: 68
diff changeset
297
kono
parents: 68
diff changeset
298 /* If non-zero, filter the input to just this subset of lines. */
kono
parents: 68
diff changeset
299 int m_first_line;
kono
parents: 68
diff changeset
300 int m_last_line;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
301
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
302 /* The first overloaded_name. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
303 overloaded_name *m_first_overload;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
304
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
305 /* Where to chain further overloaded_names, */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
306 overloaded_name **m_next_overload_ptr;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
307
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
308 /* A hash table of overloaded_names, keyed off their name and the types of
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
309 their arguments. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
310 htab_t m_overloads_htab;
111
kono
parents: 68
diff changeset
311 };
kono
parents: 68
diff changeset
312
kono
parents: 68
diff changeset
313 /* Global singleton; constrast with rtx_reader_ptr below. */
kono
parents: 68
diff changeset
314 extern md_reader *md_reader_ptr;
kono
parents: 68
diff changeset
315
kono
parents: 68
diff changeset
316 /* An md_reader subclass which skips unknown directives, for
kono
parents: 68
diff changeset
317 the gen* tools that purely use read-md.o. */
kono
parents: 68
diff changeset
318
kono
parents: 68
diff changeset
319 class noop_reader : public md_reader
kono
parents: 68
diff changeset
320 {
kono
parents: 68
diff changeset
321 public:
kono
parents: 68
diff changeset
322 noop_reader () : md_reader (false) {}
kono
parents: 68
diff changeset
323
kono
parents: 68
diff changeset
324 /* A dummy implementation which skips unknown directives. */
kono
parents: 68
diff changeset
325 void handle_unknown_directive (file_location, const char *);
kono
parents: 68
diff changeset
326 };
kono
parents: 68
diff changeset
327
kono
parents: 68
diff changeset
328 /* An md_reader subclass that actually handles full hierarchical
kono
parents: 68
diff changeset
329 rtx expressions.
kono
parents: 68
diff changeset
330
kono
parents: 68
diff changeset
331 Implemented in read-rtl.c. */
kono
parents: 68
diff changeset
332
kono
parents: 68
diff changeset
333 class rtx_reader : public md_reader
kono
parents: 68
diff changeset
334 {
kono
parents: 68
diff changeset
335 public:
kono
parents: 68
diff changeset
336 rtx_reader (bool compact);
kono
parents: 68
diff changeset
337 ~rtx_reader ();
kono
parents: 68
diff changeset
338
kono
parents: 68
diff changeset
339 bool read_rtx (const char *rtx_name, vec<rtx> *rtxen);
kono
parents: 68
diff changeset
340 rtx read_rtx_code (const char *code_name);
kono
parents: 68
diff changeset
341 virtual rtx read_rtx_operand (rtx return_rtx, int idx);
kono
parents: 68
diff changeset
342 rtx read_nested_rtx ();
kono
parents: 68
diff changeset
343 rtx read_rtx_variadic (rtx form);
kono
parents: 68
diff changeset
344 char *read_until (const char *terminator_chars, bool consume_terminator);
kono
parents: 68
diff changeset
345
kono
parents: 68
diff changeset
346 virtual void handle_any_trailing_information (rtx) {}
kono
parents: 68
diff changeset
347 virtual rtx postprocess (rtx x) { return x; }
kono
parents: 68
diff changeset
348
kono
parents: 68
diff changeset
349 /* Hook to allow function_reader subclass to put STRINGBUF into gc-managed
kono
parents: 68
diff changeset
350 memory, rather than within an obstack.
kono
parents: 68
diff changeset
351 This base class implementation is a no-op. */
kono
parents: 68
diff changeset
352 virtual const char *finalize_string (char *stringbuf) { return stringbuf; }
kono
parents: 68
diff changeset
353
kono
parents: 68
diff changeset
354 protected:
kono
parents: 68
diff changeset
355 /* Analogous to rtx_writer's m_in_call_function_usage. */
kono
parents: 68
diff changeset
356 bool m_in_call_function_usage;
kono
parents: 68
diff changeset
357
kono
parents: 68
diff changeset
358 /* Support for "reuse_rtx" directives. */
kono
parents: 68
diff changeset
359 auto_vec<rtx> m_reuse_rtx_by_id;
kono
parents: 68
diff changeset
360 };
kono
parents: 68
diff changeset
361
kono
parents: 68
diff changeset
362 /* Global singleton; constrast with md_reader_ptr above. */
kono
parents: 68
diff changeset
363 extern rtx_reader *rtx_reader_ptr;
kono
parents: 68
diff changeset
364
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
365 extern void (*include_callback) (const char *);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
366
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
367 /* Read the next character from the MD file. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
368
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
369 static inline int
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
370 read_char (void)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 {
111
kono
parents: 68
diff changeset
372 return md_reader_ptr->read_char ();
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
374
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
375 /* Put back CH, which was the last character read from the MD file. */
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
376
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
377 static inline void
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
378 unread_char (int ch)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
379 {
111
kono
parents: 68
diff changeset
380 md_reader_ptr->unread_char (ch);
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
381 }
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
382
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
383 extern hashval_t leading_string_hash (const void *);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
384 extern int leading_string_eq_p (const void *, const void *);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
385 extern const char *join_c_conditions (const char *, const char *);
111
kono
parents: 68
diff changeset
386 extern void message_at (file_location, const char *, ...) ATTRIBUTE_PRINTF_2;
kono
parents: 68
diff changeset
387 extern void error_at (file_location, const char *, ...) ATTRIBUTE_PRINTF_2;
kono
parents: 68
diff changeset
388 extern void fatal_at (file_location, const char *, ...) ATTRIBUTE_PRINTF_2;
68
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
389 extern void fatal_with_file_and_line (const char *, ...)
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
390 ATTRIBUTE_PRINTF_1 ATTRIBUTE_NORETURN;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
391 extern void fatal_expected_char (int, int) ATTRIBUTE_NORETURN;
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
392 extern int read_skip_spaces (void);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
393 extern int n_comma_elts (const char *);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
394 extern const char *scan_comma_elt (const char **);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
395 extern void upcase_string (char *);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
396 extern void traverse_enum_types (htab_trav, void *);
561a7518be6b update gcc-4.6
Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
397 extern struct enum_type *lookup_enum_type (const char *);
111
kono
parents: 68
diff changeset
398
kono
parents: 68
diff changeset
399 #endif /* GCC_READ_MD_H */