From a4721e94e844615f9a834099437254b46ccbc9fb Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 6 Apr 2016 21:50:31 -0400 Subject: [PATCH 21/55] FIXME: handle insns with NULL basic block --- gcc/print-rtl.c | 2 ++ gcc/read-md.c | 40 ++++++++++++++++++++++++++++++++++------ gcc/read-md.h | 3 ++- gcc/read-rtl.c | 4 ++-- test-loop.cleaned.rtl | 2 +- 5 files changed, 41 insertions(+), 10 deletions(-) diff --git a/gcc/print-rtl.c b/gcc/print-rtl.c index 85d9b8d..b918195 100644 --- a/gcc/print-rtl.c +++ b/gcc/print-rtl.c @@ -586,6 +586,8 @@ print_rtx (const_rtx in_rtx) #ifndef GENERATOR_FILE if (XBBDEF (in_rtx, i)) fprintf (outfile, " %i", XBBDEF (in_rtx, i)->index); + else + fprintf (outfile, " (nil)"); #endif break; diff --git a/gcc/read-md.c b/gcc/read-md.c index ec6fe69..0975758 100644 --- a/gcc/read-md.c +++ b/gcc/read-md.c @@ -99,6 +99,8 @@ static htab_t md_constants; /* A table of enum_type structures, hashed by name. */ static htab_t enum_types; +static void read_skip_construct (int depth, file_location loc); + /* Given an object that starts with a char * name field, return a hash code for its name. */ @@ -338,7 +340,7 @@ fatal_with_file_and_line (const char *msg, ...) va_end (ap); #ifndef GENERATOR_FILE - file_location loc = rtx_reader_ptr->get_currrent_location (); + file_location loc = rtx_reader_ptr->get_current_location (); inform (loc, "here"); #endif @@ -410,8 +412,8 @@ read_skip_spaces (void) /* Read an rtx code name into NAME. It is terminated by any of the punctuation chars of rtx printed syntax. */ -void -read_name (struct md_name *name) +static bool +read_name_1 (struct md_name *name) { int c; size_t i; @@ -450,7 +452,7 @@ read_name (struct md_name *name) } if (i == 0) - fatal_with_file_and_line ("missing name or number"); + return false; name->buffer[i] = 0; name->string = name->buffer; @@ -471,6 +473,32 @@ read_name (struct md_name *name) } while (def); } + + return true; +} + +/* Read an rtx code name into NAME. It is terminated by any of the + punctuation chars of rtx printed syntax. */ + +void +read_name (struct md_name *name) +{ + if (!read_name_1 (name)) + fatal_with_file_and_line ("missing name or number"); +} + +void +read_name_or_nil (struct md_name *name) +{ + if (!read_name_1 (name)) + { + file_location loc = rtx_reader_ptr->get_current_location (); + read_skip_construct (0, loc); + /* Skip the ')'. */ + read_char (); + name->buffer[0] = 0; + name->string = name->buffer; + } } /* Subroutine of the string readers. Handles backslash escapes. @@ -1032,7 +1060,7 @@ rtx_reader::handle_file () read_md_lineno = 1; while ((c = read_skip_spaces ()) != EOF) { - file_location loc = get_currrent_location (); + file_location loc = get_current_location (); if (c != '(') fatal_expected_char ('(', c); @@ -1078,7 +1106,7 @@ rtx_reader::handle_toplevel_file () } file_location -rtx_reader::get_currrent_location () const +rtx_reader::get_current_location () const { return linemap_position_for_line_and_column (m_line_table, m_current_linemap, diff --git a/gcc/read-md.h b/gcc/read-md.h index 0cc52f6..c0ace66 100644 --- a/gcc/read-md.h +++ b/gcc/read-md.h @@ -95,7 +95,7 @@ class rtx_reader unread character is the optional space after the directive name. */ virtual void handle_unknown_directive (file_location, const char *) = 0; - file_location get_currrent_location () const; + file_location get_current_location () const; private: void handle_file (); @@ -162,6 +162,7 @@ extern void fatal_with_file_and_line (const char *, ...) extern void fatal_expected_char (int, int) ATTRIBUTE_NORETURN; extern int read_skip_spaces (void); extern void read_name (struct md_name *); +extern void read_name_or_nil (struct md_name *); extern char *read_quoted_string (void); extern char *read_string (int); extern int n_comma_elts (const char *); diff --git a/gcc/read-rtl.c b/gcc/read-rtl.c index 3f902283..57adf42 100644 --- a/gcc/read-rtl.c +++ b/gcc/read-rtl.c @@ -1540,8 +1540,8 @@ read_rtx_code (const char *code_name) case 'B': { - read_name (&name); - fprintf (stderr, "FIXME: do something with basic block ID: %s\n", + read_name_or_nil (&name); + fprintf (stderr, "FIXME: do something with basic block ID: '%s'\n", name.string); } break; diff --git a/test-loop.cleaned.rtl b/test-loop.cleaned.rtl index 1a928f9..2f39d1f 100644 --- a/test-loop.cleaned.rtl +++ b/test-loop.cleaned.rtl @@ -12,7 +12,7 @@ ;; ;; Full RTL generated for this function: ;; -;;(note 1 0 6 NOTE_INSN_DELETED) +(note 1 0 6 (nil) NOTE_INSN_DELETED) ;;(note 6 1 2 2 [bb 2] NOTE_INSN_BASIC_BLOCK) (insn 2 6 3 2 (set (mem/c:SI (plus:DI (reg/f:DI 82 virtual-stack-vars) (const_int -4 [0xfffffffffffffffc])) [1 i+0 S4 A32]) -- 1.8.5.3