This is the mail archive of the fortran@gcc.gnu.org mailing list for the GNU Fortran project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

more remapping fortran math functions


   I figured out where in the fortran front-end the intrinsic libc
math functions get converted from say 'exp' (as called in the .f90 sources)
to 'expl' for long doubles. This is done by these macros in gcc/fortran/f95-lang.c.

#define DO_DEFINE_MATH_BUILTIN(code, name, argtype, tbase) \
    gfc_define_builtin ("__builtin_" name "l", tbase##longdouble[argtype], \
                       BUILT_IN_ ## code ## L, name "l", true); \
    gfc_define_builtin ("__builtin_" name, tbase##double[argtype], \
                        BUILT_IN_ ## code, name, true); \
    gfc_define_builtin ("__builtin_" name "f", tbase##float[argtype], \
                        BUILT_IN_ ## code ## F, name "f", true);

#define DEFINE_MATH_BUILTIN(code, name, argtype) \
    DO_DEFINE_MATH_BUILTIN (code, name, argtype, mfunc_)

#define DEFINE_MATH_BUILTIN_C(code, name, argtype) \
    DO_DEFINE_MATH_BUILTIN (code, name, argtype, mfunc_) \
    DO_DEFINE_MATH_BUILTIN (C##code, "c" name, argtype, mfunc_c)

If I change...

    gfc_define_builtin ("__builtin_" name "l", tbase##longdouble[argtype], \
                       BUILT_IN_ ## code ## L, name "l", true); \

to

    gfc_define_builtin ("__builtin_" name "l", tbase##longdouble[argtype], \
                       BUILT_IN_ ## code ## L, name "L", true); \

I am able to cause the 'expl' symbol to become an 'expL' symbol in the object
created for _exp_r16.F90. I'm still not sure how to proceed though.
Assuming that the fortran compiler doesn't reset the values we set in
rs6000_darwin_long_double_builtins() using SET_DECL_ASSEMBLER_NAME() for
the long double calls like expl(), we need to have the fortran front-end
check the symbolname created by the macro against that we would get
from another call to DECL_ASSEMBLER_NAME() for the same symbolname.
That is if the macro says 'expl' we need to get DECL_ASSEMBLER_NAME()
to tell us it is now 'expl$LDBL128' instead. The difficult part is
that all of these remapped functions are defined in gcc/gcc/builtins.def
which isn't include in the fortran front-end. So we don't seem to have
access to those BUILT_IN_XXX declarations we used to do the remapping
in gcc/config/darwin.c.
              Jack


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]