25234 Commits

Author SHA1 Message Date
Julien Fischer
c91d1ae787 Minor fixes for samples README.
samples/README.md:
    As above.
2026-01-20 20:06:00 +11:00
Julien Fischer
070d1fc661 Fix minor errors in the transition guide.
doc/mercury_transition_guide.texi:
    As above, these were identified by feeding the texinfo source
    for the manual into Gemini.
2026-01-20 19:57:37 +11:00
Julien Fischer
02625ad94b Fix minor errors in the reference manual.
doc/mercury_reference_manual.texi:
    As above, these were identified by feeding the texinfo source
    for the manual into Gemini.
2026-01-20 19:28:25 +11:00
Zoltan Somogyi
8583f96d25 Add unsigned versions of version_array2d operations.
library/version_array2d.m:
    For every predicate or function that takes an integer argument,
    if that integer is required to be non-negative, add an unsigned version.

    Add bounds checks to lookup (read) and set (write) operations.

    Improve the documentation of the exported operations.

    Add a new implementation of the function that returns the rows
    of the array as a list of lists.

    Improve variable names in operations that have new unsigned versions.

NEWS.md:
    Announce the new operations.

tests/hard_coded/version_array2d_test.{m,exp}:
    New test case to test the operation of version_array2d.m.
    It is based on the applicable parts of version_array_test.m,
    but with somewhat improved organization.

tests/hard_coded/Mmakefile:
    Enable the new test case.

tests/hard_coded/version_array_test.m:
    Minor style fixes.
2026-01-20 12:11:19 +11:00
Zoltan Somogyi
b6b4e85067 Add unsigned versions of version_array operations.
library/version_array.m:
    For every predicate or function that takes an integer argument,
    if that integer is required to be non-negative, add an unsigned version.

    Improve the documentation of the exported operations.

    Improve variable names in operations that have new unsigned versions.

NEWS.md:
    Announce the new operations.

tests/hard_coded/version_array_test.m:
    Modify this test case to test the new operations.
2026-01-19 19:27:50 +11:00
Zoltan Somogyi
280db1b10e Describe the reason for the mode_error_info type. 2026-01-19 14:30:49 +11:00
Zoltan Somogyi
a45c8e7f33 Clarify some comments.
And delete an obsolete comment.
2026-01-19 14:30:16 +11:00
Zoltan Somogyi
c2e5b8aac1 Improve some variable names. 2026-01-19 14:29:36 +11:00
Zoltan Somogyi
f7a0e88d89 Minor improvements to compiler_design.html.
List the top modules of the make.m package first,
and the utility and data structure modules last.

Mention the deleted backends.

Improve wording in several places.

Fix some cut-and-paste errors.
2026-01-19 14:01:38 +11:00
Julien Fischer
ce26cc1928 Minor fix to compiler_design doc.
compiler/notes/compiler_design.html:
    As above.
2026-01-19 11:33:58 +11:00
Julien Fischer
f2568d8708 Fix a link.
Documentation/README.MS-VisualC.md:
    As above.
2026-01-16 03:17:35 +11:00
Julien Fischer
1c8ee26b67 Update a pointer.
.INSTALL.in:
   As above.
2026-01-16 02:45:19 +11:00
Julien Fischer
7b1ffd585f Minor updates for the INSTALL script.
.INSTALL.in:
    s/Mac OS X/macOS/

    Mention MSYS2 instead of MinGW.
2026-01-16 02:35:34 +11:00
Julien Fischer
40b762cf91 Further revisions to README.MSYS2.md.
Documentation/README.MSYS2.md:
    Provide an overview of the different MSYS2 environments and what
    they provide from the perspective of installing and using Mercury.

    Describe how to install and use Mercury in the MSYS environment.

    Describe how to install Mercury in the CLANG64 environment.

    Extend the coverage of running Mercury at the Windows Command Prompt, to
    cover Mercury compilers built in the CLANG64 and MINGW32 environments.

    Describe installation prefix path problems in more detail.

    Lots of minor improvements.
