I.e. In GCC, if the parser for a language uses GENERIC as intermediate language representation, then a genericizer is not required. If the parser language 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:
- Case1: Parser uses GENERIC as intermediate language representation
- 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]:
- Convert the language specific trees to GENERIC. And then provide the GENERIC to the Gimplifier to generate GIMPLE.
- Convert the language specific trees to GIMPLE straightly.
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:
No comments:
Post a Comment