From 55a613a794cc2fadd5508dcf721c342d70f342cc Mon Sep 17 00:00:00 2001 From: Matthias Heil Date: Tue, 26 Nov 2002 14:26:22 +0000 Subject: [PATCH] Modi umbenannt sather und fiasco tarvals entfernt [r523] --- ir/ir/ircons.c | 18 +- ir/ir/ircons.h | 10 +- ir/ir/irdump.c | 2 +- ir/ir/irgopt.c | 6 +- ir/ir/irgraph.c | 4 +- ir/ir/irmode.c | 370 ++++++++-------- ir/ir/irmode.h | 84 ++-- ir/ir/iropt.c | 30 +- ir/ir/irvrfy.c | 52 +-- ir/tr/entity.c | 2 +- ir/tr/type.c | 16 +- ir/tv/tv.c | 1071 +++++++++++++++-------------------------------- ir/tv/tv.h | 61 ++- ir/tv/tv_t.h | 11 - 14 files changed, 648 insertions(+), 1089 deletions(-) diff --git a/ir/ir/ircons.c b/ir/ir/ircons.c index 0756c0c56..fdb83ddd4 100644 --- a/ir/ir/ircons.c +++ b/ir/ir/ircons.c @@ -50,7 +50,7 @@ new_rd_Block (dbg_info* db, ir_graph *irg, int arity, ir_node **in) { ir_node *res; - res = new_ir_node (db, irg, NULL, op_Block, mode_R, arity, in); + res = new_ir_node (db, irg, NULL, op_Block, mode_BB, arity, in); set_Block_matured(res, 1); set_Block_block_visited(res, 0); @@ -162,7 +162,7 @@ new_rd_defaultProj (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *arg, long max_proj) { ir_node *res; - assert((arg->op==op_Cond) && (get_irn_mode(arg->in[1]) == mode_I)); + assert((arg->op==op_Cond) && (get_irn_mode(arg->in[1]) == mode_Iu)); arg->attr.c.kind = fragmentary; arg->attr.c.default_proj = max_proj; res = new_rd_Proj (db, irg, block, arg, mode_X, max_proj); @@ -556,7 +556,7 @@ new_rd_Sel (dbg_info* db, ir_graph *irg, ir_node *block, ir_node *store, ir_node r_in[0] = store; r_in[1] = objptr; memcpy (&r_in[2], in, sizeof (ir_node *) * arity); - res = new_ir_node (db, irg, block, op_Sel, mode_p, r_arity, r_in); + res = new_ir_node (db, irg, block, op_Sel, mode_P, r_arity, r_in); res->attr.s.ent = ent; @@ -595,9 +595,9 @@ new_rd_SymConst (dbg_info* db, ir_graph *irg, ir_node *block, type_or_id_p value ir_node *res; ir_mode *mode; if (symkind == linkage_ptr_info) - mode = mode_p; + mode = mode_P; else - mode = mode_I; + mode = mode_Iu; res = new_ir_node (db, irg, block, op_SymConst, mode, 0, in); res->attr.i.num = symkind; @@ -1299,7 +1299,7 @@ get_r_value_internal (ir_node *block, int pos, ir_mode *mode) /* Error Message */ printf("Error: no value set. Use of undefined variable. Initializing to zero.\n"); - assert (mode->code >= irm_f && mode->code <= irm_p); + assert (mode->code >= irm_F && mode->code <= irm_P); res = new_rd_Const (NULL, current_ir_graph, block, mode, tarval_mode_null[mode->code]); } @@ -1629,7 +1629,7 @@ get_r_value_internal (ir_node *block, int pos, ir_mode *mode) /* Error Message */ printf("Error: no value set. Use of undefined variable. Initializing to zero.\n"); - assert (mode->code >= irm_f && mode->code <= irm_p); + assert (mode->code >= irm_F && mode->code <= irm_P); res = new_rd_Const (NULL, current_ir_graph, block, mode, tarval_mode_null[mode->code]); } @@ -1720,7 +1720,7 @@ ir_node * new_d_defaultProj (dbg_info* db, ir_node *arg, long max_proj) { ir_node *res; - assert((arg->op==op_Cond) && (get_irn_mode(arg->in[1]) == mode_I)); + assert((arg->op==op_Cond) && (get_irn_mode(arg->in[1]) == mode_Iu)); arg->attr.c.kind = fragmentary; arg->attr.c.default_proj = max_proj; res = new_Proj (arg, mode_X, max_proj); @@ -2094,7 +2094,7 @@ ir_node *new_d_immBlock (dbg_info* db) { assert(get_irg_phase_state (current_ir_graph) == phase_building); /* creates a new dynamic in-array as length of in is -1 */ - res = new_ir_node (db, current_ir_graph, NULL, op_Block, mode_R, -1, NULL); + res = new_ir_node (db, current_ir_graph, NULL, op_Block, mode_BB, -1, NULL); current_ir_graph->current_block = res; res->attr.block.matured = 0; res->attr.block.exc = exc_normal; diff --git a/ir/ir/ircons.h b/ir/ir/ircons.h index e9d01d483..13dbadd33 100644 --- a/ir/ir/ircons.h +++ b/ir/ir/ircons.h @@ -298,11 +298,11 @@ * add_in_edge(this_block, cf_pred1); * add_in_edge(this_block, cf_pred2); * mature_block(this_block); - * a_val = get_value(42, mode_I); + * a_val = get_value(42, mode_Iu); * mem = get_store(); * div = new_Div(mem, a_val, a_val); * mem = new_Proj(div, mode_M, 0); * for the numbers for Proj see docu * - * res = new_Proj(div, mode_I, 2); + * res = new_Proj(div, mode_Iu, 2); * set_store(mem); * set_value(res, 42); * cf_op = new_Jmp(); @@ -595,7 +595,7 @@ * datastructure don't use * new_SymConst((type_or_id*)get_entity_ld_ident(ent), linkage_ptr_info);. * Use a real const instead: - * new_Const(mode_p, tarval_p_from_entity(ent)); + * new_Const(mode_P, tarval_p_from_entity(ent)); * This makes the Constant independent of name changes of the entity due to * mangling. * @@ -616,10 +616,10 @@ * - size * - linkage_ptr_info * If the attr.i.num is type_tag or size, the node contains an attribute - * attr.i.*type, a pointer to a type_class. The mode of the node is mode_i. + * attr.i.*type, a pointer to a type_class. The mode of the node is mode_Is. * if it is linkage_ptr_info it contains * attr.i.*ptrinfo, an ident holding information for the linker. The mode - * of the node is mode_p. + * of the node is mode_P. * * THE SELECT NODE * --------------- diff --git a/ir/ir/irdump.c b/ir/ir/irdump.c index 0416053bd..540645f27 100644 --- a/ir/ir/irdump.c +++ b/ir/ir/irdump.c @@ -531,7 +531,7 @@ void print_edge_vcgattr(ir_node *from, int to) { case iro_Start: break; case iro_End: if (to >= 0) { - if (get_irn_mode(get_End_keepalive(from, to)) == mode_R) + if (get_irn_mode(get_End_keepalive(from, to)) == mode_BB) xfprintf (F, CF_EDGE_ATTR); if (get_irn_mode(get_End_keepalive(from, to)) == mode_X) xfprintf (F, MEM_EDGE_ATTR); diff --git a/ir/ir/irgopt.c b/ir/ir/irgopt.c index c76250756..e13aff300 100644 --- a/ir/ir/irgopt.c +++ b/ir/ir/irgopt.c @@ -727,8 +727,8 @@ static void collect_calls(ir_node *call, void *env) { 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 (tv->u.P.ent) { + called_irg = get_entity_irg(tv->u.P.ent); if (called_irg && pos < MAX_INLINE) { /* The Call node calls a locally defined method. Remember to inline. */ calls[pos] = call; @@ -771,7 +771,7 @@ void inline_small_irgs(ir_graph *irg, int size) { 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(tv->u.P.ent); if ((_obstack_memory_used(callee->obst) - obstack_room(callee->obst)) < size) { inline_method(calls[i], callee); } diff --git a/ir/ir/irgraph.c b/ir/ir/irgraph.c index 7ffd10ac5..710b900f2 100644 --- a/ir/ir/irgraph.c +++ b/ir/ir/irgraph.c @@ -124,8 +124,8 @@ new_ir_graph (entity *ent, int n_loc) /* Proj results of start node */ projX = new_Proj (res->start, mode_X, pns_initial_exec); set_store (new_Proj (res->start, mode_M, pns_global_store)); - res->frame = new_Proj (res->start, mode_p, pns_frame_base); - res->globals = new_Proj (res->start, mode_p, pns_globals); + res->frame = new_Proj (res->start, mode_P, pns_frame_base); + res->globals = new_Proj (res->start, mode_P, pns_globals); res->args = new_Proj (res->start, mode_T, pns_args); add_in_edge(res->start_block, projX); diff --git a/ir/ir/irmode.c b/ir/ir/irmode.c index aaa58cb93..54e89171c 100644 --- a/ir/ir/irmode.c +++ b/ir/ir/irmode.c @@ -18,46 +18,42 @@ # include "tv.h" ir_mode *mode_T; -ir_mode *mode_f; -ir_mode *mode_d; -ir_mode *mode_c; +ir_mode *mode_F; +ir_mode *mode_D; +ir_mode *mode_E; +ir_mode *mode_Bs; +ir_mode *mode_Bu; +ir_mode *mode_Hs; +ir_mode *mode_Hu; +ir_mode *mode_Is; +ir_mode *mode_Iu; +ir_mode *mode_Ls; +ir_mode *mode_Lu; ir_mode *mode_C; -ir_mode *mode_h; -ir_mode *mode_H; -ir_mode *mode_i; -ir_mode *mode_I; -ir_mode *mode_l; -ir_mode *mode_L; -ir_mode *mode_B; ir_mode *mode_b; -ir_mode *mode_p; -ir_mode *mode_s; -ir_mode *mode_S; +ir_mode *mode_P; ir_mode *mode_X; ir_mode *mode_M; -ir_mode *mode_R; -ir_mode *mode_Z; +ir_mode *mode_BB; INLINE ir_mode *get_modeT() { return mode_T; } -INLINE ir_mode *get_modef() { return mode_f; } -INLINE ir_mode *get_moded() { return mode_d; } -INLINE ir_mode *get_modec() { return mode_c; } +INLINE ir_mode *get_modeF() { return mode_F; } +INLINE ir_mode *get_modeD() { return mode_D; } +INLINE ir_mode *get_modeE() { return mode_E; } +INLINE ir_mode *get_modeBs() { return mode_Bs; } +INLINE ir_mode *get_modeBu() { return mode_Bu; } +INLINE ir_mode *get_modeHs() { return mode_Hs; } +INLINE ir_mode *get_modeHu() { return mode_Hu; } +INLINE ir_mode *get_modeIs() { return mode_Is; } +INLINE ir_mode *get_modeIu() { return mode_Iu; } +INLINE ir_mode *get_modeLs() { return mode_Ls; } +INLINE ir_mode *get_modeLu() { return mode_Lu; } INLINE ir_mode *get_modeC() { return mode_C; } -INLINE ir_mode *get_modeh() { return mode_h; } -INLINE ir_mode *get_modeH() { return mode_H; } -INLINE ir_mode *get_modei() { return mode_i; } -INLINE ir_mode *get_modeI() { return mode_I; } -INLINE ir_mode *get_model() { return mode_l; } -INLINE ir_mode *get_modeL() { return mode_L; } -INLINE ir_mode *get_modeB() { return mode_B; } -INLINE ir_mode *get_modep() { return mode_b; } -INLINE ir_mode *get_modeb() { return mode_p; } -INLINE ir_mode *get_modes() { return mode_s; } -INLINE ir_mode *get_modeS() { return mode_S; } +INLINE ir_mode *get_modeb() { return mode_b; } +INLINE ir_mode *get_modeP() { return mode_P; } INLINE ir_mode *get_modeX() { return mode_X; } INLINE ir_mode *get_modeM() { return mode_M; } -INLINE ir_mode *get_modeR() { return mode_R; } -INLINE ir_mode *get_modeZ() { return mode_Z; } +INLINE ir_mode *get_modeBB() { return mode_BB; } void init_mode (void) @@ -65,47 +61,43 @@ init_mode (void) /* allocate all modes. We need to memset them as tarval_vrfy reads fields before they are initialized: It compares to min/max when tarvals for min/max are allocated! */ - mode_T = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_T, 0, sizeof(ir_mode)); - mode_f = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_f, 0, sizeof(ir_mode)); - mode_d = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_d, 0, sizeof(ir_mode)); - mode_c = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_c, 0, sizeof(ir_mode)); - mode_C = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_C, 0, sizeof(ir_mode)); - mode_h = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_h, 0, sizeof(ir_mode)); - mode_H = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_H, 0, sizeof(ir_mode)); - mode_i = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_i, 0, sizeof(ir_mode)); - mode_I = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_I, 0, sizeof(ir_mode)); - mode_l = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_l, 0, sizeof(ir_mode)); - mode_L = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_L, 0, sizeof(ir_mode)); - mode_B = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_B, 0, sizeof(ir_mode)); - mode_b = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_b, 0, sizeof(ir_mode)); - mode_p = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_p, 0, sizeof(ir_mode)); - mode_s = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_s, 0, sizeof(ir_mode)); - mode_S = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_S, 0, sizeof(ir_mode)); - mode_X = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_X, 0, sizeof(ir_mode)); - mode_M = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_M, 0, sizeof(ir_mode)); - mode_R = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_R, 0, sizeof(ir_mode)); - mode_Z = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_Z, 0, sizeof(ir_mode)); + mode_T = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_T, 0, sizeof(ir_mode)); + mode_F = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_F, 0, sizeof(ir_mode)); + mode_D = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_D, 0, sizeof(ir_mode)); + mode_E = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_E, 0, sizeof(ir_mode)); + mode_Bs = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_Bs, 0, sizeof(ir_mode)); + mode_Bu = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_Bu, 0, sizeof(ir_mode)); + mode_Hs = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_Hs, 0, sizeof(ir_mode)); + mode_Hu = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_Hu, 0, sizeof(ir_mode)); + mode_Is = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_Is, 0, sizeof(ir_mode)); + mode_Iu = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_Iu, 0, sizeof(ir_mode)); + mode_Ls = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_Ls, 0, sizeof(ir_mode)); + mode_Lu = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_Lu, 0, sizeof(ir_mode)); + mode_C = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_C, 0, sizeof(ir_mode)); + mode_b = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_b, 0, sizeof(ir_mode)); + mode_P = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_P, 0, sizeof(ir_mode)); + mode_X = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_X, 0, sizeof(ir_mode)); + mode_M = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_M, 0, sizeof(ir_mode)); + mode_BB = (ir_mode *) malloc (sizeof (ir_mode)); memset(mode_BB, 0, sizeof(ir_mode)); mode_T->code = irm_T; - mode_f->code = irm_f; - mode_d->code = irm_d; - mode_c->code = irm_c; + mode_F->code = irm_F; + mode_D->code = irm_D; + mode_E->code = irm_E; + mode_Bs->code = irm_Bs; + mode_Bu->code = irm_Bu; + mode_Hs->code = irm_Hs; + mode_Hu->code = irm_Hu; + mode_Is->code = irm_Is; + mode_Iu->code = irm_Iu; + mode_Ls->code = irm_Ls; + mode_Lu->code = irm_Lu; mode_C->code = irm_C; - mode_h->code = irm_h; - mode_H->code = irm_H; - mode_i->code = irm_i; - mode_I->code = irm_I; - mode_l->code = irm_l; - mode_L->code = irm_L; - mode_B->code = irm_B; mode_b->code = irm_b; - mode_p->code = irm_p; - mode_s->code = irm_s; - mode_S->code = irm_S; + mode_P->code = irm_P; mode_X->code = irm_X; mode_M->code = irm_M; - mode_R->code = irm_R; - mode_Z->code = irm_Z; + mode_BB->code = irm_BB; /* initialize all modes */ @@ -114,103 +106,115 @@ init_mode (void) mode_T->ffloat = 0; /* float */ - mode_f->name = id_from_str ("f", 1); - mode_f->fsigned = 1; - mode_f->ffloat = 1; - mode_f->ld_align = 4; - mode_f->size = 4; + mode_F->name = id_from_str ("F", 1); + mode_F->fsigned = 1; + mode_F->ffloat = 1; + mode_F->ld_align = 4; + mode_F->size = 4; /* double */ - mode_d->name = id_from_str ("d", 1); - mode_d->fsigned = 1; - mode_d->ffloat = 1; - mode_d->ld_align = 4; - mode_d->size = 8; - - /* signed char */ - mode_c->name = id_from_str ("c", 1); - mode_c->fsigned = 1; - mode_c->ffloat = 0; - mode_c->ld_align = 1; - mode_c->size = 1; - mode_c->min = tarval_from_long (mode_l, 0xffffff80); - mode_c->max = tarval_from_long (mode_l, 0x0000007f); - mode_c->null = tarval_from_long (mode_c, 0); - - /* unsigned char */ - mode_C->name = id_from_str ("C", 1); - mode_C->fsigned = 0; - mode_C->ffloat = 0; - mode_C->ld_align = 1; - mode_C->size = 1; - mode_C->min = tarval_from_long (mode_L, 0x00000000); - mode_C->max = tarval_from_long (mode_L, 0x000000ff); - mode_C->null = tarval_from_long (mode_C, 0); + mode_D->name = id_from_str ("D", 1); + mode_D->fsigned = 1; + mode_D->ffloat = 1; + mode_D->ld_align = 4; + mode_D->size = 8; + + /* extended */ + mode_E->name = id_from_str ("E", 1); + mode_E->fsigned = 1; + mode_E->ffloat = 1; + mode_E->ld_align = 4; + mode_E->size = 12; + + /* signed byte */ + mode_Bs->name = id_from_str ("Bs", 1); + mode_Bs->fsigned = 1; + mode_Bs->ffloat = 0; + mode_Bs->ld_align = 1; + mode_Bs->size = 1; + mode_Bs->min = tarval_from_long (mode_Ls, 0xffffff80); + mode_Bs->max = tarval_from_long (mode_Ls, 0x0000007f); + mode_Bs->null = tarval_from_long (mode_Bs, 0); + + /* unsigned byte */ + mode_Bu->name = id_from_str ("Bu", 1); + mode_Bu->fsigned = 0; + mode_Bu->ffloat = 0; + mode_Bu->ld_align = 1; + mode_Bu->size = 1; + mode_Bu->min = tarval_from_long (mode_Lu, 0x00000000); + mode_Bu->max = tarval_from_long (mode_Lu, 0x000000ff); + mode_Bu->null = tarval_from_long (mode_Bu, 0); /* signed short integer */ - mode_h->name = id_from_str ("h", 1); - mode_h->fsigned = 1; - mode_h->ffloat = 0; - mode_h->ld_align = 2; - mode_h->size = 2; - mode_h->min = tarval_from_long (mode_l, 0xffff8000); - mode_h->max = tarval_from_long (mode_l, 0x00007fff); - mode_h->null = tarval_from_long (mode_h, 0); - - /* unsigened short integer */ - mode_H->name = id_from_str ("H", 1); - mode_H->fsigned = 0; - mode_H->ffloat = 0; - mode_H->ld_align = 2; - mode_H->size = 2; - mode_H->min = tarval_from_long (mode_L, 0x00000000); - mode_H->max = tarval_from_long (mode_L, 0x0000ffff); - mode_H->null = tarval_from_long (mode_H, 0); + mode_Hs->name = id_from_str ("Hs", 1); + mode_Hs->fsigned = 1; + mode_Hs->ffloat = 0; + mode_Hs->ld_align = 2; + mode_Hs->size = 2; + mode_Hs->min = tarval_from_long (mode_Ls, 0xffff8000); + mode_Hs->max = tarval_from_long (mode_Ls, 0x00007fff); + mode_Hs->null = tarval_from_long (mode_Hs, 0); + + /* unsigned short integer */ + mode_Hu->name = id_from_str ("Hu", 1); + mode_Hu->fsigned = 0; + mode_Hu->ffloat = 0; + mode_Hu->ld_align = 2; + mode_Hu->size = 2; + mode_Hu->min = tarval_from_long (mode_Lu, 0x00000000); + mode_Hu->max = tarval_from_long (mode_Lu, 0x0000ffff); + mode_Hu->null = tarval_from_long (mode_Hu, 0); /* signed integer */ - mode_i->name = id_from_str ("i", 1); - mode_i->fsigned = 1; - mode_i->ffloat = 0; - mode_i->ld_align = 4; - mode_i->size = 4; - mode_i->min = tarval_from_long (mode_l, 0x80000000); - mode_i->max = tarval_from_long (mode_l, 0x7fffffff); - mode_i->null = tarval_from_long (mode_i, 0); + mode_Is->name = id_from_str ("Is", 1); + mode_Is->fsigned = 1; + mode_Is->ffloat = 0; + mode_Is->ld_align = 4; + mode_Is->size = 4; + mode_Is->min = tarval_from_long (mode_Ls, 0x80000000); + mode_Is->max = tarval_from_long (mode_Ls, 0x7fffffff); + mode_Is->null = tarval_from_long (mode_Is, 0); /* unsigned integer */ - mode_I->name = id_from_str ("I", 1); - mode_I->fsigned = 0; - mode_I->ffloat = 0; - mode_I->ld_align = 4; - mode_I->size = 4; - mode_I->min = tarval_from_long (mode_L, 0x00000000); - mode_I->max = tarval_from_long (mode_L, 0xffffffff); - mode_I->null = tarval_from_long (mode_I, 0); + mode_Iu->name = id_from_str ("Iu", 1); + mode_Iu->fsigned = 0; + mode_Iu->ffloat = 0; + mode_Iu->ld_align = 4; + mode_Iu->size = 4; + mode_Iu->min = tarval_from_long (mode_Lu, 0x00000000); + mode_Iu->max = tarval_from_long (mode_Lu, 0xffffffff); + mode_Iu->null = tarval_from_long (mode_Iu, 0); /* signed long integer */ - mode_l->name = id_from_str ("l", 1); - mode_l->fsigned = 1; - mode_l->ffloat = 0; - mode_l->ld_align = 4; - mode_l->size = 4; - mode_l->min = tarval_from_long (mode_l, 0x80000000); - mode_l->max = tarval_from_long (mode_l, 0x7fffffff); - mode_I->null = tarval_from_long (mode_l, 0); + mode_Ls->name = id_from_str ("Ls", 1); + mode_Ls->fsigned = 1; + mode_Ls->ffloat = 0; + mode_Ls->ld_align = 8; + mode_Ls->size = 8; + mode_Ls->min = tarval_from_long (mode_Ls, 0x80000000); + mode_Ls->max = tarval_from_long (mode_Ls, 0x7fffffff); + mode_Ls->null = tarval_from_long (mode_Ls, 0); /* unsigned long integer */ - mode_L->name = id_from_str ("L", 1); - mode_L->fsigned = 0; - mode_L->ffloat = 0; - mode_L->ld_align = 4; - mode_L->size = 4; - mode_L->min = tarval_from_long (mode_L, 0x00000000); - mode_L->max = tarval_from_long (mode_L, 0xffffffff); - mode_L->null = tarval_from_long (mode_L, 0); - - /* universal bits */ - mode_B->name = id_from_str ("B", 1); - mode_B->fsigned = 0; - mode_B->ffloat = 0; + mode_Lu->name = id_from_str ("Lu", 1); + mode_Lu->fsigned = 0; + mode_Lu->ffloat = 0; + mode_Lu->ld_align = 8; + mode_Lu->size = 8; + mode_Lu->min = tarval_from_long (mode_Lu, 0x00000000); + mode_Lu->max = tarval_from_long (mode_Lu, 0xffffffff); + mode_Lu->null = tarval_from_long (mode_Lu, 0); + + /* character */ + mode_C->name = id_from_str ("C", 1); + mode_C->fsigned = 0; + mode_C->ffloat = 0; + mode_C->ld_align = 1; + mode_C->size = 1; + mode_C->min = tarval_from_long (mode_Ls, 0xffffff80); + mode_C->max = tarval_from_long (mode_Ls, 0x0000007f); + mode_C->null = tarval_from_long (mode_C, 0); /* boolean */ mode_b->name = id_from_str ("b", 1); @@ -218,22 +222,14 @@ init_mode (void) mode_b->ffloat = 0; /* pointer */ - mode_p->name = id_from_str ("p", 1); - mode_p->fsigned = 0; - mode_p->ffloat = 0; - mode_p->ld_align = 4; - mode_p->size = 4; - mode_p->min = tarval_from_long (mode_L, 0x00000000); - mode_p->max = tarval_from_long (mode_L, 0xffffffff); - mode_p->null = tarval_from_long (mode_p, 0); - - mode_s->name = id_from_str ("s", 1); - mode_s->fsigned = 0; - mode_s->ffloat = 0; - - mode_S->name = id_from_str ("S", 1); - mode_S->fsigned = 0; - mode_S->ffloat = 0; + mode_P->name = id_from_str ("P", 1); + mode_P->fsigned = 0; + mode_P->ffloat = 0; + mode_P->ld_align = 4; + mode_P->size = 4; + mode_P->min = tarval_from_long (mode_Lu, 0x00000000); + mode_P->max = tarval_from_long (mode_Lu, 0xffffffff); + mode_P->null = tarval_from_long (mode_P, 0); /* Execution */ mode_X->name = id_from_str ("X", 1); @@ -245,13 +241,9 @@ init_mode (void) mode_M->fsigned = 0; mode_M->ffloat = 0; - mode_R->name = id_from_str ("R", 1); - mode_R->fsigned = 0; - mode_R->ffloat = 0; - - mode_Z->name = id_from_str ("Z", 1); - mode_Z->fsigned = 1; - mode_Z->ffloat = 0; + mode_BB->name = id_from_str ("BB", 1); + mode_BB->fsigned = 0; + mode_BB->ffloat = 0; } /* Functions for the direct access to all attributes od a ir_mode */ @@ -394,34 +386,34 @@ set_mode_ffloat (ir_mode *mode, unsigned ffloat) The set of "float" is defined as: --------------------------------- - float = {irm_f, irm_d} + float = {irm_F, irm_D, irm_E} The set of "int" is defined as: ------------------------------- - int = {irm_c, irm_C, irm_h, irm_H, irm_i, irm_I, irm_l, irm_L} + int = {irm_Bs, irm_Bu, irm_Hs, irm_Hu, irm_Is, irm_Iu, irm_Ls, irm_Lu} The set of "num" is defined as: ------------------------------- - num = {irm_f, irm_d, irm_c, irm_C, irm_h, irm_H, - irm_i, irm_I, irm_l, irm_L} + num = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu, + irm_Is, irm_Iu, irm_Ls, irm_Lu} = {float || int} The set of "data" is defined as: ------------------------------- - data = {irm_f, irm_d, irm_c, irm_C, irm_h, irm_H, - irm_i, irm_I, irm_l, irm_L, irm_p} - = {num || irm_p} + data = {irm_F, irm_D, irm_E irm_Bs, irm_Bu, irm_Hs, irm_Hu, + irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_p} + = {num || irm_C || irm_P} The set of "datab" is defined as: --------------------------------- - datab = {irm_f, irm_d, irm_c, irm_C, irm_h, irm_H, - irm_i, irm_I, irm_l, irm_L, irm_p, irm_b, irm_B} - = {data || irm_b || irm_B} + datab = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu, + irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_C, irm_P, irm_b} + = {data || irm_b } The set of "dataM" is defined as: --------------------------------- - dataM = {irm_f, irm_d, irm_c, irm_C, irm_h, irm_H, irm_i, - irm_I, irm_l, irm_L, irm_p, irm_M} + dataM = {irm_F, irm_D, irm_E, irm_Bs, irm_Bu, irm_Hs, irm_Hu, + irm_Is, irm_Iu, irm_Ls, irm_Lu, irm_P, irm_M} = {data || irm_M} */ @@ -462,7 +454,7 @@ mode_is_int (ir_mode *mode) int res; modecode code; code = get_mode_modecode (mode); - if ((code >= irm_c) && (code <= irm_L)) { + if ((code >= irm_Bs) && (code <= irm_Lu)) { res = 1; } else { @@ -491,7 +483,7 @@ mode_is_data (ir_mode *mode) int res; modecode code; code = get_mode_modecode (mode); - if (mode_is_num (mode) || code == irm_p) { + if (mode_is_num (mode) || code == irm_C || code == irm_P) { res = 1; } else { @@ -506,7 +498,7 @@ mode_is_datab (ir_mode *mode) int res; modecode code; code = get_mode_modecode (mode); - if (mode_is_data (mode) || code == irm_b || code == irm_B) { + if (mode_is_data (mode) || code == irm_b ) { res = 1; } else { diff --git a/ir/ir/irmode.h b/ir/ir/irmode.h index e6b6a0c61..4e7f6851f 100644 --- a/ir/ir/irmode.h +++ b/ir/ir/irmode.h @@ -32,73 +32,59 @@ typedef struct tarval tarval; #endif typedef enum { /* irm is short for `ir mode' */ - irm_T, /* former irm_N */ - irm_f, irm_d, /* 1, 2 */ - irm_c, irm_C, irm_h, irm_H, irm_i, irm_I, irm_l, irm_L, /* 3 .. 10 */ - irm_B, irm_b, /* 11, 12 */ - irm_p, - irm_s, irm_S, /* 14, 15 */ - irm_X, irm_M, irm_R, irm_Z, - irm_max - /* according to tech report 1999-14: + /* according to tech report 1999-14: */ irm_BB, irm_X, // basic block, execution - irm_F, irm_D, irm_E, // float, double, extended - irm_B, irm_Bu, irm_H, irm_Hu, irm_I, irm_Iu, irm_L, irm_Lu, + irm_F, irm_D, irm_E, // float(32), double(64), extended(80) + irm_Bs, irm_Bu, irm_Hs, irm_Hu, irm_Is, irm_Iu, irm_Ls, irm_Lu, // byte(8), short(16), int(32), long(64) irm_C, // character irm_P, // pointer irm_b, // internal boolean irm_M, // memory irm_T, // tuple - irm_max */ + irm_max } modecode; typedef struct ir_mode ir_mode; -extern ir_mode *mode_T; /* tuple (none) */ -extern ir_mode *mode_f; /* signed float */ -extern ir_mode *mode_d; /* signed double */ -/* extern ir_mode *mode_e; * signed extended */ -extern ir_mode *mode_c; /* signed byte (former char) */ -extern ir_mode *mode_C; /* unsigned byte (former char) */ -extern ir_mode *mode_h; /* signed short integer */ -extern ir_mode *mode_H; /* unsigened short integer */ -extern ir_mode *mode_i; /* signed integer */ -extern ir_mode *mode_I; /* unsigned integer */ -extern ir_mode *mode_l; /* signed long integer */ -extern ir_mode *mode_L; /* unsigned long integer */ -extern ir_mode *mode_B; /* bits */ /* oblivious */ -/* extern ir_mode *mode_c; * char */ -extern ir_mode *mode_p; /* pointer */ -extern ir_mode *mode_b; /* internal boolean */ -extern ir_mode *mode_s; /* oblivious */ -extern ir_mode *mode_S; /* oblivious */ -extern ir_mode *mode_X; /* execution */ -extern ir_mode *mode_M; /* memory */ -extern ir_mode *mode_R; /* block */ -extern ir_mode *mode_Z; /* infinit integers */ /* oblivious */ +extern ir_mode *mode_T; /* tuple (none) */ +extern ir_mode *mode_F; /* signed float(32) */ +extern ir_mode *mode_D; /* signed double(64) */ +extern ir_mode *mode_E; /* signed extended(80) */ +extern ir_mode *mode_Bs; /* signed byte (former char) */ +extern ir_mode *mode_Bu; /* unsigned byte (former char) */ +extern ir_mode *mode_Hs; /* signed short integer */ +extern ir_mode *mode_Hu; /* unsigened short integer */ +extern ir_mode *mode_Is; /* signed integer */ +extern ir_mode *mode_Iu; /* unsigned integer */ +extern ir_mode *mode_Ls; /* signed long integer */ +extern ir_mode *mode_Lu; /* unsigned long integer */ +extern ir_mode *mode_C; /* char */ +extern ir_mode *mode_P; /* pointer */ +extern ir_mode *mode_b; /* internal boolean */ +extern ir_mode *mode_X; /* execution */ +extern ir_mode *mode_M; /* memory */ +extern ir_mode *mode_BB; /* block */ /* Access routines for JNI Interface */ ir_mode *get_modeT(); -ir_mode *get_modef(); -ir_mode *get_moded(); -ir_mode *get_modec(); +ir_mode *get_modeF(); +ir_mode *get_modeD(); +ir_mode *get_modeE(); +ir_mode *get_modeBs(); +ir_mode *get_modeBu(); +ir_mode *get_modeHs(); +ir_mode *get_modeHu(); +ir_mode *get_modeIs(); +ir_mode *get_modeIu(); +ir_mode *get_modeLs(); +ir_mode *get_modeLu(); ir_mode *get_modeC(); -ir_mode *get_modeh(); -ir_mode *get_modeH(); -ir_mode *get_modei(); -ir_mode *get_modeI(); -ir_mode *get_model(); -ir_mode *get_modeL(); -ir_mode *get_modeB(); -ir_mode *get_modep(); +ir_mode *get_modeP(); ir_mode *get_modeb(); -ir_mode *get_modes(); -ir_mode *get_modeS(); ir_mode *get_modeX(); ir_mode *get_modeM(); -ir_mode *get_modeR(); -ir_mode *get_modeZ(); +ir_mode *get_modeBB(); /* An enum for this mode */ modecode get_mode_modecode (ir_mode *mode); diff --git a/ir/ir/iropt.c b/ir/ir/iropt.c index 8150b4496..fceccdb3e 100644 --- a/ir/ir/iropt.c +++ b/ir/ir/iropt.c @@ -77,17 +77,17 @@ computed_value (ir_node *n) case iro_SymConst: if ((get_SymConst_kind(n) == size) && (get_type_state(get_SymConst_type(n))) == layout_fixed) - res = tarval_from_long (mode_i, get_type_size(get_SymConst_type(n))); + res = tarval_from_long (mode_Is, get_type_size(get_SymConst_type(n))); break; case iro_Add: if (ta && tb && (get_irn_mode(a) == get_irn_mode(b)) - && (get_irn_mode(a) != mode_p)) { + && (get_irn_mode(a) != mode_P)) { 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)) { + && (get_irn_mode(a) != mode_P)) { res = tarval_sub (ta, tb); } else if (a == b) { res = tarval_mode_null [get_irn_modecode (n)]; @@ -209,23 +209,23 @@ computed_value (ir_node *n) ir_node *aba = skip_nop(skip_Proj(ab)); if ( ( (/* aa is ProjP and aaa is Alloc */ (get_irn_op(aa) == op_Proj) - && (get_irn_mode(aa) == mode_p) + && (get_irn_mode(aa) == mode_P) && (get_irn_op(aaa) == op_Alloc)) && ( (/* ab is constant void */ (get_irn_op(ab) == op_Const) - && (get_irn_mode(ab) == mode_p) - && (get_Const_tarval(ab) == tarval_p_void)) + && (get_irn_mode(ab) == mode_P) + && (get_Const_tarval(ab) == tarval_P_void)) || (/* ab is other Alloc */ (get_irn_op(ab) == op_Proj) - && (get_irn_mode(ab) == mode_p) + && (get_irn_mode(ab) == mode_P) && (get_irn_op(aba) == op_Alloc) && (aaa != aba)))) || (/* 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_irn_mode(aa) == mode_P) + && (get_Const_tarval(aa) == tarval_P_void) && (get_irn_op(ab) == op_Proj) - && (get_irn_mode(ab) == mode_p) + && (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); @@ -256,8 +256,8 @@ computed_value (ir_node *n) bool different_identity (ir_node *a, ir_node *b) { - assert (get_irn_mode (a) == mode_p - && get_irn_mode (b) == mode_p); + assert (get_irn_mode (a) == mode_P + && get_irn_mode (b) == mode_P); if (get_irn_op (a) == op_Proj && get_irn_op(b) == op_Proj) { ir_node *a1 = get_Proj_pred (a); @@ -706,7 +706,7 @@ transform_node (ir_node *n) /* 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 && - (get_irn_mode(a) == mode_I) && + (get_irn_mode(a) == mode_Iu) && (get_Cond_kind(n) == dense) && (get_opt_unreachable_code())) { /* I don't want to allow Tuples smaller than the biggest Proj. @@ -752,12 +752,12 @@ transform_node (ir_node *n) else set_Proj_proj(n, 0); } else if ((get_irn_op(a) == op_Cond) - && (get_irn_mode(get_Cond_selector(a)) == mode_I) + && (get_irn_mode(get_Cond_selector(a)) == mode_Iu) && value_of(a) && (get_Cond_kind(a) == dense) && (get_opt_unreachable_code())) { /* The Cond is a Switch on a Constant */ - if (get_Proj_proj(n) == tv_val_CHIL(value_of(a))) { + if (get_Proj_proj(n) == tv_val_uInt(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))); diff --git a/ir/ir/irvrfy.c b/ir/ir/irvrfy.c index a3f420f91..5fe17b15a 100644 --- a/ir/ir/irvrfy.c +++ b/ir/ir/irvrfy.c @@ -34,8 +34,8 @@ vrfy_Proj_proj(ir_node *p) { case iro_Start: assert (((proj == 0 && mode == mode_X) || (proj == 1 && mode == mode_M) || - (proj == 2 && mode == mode_p) || - (proj == 3 && mode == mode_p) || + (proj == 2 && mode == mode_P) || + (proj == 3 && mode == mode_P) || (proj == 4 && mode == mode_T)) && "wrong Proj from Start" ); break; @@ -68,15 +68,15 @@ vrfy_Proj_proj(ir_node *p) { case iro_DivMod: assert (((proj == 0 && mode == mode_M) || (proj == 1 && mode == mode_X) || - (proj == 2 && mode == mode_i) || - (proj == 3 && mode == mode_i)) && + (proj == 2 && mode == mode_Is) || + (proj == 3 && mode == mode_Is)) && "wrong Proj from DivMod" ); break; case iro_Div: case iro_Mod: assert (((proj == 0 && mode == mode_M) || (proj == 1 && mode == mode_X) || - (proj == 2 && mode == mode_i)) && + (proj == 2 && mode == mode_Is)) && "wrong Proj from Div or Mod" ); break; case iro_Cmp: @@ -97,7 +97,7 @@ vrfy_Proj_proj(ir_node *p) { case iro_Alloc: assert (((proj == 0 && mode == mode_M) || (proj == 1 /* && mode == mode_X*/) || - (proj == 2 && mode == mode_p)) && + (proj == 2 && mode == mode_P)) && "wrong Proj from Alloc"); break; case iro_Proj: { @@ -192,7 +192,7 @@ irn_vrfy (ir_node *n) /* Cond: BB x b --> X x X */ (op1mode == mode_b /* Cond: BB x Iu --> X^n */ - || op1mode == mode_I) && "Cond node" + || op1mode == mode_Iu) && "Cond node" ); assert (mymode == mode_T); break; @@ -220,7 +220,7 @@ irn_vrfy (ir_node *n) op2mode = get_irn_mode(in[2]); assert ( /* Sel: BB x M x P --> X x M */ - op1mode == mode_M && op2mode == mode_p + op1mode == mode_M && op2mode == mode_P && mymode == mode_T && "Raise node" ); break; @@ -236,7 +236,7 @@ irn_vrfy (ir_node *n) assert ( /* SymConst: BB --> Iu or BB --> P */ - ((mymode == mode_I) || (mymode == mode_p)) && "SymConst node" + ((mymode == mode_Iu) || (mymode == mode_P)) && "SymConst node" ); break; case iro_Sel: @@ -244,11 +244,11 @@ irn_vrfy (ir_node *n) op2mode = get_irn_mode(in[2]); assert ( /* Sel: BB x M x P x Iu^n --> P */ - op1mode == mode_M && op2mode == mode_p - && mymode == mode_p && "Sel node" + op1mode == mode_M && op2mode == mode_P + && mymode == mode_P && "Sel node" ); for (i=3; i < get_irn_arity(n); i++) { - assert (get_irn_mode(in[i]) == mode_I && "Sel node"); } + assert (get_irn_mode(in[i]) == mode_Iu && "Sel node"); } break; case iro_InstOf: assert (mode_T == mymode); @@ -259,7 +259,7 @@ irn_vrfy (ir_node *n) op2mode = get_irn_mode(in[2]); /* Call: BB x M x P x data1 x ... x datan --> M x datan+1 x ... x data n+m */ - assert ( op1mode == mode_M && op2mode == mode_p && "Call node"); /* operand M x P */ + assert ( op1mode == mode_M && op2mode == mode_P && "Call node"); /* operand M x P */ for (i=3; i < get_irn_arity(n); i++) { assert ( mode_is_data(get_irn_mode(in[i])) && "Call node"); /* operand datai */ }; @@ -281,12 +281,12 @@ irn_vrfy (ir_node *n) ((mymode == op1mode && mymode == op2mode && mode_is_num(mymode)) || /* Pointer Add: BB x P x Is --> P */ - (op1mode == mode_p && op2mode == mode_i && mymode == mode_p) + (op1mode == mode_P && op2mode == mode_Is && mymode == mode_P) || /* Pointer Add: BB x Is x P --> P */ - (op1mode == mode_i && op2mode == mode_p && mymode == mode_p)) + (op1mode == mode_Is && op2mode == mode_P && mymode == mode_P)) && "Add node" ); - if (op1mode == mode_p || op2mode == mode_p) { + if (op1mode == mode_P || op2mode == mode_P) { /* BB x P x Is --> P or BB x Is x P --> P */ op_is_symmetric = 0; /* ArmRoq */ } else { @@ -302,16 +302,16 @@ irn_vrfy (ir_node *n) ((mymode ==op1mode && mymode == op2mode && mode_is_num(op1mode)) || /* Pointer Sub: BB x P x Is --> P */ - (op1mode == mode_p && op2mode == mode_i && mymode == mode_p) + (op1mode == mode_P && op2mode == mode_Is && mymode == mode_P) || /* Pointer Sub: BB x Is x P --> P */ - (op1mode == mode_i && op2mode == mode_p && mymode == mode_p) + (op1mode == mode_Is && op2mode == mode_P && mymode == mode_P) || /* Pointer Sub: BB x P x P --> Is */ - (op1mode == mode_p && op2mode == mode_p && mymode == mode_i)) + (op1mode == mode_P && op2mode == mode_P && mymode == mode_Is)) && "Sub node" ); - if (op1mode == mode_p && op2mode == mode_p) { + if (op1mode == mode_P && op2mode == mode_P) { op_is_symmetric = 1; /* ArmRoq */ - } else if (op1mode == mode_p || op2mode == mode_p) { + } else if (op1mode == mode_P || op2mode == mode_P) { op_is_symmetric = 0; /* ArmRoq */ } else { op_is_symmetric = 2; @@ -416,7 +416,7 @@ irn_vrfy (ir_node *n) op2mode = get_irn_mode(in[2]); assert( /* Shl, Shr, Shrs or Rot: BB x int x Iu --> int */ - mode_is_int (op1mode) && op2mode == mode_I + mode_is_int (op1mode) && op2mode == mode_Iu && op1mode == mymode && "Shl, Shr, Shr or Rot node" ); break; @@ -442,7 +442,7 @@ irn_vrfy (ir_node *n) op2mode = get_irn_mode(in[2]); assert( /* Load: BB x M x P --> M x X x data */ - op1mode == mode_M && op2mode == mode_p && "Load node" + op1mode == mode_M && op2mode == mode_P && "Load node" ); assert ( mymode == mode_T && "Load node"); break; @@ -452,7 +452,7 @@ irn_vrfy (ir_node *n) op3mode = get_irn_mode(in[3]); assert( /* Load: BB x M x P x data --> M x X */ - op1mode == mode_M && op2mode == mode_p + op1mode == mode_M && op2mode == mode_P && mode_is_data (op3mode) && "Store node" ); assert(mymode == mode_T && "Store node"); @@ -462,7 +462,7 @@ irn_vrfy (ir_node *n) op2mode = get_irn_mode(in[2]); assert( /* Alloc: BB x M x Iu --> M x X x P */ - op1mode == mode_M && op2mode == mode_I + op1mode == mode_M && op2mode == mode_Iu && mymode == mode_T && "Alloc node" ); break; @@ -472,7 +472,7 @@ irn_vrfy (ir_node *n) op3mode = get_irn_mode(in[3]); assert( /* Free: BB x M x P x Iu --> M */ - op1mode == mode_M && op2mode == mode_p && op3mode == mode_I + op1mode == mode_M && op2mode == mode_P && op3mode == mode_Iu && mymode == mode_M && "Free node" ); break; diff --git a/ir/tr/entity.c b/ir/tr/entity.c index 9e11d054a..a3c4dfb03 100644 --- a/ir/tr/entity.c +++ b/ir/tr/entity.c @@ -79,7 +79,7 @@ new_entity (type *owner, ident *name, type *type) 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, tarval_P_from_entity(res)); current_ir_graph = rem; } else { res->variability = uninitialized; diff --git a/ir/tr/type.c b/ir/tr/type.c index 308852865..9aaab6ad6 100644 --- a/ir/tr/type.c +++ b/ir/tr/type.c @@ -764,9 +764,9 @@ bool is_struct_type(type *strct) { N_param is the number of parameters, n_res the number of results. */ INLINE type *new_type_method (ident *name, int n_param, int n_res) { type *res; - res = new_type(type_method, mode_p, name); + 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); 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; @@ -969,8 +969,8 @@ set_array_bounds_int (type *array, int dimension, int lower_bound, ir_graph *rem = current_ir_graph; current_ir_graph = get_const_code_irg(); set_array_bounds (array, dimension, - new_Const(mode_I, tarval_from_long (mode_I, lower_bound)), - new_Const(mode_I, tarval_from_long (mode_I, upper_bound))); + new_Const(mode_Iu, tarval_from_long (mode_Iu, lower_bound)), + new_Const(mode_Iu, tarval_from_long (mode_Iu, upper_bound))); current_ir_graph = rem; } INLINE void @@ -982,7 +982,7 @@ void set_array_lower_bound_int (type *array, int dimension, int lower_bound) { ir_graph *rem = current_ir_graph; current_ir_graph = get_const_code_irg(); set_array_lower_bound (array, dimension, - new_Const(mode_I, tarval_from_long (mode_I, lower_bound))); + new_Const(mode_Iu, tarval_from_long (mode_Iu, lower_bound))); current_ir_graph = rem; } INLINE void @@ -994,7 +994,7 @@ void set_array_upper_bound_int (type *array, int dimension, int upper_bound) { ir_graph *rem = current_ir_graph; current_ir_graph = get_const_code_irg(); set_array_upper_bound (array, dimension, - new_Const(mode_I, tarval_from_long (mode_I, upper_bound))); + new_Const(mode_Iu, tarval_from_long (mode_Iu, upper_bound))); current_ir_graph = rem; } ir_node * get_array_lower_bound (type *array, int dimension) { @@ -1116,7 +1116,7 @@ bool is_enumeration_type (type *enumeration) { /* Create a new type pointer */ INLINE type *new_type_pointer (ident *name, type *points_to) { type *res; - res = new_type(type_pointer, mode_p, name); + res = new_type(type_pointer, mode_P, name); res->attr.pa.points_to = points_to; res->size = get_mode_size(res->mode); res->state = layout_fixed; @@ -1154,7 +1154,7 @@ bool is_pointer_type (type *pointer) { /* create a new type primitive */ INLINE type *new_type_primitive (ident *name, ir_mode *mode) { type *res; - /* @@@ assert( mode_is_data(mode) && (!mode == mode_p)); */ + /* @@@ assert( mode_is_data(mode) && (!mode == mode_P)); */ res = new_type(type_primitive, mode, name); res->size = get_mode_size(mode); res->state = layout_fixed; diff --git a/ir/tv/tv.c b/ir/tv/tv.c index a58baad63..e3e2170ef 100644 --- a/ir/tv/tv.c +++ b/ir/tv/tv.c @@ -25,9 +25,6 @@ values is cheaper than the extra obstack_alloc()/free() for discarded ones. */ -/* Defining this causes inclusions of functions renamed with new gmp.h */ -#define _TARVAL_GMP_ 0 - #ifdef HAVE_CONFIG_H # include #endif @@ -65,9 +62,9 @@ static pset *tarvals; /* pset containing pointers to _all_ tarvals */ tarval *tarval_bad; tarval *tarval_b_false; tarval *tarval_b_true; -tarval *tarval_d_NaN; -tarval *tarval_d_Inf; -tarval *tarval_p_void; +tarval *tarval_D_NaN; +tarval *tarval_D_Inf; +tarval *tarval_P_void; tarval *tarval_mode_null[irm_max]; tarval *tarval_mode_min[irm_max]; tarval *tarval_mode_max[irm_max]; @@ -75,9 +72,9 @@ tarval *tarval_mode_max[irm_max]; tarval *get_tarval_bad () { return tarval_bad; } tarval *get_tarval_b_false () { return tarval_b_false; } tarval *get_tarval_b_true () { return tarval_b_true; } -tarval *get_tarval_d_NaN () { return tarval_d_NaN; } -tarval *get_tarval_d_Inf () { return tarval_d_Inf; } -tarval *get_tarval_p_void () { return tarval_p_void; } +tarval *get_tarval_D_NaN () { return tarval_D_NaN; } +tarval *get_tarval_D_Inf () { return tarval_D_Inf; } +tarval *get_tarval_P_void () { return tarval_P_void; } tarval *get_tarval_mode_null(ir_mode *mode) { return tarval_mode_null[get_mode_modecode(mode)]; } tarval *get_tarval_mode_min (ir_mode *mode) @@ -87,13 +84,13 @@ tarval *get_tarval_mode_max (ir_mode *mode) # if 0 /* @@@ depends on order of ir_mode */ -static tarval_chil min_chil[8] = { +static tarval_sInt min_sInt[8] = { TARGET_SIMIN (c), 0, TARGET_SIMIN (h), 0, TARGET_SIMIN (i), 0, TARGET_SIMIN (l), 0 }; -static tarval_chil max_chil[8] = { +static tarval_sInt max_sInt[8] = { TARGET_SIMAX (c), TARGET_UIMAX (C), TARGET_SIMAX (h), TARGET_UIMAX (H), TARGET_SIMAX (i), TARGET_UIMAX (I), @@ -102,44 +99,44 @@ static tarval_chil max_chil[8] = { # endif /* Used to be in irmode.h, replaced now. */ -# define is_chilCHIL(m) ((m) <= irm_L && (m) >= irm_c) /* old */ +# define is_Int(m) ((m) <= irm_Lu && (m) >= irm_Bs) /* old */ /* return a mode-specific value */ -tarval_f -tv_val_f (tarval *tv) +tarval_F +tv_val_F (tarval *tv) { - return tv->u.f; + return tv->u.F; } -tarval_d -tv_val_d (tarval *tv) +tarval_D +tv_val_D (tarval *tv) { - return tv->u.d; + return tv->u.D; } -tarval_chil -tv_val_chil (tarval *tv) +tarval_E +tv_val_E (tarval *tv) { - return tv->u.chil; + return tv->u.E; } -tarval_CHIL -tv_val_CHIL (tarval *tv) +tarval_sInt +tv_val_sInt (tarval *tv) { - return tv->u.CHIL; + return tv->u.sInt; } -tarval_Z -tv_val_Z (tarval *tv) +tarval_uInt +tv_val_uInt (tarval *tv) { - return tv->u.Z; + return tv->u.uInt; } -tarval_p -tv_val_p (tarval *tv) +tarval_P +tv_val_P (tarval *tv) { - return tv->u.p; + return tv->u.P; } bool @@ -148,37 +145,25 @@ tv_val_b (tarval *tv) return tv->u.b; } -tarval_B -tv_val_B (tarval *tv) -{ - return tv->u.B; -} - -tarval_s -tv_val_s (tarval *tv) -{ - return tv->u.s; -} - -/* Overflows `chil' signed integral `mode'? */ +/* Overflows `sInt' signed integral `mode'? */ static INLINE bool -chil_overflow (tarval_chil chil, ir_mode *mode) +sInt_overflow (tarval_sInt sInt, ir_mode *mode) { - assert (is_chilCHIL(get_mode_modecode(mode))); + assert (is_Int(get_mode_modecode(mode))); return (get_mode_min(mode) && get_mode_max(mode) /* only valid after firm initialization */ - && (chil < tv_val_chil (get_mode_min(mode)) - || tv_val_chil (get_mode_max(mode)) < chil)); + && (sInt < tv_val_sInt (get_mode_min(mode)) + || tv_val_sInt (get_mode_max(mode)) < sInt)); } -/* Overflows `CHIL' unsigned integral `mode'? */ +/* Overflows `uInt' unsigned integral `mode'? */ static INLINE bool -CHIL_overflow (tarval_CHIL CHIL, ir_mode *mode) +uInt_overflow (tarval_uInt uInt, ir_mode *mode) { - assert (is_chilCHIL(get_mode_modecode(mode))); + assert (is_Int(get_mode_modecode(mode))); return (get_mode_max(mode) /* only valid after firm initialization */ - && tv_val_CHIL (get_mode_max(mode)) < CHIL); + && tv_val_uInt (get_mode_max(mode)) < uInt); } @@ -189,28 +174,23 @@ _tarval_vrfy (const tarval *val) assert (val); switch (get_mode_modecode(val->mode)) { /* floating */ - case irm_f: - case irm_d: + case irm_F: + case irm_D: + case irm_E: break; /* integral */ - case irm_C: case irm_H: case irm_I: case irm_L: - assert (!CHIL_overflow (val->u.CHIL, val->mode)); break; - case irm_c: case irm_h: case irm_i: case irm_l: - assert (!chil_overflow (val->u.chil, val->mode)); break; - case irm_Z: + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + assert (!uInt_overflow (val->u.uInt, val->mode)); break; + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + assert (!sInt_overflow (val->u.sInt, val->mode)); break; + case irm_C: break; - /* strange */ - case irm_p: - if (val->u.p.ent) - assert (val->u.p.ent->kind == k_entity); - assert ( val->u.p.xname || val->u.p.ent - || !tarval_p_void || (val == tarval_p_void)); + case irm_P: + if (val->u.P.ent) + assert (val->u.P.ent->kind == k_entity); + assert ( val->u.P.xname || val->u.P.ent + || !tarval_P_void || (val == tarval_P_void)); break; - case irm_s: - case irm_S: - assert (val->u.s.p); break; - case irm_B: - assert (val->u.B.p); break; case irm_b: assert ((unsigned)val->u.b <= 1); break; default: @@ -265,45 +245,34 @@ tarval_cmp (const void *p, const void *q) switch (get_mode_modecode(a->mode)) { /* floating */ - case irm_f: - return memcmp (&a->u.f, &b->u.f, sizeof (a->u.f)); - case irm_d: - return memcmp (&a->u.d, &b->u.d, sizeof (a->u.d)); + case irm_F: + return memcmp (&a->u.F, &b->u.F, sizeof (a->u.F)); + case irm_D: + return memcmp (&a->u.D, &b->u.D, sizeof (a->u.D)); + case irm_E: + return memcmp (&a->u.E, &b->u.E, sizeof (a->u.E)); /* unsigned */ - case irm_C: case irm_H: case irm_I: case irm_L: - if (sizeof (int) == sizeof (tarval_CHIL)) { - return a->u.CHIL - b->u.CHIL; + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + if (sizeof (int) == sizeof (tarval_uInt)) { + return a->u.uInt - b->u.uInt; } - return a->u.CHIL != b->u.CHIL; + return a->u.uInt != b->u.uInt; /* signed */ - case irm_c: case irm_h: case irm_i: case irm_l: - if (sizeof (int) == sizeof (tarval_chil)) { - return a->u.chil - b->u.chil; + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + if (sizeof (int) == sizeof (tarval_sInt)) { + return a->u.sInt - b->u.sInt; } - return a->u.chil != b->u.chil; - case irm_Z: -#if _TARVAL_GMP_ - return mpz_cmp (&a->u.Z, &b->u.Z); -#else - return 99; /* ?? */ -#endif - /* strange */ - case irm_p: - if (a->u.p.ent || b->u.p.ent) - return (char *)a->u.p.ent - (char *)b->u.p.ent; - if (a->u.p.xname && b->u.p.xname) - return strcmp (a->u.p.xname, b->u.p.xname); - return a->u.p.xname - b->u.p.xname; + return a->u.sInt != b->u.sInt; + case irm_C: + return a->u.C - b->u.C; + case irm_P: + if (a->u.P.ent || b->u.P.ent) + return (char *)a->u.P.ent - (char *)b->u.P.ent; + if (a->u.P.xname && b->u.P.xname) + return strcmp (a->u.P.xname, b->u.P.xname); + return a->u.P.xname - b->u.P.xname; case irm_b: return a->u.b - b->u.b; - case irm_B: - return ( a->u.B.n - b->u.B.n - ? memcmp (a->u.B.p, b->u.B.p, a->u.B.n) - : a->u.B.n - b->u.B.n); - case irm_s: case irm_S: - return ( a->u.s.n == b->u.s.n - ? memcmp (a->u.s.p, b->u.s.p, a->u.s.n) - : a->u.s.n - b->u.s.n); default: assert (0); } } @@ -318,53 +287,50 @@ tarval_hash (tarval *tv) switch (get_mode_modecode(tv->mode)) { case irm_T: h = 0x94b527ce; break; - case irm_f: + case irm_F: /* quick & dirty */ { union { float f; unsigned u; } u; assert (sizeof (float) <= sizeof (unsigned)); - u.u = 0; u.f = tv->u.f; + u.u = 0; u.f = tv->u.F; h ^= u.u; break; } - case irm_d: + case irm_D: /* quick & dirty */ { union { double d; unsigned u[2]; } u; assert (sizeof (double) <= 2*sizeof (unsigned)); - u.u[0] = u.u[1] = 0; u.d = tv->u.d; + u.u[0] = u.u[1] = 0; u.d = tv->u.D; h ^= u.u[0] ^ u.u[1]; break; } - case irm_C: case irm_H: case irm_I: case irm_L: - h ^= tv->u.CHIL; break; - case irm_c: case irm_h: case irm_i: case irm_l: - h ^= tv->u.chil; break; - case irm_Z: -#if _TARVAL_GMP_ - h ^= mpz_get_ui (&tv->u.Z); break; -#else - h ^= (unsigned int) tv; break; /* tut das? */ -#endif - case irm_p: - if (tv->u.p.ent) { + case irm_E: + { union { long double e; unsigned u[3]; } u; + assert (sizeof (long double) <= 3*sizeof (unsigned)); + u.u[0] = u.u[1] = u.u[2] = 0; u.e = tv->u.E; + h ^= u.u[0] ^ u.u[1] ^ u.u[2]; + break; + } + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + h ^= tv->u.uInt; break; + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + h ^= tv->u.sInt; break; + case irm_C: + h ^= tv->u.C; break; + case irm_P: + if (tv->u.P.ent) { /* @@@ lower bits not random, watch for collisions; perhaps replace by tv->u.p.ent - (entity *)0 */ - h ^= ((char *)tv->u.p.ent - (char *)0) / 64; - } else if (tv->u.p.xname) { + h ^= ((char *)tv->u.P.ent - (char *)0) / 64; + } else if (tv->u.P.xname) { /* Of course, strlen() in a hash function is a mistake, but this case should be really rare. */ - h ^= ID_HASH (tv->u.p.xname, strlen (tv->u.p.xname)); + h ^= ID_HASH (tv->u.P.xname, strlen (tv->u.P.xname)); } else { /* void */ h^= 0x2b592b88; } break; case irm_b: h ^= tv->u.b; break; - case irm_B: - h ^= tv->u.B.n; break; /* @@@ not really good */ - case irm_s: - h ^= tv->u.s.p[0]<<12 ^ tv->u.s.p[tv->u.s.n]<<4 ^ tv->u.s.n; break; - case irm_S: - h ^= tv->u.s.p[0]<<4 ^ tv->u.s.p[tv->u.s.n]<<12 ^ tv->u.s.n; break; default: assert(0); } @@ -372,7 +338,6 @@ tarval_hash (tarval *tv) } - /*** ***************** Initialization ************************************* ***/ void @@ -397,7 +362,7 @@ tarval_init_2 (void) assert (sizeof (double) * CHAR_BIT == 64); # if 0 - /* assumed by tarval_chil & friends: */ + /* assumed by tarval_sInt & friends: */ assert ( (irm_C == irm_c+1) && (irm_h == irm_C+1) && (irm_H == irm_h+1) && (irm_i == irm_H+1) && (irm_I == irm_i+1) && (irm_l == irm_I+1) @@ -405,9 +370,9 @@ tarval_init_2 (void) /* assumed everywhere: */ for (i = 0; i <= irm_L-irm_c; i += 2) { - assert ( IS_POW2 (max_chil[i+1]+1) - && (min_chil[i] == -max_chil[i]-1) - && ((tarval_CHIL)max_chil[i+1] == (tarval_CHIL)max_chil[i]-min_chil[i])); + assert ( IS_POW2 (max_sInt[i+1]+1) + && (min_sInt[i] == -max_sInt[i]-1) + && ((tarval_uInt)max_sInt[i+1] == (tarval_uInt)max_sInt[i]-min_sInt[i])); } # endif @@ -421,52 +386,53 @@ tarval_init_2 (void) /* IsInf <-> exponent == 0x7ff && ! (bits | fraction_low) */ tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval)); - tv->mode = mode_d; + tv->mode = mode_D; x.ieee.negative = 0; x.ieee.exponent = 0x7ff; x.ieee.mantissa0 = 0; x.ieee.mantissa1 = 0; - tv->u.d = x.d; - tarval_d_Inf = tarval_identify (tv); + tv->u.D = x.d; + tarval_D_Inf = tarval_identify (tv); /* IsNaN <-> exponent==0x7ff && (qnan_bit | bits | fraction_low) */ tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval)); - tv->mode = mode_d; + tv->mode = mode_D; x.ieee_nan.negative = 0; x.ieee_nan.exponent = 0x7ff; x.ieee_nan.quiet_nan = 1; /* @@@ quiet or signalling? */ x.ieee_nan.mantissa0 = 42; x.ieee_nan.mantissa1 = 0; assert(x.d != x.d /* x.d is NaN */); - tv->u.d = x.d; - tarval_d_NaN = tarval_identify (tv); + tv->u.D = x.d; + tarval_D_NaN = tarval_identify (tv); tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval)); - tv->mode = mode_p; - tv->u.p.xname = NULL; - tv->u.p.ent = NULL; - tv->u.p.tv = NULL; - tarval_p_void = tarval_identify (tv); + tv->mode = mode_P; + tv->u.P.xname = NULL; + tv->u.P.ent = NULL; + tv->u.P.tv = NULL; + tarval_P_void = tarval_identify (tv); tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval)); - tarval_mode_null [irm_f] = tarval_from_long (mode_f, 0); - tarval_mode_null [irm_d] = tarval_from_long (mode_d, 0); - tarval_mode_null [irm_c] = tarval_from_long (mode_c, 0); + tarval_mode_null [irm_F] = tarval_from_long (mode_F, 0); + tarval_mode_null [irm_D] = tarval_from_long (mode_D, 0); + tarval_mode_null [irm_E] = tarval_from_long (mode_E, 0); + tarval_mode_null [irm_Bs] = tarval_from_long (mode_Bs, 0); + tarval_mode_null [irm_Bu] = tarval_from_long (mode_Bu, 0); + tarval_mode_null [irm_Hs] = tarval_from_long (mode_Hs, 0); + tarval_mode_null [irm_Hu] = tarval_from_long (mode_Hu, 0); + tarval_mode_null [irm_Is] = tarval_from_long (mode_Is, 0); + tarval_mode_null [irm_Iu] = tarval_from_long (mode_Iu, 0); + tarval_mode_null [irm_Ls] = tarval_from_long (mode_Ls, 0); + tarval_mode_null [irm_Lu] = tarval_from_long (mode_Lu, 0); tarval_mode_null [irm_C] = tarval_from_long (mode_C, 0); - tarval_mode_null [irm_h] = tarval_from_long (mode_h, 0); - tarval_mode_null [irm_H] = tarval_from_long (mode_H, 0); - tarval_mode_null [irm_i] = tarval_from_long (mode_i, 0); - tarval_mode_null [irm_I] = tarval_from_long (mode_I, 0); - tarval_mode_null [irm_l] = tarval_from_long (mode_l, 0); - tarval_mode_null [irm_L] = tarval_from_long (mode_L, 0); tarval_mode_null [irm_b] = tarval_b_false; - tarval_mode_null [irm_p] = tarval_p_void; + tarval_mode_null [irm_P] = tarval_P_void; } - /*** ********************** Constructors for tarvals ********************** ***/ /* copy from src to dst len chars omitting '_'. */ @@ -484,103 +450,8 @@ stripcpy (char *dst, const char *src, size_t len) return dst; } - tarval * -tarval_Z_from_str (const char *s, size_t len, int base) -{ - tarval *tv; - char *buf; - - assert (!BUILDING); - - buf = alloca (len+1); - stripcpy (buf, s, len); - - tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval)); - tv->mode = mode_Z; -#if _TARVAL_GMP_ - if (mpz_init_set_str (&tv->u.Z, buf, base)) assert (0); -#else - assert(0 && "no support for Z in tv!"); -#endif - - return tarval_identify (tv); -} - - -tarval * -tarval_B_from_str (const char *s, size_t len) -{ - tarval *tv; - size_t n; /* size of B */ - const char *r; /* read ptr */ - unsigned x; /* bit store */ - int b; /* bits in x */ - int shift; /* base shift */ - - assert (!BUILDING); - assert (len >= 3); - - tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval)); - tv->mode = mode_B; - - assert (s[0] == '0'); - switch (s[1]) { - case 'o': - case 'O': shift = 3; break; - case 'x': - case 'X': shift = 4; break; - default: assert(0); - } - - r = s+len; /* set r past input */ - s += 2; /* skip header */ - x = 0; b = 0; n = 0; - while (--r >= s) { - int d; /* digit */ - - if (*r == '_') continue; /* skip _ styropor */ - if (('0' <= *r) && (*r <= '9')) { - d = *r - '0'; - } else if (('a' <= *r) && (*r <= 'f')) { - d = *r - 'a' + 10; - } else { assert (('A' <= *r) && (*r <= 'F')); - d = *r - 'A' + 10; - } - - x |= d << b; /* insert d into x above the b present bits */ - b += shift; /* x now contains shift more bits */ - - if (b >= 8) { /* we've accumulated at least a byte */ - char c = x & 0xFF; /* extract the lower 8 bits from x */ - obstack_grow (&tv_obst, &c, 1); /* and stuff them into B */ - x >>= 8; /* remove the lower 8 bits from x */ - b -= 8; /* x now contains 8 bits fewer */ - ++n; /* B grew a byte */ - } - } - - if (b >= 0) { /* flush the rest of the bits */ - char c = x; /* extract them */ - obstack_grow (&tv_obst, &c, 1); /* and stuff them into B */ - ++n; /* B grew a byte */ - } - - { unsigned char *p = obstack_finish (&tv_obst); - unsigned char *q = p + n; - - tv->u.B.p = p; - tv->u.B.n = n; - /* reverse p in place */ - while (p < q) { char c = *p; *p++ = *q; *q-- = c; } - } - - return tarval_identify (tv); -} - - -tarval * -tarval_f_from_str (const char *s, size_t len) +tarval_F_from_str (const char *s, size_t len) { tarval *tv; char *buf; @@ -592,8 +463,8 @@ tarval_f_from_str (const char *s, size_t len) stripcpy (buf, s, len); tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval)); - tv->mode = mode_f; - tv->u.f = (float)strtod (buf, &eptr); + tv->mode = mode_F; + tv->u.F = (float)strtod (buf, &eptr); assert (eptr == buf+strlen(buf)); return tarval_identify (tv); @@ -601,7 +472,7 @@ tarval_f_from_str (const char *s, size_t len) tarval * -tarval_d_from_str (const char *s, size_t len) +tarval_D_from_str (const char *s, size_t len) { tarval *tv; char *buf; @@ -613,47 +484,16 @@ tarval_d_from_str (const char *s, size_t len) stripcpy (buf, s, len); tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval)); - tv->mode = mode_d; - tv->u.d = strtod (buf, &eptr); + tv->mode = mode_D; + tv->u.D = strtod (buf, &eptr); assert (eptr == buf+strlen(buf)); return tarval_identify (tv); } - -tarval * -tarval_s_from_str (const char *s, size_t len) -{ - tarval *tv; - - assert (!BUILDING); - - tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval)); - - tv->mode = mode_s; - tv->u.s.n = len; - tv->u.s.p = obstack_copy (&tv_obst, s, len); - - return tarval_identify (tv); -} - tarval * -tarval_S_from_str (const char *s, size_t len) +tarval_int_from_str (const char *s, size_t len, int base, ir_mode *m) { - tarval *tv; - - assert (!BUILDING); - - tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval)); - - tv->mode = mode_S; - tv->u.s.n = len; - tv->u.s.p = obstack_copy (&tv_obst, s, len); - - return tarval_identify (tv); -} - -tarval *tarval_int_from_str (const char *s, size_t len, int base, ir_mode *m) { long val; char *eptr; char *buf; @@ -668,7 +508,7 @@ tarval *tarval_int_from_str (const char *s, size_t len, int base, ir_mode *m) { val = strtol(buf, &eptr, base); /* strtoll */ assert (eptr == buf+strlen(buf)); if ((errno == ERANGE) && - ((m == mode_l) || (m == mode_L)) ) { + ((m == mode_Ls) || (m == mode_Lu)) ) { printf("WARNING: Constant %s not representable. Continuing with %ld.\n", s, val); } @@ -676,7 +516,7 @@ tarval *tarval_int_from_str (const char *s, size_t len, int base, ir_mode *m) { return tarval_from_long(m, val); } -/* Create a tarval with mode `m' and value `i' casted to the type that +/* Create a tarval with mode `m' and value `val' casted to the type that represents such tarvals on host. The resulting value must be legal for mode `m'. */ tarval * @@ -693,28 +533,25 @@ tarval_from_long (ir_mode *m, long val) tv->mode = m; switch (get_mode_modecode(m)) { /* floating */ - case irm_f: - tv->u.f = val; break; - case irm_d: - tv->u.d = val; break; + case irm_F: + tv->u.F = val; break; + case irm_D: + tv->u.D = val; break; + case irm_E: + /* @@@ not yet implemented */ + break; /* unsigned */ - case irm_C: case irm_H: case irm_I: case irm_L: - tv->u.CHIL = val; break; + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + tv->u.uInt = val; break; /* signed */ - case irm_c: case irm_h: case irm_i: case irm_l: - tv->u.chil = val; break; - case irm_Z: -#if _TARVAL_GMP_ - mpz_init_set_si (&tv->u.Z, val); -#else - assert(0 && "no support for Z in tv!"); -#endif - break; - /* strange */ - case irm_p: + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + tv->u.sInt = val; break; + case irm_P: assert(!val); obstack_free (&tv_obst, tv); - return tarval_p_void; + return tarval_P_void; + case irm_C: + tv->u.C = val; break; case irm_b: tv->u.b = !!val; /* u.b must be 0 or 1 */ break; @@ -727,7 +564,7 @@ tarval_from_long (ir_mode *m, long val) tarval * -tarval_p_from_str (const char *xname) +tarval_P_from_str (const char *xname) { tarval *tv; @@ -735,16 +572,16 @@ tarval_p_from_str (const char *xname) tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval)); - tv->mode = mode_p; - tv->u.p.xname = obstack_copy0 (&tv_obst, xname, strlen (xname)); - tv->u.p.ent = NULL; - tv->u.p.tv = NULL; + tv->mode = mode_P; + tv->u.P.xname = obstack_copy0 (&tv_obst, xname, strlen (xname)); + tv->u.P.ent = NULL; + tv->u.P.tv = NULL; return tarval_identify (tv); } tarval * -tarval_p_from_entity (entity *ent) +tarval_P_from_entity (entity *ent) { tarval *tv; @@ -752,10 +589,10 @@ tarval_p_from_entity (entity *ent) tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval)); - tv->mode = mode_p; - tv->u.p.xname = NULL; - tv->u.p.ent = ent; - tv->u.p.tv = NULL; + tv->mode = mode_P; + tv->u.P.xname = NULL; + tv->u.P.ent = ent; + tv->u.P.tv = NULL; return tarval_identify (tv); } @@ -763,7 +600,7 @@ tarval_p_from_entity (entity *ent) /* Routines for building a tarval step by step follow. Legal calling sequences: tarval_start() - No contructors except tarval_append() and tarval_append1 () + No constructors except tarval_append() and tarval_append1 () tarval_finish_as() or tarval_cancel() */ /* Begin building a tarval. */ @@ -794,7 +631,7 @@ tarval_append1 (char ch) /* Finish the tarval currently under construction and give id mode `m'. - `m' must be irm_C, irm_B, irm_s or irm_S. + `m' must be irm_Bu, Return NULL if the value does not make sense for this mode, this can only happen in mode C. */ tarval * @@ -806,7 +643,7 @@ tarval_finish_as (ir_mode *m) char ch = 0; /* initialized to shut up gcc */ assert (BUILDING && (size >= 0)); - if (m == mode_C) { + if (m == mode_Bu) { if (size != 1) return tarval_cancel(); p = (unsigned char *)obstack_base (&tv_obst) + sizeof (tarval); ch = *p; @@ -817,20 +654,11 @@ tarval_finish_as (ir_mode *m) tv->mode = m; switch (get_mode_modecode(m)) { - case irm_C: - tv->u.CHIL = ch; + case irm_Bu: + tv->u.uInt = ch; break; - case irm_B: - tv->u.B.n = size; - tv->u.B.p = p; - break; - case irm_s: - case irm_S: - tv->u.s.n = size; - tv->u.s.p = p; - break; - case irm_p: - tv->u.p.tv = NULL; + case irm_P: + tv->u.P.tv = NULL; break; default: assert (0); @@ -850,7 +678,6 @@ tarval_cancel (void) } - /*** ****************** Arithmethic operations on tarvals ***************** ***/ /* Return `src' converted to mode `m' if representable, else NULL. @@ -867,92 +694,44 @@ tarval_convert_to (tarval *src, ir_mode *m) switch (get_mode_modecode(src->mode)) { - case irm_d: - if (m != mode_f) goto fail; - tv->u.f = src->u.d; + case irm_D: + if (m != mode_F) goto fail; + tv->u.F = src->u.D; break; - case irm_Z: -#if _TARVAL_GMP_ + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: switch (get_mode_modecode(m)) { - - case irm_C: case irm_H: case irm_I: case irm_L: - if (mpz_cmp_si (&src->u.Z, 0) < 0) goto fail; - if (mpz_size (&src->u.Z) > 1) goto fail; - tv->u.CHIL = mpz_get_ui (&src->u.Z); - if (CHIL_overflow (tv->u.CHIL, m)) goto fail; + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + tv->u.sInt = src->u.sInt; + if (sInt_overflow (tv->u.sInt, m)) goto fail; break; - case irm_c: case irm_h: case irm_i: case irm_l: - tv->u.chil = mpz_get_si (&src->u.Z); - if (chil_overflow (tv->u.chil, m)) goto fail; - break; - - case irm_b: - tv ->u.b = !mpz_cmp_ui (&src->u.Z, 0); - break; - - case irm_p: - if (mpz_cmp_ui (&src->u.Z, 0)) goto fail; - obstack_free (&tv_obst, tv); - return tarval_p_void; - - default: goto fail; - } -#else - goto fail; -#endif - break; - - case irm_c: case irm_h: case irm_i: case irm_l: - switch (get_mode_modecode(m)) { - case irm_c: case irm_h: case irm_i: case irm_l: - tv->u.chil = src->u.chil; - if (chil_overflow (tv->u.chil, m)) goto fail; - break; - - case irm_C: case irm_H: case irm_I: case irm_L: - tv->u.CHIL = src->u.chil; - if (CHIL_overflow (tv->u.CHIL, m)) goto fail; - break; - - case irm_Z: -#if _TARVAL_GMP_ - mpz_init_set_si (&tv->u.Z, src->u.chil); -#else - goto fail; -#endif + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + tv->u.uInt = src->u.sInt; + if (uInt_overflow (tv->u.uInt, m)) goto fail; break; case irm_b: - tv->u.b = !!src->u.chil; + tv->u.b = !!src->u.sInt; break; default: goto fail; } - case irm_C: case irm_H: case irm_I: case irm_L: + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: switch (get_mode_modecode(m)) { - case irm_c: case irm_h: case irm_i: case irm_l: - tv->u.chil = src->u.CHIL; - if (chil_overflow (tv->u.chil, m)) goto fail; + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + tv->u.sInt = src->u.uInt; + if (sInt_overflow (tv->u.sInt, m)) goto fail; break; - case irm_C: case irm_H: case irm_I: case irm_L: - tv->u.CHIL = src->u.CHIL; - if (CHIL_overflow (tv->u.CHIL, m)) goto fail; - break; - - case irm_Z: -#if _TARVAL_GMP_ - mpz_init_set_ui (&tv->u.Z, src->u.CHIL); -#else - goto fail; -#endif + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + tv->u.uInt = src->u.uInt; + if (uInt_overflow (tv->u.uInt, m)) goto fail; break; case irm_b: - tv->u.b = !!src->u.CHIL; + tv->u.b = !!src->u.uInt; break; default: goto fail; @@ -961,12 +740,12 @@ tarval_convert_to (tarval *src, ir_mode *m) case irm_b: switch (get_mode_modecode(m)) { - case irm_c: case irm_h: case irm_i: case irm_l: - tv->u.chil = src->u.b; + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + tv->u.sInt = src->u.b; break; - case irm_C: case irm_H: case irm_I: case irm_L: - tv->u.CHIL = src->u.b; + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + tv->u.uInt = src->u.b; default: goto fail; } @@ -996,32 +775,21 @@ tarval_neg (tarval *a) switch (get_mode_modecode(a->mode)) { /* floating */ - case irm_f: tv->u.f = -a->u.f; break; - case irm_d: tv->u.d = -a->u.d; break; + case irm_F: tv->u.F = -a->u.F; break; + case irm_D: tv->u.D = -a->u.D; break; /* unsigned */ - case irm_C: case irm_H: case irm_I: case irm_L: - tv->u.CHIL = -a->u.CHIL & tv_val_CHIL (get_mode_max(a->mode)); + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + tv->u.uInt = -a->u.uInt & tv_val_uInt (get_mode_max(a->mode)); break; /* signed */ - case irm_c: case irm_h: case irm_i: case irm_l: - tv->u.chil = -a->u.chil; - if ( chil_overflow (tv->u.chil, a->mode) - || ((tv->u.chil >= 0) == (a->u.chil >= 0))) { + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + tv->u.sInt = -a->u.sInt; + if ( sInt_overflow (tv->u.sInt, a->mode) + || ((tv->u.sInt >= 0) == (a->u.sInt >= 0))) { obstack_free (&tv_obst, tv); return NULL; } break; - case irm_Z: -#if _TARVAL_GMP_ - mpz_init (&tv->u.Z); - mpz_neg (&tv->u.Z, &a->u.Z); -#else - obstack_free (&tv_obst, tv); - tv = a; - printf("\nWrong negation\n\n"); -#endif - break; - /* strange */ case irm_b: tv->u.b = !a->u.b; break; default: assert(0); } @@ -1044,44 +812,36 @@ tarval_comp (tarval *a, tarval *b) switch (get_mode_modecode(a->mode)) { /* floating */ - case irm_f: return ( a->u.f == b->u.f ? irpn_Eq - : a->u.f > b->u.f ? irpn_Gt - : a->u.f < b->u.f ? irpn_Lt + case irm_F: return ( a->u.F == b->u.F ? irpn_Eq + : a->u.F > b->u.F ? irpn_Gt + : a->u.F < b->u.F ? irpn_Lt : irpn_Uo); - case irm_d: return ( a->u.d == b->u.d ? irpn_Eq - : a->u.d > b->u.d ? irpn_Gt - : a->u.d < b->u.d ? irpn_Lt + case irm_D: return ( a->u.D == b->u.D ? irpn_Eq + : a->u.D > b->u.D ? irpn_Gt + : a->u.D < b->u.D ? irpn_Lt : irpn_Uo); + case irm_E: return ( a->u.E == b-> u.E ? irpn_Eq + : a->u.E > b->u.E ? irpn_Gt + : a->u.E < b->u.E ? irpn_Lt + : irpn_Uo); /* unsigned */ - case irm_C: case irm_H: case irm_I: case irm_L: - return ( a->u.CHIL == b->u.CHIL ? irpn_Eq - : a->u.CHIL > b->u.CHIL ? irpn_Gt + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + return ( a->u.uInt == b->u.uInt ? irpn_Eq + : a->u.uInt > b->u.uInt ? irpn_Gt : irpn_Lt); /* signed */ - case irm_c: case irm_h: case irm_i: case irm_l: - return ( a->u.chil == b->u.chil ? irpn_Eq - : a->u.chil > b->u.chil ? irpn_Gt + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + return ( a->u.sInt == b->u.sInt ? irpn_Eq + : a->u.sInt > b->u.sInt ? irpn_Gt : irpn_Lt); - case irm_Z: - { -#if _TARVAL_GMP_ - int cmp = mpz_cmp (&a->u.Z, &b->u.Z); - return ( cmp == 0 ? irpn_Eq - : cmp > 0 ? irpn_Gt - : irpn_Lt); -#else - return irpn_False; -#endif - } - /* strange */ case irm_b: return ( a->u.b == b->u.b ? irpn_Eq : a->u.b > b->u.b ? irpn_Gt : irpn_Lt); /* The following assumes that pointers are unsigned, which is valid for all sane CPUs (transputers are insane). */ - case irm_p: return ( a == b ? irpn_Eq - : a == tarval_p_void ? irpn_Lt - : b == tarval_p_void ? irpn_Gt + case irm_P: return ( a == b ? irpn_Eq + : a == tarval_P_void ? irpn_Lt + : b == tarval_P_void ? irpn_Gt : irpn_False); /* unknown */ default: assert (0); } @@ -1103,31 +863,22 @@ tarval_add (tarval *a, tarval *b) switch (get_mode_modecode(a->mode)) { /* floating */ - case irm_f: tv->u.f = a->u.f + b->u.f; break; /* @@@ overflow etc */ - case irm_d: tv->u.d = a->u.d + b->u.d; break; /* @@@ dto. */ + case irm_F: tv->u.F = a->u.F + b->u.F; break; /* @@@ overflow etc */ + case irm_D: tv->u.D = a->u.D + b->u.D; break; /* @@@ dto. */ + case irm_E: tv->u.E = a->u.E + b->u.E; break; /* @@@ dto. */ /* unsigned */ - case irm_C: case irm_H: case irm_I: case irm_L: - tv->u.CHIL = (a->u.CHIL + b->u.CHIL) & tv_val_CHIL (get_mode_max(a->mode)); + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + tv->u.uInt = (a->u.uInt + b->u.uInt) & tv_val_uInt (get_mode_max(a->mode)); break; /* signed */ - case irm_c: case irm_h: case irm_i: case irm_l: - tv->u.chil = a->u.chil + b->u.chil; - if ( chil_overflow (tv->u.chil, a->mode) - || ((tv->u.chil > a->u.chil) ^ (b->u.chil > 0))) { + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + tv->u.sInt = a->u.sInt + b->u.sInt; + if ( sInt_overflow (tv->u.sInt, a->mode) + || ((tv->u.sInt > a->u.sInt) ^ (b->u.sInt > 0))) { obstack_free (&tv_obst, tv); return NULL; } break; - case irm_Z: -#if _TARVAL_GMP_ - mpz_init (&tv->u.Z); - mpz_add (&tv->u.Z, &a->u.Z, &b->u.Z); -#else - obstack_free (&tv_obst, tv); - return NULL; -#endif - break; - /* strange */ case irm_b: tv->u.b = a->u.b | b->u.b; break; /* u.b is in canonical form */ default: assert(0); } @@ -1151,31 +902,22 @@ tarval_sub (tarval *a, tarval *b) switch (get_mode_modecode(a->mode)) { /* floating */ - case irm_f: tv->u.f = a->u.f - b->u.f; break; /* @@@ overflow etc */ - case irm_d: tv->u.d = a->u.d - b->u.d; break; /* @@@ dto. */ + case irm_F: tv->u.F = a->u.F - b->u.F; break; /* @@@ overflow etc */ + case irm_D: tv->u.D = a->u.D - b->u.D; break; /* @@@ dto. */ + case irm_E: tv->u.E = a->u.E - b->u.E; break; /* @@@ dto. */ /* unsigned */ - case irm_C: case irm_H: case irm_I: case irm_L: - tv->u.CHIL = (a->u.CHIL - b->u.CHIL) & tv_val_CHIL (get_mode_max(a->mode)); + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + tv->u.uInt = (a->u.uInt - b->u.uInt) & tv_val_uInt (get_mode_max(a->mode)); break; /* signed */ - case irm_c: case irm_h: case irm_i: case irm_l: - tv->u.chil = a->u.chil - b->u.chil; - if ( chil_overflow (tv->u.chil, a->mode) - || ((tv->u.chil > a->u.chil) ^ (b->u.chil < 0))) { + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + tv->u.sInt = a->u.sInt - b->u.sInt; + if ( sInt_overflow (tv->u.sInt, a->mode) + || ((tv->u.sInt > a->u.sInt) ^ (b->u.sInt < 0))) { obstack_free (&tv_obst, tv); return NULL; } break; - case irm_Z: -#if _TARVAL_GMP_ - mpz_init (&tv->u.Z); - mpz_sub (&tv->u.Z, &a->u.Z, &b->u.Z); -#else - obstack_free (&tv_obst, tv); - return NULL; -#endif - break; - /* strange */ case irm_b: tv->u.b = a->u.b & ~b->u.b; break; /* u.b is in canonical form */ default: assert(0); } @@ -1198,31 +940,22 @@ tarval_mul (tarval *a, tarval *b) switch (get_mode_modecode(a->mode)) { /* floating */ - case irm_f: tv->u.f = a->u.f * b->u.f; break; /* @@@ overflow etc */ - case irm_d: tv->u.d = a->u.d * b->u.d; break; /* @@@ dto. */ + case irm_F: tv->u.F = a->u.F * b->u.F; break; /* @@@ overflow etc */ + case irm_D: tv->u.D = a->u.D * b->u.D; break; /* @@@ dto. */ + case irm_E: tv->u.E = a->u.E * b->u.E; break; /* @@@ dto. */ /* unsigned */ - case irm_C: case irm_H: case irm_I: case irm_L: - tv->u.CHIL = (a->u.CHIL * b->u.CHIL) & tv_val_CHIL (get_mode_max(a->mode)); + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + tv->u.uInt = (a->u.uInt * b->u.uInt) & tv_val_uInt (get_mode_max(a->mode)); break; /* signed */ - case irm_c: case irm_h: case irm_i: case irm_l: - tv->u.chil = a->u.chil * b->u.chil; - if ( chil_overflow (tv->u.chil, a->mode) - || (b->u.chil && (tv->u.chil / b->u.chil != a->u.chil))) { + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + tv->u.sInt = a->u.sInt * b->u.sInt; + if ( sInt_overflow (tv->u.sInt, a->mode) + || (b->u.sInt && (tv->u.sInt / b->u.sInt != a->u.sInt))) { obstack_free (&tv_obst, tv); return NULL; } break; - case irm_Z: -#if _TARVAL_GMP_ - mpz_init (&tv->u.Z); - mpz_mul (&tv->u.Z, &a->u.Z, &b->u.Z); -#else - obstack_free (&tv_obst, tv); - return NULL; -#endif - break; - /* strange */ case irm_b: tv->u.b = a->u.b & b->u.b; break; /* u.b is in canonical form */ default: assert(0); } @@ -1232,7 +965,7 @@ tarval_mul (tarval *a, tarval *b) /* Return floating-point `a/b' if computable, else NULL. - Modes must be equal, non-floating-point operands are converted to irm_d. */ + Modes must be equal, non-floating-point operands are converted to irm_D. */ tarval * tarval_quo (tarval *a, tarval *b) { @@ -1243,19 +976,19 @@ tarval_quo (tarval *a, tarval *b) switch (get_mode_modecode(a->mode)) { /* floating */ - case irm_f: + case irm_F: tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval)); - tv->mode = mode_f; - tv->u.f = a->u.f / b->u.f; /* @@@ overflow etc */ + tv->mode = mode_F; + tv->u.F = a->u.F / b->u.F; /* @@@ overflow etc */ break; - case irm_d: + case irm_D: tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval)); - tv->mode = mode_d; - tv->u.d = a->u.d / b->u.d; /* @@@ overflow etc */ + tv->mode = mode_D; + tv->u.D = a->u.D / b->u.D; /* @@@ overflow etc */ break; default: - a = tarval_convert_to (a, mode_d); - b = tarval_convert_to (b, mode_d); + a = tarval_convert_to (a, mode_D); + b = tarval_convert_to (b, mode_D); return a && b ? tarval_quo (a, b) : NULL; } @@ -1278,33 +1011,24 @@ tarval_div (tarval *a, tarval *b) switch (get_mode_modecode(a->mode)) { /* floating */ - case irm_f: tv->u.f = floor (a->u.f / b->u.f); break; /* @@@ overflow etc */ - case irm_d: tv->u.d = floor (a->u.d / b->u.d); break; /* @@@ dto. */ + case irm_F: tv->u.F = floor (a->u.F / b->u.F); break; /* @@@ overflow etc */ + case irm_D: tv->u.D = floor (a->u.D / b->u.D); break; /* @@@ dto. */ + case irm_E: tv->u.E = floor (a->u.E / b->u.E); break; /* @@@ dto. */ /* unsigned */ - case irm_C: case irm_H: case irm_I: case irm_L: - if (!b->u.CHIL) goto fail; - tv->u.CHIL = a->u.CHIL / b->u.CHIL; + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + if (!b->u.uInt) goto fail; + tv->u.uInt = a->u.uInt / b->u.uInt; break; /* signed */ - case irm_c: case irm_h: case irm_i: case irm_l: - if ( !b->u.chil - || ((b->u.chil == -1) && (a->u.chil == tv_val_chil (get_mode_max(a->mode)) ))) { + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + if ( !b->u.sInt + || ((b->u.sInt == -1) && (a->u.sInt == tv_val_sInt (get_mode_max(a->mode)) ))) { fail: obstack_free (&tv_obst, tv); return NULL; } - tv->u.chil = a->u.chil / b->u.chil; - break; - case irm_Z: -#if _TARVAL_GMP_ - if (!mpz_cmp_ui (&b->u.Z, 0)) goto fail; - mpz_init (&tv->u.Z); - mpz_div (&tv->u.Z, &a->u.Z, &b->u.Z); -#else - goto fail; -#endif + tv->u.sInt = a->u.sInt / b->u.sInt; break; - /* strange */ case irm_b: tv->u.b = a->u.b ^ b->u.b; break; /* u.b is in canonical form */ default: assert(0); } @@ -1328,32 +1052,23 @@ tarval_mod (tarval *a, tarval *b) switch (get_mode_modecode(a->mode)) { /* floating */ - case irm_f: tv->u.f = fmod (a->u.f, b->u.f); break; /* @@@ overflow etc */ - case irm_d: tv->u.d = fmod (a->u.d, b->u.d); break; /* @@@ dto */ + case irm_F: tv->u.F = fmod (a->u.F, b->u.F); break; /* @@@ overflow etc */ + case irm_D: tv->u.D = fmod (a->u.D, b->u.D); break; /* @@@ dto */ + case irm_E: tv->u.E = fmod (a->u.E, b->u.E); break; /* @@@ dto. */ /* unsigned */ - case irm_C: case irm_H: case irm_I: case irm_L: - if (!b->u.CHIL) goto fail; - tv->u.CHIL = a->u.CHIL % b->u.CHIL; + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + if (!b->u.uInt) goto fail; + tv->u.uInt = a->u.uInt % b->u.uInt; break; /* signed */ - case irm_c: case irm_h: case irm_i: case irm_l: - if (!b->u.chil) { + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + if (!b->u.sInt) { fail: obstack_free (&tv_obst, tv); return NULL; } - tv->u.chil = a->u.chil % b->u.chil; - break; - case irm_Z: -#if _TARVAL_GMP_ - if (!mpz_cmp_ui (&b->u.Z, 0)) goto fail; - mpz_init (&tv->u.Z); - mpz_mod (&tv->u.Z, &a->u.Z, &b->u.Z); -#else - goto fail; -#endif + tv->u.sInt = a->u.sInt % b->u.sInt; break; - /* strange */ case irm_b: tv->u.b = a->u.b ^ b->u.b; break; /* u.b is in canonical form */ default: assert(0); } @@ -1375,17 +1090,16 @@ tv_is_negative(tarval *a) { TARVAL_VRFY (a); switch (get_mode_modecode(a->mode)) { /* floating */ - case irm_f: return (a->u.f<0); break; - case irm_d: return (a->u.d<0); break; + case irm_F: return (a->u.F<0); + case irm_D: return (a->u.D<0); + case irm_E: return (a->u.E<0); /* unsigned */ - case irm_C: case irm_H: case irm_I: case irm_L: + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: return 0; break; /* signed */ - case irm_c: case irm_h: case irm_i: case irm_l: - return (a->u.chil < 0); - break; - case irm_Z: + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + return (a->u.sInt < 0); break; case irm_b: break; default: assert(0); @@ -1410,20 +1124,11 @@ tarval_and (tarval *a, tarval *b) switch (get_mode_modecode(a->mode)) { /* unsigned */ - case irm_C: case irm_H: case irm_I: case irm_L: - tv->u.CHIL = a->u.CHIL & b->u.CHIL; break; + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + tv->u.uInt = a->u.uInt & b->u.uInt; break; /* signed */ - case irm_c: case irm_h: case irm_i: case irm_l: - tv->u.chil = a->u.chil & b->u.chil; break; - case irm_Z: -#if _TARVAL_GMP_ - mpz_init (&tv->u.Z); - mpz_and (&tv->u.Z, &a->u.Z, &b->u.Z); -#else - assert(0); -#endif - break; - /* strange */ + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + tv->u.sInt = a->u.sInt & b->u.sInt; break; case irm_b: tv->u.b = a->u.b & b->u.b; break; /* u.b is in canonical form */ default: assert(0); } @@ -1447,20 +1152,11 @@ tarval_or (tarval *a, tarval *b) switch (get_mode_modecode(a->mode)) { /* unsigned */ - case irm_C: case irm_H: case irm_I: case irm_L: - tv->u.CHIL = a->u.CHIL | b->u.CHIL; break; + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + tv->u.uInt = a->u.uInt | b->u.uInt; break; /* signed */ - case irm_c: case irm_h: case irm_i: case irm_l: - tv->u.chil = a->u.chil | b->u.chil; break; - case irm_Z: -#if _TARVAL_GMP_ - mpz_init (&tv->u.Z); - mpz_ior (&tv->u.Z, &a->u.Z, &b->u.Z); -#else - assert(0); -#endif - break; - /* strange */ + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + tv->u.sInt = a->u.sInt | b->u.sInt; break; case irm_b: tv->u.b = a->u.b | b->u.b; break; /* u.b is in canonical form */ default: assert(0); } @@ -1478,29 +1174,17 @@ tarval_eor (tarval *a, tarval *b) TARVAL_VRFY (a); TARVAL_VRFY (b); assert (a->mode == b->mode); -#if 1 /* see case irm_Z below */ - if (a->mode == mode_Z) return NULL; -#endif - tv = (tarval *)obstack_alloc (&tv_obst, sizeof (tarval)); tv->mode = a->mode; switch (get_mode_modecode(a->mode)) { /* unsigned */ - case irm_C: case irm_H: case irm_I: case irm_L: - tv->u.CHIL = a->u.CHIL ^ b->u.CHIL; break; + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + tv->u.uInt = a->u.uInt ^ b->u.uInt; break; /* signed */ - case irm_c: case irm_h: case irm_i: case irm_l: - tv->u.chil = a->u.chil ^ b->u.chil; break; - case irm_Z: -#if 0 - /* gmp-1.3.2 declares but does not define mpz_xor() */ - mpz_init (&tv->u.Z); - mpz_xor (&tv->u.Z, &a->u.Z, &b->u.Z); -#endif - break; - /* strange */ + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + tv->u.sInt = a->u.sInt ^ b->u.sInt; break; case irm_b: tv->u.b = a->u.b ^ b->u.b; break; /* u.b is in canonical form */ default: assert(0); } @@ -1522,7 +1206,7 @@ tarval_shl (tarval *a, tarval *b) shift = tarval_ord (b, &b_is_huge); if ( b_is_huge || (shift < 0) - || ((shift >= get_mode_size(mode_l)*target_bits) && (a->mode != mode_Z))) { + || ((shift >= get_mode_size(mode_Ls)*target_bits))) { return NULL; } @@ -1531,20 +1215,12 @@ tarval_shl (tarval *a, tarval *b) switch (get_mode_modecode(a->mode)) { /* unsigned */ - case irm_C: case irm_H: case irm_I: case irm_L: - tv->u.CHIL = a->u.CHIL << shift; + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + tv->u.uInt = a->u.uInt << shift; break; /* signed */ - case irm_c: case irm_h: case irm_i: case irm_l: - tv->u.chil = a->u.chil << shift; - break; - case irm_Z: -#if _TARVAL_GMP_ - mpz_init (&tv->u.Z); - mpz_mul_2exp (&tv->u.Z, &a->u.Z, shift); -#else - assert(0); -#endif + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + tv->u.sInt = a->u.sInt << shift; break; default: assert (0); } @@ -1568,7 +1244,7 @@ tarval_shr (tarval *a, tarval *b) shift = tarval_ord (b, &b_is_huge); if ( b_is_huge || (shift < 0) - || ((shift >= get_mode_size(mode_l)*target_bits) && (a->mode != mode_Z))) { + || ((shift >= get_mode_size(mode_Ls)*target_bits))) { return NULL; } @@ -1577,20 +1253,12 @@ tarval_shr (tarval *a, tarval *b) switch (get_mode_modecode(a->mode)) { /* unsigned */ - case irm_C: case irm_H: case irm_I: case irm_L: - tv->u.CHIL = a->u.CHIL >> shift; + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + tv->u.uInt = a->u.uInt >> shift; break; /* signed */ - case irm_c: case irm_h: case irm_i: case irm_l: - tv->u.chil = a->u.chil >> shift; - break; - case irm_Z: -#if _TARVAL_GMP_ - mpz_init (&tv->u.Z); - mpz_div_2exp (&tv->u.Z, &a->u.Z, shift); -#else - assert(0); -#endif + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + tv->u.sInt = a->u.sInt >> shift; break; default: assert (0); } @@ -1612,28 +1280,20 @@ tarval_classify (tarval *tv) switch (get_mode_modecode(tv->mode)) { /* floating */ - case irm_f: case irm_d: + case irm_F: case irm_D: case irm_E: return 2; /* unsigned */ - case irm_C: - return (long)((tv->u.CHIL+1) & tv_val_CHIL (get_mode_max(mode_C))) - 1; - case irm_H: - return (long)((tv->u.CHIL+1) & tv_val_CHIL (get_mode_max(mode_H))) - 1; - case irm_I: - return (long)((tv->u.CHIL+1) & tv_val_CHIL (get_mode_max(mode_I))) - 1; - case irm_L: - return (long)((tv->u.CHIL+1) & tv_val_CHIL (get_mode_max(mode_L))) - 1; + case irm_Bu: + return (long)((tv->u.uInt+1) & tv_val_uInt (get_mode_max(mode_Bu))) - 1; + case irm_Hu: + return (long)((tv->u.uInt+1) & tv_val_uInt (get_mode_max(mode_Hu))) - 1; + case irm_Iu: + return (long)((tv->u.uInt+1) & tv_val_uInt (get_mode_max(mode_Iu))) - 1; + case irm_Lu: + return (long)((tv->u.uInt+1) & tv_val_uInt (get_mode_max(mode_Lu))) - 1; /* signed */ - case irm_c: case irm_h: case irm_i: case irm_l: - return tv->u.chil; - case irm_Z: -#if _TARVAL_GMP_ - if (mpz_cmp_si (&tv->u.Z, 0)) return 0; - else if (mpz_cmp_si (&tv->u.Z, 1)) return 1; - else if (mpz_cmp_si (&tv->u.Z,-1)) return -1; -#endif - return 2; - /* strange */ + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: + return tv->u.sInt; case irm_b: return tv->u.b; default: @@ -1641,21 +1301,6 @@ tarval_classify (tarval *tv) } } - -#if _TARVAL_GMP_ -bool -tarval_s_fits (tarval *tv, long min, long max) { - return (( mpz_cmp_si (&tv->u.Z, min) >= 0) - && mpz_cmp_si (&tv->u.Z, max) <= 0); -} - -bool -tarval_u_fits (tarval *tv, unsigned long max) { - return (( mpz_sgn (&tv->u.Z) >= 0) - && mpz_cmp_si (&tv->u.Z, max) <= 0); -} -#endif - /* Convert `tv' into type `long', set `fail' if not representable. If `fail' gets set for an unsigned `tv', the correct result can be obtained by casting the result to `unsigned long'. */ @@ -1666,23 +1311,13 @@ tarval_ord (tarval *tv, int *fail) switch (get_mode_modecode(tv->mode)) { /* unsigned */ - case irm_C: case irm_H: case irm_I: case irm_L: - *fail = tv->u.CHIL > tv_val_CHIL (get_mode_max(mode_l)); - return tv->u.CHIL; + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: + *fail = tv->u.uInt > tv_val_uInt (get_mode_max(mode_Ls)); + return tv->u.uInt; /* signed */ - case irm_c: case irm_h: case irm_i: case irm_l: + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: *fail = 0; - return tv->u.chil; - case irm_Z: -#if _TARVAL_GMP_ - *fail = ( (mpz_cmp_si (&tv->u.Z, tv_val_chil(get_mode_max(mode_l))) > 0) - || (mpz_cmp_si (&tv->u.Z, tv_val_chil(get_mode_max(mode_l))) < 0)); - return mpz_get_si (&tv->u.Z); -#else - *fail = 1; - return 0; -#endif - /* strange */ + return tv->u.sInt; case irm_b: *fail = 0; return tv->u.b; @@ -1692,7 +1327,6 @@ tarval_ord (tarval *tv, int *fail) } } - int tarval_print (XP_PAR1, const xprintf_info *info ATTRIBUTE((unused)), XP_PARN) { @@ -1708,45 +1342,40 @@ tarval_print (XP_PAR1, const xprintf_info *info ATTRIBUTE((unused)), XP_PARN) printed = XPSR (""); break; - case irm_f: /* float */ - sprintf (buf, "%1.9e", (float)(val->u.f)); + case irm_F: /* float */ + sprintf (buf, "%1.9e", (float)(val->u.F)); printed = XPF1R ("%s", buf); break; - case irm_d: /* double */ - printed = XPF1R ("%1.30g", (double)(val->u.d)); + case irm_D: /* double */ + printed = XPF1R ("%1.30g", (double)(val->u.D)); break; - case irm_c: /* signed char */ - case irm_C: /* unsigned char */ - if ((isprint (val->u.chil)) && - (val->u.chil != '\\') && (val->u.chil != '\'')) { - printed = XPF1R ("'%c'", val->u.chil); + case irm_C: /* character */ + if ((isprint (val->u.C)) && + (val->u.C != '\\') && (val->u.C != '\'')) { + printed = XPF1R ("'%c'", val->u.C); } else { - printed = XPF1R ("0x%x", (unsigned long)val->u.chil); + printed = XPF1R ("0x%x", (unsigned long)val->u.C); } break; - case irm_h: case irm_i: case irm_l: /* signed num */ - printed = XPF1R ("%ld", (long)val->u.chil); + case irm_Bs: case irm_Hs: case irm_Is: case irm_Ls: /* signed num */ + printed = XPF1R ("%ld", (long)val->u.sInt); break; - case irm_H: case irm_I: case irm_L: /* unsigned num */ - printed = XPF1R ("%lu", (unsigned long)val->u.CHIL); + case irm_Bu: case irm_Hu: case irm_Iu: case irm_Lu: /* unsigned num */ + printed = XPF1R ("%lu", (unsigned long)val->u.uInt); break; - case irm_Z: /* mp int */ - printed = XPF1R ("%Z", &val->u.Z); - break; - - case irm_p: /* pointer */ - if (val->u.p.xname) { - printed = XPR (val->u.p.xname); - } else if (val->u.p.ent) { - if (get_entity_peculiarity(val->u.p.ent) == existent) - printed = XPF1R ("&(%I)", get_entity_ld_ident(val->u.p.ent)); + case irm_P: /* pointer */ + if (val->u.P.xname) { + printed = XPR (val->u.P.xname); + } else if (val->u.P.ent) { + if (get_entity_peculiarity(val->u.P.ent) == existent) + printed = XPF1R ("&(%I)", get_entity_ld_ident(val->u.P.ent)); else printed = XPSR ("(NULL)"); } else { - assert (val == tarval_p_void); + assert (val == tarval_P_void); printed = XPSR ("(void)"); } break; @@ -1756,38 +1385,8 @@ tarval_print (XP_PAR1, const xprintf_info *info ATTRIBUTE((unused)), XP_PARN) else printed = XPSR ("false"); break; - case irm_B: /* universal bits */ - printed = XPSR ("<@@@ some bits>"); - break; - - case irm_s: /* string */ - case irm_S: - { size_t i; - char *buf = alloca (val->u.s.n + 2); - char *bp; - - printed = 0; - buf[0] = '\''; - bp = buf + 1; - for (i = 0; i < val->u.s.n; ++i) { - if (isprint (val->u.s.p[i])) { - *bp++ = val->u.s.p[i]; - } else { - if (bp != buf) { - XPM (buf, bp-buf); - bp = buf; - } - XPF1 ("'\\%03o'", val->u.s.p[i]); - } - } - *bp++ = '\''; - XPM (buf, bp-buf); - break; - } - - case irm_M: /* memory */ - case irm_R: /* region */ + case irm_BB: /* region */ default: assert (0); } @@ -1807,12 +1406,12 @@ get_tv_mode (tarval *tv) entity *get_tv_entity(tarval *tv) { entity *ent = NULL; - if (tv->mode == mode_p) { - if (tv->u.p.xname) { + if (tv->mode == mode_P) { + if (tv->u.P.xname) { assert(0); /* not an entity */ - } else if (tv->u.p.ent) { - ent = tv->u.p.ent; + } else if (tv->u.P.ent) { + ent = tv->u.P.ent; } else { /* not an entity */ } diff --git a/ir/tv/tv.h b/ir/tv/tv.h index 20887a1a5..5b20b6765 100644 --- a/ir/tv/tv.h +++ b/ir/tv/tv.h @@ -52,11 +52,12 @@ typedef struct tarval tarval; #endif /* how to represent target types on host */ -typedef float tarval_f; -typedef double tarval_d; -typedef long tarval_chil; -typedef unsigned long tarval_CHIL; -typedef int tarval_Z; /* Do not use!!! */ +typedef float tarval_F; +typedef double tarval_D; +typedef long double tarval_E; +typedef long tarval_sInt; +typedef unsigned long tarval_uInt; +typedef char tarval_C; typedef struct { /* if ent then xname is missing or mangled from ent, else if xname then xname is a linker symbol that is not mangled @@ -67,24 +68,18 @@ typedef struct { const char *xname; entity *ent; tarval *tv; -} tarval_p; -typedef struct { - unsigned char *p; /* may contain embedded 0, not 0-terminated */ - size_t n; -} tarval_s; -typedef tarval_s tarval_B; +} tarval_P; struct tarval { union { - tarval_f f; /* float */ - tarval_d d; /* double */ - tarval_chil chil; /* signed integral */ - tarval_CHIL CHIL; /* unsigned integral */ - tarval_Z Z; /* @@@ Do not use!!! universal int */ - tarval_p p; /* pointer */ - bool b; /* boolean */ - tarval_B B; /* universal bits */ - tarval_s s; /* string */ + tarval_F F; /* float */ + tarval_D D; /* double */ + tarval_E E;; /* extended */ + tarval_sInt sInt; /* signed integral */ + tarval_uInt uInt; /* unsigned integral */ + tarval_C C; /* character */ + tarval_P P; /* pointer */ + bool b; /* boolean */ } u; ir_mode *mode; }; @@ -94,9 +89,9 @@ extern tarval *tarval_bad; tarval *get_tarval_bad(); /* We should have a tarval_undefined */ extern tarval *tarval_b_false; tarval *get_tarval_b_false (); extern tarval *tarval_b_true; tarval *get_tarval_b_true (); -extern tarval *tarval_d_NaN; tarval *get_tarval_d_NaN (); -extern tarval *tarval_d_Inf; tarval *get_tarval_d_Inf (); -extern tarval *tarval_p_void; tarval *get_tarval_p_void (); +extern tarval *tarval_D_NaN; tarval *get_tarval_D_NaN (); +extern tarval *tarval_D_Inf; tarval *get_tarval_D_Inf (); +extern tarval *tarval_P_void; tarval *get_tarval_P_void (); extern tarval *tarval_mode_null[]; tarval *get_tarval_mode_null(ir_mode *mode); /* @@@ These are not initialized!! Don't use. */ extern tarval *tarval_mode_min[]; tarval *get_tarval_mode_min (ir_mode *mode); @@ -106,16 +101,15 @@ void tarval_init_1 (void); void tarval_init_2 (void); /* ************************ Constructors for tarvals ************************ */ -/*tarval *tarval_Z_from_str (const char *s, size_t len, int base);*/ -tarval *tarval_f_from_str (const char *s, size_t len); -tarval *tarval_d_from_str (const char *s, size_t len); +tarval *tarval_F_from_str (const char *s, size_t len); +tarval *tarval_D_from_str (const char *s, size_t len); tarval *tarval_int_from_str (const char *s, size_t len, int base, ir_mode *m); tarval *tarval_from_long (ir_mode *m, long val); -tarval *tarval_p_from_str (const char *xname); +tarval *tarval_P_from_str (const char *xname); /* The tarval represents the address of the entity. As the address must be constant the entity must have as owner the global type. */ -tarval *tarval_p_from_entity (entity *ent); +tarval *tarval_P_from_entity (entity *ent); tarval *tarval_convert_to (tarval *src, ir_mode *m); @@ -128,7 +122,7 @@ tarval *tarval_cancel (void); /* returns tarval_bad */ /* The flags for projecting a comparison result */ typedef enum { - irpn_False=0, /* 0000 false */ + irpn_False=0, /* 0000 false */ irpn_Eq, /* 0001 equal */ irpn_Lt, /* 0010 less */ irpn_Le, /* 0011 less or equal */ @@ -173,11 +167,10 @@ long tarval_classify (tarval *tv); long tarval_ord (tarval *tv, int *fail); /* return a mode-specific value */ -tarval_f tv_val_f (tarval *tv); -tarval_d tv_val_d (tarval *tv); -tarval_chil tv_val_chil (tarval *tv); -tarval_CHIL tv_val_CHIL (tarval *tv); -/*tarval_Z tv_val_Z (tarval *tv);*/ +tarval_F tv_val_F (tarval *tv); +tarval_D tv_val_D (tarval *tv); +tarval_sInt tv_val_sInt (tarval *tv); +tarval_uInt tv_val_uInt (tarval *tv); /* @@@ temporarily removed. jni builder can not deal with the return value. All definitions of types are interpreted as pointer values until diff --git a/ir/tv/tv_t.h b/ir/tv/tv_t.h index 658bf9c21..269eaa94a 100644 --- a/ir/tv/tv_t.h +++ b/ir/tv/tv_t.h @@ -9,17 +9,6 @@ # include "tv.h" # include "misc.h" -#include "gmp.h" -#undef __need_size_t /* erroneously defined by 1.3.2's gmp.h */ - - -tarval *tarval_S_from_str (const char *s, size_t len); -tarval *tarval_s_from_str (const char *s, size_t len); -tarval *tarval_B_from_str (const char *s, size_t len); -tarval_B tv_val_B (tarval *tv); -tarval_s tv_val_s (tarval *tv); - - int tarval_print (XP_PAR1, const xprintf_info *, XP_PARN); /* Hash function on tarvals */ -- 2.20.1