/*
- * 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.
+ * Copyright (C) 2012 University of Karlsruhe.
*/
/**
}
}
-typedef struct cdep_env {
- ir_node *start_block;
- ir_node *end_block;
-} cdep_env;
-
/**
* Pre-block-walker: calculate the control dependence
*/
static void cdep_pre(ir_node *node, void *ctx)
{
- cdep_env *env = (cdep_env*) ctx;
- int i;
-
- /* special case:
- * start and end block have no control dependency
- */
- if (node == env->start_block) return;
- if (node == env->end_block) return;
+ (void)ctx;
- for (i = get_Block_n_cfgpreds(node) - 1; i >= 0; --i) {
+ for (int i = get_Block_n_cfgpreds(node); i-- != 0;) {
ir_node *pred = get_Block_cfgpred_block(node, i);
ir_node *pdom;
ir_node *dependee;
void compute_cdep(ir_graph *irg)
{
- ir_node *rem;
- cdep_env env;
-
free_cdep(irg);
cdep_data = XMALLOC(cdep_info);
obstack_init(&cdep_data->obst);
the ipdom of the startblock is the end block.
Firm does NOT add the phantom edge from Start to End.
*/
- env.start_block = get_irg_start_block(irg);
- env.end_block = get_irg_end_block(irg);
-
- rem = get_Block_ipostdom(env.start_block);
- set_Block_ipostdom(env.start_block, env.end_block);
+ ir_node *const start_block = get_irg_start_block(irg);
+ ir_node *const end_block = get_irg_end_block(irg);
+ ir_node *const rem = get_Block_ipostdom(start_block);
+ set_Block_ipostdom(start_block, end_block);
- irg_block_walk_graph(irg, cdep_pre, NULL, &env);
+ irg_block_walk_graph(irg, cdep_pre, NULL, NULL);
(void) cdep_edge_hook;
/* restore the post dominator relation */
- set_Block_ipostdom(env.start_block, rem);
+ set_Block_ipostdom(start_block, rem);
}
void free_cdep(ir_graph *irg)