Difference: GccInternals (1 vs. 3)

Revision 32008-03-22 - ChenDing

Line: 1 to 1
 
META TOPICPARENT name="ProjectHome"
Changed:
<
<

Data structures in Gcc

>
>
Please expand the notes to include examples you find useful.

Code tree representation

Gcc maintains a single-node representation for many code components. For example the same identifier name is always represented by the same node. This is done through the tree interfaces (implemented) in tree.c. To get the unique node for an identifier, use tree id = get_identifier (name), where name is a character string.

 
Changed:
<
<
Please expand the notes to include examples you find useful.
>
>
If you want to print out the string representation of the node type, you can use the following trick due to TongxinBai. As an example cute code trick in Gcc, while the tree types are defined in enum tree_code in tree.h, the actual definition is not in tree.h but in tree.def, which includes a list of all node types and their (string) symbols. Looking at the code you'll quickly see how the trick works, and borrowing it you can easily construct an array of type strings (in your program file) as follows:

#define DEFTREECODE(SYM, STRING, TYPE, NARGS)   STRING,
char *type_names[] = {
#include "tree.def"
};

During debugging, you can use the node type as the index into the type_names array and pull up the string name that you so often crave for under the circumstance.

Data structures in Gcc

  Vector

Revision 22008-03-14 - ChenDing

Line: 1 to 1
 
META TOPICPARENT name="ProjectHome"

Data structures in Gcc

Line: 6 to 6
  Vector
Changed:
<
<
The file vec.h specifies the interface equivalent of a template class library for variable size vectors. For example
>
>
The file vec.h specifies the interface equivalent of a template class library for variable size vectors. For example
 
      list = VEC_alloc (data_struct*, heap, num_elements);
      VEC_quick_push (data_struct*, list, new_elem);
Added:
>
>
Hash table

The interface is specified in include/hashtab.h. To allocate and use, try exploring some uses in Gcc, one of which is the following in cgraph_node() in cgraph.c.

static GTY((param_is (struct cgraph_node))) htab_t cgraph_hash;

 if (!cgraph_hash)
     cgraph_hash = htab_create_ggc (10, hash_node, eq_test, NULL);
 
 slot = (struct cgraph_node **) htab_find_slot (cgraph_hash, &key, INSERT);

Revision 12008-03-13 - ChenDing

Line: 1 to 1
Added:
>
>
META TOPICPARENT name="ProjectHome"

Data structures in Gcc

Please expand the notes to include examples you find useful.

Vector

The file vec.h specifies the interface equivalent of a template class library for variable size vectors. For example

      list = VEC_alloc (data_struct*, heap, num_elements);
      VEC_quick_push (data_struct*, list, new_elem);
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding URCS? Send feedback