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));
172 vrfy_Proj_proj(ir_node *p, ir_graph *irg) {
177 pred = skip_nop(get_Proj_pred(p));
178 assert(get_irn_mode(pred) == mode_T);
179 mode = get_irn_mode(p);
180 proj = get_Proj_proj(p);
182 switch (get_irn_opcode(pred)) {
186 (proj == pns_initial_exec && mode == mode_X) ||
187 (proj == pns_global_store && mode == mode_M) ||
188 (proj == pns_frame_base && mode_is_reference(mode)) ||
189 (proj == pns_globals && mode_is_reference(mode)) ||
190 (proj == pns_args && mode == mode_T) ||
191 (proj == pns_value_arg_base && mode_is_reference(mode))
193 "wrong Proj from Start", 0,
194 show_proj_failure(p);
200 (proj >= 0 && mode == mode_X),
201 "wrong Proj from Cond", 0,
202 show_proj_failure(p);
208 ((proj == pn_Raise_X && mode == mode_X) || (proj == pn_Raise_M && mode == mode_M)),
209 "wrong Proj from Raise", 0,
210 show_proj_failure(p);
216 (proj >= 0 && mode == mode_X),
217 "wrong Proj from InstOf", 0,
218 show_proj_failure(p);
224 ((proj == pn_Call_M_regular && mode == mode_M) ||
225 (proj == pn_Call_X_except && mode == mode_X) ||
226 (proj == pn_Call_T_result && mode == mode_T) ||
227 (proj == pn_Call_M_except && mode == mode_M) ||
228 (proj == pn_Call_P_value_res_base && mode == mode_P)),
229 "wrong Proj from Call", 0,
230 show_proj_failure(p);
236 ((proj == pn_Quot_M && mode == mode_M) ||
237 (proj == pn_Quot_X_except && mode == mode_X) ||
238 (proj == pn_Quot_res && mode_is_float(mode))),
239 "wrong Proj from Quot", 0,
240 show_proj_failure(p);
246 ((proj == pn_DivMod_M && mode == mode_M) ||
247 (proj == pn_DivMod_X_except && mode == mode_X) ||
248 (proj == pn_DivMod_res_div && mode_is_int(mode)) ||
249 (proj == pn_DivMod_res_mod && mode_is_int(mode))),
250 "wrong Proj from DivMod", 0,
251 show_proj_failure(p);
257 ((proj == pn_Div_M && mode == mode_M) ||
258 (proj == pn_Div_X_except && mode == mode_X) ||
259 (proj == pn_Div_res && mode_is_int(mode))),
260 "wrong Proj from Div or Mod", 0,
261 show_proj_failure(p);
267 ((proj == pn_Mod_M && mode == mode_M) ||
268 (proj == pn_Mod_X_except && mode == mode_X) ||
269 (proj == pn_Mod_res && mode_is_int(mode))),
270 "wrong Proj from Div or Mod", 0,
271 show_proj_failure(p);
277 (proj >= 0 && proj <= 15 && mode == mode_b),
278 "wrong Proj from Cmp", 0,
279 show_proj_failure(p);
284 if (proj == pn_Load_res) {
285 ir_node *ptr = get_Load_ptr(pred);
287 if (get_irn_op(ptr) == op_Sel) {
288 ent = get_Sel_entity(ptr);
290 We may not test this, after lowering and optimization the Const can
291 have an unexpected type.
292 else if ((get_irn_op(ptr) == op_Const) &&
293 tarval_is_entity(get_Const_tarval(ptr))) {
294 ent = get_tarval_entity(get_Const_tarval(ptr));
298 (mode == get_type_mode(get_entity_type(ent))),
299 "wrong data Proj from Load, entity type_mode failed", 0,
300 show_proj_failure_ent(p, ent);
306 "wrong data Proj from Load", 0,
307 show_proj_failure(p);
312 ((proj == pn_Load_M && mode == mode_M) ||
313 (proj == pn_Load_X_except && mode == mode_X)),
314 "wrong Proj from Load", 0,
315 show_proj_failure(p);
322 ((proj == pn_Store_M && mode == mode_M) ||
323 (proj == pn_Store_X_except && mode == mode_X)),
324 "wrong Proj from Store", 0,
325 show_proj_failure(p);
332 (proj == pn_Alloc_M && mode == mode_M) ||
333 (proj == pn_Alloc_X_except /* && mode == mode_X*/) ||
334 (proj == pn_Alloc_res && mode_is_reference(mode))
336 "wrong Proj from Alloc", 0,
337 show_proj_failure(p);
343 type *mt; /* A method type */
344 pred = skip_nop(get_Proj_pred(pred));
345 ASSERT_AND_RET((get_irn_mode(pred) == mode_T), "Proj from something not a tuple", 0);
346 switch (get_irn_opcode(pred))
351 (proj >= 0 && mode_is_data(mode)),
352 "wrong Proj from Proj from Start", 0);
353 mt = get_entity_type(get_irg_ent(irg));
355 (proj < get_method_n_params(mt)),
356 "More Projs for args than args in type", 0
358 if ((mode_is_reference(mode)) && is_compound_type(get_method_param_type(mt, proj)))
359 /* value argument */ break;
362 (mode == get_type_mode(get_method_param_type(mt, proj))),
363 "Mode of Proj from Start doesn't match mode of param type.", 0);
370 (proj >= 0 && mode_is_data(mode)),
371 "wrong Proj from Proj from Call", 0);
372 mt = get_Call_type(pred);
374 (proj < get_method_n_ress(mt)),
375 "More Projs for results than results in type.", 0);
376 if ((mode_is_reference(mode)) && is_compound_type(get_method_res_type(mt, proj)))
377 /* value result */ break;
380 (mode == get_type_mode(get_method_res_type(mt, proj))),
381 "Mode of Proj from Call doesn't match mode of result type.", 0);
390 ASSERT_AND_RET(0, "Unknown opcode", 0);
409 ASSERT_AND_RET(0, "Unknown opcode", 0);
416 int irn_vrfy_irg(ir_node *n, ir_graph *irg)
420 ir_mode *mymode, *op1mode = NULL, *op2mode, *op3mode;
421 int op_is_symmetric = 1; /* 0: asymmetric
422 1: operands have identical modes
423 2: modes of operands == mode of this node */
424 type *mt; /* A method type */
428 if (!opt_do_node_verification) return 1;
430 if (! interprocedural_view) {
432 * do NOT check placement in interprocedural view, as we don't always know
433 * the "right" graph ...
436 node_is_in_irgs_storage(irg, n),
437 "Node is not stored on proper IR graph!", 0,
438 show_node_on_graph(irg, n);
442 opcode = get_irn_opcode (n);
444 /* We don't want to test nodes whose predecessors are Bad or Unknown,
445 as we would have to special case that for each operation. */
446 if (opcode != iro_Phi && opcode != iro_Block)
447 for (i = 0; i < get_irn_arity(n); i++) {
448 opcode1 = get_irn_opcode(get_irn_n(n, i));
449 if (opcode1 == iro_Bad /*|| opcode1 == iro_Unknown*/) /* GL: for analyses mode must be correct. */
453 mymode = get_irn_mode (n);
460 for (i = 0; i < get_Block_n_cfgpreds(n); ++i) {
461 ir_node *pred = get_Block_cfgpred(n, i);
465 (get_irn_mode(pred) == mode_X)
468 // End block may only have Return, Raise or fragile ops as preds.
469 if (n == get_irg_end_block(irg))
470 for (i = 0; i < get_Block_n_cfgpreds(n); ++i) {
471 ir_node *pred = skip_Proj(get_Block_cfgpred(n, i));
472 if (is_Proj(pred) || get_irn_op(pred) == op_Tuple)
473 break; // We can not test properly. How many tuples are there?
474 ASSERT_AND_RET(((get_irn_op(pred) == op_Return) ||
476 (get_irn_op(pred) == op_Raise) ||
477 is_fragile_op(pred) ),
478 "End Block node", 0);
480 // irg attr must == graph we are in.
481 if (! interprocedural_view) {
482 ASSERT_AND_RET(((get_irn_irg(n) && get_irn_irg(n) == irg)), "Block node has wrong irg attribute", 0);
489 /* Start: BB --> X x M x ref x data1 x ... x datan x ref */
490 mymode == mode_T, "Start node", 0
497 mymode == mode_X, "Jmp node", 0
504 mymode == mode_X, "Jmp node", 0
509 op1mode = get_irn_mode(in[1]);
511 /* Cond: BB x b --> X x X */
512 (op1mode == mode_b ||
513 /* Cond: BB x int --> X^n */
514 mode_is_int(op1mode) ), "Cond node", 0
516 ASSERT_AND_RET(mymode == mode_T, "Cond mode is not a tuple", 0);
520 op1mode = get_irn_mode(in[1]);
521 /* Return: BB x M x data1 x ... x datan --> X */
522 /* printf("mode: %s, code %s\n", ID_TO_STR(n->mode->name), ID_TO_STR(n->op->name));*/
523 ASSERT_AND_RET( op1mode == mode_M, "Return node", 0 ); /* operand M */
524 for (i=2; i < get_irn_arity(n); i++) {
525 ASSERT_AND_RET( mode_is_data(get_irn_mode(in[i])), "Return node", 0 ); /* operand datai */
527 ASSERT_AND_RET( mymode == mode_X, "Result X", 0 ); /* result X */
528 /* Compare returned results with result types of method type */
529 mt = get_entity_type(get_irg_ent(irg));
530 ASSERT_AND_RET_DBG( get_Return_n_ress(n) == get_method_n_ress(mt),
531 "Number of results for Return doesn't match number of results in type.", 0,
532 show_return_nres(irg, n, mt););
533 for (i = 0; i < get_Return_n_ress(n); i++)
535 get_irn_mode(get_Return_res(n, i)) == get_type_mode(get_method_res_type(mt, i)),
536 "Mode of result for Return doesn't match mode of result type.", 0,
537 show_return_modes(irg, n, mt, i););
541 op1mode = get_irn_mode(in[1]);
542 op2mode = get_irn_mode(in[2]);
544 /* Sel: BB x M x ref --> X x M */
545 op1mode == mode_M && mode_is_reference(op2mode) &&
546 mymode == mode_T, "Raise node", 0
552 /* Const: BB --> data */
553 (mode_is_data (mymode) ||
554 mymode == mode_b) /* we want boolean constants for static evaluation */
555 ,"Const node", 0 /* of Cmp. */
561 /* SymConst: BB --> int*/
562 (mode_is_int(mymode) ||
563 /* SymConst: BB --> ref */
564 mode_is_reference(mymode))
565 ,"SymConst node", 0);
569 op1mode = get_irn_mode(in[1]);
570 op2mode = get_irn_mode(in[2]);
572 /* Sel: BB x M x ref x int^n --> ref */
573 (op1mode == mode_M && op2mode == mymode && mode_is_reference(mymode)),
576 for (i=3; i < get_irn_arity(n); i++)
578 ASSERT_AND_RET(mode_is_int(get_irn_mode(in[i])), "Sel node", 0);
583 ASSERT_AND_RET(mode_T == mymode, "mode of Instof is not a tuple", 0);
584 ASSERT_AND_RET(mode_is_data(op1mode), "Instof not on data", 0);
588 op1mode = get_irn_mode(in[1]);
589 op2mode = get_irn_mode(in[2]);
590 /* Call: BB x M x ref x data1 x ... x datan
591 --> M x datan+1 x ... x data n+m */
592 ASSERT_AND_RET( op1mode == mode_M && mode_is_reference(op2mode), "Call node", 0 ); /* operand M x ref */
593 for (i=3; i < get_irn_arity(n); i++) {
594 ASSERT_AND_RET( mode_is_data(get_irn_mode(in[i])), "Call node", 0 ); /* operand datai */
596 ASSERT_AND_RET( mymode == mode_T, "Call result not a tuple", 0 ); /* result T */
597 /* Compare arguments of node with those of type */
598 mt = get_Call_type(n);
600 if (get_method_variadicity(mt) == variadicity_variadic) {
602 get_Call_n_params(n) >= get_method_n_params(mt),
603 "Number of args for Call doesn't match number of args in variadic type.",
605 fprintf(stderr, "Call has %d params, method %s type %d\n",
606 get_Call_n_params(n), get_type_name(mt), get_method_n_params(mt));
611 get_Call_n_params(n) == get_method_n_params(mt),
612 "Number of args for Call doesn't match number of args in non variadic type.",
616 for (i = 0; i < get_method_n_params(mt); i++) {
618 get_irn_mode(get_Call_param(n, i)) == get_type_mode(get_method_param_type(mt, i)),
619 "Mode of arg for Call doesn't match mode of arg type.", 0,
620 show_call_param(n, mt);
626 op1mode = get_irn_mode(in[1]);
627 op2mode = get_irn_mode(in[2]);
630 /* common Add: BB x numP x numP --> numP */
631 (op1mode == mymode && op2mode == op1mode && mode_is_numP(mymode)) ||
632 /* Pointer Add: BB x ref x int --> ref */
633 (mode_is_reference(op1mode) && mode_is_int(op2mode) && op1mode == mymode) ||
634 /* Pointer Add: BB x int x ref --> ref */
635 (mode_is_int(op1mode) && op2mode == mymode && mode_is_reference(mymode))
638 show_binop_failure(n, "/* common Add: BB x numP x numP --> numP */ |\n"
639 "/* Pointer Add: BB x ref x int --> ref */ |\n"
640 "/* Pointer Add: BB x int x ref --> ref */");
642 if (mode_is_reference(op1mode) != mode_is_reference(op2mode)) {
643 /* BB x ref x int --> ref or BB x int x ref --> ref */
646 /* BB x num x num --> num or BB x ref x ref */
652 op1mode = get_irn_mode(in[1]);
653 op2mode = get_irn_mode(in[2]);
655 /* common Sub: BB x numP x numP --> numP */
656 ((mymode ==op1mode && mymode == op2mode && mode_is_numP(op1mode)) ||
657 /* Pointer Sub: BB x ref x int --> ref */
658 (op1mode == mymode && mode_is_int(op2mode) && mode_is_reference(mymode)) ||
659 /* Pointer Sub: BB x int x ref --> ref */
660 (mode_is_int(op1mode) && op2mode == mymode && mode_is_reference(mymode)) ||
661 /* Pointer Sub: BB x ref x ref --> int */
662 (op1mode == op2mode && mode_is_reference(op2mode) && mode_is_int(mymode))),
664 show_binop_failure(n, "/* common Sub: BB x numP x numP --> numP */ |\n"
665 "/* Pointer Sub: BB x ref x int --> ref */ |\n"
666 "/* Pointer Sub: BB x int x ref --> ref */ |\n"
667 "/* Pointer Sub: BB x ref x ref --> int */" );
669 if (mode_is_reference(op1mode) != mode_is_reference(op2mode)) {
677 op1mode = get_irn_mode(in[1]);
679 /* Minus: BB x float --> float */
680 op1mode == mymode && get_mode_sort(op1mode) == irms_float_number, "Minus node", 0,
681 show_unop_failure(n , "/* Minus: BB x float --> float */");
687 op1mode = get_irn_mode(in[1]);
688 op2mode = get_irn_mode(in[2]);
690 /* Mul: BB x int1 x int1 --> int2 */
691 ((mode_is_int(op1mode) && op2mode == op1mode && mode_is_int(mymode)) ||
692 (mode_is_float(op1mode) && op2mode == op1mode && mymode == op1mode)),
694 show_binop_failure(n, "/* Mul: BB x int1 x int1 --> int2 */");
700 op1mode = get_irn_mode(in[1]);
701 op2mode = get_irn_mode(in[2]);
702 op3mode = get_irn_mode(in[3]);
704 /* Quot: BB x M x float x float --> M x X x float */
705 op1mode == mode_M && op2mode == op3mode &&
706 get_mode_sort(op2mode) == irms_float_number &&
709 show_binop_failure(n, "/* Quot: BB x M x float x float --> M x X x float */");
715 op1mode = get_irn_mode(in[1]);
716 op2mode = get_irn_mode(in[2]);
717 op3mode = get_irn_mode(in[3]);
719 /* DivMod: BB x M x int x int --> M x X x int x int */
721 mode_is_int(op2mode) &&
722 op3mode == op2mode &&
731 op1mode = get_irn_mode(in[1]);
732 op2mode = get_irn_mode(in[2]);
733 op3mode = get_irn_mode(in[3]);
735 /* Div or Mod: BB x M x int x int --> M x X x int */
737 op2mode == op3mode &&
738 mode_is_int(op2mode) &&
746 op1mode = get_irn_mode(in[1]);
748 /* Abs: BB x num --> num */
750 mode_is_num (op1mode),
752 show_unop_failure(n, "/* Abs: BB x num --> num */");
760 op1mode = get_irn_mode(in[1]);
761 op2mode = get_irn_mode(in[2]);
763 /* And or Or or Eor: BB x int x int --> int */
764 mode_is_int(mymode) &&
765 op2mode == op1mode &&
767 "And, Or or Eor node", 0,
768 show_binop_failure(n, "/* And or Or or Eor: BB x int x int --> int */");
774 op1mode = get_irn_mode(in[1]);
776 /* Not: BB x int --> int */
777 mode_is_int(mymode) &&
780 show_unop_failure(n, "/* Not: BB x int --> int */");
787 op1mode = get_irn_mode(in[1]);
788 op2mode = get_irn_mode(in[2]);
790 /* Cmp: BB x datab x datab --> b16 */
791 mode_is_data (op1mode) &&
792 op2mode == op1mode &&
795 show_binop_failure(n, "/* Cmp: BB x datab x datab --> b16 */");
802 op1mode = get_irn_mode(in[1]);
803 op2mode = get_irn_mode(in[2]);
805 /* Shl, Shr or Shrs: BB x int x int_u --> int */
806 mode_is_int(op1mode) &&
807 mode_is_int(op2mode) &&
808 !mode_is_signed(op2mode) &&
810 "Shl, Shr, Shr or Rot node", 0,
811 show_binop_failure(n, "/* Shl, Shr or Shrs: BB x int x int_u --> int */");
816 op1mode = get_irn_mode(in[1]);
817 op2mode = get_irn_mode(in[2]);
819 /* Rot: BB x int x int --> int */
820 mode_is_int(op1mode) &&
821 mode_is_int(op2mode) &&
824 show_binop_failure(n, "/* Rot: BB x int x int --> int */");
829 op1mode = get_irn_mode(in[1]);
831 /* Conv: BB x datab1 --> datab2 */
832 mode_is_datab(op1mode) && mode_is_data(mymode),
834 show_unop_failure(n, "/* Conv: BB x datab1 --> datab2 */");
839 op1mode = get_irn_mode(in[1]);
841 /* Conv: BB x datab1 --> datab2 */
842 mode_is_data(op1mode) && op1mode == mymode,
844 show_unop_failure(n, "/* Conv: BB x datab1 --> datab2 */");
849 /* Phi: BB x dataM^n --> dataM */
850 /* for some reason "<=" aborts. int there a problem with get_store? */
851 for (i=1; i < get_irn_arity(n); i++) {
852 if (!is_Bad(in[i]) && (get_irn_op(in[i]) != op_Unknown))
853 ASSERT_AND_RET( get_irn_mode(in[i]) == mymode, "Phi node", 0);
855 ASSERT_AND_RET( mode_is_dataM(mymode), "Phi node", 0 );
859 op1mode = get_irn_mode(in[1]);
860 op2mode = get_irn_mode(in[2]);
862 /* Load: BB x M x ref --> M x X x data */
863 op1mode == mode_M && mode_is_reference(op2mode),
866 ASSERT_AND_RET( mymode == mode_T, "Load node", 0 );
870 op1mode = get_irn_mode(in[1]);
871 op2mode = get_irn_mode(in[2]);
872 op3mode = get_irn_mode(in[3]);
874 /* Load: BB x M x ref data --> M x X */
875 op1mode == mode_M && mode_is_reference(op2mode) && mode_is_data(op3mode),
878 ASSERT_AND_RET(mymode == mode_T, "Store node", 0);
882 op1mode = get_irn_mode(in[1]);
883 op2mode = get_irn_mode(in[2]);
885 /* Alloc: BB x M x int_u --> M x X x ref */
887 mode_is_int(op2mode) &&
888 !mode_is_signed(op2mode) &&
891 show_binop_failure(n, "/* Alloc: BB x M x int_u --> M x X x ref */");
896 op1mode = get_irn_mode(in[1]);
897 op2mode = get_irn_mode(in[2]);
899 /* Free: BB x M x ref --> M */
900 op1mode == mode_M && mode_is_reference(op2mode) &&
903 show_binop_failure(n, "/* Free: BB x M x ref --> M */");
908 /* Sync: BB x M^n --> M */
909 for (i=1; i < get_irn_arity(n); i++) {
910 ASSERT_AND_RET( get_irn_mode(in[i]) == mode_M, "Sync node", 0 );
912 ASSERT_AND_RET( mymode == mode_M, "Sync node", 0 );
916 return vrfy_Proj_proj(n, irg);
920 op1mode = get_irn_mode(in[1]);
921 op2mode = get_irn_mode(in[2]);
923 /* Confirm: BB x T x T --> T */
927 show_binop_failure(n, "/* Confirm: BB x T x T --> T */");
939 int irn_vrfy(ir_node *n)
943 res = irn_vrfy_irg(n, current_ir_graph);
948 /*******************************************************************/
949 /* Verify the whole graph. */
950 /*******************************************************************/
952 static void vrfy_wrap(ir_node *node, void *env)
956 *res = irn_vrfy(node);
959 int irg_vrfy(ir_graph *irg)
965 rem = current_ir_graph;
966 current_ir_graph = irg;
968 assert(get_irg_pinned(irg) == pinned);
970 irg_walk(irg->end, vrfy_wrap, NULL, &res);
972 current_ir_graph = rem;