From 7e82f805dbf882e91c6d303571ad85a6fe12eff1 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Thu, 7 Apr 2016 12:36:14 -0400 Subject: [PATCH 35/91] FIXME: handle insns that don't have a source location --- gcc/read-rtl.c | 66 ++++++++++++++++++++++++++++++++++++++++++++------- test-loop.cleaned.rtl | 4 ++-- 2 files changed, 60 insertions(+), 10 deletions(-) diff --git a/gcc/read-rtl.c b/gcc/read-rtl.c index 93ec910..3173a16 100644 --- a/gcc/read-rtl.c +++ b/gcc/read-rtl.c @@ -1166,6 +1166,62 @@ void fixup_insn_refs (void (*cb) (file_location, rtx, int, int)) (*cb) (f->m_loc, f->m_insn, f->m_operand_idx, f->m_insn_uid); } +/* FIXME. */ + +#ifndef GENERATOR_FILE + +/* Handle the optional location information written by print_rtx for + instructions. Specifically, operand 4 of instructions (of type "i') + is printed thus: + + if (INSN_HAS_LOCATION (in_insn)) + { + expanded_location xloc = insn_location (in_insn); + fprintf (outfile, " %s:%i", xloc.file, xloc.line); + } + + Hence we need to speculatively read a location of the form + " %s:%i", and unread the content if there wasn't one. + + Assume that filenames can't contain whitespace, and can't + contain ':'. */ + +void maybe_read_location () +{ + file_location loc = rtx_reader_ptr->get_current_location (); + + /* Skip to first non-whitespace. */ + int ch = read_skip_spaces (); + auto_vec buf; + buf.safe_push (ch); + while (1) + { + int ch = read_char (); + /* If we see a ':', assume we have a filename. */ + if (ch == ':') + { + buf.safe_push ('\0'); + break; + } + buf.safe_push (ch); + + /* If we see a space before ':', assume we don't have a + filename. */ + if (ISSPACE (ch)) + { + while (!buf.is_empty ()) + unread_char (buf.pop ()); + return; + } + } + inform (loc, "got filename: %qs", buf.address ()); + struct md_name name; + read_name (&name); + inform (loc, "got line: %qs", name.string); +} + +#endif /* #ifndef GENERATOR_FILE */ + /* Subroutine of read_rtx and read_nested_rtx. CODE_NAME is the name of either an rtx code or a code iterator. Parse the rest of the rtx and return it. */ @@ -1552,16 +1608,10 @@ read_rtx_code (const char *code_name) if (i == 4 && INSN_P (return_rtx)) { - // FIXME: location from fprintf (outfile, " %s:%i", xloc.file, xloc.line); - // and this won't work with filenames with a ':' in them - char ch; - do - ch = read_char (); - while (ch != ':'); - read_name (&name); + maybe_read_location (); break; } - + read_name (&name); int value; if (format_ptr[i] == 'n') diff --git a/test-loop.cleaned.rtl b/test-loop.cleaned.rtl index 84ae52a..d6f2262 100644 --- a/test-loop.cleaned.rtl +++ b/test-loop.cleaned.rtl @@ -79,9 +79,9 @@ (nil))) (code_label 20 19 21 6 3 "" [1 uses]) (note 21 20 22 6 [bb 6] NOTE_INSN_BASIC_BLOCK) -/* (insn 22 21 26 6 (set (reg:SI 88 [ ]) +(insn 22 21 26 6 (set (reg:SI 88 [ ]) (reg:SI 87 [ _1 ])) -1 - (nil)) */ + (nil)) (insn 26 22 27 6 (set (reg/i:SI 0 ax) (reg:SI 88 [ ])) ../../src/test-loop.c:7 -1 (nil)) -- 1.8.5.3