Basile STARYNKEVITCH wrote: > Shobaki, Ghassan wrote: >> In some optimization passes it may be useful to know the programming >> language that we are compiling. Is there a way to get that information >> in the middle end and back end? > > I am not sure that would be a good idea. In fact you are suggesting that > the intermediate representation[s] (ie Gimple) is not intermediate > enough, since you need something more (like the source language).
I think some kind of optimization behaviour depends on the language used, but this should be represented in some way in the Gimple and not via some parsing of the programming language. One example is "-fcx-fortran-rules" which allows for complex multiplication and division to follow the Fortran rules - it is used when compiling the gfortran library, but I think it is also a good option for several C programs as it goes a middle way between strict IEEE and maximal optimization. Another example of language specifics is the handling of parenthesis: Fortran requires that they are honoured, e.g. for (a/b)/c the optimization a/(b*c) is not allowed. This is honoured via PAREN_EXPR and thus there is no need to know the programming language. Thus I'm in favour of programming language specific optimization - by having it expressed in the Gimple itself. Tobias PS: I think one exception are debugging symbols - there is some language dependence, but I think no plug-in support is planed for this.