- }
- 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);
- );
- }
- }
- 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;
- } else {
- /* BB x num x num --> num or BB x ref x ref */
- op_is_symmetric = 2;
- }
- break;
-
- case iro_Sub:
- op1mode = get_irn_mode(in[1]);
- op2mode = get_irn_mode(in[2]);
- ASSERT_AND_RET_DBG(
- /* common Sub: BB x numP x numP --> numP */
- ((mymode ==op1mode && mymode == op2mode && mode_is_numP(op1mode)) ||
- /* Pointer Sub: BB x ref x int --> ref */
- (op1mode == mymode && mode_is_int(op2mode) && mode_is_reference(mymode)) ||
- /* Pointer Sub: BB x int x ref --> ref */
- (mode_is_int(op1mode) && op2mode == mymode && mode_is_reference(mymode)) ||
- /* Pointer Sub: BB x ref x ref --> int */
- (op1mode == op2mode && mode_is_reference(op2mode) && mode_is_int(mymode))),
- "Sub node", 0,
- show_binop_failure(n, "/* common Sub: BB x numP x numP --> numP */ |\n"
- "/* Pointer Sub: BB x ref x int --> ref */ |\n"
- "/* Pointer Sub: BB x int x ref --> ref */ |\n"
- "/* Pointer Sub: BB x ref x ref --> int */" );
- );
- if (mode_is_reference(op1mode) != mode_is_reference(op2mode)) {
- op_is_symmetric = 0;
- } else {
- op_is_symmetric = 2;
- }
- break;
-
- case iro_Minus:
- op1mode = get_irn_mode(in[1]);
- ASSERT_AND_RET_DBG(
- /* Minus: BB x float --> float */
- op1mode == mymode && mode_is_float(op1mode), "Minus node", 0,
- show_unop_failure(n , "/* Minus: BB x float --> float */");
- );
- op_is_symmetric = 2;
- break;
-
- case iro_Mul:
- op1mode = get_irn_mode(in[1]);
- op2mode = get_irn_mode(in[2]);
- ASSERT_AND_RET_DBG(
- /* Mul: BB x int1 x int1 --> int2 */
- ((mode_is_int(op1mode) && op2mode == op1mode && mode_is_int(mymode)) ||
- /* Mul: BB x float x float --> float */
- (mode_is_float(op1mode) && op2mode == op1mode && mymode == op1mode)),
- "Mul node",0,
- show_binop_failure(n, "/* Mul: BB x int1 x int1 --> int2 */ |\n"
- "/* Mul: BB x float x float --> float */");
- );
- op_is_symmetric = 2;
- break;
-
- case iro_Quot:
- op1mode = get_irn_mode(in[1]);
- op2mode = get_irn_mode(in[2]);
- op3mode = get_irn_mode(in[3]);
- ASSERT_AND_RET_DBG(
- /* Quot: BB x M x float x float --> M x X x float */
- op1mode == mode_M && op2mode == op3mode &&
- get_mode_sort(op2mode) == irms_float_number &&
- mymode == mode_T,
- "Quot node",0,
- show_binop_failure(n, "/* Quot: BB x M x float x float --> M x X x float */");
- );
- op_is_symmetric = 2;
- break;
-
- case iro_DivMod:
- op1mode = get_irn_mode(in[1]);
- op2mode = get_irn_mode(in[2]);
- op3mode = get_irn_mode(in[3]);
- ASSERT_AND_RET(
- /* DivMod: BB x M x int x int --> M x X x int x int */
- op1mode == mode_M &&
- mode_is_int(op2mode) &&
- op3mode == op2mode &&
- mymode == mode_T,
- "DivMod node", 0
- );
- op_is_symmetric = 1;
- break;
-
- case iro_Div:
- case iro_Mod:
- op1mode = get_irn_mode(in[1]);
- op2mode = get_irn_mode(in[2]);
- op3mode = get_irn_mode(in[3]);
- ASSERT_AND_RET(
- /* Div or Mod: BB x M x int x int --> M x X x int */
- op1mode == mode_M &&
- op2mode == op3mode &&
- mode_is_int(op2mode) &&
- mymode == mode_T,
- "Div or Mod node", 0
- );
- op_is_symmetric = 1;
- break;
-
- case iro_Abs:
- op1mode = get_irn_mode(in[1]);
- ASSERT_AND_RET_DBG(
- /* Abs: BB x num --> num */
- op1mode == mymode &&
- mode_is_num (op1mode),
- "Abs node", 0,
- show_unop_failure(n, "/* Abs: BB x num --> num */");
- );
- op_is_symmetric = 2;
- break;
-
- case iro_And:
- case iro_Or:
- case iro_Eor:
- op1mode = get_irn_mode(in[1]);
- op2mode = get_irn_mode(in[2]);
- ASSERT_AND_RET_DBG(
- /* And or Or or Eor: BB x int x int --> int */
- mode_is_int(mymode) &&
- op2mode == op1mode &&
- mymode == op2mode,
- "And, Or or Eor node", 0,
- show_binop_failure(n, "/* And or Or or Eor: BB x int x int --> int */");
- );
- op_is_symmetric = 2;
- break;
-
- case iro_Not:
- op1mode = get_irn_mode(in[1]);
- ASSERT_AND_RET_DBG(
- /* Not: BB x int --> int */
- mode_is_int(mymode) &&
- mymode == op1mode,
- "Not node", 0,
- show_unop_failure(n, "/* Not: BB x int --> int */");
- );
- op_is_symmetric = 2;
- break;
-
-
- case iro_Cmp:
- op1mode = get_irn_mode(in[1]);
- op2mode = get_irn_mode(in[2]);
- ASSERT_AND_RET_DBG(
- /* Cmp: BB x datab x datab --> b16 */
- mode_is_data (op1mode) &&
- op2mode == op1mode &&
- mymode == mode_T,
- "Cmp node", 0,
- show_binop_failure(n, "/* Cmp: BB x datab x datab --> b16 */");
- );
- break;
-
- case iro_Shl:
- case iro_Shr:
- case iro_Shrs:
- op1mode = get_irn_mode(in[1]);
- op2mode = get_irn_mode(in[2]);
- ASSERT_AND_RET_DBG(
- /* Shl, Shr or Shrs: BB x int x int_u --> int */
- mode_is_int(op1mode) &&
- mode_is_int(op2mode) &&
- !mode_is_signed(op2mode) &&
- mymode == op1mode,
- "Shl, Shr, Shr or Rot node", 0,
- show_binop_failure(n, "/* Shl, Shr or Shrs: BB x int x int_u --> int */");
- );
- break;
-
- case iro_Rot:
- op1mode = get_irn_mode(in[1]);
- op2mode = get_irn_mode(in[2]);
- ASSERT_AND_RET_DBG(
- /* Rot: BB x int x int --> int */
- mode_is_int(op1mode) &&
- mode_is_int(op2mode) &&
- mymode == op1mode,
- "Rot node", 0,
- show_binop_failure(n, "/* Rot: BB x int x int --> int */");
- );
- break;
-
- case iro_Conv:
- op1mode = get_irn_mode(in[1]);
- ASSERT_AND_RET_DBG(
- /* Conv: BB x datab1 --> datab2 */
- mode_is_datab(op1mode) && mode_is_data(mymode),
- "Conv node", 0,
- show_unop_failure(n, "/* Conv: BB x datab1 --> datab2 */");
- );
- break;
-
- case iro_Cast:
- op1mode = get_irn_mode(in[1]);
- ASSERT_AND_RET_DBG(
- /* Conv: BB x datab1 --> datab2 */
- mode_is_data(op1mode) && op1mode == mymode,
- "Cast node", 0,
- show_unop_failure(n, "/* Conv: BB x datab1 --> datab2 */");
- );
- break;
-
- case iro_Phi:
- {
- ir_node *block = get_nodes_block(n);
-
- if (! is_Bad(block) && get_irg_phase_state(get_irn_irg(n)) != phase_building) {
- /* a Phi node MUST have the same number of inputs as its block */
- ASSERT_AND_RET_DBG(
- get_irn_arity(n) == get_irn_arity(block),
- "wrong number of inputs in Phi node", 0,
- show_phi_inputs(n, block);