X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fir%2Firvrfy.c;h=58e5de00b908d338c93e7799d24e34b0a5b370a5;hb=a09e658c8142719ef2be114547455bb5a68f480d;hp=f5a6e957a5ced918fd7a2a2157f273fd9d5757dc;hpb=652ec0592f713b8ca15bad13df1f6cfdd9eaca7f;p=libfirm diff --git a/ir/ir/irvrfy.c b/ir/ir/irvrfy.c index f5a6e957a..58e5de00b 100644 --- a/ir/ir/irvrfy.c +++ b/ir/ir/irvrfy.c @@ -67,7 +67,7 @@ static void show_entity_failure(ir_node *node) entity *ent = get_irg_entity(irg); if (ent) { - type *ent_type = get_entity_owner(ent); + ir_type *ent_type = get_entity_owner(ent); if (ent_type) { if (ent_type == get_glob_type()) @@ -166,7 +166,7 @@ static void show_proj_failure(ir_node *n) /** * Prints a failure message for a proj from Start */ -static void show_proj_mode_failure(ir_node *n, type *ty) +static void show_proj_mode_failure(ir_node *n, ir_type *ty) { long proj = get_Proj_proj(n); ir_mode *m = get_type_mode(ty); @@ -209,7 +209,7 @@ static void show_node_on_graph(ir_graph *irg, ir_node *n) /** * Show call parameters */ -static void show_call_param(ir_node *n, type *mt) +static void show_call_param(ir_node *n, ir_type *mt) { int i; @@ -230,7 +230,7 @@ static void show_call_param(ir_node *n, type *mt) /** * Show return modes */ -static void show_return_modes(ir_graph *irg, ir_node *n, type *mt, int i) +static void show_return_modes(ir_graph *irg, ir_node *n, ir_type *mt, int i) { entity *ent = get_irg_entity(irg); @@ -245,7 +245,7 @@ static void show_return_modes(ir_graph *irg, ir_node *n, type *mt, int i) /** * Show return number of results */ -static void show_return_nres(ir_graph *irg, ir_node *n, type *mt) +static void show_return_nres(ir_graph *irg, ir_node *n, ir_type *mt) { entity *ent = get_irg_entity(irg); @@ -590,7 +590,7 @@ static int verify_node_Proj_Proj(ir_node *pred, ir_node *p) { ir_mode *mode = get_irn_mode(p); long proj = get_Proj_proj(p); long nr = get_Proj_proj(pred); - type *mt; /* A method type */ + ir_type *mt; /* A method type */ pred = skip_Id(get_Proj_pred(pred)); ASSERT_AND_RET((get_irn_mode(pred) == mode_T), "Proj from something not a tuple", 0); @@ -655,7 +655,8 @@ static int verify_node_Proj_Proj(ir_node *pred, ir_node *p) { break; default: - ASSERT_AND_RET(0, "Unknown opcode", 0); + /* ASSERT_AND_RET(0, "Unknown opcode", 0); */ + break; } return 1; } @@ -693,6 +694,47 @@ static int verify_node_Proj_EndExcept(ir_node *n, ir_node *p) { return 1; } +/** + * verify a Proj(CopyB) node + */ +static int verify_node_Proj_CopyB(ir_node *n, ir_node *p) { + ir_mode *mode = get_irn_mode(p); + long proj = get_Proj_proj(p); + + ASSERT_AND_RET_DBG( + ((proj == pn_CopyB_M && mode == mode_M) || + (proj == pn_CopyB_X_except && mode == mode_X)), + "wrong Proj from CopyB", 0, + show_proj_failure(p); + ); + if (proj == pn_CopyB_X_except) + ASSERT_AND_RET( + get_irn_pinned(n) == op_pin_state_pinned, + "Exception Proj from unpinned CopyB", 0); + return 1; +} + +/** + * verify a Proj(Bound) node + */ +static int verify_node_Proj_Bound(ir_node *n, ir_node *p) { + ir_mode *mode = get_irn_mode(p); + long proj = get_Proj_proj(p); + + ASSERT_AND_RET_DBG( + ((proj == pn_Bound_M && mode == mode_M) || + (proj == pn_Bound_X_except && mode == mode_X) || + (proj == pn_Bound_res && mode == get_irn_mode(get_Bound_index(n)))), + "wrong Proj from Bound", 0, + show_proj_failure(p); + ); + if (proj == pn_Bound_X_except) + ASSERT_AND_RET( + get_irn_pinned(n) == op_pin_state_pinned, + "Exception Proj from unpinned Bound", 0); + return 1; +} + /** * verify a Proj node */ @@ -734,7 +776,7 @@ static int verify_node_Block(ir_node *n, ir_graph *irg) { ir_node *pred = skip_Proj(get_Block_cfgpred(n, i)); if (is_Proj(pred) || get_irn_op(pred) == op_Tuple) break; /* We can not test properly. How many tuples are there? */ - ASSERT_AND_RET(((get_irn_op(pred) == op_Return) || + ASSERT_AND_RET((is_Return(pred) || is_Bad(pred) || (get_irn_op(pred) == op_Raise) || is_fragile_op(pred) ), @@ -827,7 +869,7 @@ static int verify_node_Return(ir_node *n, ir_graph *irg) { int i; ir_mode *mymode = get_irn_mode(n); ir_mode *mem_mode = get_irn_mode(get_Return_mem(n)); - type *mt; + ir_type *mt; /* Return: BB x M x data1 x ... x datan --> X */ @@ -843,7 +885,7 @@ static int verify_node_Return(ir_node *n, ir_graph *irg) { "Number of results for Return doesn't match number of results in type.", 0, show_return_nres(irg, n, mt);); for (i = get_Return_n_ress(n) - 1; i >= 0; --i) { - type *res_type = get_method_res_type(mt, i); + ir_type *res_type = get_method_res_type(mt, i); if (is_atomic_type(res_type)) { ASSERT_AND_RET_DBG( @@ -891,6 +933,11 @@ static int verify_node_Const(ir_node *n, ir_graph *irg) { mymode == mode_b) /* we want boolean constants for static evaluation */ ,"Const node", 0 /* of Cmp. */ ); + ASSERT_AND_RET( + /* the modes of the constant and teh tarval must match */ + mymode == get_tarval_mode(get_Const_tarval(n)), + "Const node, tarval and node mode mismatch", 0 + ); return 1; } @@ -962,7 +1009,7 @@ static int verify_node_Call(ir_node *n, ir_graph *irg) { ir_mode *mymode = get_irn_mode(n); ir_mode *op1mode = get_irn_mode(get_Call_mem(n)); ir_mode *op2mode = get_irn_mode(get_Call_ptr(n)); - type *mt; + ir_type *mt; int i; /* Call: BB x M x ref x data1 x ... x datan @@ -1004,7 +1051,7 @@ static int verify_node_Call(ir_node *n, ir_graph *irg) { } for (i = 0; i < get_method_n_params(mt); i++) { - type *t = get_method_param_type(mt, i); + ir_type *t = get_method_param_type(mt, i); if (is_atomic_type(t)) { ASSERT_AND_RET_DBG( @@ -1226,7 +1273,7 @@ static int verify_node_Logic(ir_node *n, ir_graph *irg) { ASSERT_AND_RET_DBG( /* And or Or or Eor: BB x int x int --> int */ - mode_is_int(mymode) && + (mode_is_int(mymode) || mymode == mode_b) && op2mode == op1mode && mymode == op2mode, "And, Or or Eor node", 0, @@ -1558,7 +1605,7 @@ static int verify_node_CopyB(ir_node *n, ir_graph *irg) { ir_mode *op1mode = get_irn_mode(get_CopyB_mem(n)); ir_mode *op2mode = get_irn_mode(get_CopyB_dst(n)); ir_mode *op3mode = get_irn_mode(get_CopyB_src(n)); - type *t = get_CopyB_type(n); + ir_type *t = get_CopyB_type(n); /* CopyB: BB x M x ref x ref --> M x X */ ASSERT_AND_RET( @@ -1581,6 +1628,34 @@ static int verify_node_CopyB(ir_node *n, ir_graph *irg) { return 1; } +/** + * verify a Bound node + */ +static int verify_node_Bound(ir_node *n, ir_graph *irg) { + ir_mode *mymode = get_irn_mode(n); + ir_mode *op1mode = get_irn_mode(get_Bound_mem(n)); + ir_mode *op2mode = get_irn_mode(get_Bound_index(n)); + ir_mode *op3mode = get_irn_mode(get_Bound_lower(n)); + ir_mode *op4mode = get_irn_mode(get_Bound_upper(n)); + + /* Bound: BB x M x ref x ref --> M x X */ + ASSERT_AND_RET( + mymode == mode_T && + op1mode == mode_M && + op2mode == op3mode && + op3mode == op4mode && + mode_is_int(op3mode), + "Bound node", 0 ); /* operand M x int x int x int */ + + /* NoMem nodes are only allowed as memory input if the Bound is NOT pinned. + This should happen RARELY, as Bound COPIES MEMORY */ + ASSERT_AND_RET( + (get_irn_op(get_Bound_mem(n)) == op_NoMem) || + (get_irn_op(get_Bound_mem(n)) != op_NoMem && get_irn_pinned(n) == op_pin_state_pinned), + "Bound node with wrong memory input", 0 ); + return 1; +} + /* * Check dominance. * For each usage of a node, it is checked, if the block of the @@ -1643,6 +1718,11 @@ int irn_vrfy_irg(ir_node *n, ir_graph *irg) show_node_on_graph(irg, n); ); assert(get_irn_irg(n) == irg); + { + unsigned idx = get_irn_idx(n); + ir_node *node_from_map = get_idx_irn(irg, idx); + ASSERT_AND_RET_DBG(node_from_map == n, "Node index and index map entry differ", 0, ir_printf("node %+F node in map %+F(%p)", n, node_from_map, node_from_map)); + } } op = get_irn_op(n); @@ -1928,6 +2008,7 @@ void firm_set_default_verifyer(opcode code, ir_op_ops *ops) CASE(Confirm); CASE(Mux); CASE(CopyB); + CASE(Bound); default: /* leave NULL */; } @@ -1957,6 +2038,8 @@ void firm_set_default_verifyer(opcode code, ir_op_ops *ops) CASE(CallBegin); CASE(EndReg); CASE(EndExcept); + CASE(CopyB); + CASE(Bound); default: /* leave NULL */; }