|avoiding abandoned stack values email@example.com (steve) (2003-09-23)|
|Date:||23 Sep 2003 13:26:09 -0400|
|Organization:||Posted via Supernews, http://www.supernews.com|
|Keywords:||code, optimize, question|
|Posted-Date:||23 Sep 2003 13:26:08 EDT|
alone has no need to leave a stack value but when used as y=x+1; it
does. Assuming I leave a stack value for each expression, a problem
Since y and x+1 are both expressions and are always candidates for
rvals, and it is instictive to assume that a stack value should be
produced each time an expression is reduced. What is the best way to
cleanup unconsumed stack values? One of my early attempts was to emit
a pop each time a sem-colon was encountered. This solves some of the
problems, but is clearly not the solution. Even if it were,
inefficient run-time would result due to the extra instuctions.
I am working in the flex-bison arena. The target language is a report
writer using C-like constructs with built-in extensions for calls into
database API's. I'm starting with MYSQL, and expect to tackle other
db's once I get the core working.
I am familiar with the use of stack frames which eliminate the problem
in procedure calls, but the problem I have stated is
Thanks for any guidelines from those who have already overcome!
[Early C compilers evaluated expressions in three ways, depending on
whether it needed the value, the side effects, or the truth value.
Top level expressions are evaluated for side effect, internal
subexpressions for value, expressions in if/while/for statements or
operands of || and && for truth value. You have to do something like
Return to the
Search the comp.compilers archives again.