Browse Source

+ gethltemp() to allocate a temp specifying full type information even
for regular temps. This is required for targets that need special
handling of the temps depending on the type
* converted most gettemp() calls to gethltemp() calls

git-svn-id: branches/jvmbackend@18376 -

Jonas Maebe 14 years ago
parent
commit
0e87627218

+ 7 - 7
compiler/hlcgobj.pas

@@ -595,10 +595,10 @@ implementation
 *)
 *)
          LOC_FPUREGISTER,LOC_CFPUREGISTER:
          LOC_FPUREGISTER,LOC_CFPUREGISTER:
            begin
            begin
-             tg.GetTemp(list,size.size,size.alignment,tt_normal,ref);
+             tg.gethltemp(list,size,size.size,tt_normal,ref);
              a_load_reg_ref(list,size,size,r,ref);
              a_load_reg_ref(list,size,size,r,ref);
              a_loadfpu_ref_cgpara(list,size,ref,cgpara);
              a_loadfpu_ref_cgpara(list,size,ref,cgpara);
-             tg.Ungettemp(list,ref);
+             tg.ungettemp(list,ref);
            end
            end
          else
          else
            internalerror(2010120415);
            internalerror(2010120415);
@@ -1039,7 +1039,7 @@ implementation
           LOC_REGISTER,LOC_CREGISTER:
           LOC_REGISTER,LOC_CREGISTER:
             begin
             begin
               { paramfpu_ref does the check_simpe_location check here if necessary }
               { paramfpu_ref does the check_simpe_location check here if necessary }
-              tg.GetTemp(list,fromsize.size,fromsize.alignment,tt_normal,ref);
+              tg.gethltemp(list,fromsize,fromsize.size,tt_normal,ref);
               a_loadfpu_reg_ref(list,fromsize,fromsize,r,ref);
               a_loadfpu_reg_ref(list,fromsize,fromsize,r,ref);
               a_loadfpu_ref_cgpara(list,fromsize,ref,cgpara);
               a_loadfpu_ref_cgpara(list,fromsize,ref,cgpara);
               tg.Ungettemp(list,ref);
               tg.Ungettemp(list,ref);
@@ -1676,7 +1676,7 @@ implementation
         LOC_FPUREGISTER,
         LOC_FPUREGISTER,
         LOC_CFPUREGISTER :
         LOC_CFPUREGISTER :
           begin
           begin
-            tg.GetTemp(list,TCGSize2Size[l.size],TCGSize2Size[l.size],tt_normal,r);
+            tg.gethltemp(list,size,size.size,tt_normal,r);
             hlcg.a_loadfpu_reg_ref(list,size,size,l.register,r);
             hlcg.a_loadfpu_reg_ref(list,size,size,l.register,r);
             location_reset_ref(l,LOC_REFERENCE,l.size,0);
             location_reset_ref(l,LOC_REFERENCE,l.size,0);
             l.reference:=r;
             l.reference:=r;
@@ -1685,7 +1685,7 @@ implementation
         LOC_MMREGISTER,
         LOC_MMREGISTER,
         LOC_CMMREGISTER:
         LOC_CMMREGISTER:
           begin
           begin
-            tg.GetTemp(list,TCGSize2Size[l.size],TCGSize2Size[l.size],tt_normal,r);
+            tg.gethltemp(list,size,size.size,tt_normal,r);
             cg.a_loadmm_reg_ref(list,l.size,l.size,l.register,r,mms_movescalar);
             cg.a_loadmm_reg_ref(list,l.size,l.size,l.register,r,mms_movescalar);
             location_reset_ref(l,LOC_REFERENCE,l.size,0);
             location_reset_ref(l,LOC_REFERENCE,l.size,0);
             l.reference:=r;
             l.reference:=r;
@@ -1695,7 +1695,7 @@ implementation
         LOC_REGISTER,
         LOC_REGISTER,
         LOC_CREGISTER :
         LOC_CREGISTER :
           begin
           begin
-            tg.GetTemp(list,TCGSize2Size[l.size],TCGSize2Size[l.size],tt_normal,r);
+            tg.gethltemp(list,size,size.size,tt_normal,r);
             hlcg.a_load_loc_ref(list,size,size,l,r);
             hlcg.a_load_loc_ref(list,size,size,l,r);
             location_reset_ref(l,LOC_REFERENCE,l.size,0);
             location_reset_ref(l,LOC_REFERENCE,l.size,0);
             l.reference:=r;
             l.reference:=r;
