Commit Graph

197 Commits

Author SHA1 Message Date
Zoltan Somogyi
be5b71861b Convert almost all the compiler modules to use . instead of __ as
Estimated hours taken: 6
Branches: main

compiler/*.m:
	Convert almost all the compiler modules to use . instead of __ as
	the module qualifier.

	In some cases, change the names of predicates and types to make them
	meaningful without the module qualifier. In particular, most of the
	types that used to be referred to with an "mlds__" prefix have been
	changed to have a "mlds_" prefix instead of changing the prefix to
	"mlds.".

	There are no algorithmic changes.
2006-03-17 01:40:46 +00:00
Julien Fischer
9d8ca0ad37 Remove residual parts of the Aditi backend that weren't deleted the other day.
Estimated hours taken: 1.5
Branches: main

Remove residual parts of the Aditi backend that weren't deleted the other day.

configure.in:
Mmake.common.in:
	Remove support for enabling the Aditi backend.

runtime/mercury_aditi.h:
	Remove this file.

runtime/Mmakefile:
runtime/mercury.h:
runtime/mercury_imp.h:
runtime/mercury_ho_call.[ch]:
runtime/mercury_wrapper.[ch]:
	Delete support for Aditi in the runtime.

scripts/Mmake.rules:
scripts/Mmake.vars.in:
scripts/c2init.in:
scripts/parse_ml_options.sh-subr.in:
	Remove mmake support for building .rlo files, etc.

util/mkinit.c:
	Remove Aditi specific code.

compiler/bytecode_data.m:
compiler/closure_analysis.m:
compiler/code_model.m:
compiler/compile_target_code.m:
compiler/det_analysis.m:
compiler/handle_options.m:
compiler/hlds_goal.m:
compiler/hlds_module.m:
compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/make_hlds_error.m:
compiler/make_hlds_passes.m:
compiler/mercury_to_mercury.m:
compiler/mlds_to_gcc.m:
compiler/modecheck_call.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/options.m:
compiler/prog_data.m:
compiler/prog_foreign.m:
compiler/prog_mode.m:
compiler/prog_type.m:
compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/term_errors.m:
compiler/unify_proc.m:
mdbcomp/prim_data.m:
	Remove residual support for Aditi.

library/ops.m:
	Remove the 'aditi_bottom_up' and 'aditi_top_down' operators from the
	ops table.

doc/reference_manual.texi:
doc/user_guide.texi:
	Delete the sections on the Aditi interface.

extras/aditi/*:
	Delete this.
2006-02-24 07:11:21 +00:00
Peter Wang
613ab045cd Don't try to reanalyse suboptimal, non-local modules when using
Estimated hours taken: 10
Branches: main

compiler/make.program_target.m:
	Don't try to reanalyse suboptimal, non-local modules when using
	`--intermodule-analysis'.

compiler/exception_analysis.m:
compiler/trailing_analysis.m:
compiler/unused_args.m:
	When looking up an analysis result, if the result is from a non-local
	module and is `suboptimal', just assume it is `optimal' since we can't
	make requests to or reanalyse the non-local module anyway.  On the
	other hand, if we look up a result from a local module which doesn't
	yet exist, record the default (suboptimal) result that we are using
	into the module's analysis registry, so that when the module is
	reanalysed, if the answer pattern changes we will know that it changed
	and the modules which made use of the default result can be marked.
2006-02-22 00:32:14 +00:00
Julien Fischer
b4ecae2f71 Emit an error message if --intermod-opt' and --intermodule-analysis' are
Estimated hours taken: 0.5
Branches: main

Emit an error message if `--intermod-opt' and `--intermodule-analysis' are
both enabled since they are not compatible with each other.

Emit an error message with `--make' and `--trans-intermod-opt' are enabled
together.  We don't support transitive-intermodule optimization with `mmc
--make' but enabling both options together causes problems for termination
analysis (it expects that at least one more recompile is going to be performed
but it never is).

compiler/handle_options.m:
	Emit an error message if `--intermod-opt' and `--intermodule-analysis'
	are both specified.

	Emit an error message if `--make' and `--trans-intermod-opt' are both
	specified.

compiler/make.m:
compiler/make.module_dep_file.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/options.m
	Remove some preliminary support for transitive-intermodule
	optimization.  We aren't going to implement it for mmc --make.

	Update the TODO list.

	Fix some formatting.
2006-02-13 07:57:22 +00:00
Peter Wang
755cf5aa15 This patch improves the handling of libraries with the intermodule
Estimated hours taken: 25
Branches: main

This patch improves the handling of libraries with the intermodule
analysis framework.  `.analysis' files can now be installed into library
directories and used when analysing local modules.

analysis/analysis.m:
analysis/analysis.file.m:
compiler/mmc_analysis.m:
	Separate the `module_id_to_file_name' method of the `compiler'
	typeclass into `module_id_to_read_file_name' and
	`module_id_to_write_file_name'.  Add `module_is_local' method.

	Change the calls to `module_id_to_file_name' appropriately for the
	context.  This allows us to find the `.analysis' files of library
	modules.

	Only write results, IMDG and request files for local modules.

	Force `.analysis' files of the currently-analysed module to be written
	out, even if it would be empty.  This avoids us trying to reanalyse the
	module later.

compiler/options.m:
	Add internal compiler option `--local-module-id'.

compiler/make.dependencies.m:
	Add `make_local_module_id_options' to build a list of
	`--local-module-id' options.

compiler/make.module_target.m:
	Add predicate `make_module_target_extra_options' so we can pass the
	`--local-module-id' options.

compiler/make.program_target.m:
	Analyse modules in bottom up order, according to the module dependency
	graph.  The current analyses don't support non-default call patterns,
	so this should reduce the number of analysis passes to get (close to)
	to a fixpoint.

	Pass `--local-module-id' options when building analysis files, so the
	analysis framework knows which modules are local.

	Install `.analysis' files when installing libraries.

compiler/modules.m:
	Make `.analysis', `.analysis_date', `.imdg' and `.request' files
	architecture- or grade-specified so they go into grade directories
	when `--use-grade-subdirs' is used.

	Search for `.analysis' files in the same directories as `.opt' and
	`.trans_opt' files.

	Export predicate `add_module_relations' to help build module dependency
	graphs.

compiler/mercury_compile.m:
	Fix a bug where the unused argument optimisation pass was always being
	run if `--intermodule-analysis' was enabled.
2006-02-13 03:47:44 +00:00
Peter Wang
cdcdf90ac8 `mmc --make --use-grade-subdirs <linked-target>' makes symlinks/copies of the
Estimated hours taken: 2
Branches: main

`mmc --make --use-grade-subdirs <linked-target>' makes symlinks/copies of the
linked target into the current directory, but doesn't do so if the linked
target is already up to date.  This patch makes it always make the
symlink/copy, so that it is easy to switch between two or more grades even if
no source files were modified.

compiler/compile_target_code.m:
	Separate out the code to make symlinks/copies of linked targets from
	the `link' predicate into a predicate `post_link_make_symlink_or_copy'.

	Move `shared_libraries_supported' from make.program_target.m into
	compile_target_code.m.

compiler/make.program_target.m:
	Call `post_link_make_symlink_or_copy' if `--use-grade-subdirs' is
	enabled, and the linked target is otherwise up-to-date.
	Write out a message in `--verbose-make' mode.

	Conform to the move of `shared_libraries_supported'.

compiler/make.util.m:
	Add a predicate `maybe_symlink_or_copy_linked_target_message'.
2006-02-13 03:04:36 +00:00
Julien Fischer
6099dbb2d5 Fix a bug with mmc --make and shared libraries on Darwin.
Estimated hours taken: 4
Branches: main

Fix a bug with mmc --make and shared libraries on Darwin.  The problem was
that the install_name for the library was being incorrectly set.

compiler/modules.m:
	Set the value of the install-name path correctly.  If the user doesn't
	specify a value then generate one based on the current value of
	INSTALL_PREFIX.

compiler/options.m:
	Delete the bogus default value for the shlib-linker-install-name-path
	option.

compiler/compile_target_code.m:
	When linking a shared library on Darwin set the install-name path
	correctly, in particular we need to set it to the directory we
	are going to install the library in, *not* where the library is
	being built.

compiler/make.program_target.m:
	Mention that any changes to modules.get_install_name_option need to
	be reflected here.
2006-02-08 04:51:05 +00:00
Peter Wang
ad917cd909 Fix some problems with `mmc --make' on Windows (or possibly any platform
Estimated hours taken: 3
Branches: main

Fix some problems with `mmc --make' on Windows (or possibly any platform
without symbolic links).

compiler/make.program_target.m:
	Don't try to install `.mh' files into `inc/Mercury/mhs' as this is
	(seems) unnecessary.

	Make the symlinks or directories `ints/mhs' and `ints/mihs' when
	installing libraries.

	Correct a typo which created the directories
	`lib/<grade>/inc/Mercury/mih' instead of
	`lib/<grade>/inc/Mercury/mihs'.

compiler/modules.m:
	Make `copy_file' first attempt to use the `--install-command' command,
	in order to preserve more information about the file.  In particular,
	with `--use-grade-subdirs' we want executables copied from the grade
	subdirectories to keep the executable bit.
2006-02-07 00:06:20 +00:00
Peter Wang
d202be54a0 This patch mainly adds the ability to perform intermodule analysis of modules
Estimated hours taken: 20
Branches: main

This patch mainly adds the ability to perform intermodule analysis of modules
as a separate step from code generation.  It makes a start on automatic
reanalysis of modules if their .analysis files become invalid or suboptimal.

analysis/analysis.file.m:
analysis/analysis.m:
	Add a predicate `read_module_overall_status' to read just the overall
	status of an analysis file.

	Fix a bug where analysis results were being discarded (upon reading) if
	the module's overall status was `invalid'.  We can't do that as then we
	wouldn't know which results changed after reanalysis.

	Touch a `FOO.analysis_date' file after module `FOO' is analysed.
	This is needed to indicate the time at which `FOO' was last analysed,
	as `FOO.analysis' can be modified at other times.

	Add a mutable boolean variable `debug_analysis' that can be set
	to enable debugging messages for the analysis framework.

compiler/handle_options.m:
compiler/options.m:
	Add new compiler options `--make-analysis-registry',
	`--debug-intermodule-analysis' and `--analysis-repeat'.

compiler/make.dependencies.m:
	Add `.analysis' files as dependencies of compiled code files if
	`--intermodule-analysis' is used.

compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
	Add a `FOO.analyse' pseudo-target to `mmc --make'.  This produces all
	the `.analysis' files needed to compile the top-level module `FOO',
	reanalysing modules until none of the `.analysis' files are invalid.
	The `--analysis-repeat' option can also be used to force
	`suboptimal' modules to be reanalysed a number of times.

	Perform an analysis pass when building executables or libraries to make
	sure that compilation does not proceed with invalid analysis files.

	Treat `.analysis' files specially when checking whether they are out of
	date.  Analysis files require looking at their contents to determine
	whether they are invalid (in which case they are out of date), or valid
	(in which case we look at the timestamp of the corresponding
	`.analysis_date' file).

compiler/mercury_compile.m:
	Make `.analysis' be written out only when `--make-analysis-registry'
	is used, like `--make-transitive-optimization-interface'.
	`mmc --make' runs the compiler the `--make-analysis-registry'
	option as appropriate.

compiler/exception_analysis.m:
compiler/trailing_analysis.m:
compiler/unused_args.m:
	Only record intermodule dependencies and analysis results when
	`--make-analysis-registry' is enabled, not when
	`--intermodule-analysis' is enabled.

doc/user_guide.texi:
	Document `--debug-intermodule-analysis' and `--analysis-repeat'.
2006-02-06 05:39:45 +00:00
Peter Wang
f2d121b6e1 This is a follow up to a previous patch designed to solve a
Estimated hours taken: 2
Branches: main

This is a follow up to a previous patch designed to solve a
problem where "mmc --make libfoo.install --libgrade <bar>" would
install into a grade subdirectory named <bar> in non-canonical form.
The previous patch was completely broken for "hlc" grades (at least).

compiler/handle_options.m:
	Revert r1.252 as it did not properly canonicalise grade strings.

compiler/make.program_target.m:
	Use `grade_directory_component' to find out which directory a grade's
	files should be installed into instead of assuming the verbatim grade
	string passed in with `--libgrade'.
2006-02-03 05:46:21 +00:00
Peter Wang
af878d04f9 Some work on the intermodule analysis framework.
Estimated hours taken: 45
Branches: main

Some work on the intermodule analysis framework.  The main changes are that
modules and analysis results have statuses associated with them, which are
saved in the `.analysis' files, and there is now code to handle intermodule
dependency graphs (that record which modules are dependent on a particular
analysis result).

Automatic recompilation of modules that use out of date or invalid analysis
results from other modules is not handled yet.

analysis/README:
analysis/analysis.m:
analysis/analysis.file.m:
	Remove the `FuncInfo' type variable everywhere.  This was originally
	designed to be used by analyses to store "extra" information that
	would be passed from an analysis implementation through the analysis
	framework, back to methods defined by the analysis implementation
	itself.

	The main problem was that `FuncInfo' made `Call' or `Answer' values
	hard to compare, as a `FuncInfo' value always had to be present for a
	comparison to be made (because the methods in the partial_order
	typeclass required FuncInfos).  One example of when this is hard to
	satisfy is when we are ready to write everything out to disk at the
	end of all analyses.  At this step there is much comparing of Call
	and Answer values, but this step is not invoked by any particular
	analysis pass.  To compare values we would need to get the FuncInfos
	from somewhere, which means we would have to store FuncInfos in the
	analysis_info maps as well.  And any time you have two FuncInfos, you
	need to choose one of the FuncInfos arbitrarily.

	Since FuncInfos would have to be read/written with every Call and
	Answer value, including IMDGs, I have changed it so that that any
	information which might be be stored in a `FuncInfo' should be stored
	in the corresponding `Call' value itself.

	Change the format of analysis result files to include an overall
	status for the module and a status for each analysis result.  The
	statuses record whether the module or analysis result could be
	improved by further compilation, or if the module or analysis result
	is no longer valid.

	Add code to read and write intermodule dependency graphs (IMDGs).  The
	IMDG file for module M records all the modules which depend on an
	analysis result for a procedure defined in M.

	Bump analysis file format version numbers as they are incompatible
	with earlier versions.

compiler/mercury_compile.m:
	Make `mercury_compile_after_front_end' use state variables for
	copies of the HLDS and update it to match changes in the intermodule
	analysis framework.

compiler/mmc_analysis.m:
	Add the trail usage analysis to the list of analyses to be used with
	the intermodule analysis framework.

	Update the entry for unused argument elimination.

	Add predicate `module_id_func_id'.

compiler/add_pragma.m:
compiler/hlds_module.m:
compiler/trailing_analysis.m:
	Make the trail usage analysis pass able to make use of the intermodule
	analysis framework.

	Associate each `trailing_status' in the `trailing_info' map with an
	`analysis_status', i.e. whether it is optimal or not.

compiler/unused_args.m:
	Update to match the removal of `FuncInfo' arguments and the
	addition of analysis statuses.

	Record the unused argument analysis result for a procedure even if
	all of the procedures arguments are used, so that callers of the
	procedure will know not to request more precise answers.

	Record the dependence of the current module on analysis results from
	other modules.

compiler/goal_util.m:
	Add predicate `pred_proc_ids_from_goal/2'.

compiler/make.m:
compiler/make.dependencies.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/modules.m:
scripts/Mmake.vars.in:
	Make `mmc --make' and `mmake' realclean `.analysis', `.imdg' and
	`.request' files of non-library modules.  Files for imported library
	modules won't be deleted, but they probably shouldn't be generated in
	the first place.

NEWS:
library/list.m:
	Add a `list.map2_foldl2' predicate.

compiler/Mmakefile:
	Add the `analysis' directory to the list of directories to be
	processed by mtags.
2006-01-25 03:27:38 +00:00
Peter Wang
881b2d8594 Add a --lib-linkage' accumulating option for mmc --make'.
Estimated hours taken: 3
Branches: main

Add a `--lib-linkage' accumulating option for `mmc --make'.  This option
allows you to specify whether libraries should be installed for shared
linking (`shared') or static linking (`static').  The option corresponds
to an options file or environment variable called `LIB_LINKAGES'.

compiler/options.m:
compiler/options_file.m:
doc/user_guide.texi:
	Add and document `--lib-linkage' option and `LIB_LINKAGES'
	variable.

	Unrelated change: document `--no-libgrade' option.

compiler/handle_options.m:
	If no --lib-linkage option has been specified, default to the
	set of all possible linkages.

compiler/make.program_target.m:
	Skip building/installing static or shared libraries according to
	the `--lib-linkage' options.
2006-01-06 04:06:55 +00:00
Peter Wang
6c14c1cbbe Fix some problems with `mmc --make'.
Estimated hours taken: 8
Branches: main

Fix some problems with `mmc --make'.

compiler/compile_target_code.m:
	In `link' predicate, after the file has been created in a grade
	subdirectory it would try to symlink or copy the file into the user
	directory.  This would fail if a file of the same name already existed
	there, so remove it before attempting the symlink/copy.

compiler/make.program_target.m:
	Prevent `mmc --make libFOO' from trying to produce a shared library
	if they are unsupported on the current architecture.

	Disable the logic to conditionally generate `.mh' files so as to avoid
	trouble with Mmake, which expects them to always exist.

	Fix a typo that tried to install `.mih' files into `int' directories
	instead of `ints'.

compiler/modules.m:
	Make `make_symlink_or_copy_file' write a newline after errors.
2005-12-05 02:17:21 +00:00
Julien Fischer
45fdb6c451 Use expect/3 in place of require/2 throughout most of the
Estimated hours taken: 4
Branches: main

compiler/*.m:
	Use expect/3 in place of require/2 throughout most of the
	compiler.

	Use unexpected/2 (or sorry/2) in place of error/1 in more
	places.

	Fix more dodgy assertion error messages.

	s/map(prog_var, mer_type)/vartypes/ where the latter is meant.
2005-11-28 04:11:59 +00:00
Zoltan Somogyi
f9fe8dcf61 Improve the error messages generated for determinism errors involving committed
Estimated hours taken: 8
Branches: main

Improve the error messages generated for determinism errors involving committed
choice contexts. Previously, we printed a message to the effect that e.g.
a cc pred is called in context that requires all solutions, but we didn't say
*why* the context requires all solutions. We now keep track of all the goals
to the right that could fail, since it is these goals that may reject the first
solution of a committed choice goal.

The motivation for this diff was the fact that I found that locating the
failing goal can be very difficult if the conjunction to the right is
a couple of hundred lines long. This would have been a nontrivial problem,
since (a) unifications involving values of user-defined types are committed
choice goals, and (b) we can expect uses of user-defined types to increase.

compiler/det_analysis.m:
	Keep track of goals to the right of the current goal that could fail,
	and include them in the error representation if required.

compiler/det_report.m:
	Include the list of failing goals to the right in the representations
	of determinism errors involving committed committed choice goals.

	Convert the last part of this module that wasn't using error_util
	to use error_util. Make most parts of this module just construct
	error message specifications; print those specifications (using
	error_util) in only a few places.

compiler/hlds_out.m:
	Add a function for use by the new code in det_report.m.

compiler/error_util.m:
	Add a function for use by the new code in det_report.m.

compiler/error_util.m:
compiler/compiler_util.m:
	Error_util is still changing reasonably often, and yet it is
	included in lots of modules, most of which need only a few simple
	non-parse-tree-related predicates from it (e.g. unexpected).
	Move those predicates to a new module, compiler_util.m. This also
	eliminates some undesirable dependencies from libs to parse_tree.

compiler/libs.m:
	Include compiler_util.m.

compiler/notes/compiler_design.html:
	Document compiler_util.m, and fix the documentation of some other
	modules.

compiler/*.m:
	Import compiler_util instead of or in addition to error_util.
	To make this easier, consistently use . instead of __ for module
	qualifying module names.

tests/invalid/det_errors_cc.{m,err_exp}:
	Add this new test case to test the error messages for cc contexts.

tests/invalid/det_errors_deet.{m,err_exp}:
	Add this new test case to test the error messages for unifications
	inside function symbols.

tests/invalid/Mmakefile:
	Add the new test cases.

tests/invalid/det_errors.err_exp:
tests/invalid/magicbox.err_exp:
	Change the expected output to conform to the change in det_report.m,
	which is now more consistent.
2005-10-28 02:11:03 +00:00
Ian MacLarty
2e04ddc748 Remove the architecture string from the installed directory structure
Estimated hours taken: 1
Branches: main and 0.12

Remove the architecture string from the installed directory structure
and put the executables in $PREFIX/bin, instead of
$PREFIX/lib/mercury/bin/$FULLARCH.

The reason for this change is to reduce the need for unix shell scripts in
the top-level bin directory that call the actual programs in the
lib/mercury/bin/FULLARCH directory.  The unix scripts can't be run on Windows
without a unix emulation environment like Cygwin.

Because the executables are now in the top-level bin directory, we cannot
install multiple architectures under the same directory structure.  However
this is not a real loss, since the binaries for different architectures can
just be installed to different locations, as we currently do anyway on
mundula.cs.mu.oz.au.

The plan is to rename mercury_compile to mmc and do away with the mmc unix
script.  This will allow mmc to be run on Windows without Cygwin or MSYS.
This proposal replaces a previous proposal to implement a C version of the
mmc script.  That solution turned out to be quite complicated and
unreliable.

This diff will also mean mdice, mslice and mtc_union will be in the same
directory as mmc, so will be in the PATH as long as mmc is in the PATH.

configure.in:
bindist/Mmakefile:
bindist/bindist.Makefile.in:
compiler/compile_target_code.m:
compiler/handle_options.m:
compiler/make.program_target.m:
debian/rules:
library/Mmakefile:
scripts/Mmake.vars.in:
scripts/mdprof.in:
scripts/mercury.bat.in:
scripts/mgnuc.in:
scripts/ml.in:
scripts/mmc.in:
scripts/mprof.in:
tools/run_all_tests_from_cron:
tools/test_mercury:
	Remove FULLARCH from the installed directory structure.
	Install executables to the top-level bin directory.
2005-10-25 10:17:29 +00:00
Zoltan Somogyi
905e4a114f Convert a bunch of modules to four-space indentation.
Estimated hours taken: 4
Branches: main

compiler/*.m:
	Convert a bunch of modules to four-space indentation.
	In the process, fix departures from our coding standards.

	In some cases, do minor other cleanups such as changing argument orders
	to be friendly to state variables.

	There are no algorithmic changes.
2005-10-12 23:51:38 +00:00
Julien Fischer
87fb88961c Minor cleanups for mmc --make. There are no algorithmic
Estimated hours taken: 0.5
Branches: main

Minor cleanups for mmc --make.  There are no algorithmic
changes.

compiler/make.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/process_util.m:
	Bring these modules into line with our current coding
	standard.
2005-04-26 04:32:49 +00:00
Zoltan Somogyi
34d5181f3a Bring these modules up to date with our current style guidelines.
Estimated hours taken: 4
Branches: main

compiler/mercury_to_mercury.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
compiler/make.module_dep_file.m:
compiler/make.util.m:
compiler/make.m:
	Bring these modules up to date with our current style guidelines.
	Use predmode declarations where appropriate. Use state variable syntax
	where appropriate. Switch to four-space indentation where this reduces
	the number of places with excessive indentation. Use explicit
	predicates instead of lambda expressions where appropriate.

compiler/*.m:
	Minor style fixes.
2005-03-30 00:50:21 +00:00
Zoltan Somogyi
e854a5f9d9 Major improvements to tabling, of two types.
Estimated hours taken: 32
Branches: main

Major improvements to tabling, of two types. The first is the implementation
of the loopcheck and memo forms of tabling for model_non procedures, and the
second is a start on the implementation of a new method of implementing
minimal model tabling, one that has the potential for a proper fix of the
problem that we currently merely detect with the pneg stack (the detection
is followed by a runtime abort). Since this new method relies on giving each
own generator its own stack, the grade component denoting it is "mmos"
(minimal model own stack). The true name of the existing method is changed
from "mm" to "mmsc" (minimal model stack copy). The grade component "mm"
is now a shorthand for "mmsc"; when the new method works, "mm" will be changed
to be a shorthand for "mmos".

configure.in:
scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/final_grade_options.sh-subr:
compiler/options.m:
	Handle the new way of handling minimal model grades.

scripts/mgnuc.in:
compiler/compile_target_code.m:
	Conform to the changes in minimal model grade options.

compiler/table_gen.m:
	Implement the transformations required by the loopcheck and memo
	tabling of model_non procedures, and the minimal model own stack
	transformation.

	The new implementation transformations use foreign_procs with extra
	args, since there is no point in implementing them both that way and
	with separate calls to library predicates. This required making the
	choice of which method to use at the top level of each transformation.

	Fix an oversight that hasn't caused problems yet but may in the future:
	mark goals wrapping the original goals as not impure for determinism
	computations.

compiler/handle_options.m:
	Handle the new arrangement of the options for minimal model tabling.
	Detect simultaneous calls for both forms of minimal model tabling,
	and generate an error message. Allow for more than one error message
	generated at once; report them all once rather than separately.

compiler/globals.m:
	Add a mechanism to allow a fix a problem detected by the changes
	to handle_options: the fact that we currently may generate a usage
	message more than once for invocations with more than one error.

compiler/mercury_compile.m:
compiler/make.program_target.m:
compiler/make.util.m:
	Use the new mechanism in handle_options to avoid generating duplicate
	usage messages.

compiler/error_util.m:
	Add a utility predicate for use by handle_options.

compiler/hlds_pred.m:
	Allow memo tabling for model_non predicates, and handle own stack
	tabling.

compiler/hlds_out.m:
	Print information about the modes of the arguments of foreign_procs,
	since this is useful in debugging transformations such as tabling
	that generate them.

compiler/prog_data.m:
compiler/layout_out.m:
compiler/prog_out.m:
runtime/mercury_stack_layout.h:
	Mention the new evaluation method.

compiler/goal_util.m:
	Change the predicates for creating calls and foreign_procs to allow
	more than one goal feature to be attached to the new goal. table_gen.m
	now uses this capability.

compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/polymorphism.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/typecheck.m:
compiler/unify_proc.m:
	Conform to the changes in goal_util.

compiler/code_info.m:
compiler/make_hlds.m:
compiler/modules.m:
compiler/prog_io_pragma.m:
	Conform to the new the options controlling minimal model
	tabling.

compiler/prog_util.m:
	Add a utility predicate for use by table_gen.m.

library/std_util.m:
	Conform to the changes in the macros for minimal model tabling grades.

library/table_builtin.m:
	Add the types and predicates required by the new transformations.

	Delete an obsolete comment.

runtime/mercury_grade.h:
	Handle the new minimal model grade component.

runtime/mercury_conf_param.h:
	List macros controlling minimal model grades.

runtime/mercury_tabling.[ch]:
	Define the types needed by the new transformations,

	Implement the performance-critical predicates that need to be
	hand-written for memo tabling of model_non predicates.

	Add utility predicates for debugging.

runtime/mercury_tabling_preds.h:
	Add the implementations of the predicates required by the new
	transformations.

runtime/mercury_mm_own_stacks.[ch]:
	This new module contains the first draft of the implementation
	of the own stack implementation of minimal model tabling.

runtime/mercury_imp.h:
	Include the new file if the grade needs it.

runtime/Mmakefile:
	Mention the new files, and sort the lists of filenames.

runtime/mercury_tabling_macros.h:
	Add a macro for allocating answer blocks without requiring them to be
	pointed to directly by trie nodes.

runtime/mercury_minimal_model.[ch]:
	The structure type holding answer lists is now in mercury_tabling.h,
	since it is now also needed by memo tabling of model_non predicates.
	It no longer has a field for an answer num, because while it is ok
	to require a separate grade for debugging minimal model tabling,
	it is not ok to require a separate grade for debugging memo tabling
	of model_non predicates. Instead of printing the answer numbers,
	print the answers themselves when we need to identify solutions
	for debugging.

	Change function names, macro names, error messages etc where this is
	useful to distinguish the two kinds of minimal model tabling.

	Fix some oversights wrt transient registers.

runtime/mercury_context.[ch]:
runtime/mercury_engine.[ch]:
runtime/mercury_memory.[ch]:
runtime/mercury_wrapper.[ch]:
	With own stack tabling, each subgoal has its own context, so record
	the identity of the subgoal owning a context in the context itself.
	The main computation's context is the exception: it has no owner.

	Record not just the main context, but also the contexts of subgoals
	in the engine.

	Add variables for holding the sizes of the det and nondet stacks
	of the contexts of subgoals (which should in general be smaller
	than the sizes of the corresponding stacks of the main context),
	and initialize them as needed.

	Initialize the variables holding the sizes of the gen, cut and pneg
	stacks, even in grades where the stacks are not used, for safety.

	Fix some out-of-date documentation, and conform to our coding
	guidelines.

runtime/mercury_memory_zones.[ch]:
	Add a function to test whether a pointer is in a zone, to help
	debugging.

runtime/mercury_debug.[ch]:
	Add some functions to help debugging in the presence of multiple
	contexts, and factor out some common code to help with this.

	Delete the obsolete, unused function MR_printdetslot_as_label.

runtime/mercury_context.h:
runtime/mercury_bootstrap.h:
	Move a bootstrapping #define from mercury_context.h to
	mercury_bootstrap.h.

runtime/mercury_context.h:
runtime/mercury_bootstrap.h:
	Move a bootstrapping #define from mercury_context.h to
	mercury_bootstrap.h.

runtime/mercury_types.h:
	Add some more forward declarations of type names.

runtime/mercury_dlist.[ch]:
	Rename a field to avoid assignments that dereference NULL.

runtime/mercury_debug.c:
runtime/mercury_memory.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_trace.c:
runtime/mercury_stacks.[ch]:
trace/mercury_trace_util.c
	Update uses of the macros that control minimal model tabling.

runtime/mercury_stack_trace.c:
	Provide a mechanism to allow stack traces to be suppressed entirely.
	The intention is that by using this mechanism, by the testing system
	won't have to provide separate .exp files for hlc grades, nondebug
	LLDS grades and debug LLDS grades, as we do currently. The mechanism
	is the environment variable MERCURY_SUPPRESS_STACK_TRACE.

tools/bootcheck:
tools/test_mercury:
	Specify MERCURY_SUPPRESS_STACK_TRACE.

trace/mercury_trace.c:
	When performing retries across tabled calls, handle memo tabled
	model_non predicates, for which the call table tip variable holds
	a record with a back pointer to a trie node, instead of the trie node
	itself.

trace/mercury_trace_internal.c:
	When printing tables, handle memo tabled model_non predicates. Delete
	the code now moved to runtime/mercury_tabling.c.

	Add functions for printing the data structures for own stack minimal
	model tabling.

tests/debugger/print_table.{m,inp,exp}:
	Update this test case to also test the printing of tables for
	memo tabled model_non predicates.

tests/debugger/retry.{m,inp,exp}:
	Update this test case to also test retries across memo tabled
	model_non predicates.

tests/tabling/loopcheck_nondet.{m,exp}:
tests/tabling/loopcheck_nondet_non_loop.{m,exp}:
	New test cases to test loopcheck tabled model_non predicates.
	One test case has a loop to detect, one doesn't.

tests/tabling/memo_non.{m,exp}:
tests/tabling/tc_memo.{m,exp}:
tests/tabling/tc_memo2.{m,exp}:
	New test cases to test memo tabled model_non predicates.
	One test case has a loop to detect, one has a need for minimal model
	tabling to detect, and the third doesn't have either.

tests/tabling/Mmakefile:
	Add the new test cases, and reenable the existing tc_loop test case.

	Rename some make variables and targets to make them better reflect
	their meaning.

tests/tabling/test_mercury:
	Conform to the change in the name of the make target.
2004-07-20 04:41:55 +00:00
Zoltan Somogyi
d332038ee1 Bring these modules up to date with our coding guidelines.
Estimated hours taken: 16
Branches: main

compiler/aditi_builtin_ops.m:
compiler/bytecode.m:
compiler/bytecode_backend.m:
compiler/bytecode_gen.m:
compiler/c_util.m:
compiler/code_gen.m:
compiler/deep_profiling.m:
compiler/deforest.m:
compiler/dependency_graph.m:
compiler/fact_table.m:
compiler/follow_code.m:
compiler/handle_options.m:
compiler/hlds_out.m:
compiler/il_peephole.m:
compiler/ilasm.m:
compiler/java_util.m:
compiler/liveness.m:
compiler/magic.m:
compiler/magic_util.m:
compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_dep_file.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/matching.m:
compiler/name_mangle.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/options.m:
compiler/options_file.m:
compiler/prog_io.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/saved_vars.m:
compiler/source_file_map.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/stratify.m:
compiler/switch_detection.m:
compiler/term_errors.m:
compiler/type_ctor_info.m:
compiler/unify_proc.m:
compiler/unique_modes.m:
	Bring these modules up to date with our coding guidelines. Use predmode
	syntax for declarations. Use state variable syntax where appropriate,
	and reorder arguments where this is needed for the use of state
	variable syntax. Remove module qualification from the names of defined
	predicates when the module qualification was used inconsistently
	(causing problems for the use of tags) or was causing problems with
	indentation.

	There are no changes in algorithms.
2004-06-30 02:48:20 +00:00
Zoltan Somogyi
885fd4a387 Remove almost all dependencies by the modules of parse_tree.m on the modules
Estimated hours taken: 12
Branches: main

Remove almost all dependencies by the modules of parse_tree.m on the modules
of hlds.m. The only such dependencies remaining now are on type_util.m.

compiler/hlds_data.m:
compiler/prog_data.m:
	Move the cons_id type from hlds_data to prog_data, since several parts
	of the parse tree data structure depend on it (particularly insts).
	Remove the need to import HLDS modules in prog_data.m by making the
	cons_ids that refer to procedure ids refer to them via a new type
	that contains shrouded pred_ids and proc_ids. Since pred_ids and
	proc_ids are abstract types in hlds_data, add predicates to hlds_data
	to shroud and unshroud them.

	Also move some other types, e.g. mode_id and class_id, from hlds_data
	to prog_data.

compiler/hlds_data.m:
compiler/prog_util.m:
	Move predicates for manipulating cons_ids from hlds_data to prog_util.

compiler/inst.m:
compiler/prog_data.m:
	Move the contents of inst.m to prog_data.m, since that is where it
	belongs, and since doing so eliminates a circular dependency.
	The separation doesn't serve any purpose any more, since we don't
	need to import hlds_data.m anymore to get access to the cons_id type.

compiler/mode_util.m:
compiler/prog_mode.m:
compiler/parse_tree.m:
	Move the predicates in mode_util that don't depend on the HLDS to a new
	module prog_mode, which is part of parse_tree.m.

compiler/notes/compiler_design.m:
	Mention prog_mode.m, and delete the mention of inst.m.

compiler/mercury_to_mercury.m:
compiler/hlds_out.m:
	Move the predicates that depend on HLDS out of mercury_to_mercury.m
	to hlds_out.m. Export from mercury_to_mercury.m the predicates needed
	by the moved predicates.

compiler/hlds_out.m:
compiler/prog_out.m:
	Move predicates for printing parts of the parse tree out of hlds_out.m
	to prog_out.m, since mercury_to_mercury.m needs to use them.

compiler/purity.m:
compiler/prog_out.m:
	Move predicates for printing purities from purity.m, which is part
	of check_hlds.m, to prog_out.m, since mercury_to_mercury.m needs to use
	them.

compiler/passes_aux.m:
compiler/prog_out.m:
	Move some utility predicates (e.g. for printing progress messages) from
	passes_aux.m to prog_out.m, since some predicates in submodules of
	parse_tree.m need to use them.

compiler/foreign.m:
compiler/prog_data.m:
	Move some types from foreign.m to prog_data.m to allow the elimination
	of some dependencies on foreign.m from submodules of parse_tree.m.

compiler/*.m:
	Conform to the changes above, mostly by updating lists of imported
	modules and module qualifications. In some cases, also do some local
	cleanups such as converting predicate declarations to predmode syntax
	and fixing white space.
2004-06-14 04:17:03 +00:00
James Goddard
9c55bbe0ab Implement mmake library installation for the Java grade.
Estimated hours taken: 10
Branches: main

Implement mmake library installation for the Java grade.

modules.m:
	Move code for extracting .class file lists into a form suited for jar
	out into a separate predicate list_class_files_for_jar/5.

compile_target_code.m:
	Added symbol `java_archive' as a `linked_target_type' type.
	Added java_archive case for every switch on linked_target_type.
	Added create_java_archive/7 which performs a similar function to
	create_archive/6 but for Java.

make.util.m:
        linked_target_file_name/5 implemented for `java_archive'

make.program_target.m:
	Implemented lib<module>.install target for the Java grade.
	Added .jar file to realclean list.
2004-02-19 00:58:28 +00:00
Fergus Henderson
594aa9edcb More improvements to the Mmake support for Java: handle "linking",
Estimated hours taken: 1
Branches: main

More improvements to the Mmake support for Java: handle "linking",
i.e. generate the shell script which invokes the Java interpreter.

compiler/modules.m:
	After generating the dependencies,
	if Target = java then call create_java_shell_script.

compiler/make.program_target.m:
compiler/modules.m:
	Move the definition of create_java_shell_script from
	make.program_target.m to modules.m, so that it can be
	used from generate_dependencies in modules.m.
	(It needs to go in modules.m rather than make.program_target.m
	because modules.m should not depend on make.*.m.  Also
	it can't go in ml_backend.java_util since modules.m
	should not depend on ml_backend.*.)
2004-02-09 12:13:28 +00:00
James Goddard
20156301dc Implement linking stage of compiler for grade Java.
Estimated hours taken: 8
Branches: main

Implement linking stage of compiler for grade Java.

compiler/make.program_target.m:
	Added new predicate create_java_shell_script/4 which is called at
	the linking stage of compilation  for grade Java.  This predicate
	creates a shell script which in theory should:

	* set the classpath to include the standard and runtime librarys
	* prepend the directory containing the main module's .class file to the
	  classpath
	* and finally invoke the java interpreter.

	At the moment it performs steps 2 and 3 fine, but the classpath must
	be set manually as an environmental variable by the user to include the
	standard and runtime library .jar files.  Once this issue is resolved,
	you should be able to use the shell script in the same way as a
	C-generated executable.

compiler/options.m:
	Added the option to specify the Java interpreter.

doc/user_guide.texi:
	Documentation for new option.
2004-02-02 02:45:57 +00:00
Simon Taylor
6f62656e64 Clean up the conversion of targets to file names by `mmc --make'.
Estimated hours taken: 3
Branches: main

Clean up the conversion of targets to file names by `mmc --make'.
Don't assume that every target can be converted simply by adding
an extension -- this isn't true for object files for foreign code
or fact tables.

compiler/make.m:
compiler/make.*.m:
	s/factt_object/fact_table_object/

	Instead of having one fact_table_object target for each module,
	have one for each fact table file.  Previously it wasn't possible
	to identify a fact_table_object target with a target file without
	additional information.

compiler/make.util.m:
compiler/make.*.m:
	make_util.target_extension now returns a `maybe' type, since
	foreign code and fact table targets can't be converted to
	file names by adding an extension.

	Add predicates module_target_to_file_name and
	module_target_to_search_file_name which are like
	module_name_to_file_name, but which handle the
	special cases for foreign code and fact tables
	correctly.
2003-09-24 06:35:26 +00:00
Simon Taylor
404a95cdd7 Remove Unix dependencies in the compiler.
Estimated hours taken: 50
Branches: main

Remove Unix dependencies in the compiler.

Avoid calling passes_aux.invoke_shell_command, which
requires the presence of a Unix shell.

The implementation of fact tables still has dependencies
on Unix utilities (e.g. sort).

aclocal.m4:
	Don't pass Unix style paths to MSVC.

configure.in:
	Use `cygpath -m' rather than `cygpath -w'.
	`cygpath -m' uses '/' as the directory separator,
	so it doesn't cause quoting problems in shell
	scripts.

	Apply $CYGPATH to $PREFIX, $LIBDIR, $CONFIG_PREFIX
	and $CONFIG_LIBDIR.

	Don't pass `-lm' when linking with MSVC.

configure.in:
compiler/options.m:
scripts/Mercury.config.in:
	Add extra configuration options to deal with differences
	between linking with gcc and MSVC:
		--linker-opt-separator
		--linker-link-lib-flag
		--linker-link-lib-suffix
		--shlib-linker-link-lib-flag
		--shlib-linker-link-lib-suffix
		--linker-path-flag

NEWS:
doc/user_guide.texi:
compiler/options.m:
compiler/compile_target_code.m:
compiler/make.program_target.m:
	Instead of substituting in an arbitrary shell script when
	processing `--pre-link-command' and `--extra-init-command',
	require that these options specify a command which will
	be passed the name of the source file containing the main
	module as the first argument, with the source files containing
	the remaining modules following. This is simpler and avoids
	dependencies on a shell.

	Fix quote_arg to handle Windows paths better.

compiler/handle_options.m:
	Don't attempt to use symlinks if they're not available.

compiler/compile_target_code.m:
	Be more careful about quoting.

	Don't call invoke_shell_command where invoke_system_command
	would do.

	Allow linking using MSVC.

compiler/modules.m:
	Remove make_directory, which is now implemented by dir.m.

	Use io.make_symlink rather than shell scripts.

	Implement mercury_update_interface in Mercury.

compiler/llds_out.m:
compiler/make.program_target.m:
	Use dir.make_directory, not modules.make_directory,
	which has been removed.

compiler/make.module_target.m:
	Invoke mercury_compiler directly, not through the
	mmc script to avoid shell dependencies.

	If we can't fork() child `mmc --make' processes,
	pass the arguments to the child process using a
	file to avoid overflowing system limits on Windows.

compiler/mercury_compile.m:
compiler/options_file.m:
	Read argument files.

	Handle backslash-newline in options files correctly.

compiler/passes_aux.m:
	invoke_system_command shouldn't set the exit status --
	the caller may be able to try something else.

compiler/process_util.m:
	Export can_fork for use by make.module_target.m.

	Remove hacks to work around bugs in the implementation
	of zero-arity foreign procs.

compiler/prog_io.m:
	Handle bizarre file names without aborting.

library/Mmakefile:
library/print_extra_inits:
	Move code to find extra initialization functions into
	print_extra_inits, due to the change to the handling
	of the --extra-init-command option described above.

scripts/mmc.in:
	Set the MERCURY_COMPILER environment variable if it is
	not already set, so that the mercury_compile executable
	knows where to find itself.

scripts/mercury.bat.in:
	Make this actually work.

tools/bootcheck:
	Set ANALYSIS_LIB_NAME.

	Apply cygpath (-m not -w) to $root.

	Link print_extra_inits into the stage2 and stage3
	library directories.

util/mkinit.c:
	Handle '\\' in path names.
2003-08-06 12:38:14 +00:00
Zoltan Somogyi
9551640f55 Import only one compiler module per line. Sort the blocks of imports.
Estimated hours taken: 2
Branches: main

compiler/*.m:
	Import only one compiler module per line. Sort the blocks of imports.
	This makes it easier to merge in changes.

	In a couple of places, remove unnecessary imports.
2003-03-15 03:09:14 +00:00
Simon Taylor
7dbc7dedbd Fix a bug in library installation -- the `Mercury/int0s'
Estimated hours taken: 0.5
Branches: main, release

compiler/make.program_target.m:
	Fix a bug in library installation -- the `Mercury/int0s'
	symlink wasn't being created. This caused
	tests/mmc_make/complex_test to fail with
	`--intermodule-optimization'.
2003-02-04 05:10:36 +00:00
Simon Taylor
da0ea7834f Strip out the `.picreg' component of the grade
Estimated hours taken: 0.1
Branches: main, release

compiler/make.program_target.m:
	Strip out the `.picreg' component of the grade
	when working out where to install files.
2003-01-24 01:26:32 +00:00
Simon Taylor
886d2ae474 Make it easier to use shared libraries on x86 with
Estimated hours taken: 20
Branches: main

Make it easier to use shared libraries on x86 with
`mmc --make'.

There is now a third kind of object file, `.lpic_o'.
These files are compiled with `--pic-reg' but not with
CFLAGS_FOR_PIC, so they can be linked with shared Mercury
libraries.

On x86, executables which are linked with shared Mercury
libraries now depend on $(main_module.lpic_os), not
$(main_module.os).

This doesn't work with Mmake because ml doesn't know
which libraries are Mercury libraries, so it can't
link with the static versions of those libraries if
MERCURY_LINKAGE is set to "static".

configure.in:
bindist/bindist.configure.in:
bindist/bindist.build_vars.in:
	Work out whether `.lpic_o' files are needed.

compiler/modules.m:
	Add `.lpic_o' to the list of grade or architecture
	dependent files.

NEWS:
README.Linux:
compiler/options.m:
doc/user_guide.texi:
	Document MERCURY_LINKAGE, LINKAGE, --linkage,
	--mercury-linkage and -R.

compiler/options_file.m:
compiler/make.program_target.m:
	Handle LINKAGE and MERCURY_LINKAGE variables.

	Allow LIBGRADES, LINKAGE and MERCURY_LINKAGE to be target-specific.

scripts/mmc.in:
	Set up the default linkage using the MERCURY_LINKAGE
	variable.

compiler/compile_target_code.m:
	Build `.lpic_o' files.

	Work out which type of object files to link with.

	When linking statically with Mercury libraries,
	find the absolute pathname for the `.a' file
	for each Mercury library, and pass that to ml,
	rather than just using `-lname'.

	Pass `-R' options to ml for each `-R' option to mmc.

compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/mercury_compile.m:
	Specify which type of object files to build.

compiler/make.program_target.m:
compiler/make.module_target.m:
	Make sure all generated object files are cleaned up.

compiler/prog_io.m:
	Add a better message for files which can't be found.

compiler/make.util.m:
	Add `.lpic_o' to the list of extensions.

compiler/Mmakefile:
profiler/Mmakefile:
deep_profiler/Mmakefile:
	Pass `--linkage shared' to mmc (`--shared' is in MLFLAGS).

tests/Mmakefile:
tests/mmc_make/Mmakefile:
tests/mmc_make/Mercury.options:
tests/mmc_make/complex_test.{m,exp}:
tests/mmc_make/hello.{m,exp}:
	Test `mmc --make'.

tests/lib/complex*.m:
	The complex numbers library from the extras distribution,
	for use in the mmc_make tests.
2003-01-23 00:24:20 +00:00
Peter Ross
91e84bb9dd Change `mmc --make' so that it no longer builds the external foreign
Estimated hours taken: 28
Branches: main

Change `mmc --make' so that it no longer builds the external foreign
object files at the same time as it builds the target object file.

This allows one to build on the IL backend where building an external
foreign file assembly depends on having all the imported Mercury
assemblies built first.

Various fixes were also added so that `mmc --make --grade il' could make
an executable.

compiler/compile_target_code.m:
	Change il_assemble so that we always build a .dll version
	irrespective of whether it contains main or not, as MC++ or C#
	code may refer to the dll.
	Add Mercury/dlls to the search path for the C# and MC++
	compilers.
	s,/,\\\\,g in the C# filename as the MS C# compiler doesn't
	understand / as a directory seperator.
	Add the referenced dlls to the C# compilers command line.
	Export maybe_pic_object_file_extension.

compiler/handle_options.m:
	Fix a bug where copmute_grade incorrectly generated `hl.il'
	instead of `il' as the grade name because we weren't always
	considering the --target option.

compiler/make.m:
	Add to the compilation_task_type type the alternatives
	foreign_code_to_object_code and fact_table_foreign_code_file.
	Add to the module_target_type type the alternatives
	foreign_asm, foreign_object and factt_object.

compiler/make.dependencies.m:
	Add code to handle the new module_target_type alternatives.
	Add code to build the new alternatives to
	compilation_task_type.

compiler/make.module_target.m:
	Add rules to build the foreign_code_to_object_code and
	fact_table_code_to_object_code.

compiler/make.program_target.m:
	Determine the targets needed to be built for all the external
	foreign files and add them to build target list.

compiler/make.util.m:
	Add code to handle the new module_target_type alternatives.
	Change write_target_file to output the correct name when
	building the foreign_asm and foreign_object targets.

compiler/modules.m:
	Move referenced_dlls into the interface for use by
	`compile_target_code.m'.
	Don't place dlls in a sub-directory because on the IL backend
	the dlls are `part' of the executable file.
	Add a `MkDir' argument to fact_table_file_name which
	optionally creates a directory to store the generated
	file_name in.

tests/hard_coded/foreign_proc_make.exp:
tests/hard_coded/foreign_proc_make.m:
tests/hard_coded/foreign_proc_make2.m:
	Add a test case.
2002-12-20 09:47:28 +00:00
Simon Taylor
57bcfc05ba Improve the handling of `--use-grade-subdirs' so that it can
Estimated hours taken: 2.5
Branches: main

Improve the handling of `--use-grade-subdirs' so that it can
be documented.

compiler/compile_target_code.m:
	With `--use-grade-subdirs', link or copy executables
	and libraries into the user's directory.

compiler/make.program_target.m:
compiler/modules.m:
	Move code to create a symlink into modules.m, next to
	the code to create directories (all of this should really
	go in the standard library).

	Add a predicate to copy a file (which should also go
	in the standard library).

compiler/make.program_target.m:
	Make the realclean target delete the symlinks or copies
	of executables and libraries.

NEWS:
library/io.m:
	Add io__binary_input_stream_foldl, etc. for use in copying files.

NEWS:
compiler/options.m:
doc/user_guide.texi:
	Document `--use-grade-subdirs'.

tests/Mmakefile:
tests/grade_subdirs:
tests/grade_subdirs/Mmakefile:
tests/grade_subdirs/Mercury.options:
tests/grade_subdirs/hello.{m,exp}:
	Test case.
2002-10-31 14:47:44 +00:00
Simon Taylor
3fda5cf170 With `--make', warn if a target specified on the command line
Estimated hours taken: 1
Branches: main

With `--make', warn if a target specified on the command line
is already up to date.

compiler/make.util.m:
	Check whether a target that was found to be up to date
	was specified on the command line.

compiler/make.m:
	Add the targets specified on the command line to the make_info.

compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.dependencies.m:
	Call make__util__maybe_warn_up_to_date_target when a target
	is found to be up to date.

	Remove targets from the list of targets specified on the command
	line as they are processed to avoid generating multiple warnings.

compiler/options.m:
doc/user_guide.texi:
	Add an option `--no-warn-up-to-date'.

tests/warnings/Mmakefile:
tests/warnings/up_to_date.{m,exp}:
	Test case.
2002-10-30 13:32:02 +00:00
Fergus Henderson
ffee30fa53 Change things so that LIBGRADES includes the default grade.
Estimated hours taken: 1
Branches: main

Change things so that LIBGRADES includes the default grade.
This fixes a bug that sometimes caused the libraries not to be
installed in the default grade, e.g. when $(GRADE) is set in Mmake.params.

configure.in:
	Don't delete $(GRADE) from $(LIBGRADES).

Mmakefile:
scripts/Mmake.rules:
compiler/make.program_target.m:
	Change the loops over $(ALL_LIBGRADES) so that they skip $(GRADE).

scripts/Mmake.vars.in:
	Delete an bogus assignment setting LIBGRADES to empty, since it
	wasn't being used (LIBGRADES was being assigned again below).
	Update the documentation for LIBGRADES.
2002-10-15 16:23:57 +00:00
Simon Taylor
f647f928e0 Add some documentation.
Estimated hours taken: 0.25
Branches: main

compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
	Add some documentation.
2002-10-14 06:46:34 +00:00
Simon Taylor
e175b43ca0 Fix bugs in `--rebuild'.
Estimated hours taken: 2
Branches: main

Fix bugs in `--rebuild'.

compiler/compile_target_code.m:
	Always recompile the `module_init.c' file with `--rebuild'.

compiler/handle_options.m:
	The code to make `--rebuild' imply `--make' was after some
	uses of the value of `--make', in particular the code to
	make `--make' imply `--use-subdirs'.

compiler/make.dependencies.m:
compiler/make.program_target.m:
compiler/make.module_target.m:
	Add a sanity check to make sure that all files that should
	have been produced when building a target have been produced,
	and reporting a proper error message if they have not.
2002-08-26 04:56:58 +00:00
Simon Taylor
8b3ad9a096 Module qualify a call to fix a compilation error with
Estimated hours taken: 0.1
Branches: main

compiler/make.progran_target.m
	Module qualify a call to fix a compilation error with
	`--intermodule-optimization' (unresolved ambiguity between
	list__map and set__map).
2002-08-09 08:32:49 +00:00
Simon Taylor
723a9b921c Fix quoting of arguments to commands invoked by mmc.
Estimated hours taken: 2
Branches: main

Fix quoting of arguments to commands invoked by mmc.

compiler/compile_target_code.m:
compiler/make.module_target.m:
	Quote arguments passed to commands.

compiler/options_file.m:
	Pass each word in the value of CFLAGS (MLFLAGS, etc) as a
	separate `--cflag' option so it can be quoted correctly.

NEWS:
compiler/options.m:
doc/user_guide.texi:
	For each `--Xflags' option, add a `--Xflag' option which
	quotes its argument if necessary then adds it to
	the `--Xflags' option.
2002-08-08 06:25:48 +00:00
Simon Taylor
44ef4e118b Library installation with `mmc --make'.
Estimated hours taken: 10
Branches: main

Library installation with `mmc --make'.

compiler/make.m:
compiler/make.program_target.m:
	Handle `mmc --make lib<module>.install'.

compiler/options.m:
	Add an option `--use-grade-subdirs', which causes
	all grade-dependenent files to be placed in
	`Mercury/<grade>/<ext>s' subdirectories, even
	those files that are intended for use by the user.

	`--use-grade-subdirs' is not documented because it
	is only intended for use in library installation
	with `mmc --make' (it doesn't work at all with Mmake).
	Documenting it would require documenting (and setting
	in stone) the layout of the `Mercury' directory, which
	is probably a bad idea.

Mmake.workspace:
compiler/handle_options.m:
scripts/Mmake.rules:
	Header files are now always searched for using the plain
	file name (not Mercury/mihs/module.mih), so add a
	`--c-include-directory' option to search Mercury/mihs
	in the current directory.

compiler/modules.m:
compiler/intermod.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile.m:
compiler/mlds_to_c.m:
compiler/trans_opt.m:
	Handle `--use-grade-subdirs' in module_name_to_file_name.

	Add module_name_to_search_file_name, which should be
	used to generate the names of files that might be part
	of an installed library. This is needed because installation
	and local directory hierarchies have a different layout,
	A better long-term fix would be to change things so that
	the installation and local directory layouts are the same.

compiler/make.util.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
	Add an extra argument to get_target_timestamp and
	get_file_name to specify whether the file should
	be searched for.

compiler/options_file.m:
scripts/Mmake.vars.in:
	Handle the LIBGRADES and INSTALL_PREFIX make variables.

doc/user_guide.texi:
	Remove the statement that library installation is
	not supported with `mmc --make'.
2002-08-07 13:12:11 +00:00
Simon Taylor
9406f99f9d Allow tools/bootcheck to be run using `mmake --use-mmc-make'.
Estimated hours taken: 5
Branches: main

Allow tools/bootcheck to be run using `mmake --use-mmc-make'.
The tests don't work yet.

compiler/make.m:
compiler/make.module_target.m:
	Handle targets such as `<module>.cs' and `<module>.ints',
	which are used when building stage 3.

Mmake.common.in:
*/Mmakefile:
*/Mercury.options:
	Add Mercury.options files to pass module-specific flags to
	`mmc --make'.

	Avoid triggering the .DEFAULT rule introduced with `--use-mmc-make'
	for optional files like Mmake.params.

