Browse Source

+ support intrinsic for the memory.atomic.notify WebAssembly instruction

Nikolay Nikolov 3 years ago
parent
commit
f1cb5d8f71
2 changed files with 10 additions and 1 deletions
  1. 9 1
      compiler/wasm32/nwasminl.pas
  2. 1 0
      rtl/wasm32/cpuh.inc

+ 9 - 1
compiler/wasm32/nwasminl.pas

@@ -589,6 +589,11 @@ implementation
               CheckParameters(3);
               resultdef:=s32inttype;
             end;
+          in_wasm32_memory_atomic_notify:
+            begin
+              CheckParameters(2);
+              resultdef:=u32inttype;
+            end;
           else
             Result:=inherited pass_typecheck_cpu;
         end;
@@ -658,7 +663,8 @@ implementation
           in_wasm32_i64_atomic_rmw32_cmpxchg_u,
           in_wasm32_i64_atomic_rmw_cmpxchg,
           in_wasm32_memory_atomic_wait32,
-          in_wasm32_memory_atomic_wait64:
+          in_wasm32_memory_atomic_wait64,
+          in_wasm32_memory_atomic_notify:
             expectloc:=LOC_REGISTER;
           else
             Result:=inherited first_cpu;
@@ -785,6 +791,8 @@ implementation
             second_atomic_rmw_x_y_z(a_memory_atomic_wait32);
           in_wasm32_memory_atomic_wait64:
             second_atomic_rmw_x_y_z(a_memory_atomic_wait64);
+          in_wasm32_memory_atomic_notify:
+            second_atomic_rmw_x_y(a_memory_atomic_notify);
           else
             inherited pass_generate_code_cpu;
         end;

+ 1 - 0
rtl/wasm32/cpuh.inc

@@ -83,4 +83,5 @@ function fpc_wasm32_i64_atomic_rmw_cmpxchg_u(Dest: PLongWord; Expected, Replacem
 
 function fpc_wasm32_memory_atomic_wait32(Dest: PLongWord; Expected: LongWord; Timeout: Int64): LongInt;[internproc:fpc_in_wasm32_memory_atomic_wait32];
 function fpc_wasm32_memory_atomic_wait64(Dest: PQWord; Expected: QWord; Timeout: Int64): LongInt;[internproc:fpc_in_wasm32_memory_atomic_wait64];
+function fpc_wasm32_memory_atomic_notify(Address: Pointer; Count: LongWord): LongWord;[internproc:fpc_in_wasm32_memory_atomic_notify];