@@ -1706,7 +1706,7 @@ implementation
         LOC_SUBSETREF,
         LOC_SUBSETREF,
         LOC_CSUBSETREF:
         LOC_CSUBSETREF:
           begin
           begin
-            tg.GetTemp(list,TCGSize2Size[l.size],TCGSize2Size[l.size],tt_normal,r);
+            tg.gethltemp(list,size,size.size,tt_normal,r);
             cg.a_load_loc_ref(list,l.size,l,r);
             cg.a_load_loc_ref(list,l.size,l,r);
             location_reset_ref(l,LOC_REFERENCE,l.size,0);
             location_reset_ref(l,LOC_REFERENCE,l.size,0);
             l.reference:=r;
             l.reference:=r;

+ 1 - 1
compiler/jvm/njvmcal.pas

@@ -80,7 +80,7 @@ implementation
     procedure tjvmcallnode.set_result_location(realresdef: tstoreddef);
     procedure tjvmcallnode.set_result_location(realresdef: tstoreddef);
       begin
       begin
         location_reset_ref(location,LOC_REFERENCE,def_cgsize(realresdef),1);
         location_reset_ref(location,LOC_REFERENCE,def_cgsize(realresdef),1);
-        tg.gettemp(current_asmdata.CurrAsmList,realresdef.size,1,tt_normal,location.reference);
+        tg.gethltemp(current_asmdata.CurrAsmList,realresdef,realresdef.size,tt_normal,location.reference);
       end;
       end;
 
 
 
 

+ 1 - 1
compiler/ncgbas.pas

@@ -411,7 +411,7 @@ interface
         else
         else
           begin
           begin
             location_reset_ref(tempinfo^.location,LOC_REFERENCE,def_cgsize(tempinfo^.typedef),0);
             location_reset_ref(tempinfo^.location,LOC_REFERENCE,def_cgsize(tempinfo^.typedef),0);
-            tg.GetTemp(current_asmdata.CurrAsmList,size,tempinfo^.typedef.alignment,tempinfo^.temptype,tempinfo^.location.reference);
+            tg.gethltemp(current_asmdata.CurrAsmList,tempinfo^.typedef,size,tempinfo^.temptype,tempinfo^.location.reference);
           end;
           end;
         include(tempinfo^.flags,ti_valid);
         include(tempinfo^.flags,ti_valid);
         if assigned(tempinfo^.tempinitcode) then
         if assigned(tempinfo^.tempinitcode) then

+ 1 - 1
compiler/ncgcal.pas

@@ -317,7 +317,7 @@ implementation
         else
         else
           begin
           begin
             location_reset_ref(location,LOC_REFERENCE,def_cgsize(realresdef),0);
             location_reset_ref(location,LOC_REFERENCE,def_cgsize(realresdef),0);
-            tg.GetTemp(current_asmdata.CurrAsmList,retloc.intsize,retloc.Alignment,tt_normal,location.reference);
+            tg.gethltemp(current_asmdata.CurrAsmList,realresdef,retloc.intsize,tt_normal,location.reference);
           end;
           end;
       end;
       end;
 
 

+ 4 - 4
compiler/ncgcnv.pas

@@ -364,7 +364,7 @@ interface
          case tstringdef(resultdef).stringtype of
          case tstringdef(resultdef).stringtype of
            st_shortstring :
            st_shortstring :
              begin
              begin
-               tg.GetTemp(current_asmdata.CurrAsmList,256,2,tt_normal,location.reference);
+               tg.gethltemp(current_asmdata.CurrAsmList,cshortstringtype,256,tt_normal,location.reference);
                cg.a_load_loc_ref(current_asmdata.CurrAsmList,left.location.size,left.location,
                cg.a_load_loc_ref(current_asmdata.CurrAsmList,left.location.size,left.location,
                  location.reference);
                  location.reference);
                location_freetemp(current_asmdata.CurrAsmList,left.location);
                location_freetemp(current_asmdata.CurrAsmList,left.location);
