GCC Middle and Back End API Reference
graphds.c File Reference
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "obstack.h"
#include "bitmap.h"
#include "vec.h"
#include "graphds.h"
Include dependency graph for graphds.c:

Functions

void dump_graph ()
struct graphnew_graph ()
struct graph_edgeadd_edge ()
void identify_vertices ()
static int dfs_edge_src ()
static int dfs_edge_dest ()
static struct graph_edgefoll_in_subgraph ()
static struct graph_edgedfs_fst_edge ()
static struct graph_edgedfs_next_edge ()
int graphds_dfs (struct graph *g, int *qs, int nq, vec< int > *qt, bool forward, bitmap subgraph)
int graphds_scc ()
void for_each_edge ()
void free_graph ()
static int tree_nca ()
void graphds_domtree (struct graph *g, int entry, int *parent, int *son, int *brother)

Function Documentation

struct graph_edge* add_edge ( )
read

Adds an edge from F to T to graph G. The new edge is returned.

Referenced by add_edge(), and create_rdg_edges_for_scalar().

static int dfs_edge_dest ( )
inlinestatic

Helper function for graphds_dfs. Returns the destination vertex of E, in the direction given by FORWARD.

Referenced by foll_in_subgraph().

static int dfs_edge_src ( )
inlinestatic

Helper function for graphds_dfs. Returns the source vertex of E, in the direction given by FORWARD.

References graph_edge::dest, and graph_edge::src.

static struct graph_edge* dfs_fst_edge ( )
staticread

Helper function for graphds_dfs. Select the first edge from V in G, in the direction given by FORWARD, that belongs to SUBGRAPH.

References foll_in_subgraph(), graph_edge::pred_next, and graph_edge::succ_next.

static struct graph_edge* dfs_next_edge ( )
staticread

Helper function for graphds_dfs. Returns the next edge after E, in the graph direction given by FORWARD, that belongs to SUBGRAPH.

References comp, graph::n_vertices, stack, and tick.

void dump_graph ( )

Graph representation and manipulation functions. Copyright (C) 2007-2013 Free Software Foundation, Inc.

This file is part of GCC.

GCC is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 3, or (at your option) any later version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with GCC; see the file COPYING3. If not see http://www.gnu.org/licenses/. Dumps graph G into F.

References vertex::component, graph_edge::dest, vertex::pred, graph_edge::pred_next, graph_edge::src, vertex::succ, graph_edge::succ_next, and graph::vertices.

static struct graph_edge* foll_in_subgraph ( )
staticread

Helper function for graphds_dfs. Returns the first edge after E (including E), in the graph direction given by FORWARD, that belongs to SUBGRAPH.

References bitmap_bit_p, dfs_edge_dest(), graph_edge::pred_next, and graph_edge::succ_next.

Referenced by dfs_fst_edge().

void for_each_edge ( )

Runs CALLBACK for all edges in G.

References NULL, and graph::ob.

void free_graph ( )

Releases the memory occupied by G.

Referenced by stmts_from_loop().

int graphds_dfs ( struct graph g,
int *  qs,
int  nq,
vec< int > *  qt,
bool  forward,
bitmap  subgraph 
)

Runs dfs search over vertices of G, from NQ vertices in queue QS. The vertices in postorder are stored into QT. If FORWARD is false, backward dfs is run. If SUBGRAPH is not NULL, it specifies the subgraph of G to run DFS on. Returns the number of the components of the graph (number of the restarts of DFS).

References vertex::component, vertex::post, and graph::vertices.

void graphds_domtree ( struct graph g,
int  entry,
int *  parent,
int *  son,
int *  brother 
)

Determines the dominance tree of G (stored in the PARENT, SON and BROTHER arrays), where the entry node is ENTRY.

We use a slight modification of the standard iterative algorithm, as described in

K. D. Cooper, T. J. Harvey and K. Kennedy: A Simple, Fast Dominance Algorithm

sort vertices in reverse postorder foreach v dom(v) = everything dom(entry) = entry;

while (anything changes) foreach v dom(v) = {v} union (intersection of dom(p) over all predecessors of v)

The sets dom(v) are represented by the parent links in the current version of the dominance tree.

int graphds_scc ( )

Determines the strongly connected components of G, using the algorithm of Tarjan – first determine the postorder dfs numbering in reversed graph, then run the dfs on the original graph in the order given by decreasing numbers assigned by the previous pass. If SUBGRAPH is not NULL, it specifies the subgraph of G whose strongly connected components we want to determine.

After running this function, v->component is the number of the strongly connected component for each vertex of G. Returns the number of the sccs of G.

void identify_vertices ( )

Moves all the edges incident with U to V.

References graph_edge::src, vertex::succ, and graph_edge::succ_next.

Referenced by prune_bbs_to_update_dominators().

struct graph* new_graph ( )
read

Creates a new graph with N_VERTICES vertices.

static int tree_nca ( )
static

Returns the nearest common ancestor of X and Y in tree whose parent links are given by PARENT. MARKS is the array used to mark the vertices of the tree, and MARK is the number currently used as a mark.

We climb with X and Y up the tree, marking the visited nodes. When we first arrive to a marked node, it is the common ancestor.

 If we reached the root with one of the vertices, continue
 with the other one till we reach the marked part of the
 tree.