The thing inside of us that makes us go up is our attitude.
A study on genericizer in GCC - chandrakumar.in
A study on genericizer in GCC PDF Print E-mail
Written by Chandra Kumar R   


The need for genericizer in GCC depends on how well GENERIC can be made to match up with the source language that is supported in GCC front-end.

I.e. In GCC, if the parser for a language uses GENERIC as intermediate language representation, then a genericizer is not required. If the language parser uses any other intermediate language representation, then a genericizer is required to convert that intermediate language representation to GENERIC.


Note: Any intermediate language representation that seems appropriate for a language can be used. [Ref: Page 93 of GCC Internals for GCC version 4.4.0].

Hence there are following two cases:

  1. Case1: Parser uses GENERIC as intermediate language representation
  2. Case2: Parser uses any other intermediate language representation


Case1: Parser uses GENERIC as intermediate language representation


In this case, the language parser uses GENERIC and some language specific trees as intermediate language representation. [Ref: Page 93 of GCC Internals for GCC version 4.4.0]. The Gimplifier (which belongs to 'language-independent portions of the compiler') is called directly for the GENERIC representation generated by the parser.

The language specific trees which is generated along with the GENERIC by the parser would be converted into GIMPLE as follows [Ref: Page 201 of GCC Internals for GCC version 4.4.0]:

  1. Convert the language specific trees to GENERIC. And then provide the GENERIC to the Gimplifier to generate GIMPLE.
  2. Convert the language specific trees to GIMPLE straightly.


The above two tasks would be done by the gimplifier hooks [Ref: Page 199 of GCC Internals for GCC version 4.4.0]. Gimplifier hooks are the one that are used to over-ride the standard functions of Gimplifier. This over-riding of standard functions is required because of language specific trees generated as intermediate represenation by parser.

Example:

For C, the language specific trees are converted into GIMPLE straightly (without converting into GENERIC) by the gimplifier hooks [Ref: Page 201of GCC Internals for GCC version 4.4.0].



Case2: Parser uses any other intermediate language representation


In this case, the language parser uses its own intermediate language representation [Ref: Page 93 of GCC Internals for GCC version 4.4.0]. And for this intermediate language representation to be used by Gimplifier (which belongs to 'language-independent portions of the compiler'), it should be converted to GENERIC. For this we require a 'Genericizer'. Genericizer converts the intermediate language representation generated by the parser to the GENERIC form. Hence the genericizer would be the language dependent portion of the compiler.

Thus generated GENERIC is given to the gimplifier.

Example: