Selaa lähdekoodia

* disable string node optimizations for the moment

peter 22 vuotta sitten
vanhempi
commit
75394a788e
3 muutettua tiedostoa jossa 37 lisäystä ja 59 poistoa
  1. 16 7
      compiler/nadd.pas
  2. 4 50
      compiler/ncgopt.pas
  3. 17 2
      compiler/nopt.pas

+ 16 - 7
compiler/nadd.pas

@@ -24,6 +24,12 @@ unit nadd;
 
 {$i fpcdefs.inc}
 
+{ define addstringopt}
+
+{$ifdef callparatemp}
+  {$undef addstringopt}
+{$endif}
+
 interface
 
     uses
@@ -777,11 +783,11 @@ implementation
                     if not(is_constcharnode(left) and is_constcharnode(right)) then
                      begin
                        inserttypeconv(left,cshortstringtype);
-{$ifndef callparatemp}
+{$ifdef addstringopt}
                        hp := genaddsstringcharoptnode(self);
                        result := hp;
                        exit;
-{$endif callparatemp}
+{$endif addstringopt}
                      end;
                   end;
                end
@@ -1776,7 +1782,7 @@ implementation
                 end
               else
                 begin
-{$ifndef callparatemp}
+{$ifdef addstringopt}
                    { can create a call which isn't handled by callparatemp }
                    if canbeaddsstringcharoptnode(self) then
                      begin
@@ -1785,7 +1791,7 @@ implementation
                        exit;
                      end
                    else
-{$endif callparatemp}
+{$endif addstringopt}
                      begin
                        { Fix right to be shortstring }
                        if is_char(right.resulttype.def) then
@@ -1794,7 +1800,7 @@ implementation
                           firstpass(right);
                         end;
                      end;
-{$ifndef callparatemp}
+{$ifdef addstringopt}
                    { can create a call which isn't handled by callparatemp }
                    if canbeaddsstringcsstringoptnode(self) then
                      begin
@@ -1802,7 +1808,7 @@ implementation
                        pass_1 := hp;
                        exit;
                      end;
-{$endif callparatemp}
+{$endif addstringopt}
                 end;
              { otherwise, let addstring convert everything }
               result := first_addstring;
@@ -1953,7 +1959,10 @@ begin
 end.
 {
   $Log$
-  Revision 1.90  2003-05-26 19:38:28  peter
+  Revision 1.91  2003-05-26 21:15:18  peter
+    * disable string node optimizations for the moment
+
+  Revision 1.90  2003/05/26 19:38:28  peter
     * generic fpc_shorstr_concat
     + fpc_shortstr_append_shortstr optimization
 

+ 4 - 50
compiler/ncgopt.pas

@@ -34,10 +34,6 @@ type
      procedure pass_2; override;
   end;
 
-  tcgaddsstringcsstringoptnode = class(taddsstringcsstringoptnode)
-     { must be duplicated from ti386addnode :( }
-     procedure pass_2; override;
-  end;
 
 implementation
 
@@ -200,59 +196,17 @@ begin
   location_copy(location,left.location);
 end;
 
-procedure tcgaddsstringcsstringoptnode.pass_2;
-var
-  href: treference;
-  pushedregs: tpushedsavedint;
-  regstopush: tsupregset;
-begin
-  { first, we have to more or less replicate some code from }
-  { ti386addnode.pass_2                                     }
-  secondpass(left);
-  if not(tg.istemp(left.location.reference) and
-         (tg.sizeoftemp(exprasmlist,left.location.reference) = 256)) and
-     not(nf_use_strconcat in flags) then
-    begin
-       tg.GetTemp(exprasmlist,256,tt_normal,href);
-       cg.g_copyshortstring(exprasmlist,left.location.reference,href,255,true,false);
-       { release the registers }
-       location_freetemp(exprasmlist,left.location);
-       { return temp reference }
-       location_reset(left.location,LOC_REFERENCE,def_cgsize(resulttype.def));
-       left.location.reference:=href;
-    end;
-  secondpass(right);
-  { on the right we do not need the register anymore too }
-  { Instead of releasing them already, simply do not }
-  { push them (so the release is in the right place, }
-  { because emitpushreferenceaddr doesn't need extra }
-  { registers) (JM)                                  }
-  regstopush := all_intregisters;
-  remove_non_regvars_from_loc(right.location,regstopush);
-  rg.saveusedintregisters(exprasmlist,pushedregs,regstopush);
-  { push the maximum possible length of the result }
-  cg.a_paramaddr_ref(exprasmlist,left.location.reference,paramanager.getintparaloc(2));
-  { the optimizer can more easily put the          }
-  { deallocations in the right place if it happens }
-  { too early than when it happens too late (if    }
-  { the pushref needs a "lea (..),edi; push edi")  }
-  reference_release(exprasmlist,right.location.reference);
-  cg.a_paramaddr_ref(exprasmlist,right.location.reference,paramanager.getintparaloc(1));
-  rg.saveintregvars(exprasmlist,regstopush);
-  cg.a_call_name(exprasmlist,'FPC_SHORTSTR_CONCAT');
-  tg.ungetiftemp(exprasmlist,right.location.reference);
-  rg.restoreusedintregisters(exprasmlist,pushedregs);
-  location_copy(location,left.location);
-end;
 
 begin
   caddsstringcharoptnode := tcgaddsstringcharoptnode;
-  caddsstringcsstringoptnode := tcgaddsstringcsstringoptnode
 end.
 
 {
   $Log$
-  Revision 1.2  2003-04-26 09:12:55  peter
+  Revision 1.3  2003-05-26 21:15:18  peter
+    * disable string node optimizations for the moment
+
+  Revision 1.2  2003/04/26 09:12:55  peter
     * add string returns in LOC_REFERENCE
 
   Revision 1.1  2003/04/24 11:20:06  florian

+ 17 - 2
compiler/nopt.pas

@@ -67,6 +67,7 @@ type
   { add a constant string to a short string }
   taddsstringcsstringoptnode = class(taddsstringoptnode)
     constructor create(l,r : tnode); virtual;
+    function pass_1: tnode; override;
   end;
   taddsstringcsstringoptnodeclass = class of taddsstringcsstringoptnode;
 
@@ -84,7 +85,7 @@ var
 
 implementation
 
-uses cutils, htypechk, defutil, defcmp, globtype, globals, cpubase, ncnv, ncon,
+uses cutils, htypechk, defutil, defcmp, globtype, globals, cpubase, ncnv, ncon,ncal,
      verbose, symdef, cginfo,cgbase;
 
 
@@ -224,6 +225,17 @@ begin
   inherited create(addsstringcsstringoptn,l,r);
 end;
 
+
+function taddsstringcsstringoptnode.pass_1: tnode;
+begin
+  { create the call to the concat routine both strings as arguments }
+  result := ccallnode.createintern('fpc_shortstr_append_shortstr',
+    ccallparanode.create(left,ccallparanode.create(right,nil)));
+  left:=nil;
+  right:=nil;
+end;
+
+
 {*****************************************************************************
                                 HELPERS
 *****************************************************************************}
@@ -278,7 +290,10 @@ end.
 
 {
   $Log$
-  Revision 1.15  2003-04-27 11:21:33  peter
+  Revision 1.16  2003-05-26 21:15:18  peter
+    * disable string node optimizations for the moment
+
+  Revision 1.15  2003/04/27 11:21:33  peter
     * aktprocdef renamed to current_procdef
     * procinfo renamed to current_procinfo
     * procinfo will now be stored in current_module so it can be