Using fold() in frontends
Geert Bosch
bosch@adacore.com
Mon Mar 7 17:52:00 GMT 2005
On Mar 7, 2005, at 12:40, Giovanni Bajo wrote:\
> But how are you proposing to handle the fact that the C++ FE needs to
> fold
> constant expressions (in the ISO C++ sense of 'constant expressions)?
> For
> instance, we need to fold "1+1" into "2" much before gimplification.
> Should
> a part of fold() be extracted and duplicated in the C++ frontend?
Yes. As we've found out over and over again, the semantics of fold in
the
various front ends and the middle end is not the same. While it is nice
to
share code, when we end up placing an arbitrary restriction on our
selves that
the same tool must be used for both hammering nails and driving screws,
any
advantage of code reuse quickly disappears.
So, even if we end up copying a lot of the code, that's better than
forced sharing.
After a while, both copies will indeed diverge and you'll end up with a
good hammer
and a good screwdriver. Right now we're in a situation where
improvement of one
use of fold, causes problems for its other use.
-Geert
More information about the Gcc
mailing list