Browse Source

* rewrite of optimizer options

git-svn-id: trunk@2901 -
peter 19 năm trước cách đây
mục cha
commit
b6e35a200e
66 tập tin đã thay đổi với 554 bổ sung1432 xóa
  1. 0 8
      .gitattributes
  2. 2 2
      compiler/alpha/cpuinfo.pas
  3. 0 121
      compiler/alpha/cpuswtch.pas
  4. 1 1
      compiler/aopt.pas
  5. 2 2
      compiler/aoptobj.pas
  6. 2 2
      compiler/arm/cgcpu.pas
  7. 10 7
      compiler/arm/cpuinfo.pas
  8. 0 118
      compiler/arm/cpuswtch.pas
  9. 1 1
      compiler/assemble.pas
  10. 0 2
      compiler/compiler.pas
  11. 156 133
      compiler/globals.pas
  12. 9 4
      compiler/globtype.pas
  13. 2 2
      compiler/i386/aopt386.pas
  14. 14 10
      compiler/i386/cpuinfo.pas
  15. 0 117
      compiler/i386/cpuswtch.pas
  16. 7 7
      compiler/i386/csopt386.pas
  17. 4 4
      compiler/i386/daopt386.pas
  18. 2 2
      compiler/i386/n386cal.pas
  19. 2 2
      compiler/i386/n386mat.pas
  20. 4 4
      compiler/i386/n386set.pas
  21. 20 20
      compiler/i386/popt386.pas
  22. 16 16
      compiler/m68k/cgcpu.pas
  23. 11 7
      compiler/m68k/cpuinfo.pas
  24. 0 106
      compiler/m68k/cpuswtch.pas
  25. 3 3
      compiler/m68k/n68kmat.pas
  26. 9 9
      compiler/m68k/ra68kmot.pas
  27. 7 4
      compiler/mips/cpuinfo.pas
  28. 2 2
      compiler/msg/errore.msg
  29. 2 2
      compiler/msgtxt.inc
  30. 0 48
      compiler/nbas.pas
  31. 1 1
      compiler/ncal.pas
  32. 2 2
      compiler/ncgbas.pas
  33. 11 11
      compiler/ncgflw.pas
  34. 1 1
      compiler/ncgmem.pas
  35. 3 3
      compiler/ncgset.pas
  36. 2 2
      compiler/ncgutil.pas
  37. 5 5
      compiler/nflw.pas
  38. 2 2
      compiler/nld.pas
  39. 2 2
      compiler/nmat.pas
  40. 2 2
      compiler/nopt.pas
  41. 1 1
      compiler/nset.pas
  42. 76 39
      compiler/options.pas
  43. 2 2
      compiler/optunrol.pas
  44. 12 8
      compiler/parser.pas
  45. 2 2
      compiler/powerpc/cgcpu.pas
  46. 10 6
      compiler/powerpc/cpuinfo.pas
  47. 0 118
      compiler/powerpc/cpuswtch.pas
  48. 80 80
      compiler/powerpc64/cgcpu.pas
  49. 8 5
      compiler/powerpc64/cpuinfo.pas
  50. 0 125
      compiler/powerpc64/cpuswtch.pas
  51. 1 1
      compiler/powerpc64/nppcmat.pas
  52. 3 3
      compiler/psub.pas
  53. 3 1
      compiler/rabase.pas
  54. 3 3
      compiler/regvars.pas
  55. 2 2
      compiler/scandir.pas
  56. 14 3
      compiler/sparc/cpuinfo.pas
  57. 0 125
      compiler/sparc/cpuswtch.pas
  58. 1 1
      compiler/symsym.pas
  59. 1 1
      compiler/vis/cpuinfo.pas
  60. 3 3
      compiler/x86/cgx86.pas
  61. 1 1
      compiler/x86/nx86add.pas
  62. 1 1
      compiler/x86/nx86inl.pas
  63. 1 1
      compiler/x86/nx86set.pas
  64. 1 1
      compiler/x86/rgx86.pas
  65. 9 5
      compiler/x86_64/cpuinfo.pas
  66. 0 97
      compiler/x86_64/cpuswtch.pas

+ 0 - 8
.gitattributes

@@ -21,7 +21,6 @@ compiler/alpha/cpuinfo.pas svneol=native#text/plain
 compiler/alpha/cpunode.pas svneol=native#text/plain
 compiler/alpha/cpupara.pas svneol=native#text/plain
 compiler/alpha/cpupi.pas svneol=native#text/plain
-compiler/alpha/cpuswtch.pas svneol=native#text/plain
 compiler/alpha/cputarg.pas svneol=native#text/plain
 compiler/alpha/radirect.pas svneol=native#text/plain
 compiler/alpha/rasm.pas svneol=native#text/plain
@@ -50,7 +49,6 @@ compiler/arm/cpuinfo.pas svneol=native#text/plain
 compiler/arm/cpunode.pas svneol=native#text/plain
 compiler/arm/cpupara.pas svneol=native#text/plain
 compiler/arm/cpupi.pas svneol=native#text/plain
-compiler/arm/cpuswtch.pas svneol=native#text/plain
 compiler/arm/cputarg.pas svneol=native#text/plain
 compiler/arm/itcpugas.pas svneol=native#text/plain
 compiler/arm/narmadd.pas svneol=native#text/plain
@@ -119,7 +117,6 @@ compiler/i386/cpuinfo.pas svneol=native#text/plain
 compiler/i386/cpunode.pas svneol=native#text/plain
 compiler/i386/cpupara.pas svneol=native#text/plain
 compiler/i386/cpupi.pas svneol=native#text/plain
-compiler/i386/cpuswtch.pas svneol=native#text/plain
 compiler/i386/cputarg.pas svneol=native#text/plain
 compiler/i386/csopt386.pas svneol=native#text/plain
 compiler/i386/daopt386.pas svneol=native#text/plain
@@ -176,7 +173,6 @@ compiler/m68k/cpuinfo.pas svneol=native#text/plain
 compiler/m68k/cpunode.pas svneol=native#text/plain
 compiler/m68k/cpupara.pas svneol=native#text/plain
 compiler/m68k/cpupi.pas svneol=native#text/plain
-compiler/m68k/cpuswtch.pas svneol=native#text/plain
 compiler/m68k/cputarg.pas svneol=native#text/plain
 compiler/m68k/itcpugas.pas svneol=native#text/plain
 compiler/m68k/n68kadd.pas svneol=native#text/plain
@@ -301,7 +297,6 @@ compiler/powerpc/cpuinfo.pas svneol=native#text/plain
 compiler/powerpc/cpunode.pas svneol=native#text/plain
 compiler/powerpc/cpupara.pas svneol=native#text/plain
 compiler/powerpc/cpupi.pas svneol=native#text/plain
-compiler/powerpc/cpuswtch.pas svneol=native#text/plain
 compiler/powerpc/cputarg.pas svneol=native#text/plain
 compiler/powerpc/itcpugas.pas svneol=native#text/plain
 compiler/powerpc/nppcadd.pas svneol=native#text/plain
@@ -339,7 +334,6 @@ compiler/powerpc64/cpuinfo.pas svneol=native#text/plain
 compiler/powerpc64/cpunode.pas svneol=native#text/plain
 compiler/powerpc64/cpupara.pas svneol=native#text/plain
 compiler/powerpc64/cpupi.pas svneol=native#text/plain
-compiler/powerpc64/cpuswtch.pas svneol=native#text/plain
 compiler/powerpc64/cputarg.pas svneol=native#text/plain
 compiler/powerpc64/itcpugas.pas svneol=native#text/plain
 compiler/powerpc64/nppcadd.pas svneol=native#text/plain
@@ -403,7 +397,6 @@ compiler/sparc/cpuinfo.pas svneol=native#text/plain
 compiler/sparc/cpunode.pas svneol=native#text/plain
 compiler/sparc/cpupara.pas svneol=native#text/plain
 compiler/sparc/cpupi.pas svneol=native#text/plain
-compiler/sparc/cpuswtch.pas svneol=native#text/plain
 compiler/sparc/cputarg.pas svneol=native#text/plain
 compiler/sparc/itcpugas.pas svneol=native#text/plain
 compiler/sparc/ncpuadd.pas svneol=native#text/plain
@@ -541,7 +534,6 @@ compiler/x86_64/cpuinfo.pas svneol=native#text/plain
 compiler/x86_64/cpunode.pas svneol=native#text/plain
 compiler/x86_64/cpupara.pas svneol=native#text/plain
 compiler/x86_64/cpupi.pas svneol=native#text/plain
-compiler/x86_64/cpuswtch.pas svneol=native#text/plain
 compiler/x86_64/cputarg.pas svneol=native#text/plain
 compiler/x86_64/nx64add.pas svneol=native#text/plain
 compiler/x86_64/nx64cal.pas svneol=native#text/plain

+ 2 - 2
compiler/alpha/cpuinfo.pas

@@ -46,8 +46,8 @@ Type
    pbestreal=^bestreal;
 
    { possible supported processors for this target }