2026-01-16 02:19:25 +11:00
Zoltan Somogyi
86b33fbd40 Gather statistics about switch search depth results.
compiler/switch_detection.m:
    Add conditionally-enabled code to gather statistics about
    what happens when a switch candidate has disjuncts left over,
    and we test whether these leftovers form a switch on another variable.
    (The results show that after 99.91% of switch candidates,
    there are *no* disjuncts left over.)

compiler/mercury_compile_main.m:
    Invoke the predicate that writes out any statistics we gathered.

tools/switch_depth:
    This new summarizes the results.
2026-01-15 10:45:35 +11:00
Zoltan Somogyi
5063ff4a98 Use the pred form of cord.snoc where appropriate. 2026-01-15 05:52:08 +11:00
Zoltan Somogyi
d13f25ae2f Compute the best candidate as we go along.
compiler/switch_detection.m:
    As above.

compiler/switch_candidates.m:
    Adapt the underlying infrastructure.
2026-01-15 05:00:52 +11:00
Zoltan Somogyi
5e4c35505d Add a utility function. 2026-01-15 04:59:20 +11:00
Zoltan Somogyi
6e68a47ad8 Requantify a procedure body only if needed.
compiler/switch_candidates.m:
    Some ways of transforming disjunctions into switches call for
    duplicating code. Any variables local to duplicated code must be
    renamed apart by quantification. We used to set a flag calling for
    the requantification of the procedure body when finding a switch
    candidate that calls for such code duplication. However, this is wrong:
    we only need to requantify the procedure body if such a switch candidate
    is *actually selected*. Fix this, mostly to clarify the code, though
    the avoiding unneeded requantification is also a (minor) performance win.

compiler/switch_detection.m:
    Record *with each switch candidate* whether it calls for requantifying
    the procedure body if it is selected.
2026-01-14 16:12:30 +11:00
Zoltan Somogyi
05f9dfcbd3 Update copyright year. 2026-01-14 13:01:34 +11:00
Julien Fischer
28fa62c5dc Fix doubled-up word.
compiler/builtin_ops.m:
    As above.
2026-01-13 17:51:22 +11:00
Julien Fischer
df0c194d06 Rename a README file.
Documentation/README.Docker:
   Rename -> README.Docker.md. This file was already in Markdown
   format.

   Adjust heading levels.

   Fix a broken link.

README.md:
    Conform to the above change.
2026-01-13 17:30:27 +11:00
Julien Fischer
0515f96e4c Sync licenses with latest upstream revisions from the FSF.
Use the latest revisions of the GPL version 2 and LGPL version 2 text from the
FSF. This replaces out-of-date addresses and the assumption that the year
begins with 19.

COPYING:
COPYING.LIB:
    As above.
2026-01-13 17:15:06 +11:00
Julien Fischer
efdcd8e21a Convert another README to Markdown.
Documentation/README.x86.md:
   As above.

   Move the the bit about x86-64 not being affected by the issue
   described in this file from the bottom to the top.

Documentation/README.Linux.md:
   Add a pointer to the README.x86.md file.

README.md:
   Conform to the above change.
2026-01-13 16:45:12 +11:00
Julien Fischer
ae47f9df28 Make some examples copyable.
Documentation/README.CSharp.md:
    As above.
2026-01-13 16:29:55 +11:00
Julien Fischer
4ffe3475c9 Convert another README to Markdown.
Documentation/README.Linux-m68k.md:
    As above.

    Mention that this port has not been tested (to the best of my knowledge)
    since 1998.

Documentation/README.Linux.md:
    Add a link to the Linux/m68k README.

README.md:
    Update a link.
2026-01-13 16:25:59 +11:00
Zoltan Somogyi
3f58eabe9f Delete the allow_multi_arm_switches internal option.
The compiler has had no code to set it from its default value of "yes"
to "no" since the Erlang backend was deleted in October 2020.

compiler/options.m:
    Delete the option.

compiler/handle_options.m:
    Delete an (incorrect) reference to the option.

compiler/switch_detection.m:
    Stop paying attention to the option.

tests/warnings/help_text.err_exp:
    Stop expecting documentation of the option.
2026-01-13 15:22:12 +11:00
Julien Fischer
fc40e05a00 Fix bitrot in a README.
Documentation/README.Linux.md:
    As above.
2026-01-13 15:18:13 +11:00
Julien Fischer
593c67c174 Convert another README to Markdown.
Documentation/README.Linux:
    As above.

