3 * File name: ir/ir/irvrfy.c
4 * Purpose: Check irnodes for correctness.
5 * Author: Christian Schaefer
6 * Modified by: Goetz Lindenmaier. Till Riedel
9 * Copyright: (c) 1998-2003 Universität Karlsruhe
10 * Licence: This file protected by GPL - GNU GENERAL PUBLIC LICENSE.
17 # include "irgraph_t.h"
23 * in RELEASE mode, returns ret if the expression expr evaluates to zero
24 * in ASSERT mode, asserts the expression expr (and the string string).
26 #define ASSERT_AND_RET(expr, string, ret) if (!(expr)) return (ret)
29 * in RELEASE mode, returns ret if the expression expr evaluates to zero
30 * in ASSERT mode, executes blk if the expression expr evaluates to zero and asserts
32 #define ASSERT_AND_RET_DBG(expr, string, ret, blk) if (!(expr)) return (ret)
34 #define ASSERT_AND_RET(expr, string, ret) do { assert((expr) && string); if (!(expr)) return (ret); } while(0)
35 #define ASSERT_AND_RET_DBG(expr, string, ret, blk) do { if (!(expr)) { { blk } assert(0 && string); return (ret); } } while(0)
38 /* @@@ replace use of array "in" by access functions. */
39 ir_node **get_irn_in(ir_node *node);
41 bool opt_do_node_verification = 1;
42 void do_node_verification(bool b) {
43 opt_do_node_verification = b;
47 * Prints a failure message for a binop
49 static void show_binop_failure(ir_node *n, const char *text)
51 ir_node *left = get_binop_left(n);
52 ir_node *right = get_binop_right(n);
54 fprintf(stderr, "\nFIRM: irn_vrfy_irg() of node %ld %s%s(%s%s, %s%s) did not match (%s)\n",
56 get_irn_opname(n), get_irn_modename(n),
57 get_irn_opname(left), get_irn_modename(left),
58 get_irn_opname(right), get_irn_modename(right),
63 * Prints a failure message for an unop
65 static void show_unop_failure(ir_node *n, const char *text)
67 ir_node *op = get_unop_op(n);
69 fprintf(stderr, "\nFIRM: irn_vrfy_irg() of node %ld %s%s(%s%s) did not match (%s)\n",
71 get_irn_opname(n), get_irn_modename(n),
72 get_irn_opname(op), get_irn_modename(op),
77 * Prints a failure message for a proj
79 static void show_proj_failure(ir_node *n)
81 ir_node *op = get_Proj_pred(n);
82 int proj = get_Proj_proj(n);
84 fprintf(stderr, "\nFIRM: irn_vrfy_irg() of node %ld %s%s %d(%s%s) failed\n" ,
86 get_irn_opname(n), get_irn_modename(n), proj,
87 get_irn_opname(op), get_irn_modename(op));
91 * Prints a failure message for a proj
93 static void show_proj_failure_ent(ir_node *n, entity *ent)
95 ir_node *op = get_Proj_pred(n);
96 int proj = get_Proj_proj(n);
97 ir_mode *m = get_type_mode(get_entity_type(ent));
99 fprintf(stderr, "\nFIRM: irn_vrfy_irg() of node %ld %s%s %d(%s%s) entity %s(type %s mode %s)failed\n" ,
101 get_irn_opname(n), get_irn_modename(n), proj,
102 get_irn_opname(op), get_irn_modename(op),
103 get_entity_name(ent), get_type_name(get_entity_type(ent)),
104 m ? get_mode_name(m) : "<no mode>");
109 * Show a node and a graph
111 static void show_node_on_graph(ir_graph *irg, ir_node *n)
113 entity *ent = get_irg_ent(irg);
116 fprintf(stderr, "\nFIRM: irn_vrfy_irg() of entity %s, node %ld %s%s\n",
117 get_entity_name(ent),
118 get_irn_node_nr(n), get_irn_opname(n), get_irn_modename(n));
120 fprintf(stderr, "\nFIRM: irn_vrfy_irg() of graph %p, node %ld %s%s\n",
122 get_irn_node_nr(n), get_irn_opname(n), get_irn_modename(n));
128 static void show_call_param(ir_node *n, type *mt)
132 fprintf(stderr, "\nFIRM: irn_vrfy_irg() Call type-check failed: %s(", get_type_name(mt));
133 for (i = 0; i < get_method_n_params(mt); ++i) {
134 fprintf(stderr, "%s ", get_mode_name(get_type_mode(get_method_param_type(mt, i))));
136 fprintf(stderr, ") != CALL(");
138 for (i = 0; i < get_Call_n_params(n); ++i) {
139 fprintf(stderr, "%s ", get_mode_name(get_irn_mode(get_Call_param(n, i))));
141 fprintf(stderr, ")\n");
148 static void show_return_modes(ir_graph *irg, ir_node *n, type *mt, int i)
150 entity *ent = get_irg_ent(irg);
152 fprintf(stderr, "\nFIRM: irn_vrfy_irg() Return node %ld in entity \"%s\" mode %s different from type mode %s\n",
153 get_irn_node_nr(n), get_entity_name(ent),
154 get_mode_name(get_irn_mode(get_Return_res(n, i))),
155 get_mode_name(get_type_mode(get_method_res_type(mt, i)))
160 * Show return number of results
162 static void show_return_nres(ir_graph *irg, ir_node *n, type *mt)
164 entity *ent = get_irg_ent(irg);
166 fprintf(stderr, "\nFIRM: irn_vrfy_irg() Return node %ld in entity \"%s\" has %d results different from type %d\n",
167 get_irn_node_nr(n), get_entity_name(ent),
168 get_Return_n_ress(n), get_method_n_ress(mt));
174 static void show_phi_failure(ir_node *phi, ir_node *pred, int pos)
176 fprintf(stderr, "\nFIRM: irn_vrfy_irg() Phi node %ld has mode %s different from predeccessor node %ld mode %s\n",
177 get_irn_node_nr(phi), get_mode_name(get_irn_mode(phi)),
178 get_irn_node_nr(pred), get_mode_name(get_irn_mode(pred)));
182 vrfy_Proj_proj(ir_node *p, ir_graph *irg) {
187 pred = skip_nop(get_Proj_pred(p));
188 assert(get_irn_mode(pred) == mode_T);
189 mode = get_irn_mode(p);
190 proj = get_Proj_proj(p);
192 switch (get_irn_opcode(pred)) {
196 (proj == pns_initial_exec && mode == mode_X) ||
197 (proj == pns_global_store && mode == mode_M) ||
198 (proj == pns_frame_base && mode_is_reference(mode)) ||
199 (proj == pns_globals && mode_is_reference(mode)) ||
200 (proj == pns_args && mode == mode_T) ||
201 (proj == pns_value_arg_base && mode_is_reference(mode))
203 "wrong Proj from Start", 0,
204 show_proj_failure(p);
210 (proj >= 0 && mode == mode_X),
211 "wrong Proj from Cond", 0,
212 show_proj_failure(p);
218 ((proj == pn_Raise_X && mode == mode_X) || (proj == pn_Raise_M && mode == mode_M)),
219 "wrong Proj from Raise", 0,
220 show_proj_failure(p);
226 (proj >= 0 && mode == mode_X),
227 "wrong Proj from InstOf", 0,
228 show_proj_failure(p);
234 ((proj == pn_Call_M_regular && mode == mode_M) ||
235 (proj == pn_Call_X_except && mode == mode_X) ||
236 (proj == pn_Call_T_result && mode == mode_T) ||
237 (proj == pn_Call_M_except && mode == mode_M) ||
238 (proj == pn_Call_P_value_res_base && mode == mode_P)),
239 "wrong Proj from Call", 0,
240 show_proj_failure(p);
246 ((proj == pn_Quot_M && mode == mode_M) ||
247 (proj == pn_Quot_X_except && mode == mode_X) ||
248 (proj == pn_Quot_res && mode_is_float(mode))),
249 "wrong Proj from Quot", 0,
250 show_proj_failure(p);
256 ((proj == pn_DivMod_M && mode == mode_M) ||
257 (proj == pn_DivMod_X_except && mode == mode_X) ||
258 (proj == pn_DivMod_res_div && mode_is_int(mode)) ||
259 (proj == pn_DivMod_res_mod && mode_is_int(mode))),
260 "wrong Proj from DivMod", 0,
261 show_proj_failure(p);
267 ((proj == pn_Div_M && mode == mode_M) ||
268 (proj == pn_Div_X_except && mode == mode_X) ||
269 (proj == pn_Div_res && mode_is_int(mode))),
270 "wrong Proj from Div or Mod", 0,
271 show_proj_failure(p);
277 ((proj == pn_Mod_M && mode == mode_M) ||
278 (proj == pn_Mod_X_except && mode == mode_X) ||
279 (proj == pn_Mod_res && mode_is_int(mode))),
280 "wrong Proj from Div or Mod", 0,
281 show_proj_failure(p);
287 (proj >= 0 && proj <= 15 && mode == mode_b),
288 "wrong Proj from Cmp", 0,
289 show_proj_failure(p);
294 if (proj == pn_Load_res) {
295 ir_node *ptr = get_Load_ptr(pred);
297 if (get_irn_op(ptr) == op_Sel) {
298 ent = get_Sel_entity(ptr);
300 We may not test this, after lowering and optimization the Const can
301 have an unexpected type.
302 else if ((get_irn_op(ptr) == op_Const) &&
303 tarval_is_entity(get_Const_tarval(ptr))) {
304 ent = get_tarval_entity(get_Const_tarval(ptr));
308 (mode == get_type_mode(get_entity_type(ent))),
309 "wrong data Proj from Load, entity type_mode failed", 0,
310 show_proj_failure_ent(p, ent);
316 "wrong data Proj from Load", 0,
317 show_proj_failure(p);
322 ((proj == pn_Load_M && mode == mode_M) ||
323 (proj == pn_Load_X_except && mode == mode_X)),
324 "wrong Proj from Load", 0,
325 show_proj_failure(p);
332 ((proj == pn_Store_M && mode == mode_M) ||
333 (proj == pn_Store_X_except && mode == mode_X)),
334 "wrong Proj from Store", 0,
335 show_proj_failure(p);
342 (proj == pn_Alloc_M && mode == mode_M) ||
343 (proj == pn_Alloc_X_except /* && mode == mode_X*/) ||
344 (proj == pn_Alloc_res && mode_is_reference(mode))
346 "wrong Proj from Alloc", 0,
347 show_proj_failure(p);
353 type *mt; /* A method type */
354 pred = skip_nop(get_Proj_pred(pred));
355 ASSERT_AND_RET((get_irn_mode(pred) == mode_T), "Proj from something not a tuple", 0);
356 switch (get_irn_opcode(pred))
361 (proj >= 0 && mode_is_data(mode)),
362 "wrong Proj from Proj from Start", 0);
363 mt = get_entity_type(get_irg_ent(irg));
365 (proj < get_method_n_params(mt)),
366 "More Projs for args than args in type", 0
368 if ((mode_is_reference(mode)) && is_compound_type(get_method_param_type(mt, proj)))
369 /* value argument */ break;
372 (mode == get_type_mode(get_method_param_type(mt, proj))),
373 "Mode of Proj from Start doesn't match mode of param type.", 0);
380 (proj >= 0 && mode_is_data(mode)),
381 "wrong Proj from Proj from Call", 0);
382 mt = get_Call_type(pred);
384 (proj < get_method_n_ress(mt)),
385 "More Projs for results than results in type.", 0);
386 if ((mode_is_reference(mode)) && is_compound_type(get_method_res_type(mt, proj)))
387 /* value result */ break;
390 (mode == get_type_mode(get_method_res_type(mt, proj))),
391 "Mode of Proj from Call doesn't match mode of result type.", 0);
400 ASSERT_AND_RET(0, "Unknown opcode", 0);
419 ASSERT_AND_RET(0, "Unknown opcode", 0);
426 int irn_vrfy_irg(ir_node *n, ir_graph *irg)
430 ir_mode *mymode, *op1mode = NULL, *op2mode, *op3mode;
431 int op_is_symmetric = 1; /* 0: asymmetric
432 1: operands have identical modes
433 2: modes of operands == mode of this node */
434 type *mt; /* A method type */
438 if (!opt_do_node_verification) return 1;
440 if (! interprocedural_view) {
442 * do NOT check placement in interprocedural view, as we don't always know
443 * the "right" graph ...
446 node_is_in_irgs_storage(irg, n),
447 "Node is not stored on proper IR graph!", 0,
448 show_node_on_graph(irg, n);
452 opcode = get_irn_opcode(n);
454 /* We don't want to test nodes whose predecessors are Bad or Unknown,
455 as we would have to special case that for each operation. */
456 if (opcode != iro_Phi && opcode != iro_Block)
457 for (i = 0; i < get_irn_arity(n); i++) {
458 opcode1 = get_irn_opcode(get_irn_n(n, i));
459 if (opcode1 == iro_Bad /*|| opcode1 == iro_Unknown*/) /* GL: for analyses mode must be correct. */
463 mymode = get_irn_mode(n);
470 for (i = 0; i < get_Block_n_cfgpreds(n); ++i) {
471 ir_node *pred = get_Block_cfgpred(n, i);
475 (get_irn_mode(pred) == mode_X)
478 // End block may only have Return, Raise or fragile ops as preds.
479 if (n == get_irg_end_block(irg))
480 for (i = 0; i < get_Block_n_cfgpreds(n); ++i) {
481 ir_node *pred = skip_Proj(get_Block_cfgpred(n, i));
482 if (is_Proj(pred) || get_irn_op(pred) == op_Tuple)
483 break; // We can not test properly. How many tuples are there?
484 ASSERT_AND_RET(((get_irn_op(pred) == op_Return) ||
486 (get_irn_op(pred) == op_Raise) ||
487 is_fragile_op(pred) ),
488 "End Block node", 0);
490 // irg attr must == graph we are in.
491 if (! interprocedural_view) {
492 ASSERT_AND_RET(((get_irn_irg(n) && get_irn_irg(n) == irg)), "Block node has wrong irg attribute", 0);
499 /* Start: BB --> X x M x ref x data1 x ... x datan x ref */
500 mymode == mode_T, "Start node", 0
507 mymode == mode_X, "Jmp node", 0
514 mymode == mode_X, "Jmp node", 0
519 op1mode = get_irn_mode(in[1]);
521 /* Cond: BB x b --> X x X */
522 (op1mode == mode_b ||
523 /* Cond: BB x int --> X^n */
524 mode_is_int(op1mode) ), "Cond node", 0
526 ASSERT_AND_RET(mymode == mode_T, "Cond mode is not a tuple", 0);
530 op1mode = get_irn_mode(in[1]);
531 /* Return: BB x M x data1 x ... x datan --> X */
532 /* printf("mode: %s, code %s\n", ID_TO_STR(n->mode->name), ID_TO_STR(n->op->name));*/
533 ASSERT_AND_RET( op1mode == mode_M, "Return node", 0 ); /* operand M */
534 for (i=2; i < get_irn_arity(n); i++) {
535 ASSERT_AND_RET( mode_is_data(get_irn_mode(in[i])), "Return node", 0 ); /* operand datai */
537 ASSERT_AND_RET( mymode == mode_X, "Result X", 0 ); /* result X */
538 /* Compare returned results with result types of method type */
539 mt = get_entity_type(get_irg_ent(irg));
540 ASSERT_AND_RET_DBG( get_Return_n_ress(n) == get_method_n_ress(mt),
541 "Number of results for Return doesn't match number of results in type.", 0,
542 show_return_nres(irg, n, mt););
543 for (i = 0; i < get_Return_n_ress(n); i++)
545 get_irn_mode(get_Return_res(n, i)) == get_type_mode(get_method_res_type(mt, i)),
546 "Mode of result for Return doesn't match mode of result type.", 0,
547 show_return_modes(irg, n, mt, i););
551 op1mode = get_irn_mode(in[1]);
552 op2mode = get_irn_mode(in[2]);
554 /* Sel: BB x M x ref --> X x M */
555 op1mode == mode_M && mode_is_reference(op2mode) &&
556 mymode == mode_T, "Raise node", 0
562 /* Const: BB --> data */
563 (mode_is_data (mymode) ||
564 mymode == mode_b) /* we want boolean constants for static evaluation */
565 ,"Const node", 0 /* of Cmp. */
571 /* SymConst: BB --> int*/
572 (mode_is_int(mymode) ||
573 /* SymConst: BB --> ref */
574 mode_is_reference(mymode))
575 ,"SymConst node", 0);
579 op1mode = get_irn_mode(in[1]);
580 op2mode = get_irn_mode(in[2]);
582 /* Sel: BB x M x ref x int^n --> ref */
583 (op1mode == mode_M && op2mode == mymode && mode_is_reference(mymode)),
586 for (i=3; i < get_irn_arity(n); i++)
588 ASSERT_AND_RET(mode_is_int(get_irn_mode(in[i])), "Sel node", 0);
593 ASSERT_AND_RET(mode_T == mymode, "mode of Instof is not a tuple", 0);
594 ASSERT_AND_RET(mode_is_data(op1mode), "Instof not on data", 0);
598 op1mode = get_irn_mode(in[1]);
599 op2mode = get_irn_mode(in[2]);
600 /* Call: BB x M x ref x data1 x ... x datan
601 --> M x datan+1 x ... x data n+m */
602 ASSERT_AND_RET( op1mode == mode_M && mode_is_reference(op2mode), "Call node", 0 ); /* operand M x ref */
603 for (i=3; i < get_irn_arity(n); i++) {
604 ASSERT_AND_RET( mode_is_data(get_irn_mode(in[i])), "Call node", 0 ); /* operand datai */
606 ASSERT_AND_RET( mymode == mode_T, "Call result not a tuple", 0 ); /* result T */
607 /* Compare arguments of node with those of type */
608 mt = get_Call_type(n);
610 if (get_method_variadicity(mt) == variadicity_variadic) {
612 get_Call_n_params(n) >= get_method_n_params(mt),
613 "Number of args for Call doesn't match number of args in variadic type.",
615 fprintf(stderr, "Call has %d params, method %s type %d\n",
616 get_Call_n_params(n), get_type_name(mt), get_method_n_params(mt));
621 get_Call_n_params(n) == get_method_n_params(mt),
622 "Number of args for Call doesn't match number of args in non variadic type.",
626 for (i = 0; i < get_method_n_params(mt); i++) {
628 get_irn_mode(get_Call_param(n, i)) == get_type_mode(get_method_param_type(mt, i)),
629 "Mode of arg for Call doesn't match mode of arg type.", 0,
630 show_call_param(n, mt);
636 op1mode = get_irn_mode(in[1]);
637 op2mode = get_irn_mode(in[2]);
640 /* common Add: BB x numP x numP --> numP */
641 (op1mode == mymode && op2mode == op1mode && mode_is_numP(mymode)) ||
642 /* Pointer Add: BB x ref x int --> ref */
643 (mode_is_reference(op1mode) && mode_is_int(op2mode) && op1mode == mymode) ||
644 /* Pointer Add: BB x int x ref --> ref */
645 (mode_is_int(op1mode) && op2mode == mymode && mode_is_reference(mymode))
648 show_binop_failure(n, "/* common Add: BB x numP x numP --> numP */ |\n"
649 "/* Pointer Add: BB x ref x int --> ref */ |\n"
650 "/* Pointer Add: BB x int x ref --> ref */");
652 if (mode_is_reference(op1mode) != mode_is_reference(op2mode)) {
653 /* BB x ref x int --> ref or BB x int x ref --> ref */
656 /* BB x num x num --> num or BB x ref x ref */
662 op1mode = get_irn_mode(in[1]);
663 op2mode = get_irn_mode(in[2]);
665 /* common Sub: BB x numP x numP --> numP */
666 ((mymode ==op1mode && mymode == op2mode && mode_is_numP(op1mode)) ||
667 /* Pointer Sub: BB x ref x int --> ref */
668 (op1mode == mymode && mode_is_int(op2mode) && mode_is_reference(mymode)) ||
669 /* Pointer Sub: BB x int x ref --> ref */
670 (mode_is_int(op1mode) && op2mode == mymode && mode_is_reference(mymode)) ||
671 /* Pointer Sub: BB x ref x ref --> int */
672 (op1mode == op2mode && mode_is_reference(op2mode) && mode_is_int(mymode))),
674 show_binop_failure(n, "/* common Sub: BB x numP x numP --> numP */ |\n"
675 "/* Pointer Sub: BB x ref x int --> ref */ |\n"
676 "/* Pointer Sub: BB x int x ref --> ref */ |\n"
677 "/* Pointer Sub: BB x ref x ref --> int */" );
679 if (mode_is_reference(op1mode) != mode_is_reference(op2mode)) {
687 op1mode = get_irn_mode(in[1]);
689 /* Minus: BB x float --> float */
690 op1mode == mymode && get_mode_sort(op1mode) == irms_float_number, "Minus node", 0,
691 show_unop_failure(n , "/* Minus: BB x float --> float */");
697 op1mode = get_irn_mode(in[1]);
698 op2mode = get_irn_mode(in[2]);
700 /* Mul: BB x int1 x int1 --> int2 */
701 ((mode_is_int(op1mode) && op2mode == op1mode && mode_is_int(mymode)) ||
702 (mode_is_float(op1mode) && op2mode == op1mode && mymode == op1mode)),
704 show_binop_failure(n, "/* Mul: BB x int1 x int1 --> int2 */");
710 op1mode = get_irn_mode(in[1]);
711 op2mode = get_irn_mode(in[2]);
712 op3mode = get_irn_mode(in[3]);
714 /* Quot: BB x M x float x float --> M x X x float */
715 op1mode == mode_M && op2mode == op3mode &&
716 get_mode_sort(op2mode) == irms_float_number &&
719 show_binop_failure(n, "/* Quot: BB x M x float x float --> M x X x float */");
725 op1mode = get_irn_mode(in[1]);
726 op2mode = get_irn_mode(in[2]);
727 op3mode = get_irn_mode(in[3]);
729 /* DivMod: BB x M x int x int --> M x X x int x int */
731 mode_is_int(op2mode) &&
732 op3mode == op2mode &&
741 op1mode = get_irn_mode(in[1]);
742 op2mode = get_irn_mode(in[2]);
743 op3mode = get_irn_mode(in[3]);
745 /* Div or Mod: BB x M x int x int --> M x X x int */
747 op2mode == op3mode &&
748 mode_is_int(op2mode) &&
756 op1mode = get_irn_mode(in[1]);
758 /* Abs: BB x num --> num */
760 mode_is_num (op1mode),
762 show_unop_failure(n, "/* Abs: BB x num --> num */");
770 op1mode = get_irn_mode(in[1]);
771 op2mode = get_irn_mode(in[2]);
773 /* And or Or or Eor: BB x int x int --> int */
774 mode_is_int(mymode) &&
775 op2mode == op1mode &&
777 "And, Or or Eor node", 0,
778 show_binop_failure(n, "/* And or Or or Eor: BB x int x int --> int */");
784 op1mode = get_irn_mode(in[1]);
786 /* Not: BB x int --> int */
787 mode_is_int(mymode) &&
790 show_unop_failure(n, "/* Not: BB x int --> int */");
797 op1mode = get_irn_mode(in[1]);
798 op2mode = get_irn_mode(in[2]);
800 /* Cmp: BB x datab x datab --> b16 */
801 mode_is_data (op1mode) &&
802 op2mode == op1mode &&
805 show_binop_failure(n, "/* Cmp: BB x datab x datab --> b16 */");
812 op1mode = get_irn_mode(in[1]);
813 op2mode = get_irn_mode(in[2]);
815 /* Shl, Shr or Shrs: BB x int x int_u --> int */
816 mode_is_int(op1mode) &&
817 mode_is_int(op2mode) &&
818 !mode_is_signed(op2mode) &&
820 "Shl, Shr, Shr or Rot node", 0,
821 show_binop_failure(n, "/* Shl, Shr or Shrs: BB x int x int_u --> int */");
826 op1mode = get_irn_mode(in[1]);
827 op2mode = get_irn_mode(in[2]);
829 /* Rot: BB x int x int --> int */
830 mode_is_int(op1mode) &&
831 mode_is_int(op2mode) &&
834 show_binop_failure(n, "/* Rot: BB x int x int --> int */");
839 op1mode = get_irn_mode(in[1]);
841 /* Conv: BB x datab1 --> datab2 */
842 mode_is_datab(op1mode) && mode_is_data(mymode),
844 show_unop_failure(n, "/* Conv: BB x datab1 --> datab2 */");
849 op1mode = get_irn_mode(in[1]);
851 /* Conv: BB x datab1 --> datab2 */
852 mode_is_data(op1mode) && op1mode == mymode,
854 show_unop_failure(n, "/* Conv: BB x datab1 --> datab2 */");
859 /* Phi: BB x dataM^n --> dataM */
860 for (i = 1; i < get_irn_arity(n); i++) {
861 if (!is_Bad(in[i]) && (get_irn_op(in[i]) != op_Unknown))
863 get_irn_mode(in[i]) == mymode,
865 show_phi_failure(n, in[i], i);
868 ASSERT_AND_RET( mode_is_dataM(mymode), "Phi node", 0 );
872 op1mode = get_irn_mode(in[1]);
873 op2mode = get_irn_mode(in[2]);
875 /* Load: BB x M x ref --> M x X x data */
876 op1mode == mode_M && mode_is_reference(op2mode),
879 ASSERT_AND_RET( mymode == mode_T, "Load node", 0 );
883 op1mode = get_irn_mode(in[1]);
884 op2mode = get_irn_mode(in[2]);
885 op3mode = get_irn_mode(in[3]);
887 /* Load: BB x M x ref data --> M x X */
888 op1mode == mode_M && mode_is_reference(op2mode) && mode_is_data(op3mode),
891 ASSERT_AND_RET(mymode == mode_T, "Store node", 0);
895 op1mode = get_irn_mode(in[1]);
896 op2mode = get_irn_mode(in[2]);
898 /* Alloc: BB x M x int_u --> M x X x ref */
900 mode_is_int(op2mode) &&
901 !mode_is_signed(op2mode) &&
904 show_binop_failure(n, "/* Alloc: BB x M x int_u --> M x X x ref */");
909 op1mode = get_irn_mode(in[1]);
910 op2mode = get_irn_mode(in[2]);
912 /* Free: BB x M x ref --> M */
913 op1mode == mode_M && mode_is_reference(op2mode) &&
916 show_binop_failure(n, "/* Free: BB x M x ref --> M */");
921 /* Sync: BB x M^n --> M */
922 for (i=1; i < get_irn_arity(n); i++) {
923 ASSERT_AND_RET( get_irn_mode(in[i]) == mode_M, "Sync node", 0 );
925 ASSERT_AND_RET( mymode == mode_M, "Sync node", 0 );
929 return vrfy_Proj_proj(n, irg);
933 op1mode = get_irn_mode(in[1]);
934 op2mode = get_irn_mode(in[2]);
936 /* Confirm: BB x T x T --> T */
940 show_binop_failure(n, "/* Confirm: BB x T x T --> T */");
952 int irn_vrfy(ir_node *n)
956 res = irn_vrfy_irg(n, current_ir_graph);
961 /*******************************************************************/
962 /* Verify the whole graph. */
963 /*******************************************************************/
965 static void vrfy_wrap(ir_node *node, void *env)
969 *res = irn_vrfy(node);
972 int irg_vrfy(ir_graph *irg)
978 rem = current_ir_graph;
979 current_ir_graph = irg;
981 assert(get_irg_pinned(irg) == pinned);
983 irg_walk(irg->end, vrfy_wrap, NULL, &res);
985 current_ir_graph = rem;