next up previous contents external
Next: Using the C3 linear Up: Adding a new phase: Previous: Properties

PIPS

NEWGEN data structures in

 

An other key point of PIPS is the NEWGEN [7] description language that is used in PIPS to define all the data structures. Domains are defined NEWGEN to express complex data structures such as sums (+ like a C-union) or products (x like a C-struct) of other domains , lists (*), sets ({}), array ([]) or maps (->) of domains . These domains are translated by NEWGEN in type definitions for different languages (C and Common-Lisp for now) with different methods to deal with this data: creators, destructors, accessors, readers and writers, etc. The last ones allow persistence and having PIPS written in different languages but sharing the same data. In this way, NEWGEN adds an object oriented layer that abstracts the target language data structures.

In our dead code elimination example, we do not define any new type but only use the internal representation of the abstract syntax tree. An excerpt of its definition is on Figure 7. All the NEWGEN data structures are defined in the LaTeX files from $PIPS_DIR/Development/Documentation/newgen that are used to generate the documentation about the types and of course the target language specifications.

NEWGEN defines a generic mono- or multi-domain iterator (gen_recurse and gen_multi_recurse in C) that recursively applies functions on a list of domain top-down and then a bottom-up on a data structure. In our example on Figure 8 in suppress_dead_code_statement() we iterate on all the statements of the code and apply on them dead_statement_filter() top-down to eliminate some dead code, recurse if this function returns TRUE , and then dead_statement_rewrite() bottom up to remove some code that has become useless because of the previous elimination of nested statements. All the accessors such as statement_instruction() to get or set an instruction of a statement or the is_instruction_loop tag to test if an instruction is a loop are generated by NEWGEN .

   figure1496
Figure: Excerpt of the dead code elimination phase .


next up previous contents external
Next: Using the C3 linear Up: Adding a new phase: Previous: Properties

Ronan KERYELL
vendredi, 20 décembre 1996, 16:25:47 MET