aboutsummaryrefslogtreecommitdiff
path: root/gcc/read-md.h
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-md.h
parent776a8a927eeeb7ea3c13b6a981f340591dcef530 (diff)
downloadgcc-a96d1f1d028e6798413eea810d2c6beee7519a6d.zip
gcc-a96d1f1d028e6798413eea810d2c6beee7519a6d.tar.gz
gcc-a96d1f1d028e6798413eea810d2c6beee7519a6d.tar.bz2
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-md.h')
-rw-r--r--gcc/read-md.h59
1 files changed, 44 insertions, 15 deletions
diff --git a/gcc/read-md.h b/gcc/read-md.h
index 06b89b4..27fc9c2 100644
--- a/gcc/read-md.h
+++ b/gcc/read-md.h
@@ -91,11 +91,23 @@ struct enum_type {
unsigned int num_values;
};
-class rtx_reader
+/* A class for reading .md files and RTL dump files.
+
+ Implemented in read-md.c.
+
+ This class has responsibility for reading chars from input files, and
+ for certain common top-level directives including the "include"
+ directive.
+
+ It does not handle parsing the hierarchically-nested expressions of
+ rtl.def; for that see the rtx_reader subclass below (implemented in
+ read-rtl.c). */
+
+class md_reader
{
public:
- rtx_reader ();
- virtual ~rtx_reader ();
+ md_reader ();
+ virtual ~md_reader ();
bool read_md_files (int, const char **, bool (*) (const char *));
@@ -145,11 +157,6 @@ class rtx_reader
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_filename () const { return m_read_md_filename; }
@@ -231,20 +238,42 @@ class rtx_reader
htab_t m_enum_types;
};
-/* Global singleton. */
-extern rtx_reader *rtx_reader_ptr;
+/* Global singleton; constrast with rtx_reader_ptr below. */
+extern md_reader *md_reader_ptr;
-/* An rtx_reader subclass which skips unknown directives. */
+/* An md_reader subclass which skips unknown directives, for
+ the gen* tools that purely use read-md.o. */
-class noop_reader : public rtx_reader
+class noop_reader : public md_reader
{
public:
- noop_reader () : rtx_reader () {}
+ noop_reader () : md_reader () {}
/* A dummy implementation which skips unknown directives. */
void handle_unknown_directive (file_location, const char *);
};
+/* An md_reader subclass that actually handles full hierarchical
+ rtx expressions.
+
+ Implemented in read-rtl.c. */
+
+class rtx_reader : public md_reader
+{
+ public:
+ rtx_reader ();
+ ~rtx_reader ();
+
+ 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);
+};
+
+/* Global singleton; constrast with md_reader_ptr above. */
+extern rtx_reader *rtx_reader_ptr;
+
extern void (*include_callback) (const char *);
/* Read the next character from the MD file. */
@@ -252,7 +281,7 @@ extern void (*include_callback) (const char *);
static inline int
read_char (void)
{
- return rtx_reader_ptr->read_char ();
+ return md_reader_ptr->read_char ();
}
/* Put back CH, which was the last character read from the MD file. */
@@ -260,7 +289,7 @@ read_char (void)
static inline void
unread_char (int ch)
{
- rtx_reader_ptr->unread_char (ch);
+ md_reader_ptr->unread_char (ch);
}
extern hashval_t leading_string_hash (const void *);