summaryrefslogtreecommitdiff
path: root/gcc/read-rtl.c
diff options
context:
space:
mode:
authordmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-18 00:19:17 +0000
committerdmalcolm <dmalcolm@138bc75d-0d04-0410-961f-82ee72b054a4>2016-10-18 00:19:17 +0000
commite1e9159bc39cb2dcc171ef549cdf1dfadc0d74b7 (patch)
treea410a1eb6efa653792b4500a10e0449b5a96b937 /gcc/read-rtl.c
parentc003f8a52bea81df723e2724e9440f4f040d717d (diff)
downloadgcc-e1e9159bc39cb2dcc171ef549cdf1dfadc0d74b7.tar.gz
read-md.c: Move various state to within class rtx_reader
gcc/ChangeLog: * genattrtab.c (attr_string): Use rtx_reader_ptr for call to copy_md_ptr_loc. (gen_attr): Use rtx_reader_ptr for lookup_enum_type call. (write_test_expr): Use rtx_reader_ptr for calls to fprint_c_condition. (write_attr_value): Likewise. * genconditions.c (write_one_condition): Use rtx_reader_ptr for call to print_md_ptr_loc. (write_one_condition): Likewise for calls to print_c_condition. * genconstants.c: Include "statistics.h" and "vec.h". (main): Update for conversion to member functions. * genemit.c (emit_c_code): Use rtx_reader_ptr for call to print_md_ptr_loc. * genenums.c: Include "statistics.h" and "vec.h". (main): Update for conversion of traverse_enum_types to a method. * genmddeps.c: Include "statistics.h" and "vec.h". * genoutput.c (process_template): Use rtx_reader_ptr for call to print_md_ptr_loc. * genpreds.c (write_predicate_subfunction): Likewise. (write_predicate_expr): Likewise for calls to print_c_condition. * genrecog.c (print_test): Likewise. * gensupport.c (process_rtx): Likewise for calls to copy_md_ptr_loc and join_c_conditions. (alter_test_for_insn): Likewise for call to join_c_conditions. (process_substs_on_one_elem): Likewise. (gen_mnemonic_setattr): Update for move of string_obstack to a field of rtx_reader. (mnemonic_htab_callback): Likewise. Fix formatting. (gen_mnemonic_attr): Likewise. * gentarget-def.c (def_target_insn): Use rtx_reader_ptr for calls to print_c_condition. * read-md.c: Include "statistics.h" and "vec.h". (string_obstack): Convert this global to field "m_string_obstack" of class rtx_reader. (ptr_locs): Likewise, as "m_ptr_locs". (ptr_loc_obstack): Likewise, as "m_ptr_loc_obstack". (joined_conditions): Likewise, as "m_joined_conditions". (joined_conditions_obstack): Likewise, as "m_joined_conditions_obstack". (md_constants): Likewise, as "m_md_constants". (enum_types): Likewise, as "m_enum_types". (set_md_ptr_loc): Convert to... (rtx_reader::set_md_ptr_loc): ...member function. (get_md_ptr_loc): Convert to... (rtx_reader::get_md_ptr_loc): ...member function. (copy_md_ptr_loc): Convert to... (rtx_reader::copy_md_ptr_loc): ...member function. (fprint_md_ptr_loc): Convert to... (rtx_reader::fprint_md_ptr_loc): ...member function. (print_md_ptr_loc): Convert to... (rtx_reader::print_md_ptr_loc): ...member function. (join_c_conditions): Convert to... (rtx_reader::join_c_conditions): ...member function. (fprint_c_condition): Convert to... (rtx_reader::fprint_c_condition): ...member function. (print_c_condition): Convert to... (rtx_reader::print_c_condition): ...member function. (read_name): Convert to... (rtx_reader::read_name): ...member function. (read_escape): Convert to... (rtx_reader::read_escape): ...member function. (read_quoted_string): Convert to... (rtx_reader::read_quoted_string): ...member function. (read_braced_string): Convert to... (rtx_reader::read_braced_string): ...member function. (read_string): Convert to... (rtx_reader::read_string): ...member function. (read_skip_construct): Convert to... (rtx_reader::read_skip_construct): ...member function. (handle_constants): Convert to... (rtx_reader::handle_constants): ...member function. (traverse_md_constants): Convert to... (rtx_reader::traverse_md_constants): ...member function. (handle_enum): Convert to... (rtx_reader::handle_enum): ...member function. (lookup_enum_type): Convert to... (rtx_reader::lookup_enum_type): ...member function. (traverse_enum_types): Convert to... (rtx_reader::traverse_enum_types): ...member function. (rtx_reader::rtx_reader): Move initializations of various former global data from rtx_reader::read_md_files to here, as fields, along with the call to unlock_std_streams. (rtx_reader::~rtx_reader): Clean up m_base_dir, and clean up the new fields. (rtx_reader::read_md_files): Move initializations of various global data from here to the ctor. * read-md.h (read_name): Convert to... (rtx_reader::read_name): ...member function. (rtx_reader::read_escape): New method decl. (read_quoted_string): Convert to... (rtx_reader::read_quoted_string): ...member function. (rtx_reader::read_braced_string): New method decl. (read_string): Convert to... (rtx_reader::read_string): ...member function. (rtx_reader::read_skip_construct): New method decl. (rtx_reader::set_md_ptr_loc): New method decl. (rtx_reader::get_md_ptr_loc): New method decl. (copy_md_ptr_loc): Convert to... (rtx_reader::copy_md_ptr_loc): ...member function. (fprint_md_ptr_loc): Convert to... (rtx_reader::fprint_md_ptr_loc): ...member function. (print_md_ptr_loc): Convert to... (rtx_reader::print_md_ptr_loc): ...member function. (rtx_reader::lookup_enum_type): New method decl. (rtx_reader::traverse_enum_types): New method decl. (rtx_reader::handle_constants): New method decl. (traverse_md_constants): Convert to... (rtx_reader::traverse_md_constants): ...member function. (rtx_reader::handle_enum): New method decl. (rtx_reader::join_c_conditions): New method decl. (fprint_c_condition): Convert to... (rtx_reader::fprint_c_condition): ...member function. (print_c_condition): Convert to... (rtx_reader::print_c_condition): ...member function. (rtx_reader::apply_iterator_to_string): New method decl. (rtx_reader::copy_rtx_for_iterators): New method decl. (rtx_reader::read_conditions): New method decl. (rtx_reader::record_potential_iterator_use): New method decl. (rtx_reader::read_mapping): New method decl. (rtx_reader::read_rtx): New method decl. (rtx_reader::read_rtx_code): New method decl. (rtx_reader::read_rtx_operand): New method decl. (rtx_reader::read_nested_rtx): New method decl. (rtx_reader::read_rtx_variadic): New method decl. (rtx_reader::get_string_obstack): New method. (rtx_reader::get_md_constants): New method. (string_obstack): Convert global variable decl to... (rtx_reader::m_string_obstack): ...this new field. (rtx_reader::m_ptr_locs): New field. (rtx_reader::m_ptr_loc_obstack): New field. (rtx_reader::m_joined_conditions): New field. (rtx_reader::m_joined_conditions_obstack): New field. (rtx_reader::m_md_constants): New field. (rtx_reader::m_enum_types): New field. * read-rtl.c (apply_iterator_to_string): Convert to... (rtx_reader::apply_iterator_to_string): ...member function. (copy_rtx_for_iterators): Convert to... (rtx_reader::copy_rtx_for_iterators): ...member function. (add_condition_to_string): Use rtx_reader_ptr for calls join_c_conditions. (apply_iterators): Use rtx_reader_ptr for calls to join_c_conditions and copy_rtx_for_iterators. (read_conditions): Convert to... (rtx_reader::read_conditions): ...member function. (record_potential_iterator_use): Convert to... (rtx_reader::record_potential_iterator_use): ...member function. (read_mapping): Convert to... (rtx_reader::read_mapping): ...member function. (read_subst_mapping): Use rtx_reader_ptr for read_string call. (read_rtx): Convert to... (rtx_reader::read_rtx): ...member function. (read_rtx_code): Convert to... (rtx_reader::read_rtx_code): ...member function. (read_rtx_operand): Convert to... (rtx_reader::read_rtx_operand): ...member function. Update for move of string_obstack to a field. (read_nested_rtx): Convert to.. (rtx_reader::read_nested_rtx): ...member function. (read_rtx_variadic): Convert to.. (rtx_reader::read_rtx_variadic): ...member function. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@241293 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/read-rtl.c')
-rw-r--r--gcc/read-rtl.c76
1 files changed, 36 insertions, 40 deletions
diff --git a/gcc/read-rtl.c b/gcc/read-rtl.c
index 925ea451c9d..7a2021a3a23 100644
--- a/gcc/read-rtl.c
+++ b/gcc/read-rtl.c
@@ -106,10 +106,6 @@ htab_t subst_attr_to_iter_map = NULL;
const char *current_iterator_name;
static void validate_const_int (const char *);
-static rtx read_rtx_code (const char *);
-static void read_rtx_operand (rtx, int);
-static rtx read_nested_rtx (void);
-static rtx read_rtx_variadic (rtx);
/* The mode and code iterator structures. */
static struct iterator_group modes, codes, ints, substs;
@@ -329,8 +325,8 @@ map_attr_string (const char *p)
/* Apply the current iterator values to STRING. Return the new string
if any changes were needed, otherwise return STRING itself. */
-static const char *
-apply_iterator_to_string (const char *string)
+const char *
+rtx_reader::apply_iterator_to_string (const char *string)
{
char *base, *copy, *p, *start, *end;
struct map_value *v;
@@ -351,14 +347,14 @@ apply_iterator_to_string (const char *string)
/* Add everything between the last copied byte and the '<',
then add in the attribute value. */
- obstack_grow (&string_obstack, base, start - base);
- obstack_grow (&string_obstack, v->string, strlen (v->string));
+ obstack_grow (&m_string_obstack, base, start - base);
+ obstack_grow (&m_string_obstack, v->string, strlen (v->string));
base = end + 1;
}
if (base != copy)
{
- obstack_grow (&string_obstack, base, strlen (base) + 1);
- copy = XOBFINISH (&string_obstack, char *);
+ obstack_grow (&m_string_obstack, base, strlen (base) + 1);
+ copy = XOBFINISH (&m_string_obstack, char *);
copy_md_ptr_loc (copy, string);
return copy;
}
@@ -368,8 +364,8 @@ apply_iterator_to_string (const char *string)
/* Return a deep copy of X, substituting the current iterator
values into any strings. */
-static rtx
-copy_rtx_for_iterators (rtx original)
+rtx
+rtx_reader::copy_rtx_for_iterators (rtx original)
{
const char *format_ptr, *p;
int i, j;
@@ -428,7 +424,7 @@ add_condition_to_string (const char *original, const char *extra)
{
if (original != 0 && original[0] == '&' && original[1] == '&')
return original;
- return join_c_conditions (original, extra);
+ return rtx_reader_ptr->join_c_conditions (original, extra);
}
/* Like add_condition, but applied to all conditions in rtx X. */
@@ -543,10 +539,10 @@ apply_iterators (rtx original, vec<rtx> *queue)
continue;
v = iuse->iterator->current_value;
iuse->iterator->group->apply_iterator (iuse->ptr, v->number);
- condition = join_c_conditions (condition, v->string);
+ condition = rtx_reader_ptr->join_c_conditions (condition, v->string);
}
apply_attribute_uses ();
- x = copy_rtx_for_iterators (original);
+ x = rtx_reader_ptr->copy_rtx_for_iterators (original);
add_condition_to_rtx (x, condition);
/* We apply subst iterator after RTL-template is copied, as during
@@ -738,8 +734,8 @@ atoll (const char *p)
generated by (the program generated by) genconditions.c, and
slipped in at the beginning of the sequence of MD files read by
most of the other generators. */
-static void
-read_conditions (void)
+void
+rtx_reader::read_conditions ()
{
int c;
@@ -837,9 +833,9 @@ record_attribute_use (struct iterator_group *group, void *ptr,
for group GROUP. PTR is the value to pass to GROUP's apply_iterator
callback. */
-static void
-record_potential_iterator_use (struct iterator_group *group, void *ptr,
- const char *name)
+void
+rtx_reader::record_potential_iterator_use (struct iterator_group *group,
+ void *ptr, const char *name)
{
struct mapping *m;
size_t len;
@@ -849,8 +845,8 @@ record_potential_iterator_use (struct iterator_group *group, void *ptr,
{
/* Copy the attribute string into permanent storage, without the
angle brackets around it. */
- obstack_grow0 (&string_obstack, name + 1, len - 2);
- record_attribute_use (group, ptr, XOBFINISH (&string_obstack, char *));
+ obstack_grow0 (&m_string_obstack, name + 1, len - 2);
+ record_attribute_use (group, ptr, XOBFINISH (&m_string_obstack, char *));
}
else
{
@@ -872,8 +868,8 @@ record_potential_iterator_use (struct iterator_group *group, void *ptr,
Represent the declaration as a "mapping" structure; add it to TABLE
(which belongs to GROUP) and return it. */
-static struct mapping *
-read_mapping (struct iterator_group *group, htab_t table)
+struct mapping *
+rtx_reader::read_mapping (struct iterator_group *group, htab_t table)
{
struct md_name name;
struct mapping *m;
@@ -974,7 +970,7 @@ read_subst_mapping (htab_t subst_iters_table, htab_t subst_attrs_table,
int i;
for (i = 0; i < 4; i++)
- attr_operands[i] = read_string (false);
+ attr_operands[i] = rtx_reader_ptr->read_string (false);
add_define_subst_attr (attr_operands, queue);
@@ -1019,7 +1015,7 @@ check_code_iterator (struct mapping *iterator)
store the list of rtxes as an EXPR_LIST in *X. */
bool
-read_rtx (const char *rtx_name, vec<rtx> *rtxen)
+rtx_reader::read_rtx (const char *rtx_name, vec<rtx> *rtxen)
{
static bool initialized = false;
@@ -1087,8 +1083,8 @@ read_rtx (const char *rtx_name, vec<rtx> *rtxen)
either an rtx code or a code iterator. Parse the rest of the rtx and
return it. */
-static rtx
-read_rtx_code (const char *code_name)
+rtx
+rtx_reader::read_rtx_code (const char *code_name)
{
RTX_CODE code;
struct mapping *iterator;
@@ -1200,8 +1196,8 @@ read_rtx_code (const char *code_name)
based on the corresponding format character within GET_RTX_FORMAT
for the GET_CODE (RETURN_RTX). */
-static void
-read_rtx_operand (rtx return_rtx, int idx)
+void
+rtx_reader::read_rtx_operand (rtx return_rtx, int idx)
{
RTX_CODE code = GET_CODE (return_rtx);
const char *format_ptr = GET_RTX_FORMAT (code);
@@ -1304,17 +1300,17 @@ read_rtx_operand (rtx return_rtx, int idx)
|| GET_CODE (return_rtx) == DEFINE_INSN_AND_SPLIT))
{
char line_name[20];
- const char *read_md_filename = rtx_reader_ptr->get_filename ();
+ const char *read_md_filename = get_filename ();
const char *fn = (read_md_filename ? read_md_filename : "rtx");
const char *slash;
for (slash = fn; *slash; slash ++)
if (*slash == '/' || *slash == '\\' || *slash == ':')
fn = slash + 1;
- obstack_1grow (&string_obstack, '*');
- obstack_grow (&string_obstack, fn, strlen (fn));
- sprintf (line_name, ":%d", rtx_reader_ptr->get_lineno ());
- obstack_grow (&string_obstack, line_name, strlen (line_name)+1);
- stringbuf = XOBFINISH (&string_obstack, char *);
+ obstack_1grow (&m_string_obstack, '*');
+ obstack_grow (&m_string_obstack, fn, strlen (fn));
+ sprintf (line_name, ":%d", get_lineno ());
+ obstack_grow (&m_string_obstack, line_name, strlen (line_name)+1);
+ stringbuf = XOBFINISH (&m_string_obstack, char *);
}
/* Find attr-names in the string. */
@@ -1402,8 +1398,8 @@ read_rtx_operand (rtx return_rtx, int idx)
/* Read a nested rtx construct from the MD file and return it. */
-static rtx
-read_nested_rtx (void)
+rtx
+rtx_reader::read_nested_rtx ()
{
struct md_name name;
rtx return_rtx;
@@ -1427,8 +1423,8 @@ read_nested_rtx (void)
When called, FORM is (thing x1 x2), and the file position
is just past the leading parenthesis of x3. Only works
for THINGs which are dyadic expressions, e.g. AND, IOR. */
-static rtx
-read_rtx_variadic (rtx form)
+rtx
+rtx_reader::read_rtx_variadic (rtx form)
{
char c = '(';
rtx p = form, q;