This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Re: Q: Is it possible to create FORTRAN->Java compiler using GCC/EGCS


Tom Tromey <tromey@cygnus.com> writes:

> It might be possible in theory.
> There is at least one group out there with a jvm backend to gcc.

I know about the PicoJava backend.  My impression is that it generates
code for an *extended* JVM, and thus the resulting code wouldn't
run on a normal JVM.

> Whether this works with g77, I don't know.

Since Fortran doesn't have C-style pointers, it should be a lot easier
to translate f77 to jvm than languages like C.  However, by the time
the Fortran has been translated to RTL, many low-level operations may
have been translated to operations that cannot be (efficiently)
handled using JVM.  That is why gcj handles the Java soure-to-bytecode
translation by *not* using the normal Gcc backend functionality, but
by using a special module that translates tree nodes directly to
bytecode.  This module is in gcc/java/jcf-write.c.  I see no reason in
principle why you cannot do the same thing for the f77 front-end:  I.e.
extend the f77 front-end to handle the -femit-class-file in the same
way that the Java front-end does.  However, I can see some difficulties
in practice, though I think they are solveable.

First, it is possible jcf-write might depend on variables and functions
in the rest of the Java front-end.  This may require some moving things
around.  More difficult is the the f77 front-end may generate tree code
constructs that jcf-write doesn't know how to handle.  In some cases it
may be easy enough to extend jcf-write to handle those constructs.
Others may be more difficult.  For example, I don't know how EQUIVALENCE
is handled by f77, and I don't know how difficult it would be map
that into java bytecodes.  You do have to decide how function parameters
and pass-by-reference is handled.  (I would probably define some abstract
Reference class which the called function would use to access the
actual parameter.  The calling function would have to create the
appropriate Reference instance for referenccing the actual parameter,
and pass that to the callee.)
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

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