[PATCH] Adjust lazy macro definition
Nathan Sidwell
nathan@acm.org
Fri Aug 17 23:16:00 GMT 2018
We provide a lazy macro definition hook, to deal with the FP macros
where it is expensive to generate the string representation of the FP
value. The current hook is much more general than needed, but it's not
clear that generality can be used because we don't document what macro
state can be manipulated. We create the macro early with a bogus FP
token, then overwrite the identifier node making it look like a builtin
node with an out-of-range index. Upon first use we call the hook which
checks the index value, and if ok updates with the saved macro after
nadgering the token of interest with the correct string.
This patch makes things cleaner. We don't overload the builtin index
meaning, rather we add a lazy field to cpp_macro, and allow the user to
control that. There's plenty of spare space there, so this doesn't
increase the macro size.
Rather than have the user's hook fish out the cpp_macro object, we
provide the object directly, along with the lazy hook value for it to
inspect. It can then update the macro as desired and declare victory.
We already have _cpp_maybe_notify_macro_use that deals with lazy
definition, it's simply a matter of adjusting that and using it in a few
more place that are now easier.
Finally, the PCH machinery was invoking the lazy hook during PCH write
out. This seems fragile to me -- changing the memory state during
serialization. We don't need to do that, as the lazy machinery is all
GTY marked. This does mean we'll lazily define the PCH'd macro upon
every first use after reading back, but that doesn't seem costly to me.
booted & tested on x86_64-linux.
nathan
--
Nathan Sidwell
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mac-lazy.diff
Type: text/x-patch
Size: 12204 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20180817/a514fea5/attachment.bin>
More information about the Gcc-patches
mailing list