Оберон-клуб «ВЄДАsoft»

Твердыня модульных языков
Текущее время: 16 июн 2025, 14:40

Часовой пояс: UTC + 2 часа




Начать новую тему Ответить на тему  [ Сообщений: 9 ] 
Автор Сообщение
СообщениеДобавлено: 21 авг 2012, 13:47 
Не в сети
Аватара пользователя

Сообщения: 1019
Откуда: Днепропетровская обл.
Начал набрасывать письмо Филиппу Клаусу Краузе (главному мэйнтейнеру кодогенератора 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.

    First, the manually division the logical integrity of the module to separate functions (only because that's more convenient for librarian) - is extra work.

    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)
{
__asm
...
CALL POINT$
__endasm;
}//PAINT
 
BOOLEAN Best40_POINT (SHORTINT x, SHORTINT y)
{
__asm
#ifdef __SDCC
LD IX,#0xFFFE
ADD IX,SP
#else
POP AF // восст. стек для правильного выхода по RET
#endif
LD E,4(IX) // координата X
LD D,5(IX) // координата Y
CALL POINT$ // вызов POINT
LD L,A // результат: 0 (FALSE) или не 0 (TRUE)
RET
POINT$: // если точка выключена, то ZF=1 (Z), иначе ZF=0 (NZ)
...
__endasm;
}//POINT

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.

    Third, absolutely not all functions are placed in libraries. But all functions from source code will be added to target binary completely.

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 ...)
Вложение:
Комментарий к файлу: Additional example to the letter
SmartLink.zip [61.71 КБ]
Скачиваний: 998


Вернуться к началу
 Профиль  
Ответить с цитатой  
СообщениеДобавлено: 21 авг 2012, 14:41 
Не в сети
Аватара пользователя

Сообщения: 1019
Откуда: Днепропетровская обл.
2. I wanted to write you that this functions 'enter code'
Код: "EMPTY"
	push	ix
ld ix,#0
add ix,sp
...
pop ix
ret

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
add hl, sp
...
ret

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.


Вернуться к началу
 Профиль  
Ответить с цитатой  
СообщениеДобавлено: 21 авг 2012, 15:33 
Не в сети
Аватара пользователя

Сообщения: 1019
Откуда: Днепропетровская обл.
3. Constants. I know, it is a feature of C++, but useable in SDCC.
Код: "EMPTY"
const constant = 123;
 
void Best40Test_Main (void)
{
Best40_attrib = constant;
 
 
_Best40Test_Main_start::
_Best40Test_Main:
;Best40Test.c:17: Best40_attrib = constant;
ld de, #_Best40_attrib
ld hl, #_constant
ld bc, #2
ldir
...
_Best40Test_Main_end::
_constant:
.dw #0x007B

If change this code to use #define

Код: "EMPTY"
#define constant 123
 
void Best40Test_Main (void)
{
Best40_attrib = constant;
 
 
_Best40Test_Main_start::
_Best40Test_Main:
;Best40Test.c:17: Best40_attrib = constant;
ld iy,#_Best40_attrib
ld 0 (iy),#0x7B
ld 1 (iy),#0x00

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.


Вернуться к началу
 Профиль  
Ответить с цитатой  
СообщениеДобавлено: 21 авг 2012, 17:21 
Не в сети
Аватара пользователя

Сообщения: 1019
Откуда: Днепропетровская обл.
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!


Вернуться к началу
 Профиль  
Ответить с цитатой  
СообщениеДобавлено: 21 авг 2012, 17:46 
Не в сети
Аватара пользователя

Сообщения: 1019
Откуда: Днепропетровская обл.
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.


Вернуться к началу
 Профиль  
Ответить с цитатой  
СообщениеДобавлено: 07 сен 2012, 14:48 
Не в сети
Аватара пользователя

Сообщения: 1019
Откуда: Днепропетровская обл.
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
New allocator 6,5 min 32895 bytes
Old allocator 15 sec 32674 bytes
With this I would like to propose set old allocator by default. And optional new allocator as an experimental solution.

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?


Вернуться к началу
 Профиль  
Ответить с цитатой  
 Заголовок сообщения: Ответ #1 Филиппа Краузе
СообщениеДобавлено: 08 сен 2012, 13:17 
Не в сети
Аватара пользователя

Сообщения: 1019
Откуда: Днепропетровская обл.
Цитата:
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


Вернуться к началу
 Профиль  
Ответить с цитатой  
СообщениеДобавлено: 13 сен 2013, 19:58 
Не в сети

Сообщения: 4
Приветствую, Олег!
Предлагаю ввести команду препроцессора, выравнивающую в памяти следующий за ней объект на границу слова.
Дело в том, что SDCC начал активно использоваться для платформы ZX-Evoluton/TS-Labs-Config, где организован ПДП, который может работать только с ЧЁТными адресами.
Думаю, это улучшение не слишком обременительно для разработчиков, поскольку SDAS имеет соответствующие директивы.


Вернуться к началу
 Профиль  
Ответить с цитатой  
СообщениеДобавлено: 13 сен 2013, 20:41 
Не в сети
Аватара пользователя

Сообщения: 1019
Откуда: Днепропетровская обл.
Не возражаю! :) Что ожидается от меня? Требуется, чтобы я предложил это дело и набросал письмо на инглише в саппорт о feature request, или может сами? Т.к. я не числюсь среди разработчиков SDCC, а у Вас лучше получится изложить обоснование востребованности данной фичи.

http://sourceforge.net/p/sdcc/feature-requests/


Вернуться к началу
 Профиль  
Ответить с цитатой  
Показать сообщения за:  Поле сортировки  
Начать новую тему Ответить на тему  [ Сообщений: 9 ] 

Часовой пояс: UTC + 2 часа


Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 3


Вы не можете начинать темы
Вы не можете отвечать на сообщения
Вы не можете редактировать свои сообщения
Вы не можете удалять свои сообщения
Вы не можете добавлять вложения

Найти:
Перейти:  
Создано на основе phpBB® Forum Software © phpBB Group
© VEDAsoft Oberon Club