tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] Can a biggener (and idiot) like me read and understand TC


From: rempas
Subject: [Tinycc-devel] Can a biggener (and idiot) like me read and understand TCC's backend so I can create my own frontend with it?
Date: Wed, 26 Jan 2022 20:25:35 +0100 (CET)

**Huge post incoming!!!**

Hi! I'm a beginner with low level programming and assembly. I'm interested in 
learning
assembly so I can create my own (non-toy) compiler. Now, I'm a huge fanatic for
TCC!!! I LOVE IT!!! I love it so much that it inspired my to create my own 
compiler that
will output C code and then use TCC (or any C compiler to compile) it.
However, I thought about some things.

1. Compile times. TCC is the fastest non-toy compiler but my compiler
    will add up to the compilation time because it will need to create
    these C files. On top on that, the C programming language doesn't
    use the best practices when it comes to header files as you have to
    re-write the files end up on becoming slower not because of the compiler
    or the backend because because of the design of the language itself.

2. Having to deal with C. A lot of things of my language will not translate to C
    with the best possible way so it will be harder and I will need to 
sacrifice the
    compilation times and maybe runtime performance.

3. Optimizations. As we know, TCC doesn't make optimizations (or does it?) so
    the resulting code can run slower that GCC or Clang some times. This means
    that we will need to use 2 compilers in some projects to get the best 
possible
    performance while keeping the amazing fast compilation times of TCC.

So what I thought was... "You know what? We don't I make a compiler that will
create binaries itself? I will have the best possible compilation times and I 
will
be able to apply the optimizations that I want!". Well that's a great idea but 
there
are some problems.

1. This is HARD!!! Not only I must first learn assembly but I must also read
    the manufacturer manual for each CPU that I want to support. Also, even
    across the same instruction set, Each operating system needs different
    work to be done (I don't know, I suppose even OSes that use something
    common like ELF will not work out of the box without any small change 
right?).
    So even for people that know assembly NOW and are very experienced with it,
    this will be very hard to do and maintain unless you are a genius and I am 
NOT
    one for sure (the exact opposite probably).

2. Where do I learn? I mean, resources about creating binary files in ELF format
    (or whatever each OS is using) and learning the CPU instructions don't 
exist here
    and there and even in the places where they exist, it is most of the times, 
references
    or things like manufacturer manuals which are not the best things to study 
if you
    don't have years of experience and you are already confident enough with 
this topic.

Ok this is getting too big, I will be sort. So after all that, I either do my 
original idea
and output C code or I'm writing this email and hope for a reply. So what I 
wanted
to ask from people that have work with TCC's code and know how assembly works,
is TCC's backed tied with TCC's frontend? Will it be strain-forward If I was 
trying to learn
some assembly and then trying to read TCC backend and then try to understand how
it works and add my own frontend to it? What are your thoughts?



reply via email to

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