Address review comments.

compiler/options.m:
doc/user_guide.texi:
	Address review comments from Zoltan.
Add require_switch_arms_{det,semidet,...} to the language.

The new construct looks like this:

    require_switch_arms_det [C] (
        (
            C = 'a',
            ... compute Out ...
        ;
            C = 'b',
            ... compute Out ...
        )
    )

If any of the goals computing Out are not det, the compiler will generate
an error message. The det at the end of the keyword can be replaced
by any of the other seven determinisms, though I don't think either
require_switch_arms_failure or require_switch_arms_erroneous will see much use.

This diff adds only the implementation. I will add the documentation
and the NEWS item after we all had a chance to install this diff and
try it out.

compiler/hlds_goal.m:
    Add a scope representing this kind of goal in the HLDS.

compiler/prog_item.m:
    Add a goal expression for this kind of goal in the parse tree.

compiler/prog_io_goal.m:
    Look for the new kind of goal expression in terms when creating
    the parse tree.

    Factor out some commonalities between the parsing of the new goal
    expression and existing types of goal expressions.

compiler/goal_expr_to_goal.m:
    Convert the new kind of goal expression to the new scope in the HLDS.

compiler/det_report.m:
    Implement the checks that the new goal type calls for.

    Factor out some commonalities between the implementation of the new goal
    type and existing goal types.

    Move the types and predicates dealing with comparisons of determinisms
    from here to prog_data.m, due to the sort-of-bugfix to modecheck_call.m.

compiler/prog_data.m:
    Move the types and predicates dealing with comparisons of determinisms
    from det_report.m to here. The old code for this was intended for only one
    requirement, and did not deal well with comparisons of two determinisms
    in which each determinism makes an assertion the other does not make.
    Create a way to represent such comparison results.

