From 2f0c7be23a88c4b80146ae0cf70f72d82864991c Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Fri, 8 Apr 2016 03:22:37 -0400 Subject: [PATCH 46/91] FIXME: handle numeric JUMP_LABEL values --- gcc/read-md.h | 5 +++++ gcc/read-rtl.c | 29 ++++++++++++++++++---------- gcc/rtl/rtl-frontend.c | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 76 insertions(+), 10 deletions(-) diff --git a/gcc/read-md.h b/gcc/read-md.h index 493d312..7e6ad93 100644 --- a/gcc/read-md.h +++ b/gcc/read-md.h @@ -116,6 +116,11 @@ class rtx_reader int /*lineno*/) {} + virtual void add_fixup_jump_label (file_location /*loc*/, rtx /*insn*/, + int /*operand_idx*/, + const char */*label*/) + {} + file_location get_current_location () const; void update_location (bool advancing); diff --git a/gcc/read-rtl.c b/gcc/read-rtl.c index 192d8f7..ee96e5dc 100644 --- a/gcc/read-rtl.c +++ b/gcc/read-rtl.c @@ -1337,16 +1337,6 @@ read_rtx_code (const char *code_name) case '0': if (code == REG) ORIGINAL_REGNO (return_rtx) = REGNO (return_rtx); - else if (i == 7 && JUMP_P (return_rtx)) - { -#ifndef GENERATOR_FILE - /* TODO: parse the jump label. */ - char ch; - while ((ch = read_char ()) != ')') - ; - unread_char (')'); -#endif - } else if (i == 3 && code == NOTE) { /* Note-specific data appears for operand 3, which annoyingly @@ -1377,6 +1367,25 @@ read_rtx_code (const char *code_name) unread_char (c); #endif /* #ifndef GENERATOR_FILE */ } + else if (i == 7 && JUMP_P (return_rtx)) + { +#ifndef GENERATOR_FILE + if (1) + inform (rtx_reader_ptr->get_current_location (), + "jump_insn-specific data here"); + c = read_skip_spaces (); + if (c != '-') + { + unread_char (c); + break; + } + c = read_char (); + if (c != '>') + fatal_expected_char ('>', c); + file_location loc = read_name (&name); + rtx_reader_ptr->add_fixup_jump_label (loc, return_rtx, i, name.string); +#endif /* #ifndef GENERATOR_FILE */ + } break; case 'e': diff --git a/gcc/rtl/rtl-frontend.c b/gcc/rtl/rtl-frontend.c index b433574..03465a0 100644 --- a/gcc/rtl/rtl-frontend.c +++ b/gcc/rtl/rtl-frontend.c @@ -241,6 +241,23 @@ class fixup_source_location : public fixup deferred_location *m_dloc; }; +class fixup_jump_label : public fixup +{ + public: + fixup_jump_label (file_location loc, rtx insn, + int operand_idx, + const char *label) + : fixup (loc, insn, operand_idx), + m_label (xstrdup (label)) + {} + + void apply (function_reader *reader) const; + + private: + const char *m_label; +}; + + class function_reader : public rtx_reader { public: @@ -264,6 +281,10 @@ class function_reader : public rtx_reader int operand_idx, const char *filename, int lineno); + void add_fixup_jump_label (file_location loc, rtx insn, + int operand_idx, + const char *label); + void create_function (); void apply_fixups (); @@ -342,6 +363,29 @@ fixup_source_location::apply (function_reader */*reader*/) const INSN_LOCATION (as_a (m_insn)) = m_dloc->m_srcloc; } +void +fixup_jump_label::apply (function_reader *reader) const +{ + inform (m_loc, "jump_label: %qs", m_label); +#if 0 + if (0 == strcmp (m_label, "return")) + JUMP_LABEL (m_insn) = ; //RETURN + else if (0 == strcmp (m_label, "simple_return")) + JUMP_LABEL (m_insn) = ; //SIMPLE_RETURN + else +#endif + { + int label_uid = atoi (m_label); + rtx *insn_from_uid = reader->get_insn_by_uid (label_uid); + if (insn_from_uid) + JUMP_LABEL (m_insn) = *insn_from_uid; + else + error_at (m_loc, + "insn with UID %i not found for operand %i (%qs) of insn %i", + label_uid, m_operand_idx, "JUMP_LABEL", INSN_UID (m_insn)); + } +} + function_reader::~function_reader () { int i; @@ -404,6 +448,14 @@ function_reader::add_fixup_source_location (file_location loc, rtx insn, } void +function_reader::add_fixup_jump_label (file_location loc, rtx insn, + int operand_idx, + const char *label) +{ + m_fixups.safe_push (new fixup_jump_label (loc, insn, operand_idx, label)); +} + +void function_reader::create_function () { #if 1 -- 1.8.5.3