Browse Source

+ FPC_SHORTSTR_CONCAT_LEN (temporary, for -dnewoptimizations)

Jonas Maebe 25 years ago
parent
commit
ff9782d70c
1 changed files with 48 additions and 5 deletions
  1. 48 5
      rtl/i386/i386.inc

+ 48 - 5
rtl/i386/i386.inc

@@ -763,18 +763,57 @@ end;
 
 
 
 
 {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_CONCAT}
 {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_CONCAT}
-procedure int_strconcat(s1,s2:pointer);[public,alias:'FPC_SHORTSTR_CONCAT'];
+procedure int_strconcat(s1,s2:pointer);
+  [public,alias:'FPC_SHORTSTR_CONCAT'];
 begin
 begin
   asm
   asm
-        xorl    %ecx,%ecx
         movl    s2,%edi
         movl    s2,%edi
         movl    s1,%esi
         movl    s1,%esi
         movl    %edi,%ebx
         movl    %edi,%ebx
-        movb    (%edi),%cl
+        movzbl  (%edi),%ecx
+        xor     %eax,%eax
         lea     1(%edi,%ecx),%edi
         lea     1(%edi,%ecx),%edi
         negl    %ecx
         negl    %ecx
+        addl    $0x0ff,%ecx
+        lodsb
+        cmpl    %ecx,%eax
+        jbe     .LStrConcat1
+        movl    %ecx,%eax
+.LStrConcat1:
+        addb    %al,(%ebx)
+        cmpl    $7,%eax
+        jl      .LStrConcat2
+        movl    %edi,%ecx       { Align on 32bits }
+        negl    %ecx
+        andl    $3,%ecx
+        subl    %ecx,%eax
+        rep
+        movsb
+        movl    %eax,%ecx
+        andl    $3,%eax
+        shrl    $2,%ecx
+        rep
+        movsl
+.LStrConcat2:
+        movl    %eax,%ecx
+        rep
+        movsb
+  end ['EBX','ECX','EAX','ESI','EDI'];
+end;
+
+{$ifdef newoptimizations}
+procedure int_strconcatlen(s1,s2:pointer;maxlen: longint);
+  [public,alias:'FPC_SHORTSTR_CONCAT_LEN'];
+begin
+  asm
+        movl    s2,%edi
+        movl    s1,%esi
+        movl    %edi,%ebx
+        movzbl  (%edi),%ecx
         xor     %eax,%eax
         xor     %eax,%eax
-        addl    $0xff,%ecx
+        lea     1(%edi,%ecx),%edi
+        negl    %ecx
+        addl    maxlen,%ecx
         lodsb
         lodsb
         cmpl    %ecx,%eax
         cmpl    %ecx,%eax
         jbe     .LStrConcat1
         jbe     .LStrConcat1
@@ -800,6 +839,7 @@ begin
         movsb
         movsb
   end ['EBX','ECX','EAX','ESI','EDI'];
   end ['EBX','ECX','EAX','ESI','EDI'];
 end;
 end;
+{$endif newoptimizations}
 
 
 
 
 {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_COMPARE}
 {$define FPC_SYSTEM_HAS_FPC_SHORTSTR_COMPARE}
@@ -1156,7 +1196,10 @@ end;
 
 
 {
 {
   $Log$
   $Log$
-  Revision 1.71  2000-04-10 09:47:15  jonas
+  Revision 1.72  2000-04-23 09:26:51  jonas
+    + FPC_SHORTSTR_CONCAT_LEN (temporary, for -dnewoptimizations)
+
+  Revision 1.71  2000/04/10 09:47:15  jonas
     + added destroyed registers list for move procedure (it doesn't destroy
     + added destroyed registers list for move procedure (it doesn't destroy
       edx)
       edx)