Commit 5d2f7c6e authored by Michael Beck's avatar Michael Beck
Browse files

fixed config.h include

[r4561]
parent ca60816e
......@@ -10,11 +10,12 @@
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
# include "config.h"
#endif
#include <assert.h>
#include "xmalloc.h"
#include "irnode_t.h"
#include "irgraph_t.h"
#include "irprog_t.h"
......@@ -298,7 +299,7 @@ static void optimize_blocks(ir_node *b, void *env) {
for (i = 0, k = get_Block_n_cfgpreds(b); i < k; ++i) {
max_preds += test_whether_dispensable(b, i);
}
in = (ir_node **) malloc(max_preds * sizeof(ir_node *));
in = (ir_node **) xmalloc(max_preds * sizeof(ir_node *));
/*-
printf(" working on "); DDMN(b);
......@@ -489,7 +490,7 @@ static void optimize_blocks(ir_node *b, void *env) {
assert(get_irn_link(b) == NULL || (n_preds == p_preds && "Wrong Phi Fix"));
free(in);
xfree(in);
}
......
......@@ -8,6 +8,20 @@
* Copyright: (c) 1998-2004 Universitt Karlsruhe
* Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
# include "irnode_t.h"
# include "irgraph_t.h"
# include "irmode_t.h"
......@@ -219,6 +233,60 @@ static void collect_nodes(ir_node *node, void *env)
}
}
/**
* returns a entity if the address ptr points to a constant one.
*/
static entity *find_constant_entity(ir_node *ptr)
{
for (;;) {
ir_op *op = get_irn_op(ptr);
if (op == op_SymConst && (get_SymConst_kind(ptr) == symconst_addr_ent)) {
return get_SymConst_entity(ptr);
}
else if (op == op_Sel) {
entity *ent = get_Sel_entity(ptr);
type *tp = get_entity_owner(ent);
if (is_array_type(tp)) {
/* check bounds */
int i, n;
for (i = 0, n = get_Sel_n_indexs(ptr); i < n; ++i) {
ir_node *bound;
tarval *tlower, *tupper;
ir_node *index = get_Sel_index(ptr, i);
tarval *tv = computed_value(index);
/* check if the index is constant */
if (tv == tarval_bad)
return NULL;
bound = get_array_lower_bound(tp, i);
tlower = computed_value(bound);
bound = get_array_upper_bound(tp, i);
tupper = computed_value(bound);
if (tlower == tarval_bad || tupper == tarval_bad)
return NULL;
if (tarval_cmp(tv, tlower) & Lt)
return NULL;
if (tarval_cmp(tupper, tv) & Lt)
return NULL;
/* ok, bounds check finished */
}
}
/* try next */
ptr = get_Sel_ptr(ptr);
}
else
return NULL;
}
}
/**
* optimize a Load
*/
......@@ -227,6 +295,7 @@ static int optimize_load(ir_node *load)
ldst_info_t *info = get_irn_link(load);
ir_mode *load_mode = get_Load_mode(load);
ir_node *pred, *mem, *ptr;
entity *ent;
int res = 0;
/* the address of the load to be optimized */
......@@ -285,11 +354,9 @@ static int optimize_load(ir_node *load)
/* the mem of the Load. Must still be returned after optimization */
mem = get_Load_mem(load);
if ((get_irn_opcode(ptr) == iro_SymConst) && (get_SymConst_kind(ptr) == symconst_addr_ent)) {
entity *ent = get_SymConst_entity(ptr);
assert(mode_is_reference(get_irn_mode(ptr)));
/* check if we can determine the entity that will be loaded */
ent = find_constant_entity(ptr);
if (ent) {
if ((allocation_static == get_entity_allocation(ent)) &&
(visibility_external_allocated != get_entity_visibility(ent))) {
/* a static allocation that is not external: there should be NO exception
......@@ -315,10 +382,20 @@ static int optimize_load(ir_node *load)
exchange(info->projs[pn_Load_M], mem);
/* no result :-) */
if (info->projs[pn_Load_res])
exchange(info->projs[pn_Load_res], copy_const_value(get_atomic_ent_value(ent)));
if (info->projs[pn_Load_res]) {
if (is_atomic_entity(ent)) {
ir_node *c = copy_const_value(get_atomic_ent_value(ent));
return 1;
DBG_OPT_RC(load, c);
exchange(info->projs[pn_Load_res], c);
return 1;
}
}
}
else if (variability_constant == get_entity_variability(ent)) {
printf(">>>>>>>>>>>>> Found access to constant entity %s in function %s\n", get_entity_name(ent),
get_entity_name(get_irg_entity(current_ir_graph)));
}
/* we changed the irg, but try further */
......@@ -358,7 +435,7 @@ static int optimize_load(ir_node *load)
*/
if ((!pred_info->projs[pn_Store_X_except] && !info->projs[pn_Load_X_except]) ||
get_nodes_block(load) == get_nodes_block(pred)) {
DBG_OPT_RAW(pred, load);
DBG_OPT_RAW(load, pred);
exchange( info->projs[pn_Load_res], get_Store_value(pred) );
if (info->projs[pn_Load_M])
......@@ -384,7 +461,7 @@ static int optimize_load(ir_node *load)
if (! info->projs[pn_Load_X_except] || get_nodes_block(load) == get_nodes_block(pred)) {
ldst_info_t *pred_info = get_irn_link(pred);
DBG_OPT_RAR(pred, load);
DBG_OPT_RAR(load, pred);
if (pred_info->projs[pn_Load_res]) {
/* we need a data proj from the previous load for this optimization */
......@@ -476,7 +553,7 @@ static int optimize_store(ir_node *store)
* We may remove the second Store, if it does not have an exception handler.
*/
if (! info->projs[pn_Store_X_except]) {
DBG_OPT_WAR(pred, store);
DBG_OPT_WAR(store, pred);
exchange( info->projs[pn_Store_M], mem );
return 1;
}
......
......@@ -10,7 +10,7 @@
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
# include "config.h"
#endif
# include "irnode_t.h"
......
......@@ -10,7 +10,17 @@
* Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
# include "config.h"
#endif
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_STRING_H
#include <string.h>
#endif
#include <assert.h>
......
......@@ -24,7 +24,10 @@
#endif
# include <stdio.h>
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
# include "st.h"
# include "irgwalk.h"
......
......@@ -46,16 +46,18 @@ typedef struct _dag_env_t {
* a DAG Entry
*/
struct _dag_entry_t {
ir_node *root;
unsigned num_roots;
unsigned num_nodes;
unsigned num_inner_nodes;
unsigned is_dead;
dag_entry_t *next;
unsigned id; /**< assigned ID for this DAG */
ir_node *root; /**< one root of the DAG */
unsigned num_roots; /**< number of root nodes in the DAG */
unsigned num_nodes; /**< overall number of nodes in the DAG */
unsigned num_inner_nodes; /**< number of inner nodes in the DAG */
unsigned is_dead; /**< marks a dead entry */
dag_entry_t *next; /**< link all entries of a DAG */
};
/**
* a DAG Entry link
* a DAG Entry link, used to connect point
* from several places to the same DAG Entry
*/
typedef struct _dag_link_t {
dag_entry_t *entry;
......@@ -84,9 +86,10 @@ static void connect_dags(ir_node *node, void *env)
link = get_irn_link(node);
if (! link) {
/* not assigned node found, maybe a new root */
/* found a not assigned node, maybe a new root */
dag_entry_t *entry = obstack_alloc(&dag_env->obst, sizeof(*entry));
/* allocate a new link */
link = obstack_alloc(&dag_env->obst, sizeof(*link));
link->entry = entry;
......@@ -120,11 +123,12 @@ static void connect_dags(ir_node *node, void *env)
}
}
/* only nodes from teh same block goes into the DAG */
if (get_nodes_block(prev) == block) {
dag_link_t *prev_link = get_irn_link(prev);
if (! prev_link) {
/* not assigned node, do it */
/* not assigned node, put it into the same DAG */
set_irn_link(prev, link);
++link->entry->num_nodes;
++link->entry->num_inner_nodes;
......@@ -154,6 +158,7 @@ void count_dags_in_graph(graph_entry_t *global, graph_entry_t *graph)
{
dag_env_t root_env;
dag_entry_t *entry;
unsigned id;
/* do NOT check the const code irg */
if (graph->irg == get_const_code_irg())
......@@ -173,16 +178,19 @@ void count_dags_in_graph(graph_entry_t *global, graph_entry_t *graph)
printf("Graph %p %s --- %d\n", graph->irg, get_entity_name(get_irg_entity(graph->irg)),
root_env.num_of_dags);
for (entry = root_env.list_of_dags; entry; entry = entry->next) {
for (id = 0, entry = root_env.list_of_dags; entry; entry = entry->next) {
if (entry->is_dead)
continue;
entry->id = id++;
printf("number of roots %d number of nodes %d inner %d %d\n",
printf("number of roots %d number of nodes %d inner %d %ld\n",
entry->num_roots,
entry->num_nodes,
entry->num_inner_nodes,
get_irn_node_nr(entry->root));
}
assert(id == root_env.num_of_dags);
obstack_free(&root_env.obst, NULL);
}
......@@ -11,12 +11,7 @@
#ifndef _DAGS_H_
#define _DAGS_H_
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include "firmstat_t.h"
/*
* count the DAG's size of a graph
*/
......
......@@ -12,15 +12,16 @@
# include "config.h"
#endif
#include "hashptr.h"
#include "xmalloc.h"
#include "firmstat_t.h"
/**
* calculates a hash value for an address
* Addresses are typically aligned at 32bit, so we ignore the lowest bits
*/
static unsigned addr_hash(const void *object)
{
return (unsigned)object >> 3;
return HASH_PTR(object);
}
/**
......@@ -49,10 +50,7 @@ distrib_tbl_t *stat_new_distrib_tbl(pset_cmp_fun cmp_func, distrib_hash_fun hash
{
distrib_tbl_t *res;
res = malloc(sizeof(*res));
if (! res)
return res;
res = xmalloc(sizeof(*res));
obstack_init(&res->cnts);
......
......@@ -16,8 +16,13 @@
#ifdef FIRM_STATISTICS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#include "irouts.h"
#include "irdump.h"
......@@ -870,7 +875,7 @@ void stat_free_graph(ir_graph *irg)
update_graph_stat(global, graph);
/* count the DAG's */
// count_dags_in_graph(global, graph);
//count_dags_in_graph(global, graph);
/* calculate the pattern */
stat_calc_pattern_history(irg);
......@@ -1162,7 +1167,7 @@ void stat_finish(const char *name)
update_graph_stat(global, entry);
/* count the DAG's */
// count_dags_in_graph(global, entry);
//count_dags_in_graph(global, entry);
/* calculate the pattern */
stat_calc_pattern_history(entry->irg);
......
......@@ -14,7 +14,9 @@
#endif
#include <stdio.h>
#include <stdlib.h>
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include "ident.h"
#include "irop_t.h"
......
......@@ -9,13 +9,21 @@
* Copyright: (c) 1998-2003 Universitt Karlsruhe
* Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "firm_common_t.h"
#ifdef HAVE_STRING_H
# include <string.h>
#endif
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
# include <stddef.h>
# include <string.h>
#include "firm_common_t.h"
# include "xmalloc.h"
# include "entity_t.h"
# include "mangle.h"
# include "typegmod.h"
......
......@@ -9,11 +9,8 @@
* Copyright: (c) 1998-2003 Universitt Karlsruhe
* Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
# include "config.h"
#endif
# include "mangle.h"
......
......@@ -9,10 +9,8 @@
* Copyright: (c) 2001-2003 Universitt Karlsruhe
* Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
# include "config.h"
#endif
# include "xmalloc.h"
......
......@@ -36,15 +36,25 @@
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
# include "config.h"
#endif
#ifdef HAVE_ALLOCA_H
#include <alloca.h>
#endif
#ifdef HAVE_MALLOC_H
#include <malloc.h>
#endif
#ifdef HAVE_STRING_H
# include <string.h>
#endif
# include <stdlib.h>
# include <stddef.h>
# include <string.h>
# include "type_t.h"
# include "xmalloc.h"
# include "irprog_t.h"
# include "ircons.h"
# include "tpop_t.h"
......
......@@ -19,7 +19,7 @@
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
# include "config.h"
#endif
#include "type_identify_t.h"
......
......@@ -19,10 +19,13 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
# include "config.h"
#endif
#ifdef HAVE_STDLIB_H
# include <stdlib.h>
#endif
#include <stdlib.h>
#include <stdio.h>
#include "typewalk.h"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment