Commit Graph

9 Commits

Author SHA1 Message Date
Zoltan Somogyi
6bdd8b84ee Move maybe_changed to maybe_succeeded.m and rename it.
compiler/maybe_util.m:
    Move the maybe_changed type from several modules of the compiler
    to maybe_succeeded.m, and rename it to maybe_util.m.

compiler/libs.m:
compiler/notes/compiler_design.html:
    Implement and document the rename.

compiler/common.m:
compiler/compile_target_code.m:
compiler/decide_type_repn.m:
compiler/det_analysis.m:
compiler/det_util.m:
compiler/equiv_type.m:
compiler/equiv_type_hlds.m:
compiler/file_util.m:
compiler/llds_out_file.m:
compiler/make.build.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.top_level.m:
compiler/make.track_flags.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mlds_to_c_file.m:
compiler/mlds_to_c_type.m:
compiler/mlds_to_cs_file.m:
compiler/mlds_to_java_file.m:
compiler/module_cmds.m:
compiler/parse_tree_out.m:
compiler/process_util.m:
compiler/recompilation.version.m:
compiler/write_module_interface_files.m:
    Conform to the changes above.
2023-04-21 17:24:30 +10:00
Zoltan Somogyi
5a0387e030 Move foldl3_* predicates out of make.build.m.
compiler/make.track_flags.m:
    Move foldl3_maybe_stop_at_error_sn here, since it is only used here,
    along with a copy of foldl3_maybe_stop_at_error_loop, then

    - inline it at its only call site, and
    - delete the now-unused predicate.

    Simplify the local copy of foldl3_maybe_stop_at_error_loop
    by specializing it to its only set of top level arguments,
    and rename it after its now-singular purpose.

compiler/make.dependencies.m:
    Move foldl3_maybe_stop_at_error_{mi,fi} here, together with
    foldl3_maybe_stop_at_error_loop, and the type and inst it uses,
    since they are only called from here. There are not any changes
    in the code moved here (yet).

compiler/make.build.m:
    Delete the moved code.
2022-12-01 16:12:00 +11:00
Zoltan Somogyi
e46a560c91 Monomorphize some polymorphic predicates.
compiler/make.build.m:
    Replace three polymorphic predicates that fold over lists of values
    of type T with two, three and five monomorphic predicates respectively.
    The monomorphic versions fold over lists of elements of specified types.
    The list of monomorphic versions needed should be useful information for
    simplifying the make package's overuse of higher order constructs.

    The replaced predicates were mostly just interfaces to the predicates
    that looped over the lists. This diff leaves those predicates alone.

compiler/make.dependencies.m:
    Make the same change to deps_set_foldl3_maybe_stop_at_error and to
    map_find_module_deps (only the first of which does a fold).
    For map_find_module_deps, also change the argument order, because
    operating on the second argument first, and on the first argument second,
    is confusing.

compiler/make.make_info.m:
    Replace a pair type, which some of the above fold operated over,
    with a bespoke type, because its structure and semantics was related
    to existing bespoke types.

compiler/make.program_target.m:
    Conform to the changes above. In two cases, replaces nested folds
    with sequences of folds, both because this is simpler, and because
    it avoids the need for an extra variant of the fold.

compiler/make.module_target.m:
compiler/make.top_level.m:
compiler/make.track_flags.m:
compiler/make.util.m:
    Conform to the changes above.
2022-12-01 07:08:38 +11:00
Zoltan Somogyi
6f82724091 Pass streams explicitly at the top levels.
compiler/mercury_compile_main.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_make_hlds.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
    Pass progress and error streams explicitly in these top modules
    of the compiler. Use "XXX STREAM" to mark places where we could switch
    from using stderr for both the progress and error streams to using
    module-specific files as the progress and/or error streams.

compiler/passes_aux.m:
    Add a "maybe_" prefix to the names of the predicates that print progress
    messages at the appropriate verbosity levels, as their printing of those
    messages is conditional.

    Provide versions of those predicates that take explicitly specified
    streams to write to, and mark the versions that write to the current
    output stream as obsolete.

    The predicate that wrote progress messages for procedures
    used to have two versions, one taking a pred_proc_id, and one taking
    a pred_id/proc_id pair. Delete the latter, because the arity difference
    that differentiated the two versions is now needed for the difference
    between supplying and not supplying an explicit stream.

compiler/file_util.m:
compiler/hlds_error_util.m:
compiler/write_error_spec.m:
    Delete several predicates that wrote to the current output stream,
    since all their callers now use the versions that specify an explicit
    output stream.

