* [Qemu-devel] op-helper.c vs helper.c
@ 2011-09-19 12:06 Xin Tong Utoronto
2011-09-19 12:09 ` Alexander Graf
2011-09-19 13:49 ` Peter Maydell
0 siblings, 2 replies; 6+ messages in thread
From: Xin Tong Utoronto @ 2011-09-19 12:06 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 196 bytes --]
There are 2 files on helpers in target-ppc and target-i386 ( op-helper.c
helper.c), what are their differences ? also, what kind of functions are
typically emulated using helpers ?
Thanks
Xin
[-- Attachment #2: Type: text/html, Size: 290 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] op-helper.c vs helper.c
2011-09-19 12:06 [Qemu-devel] op-helper.c vs helper.c Xin Tong Utoronto
@ 2011-09-19 12:09 ` Alexander Graf
2011-09-19 13:49 ` Peter Maydell
1 sibling, 0 replies; 6+ messages in thread
From: Alexander Graf @ 2011-09-19 12:09 UTC (permalink / raw)
To: Xin Tong Utoronto; +Cc: qemu-devel
On 19.09.2011, at 14:06, Xin Tong Utoronto wrote:
> There are 2 files on helpers in target-ppc and target-i386 ( op-helper.c helper.c), what are their differences ?
General rule:
op_helper.c: Code snippets called from TCG generated code. Implement more complex operations that gcc gets better than TCG.
helper.c: Helper functions specific to the CPU, but called from multiple places around QEMU. For example the MMU code belongs here.
> also, what kind of functions are typically emulated using helpers ?
IIRC the rule of thumb is anything containing branches or bigger than 10(?) TCG ops should be in a helper. But it's up to the target developer really.
Alex
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] op-helper.c vs helper.c
2011-09-19 12:06 [Qemu-devel] op-helper.c vs helper.c Xin Tong Utoronto
2011-09-19 12:09 ` Alexander Graf
@ 2011-09-19 13:49 ` Peter Maydell
2011-09-22 13:09 ` Xin Tong Utoronto
1 sibling, 1 reply; 6+ messages in thread
From: Peter Maydell @ 2011-09-19 13:49 UTC (permalink / raw)
To: Xin Tong Utoronto; +Cc: qemu-devel
On 19 September 2011 13:06, Xin Tong Utoronto <x.tong@utoronto.ca> wrote:
> There are 2 files on helpers in target-ppc and target-i386 ( op-helper.c
> helper.c), what are their differences ? also, what kind of functions are
> typically emulated using helpers ?
The key difference is that op_helper.c is compiled with compiler
flags and includes header files that give it access to a global
variable 'CPUState *env' which is kept in a fixed CPU register
during execution of translated code. helper.c (and other foo_helper.c
files) are built as regular C files, and so if they need access to the
CPU state it has to be passed into the helper as an explicit parameter.
We're currently trying to cut back on the use of the implicit global,
so new helper functions should probably go in helper.c.
> also, what kind of functions are typically emulated using helpers ?
Anything that seems too hard to do inline :-) tcg/README has a
paragraph at the end giving some rules of thumb.
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] op-helper.c vs helper.c
2011-09-19 13:49 ` Peter Maydell
@ 2011-09-22 13:09 ` Xin Tong Utoronto
2011-09-22 13:49 ` Peter Maydell
2011-09-24 8:15 ` Blue Swirl
0 siblings, 2 replies; 6+ messages in thread
From: Xin Tong Utoronto @ 2011-09-22 13:09 UTC (permalink / raw)
To: Peter Maydell; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1318 bytes --]
On Mon, Sep 19, 2011 at 9:49 AM, Peter Maydell <peter.maydell@linaro.org>wrote:
> On 19 September 2011 13:06, Xin Tong Utoronto <x.tong@utoronto.ca> wrote:
> > There are 2 files on helpers in target-ppc and target-i386 ( op-helper.c
> > helper.c), what are their differences ? also, what kind of functions are
> > typically emulated using helpers ?
>
> The key difference is that op_helper.c is compiled with compiler
> flags and includes header files that give it access to a global
> variable 'CPUState *env' which is kept in a fixed CPU register
> during execution of translated code.
This is easier for the tcg to call ?
> helper.c (and other foo_helper.c
> files) are built as regular C files, and so if they need access to the
> CPU state it has to be passed into the helper as an explicit parameter.
>
We're currently trying to cut back on the use of the implicit global,
> so new helper functions should probably go in helper.c.
>
> Why do we want to cut back on the use of the implicit global ? what is the
criteria for a function to be in the implicit global list ?
> > also, what kind of functions are typically emulated using helpers ?
>
> Anything that seems too hard to do inline :-) tcg/README has a
> paragraph at the end giving some rules of thumb.
>
> -- PMM
>
--
Kind Regards
Xin Tong
[-- Attachment #2: Type: text/html, Size: 2292 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] op-helper.c vs helper.c
2011-09-22 13:09 ` Xin Tong Utoronto
@ 2011-09-22 13:49 ` Peter Maydell
2011-09-24 8:15 ` Blue Swirl
1 sibling, 0 replies; 6+ messages in thread
From: Peter Maydell @ 2011-09-22 13:49 UTC (permalink / raw)
To: Xin Tong Utoronto; +Cc: qemu-devel
On 22 September 2011 14:09, Xin Tong Utoronto <x.tong@utoronto.ca> wrote:
> On Mon, Sep 19, 2011 at 9:49 AM, Peter Maydell <peter.maydell@linaro.org>
> wrote:
>> We're currently trying to cut back on the use of the implicit global,
>> so new helper functions should probably go in helper.c.
>>
> Why do we want to cut back on the use of the implicit global ?
http://www.mail-archive.com/qemu-devel@nongnu.org/msg63849.html
has some links to discussion of the arguments here ("TCG_AREG0"
is the global env register).
-- PMM
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] op-helper.c vs helper.c
2011-09-22 13:09 ` Xin Tong Utoronto
2011-09-22 13:49 ` Peter Maydell
@ 2011-09-24 8:15 ` Blue Swirl
1 sibling, 0 replies; 6+ messages in thread
From: Blue Swirl @ 2011-09-24 8:15 UTC (permalink / raw)
To: Xin Tong Utoronto; +Cc: Peter Maydell, qemu-devel
On Thu, Sep 22, 2011 at 1:09 PM, Xin Tong Utoronto <x.tong@utoronto.ca> wrote:
>
>
> On Mon, Sep 19, 2011 at 9:49 AM, Peter Maydell <peter.maydell@linaro.org>
> wrote:
>>
>> On 19 September 2011 13:06, Xin Tong Utoronto <x.tong@utoronto.ca> wrote:
>> > There are 2 files on helpers in target-ppc and target-i386 ( op-helper.c
>> > helper.c), what are their differences ? also, what kind of functions
>> > are
>> > typically emulated using helpers ?
>>
>> The key difference is that op_helper.c is compiled with compiler
>> flags and includes header files that give it access to a global
>> variable 'CPUState *env' which is kept in a fixed CPU register
>> during execution of translated code.
>
> This is easier for the tcg to call ?
>
>>
>> helper.c (and other foo_helper.c
>> files) are built as regular C files, and so if they need access to the
>> CPU state it has to be passed into the helper as an explicit parameter.
>>
>>
>> We're currently trying to cut back on the use of the implicit global,
>> so new helper functions should probably go in helper.c.
>>
> Why do we want to cut back on the use of the implicit global ? what is the
> criteria for a function to be in the implicit global list ?
The global register was necessary in the dyngen based system. We can
avoid that these days, it just makes code more fragile compared to
plain C. The changes in performance seems to be marginal.
>> > also, what kind of functions are typically emulated using helpers ?
>>
>> Anything that seems too hard to do inline :-) tcg/README has a
>> paragraph at the end giving some rules of thumb.
>>
>> -- PMM
>
>
>
> --
> Kind Regards
>
> Xin Tong
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-09-24 8:15 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-19 12:06 [Qemu-devel] op-helper.c vs helper.c Xin Tong Utoronto
2011-09-19 12:09 ` Alexander Graf
2011-09-19 13:49 ` Peter Maydell
2011-09-22 13:09 ` Xin Tong Utoronto
2011-09-22 13:49 ` Peter Maydell
2011-09-24 8:15 ` Blue Swirl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).