compiler/modules.m:
	Build the interface files when building a library in IL grades,
	for consistency with C grades.

library/Mmakefile:
	Improve performance by removing the dependency on the interface
	files when building the library. The files are now always built
	by the libmer_std target.

	Pass the command to build libmer_std.init to `mmc --make'.

tools/bootcheck:
	Add an option `--use-mmc-make'.

	Copy the Mercury.options files into the stage2 and stage3 directories.

scripts/Mmake.rules:
	Don't include the rules for `.dep' files with `--use-mmc-make'.

	Include the rule for `--convert-to-mercury' even with `--use-mmc-make'.

compiler/Mmakefile:
tools/bootcheck:
tools/binary_step:
	`mmc --make' doesn't handle `<module>_init.c' targets, so
	don't make the `cs' target depend on `top_level_init.c'.
	As far as I can tell, that dependency is only present so
	that the stage2 and stage3 compilers have the same set of
	C files. bootcheck and binary_step now only compare `.c'
	files which are present in the stage3 directory.
2002-06-22 19:16:15 +00:00
Simon Taylor
ac5c98bdaf Fix problems with the compiler-generated header files:
Estimated hours taken: 25
Branches: main

Fix problems with the compiler-generated header files:
1. the header files are grade dependent, but the header files
   can only be installed for one grade.
