annotate gcc/read-rtl.c @ 111:04ced10e8804

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