ソースを参照

+ added the memory.copy and memory.fill WebAssembly instructions

Nikolay Nikolov 3 年 前
コミット
026d23632a

+ 1 - 1
compiler/systems.pas

@@ -86,7 +86,7 @@ interface
           id          : tasm;
           idtxt       : string[12];
           asmbin      : string[16];
-          asmcmd      : string[100];
+          asmcmd      : string[113];
           supported_targets : set of tsystem;
           flags        : set of tasmflags;
           labelprefix : string[3];

+ 17 - 0
compiler/wasm32/aasmcpu.pas

@@ -542,6 +542,10 @@ uses
           a_memory_size,
           a_memory_grow:
             result:=2;
+          a_memory_copy:
+            result:=4;
+          a_memory_fill:
+            result:=3;
           a_i32_const:
             begin
               if ops<>1 then
@@ -873,6 +877,19 @@ uses
               WriteByte($40);
               WriteByte($00);
             end;
+          a_memory_copy:
+            begin
+              WriteByte($FC);
+              WriteUleb(10);
+              WriteByte($00);
+              WriteByte($00);
+            end;
+          a_memory_fill:
+            begin
+              WriteByte($FC);
+              WriteUleb(11);
+              WriteByte($00);
+            end;
           a_i32_eqz:
             WriteByte($45);
           a_i32_eq:

+ 1 - 1
compiler/wasm32/agllvmmc.pas

@@ -247,7 +247,7 @@ implementation
          id     : as_wasm32_llvm_mc;
          idtxt  : 'LLVM-MC';
          asmbin : 'llvm-mc';
-         asmcmd : '--assemble --arch=wasm32 -mattr=+sign-ext,+exception-handling --filetype=obj -o $OBJ $EXTRAOPT $ASM';
+         asmcmd : '--assemble --arch=wasm32 -mattr=+sign-ext,+exception-handling,+bulk-memory --filetype=obj -o $OBJ $EXTRAOPT $ASM';
          supported_targets : [system_wasm32_embedded,system_wasm32_wasi];
          flags : [af_smartlink_sections];
          labelprefix : '.L';

+ 2 - 0
compiler/wasm32/cpubase.pas

@@ -84,6 +84,8 @@ uses
       a_i32_store8, a_i32_store16, a_i64_store8, a_i64_store16, a_i64_store32,
       // additional memory
       a_memory_grow, a_memory_size,
+      // bulk memory operations
+      a_memory_copy, a_memory_fill,
       // exceptions
       a_try,a_catch,a_catch_all,a_delegate,a_throw,a_rethrow,a_end_try
       );

+ 2 - 0
compiler/wasm32/itcpugas.pas

@@ -83,6 +83,8 @@ interface
       'i32.store8', 'i32.store16', 'i64.store8', 'i64.store16', 'i64.store32',
       // additional memory
       'memory.grow 0', 'memory.size 0',
+      // bulk memory operations
+      'memory.copy 0,0', 'memory.fill 0',
       // exceptions
       'try','catch','catch_all','delegate','throw','rethrow','end_try'
     );

+ 2 - 0
compiler/wasm32/strinst.inc

@@ -67,6 +67,8 @@
         'i32.store8', 'i32.store16', 'i64.store8', 'i64.store16', 'i64.store32',
         // additional memory
         'grow_memory', 'current_memory',
+        // bulk memory operations
+        'memory.copy', 'memory.fill',
         // exceptions
         'try','catch','catch_all','delegate','throw','rethrow','end'