https://gcc.gnu.org/g:2da641d01700907d600ff9027ecfc82500342428

commit r16-1041-g2da641d01700907d600ff9027ecfc82500342428
Author: H.J. Lu <hjl.to...@gmail.com>
Date:   Sun Jun 1 09:29:48 2025 +0800

    Move get_call_rtx_from to final.c
    
    Move get_call_rtx_from to final.c and call call_from_call_insn.
    
            PR other/120493
            * final.cc (call_from_call_insn): Change the argument type to
            const rtx_call_insn *.
            (get_call_rtx_from): New.
            * rtl.h (is_a_helper <const rtx_call_insn *>::test): New.
            (get_call_rtx_from): Moved to the final.cc section.
            * rtlanal.cc (get_call_rtx_from): Removed.
    
    Signed-off-by: H.J. Lu <hjl.to...@gmail.com>

Diff:
---
 gcc/final.cc   | 11 ++++++++++-
 gcc/rtl.h      | 10 +++++++++-
 gcc/rtlanal.cc | 15 ---------------
 3 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/gcc/final.cc b/gcc/final.cc
index 12c6eb0ac09c..a4dbab72914b 100644
--- a/gcc/final.cc
+++ b/gcc/final.cc
@@ -2072,7 +2072,7 @@ output_alternate_entry_point (FILE *file, rtx_insn *insn)
 
 /* Given a CALL_INSN, find and return the nested CALL. */
 static rtx
-call_from_call_insn (rtx_call_insn *insn)
+call_from_call_insn (const rtx_call_insn *insn)
 {
   rtx x;
   gcc_assert (CALL_P (insn));
@@ -2098,6 +2098,15 @@ call_from_call_insn (rtx_call_insn *insn)
   return x;
 }
 
+/* Return the CALL in X if there is one.  */
+
+rtx
+get_call_rtx_from (const rtx_insn *insn)
+{
+  const rtx_call_insn *call_insn = as_a<const rtx_call_insn *> (insn);
+  return call_from_call_insn (call_insn);
+}
+
 /* Print a comment into the asm showing FILENAME, LINENUM, and the
    corresponding source line, if available.  */
 
diff --git a/gcc/rtl.h b/gcc/rtl.h
index 7049ed775e8f..8a740219c2a0 100644
--- a/gcc/rtl.h
+++ b/gcc/rtl.h
@@ -957,6 +957,14 @@ is_a_helper <rtx_call_insn *>::test (rtx_insn *insn)
   return CALL_P (insn);
 }
 
+template <>
+template <>
+inline bool
+is_a_helper <const rtx_call_insn *>::test (const rtx_insn *insn)
+{
+  return CALL_P (insn);
+}
+
 template <>
 template <>
 inline bool
@@ -3682,7 +3690,6 @@ extern bool nonzero_address_p (const_rtx);
 extern bool rtx_unstable_p (const_rtx);
 extern bool rtx_varies_p (const_rtx, bool);
 extern bool rtx_addr_varies_p (const_rtx, bool);
-extern rtx get_call_rtx_from (const rtx_insn *);
 extern tree get_call_fndecl (const rtx_insn *);
 extern HOST_WIDE_INT get_integer_term (const_rtx);
 extern rtx get_related_value (const_rtx);
@@ -4572,6 +4579,7 @@ extern void simplify_using_condition (rtx, rtx *, bitmap);
 extern void compute_alignments (void);
 extern void update_alignments (vec<rtx> &);
 extern int asm_str_count (const char *templ);
+extern rtx get_call_rtx_from (const rtx_insn *);
 
 struct rtl_hooks
 {
diff --git a/gcc/rtlanal.cc b/gcc/rtlanal.cc
index 900f53e252a9..239d6691c4ca 100644
--- a/gcc/rtlanal.cc
+++ b/gcc/rtlanal.cc
@@ -813,21 +813,6 @@ rtx_addr_varies_p (const_rtx x, bool for_alias)
   return false;
 }
 
-/* Return the CALL in X if there is one.  */
-
-rtx
-get_call_rtx_from (const rtx_insn *insn)
-{
-  rtx x = PATTERN (insn);
-  if (GET_CODE (x) == PARALLEL)
-    x = XVECEXP (x, 0, 0);
-  if (GET_CODE (x) == SET)
-    x = SET_SRC (x);
-  if (GET_CODE (x) == CALL && MEM_P (XEXP (x, 0)))
-    return x;
-  return NULL_RTX;
-}
-
 /* Get the declaration of the function called by INSN.  */
 
 tree

Reply via email to