compiler/check_promise.m:
compiler/check_typeclass.m:
compiler/closure_analysis.m:
compiler/complexity.m:
compiler/cse_detection.m:
compiler/deforest.m:
compiler/delay_construct.m:
compiler/delay_partial_inst.m:
compiler/deps_map.m:
compiler/direct_arg_in_out.m:
compiler/grab_modules.m:
compiler/handle_options.m:
compiler/hhf.m:
compiler/inlining.m:
compiler/make.module_dep_file.m:
compiler/ml_proc_gen.m:
compiler/ml_top_gen.m:
compiler/mode_constraints.m:
compiler/modes.m:
compiler/polymorphism.m:
compiler/purity.m:
compiler/read_modules.m:
compiler/recompilation.check.m:
compiler/saved_vars.m:
compiler/simplify_proc.m:
compiler/size_prof.m:
compiler/stack_opt.m:
compiler/switch_detection.m:
compiler/typecheck.m:
compiler/unique_modes.m:
compiler/unneeded_code.m:
compiler/write_module_interface_files.m:
    Get these modules to take an explicitly specified stream to which
    to write progress messages when they are invoked from mercury_compile_*.m.

    For predicates in these modules that can be invoked both directly
    by mercury_compile_*.m *and* by other modules, the latter effectively
    as a subcontractor, make them take a maybe(stream), with the intention
    being that all the other modules that use the predicate as a subcontractor
    would pass a "no". This avoids the need to pass progress streams
    down to the internals of other passes, and also avoids overwhelming
    the user invoking the compiler with unnecessary details.

    As above, and also delete a progress message that shouldn't be needed
    anymore.

    Move a test of option value compatibility from
    mercury_compile_middle_passes.m to handle_options.m, where it belongs.

compiler/float_regs.m:
    Write a debug message to the debug stream.

compiler/pd_info.m:
    Include the progress stream in the pd_info structure, because this is
    the simplest way to ensure that all parts of the partial deduction pass
    have access to it.

compiler/make.build.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
    Make the minimal changes needed to conform to the changes above.
    The rest can be done when the make package is converted to consistently
    use explicit streams.

compiler/bytecode_gen.m:
compiler/structure_reuse.direct.m:
compiler/structure_reuse.versions.m:
compiler/structure_sharing.analysis.m:
    Make the minimal changes needed to conform to the changes above.
    The rest can be done when these modules start being maintained again.

compiler/Mercury.options:
    Stop specifying --no-warn-implicit-stream-calls for mercury_compile_*.m,
    since this diff makes that unnecessary.

    Start specifying --no-warn-implicit-stream-calls for some modules that
    are not currently being actively maintained, because the addition of
    progress-reporting predicates that take explicitly specified streams
    would otherwise cause the generation of such warnings for them.
2022-11-01 11:33:41 +11:00
Zoltan Somogyi
307b1dc148 Split up error_util.m into five modules.
compiler/error_spec.m:
    This new module contains the part of the old error_util.m that defines
    the error_spec type, and some functions that can help construct pieces
    of error_specs. Most modules of the compiler that deal with errors
    will need to import only this part of the old error_util.m.

    This change also renames the format_component type to format_piece,
    which matches our long-standing naming convention for variables containing
    (lists of) values of this type.

compiler/write_error_spec.m:
    This new module contains the part of the old error_util.m that
    writes out error specs, and converts them to strings.

    This diff marks as obsolete the versions of predicates that
    write out error specs to the current output stream, without
    *explicitly* specifying the intended stream.

compiler/error_sort.m:
    This new module contains the part of the old error_util.m that
    sorts lists of error specs and error msgs.

compiler/error_type_util.m:
    This new module contains the part of the old error_util.m that
    convert types to format_pieces that generate readable output.

compiler/parse_tree.m:
compiler/notes/compiler_design.html:
    Include and document the new modules.

compiler/error_util.m:
    The code remaining in the original error_util.m consists of
    general utility predicates and functions that don't fit into
    any of the modules above.

    Delete an unneeded pair of I/O states from the argument list
    of a predicate.

compiler/file_util.m:
    Move the unable_to_open_file predicate here from error_util.m,
    since it belongs here. Mark another predicate that writes
    to the current output stream as obsolete.

compiler/hlds_error_util.m:
    Mark two predicates that wrote out error_spec to the current output
    stream as obsolete, and add versions that take an explicit output stream.

