- case iro_Start:
- assert (
- /* Start: BB --> X x M x P x data1 x ... x datan */
- mymode == mode_T
- );
- break;
- case iro_Jmp:
- assert (
- /* Jmp: BB --> X */
- mymode == mode_X
- );
- break;
- case iro_Cond:
- op1mode = get_irn_mode(in[1]);
- assert (
- /* Cond: BB x b --> X x X */
- (op1mode == mode_b
- /* Cond: BB x Iu --> X^n */
- || op1mode == mode_I)
- );
- assert (mymode == mode_T);
- break;
- case iro_Return:
- op1mode = get_irn_mode(in[1]);
- /* Return: BB x M x data1 x ... x datan --> X */
- /* printf("mode: %s, code %s\n", ID_TO_STR(n->mode->name), ID_TO_STR(n->op->name));*/
- assert ( op1mode == mode_M ); /* operand M */
- for (i=2; i < get_irn_arity(n); i++) {
- assert ( mode_is_data(get_irn_mode(in[i])) ); /* operand datai */
- };
- assert ( mymode == mode_X ); /* result X */
- break;
- case iro_Raise:
- op1mode = get_irn_mode(in[1]);
- op2mode = get_irn_mode(in[2]);
- assert (
- /* Sel: BB x M x P --> X x M */
- op1mode == mode_M && op2mode == mode_p
- && mymode == mode_T
- );
- break;
- case iro_Const:
- assert (
- /* Const: BB --> data */
- mode_is_data (mymode) ||
- mymode == mode_b /* we want boolean constants for static evaluation
- of Cmp. */
- );
- break;
- case iro_SymConst:
- assert (
- /* SymConst: BB --> Iu or
- BB --> P */
- (mymode == mode_I) || (mymode == mode_p)
- );
- break;
- case iro_Sel:
- op1mode = get_irn_mode(in[1]);
- 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
- );
- for (i=3; i < get_irn_arity(n); i++) {
- assert (get_irn_mode(in[i]) == mode_I); }
- break;
- case iro_Call:
- op1mode = get_irn_mode(in[1]);
- 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 ); /* operand M x P */
- for (i=3; i < get_irn_arity(n); i++) {
- assert ( mode_is_data(get_irn_mode(in[i])) ); /* operand datai */
- };
- assert ( mymode == mode_T ); /* result T */
- break;
- case iro_Add:
- op1mode = get_irn_mode(in[1]);
- op2mode = get_irn_mode(in[2]);
- assert (
- /* common Add: BB x num x num --> num */
- (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)
- || /* Pointer Add: BB x Is x P --> P */
- (op1mode == mode_i && op2mode == mode_p && mymode == 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 */
+ case iro_Block:
+ for (i = 0; i < get_Block_n_cfgpreds(n); ++i) {
+ ir_node *pred = get_Block_cfgpred(n, i);
+ ASSERT_AND_RET(
+ (is_Bad(pred) ||
+ is_Unknown(pred) ||
+ (get_irn_mode(pred) == mode_X)
+ ), "Block node", 0);
+ }
+ /* End block may only have Return, Raise or fragile ops as preds. */
+ if (n == get_irg_end_block(irg))
+ for (i = 0; i < get_Block_n_cfgpreds(n); ++i) {
+ 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) ||
+ is_Bad(pred) ||
+ (get_irn_op(pred) == op_Raise) ||
+ is_fragile_op(pred) ),
+ "End Block node", 0);
+ }
+ /* irg attr must == graph we are in. */
+ if (! get_interprocedural_view()) {
+ ASSERT_AND_RET(((get_irn_irg(n) && get_irn_irg(n) == irg)), "Block node has wrong irg attribute", 0);
+ }
+
+ break;
+
+ case iro_Start:
+ ASSERT_AND_RET(
+ /* Start: BB --> X x M x ref x data1 x ... x datan x ref */
+ mymode == mode_T, "Start node", 0
+ );
+ break;
+
+ case iro_Jmp:
+ ASSERT_AND_RET(
+ /* Jmp: BB --> X */
+ mymode == mode_X, "Jmp node", 0
+ );
+ break;
+
+ case iro_Break:
+ ASSERT_AND_RET(
+ /* Jmp: BB --> X */
+ mymode == mode_X, "Jmp node", 0
+ );
+ break;
+
+ case iro_Cond:
+ op1mode = get_irn_mode(in[1]);
+ ASSERT_AND_RET(
+ /* Cond: BB x b --> X x X */
+ (op1mode == mode_b ||
+ /* Cond: BB x int --> X^n */
+ mode_is_int(op1mode) ), "Cond node", 0
+ );
+ ASSERT_AND_RET(mymode == mode_T, "Cond mode is not a tuple", 0);
+ break;
+
+ case iro_Return:
+ op1mode = get_irn_mode(in[1]);
+ /* Return: BB x M x data1 x ... x datan --> X */
+ /* printf("mode: %s, code %s\n", ID_TO_STR(n->mode->name), ID_TO_STR(n->op->name));*/
+ ASSERT_AND_RET( op1mode == mode_M, "Return node", 0 ); /* operand M */
+ for (i = 2; i < get_irn_arity(n); i++) {
+ ASSERT_AND_RET( mode_is_data(get_irn_mode(in[i])), "Return node", 0 ); /* operand datai */
+ };
+ ASSERT_AND_RET( mymode == mode_X, "Result X", 0 ); /* result X */
+ /* Compare returned results with result types of method type */
+ mt = get_entity_type(get_irg_entity(irg));
+ ASSERT_AND_RET_DBG( get_Return_n_ress(n) == get_method_n_ress(mt),
+ "Number of results for Return doesn't match number of results in type.", 0,
+ show_return_nres(irg, n, mt););
+ for (i = 0; i < get_Return_n_ress(n); i++) {
+ type *res_type = get_method_res_type(mt, i);
+
+ if (is_atomic_type(res_type)) {
+ ASSERT_AND_RET_DBG(
+ get_irn_mode(get_Return_res(n, i)) == get_type_mode(res_type),
+ "Mode of result for Return doesn't match mode of result type.", 0,
+ show_return_modes(irg, n, mt, i);
+ );
+ }
+ else {
+ ASSERT_AND_RET_DBG(
+ mode_is_reference(get_irn_mode(get_Return_res(n, i))),
+ "Mode of result for Return doesn't match mode of result type.", 0,
+ show_return_modes(irg, n, mt, i);
+ );
+ }
+ }
+ break;
+
+ case iro_Raise:
+ op1mode = get_irn_mode(in[1]);
+ op2mode = get_irn_mode(in[2]);
+ ASSERT_AND_RET(
+ /* Sel: BB x M x ref --> X x M */
+ op1mode == mode_M && mode_is_reference(op2mode) &&
+ mymode == mode_T, "Raise node", 0
+ );
+ break;
+
+ case iro_Const: {
+ ASSERT_AND_RET(
+ /* Const: BB --> data */
+ (mode_is_data (mymode) ||
+ mymode == mode_b) /* we want boolean constants for static evaluation */
+ ,"Const node", 0 /* of Cmp. */
+ );
+ } break;
+ case iro_SymConst:
+ if (get_SymConst_kind(n) == symconst_addr_ent) {
+ entity *ent = get_SymConst_entity(n);
+ if (is_method_type(get_entity_type(ent)) &&
+ get_irn_irg(n) != get_const_code_irg()) {
+#if 1
+ ASSERT_AND_RET((get_entity_peculiarity(ent) != peculiarity_description),
+ "A constant must address an existing method.", 0);
+#endif
+ }
+ }
+ ASSERT_AND_RET(
+ /* SymConst: BB --> int*/
+ (mode_is_int(mymode) ||
+ /* SymConst: BB --> ref */
+ mode_is_reference(mymode))
+ ,"SymConst node", 0);
+ break;
+
+ case iro_Sel:
+ op1mode = get_irn_mode(in[1]);
+ op2mode = get_irn_mode(in[2]);
+ ASSERT_AND_RET_DBG(
+ /* Sel: BB x M x ref x int^n --> ref */
+ (op1mode == mode_M && op2mode == mymode && mode_is_reference(mymode)),
+ "Sel node", 0, show_node_failure(n)
+ );
+ for (i=3; i < get_irn_arity(n); i++)
+ {
+ ASSERT_AND_RET_DBG(mode_is_int(get_irn_mode(in[i])), "Sel node", 0, show_node_failure(n));
+ }
+ ent = get_Sel_entity(n);
+ ASSERT_AND_RET_DBG(ent, "Sel node with empty entity", 0, show_node_failure(n));
+ break;
+
+ case iro_InstOf:
+ ASSERT_AND_RET(mode_T == mymode, "mode of Instof is not a tuple", 0);
+ ASSERT_AND_RET(mode_is_data(op1mode), "Instof not on data", 0);
+ break;
+
+ case iro_Call:
+ op1mode = get_irn_mode(in[1]);
+ op2mode = get_irn_mode(in[2]);
+ /* Call: BB x M x ref x data1 x ... x datan
+ --> M x datan+1 x ... x data n+m */
+ ASSERT_AND_RET( op1mode == mode_M && mode_is_reference(op2mode), "Call node", 0 ); /* operand M x ref */
+
+ mt = get_Call_type(n);
+ if(get_unknown_type() == mt) {
+ break;
+ }
+
+ for (i=3; i < get_irn_arity(n); i++) {
+ ASSERT_AND_RET( mode_is_data(get_irn_mode(in[i])), "Call node", 0 ); /* operand datai */
+ };
+ ASSERT_AND_RET( mymode == mode_T, "Call result not a tuple", 0 ); /* result T */
+ /* Compare arguments of node with those of type */
+
+ if (get_method_variadicity(mt) == variadicity_variadic) {
+ ASSERT_AND_RET_DBG(
+ get_Call_n_params(n) >= get_method_n_params(mt),
+ "Number of args for Call doesn't match number of args in variadic type.",
+ 0,
+ fprintf(stderr, "Call has %d params, method %s type %d\n",
+ get_Call_n_params(n), get_type_name(mt), get_method_n_params(mt));
+ );
+ }
+ else {
+ ASSERT_AND_RET(
+ get_Call_n_params(n) == get_method_n_params(mt),
+ "Number of args for Call doesn't match number of args in non variadic type.",
+ 0);
+ }
+
+ for (i = 0; i < get_method_n_params(mt); i++) {
+ type *t = get_method_param_type(mt, i);
+
+ if (is_atomic_type(t)) {
+ ASSERT_AND_RET_DBG(
+ get_irn_mode(get_Call_param(n, i)) == get_type_mode(t),
+ "Mode of arg for Call doesn't match mode of arg type.", 0,
+ show_call_param(n, mt);
+ );
+ }
+ else {
+ /* call with a compound type, mode must be reference */
+ ASSERT_AND_RET_DBG(
+ mode_is_reference(get_irn_mode(get_Call_param(n, i))),
+ "Mode of arg for Call doesn't match mode of arg type.", 0,
+ show_call_param(n, mt);
+ );
+ }
+ }
+
+#if 0
+ if (Call_has_callees(n)) {
+ for (i = 0; i < get_Call_n_callees(n); i++) {
+ ASSERT_AND_RET(is_entity(get_Call_callee(n, i)), "callee array must contain entities.", 0);
+ }
+ }
+#endif
+ break;
+
+ case iro_Add:
+ op1mode = get_irn_mode(in[1]);
+ op2mode = get_irn_mode(in[2]);
+ ASSERT_AND_RET_DBG(
+ (
+ /* common Add: BB x numP x numP --> numP */
+ (op1mode == mymode && op2mode == op1mode && mode_is_numP(mymode)) ||
+ /* Pointer Add: BB x ref x int --> ref */
+ (mode_is_reference(op1mode) && mode_is_int(op2mode) && op1mode == mymode) ||
+ /* Pointer Add: BB x int x ref --> ref */
+ (mode_is_int(op1mode) && op2mode == mymode && mode_is_reference(mymode))
+ ),
+ "Add node", 0,
+ show_binop_failure(n, "/* common Add: BB x numP x numP --> numP */ |\n"
+ "/* Pointer Add: BB x ref x int --> ref */ |\n"
+ "/* Pointer Add: BB x int x ref --> ref */");
+ );
+ if (mode_is_reference(op1mode) != mode_is_reference(op2mode)) {
+ /* BB x ref x int --> ref or BB x int x ref --> ref */
+ op_is_symmetric = 0;