annotate gcc/read-rtl.c @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 /* RTL reader for GCC.
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
2 Copyright (C) 1987-2018 Free Software Foundation, Inc.
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 This file is part of GCC.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 GCC is free software; you can redistribute it and/or modify it under
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 the terms of the GNU General Public License as published by the Free
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 Software Foundation; either version 3, or (at your option) any later
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9 version.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 for more details.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 along with GCC; see the file COPYING3. If not see
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 <http://www.gnu.org/licenses/>. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19
111
kono
parents: 67
diff changeset
20 /* This file is compiled twice: once for the generator programs
kono
parents: 67
diff changeset
21 once for the compiler. */
kono
parents: 67
diff changeset
22 #ifdef GENERATOR_FILE
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
23 #include "bconfig.h"
111
kono
parents: 67
diff changeset
24 #else
kono
parents: 67
diff changeset
25 #include "config.h"
kono
parents: 67
diff changeset
26 #endif
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
27
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
28 /* Disable rtl checking; it conflicts with the iterator handling. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 #undef ENABLE_RTL_CHECKING
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
31 #include "system.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
32 #include "coretypes.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
33 #include "tm.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34 #include "rtl.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
35 #include "obstack.h"
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
36 #include "read-md.h"
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
37 #include "gensupport.h"
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
111
kono
parents: 67
diff changeset
39 #ifndef GENERATOR_FILE
kono
parents: 67
diff changeset
40 #include "function.h"
kono
parents: 67
diff changeset
41 #include "memmodel.h"
kono
parents: 67
diff changeset
42 #include "emit-rtl.h"
kono
parents: 67
diff changeset
43 #endif
kono
parents: 67
diff changeset
44
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
45 /* One element in a singly-linked list of (integer, string) pairs. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46 struct map_value {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
47 struct map_value *next;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
48 int number;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
49 const char *string;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
50 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
51
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
52 /* Maps an iterator or attribute name to a list of (integer, string) pairs.
111
kono
parents: 67
diff changeset
53 The integers are iterator values; the strings are either C conditions
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
54 or attribute values. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
55 struct mapping {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
56 /* The name of the iterator or attribute. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
57 const char *name;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
58
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
59 /* The group (modes or codes) to which the iterator or attribute belongs. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
60 struct iterator_group *group;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
61
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
62 /* The list of (integer, string) pairs. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
63 struct map_value *values;
111
kono
parents: 67
diff changeset
64
kono
parents: 67
diff changeset
65 /* For iterators, records the current value of the iterator. */
kono
parents: 67
diff changeset
66 struct map_value *current_value;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68
111
kono
parents: 67
diff changeset
69 /* A structure for abstracting the common parts of iterators. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 struct iterator_group {
111
kono
parents: 67
diff changeset
71 /* Tables of "mapping" structures, one for attributes and one for
kono
parents: 67
diff changeset
72 iterators. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 htab_t attrs, iterators;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
75 /* The C++ type of the iterator, such as "machine_mode" for modes. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
76 const char *type;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
77
111
kono
parents: 67
diff changeset
78 /* Treat the given string as the name of a standard mode, etc., and
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
79 return its integer value. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
80 int (*find_builtin) (const char *);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81
111
kono
parents: 67
diff changeset
82 /* Make the given rtx use the iterator value given by the third argument.
kono
parents: 67
diff changeset
83 If the iterator applies to operands, the second argument gives the
kono
parents: 67
diff changeset
84 operand index, otherwise it is ignored. */
kono
parents: 67
diff changeset
85 void (*apply_iterator) (rtx, unsigned int, int);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
86
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
87 /* Return the C token for the given standard mode, code, etc. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
88 const char *(*get_c_token) (int);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
89 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
90
111
kono
parents: 67
diff changeset
91 /* Records one use of an iterator. */
kono
parents: 67
diff changeset
92 struct iterator_use {
kono
parents: 67
diff changeset
93 /* The iterator itself. */
kono
parents: 67
diff changeset
94 struct mapping *iterator;
kono
parents: 67
diff changeset
95
kono
parents: 67
diff changeset
96 /* The location of the use, as passed to the apply_iterator callback.
kono
parents: 67
diff changeset
97 The index is the number of the operand that used the iterator
kono
parents: 67
diff changeset
98 if applicable, otherwise it is ignored. */
kono
parents: 67
diff changeset
99 rtx x;
kono
parents: 67
diff changeset
100 unsigned int index;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102
111
kono
parents: 67
diff changeset
103 /* Records one use of an attribute (the "<[iterator:]attribute>" syntax)
kono
parents: 67
diff changeset
104 in a non-string rtx field. */
kono
parents: 67
diff changeset
105 struct attribute_use {
kono
parents: 67
diff changeset
106 /* The group that describes the use site. */
kono
parents: 67
diff changeset
107 struct iterator_group *group;
kono
parents: 67
diff changeset
108
kono
parents: 67
diff changeset
109 /* The name of the attribute, possibly with an "iterator:" prefix. */
kono
parents: 67
diff changeset
110 const char *value;
kono
parents: 67
diff changeset
111
kono
parents: 67
diff changeset
112 /* The location of the use, as passed to GROUP's apply_iterator callback.
kono
parents: 67
diff changeset
113 The index is the number of the operand that used the iterator
kono
parents: 67
diff changeset
114 if applicable, otherwise it is ignored. */
kono
parents: 67
diff changeset
115 rtx x;
kono
parents: 67
diff changeset
116 unsigned int index;
kono
parents: 67
diff changeset
117 };
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
118
111
kono
parents: 67
diff changeset
119 /* This struct is used to link subst_attr named ATTR_NAME with
kono
parents: 67
diff changeset
120 corresponding define_subst named ITER_NAME. */
kono
parents: 67
diff changeset
121 struct subst_attr_to_iter_mapping
kono
parents: 67
diff changeset
122 {
kono
parents: 67
diff changeset
123 char *attr_name;
kono
parents: 67
diff changeset
124 char *iter_name;
kono
parents: 67
diff changeset
125 };
kono
parents: 67
diff changeset
126
kono
parents: 67
diff changeset
127 /* Hash-table to store links between subst-attributes and
kono
parents: 67
diff changeset
128 define_substs. */
kono
parents: 67
diff changeset
129 htab_t subst_attr_to_iter_map = NULL;
kono
parents: 67
diff changeset
130 /* This global stores name of subst-iterator which is currently being
kono
parents: 67
diff changeset
131 processed. */
kono
parents: 67
diff changeset
132 const char *current_iterator_name;
kono
parents: 67
diff changeset
133
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
134 static void validate_const_int (const char *);
111
kono
parents: 67
diff changeset
135 static void one_time_initialization (void);
kono
parents: 67
diff changeset
136
kono
parents: 67
diff changeset
137 /* Global singleton. */
kono
parents: 67
diff changeset
138 rtx_reader *rtx_reader_ptr = NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
139
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140 /* The mode and code iterator structures. */
111
kono
parents: 67
diff changeset
141 static struct iterator_group modes, codes, ints, substs;
kono
parents: 67
diff changeset
142
kono
parents: 67
diff changeset
143 /* All iterators used in the current rtx. */
kono
parents: 67
diff changeset
144 static vec<mapping *> current_iterators;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
145
111
kono
parents: 67
diff changeset
146 /* The list of all iterator uses in the current rtx. */
kono
parents: 67
diff changeset
147 static vec<iterator_use> iterator_uses;
kono
parents: 67
diff changeset
148
kono
parents: 67
diff changeset
149 /* The list of all attribute uses in the current rtx. */
kono
parents: 67
diff changeset
150 static vec<attribute_use> attribute_uses;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
151
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
152 /* Implementations of the iterator_group callbacks for modes. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
153
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
154 static int
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
155 find_mode (const char *name)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
156 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
157 int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159 for (i = 0; i < NUM_MACHINE_MODES; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160 if (strcmp (GET_MODE_NAME (i), name) == 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 return i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
163 fatal_with_file_and_line ("unknown mode `%s'", name);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165
111
kono
parents: 67
diff changeset
166 static void
kono
parents: 67
diff changeset
167 apply_mode_iterator (rtx x, unsigned int, int mode)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168 {
111
kono
parents: 67
diff changeset
169 PUT_MODE (x, (machine_mode) mode);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
170 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
172 static const char *
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
173 get_mode_token (int mode)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
174 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
175 return concat ("E_", GET_MODE_NAME (mode), "mode", NULL);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
176 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
177
111
kono
parents: 67
diff changeset
178 /* In compact dumps, the code of insns is prefixed with "c", giving "cinsn",
kono
parents: 67
diff changeset
179 "cnote" etc, and CODE_LABEL is special-cased as "clabel". */
kono
parents: 67
diff changeset
180
kono
parents: 67
diff changeset
181 struct compact_insn_name {
kono
parents: 67
diff changeset
182 RTX_CODE code;
kono
parents: 67
diff changeset
183 const char *name;
kono
parents: 67
diff changeset
184 };
kono
parents: 67
diff changeset
185
kono
parents: 67
diff changeset
186 static const compact_insn_name compact_insn_names[] = {
kono
parents: 67
diff changeset
187 { DEBUG_INSN, "cdebug_insn" },
kono
parents: 67
diff changeset
188 { INSN, "cinsn" },
kono
parents: 67
diff changeset
189 { JUMP_INSN, "cjump_insn" },
kono
parents: 67
diff changeset
190 { CALL_INSN, "ccall_insn" },
kono
parents: 67
diff changeset
191 { JUMP_TABLE_DATA, "cjump_table_data" },
kono
parents: 67
diff changeset
192 { BARRIER, "cbarrier" },
kono
parents: 67
diff changeset
193 { CODE_LABEL, "clabel" },
kono
parents: 67
diff changeset
194 { NOTE, "cnote" }
kono
parents: 67
diff changeset
195 };
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197 /* Implementations of the iterator_group callbacks for codes. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
199 static int
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
200 find_code (const char *name)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
201 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
202 int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
203
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
204 for (i = 0; i < NUM_RTX_CODE; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
205 if (strcmp (GET_RTX_NAME (i), name) == 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
206 return i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
207
111
kono
parents: 67
diff changeset
208 for (i = 0; i < (signed)ARRAY_SIZE (compact_insn_names); i++)
kono
parents: 67
diff changeset
209 if (strcmp (compact_insn_names[i].name, name) == 0)
kono
parents: 67
diff changeset
210 return compact_insn_names[i].code;
kono
parents: 67
diff changeset
211
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
212 fatal_with_file_and_line ("unknown rtx code `%s'", name);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
213 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
214
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
215 static void
111
kono
parents: 67
diff changeset
216 apply_code_iterator (rtx x, unsigned int, int code)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
217 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
218 PUT_CODE (x, (enum rtx_code) code);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
219 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
220
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
221 static const char *
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
222 get_code_token (int code)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
223 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
224 char *name = xstrdup (GET_RTX_NAME (code));
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
225 for (int i = 0; name[i]; ++i)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
226 name[i] = TOUPPER (name[i]);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
227 return name;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
228 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
229
111
kono
parents: 67
diff changeset
230 /* Implementations of the iterator_group callbacks for ints. */
kono
parents: 67
diff changeset
231
kono
parents: 67
diff changeset
232 /* Since GCC does not construct a table of valid constants,
kono
parents: 67
diff changeset
233 we have to accept any int as valid. No cross-checking can
kono
parents: 67
diff changeset
234 be done. */
kono
parents: 67
diff changeset
235
kono
parents: 67
diff changeset
236 static int
kono
parents: 67
diff changeset
237 find_int (const char *name)
kono
parents: 67
diff changeset
238 {
kono
parents: 67
diff changeset
239 validate_const_int (name);
kono
parents: 67
diff changeset
240 return atoi (name);
kono
parents: 67
diff changeset
241 }
kono
parents: 67
diff changeset
242
kono
parents: 67
diff changeset
243 static void
kono
parents: 67
diff changeset
244 apply_int_iterator (rtx x, unsigned int index, int value)
kono
parents: 67
diff changeset
245 {
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
246 if (GET_CODE (x) == SUBREG)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
247 SUBREG_BYTE (x) = value;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
248 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
249 XINT (x, index) = value;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
250 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
251
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
252 static const char *
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
253 get_int_token (int value)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
254 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
255 char buffer[HOST_BITS_PER_INT + 1];
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
256 sprintf (buffer, "%d", value);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
257 return xstrdup (buffer);
111
kono
parents: 67
diff changeset
258 }
kono
parents: 67
diff changeset
259
kono
parents: 67
diff changeset
260 #ifdef GENERATOR_FILE
kono
parents: 67
diff changeset
261
kono
parents: 67
diff changeset
262 /* This routine adds attribute or does nothing depending on VALUE. When
kono
parents: 67
diff changeset
263 VALUE is 1, it does nothing - the first duplicate of original
kono
parents: 67
diff changeset
264 template is kept untouched when it's subjected to a define_subst.
kono
parents: 67
diff changeset
265 When VALUE isn't 1, the routine modifies RTL-template RT, adding
kono
parents: 67
diff changeset
266 attribute, named exactly as define_subst, which later will be
kono
parents: 67
diff changeset
267 applied. If such attribute has already been added, then no the
kono
parents: 67
diff changeset
268 routine has no effect. */
kono
parents: 67
diff changeset
269 static void
kono
parents: 67
diff changeset
270 apply_subst_iterator (rtx rt, unsigned int, int value)
kono
parents: 67
diff changeset
271 {
kono
parents: 67
diff changeset
272 rtx new_attr;
kono
parents: 67
diff changeset
273 rtvec attrs_vec, new_attrs_vec;
kono
parents: 67
diff changeset
274 int i;
kono
parents: 67
diff changeset
275 if (value == 1)
kono
parents: 67
diff changeset
276 return;
kono
parents: 67
diff changeset
277 gcc_assert (GET_CODE (rt) == DEFINE_INSN
kono
parents: 67
diff changeset
278 || GET_CODE (rt) == DEFINE_EXPAND);
kono
parents: 67
diff changeset
279
kono
parents: 67
diff changeset
280 attrs_vec = XVEC (rt, 4);
kono
parents: 67
diff changeset
281
kono
parents: 67
diff changeset
282 /* If we've already added attribute 'current_iterator_name', then we
kono
parents: 67
diff changeset
283 have nothing to do now. */
kono
parents: 67
diff changeset
284 if (attrs_vec)
kono
parents: 67
diff changeset
285 {
kono
parents: 67
diff changeset
286 for (i = 0; i < GET_NUM_ELEM (attrs_vec); i++)
kono
parents: 67
diff changeset
287 {
kono
parents: 67
diff changeset
288 if (strcmp (XSTR (attrs_vec->elem[i], 0), current_iterator_name) == 0)
kono
parents: 67
diff changeset
289 return;
kono
parents: 67
diff changeset
290 }
kono
parents: 67
diff changeset
291 }
kono
parents: 67
diff changeset
292
kono
parents: 67
diff changeset
293 /* Add attribute with subst name - it serves as a mark for
kono
parents: 67
diff changeset
294 define_subst which later would be applied to this pattern. */
kono
parents: 67
diff changeset
295 new_attr = rtx_alloc (SET_ATTR);
kono
parents: 67
diff changeset
296 PUT_CODE (new_attr, SET_ATTR);
kono
parents: 67
diff changeset
297 XSTR (new_attr, 0) = xstrdup (current_iterator_name);
kono
parents: 67
diff changeset
298 XSTR (new_attr, 1) = xstrdup ("yes");
kono
parents: 67
diff changeset
299
kono
parents: 67
diff changeset
300 if (!attrs_vec)
kono
parents: 67
diff changeset
301 {
kono
parents: 67
diff changeset
302 new_attrs_vec = rtvec_alloc (1);
kono
parents: 67
diff changeset
303 new_attrs_vec->elem[0] = new_attr;
kono
parents: 67
diff changeset
304 }
kono
parents: 67
diff changeset
305 else
kono
parents: 67
diff changeset
306 {
kono
parents: 67
diff changeset
307 new_attrs_vec = rtvec_alloc (GET_NUM_ELEM (attrs_vec) + 1);
kono
parents: 67
diff changeset
308 memcpy (&new_attrs_vec->elem[0], &attrs_vec->elem[0],
kono
parents: 67
diff changeset
309 GET_NUM_ELEM (attrs_vec) * sizeof (rtx));
kono
parents: 67
diff changeset
310 new_attrs_vec->elem[GET_NUM_ELEM (attrs_vec)] = new_attr;
kono
parents: 67
diff changeset
311 }
kono
parents: 67
diff changeset
312 XVEC (rt, 4) = new_attrs_vec;
kono
parents: 67
diff changeset
313 }
kono
parents: 67
diff changeset
314
kono
parents: 67
diff changeset
315 /* Map subst-attribute ATTR to subst iterator ITER. */
kono
parents: 67
diff changeset
316
kono
parents: 67
diff changeset
317 static void
kono
parents: 67
diff changeset
318 bind_subst_iter_and_attr (const char *iter, const char *attr)
kono
parents: 67
diff changeset
319 {
kono
parents: 67
diff changeset
320 struct subst_attr_to_iter_mapping *value;
kono
parents: 67
diff changeset
321 void **slot;
kono
parents: 67
diff changeset
322 if (!subst_attr_to_iter_map)
kono
parents: 67
diff changeset
323 subst_attr_to_iter_map =
kono
parents: 67
diff changeset
324 htab_create (1, leading_string_hash, leading_string_eq_p, 0);
kono
parents: 67
diff changeset
325 value = XNEW (struct subst_attr_to_iter_mapping);
kono
parents: 67
diff changeset
326 value->attr_name = xstrdup (attr);
kono
parents: 67
diff changeset
327 value->iter_name = xstrdup (iter);
kono
parents: 67
diff changeset
328 slot = htab_find_slot (subst_attr_to_iter_map, value, INSERT);
kono
parents: 67
diff changeset
329 *slot = value;
kono
parents: 67
diff changeset
330 }
kono
parents: 67
diff changeset
331
kono
parents: 67
diff changeset
332 #endif /* #ifdef GENERATOR_FILE */
kono
parents: 67
diff changeset
333
kono
parents: 67
diff changeset
334 /* Return name of a subst-iterator, corresponding to subst-attribute ATTR. */
kono
parents: 67
diff changeset
335
kono
parents: 67
diff changeset
336 static char*
kono
parents: 67
diff changeset
337 find_subst_iter_by_attr (const char *attr)
kono
parents: 67
diff changeset
338 {
kono
parents: 67
diff changeset
339 char *iter_name = NULL;
kono
parents: 67
diff changeset
340 struct subst_attr_to_iter_mapping *value;
kono
parents: 67
diff changeset
341 value = (struct subst_attr_to_iter_mapping*)
kono
parents: 67
diff changeset
342 htab_find (subst_attr_to_iter_map, &attr);
kono
parents: 67
diff changeset
343 if (value)
kono
parents: 67
diff changeset
344 iter_name = value->iter_name;
kono
parents: 67
diff changeset
345 return iter_name;
kono
parents: 67
diff changeset
346 }
kono
parents: 67
diff changeset
347
kono
parents: 67
diff changeset
348 /* Map attribute string P to its current value. Return null if the attribute
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
349 isn't known. If ITERATOR_OUT is nonnull, store the associated iterator
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
350 there. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
351
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
352 static struct map_value *
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
353 map_attr_string (const char *p, mapping **iterator_out = 0)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
354 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
355 const char *attr;
111
kono
parents: 67
diff changeset
356 struct mapping *iterator;
kono
parents: 67
diff changeset
357 unsigned int i;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
358 struct mapping *m;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
359 struct map_value *v;
111
kono
parents: 67
diff changeset
360 int iterator_name_len;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
361
111
kono
parents: 67
diff changeset
362 /* Peel off any "iterator:" prefix. Set ATTR to the start of the
kono
parents: 67
diff changeset
363 attribute name. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
364 attr = strchr (p, ':');
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
365 if (attr == 0)
111
kono
parents: 67
diff changeset
366 {
kono
parents: 67
diff changeset
367 iterator_name_len = -1;
kono
parents: 67
diff changeset
368 attr = p;
kono
parents: 67
diff changeset
369 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
370 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
371 {
111
kono
parents: 67
diff changeset
372 iterator_name_len = attr - p;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
373 attr++;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
374 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
375
111
kono
parents: 67
diff changeset
376 FOR_EACH_VEC_ELT (current_iterators, i, iterator)
kono
parents: 67
diff changeset
377 {
kono
parents: 67
diff changeset
378 /* If an iterator name was specified, check that it matches. */
kono
parents: 67
diff changeset
379 if (iterator_name_len >= 0
kono
parents: 67
diff changeset
380 && (strncmp (p, iterator->name, iterator_name_len) != 0
kono
parents: 67
diff changeset
381 || iterator->name[iterator_name_len] != 0))
kono
parents: 67
diff changeset
382 continue;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
383
111
kono
parents: 67
diff changeset
384 /* Find the attribute specification. */
kono
parents: 67
diff changeset
385 m = (struct mapping *) htab_find (iterator->group->attrs, &attr);
kono
parents: 67
diff changeset
386 if (m)
kono
parents: 67
diff changeset
387 {
kono
parents: 67
diff changeset
388 /* In contrast to code/mode/int iterators, attributes of subst
kono
parents: 67
diff changeset
389 iterators are linked to one specific subst-iterator. So, if
kono
parents: 67
diff changeset
390 we are dealing with subst-iterator, we should check if it's
kono
parents: 67
diff changeset
391 the one which linked with the given attribute. */
kono
parents: 67
diff changeset
392 if (iterator->group == &substs)
kono
parents: 67
diff changeset
393 {
kono
parents: 67
diff changeset
394 char *iter_name = find_subst_iter_by_attr (attr);
kono
parents: 67
diff changeset
395 if (strcmp (iter_name, iterator->name) != 0)
kono
parents: 67
diff changeset
396 continue;
kono
parents: 67
diff changeset
397 }
kono
parents: 67
diff changeset
398 /* Find the attribute value associated with the current
kono
parents: 67
diff changeset
399 iterator value. */
kono
parents: 67
diff changeset
400 for (v = m->values; v; v = v->next)
kono
parents: 67
diff changeset
401 if (v->number == iterator->current_value->number)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
402 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
403 if (iterator_out)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
404 *iterator_out = iterator;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
405 return v;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
406 }
111
kono
parents: 67
diff changeset
407 }
kono
parents: 67
diff changeset
408 }
kono
parents: 67
diff changeset
409 return NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
410 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
411
111
kono
parents: 67
diff changeset
412 /* Apply the current iterator values to STRING. Return the new string
kono
parents: 67
diff changeset
413 if any changes were needed, otherwise return STRING itself. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
414
111
kono
parents: 67
diff changeset
415 const char *
kono
parents: 67
diff changeset
416 md_reader::apply_iterator_to_string (const char *string)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
417 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
418 char *base, *copy, *p, *start, *end;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
419 struct map_value *v;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
420
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
421 if (string == 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
422 return string;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
423
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
424 base = p = copy = ASTRDUP (string);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
425 while ((start = strchr (p, '<')) && (end = strchr (start, '>')))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
426 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
427 p = start + 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
428
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
429 *end = 0;
111
kono
parents: 67
diff changeset
430 v = map_attr_string (p);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
431 *end = '>';
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
432 if (v == 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
433 continue;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
434
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
435 /* Add everything between the last copied byte and the '<',
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
436 then add in the attribute value. */
111
kono
parents: 67
diff changeset
437 obstack_grow (&m_string_obstack, base, start - base);
kono
parents: 67
diff changeset
438 obstack_grow (&m_string_obstack, v->string, strlen (v->string));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
439 base = end + 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
440 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
441 if (base != copy)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
442 {
111
kono
parents: 67
diff changeset
443 obstack_grow (&m_string_obstack, base, strlen (base) + 1);
kono
parents: 67
diff changeset
444 copy = XOBFINISH (&m_string_obstack, char *);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
445 copy_md_ptr_loc (copy, string);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
446 return copy;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
447 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
448 return string;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
449 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
450
111
kono
parents: 67
diff changeset
451 /* Return a deep copy of X, substituting the current iterator
kono
parents: 67
diff changeset
452 values into any strings. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
453
111
kono
parents: 67
diff changeset
454 rtx
kono
parents: 67
diff changeset
455 md_reader::copy_rtx_for_iterators (rtx original)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
456 {
111
kono
parents: 67
diff changeset
457 const char *format_ptr, *p;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
458 int i, j;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
459 rtx x;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
460
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
461 if (original == 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
462 return original;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
463
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
464 /* Create a shallow copy of ORIGINAL. */
111
kono
parents: 67
diff changeset
465 x = rtx_alloc (GET_CODE (original));
kono
parents: 67
diff changeset
466 memcpy (x, original, RTX_CODE_SIZE (GET_CODE (original)));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
467
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
468 /* Change each string and recursively change each rtx. */
111
kono
parents: 67
diff changeset
469 format_ptr = GET_RTX_FORMAT (GET_CODE (original));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
470 for (i = 0; format_ptr[i] != 0; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
471 switch (format_ptr[i])
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
472 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
473 case 'T':
111
kono
parents: 67
diff changeset
474 while (XTMPL (x, i) != (p = apply_iterator_to_string (XTMPL (x, i))))
kono
parents: 67
diff changeset
475 XTMPL (x, i) = p;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
476 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
477
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
478 case 'S':
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
479 case 's':
111
kono
parents: 67
diff changeset
480 while (XSTR (x, i) != (p = apply_iterator_to_string (XSTR (x, i))))
kono
parents: 67
diff changeset
481 XSTR (x, i) = p;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
482 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
483
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
484 case 'e':
111
kono
parents: 67
diff changeset
485 XEXP (x, i) = copy_rtx_for_iterators (XEXP (x, i));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
486 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
487
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
488 case 'V':
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
489 case 'E':
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
490 if (XVEC (original, i))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
491 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
492 XVEC (x, i) = rtvec_alloc (XVECLEN (original, i));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
493 for (j = 0; j < XVECLEN (x, i); j++)
111
kono
parents: 67
diff changeset
494 XVECEXP (x, i, j)
kono
parents: 67
diff changeset
495 = copy_rtx_for_iterators (XVECEXP (original, i, j));
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
496 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
497 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
498
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
499 default:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
500 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
501 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
502 return x;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
503 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
504
111
kono
parents: 67
diff changeset
505 #ifdef GENERATOR_FILE
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
506
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
507 /* Return a condition that must satisfy both ORIGINAL and EXTRA. If ORIGINAL
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
508 has the form "&& ..." (as used in define_insn_and_splits), assume that
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
509 EXTRA is already satisfied. Empty strings are treated like "true". */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
510
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
511 static const char *
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
512 add_condition_to_string (const char *original, const char *extra)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
513 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
514 if (original != 0 && original[0] == '&' && original[1] == '&')
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
515 return original;
111
kono
parents: 67
diff changeset
516 return rtx_reader_ptr->join_c_conditions (original, extra);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
517 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
518
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
519 /* Like add_condition, but applied to all conditions in rtx X. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
520
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
521 static void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
522 add_condition_to_rtx (rtx x, const char *extra)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
523 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
524 switch (GET_CODE (x))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
525 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
526 case DEFINE_INSN:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
527 case DEFINE_EXPAND:
111
kono
parents: 67
diff changeset
528 case DEFINE_SUBST:
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
529 XSTR (x, 2) = add_condition_to_string (XSTR (x, 2), extra);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
530 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
531
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
532 case DEFINE_SPLIT:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
533 case DEFINE_PEEPHOLE:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
534 case DEFINE_PEEPHOLE2:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
535 case DEFINE_COND_EXEC:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
536 XSTR (x, 1) = add_condition_to_string (XSTR (x, 1), extra);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
537 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
538
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
539 case DEFINE_INSN_AND_SPLIT:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
540 XSTR (x, 2) = add_condition_to_string (XSTR (x, 2), extra);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
541 XSTR (x, 4) = add_condition_to_string (XSTR (x, 4), extra);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
542 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
543
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
544 default:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
545 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
546 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
547 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
548
111
kono
parents: 67
diff changeset
549 /* Apply the current iterator values to all attribute_uses. */
kono
parents: 67
diff changeset
550
kono
parents: 67
diff changeset
551 static void
kono
parents: 67
diff changeset
552 apply_attribute_uses (void)
kono
parents: 67
diff changeset
553 {
kono
parents: 67
diff changeset
554 struct map_value *v;
kono
parents: 67
diff changeset
555 attribute_use *ause;
kono
parents: 67
diff changeset
556 unsigned int i;
kono
parents: 67
diff changeset
557
kono
parents: 67
diff changeset
558 FOR_EACH_VEC_ELT (attribute_uses, i, ause)
kono
parents: 67
diff changeset
559 {
kono
parents: 67
diff changeset
560 v = map_attr_string (ause->value);
kono
parents: 67
diff changeset
561 if (!v)
kono
parents: 67
diff changeset
562 fatal_with_file_and_line ("unknown iterator value `%s'", ause->value);
kono
parents: 67
diff changeset
563 ause->group->apply_iterator (ause->x, ause->index,
kono
parents: 67
diff changeset
564 ause->group->find_builtin (v->string));
kono
parents: 67
diff changeset
565 }
kono
parents: 67
diff changeset
566 }
kono
parents: 67
diff changeset
567
kono
parents: 67
diff changeset
568 /* A htab_traverse callback for iterators. Add all used iterators
kono
parents: 67
diff changeset
569 to current_iterators. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
570
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
571 static int
111
kono
parents: 67
diff changeset
572 add_current_iterators (void **slot, void *data ATTRIBUTE_UNUSED)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
573 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
574 struct mapping *iterator;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
575
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
576 iterator = (struct mapping *) *slot;
111
kono
parents: 67
diff changeset
577 if (iterator->current_value)
kono
parents: 67
diff changeset
578 current_iterators.safe_push (iterator);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
579 return 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
580 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
581
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
582 /* Return a hash value for overloaded_name UNCAST_ONAME. There shouldn't
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
583 be many instances of two overloaded_names having the same name but
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
584 different arguments, so hashing on the name should be good enough in
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
585 practice. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
586
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
587 static hashval_t
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
588 overloaded_name_hash (const void *uncast_oname)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
589 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
590 const overloaded_name *oname = (const overloaded_name *) uncast_oname;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
591 return htab_hash_string (oname->name);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
592 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
593
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
594 /* Return true if two overloaded_names are similar enough to share
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
595 the same generated functions. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
596
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
597 static int
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
598 overloaded_name_eq_p (const void *uncast_oname1, const void *uncast_oname2)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
599 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
600 const overloaded_name *oname1 = (const overloaded_name *) uncast_oname1;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
601 const overloaded_name *oname2 = (const overloaded_name *) uncast_oname2;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
602 if (strcmp (oname1->name, oname2->name) != 0
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
603 || oname1->arg_types.length () != oname2->arg_types.length ())
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
604 return 0;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
605
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
606 for (unsigned int i = 0; i < oname1->arg_types.length (); ++i)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
607 if (strcmp (oname1->arg_types[i], oname2->arg_types[i]) != 0)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
608 return 0;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
609
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
610 return 1;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
611 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
612
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
613 /* Return true if X has an instruction name in XSTR (X, 0). */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
614
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
615 static bool
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
616 named_rtx_p (rtx x)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
617 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
618 switch (GET_CODE (x))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
619 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
620 case DEFINE_EXPAND:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
621 case DEFINE_INSN:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
622 case DEFINE_INSN_AND_SPLIT:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
623 return true;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
624
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
625 default:
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
626 return false;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
627 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
628 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
629
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
630 /* Check whether ORIGINAL is a named pattern whose name starts with '@'.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
631 If so, return the associated overloaded_name and add the iterator for
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
632 each argument to ITERATORS. Return null otherwise. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
633
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
634 overloaded_name *
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
635 md_reader::handle_overloaded_name (rtx original, vec<mapping *> *iterators)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
636 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
637 /* Check for the leading '@'. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
638 if (!named_rtx_p (original) || XSTR (original, 0)[0] != '@')
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
639 return NULL;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
640
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
641 /* Remove the '@', so that no other code needs to worry about it. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
642 const char *name = XSTR (original, 0);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
643 copy_md_ptr_loc (name + 1, name);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
644 name += 1;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
645 XSTR (original, 0) = name;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
646
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
647 /* Build a copy of the name without the '<...>' attribute strings.
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
648 Add the iterator associated with each such attribute string to ITERATORS
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
649 and add an associated argument to TMP_ONAME. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
650 char *copy = ASTRDUP (name);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
651 char *base = copy, *start, *end;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
652 overloaded_name tmp_oname;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
653 tmp_oname.arg_types.create (current_iterators.length ());
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
654 bool pending_underscore_p = false;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
655 while ((start = strchr (base, '<')) && (end = strchr (start, '>')))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
656 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
657 *end = 0;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
658 mapping *iterator;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
659 if (!map_attr_string (start + 1, &iterator))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
660 fatal_with_file_and_line ("unknown iterator `%s'", start + 1);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
661 *end = '>';
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
662
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
663 /* Remove a trailing underscore, so that we don't end a name
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
664 with "_" or turn "_<...>_" into "__". */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
665 if (start != base && start[-1] == '_')
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
666 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
667 start -= 1;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
668 pending_underscore_p = true;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
669 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
670
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
671 /* Add the text between either the last '>' or the start of
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
672 the string and this '<'. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
673 obstack_grow (&m_string_obstack, base, start - base);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
674 base = end + 1;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
675
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
676 /* If there's a character we need to keep after the '>', check
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
677 whether we should prefix it with a previously-dropped '_'. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
678 if (base[0] != 0 && base[0] != '<')
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
679 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
680 if (pending_underscore_p && base[0] != '_')
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
681 obstack_1grow (&m_string_obstack, '_');
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
682 pending_underscore_p = false;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
683 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
684
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
685 /* Record an argument for ITERATOR. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
686 iterators->safe_push (iterator);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
687 tmp_oname.arg_types.safe_push (iterator->group->type);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
688 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
689 if (base == copy)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
690 fatal_with_file_and_line ("no iterator attributes in name `%s'", name);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
691
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
692 size_t length = obstack_object_size (&m_string_obstack);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
693 if (length == 0)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
694 fatal_with_file_and_line ("`%s' only contains iterator attributes", name);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
695
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
696 /* Get the completed name. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
697 obstack_grow (&m_string_obstack, base, strlen (base) + 1);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
698 char *new_name = XOBFINISH (&m_string_obstack, char *);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
699 tmp_oname.name = new_name;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
700
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
701 if (!m_overloads_htab)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
702 m_overloads_htab = htab_create (31, overloaded_name_hash,
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
703 overloaded_name_eq_p, NULL);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
704
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
705 /* See whether another pattern had the same overload name and list
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
706 of argument types. Create a new permanent one if not. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
707 void **slot = htab_find_slot (m_overloads_htab, &tmp_oname, INSERT);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
708 overloaded_name *oname = (overloaded_name *) *slot;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
709 if (!oname)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
710 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
711 *slot = oname = new overloaded_name;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
712 oname->name = tmp_oname.name;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
713 oname->arg_types = tmp_oname.arg_types;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
714 oname->next = NULL;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
715 oname->first_instance = NULL;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
716 oname->next_instance_ptr = &oname->first_instance;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
717
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
718 *m_next_overload_ptr = oname;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
719 m_next_overload_ptr = &oname->next;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
720 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
721 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
722 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
723 obstack_free (&m_string_obstack, new_name);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
724 tmp_oname.arg_types.release ();
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
725 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
726
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
727 return oname;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
728 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
729
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
730 /* Add an instance of ONAME for instruction pattern X. ITERATORS[I]
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
731 gives the iterator associated with argument I of ONAME. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
732
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
733 static void
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
734 add_overload_instance (overloaded_name *oname, vec<mapping *> iterators, rtx x)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
735 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
736 /* Create the instance. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
737 overloaded_instance *instance = new overloaded_instance;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
738 instance->next = NULL;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
739 instance->arg_values.create (oname->arg_types.length ());
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
740 for (unsigned int i = 0; i < iterators.length (); ++i)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
741 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
742 int value = iterators[i]->current_value->number;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
743 const char *name = iterators[i]->group->get_c_token (value);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
744 instance->arg_values.quick_push (name);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
745 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
746 instance->name = XSTR (x, 0);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
747 instance->insn = x;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
748
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
749 /* Chain it onto the end of ONAME's list. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
750 *oname->next_instance_ptr = instance;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
751 oname->next_instance_ptr = &instance->next;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
752 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
753
111
kono
parents: 67
diff changeset
754 /* Expand all iterators in the current rtx, which is given as ORIGINAL.
kono
parents: 67
diff changeset
755 Build a list of expanded rtxes in the EXPR_LIST pointed to by QUEUE. */
kono
parents: 67
diff changeset
756
kono
parents: 67
diff changeset
757 static void
kono
parents: 67
diff changeset
758 apply_iterators (rtx original, vec<rtx> *queue)
kono
parents: 67
diff changeset
759 {
kono
parents: 67
diff changeset
760 unsigned int i;
kono
parents: 67
diff changeset
761 const char *condition;
kono
parents: 67
diff changeset
762 iterator_use *iuse;
kono
parents: 67
diff changeset
763 struct mapping *iterator;
kono
parents: 67
diff changeset
764 struct map_value *v;
kono
parents: 67
diff changeset
765 rtx x;
kono
parents: 67
diff changeset
766
kono
parents: 67
diff changeset
767 if (iterator_uses.is_empty ())
kono
parents: 67
diff changeset
768 {
kono
parents: 67
diff changeset
769 /* Raise an error if any attributes were used. */
kono
parents: 67
diff changeset
770 apply_attribute_uses ();
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
771
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
772 if (named_rtx_p (original) && XSTR (original, 0)[0] == '@')
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
773 fatal_with_file_and_line ("'@' used without iterators");
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
774
111
kono
parents: 67
diff changeset
775 queue->safe_push (original);
kono
parents: 67
diff changeset
776 return;
kono
parents: 67
diff changeset
777 }
kono
parents: 67
diff changeset
778
kono
parents: 67
diff changeset
779 /* Clear out the iterators from the previous run. */
kono
parents: 67
diff changeset
780 FOR_EACH_VEC_ELT (current_iterators, i, iterator)
kono
parents: 67
diff changeset
781 iterator->current_value = NULL;
kono
parents: 67
diff changeset
782 current_iterators.truncate (0);
kono
parents: 67
diff changeset
783
kono
parents: 67
diff changeset
784 /* Mark the iterators that we need this time. */
kono
parents: 67
diff changeset
785 FOR_EACH_VEC_ELT (iterator_uses, i, iuse)
kono
parents: 67
diff changeset
786 iuse->iterator->current_value = iuse->iterator->values;
kono
parents: 67
diff changeset
787
kono
parents: 67
diff changeset
788 /* Get the list of iterators that are in use, preserving the
kono
parents: 67
diff changeset
789 definition order within each group. */
kono
parents: 67
diff changeset
790 htab_traverse (modes.iterators, add_current_iterators, NULL);
kono
parents: 67
diff changeset
791 htab_traverse (codes.iterators, add_current_iterators, NULL);
kono
parents: 67
diff changeset
792 htab_traverse (ints.iterators, add_current_iterators, NULL);
kono
parents: 67
diff changeset
793 htab_traverse (substs.iterators, add_current_iterators, NULL);
kono
parents: 67
diff changeset
794 gcc_assert (!current_iterators.is_empty ());
kono
parents: 67
diff changeset
795
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
796 /* Check whether this is a '@' overloaded pattern. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
797 auto_vec<mapping *, 16> iterators;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
798 overloaded_name *oname
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
799 = rtx_reader_ptr->handle_overloaded_name (original, &iterators);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
800
111
kono
parents: 67
diff changeset
801 for (;;)
kono
parents: 67
diff changeset
802 {
kono
parents: 67
diff changeset
803 /* Apply the current iterator values. Accumulate a condition to
kono
parents: 67
diff changeset
804 say when the resulting rtx can be used. */
kono
parents: 67
diff changeset
805 condition = "";
kono
parents: 67
diff changeset
806 FOR_EACH_VEC_ELT (iterator_uses, i, iuse)
kono
parents: 67
diff changeset
807 {
kono
parents: 67
diff changeset
808 if (iuse->iterator->group == &substs)
kono
parents: 67
diff changeset
809 continue;
kono
parents: 67
diff changeset
810 v = iuse->iterator->current_value;
kono
parents: 67
diff changeset
811 iuse->iterator->group->apply_iterator (iuse->x, iuse->index,
kono
parents: 67
diff changeset
812 v->number);
kono
parents: 67
diff changeset
813 condition = rtx_reader_ptr->join_c_conditions (condition, v->string);
kono
parents: 67
diff changeset
814 }
kono
parents: 67
diff changeset
815 apply_attribute_uses ();
kono
parents: 67
diff changeset
816 x = rtx_reader_ptr->copy_rtx_for_iterators (original);
kono
parents: 67
diff changeset
817 add_condition_to_rtx (x, condition);
kono
parents: 67
diff changeset
818
kono
parents: 67
diff changeset
819 /* We apply subst iterator after RTL-template is copied, as during
kono
parents: 67
diff changeset
820 subst-iterator processing, we could add an attribute to the
kono
parents: 67
diff changeset
821 RTL-template, and we don't want to do it in the original one. */
kono
parents: 67
diff changeset
822 FOR_EACH_VEC_ELT (iterator_uses, i, iuse)
kono
parents: 67
diff changeset
823 {
kono
parents: 67
diff changeset
824 v = iuse->iterator->current_value;
kono
parents: 67
diff changeset
825 if (iuse->iterator->group == &substs)
kono
parents: 67
diff changeset
826 {
kono
parents: 67
diff changeset
827 iuse->x = x;
kono
parents: 67
diff changeset
828 iuse->index = 0;
kono
parents: 67
diff changeset
829 current_iterator_name = iuse->iterator->name;
kono
parents: 67
diff changeset
830 iuse->iterator->group->apply_iterator (iuse->x, iuse->index,
kono
parents: 67
diff changeset
831 v->number);
kono
parents: 67
diff changeset
832 }
kono
parents: 67
diff changeset
833 }
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
834
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
835 if (oname)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
836 add_overload_instance (oname, iterators, x);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
837
111
kono
parents: 67
diff changeset
838 /* Add the new rtx to the end of the queue. */
kono
parents: 67
diff changeset
839 queue->safe_push (x);
kono
parents: 67
diff changeset
840
kono
parents: 67
diff changeset
841 /* Lexicographically increment the iterator value sequence.
kono
parents: 67
diff changeset
842 That is, cycle through iterator values, starting from the right,
kono
parents: 67
diff changeset
843 and stopping when one of them doesn't wrap around. */
kono
parents: 67
diff changeset
844 i = current_iterators.length ();
kono
parents: 67
diff changeset
845 for (;;)
kono
parents: 67
diff changeset
846 {
kono
parents: 67
diff changeset
847 if (i == 0)
kono
parents: 67
diff changeset
848 return;
kono
parents: 67
diff changeset
849 i--;
kono
parents: 67
diff changeset
850 iterator = current_iterators[i];
kono
parents: 67
diff changeset
851 iterator->current_value = iterator->current_value->next;
kono
parents: 67
diff changeset
852 if (iterator->current_value)
kono
parents: 67
diff changeset
853 break;
kono
parents: 67
diff changeset
854 iterator->current_value = iterator->values;
kono
parents: 67
diff changeset
855 }
kono
parents: 67
diff changeset
856 }
kono
parents: 67
diff changeset
857 }
kono
parents: 67
diff changeset
858 #endif /* #ifdef GENERATOR_FILE */
kono
parents: 67
diff changeset
859
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
860 /* Add a new "mapping" structure to hashtable TABLE. NAME is the name
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
861 of the mapping and GROUP is the group to which it belongs. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
862
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
863 static struct mapping *
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
864 add_mapping (struct iterator_group *group, htab_t table, const char *name)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
865 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
866 struct mapping *m;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
867 void **slot;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
868
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
869 m = XNEW (struct mapping);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
870 m->name = xstrdup (name);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
871 m->group = group;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
872 m->values = 0;
111
kono
parents: 67
diff changeset
873 m->current_value = NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
874
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
875 slot = htab_find_slot (table, m, INSERT);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
876 if (*slot != 0)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
877 fatal_with_file_and_line ("`%s' already defined", name);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
878
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
879 *slot = m;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
880 return m;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
881 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
882
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
883 /* Add the pair (NUMBER, STRING) to a list of map_value structures.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
884 END_PTR points to the current null terminator for the list; return
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
885 a pointer the new null terminator. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
886
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
887 static struct map_value **
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
888 add_map_value (struct map_value **end_ptr, int number, const char *string)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
889 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
890 struct map_value *value;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
891
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
892 value = XNEW (struct map_value);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
893 value->next = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
894 value->number = number;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
895 value->string = string;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
896
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
897 *end_ptr = value;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
898 return &value->next;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
899 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
900
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
901 /* Do one-time initialization of the mode and code attributes. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
902
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
903 static void
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
904 initialize_iterators (void)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
905 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
906 struct mapping *lower, *upper;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
907 struct map_value **lower_ptr, **upper_ptr;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
908 char *copy, *p;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
909 int i;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
910
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
911 modes.attrs = htab_create (13, leading_string_hash, leading_string_eq_p, 0);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
912 modes.iterators = htab_create (13, leading_string_hash,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
913 leading_string_eq_p, 0);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
914 modes.type = "machine_mode";
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
915 modes.find_builtin = find_mode;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
916 modes.apply_iterator = apply_mode_iterator;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
917 modes.get_c_token = get_mode_token;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
918
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
919 codes.attrs = htab_create (13, leading_string_hash, leading_string_eq_p, 0);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
920 codes.iterators = htab_create (13, leading_string_hash,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
921 leading_string_eq_p, 0);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
922 codes.type = "rtx_code";
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
923 codes.find_builtin = find_code;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
924 codes.apply_iterator = apply_code_iterator;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
925 codes.get_c_token = get_code_token;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
926
111
kono
parents: 67
diff changeset
927 ints.attrs = htab_create (13, leading_string_hash, leading_string_eq_p, 0);
kono
parents: 67
diff changeset
928 ints.iterators = htab_create (13, leading_string_hash,
kono
parents: 67
diff changeset
929 leading_string_eq_p, 0);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
930 ints.type = "int";
111
kono
parents: 67
diff changeset
931 ints.find_builtin = find_int;
kono
parents: 67
diff changeset
932 ints.apply_iterator = apply_int_iterator;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
933 ints.get_c_token = get_int_token;
111
kono
parents: 67
diff changeset
934
kono
parents: 67
diff changeset
935 substs.attrs = htab_create (13, leading_string_hash, leading_string_eq_p, 0);
kono
parents: 67
diff changeset
936 substs.iterators = htab_create (13, leading_string_hash,
kono
parents: 67
diff changeset
937 leading_string_eq_p, 0);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
938 substs.type = "int";
111
kono
parents: 67
diff changeset
939 substs.find_builtin = find_int; /* We don't use it, anyway. */
kono
parents: 67
diff changeset
940 #ifdef GENERATOR_FILE
kono
parents: 67
diff changeset
941 substs.apply_iterator = apply_subst_iterator;
kono
parents: 67
diff changeset
942 #endif
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
943 substs.get_c_token = get_int_token;
111
kono
parents: 67
diff changeset
944
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
945 lower = add_mapping (&modes, modes.attrs, "mode");
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
946 upper = add_mapping (&modes, modes.attrs, "MODE");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
947 lower_ptr = &lower->values;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
948 upper_ptr = &upper->values;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
949 for (i = 0; i < MAX_MACHINE_MODE; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
950 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
951 copy = xstrdup (GET_MODE_NAME (i));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
952 for (p = copy; *p != 0; p++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
953 *p = TOLOWER (*p);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
954
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
955 upper_ptr = add_map_value (upper_ptr, i, GET_MODE_NAME (i));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
956 lower_ptr = add_map_value (lower_ptr, i, copy);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
957 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
958
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
959 lower = add_mapping (&codes, codes.attrs, "code");
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
960 upper = add_mapping (&codes, codes.attrs, "CODE");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
961 lower_ptr = &lower->values;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
962 upper_ptr = &upper->values;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
963 for (i = 0; i < NUM_RTX_CODE; i++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
964 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
965 copy = xstrdup (GET_RTX_NAME (i));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
966 for (p = copy; *p != 0; p++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
967 *p = TOUPPER (*p);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
968
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
969 lower_ptr = add_map_value (lower_ptr, i, GET_RTX_NAME (i));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
970 upper_ptr = add_map_value (upper_ptr, i, copy);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
971 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
972 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
973
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
974 /* Provide a version of a function to read a long long if the system does
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
975 not provide one. */
111
kono
parents: 67
diff changeset
976 #if HOST_BITS_PER_WIDE_INT > HOST_BITS_PER_LONG && !HAVE_DECL_ATOLL && !defined(HAVE_ATOQ)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
977 HOST_WIDE_INT atoll (const char *);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
978
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
979 HOST_WIDE_INT
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
980 atoll (const char *p)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
981 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
982 int neg = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
983 HOST_WIDE_INT tmp_wide;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
984
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
985 while (ISSPACE (*p))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
986 p++;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
987 if (*p == '-')
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
988 neg = 1, p++;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
989 else if (*p == '+')
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
990 p++;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
991
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
992 tmp_wide = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
993 while (ISDIGIT (*p))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
994 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
995 HOST_WIDE_INT new_wide = tmp_wide*10 + (*p - '0');
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
996 if (new_wide < tmp_wide)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
997 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
998 /* Return INT_MAX equiv on overflow. */
111
kono
parents: 67
diff changeset
999 tmp_wide = HOST_WIDE_INT_M1U >> 1;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1000 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1001 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1002 tmp_wide = new_wide;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1003 p++;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1004 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1005
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1006 if (neg)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1007 tmp_wide = -tmp_wide;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1008 return tmp_wide;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1009 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1010 #endif
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1011
111
kono
parents: 67
diff changeset
1012
kono
parents: 67
diff changeset
1013 #ifdef GENERATOR_FILE
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1014 /* Process a define_conditions directive, starting with the optional
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1015 space after the "define_conditions". The directive looks like this:
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1016
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1017 (define_conditions [
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1018 (number "string")
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1019 (number "string")
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1020 ...
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1021 ])
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1022
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1023 It's not intended to appear in machine descriptions. It is
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1024 generated by (the program generated by) genconditions.c, and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1025 slipped in at the beginning of the sequence of MD files read by
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1026 most of the other generators. */
111
kono
parents: 67
diff changeset
1027 void
kono
parents: 67
diff changeset
1028 md_reader::read_conditions ()
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1029 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1030 int c;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1031
111
kono
parents: 67
diff changeset
1032 require_char_ws ('[');
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1033
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1034 while ( (c = read_skip_spaces ()) != ']')
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1035 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1036 struct md_name name;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1037 char *expr;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1038 int value;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1039
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1040 if (c != '(')
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1041 fatal_expected_char ('(', c);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1042
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1043 read_name (&name);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1044 validate_const_int (name.string);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1045 value = atoi (name.string);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1046
111
kono
parents: 67
diff changeset
1047 require_char_ws ('"');
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1048 expr = read_quoted_string ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1049
111
kono
parents: 67
diff changeset
1050 require_char_ws (')');
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1051
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1052 add_c_test (expr, value);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1053 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1054 }
111
kono
parents: 67
diff changeset
1055 #endif /* #ifdef GENERATOR_FILE */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1056
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1057 static void
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1058 validate_const_int (const char *string)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1059 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1060 const char *cp;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1061 int valid = 1;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1062
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1063 cp = string;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1064 while (*cp && ISSPACE (*cp))
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1065 cp++;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1066 if (*cp == '-' || *cp == '+')
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1067 cp++;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1068 if (*cp == 0)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1069 valid = 0;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1070 for (; *cp; cp++)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1071 if (! ISDIGIT (*cp))
111
kono
parents: 67
diff changeset
1072 {
kono
parents: 67
diff changeset
1073 valid = 0;
kono
parents: 67
diff changeset
1074 break;
kono
parents: 67
diff changeset
1075 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1076 if (!valid)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1077 fatal_with_file_and_line ("invalid decimal constant \"%s\"\n", string);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1078 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1079
111
kono
parents: 67
diff changeset
1080 static void
kono
parents: 67
diff changeset
1081 validate_const_wide_int (const char *string)
kono
parents: 67
diff changeset
1082 {
kono
parents: 67
diff changeset
1083 const char *cp;
kono
parents: 67
diff changeset
1084 int valid = 1;
kono
parents: 67
diff changeset
1085
kono
parents: 67
diff changeset
1086 cp = string;
kono
parents: 67
diff changeset
1087 while (*cp && ISSPACE (*cp))
kono
parents: 67
diff changeset
1088 cp++;
kono
parents: 67
diff changeset
1089 /* Skip the leading 0x. */
kono
parents: 67
diff changeset
1090 if (cp[0] == '0' || cp[1] == 'x')
kono
parents: 67
diff changeset
1091 cp += 2;
kono
parents: 67
diff changeset
1092 else
kono
parents: 67
diff changeset
1093 valid = 0;
kono
parents: 67
diff changeset
1094 if (*cp == 0)
kono
parents: 67
diff changeset
1095 valid = 0;
kono
parents: 67
diff changeset
1096 for (; *cp; cp++)
kono
parents: 67
diff changeset
1097 if (! ISXDIGIT (*cp))
kono
parents: 67
diff changeset
1098 valid = 0;
kono
parents: 67
diff changeset
1099 if (!valid)
kono
parents: 67
diff changeset
1100 fatal_with_file_and_line ("invalid hex constant \"%s\"\n", string);
kono
parents: 67
diff changeset
1101 }
kono
parents: 67
diff changeset
1102
kono
parents: 67
diff changeset
1103 /* Record that X uses iterator ITERATOR. If the use is in an operand
kono
parents: 67
diff changeset
1104 of X, INDEX is the index of that operand, otherwise it is ignored. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1105
111
kono
parents: 67
diff changeset
1106 static void
kono
parents: 67
diff changeset
1107 record_iterator_use (struct mapping *iterator, rtx x, unsigned int index)
kono
parents: 67
diff changeset
1108 {
kono
parents: 67
diff changeset
1109 struct iterator_use iuse = {iterator, x, index};
kono
parents: 67
diff changeset
1110 iterator_uses.safe_push (iuse);
kono
parents: 67
diff changeset
1111 }
kono
parents: 67
diff changeset
1112
kono
parents: 67
diff changeset
1113 /* Record that X uses attribute VALUE, which must match a built-in
kono
parents: 67
diff changeset
1114 value from group GROUP. If the use is in an operand of X, INDEX
kono
parents: 67
diff changeset
1115 is the index of that operand, otherwise it is ignored. */
kono
parents: 67
diff changeset
1116
kono
parents: 67
diff changeset
1117 static void
kono
parents: 67
diff changeset
1118 record_attribute_use (struct iterator_group *group, rtx x,
kono
parents: 67
diff changeset
1119 unsigned int index, const char *value)
kono
parents: 67
diff changeset
1120 {
kono
parents: 67
diff changeset
1121 struct attribute_use ause = {group, value, x, index};
kono
parents: 67
diff changeset
1122 attribute_uses.safe_push (ause);
kono
parents: 67
diff changeset
1123 }
kono
parents: 67
diff changeset
1124
kono
parents: 67
diff changeset
1125 /* Interpret NAME as either a built-in value, iterator or attribute
kono
parents: 67
diff changeset
1126 for group GROUP. X and INDEX are the values to pass to GROUP's
kono
parents: 67
diff changeset
1127 apply_iterator callback. */
kono
parents: 67
diff changeset
1128
kono
parents: 67
diff changeset
1129 void
kono
parents: 67
diff changeset
1130 md_reader::record_potential_iterator_use (struct iterator_group *group,
kono
parents: 67
diff changeset
1131 rtx x, unsigned int index,
kono
parents: 67
diff changeset
1132 const char *name)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1133 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1134 struct mapping *m;
111
kono
parents: 67
diff changeset
1135 size_t len;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1136
111
kono
parents: 67
diff changeset
1137 len = strlen (name);
kono
parents: 67
diff changeset
1138 if (name[0] == '<' && name[len - 1] == '>')
kono
parents: 67
diff changeset
1139 {
kono
parents: 67
diff changeset
1140 /* Copy the attribute string into permanent storage, without the
kono
parents: 67
diff changeset
1141 angle brackets around it. */
kono
parents: 67
diff changeset
1142 obstack_grow0 (&m_string_obstack, name + 1, len - 2);
kono
parents: 67
diff changeset
1143 record_attribute_use (group, x, index,
kono
parents: 67
diff changeset
1144 XOBFINISH (&m_string_obstack, char *));
kono
parents: 67
diff changeset
1145 }
kono
parents: 67
diff changeset
1146 else
kono
parents: 67
diff changeset
1147 {
kono
parents: 67
diff changeset
1148 m = (struct mapping *) htab_find (group->iterators, &name);
kono
parents: 67
diff changeset
1149 if (m != 0)
kono
parents: 67
diff changeset
1150 record_iterator_use (m, x, index);
kono
parents: 67
diff changeset
1151 else
kono
parents: 67
diff changeset
1152 group->apply_iterator (x, index, group->find_builtin (name));
kono
parents: 67
diff changeset
1153 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1154 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1155
111
kono
parents: 67
diff changeset
1156 #ifdef GENERATOR_FILE
kono
parents: 67
diff changeset
1157
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1158 /* Finish reading a declaration of the form:
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1159
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1160 (define... <name> [<value1> ... <valuen>])
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1161
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1162 from the MD file, where each <valuei> is either a bare symbol name or a
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1163 "(<name> <string>)" pair. The "(define..." part has already been read.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1164
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1165 Represent the declaration as a "mapping" structure; add it to TABLE
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1166 (which belongs to GROUP) and return it. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1167
111
kono
parents: 67
diff changeset
1168 struct mapping *
kono
parents: 67
diff changeset
1169 md_reader::read_mapping (struct iterator_group *group, htab_t table)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1170 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1171 struct md_name name;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1172 struct mapping *m;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1173 struct map_value **end_ptr;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1174 const char *string;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1175 int number, c;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1176
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1177 /* Read the mapping name and create a structure for it. */
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1178 read_name (&name);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1179 m = add_mapping (group, table, name.string);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1180
111
kono
parents: 67
diff changeset
1181 require_char_ws ('[');
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1182
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1183 /* Read each value. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1184 end_ptr = &m->values;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1185 c = read_skip_spaces ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1186 do
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1187 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1188 if (c != '(')
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1189 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1190 /* A bare symbol name that is implicitly paired to an
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1191 empty string. */
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1192 unread_char (c);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1193 read_name (&name);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1194 string = "";
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1195 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1196 else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1197 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1198 /* A "(name string)" pair. */
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1199 read_name (&name);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1200 string = read_string (false);
111
kono
parents: 67
diff changeset
1201 require_char_ws (')');
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1202 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1203 number = group->find_builtin (name.string);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1204 end_ptr = add_map_value (end_ptr, number, string);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1205 c = read_skip_spaces ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1206 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1207 while (c != ']');
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1208
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1209 return m;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1210 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1211
111
kono
parents: 67
diff changeset
1212 /* For iterator with name ATTR_NAME generate define_attr with values
kono
parents: 67
diff changeset
1213 'yes' and 'no'. This attribute is used to mark templates to which
kono
parents: 67
diff changeset
1214 define_subst ATTR_NAME should be applied. This attribute is set and
kono
parents: 67
diff changeset
1215 defined implicitly and automatically. */
kono
parents: 67
diff changeset
1216 static void
kono
parents: 67
diff changeset
1217 add_define_attr_for_define_subst (const char *attr_name, vec<rtx> *queue)
kono
parents: 67
diff changeset
1218 {
kono
parents: 67
diff changeset
1219 rtx const_str, return_rtx;
kono
parents: 67
diff changeset
1220
kono
parents: 67
diff changeset
1221 return_rtx = rtx_alloc (DEFINE_ATTR);
kono
parents: 67
diff changeset
1222 PUT_CODE (return_rtx, DEFINE_ATTR);
kono
parents: 67
diff changeset
1223
kono
parents: 67
diff changeset
1224 const_str = rtx_alloc (CONST_STRING);
kono
parents: 67
diff changeset
1225 PUT_CODE (const_str, CONST_STRING);
kono
parents: 67
diff changeset
1226 XSTR (const_str, 0) = xstrdup ("no");
kono
parents: 67
diff changeset
1227
kono
parents: 67
diff changeset
1228 XSTR (return_rtx, 0) = xstrdup (attr_name);
kono
parents: 67
diff changeset
1229 XSTR (return_rtx, 1) = xstrdup ("no,yes");
kono
parents: 67
diff changeset
1230 XEXP (return_rtx, 2) = const_str;
kono
parents: 67
diff changeset
1231
kono
parents: 67
diff changeset
1232 queue->safe_push (return_rtx);
kono
parents: 67
diff changeset
1233 }
kono
parents: 67
diff changeset
1234
kono
parents: 67
diff changeset
1235 /* This routine generates DEFINE_SUBST_ATTR expression with operands
kono
parents: 67
diff changeset
1236 ATTR_OPERANDS and places it to QUEUE. */
kono
parents: 67
diff changeset
1237 static void
kono
parents: 67
diff changeset
1238 add_define_subst_attr (const char **attr_operands, vec<rtx> *queue)
kono
parents: 67
diff changeset
1239 {
kono
parents: 67
diff changeset
1240 rtx return_rtx;
kono
parents: 67
diff changeset
1241 int i;
kono
parents: 67
diff changeset
1242
kono
parents: 67
diff changeset
1243 return_rtx = rtx_alloc (DEFINE_SUBST_ATTR);
kono
parents: 67
diff changeset
1244 PUT_CODE (return_rtx, DEFINE_SUBST_ATTR);
kono
parents: 67
diff changeset
1245
kono
parents: 67
diff changeset
1246 for (i = 0; i < 4; i++)
kono
parents: 67
diff changeset
1247 XSTR (return_rtx, i) = xstrdup (attr_operands[i]);
kono
parents: 67
diff changeset
1248
kono
parents: 67
diff changeset
1249 queue->safe_push (return_rtx);
kono
parents: 67
diff changeset
1250 }
kono
parents: 67
diff changeset
1251
kono
parents: 67
diff changeset
1252 /* Read define_subst_attribute construction. It has next form:
kono
parents: 67
diff changeset
1253 (define_subst_attribute <attribute_name> <iterator_name> <value1> <value2>)
kono
parents: 67
diff changeset
1254 Attribute is substituted with value1 when no subst is applied and with
kono
parents: 67
diff changeset
1255 value2 in the opposite case.
kono
parents: 67
diff changeset
1256 Attributes are added to SUBST_ATTRS_TABLE.
kono
parents: 67
diff changeset
1257 In case the iterator is encountered for the first time, it's added to
kono
parents: 67
diff changeset
1258 SUBST_ITERS_TABLE. Also, implicit define_attr is generated. */
kono
parents: 67
diff changeset
1259
kono
parents: 67
diff changeset
1260 static void
kono
parents: 67
diff changeset
1261 read_subst_mapping (htab_t subst_iters_table, htab_t subst_attrs_table,
kono
parents: 67
diff changeset
1262 vec<rtx> *queue)
kono
parents: 67
diff changeset
1263 {
kono
parents: 67
diff changeset
1264 struct mapping *m;
kono
parents: 67
diff changeset
1265 struct map_value **end_ptr;
kono
parents: 67
diff changeset
1266 const char *attr_operands[4];
kono
parents: 67
diff changeset
1267 int i;
kono
parents: 67
diff changeset
1268
kono
parents: 67
diff changeset
1269 for (i = 0; i < 4; i++)
kono
parents: 67
diff changeset
1270 attr_operands[i] = rtx_reader_ptr->read_string (false);
kono
parents: 67
diff changeset
1271
kono
parents: 67
diff changeset
1272 add_define_subst_attr (attr_operands, queue);
kono
parents: 67
diff changeset
1273
kono
parents: 67
diff changeset
1274 bind_subst_iter_and_attr (attr_operands[1], attr_operands[0]);
kono
parents: 67
diff changeset
1275
kono
parents: 67
diff changeset
1276 m = (struct mapping *) htab_find (substs.iterators, &attr_operands[1]);
kono
parents: 67
diff changeset
1277 if (!m)
kono
parents: 67
diff changeset
1278 {
kono
parents: 67
diff changeset
1279 m = add_mapping (&substs, subst_iters_table, attr_operands[1]);
kono
parents: 67
diff changeset
1280 end_ptr = &m->values;
kono
parents: 67
diff changeset
1281 end_ptr = add_map_value (end_ptr, 1, "");
kono
parents: 67
diff changeset
1282 end_ptr = add_map_value (end_ptr, 2, "");
kono
parents: 67
diff changeset
1283
kono
parents: 67
diff changeset
1284 add_define_attr_for_define_subst (attr_operands[1], queue);
kono
parents: 67
diff changeset
1285 }
kono
parents: 67
diff changeset
1286
kono
parents: 67
diff changeset
1287 m = add_mapping (&substs, subst_attrs_table, attr_operands[0]);
kono
parents: 67
diff changeset
1288 end_ptr = &m->values;
kono
parents: 67
diff changeset
1289 end_ptr = add_map_value (end_ptr, 1, attr_operands[2]);
kono
parents: 67
diff changeset
1290 end_ptr = add_map_value (end_ptr, 2, attr_operands[3]);
kono
parents: 67
diff changeset
1291 }
kono
parents: 67
diff changeset
1292
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1293 /* Check newly-created code iterator ITERATOR to see whether every code has the
111
kono
parents: 67
diff changeset
1294 same format. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1295
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1296 static void
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1297 check_code_iterator (struct mapping *iterator)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1298 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1299 struct map_value *v;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1300 enum rtx_code bellwether;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1301
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1302 bellwether = (enum rtx_code) iterator->values->number;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1303 for (v = iterator->values->next; v != 0; v = v->next)
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1304 if (strcmp (GET_RTX_FORMAT (bellwether), GET_RTX_FORMAT (v->number)) != 0)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1305 fatal_with_file_and_line ("code iterator `%s' combines "
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1306 "different rtx formats", iterator->name);
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1307 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1308
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1309 /* Read an rtx-related declaration from the MD file, given that it
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1310 starts with directive name RTX_NAME. Return true if it expands to
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1311 one or more rtxes (as defined by rtx.def). When returning true,
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1312 store the list of rtxes as an EXPR_LIST in *X. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1313
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1314 bool
111
kono
parents: 67
diff changeset
1315 rtx_reader::read_rtx (const char *rtx_name, vec<rtx> *rtxen)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1316 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1317 /* Handle various rtx-related declarations that aren't themselves
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1318 encoded as rtxes. */
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1319 if (strcmp (rtx_name, "define_conditions") == 0)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1320 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1321 read_conditions ();
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1322 return false;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1323 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1324 if (strcmp (rtx_name, "define_mode_attr") == 0)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1325 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1326 read_mapping (&modes, modes.attrs);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1327 return false;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1328 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1329 if (strcmp (rtx_name, "define_mode_iterator") == 0)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1330 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1331 read_mapping (&modes, modes.iterators);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1332 return false;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1333 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1334 if (strcmp (rtx_name, "define_code_attr") == 0)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1335 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1336 read_mapping (&codes, codes.attrs);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1337 return false;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1338 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1339 if (strcmp (rtx_name, "define_code_iterator") == 0)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1340 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1341 check_code_iterator (read_mapping (&codes, codes.iterators));
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1342 return false;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1343 }
111
kono
parents: 67
diff changeset
1344 if (strcmp (rtx_name, "define_int_attr") == 0)
kono
parents: 67
diff changeset
1345 {
kono
parents: 67
diff changeset
1346 read_mapping (&ints, ints.attrs);
kono
parents: 67
diff changeset
1347 return false;
kono
parents: 67
diff changeset
1348 }
kono
parents: 67
diff changeset
1349 if (strcmp (rtx_name, "define_int_iterator") == 0)
kono
parents: 67
diff changeset
1350 {
kono
parents: 67
diff changeset
1351 read_mapping (&ints, ints.iterators);
kono
parents: 67
diff changeset
1352 return false;
kono
parents: 67
diff changeset
1353 }
kono
parents: 67
diff changeset
1354 if (strcmp (rtx_name, "define_subst_attr") == 0)
kono
parents: 67
diff changeset
1355 {
kono
parents: 67
diff changeset
1356 read_subst_mapping (substs.iterators, substs.attrs, rtxen);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1357
111
kono
parents: 67
diff changeset
1358 /* READ_SUBST_MAPPING could generate a new DEFINE_ATTR. Return
kono
parents: 67
diff changeset
1359 TRUE to process it. */
kono
parents: 67
diff changeset
1360 return true;
kono
parents: 67
diff changeset
1361 }
kono
parents: 67
diff changeset
1362
kono
parents: 67
diff changeset
1363 apply_iterators (rtx_reader_ptr->read_rtx_code (rtx_name), rtxen);
kono
parents: 67
diff changeset
1364 iterator_uses.truncate (0);
kono
parents: 67
diff changeset
1365 attribute_uses.truncate (0);
kono
parents: 67
diff changeset
1366
kono
parents: 67
diff changeset
1367 return true;
kono
parents: 67
diff changeset
1368 }
kono
parents: 67
diff changeset
1369
kono
parents: 67
diff changeset
1370 #endif /* #ifdef GENERATOR_FILE */
kono
parents: 67
diff changeset
1371
kono
parents: 67
diff changeset
1372 /* Do one-time initialization. */
kono
parents: 67
diff changeset
1373
kono
parents: 67
diff changeset
1374 static void
kono
parents: 67
diff changeset
1375 one_time_initialization (void)
kono
parents: 67
diff changeset
1376 {
kono
parents: 67
diff changeset
1377 static bool initialized = false;
kono
parents: 67
diff changeset
1378
kono
parents: 67
diff changeset
1379 if (!initialized)
kono
parents: 67
diff changeset
1380 {
kono
parents: 67
diff changeset
1381 initialize_iterators ();
kono
parents: 67
diff changeset
1382 initialized = true;
kono
parents: 67
diff changeset
1383 }
kono
parents: 67
diff changeset
1384 }
kono
parents: 67
diff changeset
1385
kono
parents: 67
diff changeset
1386 /* Consume characters until encountering a character in TERMINATOR_CHARS,
kono
parents: 67
diff changeset
1387 consuming the terminator character if CONSUME_TERMINATOR is true.
kono
parents: 67
diff changeset
1388 Return all characters before the terminator as an allocated buffer. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1389
111
kono
parents: 67
diff changeset
1390 char *
kono
parents: 67
diff changeset
1391 rtx_reader::read_until (const char *terminator_chars, bool consume_terminator)
kono
parents: 67
diff changeset
1392 {
kono
parents: 67
diff changeset
1393 int ch = read_skip_spaces ();
kono
parents: 67
diff changeset
1394 unread_char (ch);
kono
parents: 67
diff changeset
1395 auto_vec<char> buf;
kono
parents: 67
diff changeset
1396 while (1)
kono
parents: 67
diff changeset
1397 {
kono
parents: 67
diff changeset
1398 ch = read_char ();
kono
parents: 67
diff changeset
1399 if (strchr (terminator_chars, ch))
kono
parents: 67
diff changeset
1400 {
kono
parents: 67
diff changeset
1401 if (!consume_terminator)
kono
parents: 67
diff changeset
1402 unread_char (ch);
kono
parents: 67
diff changeset
1403 break;
kono
parents: 67
diff changeset
1404 }
kono
parents: 67
diff changeset
1405 buf.safe_push (ch);
kono
parents: 67
diff changeset
1406 }
kono
parents: 67
diff changeset
1407 buf.safe_push ('\0');
kono
parents: 67
diff changeset
1408 return xstrdup (buf.address ());
kono
parents: 67
diff changeset
1409 }
kono
parents: 67
diff changeset
1410
kono
parents: 67
diff changeset
1411 /* Subroutine of read_rtx_code, for parsing zero or more flags. */
kono
parents: 67
diff changeset
1412
kono
parents: 67
diff changeset
1413 static void
kono
parents: 67
diff changeset
1414 read_flags (rtx return_rtx)
kono
parents: 67
diff changeset
1415 {
kono
parents: 67
diff changeset
1416 while (1)
kono
parents: 67
diff changeset
1417 {
kono
parents: 67
diff changeset
1418 int ch = read_char ();
kono
parents: 67
diff changeset
1419 if (ch != '/')
kono
parents: 67
diff changeset
1420 {
kono
parents: 67
diff changeset
1421 unread_char (ch);
kono
parents: 67
diff changeset
1422 break;
kono
parents: 67
diff changeset
1423 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1424
111
kono
parents: 67
diff changeset
1425 int flag_char = read_char ();
kono
parents: 67
diff changeset
1426 switch (flag_char)
kono
parents: 67
diff changeset
1427 {
kono
parents: 67
diff changeset
1428 case 's':
kono
parents: 67
diff changeset
1429 RTX_FLAG (return_rtx, in_struct) = 1;
kono
parents: 67
diff changeset
1430 break;
kono
parents: 67
diff changeset
1431 case 'v':
kono
parents: 67
diff changeset
1432 RTX_FLAG (return_rtx, volatil) = 1;
kono
parents: 67
diff changeset
1433 break;
kono
parents: 67
diff changeset
1434 case 'u':
kono
parents: 67
diff changeset
1435 RTX_FLAG (return_rtx, unchanging) = 1;
kono
parents: 67
diff changeset
1436 break;
kono
parents: 67
diff changeset
1437 case 'f':
kono
parents: 67
diff changeset
1438 RTX_FLAG (return_rtx, frame_related) = 1;
kono
parents: 67
diff changeset
1439 break;
kono
parents: 67
diff changeset
1440 case 'j':
kono
parents: 67
diff changeset
1441 RTX_FLAG (return_rtx, jump) = 1;
kono
parents: 67
diff changeset
1442 break;
kono
parents: 67
diff changeset
1443 case 'c':
kono
parents: 67
diff changeset
1444 RTX_FLAG (return_rtx, call) = 1;
kono
parents: 67
diff changeset
1445 break;
kono
parents: 67
diff changeset
1446 case 'i':
kono
parents: 67
diff changeset
1447 RTX_FLAG (return_rtx, return_val) = 1;
kono
parents: 67
diff changeset
1448 break;
kono
parents: 67
diff changeset
1449 default:
kono
parents: 67
diff changeset
1450 fatal_with_file_and_line ("unrecognized flag: `%c'", flag_char);
kono
parents: 67
diff changeset
1451 }
kono
parents: 67
diff changeset
1452 }
kono
parents: 67
diff changeset
1453 }
kono
parents: 67
diff changeset
1454
kono
parents: 67
diff changeset
1455 /* Return the numeric value n for GET_REG_NOTE_NAME (n) for STRING,
kono
parents: 67
diff changeset
1456 or fail if STRING isn't recognized. */
kono
parents: 67
diff changeset
1457
kono
parents: 67
diff changeset
1458 static int
kono
parents: 67
diff changeset
1459 parse_reg_note_name (const char *string)
kono
parents: 67
diff changeset
1460 {
kono
parents: 67
diff changeset
1461 for (int i = 0; i < REG_NOTE_MAX; i++)
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1462 if (strcmp (string, GET_REG_NOTE_NAME (i)) == 0)
111
kono
parents: 67
diff changeset
1463 return i;
kono
parents: 67
diff changeset
1464 fatal_with_file_and_line ("unrecognized REG_NOTE name: `%s'", string);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1465 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1466
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1467 /* Subroutine of read_rtx and read_nested_rtx. CODE_NAME is the name of
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1468 either an rtx code or a code iterator. Parse the rest of the rtx and
111
kono
parents: 67
diff changeset
1469 return it. */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1470
111
kono
parents: 67
diff changeset
1471 rtx
kono
parents: 67
diff changeset
1472 rtx_reader::read_rtx_code (const char *code_name)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1473 {
111
kono
parents: 67
diff changeset
1474 RTX_CODE code;
kono
parents: 67
diff changeset
1475 struct mapping *iterator = NULL;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1476 const char *format_ptr;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1477 struct md_name name;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1478 rtx return_rtx;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1479 int c;
111
kono
parents: 67
diff changeset
1480 long reuse_id = -1;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1481
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1482 /* Linked list structure for making RTXs: */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1483 struct rtx_list
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1484 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1485 struct rtx_list *next;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1486 rtx value; /* Value of this node. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1487 };
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1488
111
kono
parents: 67
diff changeset
1489 /* Handle reuse_rtx ids e.g. "(0|scratch:DI)". */
kono
parents: 67
diff changeset
1490 if (ISDIGIT (code_name[0]))
kono
parents: 67
diff changeset
1491 {
kono
parents: 67
diff changeset
1492 reuse_id = atoi (code_name);
kono
parents: 67
diff changeset
1493 while (char ch = *code_name++)
kono
parents: 67
diff changeset
1494 if (ch == '|')
kono
parents: 67
diff changeset
1495 break;
kono
parents: 67
diff changeset
1496 }
kono
parents: 67
diff changeset
1497
kono
parents: 67
diff changeset
1498 /* Handle "reuse_rtx". */
kono
parents: 67
diff changeset
1499 if (strcmp (code_name, "reuse_rtx") == 0)
kono
parents: 67
diff changeset
1500 {
kono
parents: 67
diff changeset
1501 read_name (&name);
kono
parents: 67
diff changeset
1502 unsigned idx = atoi (name.string);
kono
parents: 67
diff changeset
1503 /* Look it up by ID. */
kono
parents: 67
diff changeset
1504 gcc_assert (idx < m_reuse_rtx_by_id.length ());
kono
parents: 67
diff changeset
1505 return_rtx = m_reuse_rtx_by_id[idx];
kono
parents: 67
diff changeset
1506 return return_rtx;
kono
parents: 67
diff changeset
1507 }
kono
parents: 67
diff changeset
1508
kono
parents: 67
diff changeset
1509 /* If this code is an iterator, build the rtx using the iterator's
kono
parents: 67
diff changeset
1510 first value. */
kono
parents: 67
diff changeset
1511 #ifdef GENERATOR_FILE
kono
parents: 67
diff changeset
1512 iterator = (struct mapping *) htab_find (codes.iterators, &code_name);
kono
parents: 67
diff changeset
1513 if (iterator != 0)
kono
parents: 67
diff changeset
1514 code = (enum rtx_code) iterator->values->number;
kono
parents: 67
diff changeset
1515 else
kono
parents: 67
diff changeset
1516 code = (enum rtx_code) codes.find_builtin (code_name);
kono
parents: 67
diff changeset
1517 #else
kono
parents: 67
diff changeset
1518 code = (enum rtx_code) codes.find_builtin (code_name);
kono
parents: 67
diff changeset
1519 #endif
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1520
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1521 /* If we end up with an insn expression then we free this space below. */
111
kono
parents: 67
diff changeset
1522 return_rtx = rtx_alloc (code);
kono
parents: 67
diff changeset
1523 format_ptr = GET_RTX_FORMAT (code);
kono
parents: 67
diff changeset
1524 memset (return_rtx, 0, RTX_CODE_SIZE (code));
kono
parents: 67
diff changeset
1525 PUT_CODE (return_rtx, code);
kono
parents: 67
diff changeset
1526
kono
parents: 67
diff changeset
1527 if (reuse_id != -1)
kono
parents: 67
diff changeset
1528 {
kono
parents: 67
diff changeset
1529 /* Store away for later reuse. */
kono
parents: 67
diff changeset
1530 m_reuse_rtx_by_id.safe_grow_cleared (reuse_id + 1);
kono
parents: 67
diff changeset
1531 m_reuse_rtx_by_id[reuse_id] = return_rtx;
kono
parents: 67
diff changeset
1532 }
kono
parents: 67
diff changeset
1533
kono
parents: 67
diff changeset
1534 if (iterator)
kono
parents: 67
diff changeset
1535 record_iterator_use (iterator, return_rtx, 0);
kono
parents: 67
diff changeset
1536
kono
parents: 67
diff changeset
1537 /* Check for flags. */
kono
parents: 67
diff changeset
1538 read_flags (return_rtx);
kono
parents: 67
diff changeset
1539
kono
parents: 67
diff changeset
1540 /* Read REG_NOTE names for EXPR_LIST and INSN_LIST. */
kono
parents: 67
diff changeset
1541 if ((GET_CODE (return_rtx) == EXPR_LIST
kono
parents: 67
diff changeset
1542 || GET_CODE (return_rtx) == INSN_LIST
kono
parents: 67
diff changeset
1543 || GET_CODE (return_rtx) == INT_LIST)
kono
parents: 67
diff changeset
1544 && !m_in_call_function_usage)
kono
parents: 67
diff changeset
1545 {
kono
parents: 67
diff changeset
1546 char ch = read_char ();
kono
parents: 67
diff changeset
1547 if (ch == ':')
kono
parents: 67
diff changeset
1548 {
kono
parents: 67
diff changeset
1549 read_name (&name);
kono
parents: 67
diff changeset
1550 PUT_MODE_RAW (return_rtx,
kono
parents: 67
diff changeset
1551 (machine_mode)parse_reg_note_name (name.string));
kono
parents: 67
diff changeset
1552 }
kono
parents: 67
diff changeset
1553 else
kono
parents: 67
diff changeset
1554 unread_char (ch);
kono
parents: 67
diff changeset
1555 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1556
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1557 /* If what follows is `: mode ', read it and
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1558 store the mode in the rtx. */
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1559
111
kono
parents: 67
diff changeset
1560 c = read_skip_spaces ();
kono
parents: 67
diff changeset
1561 if (c == ':')
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1562 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1563 read_name (&name);
111
kono
parents: 67
diff changeset
1564 record_potential_iterator_use (&modes, return_rtx, 0, name.string);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1565 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1566 else
111
kono
parents: 67
diff changeset
1567 unread_char (c);
kono
parents: 67
diff changeset
1568
kono
parents: 67
diff changeset
1569 if (INSN_CHAIN_CODE_P (code))
kono
parents: 67
diff changeset
1570 {
kono
parents: 67
diff changeset
1571 read_name (&name);
kono
parents: 67
diff changeset
1572 INSN_UID (return_rtx) = atoi (name.string);
kono
parents: 67
diff changeset
1573 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1574
111
kono
parents: 67
diff changeset
1575 /* Use the format_ptr to parse the various operands of this rtx. */
kono
parents: 67
diff changeset
1576 for (int idx = 0; format_ptr[idx] != 0; idx++)
kono
parents: 67
diff changeset
1577 return_rtx = read_rtx_operand (return_rtx, idx);
kono
parents: 67
diff changeset
1578
kono
parents: 67
diff changeset
1579 /* Handle any additional information that after the regular fields
kono
parents: 67
diff changeset
1580 (e.g. when parsing function dumps). */
kono
parents: 67
diff changeset
1581 handle_any_trailing_information (return_rtx);
kono
parents: 67
diff changeset
1582
kono
parents: 67
diff changeset
1583 if (CONST_WIDE_INT_P (return_rtx))
kono
parents: 67
diff changeset
1584 {
kono
parents: 67
diff changeset
1585 read_name (&name);
kono
parents: 67
diff changeset
1586 validate_const_wide_int (name.string);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1587 {
111
kono
parents: 67
diff changeset
1588 const char *s = name.string;
kono
parents: 67
diff changeset
1589 int len;
kono
parents: 67
diff changeset
1590 int index = 0;
kono
parents: 67
diff changeset
1591 int gs = HOST_BITS_PER_WIDE_INT/4;
kono
parents: 67
diff changeset
1592 int pos;
kono
parents: 67
diff changeset
1593 char * buf = XALLOCAVEC (char, gs + 1);
kono
parents: 67
diff changeset
1594 unsigned HOST_WIDE_INT wi;
kono
parents: 67
diff changeset
1595 int wlen;
kono
parents: 67
diff changeset
1596
kono
parents: 67
diff changeset
1597 /* Skip the leading spaces. */
kono
parents: 67
diff changeset
1598 while (*s && ISSPACE (*s))
kono
parents: 67
diff changeset
1599 s++;
kono
parents: 67
diff changeset
1600
kono
parents: 67
diff changeset
1601 /* Skip the leading 0x. */
kono
parents: 67
diff changeset
1602 gcc_assert (s[0] == '0');
kono
parents: 67
diff changeset
1603 gcc_assert (s[1] == 'x');
kono
parents: 67
diff changeset
1604 s += 2;
kono
parents: 67
diff changeset
1605
kono
parents: 67
diff changeset
1606 len = strlen (s);
kono
parents: 67
diff changeset
1607 pos = len - gs;
kono
parents: 67
diff changeset
1608 wlen = (len + gs - 1) / gs; /* Number of words needed */
kono
parents: 67
diff changeset
1609
kono
parents: 67
diff changeset
1610 return_rtx = const_wide_int_alloc (wlen);
kono
parents: 67
diff changeset
1611
kono
parents: 67
diff changeset
1612 while (pos > 0)
kono
parents: 67
diff changeset
1613 {
kono
parents: 67
diff changeset
1614 #if HOST_BITS_PER_WIDE_INT == 64
kono
parents: 67
diff changeset
1615 sscanf (s + pos, "%16" HOST_WIDE_INT_PRINT "x", &wi);
kono
parents: 67
diff changeset
1616 #else
kono
parents: 67
diff changeset
1617 sscanf (s + pos, "%8" HOST_WIDE_INT_PRINT "x", &wi);
kono
parents: 67
diff changeset
1618 #endif
kono
parents: 67
diff changeset
1619 CWI_ELT (return_rtx, index++) = wi;
kono
parents: 67
diff changeset
1620 pos -= gs;
kono
parents: 67
diff changeset
1621 }
kono
parents: 67
diff changeset
1622 strncpy (buf, s, gs - pos);
kono
parents: 67
diff changeset
1623 buf [gs - pos] = 0;
kono
parents: 67
diff changeset
1624 sscanf (buf, "%" HOST_WIDE_INT_PRINT "x", &wi);
kono
parents: 67
diff changeset
1625 CWI_ELT (return_rtx, index++) = wi;
kono
parents: 67
diff changeset
1626 /* TODO: After reading, do we want to canonicalize with:
kono
parents: 67
diff changeset
1627 value = lookup_const_wide_int (value); ? */
kono
parents: 67
diff changeset
1628 }
kono
parents: 67
diff changeset
1629 }
kono
parents: 67
diff changeset
1630
kono
parents: 67
diff changeset
1631 c = read_skip_spaces ();
kono
parents: 67
diff changeset
1632 /* Syntactic sugar for AND and IOR, allowing Lisp-like
kono
parents: 67
diff changeset
1633 arbitrary number of arguments for them. */
kono
parents: 67
diff changeset
1634 if (c == '('
kono
parents: 67
diff changeset
1635 && (GET_CODE (return_rtx) == AND
kono
parents: 67
diff changeset
1636 || GET_CODE (return_rtx) == IOR))
kono
parents: 67
diff changeset
1637 return read_rtx_variadic (return_rtx);
kono
parents: 67
diff changeset
1638
kono
parents: 67
diff changeset
1639 unread_char (c);
kono
parents: 67
diff changeset
1640 return return_rtx;
kono
parents: 67
diff changeset
1641 }
kono
parents: 67
diff changeset
1642
kono
parents: 67
diff changeset
1643 /* Subroutine of read_rtx_code. Parse operand IDX within RETURN_RTX,
kono
parents: 67
diff changeset
1644 based on the corresponding format character within GET_RTX_FORMAT
kono
parents: 67
diff changeset
1645 for the GET_CODE (RETURN_RTX), and return RETURN_RTX.
kono
parents: 67
diff changeset
1646 This is a virtual function, so that function_reader can override
kono
parents: 67
diff changeset
1647 some parsing, and potentially return a different rtx. */
kono
parents: 67
diff changeset
1648
kono
parents: 67
diff changeset
1649 rtx
kono
parents: 67
diff changeset
1650 rtx_reader::read_rtx_operand (rtx return_rtx, int idx)
kono
parents: 67
diff changeset
1651 {
kono
parents: 67
diff changeset
1652 RTX_CODE code = GET_CODE (return_rtx);
kono
parents: 67
diff changeset
1653 const char *format_ptr = GET_RTX_FORMAT (code);
kono
parents: 67
diff changeset
1654 int c;
kono
parents: 67
diff changeset
1655 struct md_name name;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1656
111
kono
parents: 67
diff changeset
1657 switch (format_ptr[idx])
kono
parents: 67
diff changeset
1658 {
kono
parents: 67
diff changeset
1659 /* 0 means a field for internal use only.
kono
parents: 67
diff changeset
1660 Don't expect it to be present in the input. */
kono
parents: 67
diff changeset
1661 case '0':
kono
parents: 67
diff changeset
1662 if (code == REG)
kono
parents: 67
diff changeset
1663 ORIGINAL_REGNO (return_rtx) = REGNO (return_rtx);
kono
parents: 67
diff changeset
1664 break;
kono
parents: 67
diff changeset
1665
kono
parents: 67
diff changeset
1666 case 'e':
kono
parents: 67
diff changeset
1667 XEXP (return_rtx, idx) = read_nested_rtx ();
kono
parents: 67
diff changeset
1668 break;
kono
parents: 67
diff changeset
1669
kono
parents: 67
diff changeset
1670 case 'u':
kono
parents: 67
diff changeset
1671 XEXP (return_rtx, idx) = read_nested_rtx ();
kono
parents: 67
diff changeset
1672 break;
kono
parents: 67
diff changeset
1673
kono
parents: 67
diff changeset
1674 case 'V':
kono
parents: 67
diff changeset
1675 /* 'V' is an optional vector: if a closeparen follows,
kono
parents: 67
diff changeset
1676 just store NULL for this element. */
kono
parents: 67
diff changeset
1677 c = read_skip_spaces ();
kono
parents: 67
diff changeset
1678 unread_char (c);
kono
parents: 67
diff changeset
1679 if (c == ')')
kono
parents: 67
diff changeset
1680 {
kono
parents: 67
diff changeset
1681 XVEC (return_rtx, idx) = 0;
kono
parents: 67
diff changeset
1682 break;
kono
parents: 67
diff changeset
1683 }
kono
parents: 67
diff changeset
1684 /* Now process the vector. */
kono
parents: 67
diff changeset
1685 /* FALLTHRU */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1686
111
kono
parents: 67
diff changeset
1687 case 'E':
kono
parents: 67
diff changeset
1688 {
kono
parents: 67
diff changeset
1689 /* Obstack to store scratch vector in. */
kono
parents: 67
diff changeset
1690 struct obstack vector_stack;
kono
parents: 67
diff changeset
1691 int list_counter = 0;
kono
parents: 67
diff changeset
1692 rtvec return_vec = NULL_RTVEC;
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1693 rtx saved_rtx = NULL_RTX;
111
kono
parents: 67
diff changeset
1694
kono
parents: 67
diff changeset
1695 require_char_ws ('[');
kono
parents: 67
diff changeset
1696
kono
parents: 67
diff changeset
1697 /* Add expressions to a list, while keeping a count. */
kono
parents: 67
diff changeset
1698 obstack_init (&vector_stack);
kono
parents: 67
diff changeset
1699 while ((c = read_skip_spaces ()) && c != ']')
kono
parents: 67
diff changeset
1700 {
kono
parents: 67
diff changeset
1701 if (c == EOF)
kono
parents: 67
diff changeset
1702 fatal_expected_char (']', c);
kono
parents: 67
diff changeset
1703 unread_char (c);
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1704
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1705 rtx value;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1706 int repeat_count = 1;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1707 if (c == 'r')
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1708 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1709 /* Process "repeated xN" directive. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1710 read_name (&name);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1711 if (strcmp (name.string, "repeated"))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1712 fatal_with_file_and_line ("invalid directive \"%s\"\n",
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1713 name.string);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1714 read_name (&name);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1715 if (!sscanf (name.string, "x%d", &repeat_count))
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1716 fatal_with_file_and_line ("invalid repeat count \"%s\"\n",
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1717 name.string);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1718
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1719 /* We already saw one of the instances. */
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1720 repeat_count--;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1721 value = saved_rtx;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1722 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1723 else
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1724 value = read_nested_rtx ();
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1725
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1726 for (; repeat_count > 0; repeat_count--)
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1727 {
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1728 list_counter++;
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1729 obstack_ptr_grow (&vector_stack, value);
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1730 }
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1731 saved_rtx = value;
111
kono
parents: 67
diff changeset
1732 }
kono
parents: 67
diff changeset
1733 if (list_counter > 0)
kono
parents: 67
diff changeset
1734 {
kono
parents: 67
diff changeset
1735 return_vec = rtvec_alloc (list_counter);
kono
parents: 67
diff changeset
1736 memcpy (&return_vec->elem[0], obstack_finish (&vector_stack),
kono
parents: 67
diff changeset
1737 list_counter * sizeof (rtx));
kono
parents: 67
diff changeset
1738 }
kono
parents: 67
diff changeset
1739 else if (format_ptr[idx] == 'E')
kono
parents: 67
diff changeset
1740 fatal_with_file_and_line ("vector must have at least one element");
kono
parents: 67
diff changeset
1741 XVEC (return_rtx, idx) = return_vec;
kono
parents: 67
diff changeset
1742 obstack_free (&vector_stack, NULL);
kono
parents: 67
diff changeset
1743 /* close bracket gotten */
kono
parents: 67
diff changeset
1744 }
kono
parents: 67
diff changeset
1745 break;
kono
parents: 67
diff changeset
1746
kono
parents: 67
diff changeset
1747 case 'S':
kono
parents: 67
diff changeset
1748 case 'T':
kono
parents: 67
diff changeset
1749 case 's':
kono
parents: 67
diff changeset
1750 {
kono
parents: 67
diff changeset
1751 char *stringbuf;
kono
parents: 67
diff changeset
1752 int star_if_braced;
kono
parents: 67
diff changeset
1753
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1754 c = read_skip_spaces ();
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1755 unread_char (c);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1756 if (c == ')')
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1757 {
111
kono
parents: 67
diff changeset
1758 /* 'S' fields are optional and should be NULL if no string
kono
parents: 67
diff changeset
1759 was given. Also allow normal 's' and 'T' strings to be
kono
parents: 67
diff changeset
1760 omitted, treating them in the same way as empty strings. */
kono
parents: 67
diff changeset
1761 XSTR (return_rtx, idx) = (format_ptr[idx] == 'S' ? NULL : "");
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1762 break;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1763 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1764
111
kono
parents: 67
diff changeset
1765 /* The output template slot of a DEFINE_INSN,
kono
parents: 67
diff changeset
1766 DEFINE_INSN_AND_SPLIT, or DEFINE_PEEPHOLE automatically
kono
parents: 67
diff changeset
1767 gets a star inserted as its first character, if it is
kono
parents: 67
diff changeset
1768 written with a brace block instead of a string constant. */
kono
parents: 67
diff changeset
1769 star_if_braced = (format_ptr[idx] == 'T');
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1770
111
kono
parents: 67
diff changeset
1771 stringbuf = read_string (star_if_braced);
kono
parents: 67
diff changeset
1772 if (!stringbuf)
kono
parents: 67
diff changeset
1773 break;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1774
111
kono
parents: 67
diff changeset
1775 #ifdef GENERATOR_FILE
kono
parents: 67
diff changeset
1776 /* For insn patterns, we want to provide a default name
kono
parents: 67
diff changeset
1777 based on the file and line, like "*foo.md:12", if the
kono
parents: 67
diff changeset
1778 given name is blank. These are only for define_insn and
kono
parents: 67
diff changeset
1779 define_insn_and_split, to aid debugging. */
kono
parents: 67
diff changeset
1780 if (*stringbuf == '\0'
kono
parents: 67
diff changeset
1781 && idx == 0
kono
parents: 67
diff changeset
1782 && (GET_CODE (return_rtx) == DEFINE_INSN
kono
parents: 67
diff changeset
1783 || GET_CODE (return_rtx) == DEFINE_INSN_AND_SPLIT))
kono
parents: 67
diff changeset
1784 {
kono
parents: 67
diff changeset
1785 struct obstack *string_obstack = get_string_obstack ();
kono
parents: 67
diff changeset
1786 char line_name[20];
kono
parents: 67
diff changeset
1787 const char *read_md_filename = get_filename ();
kono
parents: 67
diff changeset
1788 const char *fn = (read_md_filename ? read_md_filename : "rtx");
kono
parents: 67
diff changeset
1789 const char *slash;
kono
parents: 67
diff changeset
1790 for (slash = fn; *slash; slash ++)
kono
parents: 67
diff changeset
1791 if (*slash == '/' || *slash == '\\' || *slash == ':')
kono
parents: 67
diff changeset
1792 fn = slash + 1;
kono
parents: 67
diff changeset
1793 obstack_1grow (string_obstack, '*');
kono
parents: 67
diff changeset
1794 obstack_grow (string_obstack, fn, strlen (fn));
kono
parents: 67
diff changeset
1795 sprintf (line_name, ":%d", get_lineno ());
kono
parents: 67
diff changeset
1796 obstack_grow (string_obstack, line_name, strlen (line_name)+1);
kono
parents: 67
diff changeset
1797 stringbuf = XOBFINISH (string_obstack, char *);
kono
parents: 67
diff changeset
1798 }
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1799
111
kono
parents: 67
diff changeset
1800 /* Find attr-names in the string. */
kono
parents: 67
diff changeset
1801 char *str;
kono
parents: 67
diff changeset
1802 char *start, *end, *ptr;
kono
parents: 67
diff changeset
1803 char tmpstr[256];
kono
parents: 67
diff changeset
1804 ptr = &tmpstr[0];
kono
parents: 67
diff changeset
1805 end = stringbuf;
kono
parents: 67
diff changeset
1806 while ((start = strchr (end, '<')) && (end = strchr (start, '>')))
kono
parents: 67
diff changeset
1807 {
kono
parents: 67
diff changeset
1808 if ((end - start - 1 > 0)
kono
parents: 67
diff changeset
1809 && (end - start - 1 < (int)sizeof (tmpstr)))
kono
parents: 67
diff changeset
1810 {
kono
parents: 67
diff changeset
1811 strncpy (tmpstr, start+1, end-start-1);
kono
parents: 67
diff changeset
1812 tmpstr[end-start-1] = 0;
kono
parents: 67
diff changeset
1813 end++;
kono
parents: 67
diff changeset
1814 }
kono
parents: 67
diff changeset
1815 else
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1816 break;
111
kono
parents: 67
diff changeset
1817 struct mapping *m
kono
parents: 67
diff changeset
1818 = (struct mapping *) htab_find (substs.attrs, &ptr);
kono
parents: 67
diff changeset
1819 if (m != 0)
kono
parents: 67
diff changeset
1820 {
kono
parents: 67
diff changeset
1821 /* Here we should find linked subst-iter. */
kono
parents: 67
diff changeset
1822 str = find_subst_iter_by_attr (ptr);
kono
parents: 67
diff changeset
1823 if (str)
kono
parents: 67
diff changeset
1824 m = (struct mapping *) htab_find (substs.iterators, &str);
kono
parents: 67
diff changeset
1825 else
kono
parents: 67
diff changeset
1826 m = 0;
kono
parents: 67
diff changeset
1827 }
kono
parents: 67
diff changeset
1828 if (m != 0)
kono
parents: 67
diff changeset
1829 record_iterator_use (m, return_rtx, 0);
kono
parents: 67
diff changeset
1830 }
kono
parents: 67
diff changeset
1831 #endif /* #ifdef GENERATOR_FILE */
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1832
111
kono
parents: 67
diff changeset
1833 const char *string_ptr = finalize_string (stringbuf);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1834
111
kono
parents: 67
diff changeset
1835 if (star_if_braced)
kono
parents: 67
diff changeset
1836 XTMPL (return_rtx, idx) = string_ptr;
kono
parents: 67
diff changeset
1837 else
kono
parents: 67
diff changeset
1838 XSTR (return_rtx, idx) = string_ptr;
kono
parents: 67
diff changeset
1839 }
kono
parents: 67
diff changeset
1840 break;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1841
111
kono
parents: 67
diff changeset
1842 case 'w':
kono
parents: 67
diff changeset
1843 {
kono
parents: 67
diff changeset
1844 HOST_WIDE_INT tmp_wide;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1845 read_name (&name);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1846 validate_const_int (name.string);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1847 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1848 tmp_wide = atoi (name.string);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1849 #else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1850 #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_LONG
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1851 tmp_wide = atol (name.string);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1852 #else
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1853 /* Prefer atoll over atoq, since the former is in the ISO C99 standard.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1854 But prefer not to use our hand-rolled function above either. */
111
kono
parents: 67
diff changeset
1855 #if HAVE_DECL_ATOLL || !defined(HAVE_ATOQ)
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1856 tmp_wide = atoll (name.string);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1857 #else
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1858 tmp_wide = atoq (name.string);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1859 #endif
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1860 #endif
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1861 #endif
111
kono
parents: 67
diff changeset
1862 XWINT (return_rtx, idx) = tmp_wide;
kono
parents: 67
diff changeset
1863 }
kono
parents: 67
diff changeset
1864 break;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1865
111
kono
parents: 67
diff changeset
1866 case 'i':
kono
parents: 67
diff changeset
1867 case 'n':
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
1868 case 'p':
111
kono
parents: 67
diff changeset
1869 /* Can be an iterator or an integer constant. */
kono
parents: 67
diff changeset
1870 read_name (&name);
kono
parents: 67
diff changeset
1871 record_potential_iterator_use (&ints, return_rtx, idx, name.string);
kono
parents: 67
diff changeset
1872 break;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1873
111
kono
parents: 67
diff changeset
1874 case 'r':
kono
parents: 67
diff changeset
1875 read_name (&name);
kono
parents: 67
diff changeset
1876 validate_const_int (name.string);
kono
parents: 67
diff changeset
1877 set_regno_raw (return_rtx, atoi (name.string), 1);
kono
parents: 67
diff changeset
1878 REG_ATTRS (return_rtx) = NULL;
kono
parents: 67
diff changeset
1879 break;
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1880
111
kono
parents: 67
diff changeset
1881 default:
kono
parents: 67
diff changeset
1882 gcc_unreachable ();
kono
parents: 67
diff changeset
1883 }
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1884
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1885 return return_rtx;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1886 }
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1887
111
kono
parents: 67
diff changeset
1888 /* Read a nested rtx construct from the MD file and return it. */
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1889
111
kono
parents: 67
diff changeset
1890 rtx
kono
parents: 67
diff changeset
1891 rtx_reader::read_nested_rtx ()
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1892 {
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1893 struct md_name name;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1894 rtx return_rtx;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1895
111
kono
parents: 67
diff changeset
1896 /* In compact dumps, trailing "(nil)" values can be omitted.
kono
parents: 67
diff changeset
1897 Handle such dumps. */
kono
parents: 67
diff changeset
1898 if (peek_char () == ')')
kono
parents: 67
diff changeset
1899 return NULL_RTX;
kono
parents: 67
diff changeset
1900
kono
parents: 67
diff changeset
1901 require_char_ws ('(');
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1902
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1903 read_name (&name);
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1904 if (strcmp (name.string, "nil") == 0)
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1905 return_rtx = NULL;
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1906 else
111
kono
parents: 67
diff changeset
1907 return_rtx = read_rtx_code (name.string);
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1908
111
kono
parents: 67
diff changeset
1909 require_char_ws (')');
kono
parents: 67
diff changeset
1910
kono
parents: 67
diff changeset
1911 return_rtx = postprocess (return_rtx);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1912
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1913 return return_rtx;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1914 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1915
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1916 /* Mutually recursive subroutine of read_rtx which reads
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1917 (thing x1 x2 x3 ...) and produces RTL as if
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1918 (thing x1 (thing x2 (thing x3 ...))) had been written.
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1919 When called, FORM is (thing x1 x2), and the file position
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1920 is just past the leading parenthesis of x3. Only works
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1921 for THINGs which are dyadic expressions, e.g. AND, IOR. */
111
kono
parents: 67
diff changeset
1922 rtx
kono
parents: 67
diff changeset
1923 rtx_reader::read_rtx_variadic (rtx form)
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1924 {
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1925 char c = '(';
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1926 rtx p = form, q;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1927
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1928 do
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1929 {
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1930 unread_char (c);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1931
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1932 q = rtx_alloc (GET_CODE (p));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1933 PUT_MODE (q, GET_MODE (p));
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1934
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1935 XEXP (q, 0) = XEXP (p, 1);
111
kono
parents: 67
diff changeset
1936 XEXP (q, 1) = read_nested_rtx ();
55
77e2b8dfacca update it from 4.4.3 to 4.5.0
ryoma <e075725@ie.u-ryukyu.ac.jp>
parents: 0
diff changeset
1937
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1938 XEXP (p, 1) = q;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1939 p = q;
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1940 c = read_skip_spaces ();
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1941 }
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1942 while (c == '(');
67
f6334be47118 update gcc from gcc-4.6-20100522 to gcc-4.6-20110318
nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp>
parents: 63
diff changeset
1943 unread_char (c);
0
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1944 return form;
a06113de4d67 first commit
kent <kent@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1945 }
111
kono
parents: 67
diff changeset
1946
kono
parents: 67
diff changeset
1947 /* Constructor for class rtx_reader. */
kono
parents: 67
diff changeset
1948
kono
parents: 67
diff changeset
1949 rtx_reader::rtx_reader (bool compact)
kono
parents: 67
diff changeset
1950 : md_reader (compact),
kono
parents: 67
diff changeset
1951 m_in_call_function_usage (false)
kono
parents: 67
diff changeset
1952 {
kono
parents: 67
diff changeset
1953 /* Set the global singleton pointer. */
kono
parents: 67
diff changeset
1954 rtx_reader_ptr = this;
kono
parents: 67
diff changeset
1955
kono
parents: 67
diff changeset
1956 one_time_initialization ();
kono
parents: 67
diff changeset
1957 }
kono
parents: 67
diff changeset
1958
kono
parents: 67
diff changeset
1959 /* Destructor for class rtx_reader. */
kono
parents: 67
diff changeset
1960
kono
parents: 67
diff changeset
1961 rtx_reader::~rtx_reader ()
kono
parents: 67
diff changeset
1962 {
kono
parents: 67
diff changeset
1963 /* Clear the global singleton pointer. */
kono
parents: 67
diff changeset
1964 rtx_reader_ptr = NULL;
kono
parents: 67
diff changeset
1965 }