+ 15.8.2000 Goetz until 3.9.00
+ Separated irnode.h and many others into two files: one public
+ one private.
+ Added funcionality to extract headers for lib.
+
23.8.2000 Goetz
type_dump also dumps irg->ent
if_example: corrected nr of locals
testprograms:
$(MAKE) -C testprograms
-lib:
+lib: ir
$(MAKE) -C ir lib
clean:
realclean:
for i in $(SUBDIRS); do $(MAKE) -C $$i realclean; done
- rm -f libfirm.a core include/*
+ rm -f libfirm.a core include/*.h
TAGFILES = $(shell find . -name '*.c' -o -name '*.h')
CFILES += xfprintf.c xfprintf.c xfprintf.c
HFILES = $(MEMBERS:.m=.h)
-HFILES += tune.h xp_help.h xprintf.h misc.h
+HFILES += tune.h xp_help.h xprintf.h misc.h bool.h
HFILES += common.h debug.h entity.h gmp.h host.h ident.h irgraph.h \
irmode.h irnode.h irop.h irprog.h label.h misc.h obst.h \
pset.h set.h tv.h type.h xprintf.h xp_help.h
DISTRIB = $(DISTRIBMEMBERS:.m=.h)
+DISTRIB += bool.h
OFILES = $(MEMBERS:%.m=../objects/%.o)
OFILES += ../objects/xfprintf.o \
--- /dev/null
+/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
+** All rights reserved.
+**
+** Authors: Goetz Lindenmaier.
+**
+** bool.h: Datatype bool.
+**
+*/
+
+# ifndef _BOOL_H_
+# define _BOOL_H_
+
+
+typedef unsigned char bool;
+
+# endif /* _BOOL_H_ */
# ifndef _COMMON_H_
# define _COMMON_H_
+// GL# include <assert.h>
+
/** Global flags. Set these by autoconf?? **/
/* There are two implementations of the Phi node construction. The first
*/
# include <stdio.h>
-# include "ident.h"
+# include "ident_t.h"
# include "firm.h"
# include "mangle.h"
# include "xp_help.h"
# include "irnode_t.h"
+# include "tv_t.h"
void
init_firm (void)
# define _FIRM_H_
/* The representations */
-# include "irprog.h"
-# include "type.h"
-# include "entity.h"
+# include "irprog.h" /* control flow and data of a program */
+# include "type.h" /* type representation */
+# include "entity.h" /* entity representation */
+# include "tv.h" /* target values */
+# include "ident.h" /* source code identificators */
/* Functionality */
-# include "ircons.h"
-# include "irgopt.h"
-
-/* */
-# include "xprintf.h"
-
+# include "ircons.h" /* construct ir */
+# include "irgopt.h" /* optimize ir */
/* initialize firm */
void init_firm (void);
Copyright (C) 1995, 1996 Markus Armbruster
All rights reserved. */
-#ifndef _MISC_H
-#define _MISC_H
-
+#ifndef _MISC_H_
+#define _MISC_H_
/* Declare alloca() */
#include "host.h"
-
+#include "bool.h"
/* Alignment of nodes, cf common/tag.h, a power of two.
#define IS_POW2(n) ((((n)-1) & (n)) == 0)
-typedef unsigned char bool;
typedef int (*cmp_fun) (const void *, const void *);
# define XMALLOC_TRACE
#endif
-#endif
+#endif /* _MISC_H_ */
$(TARGET): $(DFILES) $(OFILES)
lib:
- cp $(DISTRIB) ../../include/
+# cp $(DISTRIB) ../../include/
clean:
rm -f $(OFILES) $(DFILES)
CFILES = $(MEMBERS:.m=.c)
HFILES = $(MEMBERS:.m=.h)
+HFILES += ident_t.h
HFILES += array.h cookies.h debug.h host.h misc.h set.h tune.h xprintf.h \
xp_help.h
.DEFAULT: $(TARGET)
.SILENT: $(DFILES) clean # hides output
+$(TARGET): $(DFILES) $(OFILES)
+
%.d: %.c
$(SHELL) -ec '$(CXX) $(DEPENDFLAGS) $(INCLUDES) $(X_INCLUDES) $< | sed '\''s/\($*\)\.o[ :]*/\.\.\/objects\/\1.o $@ : /g'\'' > $@'
lib:
cp $(DISTRIB) ../../include
-$(TARGET): $(DFILES) $(OFILES)
-
clean:
rm -f $(OFILES) $(DFILES)
#include <string.h>
#include "array.h"
#include "tune.h"
-#include "ident.h"
+#include "ident_t.h"
#include "xprintf.h"
#define XX_USER(name) ident *id_##name;
#undef XX_USER
#undef XX_INTERNAL
}
+
+
+#if 1
+inline ident *id_from_str (char *str, int len) {
+ assert (len > 0);
+ return (const set_entry *)set_hinsert (id_set, (str), (len), ID_HASH ((str), (len)));
+}
+
+inline const char *id_to_str (ident *id) {
+ return ((const char *)&(id)->dptr[0]);
+}
+
+inline int id_to_strlen(ident *id) {
+ return ((id)->size);
+}
+
+#endif
# ifndef _IDENT_H_
# define _IDENT_H_
-#include <assert.h>
-#include <stddef.h>
-#include "misc.h"
-#include "debug.h"
-#include "set.h"
-
-# include "xprintf.h"
-# include "xp_help.h"
+# include "assert.h"
/* Identifiers */
typedef const struct set_entry ident;
-/* Caution: strings _not_ zero-terminated! */
-#define ID_FROM_STR(str, len) \
- (assert ((len) > 0), \
- (const set_entry *)set_hinsert (id_set, (str), (len), ID_HASH ((str), (len))))
-#define ID_TO_STR(id) ((const char *)&(id)->dptr[0])
-#define ID_TO_STRLEN(id) ((id)->size)
-#define ID_TO_HASH(id) ((long)(id) + (id)->hash)
-
-ident *new_id_derived (const char *pfx, ident *);
-ident *new_id_internal (void);
-bool id_is_internal (ident *);
-void id_init (void);
-
-#ifdef NDEBUG
-# define ID_VRFY(id) ((void)0)
-# 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
-# define id_stats() ((void)0)
-#endif
-
-/* Private */
-
-/* @@@ tune */
-#define ID_HASH(str, len) \
- ((( ((unsigned char *)(str))[0] * 33 \
- + ((unsigned char *)(str))[(len)>>1]) * 31 \
- + ((unsigned char *)(str))[(len)-1]) * 9 \
- + (len))
-
-extern set *id_set;
-
-
-# define id_from_str ID_FROM_STR
-# define id_to_str ID_TO_STR
-# define id_to_strlen ID_TO_STRLEN
-
-
-int ident_print (XP_PAR1, const xprintf_info *, XP_PARN);
+inline ident *id_from_str (char *str, int len);
+inline const char *id_to_str (ident *id);
+inline int id_to_strlen(ident *id);
# endif /* _IDENT_H_ */
--- /dev/null
+/* Declarations for ident.
+ Copyright (C) 1995, 1996 Markus Armbruster */
+
+/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
+** All rights reserved.
+**
+** Authors: Martin Trapp, Christian Schaefer
+*/
+
+# ifndef _IDENT_T_H_
+# define _IDENT_T_H_
+
+#include <assert.h>
+#include <stddef.h>
+#include "misc.h"
+#include "debug.h"
+#include "set.h"
+#include "ident.h"
+
+# include "xprintf.h"
+# include "xp_help.h"
+
+/* Caution: strings _not_ zero-terminated! */
+#define ID_FROM_STR(str, len) \
+ (assert ((len) > 0), \
+ (const set_entry *)set_hinsert (id_set, (str), (len), ID_HASH ((str), (len))))
+#define ID_TO_STR(id) ((const char *)&(id)->dptr[0])
+#define ID_TO_STRLEN(id) ((id)->size)
+#define ID_TO_HASH(id) ((long)(id) + (id)->hash)
+
+ident *new_id_derived (const char *pfx, ident *);
+ident *new_id_internal (void);
+bool id_is_internal (ident *);
+void id_init (void);
+
+#ifdef NDEBUG
+# define ID_VRFY(id) ((void)0)
+# 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
+# define id_stats() ((void)0)
+#endif
+
+/* Private */
+
+/* @@@ tune */
+#define ID_HASH(str, len) \
+ ((( ((unsigned char *)(str))[0] * 33 \
+ + ((unsigned char *)(str))[(len)>>1]) * 31 \
+ + ((unsigned char *)(str))[(len)-1]) * 9 \
+ + (len))
+
+extern set *id_set;
+
+#if 0
+# define id_from_str ID_FROM_STR
+# define id_to_str ID_TO_STR
+# define id_to_strlen ID_TO_STRLEN
+#endif
+
+int ident_print (XP_PAR1, const xprintf_info *, XP_PARN);
+
+# endif /* _IDENT_T_H_ */
SHELL = /bin/sh
MAKE = /usr/bin/make
-DISTRIBMEMBERS = ircons.m irdump.m irflag.m irgmod.m irgraph.m irgopt.m \
+DISTRIBMEMBERS = ircons.m irdump.m irflag.m irgmod.m irgraph.m irgopt.m \
irgwalk.m irmode.m irnode.m irop.m iropt.m irprog.m irvrfy.m
MEMBERS = $(DISTRIBMEMBERS)
CFILES = $(MEMBERS:.m=.c)
HFILES = $(MEMBERS:.m=.h)
+HFILES += irnode_t.h irgraph_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
** by Goetz Lindenmaier
*/
+# include "irgraph_t.h"
+# include "irnode_t.h"
# include "ircons.h"
# include "common.h"
# include "irvrfy.h"
# include "array.h"
/* memset belongs to string.h */
# include "string.h"
-# include "irnode_t.h"
#if USE_EXPICIT_PHI_IN_STACK
/* A stack needed for the automatic Phi node construction in constructor
- Phi_in. */
+ Phi_in. Redefinition in irgraph.c!! */
struct Phi_in_stack {
ir_node **stack;
int pos;
};
+typedef struct Phi_in_stack Phi_in_stack;
#endif
/*********************************************** */
/** privat interfaces, for professional use only */
/* Constructs a Block with a fixed number of predecessors.
- Does not set current_block. */
-
+ Does not set current_block. Can not be used with automatic
+ Phi node construction. */
inline ir_node *
new_r_Block (ir_graph *irg, int arity, ir_node **in)
{
res = new_ir_node (irg, NULL, op_Block, mode_R, arity, in);
set_Block_matured(res, 1);
+ set_Block_block_visited(res, 0);
irn_vrfy (res);
return res;
return res;
}
+#if 0
+/* Constructs a Block with a fixed number of predecessors.
+ Does set current_block. Can be used with automatic Phi
+ node construction. */
ir_node *
-new_Block (void)
+new_Block (int arity, ir_node **in)
{
ir_node *res;
- res = new_ir_node (current_ir_graph, NULL, op_Block, mode_R, -1, NULL);
+ res = new_r_Block (arity, in);
current_ir_graph->current_block = res;
- res->attr.block.matured = 0;
- set_Block_block_visited(res, 0);
- /* forget this optimization. use this only if mature !!!!
- res = optimize (res); */
- irn_vrfy (res);
-
- /** create a new dynamic array, which stores all parameters in irnodes */
- /** using the same obstack as the whole irgraph */
+ /* 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);
-
- /** initialize the parameter array */
memset(res->attr.block.graph_arr, 0, sizeof(ir_node *)*current_ir_graph->params);
+ res = optimize (res);
+ irn_vrfy (res);
+
return res;
}
+#else
+ir_node *
+new_Block (void)
+{
+ return new_immBlock();
+}
+#endif
/*************************************************************************/
/* Methods necessary for automatic Phi node creation */
/*************************************************************************/
/* Comfortable interface with automatic Phi node construction. */
/* (Uses also constructors of ?? interface, except new_Block. */
-/* add an adge to a jmp node */
+/*************************************************************************/
+
+/** Block construction **/
+/* immature Block without predecessors */
+ir_node *new_immBlock (void) {
+ ir_node *res;
+
+ /* creates a new dynamic in-array as length of in is -1 */
+ res = new_ir_node (current_ir_graph, NULL, op_Block, mode_R, -1, NULL);
+ current_ir_graph->current_block = res;
+ res->attr.block.matured = 0;
+ set_Block_block_visited(res, 0);
+
+ /* 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);
+
+ /* Immature block may not be optimized! */
+ irn_vrfy (res);
+
+ return res;
+}
+
+/* add an adge to a jmp/control flow node */
void
add_in_edge (ir_node *block, ir_node *jmp)
{
# include "entity.h"
# include "tv.h"
# include "type.h"
-# include "pdeq.h"
-
-#if USE_EXPICIT_PHI_IN_STACK
-/* A stack needed for the automatic Phi node construction in constructor
- Phi_in. */
-typedef struct Phi_in_stack Phi_in_stack;
-#endif
/***************************************************************************/
/* The raw interface */
+/***************************************************************************/
+/* Constructs a Block with a fixed number of predecessors.
+ Does not set current_block. Can not be used with automatic
+ Phi node construction. */
ir_node *new_r_Block (ir_graph *irg, int arity, ir_node **in);
ir_node *new_r_Start (ir_graph *irg, ir_node *block);
ir_node *new_r_End (ir_graph *irg, ir_node *block);
/*************************************************************************/
/* The block oriented interface */
+/*************************************************************************/
/* Sets the current block in which the following constructors place the
nodes they construct. */
and add a new one so dass das dann so aussieht:
passe die Beispeilprogramme an! */
#if 0
+/* Constructs a Block with a fixed number of predecessors.
+ Does set current_block. Can be used with automatic Phi
+ node construction. */
ir_node *new_Block(int arity, ir_node **in); /* creates mature Block */
#else
ir_node *new_Block (void);
/* Supports automatic Phi node construction. */
/* All routines of the block oriented interface except new_Block are */
/* needed also. */
+/***********************************************************************/
/** Block construction **/
/* immature Block without predecessors */
void add_in_edge (ir_node *immblock, ir_node *jmp);
/* fixes the number of predecessors of a block. */
-void mature_block (ir_node *block);
+void mature_block (ir_node *block);
/** Parameter administration **/
/* Read a value from the array with the local variables. Use this
/* Write a store. */
void set_store (ir_node *store);
-/* This function is for internal use only. It is visible as it is needed
- in irgraph.c to create the stack that is needed for automatic Phi
- construction. */
-#if USE_EXPICIT_PHI_IN_STACK
-Phi_in_stack *new_Phi_in_stack();
-#endif
-
-/**************************************************************************/
-/* initialize ir construction */
+/***********************************************************************/
+/* initialize ir construction */
+/***********************************************************************/
void init_cons (void);
** irdump.h: dumping of an intermediate representation graph
*/
-# include <assert.h>
-# include "irdump.h"
# include "irnode_t.h"
+# include "irgraph_t.h"
+# include "irdump.h"
# include "panic.h"
# include <string.h>
# include "entity.h"
void dump_type_graph (ir_graph *irg);
/* dumps a graph and the type inforamtion. */
- void dump_ir_graph_w_types (ir_graph *irg);
+void dump_ir_graph_w_types (ir_graph *irg);
# endif /* _IRDUMP_H_ */
*/
# include "irnode_t.h"
+# include "irgraph_t.h"
# include "irgmod.h"
# include "array.h"
# include "irnode.h"
-
/* Turns a node into a "useless" Tuple. The Tuple just forms a tuple
from several inputs. The tuples predecessors have to be
set by hand.
** Optimizations for a whole ir graph, i.e., a procedure.
*/
+# include <assert.h>
+
# include "irgopt.h"
# include "irnode_t.h"
+# include "irgraph_t.h"
# include "iropt.h"
# include "irgwalk.h"
-# include "irgraph.h"
# include "ircons.h"
+# include "misc.h"
/********************************************************************/
/* apply optimizations of iropt to all nodes. */
*/
# include "ircons.h"
-# include "irgraph.h"
+# include "irgraph_t.h"
# include "irprog.h"
-# include "iropt.h"
+# include "iropt_t.h"
# include "array.h"
# include "irgmod.h"
ir_graph *current_ir_graph;
+#if USE_EXPICIT_PHI_IN_STACK
+/* really defined in ircons.c */
+typedef struct Phi_in_stack Phi_in_stack;
+Phi_in_stack *new_Phi_in_stack();
+#endif
+
/* Allocates a list of nodes:
- The start block containing a start node and Proj nodes for it's four
results (X, M, P, Tuple).
# ifndef _IRGRAPH_H_
# define _IRGRAPH_H_
-
-# include "obst.h"
# include "tv.h"
-# include "pset.h"
/* to resolve recursion between irnode.h and irgraph.h */
#ifndef _IR_NODE_TYPEDEF_
typedef struct ir_node ir_node;
#endif
-/* ir_graph holds all information for a procedure */
-struct ir_graph {
- struct entity *ent; /* The entity of this procedure, i.e.,
- the type of the procedure and the
- class it belongs to. */
- struct ir_node *start_block; /* block the start node will belong to */
- struct ir_node *start; /* start node of this ir_graph */
- struct ir_node *end_block; /* block the end node will belong to */
- struct ir_node *end; /* end node of this ir_graph */
- struct ir_node *cstore; /* constant store -- no more needed!! */
- struct ir_node *frame; /* method's frame */
- struct ir_node *globals; /* pointer to the data segment containing all
- globals as well as global procedures. */
- struct ir_node *args; /* methods arguments */
- struct ir_node *bad; /* bad node of this ir_graph, the one and
- only in this graph */
- struct obstack *obst; /* obstack where all of the ir_nodes live */
-#if USE_EXPICIT_PHI_IN_STACK
- struct Phi_in_stack *Phi_in_stack; /* needed for automatic Phi construction */
-#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. */
- pset *value_table; /* value table for global value numbering
- for optimizing use in iropt.c */
- unsigned long visited; /* this flag is an identifier for
- ir walk. it will be incremented,
- every time, someone walk through
- the graph */
- unsigned long block_visited; /* same as visited, for a
- complete block */
-};
-
/* to resolve recursion between entity.h and irgraph.h */
#ifndef _IR_GRAPH_TYPEDEF_
#define _IR_GRAPH_TYPEDEF_
ir_node *get_irg_start (ir_graph *irg);
void set_irg_start (ir_graph *irg, ir_node *node);
-ir_node *get_start_of_irgraph (ir_graph *irg);
-void set_start_of_irgraph(ir_graph *irg, ir_node *node);
-
ir_node *get_irg_end_block (ir_graph *irg);
void set_irg_end_block (ir_graph *irg, ir_node *node);
ir_node *get_irg_bad (ir_graph *irg);
void set_irg_bad (ir_graph *irg, ir_node *node);
-/* not implemented yet
-struct obstack *get_obst_of_irgraph (ir_graph *irg);
-void set_obst_of_irgraph (ir_graph *irg, struct obstack *obst);
-*/
-
ir_node *get_irg_current_block (ir_graph *irg);
void set_irg_current_block (ir_graph *irg, ir_node *node);
unsigned long get_irg_block_visited (ir_graph *irg);
void set_irg_block_visited(ir_graph *irg, unsigned long i);
-int get_params_of_irgraph (ir_graph *irg);
-void set_params_of_irgraph (ir_graph *irg, int params);
-
# endif /* _IRGRAPH_H_ */
--- /dev/null
+/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
+** All rights reserved.
+**
+** Authors: Martin Trapp, Christian Schaefer
+**
+** irgraph.h: ir graph construction
+*/
+
+# ifndef _IRGRAPH_T_H_
+# define _IRGRAPH_T_H_
+# include "obst.h"
+# include "pset.h"
+# include "irgraph.h"
+
+/* ir_graph holds all information for a procedure */
+struct ir_graph {
+ struct entity *ent; /* The entity of this procedure, i.e.,
+ the type of the procedure and the
+ class it belongs to. */
+ struct ir_node *start_block; /* block the start node will belong to */
+ struct ir_node *start; /* start node of this ir_graph */
+ struct ir_node *end_block; /* block the end node will belong to */
+ struct ir_node *end; /* end node of this ir_graph */
+ struct ir_node *cstore; /* constant store -- no more needed!! */
+ struct ir_node *frame; /* method's frame */
+ struct ir_node *globals; /* pointer to the data segment containing all
+ globals as well as global procedures. */
+ struct ir_node *args; /* methods arguments */
+ struct ir_node *bad; /* bad node of this ir_graph, the one and
+ only in this graph */
+ struct obstack *obst; /* obstack where all of the ir_nodes live */
+#if USE_EXPICIT_PHI_IN_STACK
+ struct Phi_in_stack *Phi_in_stack; /* needed for automatic Phi construction */
+#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. */
+ pset *value_table; /* value table for global value numbering
+ for optimizing use in iropt.c */
+ unsigned long visited; /* this flag is an identifier for
+ ir walk. it will be incremented,
+ every time, someone walk through
+ the graph */
+ unsigned long block_visited; /* same as visited, for a
+ complete block */
+};
+# endif /* _IRGRAPH_T_H_ */
*/
#include "irnode_t.h"
+#include "irgraph_t.h"
+#include "ident_t.h"
#include "array.h"
#ifdef DEBUG_libfirm
#define DDMSG printf("%s(l.%i)\n", __FUNCTION__, __LINE__)
#define DDMSG1(X) printf("%s(l.%i) %s\n", __FUNCTION__, __LINE__, \
- ID_TO_STR(get_irn_opname(X)))
+ id_to_str(get_irn_opname(X)))
#define DDMSG2(X) printf("%s(l.%i) %s: %ld\n", __FUNCTION__, __LINE__, \
- ID_TO_STR(get_irn_opname(X)), get_irn_node_nr(X))
+ id_to_str(get_irn_opname(X)), get_irn_node_nr(X))
#endif
# define _IRNODE_T_H_
# include "irnode.h"
+# include "xprintf.h"
/** ir node attributes **/
/* Block attributes */
# include "irop.h"
# include "irnode_t.h"
+# include "misc.h"
ir_op *op_Block;
# ifndef _IROP_H_
# define _IROP_H_
+# include <stddef.h>
# include "ident.h"
typedef enum {
extern ir_op *op_Cond;
extern ir_op *op_Return;
extern ir_op *op_Raise;
-
extern ir_op *op_Sel;
extern ir_op *op_Const;
*/
# include "irnode_t.h"
-# include "iropt.h"
+# include "irgraph_t.h"
+# include "iropt_t.h"
# include "ircons.h"
# include "irgmod.h"
# include "irvrfy.h"
# include "irnode.h"
# include "irgraph.h"
# include "irflag.h"
-# include "pset.h"
# include "tune.h"
/* optimize_in_place (n) may change the contents of the ir_node itself,
tarval *computed_value (ir_node *n);
-pset *new_identities (void);
-void del_identities (pset *value_table);
-
ir_node *optimize (ir_node *n);
ir_node *optimize_in_place (ir_node *n);
--- /dev/null
+/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
+** All rights reserved.
+**
+** Authors: Martin Trapp, Christian Schaefer
+**
+** Declarations for optimizations intertwined with IR construction.
+*/
+
+# ifndef _IROPT_T_H_
+# define _IROPT_T_H_
+
+# include "pset.h"
+# include "iropt.h"
+
+pset *new_identities (void);
+void del_identities (pset *value_table);
+
+# endif /* _IROPT_T_H_ */
# include "irprog.h"
# include "array.h"
+# include "obst.h"
#define GLOBAL_TYPE_NAME "GlobalType"
# include "irnode.h"
# include "type.h"
-/*# include "obst.h"*/
struct ir_prog {
firm_kind kind;
**
*/
+# include "irgraph_t.h"
# include "irvrfy.h"
# include "irgwalk.h"
mymode = get_irn_mode (n);
in = get_irn_in (n);
-// IR_OP_VRFY (opcode);
-// IR_MODE_VRFY (mymode);
-
switch (opcode) {
case iro_Start:
.DEFAULT: $(TARGET)
.SILENT: $(DFILES) clean # hides output
+$(TARGET): $(DFILES) $(OFILES)
+
%.d: %.c
$(SHELL) -ec '$(CXX) $(DEPENDFLAGS) $(INCLUDES) $(X_INCLUDES) $< | sed '\''s/\($*\)\.o[ :]*/\.\.\/objects\/\1.o $@ : /g'\'' > $@'
lib:
cp $(DISTRIB) ../../include
-
-$(TARGET): $(DFILES) $(OFILES)
-
clean:
rm -f $(OFILES) $(DFILES)
# ifndef _ENTITY_T_H_
# define _ENTITY_T_H_
-# include "ident.h"
-# include "type.h"
+# include "entity.h"
#ifndef _IR_GRAPH_TYPEDEF_
#define _IR_GRAPH_TYPEDEF_
# include "obst.h"
# include "entity.h"
# include <stdlib.h>
+# include "ident_t.h"
/* Make types visible to allow most efficient access */
# include "entity_t.h"
}
/* manipulate fields of type_class */
-char *
+const char *
get_class_name (type_class *class) {
assert(class);
- return ID_TO_STR(class->name);
+ return id_to_str(class->name);
}
/* field: ident */
/* manipulate fields of type_class */
-char *get_class_name (type_class *class);
+const char *get_class_name (type_class *class);
ident *get_class_ident (type_class *class);
/* Not necessary now!
** - execute the post function after recursion
*/
+#include "stdio.h"
#include "irgwalk.h"
#include "irgraph.h"
#include "irnode.h"
type_env->env = env;
++type_visited;
- irg_walk(irg->end, start_type_walk, NULL, type_env);
+ irg_walk(get_irg_end(irg), start_type_walk, NULL, type_env);
type_walk_2((type_or_ent *)get_irg_ent(irg), pre, post, env);
CFILES = $(MEMBERS:.m=.c)
HFILES = $(MEMBERS:.m=.h)
+HFILES += tv_t.h
HFILES += ieee754.h
HFILES += common.h debug.h entity.h gmp.h ident.h irmode.h obst.h \
.DEFAULT: $(TARGET)
.SILENT: $(DFILES) clean # hides output
+$(TARGET): $(DFILES) $(OFILES)
+
%.d: %.c
$(SHELL) -ec '$(CXX) $(DEPENDFLAGS) $(INCLUDES) $(X_INCLUDES) $< | sed '\''s/$*\\.o[ :]*/& $@/g'\'' > $@'
lib:
cp $(DISTRIB) ../../include
-$(TARGET): $(DFILES) $(OFILES)
-
clean:
rm -f $(OFILES) $(DFILES)
# include <config.h>
#endif
+# include "xprintf.h"
#include <assert.h>
#include <limits.h>
#include <math.h>
#include "obst.h"
#include "ieee754.h"
#include "tune.h"
-#include "ident.h"
-#include "tv.h"
+#include "ident_t.h"
+#include "tv_t.h"
# include "entity_t.h"
# include "irmode.h"
# include "entity.h"
-# include "xprintf.h"
+# include "bool.h"
typedef struct tarval tarval;
long tarval_classify (tarval *);
long tarval_ord (tarval *, int *fail);
-int tarval_print (XP_PAR1, const xprintf_info *, XP_PARN);
+/* moved to tv_t.h
+ int tarval_print (XP_PAR1, const xprintf_info *, XP_PARN); */
/* return a mode-specific value */
--- /dev/null
+/* Declarations for Target Values.
+ Copyright (C) 1995, 1996 Christian von Roques */
+
+#ifndef _TV_T_H
+#define _TV_T_H
+
+# include "tv.h"
+# include "misc.h"
+
+int tarval_print (XP_PAR1, const xprintf_info *, XP_PARN);
+
+
+#endif
-
DIRS = adt common debug ident ir tr tv
-INCDIRS = $(DIRS:%=-I../ir/%) -I../ir/include
+INCDIRS = -I../include
LIBDIRS=-L.. -L/usr/public/lib/gmp/
LIBS=-lfirm -lgmp -lm
%.o: %.c
gcc -c $(INCDIRS) -g $<
-orb:
- ls
-
all: empty const_eval_example \
if_example if_else_example if_while_example cond_example \
call_str_example memory_example array-stack_example \
x = new_Return (get_store (), 1, in);
}
- mature_block (main_irg->current_block);
+ mature_block (get_irg_current_block(main_irg));
/* complete the end_block */
- add_in_edge (main_irg->end_block, x);
- mature_block (main_irg->end_block);
+ add_in_edge (get_irg_end_block(main_irg), x);
+ mature_block (get_irg_end_block(main_irg));
printf("Optimizing ...\n");
dead_node_elimination(main_irg);
/* Now the "real" program: */
/* Select the array from the stack frame. */
- array_ptr = new_simpleSel(get_store(), main_irg->frame, array_ent);
+ array_ptr = new_simpleSel(get_store(), get_irg_frame(main_irg), array_ent);
/* Load element 3 of the array. For this first generate the pointer
to this the element by a select node. (Alternative: increase
array pointer by (three * elt_size), but this complicates some
x = new_Return (get_store (), 1, in);
}
- mature_block (main_irg->current_block);
+ mature_block (get_irg_current_block(main_irg));
/* complete the end_block */
- add_in_edge (main_irg->end_block, x);
- mature_block (main_irg->end_block);
+ add_in_edge (get_irg_end_block(main_irg), x);
+ mature_block (get_irg_end_block(main_irg));
printf("Optimizing ...\n");
dead_node_elimination(main_irg);
/* this is how a pointer to be fixed by the linker is represented after
lowering a Sel node. */
#define FUNCTIONNAME "f"
- proc_ptr = new_SymConst ((type_or_id_p)ID_FROM_STR (FUNCTIONNAME, strlen(FUNCTIONNAME)),
+ proc_ptr = new_SymConst ((type_or_id_p)id_from_str (FUNCTIONNAME, strlen(FUNCTIONNAME)),
linkage_ptr_info);
/* call procedure set_a, first built array with parameters */
}
/* Now we generated all instructions for this block and all its predecessor blocks
* so we can mature it. */
- mature_block (irg->current_block);
+ mature_block (get_irg_current_block(irg));
/* This adds the in edge of the end block which originates at the return statement.
* The return node passes controlflow to the end block. */
- add_in_edge (irg->end_block, x);
+ add_in_edge (get_irg_end_block(irg), x);
/* Now we can mature the end block as all it's predecessors are known. */
- mature_block (irg->end_block);
+ mature_block (get_irg_end_block(irg));
printf("Optimizing ...\n");
dead_node_elimination(irg);
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
/* get the first argument a of method main - see irgraph.h */
- arg1 = new_Proj(irg->args, mode_i, 0);
+ arg1 = new_Proj(get_irg_args(irg), mode_i, 0);
/* arg1 as first first local variable - makes things simple */
set_value(0, arg1);
f = new_Proj (x, mode_X, 0); /* if condition is false */
t = new_Proj (x, mode_X, 1); /* if condition is true */
- mature_block (irg->current_block);
+ mature_block (get_irg_current_block(irg));
/* generate and fill the then block */
b = new_Block ();
}
/* Now generate all instructions for this block and all its predecessor blocks
* so we can mature it. */
- mature_block (irg->current_block);
+ mature_block (get_irg_current_block(irg));
/* This adds the in edge of the end block which originates at the
return statement. The return node passes controlflow to the end block.*/
- add_in_edge (irg->end_block, x);
+ add_in_edge (get_irg_end_block(irg), x);
/* Now we can mature the end block as all it's predecessors are known. */
- mature_block (irg->end_block);
+ mature_block (get_irg_end_block(irg));
printf("Optimizing ...\n");
dead_node_elimination(irg);
b = new_Const (mode_i, tarval_from_long (mode_i, 5));
x = new_Jmp ();
- mature_block (irg->current_block);
+ mature_block (get_irg_current_block(irg));
/* To test const eval on DivMod
c = new_DivMod(get_store(), a, b);
x = new_Return (get_store (), 2, in);
}
- add_in_edge (irg->end_block, x);
- mature_block (irg->end_block);
+ add_in_edge (get_irg_end_block(irg), x);
+ mature_block (get_irg_end_block(irg));
printf("Optimizing ...\n");
dead_node_elimination(irg);
cond = new_Cond(new_Proj(new_Cmp(c1, c2), mode_b, Eq));
f = new_Proj(cond, mode_X, 0);
t = new_Proj(cond, mode_X, 1);
- mature_block(irg->current_block);
+ mature_block(get_irg_current_block(irg));
/* end block to add jmps */
endBlock = new_Block();
get_store();
x = new_Return (get_store(), 1, in);
}
- mature_block (irg->current_block);
+ mature_block (get_irg_current_block(irg));
- add_in_edge (irg->end_block, x);
- mature_block (irg->end_block);
+ add_in_edge (get_irg_end_block(irg), x);
+ mature_block (get_irg_end_block(irg));
printf("Optimizing ...\n");
local_optimize_graph (irg);
}
/* Now generate all instructions for this block and all its predecessor blocks
* so we can mature it. */
- mature_block (irg->current_block);
+ mature_block (get_irg_current_block(irg));
/* This adds the in edge of the end block which originates at the return statement.
* The return node passes controlflow to the end block. */
- add_in_edge (irg->end_block, x);
+ add_in_edge (get_irg_end_block(irg), x);
/* Now we can mature the end block as all it's predecessors are known. */
- mature_block (irg->end_block);
+ mature_block (get_irg_end_block(irg));
/* verify the graph */
irg_vrfy(irg);
}
/* Now generate all instructions for this block and all its predecessor blocks
* so we can mature it. */
- mature_block (irg->current_block);
+ mature_block (get_irg_current_block(irg));
/* This adds the in edge of the end block which originates at the return statement.
* The return node passes controlflow to the end block. */
- add_in_edge (irg->end_block, x);
+ add_in_edge (get_irg_end_block(irg), x);
/* Now we can mature the end block as all it's predecessors are known. */
- mature_block (irg->end_block);
+ mature_block (get_irg_end_block(irg));
printf("Optimizing ...\n");
dead_node_elimination(irg);
f = new_Proj (x, mode_X, 0); /* if condition is false */
t = new_Proj (x, mode_X, 1); /* if condition is true */
- mature_block (irg->current_block);
+ mature_block (get_irg_current_block(irg));
/* generate and fill the then block */
b = new_Block ();
}
/* Now generate all instructions for this block and all its predecessor
blocks so we can mature it. */
- mature_block (irg->current_block);
+ mature_block (get_irg_current_block(irg));
/* This adds the in edge of the end block which originates at the
return statement. The return node passes control flow to the
end block. */
- add_in_edge (irg->end_block, x);
+ add_in_edge (get_irg_end_block(irg), x);
/* Now we can mature the end block as all it's predecessors are known. */
- mature_block (irg->end_block);
+ mature_block (get_irg_end_block(irg));
printf("Optimizing ...\n");
dead_node_elimination(irg);
type_primitive *typ;
ir_node *x, *r, *t, *f, *a, *cmp;
int a_pos, b_pos;
- FILE *outfile;
printf("\nCreating an IR graph: IF_EXAMPLE...\n");
(type *)proc_main);
#define RES_NAME "int"
- typ = new_type_primitive(ID_FROM_STR(RES_NAME, strlen(RES_NAME)), mode_i);
+ typ = new_type_primitive(id_from_str(RES_NAME, strlen(RES_NAME)), mode_i);
set_method_param_type(proc_main, 0, (type*)typ);
set_method_res_type(proc_main, 0, (type*)typ);
set_value (a_pos, new_Proj (get_irg_args(irg), mode_i, 0));
/*set_value (a_pos, new_Const (mode_i, tarval_from_long (mode_i, 0)));*/
set_value (b_pos, new_Const (mode_i, tarval_from_long (mode_i, 2)));
- mature_block (irg->current_block);
+ mature_block (get_irg_current_block(irg));
/* Generate a conditional branch */
cmp = new_Cmp(get_value(a_pos, mode_i), get_value(b_pos, mode_i));
}
/* finalize the end block generated in new_ir_graph() */
- add_in_edge (irg->end_block, x);
- mature_block (irg->end_block);
+ add_in_edge (get_irg_end_block(irg), x);
+ mature_block (get_irg_end_block(irg));
printf("Optimizing ...\n");
/* Generate two constants */
set_value (0, new_Const (mode_I, tarval_from_long (mode_i, 0)));
set_value (1, new_Const (mode_I, tarval_from_long (mode_i, 1)));
- mature_block (irg->current_block);
+ mature_block (get_irg_current_block(irg));
/* Generate a conditional branch */
x = new_Cond (new_Proj(new_Cmp(new_Const (mode_I, tarval_from_long (mode_i, 0)),
}
/* finalize the end block generated in new_ir_graph() */
- add_in_edge (irg->end_block, x);
- mature_block (irg->end_block);
+ add_in_edge (get_irg_end_block(irg), x);
+ mature_block (get_irg_end_block(irg));
printf("Optimizing ...\n");
dead_node_elimination(irg);
cond = new_Cond(new_Proj(new_Cmp(expr, c1), mode_b, Eq));
f = new_Proj(cond, mode_X, 0);
t = new_Proj(cond, mode_X, 1);
- mature_block(irg->current_block);
+ mature_block(get_irg_current_block(irg));
new_Block();
- add_in_edge(irg->current_block, t);
+ add_in_edge(get_irg_current_block(irg), t);
jmp = new_Jmp();
- mature_block(irg->current_block);
+ mature_block(get_irg_current_block(irg));
new_Block();
- add_in_edge(irg->current_block, f);
+ add_in_edge(get_irg_current_block(irg), f);
cond = new_Cond(new_Proj(new_Cmp(expr, c2), mode_b, Eq));
f = new_Proj(cond, mode_X, 0);
t = new_Proj(cond, mode_X, 1);
- mature_block(irg->current_block);
+ mature_block(get_irg_current_block(irg));
new_Block();
- add_in_edge(irg->current_block, t);
- add_in_edge(irg->current_block, jmp);
+ add_in_edge(get_irg_current_block(irg), t);
+ add_in_edge(get_irg_current_block(irg), jmp);
jmp = new_Jmp();
- mature_block(irg->current_block);
+ mature_block(get_irg_current_block(irg));
new_Block();
- add_in_edge(irg->current_block, f);
+ add_in_edge(get_irg_current_block(irg), f);
t = new_Jmp();
- mature_block(irg->current_block);
+ mature_block(get_irg_current_block(irg));
new_Block();
- add_in_edge(irg->current_block, t);
- add_in_edge(irg->current_block, jmp);
+ add_in_edge(get_irg_current_block(irg), t);
+ add_in_edge(get_irg_current_block(irg), jmp);
{
ir_node *in[0]; /* this is the array containing the return parameters */
x = new_Return (get_store(), 0, in);
}
- mature_block (irg->current_block);
+ mature_block (get_irg_current_block(irg));
- add_in_edge (irg->end_block, x);
- mature_block (irg->end_block);
+ add_in_edge (get_irg_end_block(irg), x);
+ mature_block (get_irg_end_block(irg));
printf("Optimizing ...\n");
dead_node_elimination(irg);
cond = new_Cond(new_Proj(new_Cmp(expr, c1), mode_b, Eq));
f = new_Proj(cond, mode_X, 0);
t = new_Proj(cond, mode_X, 1);
- mature_block(irg->current_block);
+ mature_block(get_irg_current_block(irg));
loopBlock1 = new_Block();
add_in_edge(loopBlock1, t);
mature_block(loopBlock2);
new_Block();
- add_in_edge(irg->current_block, f_l2);
- add_in_edge(irg->current_block, f_l1);
+ add_in_edge(get_irg_current_block(irg), f_l2);
+ add_in_edge(get_irg_current_block(irg), f_l1);
{
ir_node *in[0];
x = new_Return (get_store(), 0, in);
}
- mature_block (irg->current_block);
+ mature_block (get_irg_current_block(irg));
- add_in_edge (irg->end_block, x);
- mature_block (irg->end_block);
+ add_in_edge (get_irg_end_block(irg), x);
+ mature_block (get_irg_end_block(irg));
printf("Optimizing ...\n");
dead_node_elimination(irg);
/* finish this first block */
x = new_Jmp ();
- mature_block (irg->current_block);
+ mature_block (get_irg_current_block(irg));
/* a loop body */
r = new_Block ();
x = new_Return (new_Proj(x, mode_M, 0), 1, in);
}
mature_block (r);
- add_in_edge (irg->end_block, x);
- mature_block (irg->end_block);
+ add_in_edge (get_irg_end_block(irg), x);
+ mature_block (get_irg_end_block(irg));
printf("Optimizing ...\n");
dead_node_elimination(irg);
x = new_Return (get_store (), 1, in);
}
- mature_block (main_irg->current_block);
+ mature_block (get_irg_current_block(main_irg));
/* complete the end_block */
- add_in_edge (main_irg->end_block, x);
- mature_block (main_irg->end_block);
+ add_in_edge (get_irg_end_block(main_irg), x);
+ mature_block (get_irg_end_block(main_irg));
irg_vrfy(main_irg);
set_a_irg = new_ir_graph (proc_set_e, 4);
/* get the procedure parameter */
- self = new_Proj(set_a_irg->args, mode_p, 0);
- par1 = new_Proj(set_a_irg->args, mode_I, 1);
+ self = new_Proj(get_irg_args(set_a_irg), mode_p, 0);
+ par1 = new_Proj(get_irg_args(set_a_irg), mode_I, 1);
/* Create and select the entity to set */
class_langint = new_type_class(id_from_str ("Int", 3));
a_e = new_entity((type *)class_prima, id_from_str ("a", 1),
/* return nothing */
x = new_Return (get_store (), 0, NULL);
- mature_block (set_a_irg->current_block);
+ mature_block (get_irg_current_block(set_a_irg));
/* complete the end_block */
- add_in_edge (set_a_irg->end_block, x);
- mature_block (set_a_irg->end_block);
+ add_in_edge (get_irg_end_block(set_a_irg), x);
+ mature_block (get_irg_end_block(set_a_irg));
irg_vrfy(set_a_irg);
c_irg = new_ir_graph (proc_c_e, 4);
/* get the procedure parameter */
- self = new_Proj(c_irg->args, mode_p, 0);
- par1 = new_Proj(c_irg->args, mode_I, 1);
+ self = new_Proj(get_irg_args(c_irg), mode_p, 0);
+ par1 = new_Proj(get_irg_args(c_irg), mode_I, 1);
/* Select the entity and load the value */
a_ptr = new_simpleSel(get_store(), self, a_e);
x = new_Return (get_store (), 1, in);
}
- mature_block (c_irg->current_block);
+ mature_block (get_irg_current_block(c_irg));
/* complete the end_block */
- add_in_edge (c_irg->end_block, x);
- mature_block (c_irg->end_block);
+ add_in_edge (get_irg_end_block(c_irg), x);
+ mature_block (get_irg_end_block(c_irg));
/* verify the graph */
irg_vrfy(main_irg);
printf("Optimizing ...\n");
- /*
for (i = 0; i < get_irp_n_irgs(); i++)
dead_node_elimination(get_irp_irg(i));
- */
- dead_node_elimination(main_irg );
- dead_node_elimination(c_irg );
- dead_node_elimination(set_a_irg);
/****************************************************************************/
set_value(0, new_Const (mode_i, tarval_from_long (mode_i, 6)));
f = new_Proj(cond, mode_X, 0);
t = new_Proj(cond, mode_X, 1);
- mature_block(irg->current_block);
+ mature_block(get_irg_current_block(irg));
/* end block to add jmps */
endBlock = new_Block();
cond = new_Cond(new_Proj(new_Cmp(c1, get_value(1, mode_i)), mode_b, Eq));
f = new_Proj(cond, mode_X, 0);
t = new_Proj(cond, mode_X, 1);
- mature_block(irg->current_block);
+ mature_block(get_irg_current_block(irg));
/* Block 2 */
Block2 = new_Block();
in[0] = get_value(0, mode_i);
x = new_Return (get_store(), 1, in);
}
- mature_block (irg->current_block);
+ mature_block (get_irg_current_block(irg));
/* finish the Block with the end node */
- add_in_edge (irg->end_block, x);
- mature_block (irg->end_block);
+ add_in_edge (get_irg_end_block(irg), x);
+ mature_block (get_irg_end_block(irg));
printf("Optimizing ...\n");
dead_node_elimination(irg);