* list supported optimization options in -i

* support $OPTIMIZATION and $O+

git-svn-id: trunk@2904 -
This commit is contained in:
peter 2006-03-13 11:17:56 +00:00
parent 17bc033747
commit 2888a21593
16 changed files with 432 additions and 357 deletions

View File

@ -82,6 +82,9 @@ Const
'VFP'
);
{ Supported optimizations, only used for information }
supported_optimizerswitches = [cs_opt_regvar,cs_opt_loopunroll];
level1optimizerswitches = [cs_opt_level1];
level2optimizerswitches = level1optimizerswitches + [cs_opt_level2,cs_opt_regvar,cs_opt_stackframe];
level3optimizerswitches = level2optimizerswitches + [cs_opt_level3,cs_opt_loopunroll];

View File

@ -2067,9 +2067,10 @@ end;
function UpdateOptimizerStr(s:string;var a:toptimizerswitches):boolean;
var
tok : string;
doset : boolean;
doswitch : toptimizerswitch;
tok : string;
doset,
found : boolean;
opt : toptimizerswitch;
begin
result:=true;
uppervar(s);
@ -2084,27 +2085,24 @@ end;
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
found:=false;
for opt:=low(toptimizerswitch) to high(toptimizerswitch) do
begin
if OptimizerSwitchStr[opt]=tok then
begin
found:=true;
break;
end;
end;
if found then
begin
if doset then
include(a,doswitch)
include(a,opt)
else
exclude(a,doswitch);
end;
exclude(a,opt);
end
else
result:=false;
until false;
end;

View File

@ -129,6 +129,7 @@ than 255 characters. That's why using Ansi Strings}
);
tglobalswitches = set of tglobalswitch;
type
{ optimizer }
toptimizerswitch = (cs_opt_none,
cs_opt_level1,cs_opt_level2,cs_opt_level3,
@ -137,6 +138,14 @@ than 255 characters. That's why using Ansi Strings}
);
toptimizerswitches = set of toptimizerswitch;
const
OptimizerSwitchStr : array[toptimizerswitch] of string[10] = ('',
'LEVEL1','LEVEL2','LEVEL3',
'REGVAR','UNCERTAIN','SIZE','STACKFRAME',
'PEEPHOLE','ASMCSE','LOOPUNROLL'
);
type
{ Switches which can be changed by a mode (fpc,tp7,delphi) }
tmodeswitch = (m_none,m_all, { needed for keyword }
{ generic }
@ -227,6 +236,30 @@ than 255 characters. That's why using Ansi Strings}
);
tproccalloptions = set of tproccalloption;
const
proccalloptionStr : array[tproccalloption] of string[14]=('',
'CDecl',
'CPPDecl',
'Far16',
'OldFPCCall',
'InternProc',
'SysCall',
'Pascal',
'Register',
'SafeCall',
'StdCall',
'SoftFloat',
'MWPascal'
);
{ Default calling convention }
{$ifdef x86}
pocall_default = pocall_register;
{$else}
pocall_default = pocall_stdcall;
{$endif}
type
tprocinfoflag=(
{ procedure has at least one assembler block }
pi_has_assembler_block,
@ -254,29 +287,6 @@ than 255 characters. That's why using Ansi Strings}
);
tprocinfoflags=set of tprocinfoflag;
const
proccalloptionStr : array[tproccalloption] of string[14]=('',
'CDecl',
'CPPDecl',
'Far16',
'OldFPCCall',
'InternProc',
'SysCall',
'Pascal',
'Register',
'SafeCall',
'StdCall',
'SoftFloat',
'MWPascal'
);
{ Default calling convention }
{$ifdef x86}
pocall_default = pocall_register;
{$else}
pocall_default = pocall_stdcall;
{$endif}
type
stringid = string[maxidlen];

View File

@ -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];
{ Supported optimizations, only used for information }
supported_optimizerswitches = [cs_opt_peephole,cs_opt_regvar,cs_opt_stackframe,
cs_opt_asmcse,cs_opt_loopunroll,cs_opt_uncertain];
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];

View File

@ -69,6 +69,9 @@ Const
'68881'
);
{ Supported optimizations, only used for information }
supported_optimizerswitches = [cs_opt_regvar,cs_opt_loopunroll];
level1optimizerswitches = [cs_opt_level1];
level2optimizerswitches = level1optimizerswitches + [cs_opt_level2,cs_opt_regvar,cs_opt_stackframe];
level3optimizerswitches = level2optimizerswitches + [cs_opt_level3,cs_opt_loopunroll];

View File

@ -66,6 +66,9 @@ Const
'FPU'
);
{ Supported optimizations, only used for information }
supported_optimizerswitches = [cs_opt_regvar,cs_opt_loopunroll];
level1optimizerswitches = [];
level2optimizerswitches = level1optimizerswitches + [cs_opt_regvar,cs_opt_stackframe];
level3optimizerswitches = level2optimizerswitches + [cs_opt_loopunroll];

View File

