Bladeren bron

* a_load_loc_reg now has an extra size parameter for the destination
register (properly fixes what I worked around in revision 1.106 of
ncgutil.pas)

Jonas Maebe 22 jaren geleden
bovenliggende
commit
e7e2cfe9a4
8 gewijzigde bestanden met toevoegingen van 90 en 46 verwijderingen
  1. 7 2
      compiler/cg64f64.pas
  2. 9 4
      compiler/cgobj.pas
  3. 12 7
      compiler/i386/n386add.pas
  4. 7 2
      compiler/i386/n386inl.pas
  5. 9 4
      compiler/ncgmat.pas
  6. 11 6
      compiler/ncgmem.pas
  7. 7 2
      compiler/ncgset.pas
  8. 28 19
      compiler/ncgutil.pas

+ 7 - 2
compiler/cg64f64.pas

@@ -110,7 +110,7 @@ unit cg64f64;
 
     procedure tcg64f64.a_load64_loc_reg(list : taasmoutput;const l : tlocation;reg : tregister64);
       begin
-         cg.a_load_loc_reg(list,l,reg);
+         cg.a_load_loc_reg(list,l.size,l,reg);
       end;
 
     procedure tcg64f64.a_load64_loc_ref(list : taasmoutput;const l : tlocation;const ref : treference);
@@ -225,7 +225,12 @@ unit cg64f64;
 end.
 {
   $Log$
-  Revision 1.6  2003-01-05 13:36:53  florian
+  Revision 1.7  2003-05-30 23:49:18  jonas
+    * a_load_loc_reg now has an extra size parameter for the destination
+      register (properly fixes what I worked around in revision 1.106 of
+      ncgutil.pas)
+
+  Revision 1.6  2003/01/05 13:36:53  florian
     * x86-64 compiles
     + very basic support for float128 type (x86-64 only)
 

+ 9 - 4
compiler/cgobj.pas

@@ -198,7 +198,7 @@ unit cgobj;
           procedure a_load_reg_loc(list : taasmoutput;size : tcgsize;reg : tregister;const loc: tlocation);
           procedure a_load_ref_reg(list : taasmoutput;size : tcgsize;const ref : treference;register : tregister);virtual; abstract;
           procedure a_load_ref_ref(list : taasmoutput;size : tcgsize;const sref : treference;const dref : treference);virtual;
-          procedure a_load_loc_reg(list : taasmoutput;const loc: tlocation; reg : tregister);
+          procedure a_load_loc_reg(list : taasmoutput; dstsize: tcgsize; const loc: tlocation; reg : tregister);
           procedure a_load_loc_ref(list : taasmoutput;const loc: tlocation; const ref : treference);
           procedure a_loadaddr_ref_reg(list : taasmoutput;const ref : treference;r : tregister);virtual; abstract;
 
@@ -832,14 +832,14 @@ unit cgobj;
       end;
 
 
-    procedure tcg.a_load_loc_reg(list : taasmoutput;const loc: tlocation; reg : tregister);
+    procedure tcg.a_load_loc_reg(list : taasmoutput; dstsize: tcgsize; const loc: tlocation; reg : tregister);
 
       begin
         case loc.loc of
           LOC_REFERENCE,LOC_CREFERENCE:
             a_load_ref_reg(list,loc.size,loc.reference,reg);
           LOC_REGISTER,LOC_CREGISTER:
-            a_load_reg_reg(list,loc.size,loc.size,loc.register,reg);
+            a_load_reg_reg(list,loc.size,dstsize,loc.register,reg);
           LOC_CONSTANT:
             a_load_const_reg(list,loc.size,loc.value,reg);
           else
@@ -1691,7 +1691,12 @@ finalization
 end.
 {
   $Log$
-  Revision 1.101  2003-05-30 21:40:00  jonas
+  Revision 1.102  2003-05-30 23:49:18  jonas
+    * a_load_loc_reg now has an extra size parameter for the destination
+      register (properly fixes what I worked around in revision 1.106 of
+      ncgutil.pas)
+
+  Revision 1.101  2003/05/30 21:40:00  jonas
     * fixed bug in a_load_loc_ref (the source instead of dest size was passed
       to a_load_reg_ref in case of a register)
 

+ 12 - 7
compiler/i386/n386add.pas

@@ -235,7 +235,7 @@ interface
               r.number:=NR_EDI;
               rg.getexplicitregisterint(exprasmlist,NR_EDI);
             {$endif}
-              cg.a_load_loc_reg(exprasmlist,right.location,r);
+              cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,r);
               emit_reg_reg(op,opsize,left.location.register,r);
               emit_reg_reg(A_MOV,opsize,r,left.location.register);
               rg.ungetregisterint(exprasmlist,r);
@@ -285,7 +285,7 @@ interface
                         r.enum:=R_INTREGISTER;
                         r.number:=NR_EDI;
                      {$endif}
-                        cg.a_load_loc_reg(exprasmlist,right.location,r);
+                        cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,r);
                         emit_reg(A_NOT,S_L,r);
                         emit_reg_reg(A_AND,S_L,r,left.location.register);
                         rg.ungetregisterint(exprasmlist,r);
