Оберон-клуб «ВЄДАsoft» https://zx.oberon.org/forum/ |
|
Кодогенерация SDCC: предложения по улучшению компилятора https://zx.oberon.org/forum/viewtopic.php?f=10&t=32 |
Страница 1 из 1 |
Автор: | Zorko [ 21 авг 2012, 13:47 ] |
Заголовок сообщения: | Кодогенерация SDCC: предложения по улучшению компилятора |
Начал набрасывать письмо Филиппу Клаусу Краузе (главному мэйнтейнеру кодогенератора Z80 для SDCC). Цитата: All of this propositions are actual for SDCC 3.2.0 #8008 (Jul 6 2012). 1. Smart linking. It's very useable feature for restricted RAM size. And it is very requested by ZX Spectrum Russian Community on zx.pk.ru forum. Now SDCC adds to output file ALL functions from ALL included sources (see function Best40Test_DoNotUsed in file Best40Test.c) and from ALL specified libraries (all functions from Libs/z80/Best40.lib are added to result file Best40Test.bin, though really used only 4). The same I can say about unused constants and variables. Maybe there is a key of compiler or sdcclib to turn on smart linker? P.S. Recently I've read about sdar, sdranlib and sdnm tools, but I seem, they do not solve main problems with absence of smart linker. I'll bring only some considerations about the problems, which wanted to see solved.
Secondly, I have encountered a situation where the normal divide fails. Example: in the library is an assembly function, inside which there is a transition to JP from other functions. Код: "EMPTY" void Best40_PAINT (SHORTINT x, SHORTINT y) You find it ugly? This all else main way of the increase to efficiency! But now I cannot see a simple way to divide this functions to different sources to generate separated .rel files.
Question. Is it possible to automatically convert ready .lib, created from one source, so that it was similar to the created from several .rel pieces, as it is divided by functions? (Palliative course, but we have to start somewhere ...) Вложение:
|
Автор: | Zorko [ 21 авг 2012, 14:41 ] |
Заголовок сообщения: | Кодогенерация SDCC: предложения по улучшению компилятора |
2. I wanted to write you that this functions 'enter code' Код: "EMPTY" push ix in such full mode is useful only for recursive functions, and for non-recursive there is reason to remove push ix/pop ix. but I've seen that this is already made. SDCC #8008 gives: Код: "EMPTY" ld hl, #2+0 Very good work, Philipp! I would like to say to you about 'mixed' calling convention that is used, for example, in in-line procedures of BlackBox Component Builder (from OMinc). Probably pure fastcall convention is good only for functions in assembler. In this 'mixed' convention one parameter is always sent in a register (for x86 it is EAX for integer parameters), other parameters pushed to stack. For Z80 one parameter (better for non-recursive functions only) will be always sent in register A (for 1-byte parameter) or pair HL (for 2-byte). Maybe you'll like this 'mixed' alternative calling convention as more easy to be implemented, than fastcall. |
Автор: | Zorko [ 21 авг 2012, 15:33 ] |
Заголовок сообщения: | Кодогенерация SDCC: предложения по улучшению компилятора |
3. Constants. I know, it is a feature of C++, but useable in SDCC. Код: "EMPTY" const constant = 123; If change this code to use #define Код: "EMPTY" #define constant 123 As we see, instruction "const" provides not a simple replacement of #define, it's other method, and with it value of a constant not is simply substituted instead of identifier. It's placed in memory like a variable. I can't think the good reason why a constant need to occupy memory like variable, especially if it is not a constant array. |
Автор: | Zorko [ 21 авг 2012, 17:21 ] |
Заголовок сообщения: | Кодогенерация SDCC: предложения по улучшению компилятора |
4. Feature cannot assign values to aggregates still not implemented. I remind you that it is necessary to be able to develop a software for Z80 in language Oberon/Oberon-2 using Oberon-2-to-C Translator Ofront. Now Ofront is released under BSD license! |
Автор: | Zorko [ 21 авг 2012, 17:46 ] |
Заголовок сообщения: | Кодогенерация SDCC: предложения по улучшению компилятора |
5. Undocumented instructions in Z80 inline assembler of SDCC. This feature also requested by Russian ZX Spectrum Community. Personally I need instructions to work with IX/IY half-registers and SLL (Shift Left Logical — coded from CB 30 to CB 37). There is enough information about Z80 undocumented instructions in Internet, I found something at World of Spectrum website. |
Автор: | Zorko [ 07 сен 2012, 14:48 ] |
Заголовок сообщения: | Кодогенерация SDCC: предложения по улучшению компилятора |
The option key --oldralloc is still undocumented in sdccman.pdf New register allocator in SDCC 3.2.0 #8008 not always gives improvement of code quality. In my case (--opt-code-size switched on): Код: "EMPTY" Durak.c (2.3k lines) compile-time target binary size But I remember exactly that the new allocator wins about 5 minutes and 200 bytes than the old. There was in more old builds of SDCC. But maybe the allocator is now under active development? |
Автор: | Zorko [ 08 сен 2012, 13:17 ] |
Заголовок сообщения: | Ответ #1 Филиппа Краузе |
Цитата: On 08.09.2012 00:34, Oleg N. Cher wrote:
>> Dear Philipp, >> >> Now it is not a bug report. I remember my promise to share ideas to >> further improve of SDCC that gained experience in the process of >> using SDCC. >> >> SDCC - the best C compiler for Z80 of the World - to make it better. >> Yes, I love your work! It's great. >> >> I do not expect a quick response from you today or tomorrow. I like >> the steps you have taken to improve the code generation. So take this >> as the long term additional development notices. >> >> I've started this notices on my forum (posts for you is in English): >> >> viewtopic.php?f=10&t=32 I'll start with this one, since it is the shoter list: 1) The "smart" linking: The current linker behaviour is this: Link all .rel files specified. The take from the libraries all the modules needed to resolve dependencies. Example: To the linker you specify rel files A and B and libraries X and Y. Inside library X there are modules X1 and X2, inside Y there are modules Y1 and Y2. Assume that A contains function f, B contains function g (which calls h), X1 contains h (which calls i), and Y2 contains i. In that case A, B, X1 and Y2 will be linked into the result. 2) Passing parameters in registers is indeed something that could improve code in some cases, and I intend to take a closer look at it some time, but I don't know when. 3) Optimizing constants: Have a look at RFE #1483474. There's also a bit of discussion on when memory is needed (i.e. normal const, which could be used in another source file vs. static const, which means the const is only visible in the local source file). So this is on the to-do list (but so are many other things). 4) Assigning aggregates and unions: Leland has been working on this at some time during summer, but then ran out of time. I hope he picks up the work later this year. 5) I agree and have just created RFE #3565707, so this will not be forgotten. 6) In terms of register allcoation, some restirctions were dropped. This results in a) better code than ever before when using a high --max-allocs-per-node value b) somewhat worse code and slower compilation when using a small --max-allocs-per-node value (such as the default). So it essentially provides the option of even better optimization for those who are willing to increase compile times a bit, but results in worse behaviour in other cases. Also note that the tree-decomposition heuristic we use is not perfect, so the planned implementation of a better heuristic should help with compilation speed and code size a bit. See also bug report #3418072. Philipp |
Автор: | Sergey [ 13 сен 2013, 19:58 ] |
Заголовок сообщения: | Re: Кодогенерация SDCC: предложения по улучшению компилятора |
Приветствую, Олег! Предлагаю ввести команду препроцессора, выравнивающую в памяти следующий за ней объект на границу слова. Дело в том, что SDCC начал активно использоваться для платформы ZX-Evoluton/TS-Labs-Config, где организован ПДП, который может работать только с ЧЁТными адресами. Думаю, это улучшение не слишком обременительно для разработчиков, поскольку SDAS имеет соответствующие директивы. |
Автор: | Zorko [ 13 сен 2013, 20:41 ] |
Заголовок сообщения: | Re: Кодогенерация SDCC: предложения по улучшению компилятора |
Не возражаю! ![]() http://sourceforge.net/p/sdcc/feature-requests/ |
Страница 1 из 1 | Часовой пояс: UTC + 2 часа |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |