Commit Graph

1557 Commits

Author SHA1 Message Date
Julien Fischer
2a366cf295 Deprecate --no-ansi and --no-ansi-c.
--no-ansi (mgnuc) and --no-ansi-c (mmc) have not actually done anything for
many years now. Deprecate these options and remove their "use" throughout most
of the Mercury system. (The remaining uses are in the Makefiles for the Boehm
GC, which need to be updated separately.)

Also deprecate the internal compiler option --cflags-for-ansi.

compiler/options.m:
    Document that --no-ansi-c is now deprecated.

    Document that the internal option --cflags-for-ansi is now
    deprecated.

compiler/compile_target_code.m:
    Do not pass the ANSI options to the C compiler.

scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
    Deprecate the --no-ansi option; delete code that no longer does
    anything useful.

configure.ac:
    Delete the configuration variable CFLAGS_FOR_ANSI; it is only ever
    set to be empty. (The comment talks about --no-ansi doing other things
    in the mgnuc script. It used to also cause some preprocessor macros
    to be defined for compatibility with the system headers on some
    platforms -- that has not been the case since 2013.)

doc/user_guide.texi:
    Document that --no-ansi-c is deprecated.

bytecode/Mmakefile:
compiler/Mercury.options:
library/Mercury.options:
extras/odbc/odbc.m:
runtime/Mmakefile:
scripts/Mercury.config.bootstrap.in:
scripts/Mercury.config.in:
tests/hard_coded/Mercury.options:
tests/valid/Mercury.options:
trace/Mmakefile:
util/Mmakefile:
    Conform to the above change.

NEWS.md:
    Announce the above.
2023-05-31 17:44:26 +10:00
Zoltan Somogyi
585c5f6165 Limit the size of insts we output in HLDS dumps.
The reason for this is that without such limits,

- the generation of a HLDS dump for the valid/inst_perf_bug_2 test case
  takes almost forever, and
- generates a multi-gigabyte HLDS dump, which causes e.g. vim to take
  forever to open.

Making the generation and use of HLDS dumps practical is worth the cost
of losing some information. (Information you can't afford to generate
or to use is lost anyway.)

compiler/options.m:
doc/user_guide.texi.m:
    Add a new option to limit the size of the insts we output
    in the inst tables part of HLDS dumps. This option should allow users
    to select the tradeoff between the amount of information being preserved
    and the cost of generating/using that information.

compiler/hlds_out_module.m:
    Pass the value of the new option to hlds_out_inst_table.m.

compiler/hlds_out_inst_table.m:
    Specify the size limit when writing out insts as either the keys or
    the values in the various kinds of inst tables.

compiler/parse_tree_to_term.m:
    To implement those limits, add inst_to_limited_size_term and
    inst_name_to_limited_size_term, versions of the old inst_to_term
    and inst_name_to_term functions that truncate the given inst or inst name
    at the given "size" if necessary. The measure of "size" is just
    function symbols in the resulting term in most cases, though
    we treat things that in practice never get too big, such as types,
    as "one", regardless of the number of function symbols they contain.

    To make the parallel between the old non-size-limiting and the new
    size-limiting versions of the relevant codes easier to see, transform
    the functions in the old code to predicates. (The new versions have
    to be predicates to allow the size to be passed along in a state var.)

compiler/hlds_out_goal.m:
    When we print out the argument modes of a unification, limit the depth
    to which we write out the various insts to three. This should be
    more than enough, because any inst that we now replace with "..."
    should be available in the mode information of the atomic goal that
    generates it, whether that goal is a unification or a call.
2023-05-29 10:45:53 +02:00
Julien Fischer
e3b2cc1272 Fix generation of the debugger documentation on Windows.
We generate the debugger documentation files, e.g. the command list, by
processing the output of the info tool and running through a series of sh and
awk scripts. This is breaking builds for MSYS based systems on Windows because
the port of awk there does not handle non-ASCII characters and info will
sometimes output those. Using the C locale on affected systems causes the
output of info to be ASCII.

doc/generate_mdb_doc:
    Force the use of the C locale on MSYS / MinGW systems in order to avoid
    problems with awk.

    Shut up some warnings form shellcheck.
2023-05-13 16:51:57 +10:00
Julien Fischer
c047985f81 Fixes description of profiling files.
doc/user_guide.texi:
    s/Prof.Decls/Prof.Decl/ in a couple of spots.

    Fix wording.
2023-03-20 21:33:01 +11:00
Zoltan Somogyi
da3e2e80d3 Make invoked_by_mmc_make part of the op_mode.
compiler/op_mode.m:
    Add a field that specifies whether the compiler was invoked by
    "mmc --make" to the opm_top_args top-level op_mode. This is the
    class of op_modes for which we need that info.

    Fill in this new field from the value of the --invoked-by-mmc-make
    option.

compiler/options.m:
    Add an "only_opmode_" prefix to the internal name of the
    --invoked-by-mmc-make option. Move this option next to the --make option.

    Improve the wording of some options' usage messages.

doc/user_guide.texi:
    Make the same changes in wording here as well.

compiler/add_pragma.m:
compiler/add_type.m:
compiler/exception_analysis.m:
compiler/handle_options.m:
compiler/headvar_names.m:
compiler/hlds_module.m:
compiler/mercury_compile_main.m:
compiler/mercury_compile_make_hlds.m:
compiler/mode_errors.m:
compiler/op_mode.m:
compiler/options.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/structure_reuse.analysis.m:
compiler/structure_reuse.versions.m:
compiler/structure_sharing.analysis.m:
compiler/tabling_analysis.m:
compiler/term_util.m:
compiler/trailing_analysis.m:
compiler/unused_args.m:
    Conform to the changes above, either by finding out whether
    the compiler was invoked by mmc --make using the op_mode instead
    of the option, or by ignoring that info where not needed.