@@ -1298,14 +1298,14 @@ interface
       {Get a temp register and load the left value into it
        and free the location.}
       r:=rg.getregisterint(exprasmlist,OS_INT);
-      cg.a_load_loc_reg(exprasmlist,left.location,r);
+      cg.a_load_loc_reg(exprasmlist,OS_INT,left.location,r);
       location_release(exprasmlist,left.location);
       {Allocate EAX.}
       rg.getexplicitregisterint(exprasmlist,NR_EAX);
       r_eax.enum:=R_INTREGISTER;
       r_eax.number:=NR_EAX;
       {Load the right value.}
-      cg.a_load_loc_reg(exprasmlist,right.location,r_eax);
+      cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,r_eax);
       location_release(exprasmlist,right.location);
       {The mul instruction frees register r.}
       rg.ungetregisterint(exprasmlist,r);
@@ -1369,14 +1369,14 @@ interface
       rg.getexplicitregisterint(exprasmlist,NR_EDI);
       { load the left value }
       r.number:=NR_EDI;
-      cg.a_load_loc_reg(exprasmlist,left.location,r);
+      cg.a_load_loc_reg(exprasmlist,OS_INT,left.location,r);
       location_release(exprasmlist,left.location);
       { allocate EAX }
       r.number:=NR_EAX;
       if RS_EAX in rg.unusedregsint then
         exprasmList.concat(tai_regalloc.Alloc(r));
       { load he right value }
