#include "array.h"
#include "irprog.h"
#include "irgwalk.h"
-#include "irloop.h"
+#include "irloop_t.h"
#include "irflag_t.h"
static void clear_link(ir_node * node, void * env) {
# include <config.h>
#endif
-# include <assert.h>
-# include <stdbool.h>
-
-# include "irprog.h"
-# include "irgopt.h"
-# include "irnode_t.h"
-# include "irgraph_t.h"
-# include "iropt_t.h"
-# include "irgwalk.h"
-# include "ircons_t.h"
-# include "irgmod.h"
-# include "array.h"
-# include "pset.h"
-# include "eset.h"
-# include "pdeq.h" /* Fuer code placement */
-# include "irouts.h"
-# include "irloop.h"
-# include "irbackedge_t.h"
-# include "irflag_t.h"
-# include "firmstat.h"
-# include "cgana.h"
+#include <assert.h>
+#include <stdbool.h>
+
+#include "irnode_t.h"
+#include "irgraph_t.h"
+#include "irprog_t.h"
+
+#include "ircons.h"
+#include "iropt_t.h"
+#include "irgopt.h"
+#include "irgmod.h"
+#include "irgwalk.h"
+
+#include "array.h"
+#include "pset.h"
+#include "eset.h"
+#include "pdeq.h" /* Fuer code placement */
+
+#include "irouts.h"
+#include "irloop_t.h"
+#include "irbackedge_t.h"
+#include "cgana.h"
+
+#include "irflag_t.h"
+#include "firmstat.h"
/* Defined in iropt.c */
pset *new_identities (void);
}
}
+static void
+irg_walk_2_pre(ir_node *node, irg_walk_func *pre, void * env) {
+ int i;
+ set_irn_visited(node, current_ir_graph->visited);
+
+ pre(node, env);
+
+ if (node->op != op_Block) {
+ ir_node *pred = get_irn_n(node, -1);
+ if (pred->visited < current_ir_graph->visited)
+ irg_walk_2_pre(pred, pre, env);
+ }
+ for (i = get_irn_arity(node) - 1; i >= 0; --i) {
+ ir_node *pred = get_irn_n(node, i);
+ if (pred->visited < current_ir_graph->visited)
+ irg_walk_2_pre(pred, pre, env);
+ }
+}
+
+static void
+irg_walk_2_post(ir_node *node, irg_walk_func *post, void * env) {
+ int i;
+ set_irn_visited(node, current_ir_graph->visited);
+
+ if (node->op != op_Block) {
+ ir_node *pred = get_irn_n(node, -1);
+ if (pred->visited < current_ir_graph->visited)
+ irg_walk_2_post(pred, post, env);
+ }
+ for (i = get_irn_arity(node) - 1; i >= 0; --i) {
+ ir_node *pred = get_irn_n(node, i);
+ if (pred->visited < current_ir_graph->visited)
+ irg_walk_2_post(pred, post, env);
+ }
+
+ post(node, env);
+}
+
+static void
+irg_walk_2_both(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env) {
+ int i;
+ set_irn_visited(node, current_ir_graph->visited);
+
+ pre(node, env);
+
+ if (node->op != op_Block) {
+ ir_node *pred = get_irn_n(node, -1);
+ if (pred->visited < current_ir_graph->visited)
+ irg_walk_2_both(pred, pre, post, env);
+ }
+ for (i = get_irn_arity(node) - 1; i >= 0; --i) {
+ ir_node *pred = get_irn_n(node, i);
+ if (pred->visited < current_ir_graph->visited)
+ irg_walk_2_both(pred, pre, post, env);
+ }
+
+ post(node, env);
+}
+
+
static void
irg_walk_2(ir_node *node, irg_walk_func *pre, irg_walk_func *post, void * env)
{
+#if 0 /* safe, old */
int i;
- assert(node && node->kind==k_ir_node);
-#if 0 /* safe */
if (get_irn_visited(node) < get_irg_visited(current_ir_graph)) {
set_irn_visited(node, get_irg_visited(current_ir_graph));
if (post) post(node, env);
}
#else /* faster */
+#if 0
if (node->visited < current_ir_graph->visited) {
+ int i;
set_irn_visited(node, current_ir_graph->visited);
if (pre) pre(node, env);
if (post) post(node, env);
}
+#else /* even faster */
+ if (node->visited < current_ir_graph->visited) {
+ if (!post) irg_walk_2_pre (node, pre, env);
+ else if (!pre) irg_walk_2_post(node, post, env);
+ else irg_walk_2_both(node, pre, post, env);
+ }
+#endif
#endif
}
ir_node *pred;
/* don't assert node !!! */
+ if (!node || (node->op != op_Id)) return node;
+
if (!get_opt_normalize()) return node;
/* Don't use get_Id_pred: We get into an endless loop for
self-referencing Ids. */
- if (node && (node->op == op_Id) && (node != (pred = node->in[0+1]))) {
+ pred = node->in[0+1];
+
+ if (pred->op != op_Id) return pred;
+
+ if (node != pred) { /* not a self referencing Id. Resolve Id chain. */
ir_node *rem_pred, *res;
if (pred->op != op_Id) return pred; /* shortcut */
assert (get_irn_arity (node) > 0);
- node->in[0+1] = node;
+ node->in[0+1] = node; /* turn us into a self referencing Id: shorten Id cycles. */
res = skip_nop(rem_pred);
if (res->op == op_Id) /* self-loop */ return node;
- node->in[0+1] = res;
+ node->in[0+1] = res; /* Turn Id chain into Ids all referencing the chain end. */
return res;
} else {
return node;
depends on this tag. Use the proper access routine after testing
this flag. */
-#define type_tag symconst_type_tag
-//#define size symconst_size geht nicht, benennt auf size in type.c um!
-#define linkage_ptr_info symconst_addr_name
typedef enum {
symconst_type_tag, /**< The SymConst is a type tag for the given type.
Type_or_id_p is type *. */
/** SymConst attributes
This union contains the symbolic information represented by the node */
union symconst_symbol {
- type *type_p; //old typ
- ident *ident_p; // old ptrinfo
- entity *entity_p; // entity_p
+ type *type_p;
+ ident *ident_p;
+ entity *entity_p;
};
+
+
typedef union symconst_symbol symconst_symbol;
+
/** Access the kind of the SymConst. */
symconst_kind get_SymConst_kind (const ir_node *node);
void set_SymConst_kind (ir_node *node, symconst_kind num);
# include "ircons_t.h"
# include "irgmod.h"
# include "irvrfy.h"
-# include "tv.h"
+# include "tv_t.h"
# include "dbginfo_t.h"
# include "iropt_dbg.h"
# include "irflag_t.h"
irp->main_irg = main_irg;
}
-type *get_glob_type(void) {
- assert(irp);
- return irp->glob_type = skip_tid(irp->glob_type);
+type *(get_glob_type)(void) {
+ return __get_glob_type();
}
/* Adds irg to the list of ir graphs in irp. */
}
}
-int get_irp_n_irgs() {
- assert (irp && irp->graphs);
- /* Strangely the first element of the array is NULL. Why?? */
- return (ARR_LEN((irp)->graphs) - 1);
+int (get_irp_n_irgs)(void) {
+ return __get_irp_n_irgs();
}
-ir_graph *get_irp_irg(int pos){
- assert (irp && irp->graphs);
- /* Strangely the first element of the array is NULL. Why?? */
- return irp->graphs[pos+1];
+ir_graph *(get_irp_irg)(int pos){
+ return __get_irp_irg(pos);
}
void set_irp_irg(int pos, ir_graph *irg) {
remove_irp_type_from_list (typ);
}
-int get_irp_n_types (void) {
- assert (irp && irp->types);
- /* Strangely the first element of the array is NULL. Why?? */
- return (ARR_LEN((irp)->types) - 1);
+int (get_irp_n_types) (void) {
+ return __get_irp_n_types();
}
-type *get_irp_type(int pos) {
- assert (irp && irp->types);
- /* Strangely the first element of the array is NULL. Why?? */
- /* Don't set the skip_tid result so that no double entries are generated. */
- return skip_tid(irp->types[pos+1]);
+type *(get_irp_type) (int pos) {
+ return __get_irp_type(pos);
}
void set_irp_type(int pos, type *typ) {
}
-ir_graph *get_const_code_irg(void)
+ir_graph *(get_const_code_irg)(void)
{
- return irp->const_code_irg;
+ return __get_const_code_irg();
}
irg_outs_state get_irp_ip_outs_state() {
return irp->outs_state;
}
+
void set_irp_ip_outs_inconsistent() {
irp->outs_state = outs_inconsistent;
}
+
void set_irp_ip_outedges(ir_node ** ip_outedges)
{
irp -> ip_outedges = ip_outedges;
#include "irgraph.h"
#include "ircgcons.h"
#include "firm_common_t.h"
+#include "typegmod.h"
+#include "array.h"
/** ir_prog */
struct ir_prog {
INLINE void remove_irp_type_from_list (type *typ);
+static INLINE type *
+__get_glob_type(void) {
+ assert(irp);
+ return irp->glob_type = skip_tid(irp->glob_type);
+}
+
+static INLINE int
+__get_irp_n_irgs(void) {
+ assert (irp && irp->graphs);
+ /* Strangely the first element of the array is NULL. Why?? */
+ return (ARR_LEN((irp)->graphs) - 1);
+}
+
+static INLINE ir_graph *
+__get_irp_irg(int pos){
+ assert (irp && irp->graphs);
+ /* Strangely the first element of the array is NULL. Why?? */
+ return irp->graphs[pos+1];
+}
+
+
+static INLINE int
+__get_irp_n_types (void) {
+ assert (irp && irp->types);
+ /* Strangely the first element of the array is NULL. Why?? */
+ return (ARR_LEN((irp)->types) - 1);
+}
+
+static INLINE type *
+__get_irp_type(int pos) {
+ assert (irp && irp->types);
+ /* Strangely the first element of the array is NULL. Why?? */
+ /* Don't set the skip_tid result so that no double entries are generated. */
+ return skip_tid(irp->types[pos+1]);
+}
+
#ifdef DEBUG_libfirm
/** Returns a new, unique number to number nodes or the like. */
int get_irp_new_node_nr(void);
#endif
+static INLINE ir_graph *
+__get_const_code_irg(void)
+{
+ return irp->const_code_irg;
+}
+
+#define get_irp_n_irgs() __get_irp_n_irgs()
+#define get_irp_irg(pos) __get_irp_irg(pos)
+#define get_irp_n_types() __get_irp_n_types()
+#define get_irp_type(pos) __get_irp_type(pos)
+#define get_const_code_irg() __get_const_code_irg()
+#define get_glob_type() __get_glob_type()
+
#endif /* ifndef _IRPROG_T_H_ */
STAT_OPT_CONST_EVAL, /**< constant evaluation */
STAT_LOWERED, /**< lowered */
- STAT_OPT_MAX
-}
-stat_opt_kind;
+ STAT_OPT_MAX = 10
+} stat_opt_kind;
/**
* initialize the statistics module.
# include <config.h>
#endif
-
# include <stdlib.h>
# include <stddef.h>
# include <string.h>
+
# include "type_t.h"
-# include "tpop_t.h"
+
# include "irprog_t.h"
+# include "ircons.h"
+# include "tpop_t.h"
# include "typegmod.h"
-# include "array.h"
-# include "irprog.h"
# include "mangle.h"
-# include "tv.h"
-# include "ircons.h"
+# include "tv_t.h"
+
+# include "array.h"
/*******************************************************************/
/** TYPE **/
#include "type_identify.h"
-# include <stdlib.h>
-# include <stddef.h>
-# include <string.h>
-# include "type_t.h"
-# include "tpop_t.h"
-# include "irprog_t.h"
-# include "typegmod.h"
-# include "array.h"
-# include "irprog.h"
-# include "mangle.h"
+#include <stdlib.h>
+#include <stddef.h>
+#include <string.h>
+
+#include "type_t.h"
+#include "tpop_t.h"
+#include "irprog_t.h"
+#include "typegmod.h"
+#include "array.h"
+#include "irprog_t.h"
+#include "mangle.h"
#include "pset.h"
/* The hash set for types. */
#include "set.h" /* to store tarvals in */
/* #include "tune.h" */ /* some constants */
#include "entity_t.h" /* needed to store pointers to entities */
-#include "irmode.h" /* defines modes etc */
#include "irmode_t.h"
#include "irnode.h" /* defines boolean return values (pnc_number)*/
#include "host.h"
CPPFLAGS += -I$(top_srcdir)/ir/adt -I$(top_srcdir)/ir/common -I$(top_srcdir)/ir/debug \
-I$(top_srcdir)/ir/ident -I$(top_srcdir)/ir/ir -I$(top_srcdir)/ir/tr \
-I$(top_srcdir)/ir/tv -I$(top_srcdir)/ir/st -I$(top_srcdir)/ir/ana \
- -I$(top_srcdir)/ir/opt
+ -I$(top_srcdir)/ir/opt -I$(top_srcdir)/ir/stat
LDFLAGS = -L$(topdir)
LDFLAGS+= @LDFLAGS@
/* build typeinformation of procedure main */
owner = new_type_class (id_from_str ("ARRAY-STACK_EXAMPLE", 19));
- proc_main = new_type_method(id_from_str("main_tp", 4), 0, 1);
+ proc_main = new_type_method(id_from_str("main_tp", 7), 0, 1);
set_method_res_type(proc_main, 0, prim_t_int);
proc_main_e = new_entity (owner, id_from_str ("main", 4), proc_main);
+ get_entity_ld_name(proc_main_e); /* force name mangling */
/* make type information for the array and set the bounds */
# define N_DIMS 1
/* get the pointer to the procedure from the class type */
/* this is how a pointer to be fixed by the linker is represented. */
- proc_ptr = new_SymConst ((type_or_id_p)id_from_str (F_METHODNAME, strlen(F_METHODNAME)),
- linkage_ptr_info);
+ symconst_symbol sym;
+ sym.ident_p = new_id_from_str (F_METHODNAME);
+ proc_ptr = new_SymConst (sym, symconst_addr_name);
/* call procedure set_a, first built array with parameters */
{
owner = new_type_class (id_from_str ("ENDLESS_LOOP_EXAMPLE", 20));
ent = new_entity (owner, id_from_str ("main", strlen("main")), proc_main);
+ get_entity_ld_name(ent); /* force name mangling */
/* Generates start and end blocks and nodes and a first, initial block */
irg = new_ir_graph (ent, 4);
/* There is only one block in main, it contains the allocation and the calls. */
/* Allocate the defined object and generate the type information. */
- obj_size = new_SymConst((type_or_id_p)class_prima, size);
+ symconst_symbol sym = { class_prima };
+ obj_size = new_SymConst(sym, symconst_size);
obj_o = new_Alloc(get_store(), obj_size, class_prima, heap_alloc);
set_store(new_Proj(obj_o, mode_M, 0)); /* make the changed memory visible */
obj_o = new_Proj(obj_o, mode_P, 2); /* remember the pointer to the object */
/* There is only one block in main, it contains the allocation and the calls. */
/* Allocate the defined object and generate the type information. */
- obj_size = new_SymConst((type_or_id_p)class_prima, size);
+ symconst_symbol sym = {class_prima};
+ obj_size = new_SymConst(sym, symconst_size);
obj_o = new_Alloc(get_store(), obj_size, class_prima, heap_alloc);
set_store(new_Proj(obj_o, mode_M, 0)); /* make the changed memory visible */
obj_o = new_Proj(obj_o, mode_P, 2); /* remember the pointer to the object */
owner = new_type_class (id_from_str ("WHILE_EXAMPLE", 13));
ent = new_entity (owner, id_from_str ("main", strlen("main")), proc_main);
+ get_entity_ld_name(ent); /* force name mangling */
/* Generates start and end blocks and nodes and a first, initial block */
irg = new_ir_graph (ent, 4);