Skip to contentSkip to conversation

sparc: potentially incorrect if dynamic npc?

Qemu-devel Artyom Tarasenko 2 participants 4 messages Apr 20, 2010

lore
Share & tools
lore
#0 lore raw

/* XXX: potentially incorrect if dynamic npc */
static void do_branch

There are few comments like this in target-sparc/translate.c . In what case is it incorrect?

Can do_branch functions be called with dynamic npc?

#1 lore raw
Quoted 7 lines · Artyom Tarasenko

/* XXX: potentially incorrect if dynamic npc */
static void do_branch

There are few comments like this in target-sparc/translate.c . In what case is it incorrect?

Can do_branch functions be called with dynamic npc?

Maybe, if there are two branches or jumps in a row. The last time I checked, at least for successive branches we do the correct thing. It's pretty obscure, no compiler will generate such sequences and nobody with asm skills either.

Another corner case that IIRC we don't handle is where a jump instruction is at the end of the page and its delay slot instruction is at next page. I think one commit for Microblaze added support for this case.

#2 lore raw

2010/4/20 Blue Swirl <[email protected]>:

Quoted 7 lines · Artyom Tarasenko
Quoted 6 lines

/* XXX: potentially incorrect if dynamic npc */
static void do_branch

There are few comments like this in target-sparc/translate.c . In what case is it incorrect?

Quoted 6 lines
Quoted 1 line

Can do_branch functions be called with dynamic npc?

Maybe, if there are two branches or jumps in a row. The last time I checked, at least for successive branches we do the correct thing. It's pretty obscure, no compiler will generate such sequences and nobody with asm skills either.

Why not? That's how you can implement a very compact 'case' operator in asm. It is used in OBP.

But you are right, this seems to work (at least with ss-5 and ss-20 OBP).

Quoted 3 lines

Another corner case that IIRC we don't handle is where a jump instruction is at the end of the page and its delay slot instruction is at next page.

Do you mean that npc is dynamic in this case, or that if npc is dynamic and the instruction is at the end of the page we have a problem?

Quoted 2 lines

I think one commit for Microblaze added support for this case.

Signature · 4 lines
Regards,
Artyom Tarasenko

solaris/sparc under qemu blog: http://tyom.blogspot.com/
#3 lore raw
Quoted 24 lines · Artyom Tarasenko

2010/4/20 Blue Swirl <[email protected]>:

Quoted 7 lines · Artyom Tarasenko
Quoted 6 lines

/* XXX: potentially incorrect if dynamic npc */
static void do_branch

There are few comments like this in target-sparc/translate.c . In what case is it incorrect?

Quoted 6 lines
Quoted 1 line

Can do_branch functions be called with dynamic npc?

Maybe, if there are two branches or jumps in a row. The last time I checked, at least for successive branches we do the correct thing. It's pretty obscure, no compiler will generate such sequences and nobody with asm skills either.

Why not? That's how you can implement a very compact 'case'
operator in asm. It is used in OBP.

But you are right, this seems to work (at least with ss-5 and ss-20 OBP).

Quoted 8 lines
Quoted 3 lines

Another corner case that IIRC we don't handle is where a jump instruction is at the end of the page and its delay slot instruction is at next page.

Do you mean that npc is dynamic in this case, or that if
npc is dynamic and the instruction is at the end of the page we have a problem?

The problem is with code generation in general (delay slot instruction gets translated effectively before the branch), could be related to dynamic npc too but the branch could be bn or ba as well.