summaryrefslogtreecommitdiff
path: root/gcc/read-rtl.c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2016-12-08 01:51:04 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2016-12-08 01:51:04 +0000
commita96d1f1d028e6798413eea810d2c6beee7519a6d (patch)
treeda9a5cde31da5a0cbf3f908e0e00f5e09114b9f7 /gcc/read-rtl.c
parent776a8a927eeeb7ea3c13b6a981f340591dcef530 (diff)
Split class rtx_reader into md_reader vs rtx_reader
This moves read_rtx and friends into rtx_reader, and splits rtx_reader into two classes: class md_reader: has responsibility for reading chars, managing include files, top-level directives etc. It is the read-md.o part. class rtx_reader, a subclass, has the code for reading hierarchical rtx expressions using the format codes. It is the read-rtl.o part. This split is needed by a followup patch, which converts read_rtx_operand to a virtual function of rtx_reader. To do this, instances of rtx_reader (or its subclasses) need a vtable, which needs to include a ptr to the code in read-rtl.o. Splitting it up allows the gen* tools that currently purely use read-md.o to continue to do so. gcc/ChangeLog: * genpreds.c (write_tm_constrs_h): Update for renaming of rtx_reader_ptr to md_reader_ptr. (write_tm_preds_h): Likewise. (write_insn_preds_c): Likewise. * read-md.c (rtx_reader_ptr): Rename to... (md_reader_ptr): ...this, and convert from an rtx_reader * to a md_reader *. (rtx_reader::set_md_ptr_loc): Rename to... (md_reader::set_md_ptr_loc): ...this. (rtx_reader::get_md_ptr_loc): Rename to... (md_reader::get_md_ptr_loc): ...this. (rtx_reader::copy_md_ptr_loc): Rename to... (md_reader::copy_md_ptr_loc): ...this. (rtx_reader::fprint_md_ptr_loc): Rename to... (md_reader::fprint_md_ptr_loc): ...this. (rtx_reader::print_md_ptr_loc): Rename to... (md_reader::print_md_ptr_loc): ...this. (rtx_reader::join_c_conditions): Rename to... (md_reader::join_c_conditions): ...this. (rtx_reader::fprint_c_condition): ...this. (rtx_reader::print_c_condition): Rename to... (md_reader::print_c_condition): ...this. (fatal_with_file_and_line): Update for renaming of rtx_reader_ptr to md_reader_ptr. (rtx_reader::require_char): Rename to... (md_reader::require_char): ...this. (rtx_reader::require_char_ws): Rename to... (md_reader::require_char_ws): ...this. (rtx_reader::require_word_ws): Rename to... (md_reader::require_word_ws): ...this. (rtx_reader::read_char): Rename to... (md_reader::read_char): ...this. (rtx_reader::unread_char): Rename to... (md_reader::unread_char): ...this. (rtx_reader::peek_char): Rename to... (md_reader::peek_char): ...this. (rtx_reader::read_name): Rename to... (md_reader::read_name): ...this. (rtx_reader::read_escape): Rename to... (md_reader::read_escape): ...this. (rtx_reader::read_quoted_string): Rename to... (md_reader::read_quoted_string): ...this. (rtx_reader::read_braced_string): Rename to... (md_reader::read_braced_string): ...this. (rtx_reader::read_string): Rename to... (md_reader::read_string): ...this. (rtx_reader::read_skip_construct): Rename to... (md_reader::read_skip_construct): ...this. (rtx_reader::handle_constants): Rename to... (md_reader::handle_constants): ...this. (rtx_reader::traverse_md_constants): Rename to... (md_reader::traverse_md_constants): ...this. (rtx_reader::handle_enum): Rename to... (md_reader::handle_enum): ...this. (rtx_reader::lookup_enum_type): Rename to... (md_reader::lookup_enum_type): ...this. (rtx_reader::traverse_enum_types): Rename to... (md_reader::traverse_enum_types): ...this. (rtx_reader::rtx_reader): Rename to... (md_reader::md_reader): ...this, and update for renaming of rtx_reader_ptr to md_reader_ptr. (rtx_reader::~rtx_reader): Rename to... (md_reader::~md_reader): ...this, and update for renaming of rtx_reader_ptr to md_reader_ptr. (rtx_reader::handle_include): Rename to... (md_reader::handle_include): ...this. (rtx_reader::handle_file): Rename to... (md_reader::handle_file): ...this. (rtx_reader::handle_toplevel_file): Rename to... (md_reader::handle_toplevel_file): ...this. (rtx_reader::get_current_location): Rename to... (md_reader::get_current_location): ...this. (rtx_reader::add_include_path): Rename to... (md_reader::add_include_path): ...this. (rtx_reader::read_md_files): Rename to... (md_reader::read_md_files): ...this. * read-md.h (class rtx_reader): Split into... (class md_reader): ...new class. (rtx_reader_ptr): Rename to... (md_reader_ptr): ...this, and convert to a md_reader *. (class noop_reader): Update base class to be md_reader. (class rtx_reader): Reintroduce as a subclass of md_reader. (rtx_reader_ptr): Reintroduce as a rtx_reader *. (read_char): Update for renaming of rtx_reader_ptr to md_reader_ptr. (unread_char): Likewise. * read-rtl.c (rtx_reader_ptr): New global. (rtx_reader::apply_iterator_to_string): Rename to... (md_reader::apply_iterator_to_string): ...this. (rtx_reader::copy_rtx_for_iterators): Rename to... (md_reader::copy_rtx_for_iterators): ...this. (rtx_reader::read_conditions): Rename to... (md_reader::read_conditions): ...this. (rtx_reader::record_potential_iterator_use): Rename to... (md_reader::record_potential_iterator_use): ...this. (rtx_reader::read_mapping): Rename to... (md_reader::read_mapping): ...this. (rtx_reader::read_rtx): Use rtx_reader_ptr when calling read_rtx_code. (rtx_reader::read_rtx_operand): Use get_string_obstack rather than directly accessing m_string_obstack. (rtx_reader::rtx_reader): New ctor. (rtx_reader::~rtx_reader): New dtor. From-SVN: r243426
Diffstat (limited to 'gcc/read-rtl.c')
-rw-r--r--gcc/read-rtl.c43
1 files changed, 32 insertions, 11 deletions
diff --git a/gcc/read-rtl.c b/gcc/read-rtl.c
index 7a2021a3a23..f74c8751a98 100644
--- a/gcc/read-rtl.c
+++ b/gcc/read-rtl.c
@@ -107,6 +107,9 @@ const char *current_iterator_name;
static void validate_const_int (const char *);
+/* Global singleton. */
+rtx_reader *rtx_reader_ptr = NULL;
+
/* The mode and code iterator structures. */
static struct iterator_group modes, codes, ints, substs;
@@ -326,7 +329,7 @@ map_attr_string (const char *p)
if any changes were needed, otherwise return STRING itself. */
const char *
-rtx_reader::apply_iterator_to_string (const char *string)
+md_reader::apply_iterator_to_string (const char *string)
{
char *base, *copy, *p, *start, *end;
struct map_value *v;
@@ -365,7 +368,7 @@ rtx_reader::apply_iterator_to_string (const char *string)
values into any strings. */
rtx
-rtx_reader::copy_rtx_for_iterators (rtx original)
+md_reader::copy_rtx_for_iterators (rtx original)
{
const char *format_ptr, *p;
int i, j;
@@ -735,7 +738,7 @@ atoll (const char *p)
slipped in at the beginning of the sequence of MD files read by
most of the other generators. */
void
-rtx_reader::read_conditions ()
+md_reader::read_conditions ()
{
int c;
@@ -834,8 +837,8 @@ record_attribute_use (struct iterator_group *group, void *ptr,
callback. */
void
-rtx_reader::record_potential_iterator_use (struct iterator_group *group,
- void *ptr, const char *name)
+md_reader::record_potential_iterator_use (struct iterator_group *group,
+ void *ptr, const char *name)
{
struct mapping *m;
size_t len;
@@ -869,7 +872,7 @@ rtx_reader::record_potential_iterator_use (struct iterator_group *group,
(which belongs to GROUP) and return it. */
struct mapping *
-rtx_reader::read_mapping (struct iterator_group *group, htab_t table)
+md_reader::read_mapping (struct iterator_group *group, htab_t table)
{
struct md_name name;
struct mapping *m;
@@ -1072,7 +1075,7 @@ rtx_reader::read_rtx (const char *rtx_name, vec<rtx> *rtxen)
return true;
}
- apply_iterators (read_rtx_code (rtx_name), rtxen);
+ apply_iterators (rtx_reader_ptr->read_rtx_code (rtx_name), rtxen);
iterator_uses.truncate (0);
attribute_uses.truncate (0);
@@ -1270,6 +1273,7 @@ rtx_reader::read_rtx_operand (rtx return_rtx, int idx)
{
char *stringbuf;
int star_if_braced;
+ struct obstack *string_obstack = get_string_obstack ();
c = read_skip_spaces ();
unread_char (c);
@@ -1306,11 +1310,11 @@ rtx_reader::read_rtx_operand (rtx return_rtx, int idx)
for (slash = fn; *slash; slash ++)
if (*slash == '/' || *slash == '\\' || *slash == ':')
fn = slash + 1;
- obstack_1grow (&m_string_obstack, '*');
- obstack_grow (&m_string_obstack, fn, strlen (fn));
+ obstack_1grow (string_obstack, '*');
+ obstack_grow (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 *);
+ obstack_grow (string_obstack, line_name, strlen (line_name)+1);
+ stringbuf = XOBFINISH (string_obstack, char *);
}
/* Find attr-names in the string. */
@@ -1447,3 +1451,20 @@ rtx_reader::read_rtx_variadic (rtx form)
unread_char (c);
return form;
}
+
+/* Constructor for class rtx_reader. */
+
+rtx_reader::rtx_reader ()
+: md_reader ()
+{
+ /* Set the global singleton pointer. */
+ rtx_reader_ptr = this;
+}
+
+/* Destructor for class rtx_reader. */
+
+rtx_reader::~rtx_reader ()
+{
+ /* Clear the global singleton pointer. */
+ rtx_reader_ptr = NULL;
+}