Skip to content

Commit e3c4cb1

Browse files
committed
clean up dead code and duplication
1 parent 3ea0dbd commit e3c4cb1

15 files changed

Lines changed: 136 additions & 189 deletions
Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
// Shared SIMD procedure prologue for 1-parameter assembly functions.
22
// After inclusion: ebx = param1 (from EAX at entry).
3-
// FPC: Windows and Unix i386 use the same parameter entry layout.
3+
// FPC and Delphi Win32 share the same i386 register convention here.
44
// Usage:
55
// procedure MyProc(P1: Pointer);
66
// {$I SimdProc1Begin_i386.inc}
77
// // ... SIMD instructions using ebx ...
88
// end;
99
{$IFDEF FPC}
1010
assembler; nostackframe;
11+
{$ENDIF}
1112
asm
1213
mov ebx, eax
13-
{$ELSE}
14-
asm
15-
mov ebx, eax
16-
{$ENDIF}

HashLib/src/Include/Simd/Common/SimdProc1Begin_x86_64.inc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
// end;
99
{$IFDEF FPC}
1010
assembler; nostackframe;
11+
{$ENDIF}
1112
asm
12-
{$IFDEF HASHLIB_SYSV_X64_ABI}
13-
mov rcx, rdi
14-
{$ENDIF}
15-
{$ELSE}
16-
asm
13+
{$IFNDEF FPC}
1714
.noframe
1815
{$ENDIF}
16+
{$IFDEF HASHLIB_SYSV_X64_ABI}
17+
mov rcx, rdi
18+
{$ENDIF}
Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,16 @@
11
// Shared SIMD procedure prologue for 2-parameter assembly functions.
2-
// After inclusion: ebx = param1, esi = param2 (EAX, EDX at entry; callee saves EBX, ESI).
3-
// FPC: Windows and Unix i386 use the same parameter entry layout.
2+
// After inclusion: ebx = param1, esi = param2 (EAX, EDX at entry).
3+
// Callee-saved EBX, ESI - epilogue must pop ESI, EBX.
44
// Usage:
55
// procedure MyProc(P1, P2: Pointer);
66
// {$I SimdProc2Begin_i386.inc}
77
// // ... SIMD instructions using ebx, esi ...
88
// end;
99
{$IFDEF FPC}
1010
assembler; nostackframe;
11+
{$ENDIF}
1112
asm
1213
push ebx
1314
push esi
1415
mov ebx, eax
1516
mov esi, edx
16-
{$ELSE}
17-
asm
18-
push ebx
19-
push esi
20-
mov ebx, eax
21-
mov esi, edx
22-
{$ENDIF}

HashLib/src/Include/Simd/Common/SimdProc2Begin_x86_64.inc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,12 @@
88
// end;
99
{$IFDEF FPC}
1010
assembler; nostackframe;
11+
{$ENDIF}
1112
asm
12-
{$IFDEF HASHLIB_SYSV_X64_ABI}
13+
{$IFNDEF FPC}
14+
.noframe
15+
{$ENDIF}
16+
{$IFDEF HASHLIB_SYSV_X64_ABI}
1317
mov rdx, rsi
1418
mov rcx, rdi
15-
{$ENDIF}
16-
{$ELSE}
17-
asm
18-
.noframe
1919
{$ENDIF}
Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
11
// Shared SIMD procedure prologue for 3-parameter assembly functions.
22
// After inclusion: ebx = param1, esi = param2, edi = param3 (EAX, EDX, ECX at entry).
3-
// FPC: Windows and Unix i386 use the same parameter entry layout.
3+
// Callee-saved EBX, ESI, EDI - epilogue must pop EDI, ESI, EBX.
44
// Usage:
55
// procedure MyProc(P1, P2, P3: Pointer);
66
// {$I SimdProc3Begin_i386.inc}
77
// // ... SIMD instructions using ebx, esi, edi ...
88
// end;
99
{$IFDEF FPC}
1010
assembler; nostackframe;
11+
{$ENDIF}
1112
asm
1213
push ebx
1314
push esi
1415
push edi
1516
mov ebx, eax
1617
mov esi, edx
1718
mov edi, ecx
18-
{$ELSE}
19-
asm
20-
push ebx
21-
push esi
22-
push edi
23-
mov ebx, eax
24-
mov esi, edx
25-
mov edi, ecx
26-
{$ENDIF}