2023-03-11 16:55:06 +08:00
Chloé Kekoa
23cf3b5d38 Fix --no-warn-non-contiguous-decls documentation.
doc/user_guide.texi:
compiler/options.m:
    Name the option correctly in the documentation.
2023-03-03 07:21:16 +11:00
Julien Fischer
bbd7686d80 Update some links.
docs/reference_manual.texi:
docs/user_guide.texi:
    As above (and check that they are still current).

doc/mercury.html.in:
    Update a link to the old Mercury homepage.

    Update the markup style.
2023-02-14 17:25:08 +11:00
Peter Wang
c9a6ba783d Add --trans-opt-deps-spec option.
This option lets the user provide a file containing information to
remove some edges from the trans-opt dependency graph, i.e. the graph
used to determine which .trans_opt files to read when making a module's
own .trans_opt file.

The reason to remove edges from the graph is to break dependency cycles.
.trans_opt files for modules within an SCC have to be made one after
another, instead of in parallel. For example, the standard library
contains one large SCC due to circular imports, so making .trans_opt
files turns out to be a bottleneck when building the standard library
(on a machine with sufficient parallelism available).

Furthermore, the user had no control over which modules in an SCC
could read the .trans_opt files of other modules in the same SCC.
If a and b happened to import each other, the compiler would always
break the cycle by allowing a to read b.trans_opt, but not allow b to
read a.trans_opt, simply based on module names. The new option lets the
user break the cycle in a way that may improve analysis results.

compiler/options.m:
    Add the --trans-opt-deps-spec option.

compiler/generate_dep_d_files.m:
    If the option --trans-opt-deps-spec FILE is used, use the
    information given in the file to remove some edges from the
    trans-opt dependency graph.

    If --generate-module-order is passed, also output the module order
    computed from the trans-opt dependency graph to a file.
    Users may find this a useful starting point when writing their own
    spec file.

compiler/write_deps_file.m:
    Add a field to intermod_deps to hold the (user-adjusted)
    trans-opt dependencies.

    Add a type, maybe_include_trans_opt_rule, to indicate whether or not
    to include a trans_opt_deps rule in a mmake dependency file.

    Separate the case when a trans_opt_deps rule is to be written,
    indicating where the dependencies come from.

    When automatically rewriting a .d file after producing target code,
    etc., write the trans_opt_deps rule with the same list of dependencies
    as the old .d file.

compiler/mercury_compile_make_hlds.m:
    Conform to maybe_include_trans_opt_rule change.

    Rename some variables for clarity.
2023-01-12 16:53:42 +11:00
Peter Wang
d32865f00d Fix option name in documentation.
doc/user_guide.texi:
    As above.
