mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-30 18:20:27 +02:00
- powerpc and powerpc64: cleaned out code corresponding to FPC_STRTOSHORTSTRINGPROC not defined (obsolete and removed from other targets long ago). Also merged strpas.inc files into powerpc*.inc, because by now they are included only once and therefore don't need to be separate files.
git-svn-id: trunk@27832 -
This commit is contained in:
parent
a94187c79b
commit
e5f6f9c3a1
@ -992,14 +992,49 @@ end;
|
|||||||
|
|
||||||
{$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
|
{$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
|
||||||
{$define FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
|
{$define FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
|
||||||
{$ifndef FPC_STRTOSHORTSTRINGPROC}
|
|
||||||
function fpc_pchar_to_shortstr(p:pchar):shortstring;[public,alias:'FPC_PCHAR_TO_SHORTSTR']; compilerproc; assembler; nostackframe;
|
|
||||||
{$else FPC_STRTOSHORTSTRINGPROC}
|
|
||||||
procedure fpc_pchar_to_shortstr(out res : shortstring;p:pchar);assembler;[public,alias:'FPC_PCHAR_TO_SHORTSTR']; compilerproc; nostackframe;
|
procedure fpc_pchar_to_shortstr(out res : shortstring;p:pchar);assembler;[public,alias:'FPC_PCHAR_TO_SHORTSTR']; compilerproc; nostackframe;
|
||||||
{$define FPC_STRPASPROC}
|
{
|
||||||
{$endif FPC_STRTOSHORTSTRINGPROC}
|
r3: result address
|
||||||
{$include strpas.inc}
|
r4: high(result)
|
||||||
{$undef FPC_STRPASPROC}
|
r5: p (source)
|
||||||
|
}
|
||||||
|
asm
|
||||||
|
{ nil? }
|
||||||
|
mr r8, p
|
||||||
|
cmplwi p, 0
|
||||||
|
{ load the begin of the string in the data cache }
|
||||||
|
dcbt 0, p
|
||||||
|
{ maxlength }
|
||||||
|
mr r10,r4
|
||||||
|
mtctr r10
|
||||||
|
{ at LStrPasDone, we set the length of the result to 255 - r10 - r4 }
|
||||||
|
{ = 255 - 255 - 0 if the soure = nil -> perfect :) }
|
||||||
|
beq .LStrPasDone
|
||||||
|
{ save address for at the end and use r7 in loop }
|
||||||
|
mr r7,r3
|
||||||
|
{ no "subi r7,r7,1" because the first byte = length byte }
|
||||||
|
subi r8,r8,1
|
||||||
|
.LStrPasLoop:
|
||||||
|
lbzu r10,1(r8)
|
||||||
|
cmplwi cr0,r10,0
|
||||||
|
stbu r10,1(r7)
|
||||||
|
bdnzf cr0*4+eq, .LStrPasLoop
|
||||||
|
|
||||||
|
{ if we stopped because of a terminating #0, decrease the length by 1 }
|
||||||
|
cntlzw r4,r10
|
||||||
|
{ get remaining count for length }
|
||||||
|
mfctr r10
|
||||||
|
{ if r10 was zero (-> stopped because of zero byte), then r4 will be 32 }
|
||||||
|
{ (32 leading zero bits) -> shr 5 = 1, otherwise this will be zero }
|
||||||
|
srwi r4,r4,5
|
||||||
|
.LStrPasDone:
|
||||||
|
subfic r10,r10,255
|
||||||
|
sub r10,r10,r4
|
||||||
|
|
||||||
|
{ store length }
|
||||||
|
stb r10,0(r3)
|
||||||
|
end;
|
||||||
{$endif FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
|
{$endif FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
|
||||||
|
|
||||||
|
|
||||||
|
@ -492,16 +492,49 @@ end;
|
|||||||
|
|
||||||
{$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
|
{$ifndef FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
|
||||||
{$define FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
|
{$define FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
|
||||||
{$ifndef FPC_STRTOSHORTSTRINGPROC}
|
|
||||||
function fpc_pchar_to_shortstr(p:pchar):shortstring;[public,alias:'FPC_PCHAR_TO_SHORTSTR']; compilerproc;
|
|
||||||
assembler; nostackframe;
|
|
||||||
{$else FPC_STRTOSHORTSTRINGPROC}
|
|
||||||
procedure fpc_pchar_to_shortstr(out res : shortstring;p:pchar);[public,alias:'FPC_PCHAR_TO_SHORTSTR']; compilerproc;
|
procedure fpc_pchar_to_shortstr(out res : shortstring;p:pchar);[public,alias:'FPC_PCHAR_TO_SHORTSTR']; compilerproc;
|
||||||
assembler; nostackframe;
|
assembler; nostackframe;
|
||||||
{$define FPC_STRPASPROC}
|
{
|
||||||
{$endif FPC_STRTOSHORTSTRINGPROC}
|
r3: result address
|
||||||
{$include strpas.inc}
|
r4: high(result)
|
||||||
{$undef FPC_STRPASPROC}
|
r5: p (source)
|
||||||
|
}
|
||||||
|
asm
|
||||||
|
{ nil? }
|
||||||
|
mr r8, p
|
||||||
|
cmpldi p, 0
|
||||||
|
{ load the begin of the string in the data cache }
|
||||||
|
dcbt 0, p
|
||||||
|
{ maxlength }
|
||||||
|
mr r10,r4
|
||||||
|
mtctr r10
|
||||||
|
{ at LStrPasDone, we set the length of the result to 255 - r10 - r4 }
|
||||||
|
{ = 255 - 255 - 0 if the soure = nil -> perfect :) }
|
||||||
|
beq .LStrPasDone
|
||||||
|
{ save address for at the end and use r7 in loop }
|
||||||
|
mr r7,r3
|
||||||
|
{ no "subi r7,r7,1" because the first byte = length byte }
|
||||||
|
subi r8,r8,1
|
||||||
|
.LStrPasLoop:
|
||||||
|
lbzu r10,1(r8)
|
||||||
|
cmplwi cr0,r10,0
|
||||||
|
stbu r10,1(r7)
|
||||||
|
bdnzf cr0*4+eq, .LStrPasLoop
|
||||||
|
|
||||||
|
{ if we stopped because of a terminating #0, decrease the length by 1 }
|
||||||
|
cntlzd r4,r10
|
||||||
|
{ get remaining count for length }
|
||||||
|
mfctr r10
|
||||||
|
{ if r10 was zero (-> stopped because of zero byte), then r4 will be 64 }
|
||||||
|
{ (64 leading zero bits) -> shr 6 = 1, otherwise this will be zero }
|
||||||
|
srdi r4,r4,6
|
||||||
|
.LStrPasDone:
|
||||||
|
subfic r10,r10,255
|
||||||
|
sub r10,r10,r4
|
||||||
|
|
||||||
|
{ store length }
|
||||||
|
stb r10,0(r3)
|
||||||
|
end;
|
||||||
{$endif FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
|
{$endif FPC_SYSTEM_HAS_FPC_PCHAR_TO_SHORTSTR}
|
||||||
|
|
||||||
(*
|
(*
|
||||||
|
Loading…
Reference in New Issue
Block a user