Pārlūkot izejas kodu

* replace NR_LOCAL_FRAME_POINTER_REG with tcpuprocdef(current_procinfo.procdef).frame_pointer_ref in tcpuprocinfo.postprocess_code instead of inside the register allocator

git-svn-id: branches/wasm@47887 -
nickysn 4 gadi atpakaļ
vecāks
revīzija
dc151465c5
2 mainītis faili ar 31 papildinājumiem un 10 dzēšanām
  1. 26 2
      compiler/wasm32/cpupi.pas
  2. 5 8
      compiler/wasm32/rgcpu.pas

+ 26 - 2
compiler/wasm32/cpupi.pas

@@ -44,8 +44,8 @@ interface
 implementation
 
     uses
-      systems,globals, tgcpu,aasmdata,aasmcpu,aasmtai,
-      tgobj,paramgr,symconst;
+      systems,globals,cpubase,tgcpu,aasmdata,aasmcpu,aasmtai,
+      tgobj,paramgr,symconst,symcpu;
 
     procedure tcpuprocinfo.postprocess_code;
 
@@ -68,6 +68,28 @@ implementation
             end;
         end;
 
+      procedure replace_local_frame_pointer(asmlist: TAsmList);
+        var
+          hp: tai;
+          instr: taicpu;
+          l: Integer;
+        begin
+          if not assigned(asmlist) then
+            exit;
+          hp:=tai(asmlist.first);
+          while assigned(hp) do
+            begin
+              if hp.typ=ait_instruction then
+                begin
+                  instr:=taicpu(hp);
+                  for l:=0 to instr.ops-1 do
+                    if (instr.oper[l]^.typ=top_reg) and (instr.oper[l]^.reg=NR_LOCAL_FRAME_POINTER_REG) then
+                      instr.loadref(l,tcpuprocdef(current_procinfo.procdef).frame_pointer_ref);
+                end;
+              hp:=tai(hp.Next);
+            end;
+        end;
+
       var
        templist : TAsmList;
        l : TWasmLocal;
@@ -93,6 +115,8 @@ implementation
             last_tai_local.last:=true;
           end;
 
+        replace_local_frame_pointer(aktproccode);
+
         inherited postprocess_code;
       end;
 

+ 5 - 8
compiler/wasm32/rgcpu.pas

@@ -66,14 +66,11 @@ implementation
         { WebAssebly instructions never have more than one memory (virtual register)
           operand, so there is no danger of superregister conflicts }
         for l:=0 to instr.ops-1 do
-          if instr.oper[l]^.typ=top_reg then
-            if instr.oper[l]^.reg=NR_LOCAL_FRAME_POINTER_REG then
-              instr.loadref(l,tcpuprocdef(current_procinfo.procdef).frame_pointer_ref)
-            else
-              begin
-                reg:=instr.oper[l]^.reg;
-                instr.loadref(l,spilltemps[getregtype(reg)]^[getsupreg(reg)]);
-              end;
+          if (instr.oper[l]^.typ=top_reg) and (instr.oper[l]^.reg<>NR_LOCAL_FRAME_POINTER_REG) then
+            begin
+              reg:=instr.oper[l]^.reg;
+              instr.loadref(l,spilltemps[getregtype(reg)]^[getsupreg(reg)]);
+            end;
       end;