@ -322,6 +322,9 @@ scan_e_compile_time_typeerror=02072_E_Compile time expression: Wanted $1 but got
% Type check of a compile time expression failed.
scan_n_app_type_not_support=02073_N_APPTYPE is not supported by the target OS
% The \var{\{\$APPTYPE\}} directive is supported by certain operating systems only.
scan_e_illegal_optimization_specifier=02074_E_Illegal optimization specified "$1"
% When you specify an optimization with the \var{\{\$OPTIMIZATION xxx\}}
% the compiler didn't recognize the optimization you specified.
% \end{description}
#
# Parser
@ -2180,6 +2183,9 @@ Supported CPU instruction sets:
Supported FPU instruction sets:
$FPUINSTRUCTIONSETS
Supported Optimizations:
$OPTIMIZATIONS
This program comes under the GNU General Public Licence
For more information read COPYING.FPC
@ -2306,23 +2312,14 @@ S*2Aas_assemble using GNU AS
**2Nu_unroll loops
**1o<x>_change the name of the executable produced to <x>
**1O<x>_optimizations:
3*2Oa_<type>=<values> set alignment
3*2Og_generate smaller code
3*2OG_generate faster code (default)
**2Or_keep certain variables in registers
3*2Ou_enable uncertain optimizations (see docs)
3*2O1_level 1 optimizations (quick optimizations)
3*2O2_level 2 optimizations (-O1 + slower optimizations)
3*2O3_level 3 optimizations (-O2 repeatedly, max 5 times)
3*2Op<x>_target processor:
3*3Op1_set target processor to 386/486
3*3Op2_set target processor to Pentium/PentiumMMX (tm)
3*3Op3_set target processor to PPro/PII/c6x86/K6 (tm)
6*2Og_generate smaller code
6*2OG_generate faster code (default)
6*2Ox_optimize maximum (still BUGGY!!!)
6*2O0_set target processor to a MC68000
6*2O2_set target processor to a MC68020+ (default)
**2O-_disable optimizations
**2O1_level 1 optimizations (quick and debugger friendly)
**2O2_level 2 optimizations (-O1 + quick optimizations)
**2O3_level 3 optimizations (-O2 + slow optimizations)
**2Oa<x>=<y>_set alignment
**2Oo[NO]<x>_enable or disable optimizations, see fpc -i for possible values
**2Op<x>_set target cpu for optimizing, see fpc -i for possible values
**2Os_generate smaller code
**1pg_generate profile code for gprof (defines FPC_PROFILE)
**1R<x>_assembler reading style:
**2Rdefault_use default assembler

View File

@ -89,6 +89,7 @@ const
scan_c_switching_to_utf8=02071;
scan_e_compile_time_typeerror=02072;
scan_n_app_type_not_support=02073;
scan_e_illegal_optimization_specifier=02074;
parser_e_syntax_error=03000;
parser_e_dont_nest_interrupt=03004;
parser_w_proc_directive_ignored=03005;
@ -670,9 +671,9 @@ const
option_info=11024;
option_help_pages=11025;
MsgTxtSize = 39804;
MsgTxtSize = 39564;
MsgIdxMax : array[1..20] of longint=(
19,74,219,59,62,47,100,21,135,60,
19,75,219,59,62,47,100,21,135,60,
41,1,1,1,1,1,1,1,1,1
);

File diff suppressed because it is too large Load Diff

View File

@ -160,6 +160,7 @@ var
target : tsystem;
cpu : tcputype;
fpu : tfputype;
opt : toptimizerswitch;
begin
p:=MessagePchar(option_info);
while assigned(p) do
@ -205,6 +206,22 @@ begin
end;
end;
end
else if pos('$OPTIMIZATIONS',s)>0 then
begin
for opt:=low(toptimizerswitch) to high(toptimizerswitch) do
begin
if opt in supported_optimizerswitches then
begin
hs:=s;
hs1:=OptimizerSwitchStr[opt];
if hs1<>'' then
begin
Replace(hs,'$OPTIMIZATIONS',hs1);
Comment(V_Normal,hs);
end;
end;
end;
end
else
Comment(V_Normal,s);
end;

View File

@ -66,6 +66,9 @@ Const
'STANDARD'
);
{ Supported optimizations, only used for information }
supported_optimizerswitches = [cs_opt_regvar,cs_opt_loopunroll];
level1optimizerswitches = [cs_opt_level1];
level2optimizerswitches = level1optimizerswitches + [cs_opt_level2,cs_opt_regvar];
level3optimizerswitches = level2optimizerswitches + [cs_opt_level3,cs_opt_loopunroll];

View File

@ -60,6 +60,9 @@ const
'STANDARD'
);
{ Supported optimizations, only used for information }
supported_optimizerswitches = [cs_opt_regvar,cs_opt_loopunroll];
level1optimizerswitches = [cs_opt_level1];
level2optimizerswitches = level1optimizerswitches + [cs_opt_level2,cs_opt_regvar,cs_opt_stackframe];
level3optimizerswitches = level2optimizerswitches + [cs_opt_level3,cs_opt_loopunroll];

