Browse Source

+ del_location

peter 26 years ago
parent
commit
34e7bd8b81
2 changed files with 44 additions and 48 deletions
  1. 26 44
      compiler/cg386add.pas
  2. 18 4
      compiler/tgeni386.pas

+ 26 - 44
compiler/cg386add.pas

@@ -161,19 +161,8 @@ implementation
                         secondpass(p^.right);
                         if pushed then restore(p,false);
                         { release used registers }
-                        case p^.right^.location.loc of
-                          LOC_REFERENCE,LOC_MEM:
-                            del_reference(p^.right^.location.reference);
-                          LOC_REGISTER,LOC_CREGISTER:
-                            ungetregister32(p^.right^.location.register);
-                        end;
-                        case p^.left^.location.loc of
-                          LOC_REFERENCE,LOC_MEM:
-                            del_reference(p^.left^.location.reference);
-                          LOC_REGISTER,LOC_CREGISTER:
-                            ungetregister32(p^.left^.location.register);
-                        end;
-
+                        del_location(p^.right^.location);
+                        del_location(p^.left^.location);
                         { push the still used registers }
                         pushusedregisters(pushedregs,$ff);
                         { push data }
@@ -199,18 +188,8 @@ implementation
                         secondpass(p^.right);
                         if pushed then restore(p,false);
                         { release used registers }
-                        case p^.right^.location.loc of
-                          LOC_REFERENCE,LOC_MEM:
-                            del_reference(p^.right^.location.reference);
-                          LOC_REGISTER,LOC_CREGISTER:
-                            ungetregister32(p^.right^.location.register);
-                        end;
-                        case p^.left^.location.loc of
-                          LOC_REFERENCE,LOC_MEM:
-                            del_reference(p^.left^.location.reference);
-                          LOC_REGISTER,LOC_CREGISTER:
-                            ungetregister32(p^.left^.location.register);
-                        end;
+                        del_location(p^.right^.location);
+                        del_location(p^.left^.location);
                         { push the still used registers }
                         pushusedregisters(pushedregs,$ff);
                         { push data }
@@ -398,8 +377,8 @@ implementation
                   : begin
                      cmpop:=true;
 {$IfNDef regallocfix}
-                     del_reference(p^.left^.location.reference);
-                     del_reference(p^.right^.location.reference);
+                     del_location(p^.left^.location);
+                     del_location(p^.right^.location);
                      pushusedregisters(pushedregs,$ff);
 {$EndIf regallocfix}
 {$IfNDef NoSetInclusion}
@@ -408,11 +387,11 @@ implementation
 {$EndIf NoSetInclusion}
                          emitpushreferenceaddr(p^.right^.location.reference);
 {$IfDef regallocfix}
-                         del_reference(p^.right^.location.reference);
+                         del_location(p^.right^.location);
 {$EndIf regallocfix}
                          emitpushreferenceaddr(p^.left^.location.reference);
 {$IfDef regallocfix}
-                         del_reference(p^.left^.location.reference);
+                         del_location(p^.left^.location);
 {$EndIf regallocfix}
 {$IfNDef NoSetInclusion}
                        End
@@ -420,11 +399,11 @@ implementation
                        Begin
                          emitpushreferenceaddr(p^.left^.location.reference);
 {$IfDef regallocfix}
-                         del_reference(p^.left^.location.reference);
+                         del_location(p^.left^.location);
 {$EndIf regallocfix}
                          emitpushreferenceaddr(p^.right^.location.reference);
 {$IfDef regallocfix}
-                         del_reference(p^.right^.location.reference);
+                         del_location(p^.right^.location);
 {$EndIf regallocfix}
                        End;
                      Case p^.treetype of
@@ -443,8 +422,8 @@ implementation
             addn : begin
                    { add can be an other SET or Range or Element ! }
 {$IfNDef regallocfix}
-                     del_reference(p^.left^.location.reference);
-                     del_reference(p^.right^.location.reference);
+                     del_location(p^.left^.location);
+                     del_location(p^.right^.location);
                      pushusedregisters(pushedregs,$ff);
 {$EndIf regallocfix}
                      href.symbol:=nil;
@@ -452,8 +431,8 @@ implementation
                      if createset then
                       begin
 {$IfDef regallocfix}
-                        del_reference(p^.left^.location.reference);
-                        del_reference(p^.right^.location.reference);
+                        del_location(p^.left^.location);
+                        del_location(p^.right^.location);
 {$EndIf regallocfix}
                         pushsetelement(p^.right^.left);
                         emitpushreferenceaddr(href);
