[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] Some questions regarding of TCC's optimizations.
From: |
rempas |
Subject: |
[Tinycc-devel] Some questions regarding of TCC's optimizations. |
Date: |
Sun, 27 Mar 2022 10:34:56 +0200 (CEST) |
Hi! First of all I would like to say thank you to everyone that has made TCC be
what it is today! Now, I know and I will not waste anyone's times as our time
is precious.
So, I want to create a new programming language. Of course there is motivation
behind this decision but it has nothing to do with this email so anyone who's
interested can send my a personal email and talk about it.
I started learning and I get the concept of the frontend well (and I even made
some small work already)! Now about the backend. I want something that will
compile the source code FAST. What is my definition of "fast"? Well, GCC is
slow for my taste!
After making a lot of research (trust me!). I ended up on having the following
choices:
1. Output assembly and then use GAS (because of the backend support) and a
linker to create the final executable/library.
2. Output machine code and create the object files myself.
3. Use QBE. Cproc which is a C frontend for QBE, compiles times 4-7 times
faster than GCC -O2 and has about 70-80% of the runtime performance. So it is
awesome!!!
4. TCC!!!!
*** THE NEXT TWO PARAGRAPHS CAN BE SKIPPED IF YOU ARE REALLY SHORT IN TIME***
TLTR, 2 is SUPER hard when you want to support multiple OSes and ISAs like I
want to do. 3 is like a psudo assembly and If I'm about to do this then I
should as well learn and output assembly, it makes more sense to me given the
fact that I want fast compile times! I will also have more control as QBE has a
couple of limitations.
I know a couple of stuff about X86_X64 assembly so I could even make some parts
of my compiler and have fun! However, something crossed my mind immediately.
TCC compiles code faster than "GAS" (especially if you add the time needed for
linking) so why not use TCC instead? I will also have only one dependency in
this case, which is awesome!
I was thinking about outputting C as the first choice when I decided to truly
start working into achieving my goal some months ago because of TCC. However, I
was stopped because the runtime performance (aka code quality) of the code that
was compiled with TCC. Back then, I didn't knew what optimizations were. Well,
I knew the word but I didn't knew how compilers do them. Now that I have made
my research and I know a couple of them, It seems to me that I can do some of
them in my frontend and use TCC's inline assembly to do a couple of more low
level ones. So probably I will be able to achieve a compiler that compiles code
very fast but also has great runtime performance similar to GCC -O2. So it's a
dream coming true!
However, because I want to make an industry level language that will hold its
ground and that will be useful, I will need some support and help! To start, I
want to learn about optimizations on TCC. I heard that TCC doesn't make ANY
optimizations. Is this true? If no, then what are the optimizations it does? If
yes, then does this include the ability to inline functions and the "proper"
register use instead of "push" and "pop" every local variable on the stack. The
"inline" keyword seems to be ignored based one the "online documentation" but
the page was last updated in August 2018 and that was 3 and a half years ago so
I wonder if things have changed.
I'm not very interesting about things like "dead code illumination" or anything
that requires a lot of time to calculate and profile (and of course a lot of
work from our end as the profiling code for the compiler will need to be very
advanced). I think that it's up to the programmer to write code code and not
have the compiler transform bad code into good code with all the disadvantages
this brings to the compile times. You like learning and getting better right?
However, I care about the stuff that gives you the 80% of the performance and
for things that the programmer cannot manually do or decide. So I will like to
know how low should I go and how many features of TCC I can use. Register usage
and inlining will be a good start for me. After I learn how TCC treats this two
things, I think I can make the most important decisions and start working in
the language. I can then make separate questions for every specific thing that
I need as I face a problem. Sounds good?
Sorry for the long post and thanks in advance!
- [Tinycc-devel] Some questions regarding of TCC's optimizations.,
rempas <=