diff options
author | Richard Biener <rguenther@suse.de> | 2018-08-24 11:17:16 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2018-08-24 11:17:16 +0000 |
commit | e144a2b3066ecad2a7c934b1cd437d2afad0018f (patch) | |
tree | 1bf53ff1e85aa724075fc8e89e510ebad078c63e /gcc/cfg.h | |
parent | 6a84c265a32e6f407cf6712040df65527ffcf445 (diff) | |
download | gcc-e144a2b3066ecad2a7c934b1cd437d2afad0018f.zip gcc-e144a2b3066ecad2a7c934b1cd437d2afad0018f.tar.gz gcc-e144a2b3066ecad2a7c934b1cd437d2afad0018f.tar.bz2 |
cfg.h (struct control_flow_graph): Add edge_flags_allocated and bb_flags_allocated members.
2018-08-24 Richard Biener <rguenther@suse.de>
* cfg.h (struct control_flow_graph): Add edge_flags_allocated and
bb_flags_allocated members.
(auto_flag): New RAII class for allocating flags.
(auto_edge_flag): New RAII class for allocating edge flags.
(auto_bb_flag): New RAII class for allocating bb flags.
* cfgloop.c (verify_loop_structure): Allocate temporary edge
flag dynamically.
* cfganal.c (dfs_enumerate_from): Remove use of visited sbitmap
in favor of temporarily allocated BB flag.
* hsa-brig.c: Re-order includes.
* hsa-dump.c: Likewise.
* hsa-regalloc.c: Likewise.
* print-rtl.c: Likewise.
* profile-count.c: Likewise.
From-SVN: r263830
Diffstat (limited to 'gcc/cfg.h')
-rw-r--r-- | gcc/cfg.h | 60 |
1 files changed, 60 insertions, 0 deletions
@@ -74,6 +74,10 @@ struct GTY(()) control_flow_graph { /* Maximal count of BB in function. */ profile_count count_max; + + /* Dynamically allocated edge/bb flags. */ + int edge_flags_allocated; + int bb_flags_allocated; }; @@ -121,4 +125,60 @@ extern basic_block get_bb_copy (basic_block); void set_loop_copy (struct loop *, struct loop *); struct loop *get_loop_copy (struct loop *); +/* Generic RAII class to allocate a bit from storage of integer type T. + The allocated bit is accessible as mask with the single bit set + via the conversion operator to T. */ + +template <class T> +class auto_flag +{ +public: + /* static assert T is integer type of max HOST_WIDE_INT precision. */ + auto_flag (T *sptr) + { + m_sptr = sptr; + int free_bit = ffs_hwi (~*sptr); + /* If there are no unset bits... */ + if (free_bit == 0) + gcc_unreachable (); + m_flag = HOST_WIDE_INT_1U << (free_bit - 1); + /* ...or if T is signed and thus the complement is sign-extended, + check if we ran out of bits. We could spare us this bit + if we could use C++11 std::make_unsigned<T>::type to pass + ~*sptr to ffs_hwi. */ + if (m_flag == 0) + gcc_unreachable (); + gcc_checking_assert ((*sptr & m_flag) == 0); + *sptr |= m_flag; + } + ~auto_flag () + { + gcc_checking_assert ((*m_sptr & m_flag) == m_flag); + *m_sptr &= ~m_flag; + } + operator T () const { return m_flag; } +private: + T *m_sptr; + T m_flag; +}; + +/* RAII class to allocate an edge flag for temporary use. You have + to clear the flag from all edges when you are finished using it. */ + +class auto_edge_flag : public auto_flag<int> +{ +public: + auto_edge_flag (function *fun) + : auto_flag (&fun->cfg->edge_flags_allocated) {} +}; + +/* RAII class to allocate a bb flag for temporary use. You have + to clear the flag from all edges when you are finished using it. */ +class auto_bb_flag : public auto_flag<int> +{ +public: + auto_bb_flag (function *fun) + : auto_flag (&fun->cfg->bb_flags_allocated) {} +}; + #endif /* GCC_CFG_H */ |