-      cg.a_load_loc_reg(exprasmlist,right.location,r);
+      cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,r);
       location_release(exprasmlist,right.location);
       { allocate EAX if it isn't yet allocated (JM) }
       if (RS_EAX in rg.unusedregsint) then
@@ -1607,7 +1607,12 @@ begin
 end.
 {
   $Log$
-  Revision 1.68  2003-05-26 19:38:28  peter
+  Revision 1.69  2003-05-30 23:49:18  jonas
+    * a_load_loc_reg now has an extra size parameter for the destination
+      register (properly fixes what I worked around in revision 1.106 of
+      ncgutil.pas)
+
+  Revision 1.68  2003/05/26 19:38:28  peter
     * generic fpc_shorstr_concat
     + fpc_shortstr_append_shortstr optimization
 

+ 7 - 2
compiler/i386/n386inl.pas

@@ -324,7 +324,7 @@ implementation
                   hregister:=cg.get_scratch_reg_int(exprasmlist,OS_INT);
                 {$endif newra}
                 end;
-              cg.a_load_loc_reg(exprasmlist,tcallparanode(tcallparanode(left).right).left.location,hregister);
+              cg.a_load_loc_reg(exprasmlist,OS_INT,tcallparanode(tcallparanode(left).right).left.location,hregister);
               if (tcallparanode(left).left.location.loc=LOC_REFERENCE) then
                 emit_reg_ref(asmop,S_L,hregister,tcallparanode(left).left.location.reference)
               else
@@ -345,7 +345,12 @@ begin
 end.
 {
   $Log$
-  Revision 1.60  2003-04-23 09:50:31  peter
+  Revision 1.61  2003-05-30 23:49:18  jonas
+    * a_load_loc_reg now has an extra size parameter for the destination
+      register (properly fixes what I worked around in revision 1.106 of
+      ncgutil.pas)
+
+  Revision 1.60  2003/04/23 09:50:31  peter
     * wrong location_copy for include/exclude
 
   Revision 1.59  2003/04/22 23:50:23  peter

+ 9 - 4
compiler/ncgmat.pas

@@ -319,7 +319,7 @@ implementation
                   hdenom := rg.getregisterint(exprasmlist,OS_INT);
                   if right.location.loc<>LOC_CREGISTER then
                    location_release(exprasmlist,right.location);
-                  cg.a_load_loc_reg(exprasmlist,right.location,hdenom);
+                  cg.a_load_loc_reg(exprasmlist,right.location.size,right.location,hdenom);
                   { verify if the divisor is zero, if so return an error
                     immediately
                   }
@@ -395,7 +395,7 @@ implementation
                        if right.location.loc<>LOC_CREGISTER then
                         location_release(exprasmlist,right.location);
                        hcountreg:=cg.get_scratch_reg_int(exprasmlist);
-                       cg.a_load_loc_reg(exprasmlist,right.location,hcountreg);
+                       cg.a_load_loc_reg(exprasmlist,right.location.size,right.location,hcountreg);
                        freescratch := true;
                      end
                    else
@@ -442,7 +442,7 @@ implementation
                        hcountreg:=cg.get_scratch_reg_int(exprasmlist,OS_INT);
                      {$endif}
                        freescratch := true;
-                       cg.a_load_loc_reg(exprasmlist,right.location,hcountreg);
+                       cg.a_load_loc_reg(exprasmlist,right.location.size,right.location,hcountreg);
                      end
                    else
                      hcountreg:=right.location.register;
@@ -467,7 +467,12 @@ begin
 end.
 {
   $Log$
-  Revision 1.10  2003-05-23 14:27:35  peter
+  Revision 1.11  2003-05-30 23:49:18  jonas
+    * a_load_loc_reg now has an extra size parameter for the destination
+      register (properly fixes what I worked around in revision 1.106 of
+      ncgutil.pas)
+
+  Revision 1.10  2003/05/23 14:27:35  peter
     * remove some unit dependencies
     * current_procinfo changes to store more info
 

+ 11 - 6
compiler/ncgmem.pas

@@ -145,7 +145,7 @@ implementation
                     begin
                        location_release(exprasmlist,left.location);
                        reference_reset_base(href,rg.getaddressregister(exprasmlist),tobjectdef(left.resulttype.def).vmt_offset);
-                       cg.a_load_loc_reg(exprasmlist,left.location,href.base);
+                       cg.a_load_loc_reg(exprasmlist,OS_ADDR,left.location,href.base);
                     end;
                   else
                     internalerror(200305057);
@@ -250,7 +250,7 @@ implementation
               begin
                  location_release(exprasmlist,left.location);
                  location.reference.base:=rg.getaddressregister(exprasmlist);
-                 cg.a_load_loc_reg(exprasmlist,left.location,location.reference.base);
+                 cg.a_load_loc_reg(exprasmlist,OS_ADDR,left.location,location.reference.base);
               end;
          end;
          if (cs_gdb_heaptrc in aktglobalswitches) and
@@ -297,7 +297,7 @@ implementation
                   begin
                      location_release(exprasmlist,left.location);
                      location.reference.base:=rg.getaddressregister(exprasmlist);
-                     cg.a_load_loc_reg(exprasmlist,left.location,location.reference.base);
+                     cg.a_load_loc_reg(exprasmlist,OS_ADDR,left.location,location.reference.base);
                   end;
              end;
              { implicit deferencing }
@@ -482,7 +482,7 @@ implementation
                    hreg := cg.get_scratch_reg_int(exprasmlist,OS_INT);
                  {$endif}
                    freereg:=true;
-                   cg.a_load_loc_reg(exprasmlist,right.location,hreg);
+                   cg.a_load_loc_reg(exprasmlist,OS_INT,right.location,hreg);
                  end;
                objectlibrary.getlabel(neglabel);
                objectlibrary.getlabel(poslabel);
@@ -824,7 +824,12 @@ begin
 end.
 {
   $Log$
-  Revision 1.54  2003-05-15 16:10:37  florian
+  Revision 1.55  2003-05-30 23:49:18  jonas
+    * a_load_loc_reg now has an extra size parameter for the destination
+      register (properly fixes what I worked around in revision 1.106 of
+      ncgutil.pas)
+
+  Revision 1.54  2003/05/15 16:10:37  florian
     * fixed getintparaloc call for ansi- and widestring range checking
 
   Revision 1.53  2003/05/11 21:37:03  peter
@@ -1045,4 +1050,4 @@ end.
     * removed unused units
     * use tlocation.size in cg.a_*loc*() routines
 
-}
+}

+ 7 - 2
compiler/ncgset.pas

@@ -610,7 +610,7 @@ implementation
                     pleftreg:=rg.makeregsize(left.location.register,OS_INT)
                   else
                     pleftreg:=rg.getregisterint(exprasmlist,OS_INT);
-                  cg.a_load_loc_reg(exprasmlist,left.location,pleftreg);
+                  cg.a_load_loc_reg(exprasmlist,OS_INT,left.location,pleftreg);
                   location_freetemp(exprasmlist,left.location);
                   location_release(exprasmlist,left.location);
                   cg.a_param_reg(exprasmlist,OS_8,pleftreg,paramanager.getintparaloc(2));
@@ -1121,7 +1121,12 @@ begin
 end.
 {
   $Log$
-  Revision 1.36  2003-05-24 19:48:49  jonas
+  Revision 1.37  2003-05-30 23:49:18  jonas
+    * a_load_loc_reg now has an extra size parameter for the destination
+      register (properly fixes what I worked around in revision 1.106 of
+      ncgutil.pas)
+
+  Revision 1.36  2003/05/24 19:48:49  jonas
     * fixed tcginnode endian bug again, but correcty this time :)
 
   Revision 1.35  2003/05/23 21:10:50  florian

+ 28 - 19
compiler/ncgutil.pas

@@ -338,7 +338,7 @@ implementation
                     cg.a_label(list,hl);
                   end;
                 else
-                  cg.a_load_loc_reg(list,l,hregister);
+                  cg.a_load_loc_reg(list,OS_INT,l,hregister);
               end;
               { reset hi part, take care of the signed bit of the current value }
               hregisterhi:=rg.getregisterint(list,OS_INT);
@@ -451,16 +451,7 @@ implementation
                  if (TCGSize2Size[dst_size]<TCGSize2Size[l.size]) then
                   begin
                     if (l.loc in [LOC_REGISTER,LOC_CREGISTER]) then
-                     begin
-{$ifndef i386}
-                       hregisterhi := l.register;
-{$endif not i386}
-                       l.register.number:=(l.register.number and not $ff) or cgsize2subreg(dst_size);
-{$ifndef i386}
-                       { necessary for all processors that do not have subregisters (JM) }
-                       cg.a_load_reg_reg(list,l.size,dst_size,hregisterhi,l.register);
-{$endif not i386}
-                     end;
+                      l.register.number:=(l.register.number and not $ff) or cgsize2subreg(dst_size);
                     { for big endian systems, the reference's offset must }
                     { be increased in this case, since they have the      }
                     { MSB first in memory and e.g. byte(word_var) should  }
@@ -470,7 +461,7 @@ implementation
                       inc(l.reference.offset,TCGSize2Size[l.size]-TCGSize2Size[dst_size]);
                     l.size:=dst_size;
                   end;
-                 cg.a_load_loc_reg(list,l,hregister);
+                 cg.a_load_loc_reg(list,dst_size,l,hregister);
                  { Release old register when the superregister is changed }
                  if (l.loc=LOC_REGISTER) and
                     (l.register.number shr 8<>hregister.number shr 8) then
@@ -482,7 +473,11 @@ implementation
                    end;
                end;
            end;
-           location_reset(l,LOC_REGISTER,dst_size);
+           if (l.loc <> LOC_CREGISTER) or
+              not maybeconst then
+             location_reset(l,LOC_REGISTER,dst_size)
+           else
+             location_reset(l,LOC_CREGISTER,dst_size);
            l.register:=hregister;
          end;
      end;
@@ -521,7 +516,7 @@ implementation
                     cg.a_label(list,hl);
                   end;
                 else
-                  cg.a_load_loc_reg(list,l,hregister);
+                  cg.a_load_loc_reg(list,OS_INT,l,hregister);
               end;
               location_reset(l,LOC_REGISTER,dst_size);
               l.register:=hregister;
@@ -579,7 +574,7 @@ implementation
                     l.size:=dst_size;
                   end;
 
-                 cg.a_load_loc_reg(list,l,hregister);
+                 cg.a_load_loc_reg(list,dst_size,l,hregister);
                end;
            end;
            location_reset(l,LOC_REGISTER,dst_size);
@@ -1348,13 +1343,22 @@ implementation
                        case hp.paraloc.loc of
                          LOC_CREGISTER,
                          LOC_REGISTER:
-//                         if not(hp.paraloc.size in [OS_S64,OS_64]) then
-                             cg.a_load_reg_reg(list,hp.paraloc.size,OS_32,hp.paraloc.register,tvarsym(hp.parasym).reg);
-//                         else
+                         if not(hp.paraloc.size in [OS_S64,OS_64]) then
+                           cg.a_load_reg_reg(list,hp.paraloc.size,hp.paraloc.size,hp.paraloc.register,tvarsym(hp.parasym).reg)
+                         else
+                           internalerror(2003053011);                
 //                           cg64.a_load64_reg_reg(list,hp.paraloc.register64,tvarsym(hp.parasym).reg);
                          LOC_CFPUREGISTER,
                          LOC_FPUREGISTER:
                            cg.a_loadfpu_reg_reg(list,hp.paraloc.register,tvarsym(hp.parasym).reg);
+                         LOC_REFERENCE,
+                         LOC_CREFERENCE:
+                           begin
+                             reference_reset_base(href,current_procinfo.framepointer,tvarsym(hp.parasym).adjusted_address);
+                             cg.a_load_ref_reg(list,hp.paraloc.size,href,tvarsym(hp.parasym).reg);
+                           end;
+                         else
+                           internalerror(2003053010);
                        end
                      else if (hp.paraloc.loc in [LOC_REGISTER,LOC_FPUREGISTER,LOC_MMREGISTER,
                                                  LOC_CREGISTER,LOC_CFPUREGISTER,LOC_CMMREGISTER]) and
@@ -1904,7 +1908,12 @@ implementation
 end.
 {
   $Log$
-  Revision 1.110  2003-05-30 18:52:10  jonas
+  Revision 1.111  2003-05-30 23:49:18  jonas
+    * a_load_loc_reg now has an extra size parameter for the destination
+      register (properly fixes what I worked around in revision 1.106 of
+      ncgutil.pas)
+
+  Revision 1.110  2003/05/30 18:52:10  jonas
     * fixed bug with intregvars
     * locapara.loc can also be LOC_CFPUREGISTER -> also fixed
       rcgppc.a_param_ref, which previously got bogus size values