[2/6] gas: ginsn: add new ginsn_cofi_p function

Message ID 20240808153853.936481-3-indu.bhagat@oracle.com
State New
Headers
Series gas: scfi: aarch64: support split sp update pattern |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_binutils_build--master-arm success Build passed
linaro-tcwg-bot/tcwg_binutils_build--master-aarch64 success Build passed
linaro-tcwg-bot/tcwg_binutils_check--master-aarch64 success Test passed
linaro-tcwg-bot/tcwg_binutils_check--master-arm success Test passed

Commit Message

Indu Bhagat Aug. 8, 2024, 3:38 p.m. UTC
  Add new function to know whether a ginsn is a change of flow
instruction.

gas/
        * ginsn.c (ginsn_cofi_p): New definition.
        * ginsn.h (ginsn_cofi_p): New declaration.
---
 gas/ginsn.c | 14 ++++++++++++++
 gas/ginsn.h |  2 ++
 2 files changed, 16 insertions(+)
  

Patch

diff --git a/gas/ginsn.c b/gas/ginsn.c
index 7a21a5fa52e..1a5c4c0b980 100644
--- a/gas/ginsn.c
+++ b/gas/ginsn.c
@@ -432,6 +432,20 @@  ginsn_track_reg_p (unsigned int dw2reg, enum ginsn_gen_mode gmode)
   return track_p;
 }
 
+/* Whether GINSN is a change of flow instruction.  */
+
+bool
+ginsn_cofi_p (ginsnS *ginsn)
+{
+  if (!ginsn)
+    return false;
+
+  return (ginsn->type == GINSN_TYPE_JUMP
+	  || ginsn->type == GINSN_TYPE_JUMP_COND
+	  || ginsn->type == GINSN_TYPE_RETURN
+	  || ginsn->type == GINSN_TYPE_CALL);
+}
+
 static bool
 ginsn_indirect_jump_p (ginsnS *ginsn)
 {
diff --git a/gas/ginsn.h b/gas/ginsn.h
index 2513e3c5cc0..c8e2d0683aa 100644
--- a/gas/ginsn.h
+++ b/gas/ginsn.h
@@ -305,6 +305,8 @@  bool ginsn_track_reg_p (unsigned int dw2reg, enum ginsn_gen_mode);
 
 int ginsn_link_next (ginsnS *ginsn, ginsnS *next);
 
+bool ginsn_cofi_p (ginsnS *ginsn);
+
 enum gcfg_err_code
 {
   GCFG_OK = 0,