diff: handling of --grade options
Fergus Henderson
fjh at mundook.cs.mu.OZ.AU
Wed Oct 8 05:58:20 AEST 1997
Hi,
Anyone want to review this change?
compiler/options.m:
compiler/handle_options.m:
compiler/mercury_compile.m:
scripts/mgnuc.in:
scripts/ml.in:
Change mgnuc and ml to support the same
compilation model options as mmc.
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'.
doc/user_guide.texi:
README.Linux:
Document the above changes.
cvs diff README.Linux compiler/handle_options.m compiler/mercury_compile.m compiler/options.m doc/user_guide.texi scripts/mgnuc.in scripts/ml.in
Index: README.Linux
===================================================================
RCS file: /home/staff/zs/imp/mercury/README.Linux,v
retrieving revision 1.4
diff -u -r1.4 README.Linux
--- README.Linux 1997/08/08 20:14:16 1.4
+++ README.Linux 1997/10/07 16:22:22
@@ -26,17 +26,18 @@
a future release.)
To use the shared libraries, you must compile your program with
-`mmc --cflags -DPIC_REG' and link with `ml --mercury-libs shared'
-or add `MGNUCFLAGS=-DPIC_REG' and `MLFLAGS=--mercury-libs shared'
+`mmc --pic-reg' and link with `ml --mercury-libs shared'
+or add `MGNUCFLAGS=--pic-reg' and `MLFLAGS=--mercury-libs shared'
to your Mmake file.
-Mercury code compiled with `-DPIC_REG' or `-fpic' has what we shall call
-"PIC linkage", whereas Mercury code compiled without these options has
-"non-PIC linkage". The static version of the Mercury libraries has
-non-PIC linkage, while the shared version has PIC linkage.
-Be very careful that you do not try to link Mercury code
-with PIC linkage and Mercury code with non-PIC linkage into the same
-executable, otherwise your code will *almost certainly crash*.
+Mercury code compiled with `--pic-reg' or with gcc's `-fpic' option has
+what we shall call "PIC linkage", whereas Mercury code compiled without
+these options has "non-PIC linkage". The static version of the Mercury
+libraries has non-PIC linkage, while the shared version has PIC linkage.
+Be careful that you do not try to link Mercury code with PIC linkage and
+Mercury code with non-PIC linkage into the same executable, otherwise you
+will probably get an obscure link error about `MR_grade_...' undefined
+or `MR_runtime_grade' multiply defined.
(The reason for this is that standard non-PIC Mercury code uses the
`ebx' register in ways that are incompatible with its uses as the global
offset table pointer register in PIC code. If only the Intel
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/07 19:56:12
@@ -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,176 @@
[]
).
-:- pred convert_grade_option(string::in, option_table::in, option_table::out)
- is semidet.
+ % IMPORTANT: any changes here may require similar changes to
+ % runtime/mercury_grade.h
+ % scripts/mgnuc.in
+ % scripts/ml.in
+
+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, profile_time, ProfileTime),
+ globals__lookup_bool_option(Globals, profile_calls, ProfileCalls),
+ 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 = ""
+ ),
+
+/*******
+ % This can't be part of the grade, due to the way
+ % we handle things on Linux. See README.Linux.
+ ( PIC_Reg = yes ->
+ Part10 = ".picreg"
+ ;
+ Part10 = ""
+ ),
+*******/
+ Part10 = "",
+
+ string__append_list( [Part1, Part2, Part3, Part4, Part5,
+ Part6, Part7, Part8, Part9, Part10], Grade).
+
+ % IMPORTANT: any changes here may require similar changes to
+ % runtime/mercury_grade.h
+ % scripts/mgnuc.in
+ % scripts/ml.in
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(profiling, no)
+ 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)
),
- ( { string__remove_suffix(Grade4, ".gc", Grade5) } ->
- { Grade = Grade5 },
+ % part 4
+ ( { string__remove_suffix(Grade12, ".prof", Grade13) } ->
+ { Grade14 = Grade13 },
+ set_bool_opt(profile_time, yes),
+ set_bool_opt(profile_calls, yes)
+ ; { string__remove_suffix(Grade12, ".proftime", Grade13) } ->
+ { Grade14 = Grade13 },
+ set_bool_opt(profile_time, yes),
+ set_bool_opt(profile_calls, no)
+ ; { string__remove_suffix(Grade12, ".profcalls", Grade13) } ->
+ { Grade14 = Grade13 },
+ set_bool_opt(profile_time, no),
+ set_bool_opt(profile_calls, yes)
+ ;
+ { Grade14 = Grade12 },
+ set_bool_opt(profile_time, no),
+ set_bool_opt(profile_calls, no)
+ ),
+ % 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 +495,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.98
diff -u -r1.98 user_guide.texi
--- user_guide.texi 1997/10/03 04:56:13 1.98
+++ user_guide.texi 1997/10/07 19:51:54
@@ -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
@@ -1474,17 +1473,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}.
@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.
@@ -1500,9 +1499,6 @@
@item @var{Grade}
@var{Options implied}.
- at item @samp{debug}
- at code{--debug --no-c-optimize}.
-
@item @samp{none}
None.
@@ -1527,26 +1523,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.
@@ -1573,39 +1570,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.
@@ -1639,6 +1626,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
@@ -1693,6 +1688,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/07 19:42:39
@@ -13,19 +13,31 @@
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.
+ programs.
Normally it invokes gcc in ANSI mode with almost all warnings enabled,
but this can be changed using the \`--no-ansi' or \`--no-check'
options.
@@ -35,7 +47,7 @@
# *************************************************************************
# *** IMPORTANT NOTE: any changes to this file may also require similar ***
-# *** changes to compiler/mercury_compile.pp ***
+# *** changes to compiler/mercury_compile.m ***
# *************************************************************************
FULLARCH=@FULLARCH@
@@ -85,14 +97,29 @@
;;
esac
-DEBUG_OPTS="-g"
+BASE_DEBUG_OPTS="-g"
+DEBUG_OPTS="$OPT_OPTS"
AS_OPTS=""
SPLIT_OPTS=""
-grade=$DEFAULT_GRADE
verbose=false
assemble=false
+asm_labels=true
+non_local_gotos=true
+global_regs=true
+gc_method=conservative
+profile_time=false
+profile_calls=false
+use_trail=false
+args_method=compact
+debug=false
+
+case $# in
+ 0) set - "--grade $DEFAULT_GRADE" ;;
+ 0) set - "--grade $DEFAULT_GRADE" "$@" ;;
+esac
+
while : ; do
case "$1" in
-h|--help|"-?")
@@ -101,36 +128,226 @@
;;
--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
+ ;;
+ -v-|--no-verbose)
+ verbose=false
+ ;;
+
+ --inline-alloc)
+ INLINE_ALLOC_OPTS="-DINLINE_ALLOC -DSILENT"
+ ;;
+ --no-inline-alloc)
+ INLINE_ALLOC_OPTS=""
+ ;;
+
+ --asm-labels)
+ asm_labels=true ;;
+ --no-asm-labels)
+ asm_labels=false ;;
+
+ --gcc-non-local-gotos)
+ non_local_gotos=true ;;
+ --no-gcc-non-local-gotos)
+ non_local_gotos=false ;;
+
+ --gcc-global-registers)
+ global_regs=true ;;
+ --no-gcc-global-registers)
+ global_regs=false ;;
+
+ --debug)
+ debug=true ;;
+ --no-debug)
+ debug=false ;;
+
+ --gc)
shift
+ case "$1" in
+ accurate|conservative|none)
+ gc_method=$1 ;;
+ *)
+ echo "$0: invalid gc method \`$1'" 1>&2
+ exit 1
+ ;;
+ esac
;;
+
+ -p|--profiling)
+ profile_time=true
+ profile_calls=true
+ ;;
+ -p-|--no-profiling)
+ profile_time=false
+ profile_calls=false
+ ;;
+ --profile-time)
+ profile_time=true ;;
+ --no-profile-time)
+ profile_time=false ;;
+ --profile-calls)
+ profile_calls=true ;;
+ --no-profile-calls)
+ profile_calls=false ;;
+
+ --use-trail)
+ use_trail=true ;;
+ --no-use-trail)
+ use_trail=false ;;
+
+ --args)
+ shift
+ case "$1" in
+ simple|compact)
+ args_method=$1;;
+ *)
+ echo "$0: invalid arg method \`$1'" 1>&2
+ exit 1
+ ;;
+ esac
+ ;;
+
+ --pic-reg)
+ pic_reg=true ;;
+ --no-pic-reg)
+ pic_reg=false ;;
+
-s|--grade)
shift
grade="$1";
- shift
+
+ # Convert a grade to a set of options.
+ #
+ # IMPORTANT: any changes to the handling of grades here
+ # may also require changes to
+ # runtime/mercury_grade.h
+ # compiler/handle_options.m
+ # scripts/ml.in
+
+ case "$grade" in
+ *.debug)
+ debug=true
+ grade="` expr $grade : '\(.*\).debug' `"
+ ;;
+ *) debug=false
+ ;;
+ esac
+
+ case "$grade" in
+ *.sa)
+ args_method=simple
+ grade="` expr $grade : '\(.*\).sa' `"
+ ;;
+ *) args_method=compact
+ ;;
+ esac
+
+ case "$grade" in
+ *.tr) use_trail=true
+ grade="` expr $grade : '\(.*\).tr' `"
+ ;;
+ *) use_trail=false
+ ;;
+ esac
+
+ case "$grade" in
+ *.prof)
+ profile_time=true
+ profile_calls=true
+ grade="` expr $grade : '\(.*\).prof' `"
+ ;;
+ *.proftime)
+ profile_time=true
+ profile_calls=false
+ grade="` expr $grade : '\(.*\).proftime' `"
+ ;;
+ *.profcalls)
+ profile_time=false
+ profile_calls=true
+ grade="` expr $grade : '\(.*\).profcalls' `"
+ ;;
+ *)
+ profile_time=false
+ profile_calls=false
+ ;;
+ esac
+
+ case "$grade" in
+ *.agc) gc_method=accurate
+ grade="` expr $grade : '\(.*\).agc' `"
+ ;;
+ *.gc) gc_method=conservative
+ grade="` expr $grade : '\(.*\).gc' `"
+ ;;
+ *) gc_method=none
+ ;;
+ esac
+
+ case "$grade" in
+ asm_fast)
+ global_regs=true
+ non_local_gotos=true
+ asm_labels=true
+ ;;
+ fast)
+ global_regs=true
+ non_local_gotos=true
+ asm_labels=false
+ ;;
+ reg)
+ global_regs=true
+ non_local_gotos=false
+ asm_labels=false
+ ;;
+ asm_jump)
+ global_regs=false
+ non_local_gotos=true
+ asm_labels=true
+ ;;
+ jump)
+ global_regs=false
+ asm_labels=false
+ non_local_gotos=true
+ ;;
+ none)
+ global_regs=false
+ asm_labels=false
+ non_local_gotos=false
+ ;;
+ debug)
+ debug=true
+ global_regs=false
+ asm_labels=false
+ non_local_gotos=false
+ ;;
+ *)
+ echo "$0: invalid grade \`$grade'" 1>&2;
+ exit 1
+ esac
;;
-s*)
grade="` expr $1 : '-s\(.*\)' `"
- shift
+ # just insert it as `--grade $grade' and then reparse it
+ case $# in
+ 0) set - "x --grade $grade" ;;
+ 0) set - "x --grade $grade" "$@" ;;
+ esac
;;
--)
shift
@@ -140,98 +357,91 @@
break
;;
esac
+ shift
done
-case "$grade" in
- *.tr) TRAIL_OPTS="-DMR_USE_TRAIL"
- grade="` expr $grade : '\(.*\).tr' `"
- ;;
- *)
- TRAIL_OPTS=""
- ;;
+#
+# convert mgnuc options into gcc options
+#
+# IMPORTANT: any changes here will require similar changes to
+# compiler/mercury_compile.m.
+#
+
+case $asm_labels in
+ true) ASM_OPTS="-DUSE_ASM_LABELS" ;;
+ false) ASM_OPTS="" ;;
esac
-case "$grade" in
- *.prof) PROF_OPTS="-DPROFILE_TIME -DPROFILE_CALLS"
- grade="` expr $grade : '\(.*\).prof' `"
- ;;
- *)
- PROF_OPTS="-DNO_SIGNALS"
- ;;
+case $non_local_gotos in
+ true) GOTO_OPTS="-DUSE_GCC_NONLOCAL_GOTOS" ;;
+ false) GOTO_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=""
- ;;
+case $global_regs in
+ true) REG_OPTS="-DUSE_GCC_GLOBAL_REGISTERS" ;;
+ false) REG_OPTS="" ;;
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
- ;;
- debug)
- GRADE_OPTS="$DEBUG_OPTS"
- ;;
- *)
- echo "$0: invalid grade \`$grade'" 1>&2;
- exit 1
+case $debug in
+ true) DEBUG_OPTS="-g" ;;
+ false) DEBUG_OPTS="$OPT_OPTS" ;;
+esac
+
+case $gc_method in
+ accurate) GC_OPTS="-DNATIVE_GC" ;;
+ conservative) GC_OPTS="-DCONSERVATIVE_GC" ;;
+ none) GC_OPTS="" ;;
+esac
+
+case $profile_time in
+ true) PROF_TIME_OPTS="-DPROFILE_TIME" ;;
+ false) PROF_TIME_OPTS="-DNO_SIGNALS" ;;
+esac
+
+case $profile_calls in
+ true) PROF_CALLS_OPTS="-DPROFILE_CALLS" ;;
+ false) PROF_CALLS_OPTS="" ;;
esac
+case $use_trail in
+ true) TRAIL_OPTS="-DMR_USE_TRAIL" ;;
+ false) TRAIL_OPTS="" ;;
+esac
+
+case $args_method in
+ simple) ARG_OPTS="" ;;
+ compact) ARG_OPTS="-DCOMPACT_ARGS" ;;
+esac
+
+case $pic_reg in
+ true) PICREG_OPTS="-DPIC_REG" ;;
+ false) PICREG_OPTS="" ;;
+esac
+
+
# 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
- *-DUSE_GCC_GLOBAL_REGISTERS*)
- GRADE_OPTS="$GRADE_OPTS $CFLAGS_FOR_REGS"
- ;;
+case $global_regs in
+ true) GRADE_OPTS="$GRADE_OPTS $CFLAGS_FOR_REGS" ;;
+ false) ;;
esac
# if we're using non-local gotos, add CFLAGS_FOR_GOTOS
-case "$GRADE_OPTS" in
- *-DUSE_GCC_NONLOCAL_GOTOS*)
- GRADE_OPTS="$GRADE_OPTS $CFLAGS_FOR_GOTOS"
- ;;
+case $non_local_gotos in
+ true) GRADE_OPTS="$GRADE_OPTS $CFLAGS_FOR_GOTOS" ;;
+ false) ;;
esac
#
@@ -245,8 +455,8 @@
# nonlocal gotos don't work with PIC, which is the
# default for Irix 5, so if nonlocal gotos are enabled
# we need to disable the use of shared libraries.
- case "$GRADE_OPTS" in
- *-DUSE_GCC_NONLOCAL_GOTOS*)
+ case $non_local_gotos in
+ true)
LIBRARY_PATH="$NONSHARED_LIB_DIR:/usr/lib/nonshared:$LIBRARY_PATH"
export LIBRARY_PATH
AS_OPTS="-non_shared"
@@ -325,14 +535,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
Index: scripts/ml.in
===================================================================
RCS file: /home/staff/zs/imp/mercury/scripts/ml.in,v
retrieving revision 1.33
diff -u -r1.33 ml.in
--- ml.in 1997/10/07 17:50:53 1.33
+++ ml.in 1997/10/07 19:36:32
@@ -49,8 +49,18 @@
-g, --no-strip
Do not strip debugging information.
-s <grade>, --grade <grade>
- Specify which grade of the Mercury library to link with.
- (The default grade is determined by ``configure'.)"
+ --asm-labels
+ --gcc-non-local-gotos
+ --gcc-global-registers
+ -p, --profiling
+ --profile-calls
+ --profile-time
+ --debug
+ --use-trail
+ --args {simple, compact}
+ --pic-reg
+ See the documentation in the \"Invocation\" section
+ of the Mercury User's Guide."
FULLARCH=@FULLARCH@
NONSHARED_LIB_DIR=${MERCURY_NONSHARED_LIB_DIR=@NONSHARED_LIB_DIR@}
@@ -81,12 +91,26 @@
esac
mercury_libs=default
demangle=true
-GRADE=$DEFAULT_GRADE
MAYBE_STATIC_OPT=""
make_shared_lib=false
user_shlib_dirs=""
-while true; do
+asm_labels=true
+non_local_gotos=true
+global_regs=true
+gc_method=conservative
+profile_time=false
+profile_calls=false
+use_trail=false
+args_method=compact
+debug=false
+
+case $# in
+ 0) set - "--grade $DEFAULT_GRADE" ;;
+ 0) set - "--grade $DEFAULT_GRADE" "$@" ;;
+esac
+
+while : ; do
case "$1" in
-h|--help|"-?")
echo "$Help"
@@ -94,29 +118,29 @@
;;
-v|--verbose)
verbose=true
- shift ;;
+ ;;
--demangle)
demangle=true
- shift ;;
+ ;;
--no-demangle)
demangle=false
- shift ;;
+ ;;
-s|--grade)
shift
GRADE="$1"
- shift ;;
+ ;;
--strip)
strip=true
- shift ;;
+ ;;
-g|--no-strip)
strip=false
- shift ;;
+ ;;
--make-shared-lib)
make_shared_lib=true
# on some targets, stripping shared libraries will
# make them unusable, I think, so don't strip
strip=false
- shift ;;
+ ;;
--no-libs)
progname=`basename $0`
cat 1>&2 << EOF
@@ -125,12 +149,12 @@
$progname: Support for \`--no-libs' may be removed in a future release.
EOF
mercury_libs=none
- shift ;;
+ ;;
--mercury-libs)
case "$2" in
shared|static|none|default)
mercury_libs="$2"
- shift; shift ;;
+ shift ;;
*)
progname=`basename $0`
cat 1>&2 << EOF
@@ -147,7 +171,6 @@
case $mercury_libs in static|default)
mercury_libs=shared ;;
esac
- shift
;;
-static|--static)
case $FULLARCH in
@@ -167,27 +190,209 @@
case $mercury_libs in shared|default)
mercury_libs=static ;;
esac
- shift
;;
-R|--shared-lib-dir)
dir="$2"
user_shlib_dirs="$user_shlib_dirs $dir"
- shift; shift
+ shift
;;
-R*)
dir="` expr $1 : '-R\(.*\)' `"
user_shlib_dirs="$user_shlib_dirs $dir"
+ ;;
+
+ --asm-labels)
+ asm_labels=true ;;
+ --no-asm-labels)
+ asm_labels=false ;;
+
+ --gcc-non-local-gotos)
+ non_local_gotos=true ;;
+ --no-gcc-non-local-gotos)
+ non_local_gotos=false ;;
+
+ --gcc-global-registers)
+ global_regs=true ;;
+ --no-gcc-global-registers)
+ global_regs=false ;;
+
+ --debug)
+ debug=true ;;
+ --no-debug)
+ debug=false ;;
+
+ --gc)
shift
+ case "$1" in
+ accurate|conservative|none)
+ gc_method=$1 ;;
+ *)
+ echo "$0: invalid gc method \`$1'" 1>&2
+ exit 1
+ ;;
+ esac
+ ;;
+
+ -p|--profiling)
+ profile_time=true
+ profile_calls=true
+ ;;
+ -p-|--no-profiling)
+ profile_time=false
+ profile_calls=false
+ ;;
+ --profile-time)
+ profile_time=true ;;
+ --no-profile-time)
+ profile_time=false ;;
+ --profile-calls)
+ profile_calls=true ;;
+ --no-profile-calls)
+ profile_calls=false ;;
+
+ --use-trail)
+ use_trail=true ;;
+ --no-use-trail)
+ use_trail=false ;;
+
+ --args)
+ shift
+ case "$1" in
+ simple|compact)
+ args_method=$1;;
+ *)
+ echo "$0: invalid arg method \`$1'" 1>&2
+ exit 1
+ ;;
+ esac
+ ;;
+
+ --pic-reg)
+ pic_reg=true ;;
+ --no-pic-reg)
+ pic_reg=false ;;
+
+ -s|--grade)
+ shift
+ grade="$1";
+
+ case "$grade" in
+ *.debug)
+ debug=true
+ grade="` expr $grade : '\(.*\).debug' `"
+ ;;
+ *) debug=false
+ ;;
+ esac
+
+ case "$grade" in
+ *.sa)
+ args_method=simple
+ grade="` expr $grade : '\(.*\).sa' `"
+ ;;
+ *) args_method=compact
+ ;;
+ esac
+
+ case "$grade" in
+ *.tr) use_trail=true
+ grade="` expr $grade : '\(.*\).tr' `"
+ ;;
+ *) use_trail=false
+ ;;
+ esac
+
+ case "$grade" in
+ *.prof)
+ profile_time=true
+ profile_calls=true
+ grade="` expr $grade : '\(.*\).prof' `"
+ ;;
+ *.proftime)
+ profile_time=true
+ profile_calls=false
+ grade="` expr $grade : '\(.*\).proftime' `"
+ ;;
+ *.profcalls)
+ profile_time=false
+ profile_calls=true
+ grade="` expr $grade : '\(.*\).profcalls' `"
+ ;;
+ *)
+ profile_time=false
+ profile_calls=false
+ ;;
+ esac
+
+ case "$grade" in
+ *.agc) gc_method=accurate
+ grade="` expr $grade : '\(.*\).agc' `"
+ ;;
+ *.gc) gc_method=conservative
+ grade="` expr $grade : '\(.*\).gc' `"
+ ;;
+ *) gc_method=none
+ ;;
+ esac
+
+ case "$grade" in
+ asm_fast)
+ global_regs=true
+ non_local_gotos=true
+ asm_labels=true
+ ;;
+ fast)
+ global_regs=true
+ non_local_gotos=true
+ asm_labels=false
+ ;;
+ reg)
+ global_regs=true
+ non_local_gotos=false
+ asm_labels=false
+ ;;
+ asm_jump)
+ global_regs=false
+ non_local_gotos=true
+ asm_labels=true
+ ;;
+ jump)
+ global_regs=false
+ asm_labels=false
+ non_local_gotos=true
+ ;;
+ none)
+ global_regs=false
+ asm_labels=false
+ non_local_gotos=false
+ ;;
+ debug)
+ debug=true
+ global_regs=false
+ asm_labels=false
+ non_local_gotos=false
+ ;;
+ *)
+ 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 ;;
- -s*)
- GRADE="` expr $1 : '-s\(.*\)' `"
- shift ;;
*)
break ;;
esac
+ shift
done
case $mercury_libs in default)
@@ -204,6 +409,43 @@
;;
esac
+#
+# compute the grade from the options settings
+#
+
+case $non_local_gotos,$global_regs in
+ true,true) GRADE="fast" ;;
+ true,false) GRADE="jump" ;;
+ false,true) GRADE="reg" ;;
+ false,false) GRADE="none" ;;
+esac
+case $asm_labels in
+ true) GRADE="asm_$GRADE" ;;
+ false) ;;
+esac
+case $gc_method in
+ conservative) GRADE="$GRADE.gc" ;;
+ accurate) GRADE="$GRADE.agc" ;;
+esac
+case $profile_time,$profile_calls in
+ true,true) GRADE="$GRADE.prof" ;;
+ true,false) GRADE="$GRADE.proftime" ;;
+ false,true) GRADE="$GRADE.profcalls" ;;
+ false,false) ;;
+esac
+case $use_trail in
+ true) GRADE="$GRADE.tr" ;;
+ false) ;;
+esac
+case $args_method in
+ simple) GRADE="$GRADE.sa" ;;
+ compact) ;;
+esac
+case $debug in
+ true) GRADE="$GRADE.debug" ;;
+ false) ;;
+esac
+
case "$GRADE" in
*.gc.prof*)
LIBGC="-lgc_prof"
@@ -286,8 +528,8 @@
# On Irix 5, grades `fast' and `jump' only work in non_shared mode.
case $FULLARCH in
*-sgi-irix5*)
- case "$GRADE" in
- *fast*|*jump*)
+ case $non_local_gotos in
+ true)
ARCH_OPTS=-non_shared
NONSHARED_PATH="$NONSHARED_LIB_DIR:/usr/lib/nonshared"
LIBRARY_PATH="$NONSHARED_PATH:$LIBRARY_PATH"
@@ -303,6 +545,7 @@
case $verbose in
true)
+ echo "ml: using grade \`$GRADE'"
case $demangle in
false)
echo $LINKER $STRIP_OPTS $MAYBE_STATIC_OPT $ARCH_OPTS \
--
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