This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Improved use of TREE_SYMBOL_REFERENCED in the C++ front end


On Thursday, October 31, 2002, at 10:37 AM, Richard Henderson wrote:

On Thu, Oct 31, 2002 at 10:18:57AM -0800, Matt Austern wrote:
On Thursday, October 31, 2002, at 10:03 AM, Mark Mitchell wrote:
You just need to find the places we call assemble_name and pass in a
DECL, when there is one to be had. What that really means, is finding
the places where SYMBOL_REFs are created and pass in a DECL, where
appropriate. This is one of those things that will end up being a big,
but largely mechanical, patch. You don't have to set the DECL field
in the SYMBOL_REF everywher possible -- just everywhere that you need
the call back to occur. That may just be make_decl_rtl.
I've been thinking for a while that expanding a
SYMBOL_REF to contain a pointer back to the DECL
would be a Very Good Thing.

Something I didn't mention in my previous message is that if
we're going to put a callback in the macro that sets the
referenced bit, the first step is to create that macro!  That is,
the first step is to (1) change TREE_SYMBOL_REFERENCED
so that it returns an rvalue; (2) create a new macro,
TREE_SET_SYMBOL_REFERENCED; and (3) change every
place in the compiler that uses TREE_SYMBOL_REFERENCED
in an lvaluish way so that it uses the new SET macro instead.
I don't think it's worth creating a new macro.  Using a langhook
directly should be sufficient for the set.  Part 1 is still
valuable though.
One of us isn't being sufficiently clear.  I suspect it's me, so I'll
try to explain more clearly.

Yes, you're certainly right that we need a new langhook, and
I should certainly add that as well.  (I should have mentioned it
as part 4 above).  The question is: when does that langhook
get called?

The answer I would like is that it gets called whenever an
identifier's REFERENCED flag gets changed.  Right now, the
way that flag gets changed is with things like
  TREE_SYMBOL_REFERENCED (id) = 1;
Since TREE_SYMBOL_REFERENCED returns an lvalue,
there's no way to distinguish from within the macro whether
it's being used to query the flat or to change it.   (Besides,
even if I did call the langhook every time the existing macro
is used, I wouldn't be calling the langhook at the right time:
I'd be giving it the old value, not the new one.)

(You might ask why I want to have the langhook called from
within the macro, instead of calling it separately.  Answer:
the referenced flag is set all over the place, not just in (say)
assemble name, sometimes very deep in platform-specific
code; if you do a grep -r, you'll see what I mean.  My feeling
is that it's safer from a maintenance perspective to to have
the langhook called from just one point.  I'm willing to be
persuaded otherwise, of course.)

So I'd like to have two different macros, one to query the flag
and one to set it.  Certainly it would make no sense to change
TREE_SYMBOL_REFERENCED to return an rvalue unless I
also provided a new mechanism for setting that flag.

			--Matt


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]