2
0
Эх сурвалжийг харах

* moved count_locals from pstatmnt to symutils
* use count_locals in powerpc/cpupi to check whether we should set the
first temp offset (and as such generate a stackframe)

Jonas Maebe 21 жил өмнө
parent
commit
62394e45d7

+ 15 - 5
compiler/powerpc/cpupi.pas

@@ -52,7 +52,7 @@ unit cpupi;
        cpubase,
        cpubase,
        aasmtai,
        aasmtai,
        tgobj,
        tgobj,
-       symconst,symsym,paramgr;
+       symconst,symsym,paramgr,symutil;
 
 
     constructor tppcprocinfo.create(aparent:tprocinfo);
     constructor tppcprocinfo.create(aparent:tprocinfo);
 
 
@@ -65,6 +65,7 @@ unit cpupi;
     procedure tppcprocinfo.set_first_temp_offset;
     procedure tppcprocinfo.set_first_temp_offset;
       var
       var
          ofs : aword;
          ofs : aword;
+         locals: longint;
       begin
       begin
         if not(po_assembler in procdef.procoptions) then
         if not(po_assembler in procdef.procoptions) then
           begin
           begin
@@ -77,9 +78,13 @@ unit cpupi;
             tg.setfirsttemp(ofs);
             tg.setfirsttemp(ofs);
           end
           end
         else
         else
-          if assigned(procdef.localst) then
-            { at 0(r1), the previous value of r1 will be stored }
-            tg.setfirsttemp(4);
+          begin
+            locals := 0;
+            current_procinfo.procdef.localst.foreach_static({$ifdef FPCPROCVAR}@{$endif}count_locals,@locals);
+            if locals <> 0 then
+              { at 0(r1), the previous value of r1 will be stored }
+              tg.setfirsttemp(4);
+          end;
       end;
       end;
 
 
 
 
@@ -128,7 +133,12 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.31  2003-11-29 22:54:32  jonas
+  Revision 1.32  2003-12-07 16:40:45  jonas
+    * moved count_locals from pstatmnt to symutils
+    * use count_locals in powerpc/cpupi to check whether we should set the
+      first temp offset (and as such generate a stackframe)
+
+  Revision 1.31  2003/11/29 22:54:32  jonas
     * more ppc fixes, hello world works again under linuxppc
     * more ppc fixes, hello world works again under linuxppc
 
 
   Revision 1.30  2003/11/29 16:27:19  jonas
   Revision 1.30  2003/11/29 16:27:19  jonas

+ 7 - 13
compiler/pstatmnt.pas

@@ -48,7 +48,7 @@ implementation
        cpubase,aasmbase,aasmtai,
        cpubase,aasmbase,aasmtai,
        { symtable }
        { symtable }
        symconst,symbase,symtype,symdef,symsym,symtable,defutil,defcmp,
        symconst,symbase,symtype,symdef,symsym,symtable,defutil,defcmp,
-       paramgr,
+       paramgr,symutil,
        { pass 1 }
        { pass 1 }
        pass_1,htypechk,
        pass_1,htypechk,
        nutils,nbas,nmat,nadd,ncal,nmem,nset,ncnv,ninl,ncon,nld,nflw,
        nutils,nbas,nmat,nadd,ncal,nmem,nset,ncnv,ninl,ncon,nld,nflw,
@@ -1028,17 +1028,6 @@ implementation
       end;
       end;
 
 
 
 
-    procedure count_locals(p:tnamedindexitem;arg:pointer);
-      begin
-        { Count only varsyms, but ignore the funcretsym }
-        if (tsym(p).typ=varsym) and
-           (tsym(p)<>current_procinfo.procdef.funcretsym) and
-           (not(vo_is_parentfp in tvarsym(p).varoptions) or
-            (tvarsym(p).refs>0)) then
-          inc(plongint(arg)^);
-      end;
-
-
     function assembler_block : tnode;
     function assembler_block : tnode;
       var
       var
         p : tnode;
         p : tnode;
@@ -1106,7 +1095,12 @@ implementation
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.123  2003-12-03 17:39:04  florian
+  Revision 1.124  2003-12-07 16:40:45  jonas
+    * moved count_locals from pstatmnt to symutils
+    * use count_locals in powerpc/cpupi to check whether we should set the
+      first temp offset (and as such generate a stackframe)
+
+  Revision 1.123  2003/12/03 17:39:04  florian
     * fixed several arm calling conventions issues
     * fixed several arm calling conventions issues
     * fixed reference reading in the assembler reader
     * fixed reference reading in the assembler reader
     * fixed a_loadaddr_ref_reg
     * fixed a_loadaddr_ref_reg

+ 21 - 2
compiler/symutil.pas

@@ -27,7 +27,7 @@ unit symutil;
 interface
 interface
 
 
     uses
     uses
-       symbase,symtype,symsym;
+       symbase,symtype,symsym,cclasses;
 
 
     function is_funcret_sym(p:tsymentry):boolean;
     function is_funcret_sym(p:tsymentry):boolean;
 
 
@@ -36,12 +36,14 @@ interface
 
 
     function equal_constsym(sym1,sym2:tconstsym):boolean;
     function equal_constsym(sym1,sym2:tconstsym):boolean;
 
 
+    procedure count_locals(p:tnamedindexitem;arg:pointer);
 
 
 implementation
 implementation
 
 
     uses
     uses
        globtype,
        globtype,
        cpuinfo,
        cpuinfo,
+       procinfo,
        symconst;
        symconst;
 
 
 
 
@@ -102,10 +104,27 @@ implementation
         end;
         end;
       end;
       end;
 
 
+
+    procedure count_locals(p:tnamedindexitem;arg:pointer);
+      begin
+        { Count only varsyms, but ignore the funcretsym }
+        if (tsym(p).typ=varsym) and
+           (tsym(p)<>current_procinfo.procdef.funcretsym) and
+           (not(vo_is_parentfp in tvarsym(p).varoptions) or
+            (tvarsym(p).refs>0)) then
+          inc(plongint(arg)^);
+      end;
+
+
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.2  2003-04-25 20:59:35  peter
+  Revision 1.3  2003-12-07 16:40:45  jonas
+    * moved count_locals from pstatmnt to symutils
+    * use count_locals in powerpc/cpupi to check whether we should set the
+      first temp offset (and as such generate a stackframe)
+
+  Revision 1.2  2003/04/25 20:59:35  peter
     * removed funcretn,funcretsym, function result is now in varsym
     * removed funcretn,funcretsym, function result is now in varsym
       and aliases for result and function name are added using absolutesym
       and aliases for result and function name are added using absolutesym
     * vs_hidden parameter for funcret passed in parameter
     * vs_hidden parameter for funcret passed in parameter