#include "ircons_t.h"
#include "iropt_t.h"
#include "firm_common_t.h"
-#include "irvrfy.h"
+#include "irvrfy_t.h"
#include "iropt_dbg.h"
#include "archop.h"
/**
* Returns an equivalent node for a Min/Max node.
- * We do not allow Exeptions in our Min/Max, so there will be always
+ * We do not allow Exceptions in our Min/Max, so there will be always
* an result.
* The problem is Min(NaN, NaN) == NaN ???.
*/
b = get_binop_right(n);
if (a == b) {
- DBG_OPT_ALGSIM0(n, a);
+ DBG_OPT_ALGSIM0(n, a, FS_OPT_MIN_MAX_EQ);
return a;
}
a, b,
get_irn_mode(n));
- DBG_OPT_ALGSIM1(oldn, cmp, proj, n);
+ DBG_OPT_ALGSIM1(oldn, cmp, proj, n, FS_OPT_MUX_TO_MIN);
return n;
}
else if (a == f && b == t) {
a, b,
get_irn_mode(n));
- DBG_OPT_ALGSIM1(oldn, cmp, proj, n);
+ DBG_OPT_ALGSIM1(oldn, cmp, proj, n, FS_OPT_MUX_TO_MAX);
return n;
}
}
a, b,
get_irn_mode(n));
- DBG_OPT_ALGSIM1(oldn, cmp, proj, n);
+ DBG_OPT_ALGSIM1(oldn, cmp, proj, n, FS_OPT_MUX_TO_MAX);
return n;
}
else if (a == f && b == t) {
a, b,
get_irn_mode(n));
- DBG_OPT_ALGSIM1(oldn, cmp, proj, n);
+ DBG_OPT_ALGSIM1(oldn, cmp, proj, n, FS_OPT_MUX_TO_MIN);
return n;
}
}
return n;
}
+/**
+ * verify a MinMax node
+ */
+static int verify_node_MinMax(ir_node *n, ir_graph *irg) {
+ ir_mode *mymode = get_irn_mode(n);
+ ir_mode *op1mode = get_irn_mode(get_binop_left(n));
+ ir_mode *op2mode = get_irn_mode(get_binop_right(n));
+
+ ASSERT_AND_RET(
+ /* MinMax: BB x numP x numP --> numP */
+ op1mode == mymode &&
+ op2mode == mymode &&
+ mode_is_numP(mymode),
+ "Min or Max node", 0
+ );
+ return 1;
+}
+
/*
* initialize the ops.
*/
op_Min = new_ir_op(get_next_ir_opcode(), "Min", op_pin_state_floats, irop_flag_commutative, oparity_binary, 0, 0);
op_Min->computed_value = computed_value_Min;
op_Min->equivalent_node = equivalent_node_Min;
+ op_Min->verify_node = verify_node_MinMax;
op_Max = new_ir_op(get_next_ir_opcode(), "Max", op_pin_state_floats, irop_flag_commutative, oparity_binary, 0, 0);
op_Max->computed_value = computed_value_Max;
op_Max->equivalent_node = equivalent_node_Max;
+ op_Max->verify_node = verify_node_MinMax;
}
}