From 0c478b7b6bbee6236eb900c66a74492250449549 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 7 Apr 2016 06:28:31 -0400 Subject: [PATCH 25/91] FIXME: initial version of column-handling --- gcc/read-md.c | 18 +++++++++++++++++- gcc/read-md.h | 17 ++++++++++++++++- gcc/read-rtl.c | 2 +- 3 files changed, 34 insertions(+), 3 deletions(-) diff --git a/gcc/read-md.c b/gcc/read-md.c index 8cbc8db..f5722ee 100644 --- a/gcc/read-md.c +++ b/gcc/read-md.c @@ -68,6 +68,9 @@ const char *read_md_filename; /* The current line number in READ_MD_FILE. */ int read_md_lineno; +/* FIXME. */ +int read_md_colno; + /* The name of the toplevel file that indirectly included READ_MD_FILE. */ const char *in_fname; @@ -1110,7 +1113,20 @@ rtx_reader::get_current_location () const { return linemap_position_for_line_and_column (m_line_table, m_current_linemap, - read_md_lineno, 0); + read_md_lineno, read_md_colno); +} + +/* FIXME. */ + +void +rtx_reader::update_location (bool advancing) +{ + if (advancing) + { + if (read_md_lineno == 0) + linemap_line_start (m_line_table, read_md_lineno, 1024 /* max_column_hint */); + linemap_position_for_column (m_line_table, read_md_colno); + } } /* Parse a -I option with argument ARG. */ diff --git a/gcc/read-md.h b/gcc/read-md.h index 716a5a1..31e6f05 100644 --- a/gcc/read-md.h +++ b/gcc/read-md.h @@ -97,6 +97,8 @@ class rtx_reader file_location get_current_location () const; + void update_location (bool advancing); + private: void handle_file (); void handle_toplevel_file (); @@ -122,6 +124,7 @@ class noop_reader : public rtx_reader extern const char *in_fname; extern FILE *read_md_file; extern int read_md_lineno; +extern int read_md_colno; extern const char *read_md_filename; extern struct obstack string_obstack; extern void (*include_callback) (const char *); @@ -135,7 +138,15 @@ read_char (void) ch = getc (read_md_file); if (ch == '\n') - read_md_lineno++; + { + read_md_lineno++; + read_md_colno = 1; + } + else + read_md_colno++; + + rtx_reader_ptr->update_location (true); + return ch; } @@ -144,8 +155,12 @@ read_char (void) static inline void unread_char (int ch) { + /* FIXME: what about colno when unreading a '\n'? */ if (ch == '\n') read_md_lineno--; + else + read_md_colno--; + rtx_reader_ptr->update_location (false); ungetc (ch, read_md_file); } diff --git a/gcc/read-rtl.c b/gcc/read-rtl.c index beec35c..68994b3 100644 --- a/gcc/read-rtl.c +++ b/gcc/read-rtl.c @@ -1321,6 +1321,7 @@ read_rtx_code (const char *code_name) /* The RTL file recorded the ID of an insn (or 0 for NULL); we must store this as a pointer, but the insn might not have been loaded yet. Store the ID away for now. */ + file_location loc = rtx_reader_ptr->get_current_location (); read_name (&name); int insn_id = atoi (name.string); if (insn_id) @@ -1328,7 +1329,6 @@ read_rtx_code (const char *code_name) fprintf (stderr, "FIXME: would store insn %i into field %i of %s %p\n", insn_id, i, code_name, (void *)return_rtx); - file_location loc = rtx_reader_ptr->get_current_location (); fixup f (loc, return_rtx, i, insn_id); fixups.safe_push (f); } -- 1.8.5.3