qemu-discuss
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-discuss] Output many return values of some instruction


From: EricSong
Subject: Re: [Qemu-discuss] Output many return values of some instruction
Date: Mon, 1 Dec 2014 10:53:36 +0800

Hi, Peter
   1) cpu_T[2] and cpu_T[3] have been built by me as same as cpu_[0] &1.
   2) tcg_gen_getsec_tl(R_EAX, R_EBX, R_ECX, cpu_T[1]); I tried it before, but 
the result is not my expectation. But if I do a TCG mov, EAX will get what I 
want.
   3) I know that tcg_out_movi is a function used in the TCG backends. And my 
aim is to finish one instruction on HW without the instruction. So I must 
implement it use some code on the backend of QEMU. It seems the host cpu can 
support some specific instruction, but it is the QEMU's achievement.

   So, I need to understand the frontend / backend of QEMU. Please give me much 
more help for it. I feel it is QEMU ability and charm. Thank you very much!!

Best wishes,
Eric

-----邮件原件-----
发件人: Peter Maydell [mailto:address@hidden 
发送时间: 2014年11月28日 16:54
收件人: Eric Song
抄送: qemu-discuss
主题: Re: 答复: [Qemu-discuss] Output many return values of some instruction

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]