2. the generated header files can clash with system headers.

To solve these problems, the compiler now generates a
grade dependent `.mih' file containing the declarations
needed when a module is imported in a high-level C code
grade, and a grade independent `.mh' file, which contains
the prototypes for `:- pragma export' declarations.

compiler/export.m:
	Generate a `.mh' rather than a `.h' file for the `:- pragma export'
	declarations.

	Allow the header file generated by export.m to be used with
	`--high-level-code'.

compiler/modules.m:
library/Mmakefile:
	Add a module.install_grade_hdrs target to install the `.mih'
	files in a grade-dependent directory.

compiler/arg_info.m:
compiler/hlds_out.m:
compiler/hlds_pred.m:
	Make it easier to tell if the arg_info field of the proc_info
	has been set.

compiler/mlds_to_c.m:
	Include both the `.mh' and `.mih' files for imported modules.

	The type used as the return value for a semidet procedure
	exported to C is `MR_bool', not `MR_Word'.

compiler/mlds_to_c.m:
compiler/modules.m:
	Don't add a `mercury.' prefix to the standard library
	header file names. They can't clash with the system
	headers any more.

compiler/mercury_compile.m:
compiler/mlds_to_c.m:
	Use export.m to generate the header file for `:- pragma export'
	declarations even in hlc grades.

compiler/mlds.m:
compiler/ml*.m:
	Distinguish between the `.mh' and `.mih' files
	in `mlds__import's.

compiler/handle_options.m:
scripts/Mmake.vars.in:
scripts/mgnuc.in:
	Add C include directory options for the installed grade
	dependent `.mih' files.

