#include "firm_types.h"
#include "begin.h"
-/**
- * An entry in the control dependence list.
- */
-struct ir_cdep {
- ir_node *node; /**< A node on which the current block is control dependent on. */
- ir_cdep *next; /**< Link to the next one if any. */
-};
-
/** Compute the control dependence graph for a graph. */
FIRM_API void compute_cdep(ir_graph *irg);
/** Free the control dependence info. */
FIRM_API void free_cdep(ir_graph *irg);
+/** Return control dependent block */
+FIRM_API ir_node *get_cdep_node(const ir_cdep *cdep);
+
+/** Get next entry in a list of cdeps */
+FIRM_API ir_cdep *get_cdep_next(const ir_cdep *cdep);
+
/**
* Return a list of all control dependences of a block.
*/
#include "pmap.h"
#include "obst.h"
#include "xmalloc.h"
-#include "cdep.h"
+#include "cdep_t.h"
#include "irprintf.h"
#include "irdump.h"
static cdep_info *cdep_data;
+ir_node *(get_cdep_node)(const ir_cdep *cdep)
+{
+ return _get_cdep_node(cdep);
+}
+
+ir_cdep *(get_cdep_next)(const ir_cdep *cdep)
+{
+ return _get_cdep_next(cdep);
+}
+
+/* Return a list of all control dependences of a block. */
ir_cdep *find_cdep(const ir_node *block)
{
+ assert(is_Block(block));
return (ir_cdep*) pmap_get(cdep_data->cdep_map, block);
}
void exchange_cdep(ir_node *old, const ir_node *nw)
{
ir_cdep *cdep = find_cdep(nw);
+ assert(is_Block(old));
pmap_insert(cdep_data->cdep_map, old, cdep);
}
{
ir_cdep *dep = find_cdep(node);
+ assert(is_Block(dep_on));
if (dep == NULL) {
ir_cdep *newdep = OALLOC(&cdep_data->obst, ir_cdep);
ir_cdep *newdep;
for (;;) {
- if (dep->node == dep_on) return;
+ if (get_cdep_node(dep) == dep_on) return;
if (dep->next == NULL) break;
dep = dep->next;
}
const ir_cdep *dep;
for (dep = find_cdep(dependee); dep != NULL; dep = dep->next) {
- if (dep->node == candidate) return 1;
+ if (get_cdep_node(dep) == candidate) return 1;
}
return 0;
}
{
ir_cdep *cdep = find_cdep(block);
- return cdep != NULL && cdep->next == NULL ? cdep->node : NULL;
+ return cdep != NULL && cdep->next == NULL ? get_cdep_node(cdep) : NULL;
}
int has_multiple_cdep(const ir_node *block)
--- /dev/null
+/*
+ * Copyright (C) 1995-2008 University of Karlsruhe. All right reserved.
+ *
+ * This file is part of libFirm.
+ *
+ * This file may be distributed and/or modified under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * Foundation and appearing in the file LICENSE.GPL included in the
+ * packaging of this file.
+ *
+ * Licensees holding valid libFirm Professional Edition licenses may use
+ * this file in accordance with the libFirm Commercial License.
+ * Agreement provided with the Software.
+ *
+ * This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+ * WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE.
+ */
+
+/**
+ * @file
+ * @brief control dependence analysis
+ * @author Christoph Mallon
+ * @version $Id$
+ */
+#ifndef FIRM_ANA_CDEP_T_H
+#define FIRM_ANA_CDEP_T_H
+
+#include "cdep.h"
+
+/**
+ * An entry in the control dependence list.
+ */
+struct ir_cdep {
+ ir_node *node; /**< A node on which the current block is control dependent on. */
+ ir_cdep *next; /**< Link to the next one if any. */
+};
+
+static inline ir_node *_get_cdep_node(const ir_cdep *cdep)
+{
+ return skip_Id(cdep->node);
+}
+
+static inline ir_cdep *_get_cdep_next(const ir_cdep *cdep)
+{
+ return cdep->next;
+}
+
+#define get_cdep_node(cdep) _get_cdep_node(cdep)
+#define get_cdep_next(cdep) _get_cdep_next(cdep)
+
+#endif
#include "iroptimize.h"
#include "obst.h"
#include "irnode_t.h"
-#include "cdep.h"
+#include "cdep_t.h"
#include "ircons.h"
#include "irgmod.h"
#include "irgopt.h"
ir_cdep* cdep;
pred0 = get_Block_cfgpred_block(block, i);
- for (cdep = find_cdep(pred0); cdep != NULL; cdep = cdep->next) {
- const ir_node* dependency = cdep->node;
+ for (cdep = find_cdep(pred0); cdep != NULL; cdep = get_cdep_next(cdep)) {
+ const ir_node* dependency = get_cdep_node(cdep);
ir_node* projx0 = walk_to_projx(pred0, dependency);
ir_node* cond;
int j;