Browse Source

* switch PowerPC 64 RTL to provide atomic intrinsic helpers instead of Interlocked* functions

Sven/Sarah Barth 8 months ago
parent
commit
5346faa02c
1 changed files with 54 additions and 0 deletions
  1. 54 0
      rtl/powerpc64/powerpc64.inc

+ 54 - 0
rtl/powerpc64/powerpc64.inc

@@ -626,7 +626,16 @@ asm
     bne-    .LIncLockedLoop
     bne-    .LIncLockedLoop
 end;
 end;
 
 
+{$ifndef VER3_2}
+{$define FPC_SYSTEM_INTERLOCKED_USE_INTRIN}
+{$endif VER3_2}
+
+{$ifdef VER3_2}
 function InterLockedDecrement (var Target: longint) : longint; assembler; nostackframe;
 function InterLockedDecrement (var Target: longint) : longint; assembler; nostackframe;
+{$else VER3_2}
+{$define FPC_SYSTEM_HAS_ATOMIC_DEC_32}
+function fpc_atomic_dec_32 (var Target: longint) : longint; assembler; nostackframe;
+{$endif VER3_2}
 { input:  address of target in r3 }
 { input:  address of target in r3 }
 { output: target-1 in r3          }
 { output: target-1 in r3          }
 { side-effect: target := target-1 }
 { side-effect: target := target-1 }
@@ -640,7 +649,12 @@ asm
 end;
 end;
 
 
 
 
+{$ifdef VER3_2}
 function InterLockedIncrement (var Target: longint) : longint; assembler; nostackframe;
 function InterLockedIncrement (var Target: longint) : longint; assembler; nostackframe;
+{$else VER3_2}
+{$define FPC_SYSTEM_HAS_ATOMIC_INC_32}
+function fpc_atomic_inc_32 (var Target: longint) : longint; assembler; nostackframe;
+{$endif VER3_2}
 { input:  address of target in r3 }
 { input:  address of target in r3 }
 { output: target+1 in r3          }
 { output: target+1 in r3          }
 { side-effect: target := target+1 }
 { side-effect: target := target+1 }
@@ -654,7 +668,12 @@ asm
 end;
 end;
 
 
 
 
+{$ifdef VER3_2}
 function InterLockedExchange (var Target: longint;Source : longint) : longint; assembler; nostackframe;
 function InterLockedExchange (var Target: longint;Source : longint) : longint; assembler; nostackframe;
+{$else VER3_2}
+{$define FPC_SYSTEM_HAS_ATOMIC_XCHG_32}
+function fpc_atomic_xchg_32 (var Target: longint;Source : longint) : longint; assembler; nostackframe;
+{$endif VER3_2}
 { input:  address of target in r3, source in r4 }
 { input:  address of target in r3, source in r4 }
 { output: target in r3                          }
 { output: target in r3                          }
 { side-effect: target := source                 }
 { side-effect: target := source                 }
@@ -667,7 +686,12 @@ asm
 end;
 end;
 
 
 
 
+{$ifdef VER3_2}
 function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint; assembler; nostackframe;
 function InterLockedExchangeAdd (var Target: longint;Source : longint) : longint; assembler; nostackframe;
+{$else VER3_2}
+{$define FPC_SYSTEM_HAS_ATOMIC_ADD_32}
+function fpc_atomic_add_32 (var Target: longint;Value : longint) : longint; assembler; nostackframe;
+{$endif VER3_2}
 { input:  address of target in r3, source in r4 }
 { input:  address of target in r3, source in r4 }
 { output: target in r3                          }
 { output: target in r3                          }
 { side-effect: target := target+source          }
 { side-effect: target := target+source          }
@@ -680,7 +704,12 @@ asm
         sub     r3,r10,r4
         sub     r3,r10,r4
 end;
 end;
 
 
+{$ifdef VER3_2}
 function InterlockedCompareExchange(var Target: longint; NewValue: longint; Comperand: longint): longint; assembler; nostackframe;
 function InterlockedCompareExchange(var Target: longint; NewValue: longint; Comperand: longint): longint; assembler; nostackframe;
+{$else VER3_2}
+{$define FPC_SYSTEM_HAS_ATOMIC_CMP_XCHG_32}
+function fpc_atomic_cmp_xchg_32 (var Target: longint; NewValue: longint; Comparand: longint) : longint; assembler; nostackframe;
+{$endif VER3_2}
 { input:  address of target in r3, newvalue in r4, comparand in r5 }
 { input:  address of target in r3, newvalue in r4, comparand in r5 }
 { output: value stored in target before entry of the function      }
 { output: value stored in target before entry of the function      }
 { side-effect: NewValue stored in target if (target = comparand)   }
 { side-effect: NewValue stored in target if (target = comparand)   }