Mmakefile:
scripts/Mmake.rules:
	s/h/mih/ in the commands to save the grade dependent
	files when installing the library grades.

compiler/make.m:
compiler/make.dependencies.m:
compiler/make.module_target.m:
compiler/make.util.m:
	Handle dependencies on `.mh' and `.mih' files.

NEWS:
doc/user_guide.texi:
	Document the change.
2002-05-30 12:55:23 +00:00
Simon Taylor
eadcd7ab00 MLOBJS or --link-objects' may contain .a' files, which
Estimated hours taken: 0.25
Branches: main

compiler/make.program_target.m:
	MLOBJS or `--link-objects' may contain `.a' files, which
	should come last on the linker command line.
2002-05-21 18:57:07 +00:00
Simon Taylor
d0e8840ab7 Handle `mmc --make lib<module>' target, which builds all the files
Estimated hours taken: 3

Handle `mmc --make lib<module>' target, which builds all the files
required to use a library in the current grade.

compiler/make.m:
	Check for `lib<module>' when attempting to classify a target.

compiler/make.program_target.m:
compiler/compile_target_code.m:
	Make `.init' files when building the `.a' file.

	Invoke the command given by `--pre-link-command' before linking.

compiler/make.module_target.m:
compiler/make.util.m:
	Move find_oldest_timestamp into make.util.m for
	use by make.program_target.m.

compiler/options.m:
doc/user_guide.texi:
	Add an option `--make-init-file-command', to specify an
	alternative command to make the `.init' file. This is needed
	for the standard library.

	Add an option `--pre-link-command', which specifies a
	command to be run before linking. This is useful if there
	are foreign files which depend on headers produced by
	the Mercury compiler.
