Junchao Zhang
2010-Jan-19 03:58 UTC
[LLVMdev] Can I port LLVM as a source-to-source compiler?
Hello, I am working in a project on a parallel programming language. I want to base our language on Java or C/C++. But Java is preferred. Many similar projects adopts a source-to-source methodology, e.g., Berkeley UPC(using Open64), Titanium, and Rice University's Co-array Fortran. They output C code with calls to the runtime. I think there are at least three reasons: 1) using C as the output, it gets more portability. 2) leverage the front ends of existing compilers. 3) leverage optimizations in existing compilers. I wonder if LLVM is suitable for this kind of work. Can LLVM experienced users give me some hints on this topic? Thanks in advance. Junchao Zhang -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100118/000cff95/attachment.html>
Kenneth Uildriks
2010-Jan-19 14:06 UTC
[LLVMdev] Can I port LLVM as a source-to-source compiler?
On Mon, Jan 18, 2010 at 9:58 PM, Junchao Zhang <junchao.zhang at gmail.com> wrote:> Hello, > I am working in a project on a parallel programming language. I want to base > our language on Java or C/C++. But Java is preferred. > > Many similar projects adopts a source-to-source methodology, e.g., Berkeley > UPC(using Open64), Titanium, and Rice University's Co-array Fortran. They > output C code with calls to the runtime. I think there are at least three > reasons: 1) using C as the output, it gets more portability. 2) leverage the > front ends of existing compilers. 3) leverage optimizations in existing > compilers. > > I wonder if LLVM is suitable for this kind of work. Can LLVM experienced > users give me some hints on this topic? > > Thanks in advance. > > Junchao Zhang > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev > >LLVM can be made to output (horribly gnarly and non-portable) C code. However, I haven't tried it and I'm not sure what state that functionality is in.
Jean-Daniel Dupas
2010-Jan-19 14:49 UTC
[LLVMdev] Can I port LLVM as a source-to-source compiler?
Le 19 janv. 2010 à 15:06, Kenneth Uildriks a écrit :> On Mon, Jan 18, 2010 at 9:58 PM, Junchao Zhang <junchao.zhang at gmail.com> wrote: >> Hello, >> I am working in a project on a parallel programming language. I want to base >> our language on Java or C/C++. But Java is preferred. >> >> Many similar projects adopts a source-to-source methodology, e.g., Berkeley >> UPC(using Open64), Titanium, and Rice University's Co-array Fortran. They >> output C code with calls to the runtime. I think there are at least three >> reasons: 1) using C as the output, it gets more portability. 2) leverage the >> front ends of existing compilers. 3) leverage optimizations in existing >> compilers. >> >> I wonder if LLVM is suitable for this kind of work. Can LLVM experienced >> users give me some hints on this topic? >> >> Thanks in advance. >> >> Junchao Zhang >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >> >> > > LLVM can be made to output (horribly gnarly and non-portable) C code. > However, I haven't tried it and I'm not sure what state that > functionality is in. >Not very well supported I think: http://llvm.org/docs/ReleaseNotes.html LLVM 2.6 Release Notes “The C Backend (-march=c) is no longer considered part of the LLVM release criteria. We still want it to work, but no one is maintaining it and it lacks support for arbitrary precision integers and other important IR features.” -- Jean-Daniel
Greg Chadwick
2010-Jan-19 14:57 UTC
[LLVMdev] Can I port LLVM as a source-to-source compiler?
Junchao Zhang wrote:> Hello, > I am working in a project on a parallel programming language. I want to > base our language on Java or C/C++. But Java is preferred. > > Many similar projects adopts a source-to-source methodology, e.g., > Berkeley UPC(using Open64), Titanium, and Rice University's Co-array > Fortran. They output C code with calls to the runtime. I think there > are at least three reasons: 1) using C as the output, it gets more > portability. 2) leverage the front ends of existing compilers. 3) > leverage optimizations in existing compilers. > > I wonder if LLVM is suitable for this kind of work. Can LLVM experienced > users give me some hints on this topic? > > Thanks in advance. > > Junchao ZhangAs others have mentioned there is a C backend, though in this case I see little point in using it. If you produce a LLVM language front-end (i.e. something which takes your language and creates LLVM) then you get portability and a whole bunch of optimizations. If you think it's significantly easier to compile your language down to C rather than LLVM then you could pass that into one of the C language front ends (LLVM-GCC or Clang). Cheers, Greg Chadwick
Reid Kleckner
2010-Jan-19 18:04 UTC
[LLVMdev] Can I port LLVM as a source-to-source compiler?
On Mon, Jan 18, 2010 at 10:58 PM, Junchao Zhang <junchao.zhang at gmail.com> wrote:> Hello, > I am working in a project on a parallel programming language. I want to base > our language on Java or C/C++. But Java is preferred. > > Many similar projects adopts a source-to-source methodology, e.g., Berkeley > UPC(using Open64), Titanium, and Rice University's Co-array Fortran. They > output C code with calls to the runtime. I think there are at least three > reasons: 1) using C as the output, it gets more portability. 2) leverage the > front ends of existing compilers. 3) leverage optimizations in existing > compilers. > > I wonder if LLVM is suitable for this kind of work. Can LLVM experienced > users give me some hints on this topic?No, I don't think that LLVM would be useful for making a source-to-source compiler. LLVM itself is mostly concerned with optimizations and code generation. It doesn't have any code for representing any high-level ASTs or doing type checking on them. You could look at clang, though, if for some reason you need an AST for C. Reid