mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 08:49:25 +02:00
* improved fillchar for small amounts of data
git-svn-id: trunk@17644 -
This commit is contained in:
parent
7173b9dfed
commit
ceb739fbf5
@ -204,32 +204,27 @@ end;
|
|||||||
|
|
||||||
{$ifndef FPC_SYSTEM_HAS_FILLCHAR}
|
{$ifndef FPC_SYSTEM_HAS_FILLCHAR}
|
||||||
{$define FPC_SYSTEM_HAS_FILLCHAR}
|
{$define FPC_SYSTEM_HAS_FILLCHAR}
|
||||||
Procedure FillChar(var x;count:SizeInt;value:byte);assembler;
|
Procedure FillChar(var x;count:SizeInt;value:byte);assembler; nostackframe;
|
||||||
{$ifndef regcall}
|
|
||||||
var
|
|
||||||
saveedi: longint;
|
|
||||||
{$endif}
|
|
||||||
asm
|
asm
|
||||||
{A push is prefered over a local variable because a local
|
cmpl $22,%edx { empirically determined value on a Core 2 Duo Conroe }
|
||||||
variable causes the compiler to generate a stackframe.}
|
jg .LFillFull
|
||||||
|
orl %edx,%edx
|
||||||
|
jle .LFillZero
|
||||||
|
|
||||||
|
.LFillLoop:
|
||||||
|
movb %cl,(%eax)
|
||||||
|
incl %eax
|
||||||
|
decl %edx
|
||||||
|
jne .LFillLoop
|
||||||
|
.LFillZero:
|
||||||
|
ret
|
||||||
|
|
||||||
|
.LFillFull:
|
||||||
cld
|
cld
|
||||||
{$ifdef REGCALL}
|
|
||||||
push %edi
|
push %edi
|
||||||
movl %eax,%edi
|
movl %eax,%edi
|
||||||
movzbl %cl,%eax
|
movzbl %cl,%eax
|
||||||
movl %edx,%ecx
|
movl %edx,%ecx
|
||||||
{$else}
|
|
||||||
movl %edi, saveedi
|
|
||||||
movl x,%edi
|
|
||||||
movl count,%ecx
|
|
||||||
movzbl value,%eax
|
|
||||||
movl %ecx,%edx
|
|
||||||
{$endif}
|
|
||||||
{ check for zero or negative count }
|
|
||||||
or %ecx,%ecx
|
|
||||||
jle .LFillEnd
|
|
||||||
cmpl $7,%ecx
|
|
||||||
jl .LFill1
|
|
||||||
imul $0x01010101,%eax { Expand al into a 4 subbytes of eax}
|
imul $0x01010101,%eax { Expand al into a 4 subbytes of eax}
|
||||||
shrl $2,%ecx
|
shrl $2,%ecx
|
||||||
andl $3,%edx
|
andl $3,%edx
|
||||||
@ -240,11 +235,7 @@ asm
|
|||||||
rep
|
rep
|
||||||
stosb
|
stosb
|
||||||
.LFillEnd:
|
.LFillEnd:
|
||||||
{$ifdef REGCALL}
|
|
||||||
pop %edi
|
pop %edi
|
||||||
{$else}
|
|
||||||
movl saveedi,%edi
|
|
||||||
{$endif}
|
|
||||||
end;
|
end;
|
||||||
{$endif FPC_SYSTEM_HAS_FILLCHAR}
|
{$endif FPC_SYSTEM_HAS_FILLCHAR}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user