-   tprocessors =
-      (no_processor,
+   tcputype =
+      (cpu_none,
        ClassEV7,
        ClassEV8
       );

+ 0 - 121
compiler/alpha/cpuswtch.pas

@@ -1,121 +0,0 @@
-{
-    Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
-
-    This units interprets the commandline options which are Alpha specific.
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ****************************************************************************
-}
-{
-  This units interprets the commandline options which are Alpha specific.
-}
-unit cpuswtch;
-
-{$i fpcdefs.inc}
-
-interface
-
-uses
-  options;
-
-type
-  toptionalpha = class(toption)
-    procedure interpret_proc_specific_options(const opt:string);override;
-  end;
-
-implementation
-
-uses
-  cutils,globtype,systems,globals;
-
-procedure toptionalpha.interpret_proc_specific_options(const opt:string);
-var
-  more: string;
-  j: longint;
-begin
-  More:=Upper(copy(opt,3,length(opt)-2));
-  case opt[2] of
-   'O' : Begin
-           j := 3;
-           While (j <= Length(Opt)) Do
-             Begin
-               case opt[j] of
-                 '-' :
-                   begin
-                     initglobalswitches:=initglobalswitches-[cs_optimize,cs_fastoptimize,cs_slowoptimize,cs_littlesize,
-                       cs_regalloc,cs_uncertainopts];
-                     FillChar(ParaAlignment,sizeof(ParaAlignment),0);
-                   end;
-                 'a' :
-                   begin
-                     UpdateAlignmentStr(Copy(Opt,j+1,255),ParaAlignment);
-                     j:=length(Opt);
-                   end;
-                 'g' : initglobalswitches:=initglobalswitches+[cs_littlesize];
-                 'G' : initglobalswitches:=initglobalswitches-[cs_littlesize];
-                 'r' :
-                   begin
-                     initglobalswitches:=initglobalswitches+[cs_regalloc];
-                     Simplify_ppu:=false;
-                   end;
-                 'u' : initglobalswitches:=initglobalswitches+[cs_uncertainopts];
-                 '1' : initglobalswitches:=initglobalswitches-[cs_fastoptimize,cs_slowoptimize]+[cs_optimize];
-                 '2' : initglobalswitches:=initglobalswitches-[cs_slowoptimize]+[cs_optimize,cs_fastoptimize];
-                 '3' : initglobalswitches:=initglobalswitches+[cs_optimize,cs_fastoptimize,cs_slowoptimize];
-{$ifdef dummy}
-                 'p' :
-                   Begin
-                     If j < Length(Opt) Then
-                       Begin
-                         Case opt[j+1] Of
-                           '1': initoptprocessor := Class386;
-                           '2': initoptprocessor := ClassP5;
-                           '3': initoptprocessor := ClassP6
-                           Else IllegalPara(Opt)
-                         End;
-                         Inc(j);
-                       End
-                     Else IllegalPara(opt)
-                   End;
-{$endif dummy}
-                 else IllegalPara(opt);
-               End;
-               Inc(j)
-             end;
-         end;
-{$ifdef dummy}
-   'R' : begin
-           if More='GAS' then
-            initasmmode:=asmmode_ppc_gas
-           else
-            if More='MOTOROLA' then
-             initasmmode:=asmmode_ppc_motorola
-           else
-            if More='DIRECT' then
-             initasmmode:=asmmode_direct
-           else
-            IllegalPara(opt);
-         end;
-{$endif dummy}
-  else
-   IllegalPara(opt);
-  end;
-end;
-
-
-initialization
-  coption:=toptionalpha;
-end.

+ 1 - 1
compiler/aopt.pas

@@ -209,7 +209,7 @@ Unit aopt;
             { Only perform them twice in the first pass }
              if pass = 0 then
                PeepHoleOptPass1;
-            If (cs_slowoptimize in aktglobalswitches) Then
+            If (cs_opt_asmcse in aktoptimizerswitches) Then
               Begin
 //                DFA:=TAOptDFACpu.Create(AsmL,BlockStart,BlockEnd,LabelInfo);
                 { data flow analyzer }

+ 2 - 2
compiler/aoptobj.pas

@@ -505,7 +505,7 @@ Unit AoptObj;
               With Regs[Counter] Do
                 Begin
                   If (typ = Con_Ref) And
-                     ((Not(cs_UncertainOpts in aktglobalswitches) And
+                     ((Not(cs_opt_size in aktoptimizerswitches) And
                        (NrOfMods <> 1)
                       ) Or
                       (RefInSequence(Ref,Regs[Counter], RefsEq) And
@@ -533,7 +533,7 @@ Unit AoptObj;
             For Counter := LoGPReg to HiGPReg Do
               With Regs[Counter] Do
                 If (typ = Con_Ref) And
-                   (Not(cs_UncertainOpts in aktglobalswitches) Or
+                   (Not(cs_opt_size in aktoptimizerswitches) Or
       {$ifdef x86}
               {for movsl}
                     (Ref.Base = R_EDI) Or

+ 2 - 2
compiler/arm/cgcpu.pas

@@ -1271,7 +1271,7 @@ unit cgcpu;
         helpsize:=12;
         dstref:=dest;
         srcref:=source;
-        if cs_littlesize in aktglobalswitches then
+        if cs_opt_size in aktoptimizerswitches then
           helpsize:=8;
         if (len<=helpsize) and aligned then
           begin
@@ -1309,7 +1309,7 @@ unit cgcpu;
 
             countreg:=getintregister(list,OS_32);
 
-//            if cs_littlesize in aktglobalswitches  then
+//            if cs_opt_size in aktoptimizerswitches  then
               genloop(len,1);
 {
             else

+ 10 - 7
compiler/arm/cpuinfo.pas

@@ -30,15 +30,15 @@ Type
    pbestreal=^bestreal;
 
    { possible supported processors for this target }
-   tprocessors =
-      (no_processor,
-       armv3,
-       armv4,
-       armv5
+   tcputype =
+      (cpu_none,
+       cpu_armv3,
+       cpu_armv4,
+       cpu_armv5
       );
 
    tfputype =
-     (no_fpuprocessor,
+     (fpu_none,
       fpu_soft,
       fpu_libgcc,
       fpu_fpa,
@@ -67,7 +67,7 @@ Const
      pocall_softfloat
    ];
 
-   processorsstr : array[tprocessors] of string[5] = ('',
+   cputypestr : array[tcputype] of string[5] = ('',
      'ARMV3',
      'ARMV4',
      'ARMV5'
@@ -82,6 +82,9 @@ Const
      'VFP'
    );
 
+   level1optimizerswitches = [cs_opt_level1];
+   level2optimizerswitches = level1optimizerswitches + [cs_opt_level2,cs_opt_regvar,cs_opt_stackframe];
+   level3optimizerswitches = level2optimizerswitches + [cs_opt_level3,cs_opt_loopunroll];
 
 Implementation
 

+ 0 - 118
compiler/arm/cpuswtch.pas

@@ -1,118 +0,0 @@
-{
-    Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
-
-    interprets the commandline options which are arm specific
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ****************************************************************************
-}
-unit cpuswtch;
-
-{$i fpcdefs.inc}
-
-interface
-
-uses
-  options;
-
-type
-  toptionarm=class(toption)
-    procedure interpret_proc_specific_options(const opt:string);override;
-  end;
-
-implementation
-
-uses
-  cutils,globtype,systems,globals;
-
-procedure toptionarm.interpret_proc_specific_options(const opt:string);
-var
-  more: string;
-  j: longint;
-begin
-  More:=Upper(copy(opt,3,length(opt)-2));
-  case opt[2] of
-   'O' : Begin
-           j := 3;
-           While (j <= Length(Opt)) Do
-             Begin
-               case opt[j] of
-                 '-' :
-                   begin
-                     initglobalswitches:=initglobalswitches-[cs_optimize,cs_fastoptimize,cs_slowoptimize,cs_littlesize,
-                       cs_regvars,cs_uncertainopts];
-                     FillChar(ParaAlignment,sizeof(ParaAlignment),0);
-                   end;
-                 'a' :
-                   begin
-                     UpdateAlignmentStr(Copy(Opt,j+1,255),ParaAlignment);
-                     j:=length(Opt);
-                   end;
-                 'g' : initglobalswitches:=initglobalswitches+[cs_littlesize];
-                 'G' : initglobalswitches:=initglobalswitches-[cs_littlesize];
-                 'r' :
-                   begin
-                     initglobalswitches:=initglobalswitches+[cs_regvars];
-                     Simplify_ppu:=false;
-                   end;
-                 'u' : initglobalswitches:=initglobalswitches+[cs_uncertainopts];
-                 '1' : initglobalswitches:=initglobalswitches-[cs_fastoptimize,cs_slowoptimize]+[cs_optimize];
-                 '2' : initglobalswitches:=initglobalswitches-[cs_slowoptimize]+[cs_optimize,cs_fastoptimize];
-                 '3' : initglobalswitches:=initglobalswitches+[cs_optimize,cs_fastoptimize,cs_slowoptimize];
-{$ifdef dummy}
-                 'p' :
-                   Begin
-                     If j < Length(Opt) Then
-                       Begin
-                         Case opt[j+1] Of
-                           '1': initoptprocessor := Class386;
-                           '2': initoptprocessor := ClassP5;
-                           '3': initoptprocessor := ClassP6
-                           Else IllegalPara(Opt)
-                         End;
-                         Inc(j);
-                       End
-                     Else IllegalPara(opt)
-                   End;
-{$endif dummy}
-                 else IllegalPara(opt);
-               End;
-               Inc(j)
-             end;
-         end;
-{$ifdef dummy}
-   'R' : begin
-           if More='GAS' then
-            initasmmode:=asmmode_ppc_gas
-           else
-            if More='MOTOROLA' then
-             initasmmode:=asmmode_ppc_motorola
-           else
-            if More='DIRECT' then
-             initasmmode:=asmmode_direct
-           else
-            IllegalPara(opt);
-         end;
-{$endif dummy}
-  else
-   IllegalPara(opt);
-  end;
-end;
-
-
-initialization
-  coption:=toptionarm;
-end.

+ 1 - 1
compiler/assemble.pas

@@ -545,7 +545,7 @@ Implementation
       begin
         result:=target_asm.asmcmd;
 {$ifdef m68k}
-        if aktoptprocessor = MC68020 then
+        if aktoptcputype = cpu_MC68020 then
           result:='-m68020 '+result
         else
           result:='-m68000 '+result;

+ 0 - 2
compiler/compiler.pas

@@ -150,8 +150,6 @@ uses
   verbose,comphook,systems,
   cutils,cclasses,globals,options,fmodule,parser,symtable,
   assemble,link,dbgbase,import,export,tokens,pass_1
-  { cpu specific commandline options }
-  ,cpuswtch
   { cpu parameter handling }
   ,cpupara
   { procinfo stuff }

+ 156 - 133
compiler/globals.pas

@@ -209,13 +209,14 @@ interface
        initmoduleswitches : tmoduleswitches;
        initlocalswitches  : tlocalswitches;
        initmodeswitches   : tmodeswitches;
+       initoptimizerswitches : toptimizerswitches;
        {$IFDEF testvarsets}
         Initsetalloc,                            {0=fixed, 1 =var}
        {$ENDIF}
        initpackenum       : shortint;
        initalignment      : talignmentinfo;
-       initoptprocessor,
-       initspecificoptprocessor : tprocessors;
+       initcputype,
+       initoptimizecputype : tcputype;
        initfputype        : tfputype;
        initasmmode        : tasmmode;
        initinterfacetype  : tinterfacetypes;
@@ -226,6 +227,7 @@ interface
        aktglobalswitches  : tglobalswitches;
        aktmoduleswitches  : tmoduleswitches;
        aktlocalswitches   : tlocalswitches;
+       aktoptimizerswitches : toptimizerswitches;
        nextaktlocalswitches : tlocalswitches;
        localswitcheschanged : boolean;
        aktmodeswitches    : tmodeswitches;
@@ -236,8 +238,8 @@ interface
        aktpackenum        : shortint;
        aktmaxfpuregisters : longint;
        aktalignment       : talignmentinfo;
-       aktoptprocessor,
-       aktspecificoptprocessor : tprocessors;
+       aktoptcputype,
+       aktspecificoptcputype : tcputype;
        aktfputype        : tfputype;
        aktasmmode         : tasmmode;
        aktinterfacetype   : tinterfacetypes;
@@ -340,17 +342,17 @@ interface
     { discern +0.0 and -0.0 }
     function get_real_sign(r: bestreal): longint;
 
-    function SetAktProcCall(const s:string; changeInit: boolean):boolean;
-    function SetProcessor(const s:string; changeInit: boolean):boolean;
-    function SetFpuType(const s:string; changeInit: boolean):boolean;
-
     procedure InitGlobals;
     procedure DoneGlobals;
 
     function  string2guid(const s: string; var GUID: TGUID): boolean;
     function  guid2string(const GUID: TGUID): string;
 
+    function SetAktProcCall(const s:string; var a:tproccalloption):boolean;
+    function Setcputype(const s:string;var a:tcputype):boolean;
+    function SetFpuType(const s:string;var a:tfputype):boolean;
     function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
+    function UpdateOptimizerStr(s:string;var a:toptimizerswitches):boolean;
 
     {# Routine to get the required alignment for size of data, which will
        be placed in bss segment, according to the current alignment requirements }
@@ -1873,72 +1875,6 @@ end;
       end;
 
 
-    function SetAktProcCall(const s:string; changeInit:boolean):boolean;
-      const
-        DefProcCallName : array[tproccalloption] of string[12] = ('',
-         'CDECL',
-         'CPPDECL',
-         'FAR16',
-         'OLDFPCCALL',
-         '', { internproc }
-         '', { syscall }
-         'PASCAL',
-         'REGISTER',
-         'SAFECALL',
-         'STDCALL',
-         'SOFTFLOAT',
-         'MWPASCAL'
-        );
-      var
-        t : tproccalloption;
-      begin
-        result:=false;
-        for t:=low(tproccalloption) to high(tproccalloption) do
-         if DefProcCallName[t]=s then
-          begin
-            AktDefProcCall:=t;
-            result:=true;
-            break;
-          end;
-        if changeinit then
-         InitDefProcCall:=AktDefProcCall;
-      end;
-
-
-    function SetProcessor(const s:string; changeInit: boolean):boolean;
-      var
-        t : tprocessors;
-      begin
-        SetProcessor:=false;
-        for t:=low(tprocessors) to high(tprocessors) do
-          if processorsstr[t]=s then
-            begin
-              aktspecificoptprocessor:=t;
-              SetProcessor:=true;
-              break;
-            end;
-        if changeinit then
-          initspecificoptprocessor:=aktspecificoptprocessor;
-      end;
-
-
-    function SetFpuType(const s:string; changeInit: boolean):boolean;
-      var
-        t : tfputype;
-      begin
-        SetFpuType:=false;
-        for t:=low(tfputype) to high(tfputype) do
-          if fputypestr[t]=s then
-            begin
-              aktfputype:=t;
-              SetFpuType:=true;
-              break;
-            end;
-        if changeinit then
-          initfputype:=aktfputype;
-      end;
-
-
     { '('D1:'00000000-'D2:'0000-'D3:'0000-'D4:'0000-000000000000)' }
     function string2guid(const s: string; var GUID: TGUID): boolean;
         function ishexstr(const hs: string): boolean;
@@ -1990,6 +1926,7 @@ end;
           string2guid:=false;
       end;
 
+
     function guid2string(const GUID: TGUID): string;
         function long2hex(l, len: longint): string;
           const
@@ -2018,6 +1955,70 @@ end;
       end;
 
 
+    function SetAktProcCall(const s:string; var a:tproccalloption):boolean;
+      const
+        DefProcCallName : array[tproccalloption] of string[12] = ('',
+         'CDECL',
+         'CPPDECL',
+         'FAR16',
+         'OLDFPCCALL',
+         '', { internproc }
+         '', { syscall }
+         'PASCAL',
+         'REGISTER',
+         'SAFECALL',
+         'STDCALL',
+         'SOFTFLOAT',
+         'MWPASCAL'
+        );
+      var
+        t  : tproccalloption;
+        hs : string;
+      begin
+        result:=false;
+        hs:=upper(s);
+        for t:=low(tproccalloption) to high(tproccalloption) do
+         if DefProcCallName[t]=hs then
+          begin
+            a:=t;
+            result:=true;
+            break;
+          end;
+      end;
+
+
+    function Setcputype(const s:string;var a:tcputype):boolean;
+      var
+        t  : tcputype;
+        hs : string;
+      begin
+        result:=false;
+        hs:=Upper(s);
+        for t:=low(tcputype) to high(tcputype) do
+          if cputypestr[t]=hs then
+            begin
+              a:=t;
+              result:=true;
+              break;
+            end;
+      end;
+
+
+    function SetFpuType(const s:string;var a:tfputype):boolean;
+      var
+        t : tfputype;
+      begin
+        result:=false;
+        for t:=low(tfputype) to high(tfputype) do
+          if fputypestr[t]=s then
+            begin
+              aktfputype:=t;
+              result:=true;
+              break;
+            end;
+      end;
+
+
     function UpdateAlignmentStr(s:string;var a:talignmentinfo):boolean;
       var
         tok  : string;
@@ -2064,6 +2065,50 @@ end;
       end;
 
 
+    function UpdateOptimizerStr(s:string;var a:toptimizerswitches):boolean;
+      var
+        tok  : string;
+        doset : boolean;
+        doswitch : toptimizerswitch;
+      begin
+        result:=true;
+        uppervar(s);
+        repeat
+          tok:=GetToken(s,',');
+          if tok='' then
+           break;
+          if Copy(tok,1,2)='NO' then
+            begin
+              delete(tok,1,2);
+              doset:=false;
+            end
+          else
+            doset:=true;
+          if tok='LOOPUNROLL' then
+           doswitch:=cs_opt_loopunroll
+          else if tok='UNCERTAIN' then
+           doswitch:=cs_opt_uncertain
+          else if tok='REGVAR' then
+           doswitch:=cs_opt_regvar
+          else if tok='PEEPHOLE' then
+           doswitch:=cs_opt_peephole
+          else if tok='STACKFRAME' then
+           doswitch:=cs_opt_stackframe
+          else if tok='ASMCSE' then
+           doswitch:=cs_opt_asmcse
+          else { Error }
+           result:=false;
+          if doswitch<>cs_opt_none then
+            begin
+              if doset then
+                include(a,doswitch)
+              else
+                exclude(a,doswitch);
+            end;
+        until false;
+      end;
+
+
     function var_align(siz: longint): longint;
       begin
         siz := size_2_align(siz);
@@ -2152,7 +2197,7 @@ end;
      begin
         get_exepath;
 
-      { reset globals }
+        { reset globals }
         do_build:=false;
         do_release:=false;
         do_make:=true;
@@ -2166,7 +2211,7 @@ end;
         paratargetasm:=as_none;
         paratargetdbg:=dbg_none;
 
-      { Output }
+        { Output }
         OutputFile:='';
         OutputPrefix:=Nil;
         OutputSuffix:=Nil;
@@ -2175,19 +2220,19 @@ end;
         OutputExeDir:='';
         OutputUnitDir:='';
 
-      { Utils directory }
+        { Utils directory }
         utilsdirectory:='';
         utilsprefix:='';
         cshared:=false;
         rlinkpath:='';
 
-      { Search Paths }
+        { Search Paths }
         librarysearchpath:=TSearchPathList.Create;
         unitsearchpath:=TSearchPathList.Create;
         includesearchpath:=TSearchPathList.Create;
         objectsearchpath:=TSearchPathList.Create;
 
-      { Def file }
+        { Def file }
         usewindowapi:=false;
         description:='Compiled by FPC '+version_string+' - '+target_cpu_string;
         DescriptionSetExplicity:=false;
@@ -2204,87 +2249,65 @@ end;
         RelocSection:=false;
         RelocSectionSetExplicitly:=false;
         LinkTypeSetExplicitly:=false;
+        { memory sizes, will be overriden by parameter or default for target
+          in options or init_parser }
+        stacksize:=0;
+        { not initialized yet }
+        jmp_buf_size:=-1;
+        apptype:=app_cui;
 
-      { Init values }
+        { Init values }
         initmodeswitches:=fpcmodeswitches;
         initlocalswitches:=[cs_check_io,cs_typed_const_writable];
         initmoduleswitches:=[cs_extsyntax,cs_implicit_exceptions];
-        initsourcecodepage:='8859-1';
         initglobalswitches:=[cs_check_unit_name,cs_link_static{$ifdef INTERNALLINKER},cs_link_internal,cs_link_map{$endif}];
+        initoptimizerswitches:=[];
+        initsourcecodepage:='8859-1';
+        initpackenum:=4;
+        {$IFDEF testvarsets}
+        initsetalloc:=0;
+        {$ENDIF}
         fillchar(initalignment,sizeof(talignmentinfo),0);
         { might be overridden later }
         initasmmode:=asmmode_standard;
-{$ifdef i386}
-        initoptprocessor:=ClassPentium3;
-        initspecificoptprocessor:=Class386;
+        initcputype:=cpu_none;
+        initoptimizecputype:=cpu_none;
+        initfputype:=fpu_none;
+        initinterfacetype:=it_interfacecom;
+        initdefproccall:=pocall_default;
 
+        { Target specific defaults, these can override previous default options }
+{$ifdef i386}
+        initcputype:=cpu_386;
+        initoptimizecputype:=cpu_Pentium3;
         initfputype:=fpu_x87;
-
-        initpackenum:=4;
-        {$IFDEF testvarsets}
-        initsetalloc:=0;
-        {$ENDIF}
-        initasmmode:=asmmode_i386_att;
 {$endif i386}
 {$ifdef m68k}
-        initoptprocessor:=MC68020;
-        initpackenum:=4;
-        {$IFDEF testvarsets}
-         initsetalloc:=0;
-        {$ENDIF}
+        initcputype:=cpu_MC68020;
+        initfputype:=fpu_soft;
 {$endif m68k}
 {$ifdef powerpc}
-        initoptprocessor:=PPC604;
-        initpackenum:=4;
-        {$IFDEF testvarsets}
-         initsetalloc:=0;
-        {$ENDIF}
+        initcputype:=cpu_PPC604;
         initfputype:=fpu_standard;
 {$endif powerpc}
 {$ifdef POWERPC64}
-        initoptprocessor:=PPC970;
-        initpackenum:=4;
-        {$IFDEF testvarsets}
-         initsetalloc:=0;
-        {$ENDIF}
+        initcputype:=cpu_PPC970;
         initfputype:=fpu_standard;
 {$endif POWERPC64}
 {$ifdef sparc}
-        initoptprocessor:=SPARC_V8;
-        initpackenum:=4;
-        {$IFDEF testvarsets}
-         initsetalloc:=0;
-        {$ENDIF}
+        initcputype:=cpu_SPARC_V8;
+        initfputype:=fpu_hard;
 {$endif sparc}
 {$ifdef arm}
-        initpackenum:=4;
-        {$IFDEF testvarsets}
-        initsetalloc:=0;
-        {$ENDIF}
+        initcputype:=cpu_armv3;
         initfputype:=fpu_fpa;
 {$endif arm}
 {$ifdef x86_64}
-        initoptprocessor:=ClassAthlon64;
-        initspecificoptprocessor:=ClassAthlon64;
-
+        initcputype:=cpu_athlon64;
         initfputype:=fpu_sse64;
-
-        initpackenum:=4;
-        {$IFDEF testvarsets}
-        initsetalloc:=0;
-        {$ENDIF}
-        initasmmode:=asmmode_x86_64_gas;
 {$endif x86_64}
-        initinterfacetype:=it_interfacecom;
-        initdefproccall:=pocall_default;
-
-      { memory sizes, will be overriden by parameter or default for target
-        in options or init_parser }
-        stacksize:=0;
-        { not initialized yet }
-        jmp_buf_size:=-1;
-
-        apptype:=app_cui;
+        if initoptimizecputype=cpu_none then
+          initoptimizecputype:=initcputype;
      end;
 
 end.

+ 9 - 4
compiler/globtype.pas

@@ -114,14 +114,11 @@ than 255 characters. That's why using Ansi Strings}
          cs_load_objpas_unit,
          cs_load_gpc_unit,
          cs_load_fpcylix_unit,
-         { optimizer }
-         cs_regvars,cs_no_regalloc,cs_uncertainopts,cs_littlesize,
-         cs_optimize,cs_fastoptimize,cs_slowoptimize,cs_align,cs_loopunroll,
          { browser }
          cs_browser_log,
          { debuginfo }
          cs_use_heaptrc,cs_use_lineinfo,
-         cs_gdb_valgrind,
+         cs_gdb_valgrind,cs_no_regalloc,
          { assembling }
          cs_asm_leave,cs_asm_extern,cs_asm_pipe,cs_asm_source,
          cs_asm_regalloc,cs_asm_tempalloc,cs_asm_nodes,
@@ -132,6 +129,14 @@ than 255 characters. That's why using Ansi Strings}
        );
        tglobalswitches = set of tglobalswitch;
 
+       { optimizer }
+       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
+       );
+       toptimizerswitches = set of toptimizerswitch;
+
        { Switches which can be changed by a mode (fpc,tp7,delphi) }
        tmodeswitch = (m_none,m_all, { needed for keyword }
          { generic }

+ 2 - 2
compiler/i386/aopt386.pas

@@ -46,7 +46,7 @@ Var
   pass: longint;
   slowopt, changed, lastLoop: boolean;
 Begin
-  slowopt := (cs_slowoptimize in aktglobalswitches);
+  slowopt := (cs_opt_asmcse in aktoptimizerswitches);
   pass := 0;
   changed := false;
   dfa := TDFAObj.create(asml);
@@ -72,7 +72,7 @@ Begin
          if pass = 0 then
            PeepHoleOptPass1(AsmL, BlockStart, BlockEnd);
         { Data flow analyzer }
-         If (cs_fastoptimize in aktglobalswitches) Then
+         If (cs_opt_peephole in aktoptimizerswitches) Then
            begin
              if dfa.pass_2 then
               { common subexpression elimination }

+ 14 - 10
compiler/i386/cpuinfo.pas

@@ -39,18 +39,18 @@ Type
    pbestreal=^bestreal;
 
    { possible supported processors for this target }
-   tprocessors =
-      (no_processor,
-       Class386,
-       ClassPentium,
-       ClassPentium2,
-       ClassPentium3,
-       ClassPentium4,
-       ClassPentiumM
+   tcputype =
+      (cpu_none,
+       cpu_386,
+       cpu_Pentium,
+       cpu_Pentium2,
+       cpu_Pentium3,
+       cpu_Pentium4,
+       cpu_PentiumM
       );
 
    tfputype =
-     (no_fpuprocessor,
+     (fpu_none,
       fpu_soft,
       fpu_x87,
       fpu_sse,
@@ -73,7 +73,7 @@ Const
      pocall_oldfpccall
    ];
 
-   processorsstr : array[tprocessors] of string[10] = ('',
+   cputypestr : array[tcputype] of string[10] = ('',
      '386',
      'PENTIUM',
      'PENTIUM2',
@@ -93,6 +93,10 @@ Const
    sse_singlescalar : set of tfputype = [fpu_sse,fpu_sse2,fpu_sse3];
    sse_doublescalar : set of tfputype = [fpu_sse2,fpu_sse3];
 
+   level1optimizerswitches = [cs_opt_level1,cs_opt_peephole];
+   level2optimizerswitches = level1optimizerswitches + [cs_opt_level2,cs_opt_regvar,cs_opt_stackframe,cs_opt_asmcse];
+   level3optimizerswitches = level2optimizerswitches + [cs_opt_level3,cs_opt_loopunroll];
+
 Implementation
 
 end.

+ 0 - 117
compiler/i386/cpuswtch.pas

@@ -1,117 +0,0 @@
-{
-    Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
-
-    interprets the commandline options which are i386 specific
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ****************************************************************************
-}
-unit cpuswtch;
-
-{$i fpcdefs.inc}
-
-interface
-
-uses
-  options;
-
-type
-  toption386=class(toption)
-    procedure interpret_proc_specific_options(const opt:string);override;
-  end;
-
-implementation
-
-uses
-  cutils,globtype,systems,globals,cpuinfo;
-
-procedure toption386.interpret_proc_specific_options(const opt:string);
-var
-  j     : longint;
-  More  : string;
-begin
-  More:=Upper(copy(opt,3,length(opt)-2));
-  case opt[2] of
-   'O' : Begin
-           j := 3;
-           While (j <= Length(Opt)) Do
-             Begin
-               case opt[j] of
-                 '-' :
-                   begin
-                     initglobalswitches:=initglobalswitches-[cs_optimize,cs_fastoptimize,cs_slowoptimize,cs_littlesize,
-                       cs_regvars,cs_uncertainopts];
-                     FillChar(ParaAlignment,sizeof(ParaAlignment),0);
-                   end;
-                 'a' :
-                   begin
-                     if not(UpdateAlignmentStr(Copy(Opt,j+1,255),ParaAlignment)) then
-                       IllegalPara(opt);
-                     j:=length(Opt);
-                   end;
-                 'g' : initglobalswitches:=initglobalswitches+[cs_littlesize];
-                 'G' : initglobalswitches:=initglobalswitches-[cs_littlesize];
-                 'r' :
-                   begin
-                     initglobalswitches:=initglobalswitches+[cs_regvars];
-                     Simplify_ppu:=false;
-                   end;
-                 'u' : initglobalswitches:=initglobalswitches+[cs_uncertainopts];
-                 '1' : initglobalswitches:=initglobalswitches-[cs_fastoptimize,cs_slowoptimize]+[cs_optimize];
-                 '2' : initglobalswitches:=initglobalswitches-[cs_slowoptimize]+[cs_optimize,cs_fastoptimize];
-                 '3' : initglobalswitches:=initglobalswitches+[cs_optimize,cs_fastoptimize,cs_slowoptimize];
-                 'p' :
-                   Begin
-                     If j < Length(Opt) Then
-                       Begin
-                         Case opt[j+1] Of
-                           '1': initoptprocessor := Class386;
-                           '2': initoptprocessor := ClassPentium;
-                           '3': initoptprocessor := ClassPentium2;
-                           '4': initoptprocessor := ClassPentium4;
-                           '5': initoptprocessor := ClassPentiumM;
-                           Else IllegalPara(Opt)
-                         End;
-                         Inc(j);
-                       End
-                     Else IllegalPara(opt)
-                   End;
-                 else IllegalPara(opt);
-               End;
-               Inc(j)
-             end;
-         end;
-   'R' : begin
-           if More='ATT' then
-            initasmmode:=asmmode_i386_att
-           else
-            if More='INTEL' then
-             initasmmode:=asmmode_i386_intel
-           else
-            if (More='STANDARD') or (More='DEFAULT') then
-             initasmmode:=asmmode_standard
-           else
-            IllegalPara(opt);
-         end;
-  else
-   IllegalPara(opt);
-  end;
-end;
-
-
-initialization
-  coption:=toption386;
-end.

+ 7 - 7
compiler/i386/csopt386.pas

@@ -241,7 +241,7 @@ var
         hp: tai;
       begin
         { only regvars are still used at jump instructions }
-        if (cs_regvars in aktglobalswitches) and
+        if (cs_opt_regvar in aktoptimizerswitches) and
            (p.typ = ait_instruction) and
            taicpu(p).is_jmp then
          regsstillvalid := regsstillvalid - ptaiprop(p.optinfo)^.usedregs;
@@ -312,7 +312,7 @@ var
     getPrevSequence := RS_INVALID;
     passedFlagsModifyingInstr := passedFlagsModifyingInstr or
       instrWritesFlags(currentPrev);
-    if (cs_regvars in aktglobalswitches) and
+    if (cs_opt_regvar in aktoptimizerswitches) and
        (currentprev.typ = ait_instruction) and
        taicpu(currentprev).is_jmp then
       regsstillvalid := regsstillvalid - ptaiprop(currentprev.optinfo)^.usedregs;
@@ -2017,7 +2017,7 @@ begin
                                 end;
                             end;
                         Ch_MOp1:
-                          if not(CS_LittleSize in aktglobalswitches) and
+                          if not(cs_opt_size in aktoptimizerswitches) and
                              (taicpu(p).oper[0]^.typ = top_ref) then
                             begin
                               memreg :=
@@ -2064,7 +2064,7 @@ begin
                                 end;
                             end;
                         Ch_MOp2:
-                          if not(cs_littlesize in aktglobalswitches) and
+                          if not(cs_opt_size in aktoptimizerswitches) and
                              (taicpu(p).oper[1]^.typ = top_ref) and
                              ((taicpu(p).opcode < A_BT) or
                               ((taicpu(p).opcode > A_IN) and
@@ -2188,10 +2188,10 @@ end;
 
 function CSE(asml: TAAsmOutput; First, Last: tai; pass: longint): boolean;
 begin
-  doCSE(asml, First, Last, not(cs_slowoptimize in aktglobalswitches) or (pass >= 2),
-        not(cs_slowoptimize in aktglobalswitches) or (pass >= 1));
+  doCSE(asml, First, Last, not(cs_opt_asmcse in aktoptimizerswitches) or (pass >= 2),
+        not(cs_opt_asmcse in aktoptimizerswitches) or (pass >= 1));
  { register renaming }
-  if not(cs_slowoptimize in aktglobalswitches) or (pass > 0) then
+  if not(cs_opt_asmcse in aktoptimizerswitches) or (pass > 0) then
     doRenaming(asml, first, last);
   cse := removeInstructs(asml, first, last);
 end;

+ 4 - 4
compiler/i386/daopt386.pas

@@ -1808,7 +1808,7 @@ begin
         refsEq := {$ifdef fpc}@{$endif}refsOverlapping;
       invalsmemwrite :=
         assigned(c.memwrite) and
-        ((not(cs_uncertainOpts in aktglobalswitches) and
+        ((not(cs_opt_size in aktoptimizerswitches) and
           containsPointerRef(c.memwrite)) or
          refsEq(c.memwrite.oper[1]^.ref^,ref,topsize2tcgsize[c.memwrite.opsize],size));
       if not(c.typ in [con_ref,con_noRemoveRef,con_invalid]) then
@@ -1829,7 +1829,7 @@ begin
       with c do
         writeToMemDestroysContents :=
           (typ in [con_ref,con_noRemoveRef]) and
-          ((not(cs_uncertainOpts in aktglobalswitches) and
+          ((not(cs_opt_size in aktoptimizerswitches) and
             containsPointerLoad(c)
            ) or
            (refInSequence(ref,c,refsEq,size) and
@@ -1853,7 +1853,7 @@ begin
     begin
       invalsmemwrite :=
         assigned(c.memwrite) and
-        (not(cs_UncertainOpts in aktglobalswitches) or
+        (not(cs_opt_size in aktoptimizerswitches) or
          containsPointerRef(c.memwrite));
       if not(c.typ in [con_ref,con_noRemoveRef,con_invalid]) then
         begin
@@ -1863,7 +1863,7 @@ begin
       with c do
         writeToMemDestroysContents :=
           (typ in [con_ref,con_noRemoveRef]) and
-          (not(cs_UncertainOpts in aktglobalswitches) or
+          (not(cs_opt_size in aktoptimizerswitches) or
          { for movsl }
            ((ref.base = NR_EDI) and (ref.index = NR_EDI)) or
          { don't destroy if reg contains a parameter, local or global variable }

+ 2 - 2
compiler/i386/n386cal.pas

@@ -91,8 +91,8 @@ implementation
         { but the registers must be different!        }
         else
           if (pop_size=8) and
-             not(cs_littlesize in aktglobalswitches) and
-             (aktoptprocessor=ClassPentium) then
+             not(cs_opt_size in aktoptimizerswitches) and
+             (aktoptcputype=cpu_Pentium) then
             begin
                hreg:=cg.getintregister(exprasmlist,OS_INT);
                exprasmlist.concat(taicpu.op_reg(A_POP,S_L,hreg));

+ 2 - 2
compiler/i386/n386mat.pas

@@ -107,8 +107,8 @@ implementation
                   "Cardinal($ffffffff) div 16" overflows! (JM) }
                 if is_signed(left.resulttype.def) Then
                   begin
-                    if (aktOptProcessor <> class386) and
-                       not(cs_littlesize in aktglobalswitches) then
+                    if (aktOptcputype <> cpu_386) and
+                       not(cs_opt_size in aktoptimizerswitches) then
                       { use a sequence without jumps, saw this in
                         comp.compilers (JM) }
                       begin

+ 4 - 4
compiler/i386/n386set.pas

@@ -59,13 +59,13 @@ implementation
     procedure ti386casenode.optimizevalues(var max_linear_list:aint;var max_dist:aword);
       begin
         { a jump table crashes the pipeline! }
-        if aktoptprocessor=Class386 then
+        if aktoptcputype=cpu_386 then
           inc(max_linear_list,3)
-        else if aktoptprocessor=ClassPentium then
+        else if aktoptcputype=cpu_Pentium then
           inc(max_linear_list,6)
-        else if aktoptprocessor in [ClassPentium2,ClassPentium3] then
+        else if aktoptcputype in [cpu_Pentium2,cpu_Pentium3] then
           inc(max_linear_list,9)
-        else if aktoptprocessor=ClassPentium4 then
+        else if aktoptcputype=cpu_Pentium4 then
           inc(max_linear_list,14);
       end;
 

+ 20 - 20
compiler/i386/popt386.pas

@@ -148,9 +148,9 @@ begin
                     else if
                      ((taicpu(p).ops <= 2) or
                       (taicpu(p).oper[2]^.typ = Top_Reg)) and
-                     (aktoptprocessor < ClassPentium2) and
+                     (aktoptcputype < cpu_Pentium2) and
                      (taicpu(p).oper[0]^.val <= 12) and
-                     not(CS_LittleSize in aktglobalswitches) and
+                     not(cs_opt_size in aktoptimizerswitches) and
                      (not(GetNextInstruction(p, hp1)) or
                        {GetNextInstruction(p, hp1) and}
                        not((tai(hp1).typ = ait_instruction) and
@@ -198,7 +198,7 @@ begin
                              imul 6, reg1 to
                                lea (reg1,reg1,2), reg1
                                add reg1, reg1}
-                              if (aktoptprocessor <= Class386) then
+                              if (aktoptcputype <= cpu_386) then
                                 begin
                                   TmpRef.index := taicpu(p).oper[1]^.reg;
                                   if (taicpu(p).ops = 3) then
@@ -255,7 +255,7 @@ begin
                              imul 10, reg1 to
                                lea (reg1,reg1,4), reg1
                                add reg1, reg1}
-                               if (aktoptprocessor <= Class386) then
+                               if (aktoptcputype <= cpu_386) then
                                  begin
                                    if (taicpu(p).ops = 3) then
                                      hp1 :=  taicpu.op_reg_reg(A_ADD, S_L,
@@ -283,7 +283,7 @@ begin
                              imul 12, reg1 to
                                lea (reg1,reg1,2), reg1
                                lea (,reg1,4), reg1}
-                               if (aktoptprocessor <= Class386)
+                               if (aktoptcputype <= cpu_386)
                                  then
                                    begin
                                      TmpRef.index := taicpu(p).oper[1]^.reg;
@@ -337,7 +337,7 @@ begin
                      (taicpu(hp1).oper[1]^.typ = taicpu(p).oper[1]^.typ) and
                      OpsEqual(taicpu(hp1).oper[1]^, taicpu(p).oper[1]^) then
                     if (taicpu(p).oper[0]^.val > taicpu(hp1).oper[0]^.val) and
-                       not(CS_LittleSize in aktglobalswitches) then
+                       not(cs_opt_size in aktoptimizerswitches) then
                   { shr/sar const1, %reg
                     shl     const2, %reg
                     with const1 > const2 }
@@ -352,7 +352,7 @@ begin
                         end;
                       end
                     else if (taicpu(p).oper[0]^.val<taicpu(hp1).oper[0]^.val) and
-                            not(CS_LittleSize in aktglobalswitches) then
+                            not(cs_opt_size in aktoptimizerswitches) then
                   { shr/sar const1, %reg
                     shl     const2, %reg
                     with const1 < const2 }
@@ -1243,7 +1243,7 @@ begin
                             S_BW:
                               begin
                                 if (getsupreg(taicpu(p).oper[0]^.reg)=getsupreg(taicpu(p).oper[1]^.reg)) and
-                                   not(CS_LittleSize in aktglobalswitches) then
+                                   not(cs_opt_size in aktoptimizerswitches) then
                                   {Change "movzbw %al, %ax" to "andw $0x0ffh, %ax"}
                                   begin
                                     taicpu(p).opcode := A_AND;
@@ -1268,7 +1268,7 @@ begin
                             S_BL:
                               begin
                                 if (getsupreg(taicpu(p).oper[0]^.reg)=getsupreg(taicpu(p).oper[1]^.reg)) and
-                                   not(CS_LittleSize in aktglobalswitches) then
+                                   not(cs_opt_size in aktoptimizerswitches) then
                                   {Change "movzbl %al, %eax" to "andl $0x0ffh, %eax"}
                                   begin
                                     taicpu(p).opcode := A_AND;
@@ -1293,7 +1293,7 @@ begin
                             S_WL:
                               begin
                                 if (getsupreg(taicpu(p).oper[0]^.reg)=getsupreg(taicpu(p).oper[1]^.reg)) and
-                                   not(CS_LittleSize in aktglobalswitches) then
+                                   not(cs_opt_size in aktoptimizerswitches) then
                                 {Change "movzwl %ax, %eax" to "andl $0x0ffffh, %eax"}
                                   begin
                                     taicpu(p).opcode := A_AND;
@@ -1509,9 +1509,9 @@ begin
                                   end;
                             end;
                           if TmpBool2 or
-                             ((aktoptprocessor < ClassPentium2) and
+                             ((aktoptcputype < cpu_Pentium2) and
                              (taicpu(p).oper[0]^.val <= 3) and
-                             not(CS_LittleSize in aktglobalswitches)) then
+                             not(cs_opt_size in aktoptimizerswitches)) then
                             begin
                               if not(TmpBool2) and
                                   (taicpu(p).oper[0]^.val = 1) then
@@ -1528,7 +1528,7 @@ begin
                             end;
                         end
                       else
-                        if (aktoptprocessor < ClassPentium2) and
+                        if (aktoptcputype < cpu_Pentium2) and
                            (taicpu(p).oper[0]^.typ = top_const) and
                            (taicpu(p).oper[1]^.typ = top_reg) then
                           if (taicpu(p).oper[0]^.val = 1) then
@@ -1698,7 +1698,7 @@ begin
             case taicpu(p).opcode Of
 {$ifdef USECMOV}
               A_Jcc:
-                if (aktspecificoptprocessor>=ClassPentium2) then
+                if (aktspecificoptcputype>=cpu_Pentium2) then
                   begin
                      { check for
                             jCC   xxx
@@ -1930,7 +1930,7 @@ begin
           begin
             case taicpu(p).opcode Of
               A_CALL:
-                if (AktOptProcessor < ClassPentium2) and
+                if (AktOptcputype < cpu_Pentium2) and
                    GetNextInstruction(p, hp1) and
                    (hp1.typ = ait_instruction) and
                    (taicpu(hp1).opcode = A_JMP) and
@@ -1973,7 +1973,7 @@ See test/tgadint64 in the test suite.
                 {   "cmpl $3,%eax; movzbl 8(%ebp),%ebx; je .Lxxx"           }
                 { so we can't safely replace the movzx then with xor/mov,   }
                 { since that would change the flags (JM)                    }
-                if not(cs_regvars in aktglobalswitches) then
+                if not(cs_opt_regvar in aktoptimizerswitches) then
                  begin
                   if (taicpu(p).oper[1]^.typ = top_reg) then
                     if (taicpu(p).oper[0]^.typ = top_reg)
@@ -1982,8 +1982,8 @@ See test/tgadint64 in the test suite.
                           S_BL:
                             begin
                               if IsGP32Reg(getsupreg(taicpu(p).oper[1]^.reg)) and
-                                 not(CS_LittleSize in aktglobalswitches) and
-                                 (aktoptprocessor = ClassPentium) then
+                                 not(cs_opt_size in aktoptimizerswitches) and
+                                 (aktoptcputype = cpu_Pentium) then
                                   {Change "movzbl %reg1, %reg2" to
                                    "xorl %reg2, %reg2; movb %reg1, %reg2" for Pentium and
                                    PentiumMMX}
@@ -2000,9 +2000,9 @@ See test/tgadint64 in the test suite.
                       else if (taicpu(p).oper[0]^.typ = top_ref) and
                           (taicpu(p).oper[0]^.ref^.base <> taicpu(p).oper[1]^.reg) and
                           (taicpu(p).oper[0]^.ref^.index <> taicpu(p).oper[1]^.reg) and
-                          not(CS_LittleSize in aktglobalswitches) and
+                          not(cs_opt_size in aktoptimizerswitches) and
                           IsGP32Reg(getsupreg(taicpu(p).oper[1]^.reg)) and
-                          (aktoptprocessor = ClassPentium) and
+                          (aktoptcputype = cpu_Pentium) and
                           (taicpu(p).opsize = S_BL) then
                         {changes "movzbl mem, %reg" to "xorl %reg, %reg; movb mem, %reg8" for
                           Pentium and PentiumMMX}

+ 16 - 16
compiler/m68k/cgcpu.pas

@@ -211,7 +211,7 @@ unit cgcpu;
            addressing capabilities with a 32-bit
            displacement.
          }
-         if (aktoptprocessor<>MC68000) then
+         if (aktoptcputype<>cpu_MC68000) then
            exit;
          if (ref.base<>NR_NO) then
            begin
@@ -434,7 +434,7 @@ unit cgcpu;
               end;
           OP_IMUL :
               begin
-                if aktoptprocessor = MC68000 then
+                if aktoptcputype = cpu_MC68000 then
                    begin
                      r:=NR_D0;
                      r2:=NR_D1;
@@ -463,7 +463,7 @@ unit cgcpu;
               end;
           OP_MUL :
               begin
-                 if aktoptprocessor = MC68000 then
+                 if aktoptcputype = cpu_MC68000 then
                    begin
                      r:=NR_D0;
                      r2:=NR_D1;
@@ -550,7 +550,7 @@ unit cgcpu;
         case op of
           OP_ADD :
               begin
-                 if aktoptprocessor = ColdFire then
+                 if aktoptcputype = cpu_ColdFire then
                   begin
                     { operation only allowed only a longword }
                     sign_extend(list, size, reg1);
@@ -583,7 +583,7 @@ unit cgcpu;
                  else
                    hreg2 := reg2;
 
-                 if aktoptprocessor = ColdFire then
+                 if aktoptcputype = cpu_ColdFire then
                   begin
                     { operation only allowed only a longword }
                     {!***************************************
@@ -620,7 +620,7 @@ unit cgcpu;
               begin
                  sign_extend(list, size,reg1);
                  sign_extend(list, size,reg2);
-                 if aktoptprocessor = MC68000 then
+                 if aktoptcputype = cpu_MC68000 then
                    begin
                      r:=NR_D0;
                      r2:=NR_D1;
@@ -663,7 +663,7 @@ unit cgcpu;
               begin
                  sign_extend(list, size,reg1);
                  sign_extend(list, size,reg2);
-                 if aktoptprocessor = MC68000 then
+                 if aktoptcputype = cpu_MC68000 then
                    begin
                      r:=NR_D0;
                      r2:=NR_D1;
@@ -722,7 +722,7 @@ unit cgcpu;
                     hreg2 := reg2;
 
                 { coldfire only supports long version }
-                if aktoptprocessor = ColdFire then
+                if aktoptcputype = cpu_ColdFire then
                   begin
                     sign_extend(list, size,hreg2);
                     list.concat(taicpu.op_reg(topcg2tasmop[op],S_L,hreg2));
@@ -756,7 +756,7 @@ unit cgcpu;
          end
        else
          begin
-           if (aktoptprocessor = ColdFire) then
+           if (aktoptcputype = cpu_ColdFire) then
              begin
                {
                  only longword comparison is supported,
@@ -818,7 +818,7 @@ unit cgcpu;
               ai.SetCondition(flags_to_cond(f));
               list.concat(ai);
 
-              if (aktoptprocessor = ColdFire) then
+              if (aktoptcputype = cpu_ColdFire) then
                 begin
                  { neg.b does not exist on the Coldfire
                    so we need to sign extend the value
@@ -840,7 +840,7 @@ unit cgcpu;
             ai.SetCondition(flags_to_cond(f));
             list.concat(ai);
 
-            if (aktoptprocessor = ColdFire) then
+            if (aktoptcputype = cpu_ColdFire) then
               begin
                  { neg.b does not exist on the Coldfire
                    so we need to sign extend the value
@@ -883,13 +883,13 @@ unit cgcpu;
          { this should never occur }
          if len > 65535 then
            internalerror(0);
-	
+
          hregister := getintregister(list,OS_INT);
 //         if delsource then
 //            reference_release(list,source);
 
          { from 12 bytes movs is being used }
-         if {(not loadref) and} ((len<=8) or (not(cs_littlesize in aktglobalswitches) and (len<=12))) then
+         if {(not loadref) and} ((len<=8) or (not(cs_opt_size in aktoptimizerswitches) and (len<=12))) then
            begin
               srcref := source;
               dstref := dest;
@@ -943,7 +943,7 @@ unit cgcpu;
               { double word move only on 68020+ machines }
               { because of possible alignment problems   }
               { use fast loop mode }
-              if (aktoptprocessor=MC68020) then
+              if (aktoptcputype=cpu_MC68020) then
                 begin
                    helpsize := len - len mod 4;
                    len := len mod 4;
@@ -1059,7 +1059,7 @@ unit cgcpu;
             { return with immediate size possible here
               signed!
               RTD is not supported on the coldfire     }
-            if (aktoptprocessor=MC68020) and (parasize<$7FFF) then
+            if (aktoptcputype=cpu_MC68020) and (parasize<$7FFF) then
                 list.concat(taicpu.op_const(A_RTD,S_NO,parasize))
             { manually restore the stack }
             else
@@ -1143,7 +1143,7 @@ unit cgcpu;
               begin
                 if (isaddressregister(reg)) then
                    internalerror(20020729);
-                if (aktoptprocessor = MC68000) then
+                if (aktoptcputype = cpu_MC68000) then
                   begin
                     list.concat(taicpu.op_reg(A_EXT,S_W,reg));
                     list.concat(taicpu.op_reg(A_EXT,S_L,reg));

+ 11 - 7
compiler/m68k/cpuinfo.pas

@@ -30,15 +30,15 @@ Type
    pbestreal=^bestreal;
 
    { possible supported processors for this target }
-   tprocessors =
-      (no_processor,
-       MC68000,
-       MC68020,
-       Coldfire
+   tcputype =
+      (cpu_none,
+       cpu_MC68000,
+       cpu_MC68020,
+       cpu_Coldfire
       );
 
    tfputype =
-     (no_fpuprocessor,
+     (fpu_none,
       fpu_soft,
       fpu_libgcc,
       fpu_68881
@@ -57,7 +57,7 @@ Const
      pocall_syscall
    ];
 
-   processorsstr : array[tprocessors] of string[5] = ('',
+   cputypestr : array[tcputype] of string[8] = ('',
      '68000',
      '68020',
      'COLDFIRE'
@@ -69,6 +69,10 @@ Const
      '68881'
    );
 
+   level1optimizerswitches = [cs_opt_level1];
+   level2optimizerswitches = level1optimizerswitches + [cs_opt_level2,cs_opt_regvar,cs_opt_stackframe];
+   level3optimizerswitches = level2optimizerswitches + [cs_opt_level3,cs_opt_loopunroll];
+
 Implementation
 
 end.

+ 0 - 106
compiler/m68k/cpuswtch.pas

@@ -1,106 +0,0 @@
-{
-    Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
-
-    interprets the commandline options which are 680x0 specific
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ****************************************************************************
-}
-unit cpuswtch;
-
-{$i fpcdefs.inc}
-
-interface
-
-uses
-  options;
-
-type
-  toptionm68k=class(toption)
-    procedure interpret_proc_specific_options(const opt:string);override;
-  end;
-
-implementation
-
-uses
-  cutils,globtype,systems,globals,cpuinfo;
-
-procedure toptionm68k.interpret_proc_specific_options(const opt:string);
-var
-  j     : longint;
-  More  : string;
-begin
-  More:=Upper(copy(opt,3,length(opt)-2));
-  case opt[2] of
-   'O' : Begin
-           j := 3;
-           While (j <= Length(Opt)) Do
-             Begin
-               case opt[j] of
-                 '-' :
-                   begin
-                     initglobalswitches:=initglobalswitches-[cs_optimize,cs_fastoptimize,cs_slowoptimize,cs_littlesize,
-                       cs_regvars,cs_uncertainopts];
-                     FillChar(ParaAlignment,sizeof(ParaAlignment),0);
-                   end;
-                 'a' :
-                   begin
-                     UpdateAlignmentStr(Copy(Opt,j+1,255),ParaAlignment);
-                     j:=length(Opt);
-                   end;
-                 'g' : initglobalswitches:=initglobalswitches+[cs_littlesize];
-                 'G' : initglobalswitches:=initglobalswitches-[cs_littlesize];
-                 'r' :
-                   begin
-                     initglobalswitches:=initglobalswitches+[cs_regvars];
-                     Simplify_ppu:=false;
-                   end;
-                 'u' : initglobalswitches:=initglobalswitches+[cs_uncertainopts];
-                 '1' : initglobalswitches:=initglobalswitches-[cs_fastoptimize,cs_slowoptimize]+[cs_optimize];
-                 '2' : initglobalswitches:=initglobalswitches-[cs_slowoptimize]+[cs_optimize,cs_fastoptimize];
-                 '3' : initglobalswitches:=initglobalswitches+[cs_optimize,cs_fastoptimize,cs_slowoptimize];
-                 'p' :
-                   Begin
-                     If j < Length(Opt) Then
-                       Begin
-                         Case opt[j+1] Of
-                           '2': initoptprocessor := MC68020;
-                           Else IllegalPara(Opt)
-                         End;
-                         Inc(j);
-                       End
-                     Else IllegalPara(opt)
-                   End;
-                 else IllegalPara(opt);
-               End;
-               Inc(j)
-             end;
-         end;
-   'R' : begin
-           if More='GAS' then
-            initasmmode:=asmmode_standard
-           else
-            IllegalPara(opt);
-         end;
-  else
-   IllegalPara(opt);
-  end;
-end;
-
-
-initialization
-  coption:=toptionm68k;
-end.

+ 3 - 3
compiler/m68k/n68kmat.pas

@@ -145,7 +145,7 @@ implementation
      paraloc1 : tcgpara;
    begin
      { no RTL call, so inline a zero denominator verification }
-     if aktoptprocessor <> MC68000 then
+     if aktoptcputype <> cpu_MC68000 then
        begin
          { verify if denominator is zero }
          objectlibrary.getjumplabel(continuelabel);
@@ -193,7 +193,7 @@ implementation
     begin
 //     writeln('emit mod reg reg');
      { no RTL call, so inline a zero denominator verification }
-     if aktoptprocessor <> MC68000 then
+     if aktoptcputype <> cpu_MC68000 then
        begin
          { verify if denominator is zero }
          objectlibrary.getjumplabel(continuelabel);
@@ -245,7 +245,7 @@ implementation
         cg.ungetcpuregister(exprasmlist,Reg_D0);
         cg.ungetcpuregister(exprasmlist,Reg_D1);
        end;
-//      writeln('exits'); 
+//      writeln('exits');
     end;
 
 

+ 9 - 9
compiler/m68k/ra68kmot.pas

@@ -1364,7 +1364,7 @@ const
                      BuildReference(oper);
                    end
                  else { is it a label variable ? }
-                 
+
                      { // ID[ , ID.Field.Field or simple ID // }
                      { check if this is a label, if so then }
                      { emit it as a label.                  }
@@ -1377,9 +1377,9 @@ const
                          Consume(AS_ID);
                          if not (actasmtoken in [AS_SEPARATOR,AS_COMMA]) then
                           Message(asmr_e_syntax_error);
-                          
+
                        end
-                      else begin     
+                      else begin
                        expr:=actasmpattern;
                        Consume(AS_ID);
                        { typecasting? }
@@ -1414,25 +1414,25 @@ const
                               else begin
                                 writeln('unknown id: ',expr);
                                 Message1(sym_e_unknown_id,expr);
-                              end;    
+                              end;
                               expr:='';
                             end;
                          end;
 //                       Message1(sym_e_unknown_id,actasmpattern);
-                      end;        
+                      end;
 
                        case actasmtoken of
                          AS_LPAREN: { indexing }
                            BuildReference(oper);
                          AS_SEPARATOR,AS_COMMA: begin
                          end;
-                       else 
+                       else
                          Message(asmr_e_syntax_error);
                        end;
 
                    end;
                end;
-            
+
    { // Pre-decrement mode reference or constant mem offset.   // }
      AS_MINUS:    begin
                    Consume(AS_MINUS);
@@ -1555,7 +1555,7 @@ const
                    { DIVSL/DIVS/MULS/MULU with long for MC68020 only }
                    if (actasmtoken = AS_COLON) then
                    begin
-                     if (aktoptprocessor = MC68020) or (cs_compilesystem in aktmoduleswitches) then
+                     if (aktoptcputype = cpu_MC68020) or (cs_compilesystem in aktmoduleswitches) then
                      begin
                        Consume(AS_COLON);
                        if (actasmtoken = AS_REGISTER) then
@@ -1778,7 +1778,7 @@ const
                      instr.ConcatLabeledInstr(curlist)
                   else begin
                     instr.ConcatInstruction(curlist);
-                  end;    
+                  end;
                   instr.Free;
 {
                   instr.init;

+ 7 - 4
compiler/mips/cpuinfo.pas

@@ -30,13 +30,13 @@ Type
    pbestreal=^bestreal;
 
    { possible supported processors for this target }
-   tprocessors =
-      (no_processor,
+   tcputype =
+      (cpu_none,
        mips32
       );
 
    tfputype =
-     (no_fpuprocessor,
+     (fpu_none,
       fpu_fpu
      );
 
@@ -58,7 +58,7 @@ Const
      pocall_cppdecl
    ];
 
-   processorsstr : array[tprocessors] of string[5] = ('',
+   cputypestr : array[tcputype] of string[5] = ('',
      'MIPS32'
    );
 
@@ -66,6 +66,9 @@ Const
      'FPU'
    );
 
+   level1optimizerswitches = [];
+   level2optimizerswitches = level1optimizerswitches + [cs_opt_regvar,cs_opt_stackframe];
+   level3optimizerswitches = level2optimizerswitches + [cs_opt_loopunroll];
 
 Implementation
 

+ 2 - 2
compiler/msg/errore.msg

@@ -2113,11 +2113,11 @@ option_no_debug_support_recompile_fpc=11017_H_Try recompiling with -dGDB
 % It is possible to have a compiler executable that doesn't support
 % the generation of debugging info. If you use such an executable with the
 % \var{-g} switch, this warning will be displayed.
-option_obsolete_switch=11018_E_You are using the obsolete switch $1
+option_obsolete_switch=11018_W_You are using the obsolete switch $1
 % this warns you when you use a switch that is not needed/supported anymore.
 % It is recommended that you remove the switch to overcome problems in the
 % future, when the switch meaning may change.
-option_obsolete_switch_use_new=11019_E_You are using the obsolete switch $1, please use $2
+option_obsolete_switch_use_new=11019_W_You are using the obsolete switch $1, please use $2
 % this warns you when you use a switch that is not supported anymore. You
 % must now use the second switch instead.
 % It is recommended that you change the switch to overcome problems in the

+ 2 - 2
compiler/msgtxt.inc

@@ -702,8 +702,8 @@ const msgtxt : array[0..000165,1..240] of char=(
   '11016_W_Debug information generation is not supported by this executab'+
   'le'#000+
   '11017_H_Try recompiling with -dG','DB'#000+
-  '11018_E_You are using the obsolete switch $1'#000+
-  '11019_E_You are using the obsolete switch $1, please use $2'#000+
+  '11018_W_You are using the obsolete switch $1'#000+
+  '11019_W_You are using the obsolete switch $1, please use $2'#000+
   '11020_N_Switching assembler to default source writing assembler'#000+
   '11021_W_Assembler output selected "$1" is not compatible with "$2"'#000+
   '1','1022_W_"$1" assembler use forced'#000+

+ 0 - 48
compiler/nbas.pas

@@ -425,54 +425,6 @@ implementation
          hp:=tstatementnode(left);
          while assigned(hp) do
            begin
-(*
-              if cs_regvars in aktglobalswitches then
-                begin
-                   { node transformations }
-
-                   { concat function result to exit }
-                   { this is wrong for string or other complex
-                     result types !!! }
-                   if {ret_in_acc(current_procinfo.procdef.rettype.def) and }
-                      (is_ordinal(current_procinfo.procdef.rettype.def) or
-                       is_smallset(current_procinfo.procdef.rettype.def)) and
-                      assigned(hp.right) and
-                      assigned(tstatementnode(hp.right).left) and
-                      (tstatementnode(hp.right).left.nodetype=exitn) and
-                      (hp.left.nodetype=assignn) and
-                      { !!!! this tbinarynode should be tassignmentnode }
-                      (tbinarynode(hp.left).left.nodetype=loadn) and
-                      (is_funcret_sym(tloadnode(tbinarynode(hp.left).left).symtableentry)) then
-                      begin
-                         if assigned(texitnode(tstatementnode(hp.right).left).left) then
-                           CGMessage(cg_n_inefficient_code)
-                         else
-                           begin
-                              texitnode(tstatementnode(hp.right).left).left:=tassignmentnode(hp.left).right;
-                              tassignmentnode(hp.left).right:=nil;
-                              hp.left.free;
-                              hp.left:=nil;
-                           end;
-                      end
-                   { warning if unreachable code occurs and elimate this }
-                   else if (hp.left.nodetype in
-                     [exitn,breakn,continuen,goton]) and
-                     { statement node (JM) }
-                     assigned(hp.right) and
-                     { kind of statement! (JM) }
-                     assigned(tstatementnode(hp.right).left) and
-                     (tstatementnode(hp.right).left.nodetype<>labeln) then
-                     begin
-                        { use correct line number }
-                        aktfilepos:=hp.right.fileinfo;
-                        hp.right.free;
-                        hp.right:=nil;
-                        CGMessage(cg_w_unreachable_code);
-                        { old lines }
-                        aktfilepos:=hp.left.fileinfo;
-                     end;
-                end;
-*)
               if assigned(hp.left) then
                 begin
                    codegenerror:=false;

+ 1 - 1
compiler/ncal.pas

@@ -2391,7 +2391,7 @@ type
            begin
              tcallparanode(left).det_registers;
 
-             if cs_optimize in aktglobalswitches then
+             if cs_opt_level1 in aktoptimizerswitches then
                begin
                  { check for stacked parameters }
                  check_stack_parameters;

+ 2 - 2
compiler/ncgbas.pas

@@ -475,7 +475,7 @@ interface
           LOC_CREGISTER,
           LOC_REGISTER:
             begin
-              if not(cs_regvars in aktglobalswitches) or
+              if not(cs_opt_regvar in aktoptimizerswitches) or
                  (pi_has_goto in current_procinfo.flags) then
                 begin
                   { make sure the register allocator doesn't reuse the }
@@ -498,7 +498,7 @@ interface
           LOC_CFPUREGISTER,
           LOC_FPUREGISTER:
             begin
-              if not(cs_regvars in aktglobalswitches) or
+              if not(cs_opt_regvar in aktoptimizerswitches) or
                  (pi_has_goto in current_procinfo.flags) then
                 begin
                   { make sure the register allocator doesn't reuse the }

+ 11 - 11
compiler/ncgflw.pas

@@ -107,7 +107,7 @@ implementation
 
     procedure tcgwhilerepeatnode.sync_regvars(checkusedregvars: boolean);
       begin
-         if (cs_regvars in aktglobalswitches) and
+         if (cs_opt_regvar in aktoptimizerswitches) and
             not(pi_has_goto in current_procinfo.flags) then
            begin
              if checkusedregvars then
@@ -158,7 +158,7 @@ implementation
          if lnf_testatbegin in loopflags then
            cg.a_jmp_always(exprasmlist,lcont);
 
-         if not(cs_littlesize in aktglobalswitches) then
+         if not(cs_opt_size in aktoptimizerswitches) then
             { align loop target }
             exprasmList.concat(Tai_align.Create(aktalignment.loopalign));
 
@@ -235,7 +235,7 @@ implementation
 (*
          { save regvars loaded in the beginning so that we can restore them }
          { when processing the else-block                                   }
-         if cs_regvars in aktglobalswitches then
+         if cs_opt_regvar in aktoptimizerswitches then
            begin
              org_list := exprasmlist;
              exprasmlist := taasmoutput.create;
@@ -244,7 +244,7 @@ implementation
          maketojumpbool(exprasmlist,left,lr_dont_load_regvars);
 
 (*
-         if cs_regvars in aktglobalswitches then
+         if cs_opt_regvar in aktoptimizerswitches then
            begin
              org_regvar_loaded_int := rg.regvar_loaded_int;
              org_regvar_loaded_other := rg.regvar_loaded_other;
@@ -260,7 +260,7 @@ implementation
          { save current asmlist (previous instructions + then-block) and }
          { loaded regvar state and create new clean ones                 }
 {
-         if cs_regvars in aktglobalswitches then
+         if cs_opt_regvar in aktoptimizerswitches then
            begin
              then_regvar_loaded_int := rg.regvar_loaded_int;
              then_regvar_loaded_other := rg.regvar_loaded_other;
@@ -278,7 +278,7 @@ implementation
                    objectlibrary.getjumplabel(hl);
                    { do go back to if line !! }
 (*
-                   if not(cs_regvars in aktglobalswitches) then
+                   if not(cs_opt_regvar in aktoptimizerswitches) then
 *)
                      aktfilepos:=exprasmList.getlasttaifilepos^
 (*
@@ -293,7 +293,7 @@ implementation
 (*
               { save current asmlist (previous instructions + else-block) }
               { and loaded regvar state and create a new clean list       }
-              if cs_regvars in aktglobalswitches then
+              if cs_opt_regvar in aktoptimizerswitches then
                 begin
 {                  else_regvar_loaded_int := rg.regvar_loaded_int;
                   else_regvar_loaded_other := rg.regvar_loaded_other;}
@@ -307,7 +307,7 @@ implementation
          else
            begin
 (*
-              if cs_regvars in aktglobalswitches then
+              if cs_opt_regvar in aktoptimizerswitches then
                 begin
 {                  else_regvar_loaded_int := rg.regvar_loaded_int;
                   else_regvar_loaded_other := rg.regvar_loaded_other;}
@@ -323,7 +323,7 @@ implementation
            end;
 
 (*
-         if cs_regvars in aktglobalswitches then
+         if cs_opt_regvar in aktoptimizerswitches then
            begin
              { add loads of regvars at the end of the then- and else-blocks  }
              { so that at the end of both blocks the same regvars are loaded }
@@ -368,7 +368,7 @@ implementation
 
     procedure tcgfornode.sync_regvars(checkusedregvars: boolean);
       begin
-         if (cs_regvars in aktglobalswitches) and
+         if (cs_opt_regvar in aktoptimizerswitches) and
             not(pi_has_goto in current_procinfo.flags) then
            begin
              if checkusedregvars then
@@ -508,7 +508,7 @@ implementation
            cg.a_jmp_always(exprasmlist,tcglabelnode(entrylabel).getasmlabel);
 
          { align loop target }
-         if not(cs_littlesize in aktglobalswitches) then
+         if not(cs_opt_size in aktoptimizerswitches) then
             exprasmList.concat(Tai_align.Create(aktalignment.loopalign));
          cg.a_label(exprasmlist,l3);
 

+ 1 - 1
compiler/ncgmem.pas

@@ -612,7 +612,7 @@ implementation
          else
          { not nodetype=ordconstn }
            begin
-              if (cs_regvars in aktglobalswitches) and
+              if (cs_opt_regvar in aktoptimizerswitches) and
                  { if we do range checking, we don't }
                  { need that fancy code (it would be }
                  { buggy)                            }

+ 3 - 3
compiler/ncgset.pas

@@ -190,7 +190,7 @@ implementation
              { Lots of comparisions take a lot of time, so do not allow
                too much comparisions. 8 comparisions are, however, still
                smalller than emitting the set }
-             if cs_littlesize in aktglobalswitches then
+             if cs_opt_size in aktoptimizerswitches then
               maxcompares:=8
              else
               maxcompares:=5;
@@ -747,7 +747,7 @@ implementation
          else
 {$endif cpu64bit}
            begin
-              if cs_optimize in aktglobalswitches then
+              if cs_opt_level1 in aktoptimizerswitches then
                 begin
                    { procedures are empirically passed on }
                    { consumption can also be calculated   }
@@ -775,7 +775,7 @@ implementation
                      dist:=max_label-min_label;
 
                    { optimize for size ? }
-                   if cs_littlesize in aktglobalswitches  then
+                   if cs_opt_size in aktoptimizerswitches  then
                      begin
                        if has_jumptable and
                           not((labelcnt<=2) or

+ 2 - 2
compiler/ncgutil.pas

@@ -331,10 +331,10 @@ implementation
             end;
           LOC_CREFERENCE,LOC_REFERENCE:
             begin
-              if not(cs_regvars in aktglobalswitches) or
+              if not(cs_opt_regvar in aktoptimizerswitches) or
                  (getsupreg(t.reference.base) in cg.rgint.usableregs) then
                 exclude(regs,getsupreg(t.reference.base));
-              if not(cs_regvars in aktglobalswitches) or
+              if not(cs_opt_regvar in aktoptimizerswitches) or
                  (getsupreg(t.reference.index) in cg.rgint.usableregs) then
                 exclude(regs,getsupreg(t.reference.index));
             end;

+ 5 - 5
compiler/nflw.pas

@@ -497,7 +497,7 @@ implementation
          old_t_times:=cg.t_times;
 
          { calc register weight }
-         if not(cs_littlesize in aktglobalswitches ) then
+         if not(cs_opt_size in aktoptimizerswitches) then
            cg.t_times:=cg.t_times*8;
 
          firstpass(left);
@@ -530,7 +530,7 @@ implementation
 {$ifdef prefetchnext}
          { do at the end so all complex typeconversions are already }
          { converted to calln's                                     }
-         if (cs_optimize in aktglobalswitches) and
+         if (cs_opt_level1 in aktoptimizerswitches) and
             (lnf_testatbegin in loopflags) then
            begin
              { get first component of the while check }
@@ -734,7 +734,7 @@ implementation
 {$endif SUPPORT_MMX}
 
          { determines registers weigths }
-         if not(cs_littlesize in aktglobalswitches) then
+         if not(cs_opt_size in aktoptimizerswitches) then
            cg.t_times:=cg.t_times div 2;
          if cg.t_times=0 then
            cg.t_times:=1;
@@ -818,7 +818,7 @@ implementation
          resulttype:=voidtype;
 
          { loop unrolling }
-         if cs_loopunroll in aktglobalswitches then
+         if cs_opt_loopunroll in aktoptimizerswitches then
            begin
              unrollres:=unroll_loop(self);
              if assigned(unrollres) then
@@ -903,7 +903,7 @@ implementation
           begin
             { Calc register weight }
             old_t_times:=cg.t_times;
-            if not(cs_littlesize in aktglobalswitches) then
+            if not(cs_opt_size in aktoptimizerswitches) then
               cg.t_times:=cg.t_times*8;
             firstpass(t2);
             if codegenerror then

+ 2 - 2
compiler/nld.pas

@@ -691,7 +691,7 @@ implementation
               if (right.nodetype<>stringconstn) or
                  (tstringconstnode(right).len<>0) then
                begin
-                 if (cs_optimize in aktglobalswitches) and
+                 if (cs_opt_level1 in aktoptimizerswitches) and
                     (right.nodetype in [calln,blockn]) and
                     (left.nodetype = temprefn) and
                     is_shortstring(right.resulttype.def) and
@@ -724,7 +724,7 @@ implementation
             end;
            end;
 
-         if (cs_optimize in aktglobalswitches) and
+         if (cs_opt_level1 in aktoptimizerswitches) and
             (right.nodetype = calln) and
             { left must be a temp, since otherwise as soon as you modify the }
             { result, the current left node is modified and that one may     }

+ 2 - 2
compiler/nmat.pas

@@ -352,7 +352,7 @@ implementation
       begin
         result := nil;
         { divide/mod a number by a constant which is a power of 2? }
-        if (cs_optimize in aktglobalswitches) and
+        if (cs_opt_peephole in aktoptimizerswitches) and
            (right.nodetype = ordconstn) and
 {           ((nodetype = divn) or
             not is_signed(resulttype.def)) and}
@@ -365,7 +365,7 @@ implementation
                 if is_signed(resulttype.def) then
                   begin
                     if is_64bitint(left.resulttype.def) then
-                      if not (cs_littlesize in aktglobalswitches) then
+                      if not (cs_opt_size in aktoptimizerswitches) then
                         shiftval := 63
                       else
                         { the shift code is a lot bigger than the call to }

+ 2 - 2
compiler/nopt.pas

@@ -244,7 +244,7 @@ end;
 function canbeaddsstringcharoptnode(p: taddnode): boolean;
 begin
   canbeaddsstringcharoptnode :=
-    (cs_optimize in aktglobalswitches) and
+    (cs_opt_level1 in aktoptimizerswitches) and
 
 {   the shortstring will be gotten through conversion if necessary (JM)
     is_shortstring(p.left.resulttype.def) and }
@@ -266,7 +266,7 @@ end;
 function canbeaddsstringcsstringoptnode(p: taddnode): boolean;
 begin
   canbeaddsstringcsstringoptnode :=
-    (cs_optimize in aktglobalswitches) and
+    (cs_opt_level1 in aktoptimizerswitches) and
 
 {   the shortstring will be gotten through conversion if necessary (JM)
     is_shortstring(p.left.resulttype.def) and }

+ 1 - 1
compiler/nset.pas

@@ -592,7 +592,7 @@ implementation
 
          { estimates the repeat of each instruction }
          old_t_times:=cg.t_times;
-         if not(cs_littlesize in aktglobalswitches) then
+         if not(cs_opt_size in aktoptimizerswitches) then
            begin
               cg.t_times:=cg.t_times div case_count_labels(labels);
               if cg.t_times<1 then

+ 76 - 39
compiler/options.pas

@@ -49,7 +49,6 @@ type
     procedure WriteQuickInfo;
     procedure IllegalPara(const opt:string);
     function  Unsetbool(var Opts:string; Pos: Longint):boolean;
-    procedure interpret_proc_specific_options(const opt:string);virtual;
     procedure interpret_option(const opt :string;ispara:boolean);
     procedure Interpret_envvar(const envname : string);
     procedure Interpret_file(const filename : string);
@@ -78,7 +77,7 @@ uses
   version,
   cutils,cmsgs,
   comphook,
-  symtable,scanner
+  symtable,scanner,rabase
 {$ifdef BrowserLog}
   ,browlog
 {$endif BrowserLog}
@@ -159,7 +158,7 @@ var
   p : pchar;
   hs,hs1,s : TCmdStr;
   target : tsystem;
-  cpu : tprocessors;
+  cpu : tcputype;
   fpu : tfputype;
 begin
   p:=MessagePchar(option_info);
@@ -182,10 +181,10 @@ begin
       end
      else if pos('$INSTRUCTIONSETS',s)>0 then
       begin
-        for cpu:=low(tprocessors) to high(tprocessors) do
+        for cpu:=low(tcputype) to high(tcputype) do
           begin
             hs:=s;
-            hs1:=processorsstr[cpu];
+            hs1:=cputypestr[cpu];
             if hs1<>'' then
               begin
                 Replace(hs,'$INSTRUCTIONSETS',hs1);
@@ -369,11 +368,6 @@ begin
 end;
 
 
-procedure TOption.interpret_proc_specific_options(const opt:string);
-begin
-end;
-
-
 procedure TOption.interpret_option(const opt:string;ispara:boolean);
 var
   code : integer;
@@ -495,11 +489,9 @@ begin
                while j<=length(more) do
                 begin
                   case more[j] of
-                    'a' :
-                      Message2(option_obsolete_switch_use_new,'-Ca','-Or');
                     'c' :
                        begin
-                         if not SetAktProcCall(upper(copy(more,j+1,length(more)-j)),true) then
+                         if not SetAktProcCall(upper(copy(more,j+1,length(more)-j)),initdefproccall) then
                           IllegalPara(opt);
                          break;
                        end;
@@ -515,7 +507,7 @@ begin
                    'f' :
                      begin
                        s:=upper(copy(more,j+1,length(more)-j));
-                       if not(SetFpuType(s,true)) then
+                       if not(SetFpuType(s,initfputype)) then
                          IllegalPara(opt);
                        break;
                      end;
@@ -546,7 +538,7 @@ begin
                     'p' :
                       begin
                         s:=upper(copy(more,j+1,length(more)-j));
-                        if not(SetProcessor(s,true)) then
+                        if not(Setcputype(s,initcputype)) then
                           IllegalPara(opt);
                         break;
                       end;
@@ -856,21 +848,6 @@ begin
                  IllegalPara(opt);
              end;
 
-           'N' :
-             begin
-               j:=1;
-               while j<=length(more) do
-                begin
-                  case more[j] of
-                    'u' :
-                      initglobalswitches:=initglobalswitches+[cs_loopunroll];
-                     else
-                       IllegalPara(opt);
-                  end;
-                  inc(j);
-                end;
-             end;
-
            'o' :
              begin
                if More<>'' then
@@ -889,6 +866,66 @@ begin
                  IllegalPara(opt);
              end;
 
+           'O' :
+             begin
+               j:=1;
+               while j<=length(more) do
+                begin
+                  case more[j] of
+                    '1' :
+                      initoptimizerswitches:=initoptimizerswitches+level1optimizerswitches;
+                    '2' :
+                      initoptimizerswitches:=initoptimizerswitches+level2optimizerswitches;
+                    '3' :
+                      initoptimizerswitches:=initoptimizerswitches+level3optimizerswitches;
+                    'a' :
+                      begin
+                        if not(UpdateAlignmentStr(Copy(Opt,j+1,255),ParaAlignment)) then
+                          IllegalPara(opt);
+                        break;
+                      end;
+                    's' :
+                      include(initoptimizerswitches,cs_opt_size);
+                    'p' :
+                      begin
+                        if not Setcputype(copy(more,j+1,length(more)),initoptimizecputype) then
+                          begin
+                            { Give warning for old i386 switches }
+                            if (Length(More)-j=1) and
+                               (More[j+1]>='1') and (More[j+1]<='5')then
+                              Message2(option_obsolete_switch_use_new,'-Op<nr>','-Op<name>')
+                            else
+                              IllegalPara(opt);
+                          end;
+                        break;
+                      end;
+                    'o' :
+                      begin
+                        if not UpdateOptimizerStr(copy(more,j+1,length(more)),initoptimizerswitches) then
+                         IllegalPara(opt);
+                        break;
+                      end;
+                    '-' :
+                      begin
+                        initoptimizerswitches:=[];
+                        FillChar(ParaAlignment,sizeof(ParaAlignment),0);
+                      end;
+                    { Obsolete switches }
+                    'g' :
+                      Message2(option_obsolete_switch_use_new,'-Og','-Os');
+                    'G' :
+                      Message1(option_obsolete_switch,'-OG');
+                    'r' :
+                      Message2(option_obsolete_switch_use_new,'-Or','-O2 or -Ooregvar');
+                    'u' :
+                      Message2(option_obsolete_switch_use_new,'-Ou','-Oouncertain');
+                    else
+                      IllegalPara(opt);
+                  end;
+                  inc(j);
+                end;
+             end;
+
            'p' :
              begin
                if UnsetBool(More, 0) then
@@ -918,6 +955,12 @@ begin
 
            'P' : ; { Ignore used by fpc.pp }
 
+           'R' :
+             begin
+               if not SetAsmReadMode(More,initasmmode) then
+                 IllegalPara(opt);
+             end;
+
            's' :
              begin
                if UnsetBool(More, 0) then
@@ -1235,10 +1278,6 @@ begin
                   inc(j);
                 end;
              end;
-
-           { give processor specific options a chance }
-           else
-             interpret_proc_specific_options(opt);
          end;
        end;
 
@@ -1977,10 +2016,8 @@ begin
       def_system_macro('FPC_ABI_AIX');
   end;
 
-{$ifdef m68k}
-  if initoptprocessor=MC68020 then
-    def_system_macro('CPUM68020');
-{$endif m68k}
+  { CPU Define }
+  def_system_macro('CPU'+Cputypestr[initcputype]);
 
 { Check file to compile }
   if param_file='' then
@@ -2143,7 +2180,7 @@ begin
     2. override with generic optimizer setting (little size)
     3. override with the user specified -Oa }
   UpdateAlignment(initalignment,target_info.alignment);
-  if (cs_littlesize in aktglobalswitches) then
+  if (cs_opt_size in aktoptimizerswitches) then
    begin
      initalignment.procalign:=1;
      initalignment.jumpalign:=1;

+ 2 - 2
compiler/optunrol.pas

@@ -61,7 +61,7 @@ unit optunrol;
       begin
 {$ifdef i386}
         { multiply by 2 for CPUs with a long pipeline }
-        if aktoptprocessor in [ClassPentium4] then
+        if aktoptcputype in [cpu_Pentium4] then
           number_unrolls:=60 div countnodes(node)
         else
 {$endif i386}
@@ -81,7 +81,7 @@ unit optunrol;
         entrylabel : tlabelnode;
       begin
         result:=nil;
-        if (cs_littlesize in aktglobalswitches) then
+        if (cs_opt_size in aktoptimizerswitches) then
           exit;
         if not(node.nodetype in [forn]) then
           exit;

+ 12 - 8
compiler/parser.pas

@@ -330,12 +330,13 @@ implementation
           oldaktpackenum       : shortint;
           oldaktmaxfpuregisters : longint;
           oldaktalignment  : talignmentinfo;
-          oldaktspecificoptprocessor,
-          oldaktoptprocessor : tprocessors;
+          oldaktspecificoptcputype,
+          oldaktoptcputype : tcputype;
           oldaktfputype      : tfputype;
           oldaktasmmode      : tasmmode;
           oldaktinterfacetype: tinterfacetypes;
           oldaktmodeswitches : tmodeswitches;
+          oldaktoptimizerswitches : toptimizerswitches;
           old_compiled_module : tmodule;
           oldcurrent_procinfo : tprocinfo;
           oldaktdefproccall : tproccalloption;
@@ -389,12 +390,13 @@ implementation
             oldaktpackrecords:=aktpackrecords;
             oldaktfputype:=aktfputype;
             oldaktmaxfpuregisters:=aktmaxfpuregisters;
-            oldaktoptprocessor:=aktoptprocessor;
-            oldaktspecificoptprocessor:=aktspecificoptprocessor;
+            oldaktoptcputype:=aktoptcputype;
+            oldaktspecificoptcputype:=aktspecificoptcputype;
             oldaktasmmode:=aktasmmode;
             oldaktinterfacetype:=aktinterfacetype;
             oldaktfilepos:=aktfilepos;
             oldaktmodeswitches:=aktmodeswitches;
+            oldaktoptimizerswitches:=aktoptimizerswitches;
           end;
        { reset parser, a previous fatal error could have left these variables in an unreliable state, this is
          important for the IDE }
@@ -438,6 +440,7 @@ implementation
          aktlocalswitches:=initlocalswitches;
          aktmoduleswitches:=initmoduleswitches;
          aktmodeswitches:=initmodeswitches;
+         aktoptimizerswitches:=initoptimizerswitches;
          {$IFDEF Testvarsets}
          aktsetalloc:=initsetalloc;
          {$ENDIF}
@@ -445,8 +448,8 @@ implementation
          aktfputype:=initfputype;
          aktpackenum:=initpackenum;
          aktpackrecords:=0;
-         aktoptprocessor:=initoptprocessor;
-         aktspecificoptprocessor:=initspecificoptprocessor;
+         aktoptcputype:=initcputype;
+         aktspecificoptcputype:=initoptimizecputype;
          aktasmmode:=initasmmode;
          aktinterfacetype:=initinterfacetype;
 
@@ -563,13 +566,14 @@ implementation
                 aktpackenum:=oldaktpackenum;
                 aktpackrecords:=oldaktpackrecords;
                 aktmaxfpuregisters:=oldaktmaxfpuregisters;
-                aktoptprocessor:=oldaktoptprocessor;
-                aktspecificoptprocessor:=oldaktspecificoptprocessor;
+                aktoptcputype:=oldaktoptcputype;
+                aktspecificoptcputype:=oldaktspecificoptcputype;
                 aktfputype:=oldaktfputype;
                 aktasmmode:=oldaktasmmode;
                 aktinterfacetype:=oldaktinterfacetype;
                 aktfilepos:=oldaktfilepos;
                 aktmodeswitches:=oldaktmodeswitches;
+                aktoptimizerswitches:=oldaktoptimizerswitches;
                 aktexceptblock:=0;
                 exceptblockcounter:=0;
               end;

+ 2 - 2
compiler/powerpc/cgcpu.pas

@@ -1141,7 +1141,7 @@ const
                a_call_name(objectlibrary.newasmsymbol('_savegpr_'+tostr(ord(firstreggpr)-ord(R_14)+14),AB_EXTERNAL,AT_FUNCTION))
              }
             if (firstregint <= RS_R22) or
-               ((cs_littlesize in aktglobalswitches) and
+               ((cs_opt_size in aktoptimizerswitches) and
                { with RS_R30 it's also already smaller, but too big a speed trade-off to make }
                 (firstregint <= RS_R29)) then
               begin
@@ -1274,7 +1274,7 @@ const
         if (usesgpr) then
           begin
             if (firstregint <= RS_R22) or
-               ((cs_littlesize in aktglobalswitches) and
+               ((cs_opt_size in aktoptimizerswitches) and
                 { with RS_R30 it's also already smaller, but too big a speed trade-off to make }
                 (firstregint <= RS_R29)) then
               begin

+ 10 - 6
compiler/powerpc/cpuinfo.pas

@@ -30,14 +30,14 @@ Type
    pbestreal=^bestreal;
 
    { possible supported processors for this target }
-   tprocessors =
-      (no_processor,
-       ppc601,
-       ppc604
+   tcputype =
+      (cpu_none,
+       cpu_ppc601,
+       cpu_ppc604
       );
 
    tfputype =
-     (no_fpuprocessor,
+     (fpu_none,
       fpu_soft,
       fpu_standard
      );
@@ -56,7 +56,7 @@ Const
      pocall_mwpascal
    ];
 
-   processorsstr : array[tprocessors] of string[10] = ('',
+   cputypestr : array[tcputype] of string[10] = ('',
      '603',
      '604'
    );
@@ -66,6 +66,10 @@ Const
      'STANDARD'
    );
 
+   level1optimizerswitches = [cs_opt_level1];
+   level2optimizerswitches = level1optimizerswitches + [cs_opt_level2,cs_opt_regvar];
+   level3optimizerswitches = level2optimizerswitches + [cs_opt_level3,cs_opt_loopunroll];
+
 Implementation
 
 end.

+ 0 - 118
compiler/powerpc/cpuswtch.pas

@@ -1,118 +0,0 @@
-{
-    Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
-
-    interprets the commandline options which are powerpc specific
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ****************************************************************************
-}
-unit cpuswtch;
-
-{$i fpcdefs.inc}
-
-interface
-
-uses
-  options;
-
-type
-  toptionpowerpc=class(toption)
-    procedure interpret_proc_specific_options(const opt:string);override;
-  end;
-
-implementation
-
-uses
-  cutils,globtype,systems,globals;
-
-procedure toptionpowerpc.interpret_proc_specific_options(const opt:string);
-var
-  more: string;
-  j: longint;
-begin
-  More:=Upper(copy(opt,3,length(opt)-2));
-  case opt[2] of
-   'O' : Begin
-           j := 3;
-           While (j <= Length(Opt)) Do
-             Begin
-               case opt[j] of
-                 '-' :
-                   begin
-                     initglobalswitches:=initglobalswitches-[cs_optimize,cs_fastoptimize,cs_slowoptimize,cs_littlesize,
-                       cs_regvars,cs_uncertainopts];
-                     FillChar(ParaAlignment,sizeof(ParaAlignment),0);
-                   end;
-                 'a' :
-                   begin
-                     UpdateAlignmentStr(Copy(Opt,j+1,255),ParaAlignment);
-                     j:=length(Opt);
-                   end;
-                 'g' : initglobalswitches:=initglobalswitches+[cs_littlesize];
-                 'G' : initglobalswitches:=initglobalswitches-[cs_littlesize];
-                 'r' :
-                   begin
-                     initglobalswitches:=initglobalswitches+[cs_regvars];
-                     Simplify_ppu:=false;
-                   end;
-                 'u' : initglobalswitches:=initglobalswitches+[cs_uncertainopts];
-                 '1' : initglobalswitches:=initglobalswitches-[cs_fastoptimize,cs_slowoptimize]+[cs_optimize];
-                 '2' : initglobalswitches:=initglobalswitches-[cs_slowoptimize]+[cs_optimize,cs_fastoptimize];
-                 '3' : initglobalswitches:=initglobalswitches+[cs_optimize,cs_fastoptimize,cs_slowoptimize];
-{$ifdef dummy}
-                 'p' :
-                   Begin
-                     If j < Length(Opt) Then
-                       Begin
-                         Case opt[j+1] Of
-                           '1': initoptprocessor := Class386;
-                           '2': initoptprocessor := ClassP5;
-                           '3': initoptprocessor := ClassP6
-                           Else IllegalPara(Opt)
-                         End;
-                         Inc(j);
-                       End
-                     Else IllegalPara(opt)
-                   End;
-{$endif dummy}
-                 else IllegalPara(opt);
-               End;
-               Inc(j)
-             end;
-         end;
-{$ifdef dummy}
-   'R' : begin
-           if More='GAS' then
-            initasmmode:=asmmode_ppc_gas
-           else
-            if More='MOTOROLA' then
-             initasmmode:=asmmode_ppc_motorola
-           else
-            if More='DIRECT' then
-             initasmmode:=asmmode_direct
-           else
-            IllegalPara(opt);
-         end;
-{$endif dummy}
-  else
-   IllegalPara(opt);
-  end;
-end;
-
-
-initialization
-  coption:=toptionpowerpc;
-end.

+ 80 - 80
compiler/powerpc64/cgcpu.pas

@@ -129,7 +129,7 @@ type
     function fixref(list: taasmoutput; var ref: treference; const size : TCgsize): boolean;
 
     function load_got_symbol(list : taasmoutput; symbol : string) : tregister;
-    
+
     { returns whether a reference can be used immediately in a powerpc }
     { instruction                                                      }
     function issimpleref(const ref: treference): boolean;
@@ -143,7 +143,7 @@ type
     procedure a_jmp(list: taasmoutput; op: tasmop;
       c: tasmcondflag; crval: longint; l: tasmlabel);
 
-    { returns the lowest numbered FP register in use, and the number of used FP registers 
+    { returns the lowest numbered FP register in use, and the number of used FP registers
       for the current procedure }
     procedure calcFirstUsedFPR(out firstfpr : TSuperRegister; out fprcount : aint);
     { returns the lowest numbered GP register in use, and the number of used GP registers
@@ -158,9 +158,9 @@ type
      control code generation. If prependDot is true, a single dot character is prepended to
      the string, if addNOP is true a single NOP instruction is added after the call, and
      if includeCall is true, the method is marked as having a call, not if false. This
-     option is particularly useful to prevent generation of a larger stack frame for the 
+     option is particularly useful to prevent generation of a larger stack frame for the
      register save and restore helper functions. }
-    procedure a_call_name_direct(list: taasmoutput; s: string; prependDot : boolean; 
+    procedure a_call_name_direct(list: taasmoutput; s: string; prependDot : boolean;
       addNOP : boolean; includeCall : boolean = true);
 
     { emits code to store the given value a into the TOC (if not already in there), and load it from there
@@ -192,10 +192,10 @@ begin
 end;
 
 
-{ helper function which calculate "magic" values for replacement of unsigned 
+{ helper function which calculate "magic" values for replacement of unsigned
  division by constant operation by multiplication. See the PowerPC compiler
  developer manual for more information }
-procedure getmagic_unsignedN(const N : byte; const d : aWord; 
+procedure getmagic_unsignedN(const N : byte; const d : aWord;
   out magic_m : aWord; out magic_add : boolean; out magic_shift : byte);
 var
     p : aInt;
@@ -204,7 +204,7 @@ begin
   assert(d > 0);
 
   two_N_minus_1 := aWord(1) shl (N-1);
-    
+
   magic_add := false;
   nc := - 1 - (-d) mod d;
   p := N-1; { initialize p }
@@ -227,7 +227,7 @@ begin
       q2 := 2*q2 + 1; { update q2 }
       r2 := 2*r2 + 1 - d; { update r2 }
     end else begin
-      if (q2 >= two_N_minus_1) then 
+      if (q2 >= two_N_minus_1) then
         magic_add := true;
       q2 := 2*q2; { update q2 }
       r2 := 2*r2 + 1; { update r2 }
@@ -238,16 +238,16 @@ begin
   magic_shift := p - N; { resulting shift }
 end;
 
-{ helper function which calculate "magic" values for replacement of signed 
+{ helper function which calculate "magic" values for replacement of signed
  division by constant operation by multiplication. See the PowerPC compiler
  developer manual for more information }
-procedure getmagic_signedN(const N : byte; const d : aInt; 
+procedure getmagic_signedN(const N : byte; const d : aInt;
   out magic_m : aInt; out magic_s : aInt);
 var
   p : aInt;
   ad, anc, delta, q1, r1, q2, r2, t : aWord;
   two_N_minus_1 : aWord;
-    
+
 begin
   assert((d < -1) or (d > 1));
 
@@ -261,7 +261,7 @@ begin
   r1 := two_N_minus_1 - q1*anc; { initialize r1 = rem(2p,abs(nc)) }
   q2 := two_N_minus_1 div ad; { initialize q2 = 2p/abs(d) }
   r2 := two_N_minus_1 - q2*ad; { initialize r2 = rem(2p,abs(d)) }
-  repeat 
+  repeat
     inc(p);
     q1 := 2*q1; { update q1 = 2p/abs(nc) }
     r1 := 2*r1; { update r1 = rem(2p/abs(nc)) }
@@ -293,7 +293,7 @@ var
   hl : aInt;
 begin
   neg := false;
-  { also try to find negative power of two's by negating if the 
+  { also try to find negative power of two's by negating if the
    value is negative. low(aInt) is special because it can not be
    negated. Simply return the appropriate values for it }
   if (value < 0) then begin
@@ -327,7 +327,7 @@ end;
 function getInstructionLength(a : aint) : longint;
 
   function get32bitlength(a : longint; var length : longint) : boolean; inline;
-  var 
+  var
     is_half_signed : byte;
   begin
     { if the lower 16 bits are zero, do a single LIS }
@@ -355,8 +355,8 @@ begin
     extendssign := get32bitlength(lo(a), result);
     if (extendssign) and (hi(a) = 0) then
       inc(result)
-    else if (not 
-      ((extendssign and (longint(hi(a)) = -1)) or 
+    else if (not
+      ((extendssign and (longint(hi(a)) = -1)) or
        ((not extendssign) and (hi(a)=0)))
       ) then begin
       get32bitlength(hi(a), result);
@@ -439,17 +439,17 @@ begin
           list.concat(tai_comment.create(strpnew('a_param_ref with OS_NO, sizeleft ' + inttostr(sizeleft))));
           {$ENDIF extdebug}
 
-            { load non-integral sized memory location into register. This 
+            { load non-integral sized memory location into register. This
              memory location be 1-sizeleft byte sized.
              Always assume that this memory area is properly aligned, eg. start
              loading the larger quantities for "odd" quantities first }
             case sizeleft of
               1,2,4,8 :
                 a_load_ref_reg(list, int_cgsize(sizeleft), location^.size, tmpref,
-                  location^.register); 
+                  location^.register);
               3 : begin
-                a_reg_alloc(list, NR_R12); 
-                a_load_ref_reg(list, OS_16, location^.size, tmpref, 
+                a_reg_alloc(list, NR_R12);
+                a_load_ref_reg(list, OS_16, location^.size, tmpref,
                   NR_R12);
                 inc(tmpref.offset, tcgsize2size[OS_16]);
                 a_load_ref_reg(list, OS_8, location^.size, tmpref,
@@ -470,7 +470,7 @@ begin
                 a_load_ref_reg(list, OS_32, location^.size, tmpref, NR_R12);
                 inc(tmpref.offset, tcgsize2size[OS_32]);
                 a_load_ref_reg(list, OS_16, location^.size, tmpref, location^.register);
-                list.concat(taicpu.op_reg_reg_const_const(A_RLDIMI, location^.register, NR_R12, 16, 16));                
+                list.concat(taicpu.op_reg_reg_const_const(A_RLDIMI, location^.register, NR_R12, 16, 16));
                 a_reg_dealloc(list, NR_R12);
               end;
               7 : begin
@@ -493,10 +493,10 @@ begin
                 { the block is > 8 bytes, so we have to store any bytes not
                  a multiple of the register size beginning with the MSB }
                 adjusttail := true;
-            end;           
+            end;
             if (adjusttail) and (sizeleft < tcgsize2size[OS_INT]) then
-              a_op_const_reg(list, OP_SHL, OS_INT, 
-                (tcgsize2size[OS_INT] - sizeleft) * tcgsize2size[OS_INT], 
+              a_op_const_reg(list, OP_SHL, OS_INT,
+                (tcgsize2size[OS_INT] - sizeleft) * tcgsize2size[OS_INT],
                 location^.register);
 
         end;
@@ -515,7 +515,7 @@ begin
         else
           internalerror(2002072801);
         end;
-      LOC_VOID: 
+      LOC_VOID:
         { nothing to do }
         ;
     else
@@ -579,7 +579,7 @@ procedure tcgppc.a_call_reg(list: taasmoutput; reg: tregister);
 var
   tmpref: treference;
 begin
-  if (not (cs_littlesize in aktglobalswitches)) then begin
+  if (not (cs_opt_size in aktoptimizerswitches)) then begin
     { load actual function entry (reg contains the reference to the function descriptor)
     into R0 }
     reference_reset_base(tmpref, reg, 0);
@@ -627,7 +627,7 @@ procedure tcgppc.a_load_const_reg(list: taasmoutput; size: TCGSize; a: aint;
     sign extension was performed) }
   function load32bitconstant(list : taasmoutput; size : TCGSize; a : longint;
     reg : TRegister) : boolean;
-  var 
+  var
     is_half_signed : byte;
   begin
     { if the lower 16 bits are zero, do a single LIS }
@@ -673,21 +673,21 @@ procedure tcgppc.a_load_const_reg(list: taasmoutput; size: TCGSize; a: aint;
     if (lo(a) = 0) and (hi(a) <> 0) then begin
       { load only upper 32 bits, and shift }
       load32bitconstant(list, size, hi(a), reg);
-      list.concat(taicpu.op_reg_reg_const(A_SLDI, reg, reg, 32));    
+      list.concat(taicpu.op_reg_reg_const(A_SLDI, reg, reg, 32));
     end else begin
       { load lower 32 bits }
       extendssign := load32bitconstant(list, size, lo(a), reg);
       if (extendssign) and (hi(a) = 0) then
-        { if upper 32 bits are zero, but loading the lower 32 bit resulted in automatic 
+        { if upper 32 bits are zero, but loading the lower 32 bit resulted in automatic
           sign extension, clear those bits }
         a_load_reg_reg(list, OS_32, OS_64, reg, reg)
-      else if (not 
-        ((extendssign and (longint(hi(a)) = -1)) or 
+      else if (not
+        ((extendssign and (longint(hi(a)) = -1)) or
          ((not extendssign) and (hi(a)=0)))
         ) then begin
         { only load the upper 32 bits, if the automatic sign extension is not okay,
-          that is, _not_ if 
-          - loading the lower 32 bits resulted in -1 in the upper 32 bits, and the upper 
+          that is, _not_ if
+          - loading the lower 32 bits resulted in -1 in the upper 32 bits, and the upper
            32 bits should contain -1
           - loading the lower 32 bits resulted in 0 in the upper 32 bits, and the upper
            32 bits should contain 0 }
@@ -710,9 +710,9 @@ begin
   {$ENDIF EXTDEBUG}
   if not (size in [OS_8, OS_S8, OS_16, OS_S16, OS_32, OS_S32, OS_64, OS_S64]) then
     internalerror(2002090902);
-  { if PIC or basic optimizations are enabled, and the number of instructions which would be 
+  { if PIC or basic optimizations are enabled, and the number of instructions which would be
    required to load the value is greater than 2, store (and later load) the value from there }
-  if (false) {(((cs_fastoptimize in aktglobalswitches) or (cs_create_pic in aktmoduleswitches)) and 
+  if (false) {(((cs_opt_peephole in aktoptimizerswitches in aktglobalswitches) or (cs_create_pic in aktmoduleswitches)) and
     (getInstructionLength(a) > 2))} then
     loadConstantPIC(list, size, a, reg)
   else
@@ -827,7 +827,7 @@ begin
   rg[R_INTREGISTER].add_move_instruction(instr);
 end;
 
-procedure tcgppc.a_loadfpu_reg_reg(list: taasmoutput; size: tcgsize; 
+procedure tcgppc.a_loadfpu_reg_reg(list: taasmoutput; size: tcgsize;
   reg1, reg2: tregister);
 var
   instr: taicpu;
@@ -837,7 +837,7 @@ begin
   rg[R_FPUREGISTER].add_move_instruction(instr);
 end;
 
-procedure tcgppc.a_loadfpu_ref_reg(list: taasmoutput; size: tcgsize; 
+procedure tcgppc.a_loadfpu_ref_reg(list: taasmoutput; size: tcgsize;
   const ref: treference; reg: tregister);
 const
   FpuLoadInstr: array[OS_F32..OS_F64, boolean, boolean] of TAsmOp =
@@ -924,7 +924,7 @@ var
   begin
     { optimization logical and with immediate: only use "andi." for 16 bit
      ands, otherwise use register method. Doing this for 32 bit constants
-     would not give any advantage to the register method (via useReg := true), 
+     would not give any advantage to the register method (via useReg := true),
      requiring a scratch register and three instructions. }
     usereg := false;
     if (aword(a) > high(word)) then
@@ -944,7 +944,7 @@ var
     u_add : boolean;
     power : byte;
     isNegPower : boolean;
-             
+
     divreg : tregister;
   begin
     if (a = 0) then begin
@@ -982,13 +982,13 @@ var
           cg.a_op_reg_reg_reg(exprasmlist, OP_SUB, OS_INT, src, dst, dst);
         end;
         { shift shift places to the right (arithmetic) }
-        cg.a_op_const_reg_reg(exprasmlist, OP_SAR, OS_INT, shift, dst, dst);                     
+        cg.a_op_const_reg_reg(exprasmlist, OP_SAR, OS_INT, shift, dst, dst);
         { extract and add sign bit }
         if (a >= 0) then begin
           cg.a_op_const_reg_reg(exprasmlist, OP_SHR, OS_INT, 63, src, divreg);
         end else begin
           cg.a_op_const_reg_reg(exprasmlist, OP_SHR, OS_INT, 63, dst, divreg);
-        end;                     
+        end;
         cg.a_op_reg_reg_reg(exprasmlist, OP_ADD, OS_INT, dst, divreg, dst);
       end else begin
         getmagic_unsignedN(sizeof(aWord)*8, a, u_magic, u_add, u_shift);
@@ -1020,17 +1020,17 @@ begin
     exit;
   end;
   { This case includes some peephole optimizations for the various operations,
-   (e.g. AND, OR, XOR, ..) - can't this be done at some higher level, 
+   (e.g. AND, OR, XOR, ..) - can't this be done at some higher level,
    independent of architecture? }
 
   { assume that we do not need a scratch register for the operation }
   useReg := false;
   case (op) of
     OP_DIV, OP_IDIV:
-      if (cs_optimize in aktglobalswitches) then
+      if (cs_opt_level1 in aktoptimizerswitches) then
         do_constant_div(list, size, a, src, dst, op = OP_IDIV)
       else
-        usereg := true; 
+        usereg := true;
     OP_IMUL, OP_MUL:
       { idea: factorize constant multiplicands and use adds/shifts with few factors;
        however, even a 64 bit multiply is already quite fast on PPC64 }
@@ -1079,11 +1079,11 @@ begin
         do_lo_hi(A_XORI, A_XORIS);
     OP_SHL, OP_SHR, OP_SAR:
       begin
-        if (size in [OS_64, OS_S64]) then 
+        if (size in [OS_64, OS_S64]) then
           shift := 6
         else
           shift := 5;
-        
+
         shiftmask := (1 shl shift)-1;
         if (a and shiftmask) <> 0 then
           list.concat(taicpu.op_reg_reg_const(
@@ -1136,7 +1136,7 @@ end;
 
 {*************** compare instructructions ****************}
 
-procedure tcgppc.a_cmp_const_reg_label(list: taasmoutput; size: tcgsize; 
+procedure tcgppc.a_cmp_const_reg_label(list: taasmoutput; size: tcgsize;
   cmp_op: topcmp; a: aint; reg: tregister; l: tasmlabel);
 var
   scratch_register: TRegister;
@@ -1167,7 +1167,7 @@ begin
   a_jmp(list, A_BC, TOpCmp2AsmCond[cmp_op], 0, l);
 end;
 
-procedure tcgppc.a_cmp_reg_reg_label(list: taasmoutput; size: tcgsize; 
+procedure tcgppc.a_cmp_reg_reg_label(list: taasmoutput; size: tcgsize;
   cmp_op: topcmp; reg1, reg2: tregister; l: tasmlabel);
 var
   op: tasmop;
@@ -1261,7 +1261,7 @@ end;
 
 procedure tcgppc.g_save_standard_registers(list: Taasmoutput);
 begin
-  { this work is done in g_proc_entry; additionally it is not safe 
+  { this work is done in g_proc_entry; additionally it is not safe
   to use it because it is called at some weird time }
 end;
 
@@ -1301,15 +1301,15 @@ begin
       end;
 end;
 
-{ Generates the entry code of a procedure/function. 
-                                                                     
+{ Generates the entry code of a procedure/function.
+
  This procedure may be called before, as well as after g_return_from_proc
- is called. localsize is the sum of the size necessary for local variables 
- and the maximum possible combined size of ALL the parameters of a procedure 
- called by the current one 
+ is called. localsize is the sum of the size necessary for local variables
+ and the maximum possible combined size of ALL the parameters of a procedure
+ called by the current one
 
  IMPORTANT: registers are not to be allocated through the register
- allocator here, because the register colouring has already occured !! 
+ allocator here, because the register colouring has already occured !!
 }
 procedure tcgppc.g_proc_entry(list: taasmoutput; localsize: longint;
   nostackframe: boolean);
@@ -1329,7 +1329,7 @@ var
     { there are two ways to do this: manually, by generating a few "std" instructions,
      or via the restore helper functions. The latter are selected by the -Og switch,
      i.e. "optimize for size" }
-    if (cs_littlesize in aktglobalswitches) then begin
+    if (cs_opt_size in aktoptimizerswitches) then begin
       mayNeedLRStore := false;
       if ((fprcount > 0) and (gprcount > 0)) then begin
         a_op_const_reg_reg(list, OP_SUB, OS_INT, 8 * fprcount, NR_R1, NR_R12);
@@ -1381,9 +1381,9 @@ begin
     gprcount, fprcount);
 
   { determine whether we need to save the link register }
-  needslinkreg := 
-    ((not (po_assembler in current_procinfo.procdef.procoptions)) and (pi_do_call in current_procinfo.flags)) or 
-    ((cs_littlesize in aktglobalswitches) and ((fprcount > 0) or (gprcount > 0))) or
+  needslinkreg :=
+    ((not (po_assembler in current_procinfo.procdef.procoptions)) and (pi_do_call in current_procinfo.flags)) or
+    ((cs_opt_size in aktoptimizerswitches) and ((fprcount > 0) or (gprcount > 0))) or
     ([cs_lineinfo, cs_debuginfo] * aktmoduleswitches <> []);
 
   a_reg_alloc(list, NR_STACK_POINTER_REG);
@@ -1412,7 +1412,7 @@ begin
       { Use R0 for loading the constant (which is definitely > 32k when entering
        this branch).
 
-       Inlined at this position because it must not use temp registers because 
+       Inlined at this position because it must not use temp registers because
        register allocations have already been done  }
       { Code template:
       lis   r0,ofs@highest
@@ -1437,10 +1437,10 @@ begin
   a_reg_dealloc(list, NR_R0);
 end;
 
-{ Generates the exit code for a method. 
+{ Generates the exit code for a method.
 
  This procedure may be called before, as well as after g_stackframe_entry
- is called. 
+ is called.
 
  IMPORTANT: registers are not to be allocated through the register
  allocator here, because the register colouring has already occured !!
@@ -1464,7 +1464,7 @@ var
     { there are two ways to do this: manually, by generating a few "ld" instructions,
      or via the restore helper functions. The latter are selected by the -Og switch,
      i.e. "optimize for size" }
-    if (cs_littlesize in aktglobalswitches) then begin
+    if (cs_opt_size in aktoptimizerswitches) then begin
       needsExitCode := false;
       if ((fprcount > 0) and (gprcount > 0)) then begin
         a_op_const_reg_reg(list, OP_SUB, OS_INT, 8 * fprcount, NR_R1, NR_R12);
@@ -1519,9 +1519,9 @@ begin
   calcFirstUsedGPR(firstreggpr, gprcount);
 
   { determine whether we need to restore the link register }
-  needslinkreg := 
+  needslinkreg :=
     ((not (po_assembler in current_procinfo.procdef.procoptions)) and (pi_do_call in current_procinfo.flags)) or
-    ((cs_littlesize in aktglobalswitches) and ((fprcount > 0) or (gprcount > 0))) or
+    ((cs_opt_size in aktoptimizerswitches) and ((fprcount > 0) or (gprcount > 0))) or
     ([cs_lineinfo, cs_debuginfo] * aktmoduleswitches <> []);
 
   { calculate stack frame }
@@ -1662,7 +1662,7 @@ begin
     internalerror(2002072704);
   list.concat(tai_comment.create(strpnew('g_concatcopy1 ' + inttostr(len) + ' bytes left ')));
 {$ENDIF extdebug}
-  { if the references are equal, exit, there is no need to copy anything } 
+  { if the references are equal, exit, there is no need to copy anything }
   if (references_equal(source, dest)) then
     exit;
 
@@ -1671,7 +1671,7 @@ begin
    copy at all times.
    NOTE: maybe use some scratch registers to pair load/store instructions
   }
-  
+
   if (len <= maxmoveunit) then begin
     src := source; dst := dest;
     {$IFDEF extdebug}
@@ -1679,18 +1679,18 @@ begin
     {$ENDIF extdebug}
     while (len <> 0) do begin
       if (len = 8) then begin
-        a_load_ref_ref(list, OS_64, OS_64, src, dst);    
+        a_load_ref_ref(list, OS_64, OS_64, src, dst);
         dec(len, 8);
       end else if (len >= 4) then begin
-        a_load_ref_ref(list, OS_32, OS_32, src, dst);    
+        a_load_ref_ref(list, OS_32, OS_32, src, dst);
         inc(src.offset, 4); inc(dst.offset, 4);
         dec(len, 4);
       end else if (len >= 2) then begin
-        a_load_ref_ref(list, OS_16, OS_16, src, dst);    
+        a_load_ref_ref(list, OS_16, OS_16, src, dst);
         inc(src.offset, 2); inc(dst.offset, 2);
         dec(len, 2);
       end else begin
-        a_load_ref_ref(list, OS_8, OS_8, src, dst);    
+        a_load_ref_ref(list, OS_8, OS_8, src, dst);
         inc(src.offset, 1); inc(dst.offset, 1);
         dec(len, 1);
       end;
@@ -1729,9 +1729,9 @@ begin
 
   { generate a loop }
   if count > 4 then begin
-    { the offsets are zero after the a_loadaddress_ref_reg and just 
-     have to be set to 8. I put an Inc there so debugging may be   
-     easier (should offset be different from zero here, it will be 
+    { the offsets are zero after the a_loadaddress_ref_reg and just
+     have to be set to 8. I put an Inc there so debugging may be
+     easier (should offset be different from zero here, it will be
      easy to notice in the generated assembler }
     inc(dst.offset, 8);
     inc(src.offset, 8);
@@ -1947,7 +1947,7 @@ end;
 
 function tcgppc.fixref(list: taasmoutput; var ref: treference; const size : TCgsize): boolean;
 var
-  tmpreg: tregister; 
+  tmpreg: tregister;
   name : string;
 begin
   result := false;
@@ -1968,7 +1968,7 @@ begin
       a_op_reg_reg_reg(list, OP_ADD, OS_ADDR, ref.base, tmpreg, tmpreg);
       ref.base := tmpreg;
     end;
-    ref.symbol := nil;    
+    ref.symbol := nil;
     {$IFDEF EXTDEBUG}
     list.concat(tai_comment.create(strpnew('fixref-pic ' + ref2string(ref))));
     {$ENDIF EXTDEBUG}
@@ -2016,7 +2016,7 @@ begin
     list.concat(taicpu.op_reg_ref(op, reg, ref));
     exit;
   end;
- 
+
   { for some instructions we need to check that the offset is divisible by at
    least four. If not, add the bytes which are "off" to the base register and
    adjust the offset accordingly }
@@ -2089,7 +2089,7 @@ begin
       tmpref.base := ref.base;
       tmpref.index := tmpreg2;
       case op of
-        { the code generator doesn't generate update instructions anyway, so 
+        { the code generator doesn't generate update instructions anyway, so
         error out on those instructions }
         A_LBZ : op := A_LBZX;
         A_LHZ : op := A_LHZX;
@@ -2153,7 +2153,7 @@ begin
   list.concat(p)
 end;
 
-function tcgppc.hasLargeOffset(const ref : TReference) : Boolean;
+function tcgppc.hasLargeOffset(const ref : TReference) : Boolean; {$ifdef ver2_0}inline;{$endif}
 begin
   { this rather strange calculation is required because offsets of TReferences are unsigned }
   result := aword(ref.offset-low(smallint)) > high(smallint)-low(smallint);
@@ -2175,7 +2175,7 @@ begin
     asmlist[al_picdata].concat(tai_directive.create(asd_toc_entry, symname + '[TC], ' + inttostr(a)));
   end;
   reference_reset_symbol(ref,l,0);
-  ref.base := NR_R2;	
+  ref.base := NR_R2;
   ref.refaddr := addr_pic;
 
   {$IFDEF EXTDEBUG}

+ 8 - 5
compiler/powerpc64/cpuinfo.pas

@@ -30,13 +30,12 @@ type
   pbestreal = ^bestreal;
 
   { possible supported processors for this target }
-  tprocessors =
-    (no_processor,
-    ppc970
+  tcputype = (cpu_none,
+    cpu_ppc970
     );
 
   tfputype =
-    (no_fpuprocessor,
+    (fpu_none,
     fpu_soft,
     fpu_standard
     );
@@ -52,7 +51,7 @@ const
     pocall_cppdecl
     ];
 
-  processorsstr: array[tprocessors] of string[10] = ('',
+  cputypestr: array[tcputype] of string[10] = ('',
     '970'
     );
 
@@ -61,6 +60,10 @@ const
     'STANDARD'
     );
 
+   level1optimizerswitches = [cs_opt_level1];
+   level2optimizerswitches = level1optimizerswitches + [cs_opt_level2,cs_opt_regvar,cs_opt_stackframe];
+   level3optimizerswitches = level2optimizerswitches + [cs_opt_level3,cs_opt_loopunroll];
+
 implementation
 
 end.

+ 0 - 125
compiler/powerpc64/cpuswtch.pas

@@ -1,125 +0,0 @@
-{
-    Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
-
-    interprets the commandline options which are PowerPC64 specific
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ****************************************************************************
-}
-unit cpuswtch;
-
-{$I fpcdefs.inc}
-
-interface
-
-uses
-  options;
-
-type
-  toptionpowerpc = class(toption)
-    procedure interpret_proc_specific_options(const opt: string); override;
-  end;
-
-implementation
-
-uses
-  cutils, globtype, systems, globals;
-
-procedure toptionpowerpc.interpret_proc_specific_options(const opt: string);
-var
-  more: string;
-  j: longint;
-begin
-  More := Upper(copy(opt, 3, length(opt) - 2));
-  case opt[2] of
-    'O':
-      begin
-        j := 3;
-        while (j <= Length(Opt)) do
-        begin
-          case opt[j] of
-            '-':
-              begin
-                initglobalswitches := initglobalswitches - [cs_optimize,
-                  cs_fastoptimize, cs_slowoptimize, cs_littlesize,
-                  cs_regvars, cs_uncertainopts];
-                FillChar(ParaAlignment, sizeof(ParaAlignment), 0);
-              end;
-            'a':
-              begin
-                UpdateAlignmentStr(Copy(Opt, j + 1, 255), ParaAlignment);
-                j := length(Opt);
-              end;
-            'g': initglobalswitches := initglobalswitches + [cs_littlesize];
-            'G': initglobalswitches := initglobalswitches - [cs_littlesize];
-            'r':
-              begin
-                initglobalswitches := initglobalswitches + [cs_regvars];
-                Simplify_ppu := false;
-              end;
-            'u': initglobalswitches := initglobalswitches + [cs_uncertainopts];
-            '1': initglobalswitches := initglobalswitches - [cs_fastoptimize,
-              cs_slowoptimize] + [cs_optimize];
-            '2': initglobalswitches := initglobalswitches - [cs_slowoptimize] +
-              [cs_optimize, cs_fastoptimize];
-            '3': initglobalswitches := initglobalswitches + [cs_optimize,
-              cs_fastoptimize, cs_slowoptimize];
-{$IFDEF dummy}
-            'p':
-              begin
-                if j < Length(Opt) then
-                begin
-                  case opt[j + 1] of
-                    '1': initoptprocessor := Class386;
-                    '2': initoptprocessor := ClassP5;
-                    '3': initoptprocessor := ClassP6
-                  else
-                    IllegalPara(Opt)
-                  end;
-                  Inc(j);
-                end
-                else
-                  IllegalPara(opt)
-              end;
-{$ENDIF dummy}
-          else
-            IllegalPara(opt);
-          end;
-          Inc(j)
-        end;
-      end;
-{$IFDEF dummy}
-    'R':
-      begin
-        if More = 'GAS' then
-          initasmmode := asmmode_ppc_gas
-        else if More = 'MOTOROLA' then
-          initasmmode := asmmode_ppc_motorola
-        else if More = 'DIRECT' then
-          initasmmode := asmmode_direct
-        else
-          IllegalPara(opt);
-      end;
-{$ENDIF dummy}
-  else
-    IllegalPara(opt);
-  end;
-end;
-
-initialization
-  coption := toptionpowerpc;
-end.
-

+ 1 - 1
compiler/powerpc64/nppcmat.pas

@@ -151,7 +151,7 @@ begin
     resultreg := cg.getintregister(exprasmlist,size);
   end;
   done := false;
-  if (cs_optimize in aktglobalswitches) and (right.nodetype = ordconstn) then begin
+  if (cs_opt_level1 in aktoptimizerswitches) and (right.nodetype = ordconstn) then begin
     if (nodetype = divn) then
       cg.a_op_const_reg_reg(exprasmlist, divCgOps[is_signed(right.resulttype.def)], 
         size, tordconstnode(right).value, numerator, resultreg)

+ 3 - 3
compiler/psub.pas

@@ -704,7 +704,7 @@ implementation
         add_to_symtablestack;
 
         { when size optimization only count occurrence }
-        if cs_littlesize in aktglobalswitches then
+        if cs_opt_size in aktoptimizerswitches then
           cg.t_times:=1
         else
           { reference for repetition is 100 }
@@ -750,7 +750,7 @@ implementation
                 * open arrays
               - no inline assembler
             }
-            if (cs_optimize in aktglobalswitches) and
+            if (cs_opt_level1 in aktoptimizerswitches) and
                not(po_assembler in procdef.procoptions) and
                ((flags*[pi_has_assembler_block,pi_uses_exceptions,pi_is_assembler,
                        pi_needs_implicit_finally,pi_has_implicit_finally,pi_has_stackparameter])=[]) then
@@ -950,7 +950,7 @@ implementation
 {$ifndef NoOpt}
             if not(cs_no_regalloc in aktglobalswitches) then
               begin
-                if (cs_optimize in aktglobalswitches) and
+                if (cs_opt_level1 in aktoptimizerswitches) and
                    { do not optimize pure assembler procedures }
                    not(pi_is_assembler in flags)  then
                   optimize(aktproccode);

+ 3 - 1
compiler/rabase.pas

@@ -75,8 +75,10 @@ unit rabase;
         ht : tasmmode;
       begin
         result:=false;
-        { this should be case insensitive !! PM }
         hs:=upper(s);
+        { Support Default as an alias for Standard }
+        if hs='DEFAULT' then
+          hs:='STANDARD';
         for ht:=low(tasmmode) to high(tasmmode) do
          if assigned(asmmodeinfos[ht]) and
             (asmmodeinfos[ht]^.idtxt=hs) then

+ 3 - 3
compiler/regvars.pas

@@ -145,7 +145,7 @@ implementation
       { max. optimizations     }
       { only if no asm is used }
       { and no try statement   }
-      if (cs_regvars in aktglobalswitches) and
+      if (cs_opt_regvar in aktoptimizerswitches) and
         { we have to store regvars back to memory in this case (the nested }
         { procedures can access the variables of the parent)               }
         (tcgprocinfo(current_procinfo).nestedprocs.count = 0) and
@@ -455,7 +455,7 @@ implementation
       i: longint;
       regvarinfo: pregvarinfo;
     begin
-      if (cs_regvars in aktglobalswitches) and
+      if (cs_opt_regvar in aktoptimizerswitches) and
          not(pi_has_assembler_block in current_procinfo.flags) and
          not(pi_uses_exceptions in current_procinfo.flags) then
         begin
@@ -554,7 +554,7 @@ implementation
       { can happen when inlining assembler procedures (JM) }
       if not assigned(current_procinfo.procdef.regvarinfo) then
         exit;
-      if (cs_regvars in aktglobalswitches) and
+      if (cs_opt_regvar in aktoptimizerswitches) and
          not(pi_has_assembler_block in current_procinfo.flags) and
          not(pi_uses_exceptions in current_procinfo.flags) then
         with pregvarinfo(current_procinfo.procdef.regvarinfo)^ do

+ 2 - 2
compiler/scandir.pas

@@ -283,7 +283,7 @@ implementation
       begin
         current_scanner.skipspace;
         hs:=current_scanner.readid;
-        if not SetAktProcCall(hs,false) then
+        if not SetAktProcCall(hs,aktdefproccall) then
           Message1(parser_w_unknown_proc_directive_ignored,hs);
       end;
 
@@ -373,7 +373,7 @@ implementation
       begin
         current_scanner.skipspace;
         { current_scanner.undef_macro('FPU'+fputypestr[aktfputype]); }
-        if not(SetFPUType(upper(current_scanner.readcomment),false)) then
+        if not(SetFPUType(upper(current_scanner.readcomment),aktfputype)) then
           comment(V_Error,'Illegal FPU type');
         { current_scanner.def_macro('FPU'+fputypestr[aktfputype]); }
      end;

+ 14 - 3
compiler/sparc/cpuinfo.pas

@@ -38,9 +38,16 @@ type
   pbestreal=^bestreal;
 
   { possible supported processors for this target }
-  tprocessors=(no_processor,SPARC_V7,SPARC_V8,SPARC_V9);
+  tcputype=(cpu_none,
+    cpu_SPARC_V7,
+    cpu_SPARC_V8,
+    cpu_SPARC_V9
+  );
 
-  tfputype =(no_fpu,fpu_soft,fpu_hard);
+  tfputype =(fpu_none,
+    fpu_soft,
+    fpu_hard
+  );
 
 
 const
@@ -52,7 +59,7 @@ const
     pocall_cppdecl
   ];
 
-   processorsstr : array[tprocessors] of string[10] = ('',
+   cputypestr : array[tcputype] of string[10] = ('',
      'SPARC V7',
      'SPARC V8',
      'SPARC V9'
@@ -63,6 +70,10 @@ const
      'HARD'
    );
 
+   level1optimizerswitches = [cs_opt_level1];
+   level2optimizerswitches = level1optimizerswitches + [cs_opt_level2,cs_opt_regvar];
+   level3optimizerswitches = level2optimizerswitches + [cs_opt_level3,cs_opt_loopunroll];
+
 implementation
 
 end.

+ 0 - 125
compiler/sparc/cpuswtch.pas

@@ -1,125 +0,0 @@
-{
-    Copyright (c) 1998-2000 by Florian Klaempfl, Pierre Muller
-
-    interprets the commandline options which are iSPARC specific
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ****************************************************************************
-}
-unit cpuswtch;
-
-{$INCLUDE fpcdefs.inc}
-
-interface
-
-uses
-  options;
-
-type
-  toptionSPARC=class(toption)
-    procedure interpret_proc_specific_options(const opt:string);override;
-  end;
-
-implementation
-
-uses
-  cutils,globtype,systems,globals,cpuinfo;
-
-procedure toptionSPARC.interpret_proc_specific_options(const opt:string);
-var
-  j     : longint;
-  More  : string;
-begin
-  More:=Upper(copy(opt,3,length(opt)-2));
-  case opt[2] of
-   'O' : Begin
-           j := 3;
-           While (j <= Length(Opt)) Do
-             Begin
-               case opt[j] of
-                 '-' :
-                   begin
-                     initglobalswitches:=initglobalswitches-[cs_optimize,cs_fastoptimize,cs_slowoptimize,cs_littlesize,
-                       cs_regvars,cs_uncertainopts];
-                     FillChar(ParaAlignment,sizeof(ParaAlignment),0);
-                   end;
-                 'a' :
-                   begin
-                     UpdateAlignmentStr(Copy(Opt,j+1,255),ParaAlignment);
-                     j:=length(Opt);
-                   end;
-                 'g' : initglobalswitches:=initglobalswitches+[cs_littlesize];
-                 'G' : initglobalswitches:=initglobalswitches-[cs_littlesize];
-                 'r' :
-                   begin
-                     initglobalswitches:=initglobalswitches+[cs_regvars];
-                     Simplify_ppu:=false;
-                   end;
-                 'u' : initglobalswitches:=initglobalswitches+[cs_uncertainopts];
-                 '1' : initglobalswitches:=initglobalswitches-[cs_fastoptimize,cs_slowoptimize]+[cs_optimize];
-                 '2' : initglobalswitches:=initglobalswitches-[cs_slowoptimize]+[cs_optimize,cs_fastoptimize];
-                 '3' : initglobalswitches:=initglobalswitches+[cs_optimize,cs_fastoptimize,cs_slowoptimize];
-                 'p' :
-                   Begin
-                     If j < Length(Opt) Then
-                       Begin
-                         Case opt[j+1] Of
-                           '1': initoptprocessor := SPARC_V8;
-                           '2': initoptprocessor := SPARC_V9;
-                           '3': initoptprocessor := SPARC_V9;
-                           Else IllegalPara(Opt)
-                         End;
-                         Inc(j);
-                       End
-                     Else IllegalPara(opt)
-                   End;
-{$ifdef USECMOV}
-                 's' :
-                   Begin
-                     If j < Length(Opt) Then
-                       Begin
-                         Case opt[j+1] Of
-                           '3': initspecificoptprocessor:=ClassP6
-                           Else IllegalPara(Opt)
-                         End;
-                         Inc(j);
-                       End
-                     Else IllegalPara(opt)
-                   End
-{$endif USECMOV}
-                 else IllegalPara(opt);
-               End;
-               Inc(j)
-             end;
-         end;
-   'R' : begin
-           if More='GAS' then
-            initasmmode:=asmmode_i386_att
-           else
-            if More='STANDARD' then
-             initasmmode:=asmmode_i386_intel
-           else
-            IllegalPara(opt);
-         end;
-  else
-   IllegalPara(opt);
-  end;
-end;
-
-
-initialization
-  coption:=toptionSPARC;
-end.

+ 1 - 1
compiler/symsym.pas

@@ -1274,7 +1274,7 @@ implementation
                registers is not valid anymore)
            - it has a local copy
            - the value needs to be in memory (i.e. reference counted) }
-        result:=(cs_regvars in aktglobalswitches) and
+        result:=(cs_opt_regvar in aktoptimizerswitches) and
                 not(pi_has_assembler_block in current_procinfo.flags) and
                 not(pi_uses_exceptions in current_procinfo.flags) and
                 not(vo_has_local_copy in varoptions) and

+ 1 - 1
compiler/vis/cpuinfo.pas

@@ -39,7 +39,7 @@ Type
    pbestreal=^bestreal;
 
    { possible supported processors for this target }
-   tprocessors = (no_processor);
+   tcputype = (cpu_none);
 
 Const
    {# Size of native extended floating point type }

+ 3 - 3
compiler/x86/cgx86.pas

@@ -1604,7 +1604,7 @@ unit cgx86;
     begin
       cm:=copy_move;
       helpsize:=12;
-      if cs_littlesize in aktglobalswitches then
+      if cs_opt_size in aktoptimizerswitches then
         helpsize:=8;
       if (cs_mmx in aktlocalswitches) and
          not(pi_uses_fpu in current_procinfo.flags) and
@@ -1612,7 +1612,7 @@ unit cgx86;
         cm:=copy_mmx;
       if (len>helpsize) then
         cm:=copy_string;
-      if (cs_littlesize in aktglobalswitches) and
+      if (cs_opt_size in aktoptimizerswitches) and
          not((len<=16) and (cm=copy_mmx)) then
         cm:=copy_string;
       case cm of
@@ -1698,7 +1698,7 @@ unit cgx86;
             getcpuregister(list,REGCX);
 
             list.concat(Taicpu.op_none(A_CLD,S_NO));
-            if cs_littlesize in aktglobalswitches  then
+            if cs_opt_size in aktoptimizerswitches  then
               begin
                 a_load_const_reg(list,OS_INT,len,REGCX);
                 list.concat(Taicpu.op_none(A_REP,S_NO));

+ 1 - 1
compiler/x86/nx86add.pas

@@ -874,7 +874,7 @@ unit nx86add;
         left_and_right_must_be_fpureg;
 
 {$ifndef x86_64}
-        if aktspecificoptprocessor<ClassPentium2 then
+        if aktspecificoptcputype<cpu_Pentium2 then
           begin
             emit_none(A_FCOMPP,S_NO);
             tcgx86(cg).dec_fpu_stack;

+ 1 - 1
compiler/x86/nx86inl.pas

@@ -309,7 +309,7 @@ implementation
          r : tregister;
        begin
 {$ifdef i386}
-         if aktspecificoptprocessor>=ClassPentium3 then
+         if aktspecificoptcputype>=cpu_Pentium3 then
 {$endif i386}
            begin
              secondpass(left);

+ 1 - 1
compiler/x86/nx86set.pas

@@ -114,7 +114,7 @@ implementation
              { Lots of comparisions take a lot of time, so do not allow
                too much comparisions. 8 comparisions are, however, still
                smalller than emitting the set }
-             if cs_littlesize in aktglobalswitches then
+             if cs_opt_size in aktoptimizerswitches then
                maxcompares:=8
              else
                maxcompares:=5;

+ 1 - 1
compiler/x86/rgx86.pas

@@ -333,7 +333,7 @@ implementation
       var
         r: Tregister;
       begin
-        if not(cs_regvars in aktglobalswitches) then
+        if not(cs_opt_regvar in aktoptimizerswitches) then
           exit;
         if firstsavefpureg <> NR_NO then
           for r.enum := firstsavefpureg to lastsavefpureg do

+ 9 - 5
compiler/x86_64/cpuinfo.pas

@@ -38,13 +38,13 @@ Type
 
    pbestreal=^bestreal;
 
-   tprocessors =
-      (no_processor,
-       ClassAthlon64
+   tcputype =
+      (cpu_none,
+       cpu_athlon64
       );
 
    tfputype =
-     (no_fpuprocessor,
+     (fpu_none,
       fpu_sse64
      );
 
@@ -68,7 +68,7 @@ Const
      pocall_cppdecl
    ];
 
-   processorsstr : array[tprocessors] of string[10] = ('',
+   cputypestr : array[tcputype] of string[10] = ('',
      'ATHLON64'
    );
 
@@ -79,6 +79,10 @@ Const
    sse_singlescalar : set of tfputype = [fpu_sse64];
    sse_doublescalar : set of tfputype = [fpu_sse64];
 
+   level1optimizerswitches = [cs_opt_level1];
+   level2optimizerswitches = level1optimizerswitches + [cs_opt_level2,cs_opt_regvar,cs_opt_stackframe];
+   level3optimizerswitches = level2optimizerswitches + [cs_opt_level3,cs_opt_loopunroll];
+
 Implementation
 
 end.

+ 0 - 97
compiler/x86_64/cpuswtch.pas

@@ -1,97 +0,0 @@
-{
-    Copyright (c) 1998-2002 by Florian Klaempfl, Pierre Muller
-
-    interprets the commandline options which are i386 specific
-
-    This program is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License as published by
-    the Free Software Foundation; either version 2 of the License, or
-    (at your option) any later version.
-
-    This program is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-    GNU General Public License for more details.
-
-    You should have received a copy of the GNU General Public License
-    along with this program; if not, write to the Free Software
-    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
-
- ****************************************************************************
-}
-unit cpuswtch;
-
-{$i fpcdefs.inc}
-
-interface
-
-uses
-  options;
-
-type
-  toptionx86_64=class(toption)
-    procedure interpret_proc_specific_options(const opt:string);override;
-  end;
-
-implementation
-
-uses
-  cutils,globtype,systems,globals;
-
-procedure toptionx86_64.interpret_proc_specific_options(const opt:string);
-var
-  j     : longint;
-  More  : string;
-begin
-  More:=Upper(copy(opt,3,length(opt)-2));
-  case opt[2] of
-   'O' : Begin
-           j := 3;
-           While (j <= Length(Opt)) Do
-             Begin
-               case opt[j] of
-                 '-' :
-                   begin
-                     initglobalswitches:=initglobalswitches-[cs_optimize,cs_fastoptimize,cs_slowoptimize,cs_littlesize,
-                       cs_regvars,cs_uncertainopts];
-                     FillChar(ParaAlignment,sizeof(ParaAlignment),0);
-                   end;
-                 'a' :
-                   begin
-                     UpdateAlignmentStr(Copy(Opt,j+1,255),ParaAlignment);
-                     j:=length(Opt);
-                   end;
-                 'g' : initglobalswitches:=initglobalswitches+[cs_littlesize];
-                 'G' : initglobalswitches:=initglobalswitches-[cs_littlesize];
-                 'r' :
-                   begin
-                     initglobalswitches:=initglobalswitches+[cs_regvars];
-                     Simplify_ppu:=false;
-                   end;
-                 'u' : initglobalswitches:=initglobalswitches+[cs_uncertainopts];
-                 '1' : initglobalswitches:=initglobalswitches-[cs_fastoptimize,cs_slowoptimize]+[cs_optimize];
-                 '2' : initglobalswitches:=initglobalswitches-[cs_slowoptimize]+[cs_optimize,cs_fastoptimize];
-                 '3' : initglobalswitches:=initglobalswitches+[cs_optimize,cs_fastoptimize,cs_slowoptimize];
-                 else IllegalPara(opt);
-               End;
-               Inc(j)
-             end;
-         end;
-   'R' : begin
-           if More='ATT' then
-            initasmmode:=asmmode_i386_att
-           else
-            if More='INTEL' then
-             initasmmode:=asmmode_i386_intel
-           else
-            IllegalPara(opt);
-         end;
-  else
-   IllegalPara(opt);
-  end;
-end;
-
-
-initialization
-  coption:=toptionx86_64;
-end.