On Sat, 2 Jun 2012 10:48:47 -0700 Brett Foster <fost...@edgeandvertex.org> wrote:
> Hi all, > > I'm working on a GCC plugin, having made a lot of progress on that > front. So far running my plugin works 'more or less' on things like > the linux kernel. On the other hand running it on the plugin itself > causes problems. Given that some of the data structures are pretty > complicated in GCC I'm not surprised. > > So the question I have (w.r.t. TREE data structures) are: > > 1) How to marking a node as visited by my algorithm (without screwing > up the compiler!) > > 2) How to associate additional data (perhaps a pointer to something > else) to a node (like a unique identifier, or a pointer to a data > structure). In the MELT meta-plugin (recall that MELT is a high-level domain specific language to extend GCC, see http://gcc-melt.org/ for more) we extensively use associative hash-tables for that. MELT offers homogeneous hash-tables, e.g. hash-table associating tree (i.e. non-null tree pointers) to arbitrary non-null MELT values (e.g. MELT closures, or MELT lists, or MELT objects, etc etc), or hash-table associating (non null) gimple to non null MELT values. So you can have e.g. an hash-table associating each tree (every tree is in GCC a non-null pointer to a structure) with data associated to it. Once it has some data you know that this tree has been visited. You cannot (in current GCC architecture) extend existing GCC core data representations. For example, you cannot add a new field to the union tree_node or to the struct tree_decl_common ... I recommend associating information in your own plugin data structure, such as some hash table. In a few words, plugins cannot extend existing GCC data structures, but can associate them to their own data. Regards -- Basile STARYNKEVITCH http://starynkevitch.net/Basile/ email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359 8, rue de la Faiencerie, 92340 Bourg La Reine, France *** opinions {are only mine, sont seulement les miennes} ***