HashLib/src/Include/Simd/Common/SimdProc3Begin_x86_64.inc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
// end;
1010
{$IFDEF FPC}
1111
assembler; nostackframe;
12+
{$ENDIF}
1213
asm
13-
{$IFDEF HASHLIB_SYSV_X64_ABI}
14+
{$IFNDEF FPC}
15+
.noframe
16+
{$ENDIF}
17+
{$IFDEF HASHLIB_SYSV_X64_ABI}
1418
mov r8, rdx
1519
mov rdx, rsi
1620
mov rcx, rdi
17-
{$ENDIF}
18-
{$ELSE}
19-
asm
20-
.noframe
2121
{$ENDIF}
Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
// Shared SIMD procedure prologue for 4-parameter assembly functions.
22
// After inclusion: ebx = param1, esi = param2, edi = param3, eax = param4
3-
// (first three in EAX, EDX, ECX at entry; param4 from stack after callee saves).
4-
// FPC: Windows and Unix i386 use the same stack tail layout; see asm for ESP offsets.
5-
// Delphi: MS Windows uses [ebp+8] for param4; see asm for other Delphi targets.
3+
// (first three in EAX, EDX, ECX at entry; param4 from stack).
4+
// Callee-saved EBX, ESI, EDI - epilogue must pop EDI, ESI, EBX.
5+
// Delphi i386 only ships on Windows; param4 lives at [ebp + 8].
6+
// FPC i386 has no stack frame; param4 lives at [esp + 8] when read after
7+
// the EBX push but before the ESI / EDI pushes (see asm).
68
// Usage:
79
// procedure MyProc(P1, P2, P3: Pointer; P4: Int32);
810
// {$I SimdProc4Begin_i386.inc}
@@ -20,21 +22,11 @@ asm
2022
mov edi, ecx
2123
{$ELSE}
2224
asm
23-
{$IFDEF MSWINDOWS}
2425
push ebx
2526
mov ebx, eax
2627
mov eax, dword ptr [ebp + 8]
2728
push esi
2829
mov esi, edx
2930
push edi
3031
mov edi, ecx
31-
{$ELSE}
32-
push ebx
33-
push esi
34-
push edi
35-
mov ebx, dword ptr [ebp + 8]
36-
mov esi, dword ptr [ebp + 12]
37-
mov edi, dword ptr [ebp + 16]
38-
mov eax, dword ptr [ebp + 20]
39-
{$ENDIF}
4032
{$ENDIF}

HashLib/src/Include/Simd/Common/SimdProc4Begin_x86_64.inc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
// end;
1111
{$IFDEF FPC}
1212
assembler; nostackframe;
13+
{$ENDIF}
1314
asm
14-
{$IFDEF HASHLIB_SYSV_X64_ABI}
15+
{$IFNDEF FPC}
16+
.noframe
17+
{$ENDIF}
18+
{$IFDEF HASHLIB_SYSV_X64_ABI}
1519
mov r9, rcx
1620
mov r8, rdx
1721
mov rdx, rsi
1822
mov rcx, rdi
19-
{$ENDIF}
20-
{$ELSE}
21-
asm
22-
.noframe
2323
{$ENDIF}

HashLib/src/Include/Simd/Common/SimdProc5Begin_i386.inc

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// After inclusion: ebx = param1, esi = param2, edi = param3, eax = param4, ecx = param5
33
// (i386 register convention).
44
// FPC: param4 and param5 are at [esp+20] and [esp+16] after push EBX/ESI/EDI (see asm).
5-
// Delphi: MS Windows uses [ebp+12] and [ebp+8] for param4 and param5; see asm for other Delphi targets.
5+
// Delphi Win32: first 3 params in EAX/EDX/ECX; param4 at [ebp+12], param5 at [ebp+8].
66
// Callee-saved EBX, ESI, EDI — epilogue must pop EDI, ESI, EBX.
77
// Usage:
88
// procedure MyProc(P1, P2: Pointer; P3, P4: Int32; P5: Pointer);
@@ -22,7 +22,6 @@ asm
2222
mov ecx, dword ptr [esp + 16] // param5
2323
{$ELSE}
2424
asm
25-
{$IFDEF MSWINDOWS}
2625
push ebx
2726
push esi
2827
push edi
@@ -31,14 +30,4 @@ asm
3130
mov edi, ecx
3231
mov eax, dword ptr [ebp + 12] // param4 (first stack param = high address)
3332
mov ecx, dword ptr [ebp + 8] // param5 (last stack param)
34-
{$ELSE}
35-
push ebx
36-
push esi
37-
push edi
38-
mov ebx, dword ptr [ebp + 8]
39-
mov esi, dword ptr [ebp + 12]
40-
mov edi, dword ptr [ebp + 16]
41-
mov eax, dword ptr [ebp + 20]
42-
mov ecx, dword ptr [ebp + 24]
43-
{$ENDIF}
4433
{$ENDIF}

HashLib/src/Include/Simd/Common/SimdProc5Begin_x86_64.inc

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,25 @@
22
// After inclusion: rcx = param1, rdx = param2, r8 = param3, r9 = param4, r10 = param5
33
// (MS x64 ABI).
44
// When HASHLIB_SYSV_X64_ABI is defined, remaps rdi,rsi,rdx,rcx,r8 -> rcx,rdx,r8,r9,r10.
5-
// Move order avoids register clobbering.
6-
// On MS x64, param5 is loaded from [rsp+40] (after shadow space).
5+
// On MS x64, param5 is loaded from [rsp+40] (above 32-byte shadow space + 8-byte return addr).
76
// Usage:
87
// procedure MyProc(P1, P2: Pointer; P3, P4: Int32; P5: Pointer);
98
// {$I SimdProc5Begin_x86_64.inc}
109
// // ... SIMD instructions using rcx, rdx, r8, r9, r10 ...
1110
// end;
1211
{$IFDEF FPC}
1312
assembler; nostackframe;
13+
{$ENDIF}
1414
asm
15-
{$IFDEF HASHLIB_SYSV_X64_ABI}
15+
{$IFNDEF FPC}
16+
.noframe
17+
{$ENDIF}
18+
{$IFDEF HASHLIB_SYSV_X64_ABI}
1619
mov r10, r8
1720
mov r9, rcx
1821
mov r8, rdx
1922
mov rdx, rsi
2023
mov rcx, rdi
21-
{$ELSE}
22-
mov r10, [rsp + 40]
23-
{$ENDIF}
2424
{$ELSE}
25-
asm
26-
.noframe
2725
mov r10, [rsp + 40]
2826
{$ENDIF}

0 commit comments

Comments
 (0)