DF_REF_INSN looks up the "insn" field of the referenced df_insn_info.
This will eventually be an rtx_insn *, but for now is just an rtx.

As further scaffolding: for now, convert DF_REF_INSN to a function,
adding a checked downcast to rtx_insn *.  This can eventually be
converted back to macro when the field is an rtx_insn *.

gcc/
        * df-core.c (DF_REF_INSN): New, using a checked cast for now.
        * df.h (DF_REF_INSN): Convert from a macro to a function, so
        that we can return an rtx_insn *.

/
        * rtx-classes-status.txt: Add DF_REF_INSN.
---
 gcc/df-core.c          | 6 ++++++
 gcc/df.h               | 2 +-
 rtx-classes-status.txt | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/gcc/df-core.c b/gcc/df-core.c
index 9fdf6010..0dd8cc4 100644
--- a/gcc/df-core.c
+++ b/gcc/df-core.c
@@ -2532,3 +2532,9 @@ debug_df_chain (struct df_link *link)
   df_chain_dump (link, stderr);
   fputc ('\n', stderr);
 }
+
+rtx_insn *DF_REF_INSN (df_ref ref)
+{
+  rtx insn = ref->base.insn_info->insn;
+  return as_a_nullable <rtx_insn *> (insn);
+}
diff --git a/gcc/df.h b/gcc/df.h
index 878f507..aabde63 100644
--- a/gcc/df.h
+++ b/gcc/df.h
@@ -647,7 +647,7 @@ struct df_d
                        : BLOCK_FOR_INSN (DF_REF_INSN (REF)))
 #define DF_REF_BBNO(REF) (DF_REF_BB (REF)->index)
 #define DF_REF_INSN_INFO(REF) ((REF)->base.insn_info)
-#define DF_REF_INSN(REF) ((REF)->base.insn_info->insn)
+extern rtx_insn *DF_REF_INSN (df_ref ref);
 #define DF_REF_INSN_UID(REF) (INSN_UID (DF_REF_INSN(REF)))
 #define DF_REF_CLASS(REF) ((REF)->base.cl)
 #define DF_REF_TYPE(REF) ((REF)->base.type)
diff --git a/rtx-classes-status.txt b/rtx-classes-status.txt
index e57d775..68bbe54 100644
--- a/rtx-classes-status.txt
+++ b/rtx-classes-status.txt
@@ -10,5 +10,6 @@ Phase 6: use extra rtx_def subclasses:             TODO
 
 TODO: "Scaffolding" to be removed
 =================================
+* DF_REF_INSN
 * SET_BB_HEAD, SET_BB_END, SET_BB_HEADER, SET_BB_FOOTER
 * SET_NEXT_INSN, SET_PREV_INSN
-- 
1.8.5.3

Reply via email to