On 11/05/2013 04:57 PM, David Malcolm wrote:
Thanks for looking through this. Both you and Andrew objected to my use of the is-a.h stuff. Is this due to the use of C++ templates in that code? If I were to rewrite things in a more C idiom, would that be acceptable?
Thats too strong a statement. I don't like as_a<>, but it has a use. The follow on stuff you were showing was full of as_a<>'s which was what I was objecting to.
I think the as_a<>'s in this patch set is mostly necessary in order to carry out the conversion and leave it there.. The only way to get rid of them is to continue through with the rest of what I talked about... which isn't happening soon. But when we do, it should start to reduce the numbert of as_a<>'s, not increase them.
I don't really object to them in this patchset.. we're replacing GIMPLE_CHECK() with an as_a<> call, so to me thats pretty much a wash in most ways. And its a means to an end.
For instance, rather than, say: p = as_a <gimple_statement_asm> ( gimple_build_with_ops (GIMPLE_ASM, ERROR_MARK, ninputs + noutputs + nclobbers + nlabels)); we could have an inlined as_a equivalent in C syntax: p = gimple_as_a_gimple_asm ( gimple_build_with_ops (GIMPLE_ASM, ERROR_MARK, ninputs + noutputs + nclobbers + nlabels)); where there could be, say, a pair of functions like this (to handle const vs non-const): inline gimple_asm gimple_as_a_gimple_asm (gimple gs) { GIMPLE_CHECK (gs->code == GIMPLE_ASM); return (gimple_asm)gs; } inline const_gimple_asm gimple_as_a_gimple_asm (const_gimple gs) { GIMPLE_CHECK (gs->code == GIMPLE_ASM); return (const_gimple_asm)gs; }
I really don't think we need to bend over and jump through hoops in order to implement as_a<> in a different way. That's just more hackery, and we're trying to get away from that.
Andrew