Browse Source

* changed boolean fields in ttempinfo to a set for easier
extensibility without increasing the size of the record

git-svn-id: trunk@8199 -

Jonas Maebe 18 years ago
parent
commit
fc70aa545c
6 changed files with 53 additions and 52 deletions
  1. 2 2
      compiler/htypechk.pas
  2. 35 34
      compiler/nbas.pas
  3. 11 11
      compiler/ncgbas.pas
  4. 1 1
      compiler/ncgld.pas
  5. 3 3
      compiler/ncgutil.pas
  6. 1 1
      compiler/ppu.pas

+ 2 - 2
compiler/htypechk.pas

@@ -696,10 +696,10 @@ implementation
                 else
                 else
                   tabstractvarsym(tloadnode(p).symtableentry).varregable:=vr_none;
                   tabstractvarsym(tloadnode(p).symtableentry).varregable:=vr_none;
             temprefn :
             temprefn :
-              if (ttemprefnode(p).tempinfo^.may_be_in_reg) and
+              if (ti_may_be_in_reg in ttemprefnode(p).tempinfo^.flags) and
                  ((not records_only) or
                  ((not records_only) or
                   (ttemprefnode(p).tempinfo^.typedef.typ = recorddef)) then
                   (ttemprefnode(p).tempinfo^.typedef.typ = recorddef)) then
-                ttemprefnode(p).tempinfo^.may_be_in_reg:=false;
+                exclude(ttemprefnode(p).tempinfo^.flags,ti_may_be_in_reg);
          end;
          end;
       end;
       end;
 
 

+ 35 - 34
compiler/nbas.pas

@@ -94,6 +94,13 @@ interface
 
 
        ttempcreatenode = class;
        ttempcreatenode = class;
 
 
+       ttempinfoflag = (ti_may_be_in_reg,ti_valid,ti_nextref_set_hookoncopy_nil,ti_is_inlined_result);
+       ttempinfoflags = set of ttempinfoflag;
+
+const
+       tempinfostoreflags = [ti_may_be_in_reg,ti_is_inlined_result];
+
+type
        { 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                                    }
@@ -108,10 +115,7 @@ interface
          owner                      : ttempcreatenode;
          owner                      : ttempcreatenode;
          withnode                   : tnode;
          withnode                   : tnode;
          location                   : tlocation;
          location                   : tlocation;
-         may_be_in_reg              : boolean;
-         valid                      : boolean;
-         nextref_set_hookoncopy_nil : boolean;
-         is_inlined_result          : boolean;
+         flags                      : ttempinfoflags;
        end;
        end;
 
 
        { a node which will create a (non)persistent temp of a given type with a given  }
        { a node which will create a (non)persistent temp of a given type with a given  }
@@ -716,19 +720,19 @@ implementation
         tempinfo^.temptype := _temptype;
         tempinfo^.temptype := _temptype;
         tempinfo^.owner := self;
         tempinfo^.owner := self;
         tempinfo^.withnode := nil;
         tempinfo^.withnode := nil;
-        tempinfo^.may_be_in_reg:=
-          allowreg and
-          { temp must fit a single register }
-          (tstoreddef(_typedef).is_fpuregable or
-           (tstoreddef(_typedef).is_intregable and
-            (_size<=TCGSize2Size[OS_64]))) and
-          { size of register operations must be known }
-          (def_cgsize(_typedef)<>OS_NO) and
-          { no init/final needed }
-          not (_typedef.needs_inittable) and
-          ((_typedef.typ <> pointerdef) or
-           (is_object(tpointerdef(_typedef).pointeddef) or
-            not tpointerdef(_typedef).pointeddef.needs_inittable));
+        if allowreg and
+           { temp must fit a single register }
+           (tstoreddef(_typedef).is_fpuregable or
+            (tstoreddef(_typedef).is_intregable and
+             (_size<=TCGSize2Size[OS_64]))) and
+           { size of register operations must be known }
+           (def_cgsize(_typedef)<>OS_NO) and
+           { no init/final needed }
+           not (_typedef.needs_inittable) and
+           ((_typedef.typ <> pointerdef) or
+            (is_object(tpointerdef(_typedef).pointeddef) or
+             not tpointerdef(_typedef).pointeddef.needs_inittable)) then
+          include(tempinfo^.flags,ti_may_be_in_reg);
       end;
       end;
 
 
     constructor ttempcreatenode.create_withnode(_typedef: tdef; _size: aint; _temptype: ttemptype; allowreg:boolean; withnode: tnode);
     constructor ttempcreatenode.create_withnode(_typedef: tdef; _size: aint; _temptype: ttemptype; allowreg:boolean; withnode: tnode);
