Where to attach backend builtin decl?
FX Coudert
fxcoudert@gmail.com
Thu Feb 28 12:23:00 GMT 2008
> The following is an example:
>
> module spu_intrinsics
> use, intrinsic :: iso_c_binding
> implicit none
> contains
> function builtin_spu_add_int(a, b) result(c) bind(c,
> name="__builtin_spu_add_1")
> integer (c_int), intent(in):: a(4), b(4)
> integer(c_int) :: c(4)
> end function builtin_vec_add_int
> end module spu_intrinsics
There is currently no functionality in the Fortran front-end to
access a builtin decl by its name, because Fortran doesn't usually
expose builtins! However, it might be useful to add such
functionality (I can myself see others uses for it, like some of the
standard intrinsic modules). The builtins are stored in an array
named built_in_decls[], but hopefully there's something more
intelligent that going though that and checking. The C front-end has
to do it, so we can probably leverage that code...
> In trans-decl.c function
> gfc_get_extern_function_decl builds a new decl for the this function.
I would have said that you should interrupt the current codepath
before we get into gfc_get_extern_function_decl: check where that is
called, and when the symbol name starts with "__builtin_", instead of
calling gfc_get_extern_function_decl() call your own function that
looks up for the right intrinsic decl.
But...
> I
> tried to set the fndecl to the builtins backend decl, but it seems not
> working. The question is where to attach the decl of the C bultin
> function, in order to generate inline code for the fortran program?
Interesting... I can't see why.
FX
--
François-Xavier Coudert
http://www.homepages.ucl.ac.uk/~uccafco/
More information about the Fortran
mailing list