tinycc-devel
[Top][All Lists]
Advanced

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

[Tinycc-devel] Questions regarding ARM Thumb code generation


From: Erlend Sveen
Subject: [Tinycc-devel] Questions regarding ARM Thumb code generation
Date: Sun, 22 Mar 2020 11:26:30 +0000

Hi all!

I have been trying to get a compiler running on a Cortex-M7. I've had success
with some of the GNU binutils (linker, assembler, objdump, ...), but getting
GCC to run seemed to be a bit too ambitious. I went looking around and found
TCC. Sadly it does not support thumb instructions, but I did find that someone
has attempted to get going with it:

  https://github.com/gfwilliams/tinycc

While it barely compiles an empty function, I decided to spend a couple of
weekends trying to understand it and figure out if I could get it working.
Those weekends have now turned into month(s). Using the tests in the
tests/tests2 directory, I'm having a success rate of about 88% (I'm ignoring
those that are intended to not compile). The ones that fail are 4 due to
floating point support, 1 because of array copying, 1 due to C library issues
and 1 due to an immediate being out of range (still working on these). Note that
I'm running the tests manually since I can't run the test system on my MCU
(yet), so take the numbers with a grain of salt. I've also been using an older
version of TCC (from the link above), so I'll have to migrate my changes and
run all the newer tests too.

While I'm still hacking away on the original arm-gen.c it is starting to look
rather serious. So I figured I should ask a few questions on the mailing list
to ensure that I'm on the right track and that my contributions are welcome.

 * Is anyone else working on something like this? I've searched the mailing
   list but could not find any.
 * The repository I found mentions a licensing issue. I've searched the
   mailing list and found that the author of the original ARM codegen does not
   want to re-license it. Personally, I don't mind leaving the license as is.
   There is no way I will be able to write the thumb code gen from scratch,
   so my code will be based on the ARM one and subject to the same issue. Do I
   need to worry about this? It would really suck if my code gets dropped due
   to relicensing in the future.
 * Generally speaking, information to new contributors seems to be a bit
   scarce. I'm guessing that I'll have to make a new target to the build system
   at the very least, and new files for the thumb code gen. Is there anything I
   should read up on before I attemt to do this?
 * Code style: It is of course best to follow the existing code, but if I
   contribute a new file, am I allowed to use my own style for it? I've read
   the CodingStyle text file but it does not say much on this.
 * If I do substantial modifications to a function, may I reformat it? I see
   that some functions have a mix of spaces and tab indentation, I'd love to
   make this consistent.
 * C99: I could not find anything about mixed code and declarations. Am I
   allowed to use this? I personally find this to be a really important
   feature, since it improves readability by a lot. It also helps avoiding
   uninitialized variables (RAII and all).

I will probably have more questions for later, but these are the most important
ones. If there are no major roadblocks I may even have a diff ready some time
in the next few months! Also if there is something special I should know
regarding adding a new codegen I'd love to know.

Regards,
Erlend Sveen

reply via email to

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