[cfe-dev] Need for new FORTRAN front-end for LLVM ?

John McCall rjmccall at apple.com
Sat Aug 25 13:11:43 PDT 2012


On Aug 24, 2012, at 11:05 PM, Hal Finkel wrote:
> On Fri, 24 Aug 2012 17:40:07 -0700
> John McCall <rjmccall at apple.com> wrote:
>> I do not
>> think it'd be a good idea in the long run to implement it by
>> translating FORTRAN into Clang's C ASTs, and there are probably
>> relatively few things that you could re-use from Clang's source
>> code.  I recommend using Clang primarily as a design model, rather
>> than as a shortcut to a working implementation.
> 
> I think that there are a few things that can be shared, the two largest
> pieces are probably:
> 
> - The driver (both C and family and Fortran share many of the same
>   requirements for finding basic system libraries and tools and
>   running them)
> 
> - The C preprocessor (any production Fortran compiler needs a C
>   preprocessor (with slightly-modified tokenization rules). With some
>   refactoring, this should also be shared.

Okay, interesting.

>> If you're seriously interested in this, there are ways that we could
>> suggest to *improve* on Clang as an implementation model.  In
>> particular, I would recommend introducing a third IR, so that the
>> translation goes like so: source code -> AST -> high-level IR -> LLVM
>> IR -> machine code
> 
> Do you view this high-level IR as being C-ish in scope (with better
> aliasing rules)? For example, do you think that array slices will be
> expanded at this high-level IR, or would that wait until CodeGen?

I think it would be FORTRAN-ish in scope. :)  I think you would
specifically try to avoid lowering out any potentially-useful language
abstractions.  You'll probably find yourself wanting to reimplement a
few LLVM optimizations on top of it, like mem2reg and possibly GVN.

John.



More information about the cfe-dev mailing list