@@ -489,11 +468,11 @@ implementation
                            emitpushreferenceaddr(href);
                            emitpushreferenceaddr(p^.right^.location.reference);
 {$IfDef regallocfix}
-                        del_reference(p^.right^.location.reference);
+                           del_location(p^.right^.location);
 {$EndIf regallocfix}
                            emitpushreferenceaddr(p^.left^.location.reference);
 {$IfDef regallocfix}
-                        del_reference(p^.left^.location.reference);
+                           del_location(p^.left^.location);
 {$EndIf regallocfix}
                            emitcall('FPC_SET_ADD_SETS');
                          end;
@@ -509,8 +488,8 @@ implementation
          symdifn,
             muln : begin
 {$IfNDef regallocfix}
-                     del_reference(p^.left^.location.reference);
-                     del_reference(p^.right^.location.reference);
+                     del_location(p^.left^.location);
+                     del_location(p^.right^.location);
                      pushusedregisters(pushedregs,$ff);
 {$EndIf regallocfix}
                      href.symbol:=nil;
@@ -518,11 +497,11 @@ implementation
                      emitpushreferenceaddr(href);
                      emitpushreferenceaddr(p^.right^.location.reference);
 {$IfDef regallocfix}
-                     del_reference(p^.right^.location.reference);
+                     del_location(p^.right^.location);
 {$EndIf regallocfix}
                      emitpushreferenceaddr(p^.left^.location.reference);
 {$IfDef regallocfix}
-                     del_reference(p^.left^.location.reference);
+                     del_location(p^.left^.location);
 {$EndIf regallocfix}
                      case p^.treetype of
                       subn : emitcall('FPC_SET_SUB_SETS');
@@ -886,7 +865,7 @@ implementation
                                      if p^.left^.location.loc in [LOC_MEM,LOC_REFERENCE] then
                                       begin
                                         ungetiftemp(p^.left^.location.reference);
-                                        del_reference(p^.left^.location.reference);
+                                        del_location(p^.left^.location);
 {!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!}
                                         hregister:=getregister32;
                                         exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,opsize,
@@ -899,7 +878,7 @@ implementation
                                      if p^.right^.location.loc in [LOC_MEM,LOC_REFERENCE] then
                                       begin
                                         ungetiftemp(p^.right^.location.reference);
-                                        del_reference(p^.right^.location.reference);
+                                        del_location(p^.right^.location);
                                         hregister:=getregister32;
                                         exprasmlist^.concat(new(pai386,op_ref_reg(A_MOV,opsize,
                                           newreference(p^.right^.location.reference),hregister)));
@@ -2110,7 +2089,10 @@ implementation
 end.
 {
   $Log$
-  Revision 1.65  1999-06-09 23:00:11  peter
+  Revision 1.66  1999-06-09 23:22:37  peter
+    + del_location
+
+  Revision 1.65  1999/06/09 23:00:11  peter
     * small ansistring fixes
     * val_ansistr_sint destsize changed to longint
     * don't write low/hi ascii with -al

+ 18 - 4
compiler/tgeni386.pas

@@ -60,6 +60,7 @@ unit tgeni386;
     procedure cleartempgen;
     procedure del_reference(const ref : treference);
     procedure del_locref(const location : tlocation);
+    procedure del_location(const l : tlocation);
 
     { pushs and restores registers }
     procedure pushusedregisters(var pushed : tpushed;b : byte);
@@ -350,8 +351,8 @@ implementation
          ungetregister32(ref.index);
       end;
 
-    procedure del_locref(const location : tlocation);
 
+    procedure del_locref(const location : tlocation);
       begin
          if (location.loc<>loc_mem) and (location.loc<>loc_reference) then
            exit;
@@ -359,11 +360,21 @@ implementation
            exit;
          ungetregister32(location.reference.base);
          ungetregister32(location.reference.index);
-         { ref.segment:=R_DEFAULT_SEG; }
       end;
 
-    function getregister32 : tregister;
 
+    procedure del_location(const l : tlocation);
+      begin
+        case l.loc of
+          LOC_REGISTER :
+            ungetregister(l.register);
+          LOC_MEM,LOC_REFERENCE :
+            del_reference(l.reference);
+        end;
+      end;
+
+
+    function getregister32 : tregister;
       begin
          if usablereg32=0 then
            internalerror(10);
@@ -459,7 +470,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.26  1999-05-27 19:45:27  peter
+  Revision 1.27  1999-06-09 23:22:39  peter
+    + del_location
+
+  Revision 1.26  1999/05/27 19:45:27  peter
     * removed oldasm
     * plabel -> pasmlabel
     * -a switches to source writing automaticly