GCC Middle and Back End API Reference
supergraph-manipulation.h
Go to the documentation of this file.
1/* Classes for manipulating the supergraph.
2 Copyright (C) 2025 Free Software Foundation, Inc.
3 Contributed by David Malcolm <dmalcolm@redhat.com>.
4
5This file is part of GCC.
6
7GCC is free software; you can redistribute it and/or modify it
8under the terms of the GNU General Public License as published by
9the Free Software Foundation; either version 3, or (at your option)
10any later version.
11
12GCC is distributed in the hope that it will be useful, but
13WITHOUT ANY WARRANTY; without even the implied warranty of
14MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15General Public License for more details.
16
17You should have received a copy of the GNU General Public License
18along with GCC; see the file COPYING3. If not see
19<http://www.gnu.org/licenses/>. */
20
21#ifndef GCC_ANALYZER_SUPERGRAPH_MANIPULATION_H
22#define GCC_ANALYZER_SUPERGRAPH_MANIPULATION_H
23
24#if ENABLE_ANALYZER
25
26namespace ana {
27namespace supergraph_manipulation {
28
29class worklist
30{
31public:
32 worklist ()
33 : m_indices ()
34 {
35 bitmap_clear (m_indices);
36 }
37
38 void ensure_node_queued (supernode *node, ana::logger *logger)
39 {
40 if (bitmap_bit_p (m_indices, node->m_id))
41 return; // already in queue
42 if (logger)
43 logger->log ("queued SN: %i", node->m_id);
44 m_queue.push_back (node);
45 bitmap_set_bit (m_indices, node->m_id);
46 }
47
48 supernode *pop ()
49 {
50 if (m_queue.empty ())
51 return nullptr;
52 supernode *node = m_queue.front ();
53 m_queue.pop_front ();
54 bitmap_clear_bit (m_indices, node->m_id);
55 return node;
56 }
57
58private:
59 // The queue
60 std::deque<supernode *> m_queue;
61
62 /* Indices of all nodes in the queue, so
63 we can lazily add them in constant time. */
64 auto_bitmap m_indices;
65};
66
67
68} // namespace ana::supergraph_manipulation
69} // namespace ana
70
71#endif /* #if ENABLE_ANALYZER */
72
73#endif /* GCC_ANALYZER_SUPERGRAPH_MANIPULATION_H */
bool bitmap_clear_bit(bitmap head, int bit)
Definition bitmap.cc:919
void bitmap_clear(bitmap head)
Definition bitmap.cc:713
void log(const char *fmt,...) ATTRIBUTE_GCC_DIAG(2
static vec< rtx_insn * > worklist
Definition dce.cc:54
#define bitmap_bit_p(bitstring, bitno)
Definition genautomata.cc:3429
#define bitmap_set_bit(bitstring, bitno)
Definition genautomata.cc:3419
Definition access-diagram.h:30
@ pop
Definition kinds.h:34