This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Thoughts on "const tree" and "const rtx"?
- From: Roger Sayle <roger at eyesopen dot com>
- To: gcc at gcc dot gnu dot org
- Date: Fri, 7 Nov 2003 07:54:17 -0700 (MST)
- Subject: Thoughts on "const tree" and "const rtx"?
I apologise if this has been discussed numerous times before and
I've managed to miss the thread each time its been brought up.
Is there any reason why GCC doesn't make far more use of "const tree"
and "const rtx" in function parameter lists to mark the underlying
data structure as immutable? It occurred to me that an easy way of
identifying problematic parts of fold might be to change its prototype
to either "tree fold(const tree)" or "const tree fold(const tree)"
and let the compiler do all of the hard work.
This should not only improve documentation of which functions may
modify which arguments, but in theory it should also improve the code
that we generate for the compiler itself.
A quick grep of GCC shows that we do use "const tree" and "const rtx"
but only in a rare handfull of cases. Is this by design or is it a
reasonable goal to start transitioning simple leaf functions, etc.?
Does the ugliness of having to cast away constness in a few places
outweigh the potential benefits of stronger type checking elsewhere?
Would the XEXP and TREE_OPERAND macros create significant problems?
Roger
--