2002-05-13 18:22:33 +00:00
Simon Taylor
ddcd19d450 Put the lib' prefix on the filenames for .a' and `.so' files.
Estimated hours taken: 0.25
Branches: main

compiler/compile_target_code.m:
compiler/make.program_target.m:
compiler/make.util.m:
	Put the `lib' prefix on the filenames for `.a' and `.so' files.
2002-04-24 08:42:35 +00:00
Simon Taylor
a719e74ee9 Rearrange some code after the `--make' change.
Estimated hours taken: 1.5
Branches: main

Rearrange some code after the `--make' change. This was not done
as part of that change for ease of reviewing.

compiler/mercury_compile.m:
compiler/compile_target_code.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
	Move code to compile the generated code into compile_target_code.m.

compiler/make.util.m:
compiler/passes_aux.m:
compiler/process_util.m:
	Move process and signal handling functionality into process_util.m.

compiler/Mmakefile:
	Compile process_util.c with `--no-ansi' so that the declarations
	of `struct sigaction' and `kill' are available on Linux.

compiler/notes/compiler_design.html:
	Document compile_target_code.m and process_util.m.
	Move timestamp.m into the "Miscellaneous" section (it's
	used by make as well as smart recompilation).
	Fix the documentation of options_file.m.
2002-03-18 04:44:16 +00:00
Simon Taylor
9c9601808d Add an alternative implementation of Mmake as part of the compiler.
Estimated hours taken: 500