compiler/Mercury.options:
    Compile the modules that call the newly obsoleted predicates
    with --no-warn-obsolete, for the time being.

compiler/*.m:
    Conform to the changes above, mostly by updating import_module
    declarations, and renaming format_component to format_piece.
2022-10-12 20:50:16 +11:00
Zoltan Somogyi
7cba325c94 Make options_file.m return either info or error.
compiler/options_file.m:
    Change the interface of three lookup predicates to return
    either the information they are intended to look up, or a list of
    error_specs, but not both. The old code would have made sense
    if some error_specs generated during the lookup could be warnings,
    but they are always errors.

compiler/make.build.m:
    Do not make room for warnings in make build's setup, because
    (a) the code that filled in that slot with info from options_file.m
    could never put any warnings in there, and (b) most users of that
    data structure ignored that slot anyway.

    Don't take parameters that are unneeded after this change.

compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.track_flags.m:
compiler/mercury_compile_main.m:
    Conform to the changes above.

compiler/maybe_error.m:
    Add a utility predicate.
2022-01-23 02:05:23 +11:00
Zoltan Somogyi
243491523d Stop counting errors in module_infos.
Over time, we have almost completely switched over to using error_specs,
using their severity (if not yet printed out) and their effect on the
exit status (if already printed out) to represent the presence of errors,
leaving only a few places that either updated or paid attention to the
num_error field in the module_info. This diff completes that process.

compiler/hlds_module.m:
    Delete the num_errors field in the module_info, and the predicates
    that operate on it.

compiler/hlds_error_util.m:
    Delete module_info arguments whose only purpose was to update the
    now-delete field.

compiler/error_util.m:
    Delete the old write_error_spec predicates that updated a count of warnings
    and a count of errors.

    Rename the write_error_spec_ignore predicates, which ignored those counts,
    by deleting the "_ignore" from their names. This makes them take the
    place of the deleted predicates.

compiler/add_pragma_type_spec.m:
compiler/add_pred.m:
compiler/add_type.m:
compiler/compile_target_code.m:
compiler/cse_detection.m:
compiler/find_module.m:
compiler/generate_dep_d_files.m:
compiler/handle_options.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.top_level.m:
compiler/make.track_flags.m:
compiler/mercury_compile_front_end.m:
compiler/mercury_compile_llds_back_end.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_middle_passes.m:
compiler/mercury_compile_mlds_back_end.m:
compiler/mode_info.m:
compiler/modes.m:
compiler/pd_util.m:
compiler/pred_table.m:
compiler/recompilation.check.m:
compiler/typecheck.m:
compiler/write_module_interface_files.m:
    Conform to the changes above.
2022-01-15 16:33:38 +11:00
Zoltan Somogyi
0cd4453857 Fix comment. 2022-01-11 15:01:37 +11:00
Zoltan Somogyi
fe3994f324 Carve three modules out of make.m.
compiler/make.top_level.m:
compiler/make.track_flags.m:
compiler/make.make_info.m:
    Carve these three modules out of make.m.

    make.top_level.m contains the top level of the mmc --make algorithm.

    make.track_flags.m contains code for keeping track of which options
    were used to compile which modules.

    make.make_info.m defines the make_info structure used by all the
    submodules of make.m, as well as a few other utility types.

compiler/notes/compiler_design.html:
    Document the new modules.

compiler/make.m:
    Delete the code that has been moved to the new modules, leaving
    make.m as purely a package.

    Include make.build.m in the interface, so we can delete the forwarding
    predicate we used to have here for use by mercury_compile_main.m.

compiler/Mercury.options:
    Make make.top_level.m and make.track_flags inherit make.m's old
    -no-warn-implicit-stream-calls option.

compiler/file_names.m:
    Move a utility function about extensions here from make.m.
    This also allows the removal of an undesirable module import of make.m
    in write_deps_file.m.

compiler/make.build.m:
    Move a type here from make.m, since it is needed to allow
    mercury_compile_main.m call this module directly (i.e. not through
    a forwarding predicate in make.m).

compiler/make.dependencies.m:
compiler/make.deps_set.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/mercury_compile_main.m:
compiler/options_file.m:
compiler/write_deps_file.m:
    Conform to the changes above. This mostly means having each module make.X
    actually import the modules it uses, instead of relying on make.m
    importing them, and getting those imports via make.int0.

    In a few cases, it means having each module make.X NOT import the modules
    it does NOT use, since after the "package-ification" of make.m,
    we now get warnings about these imports being unused.
2022-01-10 12:22:42 +11:00