public inbox for java@gcc.gnu.org
 help / color / mirror / Atom feed
* Q: Is it possible to create FORTRAN->Java compiler using GCC/EGCS
@ 2000-04-01  0:00 Denis Mishin
  2000-04-01  0:00 ` Tom Tromey
  0 siblings, 1 reply; 6+ messages in thread
From: Denis Mishin @ 2000-04-01  0:00 UTC (permalink / raw)
  To: gcc; +Cc: java-discuss

Hello.

As far as I understand, GCC has frontend modules for various languages (C,
FORTRAN, etc) to some internal representation, and a set of those converting
to concrete os/platform - right?

Question: is it possible to write add-on for gcc/egcs to create a
cross-compiler from FORTRAN to JavaVM? Or limitations of JVM doesn't allow
to do this?

Sincerely, Denis

-----------------------------------------------------------------
Mishin Denis                      mishin@synapse.ru
Software engineer                 ICQ 51801409

SYNAPSE Science Center            www.synapse.ru
Moscow, RUSSIA
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Q: Is it possible to create FORTRAN->Java compiler using GCC/EGCS
  2000-04-01  0:00     ` Tom Tromey
@ 2000-04-01  0:00       ` Per Bothner
  0 siblings, 0 replies; 6+ messages in thread
From: Per Bothner @ 2000-04-01  0:00 UTC (permalink / raw)
  To: gcc, java-discuss

Tom Tromey <tromey@cygnus.com> writes:

> Actually, I was referring to this:
> 
> http://archive.csee.uq.edu.au/~csmweb/uqbt.html#gcc-jvm
> 
> I don't know if this targets PicoJava or not.  It was written by
> different people than the PicoJava port from SAC.

I took a very quick look at this.  It looks like the basic idea
is to have represent memory as a global array of ints.
I.e.:
        public int[] memory;

A "pointer" is an index into "memory".  It looks like each element
of memory is only used to store an 8-bit byte.  My guess is this is
so one can address 8-bit bytes, which storing a point in a memory cell.

It definitely looks like a quick hack, but it might still be a
reasonable approach.  I can see that you have (at least) two basic
choices: You have a single global "memory", which means it has to be a
single type (char or int).  You then have to do explicit conversions
(e.g masks, shifts) to re-interpret the memory as some other data type.
Alternatively, you can have multiple memory objects, one for each "C
object" (variable or array).  Then you (mostly) don't have to do as
many conversions.  However, you have to represent a "C pointer" as a
pair of (reference to a C Object, offset), and casting between pointer
and integer may not be possible.  You have various tradeoffs for heap
allocation (with the global memory you have to implement your own
malloc/free, which allocate a chunk from the memory array, and
re-allocate it if it is too small).

In any case, you should start with a run-time model: How would I
represent the data types (integer, floats, arrays, maybe pointers and
structures) of my language using Java data types?  How would I represent
parameter passing?  How do I represent call-by-reference (in Fortran)
or taking the address of an object component (in C)?

Once you can *hand-translate* Fortran (or C) code to either Java
source or Java bytecodes, then you can write a Gcc back-end that
does the translation for you.
-- 
	--Per Bothner
per@bothner.com   http://www.bothner.com/~per/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Q: Is it possible to create FORTRAN->Java compiler using GCC/EGCS
  2000-04-01  0:00   ` Per Bothner
@ 2000-04-01  0:00     ` Tom Tromey
  2000-04-01  0:00       ` Per Bothner
  2000-04-01  0:00     ` David Starner
  1 sibling, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2000-04-01  0:00 UTC (permalink / raw)
  To: Per Bothner; +Cc: Denis Mishin, gcc, java-discuss

>>>>> "Per" == Per Bothner <per@bothner.com> writes:

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

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

Actually, I was referring to this:

http://archive.csee.uq.edu.au/~csmweb/uqbt.html#gcc-jvm

I don't know if this targets PicoJava or not.  It was written by
different people than the PicoJava port from SAC.

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Q: Is it possible to create FORTRAN->Java compiler using GCC/EGCS
  2000-04-01  0:00 ` Tom Tromey
@ 2000-04-01  0:00   ` Per Bothner
  2000-04-01  0:00     ` Tom Tromey
  2000-04-01  0:00     ` David Starner
  0 siblings, 2 replies; 6+ messages in thread
From: Per Bothner @ 2000-04-01  0:00 UTC (permalink / raw)
  To: Denis Mishin, gcc, java-discuss

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/

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Q: Is it possible to create FORTRAN->Java compiler using GCC/EGCS
  2000-04-01  0:00 Q: Is it possible to create FORTRAN->Java compiler using GCC/EGCS Denis Mishin
@ 2000-04-01  0:00 ` Tom Tromey
  2000-04-01  0:00   ` Per Bothner
  0 siblings, 1 reply; 6+ messages in thread
From: Tom Tromey @ 2000-04-01  0:00 UTC (permalink / raw)
  To: Denis Mishin; +Cc: gcc, java-discuss

>>>>> "Denis" == Denis Mishin <mishin@synapse.ru> writes:

Denis> Question: is it possible to write add-on for gcc/egcs to create
Denis> a cross-compiler from FORTRAN to JavaVM? Or limitations of JVM
Denis> doesn't allow to do this?

It might be possible in theory.
There is at least one group out there with a jvm backend to gcc.
Whether this works with g77, I don't know.

Tom

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Q: Is it possible to create FORTRAN->Java compiler using GCC/EGCS
  2000-04-01  0:00   ` Per Bothner
  2000-04-01  0:00     ` Tom Tromey
@ 2000-04-01  0:00     ` David Starner
  1 sibling, 0 replies; 6+ messages in thread
From: David Starner @ 2000-04-01  0:00 UTC (permalink / raw)
  To: Per Bothner; +Cc: Denis Mishin, gcc, java-discuss

On Sun, Jan 30, 2000 at 08:28:23PM -0800, Per Bothner wrote:
> 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.

Yes, but there was someone recently with an alpha JVM backend for 
egcs 1.1.1. They didn't have time to work on it more, and I don't
know whether they resolved the issues with getting it assigned
to the FSF or not. They have an index in Freshmeat, if anyone
is interested.

-- 
David Starner - dstarner98@aasaa.ofe.org
If you wish to strive for peace of soul then believe; 
if you wish to be a devotee of truth, then inquire.
   -- Friedrich Nietzsche

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2000-04-01  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-01  0:00 Q: Is it possible to create FORTRAN->Java compiler using GCC/EGCS Denis Mishin
2000-04-01  0:00 ` Tom Tromey
2000-04-01  0:00   ` Per Bothner
2000-04-01  0:00     ` Tom Tromey
2000-04-01  0:00       ` Per Bothner
2000-04-01  0:00     ` David Starner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).