[LLVMdev] dragon egg + llvm for fortran to c translation

Dmitry Mikushin dmitry at kernelgen.org
Sat Mar 2 07:31:10 PST 2013

Hi Philipp,

Let me provide you with an example back from September 2011. Attached is
original Fortran source, optimized LLVM IR and what we regenerated back
into C from LLVM IR by means of C backend. As you can see, the C code
closely resembles LLVM IR.

I don't know what you intend to use it for (maybe some source-to-source
compiler or DSL?), but to our experience, we had a system using C backend,
but dropped it in favor of native LLVM backend for the target architecture
(NVPTX in our case). Source-to-sourcing is generally very painful, there is
a great chance to spend 90% of resources on stupid technical problems and
only 10% - for ideas/innovation.

Note we were only users of C backend, and only had to make minor fixes to a
working system. Developers are Chris, Duncan (replied on this thread too)
and others. They may have more insight, if you would need implementation

- D.

2013/3/2 Philipp Schwaha <philipp at schwaha.net>

> Thank you for your reply Dmitry!
> It would not be too great a deal, if I need to use previous versions as
> long as it would get the desired results :)
> Would the code from the IR be portable to different C compilers? I
> guess the resulting C code will not have too much resemblance to the input?
> cheers
>         Philipp
> On 03/01/2013 05:02 PM, Dmitry Mikushin wrote:
> > DragonEgg only converts GCC's IR to LLVM IR. And -march=c is C backend.
> > We used it for a while last year, but its support has been dropped
> > several months ago. There are people, who are still using it privately,
> > as far as I know.
> >
> > - D.
> >
> > 2013/3/1 Philipp Schwaha <philipp at schwaha.net <mailto:
> philipp at schwaha.net>>
> >
> >     hi!
> >
> >     I would like to know if it is feasible to use the dragon egg gcc
> >     plugin to automatically convert fortran code to c. Having found that
> >     it is possible to output llvm byte code back to c (at least
> >     something like this gave me this impression/hope: llc -march=c -o
> >     test.c) I am hoping to use dragon egg to generate the byte code from
> >     fortran 90 which than output to c.
> >     Does this seem feasible at all? How much in terms of variable names
> >     etc. could be retained in this manner?
> >
> >     thanks for any suggestions or comments
> >        Philipp
> >     _________________________________________________
> >     LLVM Developers mailing list
> >     LLVMdev at cs.uiuc.edu <mailto:LLVMdev at cs.uiuc.edu>
> >     http://llvm.cs.uiuc.edu
> >     http://lists.cs.uiuc.edu/__mailman/listinfo/llvmdev
> >     <http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev>
> >
> >
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130302/e040c8c3/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sincos.sincos_loop_1_kernelgen.c.device.F90
Type: application/octet-stream
Size: 425 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130302/e040c8c3/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sincos.sincos_loop_1_kernelgen.c.device.F90.ir.c
Type: text/x-csrc
Size: 12241 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130302/e040c8c3/attachment.c>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: sincos.sincos_loop_1_kernelgen.c.device.F90.opt.ir
Type: application/octet-stream
Size: 3354 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130302/e040c8c3/attachment-0001.obj>

More information about the llvm-dev mailing list