irdump.h \
iredgekinds.h \
iredges.h \
- irextbb.h \
irflag.h \
irgmod.h \
irgopt.h \
#include "irdump.h"
#include "iredgekinds.h"
#include "iredges.h"
-#include "irextbb.h"
#include "irflag.h"
#include "irgmod.h"
#include "irgopt.h"
k_tarval, /**< A tarval. */
k_ir_loop, /**< A loop. */
k_ir_compound_graph_path, /**< A compound graph path, see entity.h. */
- k_ir_extblk, /**< An extended basic block. */
k_ir_prog, /**< A program representation (irp). */
k_ir_graph_pass, /**< An ir_graph pass. */
k_ir_prog_pass, /**< An ir_prog pass. */
/** @ingroup ir_entity
* Entity */
typedef struct ir_entity ir_entity;
-/** Extended Basic Block */
-typedef struct ir_extblk ir_extblk;
/** @ingroup execfreq
* Execution Frequency Analysis Results */
typedef struct ir_exec_freq ir_exec_freq;
FIRMSTAT_COUNT_DELETED = 0x00000010, /**< if set, count deleted graphs */
FIRMSTAT_COUNT_SELS = 0x00000020, /**< if set, count Sel(Sel(..)) differently */
FIRMSTAT_COUNT_CONSTS = 0x00000040, /**< if set, count Const statistics */
- FIRMSTAT_COUNT_EXTBB = 0x00000080, /**< if set, count extended Basic Block statistics */
FIRMSTAT_CSV_OUTPUT = 0x10000000 /**< CSV output of some mini-statistic */
};
typedef enum {
/** dump basic blocks as subgraphs which contain the nodes in the block */
ir_dump_flag_blocks_as_subgraphs = 1U << 0,
- /** display blocks in extended basic grouped inside a subgraph */
- ir_dump_flag_group_extbb = 1U << 1,
/** dump (parts of) typegraph along with nodes */
ir_dump_flag_with_typegraph = 1U << 2,
/** Sets the vcg flag "display_edge_labels" to no.
+++ /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 Extended basis block support.
- * @author Michael Beck
- * @date 5.2005
- */
-#ifndef FIRM_ANA_IREXTBB_H
-#define FIRM_ANA_IREXTBB_H
-
-#include "firm_types.h"
-#include "execfreq.h"
-#include "begin.h"
-
-/* type of callback function for ir_graph walk */
-#ifndef _EXTBB_WALK_FUNC_TYPEDEF_
-#define _EXTBB_WALK_FUNC_TYPEDEF_
-/**
- * The type of a walk function. Does not use the link field.
- *
- * @param blk - the extended basic block that is just visited
- * @param env - an environment pointer passed by the walk functions
- */
-typedef void extbb_walk_func(ir_extblk *blk, void *env);
-#endif
-
-/**
- * Checks whether a pointer points to a extended basic block.
- * Intern version for libFirm.
- */
-FIRM_API int is_ir_extbb(const void *thing);
-
-/**
- * Compute the extended basic blocks for a graph.
- */
-FIRM_API void compute_extbb(ir_graph *irg);
-
-/**
- * Compute the extended basic blocks for a graph based on execution frequencies.
- */
-FIRM_API void compute_extbb_execfreqs(ir_graph *irg, ir_exec_freq *execfreqs);
-
-/**
- * free all extended block info.
- */
-FIRM_API void free_extbb(ir_graph *irg);
-
-/**
- * Returns the extended block of a node.
- *
- * @param node the node
- */
-FIRM_API ir_extblk *get_nodes_extbb(const ir_node *node);
-
-/**
- * Returns the visited counter of an extended block.
- *
- * @param blk the extended basic block
- */
-FIRM_API ir_visited_t get_extbb_visited(const ir_extblk *blk);
-
-/**
- * Sets the visited counter of an extended block.
- *
- * @param blk the extended basic block
- * @param visited new value for the visited counter
- */
-FIRM_API void set_extbb_visited(ir_extblk *blk, ir_visited_t visited);
-
-/**
- * Mark an extended block as visited in a graph.
- * Uses the block visit flag.
- *
- * @param blk the extended basic block
- */
-FIRM_API void mark_extbb_visited(ir_extblk *blk);
-
-/**
- * Returns non-zero if an extended was visited.
- * Uses the block visit flag.
- *
- * @param blk the extended basic block
- */
-FIRM_API int extbb_visited(const ir_extblk *blk);
-
-/**
- * Returns non-zero if an extended block was NOT visited.
- * Uses the block visit flag.
- *
- * @param blk the extended basic block
- */
-FIRM_API int extbb_not_visited(const ir_extblk *blk);
-
-/**
- * Returns the link field of an extended block.
- *
- * @param blk the extended basic block
- */
-FIRM_API void *get_extbb_link(const ir_extblk *blk);
-
-/**
- * Sets the link field of an extended block.
- *
- * @param blk the extended basic block
- * @param link the new link value
- */
-FIRM_API void set_extbb_link(ir_extblk *blk, void *link);
-
-/**
- * Returns the number of basic blocks of an extended block.
- *
- * @param blk the extended basic block
- */
-FIRM_API int get_extbb_n_blocks(const ir_extblk *blk);
-
-/**
- * Returns the i'th basic block of an extended block.
- *
- * @param blk the extended basic block
- * @param pos the position
- */
-FIRM_API ir_node *get_extbb_block(const ir_extblk *blk, int pos);
-
-/**
- * Returns the leader basic block of an extended block.
- *
- * @param blk the extended basic block
- */
-FIRM_API ir_node *get_extbb_leader(const ir_extblk *blk);
-
-/**
- * Returns the node number of an extended block.
- * Its the block number of the leader block
- *
- * @param blk the extended basic block
- */
-FIRM_API long get_extbb_node_nr(const ir_extblk *blk);
-
-/**
- * Walks only over Extended Basic Block nodes in the graph.
- *
- * @param blk - the start extended block node
- * @param pre - walker function, executed before the predecessor of a node are
- * visited
- * @param post - walker function, executed after the predecessor of a node are
- * visited
- * @param env - environment, passed to pre and post
- *
- * This function Walks only over Block nodes in the graph. Has its own visited
- * flag, so that it can be interleaved with the other walker.
- * If a none block is passed, starts at the block this node belongs to.
- * If end is passed also visits kept alive blocks. Does not use the link field.
- */
-FIRM_API void irg_extblock_walk(ir_extblk *blk, extbb_walk_func *pre,
- extbb_walk_func *post, void *env);
-
-/**
- * Walks only over reachable Extended Basic Block nodes in the graph.
- * Ensures, that the extended block containing the End node is visited last
- * and the block containing Start visited first (in post order).
- *
- * @param irg - the irg graph
- * @param pre - walker function, executed before the predecessor of a block
- * are visited
- * @param post - walker function, executed after the predecessor of a block
- * are visited
- * @param env - environment, passed to pre and post
- */
-FIRM_API void irg_extblock_walk_graph(ir_graph *irg, extbb_walk_func *pre,
- extbb_walk_func *post, void *env);
-
-#include "end.h"
-
-#endif
IR_GRAPH_STATE_CONSISTENT_LOOPINFO = 1U << 13,
/** entity usage information is computed and up to date */
IR_GRAPH_STATE_CONSISTENT_ENTITY_USAGE = 1U << 14,
- /** extended basic blocks have been formed and are up to date */
- IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS = 1U << 15,
/** graph contains as many returns as possible */
- IR_GRAPH_STATE_MANY_RETURNS = 1U << 16,
+ IR_GRAPH_STATE_MANY_RETURNS = 1U << 15,
} ir_graph_state_t;
ENUM_BITSET(ir_graph_state_t)
* @param pred a predecessor block of block
*
* @return the position of pred in block or -1
- *
- * @note When using the old extended basic block form for blocks
- * with exception exists, a predecessor block might have more
- * than one position. In that case it is not specified, with is returned.
*/
FIRM_API int get_Block_cfgpred_pos(const ir_node *block, const ir_node *pred);
/** Returns 1 if a block is marked as visited */
FIRM_API int Block_block_visited(const ir_node *node);
-/** Returns the extended basic block a block belongs to. */
-FIRM_API ir_extblk *get_Block_extbb(const ir_node *block);
-/** Sets the extended basic block a block belongs to. */
-FIRM_API void set_Block_extbb(ir_node *block, ir_extblk *extblk);
/** Returns the ir_graph this Block belongs to. */
FIRM_API ir_graph *get_Block_irg(const ir_node *block);
/** Returns the entity for a Block (creating it if necessary) */
ana/ircfscc.c \
ana/irconsconfirm.c \
ana/irdom.c \
- ana/irextbb2.c \
- ana/irextbb.c \
ana/irlivechk.c \
ana/irloop.c \
ana/irmemory.c \
ana/dfs_t.h \
ana/irbackedge_t.h \
ana/irdom_t.h \
- ana/irextbb_t.h \
ana/irlivechk.h \
ana/irloop_t.h \
ana/irmemory_t.h \
+++ /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 Extended basis block support.
- * @author Michael Beck
- * @date 5.2005
- */
-#include "config.h"
-
-#include "irextbb_t.h"
-#include "irgwalk.h"
-#include "irnode_t.h"
-#include "irgraph_t.h"
-#include "iredges_t.h"
-#include "irouts.h"
-#include "xmalloc.h"
-#include "irprintf.h"
-
-/**
- * Environment for extbb construction.
- */
-typedef struct env {
- struct obstack *obst; /**< the obstack where allocations took place */
- ir_extblk *head; /**< head of the list of all extended blocks */
- ir_node *start_block; /**< the start block of the current graph */
-} env_t;
-
-int (is_ir_extbb)(const void *thing)
-{
- return _is_ir_extbb(thing);
-}
-
-/**
- * allocate a new extended block header.
- */
-static void allocate_extblk(ir_node *block, env_t *env)
-{
- ir_extblk *extblk = OALLOC(env->obst, ir_extblk);
-
- extblk->kind = k_ir_extblk;
- extblk->visited = 1;
- extblk->blks = (ir_node **)env->head;
- extblk->link = block;
- env->head = extblk;
-
- set_Block_extbb(block, extblk);
- set_irn_link(block, NULL);
-}
-
-/**
- * Returns the number of block successors.
- * we are interested only in 1, 2 and >2.
- */
-static int get_block_n_succs(ir_node *block)
-{
- if (edges_activated(current_ir_graph)) {
- const ir_edge_t *edge;
-
- edge = get_block_succ_first(block);
- if (! edge)
- return 0;
- edge = get_block_succ_next(block, edge);
- if (! edge)
- return 1;
- edge = get_block_succ_next(block, edge);
- return edge ? 3 : 2;
- }
- return get_Block_n_cfg_outs(block);
-}
-
-/**
- * Pre block-walker. Calculates the extended block info.
- */
-static void pre_walk_calc_extbb(ir_node *block, void *ctx)
-{
- int n = get_Block_n_cfgpreds(block);
- env_t *env = (env_t*) ctx;
-
- if (n <= 0 || n > 1 || block == env->start_block) {
- /*
- * block is a JOIN-node ie the control flow from
- * many other blocks joins here. block is a leader.
- * Note that we handle unreachable blocks (n <= 0) here too.
- */
- allocate_extblk(block, env);
- }
- else { /* we have only one control flow predecessor */
- ir_node *add_to = get_Block_cfgpred_block(block, 0);
-
- /* blocks with only one BAD predecessors are leaders too */
- if (is_Bad(add_to)) {
- allocate_extblk(block, env);
- } else {
- /*
- * Only one control flow predecessor. This block belongs
- * to the same extended basic block as its predecessor.
- */
- ir_node *cf_op = skip_Proj(get_Block_cfgpred(block, 0));
-
- if (!irn_visited_else_mark(cf_op)) {
- ir_node *pred_bl = get_nodes_block(cf_op);
- if (get_block_n_succs(pred_bl) > 2) {
- /* More than two successors means we have a jump table.
- * we cannot include a jump target into the current extended
- * basic block, so create a new one here.
- */
- allocate_extblk(block, env);
- } else {
- /* either the previous block has only one successor or
- * this is the first successor after an if, include it.
- */
- set_Block_extbb(block, NULL);
- }
- } else {
- /* already marked, so begin a new extended block here */
- allocate_extblk(block, env);
- }
- }
- }
-}
-
-/** A special extended block used as sentinel */
-static ir_extblk _sentinel = { k_ir_extblk, 0xFEA1DEAD, NULL, NULL };
-
-/**
- * Post block-walker. Calculates the extended block info.
- * During construction, we use the (free) block input of all basic blocks
- * to point to their previous block.
- */
-static void post_walk_calc_extbb(ir_node *block, void *ctx)
-{
- ir_extblk *extbb = get_Block_extbb(block);
- env_t *env = (env_t*) ctx;
- ir_extblk *sentinel = &_sentinel;
-
- if (! extbb) {
- ir_node *curr, *prev, *list;
-
- /*
- * Search the leader. It can happen, that we fall into an endless
- * loop, because we enter an unreachable loop that is not yet detected.
- * We break the loop using a sentinel.
- */
- for (curr = block; !extbb; curr = prev) {
- prev = get_Block_cfgpred_block(curr, 0);
- extbb = get_Block_extbb(prev);
- set_Block_extbb(curr, sentinel);
- }
-
- if (extbb == sentinel) {
- /* We detect a dead loop. We fix this by allocating a
- * special Extended block
- */
- ir_printf("Dead loop detected starting with %+F::%+F\n", get_irg_entity(current_ir_graph), block);
-
- allocate_extblk(block, env);
- extbb = get_Block_extbb(block);
- set_Block_extbb(block, sentinel);
- }
-
- /* replace all sentinels by the extbb info */
- prev = block;
- list = NULL;
- for (;;) {
- if (get_Block_extbb(prev) != sentinel)
- break;
- set_irn_link(prev, list);
- list = prev;
- prev = get_Block_cfgpred_block(prev, 0);
- }
- /* arg, the list is in wrong order, turn around and add to the extbb list */
- for (curr = list; curr; curr = prev) {
- prev = (ir_node*) get_irn_link(curr);
- set_irn_link(curr, extbb->link);
- extbb->link = curr;
- set_Block_extbb(curr, extbb);
- ++extbb->visited;
- }
- }
-}
-
-void compute_extbb(ir_graph *irg)
-{
- env_t env;
- ir_extblk *extbb, *next;
-
- if (irg->extbb_obst)
- obstack_free(irg->extbb_obst, NULL);
- else
- irg->extbb_obst = XMALLOC(struct obstack);
- obstack_init(irg->extbb_obst);
-
- env.obst = irg->extbb_obst;
- env.head = NULL;
- env.start_block = get_irg_start_block(irg);
-
- if (! edges_activated(irg)) {
- /* we don't have edges */
- assure_irg_outs(irg);
- }
-
- /* we must mark nodes, so increase the visited flag */
- inc_irg_visited(irg);
- irg_block_walk_graph(irg, pre_walk_calc_extbb, post_walk_calc_extbb, &env);
-
- /*
- * Ok, we have now the list of all extended blocks starting with env.head
- * every extended block "knowns" the number of blocks in visited and
- * the blocks are linked in link.
- * Now we can create arrays that hold the blocks, some kind of "out" edges
- * for the extended block
- */
- for (extbb = env.head; extbb; extbb = next) {
- int i, len = (int)extbb->visited;
- ir_node *block;
-
- next = (ir_extblk *)extbb->blks;
-
- extbb->blks = NEW_ARR_D(ir_node *, env.obst, len);
-
- for (block = (ir_node*) extbb->link, i = 0; i < len; ++i) {
- ir_node *nblock = (ir_node*) get_irn_link(block);
-
- /* ensure that the leader is the first one */
- extbb->blks[len - 1 - i] = block;
- set_irn_link(block, NULL);
- block = nblock;
- }
-
-#ifndef NDEBUG
- /* check it */
- for (i = len - 1; i > 0; --i) {
- ir_node *blk = extbb->blks[i];
-
- if (get_Block_n_cfgpreds(blk) != 1) {
- assert(!"Block for more than one predecessors is no leader");
- } else if (get_Block_cfgpred_block(blk, 0) != extbb->blks[i - 1]) {
- assert(!"extbb block order wrong");
- }
- }
-#endif
-
- extbb->link = NULL;
- extbb->visited = 0;
- }
-
- set_irg_state(irg, IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
-}
-
-void free_extbb(ir_graph *irg)
-{
- if (irg->extbb_obst) {
- obstack_free(irg->extbb_obst, NULL);
- xfree(irg->extbb_obst);
- irg->extbb_obst = NULL;
- }
- clear_irg_state(irg, IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
-}
-
-ir_extblk *get_nodes_extbb(const ir_node *node)
-{
- const ir_node *block = is_Block(node) ? node : get_nodes_block(node);
- return get_Block_extbb(block);
-}
-
-ir_visited_t (get_extbb_visited)(const ir_extblk *blk)
-{
- return _get_extbb_visited(blk);
-}
-
-void (set_extbb_visited)(ir_extblk *blk, ir_visited_t visited)
-{
- _set_extbb_visited(blk, visited);
-}
-
-void (mark_extbb_visited)(ir_extblk *blk)
-{
- _mark_extbb_visited(blk);
-}
-
-int (extbb_visited)(const ir_extblk *blk)
-{
- return _extbb_visited(blk);
-}
-
-int (extbb_not_visited)(const ir_extblk *blk)
-{
- return _extbb_not_visited(blk);
-}
-
-void *(get_extbb_link)(const ir_extblk *blk)
-{
- return _get_extbb_link(blk);
-}
-
-void (set_extbb_link)(ir_extblk *blk, void *link)
-{
- _set_extbb_link(blk, link);
-}
-
-int (get_extbb_n_blocks)(const ir_extblk *blk)
-{
- return _get_extbb_n_blocks(blk);
-}
-
-ir_node *(get_extbb_block)(const ir_extblk *blk, int pos)
-{
- return _get_extbb_block(blk, pos);
-}
-
-ir_node *(get_extbb_leader)(const ir_extblk *blk)
-{
- return _get_extbb_leader(blk);
-}
-
-long get_extbb_node_nr(const ir_extblk *blk)
-{
- return get_irn_node_nr(get_extbb_leader(blk));
-}
-
-static void irg_extblock_walk_2(ir_extblk *blk, extbb_walk_func *pre, extbb_walk_func *post, void *env)
-{
- int i;
- ir_node *node;
-
- if (extbb_not_visited(blk)) {
- mark_extbb_visited(blk);
-
- if (pre) pre(blk, env);
-
- node = get_extbb_leader(blk);
- for (i = get_Block_n_cfgpreds(node) - 1; i >= 0; --i) {
- /* find the corresponding predecessor block. */
- ir_node *pred = get_Block_cfgpred_block(node, i);
- if (is_Block(pred)) {
- /* recursion */
- irg_extblock_walk_2(get_Block_extbb(pred), pre, post, env);
- }
- else {
- assert(is_Bad(pred));
- }
- }
-
- if (post) post(blk, env);
- }
-}
-
-void irg_extblock_walk(ir_extblk *blk, extbb_walk_func *pre, extbb_walk_func *post, void *env)
-{
- ir_node *pred, *start_bl = get_irg_start_block(current_ir_graph);
- ir_extblk *start_blk = get_Block_extbb(start_bl);
- int i;
-
- assert(blk);
- inc_irg_block_visited(current_ir_graph);
-
- /* assure the start block is the first one */
- mark_extbb_visited(start_blk);
- if (post)
- post(start_blk, env);
- irg_extblock_walk_2(blk, pre, post, env);
-
- /* keepalive: the endless loops ... */
- if (blk == get_Block_extbb(get_irg_end_block(current_ir_graph))) {
- ir_node *node = get_irg_end(current_ir_graph);
- int arity = get_irn_arity(node);
- for (i = 0; i < arity; i++) {
- pred = get_irn_n(node, i);
- if (is_Block(pred))
- irg_extblock_walk_2(get_Block_extbb(pred), pre, post, env);
- else if (is_Phi(pred)) {
- /* Sometimes the blocks died, but are still reachable through Phis.
- * Make sure the algorithms that try to remove these reach them. */
- ir_node *block = get_nodes_block(pred);
-
- if (! is_Bad(block))
- irg_extblock_walk_2(get_Block_extbb(block), pre, post, env);
- }
- }
- }
-
- if (pre)
- pre(start_blk, env);
-}
-
-void irg_extblock_walk_graph(ir_graph *irg, extbb_walk_func *pre, extbb_walk_func *post, void *env)
-{
- ir_node *endbl = get_irg_end_block(irg);
- ir_extblk *blk = get_Block_extbb(endbl);
- ir_graph *rem = current_ir_graph;
- current_ir_graph = irg;
- irg_extblock_walk(blk, pre, post, env);
- current_ir_graph = rem;
-}
+++ /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 Alternative extended basic block computation
- * @author Matthias Braun
- * @date 5.2005
- * @brief
- * Alternative algorithm for computing extended basic blocks (using out edges
- * and execution frequencies)
- */
-#include "config.h"
-
-#include "irextbb_t.h"
-#include "irgwalk.h"
-#include "irnode_t.h"
-#include "irgraph_t.h"
-#include "iredges_t.h"
-#include "irouts.h"
-#include "xmalloc.h"
-#include "irprintf.h"
-#include "execfreq.h"
-
-typedef struct env {
- struct obstack *obst; /**< the obstack where allocations took place */
- ir_extblk *head; /**< head of the list of all extended blocks */
- ir_exec_freq *execfreqs;
-} env_t;
-
-/**
- * allocate a new extended block header.
- */
-static ir_extblk *allocate_extblk(ir_node *block, env_t *env)
-{
- ir_extblk *extblk = OALLOC(env->obst, ir_extblk);
-
- extblk->kind = k_ir_extblk;
- extblk->visited = 1;
- extblk->blks = (ir_node **)env->head;
- extblk->link = block;
- env->head = extblk;
-
- set_Block_extbb(block, extblk);
- set_irn_link(block, NULL);
-
- return extblk;
-}
-
-/**
- * add a block to an extended block
- */
-static void addto_extblk(ir_extblk *extblk, ir_node *block)
-{
- /* link all blocks belonging to this extended block */
- set_irn_link(block, extblk->link);
-
- extblk->link = block;
- extblk->visited++;
-
- set_Block_extbb(block, extblk);
-}
-
-/**
- * Returns the number of block successors.
- * we are interested only in 1, 2 and >2.
- */
-static int get_block_n_succs(ir_node *block)
-{
- if (edges_activated(current_ir_graph)) {
- const ir_edge_t *edge;
-
- edge = get_block_succ_first(block);
- if (! edge)
- return 0;
-
- edge = get_block_succ_next(block, edge);
- if (! edge)
- return 1;
-
- edge = get_block_succ_next(block, edge);
- return edge ? 3 : 2;
- }
-
- return get_Block_n_cfg_outs(block);
-}
-
-static void pick_successor(ir_node *block, ir_extblk *extblk, env_t *env);
-
-static void create_extblk(ir_node *block, env_t *env)
-{
- ir_extblk *extblk;
-
- if (irn_visited_else_mark(block))
- return;
-
- extblk = allocate_extblk(block, env);
-
- pick_successor(block, extblk, env);
-}
-
-static void pick_successor(ir_node *block, ir_extblk *extblk, env_t *env)
-{
- const ir_edge_t *edge;
- ir_node *best_succ = NULL;
- double best_execfreq = -1;
-
- /*
- More than two successors means we have a jump table.
- we cannot include a jump target into the current extended
- basic block, so create a new one here.
- */
- if (get_block_n_succs(block) > 2) {
- foreach_block_succ(block, edge) {
- ir_node *succ = get_edge_src_irn(edge);
- create_extblk(succ, env);
- }
-
- return;
- }
-
- foreach_block_succ(block, edge) {
- ir_node *succ = get_edge_src_irn(edge);
- double execfreq;
-
- if (irn_visited(succ))
- continue;
-
- if (get_Block_n_cfgpreds(succ) > 1) {
- create_extblk(succ, env);
- continue;
- }
-
- execfreq = get_block_execfreq(env->execfreqs, succ);
-
- /*
- Remember best successor and make non best successor with only 1
- pred block to new extbb leaders.
- */
- if (execfreq > best_execfreq) {
- if (best_succ != NULL) {
- create_extblk(best_succ, env);
- }
-
- best_execfreq = execfreq;
- best_succ = succ;
- }
- else {
- create_extblk(succ, env);
- }
- }
-
- /* add best successor and recursively try to pick more */
- if (best_succ != NULL) {
- addto_extblk(extblk, best_succ);
- mark_irn_visited(best_succ);
- pick_successor(best_succ, extblk, env);
- }
-}
-
-void compute_extbb_execfreqs(ir_graph *irg, ir_exec_freq *execfreqs)
-{
- env_t env;
- ir_extblk *extbb, *next;
- ir_node *endblock;
-
- if (irg->extbb_obst) {
- obstack_free(irg->extbb_obst, NULL);
- }
- else {
- irg->extbb_obst = XMALLOC(struct obstack);
- }
- obstack_init(irg->extbb_obst);
-
- env.obst = irg->extbb_obst;
- env.head = NULL;
- env.execfreqs = execfreqs;
-
- assure_irg_outs(irg);
-
- /* we must mark nodes, so increase the visited flag */
- inc_irg_visited(irg);
- create_extblk(get_irg_start_block(irg), &env);
-
- /* the end block needs a extbb assigned (even for endless loops) */
- endblock = get_irg_end_block(irg);
- create_extblk(endblock, &env);
-
- /*
- Ok, we have now the list of all extended blocks starting with env.head
- every extended block "knowns" the number of blocks in visited and
- the blocks are linked in link.
- Now we can create arrays that hold the blocks, some kind of "out" edges
- for the extended block
- */
- for (extbb = env.head; extbb; extbb = next) {
- int i, len = (int)extbb->visited;
- ir_node *block;
-
- next = (ir_extblk *)extbb->blks;
-
- extbb->blks = NEW_ARR_D(ir_node *, env.obst, len);
-
- for (block = (ir_node*) extbb->link, i = 0; i < len; ++i) {
- ir_node *nblock = (ir_node*) get_irn_link(block);
-
- /* ensure that the leader is the first one */
- extbb->blks[len - 1 - i] = block;
- set_irn_link(block, NULL);
- block = nblock;
- }
-
-#if 0
- for (i = 0; i < len; ++i) {
- if (i > 0)
- printf(", ");
- ir_printf("%+F", extbb->blks[i]);
- }
- printf("\n");
-#endif
-
- extbb->link = NULL;
- extbb->visited = 0;
- }
-
- set_irg_state(irg, IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
-}
+++ /dev/null
-/*
- * Copyright (C) 1995-2011 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 Extended basis block support -- private header
- * @author Michael Beck
- * @date 5.2005
- */
-#ifndef FIRM_ANA_IREXTBB_T_H
-#define FIRM_ANA_IREXTBB_T_H
-
-#include "irgraph_t.h"
-#include "irextbb.h"
-#include "irtools.h"
-#include "ircons.h"
-
-/**
- * An extended block.
- */
-struct ir_extblk {
- firm_kind kind; /**< k_ir_extblk */
- ir_visited_t visited; /**< visited flag */
- ir_node **blks; /**< blocks belonging to this extended block */
- void *link; /**< private link field */
-};
-
-/**
- * Checks whether a pointer points to a extended basic block.
- * Intern version for libFirm.
- */
-static inline int _is_ir_extbb(const void *thing)
-{
- return (get_kind(thing) == k_ir_extblk);
-}
-
-/**
- * Gets the visited counter of an extended block.
- * Internal version for libFirm.
- */
-static inline ir_visited_t _get_extbb_visited(const ir_extblk *blk)
-{
- assert(blk);
- return blk->visited;
-}
-
-/**
- * Sets the visited counter of an extended block.
- * Internal version for libFirm.
- */
-static inline void _set_extbb_visited(ir_extblk *blk, ir_visited_t visited)
-{
- assert(blk);
- blk->visited = visited;
-}
-
-/**
- * Mark an extended block as visited in a graph.
- * Internal version for libFirm.
- */
-static inline void _mark_extbb_visited(ir_extblk *blk)
-{
- assert(blk);
- blk->visited = current_ir_graph->block_visited;
-}
-
-/**
- * Returns non-zero if an extended was visited.
- * Internal version for libFirm.
- */
-static inline int _extbb_visited(const ir_extblk *blk)
-{
- assert(blk);
- return blk->visited >= current_ir_graph->block_visited;
-}
-
-/**
- * Returns non-zero if an extended block was NOT visited.
- * Internal version for libFirm.
- */
-static inline int _extbb_not_visited(const ir_extblk *blk)
-{
- assert(blk);
- return blk->visited < current_ir_graph->block_visited;
-}
-
-/**
- * Returns the link field of an extended block.
- * Internal version for libFirm.
- */
-static inline void *_get_extbb_link(const ir_extblk *blk)
-{
- assert(blk);
- return blk->link;
-}
-
-/**
- * Sets the link field of an extended block.
- * Internal version for libFirm.
- */
-static inline void _set_extbb_link(ir_extblk *blk, void *link)
-{
- assert(blk);
- blk->link = link;
-}
-
-/**
- * Return the number of basis blocks of an extended block
- */
-static inline int _get_extbb_n_blocks(const ir_extblk *blk)
-{
- assert(blk);
- return (int)ARR_LEN(blk->blks);
-}
-
-/**
- * Return the i'th basis block of an extended block
- */
-static inline ir_node *_get_extbb_block(const ir_extblk *blk, int pos)
-{
- assert(blk && 0 <= pos && pos < _get_extbb_n_blocks(blk));
- return blk->blks[pos];
-}
-
-/**
- * Return the leader basis block of an extended block
- */
-static inline ir_node *_get_extbb_leader(const ir_extblk *blk)
-{
- return blk->blks[0];
-}
-
-#define is_ir_extbb(thing) _is_ir_extbb(thing)
-#define get_extbb_visited(blk) _get_extbb_visited(blk)
-#define set_extbb_visited(blk, v) _set_extbb_visited(blk, v)
-#define mark_extbb_visited(blk) _mark_extbb_visited(blk)
-#define extbb_visited(blk) _extbb_visited(blk)
-#define extbb_not_visited(blk) _extbb_not_visited(blk)
-#define get_extbb_link(blk) _get_extbb_link(blk)
-#define set_extbb_link(blk, link) _set_extbb_link(blk, link)
-#define get_extbb_n_blocks(blk) _get_extbb_n_blocks(blk)
-#define get_extbb_leader(blk) _get_extbb_leader(blk)
-
-#endif
#include "entity_t.h"
#include "error.h"
#include "util.h"
+#include "execfreq.h"
#include "be_t.h"
#include "beemitter.h"
if (blocks_removed) {
/* invalidate analysis info */
- clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
- | IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
+ clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
}
return blocks_removed;
}
#include "irgwalk.h"
#include "irtools.h"
#include "time.h"
-
-/* libfirm/ir/adt includes */
+#include "execfreq.h"
#include "bipartite.h"
/* libfirm/ir/be includes */
#include "irgraph_t.h"
#include "iredges_t.h"
#include "ircons.h"
-#include "irextbb.h"
#include "irgmod.h"
#include "debug.h"
case k_tarval:
case k_ir_loop:
case k_ir_compound_graph_path:
- case k_ir_extblk:
case k_ir_prog:
fprintf(f, "NIY\n");
break;
add[0] = '\0';
break;
}
- case k_ir_extblk: {
- ir_extblk *extblk = (ir_extblk*)X;
- snprintf(buf, sizeof(buf), "ExtBlock");
- snprintf(add, sizeof(add), "[%ld]", get_irn_node_nr(get_extbb_leader(extblk)));
- break;
- }
default:
snprintf(buf, sizeof(buf), "UNKWN");
res->attr.block.dynamic_ins = true;
res->attr.block.irg.irg = irg;
res->attr.block.backedge = NULL;
- res->attr.block.extblk = NULL;
res->attr.block.entity = NULL;
set_Block_block_visited(res, 0);
#include "irdom.h"
#include "irloop_t.h"
#include "callgraph.h"
-#include "irextbb_t.h"
#include "irhooks.h"
#include "dbginfo_t.h"
#include "irtools.h"
return (ir_node**)ird_get_irg_link(irg);
}
-typedef struct list_tuple {
- ir_node **blk_list;
- ir_extblk **extbb_list;
-} list_tuple;
-
-/** Construct lists to walk IR extended block-wise.
- * Free the lists in the tuple with DEL_ARR_F(). Sets the irg link field to
- * NULL in all graphs not visited.
- */
-static list_tuple *construct_extblock_lists(ir_graph *irg)
-{
- ir_node **blk_list = construct_block_lists(irg);
- size_t i, n;
- list_tuple *lists = XMALLOC(list_tuple);
-
- lists->blk_list = NEW_ARR_F(ir_node *, 0);
- lists->extbb_list = NEW_ARR_F(ir_extblk *, 0);
-
- inc_irg_block_visited(irg);
- for (i = 0, n = ARR_LEN(blk_list); i < n; ++i) {
- ir_extblk *ext;
-
- if (is_Block(blk_list[i])) {
- ext = get_Block_extbb(blk_list[i]);
-
- if (extbb_not_visited(ext)) {
- ARR_APP1(ir_extblk *, lists->extbb_list, ext);
- mark_extbb_visited(ext);
- }
- } else
- ARR_APP1(ir_node *, lists->blk_list, blk_list[i]);
- }
- DEL_ARR_F(blk_list);
-
- ird_set_irg_link(irg, lists);
- return lists;
-}
-
void dump_node_opcode(FILE *F, const ir_node *n)
{
const ir_op_ops *ops = get_op_ops(get_irn_op(n));
fprintf(F, " consistent_loopinfo");
if (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_ENTITY_USAGE))
fprintf(F, " consistent_entity_usage");
- if (is_irg_state(irg, IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS))
- fprintf(F, " valid_exended_blocks");
fprintf(F, "\"\n");
}
}
}
-/** dumps a graph extended block-wise. Expects all blockless nodes in arr in irgs link.
- * The outermost nodes: blocks and nodes not op_pin_state_pinned, Bad, Unknown. */
-static void dump_extblock_graph(FILE *F, ir_graph *irg)
-{
- size_t i, arr_len;
- ir_extblk **arr = (ir_extblk**)ird_get_irg_link(irg);
-
- for (i = 0, arr_len = ARR_LEN(arr); i < arr_len; ++i) {
- ir_extblk *extbb = arr[i];
- ir_node *leader = get_extbb_leader(extbb);
- size_t j, n_blks;
-
- fprintf(F, "graph: { title: \"");
- fprintf(F, "x%ld", get_irn_node_nr(leader));
- fprintf(F, "\" label: \"ExtBB %ld\" status:clustered color:lightgreen\n",
- get_irn_node_nr(leader));
-
- for (j = 0, n_blks = ARR_LEN(extbb->blks); j < n_blks; ++j) {
- ir_node *node = extbb->blks[j];
- if (is_Block(node)) {
- /* Dumps the block and all the nodes in the block, which are to
- be found in Block->link. */
- dump_whole_block(F, node);
- } else {
- /* Nodes that are not in a Block. */
- dump_node(F, node);
- if (is_Bad(get_nodes_block(node)) && !node_floats(node)) {
- dump_const_block_local(F, node);
- }
- dump_ir_data_edges(F, node);
- }
- }
- fprintf(F, "}\n");
- }
-
- if ((flags & ir_dump_flag_loops)
- && (is_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_LOOPINFO)))
- dump_loop_nodes_into_graph(F, irg);
-
- free_extbb(irg);
-}
-
-static void dump_blocks_extbb_grouped(FILE *F, ir_graph *irg)
-{
- size_t i;
- ir_entity *ent = get_irg_entity(irg);
-
- if (!is_irg_state(irg, IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS))
- compute_extbb(irg);
-
- construct_extblock_lists(irg);
-
- fprintf(F, "graph: { title: ");
- print_irgid(F, irg);
- fprintf(F, " label: \"%s\" status:clustered color: white\n",
- get_ent_dump_name(ent));
-
- dump_graph_info(F, irg);
- print_dbg_info(F, get_entity_dbg_info(ent));
-
- for (i = get_irp_n_irgs(); i > 0;) {
- ir_graph *other_irg = get_irp_irg(--i);
- list_tuple *lists = (list_tuple*)ird_get_irg_link(other_irg);
-
- if (lists) {
- /* dump the extended blocks first */
- if (ARR_LEN(lists->extbb_list)) {
- ird_set_irg_link(other_irg, lists->extbb_list);
- dump_extblock_graph(F, other_irg);
- }
-
- /* we may have blocks without extended blocks, bad for instance */
- if (ARR_LEN(lists->blk_list)) {
- ird_set_irg_link(other_irg, lists->blk_list);
- dump_block_graph(F, other_irg);
- }
-
- DEL_ARR_F(lists->extbb_list);
- DEL_ARR_F(lists->blk_list);
- xfree(lists);
- }
- }
-
- /* Close the vcg information for the irg */
- fprintf(F, "}\n\n");
-
- free_extbb(irg);
-}
-
void dump_ir_graph_file(FILE *out, ir_graph *irg)
{
dump_vcg_header(out, get_irg_dump_name(irg), NULL, NULL);
/* dump nodes */
if (flags & ir_dump_flag_blocks_as_subgraphs) {
- if (flags & ir_dump_flag_group_extbb) {
- dump_blocks_extbb_grouped(out, irg);
- } else {
- dump_blocks_as_subgraphs(out, irg);
- }
+ dump_blocks_as_subgraphs(out, irg);
} else {
/* dump_node_with_edges must be called in post visiting predecessors */
ird_walk_graph(irg, NULL, dump_node_with_edges, out);
/* invalidate infos */
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_LOOPINFO);
- clear_irg_state(irg, IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
edges_deactivate(irg);
/* Finally kill BAD and doublets from the keep alives.
res->visited = 0; /* visited flag, for the ir walker */
res->block_visited = 0; /* visited flag, for the 'block'-walker */
- res->extbb_obst = NULL;
-
res->last_node_idx = 0;
new_identities(res);
res->block_visited = 0; /* visited flag, for the 'block'-walker */
res->obst = XMALLOC(struct obstack);
obstack_init(res->obst);
- res->extbb_obst = NULL;
res->last_node_idx = 0;
res->block_visited = 0; /* visited flag, for the 'block'-walker */
res->obst = XMALLOC(struct obstack);
obstack_init(res->obst);
- res->extbb_obst = NULL;
res->last_node_idx = 0;
return Block_block_visited_(node);
}
-ir_extblk *get_Block_extbb(const ir_node *block)
-{
- ir_extblk *res;
- assert(is_Block(block));
- res = block->attr.block.extblk;
- assert(res == NULL || is_ir_extbb(res));
- return res;
-}
-
-void set_Block_extbb(ir_node *block, ir_extblk *extblk)
-{
- assert(is_Block(block));
- assert(extblk == NULL || is_ir_extbb(extblk));
- block->attr.block.extblk = extblk;
-}
-
ir_graph *(get_Block_irg)(const ir_node *block)
{
return get_Block_irg_(block);
#include "irgraph.h"
#include "iredgekinds.h"
#include "irtypeinfo.h"
-#include "irextbb.h"
#include "irmemory.h"
#include "callgraph.h"
#include "irprog.h"
datastructure. */
ir_dom_info pdom; /**< Datastructure that holds information about post-dominators. */
bitset_t *backedge; /**< Bitfield n set to true if pred n is backedge.*/
- ir_extblk *extblk; /**< The extended basic block this block belongs to. */
ir_entity *entity; /**< entitiy representing this block */
ir_node *phis; /**< The list of Phi nodes in this block. */
ir_node *anchor; /**< Pointer to the anchor node of this graph. */
struct obstack *obst; /**< The obstack where all of the ir_nodes live. */
ir_node *current_block; /**< Current block for newly gen_*()-erated ir_nodes. */
- struct obstack *extbb_obst; /**< The obstack for extended basic block info. */
/* -- Fields for graph properties -- */
irg_inline_property inline_property; /**< How to handle inlineing. */
if (env->flags & CF_CHANGED) {
/* control flow changed, dominance info is invalid */
- clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
- | IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
+ clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
}
edges_deactivate(irg);
}
set_irg_callee_info_state(irg, irg_callee_info_inconsistent);
/* Exception control flow might have changed / new block might have added. */
- clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
- | IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
+ clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
/* verify here */
irg_verify(irg, VERIFY_NORMAL);
if (n > 0) {
/* lowering might create new blocks, so be sure to handle this */
- clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
- | IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
+ clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
edges_deactivate(irg);
}
}
/* Cleanup, verify the graph. */
ir_free_resources(irg, resources);
- clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
- | IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
+ clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
}
DEL_ARR_F(env.muxes);
}
DEL_ARR_F(default_preds);
- clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
- | IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
+ clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
}
/**
DEL_ARR_F(info.defusers);
xfree(info.cases);
clear_irg_state(get_irn_irg(block), IR_GRAPH_STATE_NO_CRITICAL_EDGES
- | IR_GRAPH_STATE_CONSISTENT_DOMINANCE
- | IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
+ | IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
}
void lower_switch(ir_graph *irg, unsigned small_switch, unsigned spare_size,
break;
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
- | IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS
| IR_GRAPH_STATE_CONSISTENT_ENTITY_USAGE);
}
irg_block_walk_graph(irg, NULL, walk_critical_cf_edges, &env);
if (env.changed) {
/* control flow changed */
- clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
- | IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
+ clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
}
set_irg_state(irg, IR_GRAPH_STATE_NO_CRITICAL_EDGES);
}
if (res) {
/* control flow changed */
- clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
- | IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
+ clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
}
for (bl = env.all_blocks; bl != NULL; bl = bl->all_next) {
assert(get_irg_pinned(irg) == op_pin_state_pinned);
assert(get_irg_pinned(called_graph) == op_pin_state_pinned);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
- | IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS
| IR_GRAPH_STATE_CONSISTENT_ENTITY_USAGE);
set_irg_callee_info_state(irg, irg_callee_info_inconsistent);
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_ENTITY_USAGE);
PREPARE(IR_GRAPH_STATE_CONSISTENT_OUTS, assure_irg_outs)
PREPARE(IR_GRAPH_STATE_CONSISTENT_LOOPINFO, assure_loopinfo)
PREPARE(IR_GRAPH_STATE_CONSISTENT_ENTITY_USAGE, assure_irg_entity_usage_computed)
- PREPARE(IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS, compute_extbb)
/* now all the requirements for the optimization are fulfilled */
if (dump)
INVALIDATE(IR_GRAPH_STATE_CONSISTENT_OUT_EDGES, edges_deactivate)
INVALIDATE(IR_GRAPH_STATE_CONSISTENT_LOOPINFO, nop)
INVALIDATE(IR_GRAPH_STATE_CONSISTENT_ENTITY_USAGE, nop)
- INVALIDATE(IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS, nop)
remove_End_Bads_and_doublets(get_irg_end(irg));
* a new Block was added, so dominator, outs and loop are inconsistent,
* trouts and callee-state should be still valid
*/
- clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
- | IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
+ clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
}
/* Create a graph pass. */
| IR_GRAPH_STATE_ONE_RETURN
| IR_GRAPH_STATE_CONSISTENT_OUTS
| IR_GRAPH_STATE_NO_UNREACHABLE_CODE
- | IR_GRAPH_STATE_NO_BADS
- | IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
+ | IR_GRAPH_STATE_NO_BADS);
}
/* Create a graph pass. */
assert(env->n_tail_calls > 0);
/* we add new blocks and change the control flow */
- clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
- | IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
+ clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE);
/* we must build some new nodes WITHOUT CSE */
set_optimize(0);
/* tail recursion was done, all info is invalid */
clear_irg_state(irg, IR_GRAPH_STATE_CONSISTENT_DOMINANCE
- | IR_GRAPH_STATE_CONSISTENT_LOOPINFO
- | IR_GRAPH_STATE_VALID_EXTENDED_BLOCKS);
+ | IR_GRAPH_STATE_CONSISTENT_LOOPINFO);
set_irg_callee_info_state(irg, irg_callee_info_inconsistent);
set_optimize(rem);
} /* opt_cmp */
/**
- * Compare two elements of the block/extbb hash.
+ * Compare two elements of the block hash.
*/
static int block_cmp(const void *elt, const void *key)
{
elem->block_hash = NULL;
} /* if */
- if (elem->extbb_hash) {
- del_pset(elem->extbb_hash);
- elem->extbb_hash = NULL;
- } /* if */
-
obstack_free(&elem->recalc_cnts, NULL);
obstack_init(&elem->recalc_cnts);
} /* graph_clear_entry */
/* these hash tables are created on demand */
elem->block_hash = NULL;
- elem->extbb_hash = NULL;
for (i = 0; i != ARRAY_SIZE(elem->opt_hash); ++i)
elem->opt_hash[i] = new_pset(opt_cmp, 4);
} /* for */
} /* undate_block_info */
-/**
- * Update the extended block counter.
- */
-static void update_extbb_info(ir_node *node, graph_entry_t *graph)
-{
- ir_op *op = get_irn_op(node);
- ir_extblk *extbb;
- extbb_entry_t *eb_entry;
- int i, arity;
-
- /* check for block */
- if (op == op_Block) {
- extbb = get_nodes_extbb(node);
- arity = get_irn_arity(node);
- eb_entry = block_get_entry(&graph->recalc_cnts, get_extbb_node_nr(extbb), graph->extbb_hash);
-
- /* count all incoming edges */
- for (i = 0; i < arity; ++i) {
- ir_node *pred = get_irn_n(node, i);
- ir_extblk *other_extbb = get_nodes_extbb(pred);
-
- if (extbb != other_extbb) {
- extbb_entry_t *eb_entry_other = block_get_entry(&graph->recalc_cnts, get_extbb_node_nr(other_extbb), graph->extbb_hash);
-
- cnt_inc(&eb_entry->cnt[bcnt_in_edges]); /* an edge coming from another extbb */
- cnt_inc(&eb_entry_other->cnt[bcnt_out_edges]);
- } /* if */
- } /* for */
- return;
- } /* if */
-
- extbb = get_nodes_extbb(node);
- eb_entry = block_get_entry(&graph->recalc_cnts, get_extbb_node_nr(extbb), graph->extbb_hash);
-
- if (op == op_Phi && mode_is_datab(get_irn_mode(node))) {
- /* count data Phi per extbb */
- cnt_inc(&eb_entry->cnt[bcnt_phi_data]);
- } /* if */
-
- /* we have a new node in our block */
- cnt_inc(&eb_entry->cnt[bcnt_nodes]);
-
- /* don't count keep-alive edges */
- if (is_End(node))
- return;
-
- arity = get_irn_arity(node);
-
- for (i = 0; i < arity; ++i) {
- ir_node *pred = get_irn_n(node, i);
- ir_extblk *other_extbb = get_nodes_extbb(pred);
-
- if (other_extbb == extbb)
- cnt_inc(&eb_entry->cnt[bcnt_edges]); /* a in extbb edge */
- else {
- extbb_entry_t *eb_entry_other = block_get_entry(&graph->recalc_cnts, get_extbb_node_nr(other_extbb), graph->extbb_hash);
-
- cnt_inc(&eb_entry->cnt[bcnt_in_edges]); /* an edge coming from another extbb */
- cnt_inc(&eb_entry_other->cnt[bcnt_out_edges]);
- } /* if */
- } /* for */
-} /* update_extbb_info */
-
/**
* Calculates how many arguments of the call are const, updates
* param distribution.
/* count block edges */
undate_block_info(node, graph);
- /* count extended block edges */
- if (status->stat_options & FIRMSTAT_COUNT_EXTBB) {
- if (graph->irg != get_const_code_irg())
- update_extbb_info(node, graph);
- } /* if */
-
/* handle statistics for special node types */
switch (op->code) {
/* we need dominator info */
if (graph->irg != get_const_code_irg()) {
assure_doms(graph->irg);
-
- if (status->stat_options & FIRMSTAT_COUNT_EXTBB) {
- /* we need extended basic blocks */
- compute_extbb(graph->irg);
-
- /* create new extbb counter */
- graph->extbb_hash = new_pset(block_cmp, 5);
- } /* if */
} /* if */
/* count the nodes in the graph */
struct obstack recalc_cnts; /**< obstack containing the counters that are recalculated */
HASH_MAP(node_entry_t) *opcode_hash; /**< hash map containing the opcode counter */
HASH_MAP(block_entry_t) *block_hash; /**< hash map containing the block counter */
- HASH_MAP(block_entry_t) *extbb_hash; /**< hash map containing the extended block counter */
HASH_MAP(be_block_entry_t) *be_block_hash; /**< hash map containing backend block information */
counter_t cnt[_gcnt_last]; /**< counter */
unsigned num_tail_recursion; /**< number of tail recursion optimizations */
unsigned is_end:1; /**< set, if it's the End block. */
} block_entry_t;
-/** An entry for an extended block in a ir-graph */
-typedef block_entry_t extbb_entry_t;
-
/**
* Some potential interesting float values
*/
{
int dump_opts = 1;
block_entry_t *b_entry;
- extbb_entry_t *eb_entry;
if (! dmp->f)
return;
/* dump block permutation statistics */
simple_dump_be_block_permstat(dmp, entry);
-
- if (dmp->status->stat_options & FIRMSTAT_COUNT_EXTBB && entry->extbb_hash) {
- /* dump extended block info */
- fprintf(dmp->f, "\n%12s %12s %12s %12s %12s %12s %12s\n", "Extbb Nr", "Nodes", "intern E", "incoming E", "outgoing E", "Phi", "quot");
- foreach_pset(entry->extbb_hash, extbb_entry_t*, eb_entry) {
- fprintf(dmp->f, "ExtBB %6ld %12u %12u %12u %12u %12u %4.8f\n",
- eb_entry->block_nr,
- cnt_to_uint(&eb_entry->cnt[bcnt_nodes]),
- cnt_to_uint(&eb_entry->cnt[bcnt_edges]),
- cnt_to_uint(&eb_entry->cnt[bcnt_in_edges]),
- cnt_to_uint(&eb_entry->cnt[bcnt_out_edges]),
- cnt_to_uint(&eb_entry->cnt[bcnt_phi_data]),
- cnt_to_dbl(&eb_entry->cnt[bcnt_edges]) / cnt_to_dbl(&eb_entry->cnt[bcnt_nodes])
- );
- } /* foreach_pset */
- } /* if */
}
} /* simple_dump_graph */
RelativePath="..\ir\ana\irdom_t.h"
>
</File>
- <File
- RelativePath="..\ir\ana\irextbb.c"
- >
- <FileConfiguration
- Name="Release|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="Debug|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- <FileConfiguration
- Name="DebugJTEST|Win32"
- >
- <Tool
- Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=""
- PreprocessorDefinitions=""
- />
- </FileConfiguration>
- </File>
- <File
- RelativePath="..\ir\ana\irextbb2.c"
- >
- </File>
- <File
- RelativePath="..\ir\ana\irextbb_t.h"
- >
- </File>
<File
RelativePath="..\ir\ana\irlivechk.c"
>
RelativePath="..\include\libfirm\iredges.h"
>
</File>
- <File
- RelativePath="..\include\libfirm\irextbb.h"
- >
- </File>
<File
RelativePath="..\include\libfirm\irflag.h"
>
#include "irmode_t.h"
#include "tv_t.h"
#include "irloop_t.h"
-#include "irextbb_t.h"
#include "irprog_t.h"
#include "compound_path_t.h"
#include "tpop_t.h"
return sizeof(ir_loop);
case k_ir_compound_graph_path: /* a compound graph path, see entity.h */
return sizeof(compound_graph_path);
- case k_ir_extblk: /* an extended block */
- return sizeof(ir_extblk);
case k_ir_prog: /* a program representation (irp) */
return sizeof(ir_prog);
default:
return S_OK;
} /* get_array_desc */
-/**
- * format an extended block
- */
-static HRESULT format_extblk(DEBUGHELPER *pHelper, int nBase, const void *addr, char *pResult, size_t max)
-{
- ir_extblk extbb;
- ir_arr_descr blocks;
- ir_node *blks = NULL;
- char name[256];
- int len;
-
- if (copy_from_debuggee(addr, pHelper, &extbb, sizeof(extbb)) != S_OK)
- return E_FAIL;
- if (extbb.blks == NULL)
- return E_FAIL;
-
- if (get_array_desc(pHelper, extbb.blks, &blocks) != S_OK)
- return E_FAIL;
-
- len = ARR_LEN(&blocks.v.elts);
-
- if (len > 0) {
- if (copy_from_debuggee(extbb.blks, pHelper, &blks, sizeof(blks)) != S_OK)
- return E_FAIL;
- }
-
- if (blks) {
- switch (nBase) {
- case 16:
- _snprintf(name, sizeof(name), "0x%x 0x%x blocks", blks->node_nr, len);
- break;
- case 8:
- _snprintf(name, sizeof(name), "0%o 0%o blocks", blks->node_nr, len);
- break;
- default:
- _snprintf(name, sizeof(name), "%d %d blocks", blks->node_nr, len);
- }
- _tcsncpy(pResult, name, max);
- }
- else
- _tcsncpy(pResult, "<EMPTY>", max);
- return S_OK;
-} /* format_extblk */
-
-
/**
* format a ir_prog
*/
return format_loop(pHelper, addr, pResult, max);
case k_ir_compound_graph_path: /* a compound graph path, see entity.h */
return E_FAIL;
- case k_ir_extblk: /* an extended block */
- return format_extblk(pHelper, nBase, addr, pResult, max);
case k_ir_prog: /* a program representation (irp) */
return format_prog(pHelper, nBase, addr, pResult, max);
default:
ir\ana\interval_analysis.h\r
ir\ana\field_temperature.h\r
ir\ana\execution_frequency.h\r
-ir\ana\irextbb.h\r
ir\ana\execfreq.h\r
ir\ana\irconsconfirm.h\r
ir\ana\analyze_irg_args.h\r
# End Source File
# Begin Source File
-SOURCE=..\ir\ana\irextbb.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\ir\ana\irextbb2.c
-# End Source File
-# Begin Source File
-
-SOURCE=..\ir\ana\irextbb_t.h
-# End Source File
-# Begin Source File
-
SOURCE=..\ir\ana\irlivechk.c
# End Source File
# Begin Source File
# End Source File
# Begin Source File
-SOURCE=..\include\libfirm\irextbb.h
-# End Source File
-# Begin Source File
-
SOURCE=..\include\libfirm\irflag.h
# End Source File
# Begin Source File
<ClCompile Include="$(FirmRoot)\ir\ana\irscc.c"/>
<ClCompile Include="$(FirmRoot)\ir\ana\irconsconfirm.c"/>
<ClCompile Include="$(FirmRoot)\ir\ana\irdom.c"/>
- <ClCompile Include="$(FirmRoot)\ir\ana\irextbb.c"/>
- <ClCompile Include="$(FirmRoot)\ir\ana\irextbb2.c"/>
<ClCompile Include="$(FirmRoot)\ir\ana\irlivechk.c"/>
<ClCompile Include="$(FirmRoot)\ir\ana\irloop.c"/>
<ClCompile Include="$(FirmRoot)\ir\ana\irmemory.c"/>
<ClInclude Include="$(FirmRoot)\ir\ana\dfs_t.h"/>
<ClInclude Include="$(FirmRoot)\ir\ana\irbackedge_t.h"/>
<ClInclude Include="$(FirmRoot)\ir\ana\irdom_t.h"/>
- <ClInclude Include="$(FirmRoot)\ir\ana\irextbb_t.h"/>
<ClInclude Include="$(FirmRoot)\ir\ana\irlivechk.h"/>
<ClInclude Include="$(FirmRoot)\ir\ana\irloop_t.h"/>
<ClInclude Include="$(FirmRoot)\ir\ana\irmemory_t.h"/>
<ClInclude Include="$(FirmRoot)\include\libfirm\irgraph.h"/>
<ClInclude Include="$(FirmRoot)\include\libfirm\iredgekinds.h"/>
<ClInclude Include="$(FirmRoot)\include\libfirm\iredges.h"/>
- <ClInclude Include="$(FirmRoot)\include\libfirm\irextbb.h"/>
<ClInclude Include="$(FirmRoot)\include\libfirm\irflag.h"/>
<ClInclude Include="$(FirmRoot)\include\libfirm\irgmod.h"/>
<ClInclude Include="$(FirmRoot)\include\libfirm\irgopt.h"/>
<ClCompile Include="$(FirmRoot)\ir\ana\irdom.c">
<Filter>ir\ana</Filter>
</ClCompile>
- <ClCompile Include="$(FirmRoot)\ir\ana\irextbb2.c">
- <Filter>ir\ana</Filter>
- </ClCompile>
- <ClCompile Include="$(FirmRoot)\ir\ana\irextbb.c">
- <Filter>ir\ana</Filter>
- </ClCompile>
<ClCompile Include="$(FirmRoot)\ir\ana\irlivechk.c">
<Filter>ir\ana</Filter>
</ClCompile>
<ClInclude Include="$(FirmRoot)\ir\ana\irdom_t.h">
<Filter>ir\ana</Filter>
</ClInclude>
- <ClInclude Include="$(FirmRoot)\ir\ana\irextbb_t.h">
- <Filter>ir\ana</Filter>
- </ClInclude>
<ClInclude Include="$(FirmRoot)\ir\ana\irlivechk.h">
<Filter>ir\ana</Filter>
</ClInclude>
<ClInclude Include="$(FirmRoot)\include\libfirm\iredges.h">
<Filter>include\libfirm</Filter>
</ClInclude>
- <ClInclude Include="$(FirmRoot)\include\libfirm\irextbb.h">
- <Filter>include\libfirm</Filter>
- </ClInclude>
<ClInclude Include="$(FirmRoot)\include\libfirm\irflag.h">
<Filter>include\libfirm</Filter>
</ClInclude>
<ClCompile Include="$(FirmRoot)\ir\ana\irdom.c">
<Filter>ir\ana</Filter>
</ClCompile>
- <ClCompile Include="$(FirmRoot)\ir\ana\irextbb.c">
- <Filter>ir\ana</Filter>
- </ClCompile>
- <ClCompile Include="$(FirmRoot)\ir\ana\irextbb2.c">
- <Filter>ir\ana</Filter>
- </ClCompile>
<ClCompile Include="$(FirmRoot)\ir\ana\irlivechk.c">
<Filter>ir\ana</Filter>
</ClCompile>
<ClInclude Include="$(FirmRoot)\ir\ana\irdom_t.h">
<Filter>ir\ana</Filter>
</ClInclude>
- <ClInclude Include="$(FirmRoot)\ir\ana\irextbb_t.h">
- <Filter>ir\ana</Filter>
- </ClInclude>
<ClInclude Include="$(FirmRoot)\ir\ana\irlivechk.h">
<Filter>ir\ana</Filter>
</ClInclude>
<ClInclude Include="$(FirmRoot)\include\libfirm\iredges.h">
<Filter>include\libfirm</Filter>
</ClInclude>
- <ClInclude Include="$(FirmRoot)\include\libfirm\irextbb.h">
- <Filter>include\libfirm</Filter>
- </ClInclude>
<ClInclude Include="$(FirmRoot)\include\libfirm\irflag.h">
<Filter>include\libfirm</Filter>
</ClInclude>
<ClCompile Include="$(FirmRoot)\ir\ana\irdom.c">
<Filter>ir\ana</Filter>
</ClCompile>
- <ClCompile Include="$(FirmRoot)\ir\ana\irextbb.c">
- <Filter>ir\ana</Filter>
- </ClCompile>
- <ClCompile Include="$(FirmRoot)\ir\ana\irextbb2.c">
- <Filter>ir\ana</Filter>
- </ClCompile>
<ClCompile Include="$(FirmRoot)\ir\ana\irlivechk.c">
<Filter>ir\ana</Filter>
</ClCompile>
<ClInclude Include="$(FirmRoot)\ir\ana\irdom_t.h">
<Filter>ir\ana</Filter>
</ClInclude>
- <ClInclude Include="$(FirmRoot)\ir\ana\irextbb_t.h">
- <Filter>ir\ana</Filter>
- </ClInclude>
<ClInclude Include="$(FirmRoot)\ir\ana\irlivechk.h">
<Filter>ir\ana</Filter>
</ClInclude>
<ClInclude Include="$(FirmRoot)\include\libfirm\iredges.h">
<Filter>include\libfirm</Filter>
</ClInclude>
- <ClInclude Include="$(FirmRoot)\include\libfirm\irextbb.h">
- <Filter>include\libfirm</Filter>
- </ClInclude>
<ClInclude Include="$(FirmRoot)\include\libfirm\irflag.h">
<Filter>include\libfirm</Filter>
</ClInclude>
<ClCompile Include="$(FirmRoot)\ir\ana\irdom.c">
<Filter>ir\ana</Filter>
</ClCompile>
- <ClCompile Include="$(FirmRoot)\ir\ana\irextbb.c">
- <Filter>ir\ana</Filter>
- </ClCompile>
- <ClCompile Include="$(FirmRoot)\ir\ana\irextbb2.c">
- <Filter>ir\ana</Filter>
- </ClCompile>
<ClCompile Include="$(FirmRoot)\ir\ana\irlivechk.c">
<Filter>ir\ana</Filter>
</ClCompile>
<ClInclude Include="$(FirmRoot)\ir\ana\irdom_t.h">
<Filter>ir\ana</Filter>
</ClInclude>
- <ClInclude Include="$(FirmRoot)\ir\ana\irextbb_t.h">
- <Filter>ir\ana</Filter>
- </ClInclude>
<ClInclude Include="$(FirmRoot)\ir\ana\irlivechk.h">
<Filter>ir\ana</Filter>
</ClInclude>
<ClInclude Include="$(FirmRoot)\include\libfirm\iredges.h">
<Filter>include\libfirm</Filter>
</ClInclude>
- <ClInclude Include="$(FirmRoot)\include\libfirm\irextbb.h">
- <Filter>include\libfirm</Filter>
- </ClInclude>
<ClInclude Include="$(FirmRoot)\include\libfirm\irflag.h">
<Filter>include\libfirm</Filter>
</ClInclude>