On 11/04/13 15:25, Jakub Jelinek wrote:
On Mon, Nov 04, 2013 at 04:43:33PM -0500, David Malcolm wrote:
I tried converting gimple_call_set_lhs to accept a gimple_call, rather
than a gimple, and excitingly, it was easiest to also convert
cgraph_edge's call_stmt to also be a gimple_call, rather than just a
gimple.
Am attaching a patch (on top of the patch series being discussed) which
adds this compile-time typesafety; bootstrap is in-progress. IMHO very
little use of is-a.h was needed (5 instances of as_a, and 3 of dyn_cast;
no use of is_a).
But that was just for gimple_call_set_lhs, which indeed usually is done just
for newly created calls, not for inspecting preexisting IL. If you do it
for say gimple_call_arg, gimple_call_fndecl and/or even gimple_call_lhs, I'm
afraid suddenly it would be hundreds of ugly dyn_casts/as_a and similar mess
everywhere. And, calls are still far less common gimple statements than
gimple assign.
Understood. I think one of the questions we need to answer is when a
conversion of this nature is done (towards static typechecking), how
often will we know the static type vs how often we're going to have to
play these is_a/as_a games.
I'd claim that often if we're stuck with needing is_a/as_a, then we've
got some refactoring to do.
Based on discussions Andrew, David & myself had today, my gut says let's
try to go foward with the basic conversion based on its merits as they
stand today, but without taking the step towards static typing at this time.
Jeff