@@ -741,7 +745,7 @@ implementation
     constructor ttempcreatenode.create_inlined_result(_typedef: tdef; _size: aint; _temptype: ttemptype; allowreg:boolean);
     constructor ttempcreatenode.create_inlined_result(_typedef: tdef; _size: aint; _temptype: ttemptype; allowreg:boolean);
       begin
       begin
         self.create(_typedef,_size,_temptype,allowreg);
         self.create(_typedef,_size,_temptype,allowreg);
-        tempinfo^.is_inlined_result:=true;
+        include(tempinfo^.flags,ti_is_inlined_result);
       end;
       end;
 
 
 
 
@@ -757,8 +761,7 @@ implementation
         n.tempinfo^.owner:=n;
         n.tempinfo^.owner:=n;
         n.tempinfo^.typedef := tempinfo^.typedef;
         n.tempinfo^.typedef := tempinfo^.typedef;
         n.tempinfo^.temptype := tempinfo^.temptype;
         n.tempinfo^.temptype := tempinfo^.temptype;
-        n.tempinfo^.may_be_in_reg := tempinfo^.may_be_in_reg;
-        n.tempinfo^.is_inlined_result := tempinfo^.is_inlined_result;
+        n.tempinfo^.flags := tempinfo^.flags * tempinfostoreflags;
         if assigned(tempinfo^.withnode) then
         if assigned(tempinfo^.withnode) then
           n.tempinfo^.withnode := tempinfo^.withnode.getcopy
           n.tempinfo^.withnode := tempinfo^.withnode.getcopy
         else
         else
@@ -773,7 +776,7 @@ implementation
         { so that if the refs get copied as well, they can hook themselves }
         { so that if the refs get copied as well, they can hook themselves }
         { to the copy of the temp                                          }
         { to the copy of the temp                                          }
         tempinfo^.hookoncopy := n.tempinfo;
         tempinfo^.hookoncopy := n.tempinfo;
-        tempinfo^.nextref_set_hookoncopy_nil := false;
+        exclude(tempinfo^.flags,ti_nextref_set_hookoncopy_nil);
 
 
         result := n;
         result := n;
       end;
       end;
@@ -786,8 +789,7 @@ implementation
         size:=ppufile.getlongint;
         size:=ppufile.getlongint;
         new(tempinfo);
         new(tempinfo);
         fillchar(tempinfo^,sizeof(tempinfo^),0);
         fillchar(tempinfo^,sizeof(tempinfo^),0);
-        tempinfo^.may_be_in_reg:=boolean(ppufile.getbyte);
-        tempinfo^.is_inlined_result:=boolean(ppufile.getbyte);
+        ppufile.getsmallset(tempinfo^.flags);
         ppufile.getderef(tempinfo^.typedefderef);
         ppufile.getderef(tempinfo^.typedefderef);
         tempinfo^.temptype := ttemptype(ppufile.getbyte);
         tempinfo^.temptype := ttemptype(ppufile.getbyte);
         tempinfo^.owner:=self;
         tempinfo^.owner:=self;
@@ -799,8 +801,7 @@ implementation
       begin
       begin
         inherited ppuwrite(ppufile);
         inherited ppuwrite(ppufile);
         ppufile.putlongint(size);
         ppufile.putlongint(size);
-        ppufile.putbyte(byte(tempinfo^.may_be_in_reg));
-        ppufile.putbyte(byte(tempinfo^.is_inlined_result));
+        ppufile.putsmallset(tempinfo^.flags);
         ppufile.putderef(tempinfo^.typedefderef);
         ppufile.putderef(tempinfo^.typedefderef);
         ppufile.putbyte(byte(tempinfo^.temptype));
         ppufile.putbyte(byte(tempinfo^.temptype));
         ppuwritenode(ppufile,tempinfo^.withnode);
         ppuwritenode(ppufile,tempinfo^.withnode);
@@ -859,8 +860,7 @@ implementation
         result :=
         result :=
           inherited docompare(p) and
           inherited docompare(p) and
           (ttempcreatenode(p).size = size) and
           (ttempcreatenode(p).size = size) and
