All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] Adding a parameter to a helper
@ 2012-07-30 16:40 Jose Cano Reyes
  2012-07-31 13:19 ` Laurent Desnogues
  0 siblings, 1 reply; 5+ messages in thread
From: Jose Cano Reyes @ 2012-07-30 16:40 UTC (permalink / raw)
  To: qemu-devel

Hi all,

I am trying to add a new integer parameter to an existing helper and 
call this helper in "targeti386/translate.c". I have several problems:

1) I cannot add an integer parameter to the helper, the compiler says 
that it must be "TCGv_i32", despite I declare this new parameter as 
"int" in "target-i386/helper.h". Why?

2) If I use the the function "tcg_const_i32" in order to convert my 
integer to TCGv_i32 I always obtain the same output value, that is:

         tcg_const_i32(10) = 1074260520
         tcg_const_i32(22) = 1074260520
         tcg_const_i32(30) = 1074260520
         ...

3) Moreover, wen I pass this value in the helper call 
"gen_helper_flds_ST0", that is:

      gen_helper_flds_ST0(cpu_tmp2_i32, tcg_const_i32(MY_INT_VALUE));

     How can I use MY_INT_VALUE later in the function "tcg_gen_helperN" 
. This function is called by DEF_HELPER_FLAGS2, which corresponds to 
DEF_HELPER_2 (definition of my helper).


Thanks in advance,

    Jose Cano.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] Adding a parameter to a helper
  2012-07-30 16:40 [Qemu-devel] Adding a parameter to a helper Jose Cano Reyes
@ 2012-07-31 13:19 ` Laurent Desnogues
  2012-07-31 15:09   ` Jose Cano Reyes
  0 siblings, 1 reply; 5+ messages in thread
From: Laurent Desnogues @ 2012-07-31 13:19 UTC (permalink / raw)
  To: Jose Cano Reyes; +Cc: qemu-devel

On Mon, Jul 30, 2012 at 6:40 PM, Jose Cano Reyes <jcano@ac.upc.edu> wrote:
> I am trying to add a new integer parameter to an existing helper and call
> this helper in "targeti386/translate.c". I have several problems:
>
> 1) I cannot add an integer parameter to the helper, the compiler says that
> it must be "TCGv_i32", despite I declare this new parameter as "int" in
> "target-i386/helper.h". Why?

Helpers only accept TCGv parameters.

> 2) If I use the the function "tcg_const_i32" in order to convert my integer
> to TCGv_i32 I always obtain the same output value, that is:
>
>         tcg_const_i32(10) = 1074260520
>         tcg_const_i32(22) = 1074260520
>         tcg_const_i32(30) = 1074260520
>         ...

TCGv is an index, not the value it represents.  Think of it
as an id.

tcg_const will allocate a TCGv and then emit a TCG mov
instruction to assign it a value.

> 3) Moreover, wen I pass this value in the helper call "gen_helper_flds_ST0",
> that is:
>
>      gen_helper_flds_ST0(cpu_tmp2_i32, tcg_const_i32(MY_INT_VALUE));
>
>     How can I use MY_INT_VALUE later in the function "tcg_gen_helperN" .
> This function is called by DEF_HELPER_FLAGS2, which corresponds to
> DEF_HELPER_2 (definition of my helper).

Look at helper_aam, that should help :-)


Laurent

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] Adding a parameter to a helper
  2012-07-31 13:19 ` Laurent Desnogues
@ 2012-07-31 15:09   ` Jose Cano Reyes
  2012-07-31 15:14     ` Laurent Desnogues
  0 siblings, 1 reply; 5+ messages in thread
From: Jose Cano Reyes @ 2012-07-31 15:09 UTC (permalink / raw)
  To: Laurent Desnogues; +Cc: qemu-devel


Many thanks for your response Laurent.


- So, how ca I obtain the value that TCGv_i32 represents?

- I don't understand well how a helper functions. For instance, 
cosidering this call to a helper again:

         gen_helper_flds_ST0(cpu_tmp2_i32, tcg_const_i32(MY_INT_VALUE))

   Can I obtain the parameters "cpu_tmp2_i32" and 
"tcg_const_i32(MY_INT_VALUE)" from the args[0] and args[1] described in 
DEF_HELPER_FLAGS_2???


Jose.



