Browse Source

* maybe_in_reg moved to tempinfo
* fixed expectloc for maybe_in_reg

peter 21 years ago
parent
commit
8756d4f862
2 changed files with 28 additions and 12 deletions
  1. 22 10
      compiler/nbas.pas
  2. 6 2
      compiler/ncgbas.pas

+ 22 - 10
compiler/nbas.pas

@@ -95,7 +95,7 @@ interface
            LOC_REFERENCE: (ref: treference);
            LOC_REFERENCE: (ref: treference);
            LOC_REGISTER:  (reg: tregister);
            LOC_REGISTER:  (reg: tregister);
        end;
        end;
-         
+
        { to allow access to the location by temp references even after the temp has }
        { to allow access to the location by temp references even after the temp has }
        { already been disposed and to make sure the coherency between temps and     }
        { already been disposed and to make sure the coherency between temps and     }
        { temp references is kept after a getcopy                                    }
        { temp references is kept after a getcopy                                    }
@@ -107,6 +107,7 @@ interface
          restype                    : ttype;
          restype                    : ttype;
          temptype                   : ttemptype;
          temptype                   : ttemptype;
          owner                      : ttempcreatenode;
          owner                      : ttempcreatenode;
+         may_be_in_reg              : boolean;
          valid                      : boolean;
          valid                      : boolean;
          nextref_set_hookoncopy_nil : boolean;
          nextref_set_hookoncopy_nil : boolean;
          loc                        : ttemplocation;
          loc                        : ttemplocation;
@@ -117,7 +118,6 @@ interface
        ttempcreatenode = class(tnode)
        ttempcreatenode = class(tnode)
           size: longint;
           size: longint;
           tempinfo: ptempinfo;
           tempinfo: ptempinfo;
-          may_be_in_reg: boolean;
           { * persistent temps are used in manually written code where the temp }
           { * persistent temps are used in manually written code where the temp }
           { be usable among different statements and where you can manually say }
           { be usable among different statements and where you can manually say }
           { when the temp has to be freed (using a ttempdeletenode)             }
           { when the temp has to be freed (using a ttempdeletenode)             }
@@ -671,7 +671,7 @@ implementation
     constructor ttempcreatenode.create_reg(const _restype: ttype; _size: longint; _temptype: ttemptype);
     constructor ttempcreatenode.create_reg(const _restype: ttype; _size: longint; _temptype: ttemptype);
       begin
       begin
         create(_restype,_size,_temptype);
         create(_restype,_size,_temptype);
-        may_be_in_reg:=
+        tempinfo^.may_be_in_reg:=
           not (_restype.def.needs_inittable) and
           not (_restype.def.needs_inittable) and
           ((_restype.def.deftype <> pointerdef) or
           ((_restype.def.deftype <> pointerdef) or
            (not tpointerdef(_restype.def).pointertype.def.needs_inittable));
            (not tpointerdef(_restype.def).pointertype.def.needs_inittable));
@@ -686,7 +686,6 @@ implementation
         tempinfo^.restype := _restype;
         tempinfo^.restype := _restype;
         tempinfo^.temptype := _temptype;
         tempinfo^.temptype := _temptype;
         tempinfo^.owner:=self;
         tempinfo^.owner:=self;
-        may_be_in_reg:=false;
       end;
       end;
 
 
     function ttempcreatenode.getcopy: tnode;
     function ttempcreatenode.getcopy: tnode;
@@ -695,7 +694,6 @@ implementation
       begin
       begin
         n := ttempcreatenode(inherited getcopy);
         n := ttempcreatenode(inherited getcopy);
         n.size := size;
         n.size := size;
-        n.may_be_in_reg := may_be_in_reg;
 
 
         new(n.tempinfo);
         new(n.tempinfo);
         fillchar(n.tempinfo^,sizeof(n.tempinfo^),0);
         fillchar(n.tempinfo^,sizeof(n.tempinfo^),0);
@@ -723,9 +721,9 @@ implementation
         inherited ppuload(t,ppufile);
         inherited ppuload(t,ppufile);
 
 
         size:=ppufile.getlongint;
         size:=ppufile.getlongint;
-        may_be_in_reg:=boolean(ppufile.getbyte);
         new(tempinfo);
         new(tempinfo);
         fillchar(tempinfo^,sizeof(tempinfo^),0);
         fillchar(tempinfo^,sizeof(tempinfo^),0);