-          (ttempcreatenode(p).tempinfo^.may_be_in_reg = tempinfo^.may_be_in_reg) and
-          (ttempcreatenode(p).tempinfo^.is_inlined_result = tempinfo^.is_inlined_result) and
+          (ttempcreatenode(p).tempinfo^.flags*tempinfostoreflags=tempinfo^.flags*tempinfostoreflags) and
           (ttempcreatenode(p).tempinfo^.withnode.isequal(tempinfo^.withnode)) and
           (ttempcreatenode(p).tempinfo^.withnode.isequal(tempinfo^.withnode)) and
           equal_defs(ttempcreatenode(p).tempinfo^.typedef,tempinfo^.typedef);
           equal_defs(ttempcreatenode(p).tempinfo^.typedef,tempinfo^.typedef);
       end;
       end;
@@ -909,7 +909,7 @@ implementation
             { from a persistent one into a normal one, we must be  }
             { from a persistent one into a normal one, we must be  }
             { the last reference (since our parent should free the }
             { the last reference (since our parent should free the }
             { temp (JM)                                            }
             { temp (JM)                                            }
-            if (tempinfo^.nextref_set_hookoncopy_nil) then
+            if (ti_nextref_set_hookoncopy_nil in tempinfo^.flags) then
               tempinfo^.hookoncopy := nil;
               tempinfo^.hookoncopy := nil;
           end
           end
         else
         else
@@ -958,7 +958,7 @@ implementation
       begin
       begin
         expectloc := LOC_REFERENCE;
         expectloc := LOC_REFERENCE;
         if not tempinfo^.typedef.needs_inittable and
         if not tempinfo^.typedef.needs_inittable and
-           tempinfo^.may_be_in_reg then
+           (ti_may_be_in_reg in tempinfo^.flags) then
           begin
           begin
             if tempinfo^.typedef.typ=floatdef then
             if tempinfo^.typedef.typ=floatdef then
               begin
               begin
@@ -1034,31 +1034,32 @@ implementation
       var
       var
         n: ttempdeletenode;
         n: ttempdeletenode;
       begin
       begin
-        n := ttempdeletenode(inherited dogetcopy);
-        n.release_to_normal := release_to_normal;
+        n:=ttempdeletenode(inherited dogetcopy);
+        n.release_to_normal:=release_to_normal;
 
 
         if assigned(tempinfo^.hookoncopy) then
         if assigned(tempinfo^.hookoncopy) then
           { if the temp has been copied, assume it becomes a new }
           { if the temp has been copied, assume it becomes a new }
           { temp which has to be hooked by the copied deletenode }
           { temp which has to be hooked by the copied deletenode }
           begin
           begin
             { hook the tempdeletenode to the copied temp }
             { hook the tempdeletenode to the copied temp }
-            n.tempinfo := tempinfo^.hookoncopy;
+            n.tempinfo:=tempinfo^.hookoncopy;
             { the temp shall not be used, reset hookoncopy    }
             { the temp shall not be used, reset hookoncopy    }
             { Only if release_to_normal is false, otherwise   }
             { Only if release_to_normal is false, otherwise   }
             { the temp can still be referenced once more (JM) }
             { the temp can still be referenced once more (JM) }
             if (not release_to_normal) then
             if (not release_to_normal) then
               tempinfo^.hookoncopy:=nil
               tempinfo^.hookoncopy:=nil
             else
             else
-              tempinfo^.nextref_set_hookoncopy_nil := true;
+              include(tempinfo^.flags,ti_nextref_set_hookoncopy_nil);
           end
           end
         else
         else
           { if the temp we refer to hasn't been copied, we have a }
           { if the temp we refer to hasn't been copied, we have a }
           { problem since that means we now have two delete nodes }
           { problem since that means we now have two delete nodes }
           { for one temp                                          }
           { for one temp                                          }
           internalerror(200108234);
           internalerror(200108234);
-        result := n;
+        result:=n;
       end;
       end;
 
 
+
     constructor ttempdeletenode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
     constructor ttempdeletenode.ppuload(t:tnodetype;ppufile:tcompilerppufile);
       begin
       begin
         inherited ppuload(t,ppufile);
         inherited ppuload(t,ppufile);

+ 11 - 11
compiler/ncgbas.pas

@@ -385,7 +385,7 @@ interface
         location_reset(location,LOC_VOID,OS_NO);
         location_reset(location,LOC_VOID,OS_NO);
 
 
         { if we're secondpassing the same tcgtempcreatenode twice, we have a bug }
         { if we're secondpassing the same tcgtempcreatenode twice, we have a bug }
-        if tempinfo^.valid then
+        if (ti_valid in tempinfo^.flags) then
           internalerror(200108222);
           internalerror(200108222);
 
 
         { get a (persistent) temp }
         { get a (persistent) temp }
@@ -397,7 +397,7 @@ interface
               because we're in a loop }
               because we're in a loop }
             cg.g_finalize(current_asmdata.CurrAsmList,tempinfo^.typedef,tempinfo^.location.reference);
             cg.g_finalize(current_asmdata.CurrAsmList,tempinfo^.typedef,tempinfo^.location.reference);
           end
           end
-        else if tempinfo^.may_be_in_reg then
+        else if (ti_may_be_in_reg in tempinfo^.flags) then
           begin
           begin
             if tempinfo^.typedef.typ=floatdef then
             if tempinfo^.typedef.typ=floatdef then
               begin
               begin
@@ -442,7 +442,7 @@ interface
             location_reset(tempinfo^.location,LOC_REFERENCE,def_cgsize(tempinfo^.typedef));
             location_reset(tempinfo^.location,LOC_REFERENCE,def_cgsize(tempinfo^.typedef));
             tg.GetTemp(current_asmdata.CurrAsmList,size,tempinfo^.temptype,tempinfo^.location.reference);
             tg.GetTemp(current_asmdata.CurrAsmList,size,tempinfo^.temptype,tempinfo^.location.reference);
           end;
           end;
-        tempinfo^.valid := true;
+        include(tempinfo^.flags,ti_valid);
       end;
       end;
 
 
 
 
@@ -453,19 +453,19 @@ interface
     procedure tcgtemprefnode.pass_generate_code;
     procedure tcgtemprefnode.pass_generate_code;
       begin
       begin
         { check if the temp is valid }
         { check if the temp is valid }
-        if not tempinfo^.valid then
+        if not(ti_valid in tempinfo^.flags) then
           internalerror(200108231);
           internalerror(200108231);
         location:=tempinfo^.location;
         location:=tempinfo^.location;
         case tempinfo^.location.loc of
         case tempinfo^.location.loc of
           LOC_REFERENCE:
           LOC_REFERENCE:
             begin
             begin
               inc(location.reference.offset,offset);
               inc(location.reference.offset,offset);
-              { tempinfo^.valid should be set to false it it's a normal temp }
+              { ti_valid should be excluded if it's a normal temp }
             end;
             end;
           LOC_REGISTER,
           LOC_REGISTER,
           LOC_FPUREGISTER,
           LOC_FPUREGISTER,
           LOC_MMREGISTER :
           LOC_MMREGISTER :
-            tempinfo^.valid := false;
+            exclude(tempinfo^.flags,ti_valid);
         end;
         end;
       end;
       end;
 
 
@@ -473,7 +473,7 @@ interface
     procedure tcgtemprefnode.changelocation(const ref: treference);
     procedure tcgtemprefnode.changelocation(const ref: treference);
       begin
       begin
         { check if the temp is valid }
         { check if the temp is valid }
-        if not tempinfo^.valid then
+        if not(ti_valid in tempinfo^.flags) then
           internalerror(200306081);
           internalerror(200306081);
         if (tempinfo^.location.loc<>LOC_REFERENCE) then
         if (tempinfo^.location.loc<>LOC_REFERENCE) then
           internalerror(2004020203);
           internalerror(2004020203);
@@ -504,7 +504,7 @@ interface
               else
               else
                 begin
                 begin
                   tg.UnGetTemp(current_asmdata.CurrAsmList,tempinfo^.location.reference);
                   tg.UnGetTemp(current_asmdata.CurrAsmList,tempinfo^.location.reference);
-                  tempinfo^.valid := false;
+                  exclude(tempinfo^.flags,ti_valid);
                 end;
                 end;
             end;
             end;
           LOC_CREGISTER,
           LOC_CREGISTER,
@@ -528,7 +528,7 @@ interface
               if release_to_normal then
               if release_to_normal then
                 tempinfo^.location.loc := LOC_REGISTER
                 tempinfo^.location.loc := LOC_REGISTER
               else
               else
-                tempinfo^.valid := false;
+                exclude(tempinfo^.flags,ti_valid);
             end;
             end;
           LOC_CFPUREGISTER,
           LOC_CFPUREGISTER,
           LOC_FPUREGISTER:
           LOC_FPUREGISTER:
@@ -543,7 +543,7 @@ interface
               if release_to_normal then
               if release_to_normal then
                 tempinfo^.location.loc := LOC_FPUREGISTER
                 tempinfo^.location.loc := LOC_FPUREGISTER
               else
               else
-                tempinfo^.valid := false;
+                exclude(tempinfo^.flags,ti_valid);
             end;
             end;
           LOC_CMMREGISTER,
           LOC_CMMREGISTER,
           LOC_MMREGISTER:
           LOC_MMREGISTER:
@@ -558,7 +558,7 @@ interface
               if release_to_normal then
               if release_to_normal then
                 tempinfo^.location.loc := LOC_MMREGISTER
                 tempinfo^.location.loc := LOC_MMREGISTER
               else
               else
-                tempinfo^.valid := false;
+                exclude(tempinfo^.flags,ti_valid);
             end;
             end;
           else
           else
             internalerror(200507161);
             internalerror(200507161);

+ 1 - 1
compiler/ncgld.pas

@@ -104,7 +104,7 @@ implementation
             end;
             end;
           temprefn:
           temprefn:
             begin
             begin
-              if (ttemprefnode(n).tempinfo^.valid) and
+              if (ti_valid in ttemprefnode(n).tempinfo^.flags) and
                  { memory temp... }
                  { memory temp... }
                  (ttemprefnode(n).tempinfo^.location.loc in [LOC_REFERENCE]) and
                  (ttemprefnode(n).tempinfo^.location.loc in [LOC_REFERENCE]) and
                  { ... at the place we are looking for }
                  { ... at the place we are looking for }

+ 3 - 3
compiler/ncgutil.pas

@@ -2378,7 +2378,7 @@ implementation
             { tempinfo^.valid will be false and so we do not add            }
             { tempinfo^.valid will be false and so we do not add            }
             { unnecessary registers. This way, we don't have to look at     }
             { unnecessary registers. This way, we don't have to look at     }
             { tempcreate and tempdestroy nodes to get this info (JM)        }
             { tempcreate and tempdestroy nodes to get this info (JM)        }
-            if (ttemprefnode(n).tempinfo^.valid) then
+            if (ti_valid in ttemprefnode(n).tempinfo^.flags) then
               add_regvars(rv^,ttemprefnode(n).tempinfo^.location);
               add_regvars(rv^,ttemprefnode(n).tempinfo^.location);
           loadn:
           loadn:
             if (tloadnode(n).symtableentry.typ in [staticvarsym,localvarsym,paravarsym]) then
             if (tloadnode(n).symtableentry.typ in [staticvarsym,localvarsym,paravarsym]) then
@@ -2500,10 +2500,10 @@ implementation
             end;
             end;
           temprefn:
           temprefn:
             begin
             begin
-              if (ttemprefnode(n).tempinfo^.valid) and
+              if (ti_valid in ttemprefnode(n).tempinfo^.flags) and
                  (ttemprefnode(n).tempinfo^.location.loc in [LOC_CREGISTER,LOC_CFPUREGISTER,LOC_CMMXREGISTER,LOC_CMMREGISTER]) and
                  (ttemprefnode(n).tempinfo^.location.loc in [LOC_CREGISTER,LOC_CFPUREGISTER,LOC_CMMXREGISTER,LOC_CMMREGISTER]) and
                  (ttemprefnode(n).tempinfo^.location.register = rr^.old) and
                  (ttemprefnode(n).tempinfo^.location.register = rr^.old) and
-                 (not ttemprefnode(n).tempinfo^.is_inlined_result or
+                 (not(ti_is_inlined_result in ttemprefnode(n).tempinfo^.flags) or
                   not(fc_exit in flowcontrol)) then
                   not(fc_exit in flowcontrol)) then
                 begin
                 begin
 {$ifndef cpu64bit}
 {$ifndef cpu64bit}

+ 1 - 1
compiler/ppu.pas

@@ -43,7 +43,7 @@ type
 {$endif Test_Double_checksum}
 {$endif Test_Double_checksum}
 
 
 const
 const
-  CurrentPPUVersion=82;
+  CurrentPPUVersion=83;
 
 
 { buffer sizes }
 { buffer sizes }
   maxentrysize = 1024;
   maxentrysize = 1024;