Add an alternative implementation of Mmake as part of the compiler.
The advantages of this are
	- more accurate dependencies
	- no `mmake depend' step
	- less process creation (no processes are created to
		build interface files).

Still to do:
	- handle --split-c-files
	- handle the IL backend properly
	- library installation
	- allow the compiler to be built and the nightly tests
	  to be run with `mmc --make'

compiler/make.m:
	Control the build process.

compiler/make.program_target.m:
	Build executables and libraries.

compiler/make.module_target.m:
	Build C files, object files, interface files etc.

compiler/make.dependencies.m:
	Work out the depenendencies between targets.

compiler/make.module_dep_file.m:
	Record the inter-module dependencies between invocations of mmc.

compiler/make.util.m:
	Utility predicates used by `mmc --make'.

compiler/compile_target_code.m:
	This module will eventually contain the predicates used
	to compile the target code files generated by the compiler
	which are now in mercury_compile.m. (That will be done
	as a separate change for ease of reviewing).

	For now compile_target_code.m

compiler/mercury_compile.m:
	Export the predicates used to compile target code.

	Call make.m.

	Pass the name of the top-level module in the source file to modules.m.
	It is needed when generating the `.module_dep' files.

	Lookup the option defaults (which will eventually be stored in
	DEFAULT_MCFLAGS by the mmc script) before compiling. Up until now
	the option defaults have been passed on the command line by the
	mmc script, but with `mmc --make' the default options need
	to be overridden by the value of the MCFLAGS make variable, but
	the MCFLAGS make variable is overridden by command line options.

	Pass the value of `--link-flags' to c2init.

	Remove some uninformative messages printed when a C, IL, etc.
	compilation fails.