+        tempinfo^.may_be_in_reg:=boolean(ppufile.getbyte);
         ppufile.gettype(tempinfo^.restype);
         ppufile.gettype(tempinfo^.restype);
         tempinfo^.temptype := ttemptype(ppufile.getbyte);
         tempinfo^.temptype := ttemptype(ppufile.getbyte);
         tempinfo^.owner:=self;
         tempinfo^.owner:=self;
@@ -736,7 +734,7 @@ implementation
       begin
       begin
         inherited ppuwrite(ppufile);
         inherited ppuwrite(ppufile);
         ppufile.putlongint(size);
         ppufile.putlongint(size);
-        ppufile.putbyte(byte(may_be_in_reg));
+        ppufile.putbyte(byte(tempinfo^.may_be_in_reg));
         ppufile.puttype(tempinfo^.restype);
         ppufile.puttype(tempinfo^.restype);
         ppufile.putbyte(byte(tempinfo^.temptype));
         ppufile.putbyte(byte(tempinfo^.temptype));
       end;
       end;
@@ -772,7 +770,7 @@ implementation
         result :=
         result :=
           inherited docompare(p) and
           inherited docompare(p) and
           (ttempcreatenode(p).size = size) and
           (ttempcreatenode(p).size = size) and
-          (ttempcreatenode(p).may_be_in_reg = may_be_in_reg) and
+          (ttempcreatenode(p).tempinfo^.may_be_in_reg = tempinfo^.may_be_in_reg) and
           equal_defs(ttempcreatenode(p).tempinfo^.restype.def,tempinfo^.restype.def);
           equal_defs(ttempcreatenode(p).tempinfo^.restype.def,tempinfo^.restype.def);
       end;
       end;
 
 
@@ -863,7 +861,17 @@ implementation
 
 
     function ttemprefnode.pass_1 : tnode;
     function ttemprefnode.pass_1 : tnode;
       begin
       begin
-        expectloc:=LOC_REFERENCE;
+        expectloc := LOC_REFERENCE;
+        if tempinfo^.may_be_in_reg then
+          begin
+            if (tempinfo^.temptype = tt_persistent) then
+              begin
+                { !!tell rgobj this register is now a regvar, so it can't be freed!! }
+                expectloc := LOC_CREGISTER
+              end
+            else
+              expectloc := LOC_REGISTER;
+          end;
         result := nil;
         result := nil;
       end;
       end;
 
 
@@ -1005,7 +1013,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.80  2004-02-06 20:22:58  jonas
+  Revision 1.81  2004-03-10 20:41:17  peter
+    * maybe_in_reg moved to tempinfo
+    * fixed expectloc for maybe_in_reg
+
+  Revision 1.80  2004/02/06 20:22:58  jonas
     * don't put types that need init/fini in register temps
     * don't put types that need init/fini in register temps
 
 
   Revision 1.79  2004/02/03 22:32:54  peter
   Revision 1.79  2004/02/03 22:32:54  peter

+ 6 - 2
compiler/ncgbas.pas

@@ -358,7 +358,7 @@ interface
             tg.GetTempTyped(exprasmlist,tempinfo^.restype.def,tempinfo^.temptype,tempinfo^.loc.ref);
             tg.GetTempTyped(exprasmlist,tempinfo^.restype.def,tempinfo^.temptype,tempinfo^.loc.ref);
             tempinfo^.loc.loc := LOC_REFERENCE;
             tempinfo^.loc.loc := LOC_REFERENCE;
           end
           end
-        else if may_be_in_reg then
+        else if tempinfo^.may_be_in_reg then
           begin
           begin
             cgsize := def_cgsize(tempinfo^.restype.def);
             cgsize := def_cgsize(tempinfo^.restype.def);
             if (TCGSize2Size[cgsize]>TCGSize2Size[OS_INT]) then
             if (TCGSize2Size[cgsize]>TCGSize2Size[OS_INT]) then
@@ -475,7 +475,11 @@ begin
 end.
 end.
 {
 {
   $Log$
   $Log$
-  Revision 1.58  2004-03-02 17:32:12  florian
+  Revision 1.59  2004-03-10 20:41:17  peter
+    * maybe_in_reg moved to tempinfo
+    * fixed expectloc for maybe_in_reg
+
+  Revision 1.58  2004/03/02 17:32:12  florian
     * make cycle fixed
     * make cycle fixed
     + pic support for darwin
     + pic support for darwin
     + support of importing vars from shared libs on darwin implemented
     + support of importing vars from shared libs on darwin implemented