vkd3d-shader/hlsl: Implement normalization of binary expressions.
We normalize binary expressions by attempting to group constants together, in order to facilitate further simplification of the expressions.
For any binary operator OP, non-constants x, y, and constants a, b, we apply the following rewrite rules:
a OP x -> x OP a, if OP is commutative.
(x OP a) OP b -> x OP (a OP b), if OP is associative.
(x OP a) OP y -> (x OP y) OP a, if OP is associative and commutative.
x OP (y OP a) -> (x OP y) OP a, if OP is associative.
Note that we consider floating point operations to be non-associative.
For instance, the expression (2 + 3 * x * 4) + (y + 5)
is simplified
to x * 12 + y + 7
with the above normalization rules applied together
with constant folding.