On Tue, 2007-05-08 at 22:45 -0700, Bill Wendling wrote:> On May 8, 2007, at 10:05 PM, Mohd-Hanafiah Abdullah wrote:
>
> > On Tue, 2007-05-08 at 11:58 -0700, Bill wrote:
> >> On 5/8/07, Mohd-Hanafiah Abdullah <napi at axiomsol.com>
wrote:
> >>> How does the C back-end of LLVM differ from the one in gcc2c
> >>> developed
> >>> by SUN several years ago?
> >>>
> >> Hi Napi,
> >>
> >> For one, it converts LLVM's bytecode to C instead of GCC's
RTL. It's
> >> also under a different license.
> >
> > Hi Bill:
> >
> > Would it be easier to convert from LLVM's bytecode to C as opposed
to
> > from RTL? What about the readability of the produced C code. I would
> > think since RTL maintains a structure that is directly inherited from
> > the high-level language structure it would be less difficult to
> > turn it
> > into some C code that is relatively more readable, as compared to
> > synthesizing C code from the low-level bytecode. I stand corrected.
> >
> Hi Napi,
>
> Considering that LLVM already has a C backend, then it's easier to
> generate it from the LLVM bytecode. :-) LLVM's intermediate
> representation of the program (the bytecode) is also derived directly
> from the high-level language. When it gets to the C backend part, it
> simply has had transformations done on it.
>
> I don't believe that the C backend was made for readability. In fact,
> because LLVM is in SSA form, it uses many temporary variables and
> loses a lot of the information about what the original variable's
> name was.
>
> The best way to get a feel for how it is is to write a program and
> generate the C code for it with the LLVM backend. (See the llc tool
> for information on this.)
>
> Though, this begs the question of why you want to use something which
> converts it to C instead of just using one of the target backends to
> generate native code.
Hi Bill:
I've been looking for a C++ to C translator for quite some time.
The purpose is to support C++ for the compiler I developed targeting the
JVM. But the compiler I wrote only supports ANSI C (1989). So the C++
to C translator is needed, and among the options are as follows:
a) EDG (rather expensive, around USD 100K with source code)
b) Comeau (around USD 25K for customization service and you don't get
the source code)
c) LLVM (tried, but the resulting C code is quite hairy, pardon the
expression)
d) gcc2c (trying now, don't know how useful yet)
For more info on the said C to JVM compiler you can check out our
website: http://www.axiomsol.com
Cheers.
Napi