compiler/modecheck_call.m:
    When deciding which mode of a procedure to call, we prefer determinisms
    that make more assertions about solution counts. However, when comparing
    incomparable determinisms (such as semidet vs multi, each of which makes
    an assertion the other doesn't), the algorithm chose based solely
    on the ORDER of the modes. We now explicitly prefer modes that promise
    lower maximum solution counts, giving less importance to cannot_fail
    assertions.

compiler/*.m:
    Conform to the change to hlds_goal.m or prog_item.m.

library/ops.m:
    Add the new keywords as operators.

tests/hard_coded/require_scopes.{m,exp}:
    Extend this test case to test the new construct in the absence of errors.

tests/invalid/require_scopes.{m,exp}:
    Extend this test case to test the new construct in the presence of errors.
Fix some overlong lines.
Speed up updating mode_infos.

compiler/mode_info.m:
    If the new value of a field of mode_info is likely to be bit-identical
    to the old value, then test the old and new bits for equality in the
    setter, and if they are the same, do not allocate a new mode_info structure
    that is guaranteed to be the same as the old one.

    By avoiding unnecessary memory turnover, this speeds up the compiler
    by about 4%, as measured by tools/speedtest -l.
Generate better error messages for string.format.

library/string.format.m:
    We used to parse format strings, and pair up format specifiers with
    the list of input poly_types, using semidet code, throwing
    exceptions with generic messages if the semidet code failed.
    This diff switches to using det code that returns a list of
    situation-specific error messages. Since errors after the first
    may be caused by the first error, we now throw exceptions whose
    message is a detailed description of the first error, but that
    decision is easily changeable.

    Simplify some existing code.

tests/general/string_format_test_{2,3}.{exp,exp2,exp3,...}:
tests/invalid/string_format_bad.err_exp:
tests/invalid/string_format_unknown.err_exp:
    Update the expected error messages.
Fix an old bug in mercury_float.h.

runtime/mercury_float.h:
    As above.
Impose a structure on library/string.m.

library/string.m:
    Group the predicates in this module into groups of related predicates,
    and put those groups of predicates into a logical order. Document
    this order.

    Remove some unnecessary promise_equivalent_clauses declarations.

    Give some variables and predicates better names, e.g. change the _2
    suffix on predicates that do loops to _loop.

    Move a predicate to string.format.m, since it is not exported, and
    it is not used anywhere else.

    Avoid overlong lines.

library/string.format.m:
    Add the moved predicate, with a better name and better variable names.
Clean up string.format.m some more.

library/string.format.m:
    Provide target predicates that format_call.m can call.

    Assume that we are running on at least a 32 bit platform.

    Convert (C->T;E) to (if C then T else E).

    Shorten too long lines.
Resolve the things I noticed cleaning up string.m.

library/string.m:
    Document why line and text_file are here.

    Clarify comments about surrogate code points.

    Document codepoint vs code_point.

    Remove the workaround for a very old bug in egcs.
Optimize the det_info structure.

compiler/det_util.m:
    Delete three fields from the det_info structure. Apparently they
    haven't been used for some time now.

    When updating other fields that are likely to be set to the old value,
    check whether the new value is the same as the old, and avoid allocating
    a new det_info structure if it is.
Document the new require_switch_arms_* scopes.

doc/reference_manual.texi:
    As above.

NEWS:
    Announce the new scopes.
Fix an old copy-and-paste bug.
Fix an old bug.

compiler/make_goal.m:
    Assignments are supposed to be det, not semidet. The only reason why
    this hasn't been caught before was that the only call site that could
    call make_simple_assign was never actually reached.
Update the list of the compiler's largest modules.
Standardize divider line lengths in the library.

library/*.m:
    As above.

tool/stdlines:
    A new shell script to do the job.
Factor out commonalities in builtin ops.

compiler/builtin_ops.m:
    Replace a flat list of clauses, one for each mode of each builtin
    predicate, with a nested set of switches that shows their relationships.

    Specialize the module's interface to the two uses cases the callers
    need: testing to see if a predicate is a builtin, used when setting
    the builtin_status of call goals, and actually generating code, used
    by the various backends.

compiler/hlds_pred.m:
    Switch to using the interface predicate for the first use case.

compiler/bytecode_gen.m:
compiler/call_gen.m:
compiler/erl_call_gen.m:
compiler/ml_call_gen.m:
    Switch to using the interface predicate for the second use case.
Specialize ALL calls to string.format and io.format.

Previously, we specialized calls to string.format and io.format only if
the format string specified no flags, widths, precisions or non-default
bases for any conversion. We now specialize calls to those predicates
regardless of the format string. To make this possible, we now have two
copies of the code to parse format strings.

library/string.parse_runtime.m:
    This new module, carved out out library/string.format.m, contains
    one of those copies. As the name suggests, this copy is used by
    the runtime system.

compiler/parse_string_format.m:
    This new module contains the other copy. As its location suggests,
    this copy is used by the compiler. The separate copy is necessary
    because the compiler's parsing needs are different from the runtime's.

    The main reason for the separation is that the compiler needs to be
    able to handle cases where widths and predicates are given by manifest
    constants, as well as when they are given by the values of variables
    at runtime (when the format string contains conversion specifiers
    such as "%*d"). Having the runtime handle this extra complexity
    would have inevitably increased the runtime's format string interpretation
    overhead, which is undesirable.

    The other reason is that compiler can afford to postprocess the result
    of the parsing in order to avoid having to concatenate two or more
    constant strings at runtime.

library/string.parse_util.m:
    Types and predicates that are common to the library and compiler copies
    of the format string parsing code.

compiler/format_call.m:
    We used to check whether format strings match the supplied list
    of values to be printed by invoking string.format on dummy inputs
    of the supplied types, and seeing whether you got an exception.
    We now call parse_string_format.m instead. Not only does this
    avoid shenanigans with exceptions (which the deep profiler cannot
    yet handle), but it also allows us to specialize all calls
    to string.format and io.format. We therefore do so.

    We used to specialize calls to io.format by creating a single string
    to be printed (using the machinery needed to specialize calls to
    string.format), and then printing that. This did unnecessary memory
    allocations to hold the intermediate strings. We now simply print
    each component one after the other, which avoids this overhead.

library/string.format.m:
    Add versions of the predicates that print chars, strings, ints and floats
    that are specialized to each possible situation about whether the caller
    specifies a width and/or a precision. This means that format_call.m
    doesn't have to generate code that allocates cells on the heap.

    Remove the code that was moved to new submodules of string.m.

compiler/simplify_proc.m:
    List the predicates in string.format.m that the compiler
    may generate calls to in the list of such predicates that we maintain
    to prevent dead_pred_elim from deleting them before format_call.m
    gets a chance to do its work.

compiler/module_imports.m:
    If the code of the module calls a predicate named "format" that
    may refer to string.format or io.format, then implicitly import
    the modules that contain the types and predicates that the code
    generated by format_call.m will refer to. Note that since this
    module_imports.m works on Mercury code that has not been module
    qualified yet, we have to use a conservative approximation.

    Reorganize the way we discover what library modules we have to
    implicitly import. Instead of a separate boolean for each piece
    of functionality that needs an implicit import, put them together
    into a structure. Due to Peter's work on argument packing some
    years back, this is now more efficient as well as more convenient
    that passing around a bunch of booleans. Also switch to passing
    around the structure as an accumulator, instead of having to do
    bool.ors all over the place.

    Since the code for computing the list of modules to be implicitly
    imported can sometimes add a library module to the list twice,
    sort that list and remove any duplicates.

    To make this possible, remove the version of the main predicate
    that appends the implicitly imported module names to a list of
    module names passed by our caller, since we don't want to sort
    THAT list of module names.

    Give the remaining version of that predicate that does this
    a name that better matches the names of related predicates.

compiler/modules.m:
    Conform to the change in module_imports.m. Mark some suspicious code
    with XXXs.

    Remove some redundant comments.

compiler/options.m:
doc/user_guide.texi:
    Add a new option that tells format_call.m what it should do
    when it finds more than one problem with a format string: whether
    it should print a message only for the first problem, or for all
    the problems. (The default is the latter.)

library/MODULES_DOC:
    A list of the all the Mercury source files in the library that
    should be included in the user guide.

library/MODULES_UNDOC:
    A list of the all the Mercury source files in the library that
    should NOT be included in the user guide.

library/library.m:
    Include the new publicly visible new submodule of string.m,
    (string.parse_util). And both string.parse_util and string.parse_runtime
    (which is NOT visible from outside string.m) to the list of modules
    in the Mercury standard library.

    Update the rules for where new library modules should be documented
    to account for non-publically-visible submodules, which we haven't had
    before. Document the need to include new modules in either MODULES_DOC
    or MODULES_UNDOC.

mdbcomp/builtin_modules.m:
    Provide convenient access for format_call.m to the names of the
    submodules of string.m that it needs access to.

library/Mmakefile:
    Add a new target, check_doc_undoc, which checks whether any source files
    are missing from MODULES_DOC or MODULES_UNDOC.

doc/Mmakefile:
    Read the list of modules to be documented from MODULES_DOC. This replaces
    old code that tried to list all the undocumented modules, but missed one:
    it referred to erlang_conf.m instead of erlang_builtin.m.

    When creating the library documentation, filter out any lines that
    contain the string NOTE_TO_IMPLEMENTORS. We now use this mechanism
    to include reminders to implementors in what would otherwise be a
    publically visible part of string.m.

tools/bootcheck:
    Copy MODULES_DOC and MODULES_UNDOC to the stage 2 and 3 library
    directories, since the check_doc_undoc target, which is invoked by
    "make all" in the library directory, needs them.

compiler/hlds_out_module.m:
    When dumping out the table of types, dump out discriminated union types
    in a style that follows our recommended coding style.
Optimize access to poly_infos.

compiler/polymorphism.m:
    Remove a field in poly_infos that wasn't being used. (It contained
    the pred_info.)

    Put the remaining fields into a more logical order.

    Remove unused setter predicates for read-only fields.

    For some setter predicates of the poly_info, the value being written
    is frequently the same as the old value in the written-to field.
    Make these setter predicates not do the update if it is unnecessary.

    Provide a predicate to set the rtti_varmaps at the same time as the
    varset and vartypes, since these are usually updated together, and
    this way we can avoid generating the intermediate poly_info.

    If we know in advance what the name of a new type_info variable should be,
    create it directly with that name; don't created with a different name,
    just to rename it immediately after.

    Give some predicates and variables more meaningful names.

tools/speedtest:
    Add an option, -m (for mix), that executes each under-test version
    of the compiler once before going back to repeat. This minimizes
    the probability that automatic speed throttling of the CPU (due
    e.g. to overheating) will systematically skew the timing results.
    If the executions of the different versions being tested is mixed
    together, any skew from throttling will have effects that are
    mostly random, not systematic.
Optimize updates to goal_infos.

compiler/polymorphism.m:
    For some setter predicates of the goal_info, the value being written
    is frequently the same as the old value in the written-to field.
    Make these setter predicates not do the update if it is unnecessary.
Make pointer_equal a builtin.

There was an inline pragma on its definition, but most programs, including
the compiler, are (most of the time) not compiled with the intermodule
optimization options that would allow this to take effect. Making it a builtin
gets around this "problem".

compiler/builtin_ops.m:
    Add private_builtin.pointer_equal as a builtin op.

    Factor out some more commonalities between existing builtin ops.

compiler/bytecode.m:
    Add the new pointer_equal_conservative op. The bytecode backend
    doesn't handle it, but then again, it doesn't handle really anything
    else either.

compiler/c_util.m:
    Handle the new operator, including adding a new category for it.

compiler/llds.m:
compiler/ml_global_data.m:
    Record the output type of the new operator.

compiler/llds_out_data.m:
    Generate code for the new operator for the LLDS backend.

compiler/mlds_to_c.m:
compiler/mlds_to_cs.m:
compiler/mlds_to_java.m:
compiler/mlds_to_il.m:
    Generate code for the new operator for the MLDS backend
    when targeting C, C#, Java and IL respectively. The IL version
    just aborts, since I don't know IL well enough to know what
    code to generate for "false" (the conservative approximation,
    also used for Erlang), but this should be ok, since the backend
    is not functional anyway.

compiler/erl_call_gen.m:
    Generate code for the new operator for the ELDS backend.
    The code we generate always returns false, which is allowed by the
    operator, since this is a conservative approximation.

    Start using require_complete_switch to ensure that we handle all
    operators. Add code to handle the old operators that this code
    did not used to handle.

compiler/java_util.m:
    Add an XXX comment about a scheme to handle operators that does not allow
    anything similar to such a require_complete_switch.

compiler/opt_debug.m:
    Pretty print the new operator.

compiler/options.m:
    Allow the definition of builtins such as pointer_equal while this
    change is bootstrapped.

library/private_builtin.m:
    Remove the inline pragma from pointer_equal, because the compiler
    can't handle such a pragma for a builtin, even when being bootstrapped.
    This could be fixed, but isn't worth the bother. A compiler builtin
    is like an inline pragma that works even without intermodule optimization.