diff options
author | David Malcolm <dmalcolm@redhat.com> | 2016-10-18 00:19:17 +0000 |
---|---|---|
committer | David Malcolm <dmalcolm@gcc.gnu.org> | 2016-10-18 00:19:17 +0000 |
commit | b78027d1a3f9a8fdf3386e24dcfd6679006dd154 (patch) | |
tree | a410a1eb6efa653792b4500a10e0449b5a96b937 /gcc/gensupport.c | |
parent | b0ce21917da6fa41e693bba287e9e680342d06bd (diff) | |
download | gcc-b78027d1a3f9a8fdf3386e24dcfd6679006dd154.zip gcc-b78027d1a3f9a8fdf3386e24dcfd6679006dd154.tar.gz gcc-b78027d1a3f9a8fdf3386e24dcfd6679006dd154.tar.bz2 |
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.
From-SVN: r241293
Diffstat (limited to 'gcc/gensupport.c')
-rw-r--r-- | gcc/gensupport.c | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/gcc/gensupport.c b/gcc/gensupport.c index cb74aea..c49ad6f 100644 --- a/gcc/gensupport.c +++ b/gcc/gensupport.c @@ -551,8 +551,9 @@ process_rtx (rtx desc, file_location loc) split_cond = XSTR (desc, 4); if (split_cond[0] == '&' && split_cond[1] == '&') { - copy_md_ptr_loc (split_cond + 2, split_cond); - split_cond = join_c_conditions (XSTR (desc, 2), split_cond + 2); + rtx_reader_ptr->copy_md_ptr_loc (split_cond + 2, split_cond); + split_cond = rtx_reader_ptr->join_c_conditions (XSTR (desc, 2), + split_cond + 2); } XSTR (split, 1) = split_cond; XVEC (split, 2) = XVEC (desc, 5); @@ -1262,8 +1263,8 @@ static const char * alter_test_for_insn (struct queue_elem *ce_elem, struct queue_elem *insn_elem) { - return join_c_conditions (XSTR (ce_elem->data, 1), - XSTR (insn_elem->data, 2)); + return rtx_reader_ptr->join_c_conditions (XSTR (ce_elem->data, 1), + XSTR (insn_elem->data, 2)); } /* Modify VAL, which is an attribute expression for the "enabled" attribute, @@ -1871,8 +1872,9 @@ process_substs_on_one_elem (struct queue_elem *elem, /* Recalculate condition, joining conditions from original and DEFINE_SUBST input patterns. */ - XSTR (elem->data, 2) = join_c_conditions (XSTR (subst_elem->data, 2), - XSTR (elem->data, 2)); + XSTR (elem->data, 2) + = rtx_reader_ptr->join_c_conditions (XSTR (subst_elem->data, 2), + XSTR (elem->data, 2)); /* Mark that subst was applied by changing attribute from "yes" to "no". */ change_subst_attribute (elem, subst_elem, subst_false); @@ -2299,6 +2301,7 @@ gen_mnemonic_setattr (htab_t mnemonic_htab, rtx insn) rtx set_attr; char *attr_name; rtvec new_vec; + struct obstack *string_obstack = rtx_reader_ptr->get_string_obstack (); template_code = XTMPL (insn, 3); @@ -2324,13 +2327,13 @@ gen_mnemonic_setattr (htab_t mnemonic_htab, rtx insn) sp = ep + 1; if (i > 0) - obstack_1grow (&string_obstack, ','); + obstack_1grow (string_obstack, ','); while (cp < sp && ((*cp >= '0' && *cp <= '9') || (*cp >= 'a' && *cp <= 'z'))) { - obstack_1grow (&string_obstack, *cp); + obstack_1grow (string_obstack, *cp); cp++; size++; } @@ -2341,7 +2344,7 @@ gen_mnemonic_setattr (htab_t mnemonic_htab, rtx insn) { /* Don't set a value if there are more than one instruction in the string. */ - obstack_blank_fast (&string_obstack, -size); + obstack_blank_fast (string_obstack, -size); size = 0; cp = sp; @@ -2350,22 +2353,22 @@ gen_mnemonic_setattr (htab_t mnemonic_htab, rtx insn) cp++; } if (size == 0) - obstack_1grow (&string_obstack, '*'); + obstack_1grow (string_obstack, '*'); else add_mnemonic_string (mnemonic_htab, - (char *) obstack_next_free (&string_obstack) - size, + (char *) obstack_next_free (string_obstack) - size, size); i++; } /* An insn definition might emit an empty string. */ - if (obstack_object_size (&string_obstack) == 0) + if (obstack_object_size (string_obstack) == 0) return; - obstack_1grow (&string_obstack, '\0'); + obstack_1grow (string_obstack, '\0'); set_attr = rtx_alloc (SET_ATTR); - XSTR (set_attr, 1) = XOBFINISH (&string_obstack, char *); + XSTR (set_attr, 1) = XOBFINISH (string_obstack, char *); attr_name = XNEWVAR (char, strlen (MNEMONIC_ATTR_NAME) + 1); strcpy (attr_name, MNEMONIC_ATTR_NAME); XSTR (set_attr, 0) = attr_name; @@ -2388,8 +2391,10 @@ gen_mnemonic_setattr (htab_t mnemonic_htab, rtx insn) static int mnemonic_htab_callback (void **slot, void *info ATTRIBUTE_UNUSED) { - obstack_grow (&string_obstack, (char*)*slot, strlen ((char*)*slot)); - obstack_1grow (&string_obstack, ','); + struct obstack *string_obstack = rtx_reader_ptr->get_string_obstack (); + + obstack_grow (string_obstack, (char*) *slot, strlen ((char*) *slot)); + obstack_1grow (string_obstack, ','); return 1; } @@ -2407,6 +2412,7 @@ gen_mnemonic_attr (void) htab_t mnemonic_htab; const char *str, *p; int i; + struct obstack *string_obstack = rtx_reader_ptr->get_string_obstack (); if (have_error) return; @@ -2470,8 +2476,8 @@ gen_mnemonic_attr (void) htab_traverse (mnemonic_htab, mnemonic_htab_callback, NULL); /* Replace the last ',' with the zero end character. */ - *((char *)obstack_next_free (&string_obstack) - 1) = '\0'; - XSTR (mnemonic_attr, 1) = XOBFINISH (&string_obstack, char *); + *((char *) obstack_next_free (string_obstack) - 1) = '\0'; + XSTR (mnemonic_attr, 1) = XOBFINISH (string_obstack, char *); } /* Check if there are DEFINE_ATTRs with the same name. */ |