Commit b78027d1 by David Malcolm Committed by David Malcolm

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
parent b0ce2191
2016-10-18 David Malcolm <dmalcolm@redhat.com>
* 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.
2016-10-18 Kugan Vivekanandarajah <kuganv@linaro.org> 2016-10-18 Kugan Vivekanandarajah <kuganv@linaro.org>
* tree-vrp.c (get_value_range): Check get_ptr_nonnull. * tree-vrp.c (get_value_range): Check get_ptr_nonnull.
......
...@@ -630,7 +630,7 @@ attr_string (const char *str, int len) ...@@ -630,7 +630,7 @@ attr_string (const char *str, int len)
memcpy (new_str, str, len); memcpy (new_str, str, len);
new_str[len] = '\0'; new_str[len] = '\0';
attr_hash_add_string (hashcode, new_str); attr_hash_add_string (hashcode, new_str);
copy_md_ptr_loc (new_str, str); rtx_reader_ptr->copy_md_ptr_loc (new_str, str);
return new_str; /* Return the new string. */ return new_str; /* Return the new string. */
} }
...@@ -3157,7 +3157,7 @@ gen_attr (md_rtx_info *info) ...@@ -3157,7 +3157,7 @@ gen_attr (md_rtx_info *info)
if (GET_CODE (def) == DEFINE_ENUM_ATTR) if (GET_CODE (def) == DEFINE_ENUM_ATTR)
{ {
attr->enum_name = XSTR (def, 1); attr->enum_name = XSTR (def, 1);
et = lookup_enum_type (XSTR (def, 1)); et = rtx_reader_ptr->lookup_enum_type (XSTR (def, 1));
if (!et || !et->md_p) if (!et || !et->md_p)
error_at (info->loc, "No define_enum called `%s' defined", error_at (info->loc, "No define_enum called `%s' defined",
attr->name); attr->name);
...@@ -3768,14 +3768,14 @@ write_test_expr (FILE *outf, rtx exp, unsigned int attrs_cached, int flags, ...@@ -3768,14 +3768,14 @@ write_test_expr (FILE *outf, rtx exp, unsigned int attrs_cached, int flags,
break; break;
case MATCH_TEST: case MATCH_TEST:
fprint_c_condition (outf, XSTR (exp, 0)); rtx_reader_ptr->fprint_c_condition (outf, XSTR (exp, 0));
if (flags & FLG_BITWISE) if (flags & FLG_BITWISE)
fprintf (outf, " != 0"); fprintf (outf, " != 0");
break; break;
/* A random C expression. */ /* A random C expression. */
case SYMBOL_REF: case SYMBOL_REF:
fprint_c_condition (outf, XSTR (exp, 0)); rtx_reader_ptr->fprint_c_condition (outf, XSTR (exp, 0));
break; break;
/* The address of the branch target. */ /* The address of the branch target. */
...@@ -4365,7 +4365,7 @@ write_attr_value (FILE *outf, struct attr_desc *attr, rtx value) ...@@ -4365,7 +4365,7 @@ write_attr_value (FILE *outf, struct attr_desc *attr, rtx value)
break; break;
case SYMBOL_REF: case SYMBOL_REF:
fprint_c_condition (outf, XSTR (value, 0)); rtx_reader_ptr->fprint_c_condition (outf, XSTR (value, 0));
break; break;
case ATTR: case ATTR:
......
...@@ -124,7 +124,7 @@ write_one_condition (void **slot, void * ARG_UNUSED (dummy)) ...@@ -124,7 +124,7 @@ write_one_condition (void **slot, void * ARG_UNUSED (dummy))
const struct c_test *test = * (const struct c_test **) slot; const struct c_test *test = * (const struct c_test **) slot;
const char *p; const char *p;
print_md_ptr_loc (test->expr); rtx_reader_ptr->print_md_ptr_loc (test->expr);
fputs (" { \"", stdout); fputs (" { \"", stdout);
for (p = test->expr; *p; p++) for (p = test->expr; *p; p++)
{ {
...@@ -139,9 +139,9 @@ write_one_condition (void **slot, void * ARG_UNUSED (dummy)) ...@@ -139,9 +139,9 @@ write_one_condition (void **slot, void * ARG_UNUSED (dummy))
} }
fputs ("\",\n __builtin_constant_p ", stdout); fputs ("\",\n __builtin_constant_p ", stdout);
print_c_condition (test->expr); rtx_reader_ptr->print_c_condition (test->expr);
fputs ("\n ? (int) ", stdout); fputs ("\n ? (int) ", stdout);
print_c_condition (test->expr); rtx_reader_ptr->print_c_condition (test->expr);
fputs ("\n : -1 },\n", stdout); fputs ("\n : -1 },\n", stdout);
return 1; return 1;
} }
......
...@@ -28,6 +28,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -28,6 +28,8 @@ along with GCC; see the file COPYING3. If not see
#include "system.h" #include "system.h"
#include "coretypes.h" #include "coretypes.h"
#include "errors.h" #include "errors.h"
#include "statistics.h"
#include "vec.h"
#include "read-md.h" #include "read-md.h"
/* Called via traverse_md_constants; emit a #define for /* Called via traverse_md_constants; emit a #define for
...@@ -91,8 +93,8 @@ main (int argc, const char **argv) ...@@ -91,8 +93,8 @@ main (int argc, const char **argv)
puts ("#ifndef GCC_INSN_CONSTANTS_H"); puts ("#ifndef GCC_INSN_CONSTANTS_H");
puts ("#define GCC_INSN_CONSTANTS_H\n"); puts ("#define GCC_INSN_CONSTANTS_H\n");
traverse_md_constants (print_md_constant, 0); reader.traverse_md_constants (print_md_constant, 0);
traverse_enum_types (print_enum_type, 0); reader.traverse_enum_types (print_enum_type, 0);
puts ("\n#endif /* GCC_INSN_CONSTANTS_H */"); puts ("\n#endif /* GCC_INSN_CONSTANTS_H */");
......
...@@ -302,7 +302,7 @@ emit_c_code (const char *code, bool can_fail_p, const char *name) ...@@ -302,7 +302,7 @@ emit_c_code (const char *code, bool can_fail_p, const char *name)
printf ("#define DONE return (_val = get_insns ()," printf ("#define DONE return (_val = get_insns (),"
"end_sequence (), _val)\n"); "end_sequence (), _val)\n");
print_md_ptr_loc (code); rtx_reader_ptr->print_md_ptr_loc (code);
printf ("%s\n", code); printf ("%s\n", code);
printf ("#undef DONE\n"); printf ("#undef DONE\n");
......
...@@ -21,6 +21,8 @@ along with GCC; see the file COPYING3. If not see ...@@ -21,6 +21,8 @@ along with GCC; see the file COPYING3. If not see
#include "system.h" #include "system.h"
#include "coretypes.h" #include "coretypes.h"
#include "errors.h" #include "errors.h"
#include "statistics.h"
#include "vec.h"
#include "read-md.h" #include "read-md.h"
/* Called via traverse_enum_types. Emit an enum definition for /* Called via traverse_enum_types. Emit an enum definition for
...@@ -59,7 +61,7 @@ main (int argc, const char **argv) ...@@ -59,7 +61,7 @@ main (int argc, const char **argv)
puts ("#include \"system.h\"\n"); puts ("#include \"system.h\"\n");
puts ("#include \"insn-constants.h\"\n"); puts ("#include \"insn-constants.h\"\n");
traverse_enum_types (print_enum_type, 0); reader.traverse_enum_types (print_enum_type, 0);
if (ferror (stdout) || fflush (stdout) || fclose (stdout)) if (ferror (stdout) || fflush (stdout) || fclose (stdout))
return FATAL_EXIT_CODE; return FATAL_EXIT_CODE;
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#include "system.h" #include "system.h"
#include "coretypes.h" #include "coretypes.h"
#include "errors.h" #include "errors.h"
#include "statistics.h"
#include "vec.h"
#include "read-md.h" #include "read-md.h"
......
...@@ -631,7 +631,7 @@ process_template (struct data *d, const char *template_code) ...@@ -631,7 +631,7 @@ process_template (struct data *d, const char *template_code)
printf ("output_%d (rtx *operands ATTRIBUTE_UNUSED, rtx_insn *insn ATTRIBUTE_UNUSED)\n", printf ("output_%d (rtx *operands ATTRIBUTE_UNUSED, rtx_insn *insn ATTRIBUTE_UNUSED)\n",
d->code_number); d->code_number);
puts ("{"); puts ("{");
print_md_ptr_loc (template_code); rtx_reader_ptr->print_md_ptr_loc (template_code);
puts (template_code + 1); puts (template_code + 1);
puts ("}"); puts ("}");
} }
......
...@@ -154,7 +154,7 @@ write_predicate_subfunction (struct pred_data *p) ...@@ -154,7 +154,7 @@ write_predicate_subfunction (struct pred_data *p)
printf ("static inline int\n" printf ("static inline int\n"
"%s_1 (rtx op, machine_mode mode ATTRIBUTE_UNUSED)\n", "%s_1 (rtx op, machine_mode mode ATTRIBUTE_UNUSED)\n",
p->name); p->name);
print_md_ptr_loc (p->c_block); rtx_reader_ptr->print_md_ptr_loc (p->c_block);
if (p->c_block[0] == '{') if (p->c_block[0] == '{')
fputs (p->c_block, stdout); fputs (p->c_block, stdout);
else else
...@@ -538,7 +538,7 @@ write_predicate_expr (rtx exp) ...@@ -538,7 +538,7 @@ write_predicate_expr (rtx exp)
break; break;
case MATCH_TEST: case MATCH_TEST:
print_c_condition (XSTR (exp, 0)); rtx_reader_ptr->print_c_condition (XSTR (exp, 0));
break; break;
default: default:
......
...@@ -4659,7 +4659,7 @@ print_test (output_state *os, const rtx_test &test, bool is_param, ...@@ -4659,7 +4659,7 @@ print_test (output_state *os, const rtx_test &test, bool is_param,
gcc_assert (!is_param && value == 1); gcc_assert (!is_param && value == 1);
if (invert_p) if (invert_p)
printf ("!"); printf ("!");
print_c_condition (test.u.string); rtx_reader_ptr->print_c_condition (test.u.string);
break; break;
case rtx_test::ACCEPT: case rtx_test::ACCEPT:
......
...@@ -551,8 +551,9 @@ process_rtx (rtx desc, file_location loc) ...@@ -551,8 +551,9 @@ process_rtx (rtx desc, file_location loc)
split_cond = XSTR (desc, 4); split_cond = XSTR (desc, 4);
if (split_cond[0] == '&' && split_cond[1] == '&') if (split_cond[0] == '&' && split_cond[1] == '&')
{ {
copy_md_ptr_loc (split_cond + 2, split_cond); rtx_reader_ptr->copy_md_ptr_loc (split_cond + 2, split_cond);
split_cond = join_c_conditions (XSTR (desc, 2), split_cond + 2); split_cond = rtx_reader_ptr->join_c_conditions (XSTR (desc, 2),
split_cond + 2);
} }
XSTR (split, 1) = split_cond; XSTR (split, 1) = split_cond;
XVEC (split, 2) = XVEC (desc, 5); XVEC (split, 2) = XVEC (desc, 5);
...@@ -1262,8 +1263,8 @@ static const char * ...@@ -1262,8 +1263,8 @@ static const char *
alter_test_for_insn (struct queue_elem *ce_elem, alter_test_for_insn (struct queue_elem *ce_elem,
struct queue_elem *insn_elem) struct queue_elem *insn_elem)
{ {
return join_c_conditions (XSTR (ce_elem->data, 1), return rtx_reader_ptr->join_c_conditions (XSTR (ce_elem->data, 1),
XSTR (insn_elem->data, 2)); XSTR (insn_elem->data, 2));
} }
/* Modify VAL, which is an attribute expression for the "enabled" attribute, /* Modify VAL, which is an attribute expression for the "enabled" attribute,
...@@ -1871,8 +1872,9 @@ process_substs_on_one_elem (struct queue_elem *elem, ...@@ -1871,8 +1872,9 @@ process_substs_on_one_elem (struct queue_elem *elem,
/* Recalculate condition, joining conditions from original and /* Recalculate condition, joining conditions from original and
DEFINE_SUBST input patterns. */ 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" /* Mark that subst was applied by changing attribute from "yes"
to "no". */ to "no". */
change_subst_attribute (elem, subst_elem, subst_false); change_subst_attribute (elem, subst_elem, subst_false);
...@@ -2299,6 +2301,7 @@ gen_mnemonic_setattr (htab_t mnemonic_htab, rtx insn) ...@@ -2299,6 +2301,7 @@ gen_mnemonic_setattr (htab_t mnemonic_htab, rtx insn)
rtx set_attr; rtx set_attr;
char *attr_name; char *attr_name;
rtvec new_vec; rtvec new_vec;
struct obstack *string_obstack = rtx_reader_ptr->get_string_obstack ();
template_code = XTMPL (insn, 3); template_code = XTMPL (insn, 3);
...@@ -2324,13 +2327,13 @@ gen_mnemonic_setattr (htab_t mnemonic_htab, rtx insn) ...@@ -2324,13 +2327,13 @@ gen_mnemonic_setattr (htab_t mnemonic_htab, rtx insn)
sp = ep + 1; sp = ep + 1;
if (i > 0) if (i > 0)
obstack_1grow (&string_obstack, ','); obstack_1grow (string_obstack, ',');
while (cp < sp && ((*cp >= '0' && *cp <= '9') while (cp < sp && ((*cp >= '0' && *cp <= '9')
|| (*cp >= 'a' && *cp <= 'z'))) || (*cp >= 'a' && *cp <= 'z')))
{ {
obstack_1grow (&string_obstack, *cp); obstack_1grow (string_obstack, *cp);
cp++; cp++;
size++; size++;
} }
...@@ -2341,7 +2344,7 @@ gen_mnemonic_setattr (htab_t mnemonic_htab, rtx insn) ...@@ -2341,7 +2344,7 @@ gen_mnemonic_setattr (htab_t mnemonic_htab, rtx insn)
{ {
/* Don't set a value if there are more than one /* Don't set a value if there are more than one
instruction in the string. */ instruction in the string. */
obstack_blank_fast (&string_obstack, -size); obstack_blank_fast (string_obstack, -size);
size = 0; size = 0;
cp = sp; cp = sp;
...@@ -2350,22 +2353,22 @@ gen_mnemonic_setattr (htab_t mnemonic_htab, rtx insn) ...@@ -2350,22 +2353,22 @@ gen_mnemonic_setattr (htab_t mnemonic_htab, rtx insn)
cp++; cp++;
} }
if (size == 0) if (size == 0)
obstack_1grow (&string_obstack, '*'); obstack_1grow (string_obstack, '*');
else else
add_mnemonic_string (mnemonic_htab, add_mnemonic_string (mnemonic_htab,
(char *) obstack_next_free (&string_obstack) - size, (char *) obstack_next_free (string_obstack) - size,
size); size);
i++; i++;
} }
/* An insn definition might emit an empty string. */ /* An insn definition might emit an empty string. */
if (obstack_object_size (&string_obstack) == 0) if (obstack_object_size (string_obstack) == 0)
return; return;
obstack_1grow (&string_obstack, '\0'); obstack_1grow (string_obstack, '\0');
set_attr = rtx_alloc (SET_ATTR); 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); attr_name = XNEWVAR (char, strlen (MNEMONIC_ATTR_NAME) + 1);
strcpy (attr_name, MNEMONIC_ATTR_NAME); strcpy (attr_name, MNEMONIC_ATTR_NAME);
XSTR (set_attr, 0) = attr_name; XSTR (set_attr, 0) = attr_name;
...@@ -2388,8 +2391,10 @@ gen_mnemonic_setattr (htab_t mnemonic_htab, rtx insn) ...@@ -2388,8 +2391,10 @@ gen_mnemonic_setattr (htab_t mnemonic_htab, rtx insn)
static int static int
mnemonic_htab_callback (void **slot, void *info ATTRIBUTE_UNUSED) mnemonic_htab_callback (void **slot, void *info ATTRIBUTE_UNUSED)
{ {
obstack_grow (&string_obstack, (char*)*slot, strlen ((char*)*slot)); struct obstack *string_obstack = rtx_reader_ptr->get_string_obstack ();
obstack_1grow (&string_obstack, ',');
obstack_grow (string_obstack, (char*) *slot, strlen ((char*) *slot));
obstack_1grow (string_obstack, ',');
return 1; return 1;
} }
...@@ -2407,6 +2412,7 @@ gen_mnemonic_attr (void) ...@@ -2407,6 +2412,7 @@ gen_mnemonic_attr (void)
htab_t mnemonic_htab; htab_t mnemonic_htab;
const char *str, *p; const char *str, *p;
int i; int i;
struct obstack *string_obstack = rtx_reader_ptr->get_string_obstack ();
if (have_error) if (have_error)
return; return;
...@@ -2470,8 +2476,8 @@ gen_mnemonic_attr (void) ...@@ -2470,8 +2476,8 @@ gen_mnemonic_attr (void)
htab_traverse (mnemonic_htab, mnemonic_htab_callback, NULL); htab_traverse (mnemonic_htab, mnemonic_htab_callback, NULL);
/* Replace the last ',' with the zero end character. */ /* Replace the last ',' with the zero end character. */
*((char *)obstack_next_free (&string_obstack) - 1) = '\0'; *((char *) obstack_next_free (string_obstack) - 1) = '\0';
XSTR (mnemonic_attr, 1) = XOBFINISH (&string_obstack, char *); XSTR (mnemonic_attr, 1) = XOBFINISH (string_obstack, char *);
} }
/* Check if there are DEFINE_ATTRs with the same name. */ /* Check if there are DEFINE_ATTRs with the same name. */
......
...@@ -191,7 +191,7 @@ def_target_insn (const char *name, const char *prototype) ...@@ -191,7 +191,7 @@ def_target_insn (const char *name, const char *prototype)
printf ("target_have_%s (void)\n", name); printf ("target_have_%s (void)\n", name);
printf ("{\n"); printf ("{\n");
printf (" return "); printf (" return ");
print_c_condition (test); rtx_reader_ptr->print_c_condition (test);
printf (";\n"); printf (";\n");
printf ("}\n"); printf ("}\n");
} }
......
...@@ -107,14 +107,54 @@ class rtx_reader ...@@ -107,14 +107,54 @@ class rtx_reader
file_location get_current_location () const; file_location get_current_location () const;
/* Defined in read-md.c. */
int read_char (void); int read_char (void);
void unread_char (int ch); void unread_char (int ch);
void read_name (struct md_name *name);
void read_escape ();
char *read_quoted_string ();
char *read_braced_string ();
char *read_string (int star_if_braced);
void read_skip_construct (int depth, file_location loc);
void set_md_ptr_loc (const void *ptr, const char *filename, int lineno);
const struct ptr_loc *get_md_ptr_loc (const void *ptr);
void copy_md_ptr_loc (const void *new_ptr, const void *old_ptr);
void fprint_md_ptr_loc (FILE *outf, const void *ptr);
void print_md_ptr_loc (const void *ptr);
struct enum_type *lookup_enum_type (const char *name);
void traverse_enum_types (htab_trav callback, void *info);
void handle_constants ();
void traverse_md_constants (htab_trav callback, void *info);
void handle_enum (file_location loc, bool md_p);
const char *join_c_conditions (const char *cond1, const char *cond2);
void fprint_c_condition (FILE *outf, const char *cond);
void print_c_condition (const char *cond);
/* Defined in read-rtl.c. */
const char *apply_iterator_to_string (const char *string);
rtx copy_rtx_for_iterators (rtx original);
void read_conditions ();
void record_potential_iterator_use (struct iterator_group *group,
void *ptr, const char *name);
struct mapping *read_mapping (struct iterator_group *group, htab_t table);
bool read_rtx (const char *rtx_name, vec<rtx> *rtxen);
rtx read_rtx_code (const char *code_name);
void read_rtx_operand (rtx return_rtx, int idx);
rtx read_nested_rtx ();
rtx read_rtx_variadic (rtx form);
const char *get_top_level_filename () const { return m_toplevel_fname; } const char *get_top_level_filename () const { return m_toplevel_fname; }
const char *get_filename () const { return m_read_md_filename; } const char *get_filename () const { return m_read_md_filename; }
int get_lineno () const { return m_read_md_lineno; } int get_lineno () const { return m_read_md_lineno; }
int get_colno () const { return m_read_md_colno; } int get_colno () const { return m_read_md_colno; }
struct obstack *get_string_obstack () { return &m_string_obstack; }
htab_t get_md_constants () { return m_md_constants; }
private: private:
/* A singly-linked list of filenames. */ /* A singly-linked list of filenames. */
struct file_name_list { struct file_name_list {
...@@ -159,6 +199,32 @@ class rtx_reader ...@@ -159,6 +199,32 @@ class rtx_reader
/* A pointer to the null terminator of the md include chain. */ /* A pointer to the null terminator of the md include chain. */
file_name_list **m_last_dir_md_include_ptr; file_name_list **m_last_dir_md_include_ptr;
/* Obstack used for allocating MD strings. */
struct obstack m_string_obstack;
/* A table of ptr_locs, hashed on the PTR field. */
htab_t m_ptr_locs;
/* An obstack for the above. Plain xmalloc is a bit heavyweight for a
small structure like ptr_loc. */
struct obstack m_ptr_loc_obstack;
/* A hash table of triples (A, B, C), where each of A, B and C is a condition
and A is equivalent to "B && C". This is used to keep track of the source
of conditions that are made up of separate MD strings (such as the split
condition of a define_insn_and_split). */
htab_t m_joined_conditions;
/* An obstack for allocating joined_conditions entries. */
struct obstack m_joined_conditions_obstack;
/* A table of md_constant structures, hashed by name. Null if no
constant expansion should occur. */
htab_t m_md_constants;
/* A table of enum_type structures, hashed by name. */
htab_t m_enum_types;
}; };
/* Global singleton. */ /* Global singleton. */
...@@ -175,7 +241,6 @@ class noop_reader : public rtx_reader ...@@ -175,7 +241,6 @@ class noop_reader : public rtx_reader
void handle_unknown_directive (file_location, const char *); void handle_unknown_directive (file_location, const char *);
}; };
extern struct obstack string_obstack;
extern void (*include_callback) (const char *); extern void (*include_callback) (const char *);
/* Read the next character from the MD file. */ /* Read the next character from the MD file. */
...@@ -196,12 +261,7 @@ unread_char (int ch) ...@@ -196,12 +261,7 @@ unread_char (int ch)
extern hashval_t leading_string_hash (const void *); extern hashval_t leading_string_hash (const void *);
extern int leading_string_eq_p (const void *, const void *); extern int leading_string_eq_p (const void *, const void *);
extern void copy_md_ptr_loc (const void *, const void *);
extern void print_md_ptr_loc (const void *);
extern void fprint_md_ptr_loc (FILE *, const void *);
extern const char *join_c_conditions (const char *, const char *); extern const char *join_c_conditions (const char *, const char *);
extern void print_c_condition (const char *);
extern void fprint_c_condition (FILE *, const char *);
extern void message_at (file_location, const char *, ...) ATTRIBUTE_PRINTF_2; extern void message_at (file_location, const char *, ...) ATTRIBUTE_PRINTF_2;
extern void error_at (file_location, const char *, ...) ATTRIBUTE_PRINTF_2; extern void error_at (file_location, const char *, ...) ATTRIBUTE_PRINTF_2;
extern void fatal_at (file_location, const char *, ...) ATTRIBUTE_PRINTF_2; extern void fatal_at (file_location, const char *, ...) ATTRIBUTE_PRINTF_2;
...@@ -210,13 +270,9 @@ extern void fatal_with_file_and_line (const char *, ...) ...@@ -210,13 +270,9 @@ extern void fatal_with_file_and_line (const char *, ...)
extern void fatal_expected_char (int, int) ATTRIBUTE_NORETURN; extern void fatal_expected_char (int, int) ATTRIBUTE_NORETURN;
extern int read_skip_spaces (void); extern int read_skip_spaces (void);
extern void require_char_ws (char expected); extern void require_char_ws (char expected);
extern void read_name (struct md_name *);
extern char *read_quoted_string (void);
extern char *read_string (int);
extern int n_comma_elts (const char *); extern int n_comma_elts (const char *);
extern const char *scan_comma_elt (const char **); extern const char *scan_comma_elt (const char **);
extern void upcase_string (char *); extern void upcase_string (char *);
extern void traverse_md_constants (htab_trav, void *);
extern void traverse_enum_types (htab_trav, void *); extern void traverse_enum_types (htab_trav, void *);
extern struct enum_type *lookup_enum_type (const char *); extern struct enum_type *lookup_enum_type (const char *);
......
...@@ -106,10 +106,6 @@ htab_t subst_attr_to_iter_map = NULL; ...@@ -106,10 +106,6 @@ htab_t subst_attr_to_iter_map = NULL;
const char *current_iterator_name; const char *current_iterator_name;
static void validate_const_int (const char *); 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. */ /* The mode and code iterator structures. */
static struct iterator_group modes, codes, ints, substs; static struct iterator_group modes, codes, ints, substs;
...@@ -329,8 +325,8 @@ map_attr_string (const char *p) ...@@ -329,8 +325,8 @@ map_attr_string (const char *p)
/* Apply the current iterator values to STRING. Return the new string /* Apply the current iterator values to STRING. Return the new string
if any changes were needed, otherwise return STRING itself. */ if any changes were needed, otherwise return STRING itself. */
static const char * const char *
apply_iterator_to_string (const char *string) rtx_reader::apply_iterator_to_string (const char *string)
{ {
char *base, *copy, *p, *start, *end; char *base, *copy, *p, *start, *end;
struct map_value *v; struct map_value *v;
...@@ -351,14 +347,14 @@ apply_iterator_to_string (const char *string) ...@@ -351,14 +347,14 @@ apply_iterator_to_string (const char *string)
/* Add everything between the last copied byte and the '<', /* Add everything between the last copied byte and the '<',
then add in the attribute value. */ then add in the attribute value. */
obstack_grow (&string_obstack, base, start - base); obstack_grow (&m_string_obstack, base, start - base);
obstack_grow (&string_obstack, v->string, strlen (v->string)); obstack_grow (&m_string_obstack, v->string, strlen (v->string));
base = end + 1; base = end + 1;
} }
if (base != copy) if (base != copy)
{ {
obstack_grow (&string_obstack, base, strlen (base) + 1); obstack_grow (&m_string_obstack, base, strlen (base) + 1);
copy = XOBFINISH (&string_obstack, char *); copy = XOBFINISH (&m_string_obstack, char *);
copy_md_ptr_loc (copy, string); copy_md_ptr_loc (copy, string);
return copy; return copy;
} }
...@@ -368,8 +364,8 @@ apply_iterator_to_string (const char *string) ...@@ -368,8 +364,8 @@ apply_iterator_to_string (const char *string)
/* Return a deep copy of X, substituting the current iterator /* Return a deep copy of X, substituting the current iterator
values into any strings. */ values into any strings. */
static rtx rtx
copy_rtx_for_iterators (rtx original) rtx_reader::copy_rtx_for_iterators (rtx original)
{ {
const char *format_ptr, *p; const char *format_ptr, *p;
int i, j; int i, j;
...@@ -428,7 +424,7 @@ add_condition_to_string (const char *original, const char *extra) ...@@ -428,7 +424,7 @@ add_condition_to_string (const char *original, const char *extra)
{ {
if (original != 0 && original[0] == '&' && original[1] == '&') if (original != 0 && original[0] == '&' && original[1] == '&')
return original; 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. */ /* Like add_condition, but applied to all conditions in rtx X. */
...@@ -543,10 +539,10 @@ apply_iterators (rtx original, vec<rtx> *queue) ...@@ -543,10 +539,10 @@ apply_iterators (rtx original, vec<rtx> *queue)
continue; continue;
v = iuse->iterator->current_value; v = iuse->iterator->current_value;
iuse->iterator->group->apply_iterator (iuse->ptr, v->number); 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 (); apply_attribute_uses ();
x = copy_rtx_for_iterators (original); x = rtx_reader_ptr->copy_rtx_for_iterators (original);
add_condition_to_rtx (x, condition); add_condition_to_rtx (x, condition);
/* We apply subst iterator after RTL-template is copied, as during /* We apply subst iterator after RTL-template is copied, as during
...@@ -738,8 +734,8 @@ atoll (const char *p) ...@@ -738,8 +734,8 @@ atoll (const char *p)
generated by (the program generated by) genconditions.c, and generated by (the program generated by) genconditions.c, and
slipped in at the beginning of the sequence of MD files read by slipped in at the beginning of the sequence of MD files read by
most of the other generators. */ most of the other generators. */
static void void
read_conditions (void) rtx_reader::read_conditions ()
{ {
int c; int c;
...@@ -837,9 +833,9 @@ record_attribute_use (struct iterator_group *group, void *ptr, ...@@ -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 for group GROUP. PTR is the value to pass to GROUP's apply_iterator
callback. */ callback. */
static void void
record_potential_iterator_use (struct iterator_group *group, void *ptr, rtx_reader::record_potential_iterator_use (struct iterator_group *group,
const char *name) void *ptr, const char *name)
{ {
struct mapping *m; struct mapping *m;
size_t len; size_t len;
...@@ -849,8 +845,8 @@ record_potential_iterator_use (struct iterator_group *group, void *ptr, ...@@ -849,8 +845,8 @@ record_potential_iterator_use (struct iterator_group *group, void *ptr,
{ {
/* Copy the attribute string into permanent storage, without the /* Copy the attribute string into permanent storage, without the
angle brackets around it. */ angle brackets around it. */
obstack_grow0 (&string_obstack, name + 1, len - 2); obstack_grow0 (&m_string_obstack, name + 1, len - 2);
record_attribute_use (group, ptr, XOBFINISH (&string_obstack, char *)); record_attribute_use (group, ptr, XOBFINISH (&m_string_obstack, char *));
} }
else else
{ {
...@@ -872,8 +868,8 @@ record_potential_iterator_use (struct iterator_group *group, void *ptr, ...@@ -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 Represent the declaration as a "mapping" structure; add it to TABLE
(which belongs to GROUP) and return it. */ (which belongs to GROUP) and return it. */
static struct mapping * struct mapping *
read_mapping (struct iterator_group *group, htab_t table) rtx_reader::read_mapping (struct iterator_group *group, htab_t table)
{ {
struct md_name name; struct md_name name;
struct mapping *m; struct mapping *m;
...@@ -974,7 +970,7 @@ read_subst_mapping (htab_t subst_iters_table, htab_t subst_attrs_table, ...@@ -974,7 +970,7 @@ read_subst_mapping (htab_t subst_iters_table, htab_t subst_attrs_table,
int i; int i;
for (i = 0; i < 4; 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); add_define_subst_attr (attr_operands, queue);
...@@ -1019,7 +1015,7 @@ check_code_iterator (struct mapping *iterator) ...@@ -1019,7 +1015,7 @@ check_code_iterator (struct mapping *iterator)
store the list of rtxes as an EXPR_LIST in *X. */ store the list of rtxes as an EXPR_LIST in *X. */
bool 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; static bool initialized = false;
...@@ -1087,8 +1083,8 @@ read_rtx (const char *rtx_name, vec<rtx> *rtxen) ...@@ -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 either an rtx code or a code iterator. Parse the rest of the rtx and
return it. */ return it. */
static rtx rtx
read_rtx_code (const char *code_name) rtx_reader::read_rtx_code (const char *code_name)
{ {
RTX_CODE code; RTX_CODE code;
struct mapping *iterator; struct mapping *iterator;
...@@ -1200,8 +1196,8 @@ read_rtx_code (const char *code_name) ...@@ -1200,8 +1196,8 @@ read_rtx_code (const char *code_name)
based on the corresponding format character within GET_RTX_FORMAT based on the corresponding format character within GET_RTX_FORMAT
for the GET_CODE (RETURN_RTX). */ for the GET_CODE (RETURN_RTX). */
static void void
read_rtx_operand (rtx return_rtx, int idx) rtx_reader::read_rtx_operand (rtx return_rtx, int idx)
{ {
RTX_CODE code = GET_CODE (return_rtx); RTX_CODE code = GET_CODE (return_rtx);
const char *format_ptr = GET_RTX_FORMAT (code); const char *format_ptr = GET_RTX_FORMAT (code);
...@@ -1304,17 +1300,17 @@ read_rtx_operand (rtx return_rtx, int idx) ...@@ -1304,17 +1300,17 @@ read_rtx_operand (rtx return_rtx, int idx)
|| GET_CODE (return_rtx) == DEFINE_INSN_AND_SPLIT)) || GET_CODE (return_rtx) == DEFINE_INSN_AND_SPLIT))
{ {
char line_name[20]; 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 *fn = (read_md_filename ? read_md_filename : "rtx");
const char *slash; const char *slash;
for (slash = fn; *slash; slash ++) for (slash = fn; *slash; slash ++)
if (*slash == '/' || *slash == '\\' || *slash == ':') if (*slash == '/' || *slash == '\\' || *slash == ':')
fn = slash + 1; fn = slash + 1;
obstack_1grow (&string_obstack, '*'); obstack_1grow (&m_string_obstack, '*');
obstack_grow (&string_obstack, fn, strlen (fn)); obstack_grow (&m_string_obstack, fn, strlen (fn));
sprintf (line_name, ":%d", rtx_reader_ptr->get_lineno ()); sprintf (line_name, ":%d", get_lineno ());
obstack_grow (&string_obstack, line_name, strlen (line_name)+1); obstack_grow (&m_string_obstack, line_name, strlen (line_name)+1);
stringbuf = XOBFINISH (&string_obstack, char *); stringbuf = XOBFINISH (&m_string_obstack, char *);
} }
/* Find attr-names in the string. */ /* Find attr-names in the string. */
...@@ -1402,8 +1398,8 @@ read_rtx_operand (rtx return_rtx, int idx) ...@@ -1402,8 +1398,8 @@ read_rtx_operand (rtx return_rtx, int idx)
/* Read a nested rtx construct from the MD file and return it. */ /* Read a nested rtx construct from the MD file and return it. */
static rtx rtx
read_nested_rtx (void) rtx_reader::read_nested_rtx ()
{ {
struct md_name name; struct md_name name;
rtx return_rtx; rtx return_rtx;
...@@ -1427,8 +1423,8 @@ read_nested_rtx (void) ...@@ -1427,8 +1423,8 @@ read_nested_rtx (void)
When called, FORM is (thing x1 x2), and the file position When called, FORM is (thing x1 x2), and the file position
is just past the leading parenthesis of x3. Only works is just past the leading parenthesis of x3. Only works
for THINGs which are dyadic expressions, e.g. AND, IOR. */ for THINGs which are dyadic expressions, e.g. AND, IOR. */
static rtx rtx
read_rtx_variadic (rtx form) rtx_reader::read_rtx_variadic (rtx form)
{ {
char c = '('; char c = '(';
rtx p = form, q; rtx p = form, q;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment