Hi, It's been a while now since I've been working on and off various projects for the last few months, but I finally think my TCC additions are ready for a second pair of eyes (and more). I hope you have some time to look at it before I try getting it into the "real" repo.
Initially I wrote that I would not implement any floating point stuff, but after looking over the instruction set I found that it was way easier than I expected. I also got TCC to run on the microcontroller itself, which also took a fair bit of time. I think this is quite cool, lots of stories about people running Linux on their micros but not as many about compilers as far as I can tell! In fact I've found no articles at all after some minutes of searching. People have done interpreters but I could not find anything for C. Since I don't want to break the main repo I've put up a temporary one before I try committing anything to the mob branch. I hoped to make it in one commit but ended up with multiple, so here is an explanation of them and links: https://git.erlendjs.no/erlendjs/tinycc/commit/9e5ef0bbab28379b1ecbd7c167892e3af5f14a8d - This adds the most of the code, please see the commit message for an explanation. The most important bits are of course changes to existing files. https://git.erlendjs.no/erlendjs/tinycc/commit/8698aa391929c5c5f1ae529bda4f98f1d382545f - Once I started compiling "real" code I found some bugs, this fixes some. https://git.erlendjs.no/erlendjs/tinycc/commit/3f8c5163b4d1fe2582d916a231c5e16bbbebf154 - Adds float support back in and a new test, please see the commit message. It also cleans up a bunch of stuff, fixes some bugs and adds another test to trigger more branches. At this point there are some things left that I have not figured out yet. I hope maybe someone can help a bit with these, either by code or feedback on how to do things: * Interwork between ARM state and Thumb state. Probably required to get it working on a Raspberry Pi. But not required for MCU use. * The linker in TCC does not seem to work, so I've used the GNU one. * Adding a flag similar to "-mcpu", "-march", "-vfp?" etc. to keep control of which FPU ISA it uses. I expect that the current code will cause some troble linking with elf files that specify e.g. no FPU despite not actually having generated any FPU instructions. * Using floats requires a Cortex-M7 with double precision, since there are no fallbacks to the library routines. Could be fixed if the previous point is implemented. * There is a branch in the store function that I could not figure out how to test, so it remains unimplemented. It is for vmov i think. * log10 gets the sign wrong and I have no idea why. So far I've only tested using a Cortex-M7. M3 and M4 should work for integer code but I have not gotten around to testing that yet. There are also plenty of files that I figured does not belong in the TCC repository. It mostly contains build scripts, test harness code, various notes and so on. For an overview of how testing is going, check "tcc-hacking.ods" here: https://git.erlendjs.no/erlends-os/usr/compiler/tree/master/tinycc Anyways, I think my code is ready now. It successfully compiles all my projects that I have tried compiling, and they run properly although much slower. Regards, Erlend Sveen
_______________________________________________ Tinycc-devel mailing list Tinycc-devel@nongnu.org https://lists.nongnu.org/mailman/listinfo/tinycc-devel