@@ -393,7 +393,7 @@ interface
              if (left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
              if (left.location.loc in [LOC_CREFERENCE,LOC_REFERENCE]) then
                location_force_fpureg(current_asmdata.CurrAsmList,left.location,false);
                location_force_fpureg(current_asmdata.CurrAsmList,left.location,false);
              { round them down to the proper precision }
              { round them down to the proper precision }
-             tg.gettemp(current_asmdata.currasmlist,resultdef.size,resultdef.alignment,tt_normal,tr);
+             tg.gethltemp(current_asmdata.currasmlist,resultdef,resultdef.size,tt_normal,tr);
              cg.a_loadfpu_reg_ref(current_asmdata.CurrAsmList,left.location.size,location.size,left.location.register,tr);
              cg.a_loadfpu_reg_ref(current_asmdata.CurrAsmList,left.location.size,location.size,left.location.register,tr);
              location_reset_ref(left.location,LOC_REFERENCE,location.size,tr.alignment);
              location_reset_ref(left.location,LOC_REFERENCE,location.size,tr.alignment);
              left.location.reference:=tr;
              left.location.reference:=tr;
@@ -494,7 +494,7 @@ interface
                 { assigning a global function to a nested procvar -> create
                 { assigning a global function to a nested procvar -> create
                   tmethodpointer record and set the "frame pointer" to nil }
                   tmethodpointer record and set the "frame pointer" to nil }
                 location_reset_ref(location,LOC_REFERENCE,int_cgsize(sizeof(pint)*2),sizeof(pint));
                 location_reset_ref(location,LOC_REFERENCE,int_cgsize(sizeof(pint)*2),sizeof(pint));
-                tg.gettemp(current_asmdata.CurrAsmList,resultdef.size,sizeof(pint),tt_normal,location.reference);
+                tg.gethltemp(current_asmdata.CurrAsmList,resultdef,resultdef.size,tt_normal,location.reference);
                 tmpreg:=cg.getaddressregister(current_asmdata.CurrAsmList);
                 tmpreg:=cg.getaddressregister(current_asmdata.CurrAsmList);
                 cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,left.location.reference,tmpreg);
                 cg.a_loadaddr_ref_reg(current_asmdata.CurrAsmList,left.location.reference,tmpreg);
                 cg.a_load_reg_ref(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,tmpreg,location.reference);
                 cg.a_load_reg_ref(current_asmdata.CurrAsmList,OS_ADDR,OS_ADDR,tmpreg,location.reference);
@@ -513,7 +513,7 @@ interface
     var r:Treference;
     var r:Treference;
 
 
     begin
     begin
-      tg.gettemp(current_asmdata.currasmlist,2*sizeof(puint),sizeof(puint),tt_normal,r);
+      tg.gethltemp(current_asmdata.currasmlist,methodpointertype,methodpointertype.size,tt_normal,r);
       location_reset_ref(location,LOC_REFERENCE,def_cgsize(resultdef),0);
       location_reset_ref(location,LOC_REFERENCE,def_cgsize(resultdef),0);
       location.reference:=r;
       location.reference:=r;
       cg.a_load_const_ref(current_asmdata.currasmlist,OS_ADDR,0,r);
       cg.a_load_const_ref(current_asmdata.currasmlist,OS_ADDR,0,r);

+ 11 - 11
compiler/ncgld.pas

@@ -460,7 +460,7 @@ implementation
                      {$else}
                      {$else}
                         internalerror(20020520);
                         internalerror(20020520);
                      {$endif} {$endif}
                      {$endif} {$endif}
-                     tg.GetTemp(current_asmdata.CurrAsmList,2*sizeof(pint),sizeof(pint),tt_normal,location.reference);
+                     tg.gethltemp(current_asmdata.CurrAsmList,methodpointertype,methodpointertype.size,tt_normal,location.reference);
                      secondpass(left);
                      secondpass(left);
 
 
                      { load class instance/classrefdef address }
                      { load class instance/classrefdef address }
