[M3devel] multiple evaluation hazard in backend?
Jay K
jay.krell at cornell.edu
Mon Aug 27 04:18:29 CEST 2012
Tony, does m3front tend or tend not to ask the backend
to evaluate the same expression multiple times, or does it
tend to allocate a temporary if it would do so?
It's just that my current approach, if not given temporaries,
may tend to evaluate expressions multiple times that either
must not (for correctness) or ought not (for efficiency).
I guess I'll learn soon enough.
My current "stack" is just TEXTs.
Very simple.
If I had to eliminate multiple evaluations I'd have to consider
a few alternatives:
1) for every, push, do something like
"{ T s0 = expr;"
for every pop "}"
That would require I always "use before pop", not
"use not after pop" as I tend do. That isn't always easy.
The above is also wrong. Instead of "s0", it'd be "sN"
where N is the current stack depth, then "get(n)" would,
like, get N-n.
2) Alternatively, if I knew the maximum stack depth such
as by making two passes, I could have an array of unions.
That would make casts less verbose -- they'd be via union member access,
if no size change.
2b) I could maintain a stack pointer at compile time or runtime.
Runtime easier but slower.
I still might want to record types with my texts, like to avoid extra casts.
Or maybe m3front does that already?
Anyway, for now I can ignore it. I'm just starting in on function
calls, and I still haven't handled nested functions.
- Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20120827/4beace7b/attachment-0001.html>
More information about the M3devel
mailing list