GCC Middle and Back End API Reference
graphds.h
Go to the documentation of this file.
1/* Graph representation.
2 Copyright (C) 2007-2024 Free Software Foundation, Inc.
3
4This file is part of GCC.
5
6GCC is free software; you can redistribute it and/or modify it under
7the terms of the GNU General Public License as published by the Free
8Software Foundation; either version 3, or (at your option) any later
9version.
10
11GCC is distributed in the hope that it will be useful, but WITHOUT ANY
12WARRANTY; without even the implied warranty of MERCHANTABILITY or
13FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14for more details.
15
16You should have received a copy of the GNU General Public License
17along with GCC; see the file COPYING3. If not see
18<http://www.gnu.org/licenses/>. */
19
20#ifndef GCC_GRAPHDS_H
21#define GCC_GRAPHDS_H
22
23/* Structure representing edge of a graph. */
24
26{
27 int src, dest; /* Source and destination. */
29 /* Next edge in predecessor and successor lists. */
30 void *data; /* Data attached to the edge. */
31};
32
33/* Structure representing vertex of a graph. */
34
35struct vertex
36{
37 struct graph_edge *pred, *succ;
38 /* Lists of predecessors and successors. */
39 int component; /* Number of dfs restarts before reaching the
40 vertex. */
41 int post; /* Postorder number. */
42 void *data; /* Data attached to the vertex. */
43};
44
45/* Structure representing a graph. */
46
47struct graph
48{
49 int n_vertices; /* Number of vertices. */
50 struct vertex *vertices; /* The vertices. */
51 struct obstack ob; /* Obstack for vertex and edge allocation. */
52};
53
54struct graph *new_graph (int);
55void dump_graph (FILE *, struct graph *);
56struct graph_edge *add_edge (struct graph *, int, int);
57void identify_vertices (struct graph *, int, int);
58typedef bool (*skip_edge_callback) (struct graph_edge *);
59int graphds_dfs (struct graph *, int *, int,
62 vec<int> * = NULL);
63void graphds_domtree (struct graph *, int, int *, int *, int *);
64typedef void (*graphds_edge_callback) (struct graph *,
65 struct graph_edge *, void *);
66void for_each_edge (struct graph *, graphds_edge_callback, void *);
67void free_graph (struct graph *g);
68
69#endif /* GCC_GRAPHDS_H */
gcc::context * g
Definition context.cc:29
class bitmap_head * bitmap
Definition coretypes.h:51
static struct obstack obstack
Definition gcc.cc:357
T * ggc_alloc(ALONE_CXX_MEM_STAT_INFO)
Definition ggc.h:184
void free_graph(struct graph *g)
Definition graphds.cc:351
struct graph_edge * add_edge(struct graph *, int, int)
Definition graphds.cc:70
int graphds_scc(struct graph *, bitmap, skip_edge_callback=NULL, vec< int > *=NULL)
Definition graphds.cc:298
void graphds_domtree(struct graph *, int, int *, int *, int *)
Definition graphds.cc:412
int graphds_dfs(struct graph *, int *, int, vec< int > *, bool, bitmap, skip_edge_callback=NULL)
Definition graphds.cc:204
bool(* skip_edge_callback)(struct graph_edge *)
Definition graphds.h:58
void identify_vertices(struct graph *, int, int)
Definition graphds.cc:91
struct graph * new_graph(int)
Definition graphds.cc:55
void for_each_edge(struct graph *, graphds_edge_callback, void *)
Definition graphds.cc:338
void(* graphds_edge_callback)(struct graph *, struct graph_edge *, void *)
Definition graphds.h:64
void dump_graph(FILE *, struct graph *)
Definition graphds.cc:29
Definition graphds.h:26
void * data
Definition graphds.h:30
struct graph_edge * succ_next
Definition graphds.h:28
int src
Definition graphds.h:27
int dest
Definition graphds.h:27
struct graph_edge * pred_next
Definition graphds.h:28
Definition graphds.h:48
int n_vertices
Definition graphds.h:49
struct vertex * vertices
Definition graphds.h:50
struct obstack ob
Definition graphds.h:51
Definition vec.h:450
Definition graphds.h:36
int post
Definition graphds.h:41
int component
Definition graphds.h:39
struct graph_edge * pred
Definition graphds.h:37
struct graph_edge * succ
Definition graphds.h:37
void * data
Definition graphds.h:42
#define NULL
Definition system.h:50
#define bool
Definition system.h:893