#define SPDICT_COOKIE1 0xB0031E7
#define SPDICT_COOKIE2 0xBA17B003
-/* Line N_o_mbers ToDo: Warum o? */
+/* Line N_o_mbers ToDo: Warum o? Answer: No. 5, not Nu. 5*/
#define LINO_COOKIE 0x71b83bd5
#endif
assert(addr && "constant entity without value");
if (get_irn_op(addr) == op_Const) {
- impl_meth = get_tv_entity(get_Const_tarval(addr));
+ impl_meth = tarval_to_entity(get_Const_tarval(addr));
}
assert(!impl_meth || get_entity_peculiarity(impl_meth) == existent);
assert(get_entity_irg(ent));
set_irg_current_block(current_ir_graph, get_nodes_Block(node));
new_node = new_d_Const(get_irn_dbg_info(node),
- mode_P, tarval_P_from_entity(ent)); DBG_OPT_NORMALIZE;
+ mode_P, new_tarval_from_entity(ent, mode_P)); DBG_OPT_NORMALIZE;
exchange(node, new_node);
}
}
case iro_Const: {
/* interne Methode */
- entity * ent = get_Const_tarval(node)->u.P.ent;
+ entity * ent = tarval_to_entity(get_Const_tarval(node));
assert(ent && is_method_type(get_entity_type(ent)));
if (get_entity_visibility(ent) != external_allocated) {
assert(get_entity_irg(ent));
break;
case iro_Const: {
tarval * val = get_Const_tarval(node);
- entity * ent = val->u.P.ent;
- if (ent != NULL && is_method_type(get_entity_type(ent))) {
- eset_insert(set, ent);
+ if (tarval_is_entity(val)) { /* filter null pointer */
+ entity * ent = tarval_to_entity(val);
+ if (is_method_type(get_entity_type(ent))) {
+ eset_insert(set, ent);
+ }
}
break;
}
/* create the type kinds. */
init_tpop ();
/* create an obstack and put all tarvals in a pdeq */
- tarval_init_1 ();
+ init_tarval_1 ();
/* initialize all modes an ir node can consist of */
init_mode ();
/* initialize tarvals, and floating point arithmetic */
- tarval_init_2 ();
+ init_tarval_2 ();
/* init graph construction */
init_irgraph();
/* kind of obstack initialization */
#include <ctype.h>
#include <string.h>
#include <stddef.h>
+#include <stdlib.h>
#include "ident_t.h"
#include "array.h"
printf("Error: no value set. Use of undefined variable. Initializing to zero.\n");
assert (mode->code >= irm_F && mode->code <= irm_P);
res = new_rd_Const (NULL, current_ir_graph, block, mode,
- tarval_mode_null[mode->code]);
+ get_mode_null(mode));
}
/* The local valid value is available now. */
if (get_irn_op(addr) == op_Const) {
/* Check whether the constant is the pointer to a compiled entity. */
tv = get_Const_tarval(addr);
- if (tv->u.P.ent) {
- called_irg = get_entity_irg(tv->u.P.ent);
+ if (tarval_to_entity(tv)) {
+ called_irg = get_entity_irg(tarval_to_entity(tv));
if (called_irg && pos < MAX_INLINE) {
/* The Call node calls a locally defined method. Remember to inline. */
calls[pos] = call;
tarval *tv;
ir_graph *callee;
tv = get_Const_tarval(get_Call_ptr(calls[i]));
- callee = get_entity_irg(tv->u.P.ent);
+ callee = get_entity_irg(tarval_to_entity(tv));
if ((_obstack_memory_used(callee->obst) - obstack_room(callee->obst)) < size) {
inline_method(calls[i], callee);
}
get_irn_modeident (const ir_node *node)
{
assert(node);
- return node->mode->name;
+ return get_mode_ident(node->mode);
}
INLINE ir_op *
# ifndef _IRNODE_H_
# define _IRNODE_H_
+/* Projection numbers of compare: use for Proj nodes! */
+typedef enum {
+ False, /* false */
+ Eq, /* equal */
+ Lt, /* less */
+ Le, /* less or equal */
+ Gt, /* greater */
+ Ge, /* greater or equal */
+ Lg, /* less or greater */
+ Leg, /* less, equal or greater = ordered */
+ Uo, /* unordered */
+ Ue, /* unordered or equal */
+ Ul, /* unordered or less */
+ Ule, /* unordered, less or equal */
+ Ug, /* unordered or greater */
+ Uge, /* unordered, greater or equal */
+ Ne, /* unordered, less or greater = not equal */
+ True /* true */
+ /* not_mask = Leg*/ /* bits to flip to negate comparison * @@ hack for jni interface */
+} pnc_number;
+#define not_mask Leg
+
+# include "tv.h"
# include "irgraph.h"
# include "entity.h"
# include "firm_common.h"
# include "irop.h"
# include "irmode.h"
-# include "tv.h"
# include "type.h"
# include "dbginfo.h"
# include "exc.h"
INLINE ir_node *get_Not_op (ir_node *node);
INLINE void set_Not_op (ir_node *node, ir_node *op);
-/** Projection numbers of compare: use for Proj nodes! */
-typedef enum {
- False, /**< false */
- Eq, /**< equal */
- Lt, /**< less */
- Le, /**< less or equal */
- Gt, /**< greater */
- Ge, /**< greater or equal */
- Lg, /**< less or greater */
- Leg, /**< less, equal or greater = ordered */
- Uo, /**< unordered */
- Ue, /**< unordered or equal */
- Ul, /**< unordered or less */
- Ule, /**< unordered, less or equal */
- Ug, /**< unordered or greater */
- Uge, /**< unordered, greater or equal */
- Ne, /**< unordered, less or greater = not equal */
- True /**< true */
- /* not_mask = Leg*/ /* bits to flip to negate comparison * @@ hack for jni interface */
-} pnc_number;
-#define not_mask Leg
INLINE const char *get_pnc_string(int pnc);
+
INLINE int get_negated_pnc(int pnc);
INLINE ir_node *get_Cmp_left (ir_node *node);
INLINE void set_Cmp_left (ir_node *node, ir_node *left);
value_of (ir_node *n)
{
if ((n != NULL) && (get_irn_op(n) == op_Const))
- return get_Const_tarval(n);
+ return get_Const_tarval(n); /* might return tarval_bad */
else
- return NULL;
+ return tarval_bad;
}
/* if n can be computed, return the value, else NULL. Performs
tarval *res;
ir_node *a = NULL, *b = NULL; /* initialized to shut up gcc */
- tarval *ta = NULL, *tb = NULL; /* initialized to shut up gcc */
+ /* initialized to uniformly filter invalid constants */
+ tarval *ta = tarval_bad, *tb = tarval_bad;
- res = NULL;
+ res = tarval_bad;
/* get the operands we will work on for simple cases. */
if (is_binop(n)) {
case iro_SymConst:
if ((get_SymConst_kind(n) == size) &&
(get_type_state(get_SymConst_type(n))) == layout_fixed)
- res = tarval_from_long (mode_Is, get_type_size(get_SymConst_type(n)));
+ res = new_tarval_from_long (get_type_size(get_SymConst_type(n)), mode_Is);
break;
case iro_Add:
- if (ta && tb && (get_irn_mode(a) == get_irn_mode(b))
- && (get_irn_mode(a) != mode_P)) {
+ if ((ta != tarval_bad) && (tb != tarval_bad)
+ && (get_irn_mode(a) == get_irn_mode(b))
+ && !(get_mode_sort(get_irn_mode(a)) == reference)) {
res = tarval_add (ta, tb);
}
break;
case iro_Sub:
- if (ta && tb && (get_irn_mode(a) == get_irn_mode(b))
- && (get_irn_mode(a) != mode_P)) {
+ if ((ta != tarval_bad) && (tb != tarval_bad)
+ && (get_irn_mode(a) == get_irn_mode(b))
+ && !(get_mode_sort(get_irn_mode(a)) == reference)) {
res = tarval_sub (ta, tb);
- } else if (a == b) {
- res = tarval_mode_null [get_irn_modecode (n)];
}
break;
case iro_Minus:
- if (ta && mode_is_float(get_irn_mode(a)))
+ if ((ta != tarval_bad) && mode_is_signed(get_irn_mode(a)))
res = tarval_neg (ta);
break;
case iro_Mul:
- if (ta && tb) /* tarval_mul tests for equivalent modes itself */ {
+ if ((ta != tarval_bad) && (tb != tarval_bad) && (get_irn_mode(a) == get_irn_mode(b))) {
res = tarval_mul (ta, tb);
} else {
/* a*0 = 0 or 0*b = 0:
calls computed_value recursive and returns the 0 with proper
mode. */
tarval *v;
- if ( (tarval_classify ((v = computed_value (a))) == 0)
- || (tarval_classify ((v = computed_value (b))) == 0)) {
+ if ( ( ((v = computed_value (a)) != tarval_bad)
+ && (v == get_mode_null(get_tarval_mode(v))) )
+ || ( ((v = computed_value (b)) != tarval_bad)
+ && (v == get_mode_null(get_tarval_mode(v))) )) {
res = v;
}
}
break;
case iro_Quot:
/* This was missing in original implementation. Why? */
- if (ta && tb && (get_irn_mode(a) == get_irn_mode(b))) {
- if (tarval_classify(tb) == 0) {res = NULL; break;}
+ if ((ta != tarval_bad) && (tb != tarval_bad) && (get_irn_mode(a) == get_irn_mode(b))) {
+ if (tb == get_mode_null(get_tarval_mode(tb))) break; /* div by zero: return tarval_bad */
res = tarval_quo(ta, tb);
}
break;
case iro_Div:
/* This was missing in original implementation. Why? */
- if (ta && tb && (get_irn_mode(a) == get_irn_mode(b))) {
- if (tarval_classify(tb) == 0) {res = NULL; break;}
+ if ((ta != tarval_bad) && (tb != tarval_bad) && (get_irn_mode(a) == get_irn_mode(b))) {
+ if (tb == get_mode_null(get_tarval_mode(tb))) break; /* div by zero: return tarval_bad */
res = tarval_div(ta, tb);
}
break;
case iro_Mod:
/* This was missing in original implementation. Why? */
- if (ta && tb && (get_irn_mode(a) == get_irn_mode(b))) {
- if (tarval_classify(tb) == 0) {res = NULL; break;}
+ if ((ta != tarval_bad) && (tb != tarval_bad) && (get_irn_mode(a) == get_irn_mode(b))) {
+ if (tb == get_mode_null(get_tarval_mode(tb))) break; /* div by zero: return tarval_bad */
res = tarval_mod(ta, tb);
}
break;
/* for iro_DivMod see iro_Proj */
case iro_Abs:
- if (ta)
+ if (ta != tarval_bad)
res = tarval_abs (ta);
break;
case iro_And:
- if (ta && tb) {
+ if ((ta != tarval_bad) && (tb != tarval_bad)) {
res = tarval_and (ta, tb);
} else {
tarval *v;
- if ( (tarval_classify ((v = computed_value (a))) == 0)
- || (tarval_classify ((v = computed_value (b))) == 0)) {
+ if ( ( ((v = computed_value (a)) != tarval_bad)
+ && (v == get_mode_null(get_tarval_mode(v))) )
+ || ( ((v = computed_value (b)) != tarval_bad)
+ && (v == get_mode_null(get_tarval_mode(v))) )) {
res = v;
}
}
break;
case iro_Or:
- if (ta && tb) {
+ if ((ta != tarval_bad) && (tb != tarval_bad)) {
res = tarval_or (ta, tb);
} else {
tarval *v;
}
}
break;
- case iro_Eor: if (ta && tb) { res = tarval_eor (ta, tb); } break;
- case iro_Not: if (ta) { res = tarval_neg (ta); } break;
- case iro_Shl: if (ta && tb) { res = tarval_shl (ta, tb); } break;
- /* tarval_shr is faulty !! */
- case iro_Shr: if (ta && tb) { res = tarval_shr (ta, tb); } break;
- case iro_Shrs:if (ta && tb) { /*res = tarval_shrs (ta, tb)*/; } break;
- case iro_Rot: if (ta && tb) { /*res = tarval_rot (ta, tb)*/; } break;
- case iro_Conv:if (ta) { res = tarval_convert_to (ta, get_irn_mode (n)); }
+ case iro_Eor:
+ if ((ta != tarval_bad) && (tb != tarval_bad)) {
+ res = tarval_eor (ta, tb);
+ }
+ break;
+ case iro_Not:
+ if ((ta != tarval_bad)) {
+ res = tarval_neg (ta);
+ }
+ break;
+ case iro_Shl:
+ if ((ta != tarval_bad) && (tb != tarval_bad)) {
+ res = tarval_shl (ta, tb);
+ }
+ break;
+ case iro_Shr:
+ if ((ta != tarval_bad) && (tb != tarval_bad)) {
+ res = tarval_shr (ta, tb);
+ }
+ break;
+ case iro_Shrs:
+ if ((ta != tarval_bad) && (tb != tarval_bad)) {
+ res = tarval_shrs (ta, tb);
+ }
+ break;
+ case iro_Rot:
+ if ((ta != tarval_bad) && (tb != tarval_bad)) {
+ /*res = tarval_rot (ta, tb)*/;
+ }
+ break;
+ case iro_Conv:
+ if (ta != tarval_bad) {
+ res = tarval_convert_to (ta, get_irn_mode (n));
+ }
break;
case iro_Proj: /* iro_Cmp */
{
if (aa == ab) { /* 1.: */
/* This is a tric with the bits used for encoding the Cmp
Proj numbers, the following statement is not the same:
- res = tarval_from_long (mode_b, (get_Proj_proj(n) == Eq)): */
- res = tarval_from_long (mode_b, (get_Proj_proj(n) & irpn_Eq));
+ res = new_tarval_from_long ((get_Proj_proj(n) == Eq), mode_b) */
+ res = new_tarval_from_long ((get_Proj_proj(n) & Eq), mode_b);
} else {
tarval *taa = computed_value (aa);
tarval *tab = computed_value (ab);
- if (taa && tab) { /* 2.: */
+ if ((taa != tarval_bad) && (tab != tarval_bad)) { /* 2.: */
/* strange checks... */
- ir_pncmp flags = tarval_comp (taa, tab);
- if (flags != irpn_False) {
- res = tarval_from_long (mode_b, get_Proj_proj(n) & flags);
+ pnc_number flags = tarval_cmp (taa, tab);
+ if (flags != False) {
+ res = new_tarval_from_long (get_Proj_proj(n) & flags, mode_b);
}
} else { /* check for 3.: */
ir_node *aaa = skip_nop(skip_Proj(aa));
&& ( (/* ab is constant void */
(get_irn_op(ab) == op_Const)
&& (get_irn_mode(ab) == mode_P)
- && (get_Const_tarval(ab) == tarval_P_void))
+ && (get_Const_tarval(ab) == get_mode_null(mode_P)))
|| (/* ab is other Alloc */
(get_irn_op(ab) == op_Proj)
&& (get_irn_mode(ab) == mode_P)
|| (/* aa is void and aba is Alloc */
(get_irn_op(aa) == op_Const)
&& (get_irn_mode(aa) == mode_P)
- && (get_Const_tarval(aa) == tarval_P_void)
+ && (get_Const_tarval(aa) == get_mode_null(mode_P))
&& (get_irn_op(ab) == op_Proj)
&& (get_irn_mode(ab) == mode_P)
&& (get_irn_op(aba) == op_Alloc)))
/* 3.: */
- res = tarval_from_long (mode_b, get_Proj_proj(n) & irpn_Ne);
+ res = new_tarval_from_long (get_Proj_proj(n) & Ne, mode_b);
}
}
} else if (get_irn_op(a) == op_DivMod) {
ta = value_of(get_DivMod_left(a));
tb = value_of(get_DivMod_right(a));
- if (ta && tb && (get_irn_mode(a) == get_irn_mode(b))) {
- if (tarval_classify(tb) == 0) {res = NULL; break;}
+ if ((ta != tarval_bad) && (tb != tarval_bad) && (get_irn_mode(a) == get_irn_mode(b))) {
+ if (tb == get_mode_null(get_tarval_mode(tb))) break; /* div by zero: return tarval_bad */
if (get_Proj_proj(n)== 0) /* Div */
res = tarval_div(ta, tb);
else /* Mod */
switch (get_irn_opcode(n)) {
case iro_Div: {
ta = computed_value(n);
- if (ta) {
+ if (ta != tarval_bad) {
/* Turn Div into a tuple (mem, bad, value) */
ir_node *mem = get_Div_mem(n);
turn_into_tuple(n, 3);
set_Tuple_pred(n, 0, mem);
set_Tuple_pred(n, 1, new_Bad());
- set_Tuple_pred(n, 2, new_Const(get_tv_mode(ta), ta));
+ set_Tuple_pred(n, 2, new_Const(get_tarval_mode(ta), ta));
}
} break;
case iro_Mod: {
ta = computed_value(n);
- if (ta) {
+ if (ta != tarval_bad) {
/* Turn Div into a tuple (mem, bad, value) */
ir_node *mem = get_Mod_mem(n);
turn_into_tuple(n, 3);
set_Tuple_pred(n, 0, mem);
set_Tuple_pred(n, 1, new_Bad());
- set_Tuple_pred(n, 2, new_Const(get_tv_mode(ta), ta));
+ set_Tuple_pred(n, 2, new_Const(get_tarval_mode(ta), ta));
}
} break;
case iro_DivMod: {
break;
if (a == b) {
- a = new_Const (mode, tarval_from_long (mode, 1));
- b = new_Const (mode, tarval_from_long (mode, 0));
+ a = new_Const (mode, get_mode_one(mode));
+ b = new_Const (mode, get_mode_null(mode));
evaluated = 1;
} else {
ta = value_of(a);
tb = value_of(b);
- if (tb) {
- if (tarval_classify(tb) == 1) {
- b = new_Const (mode, tarval_from_long (mode, 0));
+ if (tb != tarval_bad) {
+ if (tb == get_mode_one(get_tarval_mode(tb))) {
+ b = new_Const (mode, get_mode_null(mode));
evaluated = 1;
- } else if (ta) {
+ } else if (ta != tarval_bad) {
tarval *resa, *resb;
resa = tarval_div (ta, tb);
- if (!resa) break; /* Causes exception!!! Model by replacing through
- Jmp for X result!? */
+ if (resa == tarval_bad) break; /* Causes exception!!! Model by replacing through
+ Jmp for X result!? */
resb = tarval_mod (ta, tb);
- if (!resb) break; /* Causes exception! */
+ if (resb == tarval_bad) break; /* Causes exception! */
a = new_Const (mode, resa);
b = new_Const (mode, resb);
evaluated = 1;
}
- } else if (tarval_classify (ta) == 0) {
+ } else if (ta == get_mode_null(get_tarval_mode(ta))) {
b = a;
evaluated = 1;
}
a = get_Cond_selector(n);
ta = value_of(a);
- if (ta &&
+ if ((ta != tarval_bad) &&
(get_irn_mode(a) == mode_b) &&
(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));
turn_into_tuple(n, 2);
- if (tv_val_b(ta) == 1) /* GL: I hope this returns 1 if true */ {
+ if (ta == tarval_b_true) {
set_Tuple_pred(n, 0, new_Bad());
set_Tuple_pred(n, 1, jmp);
} else {
}
/* We might generate an endless loop, so keep it alive. */
add_End_keepalive(get_irg_end(current_ir_graph), get_nodes_Block(n));
- } else if (ta &&
+ } else if ((ta != tarval_bad) &&
(get_irn_mode(a) == mode_Iu) &&
(get_Cond_kind(n) == dense) &&
(get_opt_unreachable_code())) {
&& (get_Cond_kind(a) == dense)
&& (get_opt_unreachable_code())) {
/* The Cond is a Switch on a Constant */
- if (get_Proj_proj(n) == tv_val_uInt(value_of(a))) {
+ if (get_Proj_proj(n) == tarval_to_long(value_of(a))) {
/* The always taken branch, reuse the existing Jmp. */
if (!get_irn_link(a)) /* well, if it exists ;-> */
set_irn_link(a, new_r_Jmp(current_ir_graph, get_nodes_Block(n)));
if (get_irn_op(n) != op_Const) {
/* try to evaluate */
tv = computed_value (n);
- if ((get_irn_mode(n) != mode_T) && (tv != NULL)) {
+ if ((get_irn_mode(n) != mode_T) && (tv != tarval_bad)) {
/* evaluation was succesful -- replace the node. */
obstack_free (current_ir_graph->obst, n);
- return new_Const (get_tv_mode (tv), tv);
+ return new_Const (get_tarval_mode (tv), tv);
}
}
}
if (get_irn_op(n) != op_Const) {
/* try to evaluate */
tv = computed_value (n);
- if ((get_irn_mode(n) != mode_T) && (tv != NULL)) {
+ if ((get_irn_mode(n) != mode_T) && (tv != tarval_bad)) {
/* evaluation was succesful -- replace the node. */
- n = new_Const (get_tv_mode (tv), tv);
+ n = new_Const (get_tarval_mode (tv), tv);
__dbg_info_merge_pair(n, old_n, dbg_const_eval);
return n;
}
/* All this is needed to build the constant node for methods: */
# include "irprog_t.h"
# include "ircons.h"
+# include "tv_t.h"
/*******************************************************************/
/** general **/
res->variability = constant;
rem = current_ir_graph;
current_ir_graph = get_const_code_irg();
- res->value = new_Const(mode_P, tarval_P_from_entity(res));
+ res->value = new_Const(mode_P, new_tarval_from_entity(res, mode_P));
current_ir_graph = rem;
} else {
res->variability = uninitialized;
void
free_entity (entity *ent) {
- free_tv_entity(ent);
+ free_tarval_entity(ent);
free_entity_attrs(ent);
free(ent);
}
current_ir_graph = get_const_code_irg();
for (i = 0; i < num_vals; i++) {
- val = new_Const(get_tv_mode (values[i]), values[i]);
+ val = new_Const(get_tarval_mode (values[i]), values[i]);
add_compound_ent_value(ent, val, get_array_element_entity(arrtp));
}
current_ir_graph = rem;
*/
#include "firm.h"
+#include "xprintf.h"
/**
* possible trvrfy() error codes
if ((tp->type_op == type_primitive) || (tp->type_op == type_enumeration)) {
/* For pointer, primitive and enumeration size depends on the mode. */
- tp->size = get_mode_size(m);
+ tp->size = get_mode_size(m)/8;
tp->mode = m;
}
}
type *res;
res = new_type(type_method, mode_P, name);
res->state = layout_fixed;
- res->size = get_mode_size(mode_P);
+ res->size = get_mode_size(mode_P)/8;
res->attr.ma.n_params = n_param;
res->attr.ma.param_type = (type **) xmalloc (sizeof (type *) * n_param);
res->attr.ma.n_res = n_res;
ir_graph *rem = current_ir_graph;
current_ir_graph = get_const_code_irg();
set_array_bounds (array, dimension,
- new_Const(mode_Iu, tarval_from_long (mode_Iu, lower_bound)),
- new_Const(mode_Iu, tarval_from_long (mode_Iu, upper_bound)));
+ new_Const(mode_Iu, new_tarval_from_long (lower_bound, mode_Iu)),
+ new_Const(mode_Iu, new_tarval_from_long (upper_bound, mode_Iu )));
current_ir_graph = rem;
}
INLINE void
ir_graph *rem = current_ir_graph;
current_ir_graph = get_const_code_irg();
set_array_lower_bound (array, dimension,
- new_Const(mode_Iu, tarval_from_long (mode_Iu, lower_bound)));
+ new_Const(mode_Iu, new_tarval_from_long (lower_bound, mode_Iu)));
current_ir_graph = rem;
}
INLINE void
ir_graph *rem = current_ir_graph;
current_ir_graph = get_const_code_irg();
set_array_upper_bound (array, dimension,
- new_Const(mode_Iu, tarval_from_long (mode_Iu, upper_bound)));
+ new_Const(mode_Iu, new_tarval_from_long (upper_bound, mode_Iu)));
current_ir_graph = rem;
}
ir_node * get_array_lower_bound (type *array, int dimension) {
type *res;
res = new_type(type_pointer, mode_P, name);
res->attr.pa.points_to = points_to;
- res->size = get_mode_size(res->mode);
+ res->size = get_mode_size(res->mode)/8;
res->state = layout_fixed;
return res;
}
type *res;
/* @@@ assert( mode_is_data(mode) && (!mode == mode_P)); */
res = new_type(type_primitive, mode, name);
- res->size = get_mode_size(mode);
+ res->size = get_mode_size(mode)/8;
res->state = layout_fixed;
return res;
}
# define U_BOUND 9
array_type = new_type_array(id_from_str("a", 1), N_DIMS, prim_t_int);
set_array_bounds(array_type, 1,
- new_Const(mode_Iu, tarval_from_long (mode_Iu, L_BOUND)),
- new_Const(mode_Iu, tarval_from_long (mode_Iu, U_BOUND)));
+ new_Const(mode_Iu, new_tarval_from_long (L_BOUND, mode_Iu)),
+ new_Const(mode_Iu, new_tarval_from_long (U_BOUND, mode_Iu)));
/* 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. */
/* better: read bounds out of array type information */
size = (U_BOUND - L_BOUND + 1) * get_mode_size(elt_type_mode);
/* make constant representing the size */
- arr_size = new_Const(mode_Iu, tarval_from_long (mode_Iu, size));
+ arr_size = new_Const(mode_Iu, new_tarval_from_long (size, mode_Iu));
/* allocate and generate the Proj nodes. */
array = new_Alloc(get_store(), arr_size, (type*)array_type, stack_alloc);
set_store(new_Proj(array, mode_M, 0)); /* make the changed memory visible */
by (three * elt_size), but this complicates some optimizations. The
type information accessible via the entity allows to generate the
pointer increment later. */
- c3 = new_Const (mode_Iu, tarval_from_long (mode_Iu, 3));
+ c3 = new_Const (mode_Iu, new_tarval_from_long (3, mode_Iu));
{
ir_node *in[1];
in[0] = c3;
# define U_BOUND 9
array_type = new_type_array(id_from_str("a_tp", 4), N_DIMS, prim_t_int);
set_array_bounds(array_type, 1,
- new_Const(mode_Iu, tarval_from_long (mode_Iu, L_BOUND)),
- new_Const(mode_Iu, tarval_from_long (mode_Iu, U_BOUND)));
+ new_Const(mode_Iu, new_tarval_from_long (L_BOUND, mode_Iu)),
+ new_Const(mode_Iu, new_tarval_from_long (U_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 pointer by (three * elt_size), but this complicates some
optimizations.) The type information accessible via the entity
allows to generate the pointer increment later. */
- c3 = new_Const (mode_Iu, tarval_from_long (mode_Iu, 3));
+ c3 = new_Const (mode_Iu, new_tarval_from_long (3, mode_Iu));
{
ir_node *in[1];
in[0] = c3;
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
/* the string is entered in the constant table. const_str is a pointer to the string */
- const_str = new_Const (mode_P, tarval_P_from_str ("Hello world!"));
+ /* length 13 because of the terminating NULL character */
+ const_str = new_Const (mode_P, new_tarval_from_str ("Hello world!", 13, mode_P));
/* get the pointer to the procedure from the class type */
/* this is how a pointer to be fixed by the linker is represented after
/* the expression that evaluates the condition */
/* cmpGt = a > 2 */
- c2 = new_Const (mode_Is, tarval_from_long (mode_Is, 2));
+ c2 = new_Const (mode_Is, new_tarval_from_long (2, mode_Is));
cmpGt = new_Proj(new_Cmp(get_value(0, mode_Is), c2), mode_b, Gt);
cmpGt = new_Conv(cmpGt, mode_Is);
/* cmpLt = a < 10 */
- c10 = new_Const (mode_Is, tarval_from_long (mode_Is, 10));
+ c10 = new_Const (mode_Is, new_tarval_from_long (10, mode_Is));
cmpLt = new_Proj(new_Cmp(get_value(0, mode_Is), c10), mode_b, Lt);
cmpLt = new_Conv(cmpLt, mode_Is);
/* cmpGt && cmpLt */
and = new_And(cmpGt, cmpLt, mode_Is);
/* compare result and 0 because we have no cast from integer to bool */
- and = new_Cmp(and, new_Const (mode_Is, tarval_from_long (mode_Is, 0)));
+ and = new_Cmp(and, new_Const (mode_Is, new_tarval_from_long (0, mode_Is)));
and = new_Proj(and, mode_b, Ne);
/* the conditional branch */
/* generate and fill the then block */
b = new_immBlock ();
add_in_edge (b, t);
- set_value (0, new_Const (mode_Is, tarval_from_long (mode_Is, 1)));
+ set_value (0, new_Const (mode_Is, new_tarval_from_long (1, mode_Is)));
mature_block (b);
x_then = new_Jmp ();
current_ir_graph = get_const_code_irg();
/* The pointer to the dispatch table is constant. */
/* The constant is the address of the given entity */
+<<<<<<< const_ent_example.c
+ n = new_Const(mode_P, new_tarval_from_entity(dipte, mode_P));
+=======
n = new_Const(mode_P, tarval_P_from_entity(dipte));
+>>>>>>> 1.7
set_entity_variability(diptpe, constant);
set_atomic_ent_value(diptpe, n);
arre = new_entity(get_glob_type(), arrei, arrt);
set_entity_variability(arre, constant);
current_ir_graph = get_const_code_irg();
- n = new_Const(mode_Is, tarval_from_long (mode_Is, 7));
+ n = new_Const(mode_Is, new_tarval_from_long (7, mode_Is));
add_compound_ent_value(arre, n, arrelte);
- n = new_Const(mode_Is, tarval_from_long (mode_Is, 2));
+ n = new_Const(mode_Is, new_tarval_from_long (2, mode_Is));
add_compound_ent_value(arre, n, arrelte);
- n = new_Const(mode_Is, tarval_from_long (mode_Is, 13));
+ n = new_Const(mode_Is, new_tarval_from_long (13, mode_Is));
add_compound_ent_value(arre, n, arrelte);
- n = new_Const(mode_Is, tarval_from_long (mode_Is, 92));
+ n = new_Const(mode_Is, new_tarval_from_long (92, mode_Is));
add_compound_ent_value(arre, n, arrelte);
}
printf("Done building the graph. Dumping it.\n");
irg = new_ir_graph (ent, 4);
- a = new_Const (mode_Is, tarval_from_long (mode_Is, 7));
- b = new_Const (mode_Is, tarval_from_long (mode_Is, 5));
+ a = new_Const (mode_Is, new_tarval_from_long (7, mode_Is));
+ b = new_Const (mode_Is, new_tarval_from_long (5, mode_Is));
x = new_Jmp ();
mature_block (get_irg_current_block(irg));
c = new_Proj(c, mode_Is, 2);
*/
- c = new_Add (new_Const (mode_Is, tarval_from_long (mode_Is, 5)),
- new_Const (mode_Is, tarval_from_long (mode_Is, 7)),
+ c = new_Add (new_Const (mode_Is, new_tarval_from_long (5, mode_Is)),
+ new_Const (mode_Is, new_tarval_from_long (7, mode_Is)),
mode_Is);
- d = new_Add (new_Const (mode_Is, tarval_from_long (mode_Is, 7)),
- new_Const (mode_Is, tarval_from_long (mode_Is, 5)),
+ d = new_Add (new_Const (mode_Is, new_tarval_from_long (7, mode_Is)),
+ new_Const (mode_Is, new_tarval_from_long (5, mode_Is)),
mode_Is);
{
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
/* to make a condition */
- c1 = new_Const (mode_Is, tarval_from_long (mode_Is, 1));
- c2 = new_Const (mode_Is, tarval_from_long (mode_Is, 2));
+ c1 = new_Const (mode_Is, new_tarval_from_long (1, mode_Is));
+ c2 = new_Const (mode_Is, new_tarval_from_long (2, mode_Is));
set_value(0, c2);
cond = new_Cond(new_Proj(new_Cmp(c1, c2), mode_b, Eq));
/* Generate two values */
set_value (0, new_Proj(get_irg_args(irg), mode_Is, 0));
- set_value (1, new_Const (mode_Is, tarval_from_long (mode_Is, 1)));
+ set_value (1, new_Const (mode_Is, new_tarval_from_long (1, mode_Is)));
x = new_Jmp();
mature_block (get_irg_current_block(irg));
/* generate a block for the loop header and the conditional branch */
r = new_immBlock ();
add_in_edge (r, x);
- x = new_Cond (new_Proj(new_Cmp(new_Const (mode_Is, tarval_from_long (mode_Is, 0)),
- new_Const (mode_Is, tarval_from_long (mode_Is, 0))),
+ 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));
f = new_Proj (x, mode_X, 0);
t = new_Proj (x, mode_X, 1);
/* set VAR_A to constant value */
set_store (new_Proj (new_Store (get_store (),
- new_Const (mode_P, tarval_P_from_str ("VAR_A")),
+ new_Const (mode_P, new_tarval_from_str ("VAR_A", 6, mode_P)), /* length 6 because of NULL */
get_value(1, mode_Is)),
mode_M, 0));
#define NUM_OF_LOCAL_VARS 0
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
- tv = tarval_d_from_str ("12345678901234567890.1234567890", 31);
+ tv = new_tarval_from_str ("12345678901234567890.1234567890", 31, mode_D);
set_value (a_pos, new_Proj (get_irg_args(irg), mode_Is, 0));
/* Generate the constant and assign it to b. The assignment is resovled to a
dataflow edge. */
- set_value (b_pos, new_Const (mode_Is, tarval_from_long (mode_Is, 2)));
+ 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));
/* Generate a conditional branch */
cmp = new_Cmp(get_value(a_pos, mode_Is), get_value(b_pos, mode_Is)); /*
- cmp = new_Cmp(new_Const (mode_Is, tarval_from_long (mode_Is, 2)),
- new_Const (mode_Is, tarval_from_long (mode_Is, 2)));*/
+ cmp = new_Cmp(new_Const (mode_Is, new_tarval_from_long (2, mode_Is)),
+ new_Const (mode_Is, new_tarval_from_long (2, mode_Is)));*/
x = new_Cond (new_Proj(cmp, mode_b, Eq));
f = new_Proj (x, mode_X, 0);
t = new_Proj (x, mode_X, 1);
r = new_immBlock ();
add_in_edge (r, t);
a = new_Sub(get_value(a_pos, mode_Is),
- new_Const (mode_Is, tarval_from_long (mode_Is, 3)),
+ new_Const (mode_Is, new_tarval_from_long (3, mode_Is)),
mode_Is);
set_value (a_pos, a);
r = new_immBlock ();
add_in_edge (r, f);
a = new_Sub(get_value(a_pos, mode_Is),
- new_Const (mode_Is, tarval_from_long (mode_Is, 3)),
+ new_Const (mode_Is, new_tarval_from_long (3, mode_Is)),
mode_Is);
- a = new_Add(a, new_Const (mode_Is, tarval_from_long (mode_Is, 5)), 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);
i_ptr = new_simpleSel(get_store(), get_irg_globals(irg), i_ent);
store = new_Store (get_store(), i_ptr,
- new_Const(mode_Is, tarval_from_long (mode_Is, 2)));
+ new_Const(mode_Is, new_tarval_from_long (2, mode_Is)));
set_store(new_Proj(store, mode_M, 0));
{
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
/* Generate two constants */
- c0 = new_Const (mode_Is, tarval_from_long (mode_Is, 0));
- c1 = new_Const (mode_Is, tarval_from_long (mode_Is, 1));
+ c0 = new_Const (mode_Is, new_tarval_from_long (0, mode_Is));
+ c1 = new_Const (mode_Is, new_tarval_from_long (1, mode_Is));
/* set a and b to constants */
set_value (0, c0); /* this (0) is variable a */
set_value (1, c1); /* this (1) is variable b */
/* the expression that evaluates the condition */
- c2 = new_Const (mode_Is, tarval_from_long (mode_Is, 2));
+ c2 = new_Const (mode_Is, new_tarval_from_long (2, mode_Is));
cmpGt = new_Proj(new_Cmp(get_value(0, mode_Is), c2), mode_b, Gt);
/* the conditional branch */
/* generate and fill the else block */
b = new_immBlock ();
add_in_edge (b, f);
- set_value (1, new_Const (mode_Is, tarval_from_long (mode_Is, 2)));
+ set_value (1, new_Const (mode_Is, new_tarval_from_long (2, mode_Is)));
mature_block (b);
x_else = new_Jmp ();
set_value (a_pos, new_Proj (get_irg_args(irg), mode_Is, 0));
/* Generate the constant and assign it to b. The assignment is resovled to a
dataflow edge. */
- set_value (b_pos, new_Const (mode_Is, tarval_from_long (mode_Is, 2)));
+ 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));
r = new_immBlock ();
add_in_edge (r, t);
a = new_Sub(get_value(a_pos, mode_Is),
- new_Const (mode_Is, tarval_from_long (mode_Is, 3)),
+ new_Const (mode_Is, new_tarval_from_long (3, mode_Is)),
mode_Is);
set_value (a_pos, a);
irg = new_ir_graph (ent, 4);
/* Generate two constants */
- set_value (0, new_Const (mode_Iu, tarval_from_long (mode_Iu, 0)));
- set_value (1, new_Const (mode_Iu, tarval_from_long (mode_Iu, 1)));
+ 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));
/* Generate a conditional branch */
/* generate a block for the loop header and the conditional branch */
r = new_immBlock ();
add_in_edge (r, x);
- x = new_Cond (new_Proj(new_Cmp(new_Const (mode_Iu, tarval_from_long (mode_Is, 0)),
- new_Const (mode_Iu, tarval_from_long (mode_Is, 0))),
+ 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));
f = new_Proj (x, mode_X, 0);
t = new_Proj (x, mode_X, 1);
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
/* two make two conditionals that represent a switch */
- expr = new_Const (mode_Is, tarval_from_long (mode_Is, 0));
- c1 = new_Const (mode_Is, tarval_from_long (mode_Is, 1));
- c2 = new_Const (mode_Is, tarval_from_long (mode_Is, 2));
+ expr = new_Const (mode_Is, new_tarval_from_long (0, mode_Is));
+ c1 = new_Const (mode_Is, new_tarval_from_long (1, mode_Is));
+ c2 = new_Const (mode_Is, new_tarval_from_long (2, mode_Is));
cond = new_Cond(new_Proj(new_Cmp(expr, c1), mode_b, Eq));
f = new_Proj(cond, mode_X, 0);
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
/* to make three conditionals */
- expr = new_Const (mode_Is, tarval_from_long (mode_Is, 0));
- c1 = new_Const (mode_Is, tarval_from_long (mode_Is, 1));
- c2 = new_Const (mode_Is, tarval_from_long (mode_Is, 2));
- c3 = new_Const (mode_Is, tarval_from_long (mode_Is, 2));
+ expr = new_Const (mode_Is, new_tarval_from_long (0, mode_Is));
+ c1 = new_Const (mode_Is, new_tarval_from_long (1, mode_Is));
+ c2 = new_Const (mode_Is, new_tarval_from_long (2, mode_Is));
+ c3 = new_Const (mode_Is, new_tarval_from_long (2, mode_Is));
cond = new_Cond(new_Proj(new_Cmp(expr, c1), mode_b, Eq));
f = new_Proj(cond, mode_X, 0);
/* generate two constant pointers to string constants */
/* this simulates two global variables, a and b point to these variables */
- a = new_Const (mode_P, tarval_P_from_str ("VAR_A"));
- b = new_Const (mode_P, tarval_P_from_str ("VAR_B"));
+ a = new_Const (mode_P, new_tarval_from_str ("VAR_A", 6, mode_P)); /* length 6 because of NULL terminator */
+ b = new_Const (mode_P, new_tarval_from_str ("VAR_B", 6, mode_P));
/* set VAR_A and VAR_B to constant values */
set_store (new_Proj (new_Store (get_store (), a,
- new_Const (mode_Iu, tarval_from_long (mode_Is, 0))),
+ new_Const (mode_Iu, new_tarval_from_long (0, mode_Is))),
mode_M, 0));
set_store (new_Proj (new_Store (get_store (), b,
- new_Const (mode_Iu, tarval_from_long (mode_Is, 1))),
+ new_Const (mode_Iu, new_tarval_from_long (1, mode_Is))),
mode_M, 0));
/* finish this first block */
x = new_Cond (
new_Proj (
new_Cmp (
- new_Const (mode_Iu, tarval_from_long (mode_Is, 0)),
+ new_Const (mode_Iu, new_tarval_from_long (0, mode_Is)),
x),
mode_b, Gt));
set_irp_main_irg(main_irg);
/* Make the constants. They are independent of a block. */
- c2 = new_Const (mode_Is, tarval_from_long (mode_Is, 2));
- c5 = new_Const (mode_Is, tarval_from_long (mode_Is, 5));
+ c2 = new_Const (mode_Is, new_tarval_from_long (2, mode_Is));
+ c5 = new_Const (mode_Is, new_tarval_from_long (5, mode_Is));
/* There is only one block in main, it contains the allocation and the calls. */
/* Allocate the defined object and generate the type information. */
set_value(0, self);
par1 = new_Proj(get_irg_args(c_irg), mode_Is, 1);
set_value(1, par1);
- set_value(2, new_Const (mode_Is, tarval_from_long (mode_Is, 0)));
+ 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));
/* generate a block for the loop header and the conditional branch */
r = new_immBlock ();
add_in_edge (r, x);
- x = new_Cond (new_Proj(new_Cmp(new_Const (mode_Is, tarval_from_long (mode_Is, 0)),
- new_Const (mode_Is, tarval_from_long (mode_Is, 0))),
+ 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));
- /* x = new_Cond (new_Proj(new_Cmp(new_Const (mode_Is, tarval_from_long (mode_Is, 0)),
+ /* 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));*/
f = new_Proj (x, mode_X, 0);
set_irp_main_irg(main_irg);
/* Make the constants. They are independent of a block. */
- c2 = new_Const (mode_Is, tarval_from_long (mode_Is, 2));
- c5 = new_Const (mode_Is, tarval_from_long (mode_Is, 5));
+ c2 = new_Const (mode_Is, new_tarval_from_long (2, mode_Is));
+ c5 = new_Const (mode_Is, new_tarval_from_long (5, mode_Is));
/* There is only one block in main, it contains the allocation and the calls. */
/* Allocate the defined object and generate the type information. */
irg = new_ir_graph (ent, NUM_OF_LOCAL_VARS);
/* to make a condition */
- c1 = new_Const (mode_Is, tarval_from_long (mode_Is, 1));
+ c1 = new_Const (mode_Is, new_tarval_from_long (1, mode_Is));
c2 = new_Proj (get_irg_args(irg), mode_Is, 0);
set_value(1, c2);
cond = new_Cond(new_Proj(new_Cmp(c1, c2), mode_b, Eq));
- set_value(0, new_Const (mode_Is, tarval_from_long (mode_Is, 6)));
+ 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));
Block1 = new_immBlock();
add_in_edge(Block1, t);
mature_block(Block1);
- set_value(0, new_Const (mode_Is, tarval_from_long (mode_Is, 5)));
+ set_value(0, new_Const (mode_Is, new_tarval_from_long (5, mode_Is)));
jmp = new_Jmp();
add_in_edge(endBlock, jmp);
scndCondBlock = new_immBlock();
add_in_edge(scndCondBlock, f);
mature_block(scndCondBlock);
- c1 = new_Const (mode_Is, tarval_from_long (mode_Is, 3));
+ 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);
/* Generate two values */
set_value (0, new_Proj(get_irg_args(irg), mode_Is, 0));
- set_value (1, new_Const (mode_Is, tarval_from_long (mode_Is, 1)));
+ set_value (1, new_Const (mode_Is, new_tarval_from_long (1, mode_Is)));
x = new_Jmp();
mature_block (get_irg_current_block(irg));
/* generate a block for the loop header and the conditional branch */
r = new_immBlock ();
add_in_edge (r, x);
- x = new_Cond (new_Proj(new_Cmp(new_Const (mode_Is, tarval_from_long (mode_Is, 0)),
+ 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));
f = new_Proj (x, mode_X, 0);