We used ET-trees for maintaining dominance information in loop optimizer. ET-tree is a data structure for representing trees. It offers logarithmic time for standard tree operations (insert, remove, link, cut) and poly-logarithmic time for finding common ancestor of two nodes.
The tree is represented by a sequence of symbols obtained by calling algorithm on root node.
Such sequences are called Eulerian Tours, hence the name of the structure.
For example, for tree on figure , the corresponding ET-sequence is
1,2,1,3,4,5,4,6,4,3,1
.
Because it's inefficient to maintain these sequences as strings, slightly different approach is used -- the sequence itself is represented by a binary tree, where the represented sequence is obtained by reading the values of the nodes from left to right.
For example, two possible encodings of the above sequence are shown in figure .
In our implementation, we have chosen splay-trees as the sequence representation, with some modifications:
remove
.
There are two data types for representing nodes -- et_forest_occurrence
and et_forest_node
.
et_forest_occurrence
represents the occurrences of the nodes in tree (therefore, these nodes form the
splay-tree). It contains informations for the splay-tree (parent node, left son, right son), pointer to the
next occurrence of the same node, and number of nodes in left and right subtree (this is used for comparison
whether an occurrence is before another one, or not). et_forest_node
represents each node. It contains
pointers to the first and last occurrences of the node and the node value. The et_forest_t
is then simply
a hashtable converting node value to appropriate et_forest_node
.