From: Erik P. <epe...@iv...> - 2004-10-22 15:51:50
|
On Fri, 22 Oct 2004, Maarten Brock wrote: > I would like to hear some comments on this from you. I see three > approaches: > 1) keep it as it is > 2) change according to the request > 3) accept "critical" before as well as after the function specifier and > change behaviour accordingly. > > Your opinion please? > Maarten > [Feature request #992518 asks that interrupts are disabled prior to stack frame setup rather than after for functions with the "critical" attribute] If the syntax of option #3 is implemented (so that the syntax is similar to the C standard's handling of the "inline" keyword), I would prefer that the alternate syntax not change the behavior. That is, there should only be one behavior for "critical" at the function scope. The tricky bit with implementing the request is keeping the stack offsets correct. If the psw if pushed before the stack frame is set up, the offsets to the parameters will need adjusting. Although aopGet/aopPut could compensate for this in the backend, the debugging symbols are generated elsewhere and would not reflect the offset change. This was as far as I originally pondered the request, since it seemed to need more extensive changes than I was comfortable with. On a second look, I think I see a fairly simple solution. SDCCast.c's createFunction() already handles other cases of discontinuities on the stack between a function's parameters and its local variables; we could simply add something like: if (IFFUNC_ISCRITICAL (name->type)) stackPtr -= port->stack.direction * port->stack.critical_overhead; with the appropriate additions to port.h, */main.c, and */gen.c (of course, the port implementation can set port->stack.critical_overhead to 0 if this change in behavior is inconvenient or undesired and leave the backend code generator alone). As far as I can tell, there is no run-time penalty for this change, so I would opt to implement as requested. Erik |