[Top][All Lists]

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

Re: [Tinycc-devel] Re : Code generation: `libtcc` vs transpiling to C

From: rempas
Subject: Re: [Tinycc-devel] Re : Code generation: `libtcc` vs transpiling to C and then compiling with tcc. Why one over another?
Date: Tue, 23 Nov 2021 20:47:06 +0100 (CET)

Hello David and thanks for the quick answer! So first of all let's start by 
saying that I'm a n00b at this topic. Haven't created a compiler, trasnpiler or 
a "programming language" with any other way. What I want to do is have a 
backend for my "programming language". So let's consider the following syntax 
(suppose the `write` function exists):

function main:
    write(1, "Hello world!\n", 13);

I want this to produce machine code. From my understanding, `libtcc` takes a 
as an argument to do the job (at least from what I understand from the code) so
I will have the convert the given code to:

int main() {
    write(1, "Hello world!\n", 13);}

In the end, I must first convert my code to C and then generate machine code no 
which way I choose to do it. I can't directly use a function from `libtcc` to 
translate each
statement of my language to an assembly instruction. And that's why I'm asking 
not generate the code and then use `tcc` directly rather than having to use 
`libtcc` and
have to interface with its API and in general make my work harder?

I hope it now makes sense now!

Btw the idea of a "real-time JIT "transpiling" is SUPER interested. If handled 
right... MAN!!!
It can be a true revolution. The funny thing is that tcc generates code so fast 
that we could
create a script that takes some input and then spits C code and compiles and 
then executes
the program. For small programs, we will not notice a difference. Dude don't do 
this to me
please I'm so so so hyped now!!!!

P.S. Forgive me if the formatting is not the best, normally I'm not writing 
so I'm still working on that

23 Νοε 2021, 19:48 Από david.koch@libertysurf.fr:

> Hi, what are you trying to achieve ?
> MIPS -> x86 ?
> MIPS -> C -> tcc -> x86 ?
> Or instead of MIPS another language ?
> There are several "esoteric" languages that compiles to C, then it's up to 
> you using the right compiler for the last mile trip.
> Decompiling is a hefty task to do, see my previous request on this list 
> (GLFrontier).
> While feasible, it's not necessarily the best option.
> If you are using an "esoteric" language, it's up to you to produce 
> "optimizable" C code that would suit tcc to compile.
> Are you doing that at build time or do you plan trying to perform a real-time 
> JIT "transpiling" ?
> More questions than answers.
> Regards.

reply via email to

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