aboutsummaryrefslogtreecommitdiff
path: root/gcc/read-md.c
diff options
context:
space:
mode:
authorDavid Malcolm <dmalcolm@redhat.com>2016-12-07 18:16:32 +0000
committerDavid Malcolm <dmalcolm@gcc.gnu.org>2016-12-07 18:16:32 +0000
commit9c4e96eb1e305a9f35e4dbafb0a1fe29ef226265 (patch)
treef630779522d438dada81b844779c84d2ca6d302d /gcc/read-md.c
parent8e1d640fcdf694fe1d83818b123b550e0da96705 (diff)
downloadgcc-9c4e96eb1e305a9f35e4dbafb0a1fe29ef226265.zip
gcc-9c4e96eb1e305a9f35e4dbafb0a1fe29ef226265.tar.gz
gcc-9c4e96eb1e305a9f35e4dbafb0a1fe29ef226265.tar.bz2
Add some functions for use by the RTL frontend.
gcc/ChangeLog: * read-md.c (rtx_reader::require_char): New method. (require_char_ws): Convert from function to... (rtx_reader::require_char_ws): ...method. (rtx_reader::require_word_ws): New method. * read-md.h (rtx_reader::require_char): New method decl. (require_char_ws): Remove global decl in favor of... (rtx_reader::require_char_ws): ...new method decl. (rtx_reader::require_word_ws): New method decl. (rtx_reader::peek_char): New method decl. From-SVN: r243376
Diffstat (limited to 'gcc/read-md.c')
-rw-r--r--gcc/read-md.c35
1 files changed, 34 insertions, 1 deletions
diff --git a/gcc/read-md.c b/gcc/read-md.c
index 6fe2600..095075f 100644
--- a/gcc/read-md.c
+++ b/gcc/read-md.c
@@ -340,17 +340,40 @@ read_skip_spaces (void)
}
}
+/* Consume the next character, issuing a fatal error if it is not
+ EXPECTED. */
+
+void
+rtx_reader::require_char (char expected)
+{
+ int ch = read_char ();
+ if (ch != expected)
+ fatal_expected_char (expected, ch);
+}
+
/* Consume any whitespace, then consume the next non-whitespace
character, issuing a fatal error if it is not EXPECTED. */
void
-require_char_ws (char expected)
+rtx_reader::require_char_ws (char expected)
{
int ch = read_skip_spaces ();
if (ch != expected)
fatal_expected_char (expected, ch);
}
+/* Consume any whitespace, then consume the next word (as per read_name),
+ issuing a fatal error if it is not EXPECTED. */
+
+void
+rtx_reader::require_word_ws (const char *expected)
+{
+ struct md_name name;
+ read_name (&name);
+ if (strcmp (name.string, expected))
+ fatal_with_file_and_line ("missing '%s'", expected);
+}
+
/* Read the next character from the file. */
int
@@ -386,6 +409,16 @@ rtx_reader::unread_char (int ch)
ungetc (ch, m_read_md_file);
}
+/* Peek at the next character from the file without consuming it. */
+
+int
+rtx_reader::peek_char (void)
+{
+ int ch = read_char ();
+ unread_char (ch);
+ return ch;
+}
+
/* Read an rtx code name into NAME. It is terminated by any of the
punctuation chars of rtx printed syntax. */