tcg: Add add/sub with carry opcodes and infrastructure
Liveness needs to track carry-live state in order to
determine if the (hidden) output of the opcode is used.
Code generation needs to track carry-live state in order
to avoid clobbering cpu flags when loading constants.
So far, output routines and backends are unchanged.
Reviewed-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
diff --git a/tcg/optimize.c b/tcg/optimize.c
index a728a4b..8b00833 100644
--- a/tcg/optimize.c
+++ b/tcg/optimize.c
@@ -1226,6 +1226,12 @@
return finish_folding(ctx, op);
}
+static bool fold_add_carry(OptContext *ctx, TCGOp *op)
+{
+ fold_commutative(ctx, op);
+ return finish_folding(ctx, op);
+}
+
static bool fold_addsub2(OptContext *ctx, TCGOp *op, bool add)
{
bool a_const = arg_is_const(op->args[2]) && arg_is_const(op->args[3]);
@@ -2829,6 +2835,11 @@
case INDEX_op_add_vec:
done = fold_add_vec(&ctx, op);
break;
+ case INDEX_op_addci:
+ case INDEX_op_addco:
+ case INDEX_op_addcio:
+ done = fold_add_carry(&ctx, op);
+ break;
CASE_OP_32_64(add2):
done = fold_add2(&ctx, op);
break;