Commit 737eb767 by Richard Sandiford Committed by Richard Sandiford

Use file_location for md_reader's ptr_loc

Also make it public, so that clients can use the location for error
reporting.

2019-07-16  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
	* read-md.h (md_reader::ptr_loc): Moved from read-md.c.
	Use file_location instead of separate fields.
	(md_reader::set_md_ptr_loc): Take a file_location instead of a
	separate filename and line number.
	* read-md.c (ptr_loc): As above.
	(md_reader::copy_md_ptr_loc): Update for new ptr_loc layout.
	(md_reader::fprint_md_ptr_loc): Likewise.
	(md_reader::set_md_ptr_loc): Likewise.  Take a file_location
	instead of a separate filename and line number.
	(md_reader::read_string): Update call accordingly.

From-SVN: r273510
parent f6e5e4b8
2019-07-16 Richard Sandiford <richard.sandiford@arm.com> 2019-07-16 Richard Sandiford <richard.sandiford@arm.com>
* read-md.h (md_reader::ptr_loc): Moved from read-md.c.
Use file_location instead of separate fields.
(md_reader::set_md_ptr_loc): Take a file_location instead of a
separate filename and line number.
* read-md.c (ptr_loc): As above.
(md_reader::copy_md_ptr_loc): Update for new ptr_loc layout.
(md_reader::fprint_md_ptr_loc): Likewise.
(md_reader::set_md_ptr_loc): Likewise. Take a file_location
instead of a separate filename and line number.
(md_reader::read_string): Update call accordingly.
2019-07-16 Richard Sandiford <richard.sandiford@arm.com>
* config/rs6000/rs6000.md (*mov<mode>_update1): Explicitly * config/rs6000/rs6000.md (*mov<mode>_update1): Explicitly
use <SFDF:mode>, <SFDF:MODE>, <SFDF:Ff> and <SFDF:bits> rather than use <SFDF:mode>, <SFDF:MODE>, <SFDF:Ff> and <SFDF:bits> rather than
leaving the choice between SFDF and P implicit. leaving the choice between SFDF and P implicit.
......
...@@ -43,14 +43,6 @@ int have_error = 0; ...@@ -43,14 +43,6 @@ int have_error = 0;
#endif /* #ifndef GENERATOR_FILE */ #endif /* #ifndef GENERATOR_FILE */
/* Associates PTR (which can be a string, etc.) with the file location
specified by FILENAME and LINENO. */
struct ptr_loc {
const void *ptr;
const char *filename;
int lineno;
};
/* This callback will be invoked whenever an md include directive is /* This callback will be invoked whenever an md include directive is
processed. To be used for creation of the dependency file. */ processed. To be used for creation of the dependency file. */
void (*include_callback) (const char *); void (*include_callback) (const char *);
...@@ -94,25 +86,24 @@ leading_ptr_eq_p (const void *def1, const void *def2) ...@@ -94,25 +86,24 @@ leading_ptr_eq_p (const void *def1, const void *def2)
return *(const void *const *) def1 == *(const void *const *) def2; return *(const void *const *) def1 == *(const void *const *) def2;
} }
/* Associate PTR with the file position given by FILENAME and LINENO. */ /* Associate PTR with the file position given by FILE_LOC. */
void void
md_reader::set_md_ptr_loc (const void *ptr, const char *filename, int lineno) md_reader::set_md_ptr_loc (const void *ptr, file_location file_loc)
{ {
struct ptr_loc *loc; struct ptr_loc *loc;
loc = (struct ptr_loc *) obstack_alloc (&m_ptr_loc_obstack, loc = (struct ptr_loc *) obstack_alloc (&m_ptr_loc_obstack,
sizeof (struct ptr_loc)); sizeof (struct ptr_loc));
loc->ptr = ptr; loc->ptr = ptr;
loc->filename = filename; loc->loc = file_loc;
loc->lineno = lineno;
*htab_find_slot (m_ptr_locs, loc, INSERT) = loc; *htab_find_slot (m_ptr_locs, loc, INSERT) = loc;
} }
/* Return the position associated with pointer PTR. Return null if no /* Return the position associated with pointer PTR. Return null if no
position was set. */ position was set. */
const struct ptr_loc * const md_reader::ptr_loc *
md_reader::get_md_ptr_loc (const void *ptr) md_reader::get_md_ptr_loc (const void *ptr)
{ {
return (const struct ptr_loc *) htab_find (m_ptr_locs, &ptr); return (const struct ptr_loc *) htab_find (m_ptr_locs, &ptr);
...@@ -125,7 +116,7 @@ md_reader::copy_md_ptr_loc (const void *new_ptr, const void *old_ptr) ...@@ -125,7 +116,7 @@ md_reader::copy_md_ptr_loc (const void *new_ptr, const void *old_ptr)
{ {
const struct ptr_loc *loc = get_md_ptr_loc (old_ptr); const struct ptr_loc *loc = get_md_ptr_loc (old_ptr);
if (loc != 0) if (loc != 0)
set_md_ptr_loc (new_ptr, loc->filename, loc->lineno); set_md_ptr_loc (new_ptr, loc->loc);
} }
/* If PTR is associated with a known file position, print a #line /* If PTR is associated with a known file position, print a #line
...@@ -136,7 +127,7 @@ md_reader::fprint_md_ptr_loc (FILE *outf, const void *ptr) ...@@ -136,7 +127,7 @@ md_reader::fprint_md_ptr_loc (FILE *outf, const void *ptr)
{ {
const struct ptr_loc *loc = get_md_ptr_loc (ptr); const struct ptr_loc *loc = get_md_ptr_loc (ptr);
if (loc != 0) if (loc != 0)
fprintf (outf, "#line %d \"%s\"\n", loc->lineno, loc->filename); fprintf (outf, "#line %d \"%s\"\n", loc->loc.lineno, loc->loc.filename);
} }
/* Special fprint_md_ptr_loc for writing to STDOUT. */ /* Special fprint_md_ptr_loc for writing to STDOUT. */
...@@ -672,7 +663,7 @@ md_reader::read_string (int star_if_braced) ...@@ -672,7 +663,7 @@ md_reader::read_string (int star_if_braced)
{ {
char *stringbuf; char *stringbuf;
int saw_paren = 0; int saw_paren = 0;
int c, old_lineno; int c;
c = read_skip_spaces (); c = read_skip_spaces ();
if (c == '(') if (c == '(')
...@@ -681,7 +672,7 @@ md_reader::read_string (int star_if_braced) ...@@ -681,7 +672,7 @@ md_reader::read_string (int star_if_braced)
c = read_skip_spaces (); c = read_skip_spaces ();
} }
old_lineno = get_lineno (); file_location loc = get_current_location ();
if (c == '"') if (c == '"')
stringbuf = read_quoted_string (); stringbuf = read_quoted_string ();
else if (c == '{') else if (c == '{')
...@@ -704,7 +695,7 @@ md_reader::read_string (int star_if_braced) ...@@ -704,7 +695,7 @@ md_reader::read_string (int star_if_braced)
if (saw_paren) if (saw_paren)
require_char_ws (')'); require_char_ws (')');
set_md_ptr_loc (stringbuf, get_filename (), old_lineno); set_md_ptr_loc (stringbuf, loc);
return stringbuf; return stringbuf;
} }
......
...@@ -149,6 +149,13 @@ struct mapping; ...@@ -149,6 +149,13 @@ struct mapping;
class md_reader class md_reader
{ {
public: public:
/* Associates PTR (which can be a string, etc.) with the file location
specified by LOC. */
struct ptr_loc {
const void *ptr;
file_location loc;
};
md_reader (bool compact); md_reader (bool compact);
virtual ~md_reader (); virtual ~md_reader ();
...@@ -183,7 +190,7 @@ class md_reader ...@@ -183,7 +190,7 @@ class md_reader
void require_word_ws (const char *expected); void require_word_ws (const char *expected);
int peek_char (void); int peek_char (void);
void set_md_ptr_loc (const void *ptr, const char *filename, int lineno); void set_md_ptr_loc (const void *ptr, file_location);
const struct ptr_loc *get_md_ptr_loc (const void *ptr); 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 copy_md_ptr_loc (const void *new_ptr, const void *old_ptr);
void fprint_md_ptr_loc (FILE *outf, const void *ptr); void fprint_md_ptr_loc (FILE *outf, const void *ptr);
......
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