Commit Graph

5139 Commits

Author SHA1 Message Date
Julien Fischer
faa18a15bd Fix the bug with initialisers/finalisers in libraries not being called ( and
Estimated hours taken: 7
Branches: main, release

Fix the bug with initialisers/finalisers in libraries not being called ( and
as consequence also fixes the bug with mutables not being given their correct
initial value).  The problem was that the directives necessary to call them
were not being included in the libraries' .init file.

The fix is to add a new mode of operation to mkinit that given a list of
.c files that make up some Mercury library, constructs the .init file for
that library.  In particular, it now constructs the .init file so that
it contains any REQUIRED_{INIT,FINAL} directives needed by the library.
The new mode of operation is invoked when mkinit is given the `-k' option.

Modify the build systems (i.e. mmake and mmc --make) to conform to the
above change.

compiler/modules.m:
	Change the rule mmake uses to build .init files so that it calls
	mkinit -k on all the .c files generated for the library.

scripts/Mmake.vars.in:
	Add a new mmake variable MKLIBINIT.  This is the program used to
	create .init files.  (It will nearly always be mkinit.)

compiler/compile_target_code.m:
	Change how .init files are built.  We now have to call mkinit -k to
	scan all of the .c files to write out the correct set of INIT,
	REQUIRED_INIT and REQUIRED_FINAL directives.  The code here is
	that used by mmc --make for creating the .init files.

compiler/make.program_target.m:
	Build the .init file after building the .c files, since building
	it before will no longer work.
2006-05-21 06:22:59 +00:00
Julien Fischer
1d3f380430 For each module generate a function mercury__<modulename>__required_init
Estimated hours taken: 2
Branches: main, release

For each module generate a function mercury__<modulename>__required_init
that calls any initialisers in the module.  We only create this function if
there are any user-defined initialisation predicates (or any introduced for
mutable initialisation.) This means that at most one REQUIRED_INIT comment per
module will be required, as opposed to the one per initialise or mutable
declaration we have now.

This change goes part of the way to fixing the bug with initialisers
in libraries not being run.  (The remainder of the fix is a separate change.)
This change also makes it simpler to ensure that the initialisers get executed
in the correct order.

Do the same thing for finalisers.

compiler/llds_out.m:
compiler/mlds_to_c.m:
	Make the above changes to the LLDS and MLDS backends respectively.
2006-05-12 08:32:07 +00:00
Julien Fischer
cefc13f4bb Make it easier for vi to jump over the header comments.
Estimated hours taken: 0
Branches: main

compiler/compile_target_code.m:
	Make it easier for vi to jump over the header comments.
2006-05-12 04:32:03 +00:00
Nancy Mazur
db5d688c43 Provide the direct reuse analysis part of the structure reuse analysis (which
Estimated hours taken: 25
Branches: main

Provide the direct reuse analysis part of the structure reuse analysis (which
itself is part of the CTGC system).

compiler/ctgc.datastruct.m:
compiler/ctgc.util.m:
	Additional predicates.

compiler/ctgc.m:
	Add structure reuse module.

compiler/handle_options.m:
compiler/options.m:
	Add new options "structure_reuse_analysis" and related ones.

compiler/handle_options.m:
compiler/hlds_out.m:
	Add dump option "R" to dump structure reuse related information
	in the hlds_dump files.

compiler/hlds_goal.m:
	Types to record structure reuse information at the level of each
	goal.
	Additional "case_get_goal" function to extract the goal from an case.

compiler/mercury_compile.m:
	Add structure reuse analysis as a new compiler stage.

compiler/structure_reuse.analysis.m:
	The top level analysis predicates.

compiler/structure_reuse.m:
compiler/structure_reuse.direct.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.direct.detect_garbage.m:
	Direct reuse analysis is split into 2 steps: determining when and how
	data structures become garbage, and then choosing how these dead
	data structures might best be reused.

compiler/structure_reuse.domain.m:
	The abstract domain for keeping track of reuse conditions, the main
	domain in the structure reuse analysis.

compiler/structure_reuse.lbu.m:
compiler/structure_reuse.lfu.m:
	To determine whether data structures become dead or not, one needs to
	know which variables in a goal are needed with respect to forward
	execution (lfu = local forward use), and backward execution, i.e.
	backtracking (lbu = local backward use). These two modules provide
	the necessary functionality to pre-annotate the goals with lfu and
	lbu information.

compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
	Remove the structure sharing table from the interface of the analysis
	predicate in structure_sharing.analysis.m;
	Move predicates to structure_sharing.domain.m so that they become
	more easily accessible for the structure_reuse modules.

compiler/prog_data.m:
	New types "dead_var", "live_var" and alike.
2006-05-10 15:20:57 +00:00
Nancy Mazur
d3e5a8eda4 Provide the direct reuse analysis part of the structure reuse analysis (which
Estimated hours taken: 25
Branches: main

Provide the direct reuse analysis part of the structure reuse analysis (which
itself is part of the CTGC system).

compiler/ctgc.datastruct.m:
compiler/ctgc.util.m:
	Additional predicates.

compiler/ctgc.m:
	Add structure reuse module.

compiler/handle_options.m:
compiler/options.m:
	Add new options "structure_reuse_analysis" and related ones.

compiler/handle_options.m:
compiler/hlds_out.m:
	Add dump option "R" to dump structure reuse related information
	in the hlds_dump files.

compiler/hlds_goal.m:
	Types to record structure reuse information at the level of each
	goal.
	Additional "case_get_goal" function to extract the goal from an case.

compiler/mercury_compile.m:
	Add structure reuse analysis as a new compiler stage.

compiler/structure_reuse.analysis.m:
	The top level analysis predicates.

compiler/structure_reuse.direct.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.direct.detect_garbage.m:
	Direct reuse analysis is split into 2 steps: determining when and how
	data structures become garbage, and then choosing how these dead
	data structures might best be reused.

compiler/structure_reuse.domain.m:
	The abstract domain for keeping track of reuse conditions, the main
	domain in the structure reuse analysis.

compiler/structure_reuse.lbu.m:
compiler/structure_reuse.lfu.m:
	To determine whether data structures become dead or not, one needs to
	know which variables in a goal are needed with respect to forward
	execution (lfu = local forward use), and backward execution, i.e.
	backtracking (lbu = local backward use). These two modules provide
	the necessary functionality to pre-annotate the goals with lfu and
	lbu information.

compiler/structure_sharing.analysis.m:
compiler/structure_sharing.domain.m:
	Remove the structure sharing table from the interface of the analysis
	predicate in structure_sharing.analysis.m;
	Move predicates to structure_sharing.domain.m so that they become
	more easily accessible for the structure_reuse modules.

compiler/prog_data.m:
	New types "dead_var", "live_var" and alike.
2006-05-10 10:56:57 +00:00
Zoltan Somogyi
afbec6110a This diff simplifies the way we handle compiler-generate data in LLDS grades.
Estimated hours taken: 2
Branches: main

This diff simplifies the way we handle compiler-generate data in LLDS grades.
We used to wrap several kinds of data structures up in different function
symbols so they could be treated as values of a single type, comp_gen_c_data,
but then we divided them up into the original caregories again when creating
the output .c file. We now instead keep the various kinds of static data
separate all the way through.

compiler/llds.m:
	Delete the comp_gen_c_data type. Replace the single list of
	comp_gen_c_data items in the representation of C files with four
	lists, one for each kind of static data.

compiler/llds_out.m:
	Make the simplifications made possible by the change to llds.m.

	Output references to MR_COMMON and MR_TAG_COMMON instead of MR_XCOMMON
	and MR_TAG_XCOMMON, since the change to make these equivalent should
	have been installed on all our machines by now.

compiler/code_info.m:
compiler/global_data.m:
compiler/stack_layout.m:
	Modify data structures to contain data of specific types instead
	comp_gen_c_datas, and modify the code accordingly. This mostly means
	avoiding now redundant operations to wrap data structures with
	comp_gen_c_data's function symbols.

compiler/mercury_compile.m:
	Build c_file structures with four lists of distinct types instead
	of appending them all to get a single giant list of comp_gen_c_datas.

compiler/transform_llds.m:
	Conform to the change to llds.m.

compiler/layout.m:
compiler/layout_out.m:
	Minor style improvements.
2006-05-08 03:36:02 +00:00
Julien Fischer
7dd5576f38 Fix a bug with profiling and the high-level C grades.
Estimated hours taken: 1
Branches: main, release

Fix a bug with profiling and the high-level C grades.  The problem was that we
were only emitting an INIT comment whenever there was a user initialisation or
finalisation predicate.  This is not noticeable in most of the hl* grades
since mercury__<modulename>__init is empty anyway.  However in the profiling
grades the init function is responsible for calling MR_init_entry for each
procedure.  Failing to do this causes unknown functions to show up in the
profile.  (This problem appears to have been introduced with r1.101 of
util/mkinit.c - prior to that, in the 0.12 release for example, init functions
in the hl* grades were handled differently.)

compiler/mlds_to_c.m:
	Always output the INIT comment for a module.
2006-05-05 08:02:56 +00:00
Peter Wang
d3ca8ee50d Fix a compiler abort when `--optimise-dups' detects some duplicate code
Estimated hours taken: 1.5
Branches: main, release

Fix a compiler abort when `--optimise-dups' detects some duplicate code
sequences in parallel conjunctions.

compiler/dupelim.m:
	Allow `most_specific_instr' to generalise two `fork',
	`init_sync_term', `join_and_continue' or `join_and_terminate'
	instructions if they take exactly the same arguments.

tests/valid/Mercury.options:
tests/valid/Mmakefile:
tests/valid/par_dupelim.m:
	Add a test case.
2006-05-04 08:34:56 +00:00
Zoltan Somogyi
aa33d8f0a3 Add file I forgot to "cvs add".
Estimated hours taken: 0.1
Branches: main

compiler/proc_gen.m:
	Add file I forgot to "cvs add".
2006-05-03 07:45:19 +00:00
Zoltan Somogyi
4e6c603d30 Fix two bugs that caused test case failures in deep profiling grades.
Estimated hours taken: 3
Branches: main

compiler/lookup_switch.m:
	Fix two bugs that caused test case failures in deep profiling grades.

	One bug was that an acquired register wasn't being released before
	the creation of a resume point, which rebuilds the code generator state
	(and thus forgets about acquired registers).

	The other bug was that is_lookup_switch wasn't performing the actions
	generate_goal would have when processing goals. In particular, it
	wasn't invoking pre_goal_update and post_goal_update on disjunctions
	inside the switch.

compiler/lookup_util.m:
	Do not standardize goals by removing scopes from around other goals,
	because this could also remove the effects of the code generator
	annotations (e.g. liveness changes such as pre-births) on the scope
	goal.

compiler/simplify.m:
	Eliminate those redundant scopes if asked to do so. Since this is done
	before the code generator annotations are put on goals, this is safe.

compiler/code_gen.m:
compiler/proc_gen.m:
	Divide the old code_gen.m into two modules: the new code_gen.m
	concerned with generating code for goals, and the new module proc_gen.m
	concerned with generating code for procedures. Without this, the code
	for handling goals is lost inside the old code_gen.m module.

compiler/ll_backend.m:
	Include the new module.

compiler/mercury_compile.m:
	Import proc_gen instead of code_gen, and ask simplify to eliminate
	unnecessary scopes before code generation.

compiler/middle_rec.m:
	Update a reference to a predicate now in proc_gen.m.

compiler/notes/compiler_design.html:
	Document the new module.
2006-05-03 06:46:20 +00:00
Julien Fischer
dccd1438c0 Make some minor formatting and style fixes.
Estimated hours taken: 0.1
Branches: main

compiler/module_qual.m:
compiler/prog_ctgc.m:
compiler/prog_data.m:
compiler/prog_item.m:
	Make some minor formatting and style fixes.

	Fix a couple of typos.
2006-05-02 08:15:34 +00:00
Julien Fischer
7018810347 Add --c-include-dir' as a synonym for --c-include-directory'.
Estimated hours taken: 0.1
Branches: main, release

compiler/options.m:
doc/user_guide.texi:
	Add `--c-include-dir' as a synonym for `--c-include-directory'.
2006-05-02 07:52:53 +00:00
Nancy Mazur
da2ecac742 Add structure_reuse pragma (prog_item.m) and related types (prog_data.m).
Estimated hours taken: 1
Branches: reuse

Add structure_reuse pragma (prog_item.m) and related types (prog_data.m).

compiler/prog_data.m:
	Add reuse_tuple and reuse_tuples as public representations for
	reuse conditions needed in the CTGC system.

compiler/prog_ctgc.m:
	Add parsing and printing routines for reuse_tuple(s).

compiler/prog_item.m:
compiler/add_pragma.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.version.m:
	Add pragma structure_reuse/7.
2006-05-02 05:57:10 +00:00
Julien Fischer
41ddbbd9f9 Fix some typos.
Estimated hours taken: 0
Branches: main

compiler/polymorphism.m:
	Fix some typos.
2006-04-30 04:37:04 +00:00
Peter Wang
2bd4e6d2bf The saved_vars pass was not pushing unifications that assign
Estimated hours taken: 1.5
Branches: main, release

compiler/saved_vars.m:
	The saved_vars pass was not pushing unifications that assign
	constants to variables into parallel conjunctions.  Since the
	original unification would be deleted, the parallel conjunction
	would be left referring to an unbound variable.

tests/valid/Mercury.options:
tests/valid/par_saved_const.m:
	Add a test case.
2006-04-28 04:13:24 +00:00
Zoltan Somogyi
c3b1c2003e Support constant "mutables". Though this sounds like a contradiction in terms,
Estimated hours taken: 3
Branches: main

Support constant "mutables". Though this sounds like a contradiction in terms,
they can be useful, because in some cases they are the best alternative.

- For some types, e.g. arrays, there is no way to write manifest constants.

- For some other types, one can write manifest constants, but the compiler
  may be too slow in compiling clauses containing them if the constant is
  very large (even after my recent improvements).

- Using a tabled zero-arity function incurs overhead on every access to check
  whether the result was recorded previously or not. This is a bad idea e.g.
  in the inner loop of a scanner (which may want to use an array for the
  representation of the DFA).

compiler/prog_item.m:
	Add a new attribute to say whether the mutable is constant or not.

compiler/prog_io.m:
	Recognize the "constant" mutable attribute.

compiler/prog_mutable.m:
	Provide predicates to construct the signatures of the get and set
	predicates of constant mutables. Rename some existing predicates
	to better reflect their purpose.

compiler/make_hlds_passes.m:
compiler/modules.m:
	Modify the code for creating mutables' get, set and init predicates
	to do the right thing for constant mutables.

doc/reference_manual.texi:
	Document the new attribute.

tests/hard_coded/pure_mutable.{m,exp}:
	Test the new attribute.
2006-04-27 07:34:37 +00:00
Zoltan Somogyi
06d998b738 Add file I forgot to "cvs add".
Estimated hours taken: 0.1
Branches: main

compiler/lookup_util.m:
	Add file I forgot to "cvs add".
2006-04-26 04:36:46 +00:00
Zoltan Somogyi
d5d5986472 Implement lookup switches in which a switch arm may contain more than one
Estimated hours taken: 40
Branches: main

Implement lookup switches in which a switch arm may contain more than one
solution, such as this code here:

	p(d, "four", f1, 4.4).
	p(e, "five", f2, 5.5).
	p(e, "five2", f3(5), 55.5).
	p(f, "six", f4("hex"), 6.6).
	p(g, "seven", f5(77.7), 7.7).
	p(g, "seven2", f1, 777.7).
	p(g, "seven3", f2, 7777.7).

Such code occurs frequently in benchmark programs used to evaluate the
performance of tabled logic programming systems.

Change frameopt.m, which previously worked only on det and semidet code,
to also work for nondet code. For predicates such as the one above, frameopt
can now arrange for the predicate's nondet stack frame to be created only
when a switch arm that has more than one solution is selected.

compiler/lookup_switch.m:
	Extend the existing code for recognizing and implementing lookup
	switches to recognize and implement them even if they are model_non.

compiler/lookup_util.m:
	New module containing utility predicates useful for implementing
	both lookup switches, and in the future, lookup disjunctions (i.e.
	disjunctions that correspond to a nondet arm of a lookup switch).

compiler/ll_backend.m:
	Include the new module.

compiler/notes/compiler_design.html:
	Mention the new module.

compiler/global_data.m:
	Move the job of filling in dummy slots to our caller, in this case
	lookup_switch.m.

compiler/frameopt.m:
	Generalize the existing code for delaying stack frame creation,
	which worked only on predicates that live on the det stack, to work
	also on predicates that live on the nondet stack. Without this,
	predicates whose bodies are model_non lookup switches would create
	a nonstack stack frame before the switch is ever entered, which
	is wasteful if the selected switch arm has at most one solution.

	Since the structure of model_non predicates is more complex (you can
	cause a branch to a label by storing its address in a redoip slot,
	you can succeed from the frame without removing the frame), this
	required considerable extra work. To make the new code debuggable,
	record, for each basic block that needs a stack frame, *why* it
	needs that stack frame.

compiler/opt_util.m:
	Be more conservative about what refers to the stack. Export some
	previously internal functionality for frameopt. Turn some predicates
	into functions, and rename them to better reflect their purpose.

compiler/opt_debug.m:
	Print much more information about pragma_c and call LLDS instructions.

compiler/prog_data.m:
	Add an extra attribute to foreign_procs that says that the code
	of the foreign_proc assumes the existence of a stack frame.
	This is needed to avoid frameopt optimizing the stack frame away.

compiler/add_pragma.m:
	When processing fact tables, we create foreign_procs that assume
	the existence of the stack frame, so set the new attribute.

compiler/pragma_c_gen.m:
	When processing foreign_procs, transmit the information in the
	attribute to the generated LLDS code.

compiler/llds.m:
	Rename the function symbols referring to the fixed slots in nondet
	stack frames to make them clearer and to avoid overloading function
	symbols such as curfr and succip.

	Rename the function symbols of the call_model type to avoid overloading
	the function symbols of the code_model type.

	Add a new field to the c_procedure type giving the code_model of the
	procedure, and give names to all the fields.

	Describe the stack slots used by lookup switches to the debugger
	and native gc.

compiler/options.m:
doc/user_guide.texi:
	Add a new option, --debug-opt-pred-name, that does when the existing
	--debug-opt-pred-id options does, but taking a user-friendly predicate
	name rather than a pred_id as its argument.

compiler/handle_options.m:
	Process --debug-opt-pred-name, and make --frameopt-comments imply
	--auto-comments, since it is not useful without it.

	Reformat some existing comments that were written in the days of
	8-space indentation.

compiler/optimize.m:
	Implement the new option.

	Use the new field of the c_procedure type to try only the version
	of frameopt appropriate for the code model of the current procedure.

	Do a peephole pass after frameopt, since frameopt can generate code
	sequences that peephole can optimize.

	Make the mechanism for recording the process of optimizing procedure
	bodies more easily usable by including the name of the optimization
	that created a given version of the code in the name of the file
	that contains that version of the code, and ensuring that all numbers
	are two characters long, so that "vi procname*.opt*" looks at the
	relevant files in the proper chronological sequence, instead of having
	version 11 appear before version 2.

compiler/peephole.m:
	Add a new optimization pattern: a "mkframe, goto fail" pair (which
	can be generated by frameopt) should be replaced by a simple "goto
	redo".

compiler/code_gen.m:
	Factor out some common code.

compiler/llds_out.m:
	Ensure that C comments nested inside comment(_) LLDS instructions
	aren't emitted as nested C comments, since C compilers cannot handle
	these.

compiler/code_info.m:
compiler/code_util.m:
compiler/continuation_info.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/jumpopt.m:
compiler/livemap.m:
compiler/llds_out.m:
compiler/mercury_compile.m:
compiler/middle_rec.m:
compiler/ml_code_gen.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/peephole.m:
compiler/stack_layout.m:
compiler/transform_llds.m:
compiler/var_locn.m:
	Conform to the change to prog_data.m, opt_util.m and/or llds.m.

compiler/handle_options.m:
	Don't execute the code in stdlabel.m if doing so would cause a compiler
	abort.

tests/hard_coded/dense_lookup_switch_non.{m,exp}:
	New test case to exercise the new algorithm.

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

tests/hard_coded/cycles.m:
	Make this test case conform to our coding convention.
2006-04-26 03:06:29 +00:00
Zoltan Somogyi
e1e9523b31 Fix a typo in the spelling of an error message.
Estimated hours taken: 0.1
Branches: main, release

compiler/state_var.m:
test/warnings/state_vars_test.exp:
	Fix a typo in the spelling of an error message.
2006-04-24 09:36:26 +00:00
Zoltan Somogyi
4917e938d8 Fix a bug that was preventing the compiler from bootstrapping
Estimated hours taken: 2
Branches: main, release

compiler/lco.m:
	Fix a bug that was preventing the compiler from bootstrapping
	with --optimize-constructor-last-call. The bug was that while
	the lco transformation was properly marking as impure the goals
	that store results at the addresses provided by the caller,
	it was not so marking the goals containing them, allowing simplify
	to optimize them away.
2006-04-24 04:23:47 +00:00
Zoltan Somogyi
46a67b0b48 When the typechecker finds highly ambiguous overloading, print what symbols
Estimated hours taken: 16
Branches: main

When the typechecker finds highly ambiguous overloading, print what symbols
were overloaded, and where they occurred. Without this information, it is
very hard to fix the error if the predicate body is at all large.

Fix some software engineering problems encountered during this process.
Modify some predicates in error_util in order to simplify their typical usage.
Change the type_ctor type to be not simply a sym_name - int pair but a type
with its own identifying type constructor. Change several other types that
were also sym_name - int pairs (mode_id, inst_id, item_name, module_qual.id
and the related simple_call_id) to have their own function symbols too.

compiler/typecheck_info.m:
	Add a field to the typecheck_info structure that records the overloaded
	symbols encountered.

compiler/typecheck.m:
	When processing ambiguous predicate and function symbols, record this
	fact in the typecheck_info.

	Add a field to the cons_type_info structure to make this possible.

compiler/typecheck_errors.m:
	When printing the message about highly ambiguous overloading,
	what the overloaded symbols were and where they occurred.

compiler/error_util.m:
	Make error_msg_specs usable with plain in and out modes by separating
	out the capability requiring special modes (storing a higher order
	value in a function symbol) into its own, rarely used type.

	Make component_list_to_line_pieces a bit more flexible.

compiler/prog_data.m:
compiler/module_qual.m:
compiler/recompilation.m:
	Change the types listed above from being equivalence types (pairs)
	to being proper discriminated union types.

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

	In some cases, simplify the code's use of error_util.

tests/warnings/ambiguous_overloading.{m,exp}:
	Greatly extend this test case to test the new functionality.

tests/recompilation/*.err_exp.2
	Reflect the fact that the expected messages now use the standard
	error_util way of quoting sym_name/arity pairs.
2006-04-20 05:37:13 +00:00
Zoltan Somogyi
18873960a3 Fix a bug reported by Michael Day. The bug was that when frameopt wanted
Estimated hours taken: 2
Branches: main, release

Fix a bug reported by Michael Day. The bug was that when frameopt wanted
to find out whether a block of instructions referred to stack variables,
it did not look past pragma_c_code LLDS instructions. As a result, the
generated code included a (redundant) assignment to a stack variable
in a section of code that, after frameopt, did not have a stack frame
anymore. It therefore overwrote part of its caller's stack frame, which
caused a crash.

compiler/opt_util.m:
	Fix the auxiliary predicate used by frameopt.

tests/hard_coded/prince_frameopt.{m,exp}:
tests/hard_coded/prince_frameopt_css.m:
tests/hard_coded/prince_frameopt_css.style.m:
	The new test case (a three module program).

tests/hard_coded/Mmakefile:
tests/hard_coded/Mercury.options:
	Enable the new test case, and compile it with the options required
	to show the bug if it exists.
2006-04-20 04:05:26 +00:00
Peter Wang
e3caf291df Some miscellaneous parallel conjunction related fixes.
Estimated hours taken: 1
Branches: main

Some miscellaneous parallel conjunction related fixes.

compiler/add_clause.m:
	Keep parallel conjuncts in the order they were written, not reversed.
	This is less confusing when debugging.

compiler/det_report.m:
	Add a missing space in an error message.

compiler/hlds_out.m:
	Indent the opening bracket of parallel conjunctions in HLDS dumps.

compiler/par_conj_gen.m:
	In the code generated for parallel conjunctions, don't attempt to copy
	output variables which are of dummy types back to the parent thread's
	stack frame.

tests/valid/Mmakefile:
tests/valid/par_dummy.m:
	Add test case for the fix above.
2006-04-18 05:47:34 +00:00
Zoltan Somogyi
f2f25c6e06 Update some code to use it natural expression, which uses a switch
Estimated hours taken: 0.1
Branches: main

compiler/constraint.m:
	Update some code to use it natural expression, which uses a switch
	in which all arms contain only disjunctions of unifications, not
	straight unifications.

configure.in:
	Require the installed compiler to include the bug fix to switch
	detection I committed on Apr 7, since without that fix code like
	this is rejected by the compiler.
2006-04-13 03:59:26 +00:00
Zoltan Somogyi
12e3241bd3 When computing the dependency graph, avoid situations in which
Estimated hours taken: 0.3
Branches: main

compiler/modules.m:
	When computing the dependency graph, avoid situations in which
	a module to be processed is in the list of modules to be processed
	multiple times, since this can lead to very deep recursion which
	requires lots of stack in debugging grades. Instead of using a list,
	use a set of modules to be processed.

	This also leads to a slight speedup in non-debugging grades; doing
	--generate-dependencies on the compiler six times in a row drops from
	a total time of 107.x seconds to 104.x seconds on my laptop.
2006-04-10 07:22:12 +00:00
Zoltan Somogyi
d50092b57f Change the order in which mmake builds modules of the program to
Estimated hours taken: 0.2
Branches: main

compiler/modules.m:
	Change the order in which mmake builds modules of the program to
	be alphabetical, instead of the current scheme, which is by levels
	(first toplevel modules, then modules inside toplevel modules, etc).

	Reformat some comments for 80 column width.
2006-04-10 06:57:26 +00:00
Julien Fischer
cd7f318f24 Fix a bug that has been causing tests/hard_coded/sub-modules/non_word_mutable
Estimated hours taken: 3
Branches: main

Fix a bug that has been causing tests/hard_coded/sub-modules/non_word_mutable
to fail in high-level C grades.

The bug occurred when we had a mutable declaration in the child module whose
type was a foreign type defined in the parent module and where that foreign
type relied on other C type definitions in a foreign_decl pragma in the
parent.  The problem was that the contents of the parent's foreign_decl pragma
were not visible in the child's .mih file at the point where the declarations
for the mutable variables were made.

The fix is to make sure that we #include all ancestor .mih files before any
foreign code declarations made by the child's .mih file.

compiler/mlds_to_c.m:
	Avoid the above problem.

compiler/modules.m:
	Update module qualifier syntax in a comment.
2006-04-10 06:25:41 +00:00
Zoltan Somogyi
e8832be3a5 A new module that contains code to standardize labels in the LLDS.
Estimated hours taken: 1
Branches: main

compiler/stdlabel.m:
	A new module that contains code to standardize labels in the LLDS.

compiler/ll_backend.m:
	Include the new module in this package.

compiler/options.m:
	Add an option that governs whether stdlabel.m is invoked or not.

compiler/optimize.m:
	If the option is set, invoke stdlabel.m.

compiler/opt_util.m:
	Add an option to opt_util.replace_labels_instruction_list to allow
	it to replace labels in label instructions themselves.

compiler/dupelim.m:
	Conform to the changes in opt_util.m

compiler/notes/compiler_design.html:
	Document the new module.
2006-04-10 04:28:24 +00:00
Zoltan Somogyi
c31be3d6ac Fix a limitation: recognize switches in which *all* arms contain
Estimated hours taken: 0.5
Branches: main

compiler/switch_detection.m:
	Fix a limitation: recognize switches in which *all* arms contain
	not a single unification of the switched-on variable but a disjunction
	of such unifications.

	Fix some misleading variable names.

tests/hard_coded/disjs_in_switch.{m,exp}:
	Add a test case for this bug.

tests/hard_coded/Mmakefile:
	Enable the new test case.
2006-04-07 01:32:58 +00:00
Zoltan Somogyi
c5af97ea18 Don't push constraints into scopes where they could change the meaning
Estimated hours taken: 0.5
Branches: main, release

compiler/constraint.m:
	Don't push constraints into scopes where they could change the meaning
	of the scope.

	Turn the predicate into a single disjunction to make the head variables
	meaningful (and consistent) names in the debugger.

tests/Mmakefile:
	Compile the one_member test case with -O5, since the old bug in
	constraint.m doesn't manifest itself at the default optimization level.
2006-04-07 01:29:28 +00:00
Zoltan Somogyi
483e861c12 Fix the same bug in all these three places: treat the rval arguments
Estimated hours taken: 0.5
Branches: main, release

compiler/livemap.m:
compiler/middle_rec.m:
compiler/var_locn.m:
	Fix the same bug in all these three places: treat the rval arguments
	of mem_ref terms as rvals, instead of as the constants they used to be.
2006-04-06 05:38:51 +00:00
Peter Wang
1c069bd786 Convert a semidet predicate to a det function for maintainability.
Estimated hours taken: 0.1
Branches: main

compiler/make.module_target.m:
	Convert a semidet predicate to a det function for maintainability.
2006-04-04 08:03:43 +00:00
Peter Wang
ad75e65dec Fix an inconsistency which prevented `mmc --make' from being able to
Estimated hours taken: 0.2
Branches: main, release

compiler/make.module_target.m:
	Fix an inconsistency which prevented `mmc --make' from being able to
	make `.opt' or `.analysis' files on platforms/grades where `mmc
	--make' is unable to fork().
2006-04-03 13:20:10 +00:00
Zoltan Somogyi
90f2724738 Don't test whether we are emitting trail operations when generating
Estimated hours taken: 0.5
Branches: main

compiler/code_gen.m:
	Don't test whether we are emitting trail operations when generating
	*every* goal; test it only when generating goals that may want to
	emit trailing operations. Make the test itself more efficient
	by doing option lookups and boolean operations on option values
	once per procedure rather than once per affected goal.

compiler/code_info.m:
	Extend the code_info structure to provide storage space for the
	result of this per-procedure computation.

compiler/code_util.m:
	Delete a function whose functionality is now in code_info.m.

compiler/goal_form.m:
	Turn the predicates that test whether a goal can modify the trail
	into functions, since that is how they were being used. Make them
	take only the goal_info as the argument, since the goal expression
	isn't needed, and creating the expression/goal_info pair would be
	an unnecessary cost on the code generator.

compiler/add_trail_ops.m:
compiler/disj_gen.m:
	Conform to the change in goal_form.m.

compiler/mercury_compile.m:
	Fix formatting.

compiler/assertion.m:
	Address some old review comments: fix some bad predicate names,
	and put some predicate's arguments into a more conventional order.

	Remove some redundant and slightly inconsistent documentation.

compiler/accumulator.m:
compiler/typecheck.m:
	Conform to the change in assertion.m.
2006-03-31 03:32:11 +00:00
Zoltan Somogyi
4fe703c7b9 Implement a more cache-friendly translation of lookup switches.
Estimated hours taken: 8
Branches: main

Implement a more cache-friendly translation of lookup switches. Previously,
for a switch such as the one in

	:- pred p(foo::in, string::out, bar::out, float::out) is semidet.

	p(d, "four", f1, 4.4).
	p(e, "five", f2, 5.5).
	p(f, "six", f4("hex"), 6.6).
	p(g, "seven", f5(77.7), 7.7).

we generated three static cells, one for each argument, and then indexed
into each one in turn to get the values of HeadVar__2, HeadVar__3 and
HeadVar__4. The different static cells each represent a column here.
Each of the loads accessing the columns will access a different cache block,
so with this technique we expect to get as many cache misses as there are
output variables.

This diff changes the code we generate to use a vector of static cells
where each cell represents a row. The assignments to the output variables
will now access the different fields of a row, which will be next to each
other. We thus expect only one cache miss irrespective of the number of output
variables, at least up to the number of variables that actually fit into one
cache block.

compiler/global_data.m:
	Provide a mechanism for creating not just single (scalar) static cells,
	but arrays (vectors) of them.

compiler/lookup_switch.m:
	Use the new mechanism to generate code along the lines described above.

	Put the information passed between the two halves of the lookup switch
	implementation (detection and code generation) into an opaque data
	structure.

compiler/switch_gen.m:
	Conform to the new interface of lookup_switch.m.

compiler/ll_pseudo_type_info.m:
compiler/stack_layout.m:
compiler/string_switch.m:
compiler/unify_gen.m:
compiler/var_locn.m:
	Conform to the change to global_data.m.

compiler/llds.m:
	Define the data structures for holding vectors of static cells. Rename
	the function symbols we used to use to refer to static cells to make
	clear that they apply to scalar cells only. Provide similar mechanisms
	for representing static cell vectors and references to them.

	Generalize heap_ref heap references to allow the index to be computed
	at runtime, not compile time. For symmetry's sake, do likewise
	for stack references.

compiler/llds_out.m:
	Add the code required to write out static cell vectors.

	Rename decl_ids to increase clarity and avoid ambiguity.

compiler/code_util.m:
compiler/exprn_aux.m:
	Modify code that traverses rvals to now also traverse the new rvals
	inside memory references.

compiler/name_mangle.m:
	Provide the prefix for static cell vectors.

compiler/layout_out.m:
compiler/rtti_out.m:
compiler/opt_debug.m:
	Conform to the change to data_addrs and decl_ids.

compiler/code_info.m:
	Provide access to the new functionality in global_data.m, and conform
	to the change to llds.m.

	Provide a utility predicate needed by lookup_switch.m.

compiler/hlds_llds.m:
	Fix the formatting of some comments.

tools/binary:
tools/binary_step:
	Fix the bit rot that has set in since they were last used (the rest
	of the system has changed quite a lot since then). I had to do so
	to debug one part of this change.

tests/hard_coded/dense_lookup_switch2.{m,exp}:
tests/hard_coded/dense_lookup_switch3.{m,exp}:
	New test cases to exercise the new algorithm.

tests/hard_coded/Mmakefile:
	Enable the new test cases, as well as an old one (from 1997!)
	that seems never to have been enabled.
2006-03-30 02:46:08 +00:00
Julien Fischer
459847a064 Move the univ, maybe, pair and unit types from std_util into their own
Estimated hours taken: 18
Branches: main

Move the univ, maybe, pair and unit types from std_util into their own
modules.  std_util still contains the general purpose higher-order programming
constructs.

library/std_util.m:
	Move univ, maybe, pair and unit (plus any other related types
	and procedures) into their own modules.

library/maybe.m:
	New module.  This contains the maybe and maybe_error types and
	the associated procedures.

library/pair.m:
	New module.  This contains the pair type and associated procedures.

library/unit.m:
	New module. This contains the types unit/0 and unit/1.

library/univ.m:
	New module. This contains the univ type and associated procedures.

library/library.m:
	Add the new modules.

library/private_builtin.m:
	Update the declaration of the type_ctor_info struct for univ.

runtime/mercury.h:
	Update the declaration for the type_ctor_info struct for univ.

runtime/mercury_mcpp.h:
runtime/mercury_hlc_types.h:
	Update the definition of MR_Univ.

runtime/mercury_init.h:
	Fix a comment: ML_type_name is now exported from type_desc.m.

compiler/mlds_to_il.m:
	Update the the name of the module that defines univs (which are
	handled specially by the il code generator.)

library/*.m:
compiler/*.m:
browser/*.m:
mdbcomp/*.m:
profiler/*.m:
deep_profiler/*.m:
	Conform to the above changes.  Import the new modules where they
	are needed; don't import std_util where it isn't needed.

	Fix formatting in lots of modules.  Delete duplicate module
	imports.

tests/*:
	Update the test suite to confrom to the above changes.
2006-03-29 08:09:58 +00:00
Julien Fischer
3bc5f096d7 Factor out the mutvars used to implement the all-solutions predicates
Estimated hours taken: 1.5
Branches: main

Factor out the mutvars used to implement the all-solutions predicates
into their own module.  For the Java backend they are also used to implement
stores.

library/solutions.m:
	Delete the definition of the mutvar type and supporting predicates
	from this module.

library/mutvar.m:
	New module.  This module provides the mutvar type that currently
	lives in solutions.m (and formerly lived in std_util.m).

library/store.m:
	Fix the definition of generic_mutvars for the Java backend.  This
	has been broken since the change that moved the all-solutions
	predicate to solutions.m.

	Replace ':' as a module qualifier.

library/library.m:
	Add the new module.

compiler/ml_util.m:
	mutvars are handled specially in the IL backend.

doc/Mmakefile:
	Don't include the mutvar module in the library reference manual.
2006-03-29 01:35:19 +00:00
Zoltan Somogyi
25b8b1abc3 Fix several performance bugs that showed up when the compiler was invoked on
Estimated hours taken: 20
Branches: main

Fix several performance bugs that showed up when the compiler was invoked on
Douglas Auclair's training_cars example. Also fix some minor problems that
made it harder to find the information needed to localize those problems.

training_cars.m is hard to compile quickly because it is big in two dimensions:
it has lots of clauses, and each clause has big terms.

My laptop still tries to swap itself to death on the full version of
training_cars.m (it has only 512 Mb), but the compiler now works fine
on a version containing about 20% of its clauses, whereas previously
it couldn't compile it at all.

In most cases, the changes convert N^2 algorithms to NlogN algorithms.
They probably have higher constant factors and may yield small slowdowns
for small N, but this is probably not noticeable. Avoiding bad worst case
behavior is more important.

compiler/superhomogeneous.m:
	Record the number of goals inserted in each goal being converted
	to superhomogeneous form. If this exceeds a threshold, wrap a
	from_ground_term scope around it.

	Put the predicates into a more cohesive sequence.

compiler/field_access.m:
	Work with the code in superhomogeneous to record the number of inserted
	goals. Reorder the arguments of some performances to be consistent
	with the predicates in superhomogeneous.m.

compiler/modes.m:
	Use the from_ground_term scope to reverse the list of inserted
	unifications if necessary. It is much more efficient to do this here
	than to let it happen by sequences of delays and wakeups. That would
	have quadratic complexity; this is linear.

	This is what I originally introduced from_ground_term scopes for.
	Then, the overhead was too high, because I added one scope per function
	symbol. This version should be fine, since there is at most one scope
	added per argument of an atom (clause head or call).

compiler/modes.m:
compiler/unique_modes.m:
	When we are processing goals inside a from_ground_term scope, record
	this fact.

compiler/mode_info.m:
	Make it possible to record this fact.

compiler/modecheck_unify.m:
	When we are inside a from_ground_term scope, don't try to update the
	insts of vars on the right hand sides of construction unifications.
	Since these variables came from expansion to superhomogeneous form,
	those variables won't occur in any following code, so updating their
	state is useless, and the algorithm we used to do so is linear in the
	size of the inst. Since the size of an inst of a variable that results
	from superhomogeneous expansion is itself on average proportional to
	the size of the original term, this change turns a quadratic algorithm
	into a linear one.

compiler/inst_match.m:
	Use balanced trees instead of ordered lists to represents sets of
	expansions, since these sets can be large.

	Note an opportunity for further improvement.

compiler/inst_util.m:
	Note another opportunity for further improvement.

compiler/instmap.m:
	Rename several predicates to avoid ambiguities.

compiler/cse_detection.m:
	We used to print statistics for the processing of each procedure
	without saying which procedure it is for; fix this.

compiler/switch_detection.m:
	Don't print progress messages for predicates with no procedures,
	since they would be misleading.

compiler/higher_order.m:
	Change an algorithm that was quadratic in the number of arms
	for merging the information from the different arms of disjunctions
	and switches to an NlogN algorithm.

	Change the algorithm for merging the info from two branches
	that quadratic in the number of variables per arm to an NlogN
	algorithm.

	Changed some type equivalences to notag types to aid robustness.

compiler/quantification.m:
	Rename several predicates to avoid ambiguities.

	The sets of variables in different arms of disjunctions and switches
	tend to have relatively small intersections. Yet the algorithms we
	used to compute the set of variables free in the disjunction or switch
	included the variables from the already processed arms in the sets
	being accumulated when processing later arms, leading to the quadratic
	behavior. This diff changes the algorithm to process each arm
	independently, and then use a more balanced algorithm to summarize
	the result.

	Specialize the predicates that compute sets of free vars in various
	HLDS fragments to work either with ordinary_nonlocals or
	code_gen_nonlocals without making the same decision repeatedly.

	Move some code out of large predicates into predicates of their own.

compiler/Mercury.options:
	Specify the compiler option that can exploit this specialization
	to make the code run faster.

compiler/simplify.m:
	Use a more efficient data structure for recording the parameters
	of an invocation of simplification.

	Change some predicate names and function symbol names to avoid
	ambiguity.

compiler/common.m:
compiler/deforest.m:
compiler/deforest.m:
compiler/make_hlds_warn.m:
compiler/mercury_compile.m:
compiler/pd_util.m:
compiler/stack_opt.m:
compiler/term_constr_build.m:
	Conform to the changes in simplify.m and/or instmap.m.

compiler/mercury_compile.m:
	Fix a bug in progress messages for polymorphism.m.

compiler/equiv_type_hlds.m:
	Most of the time, substitutions inside insts have no effect, because
	very few insts include any reference to a types. Instead of the old
	approach of building new insts and then throwing them away if they
	are the same as the old ones, don't build new insts at all if the
	old inst contains no types.

compiler/common.m:
	Change some predicate names to make them clearer.

compiler/hlds_clauses.m:
	Record the number of clauses so far, to allow a more informative
	progress message to be printed.

compiler/add_clause.m:
	Print this more informative progress message.

	Conform to the changes in superhomogeneous.m.

compiler/code_gen.m:
	Use the context of the predicate's first clause (which will be the
	context of the first clause head) as the context of the predicate's
	interface events. Unlike the context of the body goal, this won't
	be affected by program transformations such as wrapping a
	from_ground_term scope around some goals. It is better for users
	anyway, since the old policy lead to contexts in the middle of
	procedure bodies if the top level goal was a disjunction, switch or
	if-then-else.

tests/debugger/*.exp:
	Update the expected outputs to conform to the change to code_gen.m.
2006-03-29 00:57:46 +00:00
Julien Fischer
eab8879f82 Fix a line that exceeds 80 characters in length.
Estimated hours taken: 0.1
Branches: main

compiler/options.m:
	Fix a line that exceeds 80 characters in length.
2006-03-28 08:27:43 +00:00
Richard James Fothergill
44c778b15a Bugfixes for constraints based mode analysis (propagation solver).
Estimated hours taken: 35
Branch: main.

Bugfixes for constraints based mode analysis (propagation solver).

Fix a bug where the producer/consumer analysis was failing when implied modes
were required in predicate calls. Appropriate unifications are now generated
so as to allow for such calls.

Fix a bug where conservative approximation of nonlocals sets was leading
analysis to assume a goal consumed a variable it didn't actually use. This was
fixed by running a requantification before processing a module.

Finally, the transformation to hhf was leaving some nonlocals sets inaccurate,
so some producing/consuming conjuncts for certain program variables were being
ignored, resulting in a failure in producer/consumer analysis. This was fixed
by no longer transforming to hhf for the propagation solver constraints
based mode analysis. This is fine for now, because the current version
uses only simple constraints and doesn't need hhf. However, if it is going
to be extended to the full constraints system (that handles subtyping and
partial instantiation) the transformation to hhf will have to be used,
and the nonlocals sets bug fixed.

compiler/handle_options.m
	Added option implications since the antecedents do nothing
	without the consequents:
	debug_mode_constraints -> prop_mode_constraints
	simple_mode_constraints -> mode_constraints

compiler/mercury_compile.m
	The results of constraints based mode analysis are no longer
	discarded - they are now passed on to the rest of the compiler.
	The original mode analysis can now finish anything constraints
	based mode analysis hasn't done, but it shouldn't have to do
	any reordering of conjunctions.

compiler/mode_constraints.m
	When the propagation solver is used, the transformation to HHF
	no longer occurs, and unifications are generated to allow for
	use of implied modes in predicate calls. Then, the module is
	requantified to make nonlocals sets more accurate.

compiler/prop_mode_constraints.m:
	Implemented a HLDS tranformation that introduces unifications
	to allow constraints based mode analysis to consider implied
	modes in predicate calls.

tests/valid/Mmakefile:
	Included some regression tests for these bugs, and some fairly
	large modules that the analysis currently runs correctly on.

tests/valid/Mercury-options:
	Included the option --prop-mode-constraints for the new tests.

tests/valid/mc_bag.m:
tests/valid/mc_graph.m:
	Reasonably large tests taken and modified from the standard library
	that the propagation solver approach to constraints based mode
	analysis currently runs correctly on.

tests/valid/mc_extra_nonlocals.m:
tests/valid/mc_hhf_nonlocals_bug.m:
tests/valid/mc_implied_modes.m:
	Small tests that used to fail under the above bugs.
2006-03-27 13:25:54 +00:00
Zoltan Somogyi
12deb40264 Rename all the get access predicates in these modules that don't
Estimated hours taken: 0.1
Branches: main

compiler/hlds_clauses.m:
compiler/hlds_pred.m:
	Rename all the get access predicates in these modules that don't
	already have put "get" in their name. (The names of the set access
	predicates were OK already.)

compiler/*.m:
	Conform to the above.

All this was done by this sed script:

s/clauses_info_varset/clauses_info_get_varset/
s/clauses_info_explicit_vartypes/clauses_info_get_explicit_vartypes/
s/clauses_info_vartypes/clauses_info_get_vartypes/
s/clauses_info_headvars/clauses_info_get_headvars/
s/clauses_info_clauses_rep/clauses_info_get_clauses_rep/
s/clauses_info_rtti_varmaps/clauses_info_get_rtti_varmaps/
s/pred_info_import_status/pred_info_get_import_status/
s/pred_info_arg_types/pred_info_get_arg_types/
s/pred_info_typevarset/pred_info_get_typevarset/
s/pred_info_tvar_kinds/pred_info_get_tvar_kinds/
s/pred_info_procedures/pred_info_get_procedures/
s/proc_info_context/proc_info_get_context/
s/proc_info_varset/proc_info_get_varset/
s/proc_info_vartypes/proc_info_get_vartypes/
s/proc_info_headvars/proc_info_get_headvars/
s/proc_info_inst_varset/proc_info_get_inst_varset/
s/proc_info_maybe_declared_argmodes/proc_info_get_maybe_declared_argmodes/
s/proc_info_argmodes/proc_info_get_argmodes/
s/proc_info_maybe_arglives/proc_info_get_maybe_arglives/
s/proc_info_declared_determinism/proc_info_get_declared_determinism/
s/proc_info_inferred_determinism/proc_info_get_inferred_determinism/
s/proc_info_goal/proc_info_get_goal/
s/proc_info_can_process/proc_info_get_can_process/
s/proc_info_rtti_varmaps/proc_info_get_rtti_varmaps/
s/proc_info_eval_method/proc_info_get_eval_method/
s/proc_info_is_address_taken/proc_info_get_is_address_taken/
s/proc_info_stack_slots/proc_info_get_stack_slots/
s/proc_info_liveness_info/proc_info_get_liveness_info/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
s/proc_info_context/proc_info_get_context/
2006-03-27 09:36:34 +00:00
Julien Fischer
836ef1c72f Add a new option `--no-warn-obsolete' that disables warnings about calls to
Estimated hours taken: 1
Branches: main

Add a new option `--no-warn-obsolete' that disables warnings about calls to
predicates and functions that have `:- pragma obsolete' declarations.
Previously, this was controlled by `--no-warn-simple-code', but that was
non-obvious and you wouldn't necessarily want to disable all the other
warnings.  `--no-warn-simple-code' will no longer disable warnings about
obsolete procedures.

Avoid emitting warnings for calls to obsolete procedures if those calls
are from within a procedure that is itself obsolete.

doc/user_guide.texi:
compiler/options.m:
	Add a new option: `--no-warn-obsolete'.

tests/valid/Mmakefile:
tests/valid/Mercury.options:
tests/valid/no_warn_obsolete.m:
	Test the new option.

compiler/simplify.m:
	Don't warn about calls to obsolete procedures from obsolete
	procedures.

tests/warnings/Mmakefile:
tests/warnings/spurious_obsolete.m:
tests/warnings/spurious_obsolete.exp:
	Test case for the above.
2006-03-27 06:56:22 +00:00
Zoltan Somogyi
d13d5ea281 Convert all __s to dots.
Estimated hours taken: 0.2
Branches: main

compiler/typecheck.m:
	Convert all __s to dots.

compiler/modules.m:
	Misc minor cleanups.
2006-03-27 02:11:51 +00:00
Julien Fischer
0138ad6208 Add obsolete pragmas to the interface of bintree_set.
Estimated hours taken: 0.5
Branches: main

Add obsolete pragmas to the interface of bintree_set.

library/bintree_set.m:
	Add obsolete pragmas to the procedures in the interface of this
	module; the documentation has said they are obsolete for a very long
	time.

library/Mmakefile:
	Avoid warnings about calls to obsolete pragmas within bintree_set.

compiler/llds_out.m:
	Replace usage of bintree_set with set_tree234, since the former is
	obsolete.
2006-03-27 01:01:04 +00:00
Julien Fischer
a4519ed079 Move the all-solutions predicates from the library module std_util into their
Estimated hours taken: 4
Branches: main

Move the all-solutions predicates from the library module std_util into their
own module, solutions.

Move semidet_fail, semidet_succeed, cc_multi_equal and dynamic cast from
std_util.m into builtin.m.

Add some more utility functions for performing determinism or purity casts.
(The later are primarily intended for use by solver implementors.)

library/std_util.m:
	Move the all-solutions predicates into their own module, solutions.m.
	For now there are (obsolete) forwarding predicates from this module to
	the new one.  The forwarding predicates will be included in the
	upcoming 0.13 release and then removed in later versions.

	Move semidet_succeed, semidet_fail, cc_multi_equal and dynamic_cast
	to builtin.m

library/solutions.m:
	New file.  This is the new home for the all-solutions predicates.
	This is pretty much cut and pasted from std_util (with module
	qualifiers updated accordingly).  I've rearranged the code in a more
	top-down fashion as per our current coding standard.

library/builtin.m:
	Move semidet_fail/0, semidet_succeed/0, cc_multi_equal/2 and
	dynamic_cast/2 to this module.

	Add semidet_true/0 and semidet_false/0 as synonyms for semidet_fail/0
	and semidet_succeed/0.

	Add impure_true/0 and semipure_true/0.  These are useful for performing
	purity casts, e.g. in solver implementations.

library/library.m:
	Add the new module.

NEWS:
	Announce the changes.

library/*.m:
	Update to conform to the above.

compiler/const_prop.m:
	Update evaluate_semidet_call/5 with the new module name for
	dynamic_cast.

compiler/*.m:
	Module qualify calls to solutions to either disambiguate them from the
	versions in std_util (where they weren't module qualified) or change
	the module qualifier where they were (to avoid warnings about calls to
	the now deprecated versions).

tests/debugger/declarative/solutions.*:
	Rename this module as the name conflicts with the new library module.

tests/debugger/declarative/solns.*:
	Renamed version of above (with updated expected output).

tests/debugger/declarative/Mmakefile:
	Handle the renamed version of the solutions test.

tests/debugger/all_solutions.m:
tests/debugger/declarative/args.m:
tests/debugger/declarative/library_forwarding.m:
tests/hard_coded/constant_prop_2.m:
tests/invalid/multisoln_func.m:
tests/invalid/one_member.m:
tests/invalid/promise_equivalent_claueses.m:
tests/valid/simplify_bug2.m:
tests/valid/solv.m:
	Update to conform to the above changes.

sample/solutions/*.m:
	Update to conform to the above changes.
2006-03-24 04:40:59 +00:00
Zoltan Somogyi
3ebda6545f Move the stuff currently in hlds_pred.m that deals with clauses into a new
Estimated hours taken: 1.5
Branches: main

Move the stuff currently in hlds_pred.m that deals with clauses into a new
module, hlds_clauses.m.

Move the stuff currently in hlds_pred.m that deals with RTTI into a new
module, hlds_rtti.m.

Move the stuff currently in hlds_module.m that deals with predicate tables
into a new module, pred_table.m.

These changes make hlds_pred.m and hlds_module.m much more cohesive, but there
are no changes in algorithms.

compiler/hlds_clauses.m:
compiler/hlds_rtti.m:
compiler/pred_table.m:
	New modules as described above. In some cases, fix mixleading or
	ambiguous predicate names in the process, and convert a few predicates
	to functions.

compiler/hlds_pred.m:
compiler/hlds_module.m:
	Delete the stuff moved to other modules.

compiler/*.m:
	In modules that need the functionality moved a new module, import
	the new module. It is rare for all the new modules to be needed,
	and many modules don't need any of the new modules at all. (For
	example, of the 200+ modules that import hlds_module.m, only about 40
	need pred_table.m.)

	Conform to the few minor changes to e.g. predicate names.

compiler/notes/compiler_design.html:
	Document the new modules.
2006-03-24 03:04:20 +00:00
Peter Wang
2b37a06fbe Disable forking by `mmc --make' if built in a parallel grade as
Estimated hours taken: 1
Branches: main

compiler/process_util.m:
	Disable forking by `mmc --make' if built in a parallel grade as
	threads and fork() do not mix.
2006-03-24 02:40:42 +00:00
Peter Ross
3cda918ba5 Add a comment which explains why we call svmap.set instead
Estimated hours taken: 0.1
Branches: main

compiler/recompilation.usage.m:
	Add a comment which explains why we call svmap.set instead
	of svmap.det_insert.
2006-03-22 06:28:06 +00:00
Peter Ross
1f324f5b56 Fix a compiler abort which was triggered when using --smart-recompilation
Estimated hours taken: 0.5
Branches: main

Fix a compiler abort which was triggered when using --smart-recompilation
when compiling a sub-module which also imports one of its ancestor
modules.

compiler/recompilation.usage.m:
	Use svn_map.set instead of svn_map.det_insert when calling
	insert_into_imported_items_map as it is possible for this
	routine to be called twice with the same inputs.  This is
	because it's possible for visible_module to return the same
	answer twice (once as an ancestor module the second as an
	imported module), thus we will try and insert the data twice.
2006-03-22 04:34:25 +00:00
Zoltan Somogyi
ef55b420fd Remove from std_util.m the predicates that merely call predicates in
Estimated hours taken: 12
Branches: main

Remove from std_util.m the predicates that merely call predicates in
the type_desc, construct and deconstruct modules, to reduce clutter
in std_util.m.

library/std_util.m:
	Remove those predicates from std_util.m.

library/deconstruct.m:
	Add a type we need that was previously defined in std_util.m.

library/construct.m:
	Delete some module qualifications that have now become unnecessary,

browser/browse.m:
browser/browser_info.m:
browser/declarative_tree.m:
browser/dl.m:
browser/help.m:
browser/sized_pretty.m:
browser/term_rep.m:
compiler/bytecode_gen.m:
compiler/llds_out.m:
compiler/mlds_to_il.m:
compiler/mlds_to_managed.m:
library/assoc_list.m:
library/hash_table.m:
library/io.m:
library/pprint.m:
library/private_builtin.m:
library/prolog.m:
library/require.m:
library/rtti_implementation.m:
library/store.m:
library/term.m:
library/term_to_xml.m:
library/version_hash_table.m:
mdbcomp/program_representation.m:
	Import type_desc.m, construct.m and/or deconstruct.m to provide
	definitions of functions or predicates that up till now were in
	std_util.m. Modify the calls if the called function or predicate
	had a slightly different interface in std_util.m.

	Also, convert term_to_xml.m to four-space indentation, and delete
	unnecessary module qualifications in term.m.

tests/debugger/polymorphic_output.{m,inp,exp,exp2}:
tests/hard_coded/copy_pred_2.m:
tests/hard_coded/deconstruct_arg.exp:
tests/hard_coded/deconstruct_arg.exp2:
tests/hard_coded/deconstruct_arg.m:
tests/hard_coded/elim_special_pred.m:
tests/hard_coded/existential_bound_tvar.m:
tests/hard_coded/expand.m:
tests/hard_coded/foreign_type2.m:
tests/hard_coded/higher_order_type_manip.m:
tests/hard_coded/nullary_ho_func.m:
tests/hard_coded/tuple_test.m:
tests/hard_coded/type_ctor_desc.m:
tests/hard_coded/type_qual.m:
tests/hard_coded/write_xml.m:
tests/hard_coded/sub-modules/class.m:
tests/hard_coded/sub-modules/nested.m:
tests/hard_coded/sub-modules/nested2.m:
tests/hard_coded/sub-modules/nested3.m:
tests/hard_coded/sub-modules/parent.m:
tests/hard_coded/sub-modules/parent2.child.m:
tests/hard_coded/typeclasses/existential_rtti.m:
tests/recompilation/type_qual_re.m.1:
cvs update: Updating tests/submodules
cvs update: Updating tests/tabling
cvs update: Updating tests/term
cvs update: Updating tests/tools
cvs update: Updating tests/trailing
cvs update: Updating tests/typeclasses
cvs update: Updating tests/valid
tests/valid/agc_unbound_typevars.m:
tests/valid/agc_unbound_typevars2.m:
tests/valid/agc_unused_in.m:
	Replace references to the deleted predicates in std_util with
	references to the equivalent predicates in type_desc, construct
	and/or deconstruct. In test cases that already tested both the
	functionality in std_util and in the other modules, simply delete
	the part exercising std_util.
2006-03-22 02:56:44 +00:00