https://gcc.gnu.org/g:19808ef87a7862117310738b07a6c861a9092678
commit r17-421-g19808ef87a7862117310738b07a6c861a9092678 Author: Andrew Pinski <[email protected]> Date: Fri May 8 17:16:10 2026 -0700 cfghooks: Move ir_type inside cfghooks This is the first step in constification (and/or C++ification) of the cfghooks. Currently we compare variables to figure out what the current IR type is. Rather let's move the ir_type into the cfghooks. This will help with constification due to sel-sched overloading one of the hooks. Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: * cfghooks.cc (current_ir_type): Return cfghooks' ir field. * cfghooks.h (struct cfg_hooks): Add ir field. * cfgrtl.cc (rtl_cfg_hooks): Update for new ir field. (cfg_layout_rtl_cfg_hooks): Likewise. * tree-cfg.cc (gimple_cfg_hooks): Likewise. Signed-off-by: Andrew Pinski <[email protected]> Diff: --- gcc/cfghooks.cc | 9 +-------- gcc/cfghooks.h | 1 + gcc/cfgrtl.cc | 2 ++ gcc/tree-cfg.cc | 1 + 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/gcc/cfghooks.cc b/gcc/cfghooks.cc index 6415d0fdec25..381d63c9398c 100644 --- a/gcc/cfghooks.cc +++ b/gcc/cfghooks.cc @@ -86,14 +86,7 @@ set_cfg_hooks (struct cfg_hooks new_cfg_hooks) enum ir_type current_ir_type (void) { - if (cfg_hooks == &gimple_cfg_hooks) - return IR_GIMPLE; - else if (cfg_hooks == &rtl_cfg_hooks) - return IR_RTL_CFGRTL; - else if (cfg_hooks == &cfg_layout_rtl_cfg_hooks) - return IR_RTL_CFGLAYOUT; - else - gcc_unreachable (); + return cfg_hooks->ir; } /* Verify the CFG consistency. diff --git a/gcc/cfghooks.h b/gcc/cfghooks.h index bc7956be2a8a..75857f6f90dc 100644 --- a/gcc/cfghooks.h +++ b/gcc/cfghooks.h @@ -79,6 +79,7 @@ struct cfg_hooks { /* Name of the corresponding ir. */ const char *name; + enum ir_type ir; /* Debugging. */ bool (*verify_flow_info) (void); diff --git a/gcc/cfgrtl.cc b/gcc/cfgrtl.cc index 0e409140e71d..5a0b09f801e4 100644 --- a/gcc/cfgrtl.cc +++ b/gcc/cfgrtl.cc @@ -5386,6 +5386,7 @@ rtl_account_profile_record (basic_block bb, struct profile_record *record) /* Implementation of CFG manipulation for linearized RTL. */ struct cfg_hooks rtl_cfg_hooks = { "rtl", + IR_RTL_CFGRTL, rtl_verify_flow_info, rtl_dump_bb, rtl_dump_bb_for_graph, @@ -5429,6 +5430,7 @@ struct cfg_hooks rtl_cfg_hooks = { struct cfg_hooks cfg_layout_rtl_cfg_hooks = { "cfglayout mode", + IR_RTL_CFGLAYOUT, rtl_verify_flow_info_1, rtl_dump_bb, rtl_dump_bb_for_graph, diff --git a/gcc/tree-cfg.cc b/gcc/tree-cfg.cc index 3b95e0a68f13..56a5af865386 100644 --- a/gcc/tree-cfg.cc +++ b/gcc/tree-cfg.cc @@ -9361,6 +9361,7 @@ gimple_account_profile_record (basic_block bb, struct cfg_hooks gimple_cfg_hooks = { "gimple", + IR_GIMPLE, gimple_verify_flow_info, gimple_dump_bb, /* dump_bb */ gimple_dump_bb_for_graph, /* dump_bb_for_graph */
