#include "config.h"
#include "system.h"
#include "tree.h"
#include "rtl.h"
#include "flags.h"
#include "toplev.h"
#include "output.h"
#include "c-tree.h"
#include "c-common.h"
#include "expr.h"
#include "feedback.h"
#include "basic-block.h"
#include "profile.h"
#include "tree-inline.h"
#include "gcov-io.h"
#include "ggc.h"
#include "langhooks.h"
unsigned int
c_find_control_flow_tree (t)
tree t;
{
unsigned int size = 0;
switch (TREE_CODE (t))
{
case IF_STMT:
size = 4;
break;
case FOR_STMT:
size = 5;
break;
case WHILE_STMT:
case DO_STMT:
size = 3;
break;
case CONTINUE_STMT:
case BREAK_STMT:
case GOTO_STMT:
case RETURN_STMT:
size = 1;
break;
case SWITCH_STMT:
if (TREE_CODE (SWITCH_BODY (t)) != COMPOUND_STMT)
size = 1;
else if (COMPOUND_BODY (SWITCH_BODY (t)) == NULL_TREE)
size = 1;
else if (TREE_CODE (COMPOUND_BODY (SWITCH_BODY (t))) == SCOPE_STMT
&& SCOPE_BEGIN_P (COMPOUND_BODY (SWITCH_BODY (t))))
{
tree tt = TREE_CHAIN (COMPOUND_BODY (SWITCH_BODY (t)));
int nesting = 1;
int default_found = 0;
size = 2;
for (; tt && nesting; tt = TREE_CHAIN (tt))
{
if (TREE_CODE (tt) == SCOPE_STMT)
{
if (SCOPE_BEGIN_P (tt))
nesting++;
else if (SCOPE_END_P (tt))
nesting--;
}
else if (TREE_CODE (tt) == CASE_LABEL && nesting == 1)
{
size += 2;
if (CASE_LOW (tt) == NULL_TREE)
default_found = 1;
}
}
if (!default_found)
size += 2;
}
break;
default:
break;
}
return size;
}
tree
c_create_feedback_counter_tree (table, ix)
tree table;
int ix;
{
tree t;
t = build_modify_expr (
build_array_ref (table,
build_int_2 (ix, 0)),
NOP_EXPR,
build_binary_op (PLUS_EXPR,
build_array_ref (table,
build_int_2 (ix, 0)),
build_int_2 (1, 0), 0));
return t;
}
void c_decorate_for_feedback (fndecl, find_call)
tree fndecl;
walk_tree_fn find_call;
{
walk_tree_without_duplicates (&DECL_SAVED_TREE (fndecl),
find_call, (void *)0);
}