g77 intrinsics
Janne Blomqvist
jblomqvi@cc.hut.fi
Fri Oct 8 09:51:00 GMT 2004
On Thu, Oct 07, 2004 at 09:44:41PM -0700, Jerry DeLisle wrote:
> I see on the gfortran.org wiki page mention of a good beginners project
> would be to implement some g77 non-standard intrinsics. Is this need
> still valid and where can one begin to study to learn the structure of a
> g77 intrinsic and what is the list of items needing to be done?
I guess so. There are zillions of g77 intrinsics, and I think that
many are still not implemented. I think Steve Kargl made some TODO
list about this at some point (search archives for this mailing list
and ye shall find), but I don't know how current that is. In the g77
manual you'll find a list of all g77 intrinsics, and in
gcc/fortran/intrinsic.c you can find the names of all intrinsics in
gfortran.
For the 100 000 ft overview, an intrinsic typically consists of two
parts. The first is the actual implementation in the runtime library
(directory libgfortran) and the second is the magic in the compiler
fronted to make gfortran generate code to call the runtime
library. This is not always true, IIRCS some intrinsics can optionally
be handled via constant folding, e.g. instead of SQRT(3) resulting in
a runtime library call to the SQRT intrinsic with the argument 3, the
compiler can replace the entire expression with the constant value
1.414... .
The magic begins in gcc/fortran/intrinsic.c. There you'll find the
functions add_functions and add_subroutines which add all the
intrinsics to the compiler. Each intrinsic optionally has three extra
functions, a simplify function (found in simplify.c IIRC), a resolve
function (iresolve.c) and a third one which I don't remember. However,
some of the intrinsics don't need these functions, you can see this by
them having NULL pointers in the add_{function|subroutine} functions
instead of pointers to these three functions. This is because *mumble
mumble*.
I think the easiest way is to take a look at how some existing
intrinsic is implemented. I recommned getarg and iargc, they are
pretty simple.
> I am interested in learning and doing, but I am pretty green.
Well, I'm pretty green too, so I guess this is an example of the blind
leading the deaf, eh? ;-)
> But, one must start somewhere and do something or get nowhere, no?
Yes. One problem I had was to figure out where to start. gcc is among
the largest free software projects around, there's lots and lots of
code. Of course, by restricting yourself to the fortran frontend you
can ignore most of the code, but it's still a lot to wrap your head
around.
What I found that helped me a lot was using ecb (Emacs code browser)
and etags. If you use debian, just
apt-get install ecb exuberant-ctags
and off you go.
> If I can't handle it then i will certainly let folks know. I would like
> to at least look at an example and if I think I can do it I will get the
> FSF paperwork signed.
Good luck!
--
Janne Blomqvist
More information about the Fortran
mailing list