Browse Source

[PATCH 166/188] normalizing memory instructions

From 0a62c804cae96479ec427da585e873acd35adeb9 Mon Sep 17 00:00:00 2001
From: Dmitry Boyarintsev <[email protected]>
Date: Fri, 27 Mar 2020 11:33:33 -0400

git-svn-id: branches/wasm@46162 -
nickysn 5 years ago
parent
commit
41d67dc630
1 changed files with 19 additions and 6 deletions
  1. 19 6
      utils/wasmbin/wasmnormalize.pas

+ 19 - 6
utils/wasmbin/wasmnormalize.pas

@@ -48,6 +48,15 @@ begin
   Result := LblStack.Count-i-1;
   Result := LblStack.Count-i-1;
 end;
 end;
 
 
+procedure NormalizeOfsAlign(ci: TWasmInstr);
+const
+  ALIGN_STR : array [0..3] of string = ('1','2','4','8');
+begin
+  if (ci.offsetText = '') then ci.offsetText := '0';
+  if (ci.alignText = '') then
+    ci.alignText := ALIGN_STR[INST_FLAGS[ci.code].align];
+end;
+
 // Normalizing instruction list, popuplating index reference ($index)
 // Normalizing instruction list, popuplating index reference ($index)
 // with the actual numbers. (params, locals, globals, memory, functions index)
 // with the actual numbers. (params, locals, globals, memory, functions index)
 //
 //
@@ -69,13 +78,17 @@ begin
     for i:=0 to l.Count-1 do begin
     for i:=0 to l.Count-1 do begin
       ci:=l[i];
       ci:=l[i];
 
 
-      if INST_FLAGS[ci.code].Param = ipResType then
-      begin
-        inc(endNeed);
-        if not (byte(ci.operandNum) in ValidResTypes) then
-          ci.operandNum := VALTYPE_NONE;
+      case INST_FLAGS[ci.code].Param of
+        ipResType:
+        begin
+          inc(endNeed);
+          if not (byte(ci.operandNum) in ValidResTypes) then
+            ci.operandNum := VALTYPE_NONE;
 
 
-        lbl.Add(ci.jumplabel);
+          lbl.Add(ci.jumplabel);
+        end;
+        ipOfsAlign:
+          NormalizeOfsAlign( ci );
       end;
       end;
 
 
       case ci.code of
       case ci.code of