entity *impl_meth = NULL;
ir_node *addr = get_atomic_ent_value(inh_meth);
assert(addr && "constant entity without value");
-
- if (get_irn_op(addr) == op_Const) {
- impl_meth = get_tarval_entity(get_Const_tarval(addr));
- } else if ((get_irn_op(addr) == op_SymConst) &&
+ if ((get_irn_op(addr) == op_SymConst) &&
(get_SymConst_kind(addr) == symconst_addr_ent)) {
impl_meth = get_SymConst_entity(addr);
} else {
symconst_symbol sym;
assert(get_entity_irg(ent));
sym.entity_p = ent;
- set_irg_current_block(current_ir_graph, get_nodes_Block(node));
+ set_irg_current_block(current_ir_graph, get_nodes_block(node));
new_node = new_d_SymConst(get_irn_dbg_info(node), sym, symconst_addr_ent); DBG_OPT_NORMALIZE;
DDMN(new_node);
exchange(node, new_node);
/* We know which method will be called, no dispatch necessary. */
#if 0
assert(get_entity_peculiarity(ent) != peculiarity_description);
- set_irg_current_block(current_ir_graph, get_nodes_Block(node));
+ set_irg_current_block(current_ir_graph, get_nodes_block(node));
/* @@@ Is this correct?? Alloc could reference a subtype of the owner
of Sel that overwrites the method referenced in Sel. */
/* @@@ Yes, this is wrong. GL, 10.3.04 */
new_node = copy_const_value(get_atomic_ent_value(ent)); DBG_OPT_POLY_ALLOC;
#else
called_ent = resolve_ent_polymorphy(get_Alloc_type(skip_Proj(get_Sel_ptr(node))), ent);
- set_irg_current_block(current_ir_graph, get_nodes_Block(node));
+ set_irg_current_block(current_ir_graph, get_nodes_block(node));
/* called_ent may not be description: has no Address/Const to Call! */
assert(get_entity_peculiarity(called_ent) != peculiarity_description);
new_node = copy_const_value(get_atomic_ent_value(called_ent)); DBG_OPT_POLY_ALLOC;
/* @@@ GL Methode um Fehler anzuzeigen aufrufen! */
printf("WARNING: Calling method description %s\n in method %s\n of class %s\n which has "
"no implementation!\n", get_entity_name(ent),
- get_entity_name(get_irg_ent(current_ir_graph)),
- get_type_name(get_entity_owner(get_irg_ent(current_ir_graph))));
+ get_entity_name(get_irg_entity(current_ir_graph)),
+ get_type_name(get_entity_owner(get_irg_entity(current_ir_graph))));
printf("This happens when compiling a Java Interface that's never really used, i.e., "
"no class implementing the interface is ever used.\n");
} else {
#if 0
int i;
printf("\nCall site "); DDMN(node);
- printf(" in "); DDME(get_irg_ent(current_ir_graph));
+ printf(" in "); DDME(get_irg_entity(current_ir_graph));
printf(" can call:\n");
for (i = 0; i < ARR_LEN(arr); i++) {
printf(" - "); DDME(arr[i]);
* interne Methode zurückgeben. Wir können daher die
* Sel-Operation durch eine Const- bzw. SymConst-Operation
* ersetzen. */
- set_irg_current_block(current_ir_graph, get_nodes_Block(node));
+ set_irg_current_block(current_ir_graph, get_nodes_block(node));
/* assert(get_entity_peculiarity(tarval_to_entity(get_Const_tarval(get_atomic_ent_value(arr[0])))) == peculiarity_existent); */
new_node = copy_const_value(get_atomic_ent_value(arr[0])); DBG_OPT_POLY;
exchange (node, new_node);
assert(entities == NULL);
entities = eset_create();
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
- entity * ent = get_irg_ent(get_irp_irg(i));
+ entity * ent = get_irg_entity(get_irp_irg(i));
/* Nur extern sichtbare Methode können überhaupt mit SymConst
* aufgerufen werden. */
if (get_entity_visibility(ent) != visibility_local) {
eset_insert(methods, MARK); /* free method -> unknown */
}
break;
-
- case iro_Const: {
- /* interne Methode */
- entity * ent = get_tarval_entity(get_Const_tarval(node));
- assert(ent && is_method_type(get_entity_type(ent)));
- if (get_entity_visibility(ent) != visibility_external_allocated) {
- if (!get_entity_irg(ent)) {
- dump_entity(ent);
- assert(get_entity_irg(ent));
- }
- eset_insert(methods, ent);
- } else {
- eset_insert(methods, MARK); /* free method -> unknown */
- }
- break;
- }
-
case iro_Sel:
/* polymorphe Methode */
for (i = get_Sel_n_methods(node) - 1; i >= 0; --i) {
eset * methods = eset_create();
entity * ent;
entity ** arr = NEW_ARR_F(entity *, 0);
- callee_ana_node(skip_nop(get_Call_ptr(call)), methods);
+ callee_ana_node(skip_Id(get_Call_ptr(call)), methods);
if (eset_contains(methods, MARK)) { /* unknown method */
ARR_APP1(entity *, arr, NULL);
}
/* nothing: SymConst points to extern method */
}
break;
- case iro_Const: {
- tarval * val = get_Const_tarval(node);
- if (tarval_is_entity(val)) { /* filter null pointer */
- entity * ent = get_tarval_entity(val);
- if (is_method_type(get_entity_type(ent))) {
- eset_insert(set, ent);
- }
- }
- break;
- }
+
case iro_Phi:
for (i = get_Phi_n_preds(node) - 1; i >= 0; --i) {
free_mark(get_Phi_pred(node, i), set);
if (! whole) {
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
ir_graph * irg = get_irp_irg(i);
- entity * ent = get_irg_ent(irg);
+ entity * ent = get_irg_entity(irg);
/* insert "external visible" methods. */
if (get_entity_visibility(ent) != visibility_local) {
eset_insert(set, ent);
/* insert sticky methods, too */
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
ir_graph * irg = get_irp_irg(i);
- entity * ent = get_irg_ent(irg);
+ entity * ent = get_irg_entity(irg);
/* insert "external visible" methods. */
if (get_entity_stickyness (ent) == stickyness_sticky) {
eset_insert(set, ent);
/* Hauptprogramm ist auch dann frei, wenn es nicht "external
* visible" ist. */
if (get_irp_main_irg()) {
- eset_insert(set, get_irg_ent(get_irp_main_irg()));
+ eset_insert(set, get_irg_entity(get_irp_main_irg()));
}
/* Wandle Menge in Feld um. Effizienter. */
for (ent = eset_first(set); ent; ent = eset_next(set)) {
assert(entities == NULL);
entities = eset_create();
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
- entity * ent = get_irg_ent(get_irp_irg(i));
+ entity * ent = get_irg_entity(get_irp_irg(i));
/* Nur extern sichtbare Methoden können überhaupt mit SymConst
* aufgerufen werden. */
if (get_entity_visibility(ent) != local) {
assert(is_Block(n));
if ((get_Block_n_cfgpreds(n) == 1) &&
(get_irn_op(skip_Proj(get_Block_cfgpred(n, 0))) == op_Start) &&
- (get_nodes_Block(skip_Proj(get_Block_cfgpred(n, 0))) == n)) {
+ (get_nodes_block(skip_Proj(get_Block_cfgpred(n, 0))) == n)) {
return true;
}
return false;
/* Step 2 */
irn_arity = get_irn_arity(w->block);
for (j = 0; j < irn_arity; j++) {
- ir_node *pred = get_nodes_Block(get_Block_cfgpred(w->block, j));
+ ir_node *pred = get_nodes_block(get_Block_cfgpred(w->block, j));
tmp_dom_info *u;
if ((is_Bad(get_Block_cfgpred(w->block, j))) ||
void free_dom_and_peace(ir_graph *irg) {
/* Update graph state */
assert(get_irg_phase_state(current_ir_graph) != phase_building);
- current_ir_graph->dom_state = no_dom;
+ current_ir_graph->dom_state = dom_none;
/* With the implementation right now there is nothing to free,
but better call it anyways... */
*/
void compute_doms(ir_graph *irg);
-/** Frees the dominator datastructures. Sets the flag in irg to "no_dom". */
+/** Frees the dominator datastructures. Sets the flag in irg to "dom_none". */
void free_dom_and_peace(ir_graph *irg);
#endif /* _IRDOM_H_ */
irg_walk_func *pre, irg_walk_func *post,
void *env) {
assert(node);
- if (get_irg_outs_state(current_ir_graph) != no_outs) {
+ if (get_irg_outs_state(current_ir_graph) != outs_none) {
inc_irg_visited (current_ir_graph);
irg_out_walk_2(node, pre, post, env);
}
/* Update graph state */
assert(get_irg_phase_state(current_ir_graph) != phase_building);
- if (current_ir_graph->outs_state != no_outs) free_outs(current_ir_graph);
+ if (current_ir_graph->outs_state != outs_none) free_outs(current_ir_graph);
current_ir_graph->outs_state = outs_consistent;
/* This first iteration counts the overall number of out edges and the
assert(get_irp_ip_view_state() == ip_view_valid &&
"Cannot construct outs for invalid ip view.");
- if (irp->outs_state != no_outs) {
+ if (irp->outs_state != outs_none) {
free_ip_outs();
}
free(out_edges);
set_irp_ip_outedges(NULL);
}
- irp->outs_state = no_outs;
+ irp->outs_state = outs_none;
}
void free_outs(ir_graph *irg) {
- /* current_ir_graph->outs_state = no_outs; */
- irg->outs_state = no_outs;
+ /* current_ir_graph->outs_state = outs_none; */
+ irg->outs_state = outs_none;
if (irg->outs) {
#ifdef DEBUG_libfirm
/** To iterate through the successors iterate from 0 to i < get_irn_outs(). No
order of successors guaranteed. Will return edges from block to floating
- nodes even if irgraph is in state "floats". */
+ nodes even if irgraph is in state "op_pin_state_floats". */
/* returns the number of successors of the node: */
int get_irn_n_outs (ir_node *node);
/** Computes the out edges. Sets a flag in irg to "outs_consistent". If the
graph is changed this flag must be set to "outs_inconsistent". Computes
out edges from block to floating nodes even if graph is in state
- "floats". Optimizes Tuple nodes. */
+ "op_pin_state_floats". Optimizes Tuple nodes. */
void compute_outs(ir_graph *irg);
/** Computes the out edges in interprocedural view */
void compute_ip_outs(void);
-/** Frees the out datastructures. Sets the flag in irg to "no_outs". */
+/** Frees the out datastructures. Sets the flag in irg to "outs_none". */
void free_ip_outs(void);
void free_outs(ir_graph *irg);
(get_irn_op(cb) == op_EndReg) ||
(get_irn_op(cb) == op_EndExcept)) {
init_node(cb, NULL);
- init_node(get_nodes_Block(cb), NULL);
+ init_node(get_nodes_block(cb), NULL);
}
}
#endif
if ((get_irn_op(n) == op_Block) &&
(get_Block_n_cfgpreds(n) == 1) &&
(get_irn_op(skip_Proj(get_Block_cfgpred(n, 0))) == op_Start) &&
- (get_nodes_Block(skip_Proj(get_Block_cfgpred(n, 0))) == n)) {
+ (get_nodes_block(skip_Proj(get_Block_cfgpred(n, 0))) == n)) {
return true;
}
#if 0
if (get_irn_op(n) == op_Phi ||
get_irn_op(n) == op_Block ||
(get_irn_op(n) == op_Filter && interprocedural_view) ||
- (get_irg_pinned(get_irn_irg(n)) == floats &&
- get_op_pinned(get_irn_op(n)) == floats))
+ (get_irg_pinned(get_irn_irg(n)) == op_pin_state_floats &&
+ get_op_pinned(get_irn_op(n)) == op_pin_state_floats))
// Here we could test for backedge at -1 which is illegal
return 0;
else
/* Find real entry points */
sb = get_irg_start_block(current_ir_graph);
if ((get_Block_n_cfgpreds(sb) > 1) ||
- (get_nodes_Block(get_Block_cfgpred(sb, 0)) != sb)) continue;
+ (get_nodes_block(get_Block_cfgpred(sb, 0)) != sb)) continue;
/* Compute scc for this graph */
outermost_ir_graph = current_ir_graph;
set_irg_visited(outermost_ir_graph, get_max_irg_visited());
assert(get_irn_mode(pred) == mode_T);
pred_pred = get_Proj_pred(pred);
if (get_irn_op(pred_pred) == op_Start) {
- type *mtp = get_entity_type(get_irg_ent(get_Start_irg(pred_pred)));
+ type *mtp = get_entity_type(get_irg_entity(get_irn_irg(pred_pred)));
tp = get_method_param_type(mtp, get_Proj_proj(n));
} else if (get_irn_op(pred_pred) == op_Call) {
type *mtp = get_Call_type(pred_pred);
} break;
case iro_Start: {
/* globals and frame pointer */
- if (get_Proj_proj(n) == pns_frame_base)
- tp = find_pointer_type_to(get_irg_frame_type(get_Start_irg(pred)));
- else if (get_Proj_proj(n) == pns_globals)
+ if (get_Proj_proj(n) == pn_Start_P_frame_base)
+ tp = find_pointer_type_to(get_irg_frame_type(get_irn_irg(pred)));
+ else if (get_Proj_proj(n) == pn_Start_P_globals)
tp = find_pointer_type_to(get_glob_type());
- else if (get_Proj_proj(n) == pns_value_arg_base) {
+ else if (get_Proj_proj(n) == pn_Start_P_value_arg_base) {
VERBOSE_UNKNOWN_TYPE(("Value arg base proj %ld from Start: unknown type\n", get_irn_node_nr(n)));
- tp = unknown_type; /* find_pointer_type_to(get....(get_entity_type(get_irg_ent(get_Start_irg(pred))))); */
+ tp = unknown_type; /* find_pointer_type_to(get....(get_entity_type(get_irg_entity(get_irn_irg(pred))))); */
} else {
VERBOSE_UNKNOWN_TYPE(("Proj %ld %ld from Start: unknown type\n", get_Proj_proj(n), get_irn_node_nr(n)));
tp = unknown_type;
} break;
case iro_Call: {
/* value args pointer */
- if (get_Proj_proj(n) == pncl_value_res_base) {
+ if (get_Proj_proj(n) == pn_Call_P_value_res_base) {
VERBOSE_UNKNOWN_TYPE(("Value res base Proj %ld from Call: unknown type\n", get_irn_node_nr(n)));
tp = unknown_type; /* find_pointer_type_to(get....get_Call_type(pred)); */
} else {
/* Check returned type. */
/*
int i;
- type *meth_type = get_entity_type(get_irg_ent(current_ir_graph));
+ type *meth_type = get_entity_type(get_irg_entity(current_ir_graph));
for (i = 0; i < get_method_n_ress(meth_type); i++) {
type *res_type = get_method_res_type(meth_type, i);
type *ana_res_type = get_irn_type(get_Return_res(n, i));
ir_node *a = get_Load_ptr(n);
if (get_irn_op(a) == op_Sel)
tp = get_entity_type(get_Sel_entity(a));
- else if ((get_irn_op(a) == op_Const) &&
- (tarval_is_entity(get_Const_tarval(a))))
- tp = get_entity_type(get_tarval_entity(get_Const_tarval(a)));
else if (is_pointer_type(compute_irn_type(a))) {
tp = get_pointer_points_to_type(get_irn_type(a));
if (is_array_type(tp)) tp = get_array_element_type(tp);
if (!eset_contains (_live_graphs, graph)) {
if (verbose > 1) {
fprintf(stdout, "RTA: new graph of ");
- DDMEO(get_irg_ent (graph));
+ DDMEO(get_irg_entity (graph));
}
eset_insert (_live_graphs, graph);
if (iro_Sel == get_irn_opcode (ptr)) { /* CALL SEL */
ent = get_Sel_entity (ptr);
*change = add_implementing_graphs (ent);
- } else if (iro_Const == get_irn_opcode (ptr)) { /* CALL CONST */
- ent = get_tarval_entity (get_Const_tarval (ptr));
- ir_graph *graph = get_entity_irg (ent);
- /* don't use get_implementing_graph on a Const! */
- if (graph) {
- *change = add_graph (graph);
- } else {
- /* it's an external allocated thing. */
- }
} else if (iro_SymConst == get_irn_opcode (ptr)) { /* CALL SYMCONST */
if (get_SymConst_kind(ptr) == symconst_addr_ent) {
ent = get_SymConst_entity (ptr);
if (verbose > 1) {
fprintf(stdout, "RTA: RUN %i: considering graph of ", n_runs);
- DDMEO(get_irg_ent (graph));
+ DDMEO(get_irg_entity (graph));
}
rerun |= rta_fill_graph (graph);
entity *ent = get_irg_entity (graph);
peculiarity pec = get_entity_peculiarity (ent);
- /* DDMEO (get_irg_ent(graph)); */
+ /* DDMEO (get_irg_entity(graph)); */
/* delete the ir_graph data */
set_entity_peculiarity (ent, peculiarity_description);
set_entity_peculiarity (ent, peculiarity_inherited);
exchange (get_atomic_ent_value (ent),
- get_atomic_ent_value (get_irg_ent(graph)));
+ get_atomic_ent_value (get_irg_entity(graph)));
}
}
if ((verbose > 1) || get_opt_dead_method_elimination_verbose ()) {
fprintf(stdout, "RTA: removing graph of ");
- DDMEO(get_irg_ent (graph));
+ DDMEO(get_irg_entity (graph));
}
remove_irg (graph);
for (i = 0; i < get_irp_n_irgs(); i++) {
if (rta_is_alive_graph (get_irp_irg(i))) {
fprintf(stdout, "RTA: considered called: graph of ");
- DDMEO(get_irg_ent (get_irp_irg(i)));
+ DDMEO(get_irg_entity (get_irp_irg(i)));
}
}
}
/*
* $Log$
+ * Revision 1.22 2004/08/13 08:57:15 beyhan
+ * normalized names of functions, enums ...
+ * added suffix as argument to dumpers, removed global variable
+ * removed support for tarval/Const
+ *
* Revision 1.21 2004/07/08 15:50:56 goetz
* firmstat added
*
}
/* initialize all ident stuff */
- id_init(1024);
+ init_ident (1024);
/* enhanced statistics, need idents */
- stat_init(def_params.enable_statistics);
+ init_stat();
/* create the type kinds. */
init_tpop();
/* create an obstack and put all tarvals in a pdeq */
finish_op();
finish_mode();
finish_tpop();
- id_finish();
+ finish_ident();
}
extern "C" {
#endif
-#include "old_fctnames.h"
+// #include "old_fctnames.h"
+
/* The representations */
#include "firm_common.h" /* common type tags. */
printf("type: %s %s: %ld (%p)\n", get_type_tpop_name(X), get_type_name(X), get_type_nr(X), X);
break;
case k_ir_graph:
- printf("graph: %s: %ld (%p)\n", get_entity_name(get_irg_ent(X)), get_irg_graph_nr(X), X);
+ printf("graph: %s: %ld (%p)\n", get_entity_name(get_irg_entity(X)), get_irg_graph_nr(X), X);
break;
case k_ir_node:
printf("irnode: %s%s %ld (%p)\n", get_irn_opname(X), get_mode_name(get_irn_mode(X)), get_irn_node_nr(X), X);
else
{
/* add this node to block's node list */
- ir_node *block = get_nodes_Block(irn);
+ ir_node *block = get_nodes_block(irn);
data = fw_get_data(block);
ARR_APP1(ir_node *, FW_GET_DATA_LIST(data), irn);
}
#ifndef __OLD_FCTNAMES_H__
#define __OLD_FCTNAMES_H__
+/* firmstat */
+#define stat_init init_stat
+
+/* ircons */
+#define add_in_edge(X, Y) add_immBlock_pred(X, Y)
+#define mature_block(X) mature_immBlock(X)
+#define switch_block(X) set_cur_block(X)
+
+
/* irgraph */
-#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
+#define get_irg_ent(X) get_irg_entity(X)
+#define get_irg_params get_irg_n_locs
+#define get_irg_n_loc get_irg_n_locs
+#define set_irg_ent(X, Y) set_irg_entity(X, Y)
+#define set_irg_params set_irg_n_loc
+#define no_dom dom_none
+#define no_outs outs_none
/* irnode.h */
-#define get_Return_n_res get_Return_n_ress
-#define get_Sel_n_index get_Sel_n_indexs
-#define get_SymConst_ptrinfo get_SymConst_name
-#define set_SymConst_ptrinfo set_SymConst_name
+#define get_Return_n_res get_Return_n_ress
+#define get_Sel_n_index get_Sel_n_indexs
+#define get_SymConst_ptrinfo get_SymConst_name
+#define set_SymConst_ptrinfo set_SymConst_name
+#define get_nodes_Block(X) get_nodes_block(X)
+#define set_nodes_Block(X, Y) set_nodes_block(X, Y)
+#define get_Start_irg(X) get_irn_irg(X)
+#define get_EndReg_irg(X) get_irn_irg(X)
+#define get_EndExcept_irg(X) get_irn_irg(X)
+#define get_CallBegin_irg(X) get_irn_irg(X)
+#define get_ip_cfop_irg(X) get_irn_irg(X)
+#define skip_nop(X) skip_Id(X)
+
/* irmode.h */
-#define get_ident_of_mode get_mode_ident
-#define get_size_of_mode get_mode_size
-#define get_ld_align_of_mode get_mode_ld_align
-#define get_min_of_mode get_mode_min
-#define get_max_of_mode get_mode_max
-#define get_null_of_mode get_mode_null
-#define get_fsigned_of_mode get_mode_fsigned
-#define get_ffloat_of_mode get_mode_ffloat
-#define get_mode_size(X) { assert(get_mode_size_bytes(X) != -1); get_mode_size_bytes(X); }
+#define get_ident_of_mode get_mode_ident
+#define get_size_of_mode get_mode_size
+#define get_ld_align_of_mode get_mode_ld_align
+#define get_min_of_mode get_mode_min
+#define get_max_of_mode get_mode_max
+#define get_mode_vector_elems(X) get_mode_n_vector_elems(X)
+#define get_null_of_mode get_mode_null
+#define get_fsigned_of_mode get_mode_fsigned
+#define get_ffloat_of_mode get_mode_ffloat
+#define get_mode_size(X) { assert(get_mode_size_bytes(X) != -1); get_mode_size_bytes(X); }
+
+
+/* irop */
+#define floats op_pin_state_floats
+#define pinned op_pin_state_pinned
+#define op_pinned op_pin_state
/* type.h */
#define get_type_nameid(_t_) get_type_ident(_t_)
#define tarval_from_long(X, Y) new_tarval_from_long(Y, X)
#define tarval_P_from_entity(X) new_tarval_from_entity(X, mode_P_mach)
#define tarval_to_entity(X) get_tarval_entity(X)
-
+#define tarval_to_long(X) get_tarval_long(X)
+#define tarval_to_double(X) get_tarval_double(X)
+#define tarval_set_mode_output_option(X, Y) set_tarval_mode_output_option(X, Y)
+#define tarval_get_mode_output_option(X) get_tarval_mode_output_option(X)
+#define tarval_bitpattern(X) get_tarval_bitpattern(X)
+#define tarval_sub_bits(X, Y) get_tarval_sub_bits(X, Y)
+#define tarval_classify(X) classify_tarval(X)
/* ident.h */
-#define id_to_strlen get_id_strlen
-#define id_to_str get_id_str
-
+#define id_to_strlen(X) get_id_strlen(X)
+#define id_to_str(X) get_id_str(X)
#endif
set *__id_set;
-void id_init(int initial_n_idents)
+void init_ident(int initial_n_idents)
{
__id_set = new_set(memcmp, initial_n_idents);
}
-void id_finish (void) {
+void finish_ident (void) {
del_set(__id_set);
__id_set = NULL;
}
-ident *(id_from_str)(const char *str, int len)
+ident *(new_id_from_chars)(const char *str, int len)
{
return __id_from_str(str, len);
}
ident *new_id_from_str(const char *str)
{
assert(str);
- return id_from_str(str, strlen(str));
+ return new_id_from_chars(str, strlen(str));
}
const char *(get_id_str)(ident *id)
*
* @see new_id_from_str(), get_id_strlen()
*/
-ident *id_from_str (const char *str, int len);
+ident *new_id_from_chars (const char *str, int len);
/**
* Returns a string represented by an ident.
*
* @return cp - a string
*
- * @see new_id_from_str(), id_from_str(), get_id_strlen()
+ * @see new_id_from_str(), new_id_from_chars(), get_id_strlen()
*/
const char *get_id_str (ident *id);
*
* @return len - the length of the string
*
- * @see new_id_from_str(), id_from_str(), get_id_str()
+ * @see new_id_from_str(), new_id_from_chars(), get_id_str()
*/
int get_id_strlen(ident *id);
/**
* @param prefix - the prefix
* @param id - the ident
*
- * @see new_id_from_str(), id_from_str(), get_id_str(), id_is_prefix()
+ * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
*/
int id_is_prefix (ident *prefix, ident *id);
* @param suffix - the suffix
* @param id - the ident
*
- * @see new_id_from_str(), id_from_str(), get_id_str(), id_is_prefix()
+ * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
*/
int id_is_suffix (ident *suffix, ident *id);
* @param infix - the infix
* @param id - the ident to search in
*
- * @see new_id_from_str(), id_from_str(), get_id_str(), id_is_prefix()
+ * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix()
*/
/* int id_contains(ident *infix, ident *id); */
* @param id - the ident
* @param c - the character
*
- * @see new_id_from_str(), id_from_str(), get_id_str()
+ * @see new_id_from_str(), new_id_from_chars(), get_id_str()
*/
int id_contains_char (ident *id, char c);
* @return
* number of bytes written
*
- * @see new_id_from_str(), id_from_str(), get_id_str(), id_is_prefix(), fprint_id()
+ * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix(), fprint_id()
*/
int print_id (ident *id);
* @return
* number of btes written
*
- * @see new_id_from_str(), id_from_str(), get_id_str(), id_is_prefix(), print_id()
+ * @see new_id_from_str(), new_id_from_chars(), get_id_str(), id_is_prefix(), print_id()
*/
int fprint_id (FILE *F, ident *id);
# include "ident.h"
# include "set.h"
-void id_init (int initial_n_idents);
-void id_finish (void);
+void init_ident (int initial_n_idents);
+void finish_ident (void);
#define ID_HASH(str, len) \
((( ((unsigned char *)(str))[0] * 33 \
static INLINE int __get_id_strlen(ident *id) { return id->size; }
-#define id_from_str(str, len) __id_from_str(str, len)
+#define new_id_from_chars(str, len) __id_from_str(str, len)
#define get_id_str(id) __get_id_str(id)
#define get_id_strlen(id) __get_id_strlen(id)
static void caller_init(int arr_length, entity ** free_methods) {
int i, j;
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
- set_entity_link(get_irg_ent(get_irp_irg(i)), irg_data_create());
+ set_entity_link(get_irg_entity(get_irp_irg(i)), irg_data_create());
}
for (i = arr_length - 1; i >= 0; --i) {
irg_data_t * data = get_entity_link(free_methods[i]);
*call_tail = node;
}
} else if (get_irn_op(node) == op_Phi) {
- ir_node * block = get_nodes_Block(node);
+ ir_node * block = get_nodes_block(node);
set_irn_link(node, get_irn_link(block));
set_irn_link(block, node);
}
filter = new_Filter(get_Proj_pred(proj), get_irn_mode(proj), get_Proj_proj(proj));
/* Die Proj- (Id-) Operation sollte im gleichen Grundblock stehen, wie die
* Filter-Operation. */
- set_nodes_Block(proj, get_nodes_Block(filter));
+ set_nodes_block(proj, get_nodes_block(filter));
exchange(proj, filter);
return filter;
}
* den Start-Block verschieben. */
for (proj = get_irn_link(get_irg_start(irg)); proj; proj = get_irn_link(proj)) {
if (get_Proj_pred(proj) != get_irg_start(irg)
- || (get_Proj_proj(proj) != pns_initial_exec && get_Proj_proj(proj) != pns_args)) {
+ || (get_Proj_proj(proj) != pn_Start_X_initial_exec && get_Proj_proj(proj) != pn_Start_T_args)) {
ir_node * filter = exchange_proj(proj);
set_Filter_cg_pred_arr(filter, n_callers, in);
} else {
- set_nodes_Block(proj, start_block);
+ set_nodes_block(proj, start_block);
}
}
}
}
/* Globle Einträge für ersetzte Operationen korrigieren. */
- set_irg_frame (irg, skip_nop(get_irg_frame(irg)));
- set_irg_globals (irg, skip_nop(get_irg_globals(irg)));
- set_irg_initial_mem(irg, skip_nop(get_irg_initial_mem(irg)));
+ set_irg_frame (irg, skip_Id(get_irg_frame(irg)));
+ set_irg_globals (irg, skip_Id(get_irg_globals(irg)));
+ set_irg_initial_mem(irg, skip_Id(get_irg_initial_mem(irg)));
/* Unbekannten Aufrufer sofort eintragen. */
if (data->open) {
}
if (n_ret > 0) {
- int n_res = get_method_n_ress(get_entity_type(get_irg_ent(irg)));
+ int n_res = get_method_n_ress(get_entity_type(get_irg_entity(irg)));
ir_node ** in = NEW_ARR_F(ir_node *, n_ret);
/* block */
for (i = n_ret - 1; i >= 0; --i) {
- set_irg_current_block(irg, get_nodes_Block(ret_arr[i]));
+ set_irg_current_block(irg, get_nodes_block(ret_arr[i]));
in[i] = new_Jmp();
}
create_Block(n_ret, in);
for (i = n_except - 1; i >= 0; --i) {
ir_node * node = skip_Proj(skip_Tuple(except_arr[i]));
if (get_irn_op(node) == op_Call) {
- in[i] = new_r_Proj(irg, get_nodes_Block(node), node, mode_M, 3);
+ in[i] = new_r_Proj(irg, get_nodes_block(node), node, mode_M, 3);
} else if (get_irn_op(node) == op_Raise) {
- in[i] = new_r_Proj(irg, get_nodes_Block(node), node, mode_M, 1);
+ in[i] = new_r_Proj(irg, get_nodes_block(node), node, mode_M, 1);
} else {
assert(is_fragile_op(node));
/* We rely that all cfops have the memory output at the same position. */
- in[i] = new_r_Proj(irg, get_nodes_Block(node), node, mode_M, 0);
+ in[i] = new_r_Proj(irg, get_nodes_block(node), node, mode_M, 0);
}
}
data->except_mem = new_Phi(n_except, in, mode_M);
/* Zwischengespeicherte Daten wieder freigeben. */
static void cleanup_irg(ir_graph * irg) {
- entity * ent = get_irg_ent(irg);
+ entity * ent = get_irg_entity(irg);
irg_data_t * data = get_entity_link(ent);
assert(data);
if (data->res) DEL_ARR_F(data->res);
static void move_phis(ir_node * from_block, ir_node * to_block) {
ir_node * phi;
for (phi = get_irn_link(from_block); phi != NULL; phi = get_irn_link(phi)) {
- set_nodes_Block(phi, to_block);
+ set_nodes_block(phi, to_block);
}
assert(get_irn_link(to_block) == NULL);
set_irn_link(to_block, get_irn_link(from_block));
for (i = arity - 1; i >= 0; --i) {
ir_node * pred = get_irn_n(node, i);
- if (get_nodes_Block(pred) == from_block) {
+ if (get_nodes_block(pred) == from_block) {
move_nodes(from_block, to_block, pred);
}
}
- set_nodes_Block(node, to_block);
+ set_nodes_block(node, to_block);
/* Move projs of this node. */
proj = get_irn_link(node);
for (; proj; proj = skip_Id(get_irn_link(proj))) {
if (get_irn_op(proj) != op_Proj && get_irn_op(proj) != op_Filter) continue;
- if ((get_nodes_Block(proj) == from_block) && (skip_Proj(get_irn_n(proj, 0)) == node))
- set_nodes_Block(proj, to_block);
+ if ((get_nodes_block(proj) == from_block) && (skip_Proj(get_irn_n(proj, 0)) == node))
+ set_nodes_block(proj, to_block);
}
}
assert(irg);
assert(get_entity_peculiarity(callee) == peculiarity_existent); /* Else data is not initalized. */
assert((0 <= data->count) &&
- (data->count < get_Block_cg_n_cfgpreds(get_nodes_Block(start))));
+ (data->count < get_Block_cg_n_cfgpreds(get_nodes_block(start))));
- set_Block_cg_cfgpred(get_nodes_Block(start), data->count, exec);
+ set_Block_cg_cfgpred(get_nodes_block(start), data->count, exec);
for (filter = get_irn_link(start); filter; filter = get_irn_link(filter)) {
if (get_irn_op(filter) != op_Filter) continue;
if (get_Proj_pred(filter) == start) {
switch ((int) get_Proj_proj(filter)) {
- case pns_global_store:
+ case pn_Start_M:
set_Filter_cg_pred(filter, data->count, get_Call_mem(call));
break;
- case pns_frame_base:
+ case pn_Start_P_frame_base:
/* "frame_base" wird nur durch Unknown dargestellt. Man kann ihn aber
* auch explizit darstellen, wenn sich daraus Vorteile für die
* Datenflussanalyse ergeben. */
set_Filter_cg_pred(filter, data->count, get_cg_Unknown(get_irn_mode(filter)));
break;
- case pns_globals:
+ case pn_Start_P_globals:
/* "globals" wird nur durch Unknown dargestellt. Man kann ihn aber auch
* explizit darstellen, wenn sich daraus Vorteile für die
* Datenflussanalyse ergeben. */
/* Returns true if only caller of irg is "Unknown". */
static bool is_outermost_graph(ir_graph *irg) {
- irg_data_t * data = get_entity_link(get_irg_ent(irg));
+ irg_data_t * data = get_entity_link(get_irg_entity(irg));
if (data->count) {
return false;
} else if (data->open) {
* aufgerufenen Methoden eintragen. */
static void construct_call(ir_node * call) {
int n_callees = get_Call_n_callees(call);
- ir_node * post_block = get_nodes_Block(call); /* block nach dem Aufruf */
+ ir_node * post_block = get_nodes_block(call); /* block nach dem Aufruf */
ir_node * pre_block = create_Block(get_Block_n_cfgpreds(post_block),
get_Block_cfgpred_arr(post_block)); /* block vor dem Aufruf (mit CallBegin) */
ir_node * except_block = NULL, * proj;
/* CallBegin might be entry to endless recursion. */
add_End_keepalive(get_irg_end(get_irn_irg(pre_block)), pre_block);
ir_node ** in = NEW_ARR_F(ir_node *, n_callees);
- entity * caller = get_irg_ent(current_ir_graph); /* entity des aktuellen ir_graph */
+ entity * caller = get_irg_entity(current_ir_graph); /* entity des aktuellen ir_graph */
entity ** callees = NEW_ARR_F(entity *, n_callees); /* aufgerufene Methoden: entity */
ir_graph ** irgs = NEW_ARR_F(ir_graph *, n_callees); /* aufgerufene Methoden: ir_graph */
irg_data_t ** data = NEW_ARR_F(irg_data_t *, n_callees); /* aufgerufene Methoden: irg_data_t */
for (i = 0; i < n_callees; ++i) {
if (data[i]) { /* explicit */
if (data[i]->reg) {
- in[i] = new_r_Proj(irgs[i], get_nodes_Block(data[i]->reg),
+ in[i] = new_r_Proj(irgs[i], get_nodes_block(data[i]->reg),
data[i]->reg, mode_X, data[i]->count);
} else {
in[i] = new_Bad();
if (is_outermost_graph(current_ir_graph)) {
except_block = get_irg_end_block(current_ir_graph);
} else {
- irg_data_t * tmp_data = get_entity_link(get_irg_ent(current_ir_graph));
+ irg_data_t * tmp_data = get_entity_link(get_irg_entity(current_ir_graph));
except_block = get_nodes_block(tmp_data->except);
}
} else
{
except_block = create_Block(1, &proj);
- set_nodes_Block(proj, except_block);
+ set_nodes_block(proj, except_block);
exchange(proj, new_Break());
set_irg_current_block(current_ir_graph, pre_block);
set_irn_n(except_block, 0, new_Proj(call, mode_X, 1));
entity * callee = get_Call_callee(call, i);
if (data[i]) { /* explicit */
if (data[i]->except) {
- in[i] = new_r_Proj(get_entity_irg(callee), get_nodes_Block(data[i]->except),
+ in[i] = new_r_Proj(get_entity_irg(callee), get_nodes_block(data[i]->except),
data[i]->except, mode_X, data[i]->count);
} else {
in[i] = new_Bad();
if (get_Proj_proj(proj) == 0) { /* memory */
ir_node * filter;
- set_nodes_Block(proj, post_block);
+ set_nodes_block(proj, post_block);
filter = exchange_proj(proj);
/* filter in die Liste der Phis aufnehmen */
if (get_irn_link(filter) == NULL) { /* note CSE */
} else if (get_Proj_proj(proj) == 3) { /* except_mem */
ir_node * filter;
- set_nodes_Block(proj, post_block);
+ set_nodes_block(proj, post_block);
assert(except_block);
set_irg_current_block(current_ir_graph, except_block);
filter = exchange_proj(proj);
ir_node * filter;
assert(is_Proj(get_Proj_pred(proj)) && get_Proj_pred(get_Proj_pred(proj)) == call);
- set_nodes_Block(proj, post_block);
+ set_nodes_block(proj, post_block);
filter = exchange_proj(proj);
/* filter in die Liste der Phis aufnehmen */
if (get_irn_link(filter) == NULL) { /* not CSE */
/* prepare irgs */
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
ir_graph * irg = get_irp_irg(i);
- entity * ent = get_irg_ent(irg);
+ entity * ent = get_irg_entity(irg);
irg_data_t * data = get_entity_link(ent);
if (data->count) {
prepare_irg(irg, data);
if (get_irn_op(node) == op_Block) {
remove_Block_cg_cfgpred_arr(node);
} else if (get_irn_op(node) == op_Filter) {
- set_irg_current_block(current_ir_graph, get_nodes_Block(node));
+ set_irg_current_block(current_ir_graph, get_nodes_block(node));
exchange(node, new_Proj(get_Filter_pred(node), get_irn_mode(node), get_Filter_proj(node)));
} else if (get_irn_op(node) == op_Break) {
- set_irg_current_block(current_ir_graph, get_nodes_Block(node));
+ set_irg_current_block(current_ir_graph, get_nodes_block(node));
exchange(node, new_Jmp());
} else if (get_irn_op(node) == op_Call) {
remove_Call_callee_arr(node);
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
ir_graph * irg = get_irp_irg(i);
irg_walk_graph(irg, destruct_walker, clear_link, NULL);
- set_irg_frame(irg, skip_nop(get_irg_frame(irg)));
- set_irg_globals(irg, skip_nop(get_irg_globals(irg)));
- set_irg_initial_mem(irg, skip_nop(get_irg_initial_mem(irg)));
+ set_irg_frame(irg, skip_Id(get_irg_frame(irg)));
+ set_irg_globals(irg, skip_Id(get_irg_globals(irg)));
+ set_irg_initial_mem(irg, skip_Id(get_irg_initial_mem(irg)));
set_irg_callee_info_state(irg, irg_callee_info_none);
set_irg_end_reg(irg, get_irg_end(irg));
set_irg_end_except(irg, get_irg_end(irg));
/* clean */
for (i = get_irp_n_irgs() - 1; i >= 0; --i) {
ir_graph * irg = get_irp_irg(i);
- entity * ent = get_irg_ent(irg);
+ entity * ent = get_irg_entity(irg);
/* Removing any graph invalidates all interprocedural loop trees. */
if (get_irg_loopinfo_state(irg) == loopinfo_ip_consistent ||
get_irg_loopinfo_state(irg) == loopinfo_ip_inconsistent) {
{
type *tp = unknown_type;
/* removing this somehow causes errors in jack. */
- if (tarval_is_entity(con))
- tp = find_pointer_type_to_type(get_entity_type(get_tarval_entity(con)));
-
return new_rd_Const_type (db, irg, block, mode, con, tp);
}
Call Graph: ( A ---> B == A "calls" B)
- get_value mature_block
+ get_value mature_immBlock
| |
| |
| |
The call order
get_value (makes Phi0, put's it into graph_arr)
set_value (overwrites Phi0 in graph_arr)
- mature_block (upgrades Phi0, puts it again into graph_arr, overwriting
+ mature_immBlock (upgrades Phi0, puts it again into graph_arr, overwriting
the proper value.)
fails. */
if (!block->attr.block.graph_arr[pos]) {
/* The block is not mature, we don't know how many in's are needed. A Phi
with zero predecessors is created. Such a Phi node is called Phi0
node. (There is also an obsolete Phi0 opcode.) The Phi0 is then added
- to the list of Phi0 nodes in this block to be matured by mature_block
+ to the list of Phi0 nodes in this block to be matured by mature_immBlock
later.
The Phi0 has to remember the pos of it's internal value. If the real
Phi is computed, pos is used to update the array with the local
optimization possibilities.
The Phi0 node either is allocated in this function, or it comes from
a former call to get_r_value_internal. In this case we may not yet
- exchange phi0, as this is done in mature_block. */
+ exchange phi0, as this is done in mature_immBlock. */
if (!phi0) {
phi0_all = block->attr.block.graph_arr[pos];
if (!((get_irn_op(phi0_all) == op_Phi) &&
/* The block is not mature, we don't know how many in's are needed. A Phi
with zero predecessors is created. Such a Phi node is called Phi0
node. The Phi0 is then added to the list of Phi0 nodes in this block
- to be matured by mature_block later.
+ to be matured by mature_immBlock later.
The Phi0 has to remember the pos of it's internal value. If the real
Phi is computed, pos is used to update the array with the local
values. */
/** Finalize a Block node, when all control flows are known. */
/** Acceptable parameters are only Block nodes. */
void
-mature_block (ir_node *block)
+mature_immBlock (ir_node *block)
{
int ins;
/* add an adge to a jmp/control flow node */
void
-add_in_edge (ir_node *block, ir_node *jmp)
+add_immBlock_pred (ir_node *block, ir_node *jmp)
{
if (block->attr.block.matured) {
assert(0 && "Error: Block already matured!\n");
/* changing the current block */
void
-switch_block (ir_node *target)
+set_cur_block (ir_node *target)
{
current_ir_graph->current_block = target;
}
/** Useful access routines **/
/* Returns the current block of the current graph. To set the current
- block use switch_block(). */
+ block use set_cur_block. */
ir_node *get_cur_block() {
return get_irg_current_block(current_ir_graph);
}
*
* *args The ir_node that produces the arguments of the method as
* it's result. This is a Proj node on the fourth output of
- * the start node. This output is tagged as pns_args.
+ * the start node. This output is tagged as pn_Start_T_args.
*
* *bad The bad node is an auxiliary node. It is needed only once,
* so there is this globally reachable node.
*
* *current_block A pointer to the current block. Any node created with
* one of the node constructors (new_<opcode>) are assigned
- * to this block. It can be set with switch_block(block).
+ * to this block. It can be set with set_cur_block(block).
* Only needed for ir construction.
*
* params/n_loc An int giving the number of local variables in this
* *link A pointer to an ir_node. With this pointer all Phi nodes
* are attached to a Block, i.e., a Block points to it's
* first Phi node, this node points to the second Phi node
- * in the Block and so fourth. Used in mature_block
+ * in the Block and so fourth. Used in mature_immBlock
* to find all Phi nodes to be matured. It's also used to
* annotate a node with a better, optimized version of it.
*
* (new_<Node> constructurs and a set of additional routines.)
* * A less comfortable interface where all predecessors except the block
* an operation belongs to need to be specified. SSA must be constructed
- * by hand. (new_<Node> constructors and switch_block()). This interface
+ * by hand. (new_<Node> constructors and set_cur_block()). This interface
* is called "block oriented". It automatically calles the local optimizations
* for each new node.
* * An even less comfortable interface where the block needs to be specified
*
* A global variable holds the current basic block. All (non block) nodes
* generated are added to this block. The current block can be set with
- * switch_block(block). If several blocks are constructed in parallel block
+ * set_cur_block(block). If several blocks are constructed in parallel block
* switches need to be performed constantly.
*
* To generate a Block node (with the comfortable interface) it's predecessor
* control flow nodes need not be known. In case of cyclic control flow these
- * can not be known when the block is constructed. With add_in_edge(block,
+ * can not be known when the block is constructed. With add_immBlock_pred(block,
* cfnode) predecessors can be added to the block. If all predecessors are
- * added to the block mature_block(b) needs to be called. Calling mature_block
+ * added to the block mature_immBlock(b) needs to be called. Calling mature_immBlock
* early improves the efficiency of the Phi node construction algorithm.
- * But if several blocks are constructed at once, mature_block must only
+ * But if several blocks are constructed at once, mature_immBlock must only
* be called after performing all set_values and set_stores in the block!
* (See documentation of new_immBlock constructor.)
*
* ir_node *this_block, *cf_pred1, *cf_pred2, *a_val, *mem, *div, *res, *cf_op;
*
* this_block = new_immBlock();
- * add_in_edge(this_block, cf_pred1);
- * add_in_edge(this_block, cf_pred2);
- * mature_block(this_block);
+ * add_immBlock_pred(this_block, cf_pred1);
+ * add_immBlock_pred(this_block, cf_pred2);
+ * mature_immBlock(this_block);
* a_val = get_value(42, mode_Iu);
* mem = get_store();
* div = new_Div(mem, a_val, a_val);
* ir_node *new_FuncCall (ir_node *store, ir_node *callee, int arity,
* ir_node **in, type_method *type);
*
- * void add_in_edge (ir_node *block, ir_node *jmp);
- * void mature_block (ir_node *block);
- * void switch_block (ir_node *target);
+ * void add_immBlock_pred (ir_node *block, ir_node *jmp);
+ * void mature_immBlock (ir_node *block);
+ * void set_cur_block (ir_node *target);
* ir_node *get_value (int pos, ir_mode *mode);
* void set_value (int pos, ir_node *value);
* ir_node *get_store (void);
* Creates a new block. Sets current_block to itself. When a new block is
* created it cannot be known how many predecessors this block will have in the
* control flow graph. Therefore the list of inputs can not be fixed at
- * creation. Predecessors can be added with add_in_edge (block, control flow
+ * creation. Predecessors can be added with add_immBlock_pred (block, control flow
* operation). With every added predecessor the number of inputs to Phi nodes
* also changes.
*
- * The block can be completed by mature_block(block) if all predecessors are
- * known. If several blocks are built at once, mature_block can only be called
+ * The block can be completed by mature_immBlock(block) if all predecessors are
+ * known. If several blocks are built at once, mature_immBlock can only be called
* after set_value has been called for all values that are life at the end
- * of the block. This is necessary so that Phi nodes created by mature_block
- * get the right predecessors in case of cyclic dependencies. If all set_values
+ * of the block. This is necessary so that Phi nodes created mature_immBlock * get the right predecessors in case of cyclic dependencies. If all set_values
* of this block are called after maturing it and before calling get_value
* in some block that is control flow dependent on this block, the construction
* is correct.
*
* block_before_loop = new_block();
* set_value(x);
- * mature_block(block_before_loop);
+ * mature_immBlock(block_before_loop);
* before2header = new_Jmp;
*
* loop_header = new_block ();
* loop_body = new_block ();
* body2header = new_Jmp();
*
- * add_in_edge(loop_header, before2header);
- * add_in_edge(loop_header, body2header);
- * add_in_edge(loop_body, header2body);
+ * add_immBlock_pred(loop_header, before2header);
+ * add_immBlock_pred(loop_header, body2header);
+ * add_immBlock_pred(loop_body, header2body);
*
- * mature_block(loop_header);
- * mature_block(loop_body);
+ * mature_immBlock(loop_header);
+ * mature_immBlock(loop_body);
*
* get_value(loop_body, x); // gets the Phi in loop_header
* set_value(loop_header, x); // sets the value the above get_value should
* // have returned!!!
*
- * Mature_block also fixes the number of inputs to the Phi nodes. Mature_block
+ * Mature_immBlock also fixes the number of inputs to the Phi nodes. Mature_immBlock
* should be called as early as possible, as afterwards the generation of Phi
* nodes is more efficient.
*
* No inputs except the block it belogns to.
* Output:
* A tuple of 4 (5, 6) distinct values. These are labeled by the following
- * projection numbers (pns_number):
- * * pns_initial_exec
- * mode X, points to the first block to be executed.
- * * pns_global_store
- * mode M, the global store
- * * pns_frame_base mode P, a pointer to the base of the procedures
- * stack frame.
- * * pns_globals mode P, a pointer to the part of the memory containing
- * _all_ global things.
- * * pns_args mode T, a tuple containing all arguments of the procedure.
+ * projection numbers (pn_Start):
+ * * pn_Start_X_initial_exec mode X, points to the first block to be exe * cuted.
+ * * pn_Start_M mode M, the global store
+ * * pn_Start_P_frame_base mode P, a pointer to the base of the proce * dures stack frame.
+ * * pn_Start_P_globals mode P, a pointer to the part of the memory * containing_all_ global things.
+ * * pn_Start_T_args mode T, a tuple containing all arguments of * the procedure.
*
*
* ir_node *new_End (void)
*
* @param target The new current block.
*/
-void switch_block (ir_node *target);
+void set_cur_block (ir_node *target);
/** Returns the current block of the current graph. */
ir_node *get_cur_block(void);
/*-----------------------------------------------------------------------*/
/* Needed from the interfase with debug support:
-void switch_block (ir_node *target); */
+void set_cur_block (ir_node *target); */
/** Constructor for a Block node.
*
ir_node *new_immBlock (void);
/** Add a control flow edge to an immature block. */
-void add_in_edge (ir_node *immblock, ir_node *jmp);
+void add_immBlock_pred (ir_node *immblock, ir_node *jmp);
/** Fix the number of predecessors of an immature block. */
-void mature_block (ir_node *block);
+void mature_immBlock (ir_node *block);
/** Get the current value of a local variable.
*/
typedef ir_node *default_initialize_local_variable_func_t(ir_mode *mode, int pos);
-/**
- * Initializes the graph construction.
- *
- * @param func @see default_initialize_local_variable_func_t
- */
-void init_cons (default_initialize_local_variable_func_t *func);
# endif /* _IRCONS_H_ */
#include "ircons.h"
# include "irgraph_t.h"
+/**
+ * Initializes the graph construction.
+ *
+ * @param func @see default_initialize_local_variable_func_t
+ */
+void init_cons (default_initialize_local_variable_func_t *func);
+
/* inline functions */
static INLINE ir_node *
/*******************************************************************/
/* A suffix to manipulate the file name. */
-char *dump_file_suffix = "";
char *dump_file_filter = "";
static int node_floats(ir_node *n) {
- return ((get_op_pinned(get_irn_op(n)) == floats) &&
- (get_irg_pinned(current_ir_graph) == floats));
+ return ((get_op_pinned(get_irn_op(n)) == op_pin_state_floats) &&
+ (get_irg_pinned(current_ir_graph) == op_pin_state_floats));
}
static const char *get_ent_dump_name(entity *ent) {
static const char *get_irg_dump_name(ir_graph *irg) {
/* Don't use get_entity_ld_ident (ent) as it computes the mangled name! */
- entity *ent = get_irg_ent(irg);
+ entity *ent = get_irg_entity(irg);
return get_ent_dump_name(ent);
}
/** Construct lists to walk ir block-wise.
*
- * Collects all blocks, nodes not pinned,
+ * Collects all blocks, nodes not op_pin_state_pinned,
* Bad and Unknown into a flexible array in link field of
* irg they belong to. Sets the irg link field to NULL in all
* graphs not visited.
case iro_Start: {
if (interprocedural_view) {
- fprintf(F, "%s %s", get_irn_opname(n), get_ent_dump_name(get_irg_ent(get_irn_irg(n))));
+ fprintf(F, "%s %s", get_irn_opname(n), get_ent_dump_name(get_irg_entity(get_irn_irg(n))));
break;
}
} /* fall through */
switch (get_irn_opcode(n)) {
case iro_Start:
if (false && interprocedural_view) {
- fprintf (F, "%s", get_ent_dump_name(get_irg_ent(current_ir_graph)));
+ fprintf (F, "%s", get_ent_dump_name(get_irg_entity(current_ir_graph)));
}
break;
case iro_Proj:
/* Source types */
switch (get_irn_opcode(n)) {
case iro_Start: {
- type *tp = get_entity_type(get_irg_ent(get_irn_irg(n)));
+ type *tp = get_entity_type(get_irg_entity(get_irn_irg(n)));
fprintf(F, "start of method of type %s \n", get_type_name_ex(tp, &bad));
for (i = 0; i < get_method_n_params(tp); ++i)
fprintf(F, " param %d type: %s \n", i, get_type_name_ex(get_method_param_type(tp, i), &bad));
} break;
case iro_Return: {
if (!interprocedural_view) {
- type *tp = get_entity_type(get_irg_ent(get_irn_irg(n)));
+ type *tp = get_entity_type(get_irg_entity(get_irn_irg(n)));
fprintf(F, "return in method of type %s \n", get_type_name_ex(tp, &bad));
for (i = 0; i < get_method_n_ress(tp); ++i)
fprintf(F, " res %d type: %s \n", i, get_type_name_ex(get_method_res_type(tp, i), &bad));
}
/** dumps a graph block-wise. Expects all blockless nodes in arr in irgs link.
- * The outermost nodes: blocks and nodes not pinned, Bad, Unknown. */
+ * The outermost nodes: blocks and nodes not op_pin_state_pinned, Bad, Unknown. */
static void
dump_block_graph(FILE *F, ir_graph *irg) {
int i;
fprintf(F, "graph: { title: \"");
PRINT_IRGID(irg);
fprintf(F, "\" label: \"%s\" status:clustered color:white \n",
- get_ent_dump_name(get_irg_ent(irg)));
+ get_ent_dump_name(get_irg_entity(irg)));
dump_block_graph(F, irg);
/** Routine to dump a graph, blocks as conventional nodes.
*/
void
-dump_ir_graph (ir_graph *irg)
+dump_ir_graph (ir_graph *irg, char *suffix )
{
FILE *f;
ir_graph *rem;
- char *suffix;
+ char *suffix1;
rem = current_ir_graph;
- /* if a filter is set, dump only the irg's that match the filter */
- if (strncmp(get_entity_name(get_irg_ent(irg)), dump_file_filter, strlen(dump_file_filter)) != 0)
- return;
-
+ if(strncmp(get_entity_name(get_irg_entity(irg)),dump_file_filter,strlen(dump_file_filter))!=0) return;
current_ir_graph = irg;
- if (interprocedural_view) suffix = "-pure-ip";
- else suffix = "-pure";
- f = vcg_open(irg, dump_file_suffix, suffix);
+ if (interprocedural_view) suffix1 = "-pure-ip";
+ else suffix1 = "-pure";
+ f = vcg_open(irg, suffix, suffix1);
dump_vcg_header(f, get_irg_dump_name(irg), NULL);
/* walk over the graph */
irg_walk(get_irg_end(irg), NULL, dump_whole_node, f);
/* dump the out edges in a separate walk */
- if ((dump_out_edge_flag) && (get_irg_outs_state(irg) != no_outs)) {
- irg_out_walk(get_irg_start(irg), dump_out_edge, NULL, f);
+ if ((dump_out_edge_flag) && (get_irg_outs_state(irg) != outs_none)) {
+ irg_out_walk(get_irg_start(irg), dump_out_edge, NULL, NULL);
}
vcg_close(f);
void
-dump_ir_block_graph (ir_graph *irg)
+dump_ir_block_graph (ir_graph *irg, char *suffix)
{
FILE *f;
int i;
- char *suffix;
-
- /* if a filter is set, dump only the irg's that match the filter */
- if (strncmp(get_entity_name(get_irg_ent(irg)), dump_file_filter, strlen(dump_file_filter)) != 0)
- return;
+ char *suffix1;
- if (interprocedural_view) suffix = "-ip";
- else suffix = "";
- f = vcg_open(irg, dump_file_suffix, suffix);
+ if(strncmp(get_entity_name(get_irg_entity(irg)),dump_file_filter,strlen(dump_file_filter))!=0) return;
+ if (interprocedural_view) suffix1 = "-ip";
+ else suffix1 = "";
+ f = vcg_open(irg, suffix, suffix1);
dump_vcg_header(f, get_irg_dump_name(irg), NULL);
construct_block_lists(irg);
/** dumps a graph with type information
*/
void
-dump_ir_graph_w_types (ir_graph *irg)
+dump_ir_graph_w_types (ir_graph *irg, char *suffix)
{
FILE *f;
ir_graph *rem = current_ir_graph;
- char *suffix;
+ char *suffix1;
/* if a filter is set, dump only the irg's that match the filter */
if (strncmp(get_irg_dump_name(irg), dump_file_filter, strlen(dump_file_filter)) != 0)
current_ir_graph = irg;
- if (interprocedural_view) suffix = "-pure-wtypes-ip";
- else suffix = "-pure-wtypes";
- f = vcg_open(irg, dump_file_suffix, suffix);
+ if (interprocedural_view) suffix1 = "-pure-wtypes-ip";
+ else suffix1 = "-pure-wtypes";
+ f = vcg_open(irg,suffix, suffix1);
dump_vcg_header(f, get_irg_dump_name(irg), NULL);
/* dump common ir graph */
}
void
-dump_ir_block_graph_w_types (ir_graph *irg)
+dump_ir_block_graph_w_types (ir_graph *irg, char *suffix)
{
FILE *f;
int i;
- char *suffix;
+ char *suffix1;
ir_graph *rem = current_ir_graph;
/* if a filter is set, dump only the irg's that match the filter */
if (strncmp(get_irg_dump_name(irg), dump_file_filter, strlen(dump_file_filter)) != 0)
return;
- if (interprocedural_view) suffix = "-wtypes-ip";
- else suffix = "-wtypes";
- f = vcg_open(irg, dump_file_suffix, suffix);
+ if (interprocedural_view) suffix1 = "-wtypes-ip";
+ else suffix1 = "-wtypes";
+ f = vcg_open(irg, suffix, suffix1);
dump_vcg_header(f, get_irg_dump_name(irg), NULL);
/* dump common blocked ir graph */
}
void
-dump_cfg (ir_graph *irg)
+dump_cfg (ir_graph *irg, char *suffix)
{
FILE *f;
ir_graph *rem = current_ir_graph;
current_ir_graph = irg;
- f = vcg_open(irg, dump_file_suffix, "-cfg");
+ f = vcg_open(irg, suffix, "-cfg");
dump_vcg_header(f, get_irg_dump_name(irg), NULL);
if (interprocedural_view) {
for (i = 0; i < n_irgs; ++i) {
ir_graph *irg = get_irp_irg(i);
- entity *ent = get_irg_ent(irg);
+ entity *ent = get_irg_entity(irg);
int j, n_callees = get_irg_n_callees(irg);
dump_entity_node(F, ent);
/* Dump all irgs in interprocedural view to a single file. */
-void dump_all_cg_block_graph(void) {
+void dump_all_cg_block_graph(char *suffix) {
FILE *f;
int i;
int rem_view = interprocedural_view;
interprocedural_view = 1;
- f = vcg_open_name("All_graphs", dump_file_suffix);
+ f = vcg_open_name("All_graphs", suffix);
dump_vcg_header(f, "All_graphs", NULL);
/* collect nodes in all irgs reachable in call graph*/
/***********************************************************************/
void
-dump_type_graph (ir_graph *irg)
+dump_type_graph (ir_graph *irg, char *suffix)
{
FILE *f;
ir_graph *rem;
current_ir_graph = irg;
- f = vcg_open(irg, dump_file_suffix, "-type");
+ f = vcg_open(irg, suffix, "-type");
dump_vcg_header(f, get_irg_dump_name(irg), NULL);
/* walk over the blocks in the graph */
}
void
-dump_all_types (void)
+dump_all_types (char *suffix)
{
- FILE *f = vcg_open_name("All_types", dump_file_suffix);
+ FILE *f = vcg_open_name("All_types", suffix);
dump_vcg_header(f, "All_types", NULL);
type_walk(dump_type_info, NULL, f);
inc_irg_visited(get_const_code_irg());
}
void
-dump_class_hierarchy (bool entities)
+dump_class_hierarchy (bool entities, char *suffix)
{
- FILE *f = vcg_open_name("class_hierarchy", dump_file_suffix);
+ FILE *f = vcg_open_name("class_hierarchy", suffix);
h_env_t env;
env.f = f;
/* dump_ir_graph_w_types */
/***********************************************************************/
-void dump_all_ir_graphs(dump_graph_func *dmp_grph) {
+void dump_all_ir_graphs(dump_graph_func *dmp_grph, char *suffix) {
int i;
for (i=0; i < get_irp_n_irgs(); i++) {
- dmp_grph(get_irp_irg(i));
+ dmp_grph(get_irp_irg(i), suffix);
}
}
*
* @see turn_off_edge_labels()
*/
-void dump_ir_graph (ir_graph *irg);
+void dump_ir_graph (ir_graph *irg, char *suffix);
#define dump_cg_graph dump_ir_graph
/**
*
* @see turn_off_edge_labels()
*/
-void dump_ir_block_graph (ir_graph *irg);
+void dump_ir_block_graph (ir_graph *irg, char *suffix);
#define dump_cg_block_graph dump_ir_block_graph
/** Dumps all graphs in interprocedural view to a file named All_graphs.vcg.
*/
-void dump_all_cg_block_graph(void);
+void dump_all_cg_block_graph(char *suffix);
/**
* Dumps a firm graph and all the type information needed for Calls,
*
* @see turn_off_edge_labels()
*/
-void dump_ir_graph_w_types (ir_graph *irg);
+void dump_ir_graph_w_types (ir_graph *irg, char *suffix);
/**
* Dumps a firm graph and all the type information needed for Calls,
*
* @see turn_off_edge_labels()
*/
-void dump_ir_block_graph_w_types (ir_graph *irg);
+void dump_ir_block_graph_w_types (ir_graph *irg, char *suffix);
/**
* The type of a walker function that is called for each graph.
*
* @param irg current visited graph
*/
-typedef void dump_graph_func(ir_graph *irg);
+typedef void dump_graph_func(ir_graph *irg, char *suffix);
/**
* A walker that calls a dumper for each graph.
*
* @see turn_off_edge_labels()
*/
-void dump_all_ir_graphs (dump_graph_func *dump_graph);
+void dump_all_ir_graphs (dump_graph_func *dump_graph, char *suffix);
/**
*
* @see turn_off_edge_labels()
*/
-void dump_cfg (ir_graph *irg);
+void dump_cfg (ir_graph *irg, char *suffix);
/** Dump the call graph.
*
* @see turn_off_edge_labels()
*/
-void dump_type_graph (ir_graph *irg);
+void dump_type_graph (ir_graph *irg, char *suffix);
/**
* Dumps all type information.
*
* @see turn_off_edge_labels()
*/
-void dump_all_types (void);
+void dump_all_types (char *suffix);
/**
* Dumps the class hierarchy with or without entities.
* is dumped along with the entities.
* Dumps to a file class_hierarchy.vcg
*/
-void dump_class_hierarchy (bool entities);
+void dump_class_hierarchy (bool entities, char *suffix);
/**
* If opt_global_cse == 1 and opt_cse == 1 perform intra procedure
* constant subexpression elimination for floating nodes. Intra
* procedure cse gets the graph into state "floating". It is necessary
- * to run pre/code motion to get the graph back into state "pinned".
+ * to run pre/code motion to get the graph back into state "op_pin_state_pinned".
* right after a call to local_optimize with global cse turned on.
* Default: opt_global_cse == 0.
*/
/* keep old array */
} else {
/* Allocate new array, don't free old in_array, it's on the obstack. */
- ir_node *block = get_nodes_Block(node);
+ ir_node *block = get_nodes_block(node);
node->in = NEW_ARR_D (ir_node *, current_ir_graph->obst, arity+1);
- set_nodes_Block(node, block);
+ set_nodes_block(node, block);
}
}
collect (ir_node *n, void *env) {
ir_node *pred;
if (get_irn_op(n) == op_Phi) {
- set_irn_link(n, get_irn_link(get_nodes_Block(n)));
- set_irn_link(get_nodes_Block(n), n);
+ set_irn_link(n, get_irn_link(get_nodes_block(n)));
+ set_irn_link(get_nodes_block(n), n);
}
if (get_irn_op(n) == op_Proj) {
pred = n;
ir_node *proj, *pred;
/* move this node */
- set_nodes_Block(node, to_bl);
+ set_nodes_block(node, to_bl);
/* move its projs */
if (get_irn_mode(node) == mode_T) {
proj = get_irn_link(node);
while (proj) {
- if (get_nodes_Block(proj) == from_bl)
- set_nodes_Block(proj, to_bl);
+ if (get_nodes_block(proj) == from_bl)
+ set_nodes_block(proj, to_bl);
proj = get_irn_link(proj);
}
}
arity = get_irn_arity(node);
for (i = 0; i < arity; i++) {
pred = get_irn_n(node, i);
- if (get_nodes_Block(pred) == from_bl)
+ if (get_nodes_block(pred) == from_bl)
move(pred, from_bl, to_bl);
}
}
set_optimize(0);
/* Transform the control flow */
- old_block = get_nodes_Block(node);
+ old_block = get_nodes_block(node);
new_block = new_Block(get_Block_n_cfgpreds(old_block),
get_Block_cfgpred_arr(old_block));
set_irg_current_block(current_ir_graph, new_block);
set_irn_link(new_block, phi);
set_irn_link(old_block, NULL);
while (phi) {
- if(get_nodes_Block(phi) == old_block); /* @@@ inlinening chokes on phis that don't
+ if(get_nodes_block(phi) == old_block); /* @@@ inlinening chokes on phis that don't
obey this condition. How do they get into
the list??? Example: InterfaceIII */
- set_nodes_Block(phi, new_block);
+ set_nodes_block(phi, new_block);
phi = get_irn_link(phi);
}
/* Handle graph state */
assert(get_irg_phase_state(current_ir_graph) != phase_building);
if (get_opt_global_cse())
- set_irg_pinned(current_ir_graph, floats);
+ set_irg_pinned(current_ir_graph, op_pin_state_floats);
if (get_irg_outs_state(current_ir_graph) == outs_consistent)
set_irg_outs_inconsistent(current_ir_graph);
if (get_irg_dom_state(current_ir_graph) == dom_consistent)
new_arity = compute_new_arity(n);
n->attr.block.graph_arr = NULL;
} else {
- block = get_nodes_Block(n);
+ block = get_nodes_block(n);
if (get_irn_opcode(n) == iro_Phi) {
new_arity = compute_new_arity(block);
} else {
if ((get_opt_control_flow_straightening()) &&
(get_Block_n_cfgpreds(nn) == 1) &&
(get_irn_op(get_Block_cfgpred(nn, 0)) == op_Jmp)) {
- ir_node *old = get_nodes_Block(get_Block_cfgpred(nn, 0));
+ ir_node *old = get_nodes_block(get_Block_cfgpred(nn, 0));
if (nn == old) {
/* Jmp jumps into the block it is in -- deal self cycle. */
assert(is_Bad(get_new_node(get_irg_bad(current_ir_graph))));
} else if (get_irn_opcode(n) == iro_Phi) {
/* Don't copy node if corresponding predecessor in block is Bad.
The Block itself should not be Bad. */
- block = get_nodes_Block(n);
+ block = get_nodes_block(n);
set_irn_n (nn, -1, get_new_node(block));
j = 0;
irn_arity = get_irn_arity(n);
}
/* If the pre walker reached this Phi after the post walker visited the
block block_visited is > 0. */
- set_Block_block_visited(get_nodes_Block(n), 0);
+ set_Block_block_visited(get_nodes_block(n), 0);
/* Compacting the Phi's ins might generate Phis with only one
predecessor. */
if (get_irn_arity(n) == 1)
set_new_node(ob, nb);
/* copy the live nodes */
- irg_walk(get_nodes_Block(oe), copy_node, copy_preds, NULL);
+ irg_walk(get_nodes_block(oe), copy_node, copy_preds, NULL);
/* copy_preds for the end node ... */
- set_nodes_Block(ne, get_new_node(get_nodes_Block(oe)));
- set_nodes_Block(nb, get_new_node(get_nodes_Block(ob)));
+ set_nodes_block(ne, get_new_node(get_nodes_block(oe)));
+ set_nodes_block(nb, get_new_node(get_nodes_block(ob)));
/*- ... and now the keep alives. -*/
/* First pick the not marked block nodes and walk them. We must pick these
if (get_irn_op(n) == op_Phi) {
/* Relink predeseccors of phi's block */
- block = get_nodes_Block(n);
+ block = get_nodes_block(n);
if (get_irn_link(block) == NULL)
relink_bad_block_predecessors(block, env);
if ( (prop != irg_inline_forced) && (!get_opt_optimize() || !get_opt_inline() ||
(prop == irg_inline_forbidden))) return 0;
+
/*
* currently, we cannot inline two cases:
* - call with compound arguments
/* Handle graph state */
assert(get_irg_phase_state(current_ir_graph) != phase_building);
- assert(get_irg_pinned(current_ir_graph) == pinned);
- assert(get_irg_pinned(called_graph) == pinned);
+ assert(get_irg_pinned(current_ir_graph) == op_pin_state_pinned);
+ assert(get_irg_pinned(called_graph) == op_pin_state_pinned);
if (get_irg_outs_state(current_ir_graph) == outs_consistent)
set_irg_outs_inconsistent(current_ir_graph);
set_irg_loopinfo_inconsistent(current_ir_graph);
/* -- Check preconditions -- */
assert(get_irn_op(call) == op_Call);
/* @@@ does not work for InterfaceIII.java after cgana
- assert(get_Call_type(call) == get_entity_type(get_irg_ent(called_graph)));
- assert(smaller_type(get_entity_type(get_irg_ent(called_graph)),
+ assert(get_Call_type(call) == get_entity_type(get_irg_entity(called_graph)));
+ assert(smaller_type(get_entity_type(get_irg_entity(called_graph)),
get_Call_type(call)));
*/
assert(get_type_tpop(get_Call_type(call)) == type_method);
the procedure and later replaces the Start node of the called graph.
Post_call is the old Call node and collects the results of the called
graph. Both will end up being a tuple. -- */
- post_bl = get_nodes_Block(call);
+ post_bl = get_nodes_block(call);
set_irg_current_block(current_ir_graph, post_bl);
/* XxMxPxP of Start + parameter of Call */
in[pn_Start_X_initial_exec] = new_Jmp();
copying. */
set_irn_link(get_irg_start(called_graph), pre_call);
set_irn_visited(get_irg_start(called_graph), get_irg_visited(current_ir_graph));
- set_irn_link(get_irg_start_block(called_graph), get_nodes_Block(pre_call));
+ set_irn_link(get_irg_start_block(called_graph), get_nodes_block(pre_call));
set_irn_visited(get_irg_start_block(called_graph), get_irg_visited(current_ir_graph));
set_irn_link(get_irg_bad(called_graph), get_irg_bad(current_ir_graph));
set_irn_visited(get_irg_bad(called_graph), get_irg_visited(current_ir_graph));
ir_node *ret;
ret = get_irn_n(end_bl, i);
if (get_irn_op(ret) == op_Return) {
- cf_pred[n_ret] = new_r_Jmp(current_ir_graph, get_nodes_Block(ret));
+ cf_pred[n_ret] = new_r_Jmp(current_ir_graph, get_nodes_block(ret));
n_ret++;
}
}
phi = new_Phi(n_ret, cf_pred, mode_M);
set_Tuple_pred(call, pn_Call_M_regular, phi);
/* Conserve Phi-list for further inlinings -- but might be optimized */
- if (get_nodes_Block(phi) == post_bl) {
+ if (get_nodes_block(phi) == post_bl) {
set_irn_link(phi, get_irn_link(post_bl));
set_irn_link(post_bl, phi);
}
}
}
if (n_ret > 0)
- phi = new_Phi(n_ret, cf_pred, get_irn_mode(cf_pred[0]));
+ phi = new_Phi(n_ret, cf_pred, get_irn_mode(cf_pred[0]));
else
- phi = new_Bad();
+ phi = new_Bad();
res_pred[j] = phi;
/* Conserve Phi-list for further inlinings -- but might be optimized */
- if (get_nodes_Block(phi) == post_bl) {
+ if (get_nodes_block(phi) == post_bl) {
set_irn_link(phi, get_irn_link(post_bl));
set_irn_link(post_bl, phi);
}
ir_node *ret;
ret = skip_Proj(get_irn_n(end_bl, i));
if (get_irn_op(ret) == op_Call) {
- cf_pred[n_exc] = new_r_Proj(current_ir_graph, get_nodes_Block(ret), ret, mode_M, 3);
+ cf_pred[n_exc] = new_r_Proj(current_ir_graph, get_nodes_block(ret), ret, mode_M, 3);
n_exc++;
} else if (is_fragile_op(ret)) {
/* We rely that all cfops have the memory output at the same position. */
- cf_pred[n_exc] = new_r_Proj(current_ir_graph, get_nodes_Block(ret), ret, mode_M, 0);
+ cf_pred[n_exc] = new_r_Proj(current_ir_graph, get_nodes_block(ret), ret, mode_M, 0);
n_exc++;
} else if (get_irn_op(ret) == op_Raise) {
- cf_pred[n_exc] = new_r_Proj(current_ir_graph, get_nodes_Block(ret), ret, mode_M, 1);
+ cf_pred[n_exc] = new_r_Proj(current_ir_graph, get_nodes_block(ret), ret, mode_M, 1);
n_exc++;
}
}
}
/* repair */
if (i < get_Block_n_cfgpreds(end_bl)) {
- bl = get_nodes_Block(cf_op);
+ bl = get_nodes_block(cf_op);
arity = get_Block_n_cfgpreds(end_bl) + get_Block_n_cfgpreds(bl) - 1;
cf_pred = (ir_node **) malloc (arity * sizeof (ir_node *));
for (j = 0; j < i; j++)
if (get_irn_op(addr) == op_Const) {
/* Check whether the constant is the pointer to a compiled entity. */
tv = get_Const_tarval(addr);
- if (get_tarval_entity(tv))
- called_irg = get_entity_irg(get_tarval_entity(tv));
- } else if (get_irn_op(addr) == op_SymConst && get_SymConst_kind(addr) == symconst_addr_ent) {
- called_irg = get_entity_irg(get_SymConst_entity(addr));
}
return called_irg;
}
static void collect_calls(ir_node *call, void *env) {
- inline_env_t *ienv = env;
ir_node *addr;
- tarval *tv;
- ir_graph *called_irg;
if (get_irn_op(call) != op_Call) return;
addr = get_Call_ptr(call);
- if (get_irn_op(addr) == op_Const) {
- /* Check whether the constant is the pointer to a compiled entity. */
- tv = get_Const_tarval(addr);
- if (get_tarval_entity(tv)) {
- called_irg = get_entity_irg(get_tarval_entity(tv));
- if (called_irg && ienv->pos < MAX_INLINE) {
- /* The Call node calls a locally defined method. Remember to inline. */
- ienv->calls[ienv->pos++] = call;
- }
+
+ if (get_irn_op(addr) == op_SymConst) {
+ ir_graph *called_irg = get_entity_irg(get_SymConst_entity(addr));
+ inline_env_t *ienv = (inline_env_t *)env;
+ if (called_irg && ienv->pos < MAX_INLINE) {
+ /* The Call node calls a locally defined method. Remember to inline. */
+ ienv->calls[ienv->pos++] = call;
}
}
}
void inline_small_irgs(ir_graph *irg, int size) {
int i;
ir_graph *rem = current_ir_graph;
- inline_env_t env;
+ inline_env_t env /* = {0, NULL}*/;
if (!(get_opt_optimize() && get_opt_inline())) return;
/* There are calls to inline */
collect_phiprojs(irg);
for (i = 0; i < env.pos; i++) {
- tarval *tv;
ir_graph *callee;
- tv = get_Const_tarval(get_Call_ptr(env.calls[i]));
- callee = get_entity_irg(get_tarval_entity(tv));
+ //tv = get_Const_tarval(get_Call_ptr(env.calls[i]));
+ // callee = get_entity_irg(get_tarval_entity(tv));
+ callee = get_entity_irg(get_SymConst_entity(get_Call_ptr(env.calls[i])));
if (((_obstack_memory_used(callee->obst) - obstack_room(callee->obst)) < size) ||
(get_irg_inline_property(callee) == irg_inline_forced)) {
inline_method(env.calls[i], callee);
/* get_entity_name(get_irg_entity(callee))); */
if (inline_method(call, callee)) {
did_inline = 1;
- env->n_call_nodes--;
- eset_insert_all(env->call_nodes, callee_env->call_nodes);
- env->n_call_nodes += callee_env->n_call_nodes;
- env->n_nodes += callee_env->n_nodes;
- callee_env->n_callers--;
- }
+ env->n_call_nodes--;
+ eset_insert_all(env->call_nodes, callee_env->call_nodes);
+ env->n_call_nodes += callee_env->n_call_nodes;
+ env->n_nodes += callee_env->n_nodes;
+ callee_env->n_callers--;
+ }
} else {
eset_insert(env->call_nodes, call);
}
mark_irn_visited(n);
/* Place floating nodes. */
- if (get_op_pinned(get_irn_op(n)) == floats) {
+ if (get_op_pinned(get_irn_op(n)) == op_pin_state_floats) {
int depth = 0;
ir_node *b = new_Bad(); /* The block to place this node in */
int bad_recursion = is_Bad(get_nodes_block(n));
assert(get_irn_op(n) != op_Block);
if ((get_irn_op(n) == op_Const) ||
- (get_irn_op(n) == op_SymConst) ||
- (is_Bad(n)) ||
- (get_irn_op(n) == op_Unknown)) {
+ (get_irn_op(n) == op_SymConst) ||
+ (is_Bad(n)) ||
+ (get_irn_op(n) == op_Unknown)) {
/* These nodes will not be placed by the loop below. */
b = get_irg_start_block(current_ir_graph);
depth = 1;
ir_node *dep_block;
if ((irn_not_visited(dep))
- && (get_op_pinned(get_irn_op(dep)) == floats)) {
- place_floats_early(dep, worklist);
+ && (get_op_pinned(get_irn_op(dep)) == op_pin_state_floats)) {
+ place_floats_early(dep, worklist);
}
/*
if (bad_recursion)
continue;
- /* Because all loops contain at least one pinned node, now all
- our inputs are either pinned or place_early has already
+ /* Because all loops contain at least one op_pin_state_pinned node, now all
+ our inputs are either op_pin_state_pinned or place_early has already
been finished on them. We do not have any unfinished inputs! */
- dep_block = get_nodes_Block(dep);
+ dep_block = get_nodes_block(dep);
if ((!is_Bad(dep_block)) &&
- (get_Block_dom_depth(dep_block) > depth)) {
- b = dep_block;
- depth = get_Block_dom_depth(dep_block);
+ (get_Block_dom_depth(dep_block) > depth)) {
+ b = dep_block;
+ depth = get_Block_dom_depth(dep_block);
}
/* Avoid that the node is placed in the Start block */
- if ((depth == 1) && (get_Block_dom_depth(get_nodes_Block(n)) > 1)) {
- b = get_Block_cfg_out(get_irg_start_block(current_ir_graph), 0);
- assert(b != get_irg_start_block(current_ir_graph));
- depth = 2;
+ if ((depth == 1) && (get_Block_dom_depth(get_nodes_block(n)) > 1)) {
+ b = get_Block_cfg_out(get_irg_start_block(current_ir_graph), 0);
+ assert(b != get_irg_start_block(current_ir_graph));
+ depth = 2;
}
}
- set_nodes_Block(n, b);
+ set_nodes_block(n, b);
}
/* Add predecessors of non floating nodes on worklist. */
/**
* Floating nodes form subgraphs that begin at nodes as Const, Load,
- * Start, Call and that end at pinned nodes as Store, Call. Place_early
+ * Start, Call and that end at op_pin_state_pinned nodes as Store, Call. Place_early
* places all floating nodes reachable from its argument through floating
- * nodes and adds all beginnings at pinned nodes to the worklist.
+ * nodes and adds all beginnings at op_pin_state_pinned nodes to the worklist.
*/
static INLINE void place_early(pdeq* worklist) {
assert(worklist);
}
set_irg_outs_inconsistent(current_ir_graph);
- current_ir_graph->pinned = pinned;
+ current_ir_graph->op_pin_state_pinned = op_pin_state_pinned;
}
/* our consumer is a Phi-node, the effective use is in all those
blocks through which the Phi-node reaches producer */
int i, irn_arity;
- ir_node *phi_block = get_nodes_Block(consumer);
+ ir_node *phi_block = get_nodes_block(consumer);
irn_arity = get_irn_arity(consumer);
for (i = 0; i < irn_arity; i++) {
if (get_irn_n(consumer, i) == producer) {
- block = get_nodes_Block(get_Block_cfgpred(phi_block, i));
+ block = get_nodes_block(get_Block_cfgpred(phi_block, i));
}
}
} else {
assert(is_no_Block(consumer));
- block = get_nodes_Block(consumer);
+ block = get_nodes_block(consumer);
}
/* Compute the deepest common ancestor of block and dca. */
/* Find the region deepest in the dominator tree dominating
dca with the least loop nesting depth, but still dominated
by our early placement. */
- dca = get_nodes_Block(n);
+ dca = get_nodes_block(n);
best = dca;
while (dca != early) {
dca = get_Block_idom(dca);
best = dca;
}
}
- if (best != get_nodes_Block(n)) {
+ if (best != get_nodes_block(n)) {
/* debug output
printf("Moving out of loop: "); DDMN(n);
printf(" Outermost block: "); DDMN(early);
printf(" Best block: "); DDMN(best);
- printf(" Innermost block: "); DDMN(get_nodes_Block(n));
+ printf(" Innermost block: "); DDMN(get_nodes_block(n));
*/
- set_nodes_Block(n, best);
+ set_nodes_block(n, best);
}
}
(get_irn_mode(n) != mode_X)) {
/* Remember the early placement of this block to move it
out of loop no further than the early placement. */
- early = get_nodes_Block(n);
+ early = get_nodes_block(n);
/* Assure that our users are all placed, except the Phi-nodes.
--- Each data flow cycle contains at least one Phi-node. We
have to break the `user has to be placed before the
producer' dependence cycle and the Phi-nodes are the
place to do so, because we need to base our placement on the
final region of our users, which is OK with Phi-nodes, as they
- are pinned, and they never have to be placed after a
+ are op_pin_state_pinned, and they never have to be placed after a
producer of one of their inputs in the same block anyway. */
for (i = 0; i < get_irn_n_outs(n); i++) {
ir_node *succ = get_irn_out(n, i);
if (irn_not_visited(succ) && (get_irn_op(succ) != op_Phi))
- place_floats_late(succ, worklist);
+ place_floats_late(succ, worklist);
}
/* We have to determine the final block of this node... except for
constants. */
- if ((get_op_pinned(get_irn_op(n)) == floats) &&
- (get_irn_op(n) != op_Const) &&
- (get_irn_op(n) != op_SymConst)) {
+ if ((get_op_pinned(get_irn_op(n)) == op_pin_state_floats) &&
+ (get_irn_op(n) != op_Const) &&
+ (get_irn_op(n) != op_SymConst)) {
ir_node *dca = NULL; /* deepest common ancestor in the
dominator tree of all nodes'
blocks depending on us; our final
placement has to dominate DCA. */
for (i = 0; i < get_irn_n_outs(n); i++) {
- dca = consumer_dom_dca (dca, get_irn_out(n, i), n);
+ dca = consumer_dom_dca (dca, get_irn_out(n, i), n);
}
- set_nodes_Block(n, dca);
+ set_nodes_block(n, dca);
move_out_of_loops (n, early);
}
}
}
-static INLINE void place_late(pdeq *worklist) {
+static INLINE void place_late(pdeq* worklist) {
assert(worklist);
inc_irg_visited(current_ir_graph);
/* GL @@@ : is this possible? if (get_opt_normalize()) -- added, all tests go through.
A different order of optimizations might cause problems. */
if (get_opt_normalize())
- set_Block_cfgpred(n, i, skip_Tuple(get_Block_cfgpred(n, i)));
+ set_Block_cfgpred(n, i, skip_Tuple(get_Block_cfgpred(n, i)));
} else if (get_opt_optimize() && (get_irn_mode(n) == mode_X)) {
/* We will soon visit a block. Optimize it before visiting! */
- ir_node *b = get_nodes_Block(n);
+ ir_node *b = get_nodes_block(n);
ir_node *new_node = equivalent_node(b);
while (irn_not_visited(b) && (!is_Bad(new_node)) && (new_node != b)) {
/* We would have to run gigo if new is bad, so we
- promote it directly below. */
+ promote it directly below. */
assert(((b == new_node) ||
get_opt_control_flow_straightening() ||
get_opt_control_flow_weak_simplification()) &&
* Collects all Phi nodes in link list of Block.
* Marks all blocks "block_visited" if they contain a node other
* than Jmp.
- *
- * Colelct Conds and its Projs in the cond_list
*/
static void collect_nodes(ir_node *n, void *env) {
- ir_node **cond_list = env;
-
if (is_no_Block(n)) {
- ir_node *b = get_nodes_Block(n);
+ ir_node *b = get_nodes_block(n);
- switch (get_irn_opcode(n)) {
-
- case iro_Phi:
+ if ((get_irn_op(n) == op_Phi)) {
/* Collect Phi nodes to compact ins along with block's ins. */
set_irn_link(n, get_irn_link(b));
set_irn_link(b, n);
- break;
-
- case iro_Cond:
- {
- ir_node *value = get_Cond_selector(n);
- tarval *tv = computed_value(value);
-
- if (tv != tarval_bad && mode_is_int(get_tarval_mode(tv))) {
- set_irn_link(n, *cond_list);
- *cond_list = n;
- }
- else { /* mark the cond, we cannot optimize it */
- set_irn_link(n, NULL);
- }
- }
- break;
-
- case iro_Proj:
- {
- ir_node *cond = get_Proj_pred(n);
-
- if (get_irn_op(cond) == op_Cond) {
- void *link = get_irn_link(cond);
-
- if (link) {
- /* the cond node can be optimized, collect Proj */
- set_irn_link(n, link);
- set_irn_link(cond, n);
- }
- }
- }
- break;
-
- default:
- break;
- }
-
- if ((get_irn_op(n) != op_Jmp) && !is_Bad(b)) { /* Check for non empty block. */
+ } else if ((get_irn_op(n) != op_Jmp) && !is_Bad(b)) { /* Check for non empty block. */
mark_Block_block_visited(b);
}
}
static int is_pred_of(ir_node *pred, ir_node *b) {
int i;
for (i = 0; i < get_Block_n_cfgpreds(b); i++) {
- ir_node *b_pred = get_nodes_Block(get_Block_cfgpred(b, i));
+ ir_node *b_pred = get_nodes_block(get_Block_cfgpred(b, i));
if (b_pred == pred) return 1;
}
return 0;
int i, j, n_preds = 1;
int dispensable = 1;
ir_node *cfop = get_Block_cfgpred(b, pos);
- ir_node *pred = get_nodes_Block(cfop);
+ ir_node *pred = get_nodes_block(cfop);
if (get_Block_block_visited(pred) + 1
< get_irg_block_visited(current_ir_graph)) {
n_preds = get_Block_n_cfgpreds(pred);
} else {
/* b's pred blocks and pred's pred blocks must be pairwise disjunct.
- Work preds < pos as if they were already removed. */
+ Work preds < pos as if they were already removed. */
for (i = 0; i < pos; i++) {
- ir_node *b_pred = get_nodes_Block(get_Block_cfgpred(b, i));
- if (get_Block_block_visited(b_pred) + 1
- < get_irg_block_visited(current_ir_graph)) {
- for (j = 0; j < get_Block_n_cfgpreds(b_pred); j++) {
- ir_node *b_pred_pred = get_nodes_Block(get_Block_cfgpred(b_pred, j));
- if (is_pred_of(b_pred_pred, pred)) dispensable = 0;
- }
- } else {
- if (is_pred_of(b_pred, pred)) dispensable = 0;
- }
+ ir_node *b_pred = get_nodes_block(get_Block_cfgpred(b, i));
+ if (get_Block_block_visited(b_pred) + 1
+ < get_irg_block_visited(current_ir_graph)) {
+ for (j = 0; j < get_Block_n_cfgpreds(b_pred); j++) {
+ ir_node *b_pred_pred = get_nodes_block(get_Block_cfgpred(b_pred, j));
+ if (is_pred_of(b_pred_pred, pred)) dispensable = 0;
+ }
+ } else {
+ if (is_pred_of(b_pred, pred)) dispensable = 0;
+ }
}
for (i = pos +1; i < get_Block_n_cfgpreds(b); i++) {
- ir_node *b_pred = get_nodes_Block(get_Block_cfgpred(b, i));
- if (is_pred_of(b_pred, pred)) dispensable = 0;
+ ir_node *b_pred = get_nodes_block(get_Block_cfgpred(b, i));
+ if (is_pred_of(b_pred, pred)) dispensable = 0;
}
if (!dispensable) {
- set_Block_block_visited(pred, get_irg_block_visited(current_ir_graph)-1);
- n_preds = 1;
+ set_Block_block_visited(pred, get_irg_block_visited(current_ir_graph)-1);
+ n_preds = 1;
} else {
n_preds = get_Block_n_cfgpreds(pred);
}
/*-
printf(" working on "); DDMN(b);
for (i = 0; i < get_Block_n_cfgpreds(b); i++) {
- pred = get_nodes_Block(get_Block_cfgpred(b, i));
+ pred = get_nodes_block(get_Block_cfgpred(b, i));
if (is_Bad(get_Block_cfgpred(b, i))) {
printf(" removing Bad %i\n ", i);
} else if (get_Block_block_visited(pred) +1
/* Find the new predecessors for the Phi */
n_preds = 0;
for (i = 0; i < get_Block_n_cfgpreds(b); i++) {
- pred = get_nodes_Block(get_Block_cfgpred(b, i));
+ pred = get_nodes_block(get_Block_cfgpred(b, i));
if (is_Bad(get_Block_cfgpred(b, i))) {
- /* Do nothing */
+ /* Do nothing */
} else if (get_Block_block_visited(pred) +1
- < get_irg_block_visited(current_ir_graph)) {
- /* It's an empty block and not yet visited. */
- ir_node *phi_pred = get_Phi_pred(phi, i);
- for (j = 0; j < get_Block_n_cfgpreds(pred); j++) {
- if (get_nodes_Block(phi_pred) == pred) {
- assert(get_irn_op(phi_pred) == op_Phi); /* Block is empty!! */
- in[n_preds] = get_Phi_pred(phi_pred, j);
- } else {
- in[n_preds] = phi_pred;
- }
- n_preds++;
- }
- /* The Phi_pred node is replaced now if it is a Phi.
- In Schleifen kann offenbar der entfernte Phi Knoten legal verwendet werden.
- Daher muss der Phiknoten durch den neuen ersetzt werden.
- Weiter muss der alte Phiknoten entfernt werden (durch ersetzen oder
- durch einen Bad) damit er aus den keep_alive verschwinden kann.
- Man sollte also, falls keine Schleife vorliegt, exchange mit new_Bad
- aufrufen. */
- if (get_nodes_Block(phi_pred) == pred) {
- /* remove the Phi as it might be kept alive. Further there
- might be other users. */
- exchange(phi_pred, phi); /* geht, ist aber doch semantisch falsch! Warum?? */
- }
+ < get_irg_block_visited(current_ir_graph)) {
+ /* It's an empty block and not yet visited. */
+ ir_node *phi_pred = get_Phi_pred(phi, i);
+ for (j = 0; j < get_Block_n_cfgpreds(pred); j++) {
+ if (get_nodes_block(phi_pred) == pred) {
+ assert(get_irn_op(phi_pred) == op_Phi); /* Block is empty!! */
+ in[n_preds] = get_Phi_pred(phi_pred, j);
} else {
- in[n_preds] = get_Phi_pred(phi, i);
- n_preds ++;
+ in[n_preds] = phi_pred;
+ }
+ n_preds++;
+ }
+ /* The Phi_pred node is replaced now if it is a Phi.
+ In Schleifen kann offenbar der entfernte Phi Knoten legal verwendet werden.
+ Daher muss der Phiknoten durch den neuen ersetzt werden.
+ Weiter muss der alte Phiknoten entfernt werden (durch ersetzen oder
+ durch einen Bad) damit er aus den keep_alive verschwinden kann.
+ Man sollte also, falls keine Schleife vorliegt, exchange mit new_Bad
+ aufrufen. */
+ if (get_nodes_block(phi_pred) == pred) {
+ /* remove the Phi as it might be kept alive. Further there
+ might be other users. */
+ exchange(phi_pred, phi); /* geht, ist aber doch semantisch falsch! Warum?? */
+ }
+ } else {
+ in[n_preds] = get_Phi_pred(phi, i);
+ n_preds ++;
}
}
/* Fix the node */
phi = get_irn_link(phi);
}
- /*- This happens only if merge between loop backedge and single loop entry. -*/
+/*-
+ This happens only if merge between loop backedge and single loop entry. -*/
for (k = 0; k < get_Block_n_cfgpreds(b); k++) {
- pred = get_nodes_Block(get_Block_cfgpred(b, k));
+ pred = get_nodes_block(get_Block_cfgpred(b, k));
if (get_Block_block_visited(pred)+1 < get_irg_block_visited(current_ir_graph)) {
phi = get_irn_link(pred);
while (phi) {
- if (get_irn_op(phi) == op_Phi) {
- set_nodes_Block(phi, b);
-
- n_preds = 0;
- for (i = 0; i < k; i++) {
- pred = get_nodes_Block(get_Block_cfgpred(b, i));
- if (is_Bad(get_Block_cfgpred(b, i))) {
- /* Do nothing */
- } else if (get_Block_block_visited(pred) +1
- < get_irg_block_visited(current_ir_graph)) {
- /* It's an empty block and not yet visited. */
- for (j = 0; j < get_Block_n_cfgpreds(pred); j++) {
- /* @@@ Hier brauche ich Schleifeninformation!!! Kontrollflusskante
- muss Rueckwaertskante sein! (An allen vier in[n_preds] = phi
- Anweisungen.) Trotzdem tuts bisher!! */
- in[n_preds] = phi;
- n_preds++;
- }
- } else {
- in[n_preds] = phi;
- n_preds++;
- }
- }
- for (i = 0; i < get_Phi_n_preds(phi); i++) {
- in[n_preds] = get_Phi_pred(phi, i);
- n_preds++;
+ if (get_irn_op(phi) == op_Phi) {
+ set_nodes_block(phi, b);
+
+ n_preds = 0;
+ for (i = 0; i < k; i++) {
+ pred = get_nodes_block(get_Block_cfgpred(b, i));
+ if (is_Bad(get_Block_cfgpred(b, i))) {
+ /* Do nothing */
+ } else if (get_Block_block_visited(pred) +1
+ < get_irg_block_visited(current_ir_graph)) {
+ /* It's an empty block and not yet visited. */
+ for (j = 0; j < get_Block_n_cfgpreds(pred); j++) {
+ /* @@@ Hier brauche ich Schleifeninformation!!! Kontrollflusskante
+ muss Rueckwaertskante sein! (An allen vier in[n_preds] = phi
+ Anweisungen.) Trotzdem tuts bisher!! */
+ in[n_preds] = phi;
+ n_preds++;
}
- for (i = k+1; i < get_Block_n_cfgpreds(b); i++) {
- pred = get_nodes_Block(get_Block_cfgpred(b, i));
- if (is_Bad(get_Block_cfgpred(b, i))) {
- /* Do nothing */
- } else if (get_Block_block_visited(pred) +1
- < get_irg_block_visited(current_ir_graph)) {
- /* It's an empty block and not yet visited. */
- for (j = 0; j < get_Block_n_cfgpreds(pred); j++) {
- in[n_preds] = phi;
- n_preds++;
- }
- } else {
- in[n_preds] = phi;
- n_preds++;
- }
+ } else {
+ in[n_preds] = phi;
+ n_preds++;
+ }
+ }
+ for (i = 0; i < get_Phi_n_preds(phi); i++) {
+ in[n_preds] = get_Phi_pred(phi, i);
+ n_preds++;
+ }
+ for (i = k+1; i < get_Block_n_cfgpreds(b); i++) {
+ pred = get_nodes_block(get_Block_cfgpred(b, i));
+ if (is_Bad(get_Block_cfgpred(b, i))) {
+ /* Do nothing */
+ } else if (get_Block_block_visited(pred) +1
+ < get_irg_block_visited(current_ir_graph)) {
+ /* It's an empty block and not yet visited. */
+ for (j = 0; j < get_Block_n_cfgpreds(pred); j++) {
+ in[n_preds] = phi;
+ n_preds++;
}
- set_irn_in(phi, n_preds, in);
+ } else {
+ in[n_preds] = phi;
+ n_preds++;
}
- phi = get_irn_link(phi);
+ }
+ set_irn_in(phi, n_preds, in);
+ }
+ phi = get_irn_link(phi);
}
}
}
/*- Fix the block -*/
n_preds = 0;
for (i = 0; i < get_Block_n_cfgpreds(b); i++) {
- pred = get_nodes_Block(get_Block_cfgpred(b, i));
+ pred = get_nodes_block(get_Block_cfgpred(b, i));
if (is_Bad(get_Block_cfgpred(b, i))) {
/* Do nothing */
} else if (get_Block_block_visited(pred) +1
assert(get_Block_n_cfgpreds(b) > 1);
/* Else it should be optimized by equivalent_node. */
for (j = 0; j < get_Block_n_cfgpreds(pred); j++) {
- in[n_preds] = get_Block_cfgpred(pred, j);
- n_preds++;
+ in[n_preds] = get_Block_cfgpred(pred, j);
+ n_preds++;
}
/* Remove block as it might be kept alive. */
exchange(pred, b/*new_Bad()*/);
free(in);
}
-/**
- * an impossible ir_node * != NULL
- */
-static const char _anchor;
-#define ANCHOR ((ir_node *)&_anchor)
-
-/**
- * optimize constant cond with projs
- *
- * If we come here, we should have 3 situations:
- *
- * 1.) Only one Proj exists: This should be the default Proj, convert to jump
- * 2.) Two Proj's exists: One is the taken, the other the not-taken default proj
- * 3.) More than 2 Proj's: local_optimize() did not run or internal error do nothing
- */
-static void optimize_const_conds(ir_node *cond_list)
-{
- ir_node *cond, *next;
-
- for (cond = cond_list; cond != ANCHOR; cond = next) {
- ir_node *block, *jmp;
- ir_node *proj = NULL, *def_proj = NULL;
- int num = 0;
-
- for (next = get_irn_link(cond); next != ANCHOR; next = get_irn_link(next)) {
- if (get_irn_op(next) == op_Cond)
- break;
-
- assert(get_irn_op(next) == op_Proj && "something neither Cond not Proj in cond-list");
- assert(get_Proj_pred(next) == cond && "cond-list corrupt");
-
- if (get_Proj_proj(next) == get_Cond_defaultProj(cond))
- def_proj = next;
- else
- proj = next;
- ++num;
- }
-
- if (num == 1) {
- assert(def_proj);
-
- block = get_nodes_block(def_proj);
- jmp = new_rd_Jmp(get_irn_dbg_info(def_proj), current_ir_graph, block);
- exchange(def_proj, jmp);
- }
- else if (num == 2) {
- assert(def_proj && proj);
-
- exchange(def_proj, new_Bad());
-
- block = get_nodes_block(proj);
- jmp = new_rd_Jmp(get_irn_dbg_info(proj), current_ir_graph, block);
- exchange(proj, jmp);
- }
- }
-}
-
void optimize_cf(ir_graph *irg) {
int i;
ir_node **in;
ir_node *end = get_irg_end(irg);
ir_graph *rem = current_ir_graph;
current_ir_graph = irg;
- ir_node *cond_list = ANCHOR;
/* Handle graph state */
assert(get_irg_phase_state(irg) != phase_building);
/* Use block visited flag to mark non-empty blocks. */
inc_irg_block_visited(irg);
- irg_walk(end, merge_blocks, collect_nodes, &cond_list);
-
- /* now, optimize switches */
- if (get_opt_unreachable_code())
- optimize_const_conds(cond_list);
+ irg_walk(end, merge_blocks, collect_nodes, NULL);
/* Optimize the standard code. */
irg_block_walk(get_irg_end_block(irg), optimize_blocks, NULL, NULL);
/* Walk all keep alives, optimize them if block, add to new in-array
for end if useful. */
in = NEW_ARR_F (ir_node *, 1);
- in[0] = get_nodes_Block(end);
+ in[0] = get_nodes_block(end);
inc_irg_visited(current_ir_graph);
for(i = 0; i < get_End_n_keepalives(end); i++) {
ir_node *ka = get_End_keepalive(end, i);
if (irn_not_visited(ka)) {
if ((get_irn_op(ka) == op_Block) && Block_not_block_visited(ka)) {
- set_irg_block_visited(current_ir_graph, /* Don't walk all the way to Start. */
- get_irg_block_visited(current_ir_graph)-1);
- irg_block_walk(ka, optimize_blocks, NULL, NULL);
- mark_irn_visited(ka);
- ARR_APP1 (ir_node *, in, ka);
+ set_irg_block_visited(current_ir_graph, /* Don't walk all the way to Start. */
+ get_irg_block_visited(current_ir_graph)-1);
+ irg_block_walk(ka, optimize_blocks, NULL, NULL);
+ mark_irn_visited(ka);
+ ARR_APP1 (ir_node *, in, ka);
} else if (get_irn_op(ka) == op_Phi) {
- mark_irn_visited(ka);
- ARR_APP1 (ir_node *, in, ka);
+ mark_irn_visited(ka);
+ ARR_APP1 (ir_node *, in, ka);
}
}
}
int arity, i;
ir_node *pre, *block, **in, *jmp;
- arity = get_irn_arity(n);
-
/* Block has multiple predecessors */
- if (op_Block == get_irn_op(n) && arity > 1) {
+ if ((op_Block == get_irn_op(n)) &&
+ (get_irn_arity(n) > 1)) {
+ arity = get_irn_arity(n);
if (n == get_irg_end_block(current_ir_graph))
return; /* No use to add a block here. */
- for (i = 0; i < arity; ++i) {
+ for (i=0; i<arity; i++) {
pre = get_irn_n(n, i);
/* Predecessor has multiple successors. Insert new flow edge */
if ((NULL != pre) &&
- (op_Proj == get_irn_op(pre)) &&
- op_Raise != get_irn_op(skip_Proj(pre))) {
-
- /* set predecessor array for new block */
- in = NEW_ARR_D (ir_node *, current_ir_graph->obst, 1);
- /* set predecessor of new block */
- in[0] = pre;
- block = new_Block(1, in);
- /* insert new jmp node to new block */
- switch_block(block);
- jmp = new_Jmp();
- switch_block(n);
- /* set successor of new block */
- set_irn_n(n, i, jmp);
+ (op_Proj == get_irn_op(pre)) &&
+ op_Raise != get_irn_op(skip_Proj(pre))) {
+
+ /* set predecessor array for new block */
+ in = NEW_ARR_D (ir_node *, current_ir_graph->obst, 1);
+ /* set predecessor of new block */
+ in[0] = pre;
+ block = new_Block(1, in);
+ /* insert new jmp node to new block */
+ set_cur_block(block);
+ jmp = new_Jmp();
+ set_cur_block(n);
+ /* set successor of new block */
+ set_irn_n(n, i, jmp);
} /* predecessor has multiple successors */
} /* for all predecessors */
* Dead_node_elimination is only performed if options `optimize' and
* `opt_dead_node_elimination' are set. The graph may
* not be in state phase_building. The outs datasturcture is freed,
- * the outs state set to no_outs. Backedge information is conserved.
+ * the outs state set to outs_none. Backedge information is conserved.
* Removes old attributes of nodes. Sets link field to NULL.
* Callee information must be freed (irg_callee_info_none).
*
* Sets visited masterflag in current_ir_graph to the max of the flag in
* current and called graph.
* Assumes that both, the called and the calling graph are in state
- * "pinned".
+ * "op_pin_state_pinned".
* It is recommended to call local_optimize_graph after inlining as this
* function leaves a set of obscure Tuple nodes, e.g. a Proj-Tuple-Jmp
* combination as control flow operation.
static ident* frame_type_suffix = NULL;
void init_irgraph(void) {
- frame_type_suffix = id_from_str(FRAME_TP_SUFFIX, strlen(FRAME_TP_SUFFIX));
+ frame_type_suffix = new_id_from_chars(FRAME_TP_SUFFIX, strlen(FRAME_TP_SUFFIX));
}
#if USE_EXPLICIT_PHI_IN_STACK
res->outs = NULL;
res->phase_state = phase_building;
- res->pinned = pinned;
- res->outs_state = no_outs;
- res->dom_state = no_dom;
+ res->op_pin_state_pinned = op_pin_state_pinned;
+ res->outs_state = outs_none;
+ res->dom_state = dom_none;
res->typeinfo_state = irg_typeinfo_none;
res->loopinfo_state = loopinfo_none;
/* res->unknown = new_ir_node (NULL, res, res->start_block, op_Unknown, mode_T, 0, NULL); */
/* Proj results of start node */
- projX = new_Proj (res->start, mode_X, pns_initial_exec);
- res->frame = new_Proj (res->start, mode_P_mach, pns_frame_base);
- res->globals = new_Proj (res->start, mode_P_mach, pns_globals);
- res->initial_mem = new_Proj (res->start, mode_M, pns_global_store);
- res->args = new_Proj (res->start, mode_T, pns_args);
+ projX = new_Proj (res->start, mode_X, pn_Start_X_initial_exec);
+ res->frame = new_Proj (res->start, mode_P_mach, pn_Start_P_frame_base); res->globals = new_Proj (res->start, mode_P_mach, pn_Start_P_globals);
+ res->initial_mem = new_Proj (res->start, mode_M, pn_Start_M);
+ res->args = new_Proj (res->start, mode_T, pn_Start_T_args);
#ifdef DEBUG_libfirm
res->graph_nr = get_irp_new_node_nr();
#endif
set_store(res->initial_mem);
- add_in_edge(res->start_block, projX);
+ add_immBlock_pred(res->start_block, projX);
/*
* The code generation needs it. leave it in now.
* Use of this edge is matter of discussion, unresolved. Also possible:
- * add_in_edge(res->start_block, res->start_block), but invalid typed.
+ * add_immBlock_pred(res->start_block, res->start_block), but invalid typed.
*/
- mature_block (res->current_block);
+ mature_immBlock (res->current_block);
/*-- Make a block to start with --*/
first_block = new_immBlock();
- add_in_edge (first_block, projX);
+ add_immBlock_pred (first_block, projX);
return res;
}
res->obst = (struct obstack *) xmalloc (sizeof (struct obstack));
obstack_init (res->obst);
res->phase_state = phase_building;
- res->pinned = pinned;
+ res->op_pin_state_pinned = op_pin_state_pinned;
res->value_table = new_identities (); /* value table for global value
numbering for optimizing use in
iropt.c */
res->ent = NULL;
res->frame_type = NULL;
res->start_block = new_immBlock ();
- res->end_block = new_immBlock ();
- res->end = new_End ();
- res->end_reg = res->end;
- res->end_except = res->end;
- mature_block(get_cur_block());
+ res->end_block = new_immBlock ();
+ res->end = new_End ();
+ res->end_reg = res->end;
+ res->end_except = res->end;
+ mature_immBlock(get_cur_block());
res->bad = new_ir_node (NULL, res, res->start_block, op_Bad, mode_T, 0, NULL);
res->start = new_Start ();
/* Proj results of start node */
- projX = new_Proj (res->start, mode_X, pns_initial_exec);
- res->initial_mem = new_Proj (res->start, mode_M, pns_global_store);
-
- set_store(res->initial_mem);
- add_in_edge(res->start_block, projX);
-
- mature_block (res->current_block);
- add_in_edge (new_immBlock (), projX);
- mature_block(get_cur_block());
+ projX = new_Proj (res->start, mode_X, pn_Start_X_initial_exec);
+ add_immBlock_pred(res->start_block, projX);
+ mature_immBlock (res->current_block);
+ add_immBlock_pred (new_immBlock (), projX);
+ mature_immBlock(get_cur_block());
/* Set the visited flag high enough that the block will never be visited. */
set_irn_visited(get_cur_block(), -1);
set_Block_block_visited(get_cur_block(), -1);
graph, nor the entity standing for this graph. */
void free_ir_graph (ir_graph *irg) {
stat_free_graph(irg);
- if (irg->outs_state != no_outs) free_outs(irg);
+ if (irg->outs_state != outs_none) free_outs(irg);
if (irg->frame_type) free_type(irg->frame_type);
if (irg->value_table) del_identities(irg->value_table);
if (irg->ent) {
}
entity *
-(get_irg_ent)(ir_graph *irg) {
+(get_irg_entity)(ir_graph *irg) {
return __get_irg_ent(irg);
}
void
-(set_irg_ent)(ir_graph *irg, entity *ent) {
+(set_irg_entity)(ir_graph *irg, entity *ent) {
__set_irg_ent(irg, ent);
}
__set_irg_phase_low(irg);
}
-op_pinned
+op_pin_state
(get_irg_pinned)(ir_graph *irg) {
return __get_irg_pinned(irg);
}
}
void
-(set_irg_pinned)(ir_graph *irg, op_pinned p) {
+(set_irg_pinned)(ir_graph *irg, op_pin_state p) {
__set_irg_pinned(irg, p);
}
# ifndef _IRGRAPH_H_
# define _IRGRAPH_H_
# include "tv.h"
+# include "entity.h"
/* to resolve recursion between irnode.h and irgraph.h */
#ifndef _IR_NODE_TYPEDEF_
* datastructure is used to build the Phi nodes and removed after
* completion of the graph. There is no path from end to start in the
* graph after calling ir_graph.
- * pinned set to "pinned" if no global cse was performed on the graph.
- * set to "floats" if global cse was performed (and during construction:
+ * op_pin_state_pinned set to "op_pin_state_pinned" if no global cse was performed on the graph.
+ * set to "op_pin_state_floats" if global cse was performed (and during construction:
* did actually change something). Code placement is necessary.
*/
* n_loc is the number of local variables in this procedure including
* the procedure parameters.
* The constructor adds the new irgraph to the list in ir_prog.
- * The state of the ir graph is: phase_building, pinned, no_outs. */
+ * The state of the ir graph is: phase_building, op_pin_state_pinned, outs_none. */
ir_graph *new_ir_graph (entity *ent, int n_loc);
/** Frees the passed irgraph.
*/
int is_ir_graph(void *thing);
-#define get_irg_entity get_irg_ent
-#define set_irg_entity set_irg_ent
-entity *get_irg_ent (ir_graph *irg);
-void set_irg_ent (ir_graph *irg, entity *ent);
+//#define get_irg_entity get_irg_ent
+//#define set_irg_entity set_irg_ent
+entity *get_irg_entity (ir_graph *irg);
+void set_irg_entity (ir_graph *irg, entity *ent);
type *get_irg_frame_type (ir_graph *irg);
void set_irg_frame_type (ir_graph *irg, type *ftp);
irg_phase_state get_irg_phase_state (ir_graph *irg);
void set_irg_phase_low(ir_graph *irg);
-/** state: pinned
- 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
+/** state: op_pin_state_pinned
+ The graph is "op_pin_state_pinned" if all nodes are associated with a basic block.
+ It is in state "op_pin_state_floats" if nodes are in arbitrary blocks. In state
+ "op_pin_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
the node.
- The enum op_pinned is defined in irop.h. */
-op_pinned get_irg_pinned (ir_graph *irg);
+ The enum op_pin_state is defined in irop.h. */
+op_pin_state get_irg_pinned (ir_graph *irg);
/** state: outs_state
Outs are the back edges or def-use edges.
- Values: no_outs, outs_consistent, outs_inconsistent
- no_outs: outs are not computed, no memory is allocated.
+ Values: outs_none, outs_consistent, outs_inconsistent
+ outs_none: outs are not computed, no memory is allocated.
outs_consistent: outs are computed and correct,
outs_inconsistent: outs have been computed, memory is still allocated,
but the graph has been changed since. */
typedef enum {
- no_outs,
+ outs_none,
outs_consistent,
outs_inconsistent
} irg_outs_state;
/** state: dom_state
Signals the state of the dominator infomation.
- Values: no_dom, dom_consistent, dom_inconsistent
- no_dom: doms are not computed, no memory is allocated. The access routines
+ Values: dom_none, dom_consistent, dom_inconsistent
+ dom_none: doms are not computed, no memory is allocated. The access routines
may not be used.
dom_consistent: dominator information is computed and correct,
dom_inconsistent: dominator information is computed, memory is still allocated,
but the graph has been changed since. Using the access routines is possible,
obtained information may be incorrect. */
typedef enum {
- no_dom,
+ dom_none,
dom_consistent,
dom_inconsistent
} irg_dom_state;
/* -- Fields indicating different states of irgraph -- */
irg_phase_state phase_state; /**< compiler phase */
- op_pinned pinned; /**< Flag for status of nodes */
+ op_pin_state op_pin_state_pinned; /**< Flag for status of nodes */
irg_outs_state outs_state; /**< Out edges. */
irg_dom_state dom_state; /**< Dominator information */
irg_typeinfo_state typeinfo_state; /**< Validity of type information */
ir_graph *new_const_code_irg(void);
/**
- * Set the pinned state of a graph.
+ * Set the op_pin_state_pinned state of a graph.
*
* @irg the IR graph
* @p new pin state
*/
INLINE void
-set_irg_pinned (ir_graph *irg, op_pinned p);
+set_irg_pinned (ir_graph *irg, op_pin_state p);
/** Returns the obstack associated with the graph. */
struct obstack *get_irg_obstack(ir_graph *irg);
irg->phase_state = phase_low;
}
-static INLINE op_pinned
+static INLINE op_pin_state
__get_irg_pinned(ir_graph *irg) {
- return irg->pinned;
+ return irg->op_pin_state_pinned;
}
static INLINE irg_outs_state
}
static INLINE void
-__set_irg_pinned(ir_graph *irg, op_pinned p) {
- irg->pinned = p;
+__set_irg_pinned(ir_graph *irg, op_pin_state p) {
+ irg->op_pin_state_pinned = p;
}
static INLINE irg_callee_info_state
#define set_irg_bad(irg, node) __set_irg_bad(irg, node)
#define get_irg_current_block(irg) __get_irg_current_block(irg)
#define set_irg_current_block(irg, node) __set_irg_current_block(irg, node)
-#define get_irg_ent(irg) __get_irg_ent(irg)
-#define set_irg_ent(irg, ent) __set_irg_ent(irg, ent)
+#define get_irg_entity(irg) __get_irg_ent(irg)
+#define set_irg_entity(irg, ent) __set_irg_ent(irg, ent)
#define get_irg_frame_type(irg) __get_irg_frame_type(irg)
#define set_irg_frame_type(irg, ftp) __set_irg_frame_type(irg, ftp)
#define get_irg_obstack(irg) __get_irg_obstack(irg)
static ir_node *get_cf_op(ir_node *n) {
ir_node *pred;
- n = skip_nop(n);
+ n = skip_Id(n);
n = skip_Tuple(n);
pred = skip_Proj(n);
if (!(is_cfop(pred) || is_fragile_op(pred) ||
if (tos == cf_pred) {
/* We entered this procedure by the call pred pos refers to. */
pop_callsite(current_ir_graph);
- current_ir_graph = get_CallBegin_irg(cf_pred);
+ current_ir_graph = get_irn_irg(cf_pred);
return true;
} else {
/* We won't walk. */
re_enter_procedure(ir_node *block, ir_node *cf_pred, int pos) {
ir_node *callbegin = pop_callsite(current_ir_graph);
assert(interprocedural_view);
- current_ir_graph = get_CallBegin_irg(callbegin);
+ current_ir_graph = get_irn_irg(callbegin);
}
static INLINE void
}
unsigned int
-(get_mode_vector_elems)(const ir_mode *mode) {
+(get_mode_n_vector_elems)(const ir_mode *mode) {
return __get_mode_vector_elems(mode);
}
newmode.sort = irms_control_flow;
/* Basic Block */
- newmode.name = id_from_str("BB", 2);
+ newmode.name = new_id_from_chars("BB", 2);
newmode.code = irm_BB;
mode_BB = register_mode(&newmode);
/* eXecution */
- newmode.name = id_from_str("X", 1);
+ newmode.name = new_id_from_chars("X", 1);
newmode.code = irm_X;
mode_X = register_mode(&newmode);
newmode.sort = irms_memory;
/* Memory */
- newmode.name = id_from_str("M", 1);
+ newmode.name = new_id_from_chars("M", 1);
newmode.code = irm_M;
mode_M = register_mode(&newmode);
newmode.sort = irms_auxiliary,
/* Tuple */
- newmode.name = id_from_str("T", 1);
+ newmode.name = new_id_from_chars("T", 1);
newmode.code = irm_T;
mode_T = register_mode(&newmode);
/* ANY */
- newmode.name = id_from_str("ANY", 3);
+ newmode.name = new_id_from_chars("ANY", 3);
newmode.code = irm_ANY;
mode_ANY = register_mode(&newmode);
/* BAD */
- newmode.name = id_from_str("BAD", 3);
+ newmode.name = new_id_from_chars("BAD", 3);
newmode.code = irm_BAD;
mode_BAD = register_mode(&newmode);
newmode.sort = irms_internal_boolean;
/* boolean */
- newmode.name = id_from_str("b", 1);
+ newmode.name = new_id_from_chars("b", 1);
newmode.code = irm_b;
mode_b = register_mode(&newmode);
newmode.arithmetic = irma_ieee754;
/* float */
- newmode.name = id_from_str("F", 1);
+ newmode.name = new_id_from_chars("F", 1);
newmode.code = irm_F;
newmode.sign = 1;
newmode.align = 32;
mode_F = register_mode(&newmode);
/* double */
- newmode.name = id_from_str("D", 1);
+ newmode.name = new_id_from_chars("D", 1);
newmode.code = irm_D;
newmode.sign = 1;
newmode.align = 64;
mode_D = register_mode(&newmode);
/* extended */
- newmode.name = id_from_str("E", 1);
+ newmode.name = new_id_from_chars("E", 1);
newmode.code = irm_E;
newmode.sign = 1;
newmode.align = 128;
newmode.arithmetic = irma_twos_complement;
/* signed byte */
- newmode.name = id_from_str("Bs", 2);
+ newmode.name = new_id_from_chars("Bs", 2);
newmode.code = irm_Bs;
newmode.sign = 1;
newmode.align = 8;
mode_Bs = register_mode(&newmode);
/* unsigned byte */
- newmode.name = id_from_str("Bu", 2);
+ newmode.name = new_id_from_chars("Bu", 2);
newmode.code = irm_Bu;
newmode.arithmetic = irma_twos_complement;
newmode.sign = 0;
mode_Bu = register_mode(&newmode);
/* signed short integer */
- newmode.name = id_from_str("Hs", 2);
+ newmode.name = new_id_from_chars("Hs", 2);
newmode.code = irm_Hs;
newmode.sign = 1;
newmode.align = 16;
mode_Hs = register_mode(&newmode);
/* unsigned short integer */
- newmode.name = id_from_str("Hu", 2);
+ newmode.name = new_id_from_chars("Hu", 2);
newmode.code = irm_Hu;
newmode.sign = 0;
newmode.align = 16;
mode_Hu = register_mode(&newmode);
/* signed integer */
- newmode.name = id_from_str("Is", 2);
+ newmode.name = new_id_from_chars("Is", 2);
newmode.code = irm_Is;
newmode.sign = 1;
newmode.align = 32;
mode_Is = register_mode(&newmode);
/* unsigned integer */
- newmode.name = id_from_str("Iu", 2);
+ newmode.name = new_id_from_chars("Iu", 2);
newmode.code = irm_Iu;
newmode.sign = 0;
newmode.align = 32;
mode_Iu = register_mode(&newmode);
/* signed long integer */
- newmode.name = id_from_str("Ls", 2);
+ newmode.name = new_id_from_chars("Ls", 2);
newmode.code = irm_Ls;
newmode.sign = 1;
newmode.align = 32;
mode_Ls = register_mode(&newmode);
/* unsigned long integer */
- newmode.name = id_from_str("Lu", 2);
+ newmode.name = new_id_from_chars("Lu", 2);
newmode.code = irm_Lu;
newmode.sign = 0;
newmode.align = 32;
newmode.arithmetic = irma_none;
/* Character */
- newmode.name = id_from_str("C", 1);
+ newmode.name = new_id_from_chars("C", 1);
newmode.code = irm_C;
newmode.sign = 0;
newmode.align = 8;
mode_C = register_mode(&newmode);
/* Unicode character */
- newmode.name = id_from_str("U", 1);
+ newmode.name = new_id_from_chars("U", 1);
newmode.code = irm_U;
newmode.sign = 0;
newmode.align = 16;
newmode.arithmetic = irma_twos_complement;
/* pointer */
- newmode.name = id_from_str("P", 1);
+ newmode.name = new_id_from_chars("P", 1);
newmode.code = irm_P;
newmode.sign = 0;
newmode.align = 32;
* a vector mode. For non-vector modes it returns 1 for data and 0
* for all other modes
*/
-unsigned int get_mode_vector_elems(const ir_mode *mode);
+unsigned int get_mode_n_vector_elems(const ir_mode *mode);
/** Returns the stored intermediate information. */
void *get_mode_link(const ir_mode *mode);
*
* Zero is the additive neutral element and as such
* is defined only for modes allowing addition, i.e.
- * floats and ints, and references (NULL-Pointer)
+ * op_pin_state_floats and ints, and references (NULL-Pointer)
* else returns tarval_bad.
*/
tarval *get_mode_null(ir_mode *mode);
*
* One, being the multiplicative neutral element,
* is defined only for modes allowing multiplication,
- * i.e. ints and floats.
+ * i.e. ints and op_pin_state_floats.
*/
tarval *get_mode_one(ir_mode *mode);
according to firm definiton */
int smaller_mode(const ir_mode *sm, const ir_mode *lm);
-/** mode module initialization, call once before use of any other function **/
-void init_mode(void);
-
-/** mode module finalization. frees all memory. */
-void finish_mode(void);
#endif /* _IRMODE_H_ */
const void *tv_priv; /**< tarval module will save private data here */
};
+
/* ------------------------------- *
* inline functions *
* ------------------------------- */
return (__get_mode_sort(mode) == irms_int_number) && (__get_mode_vector_elems(mode) > 1);
}
-#define get_modeP_mach() __get_modeP_mach()
-#define set_modeP_mach(p) __set_modeP_mach(p)
-#define get_mode_modecode(mode) __get_mode_modecode(mode)
-#define get_mode_ident(mode) __get_mode_ident(mode)
-#define get_mode_sort(mode) __get_mode_sort(mode)
-#define get_mode_size_bits(mode) __get_mode_size_bits(mode)
-#define get_mode_size_bytes(mode) __get_mode_size_bytes(mode)
-#define get_mode_align(mode) __get_mode_align(mode)
-#define get_mode_sign(mode) __get_mode_sign(mode)
-#define get_mode_arithmetic(mode) __get_mode_arithmetic(mode)
-#define get_mode_modulo_shift(mode) __get_mode_modulo_shift(mode)
-#define get_mode_vector_elems(mode) __get_mode_vector_elems(mode)
-#define get_mode_link(mode) __get_mode_link(mode)
-#define set_mode_link(mode, l) __set_mode_link(mode, l)
-#define mode_is_signed(mode) __mode_is_signed(mode)
-#define mode_is_float(mode) __mode_is_float(mode)
-#define mode_is_int(mode) __mode_is_int(mode)
-#define mode_is_character(mode) __mode_is_character(mode)
-#define mode_is_reference(mode) __mode_is_reference(mode)
-#define mode_is_num(mode) __mode_is_num(mode)
-#define mode_is_numP(mode) __mode_is_numP(mode)
-#define mode_is_data(mode) __mode_is_data(mode)
-#define mode_is_datab(mode) __mode_is_datab(mode)
-#define mode_is_dataM(mode) __mode_is_dataM(mode)
-#define mode_is_float_vector(mode) __mode_is_float_vector(mode)
-#define mode_is_int_vector(mode) __mode_is_int_vector(mode)
+/** mode module initialization, call once before use of any other function **/
+void init_mode(void);
+
+/** mode module finalization. frees all memory. */
+void finish_mode(void);
+
+#define get_modeP_mach() __get_modeP_mach()
+#define set_modeP_mach(p) __set_modeP_mach(p)
+#define get_mode_modecode(mode) __get_mode_modecode(mode)
+#define get_mode_ident(mode) __get_mode_ident(mode)
+#define get_mode_sort(mode) __get_mode_sort(mode)
+#define get_mode_size_bits(mode) __get_mode_size_bits(mode)
+#define get_mode_size_bytes(mode) __get_mode_size_bytes(mode)
+#define get_mode_align(mode) __get_mode_align(mode)
+#define get_mode_sign(mode) __get_mode_sign(mode)
+#define get_mode_arithmetic(mode) __get_mode_arithmetic(mode)
+#define get_mode_modulo_shift(mode) __get_mode_modulo_shift(mode)
+#define get_mode_n_vector_elems(mode) __get_mode_vector_elems(mode)
+#define get_mode_link(mode) __get_mode_link(mode)
+#define set_mode_link(mode, l) __set_mode_link(mode, l)
+#define mode_is_signed(mode) __mode_is_signed(mode)
+#define mode_is_float(mode) __mode_is_float(mode)
+#define mode_is_int(mode) __mode_is_int(mode)
+#define mode_is_character(mode) __mode_is_character(mode)
+#define mode_is_reference(mode) __mode_is_reference(mode)
+#define mode_is_num(mode) __mode_is_num(mode)
+#define mode_is_numP(mode) __mode_is_numP(mode)
+#define mode_is_data(mode) __mode_is_data(mode)
+#define mode_is_datab(mode) __mode_is_datab(mode)
+#define mode_is_dataM(mode) __mode_is_dataM(mode)
+#define mode_is_float_vector(mode) __mode_is_float_vector(mode)
+#define mode_is_int_vector(mode) __mode_is_int_vector(mode)
#endif /* _IRMODE_T_H_ */
/* this works for all except Block */
ir_node *
-get_nodes_Block (ir_node *node) {
+get_nodes_block (ir_node *node) {
assert (!(node->op == op_Block));
return get_irn_n(node, -1);
}
void
-set_nodes_Block (ir_node *node, ir_node *block) {
+set_nodes_block (ir_node *node, ir_node *block) {
assert (!(node->op == op_Block));
set_irn_n(node, -1, block);
}
/ * handler handling for Nodes * /
void
set_Node_handler (ir_node *node, ir_node *handler) {
- set_Block_handler (get_nodes_Block (node), handler);
+ set_Block_handler (get_nodes_block (node), handler);
}
ir_node *
get_Node_handler (ir_node *node) {
- return (get_Block_handler (get_nodes_Block (node)));
+ return (get_Block_handler (get_nodes_block (node)));
}
/ * exc_t handling for Blocks * /
/ * exc_t handling for Nodes * /
void set_Node_exc (ir_node *node, exc_t exc) {
- set_Block_exc (get_nodes_Block (node), exc);
+ set_Block_exc (get_nodes_block (node), exc);
}
exc_t get_Node_exc (ir_node *node) {
- return (get_Block_exc (get_nodes_Block (node)));
+ return (get_Block_exc (get_nodes_block (node)));
}
*/
node->attr.block.in_cg = NULL;
}
-/* Start references the irg it is in. */
-ir_graph *
-get_Start_irg(ir_node *node) {
- return get_irn_irg(node);
-}
-
void
set_Start_irg(ir_node *node, ir_graph *irg) {
assert(node->op == op_Start);
in array afterwards ... */
}
-ir_graph *get_EndReg_irg (ir_node *end) {
- return get_irn_irg(end);
-}
-
-ir_graph *get_EndExcept_irg (ir_node *end) {
- return get_irn_irg(end);
-}
/*
> Implementing the case construct (which is where the constant Proj node is
if (tp != unknown_type) {
assert (is_atomic_type(tp));
assert (get_type_mode(tp) == get_irn_mode(node));
- assert (!tarval_is_entity(get_Const_tarval(node)) ||
- (is_pointer_type(tp) &&
- (get_pointer_points_to_type(tp) ==
- get_entity_type(get_tarval_entity(get_Const_tarval(node))))));
}
node->attr.con.tp = tp;
assert(node->op == op_CallBegin);
set_irn_n(node, 0, ptr);
}
-ir_graph * get_CallBegin_irg (ir_node *node) {
- return get_irn_irg(node);
-}
ir_node * get_CallBegin_call (ir_node *node) {
assert(node->op == op_CallBegin);
return node->attr.callbegin.call;
if (!get_opt_normalize()) return node;
- node = skip_nop(node);
+ node = skip_Id(node);
if (get_irn_op(node) == op_Proj) {
- pred = skip_nop(get_Proj_pred(node));
+ pred = skip_Id(get_Proj_pred(node));
if (get_irn_op(pred) == op_Proj) /* nested Tuple ? */
- pred = skip_nop(skip_Tuple(pred));
+ pred = skip_Id(skip_Tuple(pred));
if (get_irn_op(pred) == op_Tuple)
return get_Tuple_pred(pred, get_Proj_proj(node));
}
/** returns operand of node if node is a Cast */
ir_node *skip_Cast (ir_node *node) {
if (node && get_irn_op(node) == op_Cast) {
- return skip_nop(get_irn_n(node, 0));
+ return skip_Id(get_irn_n(node, 0));
} else {
return node;
}
than any other approach, as Id chains are resolved and all point to the real node, or
all id's are self loops. */
ir_node *
-skip_nop (ir_node *node) {
+skip_Id (ir_node *node) {
/* don't assert node !!! */
if (!get_opt_normalize()) return node;
assert (get_irn_arity (node) > 0);
node->in[0+1] = node;
- res = skip_nop(rem_pred);
+ res = skip_Id(rem_pred);
if (res->op == op_Id) /* self-loop */ return node;
node->in[0+1] = res;
than any other approach, as Id chains are resolved and all point to the real node, or
all id's are self loops. */
ir_node *
-skip_nop (ir_node *node) {
+skip_Id (ir_node *node) {
ir_node *pred;
/* don't assert node !!! */
assert (get_irn_arity (node) > 0);
node->in[0+1] = node; /* turn us into a self referencing Id: shorten Id cycles. */
- res = skip_nop(rem_pred);
+ res = skip_Id(rem_pred);
if (res->op == op_Id) /* self-loop */ return node;
node->in[0+1] = res; /* Turn Id chain into Ids all referencing the chain end. */
}
#endif
-ir_node *
-skip_Id (ir_node *node) {
- return skip_nop(node);
-}
-
int
is_Bad (ir_node *node) {
assert(node);
return is_ip_cfopcode(get_irn_op(node));
}
-ir_graph *get_ip_cfop_irg(ir_node *n) {
- return get_irn_irg(n);
-}
-
/* Returns true if the operation can change the control flow because
of an exception. */
int
void *get_irn_link (const ir_node *node);
/** Returns the ir_graph this node belongs to. Only valid if irg
- * is in state pinned (irg is only stored in the block. */
+ * is in state op_pin_state_pinned (irg is only stored in the block. */
ir_graph *get_irn_irg (ir_node *node);
/** Outputs a unique number for this node if libFIRM is compiled for
* access routines that work for all nodes we use infix "nodes" and do not
* name this function get_irn_block. */
#define get_nodes_block get_nodes_Block
-ir_node *get_nodes_Block (ir_node *node);
+ir_node *get_nodes_block (ir_node *node);
#define set_nodes_block set_nodes_Block
-void set_nodes_Block (ir_node *node, ir_node *block);
+void set_nodes_block (ir_node *node, ir_node *block);
/**
* @function get_irn_block
type of this method. */
} pn_Start; /* Projection numbers for Start. */
-/**
- * Projection numbers for result of Start node: use for Proj nodes!
- * @remark This is the old name convention, don't use anymore.
- */
-typedef 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_value_arg_base /**< Pointer to region of compound value arguments as defined by
- type of this method. */
-} pns_number; /* pns: Projection Number Start */
/** Test whether arbitrary node is frame pointer.
*
/* frees the memory. */
void remove_Block_cg_cfgpred_arr(ir_node * node);
-/* Start references the irg it is in.
- @@@ old -- use get_irn_irg instead! */
-ir_graph *get_Start_irg(ir_node *node);
-
int get_End_n_keepalives(ir_node *end);
ir_node *get_End_keepalive(ir_node *end, int pos);
void add_End_keepalive (ir_node *end, ir_node *ka);
free_End frees these data structures. */
void free_End (ir_node *end);
-/* @@@ old -- use get_irn_irg instead! */
-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.
entity *get_Sel_entity (ir_node *node); /* entity to select */
void set_Sel_entity (ir_node *node, entity *ent);
-/**
- * Projection numbers for result of Call node: use for Proj nodes!
- *
- * @remark old name convention!
- */
-typedef enum {
- pncl_memory = 0, /**< The memory result. */
- pncl_exc_target = 1, /**< The control flow result branching to the exception handler */
- pncl_result_tuple = 2, /**< The tuple containing all (0, 1, 2, ...) results */
- pncl_exc_memory = 3, /**< The memory result in case the called method terminated with
- an exception */
- pncl_value_res_base = 4 /**< A pointer to the memory region containing copied results
- passed by value (for compound result types). */
-} pncl_number; /* pncl: Projection Number CaLl */
-
/**
* Projection numbers for result of Call node: use for Proj nodes!
*/
ir_node *get_CallBegin_ptr (ir_node *node);
void set_CallBegin_ptr (ir_node *node, ir_node *ptr);
-/* @@@ old -- use get_irn_irg instead! */
-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);
/** returns operand of node if node is a Proj. */
ir_node *skip_Proj (ir_node *node);
/** returns operand of node if node is a Id */
-ir_node *skip_nop (ir_node *node);
ir_node *skip_Id (ir_node *node); /* Same as skip_nop. */
/* returns corresponding operand of Tuple if node is a Proj from
a Tuple. */
Start, End, Jmp, Cond, Return, Raise, Bad, CallBegin, EndReg, EndExcept */
int is_cfop(ir_node *node);
-/* @@@ old -- use get_irn_irg instead! */
-ir_graph *get_ip_cfop_irg(ir_node *n);
-
/** Returns true if the operation manipulates interprocedural control flow:
CallBegin, EndReg, EndExcept */
int is_ip_cfop(ir_node *node);
/** Output information about an entity and its owner */
#define DDMEO(X) printf("%s(l.%i) %s (own: %s): %ld (%p)\n", __MYFUNC__, __LINE__, get_entity_name(X), get_type_name(get_entity_owner(X)), get_entity_nr(X), (void *)(X))
/** Output information about a graph */
-#define DDMG(X) printf("%s(l.%i) %s: %ld (%p)\n", __MYFUNC__, __LINE__, get_entity_name(get_irg_ent(X)), get_irg_graph_nr(X), (void *)(X))
+#define DDMG(X) printf("%s(l.%i) %s: %ld (%p)\n", __MYFUNC__, __LINE__, get_entity_name(get_irg_entity(X)), get_irg_graph_nr(X), (void *)(X))
/** Output information about an ident */
-#define DDMI(X) printf("%s(l.%i) %s: %p\n", __MYFUNC__, __LINE__, id_to_str(X), (void *)(X))
+#define DDMI(X) printf("%s(l.%i) %s: %p\n", __MYFUNC__, __LINE__, get_id_str(X), (void *)(X))
/** Output information about a mode */
#define DDMM(X) printf("%s(l.%i) %s: %p\n", __MYFUNC__, __LINE__, get_mode_name(X), (void *)(X))
/** Output information about a loop */
*/
static INLINE ir_node *
__get_irn_intra_n (ir_node *node, int n) {
- return (node->in[n + 1] = skip_nop(node->in[n + 1]));
+ return (node->in[n + 1] = skip_Id(node->in[n + 1]));
}
/**
/* handle Filter and Block specially */
if (__get_irn_opcode(node) == iro_Filter) {
assert(node->attr.filter.in_cg);
- return (node->attr.filter.in_cg[n + 1] = skip_nop(node->attr.filter.in_cg[n + 1]));
+ return (node->attr.filter.in_cg[n + 1] = skip_Id(node->attr.filter.in_cg[n + 1]));
} else if (__get_irn_opcode(node) == iro_Block && node->attr.block.in_cg) {
- return (node->attr.block.in_cg[n + 1] = skip_nop(node->attr.block.in_cg[n + 1]));
+ return (node->attr.block.in_cg[n + 1] = skip_Id(node->attr.block.in_cg[n + 1]));
}
return __get_irn_intra_n (node, n);
ir_op *
-new_ir_op(opcode code, const char *name, op_pinned p, unsigned flags, op_arity opar, int op_index, size_t attr_size)
+new_ir_op(opcode code, const char *name, op_pin_state p, unsigned flags, op_arity opar, int op_index, size_t attr_size)
{
ir_op *res;
res = (ir_op *) xmalloc (sizeof (ir_op));
res->code = code;
- res->name = id_from_str(name, strlen(name));
- res->pinned = p;
+ res->name = new_id_from_chars(name, strlen(name));
+ res->op_pin_state_pinned = p;
res->attr_size = attr_size;
res->flags = flags;
res->opar = opar;
#define I irop_flag_ip_cfopcode
#define F irop_flag_fragile
- op_Block = new_ir_op(iro_Block, "Block", pinned, L, oparity_variable, -1, sizeof(block_attr));
-
- op_Start = new_ir_op(iro_Start, "Start", pinned, X, oparity_zero, -1, sizeof(start_attr));
- op_End = new_ir_op(iro_End, "End", pinned, X, oparity_dynamic, -1, 0);
- op_Jmp = new_ir_op(iro_Jmp, "Jmp", pinned, X, oparity_zero, -1, 0);
- op_Cond = new_ir_op(iro_Cond, "Cond", pinned, L|X, oparity_any, -1, sizeof(cond_attr));
- op_Return = new_ir_op(iro_Return, "Return", pinned, L|X, oparity_zero, -1, 0);
- op_Raise = new_ir_op(iro_Raise, "Raise", pinned, L|X, oparity_any, -1, 0);
-
- op_Const = new_ir_op(iro_Const, "Const", floats, 0, oparity_zero, -1, sizeof(const_attr));
- op_SymConst = new_ir_op(iro_SymConst, "SymConst", floats, 0, oparity_zero, -1, sizeof(symconst_attr));
-
- op_Sel = new_ir_op(iro_Sel, "Sel", floats, L, oparity_any, -1, sizeof(sel_attr));
- op_InstOf = new_ir_op(iro_InstOf, "InstOf", floats, L, oparity_any, -1, sizeof(sel_attr));
-
- op_Call = new_ir_op(iro_Call, "Call", pinned, L|F, oparity_variable, -1, sizeof(call_attr));
- op_Add = new_ir_op(iro_Add, "Add", floats, C, oparity_binary, 0, 0);
- op_Minus = new_ir_op(iro_Minus, "Minus", floats, 0, oparity_unary, 0, 0);
- op_Sub = new_ir_op(iro_Sub, "Sub", floats, L, oparity_binary, 0, 0);
- op_Mul = new_ir_op(iro_Mul, "Mul", floats, C, oparity_binary, 0, 0);
- op_Quot = new_ir_op(iro_Quot, "Quot", pinned, L|F, oparity_binary, 1, sizeof(struct irnode **));
- op_DivMod = new_ir_op(iro_DivMod, "DivMod", pinned, L|F, oparity_binary, 1, sizeof(struct irnode **));
- op_Div = new_ir_op(iro_Div, "Div", pinned, L|F, oparity_binary, 1, sizeof(struct irnode **));
- op_Mod = new_ir_op(iro_Mod, "Mod", pinned, L|F, oparity_binary, 1, sizeof(struct irnode **));
- op_Abs = new_ir_op(iro_Abs, "Abs", floats, 0, oparity_unary, 0, 0);
- op_And = new_ir_op(iro_And, "And", floats, C, oparity_binary, 0, 0);
- op_Or = new_ir_op(iro_Or, "Or", floats, C, oparity_binary, 0, 0);
- op_Eor = new_ir_op(iro_Eor, "Eor", floats, C, oparity_binary, 0, 0);
- op_Not = new_ir_op(iro_Not, "Not", floats, 0, oparity_unary, 0, 0);
- op_Cmp = new_ir_op(iro_Cmp, "Cmp", floats, L, oparity_binary, 0, 0);
- op_Shl = new_ir_op(iro_Shl, "Shl", floats, L, oparity_binary, 0, 0);
- op_Shr = new_ir_op(iro_Shr, "Shr", floats, L, oparity_binary, 0, 0);
- op_Shrs = new_ir_op(iro_Shrs, "Shrs", floats, L, oparity_binary, 0, 0);
- op_Rot = new_ir_op(iro_Rot, "Rot", floats, L, oparity_binary, 0, 0);
- op_Conv = new_ir_op(iro_Conv, "Conv", floats, 0, oparity_unary, 0, 0);
- op_Cast = new_ir_op(iro_Cast, "Cast", floats, 0, oparity_unary, 0, sizeof(cast_attr));
-
- op_Phi = new_ir_op(iro_Phi, "Phi", pinned, L, oparity_variable, -1, sizeof(int));
-
- op_Load = new_ir_op(iro_Load, "Load", pinned, L|F, oparity_any, -1, sizeof(struct irnode **));
- op_Store = new_ir_op(iro_Store, "Store", pinned, L|F, oparity_any, -1, sizeof(struct irnode **));
- op_Alloc = new_ir_op(iro_Alloc, "Alloc", pinned, L|F, oparity_any, -1, sizeof(alloc_attr));
- op_Free = new_ir_op(iro_Free, "Free", pinned, L, oparity_any, -1, sizeof(type *));
- op_Sync = new_ir_op(iro_Sync, "Sync", pinned, 0, oparity_any, -1, 0);
-
- op_Proj = new_ir_op(iro_Proj, "Proj", floats, 0, oparity_any, -1, sizeof(long));
- op_Tuple = new_ir_op(iro_Tuple, "Tuple", floats, L, oparity_variable, -1, 0);
- op_Id = new_ir_op(iro_Id, "Id", floats, 0, oparity_any, -1, 0);
- op_Bad = new_ir_op(iro_Bad, "Bad", floats, X|F, oparity_zero, -1, 0);
- op_Confirm = new_ir_op(iro_Confirm, "Confirm", floats, L, oparity_any, -1, sizeof(confirm_attr));
-
- op_Unknown = new_ir_op(iro_Unknown, "Unknown", floats, X|F, oparity_zero, -1, 0);
- op_Filter = new_ir_op(iro_Filter, "Filter", pinned, L, oparity_variable, -1, sizeof(filter_attr));
- op_Break = new_ir_op(iro_Break, "Break", pinned, X, oparity_zero, -1, 0);
- op_CallBegin = new_ir_op(iro_CallBegin, "CallBegin", pinned, X|I, oparity_any, -1, sizeof(callbegin_attr));
- op_EndReg = new_ir_op(iro_EndReg, "EndReg", pinned, X|I, oparity_any, -1, sizeof(end_attr));
- op_EndExcept = new_ir_op(iro_EndExcept, "EndExcept", pinned, X|I, oparity_any, -1, sizeof(end_attr));
-
- op_FuncCall = new_ir_op(iro_FuncCall, "FuncCall", floats, L, oparity_any, -1, sizeof(call_attr));
+ op_Block = new_ir_op(iro_Block, "Block", op_pin_state_pinned, L, oparity_variable, -1, sizeof(block_attr));
+
+ op_Start = new_ir_op(iro_Start, "Start", op_pin_state_pinned, X, oparity_zero, -1, sizeof(start_attr));
+ op_End = new_ir_op(iro_End, "End", op_pin_state_pinned, X, oparity_dynamic, -1, 0);
+ op_Jmp = new_ir_op(iro_Jmp, "Jmp", op_pin_state_pinned, X, oparity_zero, -1, 0);
+ op_Cond = new_ir_op(iro_Cond, "Cond", op_pin_state_pinned, L|X, oparity_any, -1, sizeof(cond_attr));
+ op_Return = new_ir_op(iro_Return, "Return", op_pin_state_pinned, L|X, oparity_zero, -1, 0);
+ op_Raise = new_ir_op(iro_Raise, "Raise", op_pin_state_pinned, L|X, oparity_any, -1, 0);
+
+ op_Const = new_ir_op(iro_Const, "Const", op_pin_state_floats, 0, oparity_zero, -1, sizeof(const_attr));
+ op_SymConst = new_ir_op(iro_SymConst, "SymConst", op_pin_state_floats, 0, oparity_zero, -1, sizeof(symconst_attr));
+
+ op_Sel = new_ir_op(iro_Sel, "Sel", op_pin_state_floats, L, oparity_any, -1, sizeof(sel_attr));
+ op_InstOf = new_ir_op(iro_InstOf, "InstOf", op_pin_state_floats, L, oparity_any, -1, sizeof(sel_attr));
+
+ op_Call = new_ir_op(iro_Call, "Call", op_pin_state_pinned, L|F, oparity_variable, -1, sizeof(call_attr));
+ op_Add = new_ir_op(iro_Add, "Add", op_pin_state_floats, C, oparity_binary, 0, 0);
+ op_Minus = new_ir_op(iro_Minus, "Minus", op_pin_state_floats, 0, oparity_unary, 0, 0);
+ op_Sub = new_ir_op(iro_Sub, "Sub", op_pin_state_floats, L, oparity_binary, 0, 0);
+ op_Mul = new_ir_op(iro_Mul, "Mul", op_pin_state_floats, C, oparity_binary, 0, 0);
+ op_Quot = new_ir_op(iro_Quot, "Quot", op_pin_state_pinned, L|F, oparity_binary, 1, sizeof(struct irnode **));
+ op_DivMod = new_ir_op(iro_DivMod, "DivMod", op_pin_state_pinned, L|F, oparity_binary, 1, sizeof(struct irnode **));
+ op_Div = new_ir_op(iro_Div, "Div", op_pin_state_pinned, L|F, oparity_binary, 1, sizeof(struct irnode **));
+ op_Mod = new_ir_op(iro_Mod, "Mod", op_pin_state_pinned, L|F, oparity_binary, 1, sizeof(struct irnode **));
+ op_Abs = new_ir_op(iro_Abs, "Abs", op_pin_state_floats, 0, oparity_unary, 0, 0);
+ op_And = new_ir_op(iro_And, "And", op_pin_state_floats, C, oparity_binary, 0, 0);
+ op_Or = new_ir_op(iro_Or, "Or", op_pin_state_floats, C, oparity_binary, 0, 0);
+ op_Eor = new_ir_op(iro_Eor, "Eor", op_pin_state_floats, C, oparity_binary, 0, 0);
+ op_Not = new_ir_op(iro_Not, "Not", op_pin_state_floats, 0, oparity_unary, 0, 0);
+ op_Cmp = new_ir_op(iro_Cmp, "Cmp", op_pin_state_floats, L, oparity_binary, 0, 0);
+ op_Shl = new_ir_op(iro_Shl, "Shl", op_pin_state_floats, L, oparity_binary, 0, 0);
+ op_Shr = new_ir_op(iro_Shr, "Shr", op_pin_state_floats, L, oparity_binary, 0, 0);
+ op_Shrs = new_ir_op(iro_Shrs, "Shrs", op_pin_state_floats, L, oparity_binary, 0, 0);
+ op_Rot = new_ir_op(iro_Rot, "Rot", op_pin_state_floats, L, oparity_binary, 0, 0);
+ op_Conv = new_ir_op(iro_Conv, "Conv", op_pin_state_floats, 0, oparity_unary, 0, 0);
+ op_Cast = new_ir_op(iro_Cast, "Cast", op_pin_state_floats, 0, oparity_unary, 0, sizeof(cast_attr));
+
+ op_Phi = new_ir_op(iro_Phi, "Phi", op_pin_state_pinned, L, oparity_variable, -1, sizeof(int));
+
+ op_Load = new_ir_op(iro_Load, "Load", op_pin_state_pinned, L|F, oparity_any, -1, sizeof(struct irnode **));
+ op_Store = new_ir_op(iro_Store, "Store", op_pin_state_pinned, L|F, oparity_any, -1, sizeof(struct irnode **));
+ op_Alloc = new_ir_op(iro_Alloc, "Alloc", op_pin_state_pinned, L|F, oparity_any, -1, sizeof(alloc_attr));
+ op_Free = new_ir_op(iro_Free, "Free", op_pin_state_pinned, L, oparity_any, -1, sizeof(type *));
+ op_Sync = new_ir_op(iro_Sync, "Sync", op_pin_state_pinned, 0, oparity_any, -1, 0);
+
+ op_Proj = new_ir_op(iro_Proj, "Proj", op_pin_state_floats, 0, oparity_any, -1, sizeof(long));
+ op_Tuple = new_ir_op(iro_Tuple, "Tuple", op_pin_state_floats, L, oparity_variable, -1, 0);
+ op_Id = new_ir_op(iro_Id, "Id", op_pin_state_floats, 0, oparity_any, -1, 0);
+ op_Bad = new_ir_op(iro_Bad, "Bad", op_pin_state_floats, X|F, oparity_zero, -1, 0);
+ op_Confirm = new_ir_op(iro_Confirm, "Confirm", op_pin_state_floats, L, oparity_any, -1, sizeof(confirm_attr));
+
+ op_Unknown = new_ir_op(iro_Unknown, "Unknown", op_pin_state_floats, X|F, oparity_zero, -1, 0);
+ op_Filter = new_ir_op(iro_Filter, "Filter", op_pin_state_pinned, L, oparity_variable, -1, sizeof(filter_attr));
+ op_Break = new_ir_op(iro_Break, "Break", op_pin_state_pinned, X, oparity_zero, -1, 0);
+ op_CallBegin = new_ir_op(iro_CallBegin, "CallBegin", op_pin_state_pinned, X|I, oparity_any, -1, sizeof(callbegin_attr));
+ op_EndReg = new_ir_op(iro_EndReg, "EndReg", op_pin_state_pinned, X|I, oparity_any, -1, sizeof(end_attr));
+ op_EndExcept = new_ir_op(iro_EndExcept, "EndExcept", op_pin_state_pinned, X|I, oparity_any, -1, sizeof(end_attr));
+
+ op_FuncCall = new_ir_op(iro_FuncCall, "FuncCall", op_pin_state_floats, L, oparity_any, -1, sizeof(call_attr));
#undef F
#undef I
return op->name;
}
-op_pinned get_op_pinned (const ir_op *op){
- return op->pinned;
+op_pin_state get_op_pinned (const ir_op *op){
+ return op->op_pin_state_pinned;
}
-/* Sets pinned in the opcode. Setting it to floating has no effect
+/* Sets op_pin_state_pinned in the opcode. Setting it to floating has no effect
for Phi, Block and control flow nodes. */
-void set_op_pinned(ir_op *op, op_pinned pinned) {
+void set_op_pinned(ir_op *op, op_pin_state op_pin_state_pinned) {
if (op == op_Block || op == op_Phi || is_cfopcode(op)) return;
- op->pinned = pinned;
+ op->op_pin_state_pinned = op_pin_state_pinned;
}
/** Returns the enum for the opcode */
opcode get_op_code(const ir_op *op);
-/** pinned states */
+/** op_pin_state_pinned states */
typedef enum {
- floats = 0, /**< Nodes of this opcode can be placed in any basic block. */
- pinned /**< Nodes must remain in this basic block. */
-} op_pinned;
+ op_pin_state_floats = 0, /**< Nodes of this opcode can be placed in any basic block. */
+ op_pin_state_pinned /**< Nodes must remain in this basic block. */
+} op_pin_state;
/** gets pinned state of an opcode */
-op_pinned get_op_pinned(const ir_op *op);
+op_pin_state get_op_pinned(const ir_op *op);
/** Sets pinned in the opcode. Setting it to floating has no effect
for Block, Phi and control flow nodes. */
-void set_op_pinned(ir_op *op, op_pinned pinned);
+void set_op_pinned(ir_op *op, op_pin_state pinned);
# endif /* _IROP_H_ */
opcode code; /**< the unique opcode of the op */
ident *name; /**< the name of the op */
size_t attr_size; /**< Space needed in memory for private attributes */
- op_pinned pinned; /**< How to deal with the node in cse, pre. */
+ op_pin_state op_pin_state_pinned; /**< How to deal with the node in cse, pre. */
op_arity opar; /**< arity of operator. */
int op_index; /**< the index of the first data operand, 0 for most cases, 1 for Div etc. */
unsigned flags; /**< flags describing the behavior of the ir_op, a bitmaks of irop_flags */
*
* @param code the opcode, one of type \c opcode
* @param name the printable name of this opcode
- * @param p wheater operations of this opcode are pinned or floating
+ * @param p wheater operations of this opcode are op_pin_state_pinned or floating
* @param flags a bitmask of irop_flags describing the behavior of the ir operation
* @param opar the parity of this ir operation
* @param op_index if the parity is oparity_unary, oparity_binary or oparity_trinary the index
*
* @return The genenerated ir operation.
*/
-ir_op * new_ir_op(opcode code, const char *name, op_pinned p,
+ir_op * new_ir_op(opcode code, const char *name, op_pin_state p,
unsigned flags, op_arity opar, int op_index, size_t attr_size);
/**
} else {
tarval *v;
- if ( (tarval_classify ((v = computed_value (a))) == TV_CLASSIFY_NULL)
- || (tarval_classify ((v = computed_value (b))) == TV_CLASSIFY_NULL)) {
+ if ( (classify_tarval ((v = computed_value (a))) == TV_CLASSIFY_NULL)
+ || (classify_tarval ((v = computed_value (b))) == TV_CLASSIFY_NULL)) {
return v;
}
}
return tarval_or (ta, tb);
} else {
tarval *v;
- if ( (tarval_classify ((v = computed_value (a))) == TV_CLASSIFY_ALL_ONE)
- || (tarval_classify ((v = computed_value (b))) == TV_CLASSIFY_ALL_ONE)) {
+ if ( (classify_tarval ((v = computed_value (a))) == TV_CLASSIFY_ALL_ONE)
+ || (classify_tarval ((v = computed_value (b))) == TV_CLASSIFY_ALL_ONE)) {
return v;
}
}
return new_tarval_from_long (get_Proj_proj(n) & flags, mode_b);
}
} else { /* check for 3.: */
- ir_node *aaa = skip_nop(skip_Proj(aa));
- ir_node *aba = skip_nop(skip_Proj(ab));
+ ir_node *aaa = skip_Id(skip_Proj(aa));
+ ir_node *aba = skip_Id(skip_Proj(ab));
if ( ( (/* aa is ProjP and aaa is Alloc */
(get_irn_op(aa) == op_Proj)
{
ir_node *oldn = n;
- /* The Block constructor does not call optimize, but mature_block
+ /* The Block constructor does not call optimize, but mature_immBlock
calls the optimization. */
assert(get_Block_matured(n));
Remaining Phi nodes are just Ids. */
if ((get_Block_n_cfgpreds(n) == 1) &&
(get_irn_op(get_Block_cfgpred(n, 0)) == op_Jmp)) {
- ir_node *predblock = get_nodes_Block(get_Block_cfgpred(n, 0));
+ ir_node *predblock = get_nodes_block(get_Block_cfgpred(n, 0));
if (predblock == oldn) {
/* Jmp jumps into the block it is in -- deal self cycle. */
n = new_Bad(); DBG_OPT_DEAD;
}
else if ((get_Block_n_cfgpreds(n) == 1) &&
(get_irn_op(skip_Proj(get_Block_cfgpred(n, 0))) == op_Cond)) {
- ir_node *predblock = get_nodes_Block(get_Block_cfgpred(n, 0));
+ ir_node *predblock = get_nodes_block(get_Block_cfgpred(n, 0));
if (predblock == oldn) {
/* Jmp jumps into the block it is in -- deal self cycle. */
n = new_Bad(); DBG_OPT_DEAD;
(get_irn_mode(get_Cond_selector(get_Proj_pred(a))) == mode_b)) {
/* Also a single entry Block following a single exit Block. Phis have
twice the same operand and will be optimized away. */
- n = get_nodes_Block(a); DBG_OPT_IFSIM;
+ n = get_nodes_block(a); DBG_OPT_IFSIM;
}
} else if (get_opt_unreachable_code() &&
(n != current_ir_graph->start_block) &&
{
/* GL: Why not same for op_Raise?? */
/* unreachable code elimination */
- if (is_Bad(get_nodes_Block(n)))
+ if (is_Bad(get_nodes_block(n)))
n = new_Bad();
return n;
/* If this predecessors constant value is zero, the operation is
unnecessary. Remove it: */
- if (tarval_classify (tv) == TV_CLASSIFY_NULL) {
+ if (classify_tarval (tv) == TV_CLASSIFY_NULL) {
n = on; DBG_OPT_ALGSIM1;
}
ir_node *a = get_binop_left(n);
ir_node *b = get_binop_right(n);
- if (tarval_classify(computed_value(b)) == TV_CLASSIFY_NULL) {
+ if (classify_tarval(computed_value(b)) == TV_CLASSIFY_NULL) {
n = a; DBG_OPT_ALGSIM1;
}
ir_node *b = get_Mul_right(n);
/* Mul is commutative and has again an other neutral element. */
- if (tarval_classify (computed_value (a)) == TV_CLASSIFY_ONE) {
+ if (classify_tarval (computed_value (a)) == TV_CLASSIFY_ONE) {
n = b; DBG_OPT_ALGSIM1;
- } else if (tarval_classify (computed_value (b)) == TV_CLASSIFY_ONE) {
+ } else if (classify_tarval (computed_value (b)) == TV_CLASSIFY_ONE) {
n = a; DBG_OPT_ALGSIM1;
}
return n;
ir_node *b = get_Div_right(n);
/* Div is not commutative. */
- if (tarval_classify(computed_value(b)) == TV_CLASSIFY_ONE) { /* div(x, 1) == x */
+ if (classify_tarval(computed_value(b)) == TV_CLASSIFY_ONE) { /* div(x, 1) == x */
/* Turn Div into a tuple (mem, bad, a) */
ir_node *mem = get_Div_mem(n);
turn_into_tuple(n, 3);
if (a == b) {
n = a; /* And has it's own neutral element */
- } else if (tarval_classify(computed_value(a)) == TV_CLASSIFY_ALL_ONE) {
+ } else if (classify_tarval(computed_value(a)) == TV_CLASSIFY_ALL_ONE) {
n = b;
- } else if (tarval_classify(computed_value(b)) == TV_CLASSIFY_ALL_ONE) {
+ } else if (classify_tarval(computed_value(b)) == TV_CLASSIFY_ALL_ONE) {
n = a;
}
if (n != oldn) DBG_OPT_ALGSIM1;
n = new_Bad();
}
} else if (get_irn_mode(n) == mode_X &&
- is_Bad(get_nodes_Block(n))) {
+ is_Bad(get_nodes_block(n))) {
/* Remove dead control flow -- early gigo. */
n = new_Bad();
}
set_Tuple_pred(n, pn_DivMod_X_except, new_Bad()); /* no exception */
set_Tuple_pred(n, pn_DivMod_res_div, a);
set_Tuple_pred(n, pn_DivMod_res_mod, b);
- assert(get_nodes_Block(n));
+ assert(get_nodes_block(n));
}
return n;
(get_opt_unreachable_code())) {
/* It's a boolean Cond, branching on a boolean constant.
Replace it by a tuple (Bad, Jmp) or (Jmp, Bad) */
- jmp = new_r_Jmp(current_ir_graph, get_nodes_Block(n));
+ jmp = new_r_Jmp(current_ir_graph, get_nodes_block(n));
turn_into_tuple(n, 2);
if (ta == tarval_b_true) {
set_Tuple_pred(n, pn_Cond_false, new_Bad());
set_Tuple_pred(n, pn_Cond_true, new_Bad());
}
/* We might generate an endless loop, so keep it alive. */
- add_End_keepalive(get_irg_end(current_ir_graph), get_nodes_Block(n));
+ add_End_keepalive(get_irg_end(current_ir_graph), get_nodes_block(n));
} else if ((ta != tarval_bad) &&
(get_irn_mode(a) == mode_Iu) &&
(get_Cond_kind(n) == dense) &&
Also this tuple might get really big...
I generate the Jmp here, and remember it in link. Link is used
when optimizing Proj. */
- set_irn_link(n, new_r_Jmp(current_ir_graph, get_nodes_Block(n)));
+ set_irn_link(n, new_r_Jmp(current_ir_graph, get_nodes_block(n)));
/* We might generate an endless loop, so keep it alive. */
- add_End_keepalive(get_irg_end(current_ir_graph), get_nodes_Block(n));
+ add_End_keepalive(get_irg_end(current_ir_graph), get_nodes_block(n));
} else if ((get_irn_op(a) == op_Eor)
&& (get_irn_mode(a) == mode_b)
- && (tarval_classify(computed_value(get_Eor_right(a))) == TV_CLASSIFY_ONE)) {
+ && (classify_tarval(computed_value(get_Eor_right(a))) == TV_CLASSIFY_ONE)) {
/* The Eor is a negate. Generate a new Cond without the negate,
simulate the negate by exchanging the results. */
- set_irn_link(n, new_r_Cond(current_ir_graph, get_nodes_Block(n),
+ set_irn_link(n, new_r_Cond(current_ir_graph, get_nodes_block(n),
get_Eor_left(a)));
} else if ((get_irn_op(a) == op_Not)
&& (get_irn_mode(a) == mode_b)) {
/* A Not before the Cond. Generate a new Cond without the Not,
simulate the Not by exchanging the results. */
- set_irn_link(n, new_r_Cond(current_ir_graph, get_nodes_Block(n),
+ set_irn_link(n, new_r_Cond(current_ir_graph, get_nodes_block(n),
get_Not_op(a)));
}
return n;
if ((get_irn_mode(n) == mode_b)
&& (get_irn_op(a) == op_Proj)
&& (get_irn_mode(a) == mode_b)
- && (tarval_classify (computed_value (b)) == TV_CLASSIFY_ONE)
+ && (classify_tarval (computed_value (b)) == TV_CLASSIFY_ONE)
&& (get_irn_op(get_Proj_pred(a)) == op_Cmp))
/* The Eor negates a Cmp. The Cmp has the negated result anyways! */
- n = new_r_Proj(current_ir_graph, get_nodes_Block(n), get_Proj_pred(a),
+ n = new_r_Proj(current_ir_graph, get_nodes_block(n), get_Proj_pred(a),
mode_b, get_negated_pnc(get_Proj_proj(a)));
else if ((get_irn_mode(n) == mode_b)
- && (tarval_classify (computed_value (b)) == TV_CLASSIFY_ONE))
+ && (classify_tarval (computed_value (b)) == TV_CLASSIFY_ONE))
/* The Eor is a Not. Replace it by a Not. */
/* ????!!!Extend to bitfield 1111111. */
- n = new_r_Not(current_ir_graph, get_nodes_Block(n), a, mode_b);
+ n = new_r_Not(current_ir_graph, get_nodes_block(n), a, mode_b);
return n;
}
&& (get_irn_mode(a) == mode_b)
&& (get_irn_op(get_Proj_pred(a)) == op_Cmp))
/* We negate a Cmp. The Cmp has the negated result anyways! */
- n = new_r_Proj(current_ir_graph, get_nodes_Block(n), get_Proj_pred(a),
+ n = new_r_Proj(current_ir_graph, get_nodes_block(n), get_Proj_pred(a),
mode_b, get_negated_pnc(get_Proj_proj(a)));
return n;
b = get_Div_right(n);
tb = computed_value(b);
- if (tb != tarval_bad && tarval_classify(tb) != TV_CLASSIFY_NULL) { /* div(x, c) && c != 0 */
+ if (tb != tarval_bad && classify_tarval(tb) != TV_CLASSIFY_NULL) { /* div(x, c) && c != 0 */
ir_node *div, *proj;
ir_node *a = get_Div_left(n);
ir_node *mem = get_Div_mem(n);
set_optimize(0);
{
div = new_rd_Div(get_irn_dbg_info(n), current_ir_graph,
- get_nodes_Block(n), get_irg_initial_mem(current_ir_graph), a, b);
+ get_nodes_block(n), get_irg_initial_mem(current_ir_graph), a, b);
- proj = new_r_Proj(current_ir_graph, get_nodes_Block(n), div, get_irn_mode(a), pn_Div_res);
+ proj = new_r_Proj(current_ir_graph, get_nodes_block(n), div, get_irn_mode(a), pn_Div_res);
}
set_optimize(rem);
b = get_Mod_right(n);
tb = computed_value(b);
- if (tb != tarval_bad && tarval_classify(tb) != TV_CLASSIFY_NULL) { /* mod(x, c) && c != 0 */
+ if (tb != tarval_bad && classify_tarval(tb) != TV_CLASSIFY_NULL) { /* mod(x, c) && c != 0 */
ir_node *mod, *proj;
ir_node *a = get_Mod_left(n);
ir_node *mem = get_Mod_mem(n);
set_optimize(0);
{
mod = new_rd_Mod(get_irn_dbg_info(n), current_ir_graph,
- get_nodes_Block(n), get_irg_initial_mem(current_ir_graph), a, b);
+ get_nodes_block(n), get_irg_initial_mem(current_ir_graph), a, b);
- proj = new_r_Proj(current_ir_graph, get_nodes_Block(n), mod, get_irn_mode(a), pn_Mod_res);
+ proj = new_r_Proj(current_ir_graph, get_nodes_block(n), mod, get_irn_mode(a), pn_Mod_res);
}
set_optimize(rem);
b = get_DivMod_right(n);
tb = computed_value(b);
- if (tb != tarval_bad && tarval_classify(tb) != TV_CLASSIFY_NULL) { /* DivMod(x, c) && c != 0 */
+ if (tb != tarval_bad && classify_tarval(tb) != TV_CLASSIFY_NULL) { /* DivMod(x, c) && c != 0 */
ir_node *div_mod, *proj_div, *proj_mod;
ir_node *a = get_Mod_left(n);
ir_node *mem = get_Mod_mem(n);
set_optimize(0);
{
div_mod = new_rd_DivMod(get_irn_dbg_info(n), current_ir_graph,
- get_nodes_Block(n), get_irg_initial_mem(current_ir_graph), a, b);
+ get_nodes_block(n), get_irg_initial_mem(current_ir_graph), a, b);
- proj_div = new_r_Proj(current_ir_graph, get_nodes_Block(n), div_mod, get_irn_mode(a), pn_DivMod_res_div);
- proj_mod = new_r_Proj(current_ir_graph, get_nodes_Block(n), div_mod, get_irn_mode(a), pn_DivMod_res_mod);
+ proj_div = new_r_Proj(current_ir_graph, get_nodes_block(n), div_mod, get_irn_mode(a), pn_DivMod_res_div);
+ proj_mod = new_r_Proj(current_ir_graph, get_nodes_block(n), div_mod, get_irn_mode(a), pn_DivMod_res_mod);
}
set_optimize(rem);
tv4 = get_Const_tarval(c4);
tv = tarval_or(tv4, tv2);
- if (tarval_classify(tv) != TV_CLASSIFY_ALL_ONE) {
+ if (classify_tarval(tv) != TV_CLASSIFY_ALL_ONE) {
/* have at least one 0 at the same bit position */
return or;
}
if (irn_arity_a != get_irn_arity(b))
return 1;
- /* for block-local cse and pinned nodes: */
- if (!get_opt_global_cse() || (get_op_pinned(get_irn_op(a)) == pinned)) {
+ /* for block-local cse and op_pin_state_pinned nodes: */
+ if (!get_opt_global_cse() || (get_op_pinned(get_irn_op(a)) == op_pin_state_pinned)) {
if (get_irn_n(a, -1) != get_irn_n(b, -1))
return 1;
}
}
/**
- * During construction we set the pinned flag in the graph right when the
+ * During construction we set the op_pin_state_pinned flag in the graph right when the
* optimization is performed. The flag turning on procedure global cse could
* be changed between two allocations. This way we are safe.
*/
ir_node *old = n;
n = identify(value_table, n);
if (get_irn_n(old, -1) != get_irn_n(n, -1))
- set_irg_pinned(current_ir_graph, floats);
+ set_irg_pinned(current_ir_graph, op_pin_state_floats);
return n;
}
/** common subexpression elimination **/
/* Checks whether n is already available. */
/* The block input is used to distinguish different subexpressions. Right
- now all nodes are pinned to blocks, i.e., the cse only finds common
+ now all nodes are op_pin_state_pinned to blocks, i.e., the cse only finds common
subexpressions within a block. */
if (get_opt_cse())
n = identify_cons (current_ir_graph->value_table, n);
/** common subexpression elimination **/
/* Checks whether n is already available. */
/* The block input is used to distinguish different subexpressions. Right
- now all nodes are pinned to blocks, i.e., the cse only finds common
+ now all nodes are op_pin_state_pinned to blocks, i.e., the cse only finds common
subexpressions within a block. */
if (get_opt_cse()) {
n = identify (current_ir_graph->value_table, n);
assert(get_irg_phase_state(current_ir_graph) != phase_building);
if (get_opt_global_cse())
- set_irg_pinned(current_ir_graph, floats);
+ set_irg_pinned(current_ir_graph, op_pin_state_floats);
if (get_irg_outs_state(current_ir_graph) == outs_consistent)
set_irg_outs_inconsistent(current_ir_graph);
/* Maybe we could also test whether optimizing the node can
res->max_node_nr = 0;
#endif
- res->glob_type = new_type_class(id_from_str (GLOBAL_TYPE_NAME,
+ res->glob_type = new_type_class(new_id_from_chars (GLOBAL_TYPE_NAME,
strlen(GLOBAL_TYPE_NAME)));
/* Remove type from type list. Must be treated differently than
other types. */
res->const_code_irg = new_const_code_irg();
- res->outs_state = no_outs;
+ res->outs_state = outs_none;
res->ip_outedges = NULL;
return res;
*/
ir_prog *get_irp(void);
-/** initializes ir_prog. Calls the constructor for an ir_prog. */
-void init_irprog(void);
-
/** Creates a new ir_prog, returns it and sets irp with it.
* Automatically called by init_firm() through init_irprog. */
ir_prog *new_ir_prog (void);
void set_irp_ip_outedges(ir_node ** ip_outedges);
ir_node** get_irp_ip_outedges(void);
+/** initializes ir_prog. Calls the constructor for an ir_prog. */
+void init_irprog(void);
+
#define get_irp_n_irgs() __get_irp_n_irgs()
#define get_irp_irg(pos) __get_irp_irg(pos)
#define get_irp_n_types() __get_irp_n_types()
*/
static void show_node_on_graph(ir_graph *irg, ir_node *n)
{
- entity *ent = get_irg_ent(irg);
+ entity *ent = get_irg_entity(irg);
if (ent)
fprintf(stderr, "\nFIRM: irn_vrfy_irg() of entity %s, node %ld %s%s\n",
*/
static void show_return_modes(ir_graph *irg, ir_node *n, type *mt, int i)
{
- entity *ent = get_irg_ent(irg);
+ entity *ent = get_irg_entity(irg);
fprintf(stderr, "\nFIRM: irn_vrfy_irg() Return node %ld in entity \"%s\" mode %s different from type mode %s\n",
get_irn_node_nr(n), get_entity_name(ent),
*/
static void show_return_nres(ir_graph *irg, ir_node *n, type *mt)
{
- entity *ent = get_irg_ent(irg);
+ entity *ent = get_irg_entity(irg);
fprintf(stderr, "\nFIRM: irn_vrfy_irg() Return node %ld in entity \"%s\" has %d results different from type %d\n",
get_irn_node_nr(n), get_entity_name(ent),
ir_mode *mode;
int proj;
- pred = skip_nop(get_Proj_pred(p));
+ pred = skip_Id(get_Proj_pred(p));
ASSERT_AND_RET(get_irn_mode(pred) == mode_T, "mode of a 'projed' node is not Tuple", 0);
mode = get_irn_mode(p);
proj = get_Proj_proj(p);
case iro_Start:
ASSERT_AND_RET_DBG(
(
- (proj == pns_initial_exec && mode == mode_X) ||
- (proj == pns_global_store && mode == mode_M) ||
- (proj == pns_frame_base && mode_is_reference(mode)) ||
- (proj == pns_globals && mode_is_reference(mode)) ||
- (proj == pns_args && mode == mode_T) ||
- (proj == pns_value_arg_base && mode_is_reference(mode)) ||
- (proj == pns_value_arg_base && mode == mode_T) /* FIXME: only one of those */
+ (proj == pn_Start_X_initial_exec && mode == mode_X) ||
+ (proj == pn_Start_M && mode == mode_M) ||
+ (proj == pn_Start_P_frame_base && mode_is_reference(mode)) ||
+ (proj == pn_Start_P_globals && mode_is_reference(mode)) ||
+ (proj == pn_Start_T_args && mode == mode_T) ||
+ (proj == pn_Start_P_value_arg_base && mode_is_reference(mode)) ||
+ (proj == pn_Start_P_value_arg_base && mode == mode_T) /* FIXME: only one of those */
),
"wrong Proj from Start", 0,
show_proj_failure(p);
type *mt; /* A method type */
long nr = get_Proj_proj(pred);
- pred = skip_nop(get_Proj_pred(pred));
+ pred = skip_Id(get_Proj_pred(pred));
ASSERT_AND_RET((get_irn_mode(pred) == mode_T), "Proj from something not a tuple", 0);
switch (get_irn_opcode(pred))
{
case iro_Start:
- mt = get_entity_type(get_irg_ent(irg));
+ mt = get_entity_type(get_irg_entity(irg));
- if (nr == pns_args) {
+ if (nr == pn_Start_T_args) {
ASSERT_AND_RET(
(proj >= 0 && mode_is_data(mode)),
"wrong Proj from Proj from Start", 0);
(mode == get_type_mode(get_method_param_type(mt, proj))),
"Mode of Proj from Start doesn't match mode of param type.", 0);
}
- else if (nr == pns_value_arg_base) {
+ else if (nr == pn_Start_P_value_arg_base) {
ASSERT_AND_RET(
(proj >= 0 && mode_is_reference(mode)),
"wrong Proj from Proj from Start", 0
};
ASSERT_AND_RET( mymode == mode_X, "Result X", 0 ); /* result X */
/* Compare returned results with result types of method type */
- mt = get_entity_type(get_irg_ent(irg));
+ mt = get_entity_type(get_irg_entity(irg));
ASSERT_AND_RET_DBG( get_Return_n_ress(n) == get_method_n_ress(mt),
"Number of results for Return doesn't match number of results in type.", 0,
show_return_nres(irg, n, mt););
case iro_Const: {
tarval *tv = get_Const_tarval(n);
- if (tarval_is_entity(tv))
- ASSERT_AND_RET(
- (get_irn_irg(n) == get_const_code_irg()) ||
- (get_entity_peculiarity(get_tarval_entity(tv)) != peculiarity_description),
- "descriptions have no address", 0);
ASSERT_AND_RET(
/* Const: BB --> data */
(mode_is_data (mymode) ||
rem = current_ir_graph;
current_ir_graph = irg;
- assert(get_irg_pinned(irg) == pinned);
+ assert(get_irg_pinned(irg) == op_pin_state_pinned);
irg_walk(irg->end, vrfy_wrap, NULL, &res);
/**
* Calls irn_vrfy for each node in irg.
- * Graph must be in state "pinned".
+ * Graph must be in state "op_pin_state_pinned".
*
* \return
* NON-zero on success.
for (i = 1, p = rets; p; p = get_irn_link(p)) {
ir_node *jmp;
- switch_block(get_nodes_Block(p));
+ set_cur_block(get_nodes_block(p));
jmp = new_Jmp();
exchange(p, new_Bad());
/* check if it's a recursive call */
call_ptr = get_Call_ptr(call);
- if (get_irn_op(call_ptr) != op_Const)
+ if (get_irn_op(call_ptr) != op_SymConst)
continue;
- tv = get_Const_tarval(call_ptr);
- if (! tarval_is_entity(tv))
- continue;
-
- ent = get_tarval_entity(tv);
+ ent = get_SymConst_entity(call_ptr);
if (!ent || get_entity_irg(ent) != irg)
continue;
/* check preds: */
for (i = 0; i < n_ins; i ++)
{
- ir_node *in = get_nodes_Block (get_irn_n (block, i));
+ ir_node *in = get_nodes_block (get_irn_n (block, i));
bs_t in_mask = get_mask (dt, in);
new_mask &= in_mask;
{
ir_node *ndom = 0;
- pred = get_nodes_Block (get_irn_n (block, i));
+ pred = get_nodes_block (get_irn_n (block, i));
ndom = _get_idom (dt, pred);
if (ndom != idom)
/* count all incoming edges */
for (i = 0; i < arity; ++i) {
ir_node *pred = get_irn_n(node, i);
- ir_node *other_block = get_nodes_Block(pred);
+ ir_node *other_block = get_nodes_block(pred);
block_entry_t *b_entry_other = block_get_entry(get_irn_node_nr(other_block), graph->block_hash);
cnt_inc(&b_entry->cnt_in_edges); /* an edge coming from another block */
// return;
}
- block = get_nodes_Block(node);
+ block = get_nodes_block(node);
b_entry = block_get_entry(get_irn_node_nr(block), graph->block_hash);
/* we have a new nodes */
if (get_irn_op(pred) == op_Block)
continue;
- other_block = get_nodes_Block(pred);
+ other_block = get_nodes_block(pred);
if (other_block == block)
cnt_inc(&b_entry->cnt_edges); /* a in block edge */
}
/* initialize the statistics module. */
-void stat_init(unsigned enable_options)
+void init_stat(void)
{
#define X(a) a, sizeof(a)-1
/* build the pseudo-ops */
_op_Phi0.code = --pseudo_id;
- _op_Phi0.name = id_from_str(X("Phi0"));
+ _op_Phi0.name = new_id_from_chars(X("Phi0"));
_op_PhiM.code = --pseudo_id;
- _op_PhiM.name = id_from_str(X("PhiM"));
+ _op_PhiM.name = new_id_from_chars(X("PhiM"));
/* create the hash-tables */
status->irg_hash = new_pset(graph_cmp, 8);
#define FIRM_STATISTICS
#include "firmstat.h"
-void stat_init(unsigned options) {}
+void init_stat(void) {}
void stat_finish(void) {}
*
* @param enable_options Bitmask containing the statistic options
*/
-void stat_init(unsigned enable_options);
+
+void init_stat(void);
+
+/**
+ * Finish the statistics.
+ */
+void stat_finish(void);
/**
* A new IR op is registered.
#else
-#define stat_init(flag)
+#define init_stat()
+#define stat_finish()
#define stat_new_ir_op(op)
#define stat_free_ir_op(op)
#define stat_new_node(node)
void
free_entity (entity *ent) {
assert(ent && ent->kind == k_entity);
- free_tarval_entity(ent);
free_entity_attrs(ent);
ent->kind = k_BAD;
free(ent);
obstack_grow(&mangle_obst,get_id_str(ent->name),get_id_strlen(ent->name));
len = obstack_object_size (&mangle_obst);
cp = obstack_finish (&mangle_obst);
- res = id_from_str(cp, len);
+ res = new_id_from_chars(cp, len);
obstack_free (&mangle_obst, cp);
return res;
}
obstack_grow(&mangle_obst, get_id_str(scnd), get_id_strlen(scnd));
len = obstack_object_size (&mangle_obst);
cp = obstack_finish (&mangle_obst);
- res = id_from_str (cp, len);
+ res = new_id_from_chars (cp, len);
obstack_free (&mangle_obst, cp);
return res;
}
obstack_grow(&mangle_obst,get_id_str(scnd),get_id_strlen(scnd));
len = obstack_object_size (&mangle_obst);
cp = obstack_finish (&mangle_obst);
- res = id_from_str (cp, len);
+ res = new_id_from_chars (cp, len);
obstack_free (&mangle_obst, cp);
return res;
}
void
init_tpop(void)
{
- type_class = new_tpop (tpo_class , id_from_str("class" , 5), sizeof (cls_attr));
- type_struct = new_tpop (tpo_struct , id_from_str("struct" , 6), sizeof (stc_attr));
- type_method = new_tpop (tpo_method , id_from_str("method" , 6), sizeof (mtd_attr));
- type_union = new_tpop (tpo_union , id_from_str("union" , 5), sizeof (uni_attr));
- type_array = new_tpop (tpo_array , id_from_str("array" , 5), sizeof (arr_attr));
- type_enumeration = new_tpop (tpo_enumeration, id_from_str("enumeration" ,11), sizeof (enm_attr));
- type_pointer = new_tpop (tpo_pointer , id_from_str("pointer" , 7), sizeof (ptr_attr));
- type_primitive = new_tpop (tpo_primitive , id_from_str("primitive" , 9), /* sizeof (pri_attr) */ 0);
- type_id = new_tpop (tpo_id , id_from_str("type_id" , 7), /* sizeof (id_attr) */ 0);
- tpop_none = new_tpop (tpo_none , id_from_str("tpop_none" , 9), /* sizeof (non_attr) */ 0);
- tpop_unknown = new_tpop (tpo_unknown , id_from_str("tpop_unknown",12), /* sizeof (ukn_attr) */ 0);
+ type_class = new_tpop (tpo_class , new_id_from_chars("class" , 5), sizeof (cls_attr));
+ type_struct = new_tpop (tpo_struct , new_id_from_chars("struct" , 6), sizeof (stc_attr));
+ type_method = new_tpop (tpo_method , new_id_from_chars("method" , 6), sizeof (mtd_attr));
+ type_union = new_tpop (tpo_union , new_id_from_chars("union" , 5), sizeof (uni_attr));
+ type_array = new_tpop (tpo_array , new_id_from_chars("array" , 5), sizeof (arr_attr));
+ type_enumeration = new_tpop (tpo_enumeration, new_id_from_chars("enumeration" ,11), sizeof (enm_attr));
+ type_pointer = new_tpop (tpo_pointer , new_id_from_chars("pointer" , 7), sizeof (ptr_attr));
+ type_primitive = new_tpop (tpo_primitive , new_id_from_chars("primitive" , 9), /* sizeof (pri_attr) */ 0);
+ type_id = new_tpop (tpo_id , new_id_from_chars("type_id" , 7), /* sizeof (id_attr) */ 0);
+ tpop_none = new_tpop (tpo_none , new_id_from_chars("tpop_none" , 9), /* sizeof (non_attr) */ 0);
+ tpop_unknown = new_tpop (tpo_unknown , new_id_from_chars("tpop_unknown",12), /* sizeof (ukn_attr) */ 0);
}
/* Finalize the topo module.
current_ir_graph = rem;
res->attr.aa.element_type = element_type;
- new_entity(res, mangle_u(name, id_from_str("elem_ent", 8)), element_type);
+ new_entity(res, mangle_u(name, new_id_from_chars("elem_ent", 8)), element_type);
return res;
}
assert(array && (array->type_op == type_array));
node = array->attr.aa.lower_bound[dimension];
assert(get_irn_op(node) == op_Const);
- return tarval_to_long(get_Const_tarval(node));
+ return get_tarval_long(get_Const_tarval(node));
}
int has_array_upper_bound (type *array, int dimension) {
assert(array && (array->type_op == type_array));
assert(array && (array->type_op == type_array));
node = array->attr.aa.upper_bound[dimension];
assert(get_irn_op(node) == op_Const);
- return tarval_to_long(get_Const_tarval(node));
+ return get_tarval_long(get_Const_tarval(node));
}
void set_array_order (type *array, int dimension, int order) {
++type_visited;
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);
+ type_walk_2((type_or_ent *)get_irg_entity(irg), pre, post, env);
type_walk_2((type_or_ent *)get_irg_frame_type(irg), pre, post, env);
}
/* this might overflow the machine's long, so use only with small values */
-long tarval_to_long(tarval* tv)
+long get_tarval_long(tarval* tv)
{
ANNOUNCE();
assert(tarval_is_long(tv) && "tarval too big to fit in long");
return (get_mode_sort(tv->mode) == irms_float_number);
}
-long double tarval_to_double(tarval *tv)
+long double get_tarval_double(tarval *tv)
{
ANNOUNCE();
assert(tarval_is_double(tv));
return fc_val_to_float(tv->value);
}
-/* The tarval represents the address of the entity. As the address must
- be constant the entity must have as owner the global type.
- * We no more support this function: Use the new SymConst instead.
- */
-tarval *new_tarval_from_entity (entity *ent, ir_mode *mode)
-{
- ANNOUNCE();
- assert(ent);
- assert(mode && (get_mode_sort(mode) == irms_reference));
-
- return get_tarval((void *)ent, 0, mode);
-}
-
-
-int tarval_is_entity(tarval *tv)
-{
- ANNOUNCE();
- assert(tv);
- /* tv->value == NULL means dereferencing a null pointer */
- return ((get_mode_sort(tv->mode) == irms_reference) && (tv->value != NULL) && (tv->length == 0)
- && (tv != tarval_P_void));
-}
-
-#undef tarval_to_entity
-entity *tarval_to_entity(tarval *tv) { return get_tarval_entity(tv); }
-entity *get_tarval_entity(tarval *tv)
-{
- ANNOUNCE();
- assert(tv);
-
- if (tarval_is_entity(tv))
- return (entity *)tv->value;
- else {
- assert(0 && "tarval did not represent an entity");
- return NULL;
- }
-}
-
-void free_tarval_entity(entity *ent) {
- /* There can be a tarval referencing this entity. Even if the
- tarval is not used by the code any more, it can still reference
- the entity as tarvals live indepently of the entity referenced.
- Further the tarval is hashed into a set. If a hash function
- evaluation happens to collide with this tarval, we will vrfy that
- it contains a proper entity and we will crash if the entity is
- freed.
-
- Unluckily, tarvals can neither be changed nor deleted, and to find
- one, all existing reference modes have to be tried -> a facility
- to retrieve all modes of a kind is needed. */
- ANNOUNCE();
-}
/*
* Access routines for tarval fields ========================================
ANNOUNCE();
assert(mode);
- if (get_mode_vector_elems(mode) > 1) {
+ if (get_mode_n_vector_elems(mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
ANNOUNCE();
assert(mode);
- if (get_mode_vector_elems(mode) > 1) {
+ if (get_mode_n_vector_elems(mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
ANNOUNCE();
assert(mode);
- if (get_mode_vector_elems(mode) > 1) {
+ if (get_mode_n_vector_elems(mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
ANNOUNCE();
assert(mode);
- if (get_mode_vector_elems(mode) > 1) {
+ if (get_mode_n_vector_elems(mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
ANNOUNCE();
assert(mode);
- if (get_mode_vector_elems(mode) > 1) {
+ if (get_mode_n_vector_elems(mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
ANNOUNCE();
assert(mode);
- if (get_mode_vector_elems(mode) > 1) {
+ if (get_mode_n_vector_elems(mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
ANNOUNCE();
assert(a);
- if (get_mode_vector_elems(a->mode) > 1) {
+ if (get_mode_n_vector_elems(a->mode) > 1) {
/* vector arithmetic not implemented yet */
assert(0 && "tarval_is_negative is not allowed for vector modes");
return 0;
if (a == b) return Eq;
if (a->mode != b->mode) return False;
- if (get_mode_vector_elems(a->mode) > 1) {
+ if (get_mode_n_vector_elems(a->mode) > 1) {
/* vector arithmetic not implemented yet */
assert(0 && "cmp not implemented for vector modes");
}
if (src->mode == m) return src;
- if (get_mode_vector_elems(src->mode) > 1) {
+ if (get_mode_n_vector_elems(src->mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
assert(mode_is_num(a->mode)); /* negation only for numerical values */
assert(mode_is_signed(a->mode)); /* negation is difficult without negative numbers, isn't it */
- if (get_mode_vector_elems(a->mode) > 1) {
+ if (get_mode_n_vector_elems(a->mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
assert(b);
assert((a->mode == b->mode) || (get_mode_sort(a->mode) == irms_character && mode_is_int(b->mode)));
- if (get_mode_vector_elems(a->mode) > 1 || get_mode_vector_elems(b->mode) > 1) {
+ if (get_mode_n_vector_elems(a->mode) > 1 || get_mode_n_vector_elems(b->mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
assert(b);
assert((a->mode == b->mode) || (get_mode_sort(a->mode) == irms_character && mode_is_int(b->mode)));
- if (get_mode_vector_elems(a->mode) > 1 || get_mode_vector_elems(b->mode) > 1) {
+ if (get_mode_n_vector_elems(a->mode) > 1 || get_mode_n_vector_elems(b->mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
assert(b);
assert((a->mode == b->mode) && mode_is_num(a->mode));
- if (get_mode_vector_elems(a->mode) > 1) {
+ if (get_mode_n_vector_elems(a->mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
assert(b);
assert((a->mode == b->mode) && mode_is_float(a->mode));
- if (get_mode_vector_elems(a->mode) > 1) {
+ if (get_mode_n_vector_elems(a->mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
assert(b);
assert((a->mode == b->mode) && mode_is_int(a->mode));
- if (get_mode_vector_elems(a->mode) > 1) {
+ if (get_mode_n_vector_elems(a->mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
assert(b);
assert((a->mode == b->mode) && mode_is_int(a->mode));
- if (get_mode_vector_elems(a->mode) > 1) {
+ if (get_mode_n_vector_elems(a->mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
assert(a);
assert(mode_is_num(a->mode));
- if (get_mode_vector_elems(a->mode) > 1) {
+ if (get_mode_n_vector_elems(a->mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
assert(b);
assert(mode_is_int(a->mode) && mode_is_int(b->mode));
- if (get_mode_vector_elems(a->mode) > 1 || get_mode_vector_elems(a->mode) > 1) {
+ if (get_mode_n_vector_elems(a->mode) > 1 || get_mode_n_vector_elems(a->mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
assert(b);
assert(mode_is_int(a->mode) && mode_is_int(b->mode));
- if (get_mode_vector_elems(a->mode) > 1 || get_mode_vector_elems(a->mode) > 1) {
+ if (get_mode_n_vector_elems(a->mode) > 1 || get_mode_n_vector_elems(a->mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
assert(b);
assert(mode_is_int(a->mode) && mode_is_int(b->mode));
- if (get_mode_vector_elems(a->mode) > 1 || get_mode_vector_elems(a->mode) > 1) {
+ if (get_mode_n_vector_elems(a->mode) > 1 || get_mode_n_vector_elems(a->mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
assert(b);
assert(mode_is_int(a->mode) && mode_is_int(b->mode));
- if (get_mode_vector_elems(a->mode) > 1 || get_mode_vector_elems(a->mode) > 1) {
+ if (get_mode_n_vector_elems(a->mode) > 1 || get_mode_n_vector_elems(a->mode) > 1) {
/* vector arithmetic not implemented yet */
return tarval_bad;
}
case irms_reference:
if (tv == tarval_P_void) return snprintf(buf, len, "NULL");
- if (tv->value != NULL)
- if (tarval_is_entity(tv)) {
- if (get_entity_peculiarity((entity *)tv->value) != peculiarity_description)
- return snprintf(buf, len, "%s%s%s", prefix, get_entity_ld_name((entity *)tv->value), suffix);
- else {
- if (mode_info->mode_output == TVO_NATIVE)
- return snprintf(buf, len, "NULL");
- else
- return snprintf(buf, len, "0");
- }
- }
- else {
+ if (tv->value != NULL){
if (len > tv->length) {
memcpy(buf, tv->value, tv->length);
buf[tv->length] = '\0';
buf[len-1] = '\0';
}
return tv->length;
- }
+ }
else
return snprintf(buf, len, "void");
}
-char *tarval_bitpattern(tarval *tv)
+char *get_tarval_bitpattern(tarval *tv)
{
return NULL;
}
/*
* access to the bitpattern
*/
-unsigned char tarval_sub_bits(tarval *tv, unsigned byte_ofs)
+unsigned char get_tarval_sub_bits(tarval *tv, unsigned byte_ofs)
{
switch (get_mode_sort(tv->mode)) {
case irms_int_number:
*
* Returns zero on success.
*/
-int tarval_set_mode_output_option(ir_mode *mode, const tarval_mode_info *modeinfo)
+int set_tarval_mode_output_option(ir_mode *mode, const tarval_mode_info *modeinfo)
{
assert(mode);
*
* This functions returns the modinfo of a given mode.
*/
-const tarval_mode_info *tarval_get_mode_output_option(ir_mode *mode)
+const tarval_mode_info *get_tarval_mode_output_option(ir_mode *mode)
{
assert(mode);
* - TV_CLASSIFY_ALL_ONE for bitwise-and neutral
* - TV_CLASSIFY_OTHER else
*/
-tarval_classification_t tarval_classify(tarval *tv)
+tarval_classification_t classify_tarval(tarval *tv)
{
ANNOUNCE();
if (!tv || tv == tarval_bad) return TV_CLASSIFY_OTHER;
* assign output modes that are compatible with the
* old implementation: Hex output
*/
- tarval_set_mode_output_option(mode_U, &hex_output);
- tarval_set_mode_output_option(mode_C, &hex_output);
- tarval_set_mode_output_option(mode_Bs, &hex_output);
- tarval_set_mode_output_option(mode_Bu, &hex_output);
- tarval_set_mode_output_option(mode_Hs, &hex_output);
- tarval_set_mode_output_option(mode_Hu, &hex_output);
- tarval_set_mode_output_option(mode_Is, &hex_output);
- tarval_set_mode_output_option(mode_Iu, &hex_output);
- tarval_set_mode_output_option(mode_Ls, &hex_output);
- tarval_set_mode_output_option(mode_Lu, &hex_output);
- tarval_set_mode_output_option(mode_P, &reference_output);
+ set_tarval_mode_output_option(mode_U, &hex_output);
+ set_tarval_mode_output_option(mode_C, &hex_output);
+ set_tarval_mode_output_option(mode_Bs, &hex_output);
+ set_tarval_mode_output_option(mode_Bu, &hex_output);
+ set_tarval_mode_output_option(mode_Hs, &hex_output);
+ set_tarval_mode_output_option(mode_Hu, &hex_output);
+ set_tarval_mode_output_option(mode_Is, &hex_output);
+ set_tarval_mode_output_option(mode_Iu, &hex_output);
+ set_tarval_mode_output_option(mode_Ls, &hex_output);
+ set_tarval_mode_output_option(mode_Lu, &hex_output);
+ set_tarval_mode_output_option(mode_P, &reference_output);
}
/* free all memory occupied by tarval. */
#define _TV_H_
# include "irmode.h"
-# include "entity.h"
+ //# include "entity.h"
# include "irnode.h" /* for pnc_number enum */
* you are doing! (better check with tarval_is_long()...)
* Works only for int modes, even not for character modes!
*/
-long tarval_to_long(tarval *tv);
-#define get_tarval_long tarval_to_long
+long get_tarval_long(tarval *tv);
/**
* This validates if tarval_to_long() will return a satisfying
* This will overflow silently, so use only if you know what
* you are doing! (better check with tarval_is_long...)
*/
-long double tarval_to_double(tarval *tv);
+long double get_tarval_double(tarval *tv);
/**
* This validates if tarval_to_double() will return a satisfying
*
* The address must be constant, the entity must have as owner the global type.
* We no more support this function: Use the new SymConst instead.
- */
tarval *new_tarval_from_entity (entity *ent, ir_mode *mode);
+ */
/**
* Returns the associated entity of a tarval. Asserts if tarval does not
* contain an entity.
- */
entity *get_tarval_entity(tarval *tv);
+ */
/**
* Returns non-zero if a the given tarval represents an entity.
- */
int tarval_is_entity(tarval *tv);
+ */
/** ********** Access routines for tarval fields ********** **/
*
* @return zero on success.
*/
-int tarval_set_mode_output_option(ir_mode *mode, const tarval_mode_info *modeinfo);
+int set_tarval_mode_output_option(ir_mode *mode, const tarval_mode_info *modeinfo);
/**
* Returns the output options of one mode.
*
* @return the output option
*/
-const tarval_mode_info *tarval_get_mode_output_option(ir_mode *mode);
+const tarval_mode_info *get_tarval_mode_output_option(ir_mode *mode);
/**
* Returns Bit representation of a tarval value, as string of '0' and '1'
* irmode.h for the definition of the ir_mode struct
* the size member of aforementioned struct
*/
-char *tarval_bitpattern(tarval *tv);
+char *get_tarval_bitpattern(tarval *tv);
/**
* Returns the bitpattern of the bytes_ofs byte.
* @note
* The result of this funcion is undefined if the mode is neither integer nor float.
*/
-unsigned char tarval_sub_bits(tarval *tv, unsigned byte_ofs);
+unsigned char get_tarval_sub_bits(tarval *tv, unsigned byte_ofs);
/**
* Return values of tarval classify
* - TV_CLASSIFY_ALL_ONE for bitwise-and neutral
* - TV_CLASSIFY_OTHER else
*/
-tarval_classification_t tarval_classify(tarval *tv);
+tarval_classification_t classify_tarval(tarval *tv);
This is the modeling appropriate for other languages.
Mode_i says that all integers shall be implemented as a
32 bit integer value. */
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
+ prim_t_int = new_type_primitive(new_id_from_chars ("int", 3), mode_Is);
printf("\nCreating an IR graph: ARRAY-HEAP_EXAMPLE...\n");
/* first build procedure main */
owner = get_glob_type();
- proc_main = new_type_method(id_from_str("ARRAY-HEAP_EXAMPLE_main", 23), 0, 1);
+ proc_main = new_type_method(new_id_from_chars("ARRAY-HEAP_EXAMPLE_main", 23), 0, 1);
set_method_res_type(proc_main, 0, (type *)prim_t_int);
- proc_main_e = new_entity ((type*)owner, id_from_str ("ARRAY-HEAP_EXAMPLE_main", 23), (type *)proc_main);
+ proc_main_e = new_entity ((type*)owner, new_id_from_chars("ARRAY-HEAP_EXAMPLE_main", 23), (type *)proc_main);
/* make type information for the array and set the bounds */
# define N_DIMS 1
# define L_BOUND 0
# define U_BOUND 9
current_ir_graph = get_const_code_irg();
- array_type = new_type_array(id_from_str("a", 1), N_DIMS, prim_t_int);
+ array_type = new_type_array(new_id_from_chars("a", 1), N_DIMS, prim_t_int);
set_array_bounds(array_type, 0,
new_Const(mode_Iu, new_tarval_from_long (L_BOUND, mode_Iu)),
new_Const(mode_Iu, new_tarval_from_long (U_BOUND, mode_Iu)));
x = new_Return (get_store (), 1, in);
}
- mature_block (get_irg_current_block(main_irg));
+ mature_immBlock (get_irg_current_block(main_irg));
/* complete the end_block */
- add_in_edge (get_irg_end_block(main_irg), x);
- mature_block (get_irg_end_block(main_irg));
+ add_immBlock_pred (get_irg_end_block(main_irg), x);
+ mature_immBlock (get_irg_end_block(main_irg));
finalize_cons (main_irg);
irg_vrfy(main_irg);
printf("Dumping the graph and a type graph.\n");
- dump_ir_block_graph (main_irg);
- dump_type_graph(main_irg);
- dump_all_types();
+ char *dump_file_suffix = "";
+ dump_ir_block_graph (main_irg, dump_file_suffix);
+ dump_type_graph(main_irg, dump_file_suffix);
+ dump_all_types(dump_file_suffix);
printf("use xvcg to view these graphs:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
+
/*
* Project: libFIRM
* File name: testprograms/array-stack_example.c
This is the modeling appropriate for other languages.
Mode_i says that all language-integers shall be implemented
as a 32 bit processor-integer value. */
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
+ prim_t_int = new_type_primitive(new_id_from_chars ("int", 3), mode_Is);
/* build typeinformation of procedure main */
- owner = new_type_class (id_from_str ("ARRAY-STACK_EXAMPLE", 19));
- proc_main = new_type_method(id_from_str("main_tp", 7), 0, 1);
+ owner = new_type_class (new_id_from_chars ("ARRAY-STACK_EXAMPLE", 19));
+ proc_main = new_type_method(new_id_from_chars("main_tp", 7), 0, 1);
set_method_res_type(proc_main, 0, prim_t_int);
- proc_main_e = new_entity (owner, id_from_str ("main", 4), proc_main);
+ proc_main_e = new_entity (owner, new_id_from_chars ("main", 4), proc_main);
get_entity_ld_name(proc_main_e); /* force name mangling */
/* make type information for the array and set the bounds */
# define N_DIMS 1
# define L_BOUND 0
# define U_BOUND 9
- array_type = new_type_array(id_from_str("a_tp", 4), N_DIMS, prim_t_int);
+ array_type = new_type_array(new_id_from_chars("a_tp", 4), N_DIMS, prim_t_int);
current_ir_graph = get_const_code_irg();
set_array_bounds(array_type, 0,
new_Const(mode_Iu, new_tarval_from_long (L_BOUND, mode_Iu)),
/* The array is an entity of the method, placed on the mehtod's own memory,
the stack frame. */
- array_ent = new_entity(get_cur_frame_type(), id_from_str("a", 1), array_type);
+ array_ent = new_entity(get_cur_frame_type(), new_id_from_chars("a", 1), array_type);
/* As the array is accessed by Sel nodes, we need information about
the entity the node selects. Entities of an array are it's elements
which are, in this case, integers. */
x = new_Return (get_store (), 1, in);
}
- mature_block (get_irg_current_block(main_irg));
+ mature_immBlock (get_irg_current_block(main_irg));
/* complete the end_block */
- add_in_edge (get_irg_end_block(main_irg), x);
- mature_block (get_irg_end_block(main_irg));
+ add_immBlock_pred (get_irg_end_block(main_irg), x);
+ mature_immBlock (get_irg_end_block(main_irg));
finalize_cons (main_irg);
/* verify the graph */
irg_vrfy(main_irg);
-
+ char *dump_file_suffix = "";
printf("Dumping the graph and a type graph.\n");
- dump_ir_block_graph (main_irg);
- dump_type_graph(main_irg);
- dump_ir_block_graph_w_types(main_irg);
- dump_all_types();
+ dump_ir_block_graph (main_irg, dump_file_suffix);
+ dump_type_graph(main_irg, dump_file_suffix);
+ dump_ir_block_graph_w_types(main_irg, dump_file_suffix);
+ dump_all_types(dump_file_suffix);
printf("Use xvcg to view these graphs:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
init_firm (NULL);
/* An unsinged 8 bit type */
- U8 = new_type_primitive (id_from_str("char", 4), mode_Bu);
+ U8 = new_type_primitive (new_id_from_chars("char", 4), mode_Bu);
/* An array containing unsigned 8 bit elements. */
- U8array = new_type_array (id_from_str ("char_arr", 8), 1, U8);
- string_ptr = new_type_pointer (id_from_str ("ptr_to_string", 13), U8array);
+ U8array = new_type_array (new_id_from_chars("char_arr", 8), 1, U8);
+ string_ptr = new_type_pointer (new_id_from_chars ("ptr_to_string", 13), U8array);
/* Make a global entity that represents the constant String. */
const_str = new_entity(get_glob_type(), new_id_from_str("constStr"), U8array);
#define NRARGS 0
#define NRES 0
owner = get_glob_type();
- proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
+ proc_main = new_type_method(new_id_from_chars(METHODNAME, strlen(METHODNAME)),
NRARGS, NRES);
/* Make type information for called method which also belongs to the
#define F_NRARGS 1
#define F_NRES 0
owner = get_glob_type();
- proc_called = new_type_method(id_from_str(F_METHODNAME, strlen(F_METHODNAME)),
+ proc_called = new_type_method(new_id_from_chars(F_METHODNAME, strlen(F_METHODNAME)),
F_NRARGS, F_NRES);
set_method_param_type(proc_called, 0, string_ptr);
/* Make the entity for main needed for a correct ir_graph. */
#define ENTITYNAME "CALL_STR_EXAMPLE_main"
- ent = new_entity (owner, id_from_str (ENTITYNAME, strlen(ENTITYNAME)),
+ ent = new_entity (owner, new_id_from_chars (ENTITYNAME, strlen(ENTITYNAME)),
proc_main);
/* Generates the basic graph for the method represented by entity ent, that
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
/* get the pointer to the string constant */
- str_addr = new_Const(mode_P, new_tarval_from_entity(const_str, mode_P));
+ symconst_symbol sym;
+ sym.entity_p = const_str;
+ str_addr = new_SymConst(sym, symconst_addr_ent);
/* get the pointer to the procedure from the class type */
/* this is how a pointer to be fixed by the linker is represented. */
- symconst_symbol sym;
sym.ident_p = new_id_from_str (F_METHODNAME);
proc_ptr = new_SymConst (sym, symconst_addr_name);
x = new_Return (get_store(), 0, NULL);
/* Now we generated all instructions for this block and all its predecessor blocks
* so we can mature it. */
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (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 (get_irg_end_block(irg), x);
+ add_immBlock_pred (get_irg_end_block(irg), x);
/* Now we can mature the end block as all it's predecessors are known. */
- mature_block (get_irg_end_block(irg));
+ mature_immBlock (get_irg_end_block(irg));
finalize_cons (irg);
irg_vrfy(irg);
printf("Done building the graph. Dumping it.\n");
- dump_ir_block_graph (irg);
- dump_all_types();
+ char *dump_file_suffix = "";
+ dump_ir_block_graph (irg, dump_file_suffix);
+ dump_all_types(dump_file_suffix);
printf("Use xvcg to view this graph:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
init_firm (NULL);
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
+ prim_t_int = new_type_primitive(new_id_from_chars ("int", 3), mode_Is);
/* FIRM was designed for oo languages where all methods belong to a class.
* For imperative languages like C we view a file as a large class containing
#define CLASSNAME "COND_EXAMPLE"
#define ENTITYNAME "main"
- owner = new_type_class (id_from_str (CLASSNAME, strlen(CLASSNAME)));
- method = new_type_method (id_from_str("main", 4), 1, 1);
+ owner = new_type_class (new_id_from_chars (CLASSNAME, strlen(CLASSNAME)));
+ method = new_type_method (new_id_from_chars("main", 4), 1, 1);
set_method_param_type(method, 0, prim_t_int);
set_method_res_type(method, 0, prim_t_int);
- ent = new_entity (owner, id_from_str (ENTITYNAME, strlen(ENTITYNAME)), method);
+ ent = new_entity (owner, new_id_from_chars (ENTITYNAME, strlen(ENTITYNAME)), method);
get_entity_ld_name(ent);
f = new_Proj (x, mode_X, 0); /* if condition is false */
t = new_Proj (x, mode_X, 1); /* if condition is true */
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (get_irg_current_block(irg));
/* generate and fill the then block */
b = new_immBlock ();
- add_in_edge (b, t);
+ add_immBlock_pred (b, t);
set_value (0, new_Const (mode_Is, new_tarval_from_long (1, mode_Is)));
- mature_block (b);
+ mature_immBlock (b);
x_then = new_Jmp ();
/* generate the fall through block and add all cfg edges */
b = new_immBlock ();
- add_in_edge (b, x_then);
- add_in_edge (b, f);
+ add_immBlock_pred (b, x_then);
+ add_immBlock_pred (b, f);
/* Generate the return node into current region. */
}
/* Now generate all instructions for this block and all its predecessor blocks
* so we can mature it. */
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (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 (get_irg_end_block(irg), x);
+ add_immBlock_pred (get_irg_end_block(irg), x);
/* Now we can mature the end block as all it's predecessors are known. */
- mature_block (get_irg_end_block(irg));
+ mature_immBlock (get_irg_end_block(irg));
finalize_cons (irg);
irg_vrfy(irg);
printf("Done building the graph. Dumping it.\n");
- dump_ir_block_graph (irg);
+ dump_ir_block_graph (irg, 0);
printf("Use xvcg to view this graph:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
init_firm (NULL);
/** make idents for all used identifiers in the program. */
- Ci = id_from_str("C", strlen("C"));
- ai = id_from_str("a", strlen("a"));
- fi = id_from_str("f", strlen("f"));
- fti = id_from_str("f_type", strlen("f_type"));
- gi = id_from_str("g", strlen("g"));
- gti = id_from_str("g_type", strlen("g_type"));
- inti = id_from_str("int", strlen("int"));
- dipti = id_from_str("C_dispatch_table_type", strlen("C_dispatch_table_type"));
- diptei = id_from_str("C_dispatch_table", strlen("C_dispatch_table"));
- diptpi = id_from_str("C_dispatch_table_p_type", strlen("C_dispatch_table_p_type"));
- diptpei = id_from_str("C_dispatch_table_p", strlen("C_dispatch_table_p"));
+ Ci = new_id_from_chars("C", strlen("C"));
+ ai = new_id_from_chars("a", strlen("a"));
+ fi = new_id_from_chars("f", strlen("f"));
+ fti = new_id_from_chars("f_type", strlen("f_type"));
+ gi = new_id_from_chars("g", strlen("g"));
+ gti = new_id_from_chars("g_type", strlen("g_type"));
+ inti = new_id_from_chars("int", strlen("int"));
+ dipti = new_id_from_chars("C_dispatch_table_type", strlen("C_dispatch_table_type"));
+ diptei = new_id_from_chars("C_dispatch_table", strlen("C_dispatch_table"));
+ diptpi = new_id_from_chars("C_dispatch_table_p_type", strlen("C_dispatch_table_p_type"));
+ diptpei = new_id_from_chars("C_dispatch_table_p", strlen("C_dispatch_table_p"));
/** make the type information needed */
current_ir_graph = get_const_code_irg();
/* The pointer to the dispatch table is constant. */
/* The constant is the address of the given entity */
- n = new_Const(mode_P, new_tarval_from_entity(dipte, mode_P));
+ symconst_symbol sym;
+ sym.entity_p = dipte;
+ n = new_SymConst(sym, symconst_addr_ent);
set_entity_variability(diptpe, variability_constant);
set_atomic_ent_value(diptpe, n);
type *arrt;
entity *arre, *arrelte;
- arrei = id_from_str("arr", strlen("arr"));
- arrti = id_from_str("arr_t", strlen("arr_t"));
+ arrei = new_id_from_chars("arr", strlen("arr"));
+ arrti = new_id_from_chars("arr_t", strlen("arr_t"));
/** The array type **/
/* Don't reuse int type so that graph layout is better readable */
add_compound_ent_value(arre, n, arrelte);
}
printf("Done building the graph. Dumping it.\n");
- dump_all_types();
+ dump_all_types(0);
printf("use xvcg to view this graph:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
init_firm (NULL);
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
+ prim_t_int = new_type_primitive(new_id_from_chars ("int", 3), mode_Is);
/* Try both optimizations: */
set_opt_constant_folding(1);
set_opt_cse(1);
set_opt_dead_node_elimination (1);
- owner = new_type_class (id_from_str ("CONST_EVAL_EXAMPLE", 18));
- method = new_type_method (id_from_str("main", 4), 0, 2);
+ owner = new_type_class (new_id_from_chars ("CONST_EVAL_EXAMPLE", 18));
+ method = new_type_method (new_id_from_chars("main", 4), 0, 2);
set_method_res_type(method, 0, prim_t_int);
set_method_res_type(method, 1, prim_t_int);
- ent = new_entity (owner, id_from_str ("main", 4), method);
+ ent = new_entity (owner, new_id_from_chars ("main", 4), method);
get_entity_ld_name(ent);
irg = new_ir_graph (ent, 4);
b = new_Const (mode_Is, new_tarval_from_long (5, mode_Is));
x = new_Jmp ();
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (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 (get_irg_end_block(irg), x);
- mature_block (get_irg_end_block(irg));
+ add_immBlock_pred (get_irg_end_block(irg), x);
+ mature_immBlock (get_irg_end_block(irg));
finalize_cons (irg);
irg_vrfy(irg);
printf("Done building the graph. Dumping it.\n");
- dump_ir_block_graph (irg);
+ dump_ir_block_graph (irg, 0);
printf("use xvcg to view this graph:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
init_firm (NULL);
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
+ prim_t_int = new_type_primitive(new_id_from_chars ("int", 3), mode_Is);
/* FIRM was designed for oo languages where all methods belong to a class.
* For imperative languages like C we view a file as a large class containing
#define NRES 1
printf("\nCreating an IR graph: %s...\n", CLASSNAME);
- owner = new_type_class (id_from_str (CLASSNAME, strlen(CLASSNAME)));
- proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
+ owner = new_type_class (new_id_from_chars (CLASSNAME, strlen(CLASSNAME)));
+ proc_main = new_type_method(new_id_from_chars(METHODNAME, strlen(METHODNAME)),
NRARGS, NRES);
set_method_res_type(proc_main, 0, prim_t_int);
ent = new_entity (owner,
- id_from_str (METHODNAME, strlen(METHODNAME)),
+ new_id_from_chars (METHODNAME, strlen(METHODNAME)),
proc_main);
get_entity_ld_name(ent); /* To enforce name mangling for vcg graph name */
#define NUM_OF_LOCAL_VARS 1
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(get_irg_current_block(irg));
+ mature_immBlock(get_irg_current_block(irg));
/* end block to add jmps */
endBlock = new_immBlock();
/* Block 1 */
Block1 = new_immBlock();
- add_in_edge(Block1, t);
- mature_block(Block1);
+ add_immBlock_pred(Block1, t);
+ mature_immBlock(Block1);
jmp = new_Jmp();
- add_in_edge(endBlock, jmp);
+ add_immBlock_pred(endBlock, jmp);
/* Block 2 */
Block2 = new_immBlock();
- add_in_edge(Block2, f);
- mature_block(Block2);
+ add_immBlock_pred(Block2, f);
+ mature_immBlock(Block2);
jmp = new_Jmp();
- add_in_edge(endBlock, jmp);
+ add_immBlock_pred(endBlock, jmp);
/* dead Block */
deadBlock = new_immBlock();
- mature_block(deadBlock);
+ mature_immBlock(deadBlock);
jmp = new_Jmp();
- add_in_edge(endBlock, jmp);
+ add_immBlock_pred(endBlock, jmp);
/* finish end block */
- switch_block(endBlock);
+ set_cur_block(endBlock);
{
ir_node *in[1];
in[0] = get_value(0, mode_Is);
get_store();
x = new_Return (get_store(), 1, in);
}
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (get_irg_current_block(irg));
- add_in_edge (get_irg_end_block(irg), x);
- mature_block (get_irg_end_block(irg));
+ add_immBlock_pred (get_irg_end_block(irg), x);
+ mature_immBlock (get_irg_end_block(irg));
finalize_cons (irg);
irg_vrfy(irg);
printf("Dumping the graph and a control flow graph.\n");
- dump_ir_block_graph (irg);
- dump_cfg (irg);
+ char *dump_file_suffix = "";
+ dump_ir_block_graph (irg, dump_file_suffix);
+ dump_cfg (irg, dump_file_suffix);
printf("Use xvcg to view these graphs:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
#define NRARGS 0
#define NRES 0
/* The type of the method */
- proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
+ proc_main = new_type_method(new_id_from_chars(METHODNAME, strlen(METHODNAME)),
NRARGS, NRES);
/* An entity representing the method. Owner of the entity is the global class
type mentioned above. */
ent = new_entity ((type *)owner,
- id_from_str (METHODNAME, strlen(METHODNAME)),
+ new_id_from_chars (METHODNAME, strlen(METHODNAME)),
(type *)proc_main);
/** Build code for the procedure. **/
x = new_Return (get_store(), 0, NULL);
/* Now we generated all instructions for this block and all its predecessor
* blocks so we can mature it. (There are not too much.) */
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (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 (get_irg_end_block(irg), x);
+ add_immBlock_pred (get_irg_end_block(irg), x);
/* Now we can mature the end block as all it's predecessors are known. */
- mature_block (get_irg_end_block(irg));
+ mature_immBlock (get_irg_end_block(irg));
/* Verify the graph. Finds some very bad errors in the graph. */
irg_vrfy(irg);
finalize_cons (irg);
printf("Done building the graph. Dumping it.\n");
- dump_ir_block_graph (irg);
+ dump_ir_block_graph (irg, 0);
printf("use xvcg to view this graph:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
set_opt_global_cse(0);
set_opt_dead_node_elimination (1);
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
+ prim_t_int = new_type_primitive(new_id_from_chars ("int", 3), mode_Is);
#define METHODNAME "main_tp"
#define NRARGS 1
#define NRES 1
- proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
+ proc_main = new_type_method(new_id_from_chars(METHODNAME, strlen(METHODNAME)),
NRARGS, NRES);
set_method_param_type(proc_main, 0, prim_t_int);
set_method_res_type(proc_main, 0, prim_t_int);
- owner = new_type_class (id_from_str ("ENDLESS_LOOP_EXAMPLE", 20));
- ent = new_entity (owner, id_from_str ("main", strlen("main")), proc_main);
+ owner = new_type_class (new_id_from_chars ("ENDLESS_LOOP_EXAMPLE", 20));
+ ent = new_entity (owner, new_id_from_chars ("main", strlen("main")), proc_main);
get_entity_ld_name(ent); /* force name mangling */
/* Generates start and end blocks and nodes and a first, initial block */
set_value (1, new_Const (mode_Is, new_tarval_from_long (1, mode_Is)));
x = new_Jmp();
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (get_irg_current_block(irg));
/* generate a block for the loop header and the conditional branch */
r = new_immBlock ();
- add_in_edge (r, x);
+ add_immBlock_pred (r, x);
x = new_Cond (new_Proj(new_Cmp(new_Const (mode_Is, new_tarval_from_long (0, mode_Is)),
new_Const (mode_Is, new_tarval_from_long (0, mode_Is))),
mode_b, Eq));
/* generate the block for the loop body */
b = new_immBlock ();
- add_in_edge (b, t);
+ add_immBlock_pred (b, t);
x = new_Jmp ();
- add_in_edge (r, x);
+ add_immBlock_pred (r, x);
/* The code in the loop body,
as we are dealing with local variables only the dataflow edges
new_simpleSel(
get_store(),
get_irg_globals(irg),
- new_entity(get_glob_type(),id_from_str("VAR_A",6),prim_t_int)),
+ new_entity(get_glob_type(),new_id_from_chars("VAR_A",6),prim_t_int)),
get_value(1, mode_Is)),
mode_M, 0));
- mature_block (b);
- mature_block (r);
+ mature_immBlock (b);
+ mature_immBlock (r);
/* generate the return block */
r = new_immBlock ();
- add_in_edge (r, f);
- mature_block (r);
+ add_immBlock_pred (r, f);
+ mature_immBlock (r);
{
ir_node *in[1];
}
/* finalize the end block generated in new_ir_graph() */
- add_in_edge (get_irg_end_block(irg), x);
- mature_block (get_irg_end_block(irg));
+ add_immBlock_pred (get_irg_end_block(irg), x);
+ mature_immBlock (get_irg_end_block(irg));
finalize_cons (irg);
printf("Done building the graph. Dumping it.\n");
/* turn_of_edge_labels(); */
dump_keepalive_edges(true);
- dump_all_types();
- dump_ir_block_graph (irg);
+ char *dump_file_suffix = "";
+ dump_all_types(dump_file_suffix);
+ dump_ir_block_graph (irg, dump_file_suffix);
printf("Use xvcg to view this graph:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
#define NRARGS 0
#define NRES 1
/* The type of the method */
- prim_t_dbl = new_type_primitive(id_from_str ("dbl", 3), mode_D);
- proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
+ prim_t_dbl = new_type_primitive(new_id_from_chars ("dbl", 3), mode_D);
+ proc_main = new_type_method(new_id_from_chars(METHODNAME, strlen(METHODNAME)),
NRARGS, NRES);
set_method_res_type(proc_main, 0, prim_t_dbl);
/* An entity representing the method. Owner of the entity is the global class
type mentioned above. */
ent = new_entity ((type *)owner,
- id_from_str (METHODNAME, strlen(METHODNAME)),
+ new_id_from_chars (METHODNAME, strlen(METHODNAME)),
(type *)proc_main);
/** Build code for the procedure. **/
}
/* Now we generated all instructions for this block and all its predecessor
* blocks so we can mature it. (There are not too much.) */
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (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 (get_irg_end_block(irg), x);
+ add_immBlock_pred (get_irg_end_block(irg), x);
/* Now we can mature the end block as all it's predecessors are known. */
- mature_block (get_irg_end_block(irg));
+ mature_immBlock (get_irg_end_block(irg));
/* Verify the graph. Finds some very bad errors in the graph. */
irg_vrfy(irg);
finalize_cons (irg);
printf("Done building the graph. Dumping it.\n");
- dump_ir_block_graph (irg);
+ dump_ir_block_graph (irg, 0);
printf("use xvcg to view this graph:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
owner = get_glob_type();
/* Type information for the procedure */
- proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
+ proc_main = new_type_method(new_id_from_chars(METHODNAME, strlen(METHODNAME)),
NRARGS, NRES);
/* The entity for the procedure */
ent = new_entity (owner,
- id_from_str (METHODNAME, strlen(METHODNAME)),
+ new_id_from_chars (METHODNAME, strlen(METHODNAME)),
proc_main);
/* The type int. This type is necessary to model the result and parameters
the procedure. */
#define PRIM_NAME "int"
- typ = new_type_primitive(id_from_str(PRIM_NAME, strlen(PRIM_NAME)), mode_Is);
+ typ = new_type_primitive(new_id_from_chars(PRIM_NAME, strlen(PRIM_NAME)), mode_Is);
/* The parameter and result types of the procedure. */
set_method_param_type(proc_main, 0, typ);
set_method_res_type(proc_main, 0, typ);
set_value (b_pos, new_Const (mode_Is, new_tarval_from_long (2, mode_Is)));
/* We know all predecessors of the block and all set_values and set_stores are
preformed. We can mature the block. */
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (get_irg_current_block(irg));
/* Generate a conditional branch */
cmp = new_Cmp(get_value(a_pos, mode_Is), get_value(b_pos, mode_Is)); /*
/* generate and fill the then block */
r = new_immBlock ();
- add_in_edge (r, t);
+ add_immBlock_pred (r, t);
a = new_Sub(get_value(a_pos, mode_Is),
new_Const (mode_Is, new_tarval_from_long (3, mode_Is)),
mode_Is);
set_value (a_pos, a);
- mature_block (r);
+ mature_immBlock (r);
t = new_Jmp ();
/* generate the else block */
r = new_immBlock ();
- add_in_edge (r, f);
+ add_immBlock_pred (r, f);
a = new_Sub(get_value(a_pos, mode_Is),
new_Const (mode_Is, new_tarval_from_long (3, mode_Is)),
mode_Is);
a = new_Add(a, new_Const (mode_Is, new_tarval_from_long (5, mode_Is)), mode_Is);
set_value (a_pos, a);
- mature_block (r);
+ mature_immBlock (r);
f = new_Jmp ();
/* generate the fall through block and add all cfg edges */
r = new_immBlock ();
- add_in_edge (r, f);
- add_in_edge (r, t);
- mature_block (r);
+ add_immBlock_pred (r, f);
+ add_immBlock_pred (r, t);
+ mature_immBlock (r);
/* The Return statement */
{
ir_node *in[1], *store ;
}
/* finalize the end block generated in new_ir_graph() */
- add_in_edge (get_irg_end_block(irg), x);
- mature_block (get_irg_end_block(irg));
+ add_immBlock_pred (get_irg_end_block(irg), x);
+ mature_immBlock (get_irg_end_block(irg));
/* verify the graph */
irg_vrfy(irg);
/* output the vcg file */
printf("Done building the graph. Dumping it.\n");
- dump_ir_block_graph (irg);
+ dump_ir_block_graph (irg, 0);
printf("use xvcg to view this graph:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
This is the modeling appropriate for other languages.
Mode_i says that all integers shall be implemented as a
32 bit integer value. */
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
+ prim_t_int = new_type_primitive(new_id_from_chars ("int", 3), mode_Is);
/* FIRM was designed for oo languages where all methods belong to a class.
* For imperative languages like C we view a file or compilation unit as
/* Main is an entity of this global class. */
owner = get_glob_type();
- proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
+ proc_main = new_type_method(new_id_from_chars(METHODNAME, strlen(METHODNAME)),
NRARGS, NRES);
main_ent = new_entity (owner,
- id_from_str (METHODNAME, strlen(METHODNAME)),
+ new_id_from_chars (METHODNAME, strlen(METHODNAME)),
proc_main);
/* Generates the basic graph for the method represented by entity main_ent, that
/* Generate the entities for the global variables. */
i_ent = new_entity (get_glob_type(),
- id_from_str ("i", strlen("i")),
+ new_id_from_chars ("i", strlen("i")),
prim_t_int);
irg = new_ir_graph (main_ent, NUM_OF_LOCAL_VARS);
/* Now generate all instructions for this block and all its predecessor blocks
* so we can mature it. */
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (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 (get_irg_end_block(irg), x);
+ add_immBlock_pred (get_irg_end_block(irg), x);
/* Now we can mature the end block as all it's predecessors are known. */
- mature_block (get_irg_end_block(irg));
+ mature_immBlock (get_irg_end_block(irg));
finalize_cons (irg);
irg_vrfy(irg);
printf("Done building the graph. Dumping it.\n");
- dump_ir_block_graph (irg);
- dump_ir_graph_w_types (irg);
+ char *dump_file_suffix = "";
+ dump_ir_block_graph (irg, dump_file_suffix);
+ dump_ir_graph_w_types (irg, dump_file_suffix);
printf("Use xvcg to view this graph:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
*/
printf("Done building the graph. Dumping it.\n");
- dump_all_types();
+ dump_all_types(0);
printf("use xvcg to view this graph:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
init_firm (NULL);
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
+ prim_t_int = new_type_primitive(new_id_from_chars ("int", 3), mode_Is);
/* FIRM was designed for oo languages where all methods belong to a class.
* For imperative languages like C we view a file as a large class containing
#define ENTITYNAME "IF_ELSE_EXAMPLE_main"
owner = get_glob_type();
- method = new_type_method (id_from_str(ENTITYNAME, strlen(ENTITYNAME)), 0, 2);
+ method = new_type_method (new_id_from_chars(ENTITYNAME, strlen(ENTITYNAME)), 0, 2);
set_method_res_type(method, 0, prim_t_int);
set_method_res_type(method, 1, prim_t_int);
- ent = new_entity (owner, id_from_str (ENTITYNAME,
+ ent = new_entity (owner, new_id_from_chars (ENTITYNAME,
strlen(ENTITYNAME)), method);
/* Generates the basic graph for the method represented by entity ent, that
f = new_Proj (x, mode_X, 0); /* if condition is false */
t = new_Proj (x, mode_X, 1); /* if condition is true */
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (get_irg_current_block(irg));
/* generate and fill the then block */
b = new_immBlock ();
- add_in_edge (b, t);
+ add_immBlock_pred (b, t);
set_value (0, get_value(1, mode_Is));
- mature_block (b);
+ mature_immBlock (b);
x_then = new_Jmp ();
/* generate and fill the else block */
b = new_immBlock ();
- add_in_edge (b, f);
+ add_immBlock_pred (b, f);
set_value (1, new_Const (mode_Is, new_tarval_from_long (2, mode_Is)));
- mature_block (b);
+ mature_immBlock (b);
x_else = new_Jmp ();
/* generate the join block and add all cfg edges */
b = new_immBlock ();
- add_in_edge (b, x_then);
- add_in_edge (b, x_else);
+ add_immBlock_pred (b, x_then);
+ add_immBlock_pred (b, x_else);
/* Generate the return node into current region. */
{
}
/* Now generate all instructions for this block and all its predecessor
blocks so we can mature it. */
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (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 (get_irg_end_block(irg), x);
+ add_immBlock_pred (get_irg_end_block(irg), x);
/* Now we can mature the end block as all it's predecessors are known. */
- mature_block (get_irg_end_block(irg));
+ mature_immBlock (get_irg_end_block(irg));
finalize_cons (irg);
finalize_cons (irg);
printf("Done building the graph. Dumping it.\n");
- dump_ir_block_graph (irg);
+ dump_ir_block_graph (irg, 0);
printf("use xvcg to view this graph:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
owner = get_glob_type();
/* Type information for the procedure */
- proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
+ proc_main = new_type_method(new_id_from_chars(METHODNAME, strlen(METHODNAME)),
NRARGS, NRES);
/* The entity for the procedure */
ent = new_entity (owner,
- id_from_str (METHODNAME, strlen(METHODNAME)),
+ new_id_from_chars (METHODNAME, strlen(METHODNAME)),
proc_main);
/* The type int. This type is necessary to model the result and parameters
the procedure. */
#define PRIM_NAME "int"
- typ = new_type_primitive(id_from_str(PRIM_NAME, strlen(PRIM_NAME)), mode_Is);
+ typ = new_type_primitive(new_id_from_chars(PRIM_NAME, strlen(PRIM_NAME)), mode_Is);
/* The parameter and result types of the procedure. */
set_method_param_type(proc_main, 0, typ);
set_method_res_type(proc_main, 0, typ);
set_value (b_pos, new_Const (mode_Is, new_tarval_from_long (2, mode_Is)));
/* We know all predecessors of the block and all set_values and set_stores are
preformed. We can mature the block. */
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (get_irg_current_block(irg));
/* Generate a conditional branch */
cmp = new_Cmp(get_value(a_pos, mode_Is), get_value(b_pos, mode_Is));
/* generate and fill the then block */
r = new_immBlock ();
- add_in_edge (r, t);
+ add_immBlock_pred (r, t);
{
ir_node *b,*c;
c = new_Const (mode_Is, new_tarval_from_long (3, mode_Is));
}
set_value (a_pos, a);
- mature_block (r);
+ mature_immBlock (r);
x = new_Jmp ();
/* generate the fall through block and add all cfg edges */
r = new_immBlock ();
- add_in_edge (r, f);
- add_in_edge (r, x);
- mature_block (r);
+ add_immBlock_pred (r, f);
+ add_immBlock_pred (r, x);
+ mature_immBlock (r);
/* The Return statement */
{
ir_node *in[1], *store ;
}
/* finalize the end block generated in new_ir_graph() */
- add_in_edge (get_irg_end_block(irg), x);
- mature_block (get_irg_end_block(irg));
+ add_immBlock_pred (get_irg_end_block(irg), x);
+ mature_immBlock (get_irg_end_block(irg));
/* verify the graph */
irg_vrfy(irg);
/* output the vcg file */
printf("Done building the graph. Dumping it.\n");
- dump_ir_block_graph (irg);
+ dump_ir_block_graph (irg, 0);
printf("use xvcg to view this graph:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
set_opt_dead_node_elimination (1);
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Iu);
+ prim_t_int = new_type_primitive(new_id_from_chars ("int", 3), mode_Iu);
#define METHODNAME "main"
#define NRARGS 0
#define NRES 1
- proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
+ proc_main = new_type_method(new_id_from_chars(METHODNAME, strlen(METHODNAME)),
NRARGS, NRES);
set_method_res_type(proc_main, 0, prim_t_int);
- owner = new_type_class (id_from_str ("IF_WHILE_EXAMPLE", 16));
- ent = new_entity (owner, id_from_str ("main", 4), proc_main);
+ owner = new_type_class (new_id_from_chars ("IF_WHILE_EXAMPLE", 16));
+ ent = new_entity (owner, new_id_from_chars ("main", 4), proc_main);
get_entity_ld_name(ent);
/* Generates start and end blocks and nodes and a first, initial block */
/* Generate two constants */
set_value (0, new_Const (mode_Iu, new_tarval_from_long (0, mode_Iu)));
set_value (1, new_Const (mode_Iu, new_tarval_from_long (1, mode_Iu)));
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (get_irg_current_block(irg));
/* Generate a conditional branch */
x = new_Jmp();
/* generate the fall through block and add all cfg edges */
r = new_immBlock ();
- add_in_edge (r, x);
- mature_block (r);
+ add_immBlock_pred (r, x);
+ mature_immBlock (r);
x = new_Jmp ();
/* generate a block for the loop header and the conditional branch */
r = new_immBlock ();
- add_in_edge (r, x);
+ add_immBlock_pred (r, x);
x = new_Cond (new_Proj(new_Cmp(new_Const (mode_Iu, new_tarval_from_long (0, mode_Is)),
new_Const (mode_Iu, new_tarval_from_long (0, mode_Is))),
mode_b, Eq));
/* generate the block for the loop body */
b = new_immBlock ();
- add_in_edge (b,t);
+ add_immBlock_pred (b,t);
x = new_Jmp ();
- add_in_edge (r, x);
- mature_block (r);
+ add_immBlock_pred (r, x);
+ mature_immBlock (r);
/* the code in the loop body,
as we are dealing with local variables only the dataflow edges
set_value (2, get_value (0, mode_Iu));
set_value (0, get_value (1, mode_Iu));
set_value (1, get_value (2, mode_Iu));
- mature_block (b);
+ mature_immBlock (b);
/* generate the return block */
r = new_immBlock ();
- add_in_edge (r, f);
- mature_block (r);
+ add_immBlock_pred (r, f);
+ mature_immBlock (r);
{
ir_node *in[1];
}
/* finalize the end block generated in new_ir_graph() */
- add_in_edge (get_irg_end_block(irg), x);
- mature_block (get_irg_end_block(irg));
+ add_immBlock_pred (get_irg_end_block(irg), x);
+ mature_immBlock (get_irg_end_block(irg));
finalize_cons (irg);
/* output the vcg file */
printf("Done building the graph. Dumping it with out-edges.\n");
dump_out_edges();
- dump_ir_graph (irg);
+ dump_ir_graph (irg, 0);
printf("Use xvcg to view this graph:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
init_firm (NULL);
/** make idents for all used identifiers in the program. */
- ii = id_from_str("i", strlen("i"));
- ci = id_from_str("c", strlen("c"));
- di = id_from_str("d", strlen("d"));
- ei = id_from_str("e", strlen("e"));
- m1i = id_from_str("m1", strlen("m1"));
- m2i = id_from_str("m2", strlen("m2"));
- inti= id_from_str("int",strlen("int"));
- ai = id_from_str("a", strlen("a"));
- bi = id_from_str("b", strlen("b"));
+ ii = new_id_from_chars("i", strlen("i"));
+ ci = new_id_from_chars("c", strlen("c"));
+ di = new_id_from_chars("d", strlen("d"));
+ ei = new_id_from_chars("e", strlen("e"));
+ m1i = new_id_from_chars("m1", strlen("m1"));
+ m2i = new_id_from_chars("m2", strlen("m2"));
+ inti= new_id_from_chars("int",strlen("int"));
+ ai = new_id_from_chars("a", strlen("a"));
+ bi = new_id_from_chars("b", strlen("b"));
/** make the type information needed */
/* Language defined types */
printf("Done building the graph. Dumping it.\n");
- dump_all_types();
+ dump_all_types(0);
printf("use xvcg to view this graph:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
#define NRARGS 0
#define NRES 0
- owner = new_type_class (id_from_str (CLASSNAME, strlen(CLASSNAME)));
- proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
+ owner = new_type_class (new_id_from_chars (CLASSNAME, strlen(CLASSNAME)));
+ proc_main = new_type_method(new_id_from_chars(METHODNAME, strlen(METHODNAME)),
NRARGS, NRES);
ent = new_entity ((type *)owner,
- id_from_str (METHODNAME, strlen(METHODNAME)),
+ new_id_from_chars (METHODNAME, strlen(METHODNAME)),
(type *)proc_main);
get_entity_ld_name(ent);
#define NUM_OF_LOCAL_VARS 0
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(get_irg_current_block(irg));
+ mature_immBlock(get_irg_current_block(irg));
new_immBlock();
- add_in_edge(get_irg_current_block(irg), t);
+ add_immBlock_pred(get_irg_current_block(irg), t);
jmp = new_Jmp();
- mature_block(get_irg_current_block(irg));
+ mature_immBlock(get_irg_current_block(irg));
new_immBlock();
- add_in_edge(get_irg_current_block(irg), f);
+ add_immBlock_pred(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(get_irg_current_block(irg));
+ mature_immBlock(get_irg_current_block(irg));
new_immBlock();
- add_in_edge(get_irg_current_block(irg), t);
- add_in_edge(get_irg_current_block(irg), jmp);
+ add_immBlock_pred(get_irg_current_block(irg), t);
+ add_immBlock_pred(get_irg_current_block(irg), jmp);
jmp = new_Jmp();
- mature_block(get_irg_current_block(irg));
+ mature_immBlock(get_irg_current_block(irg));
new_immBlock();
- add_in_edge(get_irg_current_block(irg), f);
+ add_immBlock_pred(get_irg_current_block(irg), f);
t = new_Jmp();
- mature_block(get_irg_current_block(irg));
+ mature_immBlock(get_irg_current_block(irg));
new_immBlock();
- add_in_edge(get_irg_current_block(irg), t);
- add_in_edge(get_irg_current_block(irg), jmp);
+ add_immBlock_pred(get_irg_current_block(irg), t);
+ add_immBlock_pred(get_irg_current_block(irg), jmp);
x = new_Return (get_store(), 0, NULL);
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (get_irg_current_block(irg));
- add_in_edge (get_irg_end_block(irg), x);
- mature_block (get_irg_end_block(irg));
+ add_immBlock_pred (get_irg_end_block(irg), x);
+ mature_immBlock (get_irg_end_block(irg));
finalize_cons (irg);
irg_vrfy(irg);
printf("Dumping the graph and a control flow graph.\n");
- dump_ir_block_graph (irg);
- dump_cfg (irg);
+ char *dump_file_suffix = "";
+ dump_ir_block_graph (irg, dump_file_suffix);
+ dump_cfg (irg, dump_file_suffix);
printf("Use xvcg to view these graphs:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
#define NRES 0
printf("\nCreating an IR graph: %s...\n", CLASSNAME);
- owner = new_type_class (id_from_str (CLASSNAME, strlen(CLASSNAME)));
- proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
+ owner = new_type_class (new_id_from_chars (CLASSNAME, strlen(CLASSNAME)));
+ proc_main = new_type_method(new_id_from_chars(METHODNAME, strlen(METHODNAME)),
NRARGS, NRES);
ent = new_entity (owner,
- id_from_str (METHODNAME, strlen(METHODNAME)),
+ new_id_from_chars (METHODNAME, strlen(METHODNAME)),
proc_main);
get_entity_ld_name(ent); /* To enforce name mangling for vcg graph name */
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(get_irg_current_block(irg));
+ mature_immBlock(get_irg_current_block(irg));
loopBlock1 = new_immBlock();
- add_in_edge(loopBlock1, t);
+ add_immBlock_pred(loopBlock1, t);
cond = new_Cond(new_Proj(new_Cmp(expr, c2), mode_b, Eq));
f_l1 = new_Proj(cond, mode_X, 0);
t_l1 = new_Proj(cond, mode_X, 1);
loopBlock2 = new_immBlock();
- add_in_edge(loopBlock2, f);
+ add_immBlock_pred(loopBlock2, f);
cond = new_Cond(new_Proj(new_Cmp(expr, c3), mode_b, Eq));
f_l2 = new_Proj(cond, mode_X, 0);
t_l2 = new_Proj(cond, mode_X, 1);
- add_in_edge(loopBlock1, t_l2);
- add_in_edge(loopBlock2, t_l1);
- mature_block(loopBlock1);
- mature_block(loopBlock2);
+ add_immBlock_pred(loopBlock1, t_l2);
+ add_immBlock_pred(loopBlock2, t_l1);
+ mature_immBlock(loopBlock1);
+ mature_immBlock(loopBlock2);
new_immBlock();
- add_in_edge(get_irg_current_block(irg), f_l2);
- add_in_edge(get_irg_current_block(irg), f_l1);
+ add_immBlock_pred(get_irg_current_block(irg), f_l2);
+ add_immBlock_pred(get_irg_current_block(irg), f_l1);
x = new_Return (get_store(), 0, NULL);
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (get_irg_current_block(irg));
- add_in_edge (get_irg_end_block(irg), x);
- mature_block (get_irg_end_block(irg));
+ add_immBlock_pred (get_irg_end_block(irg), x);
+ mature_immBlock (get_irg_end_block(irg));
finalize_cons (irg);
irg_vrfy(irg);
printf("Dumping the graph and a control flow graph.\n");
- dump_ir_block_graph (irg);
- dump_cfg (irg);
+ char *dump_file_suffix = "";
+ dump_ir_block_graph (irg, dump_file_suffix);
+ dump_cfg (irg, dump_file_suffix);
printf("Use xvcg to view these graphs:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
set_opt_dead_node_elimination (1);
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Iu);
+ prim_t_int = new_type_primitive(new_id_from_chars ("int", 3), mode_Iu);
/* a class to get started with, containing the main procedure */
- owner = new_type_class (id_from_str ("MEMORY_EXAMPLE", 14));
- method = new_type_method (id_from_str("main", 4), 0, 1);
+ owner = new_type_class (new_id_from_chars ("MEMORY_EXAMPLE", 14));
+ method = new_type_method (new_id_from_chars("main", 4), 0, 1);
set_method_res_type(method, 0, prim_t_int);
- ent = new_entity (owner, id_from_str ("main", 4), method);
+ ent = new_entity (owner, new_id_from_chars ("main", 4), method);
get_entity_ld_name(ent); /* To enforce name mangling for vcg graph name */
/* Generates start and end blocks and nodes and a first, initial block */
a = new_simpleSel(
get_store(),
get_irg_globals(irg),
- new_entity(get_glob_type(),id_from_str("VAR_A",6),prim_t_int));
+ new_entity(get_glob_type(),new_id_from_chars("VAR_A",6),prim_t_int));
b = new_simpleSel(
get_store(),
get_irg_globals(irg),
- new_entity(get_glob_type(),id_from_str("VAR_B",6),prim_t_int));
+ new_entity(get_glob_type(),new_id_from_chars("VAR_B",6),prim_t_int));
/* set VAR_A and VAR_B to constant values */
set_store (new_Proj (new_Store (get_store (), a,
new_Const (mode_Iu, new_tarval_from_long (0, mode_Is))),
/* finish this first block */
x = new_Jmp ();
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (get_irg_current_block(irg));
/* a loop body */
r = new_immBlock ();
- add_in_edge (r, x);
+ add_immBlock_pred (r, x);
/* exchange the content of the two variables. Exceptions not cached. */
/* load the value and make it's effects visible. */
mode_b, Gt));
/* build the cfg of the loop */
- add_in_edge (r, new_Proj (x, mode_X, 0));
+ add_immBlock_pred (r, new_Proj (x, mode_X, 0));
x = new_Proj (x, mode_X, 1);
- mature_block(r);
+ mature_immBlock(r);
/* generate the block the loop exits to */
r = new_immBlock ();
- add_in_edge (r, x);
+ add_immBlock_pred (r, x);
/* generate the return block and return the content of VAR_A */
{
x = new_Return (new_Proj(x, mode_M, 0), 1, in);
}
- mature_block (r);
- add_in_edge (get_irg_end_block(irg), x);
- mature_block (get_irg_end_block(irg));
+ mature_immBlock (r);
+ add_immBlock_pred (get_irg_end_block(irg), x);
+ mature_immBlock (get_irg_end_block(irg));
finalize_cons (irg);
irg_vrfy(irg);
printf("Done building the graph. Dumping it.\n");
- dump_ir_block_graph (irg);
+ dump_ir_block_graph (irg, 0);
printf("Use xvcg to view this graph:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
set_opt_dead_node_elimination(1);
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
+ prim_t_int = new_type_primitive(new_id_from_chars ("int", 3), mode_Is);
/*** Make type information for the class (PRIMA). ***/
/* The type of the class */
class_prima = new_type_class(new_id_from_str ("PRIMA_INLINE"));
/* We need type information for pointers to the class: */
- class_p_ptr = new_type_pointer (id_from_str ("class_prima_ptr", 15),
+ class_p_ptr = new_type_pointer (new_id_from_chars ("class_prima_ptr", 15),
class_prima);
/* An entity for the field (a). The entity constructor automatically adds
the entity as member of the owner. */
- a_e = new_entity(class_prima, id_from_str ("a", 1), prim_t_int);
+ a_e = new_entity(class_prima, new_id_from_chars ("a", 1), prim_t_int);
/* An entity for the method set_a. But first we need type information
for the method. */
- proc_set_a = new_type_method(id_from_str("set_a", 5), 2, 0);
+ proc_set_a = new_type_method(new_id_from_chars("set_a", 5), 2, 0);
set_method_param_type(proc_set_a, 0, class_p_ptr);
set_method_param_type(proc_set_a, 1, prim_t_int);
- proc_set_a_e = new_entity(class_prima, id_from_str ("set_a", 5), proc_set_a);
+ proc_set_a_e = new_entity(class_prima, new_id_from_chars ("set_a", 5), proc_set_a);
/* An entity for the method c. Implicit argument "self" must be modeled
explicit! */
- proc_c = new_type_method(id_from_str("c", 1 ), 2, 1);
+ proc_c = new_type_method(new_id_from_chars("c", 1 ), 2, 1);
set_method_param_type(proc_c, 0, class_p_ptr);
set_method_param_type(proc_c, 1, prim_t_int);
set_method_res_type(proc_c, 0, prim_t_int);
- proc_c_e = new_entity(class_prima, id_from_str ("c", 1), proc_c);
+ proc_c_e = new_entity(class_prima, new_id_from_chars ("c", 1), proc_c);
/*** Now build procedure main. ***/
/** Type information for main. **/
owner is the global type. */
owner = get_glob_type();
/* Main has zero parameters and one result. */
- proc_main = new_type_method(id_from_str("OO_INLINE_EXAMPLE_main", 22), 0, 1);
+ proc_main = new_type_method(new_id_from_chars("OO_INLINE_EXAMPLE_main", 22), 0, 1);
/* The result type is int. */
set_method_res_type(proc_main, 0, prim_t_int);
/* The entity for main. */
- proc_main_e = new_entity (owner, id_from_str ("OO_INLINE_EXAMPLE_main", 22), proc_main);
+ proc_main_e = new_entity (owner, new_id_from_chars ("OO_INLINE_EXAMPLE_main", 22), proc_main);
/** Build code for procedure main. **/
/* We need one local variable (for "o"). */
in[0] = res;
x = new_Return (get_store(), 1, in);
}
- mature_block (get_irg_current_block(main_irg));
+ mature_immBlock (get_irg_current_block(main_irg));
/* complete the end_block */
- add_in_edge (get_irg_end_block(main_irg), x);
- mature_block (get_irg_end_block(main_irg));
+ add_immBlock_pred (get_irg_end_block(main_irg), x);
+ mature_immBlock (get_irg_end_block(main_irg));
irg_vrfy(main_irg);
finalize_cons (main_irg);
/* return nothing */
x = new_Return (get_store (), 0, NULL);
- mature_block (get_irg_current_block(set_a_irg));
+ mature_immBlock (get_irg_current_block(set_a_irg));
/* complete the end_block */
- add_in_edge (get_irg_end_block(set_a_irg), x);
- mature_block (get_irg_end_block(set_a_irg));
+ add_immBlock_pred (get_irg_end_block(set_a_irg), x);
+ mature_immBlock (get_irg_end_block(set_a_irg));
/* verify the graph */
irg_vrfy(set_a_irg);
set_value(2, new_Const (mode_Is, new_tarval_from_long (0, mode_Is)));
x = new_Jmp();
- mature_block (get_irg_current_block(c_irg));
+ mature_immBlock (get_irg_current_block(c_irg));
/* generate a block for the loop header and the conditional branch */
r = new_immBlock ();
- add_in_edge (r, x);
+ add_immBlock_pred (r, x);
x = new_Cond (new_Proj(new_Cmp(new_Const (mode_Is, new_tarval_from_long (0, mode_Is)),
new_Const (mode_Is, new_tarval_from_long (0, mode_Is))),
mode_b, Eq));
/* generate the block for the loop body */
b = new_immBlock ();
- add_in_edge (b, t);
+ add_immBlock_pred (b, t);
/* The code in the loop body,
as we are dealing with local variables only the dataflow edges
a_ptr = new_simpleSel(get_store(), self, a_e);
set_store(new_Store(get_store(), a_ptr, get_value(2, mode_Is)));
x = new_Jmp ();
- add_in_edge(r, x);
- mature_block (b);
- mature_block (r);
+ add_immBlock_pred(r, x);
+ mature_immBlock (b);
+ mature_immBlock (r);
/* generate the return block */
r = new_immBlock ();
- add_in_edge (r, f);
+ add_immBlock_pred (r, f);
/* Select the entity and load the value */
a_ptr = new_simpleSel(get_store(), self, a_e);
a_val = new_Load(get_store(), a_ptr);
x = new_Return (get_store (), 1, in);
}
- mature_block (r);
+ mature_immBlock (r);
/* complete the end_block */
- add_in_edge (get_irg_end_block(c_irg), x);
- mature_block (get_irg_end_block(c_irg));
+ add_immBlock_pred (get_irg_end_block(c_irg), x);
+ mature_immBlock (get_irg_end_block(c_irg));
/* verify the graph */
irg_vrfy(c_irg);
get_entity_ld_ident(proc_set_a_e);
get_entity_ld_ident(proc_c_e);
turn_off_edge_labels();
- dump_all_ir_graphs(dump_ir_block_graph);
- dump_all_ir_graphs(dump_ir_block_graph_w_types);
- dump_all_types();
+ char *suffix = "";
+ dump_all_ir_graphs(dump_ir_block_graph, suffix);
+ dump_all_ir_graphs(dump_ir_block_graph_w_types, suffix);
+ dump_all_types(0);
printf("Use xvcg to view these graphs:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
set_opt_dead_node_elimination(1);
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
+ prim_t_int = new_type_primitive(new_id_from_chars ("int", 3), mode_Is);
/*** Make type information for the class (PRIMA). ***/
/* The type of the class */
- class_prima = new_type_class(id_from_str ("PRIMA", 5));
+ class_prima = new_type_class(new_id_from_chars ("PRIMA", 5));
/* We need type information for pointers to the class: */
- class_p_ptr = new_type_pointer (id_from_str ("class_prima_ptr", 15),
+ class_p_ptr = new_type_pointer (new_id_from_chars("class_prima_ptr", 15),
class_prima);
/* An entity for the field (a). The entity constructor automatically adds
the entity as member of the owner. */
- a_e = new_entity(class_prima, id_from_str ("a", 1), prim_t_int);
+ a_e = new_entity(class_prima, new_id_from_chars ("a", 1), prim_t_int);
/* An entity for the method set_a. But first we need type information
for the method. */
- proc_set_a = new_type_method(id_from_str("set_a", 5), 2, 0);
+ proc_set_a = new_type_method(new_id_from_chars("set_a", 5), 2, 0);
set_method_param_type(proc_set_a, 0, class_p_ptr);
set_method_param_type(proc_set_a, 1, prim_t_int);
- proc_set_a_e = new_entity(class_prima, id_from_str ("set_a", 5), proc_set_a);
+ proc_set_a_e = new_entity(class_prima, new_id_from_chars ("set_a", 5), proc_set_a);
/* An entity for the method c. Implicit argument "self" must be modeled
explicit! */
- proc_c = new_type_method(id_from_str("c", 1 ), 2, 1);
+ proc_c = new_type_method(new_id_from_chars("c", 1 ), 2, 1);
set_method_param_type(proc_c, 0, class_p_ptr);
set_method_param_type(proc_c, 1, prim_t_int);
set_method_res_type(proc_c, 0, prim_t_int);
- proc_c_e = new_entity(class_prima, id_from_str ("c", 1), proc_c);
+ proc_c_e = new_entity(class_prima, new_id_from_chars ("c", 1), proc_c);
/*** Now build procedure main. ***/
/** Type information for main. **/
owner is the global type. */
owner = get_glob_type();
/* Main has zero parameters and one result. */
- proc_main = new_type_method(id_from_str("OO_PROGRAM_EXAMPLE_main", 23), 0, 1);
+ proc_main = new_type_method(new_id_from_chars("OO_PROGRAM_EXAMPLE_main", 23), 0, 1);
/* The result type is int. */
set_method_res_type(proc_main, 0, prim_t_int);
/* The entity for main. */
- proc_main_e = new_entity (owner, id_from_str ("OO_PROGRAM_EXAMPLE_main", 23), proc_main);
+ proc_main_e = new_entity (owner, new_id_from_chars ("OO_PROGRAM_EXAMPLE_main", 23), proc_main);
/** Build code for procedure main. **/
/* We need one local variable (for "o"). */
in[0] = res;
x = new_Return (get_store(), 1, in);
}
- mature_block (get_irg_current_block(main_irg));
+ mature_immBlock (get_irg_current_block(main_irg));
/* complete the end_block */
- add_in_edge (get_irg_end_block(main_irg), x);
- mature_block (get_irg_end_block(main_irg));
+ add_immBlock_pred (get_irg_end_block(main_irg), x);
+ mature_immBlock (get_irg_end_block(main_irg));
irg_vrfy(main_irg);
finalize_cons (main_irg);
/* return nothing */
x = new_Return (get_store (), 0, NULL);
- mature_block (get_irg_current_block(set_a_irg));
+ mature_immBlock (get_irg_current_block(set_a_irg));
/* complete the end_block */
- add_in_edge (get_irg_end_block(set_a_irg), x);
- mature_block (get_irg_end_block(set_a_irg));
+ add_immBlock_pred (get_irg_end_block(set_a_irg), x);
+ mature_immBlock (get_irg_end_block(set_a_irg));
/* verify the graph */
irg_vrfy(set_a_irg);
x = new_Return (get_store (), 1, in);
}
- mature_block (get_irg_current_block(c_irg));
+ mature_immBlock (get_irg_current_block(c_irg));
/* complete the end_block */
- add_in_edge (get_irg_end_block(c_irg), x);
- mature_block (get_irg_end_block(c_irg));
+ add_immBlock_pred (get_irg_end_block(c_irg), x);
+ mature_immBlock (get_irg_end_block(c_irg));
/* verify the graph */
irg_vrfy(c_irg);
dump_consts_local(1);
turn_off_edge_labels();
- dump_all_ir_graphs(dump_ir_graph);
- dump_all_ir_graphs(dump_ir_block_graph);
- dump_all_ir_graphs(dump_ir_graph_w_types);
- dump_all_ir_graphs(dump_ir_block_graph_w_types);
- dump_all_ir_graphs(dump_type_graph);
- dump_all_types();
- dump_class_hierarchy (true);
+ dump_all_ir_graphs(dump_ir_graph, "");
+ dump_all_ir_graphs(dump_ir_block_graph, "");
+ dump_all_ir_graphs(dump_ir_graph_w_types, "");
+ dump_all_ir_graphs(dump_ir_block_graph_w_types, "");
+ dump_all_ir_graphs(dump_type_graph, "");
+ dump_all_types("");
+ dump_class_hierarchy (true, "");
entity **free_methods;
int arr_len;
cg_construct(arr_len, free_methods);
interprocedural_view = 1;
- dump_ir_graph(main_irg);
- dump_ir_block_graph(main_irg);
- dump_ir_graph_w_types(main_irg);
- dump_ir_block_graph_w_types(main_irg);
- dump_all_cg_block_graph();
+ dump_ir_graph(main_irg, "");
+ dump_ir_block_graph(main_irg, "");
+ dump_ir_graph_w_types(main_irg, "");
+ dump_ir_block_graph_w_types(main_irg, "");
+ dump_all_cg_block_graph("");
printf("Use xvcg to view these graphs:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
ir_node *make_Call(ir_graph *c, int n_args, ir_node **args) {
- entity *ent = get_irg_ent(c);
+ entity *ent = get_irg_entity(c);
type *mtp = get_entity_type(ent);
symconst_symbol sym;
sym.entity_p = ent;
void close_method(int n_ins, ir_node **ins) {
ir_node *x = new_Return (get_store(), n_ins, ins);
- mature_block (get_cur_block());
- add_in_edge (get_cur_end_block(), x);
- mature_block (get_cur_end_block());
+ mature_immBlock (get_cur_block());
+ add_immBlock_pred (get_cur_end_block(), x);
+ mature_immBlock (get_cur_end_block());
finalize_cons(current_ir_graph);
}
set_optimize(1);
/*** Make basic type information for primitive type int. ***/
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
+ prim_t_int = new_type_primitive(new_id_from_chars ("int", 3), mode_Is);
/* FIRM was designed for oo languages where all methods belong to a class.
* For imperative languages like C we view a file as a large class containing
printf("\nCreating an IR graph: THREE_CFPRED_EXAMPLE ...\n");
owner = get_glob_type();
- proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
+ proc_main = new_type_method(new_id_from_chars(METHODNAME, strlen(METHODNAME)),
NRARGS, NRES);
set_method_param_type(proc_main, 0, prim_t_int);
set_method_res_type(proc_main, 0, prim_t_int);
ent = new_entity (owner,
- id_from_str (METHODNAME, strlen(METHODNAME)),
+ new_id_from_chars (METHODNAME, strlen(METHODNAME)),
proc_main);
#define NUM_OF_LOCAL_VARS 2
set_value(0, new_Const (mode_Is, new_tarval_from_long (6, mode_Is)));
f = new_Proj(cond, mode_X, 0);
t = new_Proj(cond, mode_X, 1);
- mature_block(get_irg_current_block(irg));
+ mature_immBlock(get_irg_current_block(irg));
/* end block to add jmps */
endBlock = new_immBlock();
/* Block 1 */
Block1 = new_immBlock();
- add_in_edge(Block1, t);
- mature_block(Block1);
+ add_immBlock_pred(Block1, t);
+ mature_immBlock(Block1);
set_value(0, new_Const (mode_Is, new_tarval_from_long (5, mode_Is)));
jmp = new_Jmp();
- add_in_edge(endBlock, jmp);
+ add_immBlock_pred(endBlock, jmp);
/* scndCondBlock */
scndCondBlock = new_immBlock();
- add_in_edge(scndCondBlock, f);
- mature_block(scndCondBlock);
+ add_immBlock_pred(scndCondBlock, f);
+ mature_immBlock(scndCondBlock);
c1 = new_Const (mode_Is, new_tarval_from_long (3, mode_Is));
cond = new_Cond(new_Proj(new_Cmp(c1, get_value(1, mode_Is)), mode_b, Eq));
f = new_Proj(cond, mode_X, 0);
t = new_Proj(cond, mode_X, 1);
- mature_block(get_irg_current_block(irg));
+ mature_immBlock(get_irg_current_block(irg));
/* Block 2 */
Block2 = new_immBlock();
- add_in_edge(Block2, f);
- mature_block(Block2);
+ add_immBlock_pred(Block2, f);
+ mature_immBlock(Block2);
jmp = new_Jmp();
- add_in_edge(endBlock, jmp);
+ add_immBlock_pred(endBlock, jmp);
/* Block 3 */
Block3 = new_immBlock();
- add_in_edge(Block3, t);
- mature_block(Block3);
+ add_immBlock_pred(Block3, t);
+ mature_immBlock(Block3);
jmp = new_Jmp();
- add_in_edge(endBlock, jmp);
+ add_immBlock_pred(endBlock, jmp);
/* finish the end Block */
- switch_block(endBlock);
+ set_cur_block(endBlock);
{
ir_node *in[1];
in[0] = get_value(0, mode_Is);
x = new_Return (get_store(), 1, in);
}
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (get_irg_current_block(irg));
/* finish the Block with the end node */
- add_in_edge (get_irg_end_block(irg), x);
- mature_block (get_irg_end_block(irg));
+ add_immBlock_pred (get_irg_end_block(irg), x);
+ mature_immBlock (get_irg_end_block(irg));
/* verify the graph */
irg_vrfy(irg);
dead_node_elimination(irg);
printf("Dumping the graph and a control flow graph.\n");
- dump_ir_block_graph (irg);
- dump_cfg (irg);
+ char *suffix = "";
+ dump_ir_block_graph (irg, suffix);
+ dump_cfg (irg, suffix);
printf("Use xvcg to view these graphs:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");
set_opt_cse(1);
set_opt_dead_node_elimination (1);
- prim_t_int = new_type_primitive(id_from_str ("int", 3), mode_Is);
+ prim_t_int = new_type_primitive(new_id_from_chars ("int", 3), mode_Is);
#define METHODNAME "main_tp"
#define NRARGS 1
#define NRES 1
- proc_main = new_type_method(id_from_str(METHODNAME, strlen(METHODNAME)),
+ proc_main = new_type_method(new_id_from_chars(METHODNAME, strlen(METHODNAME)),
NRARGS, NRES);
set_method_param_type(proc_main, 0, prim_t_int);
set_method_res_type(proc_main, 0, prim_t_int);
- owner = new_type_class (id_from_str ("WHILE_EXAMPLE", 13));
- ent = new_entity (owner, id_from_str ("main", strlen("main")), proc_main);
+ owner = new_type_class (new_id_from_chars ("WHILE_EXAMPLE", 13));
+ ent = new_entity (owner, new_id_from_chars ("main", strlen("main")), proc_main);
get_entity_ld_name(ent); /* force name mangling */
/* Generates start and end blocks and nodes and a first, initial block */
set_value (0, new_Proj(get_irg_args(irg), mode_Is, 0));
set_value (1, new_Const (mode_Is, new_tarval_from_long (1, mode_Is)));
x = new_Jmp();
- mature_block (get_irg_current_block(irg));
+ mature_immBlock (get_irg_current_block(irg));
/* generate a block for the loop header and the conditional branch */
r = new_immBlock ();
- add_in_edge (r, x);
+ add_immBlock_pred (r, x);
x = new_Cond (new_Proj(new_Cmp(new_Const (mode_Is, new_tarval_from_long (0, mode_Is)),
get_value(1, mode_Is)),
mode_b, Eq));
/* generate the block for the loop body */
b = new_immBlock ();
- add_in_edge (b, t);
+ add_immBlock_pred (b, t);
x = new_Jmp ();
- add_in_edge (r, x);
+ add_immBlock_pred (r, x);
/* The code in the loop body,
as we are dealing with local variables only the dataflow edges
set_value (2, get_value (0, mode_Is));
set_value (0, get_value (1, mode_Is));
set_value (1, get_value (2, mode_Is));
- mature_block (b);
- mature_block (r);
+ mature_immBlock (b);
+ mature_immBlock (r);
/* generate the return block */
r = new_immBlock ();
- add_in_edge (r, f);
- mature_block (r);
+ add_immBlock_pred (r, f);
+ mature_immBlock (r);
{
ir_node *in[1];
}
/* finalize the end block generated in new_ir_graph() */
- add_in_edge (get_irg_end_block(irg), x);
- mature_block (get_irg_end_block(irg));
+ add_immBlock_pred (get_irg_end_block(irg), x);
+ mature_immBlock (get_irg_end_block(irg));
finalize_cons (irg);
/* output the vcg file */
printf("Done building the graph. Dumping it.\n");
turn_off_edge_labels();
- dump_all_types();
- dump_ir_block_graph (irg);
+ char *suffix = "";
+ dump_all_types(suffix);
+ dump_ir_block_graph (irg, suffix);
printf("Use xvcg to view this graph:\n");
printf("/ben/goetz/bin/xvcg GRAPHNAME\n\n");