return e;
}
}
- for (i = get_class_n_supertype(class) - 1; i >= 0; --i) {
+ for (i = get_class_n_supertypes(class) - 1; i >= 0; --i) {
entity * e = get_implementation(get_class_supertype(class, i), method);
if (e) {
return e;
}
}
if (n_ret > 0) {
- int n_res = get_method_n_res(get_entity_type(get_irg_ent(irg)));
+ int n_res = get_method_n_ress(get_entity_type(get_irg_ent(irg)));
ir_node ** in = NEW_ARR_F(ir_node *, n_ret);
/* block */
for (i = n_ret - 1; i >= 0; --i) {
#include "entity.h"
-/* Aufbau der interprozeduralen Darstellung. Das Analyseergebnis muss
- * in den Call-Operationen gespeichert sein. */
+/* Aufbau der interprozeduralen Darstellung. In den Call-Operationen
+ * mussen alle potentialen callees gespeichert sein. */
void cg_construct(int arr_len, entity ** free_methods_arr);
memcpy (&r_in[2], in, sizeof (ir_node *) * arity);
res = new_ir_node (db, irg, block, op_Sel, mode_p, r_arity, r_in);
- res->attr.s.ltyp = static_linkage;
res->attr.s.ent = ent;
res = optimize (res);
ir_node *new_Block(int arity, ir_node **in);
ir_node *new_Start (void);
ir_node *new_End (void);
+ir_node *new_EndReg (void);
+ir_node *new_EndExcept(void);
ir_node *new_Jmp (void);
+ir_node *new_Break (void);
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_InstOf (ir_node *store, ir_node *objptr, type *ent);
ir_node *new_Call (ir_node *store, ir_node *callee, int arity, ir_node **in,
type *type);
+ir_node *new_CallBegin(ir_node *callee);
ir_node *new_Add (ir_node *op1, ir_node *op2, ir_mode *mode);
ir_node *new_Sub (ir_node *op1, ir_node *op2, ir_mode *mode);
ir_node *new_Minus (ir_node *op, ir_mode *mode);
type *free_type);
ir_node *new_Sync (int arity, ir_node **in);
ir_node *new_Proj (ir_node *arg, ir_mode *mode, long proj);
+ir_node *new_Filter (ir_node *arg, ir_mode *mode, long proj);
ir_node *new_defaultProj (ir_node *arg, long max_proj);
ir_node *new_Tuple (int arity, ir_node **in);
ir_node *new_Id (ir_node *val, ir_mode *mode);
ir_node *new_Bad (void);
ir_node *new_Unknown(void);
-ir_node *new_CallBegin(ir_node *callee);
-ir_node *new_EndReg (void);
-ir_node *new_EndExcept(void);
-ir_node *new_Break (void);
-ir_node *new_Filter (ir_node *arg, ir_mode *mode, long proj);
/***********************************************************************/
/* The comfortable interface. */
switch (get_type_tpop_code(tp)) {
case tpo_class:
{
- for (i=0; i < get_class_n_supertype(tp); i++)
+ for (i=0; i < get_class_n_supertypes(tp); i++)
xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
TYPE_SUPER_EDGE_ATTR "}\n",
tp, get_class_supertype(tp, i));
- for (i=0; i < get_class_n_member(tp); i++)
+ for (i=0; i < get_class_n_members(tp); i++)
xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
TYPE_MEMBER_EDGE_ATTR "}\n",
tp, get_class_member(tp, i));
} break;
case tpo_struct:
{
- for (i=0; i < get_struct_n_member(tp); i++)
+ for (i=0; i < get_struct_n_members(tp); i++)
xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
TYPE_MEMBER_EDGE_ATTR "}\n",
tp, get_struct_member(tp, i));
xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
METH_PAR_EDGE_ATTR "}\n",
tp, get_method_param_type(tp, i), i);
- for (i = 0; i < get_method_n_res(tp); i++)
+ for (i = 0; i < get_method_n_ress(tp); i++)
xfprintf (F, "edge: { sourcename: \"%p\" targetname: \"%p\" "
METH_RES_EDGE_ATTR "}\n",
tp, get_method_res_type(tp, i), i);
/*** Replicate local entities of the called_graph ***/
/* copy the entities. */
called_frame = get_irg_frame_type(called_graph);
- for (i = 0; i < get_class_n_member(called_frame); i++) {
+ for (i = 0; i < get_class_n_members(called_frame); i++) {
entity *new_ent, *old_ent;
old_ent = get_class_member(called_frame, i);
new_ent = copy_entity_own(old_ent, get_cur_frame_type());
end_bl = get_new_node(get_irg_end_block(called_graph));
end = get_new_node(get_irg_end(called_graph));
arity = get_irn_arity(end_bl); /* arity = n_exc + n_ret */
- n_res = get_method_n_res(get_Call_type(call));
+ n_res = get_method_n_ress(get_Call_type(call));
res_pred = (ir_node **) malloc (n_res * sizeof (ir_node *));
cf_pred = (ir_node **) malloc (arity * sizeof (ir_node *));
# include "ircons.h"
# include "irgraph_t.h"
-# include "irprog.h"
+# include "irprog_t.h"
# include "iropt_t.h"
# include "array.h"
# include "irgmod.h"
ir_graph *
new_ir_graph (entity *ent, int n_loc)
{
+ int i;
ir_graph *res;
ir_node *first_block;
ir_node *projX;
res->outs_state = no_outs;
res->dom_state = no_dom;
- /** Type inforamtion for the procedure of the graph **/
+ /** Type information for the procedure of the graph **/
res->ent = ent;
set_entity_irg(ent, res);
/** A type that represents the stack frame. A class type so that it can
contain "inner" methods as in Pascal. **/
res->frame_type = new_type_class(mangle(get_entity_ident(ent),
- id_from_str(FRAME_TP_SUFFIX, strlen(FRAME_TP_SUFFIX))));
+ id_from_str(FRAME_TP_SUFFIX, strlen(FRAME_TP_SUFFIX))));
+ /* Remove type from type list. Must be treated differently than other types. */
+ remove_irp_type_from_list(res->frame_type);
/** Nodes needed in every graph **/
res->end_block = new_immBlock ();
}
int
-get_irg_n_loc (ir_graph *irg)
+get_irg_n_locs (ir_graph *irg)
{
#if PRECISE_EXC_CONTEXT
return irg->n_loc - 1 - 1;
graph, nor the entity standing for this graph. */
void free_ir_graph (ir_graph *irg);
-/* access routines for all ir_graph attributes */
+/** access routines for all ir_graph attributes **/
+entity *get_irg_ent (ir_graph *irg);
+void set_irg_ent (ir_graph *irg, entity *ent);
+
+type *get_irg_frame_type (ir_graph *irg);
+void set_irg_frame_type (ir_graph *irg, type *ftp);
+/* To test for a frame type */
+int is_frame_type(type *ftp);
+
ir_node *get_irg_start_block (ir_graph *irg);
void set_irg_start_block (ir_graph *irg, ir_node *node);
ir_node *get_irg_end (ir_graph *irg);
void set_irg_end (ir_graph *irg, ir_node *node);
+/* @@@ oblivious, no more supported. */
ir_node *get_irg_cstore (ir_graph *irg);
void set_irg_cstore (ir_graph *irg, ir_node *node);
ir_node *get_irg_args (ir_graph *irg);
void set_irg_args (ir_graph *irg, ir_node *node);
+ir_node *get_irg_current_block (ir_graph *irg);
+void set_irg_current_block (ir_graph *irg, ir_node *node);
+
/* Use new_Bad() instead!! */
ir_node *get_irg_bad (ir_graph *irg);
void set_irg_bad (ir_graph *irg, ir_node *node);
ir_node *get_irg_unknown (ir_graph *irg);
void set_irg_unknown (ir_graph *irg, ir_node *node);
-ir_node *get_irg_current_block (ir_graph *irg);
-void set_irg_current_block (ir_graph *irg, ir_node *node);
-
-entity *get_irg_ent (ir_graph *irg);
-void set_irg_ent (ir_graph *irg, entity *ent);
-
-type *get_irg_frame_type (ir_graph *irg);
-void set_irg_frame_type (ir_graph *irg, type *ftp);
-/* To test for a frame type */
-int is_frame_type(type *ftp);
-
-/* 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);
-
+int get_irg_n_locs (ir_graph *irg);
/********************************************************************************/
/* States of an ir_graph. */
/********************************************************************************/
-/* An ir_graph can have different states. These states represent the analysis
+/** An ir_graph can have different states. These states represent the analysis
information associated with the graph. Optimizations invalidate these
- states. */
+ states. **/
/* state: phase values: phase_building, phase_high, phase_low.
The irg is in phase_building during construction of the irgraph. It is in
void set_irg_phase_low(ir_graph *irg);
/* state: pinned
- The graph is "pinned" if all nodes are accosiated with a basic block.
+ The graph is "pinned" if all nodes are associated with a basic block.
It is in state "floats" if nodes are in arbitrary blocks. In state
"floats" the block predecessor is set in all nodes, but this can be an
invalid block, i.e., the block is not a dominator of all the uses of
}
INLINE void
-set_irn_link (ir_node *node, ir_node *link) {
+set_irn_link (ir_node *node, void *link) {
assert (node);
node->link = link;
}
-INLINE ir_node *
+INLINE void *
get_irn_link (ir_node *node) {
assert (node);
return node->link;
return (get_irn_arity(node));
}
-/*
-INLINE void
-set_Block_n_cfgpreds (ir_node *node, int n_preds) {
- assert ((node->op == op_Block));
-}
-*/
-
INLINE ir_node *
get_Block_cfgpred (ir_node *node, int pos) {
assert (node->op == op_Block);
INLINE void
free_End (ir_node *end) {
+ assert (end->op == op_End);
/* DEL_ARR_F(end->in); GL @@@ tut nicht ! */
- end->in = NULL; /* @@@ make sure we get an error if we use the in array afterwards ... */
+ end->in = NULL; /* @@@ make sure we get an error if we use the
+ in array afterwards ... */
+}
+
+ir_graph *get_EndReg_irg (ir_node *end) {
+ assert (end->op == op_EndReg);
+ return end->attr.end.irg;
+}
+
+ir_graph *get_EndExcept_irg (ir_node *end) {
+ assert (end->op == op_EndReg);
+ return end->attr.end.irg;
}
/*
}
INLINE int
-get_Return_n_res (ir_node *node) {
+get_Return_n_ress (ir_node *node) {
assert (node->op == op_Return);
return (get_irn_arity(node) - RETURN_RESULT_OFFSET);
}
get_Return_res_arr (ir_node *node)
{
assert ((node->op == op_Return));
- if (get_Return_n_res(node) > 0)
+ if (get_Return_n_ress(node) > 0)
return (ir_node **)&(get_irn_in(node)[1 + RETURN_RESULT_OFFSET]);
else
return NULL;
INLINE ir_node *
get_Return_res (ir_node *node, int pos) {
assert (node->op == op_Return);
- assert (get_Return_n_res(node) > pos);
+ assert (get_Return_n_ress(node) > pos);
return get_irn_n(node, pos + RETURN_RESULT_OFFSET);
}
}
INLINE int
-get_Sel_n_index (ir_node *node) {
+get_Sel_n_indexs (ir_node *node) {
assert (node->op == op_Sel);
return (get_irn_arity(node) - SEL_INDEX_OFFSET);
}
get_Sel_index_arr (ir_node *node)
{
assert ((node->op == op_Sel));
- if (get_Sel_n_index(node) > 0)
+ if (get_Sel_n_indexs(node) > 0)
return (ir_node **)& get_irn_in(node)[SEL_INDEX_OFFSET + 1];
else
return NULL;
}
-/*
-INLINE void
-set_Sel_n_index (ir_node *node, int n_index) {
- assert (node->op == op_Sel);
-}
-*/
-
INLINE ir_node *
get_Sel_index (ir_node *node, int pos) {
assert (node->op == op_Sel);
node->attr.s.ent = ent;
}
-INLINE linkage_type
-get_Sel_linkage_type (ir_node *node) {
- assert (node->op == op_Sel);
- return node->attr.s.ltyp;
-}
-
-INLINE void
-set_Sel_linkage_type (ir_node *node, linkage_type lt) {
- assert (node->op == op_Sel);
- node->attr.s.ltyp = lt;
-}
-
type *
get_InstOf_ent (ir_node *node) {
assert (node->op = op_InstOf);
node->attr.call.callee_arr = NULL;
}
+ir_node * get_CallBegin_ptr (ir_node *node) {
+ assert(node->op == op_CallBegin);
+ return get_irn_n(node, 0);
+}
+void set_CallBegin_ptr (ir_node *node, ir_node *ptr) {
+ assert(node->op == op_CallBegin);
+ set_irn_n(node, 0, ptr);
+}
+ir_graph * get_CallBegin_irg (ir_node *node) {
+ assert(node->op == op_CallBegin);
+ return node->attr.callbegin.irg;
+}
+ir_node * get_CallBegin_call (ir_node *node) {
+ assert(node->op == op_CallBegin);
+ return node->attr.callbegin.call;
+}
+void set_CallBegin_call (ir_node *node, ir_node *call) {
+ assert(node->op == op_CallBegin);
+ node->attr.callbegin.call = call;
+}
+
INLINE ir_node *
get_Add_left (ir_node *node) {
assert (node->op == op_Add);
INLINE ir_node *
-get_Filter_pred(ir_node *node) {
+get_Filter_pred (ir_node *node) {
assert(node->op == op_Filter);
return node->in[1];
}
-
+INLINE void
+set_Filter_pred (ir_node *node, ir_node *pred) {
+ assert(node->op == op_Filter);
+ node->in[1] = pred;
+}
INLINE long
get_Filter_proj(ir_node *node) {
assert(node->op == op_Filter);
return node->attr.filter.proj;
}
+INLINE void
+set_Filter_proj (ir_node *node, long proj) {
+ assert(node->op == op_Filter);
+ node->attr.filter.proj = proj;
+}
void set_Filter_cg_pred_arr(ir_node * node, int arity, ir_node ** in) {
assert(node->op == op_Filter);
/* returns the number of predecessors without the block predecessor: */
int get_irn_arity (ir_node *node);
-/* returns the array with the ins: */
-INLINE ir_node **get_irn_in (ir_node *node);
/* Replaces the old in array by a new one that will contain the ins given in
the parameters. Conserves the block predecessor. It copies the array passed.
This function is necessary to ajust in arrays of blocks, calls and phis.
INLINE unsigned long get_irn_visited (ir_node *node);
/* Sets visited to get_irg_visited(current_ir_graph) */
INLINE void mark_irn_visited (ir_node *node);
-/* Returns 1 of visited < get_irg_visited(current_ir_graph). */
+/* Returns 1 if visited < get_irg_visited(current_ir_graph). */
INLINE int irn_not_visited (ir_node *node);
-INLINE void set_irn_link (ir_node *node, ir_node *link);
-INLINE ir_node *get_irn_link (ir_node *node);
+INLINE void set_irn_link (ir_node *node, void *link);
+INLINE void *get_irn_link (ir_node *node);
/* Outputs a unique number for this node if libfirm is compiled for
- debugging, else returns 0. */
+ debugging, (configure with --enable-debug) else returns 0. */
INLINE long get_irn_node_nr(ir_node *node);
+/* Returns the ir_graph this node belongs to. Only valid for
+ * CallBegin, EndReg and EndExcept */
+INLINE ir_graph *get_irn_irg(ir_node *node);
/*****/
/* irnode constructor */
pns_args /* Projection on all arguments */
} pns_number;
+/* @@@ no more supported */
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);
/* For this current_ir_graph must be set. */
INLINE void mark_Block_block_visited(ir_node *node);
INLINE int Block_not_block_visited(ir_node *node);
-INLINE ir_node *get_Block_graph_arr (ir_node *node, int pos);
-INLINE void set_Block_graph_arr (ir_node *node, int pos, ir_node *value);
-/* exc handling */
+/* exc handling @@@ ajacs specific -- not supported */
void set_Block_exc (ir_node*, exc_t);
exc_t get_Block_exc (ir_node*);
void set_Node_exc (ir_node*, exc_t);
exc_t get_Node_exc (ir_node*);
-/* handler handling */
+/* handler handling @@@ ajacs specific -- not supported */
void set_Block_handler (ir_node*, ir_node*);
ir_node* get_Block_handler (ir_node*);
* both views. */
void set_Block_cg_cfgpred_arr(ir_node * node, int arity, ir_node ** in);
void set_Block_cg_cfgpred(ir_node * node, int pos, ir_node * pred);
+/* @@@ not supported */
ir_node ** get_Block_cg_cfgpred_arr(ir_node * node);
int get_Block_cg_n_cfgpreds(ir_node * node);
void remove_Block_cg_cfgpred_arr(ir_node * node);
free_End frees these data structures. */
INLINE void free_End (ir_node *end);
+ir_graph *get_EndReg_irg (ir_node *end);
+
+ir_graph *get_EndExcept_irg (ir_node *end);
+
/* We distinguish three kinds of Cond nodes. These can be distinguished
by the mode of the selector operand and an internal flag of type cond_kind.
First we distinguish binary Conds and switch Conds.
INLINE ir_node *get_Return_mem (ir_node *node);
INLINE void set_Return_mem (ir_node *node, ir_node *mem);
INLINE ir_node **get_Return_res_arr (ir_node *node);
-INLINE int get_Return_n_res (ir_node *node);
-/*INLINE void set_Return_n_res (ir_node *node, int results); */
+INLINE int get_Return_n_ress (ir_node *node);
INLINE ir_node *get_Return_res (ir_node *node, int pos);
INLINE void set_Return_res (ir_node *node, int pos, ir_node *res);
INLINE ir_node *get_Sel_ptr (ir_node *node); /* ptr to the object to select from */
INLINE void set_Sel_ptr (ir_node *node, ir_node *ptr);
INLINE ir_node **get_Sel_index_arr (ir_node *node);
-INLINE int get_Sel_n_index (ir_node *node);
-/*INLINE void set_Sel_n_index (ir_node *node, int n_index); */
+INLINE int get_Sel_n_indexs (ir_node *node);
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);
+/* @@@ ajacs specific node -- not supported */
type *get_InstOf_ent (ir_node*);
void set_InstOf_ent (ir_node*, type*);
ir_node *get_InstOf_obj (ir_node*);
INLINE void set_Call_ptr (ir_node *node, ir_node *ptr);
INLINE ir_node **get_Call_param_arr (ir_node *node);
INLINE int get_Call_n_params (ir_node *node);
-INLINE int get_Call_arity (ir_node *node);
-/* INLINE void set_Call_arity (ir_node *node, ir_node *arity); */
INLINE ir_node *get_Call_param (ir_node *node, int pos);
INLINE void set_Call_param (ir_node *node, int pos, ir_node *param);
INLINE type *get_Call_type (ir_node *node);
INLINE void set_Call_type (ir_node *node, type *type);
-
/* Set, get and remove the callee-analysis. */
int get_Call_n_callees(ir_node * node);
entity * get_Call_callee(ir_node * node, int pos);
void set_Call_callee_arr(ir_node * node, int n, entity ** arr);
void remove_Call_callee_arr(ir_node * node);
+ir_node * get_CallBegin_ptr (ir_node *node);
+void set_CallBegin_ptr (ir_node *node, ir_node *ptr);
+ir_graph *get_CallBegin_irg (ir_node *node);
+ir_node *get_CallBegin_call (ir_node *node);
+void set_CallBegin_call (ir_node *node, ir_node *call);
+
/* For unary and binary arithmetic operations the access to the
operands can be factored out. Left is the first, right the
second arithmetic value as listed in tech report 1999-44.
INLINE ir_node **get_Phi_preds_arr (ir_node *node);
INLINE int get_Phi_n_preds (ir_node *node);
-/* INLINE void set_Phi_n_preds (ir_node *node, int n_preds); */
INLINE ir_node *get_Phi_pred (ir_node *node, int pos);
INLINE void set_Phi_pred (ir_node *node, int pos, ir_node *pred);
+INLINE ir_node *get_Filter_pred(ir_node *node);
+INLINE void set_Filter_pred(ir_node *node, ir_node *pred);
+INLINE long get_Filter_proj(ir_node *node);
+INLINE void set_Filter_proj(ir_node *node, long proj);
+/* set the interprocedural predecessors */
+void set_Filter_cg_pred_arr(ir_node * node, int arity, ir_node ** in);
+void set_Filter_cg_pred(ir_node * node, int pos, ir_node * pred);
+
INLINE ir_node *get_Load_mem (ir_node *node);
INLINE void set_Load_mem (ir_node *node, ir_node *mem);
INLINE ir_node *get_Load_ptr (ir_node *node);
INLINE ir_node **get_Sync_preds_arr (ir_node *node);
INLINE int get_Sync_n_preds (ir_node *node);
-/* INLINE void set_Sync_n_preds (ir_node *node, int n_preds); */
INLINE ir_node *get_Sync_pred (ir_node *node, int pos);
INLINE void set_Sync_pred (ir_node *node, int pos, ir_node *pred);
INLINE ir_node **get_Tuple_preds_arr (ir_node *node);
INLINE int get_Tuple_n_preds (ir_node *node);
-/* INLINE void set_Tuple_n_preds (ir_node *node, int n_preds); */
INLINE ir_node *get_Tuple_pred (ir_node *node, int pos);
INLINE void set_Tuple_pred (ir_node *node, int pos, ir_node *pred);
INLINE ir_node *get_Id_pred (ir_node *node);
INLINE void set_Id_pred (ir_node *node, ir_node *pred);
-INLINE ir_node *get_Filter_pred(ir_node *node);
-INLINE long get_Filter_proj(ir_node *node);
-/* set the interprocedural predecessors */
-void set_Filter_cg_pred_arr(ir_node * node, int arity, ir_node ** in);
-void set_Filter_cg_pred(ir_node * node, int pos, ir_node * pred);
-
-/* Returns the ir_graph this node belongs to. Only valid for
- * CallBegin, EndReg and EndExcept */
-INLINE ir_graph *get_irn_irg(ir_node *node);
-
/*****/
/****s* irnode/other2
/* Sel attributes */
typedef struct {
entity *ent; /* entity to select */
- linkage_type ltyp; /* linkage type of the entity */
} sel_attr;
typedef struct {
symconst_attr i; /* For SymConst. */
sel_attr s; /* For Sel. */
call_attr call; /* For Call: pointer to the type of the method to call */
+ callbegin_attr callbegin; /* For CallBegin */
alloc_attr a; /* For Alloc. */
io_attr io; /* For InstOf */
type *f; /* For Free. */
predecessors. If this attribute is set, the Phi
node takes the role of the obsolete Phi0 node,
therefore the name. */
- long proj; /* For Proj: contains the result position to project */
+ long proj; /* For Proj: contains the result position to project */
filter_attr filter; /* For Filter */
end_attr end; /* For EndReg, EndExcept */
- callbegin_attr callbegin; /* For CallBegin */
#if PRECISE_EXC_CONTEXT
struct ir_node **frag_arr; /* For Phi node construction in case of exceptions
for nodes Store, Load, Div, Mod, Quot, DivMod. */
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.
+ void *link; /* to attach additional information to the node, e.g.
used while construction to link Phi0 nodes and
during optimization to link to nodes that
shall replace a node. */
/* @@@@ brauchen wir dienoch? dann fliegt ev. das xprint raus?*/
int ir_node_print (XP_PAR1, const xprintf_info *, XP_PARN);
+/* Returns the array with the ins. The content of the array may not be
+ changed. */
+ir_node **get_irn_in (ir_node *node);
/** access attributes directly **/
INLINE tarval *get_irn_const_attr (ir_node *node);
extern ir_op *op_EndExcept;
+/* Returns the ident for the opcode name */
+ident *get_op_ident (ir_op *op);
/* Returns the string for the opcode. */
-const char *get_op_name (ir_op *op);
+const char *get_op_name (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);
-
typedef enum {
floats = 0, /* Nodes of this opcode can be placed in any basic block. */
pinned /* Nodes must remain in this basic block. */
for Block, Phi and control flow nodes. */
void set_op_pinned(ir_op *op, op_pinned pinned);
-/* Returns the attribute size of nodes of this opcode.
- Use not encouraged, internal feature. */
-int get_op_attr_size (ir_op *op);
-
/* Returns true if op is one of Start, End, Jmp, Cond, Return, Raise or Bad. */
int is_cfopcode(ir_op *op);
+/* Returns the attribute size of nodes of this opcode.
+ @@@ Use not encouraged, internal feature. */
+int get_op_attr_size (ir_op *op);
# endif /* _IROP_H_ */
(get_irn_mode(a) != get_irn_mode(b))) return 1;
/* compare if a's in and b's in are equal */
- /* GL: we optimize only nodes with in arrays of fixed sizes.
- if (get_irn_arity (a) != -2) {
- ins = get_irn_arity (a);
- if (ins != get_irn_arity (b)) return 1;
- ain = get_irn_in (a);
- bin = get_irn_in (b);
- }
- */
if (get_irn_arity (a) != get_irn_arity(b))
return 1;
|| (get_irn_sel_attr(a).ent->name != get_irn_sel_attr(b).ent->name)
|| (get_irn_sel_attr(a).ent->owner != get_irn_sel_attr(b).ent->owner)
|| (get_irn_sel_attr(a).ent->ld_name != get_irn_sel_attr(b).ent->ld_name)
- || (get_irn_sel_attr(a).ent->type != get_irn_sel_attr(b).ent->type)
- || (get_irn_sel_attr(a).ltyp != get_irn_sel_attr(b).ltyp);
+ || (get_irn_sel_attr(a).ent->type != get_irn_sel_attr(b).ent->type);
case iro_Phi:
return get_irn_phi_attr (a) != get_irn_phi_attr (b);
default: ;
res->types = NEW_ARR_F (type *, 1);
res->glob_type = new_type_class(id_from_str (GLOBAL_TYPE_NAME,
strlen(GLOBAL_TYPE_NAME)));
- /* @@@ Das ist hier das 2. mal!! */
- add_irp_type(res->glob_type);
+ /* Remove type from type list. Must be treated differently than other types. */
+ remove_irp_type_from_list(res->glob_type);
+ /* @@@ Das ist hier das 2. mal!!
+ add_irp_type(res->glob_type); */
res->const_code_irg = new_const_code_irg();
ARR_APP1 (ir_graph *, irp->graphs, irg);
}
-/* Removes irg from the list or irgs, shrinks the list by one.
- @@@ does not work properly. */
+/* Removes irg from the list or irgs, shrinks the list by one. */
void remove_irp_irg(ir_graph *irg){
int i;
assert(irg);
ARR_APP1 (type *, irp->types, typ);
}
+INLINE void remove_irp_type_from_list (type *typ) {
+ int i;
+ assert(typ);
+ for (i = 1; i < (ARR_LEN (irp->types)); i++) {
+ if (irp->types[i] == typ) {
+ for(; i < (ARR_LEN (irp->types)) - 1; i++) {
+ irp->types[i] = irp->types[i+1];
+ }
+ ARR_SETLEN(type*, irp->types, (ARR_LEN(irp->types)) - 1);
+ break;
+ }
+ }
+}
+
+void remove_irp_type(type *typ) {
+ remove_irp_type_from_list (typ);
+ free_type(typ);
+}
+
int get_irp_n_types (void) {
assert (irp && irp->types);
/* Strangely the first element of the array is NULL. Why?? */
/* Adds type to the list of types in irp. */
void add_irp_type(type *typ);
+/* Removes type from the list of types, deallocates it and
+ shrinks the list by one. */
+void remove_irp_type(type *typ);
int get_irp_n_types();
type *get_irp_type(int pos);
void set_irp_type(int pos, type *typ);
* ir_graph *get_const_code_irg();
* NOTE
* Do not use any access function for this graph, do not generate code
- * for this graph.
+ * for this graph. This graph contains only one block. The constant
+ * expressions may not contain control flow. See also copy_const_code
+ * in entity.h.
*/
ir_graph *get_const_code_irg();
#endif
};
+void remove_irp_type_from_list (type *typ);
+
#ifdef DEBUG_libfirm
/* Returns a new, unique number to number nodes or the like. */
int get_irp_new_node_nr();
# include "irvrfy.h"
# include "irgwalk.h"
+/* @@@ replace use of array "in" by access functions. */
+ir_node **get_irn_in (ir_node *node);
+
INLINE static void
vrfy_Proj_proj(ir_node *p) {
ir_node *pred;
assert (proj >= 0 && mode_is_data(mode) &&
"wrong Proj from Proj from Call");
mt = get_Call_type(pred);
- assert(proj < get_method_n_res(mt) &&
+ assert(proj < get_method_n_ress(mt) &&
"More Projs for results than results in type.");
assert(mode == get_type_mode(get_method_res_type(mt, proj)) &&
"Mode of Proj from Call doesn't match mode of result type.");
mymode == mode_X && "Jmp node"
);
break;
+ case iro_Break:
+ assert (
+ /* Jmp: BB --> X */
+ mymode == mode_X && "Jmp node"
+ );
+ break;
case iro_Cond:
op1mode = get_irn_mode(in[1]);
assert (
assert ( mymode == mode_X ); /* result X */
/* Compare returned results with result types of method type */
mt = get_entity_type(get_irg_ent(current_ir_graph));
- assert(get_Return_n_res(n) == get_method_n_res(mt) &&
+ assert(get_Return_n_ress(n) == get_method_n_ress(mt) &&
"Number of results for Return doesn't match number of results in type.");
- for (i = 0; i < get_Return_n_res(n); i++)
+ for (i = 0; i < get_Return_n_ress(n); i++)
assert((get_irn_mode(get_Return_res(n, i))
== get_type_mode(get_method_res_type(mt, i))) &&
"Mode of result for Return doesn't match mode of result type.");
/* Phi: BB x dataM^n --> dataM */
/* for some reason "<=" aborts. Is there a problem with get_store? */
for (i=1; i < get_irn_arity(n); i++) {
- if (!is_Bad(in[i]))
+ if (!is_Bad(in[i]) && (get_irn_op(in[i]) != op_Unknown))
assert ( get_irn_mode(in[i]) == mymode && "Phi node");
};
assert ( mode_is_dataM(mymode) && "Phi node");
#define __OLD_FCTNAMES_H__
/* irgraph */
-#define get_irg_params get_irg_n_loc
+#define get_irg_params get_irg_n_locs
+#define get_irg_n_loc get_irg_n_locs
#define set_irg_params set_irg_n_loc
+/* irnode.h */
+#define get_Return_n_res get_Return_n_ress
+#define get_Sel_n_index get_Sel_n_indexs
/* irmode.h */
#define get_ident_of_mode get_mode_ident
/* type.h */
#define get_type_nameid(_t_) get_type_ident(_t_)
#define set_type_nameid(_t_,_i_) set_type_ident(_t_,_i_)
+#define get_class_n_member get_class_n_members
+#define get_class_n_subtype get_class_n_subtypes
+#define get_class_n_supertype get_class_n_supertypes
+#define get_struct_n_member get_struct_n_members
#endif
INLINE ent_volatility
get_entity_volatility (entity *ent) {
+ assert (ent);
return ent->volatility;
}
INLINE void
set_entity_volatility (entity *ent, ent_volatility vol) {
+ assert (ent);
ent->volatility = vol;
}
INLINE void
set_entity_peculiarity (entity *ent, peculiarity pec) {
assert (ent);
+ /* @@@ why peculiarity only for methods? */
assert (is_method_type(ent->type));
ent->peculiarity = pec;
}
return nn;
}
-/* Copies the value represented by the entity to current_block
- in current_ir_graph. */
-ir_node *copy_atomic_ent_value(entity *ent) {
- assert(ent && is_atomic_entity(ent) && (ent->variability != uninitialized));
- return copy_const_value(ent->value);
-}
-
/* A value of a compound entity is a pair of value and the corresponding member of
the compound. */
INLINE void
/* Copies the firm subgraph referenced by val to const_code_irg and adds
the node as constant initialization to ent.
- The subgraph may not contain control flow operations. */
+ The subgraph may not contain control flow operations.
INLINE void
copy_and_add_compound_ent_value(entity *ent, ir_node *val, entity *member) {
ir_graph *rem = current_ir_graph;
val = copy_const_value(val);
add_compound_ent_value(ent, val, member);
current_ir_graph = rem;
-}
+ }*/
INLINE int
get_compound_ent_n_values(entity *ent) {
return ent->values[pos+1];
}
-/* Copies the value i of the entity to current_block in current_ir_graph. */
+/* Copies the value i of the entity to current_block in current_ir_graph.
ir_node *
copy_compound_ent_value(entity *ent, int pos) {
assert(ent && is_compound_entity(ent) && (ent->variability != uninitialized));
return copy_const_value(ent->values[pos+1]);
-}
+ }*/
INLINE entity *
get_compound_ent_value_member(entity *ent, int pos) {
/** manipulate fields of entity **/
const char *get_entity_name (entity *ent);
ident *get_entity_ident (entity *ent);
+
/* returns the mangled name of the entity. If the mangled name is
set it returns the existing name. Else it generates a name
with mangle_entity() and remembers this new name internally. */
void set_entity_ld_ident (entity *ent, ident *ld_ident);
const char *get_entity_ld_name (entity *end);
-/*
-char *get_entity_ld_name (entity *ent);
-void set_entity_ld_name (entity *ent, char *ld_name);
-*/
-
type *get_entity_owner (entity *ent);
/* Sets the owner field in entity to owner. */
void set_entity_owner (entity *ent, type *owner);
ent_volatility get_entity_volatility (entity *ent);
void set_entity_volatility (entity *ent, ent_volatility vol);
+/* Only set if layout = fixed. */
+int get_entity_offset (entity *ent);
+void set_entity_offset (entity *ent, int offset);
+
+/* A link to store intermediate information */
+void* get_entity_link(entity *ent);
+void set_entity_link(entity *ent, void *l);
+
+/** Fields of method entities **/
+/* The entity knows the corresponding irg if the entity is a method.
+ This allows to get from a Call to the called irg.
+ Only entities of peculiarity "existent" can have a corresponding irg,
+ else the field is fixed to NULL. (Get returns NULL, set asserts.) */
+ir_graph *get_entity_irg(entity *ent);
+void set_entity_irg(entity *ent, ir_graph *irg);
+
/* For the definition of enumeration peculiarity see type.h */
peculiarity get_entity_peculiarity (entity *ent);
void set_entity_peculiarity (entity *ent, peculiarity pec);
+/** Representation of constant values of entites **/
+/* Set current_ir_graph to get_const_code_irg() to generate a constant
+ expression. */
/* Copies a firm subgraph that complies to the restrictions for
constant expressions to current_block in current_ir_graph. */
ir_node *copy_const_value(ir_node *n);
/* Set has no effect for entities of type method. */
ir_node *get_atomic_ent_value(entity *ent);
void set_atomic_ent_value(entity *ent, ir_node *val);
-/* Copies the value represented by the entity to current_block
- in current_ir_graph. @@@ oblivious, use copy_const_vallue */
-ir_node *copy_atomic_ent_value(entity *ent);
-/* A value of a compound entity is a pair of value and the corresponding
+/* A value of a compound entity is a pair of a value and the corresponding
member of the compound. */
void add_compound_ent_value(entity *ent, ir_node *val, entity *member);
-/* oblivious, use copy_const_value @@@ */
-void copy_and_add_compound_ent_value(entity *ent, ir_node *val, entity *member);
int get_compound_ent_n_values(entity *ent);
ir_node *get_compound_ent_value(entity *ent, int pos);
entity *get_compound_ent_value_member(entity *ent, int pos);
fits into the given array size. Does not test whether the
values have the proper mode for the array. */
void set_array_entity_values(entity *ent, tarval **values, int num_vals);
-/* Copies the value pos of the entity to current_block in current_ir_graph. */
-ir_node *copy_compound_ent_value(entity *ent, int pos);
-
-/* Only set if layout = fixed. */
-int get_entity_offset (entity *ent);
-void set_entity_offset (entity *ent, int offset);
+/** Fields of entities with a class type as owner **/
/* Overwrites is a field that specifies that an access to the overwritten
entity in the supertype must use this entity. It's a list as with
multiple inheritance several enitites can be overwritten. This field
int get_entity_n_overwrites (entity *ent);
entity *get_entity_overwrites (entity *ent, int pos);
void set_entity_overwrites (entity *ent, int pos, entity *overwritten);
+
void add_entity_overwrittenby (entity *ent, entity *overwrites);
int get_entity_n_overwrittenby (entity *ent);
entity *get_entity_overwrittenby (entity *ent, int pos);
void set_entity_overwrittenby (entity *ent, int pos, entity *overwrites);
-/* A link to store intermediate information */
-void* get_entity_link(entity *ent);
-void set_entity_link(entity *ent, void *l);
-
-/* The entity knows the corresponding irg if the entity is a method.
- This allows to get from a Call to the called irg.
- Only entities of peculiarity "existent" can have a corresponding irg,
- else the field is fixed to NULL. (Get returns NULL, set asserts.) */
-ir_graph *get_entity_irg(entity *ent);
-void set_entity_irg(entity *ent, ir_graph *irg);
-
-
/* Returns true if the type of the entity is a primitive, pointer
enumeration or method type. */
int is_atomic_entity(entity *ent);
unsigned long type_visited;
+void free_type(type *tp) {
+ /* @@@ not implemented */
+}
+
INLINE type *
new_type(tp_op *type_op, ir_mode *mode, ident* name) {
type *res;
{
assert(get_type_size(tp) > -1);
if (tp != get_glob_type())
- for (i = 0; i < get_class_n_member(tp); i++) {
+ for (i = 0; i < get_class_n_members(tp); i++) {
assert(get_entity_offset(get_class_member(tp, i)) > -1);
assert(is_method_type(get_entity_type(get_class_member(tp, i))) ||
(get_entity_allocation(get_class_member(tp, i)) == automatic_allocated));
case tpo_struct:
{
/* assert(get_type_size(tp) > -1); @@@ lowerfirm geht nicht durch */
- for (i = 0; i < get_struct_n_member(tp); i++) {
+ for (i = 0; i < get_struct_n_members(tp); i++) {
assert(get_entity_offset(get_struct_member(tp, i)) > -1);
assert((get_entity_allocation(get_struct_member(tp, i)) == automatic_allocated));
}
DEL_ARR_F(clss->attr.ca.subtypes);
DEL_ARR_F(clss->attr.ca.supertypes);
}
+
/* manipulate private fields of class type */
void add_class_member (type *clss, entity *member) {
assert(clss && (clss->type_op == type_class));
ARR_APP1 (entity *, clss->attr.ca.members, member);
}
-int get_class_n_member (type *clss) {
+int get_class_n_members (type *clss) {
assert(clss && (clss->type_op == type_class));
return (ARR_LEN (clss->attr.ca.members))-1;
}
entity *get_class_member (type *clss, int pos) {
assert(clss && (clss->type_op == type_class));
- assert(pos >= 0 && pos < get_class_n_member(clss));
+ assert(pos >= 0 && pos < get_class_n_members(clss));
return clss->attr.ca.members[pos+1];
}
void set_class_member (type *clss, entity *member, int pos) {
assert(clss && (clss->type_op == type_class));
- assert(pos >= 0 && pos < get_class_n_member(clss));
+ assert(pos >= 0 && pos < get_class_n_members(clss));
clss->attr.ca.members[pos+1] = member;
}
void set_class_members (type *clss, entity **members, int arity) {
int i;
assert(clss && (clss->type_op == type_class));
ARR_APP1 (type *, clss->attr.ca.subtypes, subtype);
- for (i = 0; i < get_class_n_supertype(subtype); i++)
+ for (i = 0; i < get_class_n_supertypes(subtype); i++)
if (get_class_supertype(subtype, i) == clss)
/* Class already registered */
return;
ARR_APP1 (type *, subtype->attr.ca.supertypes, clss);
}
-int get_class_n_subtype (type *clss) {
+int get_class_n_subtypes (type *clss) {
assert(clss && (clss->type_op == type_class));
return (ARR_LEN (clss->attr.ca.subtypes))-1;
}
type *get_class_subtype (type *clss, int pos) {
assert(clss && (clss->type_op == type_class));
- assert(pos >= 0 && pos < get_class_n_subtype(clss));
+ assert(pos >= 0 && pos < get_class_n_subtypes(clss));
return clss->attr.ca.subtypes[pos+1] = skip_tid(clss->attr.ca.subtypes[pos+1]);
}
void set_class_subtype (type *clss, type *subtype, int pos) {
assert(clss && (clss->type_op == type_class));
- assert(pos >= 0 && pos < get_class_n_subtype(clss));
+ assert(pos >= 0 && pos < get_class_n_subtypes(clss));
clss->attr.ca.subtypes[pos+1] = subtype;
}
void remove_class_subtype(type *clss, type *subtype) {
assert(clss && (clss->type_op == type_class));
assert(supertype && (supertype -> type_op == type_class));
ARR_APP1 (type *, clss->attr.ca.supertypes, supertype);
- for (i = 0; i < get_class_n_subtype(supertype); i++)
+ for (i = 0; i < get_class_n_subtypes(supertype); i++)
if (get_class_subtype(supertype, i) == clss)
/* Class already registered */
return;
ARR_APP1 (type *, supertype->attr.ca.subtypes, clss);
}
-int get_class_n_supertype (type *clss) {
+int get_class_n_supertypes (type *clss) {
assert(clss && (clss->type_op == type_class));
return (ARR_LEN (clss->attr.ca.supertypes))-1;
}
type *get_class_supertype (type *clss, int pos) {
assert(clss && (clss->type_op == type_class));
- assert(pos >= 0 && pos < get_class_n_supertype(clss));
+ assert(pos >= 0 && pos < get_class_n_supertypes(clss));
return clss->attr.ca.supertypes[pos+1] = skip_tid(clss->attr.ca.supertypes[pos+1]);
}
void set_class_supertype (type *clss, type *supertype, int pos) {
assert(clss && (clss->type_op == type_class));
- assert(pos >= 0 && pos < get_class_n_supertype(clss));
+ assert(pos >= 0 && pos < get_class_n_supertypes(clss));
clss->attr.ca.supertypes[pos+1] = supertype;
}
void remove_class_supertype(type *clss, type *supertype) {
}
INLINE void set_class_peculiarity (type *clss, peculiarity pec) {
assert(clss && (clss->type_op == type_class));
+ assert(pec != inherited); /* There is no inheritance of types in libFirm. */
clss->attr.ca.peculiarity = pec;
}
assert(strct && (strct->type_op == type_struct));
DEL_ARR_F(strct->attr.sa.members);
}
+
/* manipulate private fields of struct */
+int get_struct_n_members (type *strct) {
+ assert(strct && (strct->type_op == type_struct));
+ return (ARR_LEN (strct->attr.sa.members))-1;
+}
void add_struct_member (type *strct, entity *member) {
assert(strct && (strct->type_op == type_struct));
assert(get_type_tpop(get_entity_type(member)) != type_method);
/* @@@ lowerfirm geht nicht durch */
ARR_APP1 (entity *, strct->attr.sa.members, member);
}
-int get_struct_n_member (type *strct) {
- assert(strct && (strct->type_op == type_struct));
- return (ARR_LEN (strct->attr.sa.members))-1;
-}
entity *get_struct_member (type *strct, int pos) {
assert(strct && (strct->type_op == type_struct));
- assert(pos >= 0 && pos < get_struct_n_member(strct));
+ assert(pos >= 0 && pos < get_struct_n_members(strct));
return strct->attr.sa.members[pos+1];
}
void set_struct_member (type *strct, int pos, entity *member) {
assert(strct && (strct->type_op == type_struct));
- assert(pos >= 0 && pos < get_struct_n_member(strct));
+ assert(pos >= 0 && pos < get_struct_n_members(strct));
assert(get_entity_type(member)->type_op != type_method);/* @@@ lowerfirm !!*/
strct->attr.sa.members[pos+1] = member;
}
break;
}
}
+
/* typecheck */
bool is_struct_type(type *strct) {
assert(strct);
method->attr.ma.param_type[pos] = type;
}
-int get_method_n_res (type *method) {
+int get_method_n_ress (type *method) {
assert(method && (method->type_op == type_method));
return method->attr.ma.n_res;
}
type *get_method_res_type(type *method, int pos) {
assert(method && (method->type_op == type_method));
- assert(pos >= 0 && pos < get_method_n_res(method));
+ assert(pos >= 0 && pos < get_method_n_ress(method));
return method->attr.ma.res_type[pos] = skip_tid(method->attr.ma.res_type[pos]);
}
void set_method_res_type(type *method, int pos, type* type) {
assert(method && (method->type_op == type_method));
- assert(pos >= 0 && pos < get_method_n_res(method));
+ assert(pos >= 0 && pos < get_method_n_ress(method));
method->attr.ma.res_type[pos] = type;
}
/* create a new type array -- set dimension sizes independently */
type *new_type_array (ident *name, int n_dimensions,
- type *element_type) {
+ type *element_type) {
type *res;
int i;
- assert((element_type->type_op != type_method));
- assert(get_type_tpop(element_type) != type_method);
+ assert(!is_method_type(element_type));
res = new_type(type_array, NULL, name);
res->attr.aa.n_dimensions = n_dimensions;
res->attr.aa.lower_bound = (ir_node **) xmalloc (sizeof (ir_node *) * n_dimensions);
assert(array && (array->type_op == type_array));
return array->attr.aa.n_dimensions;
}
-void set_array_bounds_int (type *array, int dimension, int lower_bound,
- int upper_bound) {
- ir_graph *rem;
- assert(array && (array->type_op == type_array));
- rem = current_ir_graph;
- current_ir_graph = get_const_code_irg();
- array->attr.aa.lower_bound[dimension] =
- new_Const(mode_I, tarval_from_long (mode_I, lower_bound));
- array->attr.aa.upper_bound[dimension] =
- new_Const(mode_I, tarval_from_long (mode_I, upper_bound));
- current_ir_graph = rem;
-}
-void set_array_bounds (type *array, int dimension, ir_node * lower_bound,
- ir_node * upper_bound) {
+INLINE void
+set_array_bounds (type *array, int dimension, ir_node * lower_bound,
+ ir_node * upper_bound) {
assert(array && (array->type_op == type_array));
array->attr.aa.lower_bound[dimension] = lower_bound;
array->attr.aa.upper_bound[dimension] = upper_bound;
}
-void set_array_lower_bound_int (type *array, int dimension, int lower_bound) {
- ir_graph *rem;
- assert(array && (array->type_op == type_array));
- rem = current_ir_graph;
+void
+set_array_bounds_int (type *array, int dimension, int lower_bound,
+ int upper_bound) {
+ ir_graph *rem = current_ir_graph;
current_ir_graph = get_const_code_irg();
- array->attr.aa.lower_bound[dimension] =
- new_Const(mode_I, tarval_from_long (mode_I, lower_bound));
+ set_array_bounds (array, dimension,
+ new_Const(mode_I, tarval_from_long (mode_I, lower_bound)),
+ new_Const(mode_I, tarval_from_long (mode_I, upper_bound)));
current_ir_graph = rem;
}
-void set_array_lower_bound (type *array, int dimension, ir_node * lower_bound) {
+INLINE void
+set_array_lower_bound (type *array, int dimension, ir_node * lower_bound) {
assert(array && (array->type_op == type_array));
array->attr.aa.lower_bound[dimension] = lower_bound;
}
-void set_array_upper_bound (type *array, int dimension, ir_node * upper_bound) {
+void set_array_lower_bound_int (type *array, int dimension, int lower_bound) {
+ ir_graph *rem = current_ir_graph;
+ current_ir_graph = get_const_code_irg();
+ set_array_lower_bound (array, dimension,
+ new_Const(mode_I, tarval_from_long (mode_I, lower_bound)));
+ current_ir_graph = rem;
+}
+INLINE void
+set_array_upper_bound (type *array, int dimension, ir_node * upper_bound) {
assert(array && (array->type_op == type_array));
array->attr.aa.upper_bound[dimension] = upper_bound;
}
+void set_array_upper_bound_int (type *array, int dimension, int upper_bound) {
+ ir_graph *rem = current_ir_graph;
+ current_ir_graph = get_const_code_irg();
+ set_array_upper_bound (array, dimension,
+ new_Const(mode_I, tarval_from_long (mode_I, upper_bound)));
+ current_ir_graph = rem;
+}
ir_node * get_array_lower_bound (type *array, int dimension) {
assert(array && (array->type_op == type_array));
return array->attr.aa.lower_bound[dimension];
assert(array && (array->type_op == type_array));
return array->attr.aa.upper_bound[dimension];
}
+
void set_array_order (type *array, int dimension, int order) {
assert(array && (array->type_op == type_array));
array->attr.aa.order[dimension] = order;
assert(array && (array->type_op == type_array));
return array->attr.aa.order[dimension];
}
+
void set_array_element_type (type *array, type *type) {
assert(array && (array->type_op == type_array));
+ assert(!is_method_type(type));
array->attr.aa.element_type = type;
}
type *get_array_element_type (type *array) {
assert(array && (array->type_op == type_array));
return array->attr.aa.element_type = skip_tid(array->attr.aa.element_type);
}
+
void set_array_element_entity (type *array, entity *ent) {
assert(array && (array->type_op == type_array));
assert((get_entity_type(ent)->type_op != type_method));
# include "type_or_entity.h"
-void* get_type_link(type *tp);
-void set_type_link(type *tp, void *l);
+/* Frees the memory used by the type. Does not free the entities
+ belonging to the type, except for the array element entity. */
+void free_type(type *tp);
+
tp_op* get_type_tpop(type *tp);
ident* get_type_tpop_nameid(type *tp);
const char* get_type_tpop_name(type *tp);
tp_opcode get_type_tpop_code(type *tp);
-/* Returns NULL for all non atomic types. */
-ir_mode* get_type_mode(type *tp);
-/* Only has an effect on primitive and enumeration types */
-void set_type_mode(type *tp, ir_mode* m);
-
ident* get_type_ident(type *tp);
void set_type_ident(type *tp, ident* id);
const char* get_type_name(type *tp);
-int get_type_size(type *tp);
-/* For primitives, enumerations, pointer and method types the size
- is always fixed. This call is legal but has no effect. */
-void set_type_size(type *tp, int size);
-
typedef enum {
layout_undefined, /* The layout of this type is not defined.
Address computation to access fields is not
- possible, fields must be accessed by Sel nodes.
- This is the default value except for pointer and
- primitive types. */
+ possible, fields must be accessed by Sel
+ nodes. This is the default value except for
+ pointer, primitive and method types. */
layout_fixed /* The layout is fixed, all component/member entities
have an offset assigned. Size of the type is known.
Arrays can be accessed by explicit address
- computation. Default for pointer and primitive types.
- */
+ computation. Default for pointer, primitive ane method
+ types. */
} type_state;
-
type_state get_type_state(type *tp);
/* For primitives, pointer and method types the layout is always fixed.
This call is legal but has no effect. */
void set_type_state(type *tp, type_state state);
+/* Returns NULL for all non atomic types. */
+ir_mode* get_type_mode(type *tp);
+/* Only has an effect on primitive and enumeration types */
+void set_type_mode(type *tp, ir_mode* m);
+
+int get_type_size(type *tp);
+/* For primitive, enumeration, pointer and method types the size
+ is always fixed. This call is legal but has no effect. */
+void set_type_size(type *tp, int size);
+
+
unsigned long get_type_visited(type *tp);
void set_type_visited(type *tp, unsigned long num);
/* Sets visited field in type to type_visited. */
void mark_type_visited(type *tp);
+
+void* get_type_link(type *tp);
+void set_type_link(type *tp, void *l);
/*****/
/****v* type/visited
/* Adds the entity as member of the class. */
void add_class_member (type *clss, entity *member);
/* Returns the number of members of this class. */
-int get_class_n_member (type *clss);
+int get_class_n_members (type *clss);
/* Returns the member at position pos, 0 <= pos < n_member */
entity *get_class_member (type *clss, int pos);
/* Overwrites the member at position pos, 0 <= pos < n_member with
adds also clss as supertype to subtype. */
void add_class_subtype (type *clss, type *subtype);
/* Returns the number of subtypes */
-int get_class_n_subtype (type *clss);
+int get_class_n_subtypes (type *clss);
/* Gets the subtype at position pos, 0 <= pos < n_subtype. */
type *get_class_subtype (type *clss, int pos);
/* Sets the subtype at positioin pos, 0 <= pos < n_subtype. Does not
adds also clss as subtype to supertype. */
void add_class_supertype (type *clss, type *supertype);
/* Returns the number of supertypes */
-int get_class_n_supertype (type *clss);
+int get_class_n_supertypes (type *clss);
/* Gets the supertype at position pos, 0 <= pos < n_supertype. */
type *get_class_supertype (type *clss, int pos);
/* Sets the supertype at postition pos, 0 <= pos < n_subtype. Does not
INLINE peculiarity get_class_peculiarity (type *clss);
INLINE void set_class_peculiarity (type *clss, peculiarity pec);
-/* Set and get a class' dfn */
+/* Set and get a class' dfn --
+ @@@ This is an undocumented field, subject to change! */
void set_class_dfn (type*, int);
int get_class_dfn (type*);
/* manipulate private fields of struct */
void add_struct_member (type *strct, entity *member);
-int get_struct_n_member (type *strct);
+int get_struct_n_members (type *strct);
entity *get_struct_member (type *strct, int pos);
void set_struct_member (type *strct, int pos, entity *member);
/* Finds member in the list of memberss and overwrites it with NULL
type *get_method_param_type(type *method, int pos);
void set_method_param_type(type *method, int pos, type* type);
-int get_method_n_res (type *method);
+/* @@@ fuer emitter.h von cggg */
+#define get_method_n_res(X) get_method_n_ress(X)
+
+int get_method_n_ress (type *method);
type *get_method_res_type(type *method, int pos);
void set_method_res_type(type *method, int pos, type* type);
/* create a new type array --
Sets n_dimension to dimension and all dimension entries to NULL.
Initializes order to the order of the dimensions.
- Entity for array elements is built automatically.
+ The entity for array elements is built automatically.
Set dimension sizes after call to constructor with set_* routines. */
type *new_type_array (ident *name, int n_dimensions,
- type *element_type);
+ type *element_type);
/* manipulate private fields of array type */
int get_array_n_dimensions (type *array);
void set_array_lower_bound (type *array, int dimension, ir_node *lower_bound);
void set_array_lower_bound_int (type *array, int dimension, int lower_bound);
void set_array_upper_bound (type *array, int dimension, ir_node *upper_bound);
+void set_array_upper_bound_int (type *array, int dimension, int lower_bound);
ir_node * get_array_lower_bound (type *array, int dimension);
ir_node * get_array_upper_bound (type *array, int dimension);
switch (get_type_tpop_code(tp)) {
case tpo_class:
{
- for (i=0; i<get_class_n_supertype(tp); i++)
+ for (i=0; i<get_class_n_supertypes(tp); i++)
type_walk_2((type_or_ent *)get_class_supertype(tp, i), pre, post, env);
- for (i=0; i<get_class_n_member(tp); i++)
+ for (i=0; i<get_class_n_members(tp); i++)
type_walk_2((type_or_ent *)get_class_member(tp, i), pre, post, env);
- for (i=0; i<get_class_n_subtype(tp); i++)
+ for (i=0; i<get_class_n_subtypes(tp); i++)
type_walk_2((type_or_ent *)get_class_subtype(tp, i), pre, post, env);
}
break;
case tpo_struct:
{
- for (i=0; i<get_struct_n_member(tp); i++)
+ for (i=0; i<get_struct_n_members(tp); i++)
type_walk_2((type_or_ent *)get_struct_member(tp, i), pre, post, env);
}
break;
{
for (i = 0; i < get_method_n_params(tp); i++)
type_walk_2((type_or_ent *)get_method_param_type(tp, i), pre, post, env);
- for (i = 0; i < get_method_n_res(tp); i++)
+ for (i = 0; i < get_method_n_ress(tp); i++)
type_walk_2((type_or_ent *)get_method_res_type(tp, i), pre, post, env);
}
break;
switch (get_type_tpop_code(tp)) {
case tpo_class:
{
- for (i = 0; i < get_class_n_supertype(tp); i++) {
+ for (i = 0; i < get_class_n_supertypes(tp); i++) {
type_walk_s2s_2((type_or_ent *)get_class_supertype(tp, i), pre,
post, env);
}
pre(tore, env);
tp = skip_tid((type*)tore);
- for (i = 0; i < get_class_n_subtype(tp); i++) {
+ for (i = 0; i < get_class_n_subtypes(tp); i++) {
type_walk_s2s_2((type_or_ent *)get_class_subtype(tp, i), pre,
post, env);
}
pre(tore, env);
tp = skip_tid((type*)tore);
- for (i = 0; i < get_class_n_supertype(tp); i++) {
+ for (i = 0; i < get_class_n_supertypes(tp); i++) {
type_walk_super_2((type_or_ent *)get_class_supertype(tp, i), pre,
post, env);
}
assert(is_class_type(tp));
/* Assure all supertypes are visited before */
- for (i=0; i < get_class_n_supertype(tp); i++) {
+ for (i=0; i < get_class_n_supertypes(tp); i++) {
if (get_type_visited(get_class_supertype(tp, i)) < type_visited)
return;
}
pre(tp, env);
tp = skip_tid((type*)tp);
- for (i=0; i<get_class_n_subtype(tp); i++) {
+ for (i=0; i<get_class_n_subtypes(tp); i++) {
class_walk_s2s_2(get_class_subtype(tp, i), pre, post, env);
}
/* execute post method */
return;
}
-
+#if 0
void class_walk_super2sub(void (pre)(type*, void*),
void (post)(type*, void*),
void *env) {
for (i = 0; i < get_irp_n_types(); i++) {
tp = get_irp_type(i);
if (is_class_type(tp) &&
- (get_class_n_supertype(tp) == 0) &&
+ (get_class_n_supertypes(tp) == 0) &&
(tp->visit < type_visited) &&
(!is_frame_type(tp)) &&
(tp != get_glob_type())) {
}
}
}
+#endif
+void class_walk_super2sub(void (pre)(type*, void*),
+ void (post)(type*, void*),
+ void *env) {
+ int i;
+ type *tp;
+
+ ++type_visited;
+ for (i = 0; i < get_irp_n_types(); i++) {
+ tp = get_irp_type(i);
+ if (is_class_type(tp) &&
+ (get_class_n_supertypes(tp) == 0) &&
+ (tp->visit < type_visited)) {
+ assert(!is_frame_type(tp));
+ assert(tp != get_glob_type());
+ class_walk_s2s_2(tp, pre, post, env);
+ }
+ }
+}