calling convention
Nuno Pedrosa
nunomdp@gmail.com
Wed Nov 27 22:22:00 GMT 2013
Hi all,
Regarding my question below and due to the lack of interest on this list
on developing this I decided
to roll up my sleeves and do some code hunting.
So far I have found the following (svn rev 205232):
upercase names: - I believe we could use the function that does name
mangling as all the code is read in lowercase.
this is gcc/fortran/trans-decl.c:346 (more
or less) and function is gfc_sym_mangled_function_id()
order of hidden string arguments: this get a bit more hairy but here are
my findings:
- in gcc/fortran/trans-types.c:2823 (gfc_get_function_type) the hidden
string length arguments are added.
so I thought that could just added them in the loop where the
individual arguments are processed (line 2775).
all seems good but further down the line I get problems in
gcc/fortran/trans-decl.c:2099 (create_function_arglist) with gcc
assertion failures.
my conclusion is that I do not really understand the *tree* type used
in the code and I struggle to understand what is happening in the
following chunck of code from gcc/fortran/trans-decl.c
"""
hidden_typelist = typelist;
for (f = gfc_sym_get_dummy_args (sym); f; f = f->next)
if (f->sym != NULL) /* Ignore alternate returns. */
hidden_typelist = TREE_CHAIN (hidden_typelist);
for (f = gfc_sym_get_dummy_args (sym); f; f = f->next)
{
char name[GFC_MAX_SYMBOL_LEN + 2];
/* Ignore alternate returns. */
if (f->sym == NULL)
continue;
type = TREE_VALUE (typelist);
if (f->sym->ts.type == BT_CHARACTER
&& (!sym->attr.is_bind_c || sym->attr.entry_master))
{
tree len_type = TREE_VALUE (hidden_typelist);
tree length = NULL_TREE;
if (!f->sym->ts.deferred)
gcc_assert (len_type == gfc_charlen_type_node);
else
gcc_assert (POINTER_TYPE_P (len_type));
"""
can anybody shed some light?
I will be very grateful for any help.
Nuno
On 19/11/13 23:59, Nuno Pedrosa wrote:
> Hi all,
>
> This is my first post in the GCC Fortran mailing list but i have been
> working with fortran for the last 10 years.
> gfortran has been an important part during all this time, most of the
> time in Linux.
>
> Quite recently I moved to developing in Windows and a lot of the legacy
> code was compiled in Compaq Visual Fortran.
> this means that code that depends on this Fortran library relies on the
> old Compaq calling conventions.
>
> The Intel compiler has options to change calling conventions.
> that is change from default: lower case + appended underscore and string
> lengths passed at the end of the argument list, to the Compaq
> conventions: Upper case, no underscore and string lengths passed after
> each string argument.
> Not to mention the cdecl and stdcall calling conventions.
>
> My question is: are there any plans to include such compiler options in
> gfortran, if not can anybody point me in the right direction on which
> gfortran source files to check if this can be done?
>
> thanks in advance,
>
> Nuno
More information about the Fortran
mailing list