Bläddra i källkod

+ TAILREC optimizer switch

git-svn-id: trunk@4849 -
florian 19 år sedan
förälder
incheckning
82b7b785f7
2 ändrade filer med 10 tillägg och 4 borttagningar
  1. 2 2
      compiler/globtype.pas
  2. 8 2
      compiler/psub.pas

+ 2 - 2
compiler/globtype.pas

@@ -149,7 +149,7 @@ than 255 characters. That's why using Ansi Strings}
        toptimizerswitch = (cs_opt_none,
          cs_opt_level1,cs_opt_level2,cs_opt_level3,
          cs_opt_regvar,cs_opt_uncertain,cs_opt_size,cs_opt_stackframe,
-         cs_opt_peephole,cs_opt_asmcse,cs_opt_loopunroll
+         cs_opt_peephole,cs_opt_asmcse,cs_opt_loopunroll,cs_opt_tailrecursion
        );
        toptimizerswitches = set of toptimizerswitch;
 
@@ -157,7 +157,7 @@ than 255 characters. That's why using Ansi Strings}
        OptimizerSwitchStr : array[toptimizerswitch] of string[10] = ('',
          'LEVEL1','LEVEL2','LEVEL3',
          'REGVAR','UNCERTAIN','SIZE','STACKFRAME',
-         'PEEPHOLE','ASMCSE','LOOPUNROLL'
+         'PEEPHOLE','ASMCSE','LOOPUNROLL','TAILREC'
        );
 
     type

+ 8 - 2
compiler/psub.pas

@@ -100,7 +100,8 @@ implementation
        pbase,pstatmnt,pdecl,pdecsub,pexports,
        { codegen }
        tgobj,cgbase,cgobj,dbgbase,
-       ncgutil,regvars
+       ncgutil,regvars,
+       opttail
 {$if defined(arm) or defined(powerpc) or defined(powerpc64)}
        ,aasmcpu
 {$endif arm}
@@ -727,6 +728,12 @@ implementation
         if code.registersfpu>0 then
           include(flags,pi_uses_fpu);
 
+        { do this before adding the entry code else the tail recursion recognition won't work,
+          if this causes troubles, it must be ifdef'ed
+        }
+        if cs_opt_tailrecursion in aktoptimizerswitches then
+          do_opttail(code,procdef);
+
         { add implicit entry and exit code }
         add_entry_exit_code;
 
@@ -806,7 +813,6 @@ implementation
                 procdef.has_paraloc_info:=true;
               end;
 
-
             { generate code for the node tree }
             do_secondpass(code);
             aktproccode.concatlist(current_asmdata.CurrAsmList);