README.md:
    Conform the above change.
2026-01-13 15:15:35 +11:00
Julien Fischer
ca719a38ea Fix quoting in a spot.
Documentation/README.Linux-PPC.md:
    As above.
2026-01-13 15:05:06 +11:00
Julien Fischer
b526e95db5 Adjust markup.
Documentation/README.Linux-PPC.md:
    As above.
2026-01-13 15:03:23 +11:00
Julien Fischer
ef589651f8 Convert another README to Markdown.
Documentation/README.Linux-PPC:
    Rename -> README.Linux-PPC.md:

    Convert this file to Markdown.

    Make the note at the head of this file a bit stronger.

    Delete a dead link.

README.md:
Documentation/README.Linux:
    Conform to the above change.
2026-01-13 15:01:22 +11:00
Julien Fischer
0035d6d23d Delete --with-msvcrt configure option.
The --with-msvcrt option was intended for selecting between the older Microsoft
C runtime (crtdll.dll) and the Microsoft Visual C runtime (msvcrt.dll). This is
all now ancient history, since the MSVCRT itself has been superseded by the
Universal C runtime since Windows 10. Delete the --with-msvcrt option and all
uses of it.

configure.ac:
    Delete the --with-msvcrt option.

scripts/mgnuc.in
scripts/ml.in:
    Delete uses of the above configuration value.

Documentation/README.MS-VisualC.md:
    Delete references to --with-msvcrt.
2026-01-13 14:10:09 +11:00
Julien Fischer
41328b42b2 Minor corrections.
compiler/hlds_goal.m:
    Fix spelling.

compiler/handle_options.m:
compiler/mercury_compile_front_end.m:
compiler/source_file_map.m:
compiler/unused_imports.m:
    Fix doubled-up words.