@@ -702,7 +731,12 @@ asm
 end;
 end;
 
 
 
 
+{$ifdef VER3_2}
 function InterLockedDecrement64(var Target: Int64) : Int64; assembler; nostackframe;
 function InterLockedDecrement64(var Target: Int64) : Int64; assembler; nostackframe;
+{$else VER3_2}
+{$define FPC_SYSTEM_HAS_ATOMIC_DEC_64}
+function fpc_atomic_dec_64 (var Target: int64) : int64; assembler; nostackframe;
+{$endif VER3_2}
 { input:  address of target in r3 }
 { input:  address of target in r3 }
 { output: target-1 in r3          }
 { output: target-1 in r3          }
 { side-effect: target := target-1 }
 { side-effect: target := target-1 }
@@ -716,7 +750,12 @@ asm
 end;
 end;
 
 
 
 
+{$ifdef VER3_2}
 function InterLockedIncrement64(var Target: Int64) : Int64; assembler; nostackframe;
 function InterLockedIncrement64(var Target: Int64) : Int64; assembler; nostackframe;
+{$else VER3_2}
+{$define FPC_SYSTEM_HAS_ATOMIC_INC_64}
+function fpc_atomic_inc_64 (var Target: int64) : int64; assembler; nostackframe;
+{$endif VER3_2}
 { input:  address of target in r3 }
 { input:  address of target in r3 }
 { output: target+1 in r3          }
 { output: target+1 in r3          }
 { side-effect: target := target+1 }
 { side-effect: target := target+1 }
@@ -730,7 +769,12 @@ asm
 end;
 end;
 
 
 
 
+{$ifdef VER3_2}
 function InterLockedExchange64(var Target: Int64; Source : Int64) : Int64; assembler; nostackframe;
 function InterLockedExchange64(var Target: Int64; Source : Int64) : Int64; assembler; nostackframe;
+{$else VER3_2}
+{$define FPC_SYSTEM_HAS_ATOMIC_XCHG_64}
+function fpc_atomic_xchg_64 (var Target: Int64; Source : Int64) : Int64; assembler; nostackframe;
+{$endif VER3_2}
 { input:  address of target in r3, source in r4 }
 { input:  address of target in r3, source in r4 }
 { output: target in r3                          }
 { output: target in r3                          }
 { side-effect: target := source                 }
 { side-effect: target := source                 }
@@ -743,7 +787,12 @@ asm
 end;
 end;
 
 
 
 
+{$ifdef VER3_2}
 function InterLockedExchangeAdd64(var Target: Int64; Source : Int64) : Int64; assembler; nostackframe;
 function InterLockedExchangeAdd64(var Target: Int64; Source : Int64) : Int64; assembler; nostackframe;
+{$else VER3_2}
+{$define FPC_SYSTEM_HAS_ATOMIC_ADD_64}
+function fpc_atomic_add_64 (var Target: Int64; Value : Int64) : Int64; assembler; nostackframe;
+{$endif VER3_2}
 { input:  address of target in r3, source in r4 }
 { input:  address of target in r3, source in r4 }
 { output: target in r3                          }
 { output: target in r3                          }
 { side-effect: target := target+source          }
 { side-effect: target := target+source          }
@@ -756,7 +805,12 @@ asm
         sub     r3,r10,r4
         sub     r3,r10,r4
 end;
 end;
 
 
+{$ifdef VER3_2}
 function InterlockedCompareExchange64(var Target: Int64; NewValue: Int64; Comperand: Int64): Int64; assembler; nostackframe;
 function InterlockedCompareExchange64(var Target: Int64; NewValue: Int64; Comperand: Int64): Int64; assembler; nostackframe;
+{$else VER3_2}
+{$define FPC_SYSTEM_HAS_ATOMIC_CMP_XCHG_64}
+function fpc_atomic_cmp_xchg_64 (var Target: Int64; NewValue: Int64; Comparand: Int64) : Int64; [public,alias:'FPC_ATOMIC_CMP_XCHG_64']; assembler; nostackframe;
+{$endif VER3_2}
 { input:  address of target in r3, newvalue in r4, comparand in r5 }
 { input:  address of target in r3, newvalue in r4, comparand in r5 }
 { output: value stored in target before entry of the function      }
 { output: value stored in target before entry of the function      }
 { side-effect: NewValue stored in target if (target = comparand)   }
 { side-effect: NewValue stored in target if (target = comparand)   }