[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] Using TCC as a backbone for our compiler

From: grischka
Subject: Re: [Tinycc-devel] Using TCC as a backbone for our compiler
Date: Sat, 13 Jun 2009 15:39:40 +0200
User-agent: Thunderbird (Windows/20070221)

Jerome St-Louis wrote:
Hi all...

We are contemplating using TCC as the backbone engine to generate
object code for an eC language Just-In-Time compiler system.

At the moment, the compiler uses C as an intermediate language,
outputs intermediate C files, then call GCC on those to produce object
We're hoping to do everything at once, in-memory for a more lively solution.

How would this best be done by using the TCC library? Is there some
kind of abstract syntax tree system or other in memory code
representation we could plug into directly, as opposed to having TCC
do parsing again? This would ideally increase performance a lot..

One of our main worries are the few GCC extensions the intermediate C
code makes use of, which I believe TCC does not support... Again this
might possibly not be an issue if we're going directly to an in-memory
code representation?

If you have something already working that produces C code then it
might be easy to adjust it for TCC.  The performance on the side
of TCC might be a non issue, it reads 20-30MB of C per second.

Of course it has advantages if you can use a code generator directly,
say TCG (Tiny Code Generator from qemu) as something small and fast
or LLVM as something more solid.

However the input for such generators is not C, it's more like high
level assembler code.  Basically you get arithmetic instructions with
abstract registers such as
        tcg_gen_add_i32(R2, R0, R1);
and branch instructions to labels such as
        tcg_gen_brcond_i32(TCG_COND_EQ, R0, R1, L1);
and that's it, roughly.

Currently TCC's does not provide an interface with such generators,
but I guess sooner or later we are going there (if anywhere). That
is either by using TCG and/or changing TCC's current generators to
provide a better defined interface.

For now TCC's only input is C and the only "in memory representation"
is machine code.

See "libtcc.h" for the interface and "tests/libtcc_test.c" for an
usage example.

--- grischka

It is very likely that this project becomes our primary focus for the
time to come so we're very interested in any feedback you guys may
have, and if there is an opportunity for us to improve TCC at the same
time we'd be more than happy to contribute.


Best regards,

Jerome @ Ecere

reply via email to

[Prev in Thread] Current Thread [Next in Thread]