On 10/19/23 03:46, Paolo Bonzini wrote:
> + /*
> + * Write back flags after last memory access. Some newer ALU instructions, as
> + * well as SSE instructions, write flags in the gen_* function, but that can
> + * cause incorrect tracking of CC_OP for instructions that write to both memory
> + * and flags.
> + */
> + if (decode.cc_op != -1) {
> + if (decode.cc_dst) {
> + tcg_gen_mov_tl(cpu_cc_dst, decode.cc_dst);
> + }
> + if (decode.cc_src) {
> + tcg_gen_mov_tl(cpu_cc_src, decode.cc_src);
> + }
> + if (decode.cc_src2) {
> + tcg_gen_mov_tl(cpu_cc_src2, decode.cc_src2);
> + }
> + if (decode.cc_op == CC_OP_DYNAMIC) {
> + tcg_gen_mov_i32(cpu_cc_op, decode.cc_op_dynamic);
> + } else {
> + assert(!decode.cc_op_dynamic);
> + }
> + set_cc_op(s, decode.cc_op);
> + } else {
> + assert(!decode.cc_dst);
> + assert(!decode.cc_src);
> + assert(!decode.cc_src2);
> + assert(!decode.cc_op_dynamic);
> + }
I suggest you use cc_op_live[] to ensure that each output is present if USES_CC_* is set,
and absent otherwise. Obviously that's not possible for CC_OP_DYNAMIC, but for everything else...
I tried but it didn't work very well. I have shuffled things a bit and I don't remember why :) so I will give it another go.
Paolo