View File

@ -32,7 +32,7 @@ implementation
uses
cutils,
globtype,globals,systems,widestr,
globtype,globals,systems,widestr,cpuinfo,
verbose,comphook,ppu,
scanner,switches,
fmodule,
@ -697,6 +697,26 @@ implementation
do_delphiswitch('P');
end;
procedure dir_optimization;
var
hs : string;
begin
current_scanner.skipspace;
{ Support also the ON and OFF as switch }
hs:=current_scanner.readid;
if (hs='ON') then
aktoptimizerswitches:=level2optimizerswitches
else if (hs='OFF') then
aktoptimizerswitches:=[]
else if (hs='DEFAULT') then
aktoptimizerswitches:=initoptimizerswitches
else
begin
if not UpdateOptimizerStr(hs,aktoptimizerswitches) then
Message1(scan_e_illegal_optimization_specifier,hs);
end;
end;
procedure dir_overflowchecks;
begin
do_delphiswitch('Q');
@ -1197,6 +1217,7 @@ implementation
AddDirective('OBJECTCHECKS',directive_all, @dir_objectchecks);
AddDirective('OBJECTPATH',directive_all, @dir_objectpath);
AddDirective('OPENSTRINGS',directive_all, @dir_openstrings);
AddDirective('OPTIMIZATION',directive_all, @dir_optimization);
AddDirective('OVERFLOWCHECKS',directive_all, @dir_overflowchecks);
AddDirective('PACKENUM',directive_all, @dir_packenum);
AddDirective('PACKRECORDS',directive_all, @dir_packrecords);

View File

@ -70,6 +70,9 @@ const
'HARD'
);
{ Supported optimizations, only used for information }
supported_optimizerswitches = [cs_opt_regvar,cs_opt_loopunroll];
level1optimizerswitches = [cs_opt_level1];
level2optimizerswitches = level1optimizerswitches + [cs_opt_level2,cs_opt_regvar];
level3optimizerswitches = level2optimizerswitches + [cs_opt_level3,cs_opt_loopunroll];

View File

@ -31,7 +31,7 @@ function CheckSwitch(switch,state:char):boolean;
implementation
uses
globtype,systems,
globtype,systems,cpuinfo,
globals,verbose,fmodule;
{****************************************************************************
@ -39,7 +39,7 @@ uses
****************************************************************************}
type
TSwitchType=(ignoredsw,localsw,modulesw,globalsw,illegalsw,unsupportedsw,alignsw);
TSwitchType=(ignoredsw,localsw,modulesw,globalsw,illegalsw,unsupportedsw,alignsw,optimizersw);
SwitchRec=record
typesw : TSwitchType;
setsw : byte;
@ -62,7 +62,7 @@ const
{L} (typesw:modulesw; setsw:ord(cs_local_browser)),
{M} (typesw:localsw; setsw:ord(cs_generate_rtti)),
{N} (typesw:unsupportedsw; setsw:ord(cs_localnone)),
{O} (typesw:unsupportedsw; setsw:ord(cs_localnone)),
{O} (typesw:optimizersw; setsw:ord(cs_opt_none)),
{P} (typesw:modulesw; setsw:ord(cs_openstring)),
{Q} (typesw:localsw; setsw:ord(cs_check_overflow)),
{R} (typesw:localsw; setsw:ord(cs_check_range)),
@ -92,7 +92,7 @@ const
{L} (typesw:modulesw; setsw:ord(cs_local_browser)),
{M} (typesw:localsw; setsw:ord(cs_generate_rtti)),
{N} (typesw:unsupportedsw; setsw:ord(cs_localnone)),
{O} (typesw:unsupportedsw; setsw:ord(cs_localnone)),
{O} (typesw:optimizersw; setsw:ord(cs_opt_none)),
{P} (typesw:modulesw; setsw:ord(cs_openstring)),
{Q} (typesw:localsw; setsw:ord(cs_check_overflow)),
{R} (typesw:localsw; setsw:ord(cs_check_range)),
@ -135,6 +135,13 @@ begin
aktpackrecords:=4
else
aktpackrecords:=1;
optimizersw :
begin
if state='+' then
aktoptimizerswitches:=level2optimizerswitches
else
aktoptimizerswitches:=[];
end;
ignoredsw :
Message1(scan_n_ignored_switch,'$'+switch);
illegalsw :

View File

@ -79,6 +79,9 @@ Const
sse_singlescalar : set of tfputype = [fpu_sse64];
sse_doublescalar : set of tfputype = [fpu_sse64];
{ Supported optimizations, only used for information }
supported_optimizerswitches = [cs_opt_regvar,cs_opt_loopunroll,cs_opt_stackframe];
level1optimizerswitches = [cs_opt_level1];
level2optimizerswitches = level1optimizerswitches + [cs_opt_level2,cs_opt_regvar,cs_opt_stackframe];
level3optimizerswitches = level2optimizerswitches + [cs_opt_level3,cs_opt_loopunroll];