gfortran

Hi, in a thread this afternoon about compiling the Fortran SPEC2000 to
LLVM bytecode, Chris mentioned that it should be possible to compile
to LLVM with the gfortran front end, although no one has necessarily
tried it.

I was surprised (and happy) to hear this, as under the impression that
it would require a "complete rewrite of the gfortran backend" [1].
Now, I probably misinterpreted that exchange, but it was the only
public record I could find of discussion about using LLVM and
gfortran.

What's the difference between how it works now and what Steven
Bosscher was saying would be a huge job?

Also, is there any rough idea of how far from working it might be - I
note that there's considerable room for interpretation in the phrasing
of "See what works and what
doesn't, debug, fix, submit patch, repeat." :slight_smile:

The reason I'm asking is that if it sounds like something I'll be able
to make a dent in, I'm going to start on it first thing tomorrow
morning. Like it's my job.

Thanks,
-mike

[1]:Steven Bosscher - Re: LLVM/GCC Integration Proposal

That would be great! That way I don't have to fiddle around with NAG f95 anymore, because even for research purposes, the license is quite expensive.

Be sure to keep us posted on your progress.

greetings,

Kenneth

Hi, in a thread this afternoon about compiling the Fortran SPEC2000 to
LLVM bytecode, Chris mentioned that it should be possible to compile
to LLVM with the gfortran front end, although no one has necessarily
tried it.

Yup.

I was surprised (and happy) to hear this, as under the impression that it would require a "complete rewrite of the gfortran backend" [1]. Now, I probably misinterpreted that exchange, but it was the only public record I could find of discussion about using LLVM and gfortran. What's the difference between how it works now and what Steven Bosscher was saying would be a huge job?

This comment meant that a "complete rewrite" was needed to go from GFortran AST's directly to LLVM, without going through GENERIC/GIMPLE. If you use GENERIC/GIMPLE (as we currently do) it should be straight-forward.

Also, is there any rough idea of how far from working it might be - I note that there's considerable room for interpretation in the phrasing of "See what works and what doesn't, debug, fix, submit patch, repeat." :slight_smile:

I don't know that anyone has tried it. I'd suggest configuring llvm-gcc4 with gfortran enabled, then try some simple fortran programs. I expect that there are only minor corner cases missing, e.g. some forms of ARRAY_REF we don't implement or something.

The reason I'm asking is that if it sounds like something I'll be able
to make a dent in, I'm going to start on it first thing tomorrow
morning. Like it's my job.

Very cool, that would certainly be welcome.

-Chris

> Hi, in a thread this afternoon about compiling the Fortran SPEC2000 to
> LLVM bytecode, Chris mentioned that it should be possible to compile
> to LLVM with the gfortran front end, although no one has necessarily
> tried it.

Yup.

> I was surprised (and happy) to hear this, as under the impression that
> it would require a "complete rewrite of the gfortran backend" [1]. Now,
> I probably misinterpreted that exchange, but it was the only public
> record I could find of discussion about using LLVM and gfortran. What's
> the difference between how it works now and what Steven Bosscher was
> saying would be a huge job?

This comment meant that a "complete rewrite" was needed to go from
GFortran AST's directly to LLVM, without going through GENERIC/GIMPLE. If
you use GENERIC/GIMPLE (as we currently do) it should be straight-forward.

OK, I see.

> Also, is there any rough idea of how far from working it might be - I
> note that there's considerable room for interpretation in the phrasing
> of "See what works and what doesn't, debug, fix, submit patch, repeat."
> :slight_smile:

I don't know that anyone has tried it. I'd suggest configuring llvm-gcc4
with gfortran enabled, then try some simple fortran programs. I expect
that there are only minor corner cases missing, e.g. some forms of
ARRAY_REF we don't implement or something.

> The reason I'm asking is that if it sounds like something I'll be able
> to make a dent in, I'm going to start on it first thing tomorrow
> morning. Like it's my job.

Very cool, that would certainly be welcome.

OK, I've started by pulling the latest LLVM CVS and gcc4 SVN.
It looks like building f95 requires GMP, so I'm working on that too.
I'll update again once I get it building.

Thanks,
-mike