annotate gcc/read-md.h @ 158:494b0b89df80 default tip

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