[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-discuss] 答复: Output many return values of some instruction
From: |
Peter Maydell |
Subject: |
Re: [Qemu-discuss] 答复: Output many return values of some instruction |
Date: |
Fri, 28 Nov 2014 08:54:13 +0000 |
On 28 November 2014 at 02:27, <address@hidden> wrote:
> Hi,Peter
> Many thanks for you to reply, I am confused here in many days. Thanks you
> very much.
> Another problem, my instruction “Getsec” want to output 3 return value to
> eax/ebx/ecx and only one input parameter eax.
> But the return value eax and ecx is correct. The ebx is not correct. It is
> strange.
> My code is :
> gen_op_mov_v_reg(MO_64, cpu_T[1], R_EAX); // mov
> input parameter eax to cpu_T[1]
> tcg_gen_getsec_tl(cpu_T[0], cpu_T[2], cpu_T[3], cpu_T[1]);
> // My instruction: The first 3 is for output and the last is for input
This is broken, because cpu_T[2] and cpu_T[3] don't exist.
You should create and use temporaries yourself, like I suggested,
if you need them. However:
> gen_op_mov_reg_v(MO_64, R_EAX, cpu_T[0]); // mov
> 1st return to eax
A gen_op_mov_reg_v() whose first argument is always
MO_64 is just going to compile to a TCG mov, so you
might as well just say
tcg_gen_getsec_tl(R_EAX, R_EBX, R_ECX, cpu_T[1]);
and avoid the extra mov ops.
> And From your comment about cpu_T[], I cannot find where
> cpu_T[0] & [1] are freed. Cpu_T[] don't need to free ?
No, because they are created once when the TCG code is initialized,
and last for the lifetime of the translator.
> In Getsec implementation, I set the return value as followings:
> ots = &s->temps[args[0]];
> tcg_out_movi(s, ots->type, ots->reg, 0xC0);
> ots = &s->temps[args[1]];
> tcg_out_movi(s, ots->type, ots->reg, 0xE0);
> ots = &s->temps[args[2]];
> tcg_out_movi(s, ots->type, ots->reg, 0x1D);
I don't know what bit of code you're referring to here, but
this looks wrong. tcg_out_movi is a function used in the
TCG backends (the part of QEMU that generates code for a
particular host CPU). You don't need it at all to add a
new instruction to the TCG target-* frontend (which supports
a particular guest CPU).
-- PMM