@@ -810,7 +810,7 @@ implementation
                             { convert an extended into a double/single, since sse   }
                             { convert an extended into a double/single, since sse   }
                             { doesn't support extended)                             }
                             { doesn't support extended)                             }
                             r:=cg.getfpuregister(current_asmdata.CurrAsmList,right.location.size);
                             r:=cg.getfpuregister(current_asmdata.CurrAsmList,right.location.size);
-                            tg.gettemp(current_asmdata.CurrAsmList,left.resultdef.size,left.resultdef.alignment,tt_normal,href);
+                            tg.gethltemp(current_asmdata.CurrAsmList,left.resultdef,left.resultdef.size,tt_normal,href);
                             cg.a_loadfpu_ref_reg(current_asmdata.CurrAsmList,right.location.size,right.location.size,right.location.reference,r);
                             cg.a_loadfpu_ref_reg(current_asmdata.CurrAsmList,right.location.size,right.location.size,right.location.reference,r);
                             cg.a_loadfpu_reg_ref(current_asmdata.CurrAsmList,right.location.size,left.location.size,r,href);
                             cg.a_loadfpu_reg_ref(current_asmdata.CurrAsmList,right.location.size,left.location.size,r,href);
                             if releaseright then
                             if releaseright then
@@ -894,7 +894,7 @@ implementation
                         begin
                         begin
                           { perform size conversion if needed (the mm-code cannot convert an   }
                           { perform size conversion if needed (the mm-code cannot convert an   }
                           { extended into a double/single, since sse doesn't support extended) }
                           { extended into a double/single, since sse doesn't support extended) }
-                          tg.gettemp(current_asmdata.CurrAsmList,left.resultdef.size,left.resultdef.alignment,tt_normal,href);
+                          tg.gethltemp(current_asmdata.CurrAsmList,left.resultdef, left.resultdef.size,tt_normal,href);
                           cg.a_loadfpu_reg_ref(current_asmdata.CurrAsmList,right.location.size,left.location.size,right.location.register,href);
                           cg.a_loadfpu_reg_ref(current_asmdata.CurrAsmList,right.location.size,left.location.size,right.location.register,href);
                           location_reset_ref(right.location,LOC_REFERENCE,left.location.size,0);
                           location_reset_ref(right.location,LOC_REFERENCE,left.location.size,0);
                           right.location.reference:=href;
                           right.location.reference:=href;
@@ -1016,8 +1016,8 @@ implementation
         otlabel,
         otlabel,
         oflabel : tasmlabel;
         oflabel : tasmlabel;
         vtype : longint;
         vtype : longint;
-        elesize,
-        elealign : longint;
+        eledef: tdef;
+        elesize : longint;
         tmpreg  : tregister;
         tmpreg  : tregister;
         vaddr : boolean;
         vaddr : boolean;
         freetemp,
         freetemp,
@@ -1028,23 +1028,23 @@ implementation
         dovariant:=(nf_forcevaria in flags) or is_variant_array(resultdef);
         dovariant:=(nf_forcevaria in flags) or is_variant_array(resultdef);
         if dovariant then
         if dovariant then
           begin
           begin
-            elesize:=sizeof(pint)+sizeof(pint);
-            elealign:=sizeof(pint);
+            eledef:=search_system_type('TVARREC').typedef;
+            elesize:=eledef.size;
           end
           end
         else
         else
           begin
           begin
+            eledef:=tarraydef(resultdef).elementdef;
             elesize:=tarraydef(resultdef).elesize;
             elesize:=tarraydef(resultdef).elesize;
-            elealign:=tarraydef(resultdef).elementdef.alignment;
           end;
           end;
-        { alignment is filled in by tg.gettemp below }
+        { alignment is filled in by tg.gethltemp below }
         location_reset_ref(location,LOC_CREFERENCE,OS_NO,0);
         location_reset_ref(location,LOC_CREFERENCE,OS_NO,0);
         fillchar(paraloc,sizeof(paraloc),0);
         fillchar(paraloc,sizeof(paraloc),0);
         { Allocate always a temp, also if no elements are required, to
         { Allocate always a temp, also if no elements are required, to
           be sure that location is valid (PFV) }
           be sure that location is valid (PFV) }
          if tarraydef(resultdef).highrange=-1 then
          if tarraydef(resultdef).highrange=-1 then
-           tg.GetTemp(current_asmdata.CurrAsmList,elesize,elealign,tt_normal,location.reference)
+           tg.gethltemp(current_asmdata.CurrAsmList,eledef,elesize,tt_normal,location.reference)
          else
          else
-           tg.GetTemp(current_asmdata.CurrAsmList,(tarraydef(resultdef).highrange+1)*elesize,resultdef.alignment,tt_normal,location.reference);
+           tg.gethltemp(current_asmdata.CurrAsmList,eledef,(tarraydef(resultdef).highrange+1)*elesize,tt_normal,location.reference);
          href:=location.reference;
          href:=location.reference;
         { Process nodes in array constructor }
         { Process nodes in array constructor }
         hp:=self;
         hp:=self;

+ 1 - 1
compiler/ncgopt.pas

@@ -90,7 +90,7 @@ begin
   if not(tg.istemp(left.location.reference) and
   if not(tg.istemp(left.location.reference) and
          (tg.sizeoftemp(current_asmdata.CurrAsmList,left.location.reference) = 256)) then
          (tg.sizeoftemp(current_asmdata.CurrAsmList,left.location.reference) = 256)) then
     begin
     begin
-       tg.Gettemp(current_asmdata.CurrAsmList,256,1,tt_normal,href);
+       tg.gethltemp(current_asmdata.CurrAsmList,cshortstringtype,256,tt_normal,href);
        cg.g_copyshortstring(current_asmdata.CurrAsmList,left.location.reference,href,255);
        cg.g_copyshortstring(current_asmdata.CurrAsmList,left.location.reference,href,255);
        location_freetemp(current_asmdata.CurrAsmList,left.location);
        location_freetemp(current_asmdata.CurrAsmList,left.location);
        { return temp reference }
        { return temp reference }

+ 4 - 1
compiler/paramgr.pas

@@ -390,7 +390,10 @@ implementation
                     duplicatecgparaloc(paraloc,newparaloc)
                     duplicatecgparaloc(paraloc,newparaloc)
                   else
                   else
                     begin
                     begin
-                      tg.gettemp(list,len,cgpara.alignment,tt_persistent,href);
+                      if assigned(cgpara.def) then
+                        tg.gethltemp(list,cgpara.def,len,tt_persistent,href)
+                      else
+                        tg.gettemp(list,len,cgpara.alignment,tt_persistent,href);
                       newparaloc^.reference.index:=href.base;
                       newparaloc^.reference.index:=href.base;
                       newparaloc^.reference.offset:=href.offset;
                       newparaloc^.reference.offset:=href.offset;
                     end;
                     end;

+ 13 - 0
compiler/tgobj.pas

@@ -80,6 +80,13 @@ unit tgobj;
           }
           }
           procedure setfirsttemp(l : longint); virtual;
           procedure setfirsttemp(l : longint); virtual;
 
 
+          { version of gettemp that is compatible with hlcg-based targets;
+            always use in common code, only use gettemp in cgobj and
+            architecture-specific backends.
+
+            the forcesize parameter is so that it can be used for defs that
+            don't have an inherent size (e.g., array of const) }
+          procedure gethltemp(list: TAsmList; def: tdef; forcesize: aint; temptype: ttemptype; out ref: treference);
           procedure gettemp(list: TAsmList; size, alignment : longint;temptype:ttemptype;out ref : treference);
           procedure gettemp(list: TAsmList; size, alignment : longint;temptype:ttemptype;out ref : treference);
           procedure gettemptyped(list: TAsmList; def:tdef;temptype:ttemptype;out ref : treference);
           procedure gettemptyped(list: TAsmList; def:tdef;temptype:ttemptype;out ref : treference);
           procedure ungettemp(list: TAsmList; const ref : treference);
           procedure ungettemp(list: TAsmList; const ref : treference);
@@ -495,6 +502,12 @@ implementation
       end;
       end;
 
 
 
 
+    procedure ttgobj.gethltemp(list: TAsmList; def: tdef; forcesize: aint; temptype: ttemptype; out ref: treference);
+      begin
+        gettemp(list,forcesize,def.alignment,temptype,ref);
+      end;
+
+
     procedure ttgobj.gettemp(list: TAsmList; size, alignment : longint;temptype:ttemptype;out ref : treference);
     procedure ttgobj.gettemp(list: TAsmList; size, alignment : longint;temptype:ttemptype;out ref : treference);
       var
       var
         varalign : shortint;
         varalign : shortint;