diff: handling of --grade options
Fergus Henderson
fjh at cs.mu.oz.au
Thu Oct 2 11:28:24 AEST 1997
Hi,
This change isn't complete yet.
But I thought it worth posting at this stage to see
if anyone has any comments about this set of proposed changes.
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
scripts/mgnuc.in:
Allow the user to mix `--grade foo' options with
other options that affect the grade such as `--profiling'.
Compute the final grade to link with from the options.
Add `--profile-time' and `--profile-calls' options.
Change `--profiling' to now just imply both of those.
Add support for grades *.proftime and *.profcalls.
Add `--pic-reg' option (just implies `-DPIC_REG' in cflags).
Make `.debug' a grade modifier, rather than having a base
grade `debug'.
Change mgnuc to support most of the same compilation model
options as mmc.
XXX should also change `ml'
doc/user_guide.texi:
Document the above changes.
XXX need to document it better
cvs diff compiler/handle_options.m compiler/mercury_compile.m compiler/options.m doc/user_guide.texi scripts/mgnuc.in
Index: compiler/handle_options.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/handle_options.m,v
retrieving revision 1.29
diff -u -r1.29 handle_options.m
--- handle_options.m 1997/09/02 07:03:39 1.29
+++ handle_options.m 1997/10/02 00:53:46
@@ -10,12 +10,15 @@
% This module does post-procesing on the command-line options, after
% getopt has done its stuff.
+% It also contains code for handling the --grade option.
+
%-----------------------------------------------------------------------------%
:- module handle_options.
:- interface.
:- import_module list, bool, std_util, io.
+:- import_module globals, options.
:- pred handle_options(maybe(string), list(string), bool, io__state, io__state).
:- mode handle_options(out, out, out, di, uo) is det.
@@ -29,6 +32,16 @@
% Display long usage message for help
:- pred long_usage(io__state::di, io__state::uo) is det.
+
+ % Given the current set of options, figure out
+ % which grade to use.
+:- pred compute_grade(globals::in, string::out) is det.
+
+ % The inverse of compute_grade: given a grade,
+ % set the appropriate options.
+:- pred convert_grade_option(string::in, option_table::in, option_table::out)
+ is semidet.
+
%-----------------------------------------------------------------------------%
:- implementation.
@@ -94,12 +107,7 @@
:- mode postprocess_options(in, out, di, uo) is det.
postprocess_options(error(ErrorMessage), yes(ErrorMessage)) --> [].
-postprocess_options(ok(OptionTable0), Error) -->
- { map__lookup(OptionTable0, grade, GradeOpt) },
- (
- { GradeOpt = string(GradeStr) },
- { convert_grade_option(GradeStr, OptionTable0, OptionTable) }
- ->
+postprocess_options(ok(OptionTable), Error) -->
{ map__lookup(OptionTable, gc, GC_Method0) },
(
{ GC_Method0 = string(GC_MethodStr) },
@@ -158,10 +166,7 @@
)
;
{ Error = yes("Invalid GC option (must be `none', `conservative' or `accurate')") }
- )
- ;
- { Error = yes("Invalid grade option") }
- ).
+ ).
:- pred postprocess_options_2(option_table, gc_method, tags_method, args_method,
type_info_method, prolog_dialect, io__state, io__state).
@@ -219,7 +224,8 @@
io__progname_base("mercury_compile", ProgName),
io__stderr_stream(StdErr),
report_warning(ProgName),
- report_warning(": warning: --num-tag-bits invalid or unspecified\n"),
+ report_warning(
+ ": warning: --num-tag-bits invalid or unspecified\n"),
io__write_string(StdErr, ProgName),
report_warning(": using --num-tag-bits 0 (tags disabled)\n"),
{ NumTagBits = 0 }
@@ -248,7 +254,8 @@
% -D all is really -D "abcdefghijklmnopqrstuvwxyz"
globals__io_lookup_string_option(verbose_dump_hlds, VerboseDump),
( { VerboseDump = "all" } ->
- globals__io_set_option(verbose_dump_hlds, string("abcdefghijklmnopqrstuvwxyz"))
+ globals__io_set_option(verbose_dump_hlds,
+ string("abcdefghijklmnopqrstuvwxyz"))
;
[]
),
@@ -304,32 +311,153 @@
[]
).
-:- pred convert_grade_option(string::in, option_table::in, option_table::out)
- is semidet.
+ % IMPORTANT: any changes here will require similar changes to
+ % runtime/mercury_grade.h.
+
+compute_grade(Globals, Grade) :-
+ globals__lookup_bool_option(Globals, asm_labels, AsmLabels),
+ globals__lookup_bool_option(Globals, gcc_non_local_gotos,
+ NonLocalGotos),
+ globals__lookup_bool_option(Globals, gcc_global_registers, GlobalRegs),
+ globals__get_gc_method(Globals, GC_Method),
+ globals__lookup_bool_option(Globals, profiling, Profiling),
+ globals__lookup_bool_option(Globals, use_trail, UseTrail),
+/*
+% These vary from machine to machine, and (for backwards compatibility,
+% if nothing else) we want examples such as "GRADE = asm_fast.gc.prof"
+% to continue to work, so we can't include these in the grade.
+ globals__get_tags_method(Globals, TagsMethod),
+ globals__lookup_int_option(Globals, tag_bits, TagBits),
+ globals__lookup_bool_option(Globals, unboxed_float, UnboxedFloat),
+*/
+ globals__get_args_method(Globals, ArgsMethod),
+ globals__lookup_bool_option(Globals, debug, Debug),
+ globals__lookup_bool_option(Globals, pic_reg, PIC_Reg),
+
+ ( AsmLabels = yes ->
+ Part1 = "asm_"
+ ;
+ Part1 = ""
+ ),
+ ( NonLocalGotos = yes ->
+ ( GlobalRegs = yes ->
+ Part2 = "fast"
+ ;
+ Part2 = "jump"
+ )
+ ;
+ ( GlobalRegs = yes ->
+ Part2 = "reg"
+ ;
+ Part2 = "none"
+ )
+ ),
+ ( GC_Method = conservative, Part3 = ".gc"
+ ; GC_Method = accurate, Part3 = ".agc"
+ ; GC_Method = none, Part3 = ""
+ ),
+ ( Profiling = yes ->
+ Part4 = ".prof"
+ ;
+ Part4 = ""
+ ),
+ ( UseTrail = yes ->
+ Part5 = ".tr"
+ ;
+ Part5 = ""
+ ),
+
+/*
+% These vary from machine to machine, and (for backwards compatibility,
+% if nothing else) we want examples such as "GRADE = asm_fast.gc.prof"
+% to continue to work, so we can't include these in the grade.
+ ( HighTags = yes ->
+ string__format(".hightags%d", [i(TagBits)], Part6)
+ ;
+ string__format(".tags%d", [i(TagBits)], Part6)
+ ;
+
+ ),
+ ( UnboxedFloat = yes ->
+ Part7 = ".ubf"
+ ;
+ Part7 = ""
+ ),
+*/
+ Part6 = "",
+ Part7 = "",
+
+ ( ArgsMethod = compact, Part8 = ""
+ ; ArgsMethod = simple, Part8 = ".sa"
+ ),
+
+ ( Debug = yes ->
+ Part9 = ".debug"
+ ;
+ Part9 = ""
+ ),
+
+ ( PIC_Reg = yes ->
+ Part10 = ".picreg"
+ ;
+ Part10 = ""
+ ),
+
+ string__append_list( [Part1, Part2, Part3, Part4, Part5,
+ Part6, Part7, Part8, Part9, Part10], Grade).
convert_grade_option(Grade0) -->
- ( { string__remove_suffix(Grade0, ".tr", Grade1) } ->
+ % part10
+ ( { string__remove_suffix(Grade0, ".picreg", Grade1) } ->
{ Grade2 = Grade1 },
- set_bool_opt(use_trail, yes)
+ set_bool_opt(pic_reg, yes)
;
{ Grade2 = Grade0 },
- set_bool_opt(use_trail, no)
+ set_bool_opt(pic_reg, no)
),
- ( { string__remove_suffix(Grade2, ".prof", Grade3) } ->
+ % part9
+ ( { string__remove_suffix(Grade2, ".debug", Grade3) } ->
{ Grade4 = Grade3 },
- set_bool_opt(profiling, yes)
+ set_bool_opt(debug, yes)
;
{ Grade4 = Grade2 },
+ set_bool_opt(debug, no)
+ ),
+ % part8
+ ( { string__remove_suffix(Grade4, ".sa", Grade5) } ->
+ { Grade6 = Grade5 },
+ set_string_opt(args, "simple")
+ ;
+ { Grade6 = Grade4 },
+ set_string_opt(args, "compact")
+ ),
+ % part6 & 7
+ { Grade10 = Grade6 },
+ % part5
+ ( { string__remove_suffix(Grade10, ".tr", Grade11) } ->
+ { Grade12 = Grade11 },
+ set_bool_opt(use_trail, yes)
+ ;
+ { Grade12 = Grade10 },
+ set_bool_opt(use_trail, no)
+ ),
+ % part 4
+ ( { string__remove_suffix(Grade12, ".prof", Grade13) } ->
+ { Grade14 = Grade13 },
+ set_bool_opt(profiling, yes)
+ ;
+ { Grade14 = Grade12 },
set_bool_opt(profiling, no)
),
- ( { string__remove_suffix(Grade4, ".gc", Grade5) } ->
- { Grade = Grade5 },
+ % part 3
+ ( { string__remove_suffix(Grade14, ".gc", Grade15) } ->
+ { Grade = Grade15 },
{ GC = conservative }
- ; { string__remove_suffix(Grade4, ".agc", Grade5) } ->
- { Grade = Grade5 },
+ ; { string__remove_suffix(Grade14, ".agc", Grade15) } ->
+ { Grade = Grade15 },
{ GC = accurate }
;
- { Grade = Grade4 },
+ { Grade = Grade14 },
{ GC = none }
),
% Set the type of gc that the grade option implies.
@@ -344,6 +472,7 @@
{ GC = none },
set_string_opt(gc, "none")
),
+ % parts 2 & 1
convert_grade_option_2(Grade).
:- pred convert_grade_option_2(string::in, option_table::in, option_table::out)
Index: compiler/mercury_compile.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/mercury_compile.m,v
retrieving revision 1.54
diff -u -r1.54 mercury_compile.m
--- mercury_compile.m 1997/09/25 03:34:51 1.54
+++ mercury_compile.m 1997/10/02 01:01:33
@@ -1027,9 +1027,10 @@
mercury_compile__maybe_output_prof_call_graph(ModuleInfo0, Verbose, Stats,
ModuleInfo) -->
- globals__io_lookup_bool_option(profiling, Profiling),
+ globals__io_lookup_bool_option(profile_calls, ProfileCalls),
+ globals__io_lookup_bool_option(profile_time, ProfileTime),
(
- { Profiling = yes }
+ { ProfileCalls = yes ; ProfileTime = yes }
->
maybe_write_string(Verbose, "% Outputing profiling call graph..."),
maybe_flush_output(Verbose),
@@ -1656,11 +1657,23 @@
;
GC_Opt = ""
},
- globals__io_lookup_bool_option(profiling, Profiling),
- { Profiling = yes ->
- ProfileOpt = "-DPROFILE_CALLS -DPROFILE_TIME "
+ globals__io_lookup_bool_option(profile_calls, ProfileCalls),
+ { ProfileCalls = yes ->
+ ProfileCallsOpt = "-DPROFILE_CALLS "
;
- ProfileOpt = ""
+ ProfileCallsOpt = ""
+ },
+ globals__io_lookup_bool_option(profile_time, ProfileTime),
+ { ProfileTime = yes ->
+ ProfileTimeOpt = "-DPROFILE_TIME "
+ ;
+ ProfileTimeOpt = ""
+ },
+ globals__io_lookup_bool_option(pic_reg, PIC_Reg),
+ { PIC_Reg = yes ->
+ PIC_Reg_Opt = "-DPIC_REG "
+ ;
+ PIC_Reg_Opt = ""
},
globals__io_get_tags_method(Tags_Method),
{ Tags_Method = high ->
@@ -1746,7 +1759,8 @@
{ string__append_list([CC, " ", InclOpt, SplitOpt, OptimizeOpt,
RegOpt, GotoOpt, AsmOpt,
CFLAGS_FOR_REGS, " ", CFLAGS_FOR_GOTOS, " ",
- GC_Opt, ProfileOpt, TagsOpt, NumTagBitsOpt, DebugOpt,
+ GC_Opt, ProfileCallsOpt, ProfileTimeOpt, PIC_Reg_Opt,
+ TagsOpt, NumTagBitsOpt, DebugOpt,
UseTrailOpt, ArgsOpt, TypeInfoOpt, TypeLayoutOpt,
InlineAllocOpt, WarningOpt, CFLAGS,
" -c ", C_File, " -o ", O_File], Command) },
@@ -1815,7 +1829,8 @@
report_error("compilation of init file failed.")
;
maybe_write_string(Verbose, "% Linking...\n"),
- globals__io_lookup_string_option(grade, Grade),
+ globals__io_get_globals(Globals),
+ { compute_grade(Globals, Grade) },
globals__io_lookup_accumulating_option(link_flags,
LinkFlagsList),
{ join_string_list(LinkFlagsList, "", "", " ", LinkFlags) },
Index: compiler/options.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/options.m,v
retrieving revision 1.203
diff -u -r1.203 options.m
--- options.m 1997/08/25 02:24:46 1.203
+++ options.m 1997/10/02 00:46:16
@@ -93,7 +93,10 @@
; asm_labels
; gc
; profiling
+ ; profile_calls
+ ; profile_time
; use_trail
+ ; pic_reg
; debug
; debug_data
; tags
@@ -220,7 +223,8 @@
:- implementation.
-:- import_module bool, int, map, std_util, assoc_list, require, list.
+:- import_module string, bool, int, map, std_util, assoc_list, require, list.
+:- import_module handle_options.
:- type option_category
---> warning_option
@@ -312,16 +316,19 @@
option_defaults_2(compilation_model_option, [
% Compilation model options (ones that affect binary
% compatibility).
- grade - string("asm_fast.gc"),
- % the `mc' script will override the
- % above default with a value determined
+ grade - string_special,
+ % the `mc' script will pass the
+ % default grade determined
% at configuration time
gcc_non_local_gotos - bool(yes),
gcc_global_registers - bool(yes),
asm_labels - bool(yes),
gc - string("conservative"),
- profiling - bool(no),
+ profiling - bool_special,
+ profile_calls - bool(no),
+ profile_time - bool(no),
use_trail - bool(no),
+ pic_reg - bool(no),
debug - bool(no),
tags - string("low"),
num_tag_bits - int(-1),
@@ -594,6 +601,10 @@
long_option("gc", gc).
long_option("garbage-collection", gc).
long_option("profiling", profiling).
+long_option("profile-calls", profile_calls).
+long_option("profile-time", profile_time).
+long_option("use-trail", use_trail).
+long_option("pic-reg", pic_reg).
long_option("debug", debug).
long_option("tags", tags).
long_option("num-tag-bits", num_tag_bits).
@@ -750,6 +761,16 @@
%-----------------------------------------------------------------------------%
+special_handler(grade, string(Grade), OptionTable0, Result) :-
+ ( convert_grade_option(Grade, OptionTable0, OptionTable) ->
+ Result = ok(OptionTable)
+ ;
+ string__append_list(["invalid Grade `", Grade, "'"], Msg),
+ Result = error(Msg)
+ ).
+special_handler(profiling, bool(Value), OptionTable0, ok(OptionTable)) :-
+ map__set(OptionTable0, profile_time, bool(Value), OptionTable1),
+ map__set(OptionTable1, profile_calls, bool(Value), OptionTable).
special_handler(inlining, bool(Value), OptionTable0, ok(OptionTable)) :-
map__set(OptionTable0, inline_simple, bool(Value), OptionTable1),
map__set(OptionTable1, inline_single_use, bool(Value), OptionTable2),
@@ -1168,13 +1189,11 @@
io__write_string("\tcompiled with the same setting of these options,\n"),
io__write_string("\tand it must be linked to a version of the Mercury\n"),
io__write_string("\tlibrary which has been compiled with the same setting.\n"),
- io__write_string("\tRather than setting them individually, you must\n"),
- io__write_string("\tspecify them all at once by selecting a particular\n"),
- io__write_string("\tcompilation model (""grade"").\n\n"),
io__write_string("\t-s <grade>, --grade <grade>\n"),
io__write_string("\t\tSelect the compilation model. The <grade> should be one of\n"),
- io__write_string("\t\t`debug', `none', `reg', `jump', `asm_jump', `fast', `asm_fast',\n"),
- io__write_string("\t\tor one of those with `.gc', `.prof' or `.gc.prof' appended.\n"),
+ io__write_string("\t\t`none', `reg', `jump', `asm_jump', `fast', `asm_fast',\n"),
+ io__write_string("\t\tor one of those with `.gc', `.prof', `.tr',\n"),
+ io__write_string("\t\t`.sa', `.debug', and/or `.pic_reg' appended.\n"),
io__write_string("\t\tDepending on your particular installation, only a subset\n"),
io__write_string("\t\tof these possible grades will have been installed.\n"),
io__write_string("\t\tAttempting to use a grade which has not been installed\n"),
@@ -1182,19 +1201,19 @@
io__write_string("\t--gcc-global-registers\t"),
io__write_string("\t(grades: reg, fast, asm_fast)\n"),
io__write_string("\t--no-gcc-global-registers"),
- io__write_string("\t(grades: debug, none, jump, asm_jump)\n"),
+ io__write_string("\t(grades: none, jump, asm_jump)\n"),
io__write_string("\t\tSpecify whether or not to use GNU C's\n"),
io__write_string("\t\tglobal register variables extension.\n"),
io__write_string("\t--gcc-non-local-gotos\t"),
io__write_string("\t(grades: jump, fast, asm_jump, asm_fast)\n"),
io__write_string("\t--no-gcc-non-local-gotos"),
- io__write_string("\t(grades: debug, none, reg)\n"),
+ io__write_string("\t(grades: none, reg)\n"),
io__write_string("\t\tSpecify whether or not to use GNU C's\n"),
io__write_string("\t\t""labels as values"" extension.\n"),
io__write_string("\t--asm-labels\t\t"),
io__write_string("\t(grades: asm_jump, asm_fast)\n"),
io__write_string("\t--no-asm-labels\t\t"),
- io__write_string("\t(grades: debug, none, reg, jump, fast)\n"),
+ io__write_string("\t(grades: none, reg, jump, fast)\n"),
io__write_string("\t\tSpecify whether or not to use GNU C's\n"),
io__write_string("\t\tasm extensions for inline assembler labels.\n"),
io__write_string("\t--gc {none, conservative, accurate}\n"),
@@ -1204,22 +1223,39 @@
io__write_string("\t\tSpecify which method of garbage collection to use\n"),
io__write_string("\t\t(default: conservative). `accurate' GC is not yet implemented.\n"),
io__write_string("\t--use-trail\n"),
- io__write_string("\t(grades: any grade ending in `.tr')\n"),
+ io__write_string("\t(grades: any grade containing `.tr')\n"),
io__write_string("\t\tEnable use of a trail.\n"),
io__write_string("\t\tThis is necessary for interfacing with constraint solvers,\n"),
io__write_string("\t\tor for backtrackable destructive update.\n"),
io__write_string("\t--profiling\t\t"),
- io__write_string("\t(grades: any grade ending in `.prof')\n"),
+ io__write_string("\t(grades: any grade containing `.prof')\n"),
io__write_string("\t\tEnable profiling. Insert profiling hooks in the\n"),
io__write_string("\t\tgenerated code, and also output some profiling\n"),
io__write_string("\t\tinformation (the static call graph) to the file\n"),
io__write_string("\t\t`<module>.prof'.\n"),
+ io__write_string("\t--profile-calls\t\t"),
+ io__write_string("\t(grades: any grade containing `.profcalls')\n"),
+ io__write_string("\t\tSimilar to --profiling, except that only gathers\n"),
+ io__write_string("\t\tcall counts, not timing information.\n"),
+ io__write_string("\t\tUseful on systems where time profiling is not supported\n"),
+ io__write_string("\t\t(e.g. MS Windows).\n"),
+ io__write_string("\t--profile-time\t\t"),
+ io__write_string("\t(grades: any grade containing `.profcalls')\n"),
+ io__write_string("\t\tSimilar to --profiling, except that only gathers\n"),
+ io__write_string("\t\ttiming information, not call counts.\n"),
io__write_string("\t--debug\t\t\t"),
- io__write_string("\t(grades: debug)\n"),
+ io__write_string("\t(grades: any grade containing `.debug')\n"),
io__write_string("\t\tEnable debugging.\n"),
io__write_string("\t\tDebugging support is currently extremely primitive.\n"),
io__write_string("\t\tWe recommend that you use instead use `mnp' or `msp'.\n"),
io__write_string("\t\tSee the Mercury User's Guide for details.\n"),
+ io__write_string("\t--pic-reg\n"),
+ io__write_string("\t(grades: any grade containing `.pic_reg')\n"),
+ io__write_string("\t[For Unix with intel x86 architecture only]\n"),
+ io__write_string("\t\tSelect a register usage convention that is compatible,\n"),
+ io__write_string("\t\twith position-independent code (gcc's `-fpic' option).\n"),
+ io__write_string("\t\tThis is necessary when using shared libraries on Intel x86 systems\n"),
+ io__write_string("\t\trunning Unix. On other systems it has no effect.\n"),
io__write_string("\t--tags {none, low, high}"),
io__write_string("\t(This option is not for general use.)\n"),
io__write_string("\t\tSpecify whether to use the low bits or the high bits of \n"),
Index: doc/user_guide.texi
===================================================================
RCS file: /home/staff/zs/imp/mercury/doc/user_guide.texi,v
retrieving revision 1.97
diff -u -r1.97 user_guide.texi
--- user_guide.texi 1997/09/23 14:00:16 1.97
+++ user_guide.texi 1997/10/02 00:42:47
@@ -914,8 +914,7 @@
Due to a known timing-related bug in our code, you may occasionally get
segmentation violations when running your program with profiling enabled.
-If this happens, just run it again --- the problem does not occur frequently.
-This bug will hopefully be fixed soon.
+If this happens, just run it again --- the problem occurs very rarely.
@node Displaying the profile
@section Displaying the profile
@@ -1470,17 +1469,17 @@
compiled with the same setting of these options,
and it must be linked to a version of the Mercury
library which has been compiled with the same setting.
-Rather than setting them individually, you must
-specify them all at once by selecting a particular
-compilation model ("grade").
+
+The options below must be passed to @samp{mgnuc} and @samp{ml} as well
+as to @samp{mmc}. XXX
@table @asis
@item @code{-s @var{grade}}
@itemx @code{--grade @var{grade}}
Select the compilation model. The @var{grade} should be one of
- at samp{debug}, @samp{none}, @samp{reg}, @samp{jump}, @samp{asm_jump},
+ at samp{none}, @samp{reg}, @samp{jump}, @samp{asm_jump},
@samp{fast}, @samp{asm_fast},
-or one of those with @samp{.gc}, @samp{.prof} or @samp{.gc.prof} appended.
+or one of those with @samp{.gc}, @samp{.prof}, and/or @samp{.tr} appended.
The default grade is system-dependent; it is chosen at installation time
by @samp{configure}, the auto-configuration script, but can be overridden
with the @samp{MERCURY_DEFAULT_GRADE} environment variable if desired.
@@ -1496,9 +1495,6 @@
@item @var{Grade}
@var{Options implied}.
- at item @samp{debug}
- at code{--debug --no-c-optimize}.
-
@item @samp{none}
None.
@@ -1523,26 +1519,27 @@
@item Any of the above followed by @samp{.prof}
As above, plus @code{--profiling}.
- at end table
+ at item Any of the above followed by @samp{.tr}
+As above, plus @code{--use-trail}.
- at sp 1
-Reminder: the following optimizations should not be set individually.
-Instead, you should use the @samp{--grade} option to change the setting of
-these options.
+ at item Any of the above followed by @samp{.debug}
+As above, plus @code{--debug}.
+
+ at end table
@sp 1
@item @code{--gcc-global-registers} (grades: reg, fast, asm_fast)
- at itemx @code{--no-gcc-global-registers} (grades: debug, none, jump, asm_jump)
+ at itemx @code{--no-gcc-global-registers} (grades: none, jump, asm_jump)
Specify whether or not to use GNU C's global register variables extension.
@sp 1
@item @code{--gcc-non-local-gotos} (grades: jump, fast, asm_jump, asm_fast)
- at item @code{--no-gcc-non-local-gotos} (grades: debug, none, reg)
+ at item @code{--no-gcc-non-local-gotos} (grades: none, reg)
Specify whether or not to use GNU C's ``labels as values'' extension.
@sp 1
@item @code{--asm-labels} (grades: asm_jump, asm_fast)
- at itemx @code{--no-asm-labels} (grades: debug, none, reg, jump, fast)
+ at itemx @code{--no-asm-labels} (grades: none, reg, jump, fast)
Specify whether or not to use GNU C's asm extensions
for inline assembler labels.
@@ -1569,39 +1566,29 @@
is determined by the auto-configuration script.
@sp 1
- at item @code{--have-delay-slot}
-(This option is not intended for general use.)
-Assume that branch instructions have a delay slot.
-
- at sp 1
- at item @code{--num-real-r-regs @var{n}}
-(This option is not intended for general use.)
-Assume r1 up to r at var{n} are real general purpose registers.
-
- at sp 1
- at item @code{--num-real-f-regs @var{n}}
-(This option is not intended for general use.)
-Assume f1 up to f at var{n} are real floating point registers.
-
- at sp 1
- at item @code{--num-real-r-temps @var{n}}
-(This option is not intended for general use.)
-Assume that @var{n} non-float temporaries will fit into real machine registers.
-
- at sp 1
- at item @code{--num-real-f-temps @var{n}}
-(This option is not intended for general use.)
-Assume that @var{n} float temporaries will fit into real machine registers.
-
- at sp 1
- at item @code{--profiling} (grades: any grade ending in @samp{.prof})
+ at item @code{--profiling} (grades: any grade containing @samp{.prof})
Enable profiling. Insert profiling hooks in the
generated code, and also output some profiling
information (the static call graph) to the file
@samp{@var{module}.prof}. @xref{Profiling}.
@sp 1
- at item @code{--debug} (grades: debug)
+ at item @code{--profile-calls} (grades: any grade containing @samp{.profcalls})
+Similar to @samp{--profiling}, except that this option only gathers
+call counts, not timing information. Useful on systems where time
+profiling is not supported (e.g. MS Windows).
+
+ at sp 1
+ at item @code{--profile-time} (grades: any grade containing @samp{.proftime})
+Similar to @samp{--profiling}, except that this option only gathers
+timing information, not call counts. For the results to be useful,
+call counts for an identical run of your program need to be gathered
+using @samp{--profiling} or @samp{--profile-calls}.
+The only advantage of using @code{--profile-time} is that it can give
+slightly more accurate timing results than @code{--profiling}.
+
+ at sp 1
+ at item @code{--debug} (grades: any grade containing @samp{.debug})
Enable debugging.
Pass the @samp{-g} flag to the C compiler, instead of @samp{-DSPEED},
to enable debugging of the generated C code.
@@ -1635,6 +1622,14 @@
runtime. The C code also needs to be compiled with
@samp{-DNO_TYPE_LAYOUT}.
+ at sp 1
+ at item @code{--pic-reg} (grades: any grade containing `.pic_reg')
+[For Unix with intel x86 architecture only.]
+Select a register usage convention that is compatible
+with position-independent code (gcc's `-fpic' option).
+This is necessary when using shared libraries on Intel x86 systems
+running Unix. On other systems it has no effect.
+
@end table
@node Code generation options
@@ -1689,6 +1684,31 @@
default: 90). A lower value means that the compiler will use
larger tables, but there will generally be less hash collisions,
so it may result in faster lookups.
+
+ at sp 1
+ at item @code{--have-delay-slot}
+(This option is not intended for general use.)
+Assume that branch instructions have a delay slot.
+
+ at sp 1
+ at item @code{--num-real-r-regs @var{n}}
+(This option is not intended for general use.)
+Assume r1 up to r at var{n} are real general purpose registers.
+
+ at sp 1
+ at item @code{--num-real-f-regs @var{n}}
+(This option is not intended for general use.)
+Assume f1 up to f at var{n} are real floating point registers.
+
+ at sp 1
+ at item @code{--num-real-r-temps @var{n}}
+(This option is not intended for general use.)
+Assume that @var{n} non-float temporaries will fit into real machine registers.
+
+ at sp 1
+ at item @code{--num-real-f-temps @var{n}}
+(This option is not intended for general use.)
+Assume that @var{n} float temporaries will fit into real machine registers.
@end table
Index: scripts/mgnuc.in
===================================================================
RCS file: /home/staff/zs/imp/mercury/scripts/mgnuc.in,v
retrieving revision 1.43
diff -u -r1.43 mgnuc.in
--- mgnuc.in 1997/08/28 16:04:10 1.43
+++ mgnuc.in 1997/10/02 00:16:44
@@ -13,16 +13,28 @@
Name: mgnuc - Mercury front-end to GNU C
Usage: mgnuc [<options>] [-- <gcc options>] files...
Options:
- -s <grade>, --grade <grade>
- Select optimization/debug/gc options according to <grade>,
- which must be one of debug, none, jump, asm_jump, reg, fast,
- or asm_fast, or one of those with .gc and/or .prof appended.
-v, --verbose
Echo gcc command before executing it.
--no-ansi
Don't pass \`-ansi' to gcc.
--no-check
Don't enable any of gcc's warnings.
+ -s <grade>, --grade <grade>
+ --asm-labels
+ --gcc-non-local-gotos
+ --gcc-global-registers
+ -p, --profiling
+ --profile-calls
+ --profile-time
+ --debug
+ --use-trail
+ --args {simple, compact}
+ --pic-reg
+ --inline-alloc
+ --split-c-files
+ See the documentation in the "Invocation" section
+ of the Mercury User's Guide.
+
Description:
This runs gcc with the appropriate options for compiling Mercury
programs in the specified grade.
@@ -85,7 +97,8 @@
;;
esac
-DEBUG_OPTS="-g"
+BASE_DEBUG_OPTS="-g"
+DEBUG_OPTS="$OPT_OPTS"
AS_OPTS=""
SPLIT_OPTS=""
@@ -101,127 +114,259 @@
;;
--assemble)
assemble=true
- shift
;;
--no-ansi)
ANSI_OPTS=
- shift
;;
--no-check)
CHECK_OPTS=
- shift
;;
+
--split-c-files)
SPLIT_OPTS=-DSPLIT_C_FILES
- shift
;;
--no-split-c-files)
SPLIT_OPTS=
- shift
;;
+
-v|--verbose)
verbose=true
- shift
;;
- -s|--grade)
- shift
- grade="$1";
- shift
+ -v-|--no-verbose)
+ verbose=false
;;
- -s*)
- grade="` expr $1 : '-s\(.*\)' `"
- shift
+
+ --inline-alloc)
+ INLINE_ALLOC_OPTS="-DINLINE_ALLOC -DSILENT"
;;
- --)
- shift
- break
+ --no-inline-alloc)
+ INLINE_ALLOC_OPTS=""
;;
- *)
- break
+
+ --asm-labels)
+ ASM_OPTS="-DUSE_ASM_LABELS"
+ ;;
+ --no-asm-labels)
+ ASM_OPTS=""
;;
- esac
-done
-case "$grade" in
- *.tr) TRAIL_OPTS="-DMR_USE_TRAIL"
- grade="` expr $grade : '\(.*\).tr' `"
+ --gcc-non-local-gotos)
+ GOTO_OPTS="-DUSE_GCC_NONLOCAL_GOTOS"
;;
- *)
- TRAIL_OPTS=""
+ --no-gcc-non-local-gotos)
+ GOTO_OPTS=""
;;
-esac
-case "$grade" in
- *.prof) PROF_OPTS="-DPROFILE_TIME -DPROFILE_CALLS"
- grade="` expr $grade : '\(.*\).prof' `"
+ --gcc-global-registers)
+ REG_OPTS="-DUSE_GCC_GLOBAL_REGISTERS"
;;
- *)
- PROF_OPTS="-DNO_SIGNALS"
+ --no-gcc-global-registers)
+ REG_OPTS=""
;;
-esac
-case "$grade" in
- *.agc) GC_OPTS="-DNATIVE_GC"
- grade="` expr $grade : '\(.*\).agc' `"
+ --debug)
+ DEBUG_OPTS="-g"
;;
- *.gc) GC_OPTS="-DCONSERVATIVE_GC"
- grade="` expr $grade : '\(.*\).gc' `"
+ --no-debug)
+ DEBUG_OPTS="$OPT_OPTS"
;;
- *)
- GC_OPTS=""
+
+ --gc)
+ shift
+ case "$1" in
+ accurate)
+ GC_OPTS="-DNATIVE_GC"
+ ;;
+ conservative)
+ GC_OPTS="-DCONSERVATIVE_GC"
+ ;;
+ none)
+ GC_OPTS=""
+ ;;
+ *)
+ echo "$0: invalid gc method \`$1'" 1>&2;
+ ;;
+ esac
+ ;;
+
+ -p|--profiling)
+ PROF_TIME_OPTS="-DPROFILE_TIME"
+ PROF_CALLS_OPTS="-DCALLS"
+ ;;
+ -p-|--no-profiling)
+ PROF_TIME_OPTS="-DNO_SIGNALS"
+ PROF_CALLS_OPTS=""
+ ;;
+ --profile-time)
+ PROF_TIME_OPTS="-DPROFILE_TIME"
+ ;;
+ --no-profile-time)
+ PROF_TIME_OPTS="-DNO_SIGNALS"
+ ;;
+ --profile-calls)
+ PROF_CALLS_OPTS="-DPROFILE_CALLS"
+ ;;
+ --no-profile-calls)
+ PROF_CALLS_OPTS=""
+ ;;
+
+ --use-trail)
+ TRAIL_OPTS="-DMR_USE_TRAIL"
+ ;;
+ --no-use-trail)
+ TRAIL_OPTS=""
+ ;;
+
+ --args)
+ shift
+ case "$1" in
+ simple)
+ ARG_OPTS=""
+ ;;
+ compact)
+ ARG_OPTS="-DCOMPACT_ARGS"
+ ;;
+ *)
+ echo "$0: invalid arg method \`$1'" 1>&2;
+ ;;
+ esac
;;
-esac
-case "$grade" in
- asm_fast)
- GRADE_OPTS="$OPT_OPTS -DUSE_GCC_GLOBAL_REGISTERS
- -DUSE_ASM_LABELS -DUSE_GCC_NONLOCAL_GOTOS"
- ;;
- fast)
- GRADE_OPTS="$OPT_OPTS
- -DUSE_GCC_GLOBAL_REGISTERS -DUSE_GCC_NONLOCAL_GOTOS"
- ;;
- reg)
- GRADE_OPTS="$OPT_OPTS
- -DUSE_GCC_GLOBAL_REGISTERS"
- ;;
- asm_jump)
- GRADE_OPTS="$OPT_OPTS
- -DUSE_ASM_LABELS -DUSE_GCC_NONLOCAL_GOTOS"
- ;;
- jump)
- GRADE_OPTS="$OPT_OPTS
- -DUSE_GCC_NONLOCAL_GOTOS"
- ;;
- none)
- GRADE_OPTS="$OPT_OPTS"
- ;;
- init)
- echo "$0: the \`-s init' option is no longer supported" 1>&2
- exit 1
+ --pic-reg)
+ PICREG_OPTS="-DPIC_REG"
;;
- debug)
- GRADE_OPTS="$DEBUG_OPTS"
+ --no-pic-reg)
+ PICREG_OPTS=""
+ ;;
+
+ -s|--grade)
+ shift
+ grade="$1";
+ case "$grade" in
+ *.tr) TRAIL_OPTS="-DMR_USE_TRAIL"
+ grade="` expr $grade : '\(.*\).tr' `"
+ ;;
+ *)
+ TRAIL_OPTS=""
+ ;;
+ esac
+
+ case "$grade" in
+ *.prof)
+ PROF_TIME_OPTS="-DPROFILE_TIME"
+ PROF_CALLS_OPTS="-DPROFILE_CALLS"
+ grade="` expr $grade : '\(.*\).prof' `"
+ ;;
+ *.proftime)
+ PROF_TIME_OPTS="-DPROFILE_TIME"
+ PROF_CALLS_OPTS=""
+ grade="` expr $grade : '\(.*\).proftime' `"
+ ;;
+ *.profcalls)
+ PROF_TIME_OPTS="-DNO_SIGNALS"
+ PROF_CALLS_OPTS="-DPROFILE_CALLS"
+ grade="` expr $grade : '\(.*\).profcalls' `"
+ ;;
+ *)
+ PROF_TIME_OPTS="-DNO_SIGNALS"
+ PROF_CALLS_OPTS=""
+ ;;
+ esac
+
+ case "$grade" in
+ *.agc) GC_OPTS="-DNATIVE_GC"
+ grade="` expr $grade : '\(.*\).agc' `"
+ ;;
+ *.gc) GC_OPTS="-DCONSERVATIVE_GC"
+ grade="` expr $grade : '\(.*\).gc' `"
+ ;;
+ *)
+ GC_OPTS=""
+ ;;
+ esac
+
+ case "$grade" in
+ asm_fast)
+ DEBUG_OPTS="$OPT_OPTS"
+ REG_OPTS="-DUSE_GCC_GLOBAL_REGISTERS"
+ ASM_OPTS="-DUSE_ASM_LABELS"
+ GOTO_OPTS="-DUSE_GCC_NONLOCAL_GOTOS"
+ ;;
+ fast)
+ DEBUG_OPTS="$OPT_OPTS"
+ REG_OPTS="-DUSE_GCC_GLOBAL_REGISTERS"
+ ASM_OPTS=""
+ GOTO_OPTS="-DUSE_GCC_NONLOCAL_GOTOS"
+ ;;
+ reg)
+ DEBUG_OPTS="$OPT_OPTS"
+ REG_OPTS="-DUSE_GCC_GLOBAL_REGISTERS"
+ ASM_OPTS=""
+ GOTO_OPTS=""
+ ;;
+ asm_jump)
+ DEBUG_OPTS="$OPT_OPTS"
+ REG_OPTS=""
+ ASM_OPTS="-DUSE_ASM_LABELS"
+ GOTO_OPTS="-DUSE_GCC_NONLOCAL_GOTOS"
+ ;;
+ jump)
+ DEBUG_OPTS="$OPT_OPTS"
+ REG_OPTS=""
+ ASM_OPTS=""
+ GOTO_OPTS="-DUSE_GCC_NONLOCAL_GOTOS"
+ ;;
+ none)
+ DEBUG_OPTS="$OPT_OPTS"
+ REG_OPTS=""
+ ASM_OPTS=""
+ GOTO_OPTS=""
+ ;;
+ debug)
+ DEBUG_OPTS="-g"
+ REG_OPTS=""
+ ASM_OPTS=""
+ GOTO_OPTS=""
+ ;;
+ *)
+ echo "$0: invalid grade \`$grade'" 1>&2;
+ exit 1
+ esac
+ ;;
+ -s*)
+ grade="` expr $1 : '-s\(.*\)' `"
+ # just insert it as `--grade $grade' and then reparse it
+ case $# in
+ 0) set - "x --grade $grade" ;;
+ 0) set - "x --grade $grade" "$@" ;;
+ esac
+ ;;
+ --)
+ shift
+ break
;;
*)
- echo "$0: invalid grade \`$grade'" 1>&2;
- exit 1
-esac
+ break
+ ;;
+ esac
+ shift
+done
# check that special grades are only used with gcc
case $COMPILER in
gcc) ;;
- *) case $grade in
- debug|none) ;;
- *)
+ *) case "$GRADE_OPTS" in
+ *USE_GCC*)
echo "$0: For compilers other than GNU C, the only" 1>&2
echo "$0: grades allowed are \`debug' and \`none'" 1>&2
;;
esac
esac
+GRADE_OPTS="$DEBUG_OPTS $ASM_OPTS $GOTO_OPTS $REG_OPTS"
+
# if we're using global registers, add CFLAGS_FOR_REGS
-case "$GRADE_OPTS" in
+case "$GOTO_OPTS" in
*-DUSE_GCC_GLOBAL_REGISTERS*)
GRADE_OPTS="$GRADE_OPTS $CFLAGS_FOR_REGS"
;;
@@ -325,14 +470,17 @@
case $verbose in true)
echo $CC -I$C_INCL_DIR $ANSI_OPTS $CHECK_OPTS \
- $GRADE_OPTS $GC_OPTS $PROF_OPTS $TRAIL_OPTS $SPLIT_OPTS \
- $ARCH_OPTS $ARG_OPTS "$@" $OVERRIDE_OPTS ;;
+ $GRADE_OPTS $GC_OPTS $PROF_TIME_OPTS $PROF_CALLS_OPTS \
+ $INLINE_ALLOC_OPTS $TRAIL_OPTS $SPLIT_OPTS \
+ $PICREG_OPTS $ARCH_OPTS $ARG_OPTS "$@" $OVERRIDE_OPTS ;;
esac
case $# in
0) exec $CC -I$C_INCL_DIR $ANSI_OPTS $CHECK_OPTS \
- $GRADE_OPTS $GC_OPTS $PROF_OPTS $TRAIL_OPTS $SPLIT_OPTS \
- $ARCH_OPTS $OVERRIDE_OPTS ;;
+ $GRADE_OPTS $GC_OPTS $PROF_TIME_OPTS $PROF_CALLS_OPTS \
+ $INLINE_ALLOC_OPTS $TRAIL_OPTS $SPLIT_OPTS \
+ $PICREG_OPTS $ARCH_OPTS $OVERRIDE_OPTS ;;
*) exec $CC -I$C_INCL_DIR $ANSI_OPTS $CHECK_OPTS \
- $GRADE_OPTS $GC_OPTS $PROF_OPTS $TRAIL_OPTS $SPLIT_OPTS \
- $ARCH_OPTS $ARG_OPTS "$@" $OVERRIDE_OPTS ;;
+ $GRADE_OPTS $GC_OPTS $PROF_TIME_OPTS $PROF_CALLS_OPTS \
+ $INLINE_ALLOC_OPTS $TRAIL_OPTS $SPLIT_OPTS \
+ $PICREG_OPTS $ARCH_OPTS $ARG_OPTS "$@" $OVERRIDE_OPTS ;;
esac
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh> | of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3 | -- the last words of T. S. Garp.
More information about the developers
mailing list