[m-dev.] for review: round 2: --target option, IL grades and copy-in/copy-out
Peter Ross
peter.ross at miscrit.be
Tue Sep 5 22:57:11 AEDT 2000
>
>
> Estimated hours taken: 24 (by fjh)
>
> Add new options and grades for the IL back-end.
>
> Implement an option to handle output parameters for nondeterministic
> procedures by passing the outputs (by value) to the continuation,
> rather than using pass-by-reference. This is needed for IL
> because IL does not allow managed pointers (which we used to
> implement pass-by-refernece) to be stored as fields of environment
> structs.
>
> Also add an option to return outputs by value in det/semidet code.
> This is not yet tested, since none of our target languages support
> returning multiple values.
>
> (Note that the IL backend is not activated by these changes -- it
> hasn't been checked in).
>
> compiler/globals.m:
> Use field names for the globals structure.
> Add new `target' field to the globals.
>
> compiler/options.m:
> compiler/handle_options.m:
> Add new options `--target', `--target-only', `--il', and `--il-only'.
> Add new grades `il' and `ilc'.
> Change `--compile-to-c' from a boolean option to an abbreviation
> for `--target c --target-only', and move it from the "Output options"
> section to the "Compilation model options" section.
>
> Comment out the documentation for `--generate-prolog' and
> `--prolog-dialect', since those options are not yet implemented.
>
> Document the `--infer-all' option.
>
I had to read the source to understand what all these options meant.
Please give a brief description.
> compiler/mercury_compile.m:
> Check the `target_code_only' option rather than `compile_to_c',
> since the latter is just an abbreviation now, not a real option.
>
> compiler/ml_call_gen.m:
> compiler/ml_code_gen.m:
> compiler/ml_code_util.m:
> compiler/ml_unify_gen.m:
> Use the `--det-copy-out' option to decide whether to pass
> output arguments for model_det/model_semi procedures by
> reference, or whether to just return multiple values.
> Use the `--nondet-copy-out' option to decide whether to pass
> output arguments for model_non procedures by reference, or
> whether to just pass them to the continuation.
>
> compiler/mlds.m:
> Change the mlds__cont_type so that it includes a list of
> the continuation's argument types (if any).
>
> compiler/mlds_to_c.m:
> Update to reflect the change to mlds.m.
>
> doc/user_guide.texi:
> Update the documentation to reflect the above changes.
>
>
> scripts/parse_grade_options.sh-subr:
> Add new options `--target' and `--il'.
>
> scripts/init_grade_options.sh-subr
> Add new grades `il' and `ilc'.
>
> scripts/final_grade_options.sh-subr
> Make `--target il' imply `--high-level-code'.
>
>
> Index: compiler/globals.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/globals.m,v
> retrieving revision 1.34
> diff -u -r1.34 globals.m
> --- compiler/globals.m 1999/06/01 09:43:44 1.34
> +++ compiler/globals.m 2000/09/05 02:32:23
> @@ -164,6 +177,13 @@
> :- import_module exprn_aux.
> :- import_module map, std_util, io, require.
>
> +convert_target("java", java).
> +convert_target("Java", java).
> +convert_target("il", il).
> +convert_target("IL", il).
> +convert_target("c", c).
> +convert_target("C", c).
> +
You may want to think about running a preprocessing step which tranlates
the string to lower case then doing the check.
> convert_gc_method("none", none).
> convert_gc_method("conservative", conservative).
> convert_gc_method("accurate", accurate).
> @@ -202,33 +222,32 @@
>
> :- type globals
> ---> globals(
> - option_table,
> - gc_method,
> - tags_method,
> - prolog_dialect,
> - termination_norm,
> - trace_level
> + options :: option_table,
> + target :: compilation_target,
> + gc_method :: gc_method,
> + tags_method :: tags_method,
> + prolog_dialect :: prolog_dialect,
> + termination_norm :: termination_norm,
> + trace_level :: trace_level
> ).
>
Our coding standard doesn't say anything about the layout of field names,
but I find the following layout much easier to read.
:- type t
---> f(
f1 :: type1
f2 :: type2
).
> Index: doc/user_guide.texi
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
> retrieving revision 1.218
> diff -u -r1.218 user_guide.texi
> --- doc/user_guide.texi 2000/09/01 00:50:12 1.218
> +++ doc/user_guide.texi 2000/09/04 03:06:46
> @@ -1818,24 +1818,8 @@
> @sp 1
> By default, this command is strict, and it uses the default print level.
> @sp 1
> - at item next [-NSans] [@var{num}]
> -Continues execution until it reaches the next event of
> -the @var{num}'th ancestor of the call to which the current event refers.
> -The default value of @var{num} is zero,
> -which means skipping to the next event of the current call.
> -Reports an error if execution is already at the end of the specified call.
> - at sp 1
> -The options @samp{-n} or @samp{--none}, @samp{-s} or @samp{--some},
> - at samp{-a} or @samp{--all} specify the print level to use
> -for the duration of the command,
> -while the options @samp{-S} or @samp{--strict}
> -and @samp{-N} or @samp{--nostrict} specify
> -the strictness of the command.
> - at sp 1
> -By default, this command is strict, and it uses the default print level.
> - at sp 1
> @item finish [-NSans] [@var{num}]
> -Continues execution until it reaches a final (EXIT, FAIL or EXCP) port of
> +Continues execution until it reaches a final (EXIT or FAIL) port of
> the @var{num}'th ancestor of the call to which the current event refers.
> The default value of @var{num} is zero,
> which means skipping to the end of the current call.
> @@ -2122,21 +2106,10 @@
> specify the action to be taken at the break point.
> @sp 1
> By default, the initial state of the break point is @samp{stop}.
> - at item break [-AOPSaei] @var{proc-spec}
> + at item break [-PSaei] @var{proc-spec}
> @c <module name> <predicate name> [<arity> [<mode> [<predfunc>]]]
> Puts a break point on the specified procedure.
> @sp 1
> -The options @samp{-A} or @samp{--select-all},
> -and @samp{-O} or @samp{--select-one}
> -select the action to be taken
> -if the specification matches more than one procedure.
> -If you have specified option @samp{-A} or @samp{--select-all},
> -mdb will put a breakpoint on all matched procedures,
> -whereas if you have specified option @samp{-O} or @samp{--select-one},
> -mdb will report an error.
> -By default, mdb will ask you whether you want to put a breakpoint
> -on all matched procedures or just one, and if so, which one.
> - at sp 1
> The options @samp{-P} or @samp{--print}, and @samp{-S} or @samp{--stop}
> specify the action to be taken at the break point,
> while the options @samp{-a} or @samp{--all},
> @@ -2306,12 +2279,12 @@
> the debugger will substitute the given command and parameters for this word
> before executing the command line.
> @sp 1
> -If @var{name} is the upper-case word @samp{EMPTY},
> +If @var{command} is the upper-case word @samp{EMPTY},
> the debugger will substitute the given command and parameters
> whenever the user types in an empty command line.
> @sp 1
> @sp 1
> -If @var{name} is the upper-case word @samp{NUMBER},
> +If @var{command} is the upper-case word @samp{NUMBER},
> the debugger will insert the given command and parameters
> before the command line
> whenever the user types in a command line that consists of a single number.
What are these changes doing in here?
Looks like a merging error to me.
> @@ -3056,9 +3029,9 @@
>
> @sp 1
> @item -C
> - at itemx --compile-to-c
> - at itemx --compile-to-C
> -Generate C code in @file{@var{module}.c}, but not object code.
> + at itemx --target-code-only
> +Generate target code (i.e. C in @file{@var{module}.c},
> +or IL in @file{@var{module}.il}, but not object code.
>
> @sp 1
> @item -c
> @@ -3242,10 +3215,12 @@
>
> @sp 1
> @item --infer-types
> -If there is no type declaration for a predicate or function,
> -try to infer the type, rather than just reporting an error.
>
Why delete these two lines?
> @sp 1
> + at item --infer-all
> +An abbreviation for @samp{--infer-types --infer-modes --infer-det}.
> +
> + at sp 1
> @item --infer-modes
> If there is no mode declaration for a predicate,
> try to infer the modes, rather than just reporting an error.
> @@ -3360,9 +3335,10 @@
> The set of aspects and their alternatives are:
>
> @table @asis
> - at item What combination of GNU C extensions to use:
> + at item What target language to use, and (for C) what combination of GNU C extensions to use:
> @samp{none}, @samp{reg}, @samp{jump}, @samp{asm_jump},
> - at samp{fast}, @samp{asm_fast}, and @samp{hlc} (the default is system dependent).
> + at samp{fast}, @samp{asm_fast}, @samp{hlc}, and @samp{ilc}
> +(the default is system dependent).
>
> @item What garbage collection strategy to use:
> @samp{gc}, and @samp{agc} (the default is no garbage collection).
> @@ -3402,25 +3378,28 @@
> @var{Options implied}.
>
> @item @samp{none}
> - at code{--no-gcc-global-registers --no-gcc-nonlocal_gotos --no-asm-labels}.
> + at code{--target c --no-gcc-global-registers --no-gcc-nonlocal_gotos --no-asm-labels}.
>
> @item @samp{reg}
> - at code{--gcc-global-registers --no-gcc-nonlocal_gotos --no-asm-labels}.
> + at code{--target c --gcc-global-registers --no-gcc-nonlocal_gotos --no-asm-labels}.
>
> @item @samp{jump}
> - at code{--no-gcc-global-registers --gcc-nonlocal-gotos --no-asm-labels}.
> + at code{--target c --no-gcc-global-registers --gcc-nonlocal-gotos --no-asm-labels}.
>
> @item @samp{fast}
> - at code{--gcc-global-registers --gcc-nonlocal-gotos --no-asm-labels}.
> + at code{--target c --gcc-global-registers --gcc-nonlocal-gotos --no-asm-labels}.
>
> @item @samp{asm_jump}
> - at code{--no-gcc-global-registers --gcc-nonlocal-gotos --asm-labels}.
> + at code{--target c --no-gcc-global-registers --gcc-nonlocal-gotos --asm-labels}.
>
> @item @samp{asm_fast}
> - at code{--gcc-global-registers --gcc-nonlocal_gotos --asm-labels}.
> + at code{--target c --gcc-global-registers --gcc-nonlocal_gotos --asm-labels}.
>
> @item @samp{hlc}
> - at code{--high-level-code}.
> + at code{--target c --high-level-code}.
> +
> + at item @samp{il}
> + at code{--target il --high-level-code}.
>
> @item @samp{.gc}
> @code{--gc conservative}.
> @@ -3458,6 +3437,27 @@
> @end table
>
> @sp 1
> + at item @code{--target c} (grades: none, reg, jump, fast, asm_jump, asm_fast, hlc)
> + at itemx @code{--il}, @code{--target il} (grades: ilc)
> +Specify the target language used for compilation: C or IL.
> +C means ANSI/ISO C, optionally with GNU C extensions (see below).
> +IL means the Microsoft COM+ 2.0 Intermediate Language.
> + at samp{--target il} implies @samp{--high-level-code}.
> +
> + at sp 1
> + at item @code{--il-only}
> +An abbreviation for @samp{--target il --target-code-only}.
> +Generate IL assembler code in @file{@var{module}.il}, but do not invoke
> +ilasm to produce IL object code.
> +
> + at sp 1
> + at item @code{--compile-to-c}
> + at itemx @code{--compile-to-C}
> +An abbreviation for @samp{--target c --target-code-only}.
> +Generate C code in @file{@var{module}.c}, but do not invoke the
> +C compiler to generate object code.
> +
> + at sp 1
> @item @code{--gcc-global-registers} (grades: reg, fast, asm_fast)
> @itemx @code{--no-gcc-global-registers} (grades: none, jump, asm_jump)
> Specify whether or not to use GNU C's global register variables extension.
> @@ -3477,9 +3477,9 @@
> This option is ignored if the @samp{--high-level-code} option is enabled.
>
> @sp 1
> - at item @code{-H}, @code{--high-level-code} (grades: hlc)
> -Use an alternative back-end that generates high-level C code
> -rather than the very low-level C code that is generated by our
> + at item @code{-H}, @code{--high-level-code} (grades: hlc, ilc)
> +Use an alternative back-end that generates high-level code
> +rather than the very low-level code that is generated by our
> original back-end.
>
> @sp 1
Otherwise the rest of this diff looks fine.
Pete
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list