From 7f52b73661671e76c9d59d0e023d19e5499a0574 Mon Sep 17 00:00:00 2001 From: David Malcolm Date: Wed, 23 Mar 2016 00:04:12 -0400 Subject: [PATCH 13/91] FIXME: insn ref fixup --- gcc/read-rtl.c | 22 ++++++++++++++++++++++ gcc/rtl.h | 1 + gcc/rtl/rtl-frontend.c | 16 ++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/gcc/read-rtl.c b/gcc/read-rtl.c index f622981..3f902283 100644 --- a/gcc/read-rtl.c +++ b/gcc/read-rtl.c @@ -1139,6 +1139,26 @@ parse_note_insn_name (const char *string) } #endif /* #ifndef GENERATOR_FILE */ +class fixup +{ + public: + fixup (rtx insn, int operand_idx, int insn_uid) + : m_insn (insn), m_operand_idx (operand_idx), m_insn_uid (insn_uid) + {} + + rtx m_insn; + int m_operand_idx; + int m_insn_uid; +}; +static vec fixups; + +void fixup_insn_refs (void (*cb) (rtx, int, int)) +{ + int i; + fixup *f; + FOR_EACH_VEC_ELT (fixups, i, f) + (*cb) (f->m_insn, f->m_operand_idx, f->m_insn_uid); +} /* 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 @@ -1304,6 +1324,8 @@ read_rtx_code (const char *code_name) fprintf (stderr, "FIXME: would store insn %i into field %i of %s %p\n", insn_id, i, code_name, (void *)return_rtx); + fixup f (return_rtx, i, insn_id); + fixups.safe_push (f); } #endif break; diff --git a/gcc/rtl.h b/gcc/rtl.h index 3a19242..d285e66 100644 --- a/gcc/rtl.h +++ b/gcc/rtl.h @@ -3643,6 +3643,7 @@ extern rtx make_debug_expr_from_rtl (const_rtx); extern bool read_rtx (const char *, vec *); #endif extern rtx read_rtx_code (const char *code_name); +extern void fixup_insn_refs (void (*cb) (rtx, int, int)); /* In alias.c */ extern rtx canon_rtx (rtx); diff --git a/gcc/rtl/rtl-frontend.c b/gcc/rtl/rtl-frontend.c index cfb9e2e..2a17b73 100644 --- a/gcc/rtl/rtl-frontend.c +++ b/gcc/rtl/rtl-frontend.c @@ -156,6 +156,9 @@ rtl_langhook_handle_option ( return true; } +struct uid_hash : int_hash {}; +static hash_map insns_by_uid; + static void directive_handler (file_location loc, const char *name) { @@ -163,6 +166,17 @@ directive_handler (file_location loc, const char *name) if (!x) return; debug (x); + insns_by_uid.put (INSN_UID(x), x); +} + +static void +fixup_cb (rtx insn, int operand_idx, int insn_uid) +{ + rtx *insn_from_uid = insns_by_uid.get (insn_uid); + if (insn_from_uid) + XEXP (insn, operand_idx) = *insn_from_uid; + else + error ("insn UID %i not found", insn_uid); } static void @@ -179,6 +193,8 @@ rtl_langhook_parse_file (void) else { } + + fixup_insn_refs (fixup_cb); } static tree -- 1.8.5.3