[fpc-devel] inline and asm code

Peter Vreman peter at freepascal.org
Sun Aug 14 12:29:32 CEST 2005


At 10:46 3-8-2005, you wrote:
> > I would suggest an "experimental" solution {$inline unsafe ?} which 
> does the
> > inline without checks, and maybe gives a warning at compiletime: Warning:
> > inlined func/proc might be unsafe.
>
>The used registers still have to be known. For pascal code this is info that
>is gained during the compilation. For asm this is afaik not kept.
>
>However if sb would work on this and submit a patch (scanning assembler blocks
>to build a register use), it would probably help.
>
> > Could save some code and some exection time.
> >
> > I do not understand the argument with e.g. EBP usage. I would say this is
> > dangerous in not inlined code also, isn't it?
>
>procedure x(a:integer);assembler; stdcall;
>
>asm
>   movl 8(%ebp),%eax
>end;
>
>Will load parameter in eax. However when inlined it will fail.

Also a lot of assembler procedures (coming from delphi) expect the 
parameters in specific registers. The compiler then firsts needs to load 
the values in these registers like the register calling convention 
describes. The result is in a lot of cases not what was expected and it 
makes the compiler a lot more complex regarding inlining. So for now the 
inlining of assembler code is disabled to keep the code in the compiler 
simple. Also note that this behaviour is compatible with delphi 2005.


Peter





More information about the fpc-devel mailing list