소스 검색

+ added the WebAssembly saturating truncation instructions to the internal assembler

Nikolay Nikolov 3 년 전
부모
커밋
d378240134
4개의 변경된 파일75개의 추가작업 그리고 0개의 파일을 삭제
  1. 48 0
      compiler/wasm32/aasmcpu.pas
  2. 9 0
      compiler/wasm32/cpubase.pas
  3. 9 0
      compiler/wasm32/itcpugas.pas
  4. 9 0
      compiler/wasm32/strinst.inc

+ 48 - 0
compiler/wasm32/aasmcpu.pas

@@ -539,6 +539,14 @@ uses
           a_end_try,
           a_catch_all:
             result:=1;
+          a_i32_trunc_sat_f32_s,
+          a_i32_trunc_sat_f32_u,
+          a_i32_trunc_sat_f64_s,
+          a_i32_trunc_sat_f64_u,
+          a_i64_trunc_sat_f32_s,
+          a_i64_trunc_sat_f32_u,
+          a_i64_trunc_sat_f64_s,
+          a_i64_trunc_sat_f64_u,
           a_memory_size,
           a_memory_grow:
             result:=2;
@@ -1910,6 +1918,46 @@ uses
                     internalerror(2022052809);
                 end;
             end;
+          a_i32_trunc_sat_f32_s:
+            begin
+              WriteByte($FC);
+              WriteByte($00);
+            end;
+          a_i32_trunc_sat_f32_u:
+            begin
+              WriteByte($FC);
+              WriteByte($01);
+            end;
+          a_i32_trunc_sat_f64_s:
+            begin
+              WriteByte($FC);
+              WriteByte($02);
+            end;
+          a_i32_trunc_sat_f64_u:
+            begin
+              WriteByte($FC);
+              WriteByte($03);
+            end;
+          a_i64_trunc_sat_f32_s:
+            begin
+              WriteByte($FC);
+              WriteByte($04);
+            end;
+          a_i64_trunc_sat_f32_u:
+            begin
+              WriteByte($FC);
+              WriteByte($05);
+            end;
+          a_i64_trunc_sat_f64_s:
+            begin
+              WriteByte($FC);
+              WriteByte($06);
+            end;
+          a_i64_trunc_sat_f64_u:
+            begin
+              WriteByte($FC);
+              WriteByte($07);
+            end;
           else
             internalerror(2021092624);
         end;

+ 9 - 0
compiler/wasm32/cpubase.pas

@@ -90,6 +90,15 @@ uses
       a_ref_null, a_ref_is_null, a_ref_func,
       // table instructions
       a_table_get, a_table_set, a_table_size, a_table_grow, a_table_fill, a_table_copy, a_table_init, a_elem_drop,
+      // saturating truncation instructions
+      a_i32_trunc_sat_f32_s,
+      a_i32_trunc_sat_f32_u,
+      a_i32_trunc_sat_f64_s,
+      a_i32_trunc_sat_f64_u,
+      a_i64_trunc_sat_f32_s,
+      a_i64_trunc_sat_f32_u,
+      a_i64_trunc_sat_f64_s,
+      a_i64_trunc_sat_f64_u,
       // exceptions
       a_try,a_catch,a_catch_all,a_delegate,a_throw,a_rethrow,a_end_try,
       // atomic memory accesses - load/store

+ 9 - 0
compiler/wasm32/itcpugas.pas

@@ -89,6 +89,15 @@ interface
       'ref.null', 'ref.is_null', 'ref.func',
       // table instructions
       'table.get', 'table.set', 'table.size', 'table.grow', 'table.fill', 'table.copy', 'table.init', 'elem.drop',
+      // saturating truncation instructions
+      'i32.trunc_sat_f32_s',
+      'i32.trunc_sat_f32_u',
+      'i32.trunc_sat_f64_s',
+      'i32.trunc_sat_f64_u',
+      'i64.trunc_sat_f32_s',
+      'i64.trunc_sat_f32_u',
+      'i64.trunc_sat_f64_s',
+      'i64.trunc_sat_f64_u',
       // exceptions
       'try','catch','catch_all','delegate','throw','rethrow','end_try',
       // atomic memory accesses - load/store

+ 9 - 0
compiler/wasm32/strinst.inc

@@ -73,6 +73,15 @@
         'ref.null', 'ref.is_null', 'ref.func',
         // table instructions
         'table.get', 'table.set', 'table.size', 'table.grow', 'table.fill', 'table.copy', 'table.init', 'elem.drop',
+        // saturating truncation instructions
+        'i32.trunc_sat_f32_s',
+        'i32.trunc_sat_f32_u',
+        'i32.trunc_sat_f64_s',
+        'i32.trunc_sat_f64_u',
+        'i64.trunc_sat_f32_s',
+        'i64.trunc_sat_f32_u',
+        'i64.trunc_sat_f64_s',
+        'i64.trunc_sat_f64_u',
         // exceptions
         'try','catch','catch_all','delegate','throw','rethrow','end',
         // atomic memory accesses - load/store