Commit 6d36abf3 authored by Götz Lindenmaier's avatar Götz Lindenmaier
Browse files

*** empty log message ***

[r61]
parent b5e930bc
23.8.2000 Goetz
type_dump also dumps irg->ent
if_example: corrected nr of locals
16.8.2000 Goetz
irgopt: Correct copy of self pointer in start block.
irgopt: Correct treatment of loops: pre function in walker
......
......@@ -10,6 +10,8 @@
# ifndef _COMMON_H_
# define _COMMON_H_
/** Global flags. Set these by autoconf?? **/
/* There are two implementations of the Phi node construction. The first
is faster, but does not work for blocks with more than 2 predecessors.
The second works always but is slower and causes more unnecessary Phi
......@@ -23,6 +25,10 @@
as a stack! */
#define USE_EXPICIT_PHI_IN_STACK 1
/* If this is defined debuging aids are created, e.g. a field in
ir_node uniquely numbering the nodes. */
#define DEBUG_libfirm 1
/* a list of firm kinds */
typedef enum {
k_entity,
......
......@@ -10,6 +10,7 @@
# include "firm.h"
# include "mangle.h"
# include "xp_help.h"
# include "irnode_t.h"
void
init_firm (void)
......
......@@ -68,13 +68,6 @@
# include "xprintf.h"
/** Global flags. Set these by autoconf?? **/
/* If this is defined debuging aids are created, e.g. a field in
ir_node uniquely numbering the nodes. */
/* @@@???? this is also set in irnode.h */
#define DEBUG_libfirm
/* initialize firm */
void init_firm (void);
......
......@@ -28,6 +28,7 @@ MEMBERS = ircons.m irdump.m irflag.m irgmod.m irgraph.m irgopt.m \
CFILES = $(MEMBERS:.m=.c)
HFILES = $(MEMBERS:.m=.h)
HFILES += irnode_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
......
......@@ -18,7 +18,7 @@
# include "array.h"
/* memset belongs to string.h */
# include "string.h"
# include "irnode.h"
# include "irnode_t.h"
#if USE_EXPICIT_PHI_IN_STACK
/* A stack needed for the automatic Phi node construction in constructor
......@@ -527,7 +527,7 @@ new_r_Sel (ir_graph *irg, ir_node *block, ir_node *store, ir_node *objptr,
}
inline ir_node *
new_r_SymConst (ir_graph *irg, ir_node *block, type_or_id *value,
new_r_SymConst (ir_graph *irg, ir_node *block, type_or_id_p value,
symconst_kind symkind)
{
ir_node *in[0] = {};
......@@ -1479,7 +1479,7 @@ new_Sel (ir_node *store, ir_node *objptr, int n_index, ir_node **index, entity *
}
ir_node *
new_SymConst (type_or_id *value, symconst_kind kind)
new_SymConst (type_or_id_p value, symconst_kind kind)
{
return new_r_SymConst (current_ir_graph, current_ir_graph->current_block,
value, kind);
......
......@@ -1112,7 +1112,7 @@ ir_node *new_r_Raise (ir_graph *irg, ir_node *block,
ir_node *new_r_Const (ir_graph *irg, ir_node *block,
ir_mode *mode, tarval *con);
ir_node *new_r_SymConst (ir_graph *irg, ir_node *block,
type_or_id *value, symconst_kind symkind);
type_or_id_p value, symconst_kind symkind);
ir_node *new_r_Sel (ir_graph *irg, ir_node *block, ir_node *store,
ir_node *objptr, int n_index, ir_node **index,
entity *ent);
......@@ -1200,7 +1200,7 @@ ir_node *new_Cond (ir_node *c);
ir_node *new_Return (ir_node *store, int arity, ir_node **in);
ir_node *new_Raise (ir_node *store, ir_node *obj);
ir_node *new_Const (ir_mode *mode, tarval *con);
ir_node *new_SymConst (type_or_id *value, symconst_kind kind);
ir_node *new_SymConst (type_or_id_p value, symconst_kind kind);
ir_node *new_simpleSel (ir_node *store, ir_node *objptr, entity *ent);
ir_node *new_Sel (ir_node *store, ir_node *objptr, int arity, ir_node **in,
entity *ent);
......
......@@ -8,6 +8,7 @@
# include <assert.h>
# include "irdump.h"
# include "irnode_t.h"
# include "panic.h"
# include <string.h>
# include "entity.h"
......
......@@ -6,6 +6,7 @@
** irgmod: ir graph modification
*/
# include "irnode_t.h"
# include "irgmod.h"
# include "array.h"
......
......@@ -7,7 +7,7 @@
*/
# include "irgopt.h"
# include "irnode.h"
# include "irnode_t.h"
# include "iropt.h"
# include "irgwalk.h"
# include "irgraph.h"
......@@ -193,18 +193,18 @@ copy_node2 (ir_node *n, void *env) {
break;
case iro_SymConst:
{
type_or_id *value = NULL;
type_or_id_p value = NULL;
if ((get_SymConst_kind(n)==type_tag) || (get_SymConst_kind(n)==size))
{
value = (type_or_id *) get_SymConst_type(n);
value = (type_or_id_p) get_SymConst_type(n);
}
else
{
if (get_SymConst_kind(n)==linkage_ptr_info)
{
value = (type_or_id *) get_SymConst_ptrinfo(n);
value = (type_or_id_p) get_SymConst_ptrinfo(n);
}
}
res = new_r_SymConst (current_ir_graph, get_new_node(get_nodes_Block(n)),
......
......@@ -5,9 +5,13 @@
**
*/
#include "irnode.h"
#include "irnode_t.h"
#include "array.h"
#ifdef DEBUG_libfirm
#include "irprog.h"
#endif
/* some constants fixing the positions of nodes predecessors
in the in array */
#define CALL_PARAM_OFFSET 2
......
......@@ -17,154 +17,6 @@
# include "tv.h"
# include "type.h"
/** Global flags. Set these by autoconf?? **/
/* If this is defined debuging aids are created, e.g. a field in
ir_node uniquely numbering the nodes. */
/* @@@???? this is also set in firm.h */
#define DEBUG_libfirm
#ifdef DEBUG_libfirm
#include "irprog.h"
#endif
/* projection numbers of compare. */
enum {
False, /* false */
Eq, /* equal */
Lt, /* less */
Le, /* less or equal */
Gt, /* greater */
Ge, /* greater or equal */
Lg, /* less or greater */
Leg, /* less, equal or greater = ordered */
Uo, /* unordered */
Ue, /* unordered or equal */
Ul, /* unordered or less */
Ule, /* unordered, less or equal */
Ug, /* unordered or greater */
Uge, /* unordered, greater or equal */
Ne, /* unordered, less or greater = not equal */
True, /* true */
not_mask = Leg /* bits to flip to negate comparison */
} pnc_number;
inline char *
get_pnc_string(int pnc);
int
get_negated_pnc(int pnc);
/* projection numbers for result of Start node. */
enum {
pns_initial_exec, /* Projection on an executable, the initial control
flow. */
pns_global_store, /* Projection on the global store */
pns_frame_base, /* Projection on the frame base */
pns_globals, /* Projection on the pointer to the data segment
containing _all_ global entities. */
pns_args /* Projection on all arguments */
} pns_number;
/** ir node attributes **/
/* Block attributes */
typedef struct {
unsigned long block_visited; /* for the walker that walks over all blocks. */
/* Attributes private to construction: */
bool matured; /* if set, all in-nodes of the block are fixed */
struct ir_node **graph_arr; /* array to store all parameters */
} block_attr;
/* SymConst attributes */
/* This enum names the three different kinds of symbolic Constants
represented by SymConst. The content of the attribute type_or_id
depends on this tag. */
typedef enum {
type_tag, /* The SymConst is a type tag for the given type.
Type_or_id is type */
size, /* The SymConst is the size of the given type.
Type_or_id is type */
linkage_ptr_info /* The SymConst is a symbolic pointer to be filled in
by the linker. Type_or_id is ident */
} symconst_kind;
/* This union contains the symbolic information represented by the node */
typedef union {
type *typ;
ident *ptrinfo;
} type_or_id;
typedef struct {
type_or_id tori;
symconst_kind num;
} symconst_attr;
/* Sel attributes */
typedef enum {
static_linkage, /* entity is used internal and not visible out of this
file/class. */
external_linkage, /* */
no_linkage
} linkage_type;
typedef struct {
entity *ent; /* entity to select */
linkage_type ltyp; /* linkage type of the entity */
} sel_attr;
/* Alloc attributes */
typedef enum {
stack_alloc, /* Alloc allocates the object on the stack. */
heap_alloc /* Alloc allocates the object on the heap. */
} where_alloc;
typedef struct {
type *type; /* Type of the allocated object. */
where_alloc where; /* stack, heap or other managed part of memory */
} alloc_attr;
/* Some irnodes just have one attribute, these are stored here,
some have more. Their name is 'irnodename_attr' */
typedef union {
block_attr block; /* For Block: Fields needed to construct it */
struct tarval *con; /* For Const: contains the value of the constant */
symconst_attr i; /* For SymConst. */
sel_attr s; /* For Sel. */
type_method *call; /* For Call: pointer to the type of the method to call */
long proj; /* For Proj: contains the result position to project */
alloc_attr a; /* For Alloc. */
type *f; /* For Free. */
int phi0_pos; /* For Phi. Used to remember the value defined by
this Phi node. Needed when the Phi is completed
to call get_r_internal_value to find the
predecessors. If this attribute is set, the Phi
node takes the role of the obsolete Phi0 node,
therefore the name. */
} attr;
/* common structure of an irnode */
/* if the node has some attributes, they are stored in attr */
struct ir_node {
firm_kind kind; /* distinguishes this node from others */
ir_op *op; /* Opcode of this node. */
ir_mode *mode; /* Mode of this node. */
unsigned long visited; /* visited counter for walks of the graph */
struct ir_node **in; /* array with predecessors / operands */
struct ir_node *link; /* for linking nodes somehow to a list, e.g.
used while construction to link Phi0 nodes and
during optimization to link to nodes that
shall replace a node. */
#ifdef DEBUG_libfirm
int node_nr; /* a unique node number for each node to make output
readable. */
#endif
attr attr; /* attribute of this node. Depends on opcode. */
/* Must be last field of struct ir_node. */
};
/* The typedefiniton of ir_node is also in irgraph.h to resolve
recursion between irnode.h and irgraph.h */
#ifndef _IR_NODE_TYPEDEF_
......@@ -185,18 +37,9 @@ new_ir_node (ir_graph *irg,
int arity,
ir_node **in);
/* Copies all attributes stored in the old node to the new node.
Assumes both have the same opcode and sufficient size. */
void
copy_attrs (ir_node *old, ir_node *new);
/* Print IR-Nodes with attributes */
/* @@@@ brauchen wir dienoch? dann fliegt ev. das xprint raus?*/
int ir_node_print (XP_PAR1, const xprintf_info *, XP_PARN);
/** manipulate the fields of ir_node **/
/** Manipulate the fields of ir_node. With these access routines
you can work on the graph without considering the different types
of nodes, it's just a big graph. **/
/* returns the number of predecessors without the block predecessor: */
int get_irn_arity (ir_node *node);
......@@ -205,7 +48,7 @@ inline ir_node **get_irn_in (ir_node *node);
/* to iterate through the predecessors without touching the array. No
order of predecessors guaranteed.
To iterate over the operands iterate from 0 to i < get_irn_arity(),
to iterate includind the Block predecessor iterate from i = -1 to
to iterate including the Block predecessor iterate from i = -1 to
i < get_irn_arity. */
/* Access predecessor n */
inline ir_node *get_irn_n (ir_node *node, int n);
......@@ -227,32 +70,31 @@ inline void set_irn_visited (ir_node *node, unsigned long visited);
inline unsigned long get_irn_visited (ir_node *node);
inline void set_irn_link (ir_node *node, ir_node *link);
inline ir_node *get_irn_link (ir_node *node);
#ifdef DEBUG_libfirm
/* Outputs a unique number for this node */
inline long get_irn_node_nr(ir_node *node);
#endif
/** access attributes directly **/
inline tarval *get_irn_const_attr (ir_node *node);
inline long get_irn_proj_attr (ir_node *node);
inline alloc_attr get_irn_alloc_attr (ir_node *node);
inline type *get_irn_free_attr (ir_node *node);
inline symconst_attr get_irn_symconst_attr (ir_node *node);
type_method *get_irn_call_attr (ir_node *node);
sel_attr get_irn_sel_attr (ir_node *node);
int get_irn_phi_attr (ir_node *node);
block_attr get_irn_return_attr (ir_node *node);
/** manipulate fields of individual nodes **/
/** Manipulate fields of individual nodes. **/
/* this works for all except Block */
inline ir_node *get_nodes_Block (ir_node *node);
inline void set_nodes_Block (ir_node *node, ir_node *block);
/* Projection numbers for result of Start node: use for Proj nodes! */
enum {
pns_initial_exec, /* Projection on an executable, the initial control
flow. */
pns_global_store, /* Projection on the global store */
pns_frame_base, /* Projection on the frame base */
pns_globals, /* Projection on the pointer to the data segment
containing _all_ global entities. */
pns_args /* Projection on all arguments */
} pns_number;
inline ir_node **get_Block_cfgpred_arr (ir_node *node);
int get_Block_n_cfgpreds (ir_node *node);
/* inline void set_Block_n_cfgpreds (ir_node *node, int n_preds); */
inline ir_node *get_Block_cfgpred (ir_node *node, int pos);
inline void set_Block_cfgpred (ir_node *node, int pos, ir_node *pred);
inline bool get_Block_matured (ir_node *node);
......@@ -281,6 +123,19 @@ inline void set_Raise_exo_ptr (ir_node *node, ir_node *exoptr);
inline tarval *get_Const_tarval (ir_node *node);
inline void set_Const_tarval (ir_node *node, tarval *con);
/* This enum names the three different kinds of symbolic Constants
represented by SymConst. The content of the attribute type_or_id
depends on this tag. Use the proper access routine after testing
this flag. */
typedef enum {
type_tag, /* The SymConst is a type tag for the given type.
Type_or_id_p is type * */
size, /* The SymConst is the size of the given type.
Type_or_id_p is type * */
linkage_ptr_info /* The SymConst is a symbolic pointer to be filled in
by the linker. Type_or_id_p is ident * */
} symconst_kind;
typedef union type_or_id * type_or_id_p;
inline symconst_kind get_SymConst_kind (ir_node *node);
inline void set_SymConst_kind (ir_node *node, symconst_kind num);
inline type *get_SymConst_type (ir_node *node);
......@@ -299,6 +154,12 @@ inline ir_node *get_Sel_index (ir_node *node, int pos);
inline void set_Sel_index (ir_node *node, int pos, ir_node *index);
inline entity *get_Sel_entity (ir_node *node); /* entity to select */
inline void set_Sel_entity (ir_node *node, entity *ent);
typedef enum {
static_linkage, /* entity is used internal and not visible out of this
file/class. */
external_linkage, /* */
no_linkage
} linkage_type;
inline linkage_type get_Sel_linkage_type (ir_node *node);
inline void set_Sel_linkage_type (ir_node *node, linkage_type lt);
......@@ -396,6 +257,28 @@ inline void set_Eor_right (ir_node *node, ir_node *right);
inline ir_node *get_Not_op (ir_node *node);
inline void set_Not_op (ir_node *node, ir_node *op);
/* Projection numbers of compare: use for Proj nodes! */
enum {
False, /* false */
Eq, /* equal */
Lt, /* less */
Le, /* less or equal */
Gt, /* greater */
Ge, /* greater or equal */
Lg, /* less or greater */
Leg, /* less, equal or greater = ordered */
Uo, /* unordered */
Ue, /* unordered or equal */
Ul, /* unordered or less */
Ule, /* unordered, less or equal */
Ug, /* unordered or greater */
Uge, /* unordered, greater or equal */
Ne, /* unordered, less or greater = not equal */
True, /* true */
not_mask = Leg /* bits to flip to negate comparison */
} pnc_number;
inline char *get_pnc_string(int pnc);
inline int get_negated_pnc(int pnc);
inline ir_node *get_Cmp_left (ir_node *node);
inline void set_Cmp_left (ir_node *node, ir_node *left);
inline ir_node *get_Cmp_right (ir_node *node);
......@@ -448,6 +331,10 @@ inline ir_node *get_Alloc_size (ir_node *node);
inline void set_Alloc_size (ir_node *node, ir_node *size);
inline type *get_Alloc_type (ir_node *node);
inline void set_Alloc_type (ir_node *node, type *type);
typedef enum {
stack_alloc, /* Alloc allocates the object on the stack. */
heap_alloc /* Alloc allocates the object on the heap. */
} where_alloc;
inline where_alloc get_Alloc_where (ir_node *node);
inline void set_Alloc_where (ir_node *node, where_alloc where);
......
/* Copyright (C) 1998 - 2000 by Universitaet Karlsruhe
** All rights reserved.
**
** Authors: Martin Trapp, Christian Schaefer
**
** declarations of an ir node
*/
# ifndef _IRNODE_T_H_
# define _IRNODE_T_H_
# include "irnode.h"
/** ir node attributes **/
/* Block attributes */
typedef struct {
unsigned long block_visited; /* for the walker that walks over all blocks. */
/* Attributes private to construction: */
bool matured; /* if set, all in-nodes of the block are fixed */
struct ir_node **graph_arr; /* array to store all parameters */
} block_attr;
/* SymConst attributes */
/* This union contains the symbolic information represented by the node */
typedef union type_or_id {
type *typ;
ident *ptrinfo;
} type_or_id;
typedef struct {
type_or_id tori;
symconst_kind num;
} symconst_attr;
/* Sel attributes */
typedef struct {
entity *ent; /* entity to select */
linkage_type ltyp; /* linkage type of the entity */
} sel_attr;
/* Alloc attributes */
typedef struct {
type *type; /* Type of the allocated object. */
where_alloc where; /* stack, heap or other managed part of memory */
} alloc_attr;
/* Some irnodes just have one attribute, these are stored here,
some have more. Their name is 'irnodename_attr' */
typedef union {
block_attr block; /* For Block: Fields needed to construct it */
struct tarval *con; /* For Const: contains the value of the constant */
symconst_attr i; /* For SymConst. */
sel_attr s; /* For Sel. */
type_method *call; /* For Call: pointer to the type of the method to call */
long proj; /* For Proj: contains the result position to project */
alloc_attr a; /* For Alloc. */
type *f; /* For Free. */
int phi0_pos; /* For Phi. Used to remember the value defined by
this Phi node. Needed when the Phi is completed
to call get_r_internal_value to find the
predecessors. If this attribute is set, the Phi
node takes the role of the obsolete Phi0 node,
therefore the name. */
} attr;
/* common structure of an irnode */
/* if the node has some attributes, they are stored in attr */
struct ir_node {
firm_kind kind; /* distinguishes this node from others */
ir_op *op; /* Opcode of this node. */
ir_mode *mode; /* Mode of this node. */
unsigned long visited; /* visited counter for walks of the graph */
struct ir_node **in; /* array with predecessors / operands */
struct ir_node *link; /* for linking nodes somehow to a list, e.g.
used while construction to link Phi0 nodes and
during optimization to link to nodes that
shall replace a node. */
#ifdef DEBUG_libfirm
int node_nr; /* a unique node number for each node to make output
readable. */
#endif
attr attr; /* attribute of this node. Depends on opcode. */
/* Must be last field of struct ir_node. */
};
/* Copies all attributes stored in the old node to the new node.
Assumes both have the same opcode and sufficient size. */
void
copy_attrs (ir_node *old, ir_node *new);
/* Print IR-Nodes with attributes */
/* @@@@ brauchen wir dienoch? dann fliegt ev. das xprint raus?*/
int ir_node_print (XP_PAR1, const xprintf_info *, XP_PARN);
/** access attributes directly **/
inline tarval *get_irn_const_attr (ir_node *node);
inline long get_irn_proj_attr (ir_node *node);
inline alloc_attr get_irn_alloc_attr (ir_node *node);
inline type *get_irn_free_attr (ir_node *node);
inline symconst_attr get_irn_symconst_attr (ir_node *node);
type_method *get_irn_call_attr (ir_node *node);
sel_attr get_irn_sel_attr (ir_node *node);
int get_irn_phi_attr (ir_node *node);
block_attr get_irn_return_attr (ir_node *node);
# endif /* _IRNODE_T_H_ */
......@@ -6,7 +6,7 @@
*/
# include "irop.h"
# include "irnode.h"
# include "irnode_t.h"
ir_op *op_Block;
......
......@@ -6,6 +6,7 @@
** iropt --- optimizations intertwined with IR construction.
*/
# include "irnode_t.h"
# include "iropt.h"
# include "ircons.h"
# include "irgmod.h"
......
......@@ -168,5 +168,7 @@ void type_walk(ir_graph *irg,
++type_visited;
irg_walk(irg->end, start_type_walk, NULL, type_env);
type_walk_2((type_or_ent *)get_irg_ent(irg), pre, post, env);
return;
}
......@@ -17,6 +17,8 @@
# include "type_or_entity.h"
/** dumps all type information reachable from irg **/
void type_walk(ir_graph *irg,
void (pre)(type_or_ent*, void*), void (post)(type_or_ent*, void*),
void *env);
......@@ -76,7 +76,7 @@ int main(int argc, char **argv)
/* 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 *)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 */
......@@ -112,7 +112,7 @@ int main(int argc, char **argv)
printf("Done building the graph. Dumping it.\n");
dump_ir_block_graph (irg);