compiler/options_file.m:
	Read files containing Make style variable assignments.

compiler/options.m:
doc/user_guide.texi:
	Add a new options category: build system options.

	Add some extra options:
	--warn-undefined-options-variables - like mmake --warn-undefined-vars
	--verbose-commands - print commands that the user might be
		interested in, like C compilation, but not things
		like mercury_update_interface.
	--output-compile-error-lines - print the first n lines
		of the error file generated by a command.
	--generate-mmc-make-modules-dependencies - generate dependencies
		for use by `mmc --make' even when using Mmake.

	--il-assembler, --ilasm-flags, --mcpp-compiler, --mcpp-flags,
	--csharp-compiler, --csharp-flags, --install-prefix,
	--install-command, --libgrades, --options-files,
	--options-search-directories.

compiler/modules.m:
	Add fields to the `module_imports' type for use by make.*m.

	Don't try to fill in fields of the module_imports structure
	lazily. It's error prone, and probably doesn't save much
	anyway.

	Clean up the code to compute what foreign languages
	are used by a list of item.

	Simplify the handling of fact tables by recording that a module
	containing fact tables has foreign code to implement them,
	rather than requiring separate checks everywhere.

	Generalise predicates like get_interface so that they
	work even after the imported items have been read.

	Fix the handling of header files with the LLDS backend.

	Install the `.module_dep' files created for use by
	`mmc --make'.

