# WARNING: this is generated by running 'nowhere treecode-simplify.in'.
# Do not edit this file directly.
# Version 1.2.2
#
# "algebraic simplification and constant folding for [treecode]."
# -- http://www.cs.nyu.edu/leunga/MLRISC/Doc/html/mltree-util.html
# Compiled by:
#
src/lib/compiler/back/low/lib/treecode.lib#DO set_control "compiler::trap_int_overflow" "TRUE";
# We are nowhere invoked.
###line 15.1 "treecode-simplify::in"
generic package treecode_simplifier_g (
###line 16.4 "treecode-simplify::in"
package tcf: Treecode_Form; # Treecode_Form is from
src/lib/compiler/back/low/treecode/treecode-form.api###line 17.4 "treecode-simplify::in"
# This arg is never referenced:
package tsz: Treecode_Bitsize # Treecode_Bitsize is from
src/lib/compiler/back/low/treecode/treecode-bitsize.api where tcf == tcf;
###line 20.4 "treecode-simplify::in"
sext: tcf::Rewrite_Fns -> tcf::Sext -> tcf::Sext;
###line 21.4 "treecode-simplify::in"
rext: tcf::Rewrite_Fns -> tcf::Rext -> tcf::Rext;
###line 22.4 "treecode-simplify::in"
fext: tcf::Rewrite_Fns -> tcf::Fext -> tcf::Fext;
###line 23.4 "treecode-simplify::in"
ccext: tcf::Rewrite_Fns -> tcf::Ccext -> tcf::Ccext;
)
: (weak) Treecode_Simplifier # Treecode_Simplifier is from
src/lib/compiler/back/low/treecode/treecode-simplifier.api=
package {
###line 27.4 "treecode-simplify::in"
# Export to client packages:
#
package tcf = tcf;
###line 28.4 "treecode-simplify::in"
package i = tcf::mi; # "mi" == "machine_int".
###line 29.4 "treecode-simplify::in"
package r = treecode_rewrite_g
(
###line 30.7 "treecode-simplify::in"
package tcf = tcf; # "tcf" == "treecode_form".
###line 31.7 "treecode-simplify::in"
sext = sext;
rext = rext;
fext = fext;
ccext = ccext;
);
###line 34.4 "treecode-simplify::in"
Simplifier = tcf::Rewrite_Fns;
###line 36.4 "treecode-simplify::in"
lit_11 = (multiword_int::from_int 0);
lit_16 = (multiword_int::from_int 1);
###line 37.4 "treecode-simplify::in"
zero = (multiword_int::from_int 0);
###line 38.4 "treecode-simplify::in"
zero_t = tcf::LITERAL zero;
###line 40.4 "treecode-simplify::in"
fun simplify { address_width, signed_address } =
{
###line 43.4 "treecode-simplify::in"
fun dm (tcf::d::ROUND_TO_ZERO ) => i::DIV_TO_ZERO;
dm (tcf::d::ROUND_TO_NEGINF) => i::DIV_TO_NEGINF;
end;
###line 46.4 "treecode-simplify::in"
fun sim ===> expression =
{ v_3 = expression;
fun state_165 e = e;
fun state_149 () = zero_t;
fun state_158 () = zero_t;
fun state_180 v_3 =
{ expression = v_3;
expression;
};
fun state_118 (v_1, v_4) =
{ b = v_4;
type = v_1;
b;
};
fun state_15 (v_1, v_0) =
{ a = v_0;
type = v_1;
a;
};
fun state_148 v_1 =
{ type = v_1;
zero_t;
};
fun state_140 v_1 =
{ type = v_1;
zero_t;
};
fun state_157 v_1 =
{ type = v_1;
zero_t;
};
fun state_109 v_4 =
{ b = v_4;
b;
};
fun state_45 (v_1, v_4) =
{ type = v_1;
x = v_4;
x;
};
fun state_43 v_1 =
{ type = v_1;
zero_t;
};
fun state_47 (v_1, v_0) =
{ type = v_1;
x = v_0;
x;
};
fun state_85 (v_1, v_4) =
{ type = v_1;
x = v_4;
x;
};
fun state_83 v_1 =
{ type = v_1;
zero_t;
};
fun state_87 (v_1, v_0) =
{ type = v_1;
x = v_0;
x;
};
fun state_23 (v_1, v_4) =
{ type = v_1;
x = v_4;
x;
};
fun state_21 v_1 =
{ type = v_1;
zero_t;
};
fun state_25 (v_1, v_0) =
{ type = v_1;
x = v_0;
x;
};
fun state_127 (v_1, v_4) =
{ b = v_4;
type = v_1;
zero_t;
};
fun state_100 v_0 =
{ a = v_0;
a;
};
fun state_69 (v_1, v_0) =
{ type = v_1;
x = v_0;
x;
};
fun state_5 (v_1, v_0) =
{ type = v_1;
x = v_0;
x;
};
fun state_1717 (v_3, v_1, v_10, v_4)
=
if ((multiword_int::compare (v_10, lit_11)) == EQUAL)
(state_118 (v_1, v_4));
else (state_180 v_3);fi;
fun state_1450 (v_3, v_1, v_0, v_2)
=
if ((multiword_int::compare (v_2, lit_11)) == EQUAL)
(state_15 (v_1, v_0));
else (state_180 v_3);fi;
fun state_1279 (v_3, v_1, v_10) = (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
(state_148 v_1);
else (state_180 v_3);fi);
fun state_1192 (v_3, v_1, v_10) = (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
(state_140 v_1);
else (state_180 v_3);fi);
fun state_1021 (v_3, v_1, v_10) = (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
(state_157 v_1);
else (state_180 v_3);fi);
fun state_916 (v_3, v_10, v_4) = (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
(state_109 v_4);
else (state_180 v_3);fi);
fun state_820 (v_3, v_1, v_0, v_2) = (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
(state_43 v_1);
else (if (((multiword_int::compare (v_2, lit_16)) == EQUAL))
(state_47 (v_1, v_0));
else (state_180 v_3);fi);fi);
fun state_731 (v_3, v_1, v_0, v_2) = (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
(state_83 v_1);
else (if (((multiword_int::compare (v_2, lit_16)) == EQUAL))
(state_87 (v_1, v_0));
else (state_180 v_3);fi);fi);
fun state_642 (v_3, v_1, v_0, v_2) = (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
(state_21 v_1);
else (if (((multiword_int::compare (v_2, lit_16)) == EQUAL))
(state_25 (v_1, v_0));
else (state_180 v_3);fi);fi);
fun state_555 (v_3, v_1, v_10, v_4) = (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
(state_127 (v_1, v_4));
else (state_180 v_3);fi);
fun state_441 (v_3, v_0, v_10) = (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
(state_100 v_0);
else (state_180 v_3);fi);
fun state_354 (v_3, v_1, v_0, v_2) = (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
(state_69 (v_1, v_0));
else (state_180 v_3);fi);
fun state_181 (v_3, v_1, v_0, v_2) = (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
(state_5 (v_1, v_0));
else (state_180 v_3);fi);
fun state_1451 (v_3, v_1, v_0, v_4) =
(case v_4
tcf::LITERAL v_2 => state_1450 (v_3, v_1, v_0, v_2);
_ => state_180 v_3; esac
);
fun state_182 (v_3, v_1, v_0, v_4) =
(case v_4
tcf::LITERAL v_2 => state_181 (v_3, v_1, v_0, v_2);
_ => state_180 v_3; esac
);
(case v_3
tcf::ADD v_5 =>
{ my (v_1, v_0, v_4) = v_5;
(case v_0
tcf::ADD v_10 =>
{ my (v_7, v_9, v_13) = v_10;
(case v_13
tcf::LITERAL v_12 =>
(case v_4
tcf::LITERAL v_2 =>
{ a = v_9;
type = v_1;
type' = v_7;
x = v_12;
y = v_2;
(if ((type == type'))
(tcf::ADD (type, a, tcf::LITERAL (i::add (type, x, y))));
else (state_181 (v_3, v_1, v_0, v_2));fi);
};
_ => state_180 v_3; esac
);
_ => state_182 (v_3, v_1, v_0, v_4); esac
);
};
tcf::LABEL_EXPRESSION v_10 =>
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
{ type = v_1;
x = v_10;
y = v_2;
tcf::LABEL_EXPRESSION (tcf::ADD (type, x, y));
};
tcf::LITERAL v_2 => state_181 (v_3, v_1, v_0, v_2);
_ => state_180 v_3; esac
);
tcf::LITERAL v_10 => (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
{ type = v_1;
x = v_4;
x;
};
else
(case v_4
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
(state_5 (v_1, v_0));
else
{ type = v_1;
x = v_10;
y = v_2;
tcf::LITERAL (i::add (type, x, y));
};fi);
_ => state_180 v_3; esac
);fi);
_ => state_182 (v_3, v_1, v_0, v_4); esac
);
};
tcf::ADD_OR_TRAP v_5 =>
{ my (v_1, v_0, v_4) = v_5;
(case v_0
tcf::LABEL_EXPRESSION v_10 =>
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
{ type = v_1;
x = v_10;
y = v_2;
tcf::LABEL_EXPRESSION (tcf::ADD_OR_TRAP (type, x, y));
};
tcf::LITERAL v_2 => state_354 (v_3, v_1, v_0, v_2);
_ => state_180 v_3; esac
);
tcf::LITERAL v_10 => (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
{ type = v_1;
x = v_4;
x;
};
else
(case v_4
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
(state_69 (v_1, v_0));
else
{ type = v_1;
x = v_10;
y = v_2;
((tcf::LITERAL (i::addt (type, x, y))) except OVERFLOW = expression
);
};fi);
_ => state_180 v_3; esac
);fi);
_ =>
(case v_4
tcf::LITERAL v_2 => state_354 (v_3, v_1, v_0, v_2);
_ => state_180 v_3; esac
); esac
);
};
tcf::BITWISE_AND v_5 =>
{ my (v_1, v_0, v_4) = v_5;
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
(case v_0
tcf::LABEL_EXPRESSION v_10 =>
{ type = v_1;
x = v_10;
y = v_2;
tcf::LABEL_EXPRESSION (tcf::BITWISE_AND (type, x, y));
};
tcf::LITERAL v_10 => state_441 (v_3, v_0, v_10);
_ => state_180 v_3; esac
);
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
{ b = v_4;
b;
};
else
(case v_0
tcf::LITERAL v_10 => (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
(state_100 v_0);
else
{ type = v_1;
x = v_10;
y = v_2;
tcf::LITERAL (i::bitwise_and (type, x, y));
};fi);
_ => state_180 v_3; esac
);fi);
tcf::BITWISE_NOT v_2 =>
(case v_0
tcf::LITERAL v_10 => state_441 (v_3, v_0, v_10);
tcf::BITWISE_NOT v_10 =>
{ my (v_7, v_9) = v_10;
{ my (v_6, v_8) = v_2;
{ a = v_9;
b = v_8;
type = v_1;
type' = v_7;
type'' = v_6;
(if (((type == type') and (type' == type'')))
(tcf::BITWISE_NOT (type, tcf::BITWISE_OR (type, a, b)));
else (state_180 v_3);fi);
};
};
};
_ => state_180 v_3; esac
);
_ =>
(case v_0
tcf::LITERAL v_10 => state_441 (v_3, v_0, v_10);
_ => state_180 v_3; esac
); esac
);
};
tcf::CONDITIONAL_LOAD v_5 =>
{ my (v_1, v_0, v_4, v_18) = v_5;
(case v_0
tcf::FALSE =>
{ a = v_4;
b = v_18;
type = v_1;
b;
};
tcf::TRUE =>
{ a = v_4;
b = v_18;
type = v_1;
a;
};
_ => state_180 v_3; esac
);
};
tcf::DIVS v_5 =>
{ my (v_1, v_0, v_4, v_18) = v_5;
(case v_18
tcf::LABEL_EXPRESSION v_17 =>
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
{ m = v_1;
type = v_0;
x = v_2;
y = v_17;
tcf::LABEL_EXPRESSION (tcf::DIVS (m, type, x, y));
};
_ => state_180 v_3; esac
);
tcf::LITERAL v_17 => (if (((multiword_int::compare (v_17, lit_16)) == EQUAL))
{ a = v_4;
m = v_1;
type = v_0;
a;
};
else
(case v_4
tcf::LITERAL v_2 =>
{ m = v_1;
type = v_0;
x = v_2;
y = v_17;
(if ((y != zero))
(tcf::LITERAL (i::divs (dm m, type, x, y)));
else (state_180 v_3);fi);
};
_ => state_180 v_3; esac
);fi);
_ => state_180 v_3; esac
);
};
tcf::DIVS_OR_TRAP v_5 =>
{ my (v_1, v_0, v_4, v_18) = v_5;
(case v_18
tcf::LABEL_EXPRESSION v_17 =>
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
{ m = v_1;
type = v_0;
x = v_2;
y = v_17;
tcf::LABEL_EXPRESSION (tcf::DIVS_OR_TRAP (m, type, x, y));
};
_ => state_180 v_3; esac
);
tcf::LITERAL v_17 => (if (((multiword_int::compare (v_17, lit_16)) == EQUAL))
{ a = v_4;
m = v_1;
type = v_0;
a;
};
else
(case v_4
tcf::LITERAL v_2 =>
{ m = v_1;
type = v_0;
x = v_2;
y = v_17;
(if ((y != zero))
(tcf::LITERAL (i::divt (dm m, type, x, y)));
else (state_180 v_3);fi);
};
_ => state_180 v_3; esac
);fi);
_ => state_180 v_3; esac
);
};
tcf::DIVU v_5 =>
{ my (v_1, v_0, v_4) = v_5;
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
(case v_0
tcf::LABEL_EXPRESSION v_10 =>
{ type = v_1;
x = v_10;
y = v_2;
tcf::LABEL_EXPRESSION (tcf::DIVU (type, x, y));
};
_ => state_180 v_3; esac
);
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_16)) == EQUAL))
{ a = v_0;
type = v_1;
a;
};
else
(case v_0
tcf::LITERAL v_10 =>
{ type = v_1;
x = v_10;
y = v_2;
(if ((y != zero))
(tcf::LITERAL (i::divu (type, x, y)));
else (state_180 v_3);fi);
};
_ => state_180 v_3; esac
);fi);
_ => state_180 v_3; esac
);
};
tcf::BITWISE_EQV v_5 =>
{ my (v_1, v_0, v_4) = v_5;
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
(case v_0
tcf::LABEL_EXPRESSION v_10 =>
{ type = v_1;
x = v_10;
y = v_2;
tcf::LABEL_EXPRESSION (tcf::BITWISE_EQV (type, x, y));
};
tcf::LITERAL v_10 => state_555 (v_3, v_1, v_10, v_4);
_ => state_180 v_3; esac
);
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
{ a = v_0;
type = v_1;
zero_t;
};
else
(case v_0
tcf::LITERAL v_10 => (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
(state_127 (v_1, v_4));
else
{ type = v_1;
x = v_10;
y = v_2;
tcf::LITERAL (i::eqvb (type, x, y));
};fi);
_ => state_180 v_3; esac
);fi);
_ =>
(case v_0
tcf::LITERAL v_10 => state_555 (v_3, v_1, v_10, v_4);
_ => state_180 v_3; esac
); esac
);
};
tcf::MULS v_5 =>
{ my (v_1, v_0, v_4) = v_5;
(case v_0
tcf::LABEL_EXPRESSION v_10 =>
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
{ type = v_1;
x = v_10;
y = v_2;
tcf::LABEL_EXPRESSION (tcf::MULS (type, x, y));
};
tcf::LITERAL v_2 => state_642 (v_3, v_1, v_0, v_2);
_ => state_180 v_3; esac
);
tcf::LITERAL v_10 => (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
{ type = v_1;
zero_t;
};
else (if (((multiword_int::compare (v_10, lit_16)) == EQUAL))
(case v_4
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
(state_21 v_1);
else (if (((multiword_int::compare (v_2, lit_16)) == EQUAL))
(state_23 (v_1, v_4));
else (state_23 (v_1, v_4));fi);fi);
_ => state_23 (v_1, v_4); esac
);
else
(case v_4
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
(state_21 v_1);
else (if (((multiword_int::compare (v_2, lit_16)) == EQUAL))
(state_25 (v_1, v_0));
else
{ type = v_1;
x = v_10;
y = v_2;
tcf::LITERAL (i::muls (type, x, y));
};fi);fi);
_ => state_180 v_3; esac
);fi);fi);
_ =>
(case v_4
tcf::LITERAL v_2 => state_642 (v_3, v_1, v_0, v_2);
_ => state_180 v_3; esac
); esac
);
};
tcf::MULS_OR_TRAP v_5 =>
{ my (v_1, v_0, v_4) = v_5;
(case v_0
tcf::LABEL_EXPRESSION v_10 =>
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
{ type = v_1;
x = v_10;
y = v_2;
tcf::LABEL_EXPRESSION (tcf::MULS_OR_TRAP (type, x, y));
};
tcf::LITERAL v_2 => state_731 (v_3, v_1, v_0, v_2);
_ => state_180 v_3; esac
);
tcf::LITERAL v_10 => (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
{ type = v_1;
zero_t;
};
else (if (((multiword_int::compare (v_10, lit_16)) == EQUAL))
(case v_4
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
(state_83 v_1);
else (if (((multiword_int::compare (v_2, lit_16)) == EQUAL))
(state_85 (v_1, v_4));
else (state_85 (v_1, v_4));fi);fi);
_ => state_85 (v_1, v_4); esac
);
else
(case v_4
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
(state_83 v_1);
else (if (((multiword_int::compare (v_2, lit_16)) == EQUAL))
(state_87 (v_1, v_0));
else
{ type = v_1;
x = v_10;
y = v_2;
((tcf::LITERAL (i::mult (type, x, y))) except OVERFLOW => expression; end
);
};fi);fi);
_ => state_180 v_3; esac
);fi);fi);
_ =>
(case v_4
tcf::LITERAL v_2 => state_731 (v_3, v_1, v_0, v_2);
_ => state_180 v_3; esac
); esac
);
};
tcf::MULU v_5 =>
{ my (v_1, v_0, v_4) = v_5;
(case v_0
tcf::LABEL_EXPRESSION v_10 =>
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
{ type = v_1;
x = v_10;
y = v_2;
tcf::LABEL_EXPRESSION (tcf::MULU (type, x, y));
};
tcf::LITERAL v_2 => state_820 (v_3, v_1, v_0, v_2);
_ => state_180 v_3; esac
);
tcf::LITERAL v_10 => (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
{ type = v_1;
zero_t;
};
else (if (((multiword_int::compare (v_10, lit_16)) == EQUAL))
(case v_4
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
(state_43 v_1);
else (if (((multiword_int::compare (v_2, lit_16)) == EQUAL))
(state_45 (v_1, v_4));
else (state_45 (v_1, v_4));fi);fi);
_ => state_45 (v_1, v_4); esac
);
else
(case v_4
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
(state_43 v_1);
else (if (((multiword_int::compare (v_2, lit_16)) == EQUAL))
(state_47 (v_1, v_0));
else
{ type = v_1;
x = v_10;
y = v_2;
tcf::LITERAL (i::mulu (type, x, y));
};fi);fi);
_ => state_180 v_3; esac
);fi);fi);
_ =>
(case v_4
tcf::LITERAL v_2 => state_820 (v_3, v_1, v_0, v_2);
_ => state_180 v_3; esac
); esac
);
};
tcf::NEG_OR_TRAP v_5 =>
{ my (v_1, v_0) = v_5;
(case v_0
tcf::LABEL_EXPRESSION v_10 =>
{ type = v_1;
x = v_10;
tcf::LABEL_EXPRESSION (tcf::NEG_OR_TRAP (type, x));
};
tcf::LITERAL v_10 =>
{ type = v_1;
x = v_10;
((tcf::LITERAL (i::negt (type, x))) except OVERFLOW => expression; end
);
};
_ => state_180 v_3; esac
);
};
tcf::BITWISE_NOT v_5 =>
{ my (v_1, v_0) = v_5;
(case v_0
tcf::LABEL_EXPRESSION v_10 =>
{ type = v_1;
x = v_10;
tcf::LABEL_EXPRESSION (tcf::BITWISE_NOT (type, x));
};
tcf::LITERAL v_10 =>
{ n = v_10;
type = v_1;
tcf::LITERAL (i::bitwise_not (type, n));
};
tcf::BITWISE_NOT v_10 =>
{ my (v_7, v_9) = v_10;
{ a = v_9;
type = v_1;
type' = v_7;
(if ((type == type'))
a;
else (state_180 v_3);fi);
};
};
_ => state_180 v_3; esac
);
};
tcf::BITWISE_OR v_5 =>
{ my (v_1, v_0, v_4) = v_5;
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
(case v_0
tcf::LABEL_EXPRESSION v_10 =>
{ type = v_1;
x = v_10;
y = v_2;
tcf::LABEL_EXPRESSION (tcf::BITWISE_OR (type, x, y));
};
tcf::LITERAL v_10 => state_916 (v_3, v_10, v_4);
_ => state_180 v_3; esac
);
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
{ a = v_0;
a;
};
else
(case v_0
tcf::LITERAL v_10 => (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
(state_109 v_4);
else
{ type = v_1;
x = v_10;
y = v_2;
tcf::LITERAL (i::bitwise_or (type, x, y));
};fi);
_ => state_180 v_3; esac
);fi);
tcf::BITWISE_NOT v_2 =>
(case v_0
tcf::LITERAL v_10 => state_916 (v_3, v_10, v_4);
tcf::BITWISE_NOT v_10 =>
{ my (v_7, v_9) = v_10;
{ my (v_6, v_8) = v_2;
{ a = v_9;
b = v_8;
type = v_1;
type' = v_7;
type'' = v_6;
(if (((type == type') and (type' == type'')))
(tcf::BITWISE_NOT (type, tcf::BITWISE_AND (type, a, b)));
else (state_180 v_3);fi);
};
};
};
_ => state_180 v_3; esac
);
_ =>
(case v_0
tcf::LITERAL v_10 => state_916 (v_3, v_10, v_4);
_ => state_180 v_3; esac
); esac
);
};
tcf::REMS v_5 =>
{ my (v_1, v_0, v_4, v_18) = v_5;
(case v_18
tcf::LABEL_EXPRESSION v_17 =>
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
{ m = v_1;
type = v_0;
x = v_2;
y = v_17;
tcf::LABEL_EXPRESSION (tcf::REMS (m, type, x, y));
};
_ => state_180 v_3; esac
);
tcf::LITERAL v_17 => (if (((multiword_int::compare (v_17, lit_16)) == EQUAL))
{ a = v_4;
m = v_1;
type = v_0;
zero_t;
};
else
(case v_4
tcf::LITERAL v_2 =>
{ m = v_1;
type = v_0;
x = v_2;
y = v_17;
(if ((y != zero))
(tcf::LITERAL (i::rems (dm m, type, x, y)));
else (state_180 v_3);fi);
};
_ => state_180 v_3; esac
);fi);
_ => state_180 v_3; esac
);
};
tcf::REMU v_5 =>
{ my (v_1, v_0, v_4) = v_5;
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
(case v_0
tcf::LABEL_EXPRESSION v_10 =>
{ type = v_1;
x = v_10;
y = v_2;
tcf::LABEL_EXPRESSION (tcf::REMU (type, x, y));
};
_ => state_180 v_3; esac
);
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_16)) == EQUAL))
{ a = v_0;
type = v_1;
zero_t;
};
else
(case v_0
tcf::LITERAL v_10 =>
{ type = v_1;
x = v_10;
y = v_2;
(if ((y != zero))
(tcf::LITERAL (i::remu (type, x, y)));
else (state_180 v_3);fi);
};
_ => state_180 v_3; esac
);fi);
_ => state_180 v_3; esac
);
};
tcf::LEFT_SHIFT v_5 =>
{ my (v_1, v_0, v_4) = v_5;
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
(case v_0
tcf::LABEL_EXPRESSION v_10 =>
{ type = v_1;
x = v_10;
y = v_2;
tcf::LABEL_EXPRESSION (tcf::LEFT_SHIFT (type, x, y));
};
tcf::LITERAL v_10 => state_1021 (v_3, v_1, v_10);
_ => state_180 v_3; esac
);
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
{ a = v_0;
type = v_1;
a;
};
else
(case v_0
tcf::LITERAL v_10 => (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
(state_157 v_1);
else
{ n = v_2;
type = v_1;
(if ((multiword_int::(<=) (multiword_int::from_int type, n)))
(state_158 ());
else
{ type = v_1;
x = v_10;
y = v_2;
tcf::LITERAL (i::sll_x (type, x, y));
};fi);
};fi);
_ =>
{ n = v_2;
type = v_1;
(if ((multiword_int::(<=) (multiword_int::from_int type, n)))
(state_158 ());
else (state_180 v_3);fi);
}; esac
);fi);
_ =>
(case v_0
tcf::LITERAL v_10 => state_1021 (v_3, v_1, v_10);
_ => state_180 v_3; esac
); esac
);
};
tcf::RIGHT_SHIFT v_5 =>
{ my (v_1, v_0, v_4) = v_5;
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
(case v_0
tcf::LABEL_EXPRESSION v_10 =>
{ type = v_1;
x = v_10;
y = v_2;
tcf::LABEL_EXPRESSION (tcf::RIGHT_SHIFT (type, x, y));
};
tcf::LITERAL v_10 => state_1192 (v_3, v_1, v_10);
_ => state_180 v_3; esac
);
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
{ a = v_0;
type = v_1;
a;
};
else
(case v_0
tcf::LITERAL v_10 => (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
(state_140 v_1);
else
{ type = v_1;
x = v_10;
y = v_2;
tcf::LITERAL (i::sra_x (type, x, y));
};fi);
_ => state_180 v_3; esac
);fi);
_ =>
(case v_0
tcf::LITERAL v_10 => state_1192 (v_3, v_1, v_10);
_ => state_180 v_3; esac
); esac
);
};
tcf::RIGHT_SHIFT_U v_5 =>
{ my (v_1, v_0, v_4) = v_5;
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
(case v_0
tcf::LABEL_EXPRESSION v_10 =>
{ type = v_1;
x = v_10;
y = v_2;
tcf::LABEL_EXPRESSION (tcf::RIGHT_SHIFT_U (type, x, y));
};
tcf::LITERAL v_10 => state_1279 (v_3, v_1, v_10);
_ => state_180 v_3; esac
);
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
{ a = v_0;
type = v_1;
a;
};
else
(case v_0
tcf::LITERAL v_10 => (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
(state_148 v_1);
else
{ n = v_2;
type = v_1;
(if ((multiword_int::(<=) (multiword_int::from_int type, n)))
(state_149 ());
else
{ type = v_1;
x = v_10;
y = v_2;
tcf::LITERAL (i::srl_x (type, x, y));
};fi);
};fi);
_ =>
{ n = v_2;
type = v_1;
(if ((multiword_int::(<=) (multiword_int::from_int type, n)))
(state_149 ());
else (state_180 v_3);fi);
}; esac
);fi);
_ =>
(case v_0
tcf::LITERAL v_10 => state_1279 (v_3, v_1, v_10);
_ => state_180 v_3; esac
); esac
);
};
tcf::SUB v_5 =>
{ my (v_1, v_0, v_4) = v_5;
(case v_0
tcf::LABEL_EXPRESSION v_10 =>
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
{ type = v_1;
x = v_10;
y = v_2;
tcf::LABEL_EXPRESSION (tcf::SUB (type, x, y));
};
tcf::LITERAL v_2 => state_1450 (v_3, v_1, v_0, v_2);
_ => state_180 v_3; esac
);
tcf::LITERAL v_10 =>
(case v_4
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
(state_15 (v_1, v_0));
else
{ type = v_1;
x = v_10;
y = v_2;
tcf::LITERAL (i::sub (type, x, y));
};fi);
tcf::SUB v_2 =>
{ my (v_6, v_8, v_14) = v_2;
(if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
(case v_8
tcf::LITERAL v_15 => (if (((multiword_int::compare (v_15, lit_11)) == EQUAL))
{ a = v_14;
type = v_1;
type' = v_6;
(if ((type == type'))
a;
else (state_180 v_3);fi);
};
else (state_180 v_3);fi);
_ => state_180 v_3; esac
);
else (state_180 v_3);fi);
};
_ => state_180 v_3; esac
);
tcf::SUB v_10 =>
{ my (v_7, v_9, v_13) = v_10;
(case v_13
tcf::LITERAL v_12 =>
(case v_4
tcf::LITERAL v_2 =>
{ a = v_9;
type = v_1;
type' = v_7;
x = v_12;
y = v_2;
(if ((type == type'))
(tcf::SUB (type, a, tcf::LITERAL (i::add (type, x, y))));
else (state_1450 (v_3, v_1, v_0, v_2));fi);
};
_ => state_180 v_3; esac
);
_ => state_1451 (v_3, v_1, v_0, v_4); esac
);
};
_ => state_1451 (v_3, v_1, v_0, v_4); esac
);
};
tcf::SUB_OR_TRAP v_5 =>
{ my (v_1, v_0, v_4) = v_5;
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
(case v_0
tcf::LABEL_EXPRESSION v_10 =>
{ type = v_1;
x = v_10;
y = v_2;
tcf::LABEL_EXPRESSION (tcf::SUB_OR_TRAP (type, x, y));
};
_ => state_180 v_3; esac
);
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
{ a = v_0;
type = v_1;
a;
};
else
(case v_0
tcf::LITERAL v_10 =>
{ type = v_1;
x = v_10;
y = v_2;
((tcf::LITERAL (i::subt (type, x, y))) except OVERFLOW => expression; end
);
};
_ => state_180 v_3; esac
);fi);
_ => state_180 v_3; esac
);
};
tcf::SIGN_EXTEND v_5 =>
{ my (v_1, v_0, v_4) = v_5;
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
{ e = v_4;
type = v_1;
type' = v_0;
(if ((type == type'))
(state_165 e);
else
{ type = v_1;
type' = v_0;
x = v_2;
tcf::LABEL_EXPRESSION (tcf::SIGN_EXTEND (type, type', x));
};fi);
};
tcf::LITERAL v_2 =>
{ e = v_4;
type = v_1;
type' = v_0;
(if ((type == type'))
(state_165 e);
else
{ n = v_2;
type = v_1;
type' = v_0;
tcf::LITERAL (i::sx (type, type', n));
};fi);
};
tcf::LOAD v_2 =>
{ type = v_1;
type' = v_0;
expression;
};
_ =>
{ e = v_4;
type = v_1;
type' = v_0;
(if ((type == type'))
(state_165 e);
else (state_180 v_3);fi);
}; esac
);
};
tcf::BITWISE_XOR v_5 =>
{ my (v_1, v_0, v_4) = v_5;
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
(case v_0
tcf::LABEL_EXPRESSION v_10 =>
{ type = v_1;
x = v_10;
y = v_2;
tcf::LABEL_EXPRESSION (tcf::BITWISE_XOR (type, x, y));
};
tcf::LITERAL v_10 => state_1717 (v_3, v_1, v_10, v_4);
_ => state_180 v_3; esac
);
tcf::LITERAL v_2 => (if (((multiword_int::compare (v_2, lit_11)) == EQUAL))
{ a = v_0;
type = v_1;
a;
};
else
(case v_0
tcf::LITERAL v_10 => (if (((multiword_int::compare (v_10, lit_11)) == EQUAL))
(state_118 (v_1, v_4));
else
{ type = v_1;
x = v_10;
y = v_2;
tcf::LITERAL (i::bitwise_xor (type, x, y));
};fi);
_ => state_180 v_3; esac
);fi);
tcf::BITWISE_NOT v_2 =>
(case v_0
tcf::LITERAL v_10 => state_1717 (v_3, v_1, v_10, v_4);
tcf::BITWISE_NOT v_10 =>
{ my (v_7, v_9) = v_10;
{ my (v_6, v_8) = v_2;
{ a = v_9;
b = v_8;
type = v_1;
type' = v_7;
type'' = v_6;
(if (((type == type') and (type' == type'')))
(tcf::BITWISE_NOT (type, tcf::BITWISE_XOR (type, a, b)));
else (state_180 v_3);fi);
};
};
};
_ => state_180 v_3; esac
);
_ =>
(case v_0
tcf::LITERAL v_10 => state_1717 (v_3, v_1, v_10, v_4);
_ => state_180 v_3; esac
); esac
);
};
tcf::ZERO_EXTEND v_5 =>
{ my (v_1, v_0, v_4) = v_5;
{ e = v_4;
type = v_1;
type' = v_0;
(if ((type == type'))
e;
else
(case v_4
tcf::LABEL_EXPRESSION v_2 =>
{ type = v_1;
type' = v_0;
x = v_2;
tcf::LABEL_EXPRESSION (tcf::ZERO_EXTEND (type, type', x));
};
tcf::LITERAL v_2 =>
{ n = v_2;
type = v_1;
type' = v_0;
tcf::LITERAL (i::zx (type, type', n));
};
_ => state_180 v_3; esac
);fi);
};
};
_ => state_180 v_3; esac
);
}
also
fun sim_void_expression ===> (tcf::IF (tcf::TRUE, yes, no)) => yes;
sim_void_expression ===> (tcf::IF (tcf::FALSE, yes, no)) => no;
sim_void_expression ===> (tcf::SEQ [x]) => x;
sim_void_expression ===> s => s; end
also
fun sim_f p_0 p_1 =
{ v_29 = (p_0, p_1);
fun state_8 (v_19, v_20) =
{ my ===> = v_19;
expression = v_20;
expression;
};
{ my (v_19, v_20) = v_29;
(case v_20
tcf::FLOAT_TO_FLOAT v_26 =>
{ my (v_22, v_25, v_27) = v_26;
{ my ===> = v_19;
e = v_27;
type = v_22;
type' = v_25;
(if ((type == type'))
e;
else (state_8 (v_19, v_20));fi);
};
};
tcf::FCONDITIONAL_LOAD v_26 =>
{ my (v_22, v_25, v_27, v_28) = v_26;
(case v_25
tcf::FALSE =>
{ my ===> = v_19;
no = v_28;
type = v_22;
yes = v_27;
no;
};
tcf::TRUE =>
{ my ===> = v_19;
no = v_28;
type = v_22;
yes = v_27;
yes;
};
_ => state_8 (v_19, v_20); esac
);
};
tcf::FNEG v_26 =>
{ my (v_22, v_25) = v_26;
(case v_25
tcf::FNEG v_24 =>
{ my (v_21, v_23) = v_24;
{ my ===> = v_19;
e = v_23;
type = v_22;
type' = v_21;
(if ((type == type'))
e;
else (state_8 (v_19, v_20));fi);
};
};
_ => state_8 (v_19, v_20); esac
);
};
_ => state_8 (v_19, v_20); esac
);
};
}
also
fun cc FALSE => tcf::FALSE;
cc TRUE => tcf::TRUE; end
also
fun sim_cc ===> (tcf::CMP (type, tcf::EQ, tcf::LITERAL x, tcf::LITERAL y)) => cc (i::eq (type, x, y));
sim_cc ===> (tcf::CMP (type, tcf::NE, tcf::LITERAL x, tcf::LITERAL y)) => cc (i::ne (type, x, y));
sim_cc ===> (tcf::CMP (type, tcf::GT, tcf::LITERAL x, tcf::LITERAL y)) => cc (i::gt (type, x, y));
sim_cc ===> (tcf::CMP (type, tcf::GE, tcf::LITERAL x, tcf::LITERAL y)) => cc (i::ge (type, x, y));
sim_cc ===> (tcf::CMP (type, tcf::LT, tcf::LITERAL x, tcf::LITERAL y)) => cc (i::lt (type, x, y));
sim_cc ===> (tcf::CMP (type, tcf::LE, tcf::LITERAL x, tcf::LITERAL y)) => cc (i::le (type, x, y));
sim_cc ===> (tcf::CMP (type, tcf::GTU, tcf::LITERAL x, tcf::LITERAL y)) => cc (i::gtu (type, x, y));
sim_cc ===> (tcf::CMP (type, tcf::LTU, tcf::LITERAL x, tcf::LITERAL y)) => cc (i::ltu (type, x, y));
sim_cc ===> (tcf::CMP (type, tcf::GEU, tcf::LITERAL x, tcf::LITERAL y)) => cc (i::geu (type, x, y));
sim_cc ===> (tcf::CMP (type, tcf::LEU, tcf::LITERAL x, tcf::LITERAL y)) => cc (i::leu (type, x, y));
sim_cc ===> (tcf::AND (tcf::TRUE, x)) => x;
sim_cc ===> (tcf::AND (x, tcf::TRUE)) => x;
sim_cc ===> (tcf::AND (tcf::FALSE, x)) => tcf::FALSE;
sim_cc ===> (tcf::AND (x, tcf::FALSE)) => tcf::FALSE;
sim_cc ===> (tcf::OR (tcf::FALSE, x)) => x;
sim_cc ===> (tcf::OR (x, tcf::FALSE)) => x;
sim_cc ===> (tcf::OR (tcf::TRUE, x)) => tcf::TRUE;
sim_cc ===> (tcf::OR (x, tcf::TRUE)) => tcf::TRUE;
sim_cc ===> (tcf::XOR (tcf::TRUE, tcf::TRUE)) => tcf::FALSE;
sim_cc ===> (tcf::XOR (tcf::FALSE, x)) => x;
sim_cc ===> (tcf::XOR (x, tcf::FALSE)) => x;
sim_cc ===> (tcf::XOR (tcf::TRUE, x)) => tcf::NOT x;
sim_cc ===> (tcf::XOR (x, tcf::TRUE)) => tcf::NOT x;
sim_cc ===> (tcf::EQV (tcf::FALSE, tcf::FALSE)) => tcf::TRUE;
sim_cc ===> (tcf::EQV (tcf::TRUE, x)) => x;
sim_cc ===> (tcf::EQV (x, tcf::TRUE)) => x;
sim_cc ===> (tcf::EQV (tcf::FALSE, x)) => tcf::NOT x;
sim_cc ===> (tcf::EQV (x, tcf::FALSE)) => tcf::NOT x;
sim_cc ===> expression => expression;
end;
r::rewrite { int_expression=>sim, float_expression=>sim_f, flag_expression=>sim_cc, void_expression=>sim_void_expression };
};
};