Fortran's Affinity towards intel x86

Tobias Burnus burnus@net-b.de
Tue Mar 12 09:52:00 GMT 2013


Hi,

Vikram wrote:
> It is amazing to see, when porting gfortran to custom architecture, that
> calling convention of the assembly code generated one to one match to that of intel x86. In my
> view the reasons may be

Can you specify a bit more in detail what you mean by calling 
convention? gfortran should use the normal calling convention of the 
platform.

However: Fortran uses (by default) something like call by reference. 
Hence, if you have:
call foo(7)
the compiler creates an integer variable - and a pointer to that 
variable is passed. In C it would pass the value. In Fortran, you have 
to use the VALUE attribute for the dummy argument in the procedure 
declaration for pass-by-value.

Additionally, gfortran *sometimes* passes the function results as hidden 
first argument. (And with -ff2c, there are also some other 
particularities.) For the naming: By default, gfortran lowercases all 
procedure names name and appends an underscore (with modules a bit 
more). The platform might then add further dressing, depending on the 
platform ABI. Using attributes, one can change the default cdecl to 
stddecl or fastcall (as in C/C++).

There is some code which does certain assumptions, e.g. a byte consists 
of 8 bits (which should have been done more properly), but as gfortran 
successfully runs on (nearly?) all GCC targets, I doubt that it matters 
in practice – and for target

Tobias



More information about the Fortran mailing list