Fix --link-object <archive> with --restricted-command-line.

When --restricted-command-line is enabled, we try to shorten the link
command by creating a temporary archive of object files, including files
specified with --link-object.  --link-object can also be used to specify
archives (.a) to link with, which results in nested archives in the
temporary archive.  The linker does not look for object files in nested
archives so it does not work as intended.

compiler/compile_target_code.m:
	Create the temporary archive for --restricted-command-line
	consisting of only the file names in ObjectsList with known
	object file extensions.  Pass any other names in ObjectsList
	to the link command directly.
Document that --link-object and MLOBJS may specify archives.

It was not explicitly stated that --link-object and MLOBJS may specify
archives to link with.  The Mercury build system uses that fact, the
documentation contains some examples doing so, and it has been a
consideration since at least commit eadcd7ab00ca5599f4bc371803afd5b106c581f6,
so document it as a supported feature.

compiler/options.m:
doc/reference_manual.texi:
doc/user_guide.texi:
	Mention archives in --link-object and MLOBJS documentation.
Minor cleanup before fixing Mantis bug 351. (This is NOT the bug fix.)

compiler/hlds_pred.m:
    Replace some uses of booleans in proc_infos with specialized types.
    Put the fields involved into a more logical order. Give their access
    predicates more meaningful names.

    When creating new proc_infos, give names to all the arguments of
    proc_infos and proc_sub_infos. (I believe Mantis bug 351 is in
    these arguments.)

compiler/hlds_module.m:
    Use the new types in hlds_pred.m where relevant.

compiler/parallel_to_plain_conj.m:
    Add some conditionally combined debugging output that helped me track down
    the problem.

compiler/loop_inv.m:
mdbcomp/mdbcomp.goal_path.m:
    Minor cleanup of some comments.

compiler/code_info.m:
compiler/deforest.m:
compiler/dep_par_conj.m:
compiler/distance_granularity.m:
compiler/granularity.m:
compiler/hlds_out_pred.m:
compiler/inlining.m:
compiler/introduce_parallelism.m:
compiler/lambda.m:
compiler/mark_tail_calls.m:
compiler/mercury_compile_middle_passes.m:
compiler/par_loop_control.m:
compiler/proc_gen.m:
compiler/simplify_goal_call.m:
compiler/simplify_goal_conj.m:
compiler/simplify_info.m:
compiler/simplify_proc.m:
compiler/trace_gen.m:
compiler/trace_params.m:
    Conform to the changes above.
Avoid some C compiler warnings in the trace directory.

trace/mercury_trace.h:
    Avoid a warning from the C compiler about casting -1 to an enum
    by adding bool next to the enum that says whether the enum is actually
    defined, or is supposed to be set later (the latter is what the cast -1
    meant).

trace/mercury_trace_cmds.h:
    Rename the type MR_Trace_Command_Info to MR_TraceCmdTableEntry,
    since this (a) says more about the values of the type, (b) avoids
    confusion with the separate MR_TraceCmdInfo type (the one that
    contained the enum mentioned above), and (c) avoids combining
    underscores with CamelCase.

trace/mercury_trace_spy.c:
    Avoid some warnings about switches on enums specifying -1 as a case.

trace/mercury_trace.c:
trace/mercury_trace_*.[ch]:
    Conform to the above changes.
Make filling in goal ids faster.

compiler/goal_path.m:
    When filling in the goal ids in a procedure body, avoid building 234 trees
    that we have keep modifying. Build a simple list, and convert it to a
    234 tree all at once at the end. Repeated insertions into a 234 tree
    leave several garbage cells behind per insertion (at least one per level of
    the tree), whereas our new method leaves just one pair cell and one cons
    cell per goal id.
Fix the has_parallel_conj field of generated procedures (Mantis bug 351).

The event sequence that lead to the compiler abort in Mantis 351 was:

1 With -O5 --intermod-opt, the loop invariant optimization finds a loop
  invariant in the pos_mul_karatsuba predicate in library/integer.m.

2 To create the inner predicate (the one that has the already-computed
  invariant passed to it), it tries to make a copy of the original predicate,
  but sets the has_parallel_conj field of the new proc's proc_info to the
  default value, which is has_no_parallel_conj.

3 A later compiler pass has the task of (in par grades) adding synchronization
  to parallel conjunctions, and (in non-par grades) converting the parallel
  conjunctions to sequential. However, due to the has_no_parallel_conj flag
  in the proc_info, it thinks it has no work to do. It therefore leaves the
  parallel conjunction intact.

4 The pre-code-generation simplification pass traverses the entire body of
  the predicate, and, seeing a parallel conjunction, puts a has_parallel_conj
  flag on the proc_info.

5 generate_proc_code sees this flag, but since the target grade is not
  parallel, it ignores the flag. Since debugging is not enabled either,
  it does NOT create a ContainingGoalMap. (The debugger and parallel
  conjunctions are the two things that need this map.)

6 When trying to create the id for the parallel conjunction, par_conj_gen.m
  looks for the ContainingGoalMap. Not finding it, it aborts.

The problem arises in step 2, and the main part of the bug fix is to step 2.
However, it adds a sanity check to step 5 as well, to make any such problems
easier to diagnose in the future.