2023-01-12 11:00:09 +11:00
Julien Fischer
79fd8539cb Update copyright notices for 2023.
LICENSE:
compiler/handle_options.m:
doc/*.texi:
profiler/mercury_profile.m:
trace/mercury_trace_internal.c:
    As above.
2023-01-02 15:54:22 +11:00
Julien Fischer
90753b830a Minor documentation fix.
doc/reference_manual.texi:
    s/a/an/ in a couple of spots.
2022-12-29 23:56:25 +11:00
Zoltan Somogyi
05ef8e01fb Rename the .ll_debug grade component to .c_debug.
Rename mmc and mgnuc options that set this grade component to --c-debug-grade.
Let the options named --c-debug of both mmc and mgnuc enable C level debugging
of only the module being compiled.

runtime/mercury_grade.h:
    Rename the .ll_debug grade component to .c_debug. Also rename the C macro
    that controls the presence or absence of this grade component
    from MR_LL_DEBUG to MR_C_DEBUG_GRADE.

runtime/mercury_conf_param.h:
runtime/mercury_debug.c:
runtime/mercury_debug.h:
runtime/mercury_engine.c:
runtime/mercury_label.c:
runtime/mercury_memory_zones.c:
runtime/mercury_memory_zones.h:
runtime/mercury_overflow.c:
runtime/mercury_std.h:
runtime/mercury_wrapper.c:
    Rename the MR_LOWLEVEL_DEBUG macro to MR_DEBUG_THE_RUNTIME.
    Previously, the name of this macro wrongly implied that it had
    something to do with the old .ll_debug grade component, even though

    - the MR_LOWLEVEL_DEBUG macro was designed to debug LLDS grades,
      since only these existed when it was created, while

    - the .ll_debug grade component (now .c_debug) is useful only for
      MLDS grades targeting C.

compiler/options.m:
    Rename the old confusingly named low_level_debug option to c_debug_grade.
    Move it to the list of grade options, and fix its documentation, which
    was completely wrong:

    - code in compile_target_code.m treated it as being a synonym of
      the .ll_debug (now .c_debug) grade component, while
    - its (commented out) documentation here in options.m said it called for
      the enabling of what is now MR_DEBUG_THE_RUNTIME.

compiler/compile_target_code.m:
    Conform to the rename just above.

    Define MR_C_DEBUG_GRADE instead of MR_LL_DEBUG if c_debug_grade is enabled.

    Pass -g to the C compiler if either c_debug_grade or target_debug
    is enabled.

    Add an XXX about a missing safety check for an obsolete experimental
    feature.

compiler/compute_grade.m:
    When given a grade with a .c_debug grade component, set only the
    c_debug_grade option; don't set the target_debug option, which is NOT
    a grade option. The change to compile_target_code.m above handles the
    only situation in which this implication was formerly required.

scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
    Look for and process the .c_debug grade component instead of .ll_debug.
    Use a sh variable named c_debug_grade to record its absence/presence.

    Look for and process the --c-debug-grade grade-component option,
    setting the same sh variable, c_debug_grade. (All grade components
    can be set piecemeal using sh options to the scripts using these
    subroutines.) This replaces the old, confusingly named option
    --low-level-debug.

scripts/mgnuc.in:
scripts/mgnuc_file_opts.sh-subr:
    Consistently use the sh variable c_debug to record the presence of
    the (non-grade) --c-debug option to mgnuc, and the sh variable
    c_debug_grade to record the presence of the .c_debug grade component.

    Stop looking for and handling the --low-level-debug option, which
    mgnuc used to document, even though this duplicated the same documentation
    in init_grade_options.sh-subr, which mgnuc includes. The difference was
    that init_grade_options.sh-subr meant it to represent the old .ll_debug
    MLDS grade component, while mgnuc treated it as specifying what is now
    MR_DEBUG_THE_RUNTIME for LLDS grades. It didn't help that two sh variables
    with quite different semantics had names that differed only in an
    underscore: LLDEBUG_OPTS vs LL_DEBUG_OPTS.

scripts/Mmakefile:
    Add a missing dependency to force the rebuild of mgnuc after each update
    of its sh subroutine mgnuc_file_ops.sh-subr.

doc/user_guide.texi:
    Document the --c-debug-grade option of mmc. This option was not publicly
    documented under its original misleading name (--low-level-debug), but
    its documentation is now possible without contorted dancing around the
    name.

    Clarify the documentation of mgnuc's --c-debug option.

README.sanitizers:
configure.ac:
    Conform to the rename of the grade component.

grade_lib/grade_spec.m:
grade_lib/grade_string.m:
grade_lib/grade_structure.m:
grade_lib/try_all_grade_structs.m:
    Conform to the rename of the grade component .ll_debug to .c_debug.

    Don't allow the .c_debug grade component in LLDS grades.

    In grade_string.m, add some obvious implications of some grade components.

grade_lib/choose_grade.m:
grade_lib/grade_lib.m:
grade_lib/test_grades.m:
grade_lib/var_value_names.m:
    Fix white space.

scripts/ml.in:
tools/lmc.in:
tools/test_mercury:
    Conform to the change in compile_target_code.m to the naming of
    Boehm gc library variants.
2022-12-29 20:33:08 +11:00
Zoltan Somogyi
ae7437c8f1 Recognize <<u and >>u as operators.
library/ops.m:
    Add these to the list of operators, at the same priority as << and >>.

library/mercury_term_lexer.m:
    <<u and >>u are the first operators that combine graphic characters with
    alphanumeric characters. This requires extending the lexer, because
    if the lexer, when given e.g. the string "<<u", returns "<<" and "u"
    as separate tokens, then the presence of <<u in the ops table
    would not matter.

    Implement this special case in all three different variants of the lexer.

doc/reference_manual.texi:
    Document the new operators, and their special-case nature.
2022-12-05 18:22:32 +11:00
Zoltan Somogyi
4955a75561 Update the manual for changes in ops priorities. 2022-12-04 18:42:01 +11:00
Zoltan Somogyi
0337cee2df Add the new option --reverse-error-order.
compiler/options.m:
doc/user_guide.texi:
    As above.

NEWS:
    Announce the new option.

compiler/error_sort.m:
    Implement the new option.
2022-11-01 17:41:45 +11:00
Mark Brown
6c0703d83c Improve documentation of module qualifiers.
doc/reference_manual.texi:
    Clarify how the module qualification operator interacts with
    other operators.

    Extend the definition of "principal functor" to module-qualified
    terms.

    Define "fully qualified" prior to use.

    State the requirements on module qualification _after_ describing
    use_module.
2022-10-31 15:05:16 +11:00
Julien Fischer
29421d9454 Fix spelling.
docs/reference_manual.texi:
     As above.
2022-10-16 21:06:57 +11:00
Mark Brown
36cc76a8a2 Clarify predicate strictness in the reference manual.
doc/reference_manual.texi:
    In the description of mode-determinism assertions, point readers
    to the strict sequential semantics to disable optimizations
    derived from those assertions.

    In Exception handling, provide an example where the behaviour
    depends on the choice of operational semantics. Show one way to
    rewrite the example to make it work with any operational semantics.

    In Formal semantics, define predicate strictness, and be more
    expansive on the options that determine the operational semantics
    to be used.

    In Trace goals, mention the effect of non-fully-strict semantics
    on calls to predicates containing trace goals.
2022-10-16 10:00:00 +11:00
Zoltan Somogyi
daa4513894 Add the new compiler option --show-local-call-tree.
When specified, this option causes the compiler to output,
to <module>.local_call_tree, a flattened form of the part of the
module call tree restricted to local predicates and functions, like this:

    pred polymorphism_process_module/5
        pred maybe_polymorphism_process_pred/7
        pred polymorphism_update_arg_types/5

    pred maybe_polymorphism_process_pred/7
        pred polymorphism_process_pred_msg/7

    pred polymorphism_process_pred_msg/7
        pred polymorphism_process_pred/6

    pred polymorphism_process_pred/6
        pred polymorphism_process_clause_info/6
        pred add_extra_arg_modes_to_proc/3

This output consists of a list of entries, with each entry naming
a predicate or function, and listing all the local predicates and functions
it calls. Both the callees in a single entry and the entries themselves
are in the order in which a depth-first left-to-right traversal of the
module, starting at the exported predicates and functions, would encounter
them. That order is also output to <module>.local_call_tree_order.
This information can give useful guidance about how the contents
of a module should be ordered.

doc/user_guide.texi:
compiler/options.m:
    As above.

NEWS:
    Announce the new option.

compiler/hlds_call_tree.m:
    A new module to implement the new option.

compiler/hlds.m:
compiler/notes/compiler_design.html:
    Add and document the new module.

compiler/mercury_compile_front_end.m:
    Invoke the new module if the new option is set.

compiler/hlds_desc.m:
    Add describe_pred and describe_pred_from_id. Reimplement
    describe_proc and describe_proc_from_id in terms of those.
    Allow callers of all four to decide whether we want the descriptions
    to include the names of the defining module.

compiler/dead_proc_elim.m:
compiler/ml_proc_gen.m:
compiler/proc_gen.m:
    Conform to the change to hlds_desc.m.

compiler/hlds_goal.m:
    Document when it is ok for traversals of goals to assume that
    they won't find any rhs_lambda_goals or complicated_unifys
    in unifications.

    Change the documentation of the five classes of unifications
    (construct/deconstruct/assign/simple_test/complicated_unify)
    to refer to the LHS as X and the RHS as Y, since pretty much
    all the modules focusing on unifications (such as superhomoneous.m)
    use that naming convention. Having the opposite convention here
    was not a good idea.

compiler/prog_data.m:
    Fix comment rot.
2022-09-25 18:04:20 +10:00
Zoltan Somogyi
a32d6a16f4 Add the format_call pragma to the language.
doc/reference_manual.texi:
NEWS:
    Document and announce the new pragma.

compiler/prog_data_pragma.m:
compiler/prog_item.m:
    Provide a representation for the new pragma. The part that ends up
    being referred to from the HLDS goes into prog_data_pragma.m,
    the part that is not needed once the HLDS has been constructed
    goes into prog_item.m.

compiler/hlds_pred.m:
    Add a slot to pred_infos for info from the new pragma.

    Fix a bug in the comment on marker_has_format_call.

compiler/add_pragma.m:
    Add the information in these pragmas to the HLDS.

compiler/check_pragma_format_call.m:
    A new module to check the validity of format_call pragmas.
    These checks test whether the arguments named in such pragmas
    have the expected types and modes, which means that
    the check must be done after both type and mode checking.

compiler/check_hlds.m:
compiler/notes/compiler_design.html:
    Add and document the new module.

compiler/hlds_module.m:
    Add a field to the module_info that records the set of pred_ids
    that have format_call pragmas.

compiler/mercury_compile_front_end.m:
    Invoke the check_pragma_format_call pass *provided* that
    the new field in the module_info says it has any pragmas to check.

compiler/parse_pragma.m:
    Add code to parse the new pragma.

compiler/format_call.m:
    Check calls to predicates and functions with the new pragma
    the same way as we check calls to string.format, io.format,
    and stream.string_writer.format.

    This required separating the code that checked calls to such predicates
    from the code that optimized calls to such predicates, since

    - a predicate or function with a format_call pragma that specifies
      more than one argument pair has to have its correctness checked
      for each pair, and

    - a predicate or function with a format_call pragma does not actually
      do any formatting, so that formatting cannot be optimized.

    Fix an old bug, where we included the function result in the function's
    reported arity, which meant that an error message could mention a call
    to a nonexistent function. As part of that fix, the error message
    now specifies whether it is complaining about a call to a predicate
    or a function.

    Change the exported interface of this module a bit
    in order to allow the factoring out of repeated code.

compiler/parse_string_format.m:
    Separate the parsing of format strings from their optimization,
    again because calls to predicates and functions with format_call
    pragmas need to be checked but cannot be optimized.

compiler/polymorphism.m:
    Record the effect on argument numbers of any type_info and/or
    typeclass_info arguments added by this pass.

compiler/convert_parse_tree.m:
compiler/det_analysis.m:
compiler/direct_arg_in_out.m:
compiler/equiv_type.m:
compiler/get_dependencies.m:
compiler/hlds_out_pred.m:
compiler/item_util.m:
compiler/module_qual.qualify_items.m:
compiler/parse_tree_out_pragma.m:
compiler/prog_item_stats.m:
compiler/recompilation.version.m:
compiler/simplify_proc.m:
    Conform to the changes above.

tests/invalid/bad_format_call.{m,err_exp}:
    A new test case to see whether check_pragma_format_call.m detects
    and reports invalid format_call pragmas as expected.

tests/warnings/format_call_warning.{m,exp}:
tests/warnings/format_call_warning_helper.m:
    A new test case to see whether we generate the expected set of error
    messages for incorrect calls to a predicate with a format_call pragma.

tests/invalid/Mmakefile:
tests/warnings/Mercury.options:
tests/warnings/Mmakefile:
    Enable the new test cases.

tests/invalid/string_format_bad.err_exp:
tests/invalid/string_format_unknown.err_exp:
tests/warnings/disabled_warning.exp:
    Expect the predicate vs function distinction to the printed in
    error messages about bad calls to formatting predicates and functions.
2022-09-24 08:42:36 +10:00
Mark Brown
16fdab788b Overhaul of the Syntax chapter of the reference manual
There are three main aims for this change:

1. Don't rely so much on users having knowledge of Prolog (ideally we
wouldn't require it at all, but this change probably doesn't fully achieve
that). Present the information more linearly, i.e., without requiring
so many forward references.

2. Make important information less likely to be overlooked. As it stands,
we give a lot of semantics in the Syntax chapter where users wouldn't
expect to find it (they're more likely to just skim over such a chapter).

3. Remove some inconsistencies in our descriptions and use of terminology,
and try to remove ambiguities.

Changes to terminology
----------------------

These are aimed at being more consistent, as well as dividing things up
into concepts that we need to refer to later on.

- A term is now a core term or a special term. The latter are for list
syntax, etc. Avoid the use of "is parsed as", the significance of which
is not clear, and instead define an equivalence relation via a term
normalization procedure.

- Define "functor" and "principal functor". Don't use "functor" to talk
about terms: the functor is defined as the name/arity pair. Also give
some synonyms we use for functor.

- Core terms are divided into variables, constants, and functor terms.
Functor terms are names on their own or names with arguments
(i.e., "functor terms" are those terms that have meaningful functors).

- "Higher-order terms" are now called "apply terms", since they aren't
necessarily higher-order themselves, and because that is a semantic
concept anyway.

- Data-terms are now referred to as expressions.

- Refer to "field access" rather than "record syntax". It's not made clear
that these are referring to the same feature, so it's better to stick to
one term (at least until full definitions are given).

Changes to document structure
-----------------------------

The Syntax chapter as a whole has been split into two chapters,
Syntax and Clauses. The new structure is as follows:

Syntax

- Additional sections are added for comments and line number directives.

- The Tokens section is split into token types (so that, e.g., variables
can be looked up quickly).

- "Operators" covers everything about operator syntax, not just builtin
operators.

- "Terms" covers the material previously in that section. It adds a summary
in the form of grammar rules (but makes it clear all the information is
also in the prose), and a term normalization procedure that is _not_
written in pseudo-Mercury. The grammar is there for people who are likely
to skip the prose but less likely to skip a grammar, and the prose is there
because that's the best way to describe things.

- "Items" covers the material previously in "Items", "Declarations",
"Facts", and "Rules".

Clauses

- Added an overview of Mercury semantics.

- "Goals" covers the same material as before, but I have rearranged the
order of the goals so as to avoid forward references, and to put more
commonly used goals earlier.

- "Expressions" covers the material previously in "Data-terms" and its
subsections. The expressions are (mostly) collected into one table, but
field access expressions are kept separate as they require a bit more
explanation. I've used an anchor on this separate bit, however, so maybe
it should be in a section that follows Expressions (i.e., Expressions
should say "see next section for details" or whatever).

- "State variables", "Variable scoping", "Implicit quantifiaction", and
"Elimination of double negation" are kept largely as is.

- "Definite Clause Grammars" is added which collects all the information
relating to DCGs.

Other changes
-------------

- Names now include sequences of graphic chars and a single semicolon,
which is what our parser actually allows.

- Use hyphens in meta-variables rather than underscore, per the texinfo
guidelines.

- Explain that operators are a syntactic concept and you need to import
a module to get, e.g., arithmetic operations. Point out the user defined
operator in the prose rather than in a footnote. And fix the formatting
of that table!

- Try to use a more consistent writing style.
2022-09-12 23:37:26 +10:00
Zoltan Somogyi
31ad9a21e1 Allow terms to be dumped as docs in mdb.
The usual mdb "dump" command puts every function symbol on its own line.
This guarantees that we generate any line that is too long to be displayed
on terminals, but it also generates output that is too stretched out
vertically for its structure to be readily apparent. Dumping the term
as a doc allows pretty_printer.m to put as many function symbols on a line
as would fit, without exceeding the maximum line length.

browser/browse.m:
    Add save_term_to_file_doc, a way to save a (possibly synthetic)
    browser term in a file, using an interface that works the same way
    the predicate that saves browser terms as XML.

    Inline a predicate at its only call site. Improve variable names.

trace/mercury_trace_browse.[ch]:
    Add MR_trace_save_term_as_doc, as an interface function between
    save_term_to_file_doc and the code of mercury_trace_cmd_browsing.c.

trace/mercury_trace_cmd_browsing.c:
    Add support for a new -p/--prettyprint flag to the mdb "dump" command,
    which asks for the given term to be dumped as a pretty_printer doc.

doc/user_guide.texi:
NEWS:
    Document the new option.

library/pretty_printer.m:
NEWS:
    Rename write_as_doc to write_doc_formatted, and fix its argument type.

tests/debugger/browser_test.inp:
    Dump a term that we already dumped with "dump" with "dump -x" and
    "dump -p" as well.

tests/debugger/browser_test.m:
    Put the code to remove the files we are going to dump to
    and then later to print the files we have dumped to into separate
    predicates. This keeps most (but not all) line numbers unchanged
    even though we now dump to more files.

tests/debugger/browser_test.exp3:
    Update this file to account both for the extra output from the just-added
    dump commands, and for the changes in line numbers.
2022-08-25 16:39:50 +10:00
Zoltan Somogyi
47ca4f9a66 Let disable_warning apply to unknown_format_calls.
doc/reference_manual.texi:
NEWS:
    Allow a disable_warning scope to override the setting of the
    --warn-unknown-format-calls option to "yes" inside its scope.

compiler/prog_data.m:
    Provide a representation for the new kind of disable-able warning.

compiler/parse_goal.m:
    Parse the new kind of disable-able warning.

compiler/prog_out.m:
    Print out the new kind of disable-able warning.

compiler/format_call.m:
    Add a parameter to the format checking code to control whether
    we generate this warning. Using this parameter yields clearer code
    that locally overriding the value of the option.

compiler/simplify_goal_scope.m:
    Ignore the new kind of disable-able warning in code that has nothing
    to do with it.

compiler/options.m:
doc/user_guide.texi:
    Fix an old issue: include stream.string_writer.format in the description
    of --warn-unknown-format-calls.

tests/warnings/disabled_warning.{m,exp}:
    Add a test of the new functionality.

tests/warnings/Mmakefile:
tests/warnings/Mercury.options:
    Enable the new test case.
2022-08-24 16:33:46 +10:00
Zoltan Somogyi
26be4bb8e3 Add --warn-ambiguous-pragmas.
The new option is on by default, and it generates a warning about pragmas
that specify a name/arity pair that matches both a predicate and a function,
but does not say which one it is intended to apply to.

compiler/options.m:
doc/user_guide.texi:
    Add the new option.

NEWS:
    Announce the new option.

compiler/add_pragma.m:
    Implement the new option.

    Move to one predicate, get_matching_pred_ids, the code for dealing with
    both the absence of any matches, and the presence of more than one match,
    when looking up name/arity pairs in the predicate table. This allows us
    to delete the mostly-duplicate code fragments that did the same thing
    in all of get_matching_pred_ids's callers.

    Simplify the handling of conflicts between marker pragmas.

compiler/hlds_pred.m:
    Separate out no_inline decisions made by the compiler itself from
    the similar decisions made by users, in order to allow that simplification.

    Move the two inline markers next to each other.

compiler/make_hlds_error.m:
    Change a predicate called from add_pragma*.m to take user arities
    in their semantic form, not their int form, which raises the level
    of the predicate's interface, and factors out duplicate code in its
    callers.

compiler/add_pragma_type_spec.m:
compiler/intermod.m:
compiler/table_gen.m:
    Conform to the changes above.

doc/reference_manual.texi:
    Document pred(...) and func(...) wrappers around name/arity pairs
    in pragmas.

    Delete the commented out section on reserve_tag pragmas, which were
    deleted a while ago.

tests/invalid/inline_conflict.m:
    Expand this test case to test the *absence* of a warning for an
    ambiguous pragma with --no-warn-ambiguous-pragma.

tests/invalid/inline_conflict_warn.{m,err_exp}:
tests/invalid/Mercury.options:
    Add a copy of the inline_conflict test case to test the presence of
    a warning for an actually ambiguous pragma.

tests/invalid_nodepend/fact_table_in_interface.err_exp:
    Expect the updated wording of a warning.
2022-07-31 18:17:02 +10:00
Julien Fischer
abc65f4d05 Improvements to the Java launcher scripts.
Add new options that allow Java runtime flags to be set in the launcher scripts
we generate for executables in the Java grade.

compiler/options.m:
     Add two new options: --java-runtime-flags and --java-runtime-flag
     that can be used to embed flags for the Java interpreter in the
     launcher scripts we generate for Java grade executables.

     Add --javac-flags and --javac-flag as synonyms for --java-flags
     and --java-flag respectively.

     Rename the corresponding values of the option/0 type to
     java_compiler_flags and quoted_java_compiler_flag respectively.

     Extend the documentation of --java-classpath to say that it also
     affects the Java launcher scripts.

compiler/module_cmds.m:
     Include any user-specified Java runtime flags in the launcher
     scripts.

compiler/compile_target_code.m:
     Conform to the above change.

doc/user_guide.texi:
     Document the above option changes and additions.

     Document how the launcher scripts interact with with the new
     options and also with --java-classpath.

NEWS:
    Announce the above changes.
2022-07-23 11:45:03 +10:00
Zoltan Somogyi
0e8018316d Clarify wording. 2022-07-06 14:32:54 +10:00
Zoltan Somogyi
e35a09542e Print two kinds of ambiguities only if asked for.
trace/mercury_trace_cmd_developer.c:
trace/mercury_trace_tables.[ch]:
    Add two options to the mdb command "ambiguity".

    Print ambiguities between function and predicate forms of the same
    operation, such as list.length, only if the new option -b, or
    --both-pred-and-func, is given.

    Print ambiguities involving procedures that were created by type
    specialization only if the new option -s, or --typespec is given.
    (The -t option name was already taken.)

    These changes remove from the ambiguity command's output
    (some of) the parts that are not useful when one wants to eliminate
    ambiguities by renaming.

    Clarify a heading.

doc/user_guide.texi:
    Document the above changes.

runtime/mercury_proc_id.h:
    Fix a field name that has become misleading.

    MR_UserProcId_Structs have a field named MR_user_arity.
    In this name, the "MR_user_" part is a prefix shared by the other
    fields in that structure, to indicate that they are part of the id
    of a user-defined procedure, as opposed to a compiler-created
    unify, compare or index procedure. However, the arity it contains
    is what the compiler now calls a pred_form_arity: it does not count
    type_info and typeclass_info arguments added by polymorphism, but
    it *does* count function return values for functions. This is now
    misleading, because in the compiler, a user_arity does *not* count
    function return values for functions.

    Replace this field name with MR_user_pred_form_arity, which tells
    readers that this arity is a pred_form_arity. The presence of the
    "user" part of the name may still cause some confusion, but at least
    that confusion should motivate readers to look up the field name,
    whose comment should clarify things.

mdbcomp/rtti_access.m:
runtime/mercury_debug.c:
runtime/mercury_deep_profiling.c:
runtime/mercury_ho_call.c:
runtime/mercury_layout_util.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_layout.h:
runtime/mercury_trace_base.c:
trace/mercury_trace.c:
trace/mercury_trace_external.c:
trace/mercury_trace_util.c:
    Conform to the change in mercury_proc_id.h.

tests/debugger/ambiguity.{m,inp,exp}:
tests/debugger/ambiguity_helper.m:
    Expand this test case to test the new functionality.
    The type specialized predicates are in a new helper module,
    because this is the simplest way to avoid dead procedure elimination
    deleting any of the predicates whose names we want to test for ambiguities.
2022-07-05 08:00:12 +10:00
Zoltan Somogyi
ee34187966 Don't print specialization requests with -V.
compiler/options.m:
doc/user_guide.texi:
    Introduce a new option, --debug-higher-order-specialization.

compiler/higher_order.m:
    Print messages about procedures being specialized to a specific
    higher-order value only if this new option is specified, not when
    -V is specified, since these messages are of interest only to people
    who are actively working on higher_order.m.

    Check whether the option is enabled just once, rather than performing
    that test, and possibly the creation of the progress output stream,
    once per specialization.
2022-05-13 19:24:09 +10:00
Zoltan Somogyi
189e426bc6 Extend debug messages from dead_proc_elim.m.
compiler/dead_proc_elim.m:
    If the new option --debug-dead-proc-elim is enabled, print information
    about why each procedure (actually any entity) we cannot delete
    is actually needed. This is the information we need when we want
    to find out why procedures that we think should have been deleted
    haven't been. This requires modifying the needed map to keep track
    of this information.

    Also, use the same option, instead of -V, to control whether we print
    messages about which predicates/procedures have been eliminated,
    since such messages are rarely of interest to anyone who is not actively
    working on dead_proc_elim.m.

    To allow these two sets of diagnostics to come out in the natural order
    (first what we need and why, and then what we could eliminate), don't
    print messages about what we eliminated as we go along. Instead,
    gather up a map of what we eliminated from each affected predicate,
    and print all the messages, in sorted order, at the end. Fix the
    messages themselves by avoiding phrasing such as "Eliminated the dead
    procedure function ...".

    Refer to procedures in entities using a pred_proc_id instead of
    separate pred- and proc_ids, to minimize the conversions required
    to the new data structures.

    Improve documentation.

compiler/options.m:
doc/user_guide.texi:
    Add the new developer-only option --debug-dead-proc-elim.

compiler/mercury_compile_middle_passes.m:
    Print the needed map and list of eliminated procedures only if
    the new option is enabled.

compiler/deep_profiling.m:
compiler/inlining.m:
    Conform to the changes in dead_proc_elim.m.

library/set_ctree234.m:
    Enable a sanity check only with the right trace flag.
2022-05-13 18:50:08 +10:00
Julien Fischer
3362159147 Fix Mantis bug #558.
Mmakefile:
    Ensure that the mercury_{compile,profile} executables exist
    *before* attempting to build the manual pages.

doc/Mmakefile:
    Rebuild the mprof.1 manual page if the profiler options.m
    file changes.
2022-04-21 19:34:00 +10:00
Julien Fischer
8731d16c74 Fix spelling.
compiler/options.m:
doc/user_guide.texi:
    As above.
2022-04-18 23:57:12 +10:00
Julien Fischer
8ef9073be2 Delete remaining references to --use-trail-segments.
doc/user_guide.texi:
extras/trailed_update/samples/Mmakefile:
extras/trailed_update/tests/Mmakefile:
samples/solver_types/Mercury.options:
scripts/init_grade_options.sh-subr:
    As above.

RELEASE_NOTES_NEXT:
    Delete item concerning the above.
2022-04-18 21:45:15 +10:00
Zoltan Somogyi
0186a64520 Warn for unneeded use of mode-specific clauses.
compiler/add_clause.m:
    Generate a warning for mode-specific clauses when the clause is for
    a predicate that has only one mode, provided that the warning is enabled.

compiler/options.m:
    Add an option to enable this warning.

doc/user_guide.texi:
    Document this option.

library/exception.m:
library/int.m:
library/rtti_implementation.m:
library/string.m:
    Delete modes from clause heads that would get this warning.

tests/valid/spurious_purity_warning.m:
    Delete modes from clause heads that would get this warning.

    Do not interleave predicate definitions.

tests/warnings/unneeded_mode_specific_clause.{m,exp}:
    A test case for this warning.
tests/warnings/Mmakefile:
    Enable the new test case.

tests/invalid/multimode_syntax.err_exp:
    Expect the new warning.
2022-04-13 23:39:23 +10:00
Zoltan Somogyi
172ae87fb9 Replace (C->T;E) with (if C then T else E). 2022-04-13 20:13:22 +10:00
Julien Fischer
513105d4bb Minor documentation fix.
doc/reference_manual.texi:
    Delete a stray full stop from a section header.
2022-04-11 16:00:56 +10:00
Julien Fischer
105580a765 Delete the trseg component and --trail-segments option.
Trail segments have been the default in trailing grades since Mercury 20.06.
Delete the trseg grade components and --trail-segment option since apart from
acting as synonyms for the tr component and --use-trail option repsectively,
they no longer do anything.

compiler/compute_grade.m:
compiler/handle_options.m:
compiler/options.m:
doc/user_guide.texi:
grade_lib/grade_vars.m:
scripts/parse_grade_option.sh-subr:
grade_lib/grade_string.m:
grade_lib/grade_vars.m:
   Delete the trseg grade component and --trail-segments option.

compiler/add_pragma.m:
   Update the wording of an error message.

NEWS:
   Announce the above.

extras/trail/Mercury.options:
extras/trailed_update/Mmakefile:
extras/references/Mercury.options:
tests/invalid/test_feature_set.err_exp:
    Conform to the above changes
2022-04-05 17:02:40 +10:00
Julien Fischer
03b1bcefe2 Minor corrections to reference manual.
doc/reference_manual.texi:
    As above.
2022-02-03 18:03:45 +11:00
Zoltan Somogyi
939c9cb063 Address Julien's review comments.
doc/reference_manual.texi:
    Give a reason why nonabstract instance declarations may not appear
    in interface sections. To make this reason understandable, delay it
    until we have discussed method definitions.

    Add an example of an abstract instance declaration with a typeclass
    constraint.

compiler/split_parse_tree_src.m:
    Improve the wording along lines suggested by Julien.

tests/invalid_nodepend/instance_bug.err_exp:
    Expect the updated wording.
2022-02-03 13:16:48 +11:00
Zoltan Somogyi
0b7282d701 Require non-abstract instances in interfaces.
doc/reference_manual.texi:
    As above. The compiler enforced this requirement since April 2005,
    but the manual was silent on the matter.

compiler/split_parse_tree_src.m:
    When we detect an abstract instance declaration in the interface section,
    extend the error message with a verbose-only mention of the usual fix.

tests/invalid_nodepend/Mercury.options:
    Turn on verbose errors for this test case, which tests this error message.

tests/invalid_nodepend/instance_bug.err_exp:
    Expect the new verbose component.
2022-02-03 10:56:54 +11:00
Zoltan Somogyi
1e9b97a57d Reword confusing sentence. 2022-01-27 03:50:20 +11:00
Zoltan Somogyi
87a05b7b95 Add the new option --output-stdlib-grades.
compiler/mercury_compile_main.m:
    Implement the new option. Doing so without duplicating the existing
    code tree of detect_libgrades required factoring out its reusable parts.

    Do not pass I/O states to computations that do not need them.

    Add XXXs for some questionable past decisions.

compiler/op_mode.m:
    Define the new op_mode selected by the new option.

compiler/options.m:
doc/user_guide.texi:
    Add and document the new option, and revert my screw-up of the
    documentation of --output-libgrades.

compiler/options_file.m:
    Make the interface of another predicate less error prone.

NEWS:
    Mention the new option.
2022-01-21 20:59:02 +11:00
Julien Fischer
70b7714198 Fix typo in user guide.
doc/user_guide.texi:
    As above.
2022-01-16 19:16:21 +11:00
Zoltan Somogyi
f4d1b90410 Fix a sentence. 2022-01-15 00:12:39 +11:00
Zoltan Somogyi
105f6fb4e5 Improve documentation of grade components. 2022-01-14 22:14:06 +11:00
Zoltan Somogyi
b89fb194f7 Fix indentation. 2022-01-14 21:50:48 +11:00
Zoltan Somogyi
6e11ee923f Improve documention of the query options.
compiler/options.m:
doc/user_guide.texi:
    As above. Also, fix some existing inconsistencies between these two files.
2022-01-14 21:43:03 +11:00
Julien Fischer
093018109c Update references to LIMITATIONS file.
BUGS:
README.md:
bindist/Mmakefile:
compiler/notes/release_checklist.html:
compiler/prog_data.m:
doc/reference_manual.texi:
library/list.m:
runtime/mercury_type_desc.h:
    As above.
2022-01-01 15:53:34 +11:00
Julien Fischer
b2e14c0b32 Update copyright notices for 2022.
LICENSE:
compiler/handle_options.m:
doc/*.texi:
profiler/mercury_profile.m:
trace/mercury_trace_internal.c:
        As above.
2022-01-01 13:48:16 +11:00
Zoltan Somogyi
bb1b900ba6 Check "for type_ctor" annotations on user insts.
NEWS:
doc/reference_manual.texi:
    Document the fact that the compiler now does such checks.

compiler/post_typecheck.m:
    When propagating types into insts, ask inst_mode_type_prop.m to check
    whether the types being propagated into user defined insts violate the
    "for type_ctor" annotations on those insts.

    Fix a bug in my earlier change. We want to propagate types into insts,
    and check for applications of insts to values of inappropriate types
    for lambda expressions. We used try to do it by traversing each procedure's
    body goal, but this did nothing, because we copy goals to procedure bodies
    in a pass that happens *after* the post-typecheck pass. During the
    post-typecheck pass, these lambda expressions exist only in the predicate's
    clauses, so that is where now we process them.

compiler/inst_mode_type_prop.m:
    The code in this module is called not just from post_typecheck.m,
    which needs this new check, but also from other modules, which do not.
    To avoid excessive performance impact on the latter, make the
    checking optional through a typeclass with two instances,
    one of which prepares for and then does the checking, while the other
    replaces all those operations with no-ops. Then use type_spec pragmas
    to create two versions of all the predicates using this type class,
    effectively creating two versions, one with the checks and the other
    without the checks.

    Change the name of all the exported predicates of this module
    to specify whether they do these checks or not.

compiler/inst_lookup.m:
    Conform to the changes above.

    Note a possible performance problem.

compiler/add_special_pred.m:
compiler/inst_user.m:
    Conform to the changes above.

tests/invalid/bad_type_for_inst.{m,err_exp}:
    A test case for the error messages.

tests/invalid/Mmakefile:
    Enable the new test case.
2021-12-30 23:39:20 +11:00
Julien Fischer
419feb0ba3 Add a missing word.
compiler/options.m:
doc/user_guide.texi:
    As above.
2021-12-21 12:48:08 +11:00