2026-01-12 23:36:24 +11:00
Peter Wang
9f84fec4f5 Fix bug with direct-arg ctors and intermodule optimisation.
If the compiler decides that a du type should use the direct-arg
representation for some of its constructors, it must include information
about that into the .opt file of the module defining the type, in the
form of `where direct_arg is' clauses, which will be used by modules
opt-importing that module and that type. That information was not being
included for du types defined in the *interface* section of a module.

Also fix a related issue that was uncovered: a word_aligned_pointer
assertion on a foreign_type definition would have no effect if there is
a no-tag du type definition for the same type constructor.

compiler/intermod.m:
compler/intermod_decide.m:
    Make should_opt_export_type_defn and some_type_needs_to_be_written
    succeed for `status_exported' du type definitions with direct-arg
    constructors. While `status_exported' suggests those type
    definitions would be redundant in .opt files, the information about
    the direct-arg constructors is not redundant.

compiler/du_type_layout.m:
    Add a is_word_aligned_ptr() value to the ComponentTypeMap if a
    no-tag du type also has a foreign_type definition for the current
    target language with a word_aligned_pointer assertion. Previously,
    this was only being done for single ctor NON no-tag du types.

    Add a XXX mentioning that we silently ignore word_aligned_pointer
    assertions in other cases.

tests/hard_coded/Mercury.options:
tests/hard_coded/Mmakefile:
tests/hard_coded/direct_arg_opt.m:
tests/hard_coded/direct_arg_opt_helper_1.m:
tests/hard_coded/direct_arg_opt_helper_1.direct_arg_opt_helper_2.m:
tests/hard_coded/direct_arg_opt.exp:
    Add a test case.
2026-01-12 11:33:56 +11:00
Zoltan Somogyi
81cafc5928 Improve code readability. 2026-01-11 10:12:47 +11:00
Zoltan Somogyi
b071f84f81 Assign goal_ids in the scout disjunctions pass ...
... reducing the number of procedure body traversals by one,
and avoiding the unneeded construction of the containing goal map.
2026-01-11 07:26:49 +11:00
Zoltan Somogyi
635b2268fe Improve handling of from_ground_term_deconstruct scopes.
compiler/hlds_goal.m:
    Document that all goals inside from_ground_term_deconstruct scopes
    are not just unifications, but unifications whose right hand sides
    are rhs_functors.

compiler/constraint.m:
    Fix a potential problem, which is that pushing a constraint into
    from_ground_term_{deconstruct,other) scopes can invalidate
    their invariants.

compiler/goal_refs.m:
    Fix a comment.

compiler/lco.m:
    Qualify a call.

compiler/modecheck_goal.m:
    Fix a misleading predicate name, and typos.

compiler/try_expand.m:
    Exploit the newly-documented invariant about from_ground_term_deconstruct
    scopes.
2026-01-11 03:57:52 +11:00
Zoltan Somogyi
77017dcbcb Put related predicates together. 2026-01-10 14:57:24 +11:00
Zoltan Somogyi
17f0230447 Carve three new modules out of switch_detection.m.
Simplify the interfaces between the new modules and switch_detection.m.

compiler/scout_disjunctions.m:
    New module containing the part of the old switch_detection.m
    that scouts disjunctions ahead of the main pass in bulk.

compiler/find_bind_var.m:
    New module containing the part of the old switch_detection.m
    that scouts disjunctions as *part* of the main pass, piecemeal.

compiler/switch_candidates.m:
    New module containing the part of the old switch_detection.m
    that recognizes candidate switches, and chooses the best switch
    if there is more than one candidate.

compiler/switch_detection.m:
    Delete the moved code. Conform to the interface simplifications.

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

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

compiler/hlds_out_goal.m:
    Add the capability to format a case as a string.
2026-01-10 10:40:43 +11:00
Julien Fischer
a52090b1e7 Fix broken link (properly this time).
NEWS.md:
    As above.
2026-01-09 20:46:17 +11:00
Julien Fischer
a680c9e560 Fix broken link.
NEWS.md:
    As above.
2026-01-09 20:45:13 +11:00
Zoltan Somogyi
950edaa6c9 Describe each cluster of related library modules. 2026-01-08 22:58:17 +11:00
Zoltan Somogyi
9ef5357c60 Improve readability. 2026-01-08 12:29:27 +11:00
Zoltan Somogyi
a0d5c3590f Fix two (or three) C# test case failures.
tests/invalid_nodepend/Mercury.options:
    Prevent two test cases, fundeps_vars and require_tailrec_invalid,
    from stopping after the creation of their .int files finds errors.
    Continue on to the code generation stage, where the errors that
    these test cases for are detected. (The fix is needed only for
    bootchecks that use mmc --make.)

tests/EXPECT_FAIL_TESTS.csharp:
    Recognize that hard_coded/functor_ho_inst_excp_1 is expected to fail
    in C# grades. This test case was already on the expected-to-fail list,
    but under its old name, functor_ho_inst_excp, which was not updated
    when the name was changed.
2026-01-08 09:57:54 +11:00
Zoltan Somogyi
a94ac41af2 Fix a comment. 2026-01-08 09:16:16 +11:00
Zoltan Somogyi
3c5f1a907b Put the contents of this file into meaningful order. 2026-01-08 06:10:14 +11:00
Zoltan Somogyi
928fd04f5a Update the style of this Mmakefile. 2026-01-08 03:59:52 +11:00
Zoltan Somogyi
94fadf1797 Add uint versions of array operations.
library/array.m:
    Add uint versions of most of this module's operations.

NEWS.md:
    Mention the new operations.

library/edit_distance.m:
    Use the new array operations to eliminate some casts.

library/edit_seq.m:
    Minor style fix.

tests/hard_coded/array_gen.{m,exp}:
tests/hard_coded/array_test_2.{m,exp}:
    Extend the tests of array.m's operations to the corresponding uint
    versions. Expect the output for the new versions.

tests/hard_coded/array_resize.m:
tests/hard_coded/array_shrink.m:
    Extend the tests of array.m's operations to the corresponding uint
    versions, but generate output only if their results differ from the
    original int versions. (They don't differ.)

tests/hard_coded/array_primitives.m:
    Style fixes.
2026-01-08 03:47:09 +11:00
Julien Fischer
f1cc066ab0 Remove workarounds for depend_ints on Windows.
The changes to file copying in the compiler in early 2024 mean that we no
longer encounter the same performance problems these workarounds were put
in place to avoid.

compiler/Mmakefile:
library/Mmakefile:
    As above.
2026-01-07 16:55:55 +11:00