[m-rev.] for review: feature set pragmas

Julien Fischer juliensf at csse.unimelb.edu.au
Wed Dec 5 01:07:39 AEDT 2007


In the absence of any further review comments I will commit this later 
today.

Julien


On Mon, 3 Dec 2007, Julien Fischer wrote:

>
> On Fri, 30 Nov 2007, Julien Fischer wrote:
>
>> For review by anyone.
>> 
>> Estimated hours taken: 8
>> Branches: main
>> 
>> Add a new pragma that allows dependencies on optional features of the
>> compilation model to be checked by the compiler.  The new pragma
>> has the form
>> 
>> 	:- pragma require_feature_set(<list_of_features>).
>> 
>> where <list_of_features> is a list of optional compilation model features
>> whose presence is required by the module containing the pragma.
>> 
>> For example,
>> 
>> 	:- pragma require_feature_set([trailing, double_prec_float, memo]).
>> 
>> asserts that the module requires trailing, double precision floats and
>> memoisation.  The compiler will emit an error message if these features
>> are not available in the current compilation grade.  This is particularly
>> helpful in cases like memoisation and parallel conjunction that are ignored
>> by default in grades that do not support them.
>> 
>> Fix a bug where we where not emitting a warning about memo and loopcheck
>> pragmas being ignored in grades that use --highlevel-data.
>> 
>> compiler/prog_item.m:
>> 	Represent require_feature_set pragmas in the parse tree.
>> 
>> compiler/prog_data.m:
>> 	Add a type that represents optional features of the compilation
>> 	model whose presence is required.
>> 
>> compiler/prog_io_pragma.m:
>> 	Parse the new pragma.
>> 
>> 	Turn an if-then-else into a switch.
>> 
>> compiler/add_pragma.m:
>> 	Process require_feature_set pragmas and emit error messages
>> 	concerning required features that are not supported by the
>> 	compilation grade.
>> 
>> compiler/globals.m:
>> 	Add three predicates that check whether tabling, threads and
>> 	parallel conjunctions are support by the current grade respectively.
>> 	(Some of this code used to be in table_gen.m and dep_par_conj.m
>> 	and has been moved here since it now called from more than one 
>> place).
>> 
>> 	Fix a bug where we were not emitting a message about memo
>> 	and loopcheck pragmas being ignored in grades where --highlevel-data
>> 	was enabled.
>> 
>> compiler/make_hlds_passes.m:
>> compiler/mercury_to_mercury.m:
>> 	Handle require_feature_set pragmas.
>> 
>> compiler/module_qual.m:
>> compiler/recompilation.version.m:
>> compiler/dep_par_conj.m:
>> compiler/table_gen.m:
>> 	Conform to the above change.
>> 
>> doc/reference_manual.texi:
>> 	Document the new pragma.
>> 
>> tests/invalid/Mmakefile:
>> tests/invalid/Mercury.options:
>> tests/invalid/conflicting_fs.{m,err_exp}
>> tests/invalid/test_feature_set.{m,err_exp}:
>> 	Test the new pragma.
>
> I have modified this change to implement the `strict_sequential' feature
> requested by Peter and Mark.  There are a couple of other minor changes
> to the way require_feature_set pragma interact with the module system.
>
> Relative diff follows:
>
>
> diff -u compiler/add_pragma.m compiler/add_pragma.m
> --- compiler/add_pragma.m	30 Nov 2007 03:29:28 -0000
> +++ compiler/add_pragma.m	3 Dec 2007 02:41:26 -0000
> @@ -3734,14 +3734,22 @@
> check_required_feature_set(FeatureSet, ImportStatus, Context, !ModuleInfo,
>         !Specs) :-
>     module_info_get_globals(!.ModuleInfo, Globals),
> -    set.fold(check_required_feature(Globals, ImportStatus, Context), - 
> FeatureSet, !Specs).
> +    IsImported = status_is_imported(ImportStatus),
> +    (
> +        % `require_feature_set' pragmas are not included in interface files
> +        % (including private interfaces) and so this case should not occur.
> +        IsImported = yes,
> +        unexpected(this_file, "imported require_feature_set pragma")
> +    ;
> +        IsImported = no,
> +        set.fold(check_required_feature(Globals, Context), FeatureSet, 
> !Specs)
> +    ).
>
> -:- pred check_required_feature(globals::in, import_status::in,
> +:- pred check_required_feature(globals::in,
>     prog_context::in, required_feature::in,
>     list(error_spec)::in, list(error_spec)::out) is det.
>
> -check_required_feature(Globals, _ImportStatus, Context, Feature, !Specs) :-
> +check_required_feature(Globals, Context, Feature, !Specs) :-
>     (
>         Feature = reqf_concurrency,
>         current_grade_supports_concurrency(Globals, IsConcurrencySupported),
> @@ -3849,6 +3857,26 @@
>         ;
>             UseTrail = yes
>         )
> +    ;
> +        Feature = reqf_strict_sequential,
> +        globals.lookup_bool_option(Globals, reorder_conj, ReorderConj),
> +        globals.lookup_bool_option(Globals, reorder_disj, ReorderDisj),
> +        globals.lookup_bool_option(Globals, fully_strict, FullyStrict),
> +        (
> +            ReorderConj = no,
> +            ReorderDisj = no,
> +            FullyStrict = yes
> +        ->
> +            true
> +        ;
> +            Pieces = [
> +                words("Error: this module must be compiled using the"),
> +                words("strict sequential semantics.")
> +            ],
> +            Msg = simple_msg(Context, [always(Pieces)]),
> +            Spec = error_spec(severity_error, phase_parse_tree_to_hlds, 
> [Msg]),
> +            !:Specs = [Spec | !.Specs]
> +        )
>     ).
>
> %----------------------------------------------------------------------------%
> diff -u compiler/mercury_to_mercury.m compiler/mercury_to_mercury.m
> --- compiler/mercury_to_mercury.m	29 Nov 2007 01:23:31 -0000
> +++ compiler/mercury_to_mercury.m	3 Dec 2007 01:36:35 -0000
> @@ -3787,6 +3787,8 @@
>     add_string("parallel_conj", !U).
> mercury_format_required_feature(reqf_trailing, !U) :-
>     add_string("trailing", !U).
> +mercury_format_required_feature(reqf_strict_sequential, !U) :-
> +    add_string("strict_sequential", !U).
>
> %-----------------------------------------------------------------------------%
>
> diff -u compiler/prog_data.m compiler/prog_data.m
> --- compiler/prog_data.m	28 Nov 2007 06:52:42 -0000
> +++ compiler/prog_data.m	3 Dec 2007 01:31:26 -0000
> @@ -635,7 +635,8 @@
>     ;       reqf_double_prec_float
>     ;       reqf_memo
>     ;       reqf_parallel_conj
> -    ;       reqf_trailing.
> +    ;       reqf_trailing
> +    ;       reqf_strict_sequential.
>
> %-----------------------------------------------------------------------------%
> %
> diff -u compiler/prog_io_pragma.m compiler/prog_io_pragma.m
> --- compiler/prog_io_pragma.m	29 Nov 2007 02:32:33 -0000
> +++ compiler/prog_io_pragma.m	3 Dec 2007 01:37:06 -0000
> @@ -2746,6 +2746,7 @@
> string_to_required_feature("memo",              reqf_memo).
> string_to_required_feature("parallel_conj",     reqf_parallel_conj).
> string_to_required_feature("trailing",          reqf_trailing).
> +string_to_required_feature("strict_sequential", reqf_strict_sequential).
>
> %-----------------------------------------------------------------------------%
>
> diff -u doc/reference_manual.texi doc/reference_manual.texi
> --- doc/reference_manual.texi	30 Nov 2007 03:15:52 -0000
> +++ doc/reference_manual.texi	3 Dec 2007 02:51:16 -0000
> @@ -10428,7 +10428,7 @@
>
> The University of Melbourne Mercury implementation supports a number
> of optional compilation model features,
> -such as @ref{Trailing} or @ref{Tabled evaluation},
> +such as @ref{Trailing} or @ref{Tabled evaluation}.
> Feature sets allow the programmer to assert that a module requires
> the presence of one or more optional features in the compilation model.
> These assertions can be made use a @samp{pragma require_feature_set}
> @@ -10476,6 +10476,10 @@
> This feature cannot be specified together with the @samp{parallel_conj}
> feature.
>
> + at item @samp{strict_sequential}
> +This feature specifes that a semantics that is equivalent to the strict
> +sequential operational semantics must be used.
> +
> @end table
>
> When a module containing a @samp{pragma require_feature_set} declaration
> @@ -10486,6 +10490,9 @@
> A @samp{pragma require_feature_set} may only occur in the implementation
> section of a module.
>
> +A @samp{pragma require_feature_set} affects only the the module in which
> +it occurs; in particular it does not affect any sub-modules
> +
> If a module contains multiple @samp{pragma require_feature_set} declarations
> then the implementation should emit an error if any of them specifies a
> feature that is not supported by the compilation model.
>
> --------------------------------------------------------------------------
> mercury-reviews mailing list
> Post messages to:       mercury-reviews at csse.unimelb.edu.au
> Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
> Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
> --------------------------------------------------------------------------
>
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list