27.2.2001 Goetz
- Moved struct from irprog.h to irprog_t.h
+ Moved struct from irprog.h to irprog_t.h, same for irmode.h.
+ Added a module deb_info in debug.h. Adapted makefile. Added example
+ use in iropt.h.
+ Removed use of debug.h in ident.c. Now debug.c|h can be moved to
+ /adt/.
+ Removed inabled code for dead node elimination in irgopt.h.
+ Renamed some missnamed access routines (_of_). Macros with old names
+ are in old_fctnames.h.
+ Edited makefiles to remove #* and *.flc.
+
+ ??.2.2001 Goetz
+ Some minor bugfixes...
25.1.2001 Goetz
After compacting of in arrays in dead_node_elimination
rm -f $(OFILES) $(DFILES)
realclean: clean
- rm -f $(TARGET) *.flc TAGS
+ rm -f $(TARGET) *.flc TAGS \#*
+ rm -rf auto/
-include $(DFILES)
rm -f $(OFILES) $(DFILES)
realclean: clean
- rm -f $(TARGET) *.flc TAGS
+ rm -f $(TARGET) *.flc TAGS \#*
+ rm -rf auto/
-include $(DFILES)
LIBPATH =
LIBS =
X_LIBS =
-INCLUDES = -I../adt -I../common -I../debug
+INCLUDES = -I../adt -I../common -I../debug -I../ir
X_INCLUDES =
AR = ar rcs
MAKE = /usr/bin/make
DISTRIBMEMBERS =
-MEMBERS = $(DISTRIBMEMBERS) debug.m
+MEMBERS = $(DISTRIBMEMBERS) debug.m debinfo.m
CFILES = $(MEMBERS:.m=.c)
rm -f $(OFILES) $(DFILES)
realclean: clean
- rm -f $(TARGET) *.flc TAGS
+ rm -f $(TARGET) *.flc TAGS \#*
+ rm -rf auto/
-include $(DFILES)
--- /dev/null
+/*
+** Copyright (C) 2001 by Universitaet Karlsruhe
+** All rights reserved.
+**
+** Authors: Goetz Lindenmaier
+**
+** debinfo: This is a empty implementation of the Firm interface to
+** debugging support. It only guarantees that the Firm library compiles
+** and runs without any real debugging support.
+** The functions herein are declared weak so that they can be overriden
+** by a real implementation.
+*/
+
+#include "debinfo.h"
+
+
+void deb_info_copy(ir_node *new, ir_node *old, ident *info) {
+}
+
+void deb_info_merge(ir_node **new_nodes, ir_node **old_nodes, ident *info) {
+}
--- /dev/null
+/*
+** Copyright (C) 2001 by Universitaet Karlsruhe
+** All rights reserved.
+**
+** Authors: Goetz Lindenmaier
+**
+** debinfo: This is the Firm interface to debugging support. Firm requires
+** a debugging module fulfilling this interface.
+** The interface requires a datatype representing the debugging information.
+** Firm supports administrating a reference to the debug information
+** in every firm node. Further Firm optimizations call routines to
+** propagate debug information from old nodes to new nodes if the optimization
+** replaces the old ones by the new ones.
+**
+** This file does not belong to the interface of the firm library.
+*/
+# ifndef _DEBINFO_H_
+# define _DEBINFO_H_
+
+#include "irnode.h"
+#include "ident.h"
+
+/* A datastructure containing information for debugging. */
+typedef struct deb_info deb_info;
+/* Every Firm node contains a reference to a deb_info struct. This reference
+ can be accessed by the debug support module by
+ deb_info *get_irn_deb_info(irnode *n);
+ void set_irn_deb_info(irnode *n, deb_info *d);.
+ The module may not touch or change anything else in the Firm data structure.
+*/
+
+/** The following routines are called by firm optmizations. The optimization
+ passes an ident representing a string that describes the optimization
+ performed. **/
+/* deb_info_copy() is called in the following situation:
+ The optimization replaced the old node by the new one. The new node
+ might be a recent allocated node not containing any debug information,
+ or just another node from somewhere in the graph with the same
+ semantics. */
+void deb_info_copy(ir_node *new, ir_node *old, ident *info);
+
+/* deb_info_merge() is called in the following situation:
+ The optimization replaced a subgraph by another subgraph. There is no
+ obviouse mapping between single nodes in both subgraphs. The optimization
+ simply passes two lists to the debug module, one containing the nodes in
+ the old subgraph, the other containing the nodes in the new subgraph. */
+void deb_info_merge(ir_node **new_nodes, ir_node **old_nodes, ident *info);
+
+
+#endif /* _DEBINFO_H_ */
#define _DEBUG_H_
void d_init (int nflags);
-int d_ (int flag, unsigned level);
-int d_level (int flag);
-int d_set_level (int flag, unsigned level);
+int d_ (int flag, unsigned level);
+int d_level (int flag);
+int d_set_level (int flag, unsigned level);
void d_parse (const char *s);
#ifdef DEBUG
rm -f $(OFILES) $(DFILES)
realclean: clean
- rm -f $(TARGET) *.flc TAGS
+ rm -f $(TARGET) *.flc TAGS \#*
+ rm -rf auto/
-include $(DFILES)
/* Identifiers */
typedef const struct set_entry ident;
+/* Stores a string in the ident module and returns a handle for
+ the string. */
inline ident *id_from_str (char *str, int len);
+/* Returns the string represented by id. This string is not Null
+ terminated! */
inline const char *id_to_str (ident *id);
+/* Returns the length of the string represented by id. */
inline int id_to_strlen(ident *id);
# endif /* _IDENT_H_ */
#include <assert.h>
#include <stddef.h>
#include "misc.h"
-#include "debug.h"
#include "set.h"
#include "ident.h"
bool id_is_internal (ident *);
void id_init (void);
-#ifdef NDEBUG
+/* Vormals Debugunterstuetzung, entfernt (debug.h). */
# define ID_VRFY(id) ((void)0)
+
+#ifdef NDEBUG
# define IDS_VRFY(id) ((void)0)
#else
-# define ID_VRFY(id) \
- assert ( (id) \
- && ( !d_ (df_vrfy_level, 1) \
- || (ID_FROM_STR (ID_TO_STR((id)), ID_TO_STRLEN((id))) == (id))))
# define IDS_VRFY(id) ids_vrfy ((id))
void ids_vrfy (ident **id);
#endif
+
#ifdef STATS
# define id_stats() set_stats (id_set)
#else
CFILES = $(MEMBERS:.m=.c)
HFILES = $(MEMBERS:.m=.h)
-HFILES += irnode_t.h irgraph_t.h irop_t.h
+HFILES += irnode_t.h irgraph_t.h ir_prog.h irop_t.h irmode_t.h
HFILES += array.h common.h cookies.h debug.h entity.h gmp.h \
host.h ident.h label.h misc.h obst.h pdeq.h pset.h \
set.h tune.h tv.h type.h xprintf.h xp_help.h irnode2.h
DISTRIB = $(DISTRIBMEMBERS:.m=.h)
+DISTRIB += old_fctnames.h
OFILES = $(MEMBERS:%.m=../objects/%.o)
rm -f $(OFILES) $(DFILES)
realclean: clean
- rm -f $(TARGET) *.flc TAGS
+ rm -f $(TARGET) *.flc TAGS \#*
+ rm -rf auto/
-include $(DFILES)
# include "irgraph_t.h"
# include "irnode_t.h"
+# include "irmode_t.h"
# include "ircons.h"
# include "common.h"
# include "irvrfy.h"
/* Create and initialize array for Phi-node construction. */
res->attr.block.graph_arr = NEW_ARR_D (ir_node *, current_ir_graph->obst,
- current_ir_graph->params);
- memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->params);
+ current_ir_graph->n_loc);
+ memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc);
res = optimize (res);
irn_vrfy (res);
/* Create and initialize array for Phi-node construction. */
res->attr.block.graph_arr = NEW_ARR_D (ir_node *, current_ir_graph->obst,
- current_ir_graph->params);
- memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->params);
+ current_ir_graph->n_loc);
+ memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->n_loc);
/* Immature block may not be optimized! */
irn_vrfy (res);
/** Parameter administration **/
/* Read a value from the array with the local variables. Use this
function to obtain the last definition of the value associated with
- pos. */
+ pos. Pos may not exceed the value passed as n_loc to new_ir_graph. */
ir_node *get_value (int pos, ir_mode *mode);
/* Write a value in the array with the local variables. Use this function
- to remember a new definition of the value associated with pos. */
+ to remember a new definition of the value associated with pos. Pos may
+ not exceed the value passed as n_loc to new_ir_graph. */
void set_value (int pos, ir_node *value);
/* Read a store.
}
/* all others */
} else {
- xfprintf (F, "%I", n->op->name);
+ xfprintf (F, "%I", get_irn_opident(n));
}
}
case iro_Shr:
case iro_Abs:
case iro_Cmp:
- xfprintf (F, "%I", n->mode->name);
+ xfprintf (F, "%I", get_mode_ident(n->mode));
break;
default:
}
xfprintf (F, "%s", id_to_str(get_entity_ident(get_Sel_entity(n))));
/* xdoesn't work for some reason.
- fprintf (F, "\"%I %I\" ", n->op->name, n->attr.s.ent); */
+ fprintf (F, "\"%I %I\" ", get_irn_opident(n), n->attr.s.ent); */
break;
default:
} /* end switch */
switch (n->op->code) { /* node label */
case iro_Start:
- xfprintf (F, "\"%I\" color: blue ", n->op->name);
+ xfprintf (F, "\"%I\" color: blue ", get_irn_opident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_End:
- xfprintf (F, "\"%I\" color: blue ", n->op->name);
+ xfprintf (F, "\"%I\" color: blue ", get_irn_opident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Block:
- xfprintf (F, "\"%I\" color: lightyellow ", n->op->name);
+ xfprintf (F, "\"%I\" color: lightyellow ", get_irn_opident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Phi:
- xfprintf (F, "\"%I%I\" color: green", n->op->name, n->mode->name);
- if (n->mode->code == irm_M)
+ xfprintf (F, "\"%I%I\" color: green", get_irn_opident(n), get_irn_modeident(n));
+ if (get_irn_modecode(n) == irm_M)
xfprintf (F, DEFAULT_NODE_ATTR " color: green");
else
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Const:
- xfprintf (F, "\"%v%I\" color: yellow ", n->attr.con, n->mode->name);
+ xfprintf (F, "\"%v%I\" color: yellow ", n->attr.con, get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Id:
- xfprintf (F, "\"%I%I\" ", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\" ", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Proj:
if (n->in[1]->op->code == iro_Cmp) {
- xfprintf (F, "\"%I%I %s\" color: yellow", n->op->name, n->mode->name,
+ xfprintf (F, "\"%I%I %s\" color: yellow", get_irn_opident(n), get_irn_modeident(n),
get_pnc_string(n->attr.proj));
} else {
- xfprintf (F, "\"%I%I %ld\"", n->op->name, n->mode->name, n->attr.proj);
+ xfprintf (F, "\"%I%I %ld\"", get_irn_opident(n), get_irn_modeident(n), n->attr.proj);
}
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Conv:
- xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Tuple:
- xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Add:
- xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Sub:
- xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Mul:
- xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Quot:
- xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_DivMod:
- xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Div:
- xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Mod:
- xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_And:
- xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Or:
- xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Eor:
- xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Shl:
- xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Shr:
- xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Abs:
- xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Cmp:
- xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Jmp:
- xfprintf (F, "\"%I\"", n->op->name);
+ xfprintf (F, "\"%I\"", get_irn_opident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Cond:
- xfprintf (F, "\"%I\"", n->op->name);
+ xfprintf (F, "\"%I\"", get_irn_opident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Call:
- xfprintf (F, "\"%I\"", n->op->name);
+ xfprintf (F, "\"%I\"", get_irn_opident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Return:
- xfprintf (F, "\"%I\"", n->op->name);
+ xfprintf (F, "\"%I\"", get_irn_opident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Raise:
- xfprintf (F, "\"%I%I\"", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\"", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Load:
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Alloc:
- xfprintf (F, "\"%I\" ", n->op->name);
+ xfprintf (F, "\"%I\" ", get_irn_opident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Sel:
assert(get_kind(get_Sel_entity(n)) == k_entity);
- xfprintf (F, "\"%I ", n->op->name);
+ xfprintf (F, "\"%I ", get_irn_opident(n));
xfprintf (F, "%s", id_to_str(get_entity_ident(get_Sel_entity(n))));
/* xdoesn't work for some reason.
- fprintf (F, "\"%I %I\" ", n->op->name, get_entity_ident(get_Sel_entity(n))); */
+ fprintf (F, "\"%I %I\" ", get_irn_opident(n), get_entity_ident(get_Sel_entity(n))); */
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_SymConst:
xfprintf (F, DEFAULT_NODE_ATTR);
break;
case iro_Sync:
- xfprintf (F, "\"%I\" ", n->op->name);
+ xfprintf (F, "\"%I\" ", get_irn_opident(n));
xfprintf (F, DEFAULT_NODE_ATTR " color: green");
break;
case iro_Bad:
- xfprintf (F, "\"%I%I\" ", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\" ", get_irn_opident(n), get_irn_modeident(n));
xfprintf (F, DEFAULT_NODE_ATTR);
break;
default:
- xfprintf (F, "\"%I%I\" ", n->op->name, n->mode->name);
+ xfprintf (F, "\"%I%I\" ", get_irn_opident(n), get_irn_modeident(n));
}
xfprintf (F, "}\n"); /* footer */
}
# include "irnode.h"
-/* Turns a node into a "useless" Tuple. The Tuple just forms a tuple
+/* Turns a node into a "useless" Tuple. The Tuple node just forms a tuple
from several inputs. The predecessors of the tuple have to be
set by hand.
This is useful if a node returning a tuple is removed, but the Projs
Spare the Bad predecessors of Phi and Block nodes. */
inline void
copy_preds (ir_node *n, void *env) {
- ir_node *nn, *block, *on;
+ ir_node *nn, *block/*, *on*/;
int i, j;
nn = get_new_node(n);
current_ir_graph = rem;
}
-
-
-
-
-
-#if 0 /* An old implementation */
-
-/* To break the recursion of the graph walk if there are loops in
- the graph we have to allocate new nodes for Phis and blocks
- before descending. Here we use the old predecessors for the
- new nodes. These are replaced by the proper predecessors in
- copy_node.
- It turned out that it is not sufficient to just break loops
- for Phi and Block nodes, as the walker can hit visited but
- not copied nodes at any point in the graph.
- A simple fix would be allocating Id's for every node and then
- exchanging them, but this will cause new dead nodes on the new
- obstack.
- So now there is a different implementation more based on the
- view on the graph as a graph than as a represented program. */
-void
-create_dummy (ir_node *n, void *env) {
- assert (n);
-
- /* Assure link is set to NULL so we can test whether there is a
- new node by checking link.
- set_irn_link(n, NULL); */
-
- switch (get_irn_opcode(n)) {
- case iro_Block:
- set_new_node(n, new_ir_node(current_ir_graph, NULL, op_Block, mode_R,
- get_irn_arity(n), get_irn_in(n)));
- break;
- case iro_Phi:
- set_new_node(n, new_ir_node(current_ir_graph, NULL, op_Phi,
- get_irn_mode(n),
- get_irn_arity(n), get_irn_in(n)));
- break;
- default: {}
- } /* end switch (get_irn_opcode(n)) */
-}
-
-/* Create a copy of this node on a new obstack. */
-void
-copy_node2 (ir_node *n, void *env) {
- ir_node *res = NULL;
- ir_node *a = NULL;
- ir_node *b = NULL;
- int i = 0;
-
- assert (n);
- DDMSG2(n);
-
- if (is_binop(n)) {
- a = get_binop_left(n);
- b = get_binop_right(n);
- } else if (is_unop(n)) {
- a = get_unop_op(n);
- }
-
- switch (get_irn_opcode(n)) {
- case iro_Block:
- {
- res = get_new_node(n);
- assert(res);
- for (i = 0; i < get_Block_n_cfgpreds(n); i++)
- set_Block_cfgpred(res, i, get_new_node(get_Block_cfgpred(n, i)));
- set_Block_matured(res, 1);
- }
- break;
- case iro_Start:
- res = new_r_Start (current_ir_graph, get_new_node(get_nodes_Block(n)));
- break;
- case iro_End:
- res = new_r_End (current_ir_graph, get_new_node(get_nodes_Block(n)));
- current_ir_graph -> end = res;
- current_ir_graph -> end_block = get_nodes_Block(res);
- break;
- case iro_Jmp:
- res = new_r_Jmp (current_ir_graph, get_new_node(get_nodes_Block(n)));
- break;
- case iro_Cond:
- res = new_r_Cond (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_Cond_selector(n)));
- break;
- case iro_Return:
- {
- ir_node **in;
- in = get_Return_res_arr(n);
- for (i = 0; i < get_Return_n_res(n); i++)
- set_Return_res(n, i, get_new_node(get_Return_res(n, i)));
- res = new_r_Return (current_ir_graph,
- get_new_node(get_nodes_Block(n)),
- get_new_node(get_Return_mem(n)),
- get_Return_n_res(n), in);
- }
- break;
- case iro_Raise:
- res = new_r_Raise (current_ir_graph,
- get_new_node(get_nodes_Block(n)),
- get_new_node(get_Raise_mem(n)),
- get_new_node(get_Raise_exo_ptr(n)));
- break;
- case iro_Const:
- res = new_r_Const (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_irn_mode(n), get_Const_tarval(n));
- break;
- case iro_SymConst:
- {
- type_or_id_p value = NULL;
-
- if ((get_SymConst_kind(n)==type_tag) || (get_SymConst_kind(n)==size))
- {
-
- value = (type_or_id_p) get_SymConst_type(n);
- }
- else
- {
- if (get_SymConst_kind(n)==linkage_ptr_info)
- {
- value = (type_or_id_p) get_SymConst_ptrinfo(n);
- }
- }
- res = new_r_SymConst (current_ir_graph, get_new_node(get_nodes_Block(n)),
- value, get_SymConst_kind (n));
- }
- break;
- case iro_Sel:
- {
- ir_node **in = get_Sel_index_arr(n);
- for (i = 0; i < get_Sel_n_index(n); i++)
- set_Sel_index(n, i, get_new_node(get_Sel_index(n, i)));
- res = new_r_Sel (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_Sel_mem(n)),
- get_new_node(get_Sel_ptr(n)), get_Sel_n_index(n),
- in, get_Sel_entity(n));
- }
- break;
- case iro_Call:
- {
- ir_node **in;
- in = get_Call_param_arr(n);
-
- for (i = 0; i < get_Call_arity(n); i++)
- set_Call_param(n, i, get_new_node(get_Call_param(n, i)));
- res = new_r_Call (current_ir_graph,
- get_new_node(get_nodes_Block(n)),
- get_new_node(get_Call_mem(n)),
- get_new_node(get_Call_ptr(n)),
- get_Call_arity(n), in,
- get_Call_type (n));
- }
- break;
- case iro_Add:
- res = new_r_Add (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(a), get_new_node(b), get_irn_mode(n));
- break;
- case iro_Sub:
- {
- res = new_r_Sub (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(a), get_new_node(b), get_irn_mode(n));
- }
- break;
- case iro_Minus:
- res = new_r_Minus (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(a), get_irn_mode(n));
- break;
- case iro_Mul:
- res = new_r_Mul (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(a), get_new_node(b), get_irn_mode(n));
- break;
- case iro_Quot:
- res = new_r_Quot (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_Quot_mem(n)), get_new_node(a),
- get_new_node(b));
- break;
- case iro_DivMod:
- res = new_r_DivMod (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_DivMod_mem(n)), get_new_node(a),
- get_new_node(b));
- break;
- case iro_Div:
- res = new_r_Div (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_Div_mem(n)), get_new_node(a),
- get_new_node(b));
- break;
- case iro_Mod:
- res = new_r_Mod (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_Mod_mem(n)), get_new_node(a),
- get_new_node(b));
- break;
- case iro_Abs:
- res = new_r_Abs (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_Abs_op(n)), get_irn_mode(n));
- break;
- case iro_And:
- res = new_r_And (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(a), get_new_node(b), get_irn_mode(n));
- break;
- case iro_Or:
- res = new_r_Or (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(a), get_new_node(b), get_irn_mode(n));
- break;
- case iro_Eor:
- res = new_r_Eor (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(a), get_new_node(b), get_irn_mode(n));
- break;
- case iro_Not:
- res = new_r_Not (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_Not_op(n)), get_irn_mode(n));
- break;
- case iro_Cmp:
- res = new_r_Cmp (current_ir_graph,
- get_new_node(get_nodes_Block(n)),
- get_new_node(get_Cmp_left(n)),
- get_new_node(get_Cmp_right(n)));
- break;
- case iro_Shl:
- res = new_r_Shl (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_Shl_left(n)),
- get_new_node(get_Shl_right(n)), get_irn_mode(n));
- break;
- case iro_Shr:
- res = new_r_Shr (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_Shr_left(n)),
- get_new_node(get_Shr_right(n)), get_irn_mode(n));
- break;
- case iro_Shrs:
- res = new_r_Shrs (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_Shrs_left(n)),
- get_new_node(get_Shrs_right(n)), get_irn_mode(n));
- break;
- case iro_Rot:
- res = new_r_Rot (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_Rot_left(n)),
- get_new_node(get_Rot_right(n)), get_irn_mode(n));
- break;
- case iro_Conv:
- res = new_r_Conv (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_Conv_op(n)),
- get_irn_mode(n));
- break;
- case iro_Phi:
- {
- res = get_new_node(n);
- for (i = 0; i < get_Phi_n_preds(n); i++)
- set_Phi_pred(res, i, get_new_node(get_Phi_pred(n, i)));
- set_nodes_Block(res, get_new_node(get_nodes_Block(n)));
- }
- break;
- case iro_Load:
- res = new_r_Load (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_Load_mem(n)),
- get_new_node(get_Load_ptr(n)));
- break;
- case iro_Store:
- res = new_r_Store (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_Store_mem(n)),
- get_new_node(get_Store_ptr(n)),
- get_new_node(get_Store_value(n)));
- break;
- case iro_Alloc:
- res = new_r_Alloc (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_Alloc_mem(n)),
- get_new_node(get_Alloc_size(n)),
- get_Alloc_type(n), get_Alloc_where(n));
-
- break;
- case iro_Free:
- res = new_r_Free (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_Free_mem(n)),
- get_new_node(get_Free_ptr(n)),
- get_new_node(get_Free_size(n)), get_Free_type(n));
- break;
- case iro_Sync:
- {
- ir_node **in = get_Sync_preds_arr(n);
- for (i = 0; i < get_Sync_n_preds(n); i++)
- set_Sync_pred(n, i, get_new_node(get_Sync_pred(n, i)));
- res = new_r_Sync (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_Sync_n_preds(n), in);
- }
- break;
- case iro_Proj: {
- res = new_r_Proj (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_new_node(get_Proj_pred(n)), get_irn_mode(n),
- get_Proj_proj(n));
- }
- break;
- case iro_Tuple:
- {
- ir_node **in = get_Tuple_preds_arr(n);
- for (i = 0; i < get_Tuple_n_preds(n); i++)
- set_Tuple_pred(n, i, get_new_node(get_Tuple_pred(n, i)));
- res = new_r_Tuple (current_ir_graph, get_new_node(get_nodes_Block(n)),
- get_Tuple_n_preds(n), in);
- }
- break;
- case iro_Id:
- res = get_new_node(get_Id_pred(n));
- break;
- case iro_Bad:
- res = new_r_Bad ();
- break;
- }
- /* @@@ Here we could call optimize()!! Not necessary, called in constructor anyways. */
- set_new_node(n, res);
- printf(" "); DDMSG2(res);
-}
-
-void
-copy_graph2 () {
- ir_node *old_node, *new_node, *projX;
- ir_graph *irg = current_ir_graph;
-
- /*CS*/
- printf("Before starting the DEAD NODE ELIMINATION !\n");
-
- /* Copy nodes remembered in irg fields first.
- The optimization contains tests against these fields, e.g., not
- to optimize the start block away. Therefore these fields have to
- be fixed first.
- Further setting these fields in copy_node would impose additional
- tests for all nodes of a kind.
- Predict the visited flag the walker will use! */
- /* Copy the start Block node. Get the ProjX of the Start node, that is
- predecessor of the start Block. We have to break the cycle and fix it
- later. We use the old in array as placeholder. */
- old_node = irg->start_block;
- new_node = new_r_Block (current_ir_graph, get_Block_n_cfgpreds(old_node),
- get_Block_cfgpred_arr(old_node));
- /* new_r_Block calls no optimization --> save */
- projX = get_Block_cfgpred(old_node, 0);
- irg->start_block = new_node;
- set_new_node (old_node, new_node);
- set_irn_visited (old_node, get_irg_visited(current_ir_graph)+1);
- /* Copy the Start node */
- old_node = irg->start;
- new_node = new_r_Start (current_ir_graph, irg->start_block);
- irg->start = new_node;
- set_new_node (old_node, new_node);
- set_irn_visited (old_node, get_irg_visited(current_ir_graph)+1);
- /* Copy the Bad node */
- old_node = irg->bad;
- new_node = new_ir_node (irg, irg->start_block, op_Bad, mode_T, 0, NULL);
- irg->bad = new_node;
- set_new_node (old_node, new_node);
- set_irn_visited (old_node, get_irg_visited(current_ir_graph)+1);
- /* Copy the Projs for the Start's results. */
- old_node = projX;
- new_node = new_r_Proj (irg, irg->start_block, irg->start, mode_X, pns_initial_exec);
- set_Block_cfgpred(irg->start_block, 0, new_node);
- set_new_node (old_node, new_node);
- set_irn_visited (old_node, get_irg_visited(current_ir_graph)+1);
-
- old_node = irg->frame;
- new_node = new_r_Proj (irg, irg->start_block, irg->start, mode_p, pns_frame_base);
- irg->frame = new_node;
- set_new_node (old_node, new_node);
- set_irn_visited (old_node, get_irg_visited(current_ir_graph)+1);
-
- old_node = irg->globals;
- new_node = new_r_Proj (irg, irg->start_block, irg->start, mode_p, pns_globals);
- irg->globals = new_node;
- set_new_node (old_node, new_node);
- set_irn_visited (old_node, get_irg_visited(current_ir_graph)+1);
-
- old_node = irg->args;
- new_node = new_r_Proj (irg, irg->start_block, irg->start, mode_T, pns_args);
- irg->args = new_node;
- set_new_node (old_node, new_node);
- set_irn_visited (old_node, get_irg_visited(current_ir_graph)+1);
-
- /* Walks the graph once, and at the recursive way do the copy thing.
- all reachable nodes will be copied to a new obstack. */
- irg_walk(irg->end, create_dummy, copy_node2, NULL);
-
- /*CS*/
- printf("After DEAD NODE ELIMINATION !\n");
-}
-#endif
and optimization.
*/
ir_graph *
-new_ir_graph (entity *ent, int params)
+new_ir_graph (entity *ent, int n_loc)
{
ir_graph *res;
ir_node *first_block;
/** Internal information for graph construction either held in the graph or
*** initialized for each graph. **/
- res->params = params + 1; /* number of local variables that are never
+ res->n_loc = n_loc + 1; /* number of local variables that are never
dereferenced in this graph plus one for
the store. This is not the number of parameters
to the procedure! */
}
int
-get_irg_params (ir_graph *irg)
+get_irg_n_loc (ir_graph *irg)
{
- return irg->params;
+ return irg->n_loc;
}
void
-set_irg_params (ir_graph *irg, int params)
+set_irg_n_loc (ir_graph *irg, int n_loc)
{
- irg->params = params;
+ irg->n_loc = n_loc;
}
unsigned long
optimizations. */
extern ir_graph *current_ir_graph;
-/* create a new ir graph. Automatically sets the field irg of
- entity to the new ir graph. */
-ir_graph *new_ir_graph (entity *ent, int params);
-
+/* Create a new ir graph to built ir for a procedure.
+ ent is the entity representing this procedure, i.e., the type of the
+ entity must be type_method. The constructor automatically sets the
+ field irg of the entity to the new ir graph.
+ n_loc is the number of local variables in this procedure including
+ the procedure parameters. */
+ir_graph *new_ir_graph (entity *ent, int n_loc);
/* access routines for all ir_graph attributes */
ir_node *get_irg_start_block (ir_graph *irg);
entity *get_irg_ent (ir_graph *irg);
void set_irg_ent (ir_graph *irg, entity *ent);
-int get_irg_params (ir_graph *irg);
-void set_irg_params (ir_graph *irg, int params);
+/* Use not encouraged, internal of Phi construction algorithm. */
+int get_irg_n_loc (ir_graph *irg);
+void set_irg_n_loc (ir_graph *irg, int n_loc);
/* increments visited by one */
void inc_irg_visited(ir_graph *irg);
#endif
struct ir_node *current_block; /* block for newly gen_*()-erated
ir_nodes */
- int params; /* number of local variable in this
- procedure; should be n_loc or so,
- params is ambiguous. */
+ int n_loc; /* number of local variable in this
+ procedure including procedure parameters. */
pset *value_table; /* value table for global value numbering
for optimizing use in iropt.c */
unsigned long visited; /* this flag is an identifier for
**
*/
-# include "irmode.h"
+# include "irmode_t.h"
# include <malloc.h>
# include <stddef.h>
# include "tv.h"
ir_mode *mode_R;
ir_mode *mode_Z;
-
void
init_mode (void)
{
mode_S->fsigned = 0;
mode_S->ffloat = 0;
+ /* Execution */
mode_X->name = id_from_str ("X", 1);
mode_X->fsigned = 0;
mode_X->ffloat = 0;
+ /* Memory */
mode_M->name = id_from_str ("M", 1);
mode_M->fsigned = 0;
mode_M->ffloat = 0;
mode_Z->name = id_from_str ("Z", 1);
mode_Z->fsigned = 1;
mode_Z->ffloat = 0;
-
}
/* Functions for the direct access to all attributes od a ir_mode */
modecode
-get_modecode_of_mode (ir_mode *mode)
+get_mode_modecode (ir_mode *mode)
{
return mode->code;
}
/*
inline void
-set_modecode_of_mode (ir_mode *mode, modecode code)
+set_mode_modecode (ir_mode *mode, modecode code)
{
mode->code = code;
}
/*
inline void
-set_ident_of_mode (ir_mode *mode, ident *name)
+set_mode_ident (ir_mode *mode, ident *name)
{
mode->name = name;
}
*/
+inline const char *
+get_mode_name (ir_mode *mode) {
+ assert(mode);
+ return id_to_str(mode->name);
+}
+/* void set_mode_name (ir_mode *mode, char *name); */
+
int
-get_size_of_mode (ir_mode *mode)
+get_mode_size (ir_mode *mode)
{
return mode->size;
}
/*
inline void
-set_size_of_mode (ir_mode *mode, int size)
+set_mode_size (ir_mode *mode, int size)
{
mode->size = size;
}
*/
int
-get_ld_align_of_mode (ir_mode *mode)
+get_mode_ld_align (ir_mode *mode)
{
return mode->ld_align;
}
/*
inline void
-set_ld_align_of_mode (ir_mode *mode, int ld_align)
+set_mode_ld_align (ir_mode *mode, int ld_align)
{
mode->ld_align = ld_align;
}
*/
tarval *
-get_min_of_mode (ir_mode *mode)
+get_mode_min (ir_mode *mode)
{
return mode->min;
}
/*
inline void
-set_min_of_mode (ir_mode *mode, struct tarval *min)
+set_mode_min (ir_mode *mode, tarval *min)
{
mode->min = min;
}
*/
tarval *
-get_max_of_mode (ir_mode *mode)
+get_mode_max (ir_mode *mode)
{
return mode->max;
}
/*
inline void
-set_max_of_mode (ir_mode *mode, struct tarval *max)
+set_mode_max (ir_mode *mode, tarval *max)
{
mode->max = max;
}
*/
tarval *
-get_null_of_mode (ir_mode *mode)
+get_mode_null (ir_mode *mode)
{
return mode->null;
}
/*
inline void
-set_null_of_mode (ir_mode *mode, struct tarval *null)
+set_mode_null (ir_mode *mode, tarval *null)
{
mode->null = null;
}
*/
unsigned
-get_fsigned_of_mode (ir_mode *mode)
+get_mode_fsigned (ir_mode *mode)
{
return mode->fsigned;
}
/*
inline voida
-set_fsigned_of_mode (ir_mode *mode, unsigned fsigned)
+set_mode_fsigned (ir_mode *mode, unsigned fsigned)
{
mode->fsigned = fsigned;
}
*/
unsigned
-get_ffloat_of_mode (ir_mode *mode)
+get_mode_ffloat (ir_mode *mode)
{
return mode->ffloat;
}
/*
inline void
-set_ffloat_of_mode (ir_mode *mode, unsigned ffloat)
+set_mode_ffloat (ir_mode *mode, unsigned ffloat)
{
mode->ffloat = ffloat;
}
{
int res;
unsigned fsigned;
- fsigned = get_fsigned_of_mode (mode);
+ fsigned = get_mode_fsigned (mode);
if (fsigned == 1) {
res = 1;
}
{
int res;
unsigned ffloat;
- ffloat = get_ffloat_of_mode (mode);
+ ffloat = get_mode_ffloat (mode);
if (ffloat == 1) {
res = 1;
}
{
int res;
modecode code;
- code = get_modecode_of_mode (mode);
+ code = get_mode_modecode (mode);
if ((code >= irm_c) && (code <= irm_L)) {
res = 1;
}
{
int res;
modecode code;
- code = get_modecode_of_mode (mode);
+ code = get_mode_modecode (mode);
if (mode_is_num (mode) || code == irm_p) {
res = 1;
}
{
int res;
modecode code;
- code = get_modecode_of_mode (mode);
+ code = get_mode_modecode (mode);
if (mode_is_data (mode) || code == irm_b || code == irm_B) {
res = 1;
}
{
int res;
modecode code;
- code = get_modecode_of_mode (mode);
+ code = get_mode_modecode (mode);
if (mode_is_data (mode) || code == irm_M) {
res = 1;
}
# define NUM_MODES 20
+#ifndef _TARVAL_TYPEDEF_
+#define _TARVAL_TYPEDEF_
+typedef struct tarval tarval;
+#endif
+
typedef enum { /* irm is short for `ir mode' */
irm_T, /* former irm_N */
irm_f, irm_d,
irm_max */
} modecode;
-typedef struct {
- modecode code;
- ident *name; /* Name of this mode */
- int size; /* size of the mode in Bytes. */
- int ld_align; /* ld means log2 */
- struct tarval *min; /* largest value to be represented by this mode */
- struct tarval *max; /* smallest value to be represented by this mode */
- struct tarval *null; /* Representation of zero in this mode */
- unsigned fsigned:1; /* signedness of this mode */
- unsigned ffloat:1; /* true if this is a float */
-} ir_mode;
+typedef struct ir_mode ir_mode;
extern ir_mode *mode_T; /* tuple (none) */
extern ir_mode *mode_f; /* signed float */
extern ir_mode *mode_Z; /* infinit integers */ /* oblivious */
extern ir_mode *mode_T; /* tuple (none) */
-void init_mode (void);
-
-modecode get_modecode_of_mode (ir_mode *mode);
-/* void set_modecode_of_mode (ir_mode *mode, modecode code); */
-ident *get_ident_of_mode (ir_mode *mode);
-ident *get_mode_ident (ir_mode *mode);
-
-/* void set_ident_of_mode (ir_mode *mode, ident *name); */
-int get_size_of_mode (ir_mode *mode);
-/* void set_size_of_mode (ir_mode *mode, int size); */
-int get_ld_align_of_mode (ir_mode *mode);
-/* void set_ld_align_of_mode (ir_mode *mode, int ld_align); */
-struct tarval *get_min_of_mode (ir_mode *mode);
-/* void set_min_of_mode (ir_mode *mode, struct tarval *min); */
-struct tarval *get_max_of_mode (ir_mode *mode);
-/* void set_max_of_mode (ir_mode *mode, struct tarval *max); */
-struct tarval *get_null_of_mode (ir_mode *mode);
-/* void set_null_of_mode (ir_mode *mode, struct tarval *null); */
-unsigned get_fsigned_of_mode (ir_mode *mode);
-/* void set_fsigned_of_mode (ir_mode *mode, unsigned fsigned); */
-unsigned get_ffloat_of_mode (ir_mode *mode);
-/* void set_ffloat_of_mode (ir_mode *mode, unsigned ffloat); */
+/* An enum for this mode */
+modecode get_mode_modecode (ir_mode *mode);
+/* void set_mode_modecode (ir_mode *mode, modecode code); */
+
+/* The ident of this mode */
+ident *get_mode_ident (ir_mode *mode);
+/* void set_mode_ident (ir_mode *mode, ident *id); */
+
+/* The name of this mode */
+const char *get_mode_name (ir_mode *mode);
+/* void set_mode_name (ir_mode *mode, char *name); */
+
+/* The size of values of the mode in bytes. */
+int get_mode_size (ir_mode *mode);
+/* void set_mode_size (ir_mode *mode, int size); */
+
+/* The alignment of values of the mode. */
+int get_mode_ld_align (ir_mode *mode);
+/* void set_mode_ld_align (ir_mode *mode, int ld_align); */
+
+/* The smallest representable value */
+tarval *get_mode_min (ir_mode *mode);
+/* void set_mode_min (ir_mode *mode, tarval *min); */
+
+/* The biggest representable value */
+tarval *get_mode_max (ir_mode *mode);
+/* void set_mode_max (ir_mode *mode, tarval *max); */
+
+/* The value Zero represented in this mode */
+tarval *get_mode_null (ir_mode *mode);
+/* void set_mode_null (ir_mode *mode, tarval *null); */
+
+/* Returns 1 if mode is signed, else 0. */
+unsigned get_mode_fsigned (ir_mode *mode);
+/* void set_mode_fsigned (ir_mode *mode, unsigned fsigned); */
+
+/* Returns 1 if mode is float, else 0. */
+unsigned get_mode_ffloat (ir_mode *mode);
+/* void set_mode_ffloat (ir_mode *mode, unsigned ffloat); */
+
+/* Test for a certain class of modes. */
int mode_is_signed (ir_mode *mode);
int mode_is_float (ir_mode *mode);
int mode_is_int (ir_mode *mode);
--- /dev/null
+
+# ifndef _IRMODE_T_H_
+# define _IRMODE_T_H_
+
+# include "irmode.h"
+
+struct ir_mode {
+ modecode code;
+ ident *name; /* Name of this mode */
+ int size; /* size of the mode in Bytes. */
+ int ld_align; /* ld means log2 */
+ tarval *min; /* largest value to be represented by this mode */
+ tarval *max; /* smallest value to be represented by this mode */
+ tarval *null; /* Representation of zero in this mode */
+ unsigned fsigned:1; /* signedness of this mode */
+ unsigned ffloat:1; /* true if this is a float */
+};
+
+
+void init_mode (void);
+
+#endif
#include "irnode_t.h"
#include "irgraph_t.h"
#include "ident_t.h"
+#include "irmode_t.h"
#include "array.h"
#ifdef DEBUG_libfirm
inline ident *
-get_irn_modename (ir_node *node)
+get_irn_modeident (ir_node *node)
{
assert(node);
return node->mode->name;
/* Get the mode-enum modecode */
inline modecode get_irn_modecode (ir_node *node);
/* Get the ident for a string representation of the mode */
-inline ident *get_irn_modename (ir_node *node);
+inline ident *get_irn_modeident (ir_node *node);
/* Access the opcode struct of the node */
inline ir_op *get_irn_op (ir_node *node);
inline void set_irn_op (ir_node *node, ir_op *op);
op_Bad = new_ir_op (iro_Bad, id_from_str ("Bad", 3), 0, 0);
}
-/* returns the attribute size of the operator. */
+/* Returns the string for the opcode. */
+const char *get_op_name (ir_op *op) {
+ return id_to_str(op->name);
+}
opcode get_op_code (ir_op *op){
return op->code;
}
-ident *get_op_name(ir_op *op){
+ident *get_op_ident(ir_op *op){
return op->name;
}
+/* returns the attribute size of the operator. */
int get_op_attr_size (ir_op *op) {
return op->attr_size;
}
/* Returns the string for the opcode. */
+const char *get_op_name (ir_op *op);
-opcode get_op_code (ir_op *op);
-ident *get_op_name(ir_op *op);
-int get_op_attr_size (ir_op *op);
+/* Returns the enum for the opcode */
+opcode get_op_code (ir_op *op);
+/* Returns the ident for the opcode name */
+ident *get_op_ident (ir_op *op);
+
+/* Returns the attribute size of the opcode.
+ Use not encouraged, internal feature. */
+int get_op_attr_size (ir_op *op);
# endif /* _IROP_H_ */
# include "irvrfy.h"
# include "tv.h"
# include "tune.h"
-
+# include "debinfo.h"
/* Make types visible to allow most efficient access */
# include "entity_t.h"
tv = computed_value (n);
if (tv != NULL) {
/* evaluation was succesful -- replace the node. */
- return new_Const (get_tv_mode (tv), tv);
+ n = new_Const (get_tv_mode (tv), tv);
+ deb_info_copy(n, old_n, id_from_str("const_eval", 10));
+ return n;
/* xprintf("* optimize: computed node %I\n", n->op->name);*/
}
}
** irprog.c: ir representation of a program
*/
-# include "irprog.h"
+# include "irprog_t.h"
# include "array.h"
# include "obst.h"
# include "irnode.h"
# include "type.h"
-struct ir_prog {
- firm_kind kind;
- ir_graph *main_irg; /* entry point to the compiled program */
- /* or a list, in case we compile a library or the like? */
- ir_graph **graphs; /* all graphs in the ir */
- type_class *glob_type; /* global type. Class as it can have
- fields and procedures. Does this work?
- Better name??? @@@ */
- type **types; /* all types in the ir */
- /*struct obstack *obst; * @@@ Should we place all types and
- entities on an obstack, too? */
-#ifdef DEBUG_libfirm
- long max_node_nr; /* to generate unique numbers for nodes. */
-#endif
-};
typedef struct ir_prog ir_prog;
--- /dev/null
+
+# ifndef _IRPROG_T_H_
+# define _IRPROG_T_H_
+
+#include "irprog.h"
+
+struct ir_prog {
+ firm_kind kind;
+ ir_graph *main_irg; /* entry point to the compiled program */
+ /* or a list, in case we compile a library or the like? */
+ ir_graph **graphs; /* all graphs in the ir */
+ type_class *glob_type; /* global type. Class as it can have
+ fields and procedures. Does this work?
+ Better name??? @@@ */
+ type **types; /* all types in the ir */
+ /*struct obstack *obst; * @@@ Should we place all types and
+ entities on an obstack, too? */
+#ifdef DEBUG_libfirm
+ long max_node_nr; /* to generate unique numbers for nodes. */
+#endif
+};
+
+#endif /* ifndef _IRPROG_T_H_ */
--- /dev/null
+
+/* Copyright (C) 2001 by Universitaet Karlsruhe
+** All rights reserved.
+**
+** Authors: Goetz Lindenmaier
+**
+** Some makros supporting old function names.
+*/
+
+
+/* irgraph */
+#define get_irg_params get_irg_n_loc
+#define set_irg_params set_irg_n_loc
+
+
+/* irmode.h */
+#define get_ident_of_mode get_mode_ident
+#define get_size_of_mode get_mode_size
+#define get_ld_align_of_mode get_mode_ld_align
+#define get_min_of_mode get_mode_min
+#define get_max_of_mode get_mode_max
+#define get_null_of_mode get_mode_null
+#define get_fsigned_of_mode get_mode_fsigned
+#define get_ffloat_of_mode get_mode_ffloat
+
+
+
+#define
+#define
rm -f $(OFILES) $(DFILES)
realclean: clean
- rm -f $(TARGET) *.flc TAGS
+ rm -f $(TARGET) *.flc TAGS \#*
+ rm -rf auto/
-include $(DFILES)
void init_mangle (void);
+/* Computes a definite name for this entity by concatenating
+ the name of the owner type and the name of the entity with
+ a separating "_". f*/
ident *mangle_entity (entity *ent);
-ident *mangle_type (type *type);
+
+/* Sorry, I'm not sure what this does... */
+ident *mangle_type (type *type);
# define _TYPE_OR_ENTITY_H_
typedef union {
- type *typ;
+ type *typ;
entity *ent;
} type_or_ent;
rm -f $(OFILES) $(DFILES)
realclean: clean
- rm -f $(TARGET) *.flc TAGS
+ rm -f $(TARGET) *.flc TAGS \#*
+ rm -rf auto/
-include $(DFILES)
#include "tune.h"
#include "ident_t.h"
#include "tv_t.h"
-
-# include "entity_t.h"
+#include "entity_t.h"
+#include "irmode.h"
static struct obstack tv_obst; /* obstack for all the target values */
static pset *tarvals; /* pset containing pointers to _all_ tarvals */
static inline bool
chil_overflow (tarval_chil chil, ir_mode *mode)
{
- assert (is_chilCHIL(mode->code));
- return (mode->min && mode->max /* only valid after firm initialization */
- && (chil < tv_val_chil (mode->min) || tv_val_chil (mode->max) < chil));
+ assert (is_chilCHIL(get_mode_modecode(mode)));
+ return (get_mode_min(mode) && get_mode_max(mode) /* only valid after firm initialization */
+ && (chil < tv_val_chil (get_mode_min(mode))
+ || tv_val_chil (get_mode_max(mode)) < chil));
}
static inline bool
CHIL_overflow (tarval_CHIL CHIL, ir_mode *mode)
{
- assert (is_chilCHIL(mode->code));
- return (mode->max /* only valid after firm initialization */
- && tv_val_CHIL (mode->max) < CHIL);
+ assert (is_chilCHIL(get_mode_modecode(mode)));
+ return (get_mode_max(mode) /* only valid after firm initialization */
+ && tv_val_CHIL (get_mode_max(mode)) < CHIL);
}
_tarval_vrfy (const tarval *val)
{
assert (val);
- switch (val->mode->code) {
+ switch (get_mode_modecode(val->mode)) {
/* floating */
case irm_f:
case irm_d:
TARVAL_VRFY (b);
if (a == b) return 0;
- if (a->mode - b->mode) return a->mode - b->mode;
+ if ((void *)a->mode - (void *)b->mode)
+ return (void *)a->mode - (void *)b->mode;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f:
return memcmp (&a->u.f, &b->u.f, sizeof (a->u.f));
{
unsigned h;
- h = tv->mode->code * 0x421u;
- switch (tv->mode->code) {
+ h = get_mode_modecode(tv->mode) * 0x421u;
+ switch (get_mode_modecode(tv->mode)) {
case irm_T:
h = 0x94b527ce; break;
case irm_f:
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = m;
- switch (m->code) {
+ switch (get_mode_modecode(m)) {
/* floating */
case irm_f:
tv->u.f = val; break;
p = (unsigned char *)tv + sizeof (tarval);
tv->mode = m;
- switch (m->code) {
+ switch (get_mode_modecode(m)) {
case irm_C:
tv->u.CHIL = ch;
break;
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = m;
- switch (src->mode->code) {
+ switch (get_mode_modecode(src->mode)) {
case irm_d:
if (m != mode_f) goto fail;
break;
case irm_Z:
- switch (m->code) {
+ switch (get_mode_modecode(m)) {
case irm_C: case irm_H: case irm_I: case irm_L:
if (mpz_cmp_si (&src->u.Z, 0) < 0) goto fail;
break;
case irm_c: case irm_h: case irm_i: case irm_l:
- switch (m->code) {
+ switch (get_mode_modecode(m)) {
case irm_c: case irm_h: case irm_i: case irm_l:
tv->u.chil = src->u.chil;
if (chil_overflow (tv->u.chil, m)) goto fail;
}
case irm_C: case irm_H: case irm_I: case irm_L:
- switch (m->code) {
+ switch (get_mode_modecode(m)) {
case irm_c: case irm_h: case irm_i: case irm_l:
tv->u.chil = src->u.CHIL;
if (chil_overflow (tv->u.chil, m)) goto fail;
break;
case irm_b:
- switch (m->code) {
+ switch (get_mode_modecode(m)) {
case irm_c: case irm_h: case irm_i: case irm_l:
tv->u.chil = src->u.b;
break;
tv->mode = a->mode;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f: tv->u.f = -a->u.f; break;
case irm_d: tv->u.d = -a->u.d; break;
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
- tv->u.CHIL = -a->u.CHIL & tv_val_CHIL (a->mode->max);
+ tv->u.CHIL = -a->u.CHIL & tv_val_CHIL (get_mode_max(a->mode));
break;
/* signed */
case irm_c: case irm_h: case irm_i: case irm_l:
assert (a->mode == b->mode);
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f: return ( a->u.f == b->u.f ? irpn_Eq
: a->u.f > b->u.f ? irpn_Gt
tv->mode = a->mode;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f: tv->u.f = a->u.f + b->u.f; break; /* @@@ overflow etc */
case irm_d: tv->u.d = a->u.d + b->u.d; break; /* @@@ dto. */
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
- tv->u.CHIL = (a->u.CHIL + b->u.CHIL) & tv_val_CHIL (a->mode->max);
+ tv->u.CHIL = (a->u.CHIL + b->u.CHIL) & tv_val_CHIL (get_mode_max(a->mode));
break;
/* signed */
case irm_c: case irm_h: case irm_i: case irm_l:
tv->mode = a->mode;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f: tv->u.f = a->u.f - b->u.f; break; /* @@@ overflow etc */
case irm_d: tv->u.d = a->u.d - b->u.d; break; /* @@@ dto. */
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
- tv->u.CHIL = (a->u.CHIL - b->u.CHIL) & tv_val_CHIL (a->mode->max);
+ tv->u.CHIL = (a->u.CHIL - b->u.CHIL) & tv_val_CHIL (get_mode_max(a->mode));
break;
/* signed */
case irm_c: case irm_h: case irm_i: case irm_l:
tv->mode = a->mode;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f: tv->u.f = a->u.f * b->u.f; break; /* @@@ overflow etc */
case irm_d: tv->u.d = a->u.d * b->u.d; break; /* @@@ dto. */
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
- tv->u.CHIL = (a->u.CHIL * b->u.CHIL) & tv_val_CHIL (a->mode->max);
+ tv->u.CHIL = (a->u.CHIL * b->u.CHIL) & tv_val_CHIL (get_mode_max(a->mode));
break;
/* signed */
case irm_c: case irm_h: case irm_i: case irm_l:
TARVAL_VRFY (a); TARVAL_VRFY (b);
assert (a->mode == b->mode);
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f:
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = a->mode;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f: tv->u.f = floor (a->u.f / b->u.f); break; /* @@@ overflow etc */
case irm_d: tv->u.d = floor (a->u.d / b->u.d); break; /* @@@ dto. */
/* signed */
case irm_c: case irm_h: case irm_i: case irm_l:
if ( !b->u.chil
- || ((b->u.chil == -1) && (a->u.chil == tv_val_chil (a->mode->max) ))) {
+ || ((b->u.chil == -1) && (a->u.chil == tv_val_chil (get_mode_max(a->mode)) ))) {
fail:
obstack_free (&tv_obst, tv);
return NULL;
tv->mode = a->mode;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* floating */
case irm_f: tv->u.f = fmod (a->u.f, b->u.f); break; /* @@@ overflow etc */
case irm_d: tv->u.d = fmod (a->u.d, b->u.d); break; /* @@@ dto */
tv->mode = a->mode;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
tv->u.CHIL = a->u.CHIL & b->u.CHIL; break;
tv->mode = a->mode;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
tv->u.CHIL = a->u.CHIL | b->u.CHIL; break;
tv->mode = a->mode;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
tv->u.CHIL = a->u.CHIL ^ b->u.CHIL; break;
shift = tarval_ord (b, &b_is_huge);
if ( b_is_huge
|| (shift < 0)
- || ((shift >= mode_l->size*target_bits) && (a->mode != mode_Z))) {
+ || ((shift >= get_mode_size(mode_l)*target_bits) && (a->mode != mode_Z))) {
return NULL;
}
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = a->mode;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
tv->u.CHIL = a->u.CHIL << shift;
shift = tarval_ord (b, &b_is_huge);
if ( b_is_huge
|| (shift < 0)
- || ((shift >= mode_l->size*target_bits) && (a->mode != mode_Z))) {
+ || ((shift >= get_mode_size(mode_l)*target_bits) && (a->mode != mode_Z))) {
return NULL;
}
tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval));
tv->mode = a->mode;
- switch (a->mode->code) {
+ switch (get_mode_modecode(a->mode)) {
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
tv->u.CHIL = a->u.CHIL >> shift;
TARVAL_VRFY (tv);
- switch (tv->mode->code) {
+ switch (get_mode_modecode(tv->mode)) {
/* floating */
case irm_f: case irm_d:
return 2;
/* unsigned */
case irm_C:
- return (long)((tv->u.CHIL+1) & tv_val_CHIL (mode_C->max)) - 1;
+ return (long)((tv->u.CHIL+1) & tv_val_CHIL (get_mode_max(mode_C))) - 1;
case irm_H:
- return (long)((tv->u.CHIL+1) & tv_val_CHIL (mode_H->max)) - 1;
+ return (long)((tv->u.CHIL+1) & tv_val_CHIL (get_mode_max(mode_H))) - 1;
case irm_I:
- return (long)((tv->u.CHIL+1) & tv_val_CHIL (mode_I->max)) - 1;
+ return (long)((tv->u.CHIL+1) & tv_val_CHIL (get_mode_max(mode_I))) - 1;
case irm_L:
- return (long)((tv->u.CHIL+1) & tv_val_CHIL (mode_L->max)) - 1;
+ return (long)((tv->u.CHIL+1) & tv_val_CHIL (get_mode_max(mode_L))) - 1;
/* signed */
case irm_c: case irm_h: case irm_i: case irm_l:
return tv->u.chil;
{
TARVAL_VRFY (tv);
- switch (tv->mode->code) {
+ switch (get_mode_modecode(tv->mode)) {
/* unsigned */
case irm_C: case irm_H: case irm_I: case irm_L:
- *fail = tv->u.CHIL > tv_val_CHIL (mode_l->max);
+ *fail = tv->u.CHIL > tv_val_CHIL (get_mode_max(mode_l));
return tv->u.CHIL;
/* signed */
case irm_c: case irm_h: case irm_i: case irm_l:
*fail = 0;
return tv->u.chil;
case irm_Z:
- *fail = ( (mpz_cmp_si (&tv->u.Z, tv_val_chil(mode_l->max)) > 0)
- || (mpz_cmp_si (&tv->u.Z, tv_val_chil(mode_l->min)) < 0));
+ *fail = ( (mpz_cmp_si (&tv->u.Z, tv_val_chil(get_mode_max(mode_l))) > 0)
+ || (mpz_cmp_si (&tv->u.Z, tv_val_chil(get_mode_max(mode_l))) < 0));
return mpz_get_si (&tv->u.Z);
/* strange */
case irm_b:
TARVAL_VRFY (val);
- switch (val->mode->code) {
+ switch (get_mode_modecode(val->mode)) {
case irm_T: /* none */
printed = XPSR ("<bad>");
# include "entity.h"
# include "bool.h"
+#ifndef _TARVAL_TYPEDEF_
+#define _TARVAL_TYPEDEF_
typedef struct tarval tarval;
+#endif
/* #include <gmp.h> Eli can't find gmp.h if it's available in a local
search path but not in a standard one known to gcc. */
/* #include "deftab.h" */
/* how to represent target types on host */
-typedef float tarval_f;
+typedef float tarval_f;
typedef double tarval_d;
-typedef long tarval_chil;
+typedef long tarval_chil;
typedef unsigned long tarval_CHIL;
typedef MP_INT tarval_Z;
typedef struct {
tarval_CHIL tv_val_CHIL (tarval *tv);
tarval_Z tv_val_Z (tarval *tv);
tarval_p tv_val_p (tarval *tv);
-bool tv_val_b (tarval *tv);
+bool tv_val_b (tarval *tv);
tarval_B tv_val_B (tarval *tv);
tarval_s tv_val_s (tarval *tv);
*.o *.vcg core
realclean: clean
+ rm -f \#* *.flc
+ rm -rf auto/
run:
./empty; \
if (! (elt_type->kind == k_type_primitive)) printf(" do something else\n");
elt_type_mode = get_primitive_mode(elt_type);
/* better: read bounds out of array type information */
- size = (U_BOUND - L_BOUND + 1) * elt_type_mode->size;
+ size = (U_BOUND - L_BOUND + 1) * get_mode_size(elt_type_mode);
/* make constant representing the size */
arr_size = new_Const(mode_I, tarval_from_long (mode_I, size));
/* allocate and generate the Proj nodes. */
printf("Optimizing ...\n");
//dead_node_elimination(irg);
+ local_optimize_graph(irg);
/* verify the graph */
irg_vrfy(irg);