compiler/hlds_pred.m:
    Require callers of proc_info_create and similar predicates to specify
    whether the new procedure has parallel conjunctions or not.

    Arrange the code of these predicates so that all the fields in the
    proc_info are filled in with variables whose names say what they stand
    for. Previously, many of the fields were just "no" or "[]", not saying
    what `maybe' type or list there was no information for.

    Put these variables in the same order as the fields.

    Add a XXX about the possibility of similar bugs.

compiler/loop_inv.m:
    When creating the inner procedure (and its containing predicate),
    pass the has_parallel_conj flag of the original predicate. This is
    the actual bug fix.

compiler/par_conj_gen.m:
    Improve some comments.

compiler/parallel_to_plain_conj.m:
    Set a procedure's flag to has_no_parallel_conj right after eliminating
    all the parallel conjunctions in it.

compiler/proc_gen.m:
    Add a sanity check: if a procedure has has_parallel_conj, then require
    that the grade be a parallel grade.

compiler/accumulator.m:
compiler/add_pred.m:
compiler/add_special_pred.m:
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/clause_to_proc.m:
compiler/clause_to_proc.m:
compiler/lambda.m:
compiler/make_hlds.m:
compiler/par_loop_control.m:
compiler/pd_info.m:
compiler/stm_expand.m:
compiler/table_gen.m:
compiler/tupling.m:
compiler/unify_proc.m:
compiler/untupling.m:
    Conform to the changes above.
Merge branch 'version-14_01-branch'
Make is_exist_constr a proper type, not a synonym for boolean.

compiler/hlds_goal.m:
    The is_exist_constr field of rhs_functor, which used to be represented by
    a synonym of boolean. Make this type an enum type.

compiler/*.m:
    Conform to the above change.
Fix implicit declaration of GC_setup_mark_lock.

boehm_gc/misc.c:
	Include pthread_support.h for GC_setup_mark_lock,
	a Mercury-specific addition.
Enable thread-local allocation and parallel marking on more platforms.

The changes to the platforms that I am unable to test are based on the
boehm_gc/configure script.  If that script allows the features to be
enabled then I assume that the features are usable.

configure.ac:
	Enable parallel marking on Solaris (untested by me).

	Enable on Cygwin (untested by me).

	Enable on MinGW32 (tested).

	Enable on MinGW-w64 (tested with winpthreads, which requires some
	other changes).

	Enable on Darwin (tested by Julien).
Make the lmc script work in grade hlc.par.gc.ll_debug.

tools/lmc.in:
	As above.
Define atomic ops in high-level .par grades.

runtime/mercury_atomic_ops.c:
	Fix a mismatch between the macros protecting the declarations and
	the definitions of the atomic ops.
Support building Boehm GC with Winpthreads.

Winpthreads is a pthreads implementation from the MinGW-w64 project,
different from pthreads-win32.  A similar patch to this should make its
way into Boehm GC upstream.  As we will not be upgrading Boehm GC on the
14.01 branch, apply this small change to our copy of the library for now.

boehm_gc/include/private/gc_locks.h:
	Winpthreads uses scalar thread IDs.

boehm_gc/win32_threads.c:
	Winpthread thread IDs should be practically unique but make the
	conservative assumption anyway.
Account for Winpthreads in configure.

configure.ac:
	Always build the par_gc library with GC_WIN32_PTHREADS when
	pthread.h is detected on MinGW* systems.  Previously, if the
	pthread implementation is not pthread-win32 we would fallback to
	building Boehm GC with GC_WIN32_THREADS (no "P"), so it would
	NOT provide pthread wrapper functions.  But since pthread.h was
	found, the Mercury implementation would make pthread calls, calls
	which are not intercepted by Boehm GC and thus unsafe.

	Change `--with-gc-pthreads-win32' to `--with-gc-win32-pthreads',
	to mean either of pthreads-win32 or winpthreads.
Fix configuration of thread support for MinGW-w64 32-bit target.

configure.ac:
	Relax a host pattern to cover MinGW-w64 x86 targets (i*86)
	in addition to x86_64.
Reorganize delay_partial_inst.m before working on it.

compiler/delay_partial_inst.m:
    Separate out the important code: handling constructions and deconstructions
    involving partially instantiated terms.

    Put the predicates in a logical order.

compiler/hlds_goal.m:
    Provide insts for each kind of unification.

    Remove some existing insts that were redundant.

compiler/accumulator.m:
compiler/distance_granularity.m:
compiler/higher_order.m:
compiler/lco.m:
compiler/structure_reuse.indirect.m:
    Conform to the change to hlds_goal.m.
Merge branch 'version-14_01-branch'
Allow the compiler to bootstrap with --delay-partial-instantiations.

compiler/modes.m:
    As above.
Remove most non-core predicates from hlds_goal.m.

compiler/hlds_goal.m:
    As above.

    Put some of the remaining stuff in a more logical order.

compiler/make_goal.m:
    This new module contains the predicates, previously in hlds_goal.m,
    that construct new goals.

compiler/hlds.m:
compiler/notes/compiler_design.html:
    Include the new module.

compiler/goal_form.m:
    Move to this existing module the predicates previously in hlds_goal.m
    that test whether goals have particular forms (which is the task of
    this module).

compiler/*.m:
    Conform to the above. Note that no module requires a new import
    of BOTH make_goal and goal_form.
Add forgotten module.