Browse Source

* patch from Peter for int64 function results

Jonas Maebe 22 years ago
parent
commit
3a35aefdfd
2 changed files with 41 additions and 6 deletions
  1. 11 4
      compiler/ncgcal.pas
  2. 30 2
      compiler/ncgutil.pas

+ 11 - 4
compiler/ncgcal.pas

@@ -482,15 +482,19 @@ implementation
                       location.registerlow:=rg.getregisterint(exprasmlist,OS_INT);
                       location.registerhigh:=rg.getregisterint(exprasmlist,OS_INT);
 {$else newra}
-                      cg.a_reg_alloc(exprasmlist,r);
-                      cg.a_reg_alloc(exprasmlist,hregister);
                       if RS_ACCUMULATOR in rg.unusedregsint then
                         location.registerlow:=rg.getexplicitregisterint(exprasmlist,NR_ACCUMULATOR)
                       else
-                        location.registerlow:=rg.getregisterint(exprasmlist,OS_INT);
+                        cg.a_reg_alloc(exprasmlist,r);
                       if RS_ACCUMULATORHIGH in rg.unusedregsint then
                         location.registerhigh:=rg.getexplicitregisterint(exprasmlist,NR_ACCUMULATORHIGH)
                       else
+                        cg.a_reg_alloc(exprasmlist,hregister);
+                      { do this after both low,high are allocated, else it is possible that
+                        low will be loaded in the register that still contains high }
+                      if location.registerlow.number=NR_NO then
+                        location.registerlow:=rg.getregisterint(exprasmlist,OS_INT);
+                      if location.registerhigh.number=NR_NO then
                         location.registerhigh:=rg.getregisterint(exprasmlist,OS_INT);
 {$endif newra}
                       cg64.a_load64_reg_reg(exprasmlist,joinreg64(r,hregister),
@@ -1125,7 +1129,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.63  2003-05-13 19:14:41  peter
+  Revision 1.64  2003-05-14 19:36:54  jonas
+    * patch from Peter for int64 function results
+
+  Revision 1.63  2003/05/13 19:14:41  peter
     * failn removed
     * inherited result code check moven to pexpr
 

+ 30 - 2
compiler/ncgutil.pas

@@ -410,10 +410,26 @@ implementation
                  (TCGSize2Size[dst_size]=TCGSize2Size[l.size]) then
                hregister:=l.register
               else
-               hregister:=rg.getregisterint(list,OS_INT);
+               begin
+                 hregister.enum:=R_INTREGISTER;
+                 hregister.number:=NR_NO;
+               end;
             end;
            if hregister.enum<>R_INTREGISTER then
             internalerror(200302022);
+           { need to load into address register? }
+           if (dst_size=OS_ADDR) then
+             begin
+               if (hregister.number=NR_NO) or
+                  (not rg.isaddressregister(hregister)) then
+                 hregister:=rg.getaddressregister(list);
+             end
+           else
+             begin
+               if (hregister.number=NR_NO) {or
+                  rg.isaddressregister(hregister)} then
+                 hregister:=rg.getregisterint(list,dst_size);
+             end;
            hregister.number:=(hregister.number and not $ff) or cgsize2subreg(dst_size);
            { load value in new register }
            case l.loc of
@@ -448,6 +464,15 @@ implementation
                     l.size:=dst_size;
                   end;
                  cg.a_load_loc_reg(list,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
+                   begin
+                     if rg.isaddressregister(l.register) then
+                       rg.ungetaddressregister(list,l.register)
+                     else
+                       rg.ungetregisterint(list,l.register);
+                   end;
                end;
            end;
            location_reset(l,LOC_REGISTER,dst_size);
@@ -1847,7 +1872,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.102  2003-05-13 19:14:41  peter
+  Revision 1.103  2003-05-14 19:37:25  jonas
+    * patch from Peter for int64 function results
+
+  Revision 1.102  2003/05/13 19:14:41  peter
     * failn removed
     * inherited result code check moven to pexpr