On 1/27/24 20:41, Sophie 'Tyalie' Friedrich via Gcc wrote:
Hello dear people,
I want to try building a GCC compiler backend for the STM8
micro-controller target in order to make this wonderful architecture
more accessible.
But as I'm fairly new in this area of building compiler backends for
GCC, I would need a bit of guidance / read material to get started. Do
you have recommendations for anything? And is there interest in such work?
There is a GCC internals manual which I would strongly recommend you
read and keep handy. It describes most of the basic concepts necessary
to write a functioning machine description.
Second I would strongly recommend you start with an existing port for a
chip that has similar characteristics. If you make a good choice on
ports to copy, this can dramatically reduce your development time. GCC
supports over 30 distinct families of processors. If you're lucky one
will map reasonably closely to the STM8. Some processor families have
had their ports removed due to lack of maintenance and lack of
processors deployed in the wild. Point being there may be older ports
that match STM8 better than what's in the tree now. I just don't know.
You're going to need an assembler, linker and libraries. Those are not
part of the compiler proper. They are usually co-developed as part of
doing a new port. You'll probably want a debugger too. The assembler,
linker, binary utilities and debugger are the gdb-binutils project. A C
library can be found in the newlib-cygwin project.
If there is an existing compiler and you need/want to be compatible with
calling conventions, then it's obviously advisable to get a copy of any
ABI documentation that may be available. Otherwise you'll have to get a
copy of that other compiler and reverse-engineer the ABI.
GCC includes a significant testsuite. For port bring-up, the c-torture
tests are usually the most interesting, especially the compile and
execution tests.
This will be a non-trivial project, almost certainly measured in months
for an experienced GCC developer. Good luck.
jeff