Re: [PATCH] fix trap in parallel for m32r-sim

Kazuhiro Inaoka
2004-01-20T04:57:56Z

> Ah hah! So this is about TRAP_SYSCALL. :-)
> TRAP_SYSCALL is a simulator-only facility to simplify printf,exit,etc.
Yes. It's only for executing a system call hook routine.
The parallel execution is no problem if a trap is not for system
calls(TRAP_SYSCALL etc.).
A trap instruction doesn't need a result of second insn. (A trap is like a
jump instruction.)
A trap handler routine needs a result of second insn.
A m32r_trap() also executes a trap handler routine.

> I gather you want r0 to be 1 before the trap is taken,
> violating standard parallel execution semantics: all inputs
> read before any outputs written.
> i.e. you want the trap to _read_ the value of r0 and get 1.
> This is different than the violation I refered to previously
> where the trap will _write_ the value of r0, say, before
> other insns have read their inputs.
>
> It seems like you're trying to fix a broken program by breaking
> (or at least hacking) the simulator. How about instead just having
> a rule that says the TRAP_SYSCALL trap cannot be paired with instructions
> that set up inputs for the syscall? This would be no different
> than trying to make
>
> asm ("add r1,r0 || ldi r0,#1"); // increment r1 by 1
>
> work. It doesn't work because the `add' will read the value of r0
> before the ldi has set it to 1.
> [apologies if I got the syntax wrong, haven't programmed m32r
> assembler in a while :-)]

> the TRAP_SYSCALL trap cannot be paired with instructions
> that set up inputs for the syscall
....(--;)

The following patch is only for a trap in parallel.