[fpc-pascal]Default calling convention
mm10 at ellipsa.net
Sun Jul 4 18:33:27 CEST 2004
Florian Klaempfl a écrit :
> Marcel Martin wrote:
> > Florian Klaempfl a écrit :
> >>Thomas Schatzl wrote:
> >>>In this case
> >>> procedure nx_fill(P: PLongword; Count: Longint; Value: Longword);
> >>> assembler;
> >>> asm
> >>> pushl %edi
> >>> movl P,%edi // edi <- P
> >>> movl Value,%eax // eax <- Value
> >>> movl Count,%ecx // ecx <- Count
> >>> rep
> >>> stosl
> >>> popl %edi
> >>> end;
> >>>works both as embedded and non-embedded assembler procedure because the
> >>>order of assignments is ok in both cases.
> >>>Btw, there's already a method in the system unit which does the same
> >>>thing as your routine: filldword()...
> >>... and with better instruction selection ;)
> > 1) This little routine was sent to point out a problem.
> > 2) Better than what? Where do you see an "instruction selection"
> Push instead of mov. mov is faster on modern machines because it causes
> less instruction dependencies.
1) That's what you call an 'instruction selection'? Such an answer
is what I call bad faith. You were talking about checking the
possible negativity of 'Count'.
2) Not with Delphi 5.01. With such a procedure, Delphi 5.01 doesn't
generate the instructions "push ebp, etc. ". By using a local, you
constraint it to do that. In short, if you want to use 2 mov's
instead of push/pop by creating a local, you will have 2 mov's AND
a push/pop. Now I agree, this is no more true with FPC 1.9.4 since
it seems to generate the sequence "push ebp ..." as soon as there
is a parameter (even if there is no local and if this parameter is
sent through a register). But you know what? My library was written
with (and for) Delphi 5.01 and, I am sorry, but adapting 30,000
lines of code for a compiler I don't know well cannot be done in
two weeks. At least, _I_ cannot.
3) Next time I will have a problem with FPC, I will think twice
before talking about it on this list.
More information about the fpc-pascal