compiler/*.m:
	Use record syntax rather than explicit deconstruction to
	refer to fields of the `module_imports' type.

compiler/*.m:
	Be more careful about where output goes.
	mercury_compile.m sets the output stream to be io__stderr_stream
	at the start of compilation, so remove all explicit writes to
	io__stderr_stream (with `--make' the error output stream may be
	a `.err' file, not io__stderr_stream).

	Change all occurrences of io__tell/io__told to use
	io__open_output/io__close_output (io__told restores the current
	output stream to io__stdout_stream, not the previous value).

compiler/passes_aux.m:
	Make the output from system commands go to the current
	output stream, not C stdout and stderr.

	Allow commands to be printed with `--verbose-commands'.

	Remove uninformative error messages when a command fails.

compiler/timestamp.m:
	Add functions oldest_timestamp and newest_timestamp.

compiler/llds_out.m:
	Record the number of C files written with `--split-c-files'
	in <module>.num_split.

compiler/prog_io.m:
compiler/*.m:
	`search_for_file' now returns the directory in which the
	file was found.

compiler/foreign.m:
	Use sub-typing to make some calls to predicates in this
	module `det' rather than `semidet'.

compiler/handle_options.m:
	Return the option arguments.

compiler/Mmakefile:
	make.util.m refers to kill() and `struct sigaction' which
	are not exported from <signal.h> unless `--no-ansi' is
	passed to gcc.

compiler/notes/compiler_design.html:
	Document the new modules.

runtime/mercury_signal.h:
runtime/mercury_signal.c:
	Add a function MR_signal_should_restart() which alters
	whether a signal restarts or interrupts system calls.
	In general restarting is the preferred behaviour, but
	the wait() for a child process needs to be interruptible.

scripts/Mmake.vars.in:
	Add subdirs for `.module_dep', `.err_date'
	and `.num_split' files.

library/io.m:
	Add a version of io_call_system which returns the signal
	that killed the command rather than converting it into
	an error message.

	Add a predicate to interpret the result of system() or wait().

library/list.m:
	Add list__map_foldl2 and a unique mode for list__foldl3.

NEWS:
	Document the new library predicates.

configure.in:
runtime/mercury_conf.h.in:
	Check for siginterrupt().

doc/user_guide.texi:
	Document the new options.

	Add a description of `mmc --make' to the "Using Mmake" chapter.
2002-03-12 16:33:37 +00:00