2016-07-25 03:39 AM
Code speed results didn't look that good for SDCC at the time of the SDCC 3.6.0 release about a month ago (http://colecovision.eu/stm8/compilers.shtml). But SDCC has made huge progress since, and now achieves higher Dhrystone and Coremark scores than the other compilers. Here are the results for the current development version (SDCC 3.6.2 #9667):
Philipp P.S.: It's really time to look for some paid work for myself now. This will slow SDCC stm8 progress a bit, since I am the main developer of the stm8 backend in SDCC. However, development will continue both by me and the other SDCC developers. Note: this post was migrated and contained many threaded conversations, some content may be missing.2017-10-17 01:15 PM
Could you post a compileable sample of C source that shows the issues? I'll have a look at it and see what can be done before SDCC 3.7.0.
Philipp
2017-10-17 11:23 PM
Ok. In my opinion, the main problem of the SDCC for STM8 is too wasteful use of the stack. I wanted to show you an example, but in the comment field the text is heavily distorted, and there is no possibility of transferring the attachment. In is snippet:
0001F9 460 00104$:
461 ; /home/master/Desktop/kernel.c: 134: base.counter++;
0001F9 1E 07 [ 2] 462 ldw x, (0x07, sp)
0001FB 5C [ 1] 463 incw x
0001FC 16 03 [ 2] 464 ldw y, (0x03, sp)
0001FE 90 FF [ 2] 465 ldw (y), x
466 ; /home/master/Desktop/kernel.c: 135: }
000200 5B 0A [ 2] 467 addw sp, &sharp10
000202 81 [ 4] 468 ret
; sdcc -c -mstm8 --peep-file /home/master/peeph.def -max-allocs-per-node --opt-code-size %f
; SDCC : mcs51/z80/z180/r2k/r3ka/gbz80/tlcs90/ds390/pic16/pic14/TININative/ds400/hc08/s08/stm8 3.6.9 &sharp10062 (Linux)
Variable base it is simple static structure, but SDCC for some reason, it generates indirect addressing, storing pointer variables on the stack. Saving RAM is very important, for micro-controllers. I would like to have a stack saving mode. The second problem concerns prologues and epilogues of system functions declared as __interrupt and __critical. It would be desirable to have, what or possibility, independently to describe their code and insert it before automatic reservation of a stack. For example, I need use 'push cc\n push &sharpmylevel\n ... pop cc\n ret\n' instead 'sim\n ... rim\n ret\n'. Also, in the inline assembler, the meta-constants indicating offsets of the variables in the stack would be very useful. I hope that soon, this compiler will become good enough for real use.
Vyacheslav
2017-10-18 12:54 AM
If you want to use custom function prologue/epilogue (as in your example of the interrupt handler). You can use __naked with __asm:
volatile unsigned char i;
void f(void) __interrupt(2) __naked { __asm push cc __endasm; i++ __asm pop cc ret __endasm; }Philipp
P.S.: The edit window has an option to set formatting of a paragraph to 'preformatted'. I hope that is sufficient to keep the code above readable.
2017-11-08 01:41 AM
SDCC is a very attractive offer, an open source compiler. However, very would like to have a better code generation for STM8. I want to give a tiny example. The attachment contains files of the simplest real algorithm with pointers and the results of its compilation by the compilers of the SDCC and COSMIC. We can observe a significant difference.
________________ Attachments : sdcc-sample.lst.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyIB&d=%2Fa%2F0X0000000b5x%2FAsn7gSRzf2R5KMrLd7E_8eRO0K87BLiEaLqBK3uZTdA&asPdf=falsecosmic-sample.ls.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyF2&d=%2Fa%2F0X0000000b5v%2FhUNPRTCuGg0pEzlcj51IMDcbMObvk51_0.BDfQ8UxTY&asPdf=falsesample.c.zip : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006HyJh&d=%2Fa%2F0X0000000b5w%2FBoXohfy0IWPrLCu1Qu94PqcW0Rd4_Pu5T5YpcswsYcc&asPdf=false2017-11-08 04:16 AM
Thanks. In the current development versions, with high optimization setting SDCC genreates slightly better code (making betteruse of register y), but still far wose than Cosmic. Generating code for multiple nearby accesses to different members of one struct definitely is still a weak point of SDCC. I've opened a feature request (
https://sourceforge.net/p/sdcc/feature-requests/545/
) to ensure that this issue remains visible on the SDCC side. This is definitely something that should be looked into after the 3.7.0 release.Philipp