El 31/07/12 15:19, Laurent Desnogues escribió:
> On Mon, Jul 30, 2012 at 6:40 PM, Jose Cano Reyes <jcano@ac.upc.edu> wrote:
>> I am trying to add a new integer parameter to an existing helper and call
>> this helper in "targeti386/translate.c". I have several problems:
>>
>> 1) I cannot add an integer parameter to the helper, the compiler says that
>> it must be "TCGv_i32", despite I declare this new parameter as "int" in
>> "target-i386/helper.h". Why?
> Helpers only accept TCGv parameters.
>
>> 2) If I use the the function "tcg_const_i32" in order to convert my integer
>> to TCGv_i32 I always obtain the same output value, that is:
>>
>>          tcg_const_i32(10) = 1074260520
>>          tcg_const_i32(22) = 1074260520
>>          tcg_const_i32(30) = 1074260520
>>          ...
> TCGv is an index, not the value it represents.  Think of it
> as an id.
>
> tcg_const will allocate a TCGv and then emit a TCG mov
> instruction to assign it a value.
>
>> 3) Moreover, wen I pass this value in the helper call "gen_helper_flds_ST0",
>> that is:
>>
>>       gen_helper_flds_ST0(cpu_tmp2_i32, tcg_const_i32(MY_INT_VALUE));
>>
>>      How can I use MY_INT_VALUE later in the function "tcg_gen_helperN" .
>> This function is called by DEF_HELPER_FLAGS2, which corresponds to
>> DEF_HELPER_2 (definition of my helper).
> Look at helper_aam, that should help :-)
>
>
> Laurent

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] Adding a parameter to a helper
  2012-07-31 15:09   ` Jose Cano Reyes
@ 2012-07-31 15:14     ` Laurent Desnogues
  2012-07-31 17:14       ` Jose Cano Reyes
  0 siblings, 1 reply; 5+ messages in thread
From: Laurent Desnogues @ 2012-07-31 15:14 UTC (permalink / raw)
  To: Jose Cano Reyes; +Cc: qemu-devel

On Tue, Jul 31, 2012 at 5:09 PM, Jose Cano Reyes <jcano@ac.upc.edu> wrote:
> - So, how ca I obtain the value that TCGv_i32 represents?

In the generated code (that is after TCG is translated to host
machine code), you'll et your value in your helper.  If you mean
before running the helper, then it's much more complex and
would require to process the TCG code.

> - I don't understand well how a helper functions. For instance, cosidering
> this call to a helper again:
>
>         gen_helper_flds_ST0(cpu_tmp2_i32, tcg_const_i32(MY_INT_VALUE))
>
>   Can I obtain the parameters "cpu_tmp2_i32" and
> "tcg_const_i32(MY_INT_VALUE)" from the args[0] and args[1] described in
> DEF_HELPER_FLAGS_2???

cf. above.  Again look at existing helpers and how they get
const values.


Laurent

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [Qemu-devel] Adding a parameter to a helper
  2012-07-31 15:14     ` Laurent Desnogues
@ 2012-07-31 17:14       ` Jose Cano Reyes
  0 siblings, 0 replies; 5+ messages in thread
From: Jose Cano Reyes @ 2012-07-31 17:14 UTC (permalink / raw)
  To: Laurent Desnogues; +Cc: qemu-devel


Ok, I am going to try...


In fact, I did it before posting Laurent, but I don't understand it 
completely. Anyway, thanks a lot for your help.


    Jose.



El 31/07/12 17:14, Laurent Desnogues escribió:
> On Tue, Jul 31, 2012 at 5:09 PM, Jose Cano Reyes <jcano@ac.upc.edu> wrote:
>> - So, how ca I obtain the value that TCGv_i32 represents?
> In the generated code (that is after TCG is translated to host
> machine code), you'll et your value in your helper.  If you mean
> before running the helper, then it's much more complex and
> would require to process the TCG code.
>
>> - I don't understand well how a helper functions. For instance, cosidering
>> this call to a helper again:
>>
>>          gen_helper_flds_ST0(cpu_tmp2_i32, tcg_const_i32(MY_INT_VALUE))
>>
>>    Can I obtain the parameters "cpu_tmp2_i32" and
>> "tcg_const_i32(MY_INT_VALUE)" from the args[0] and args[1] described in
>> DEF_HELPER_FLAGS_2???
> cf. above.  Again look at existing helpers and how they get
> const values.
>
>
> Laurent

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-07-31 17:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-30 16:40 [Qemu-devel] Adding a parameter to a helper Jose Cano Reyes
2012-07-31 13:19 ` Laurent Desnogues
2012-07-31 15:09   ` Jose Cano Reyes
2012-07-31 15:14     ` Laurent Desnogues
2012-07-31 17:14       ` Jose Cano Reyes

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.