Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2007-11

Tiny fix for codegenerator

2 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Sergei Gorelkin

Hello,

I was wondering why Pascal statements like
"Inc(SomePointer, sizeof(WideChar))" are compiled into two assembler commands (mov ecx,2; add [location],ecx).
I found out that tcginlinenode.second_incdec checks second argument to be an ordinal constant. In my case, however, the second argument is being converted into pointer constant somewhere earlier, therefore tcginlinenode.second_incdec forces it into register. I added a check (see the patch attached) and now it is compiled into "add [location],2", thus saving the register for other usage.

Regards,
Sergei

Reply by email

Jonas Maebe
to Sergei Gorelkin
Sergei Gorelkin wrote 9 lines
I was wondering why Pascal statements like "Inc(SomePointer, sizeof(WideChar))" are compiled into two assembler commands (mov ecx,2; add [location],ecx). I found out that tcginlinenode.second_incdec checks second argument to be an ordinal constant. In my case, however, the second argument is being converted into pointer constant somewhere earlier, therefore tcginlinenode.second_incdec forces it into register. I added a check (see the patch attached) and now it is compiled into "add [location],2", thus saving the register for other usage.

It would probably be better to just check whether
location.loc=LOC_CONST and then use location.value (this code presumable predates the existence of LOC_CONST). Then you don't have to care about the node type.

Jonas

Reply by email