Commit Graph

37 Commits

Author SHA1 Message Date
Simon Taylor
5d693f5a1c Factor out the common Mmake code to set up the mmc, mgnuc
Estimated hours taken: 8
Branches: main

Factor out the common Mmake code to set up the mmc, mgnuc
and ml flags when building the Mercury compiler and libraries.
Use options, not environment variables. This will make it simpler
to use `mmc --make' to compile the compiler.

Mmake.workspace:
	Similar to tools/lmc. Sets up Mmake variables to
	use the library files in a workspace rather than
	an installed library.

configure.in:
	Check for the `--no-mercury-stdlib-dir' mmc option.
	Bootstrap CVS tag: bootstrap_20020429_stdlib_dir

Mmake.common.in:
*/Mmakefile:
	Move common code into Mmake.workspace.

browser/Mmakefile:
library/Mmakefile:
	Avoid invoking the linker explicitly when creating
	libraries of Mercury code. That won't work well
	with `mmc --make'.

tools/bootcheck:
tests/Mmake.common:
	Use Mmake.workspace instead of setting up environment
	variables in bootcheck.

scripts/Mmake.vars.in:
	mmc compiles split C files to object code itself,
	so pass `--cflags "$(ALL_CFLAGS)"' to mmc when
	compiling with `--split-c-files'.

browser/interactive_query.m:
	Use `mmc --make' when compiling the query. This is needed
	to make tests/debugger/interactive_query.m work when linking
	against a workspace using options rather than environment
	variables.  This also fixes a bug -- mmc options were being
	passed to ml.

	Clean up after the query.

tests/debugger/Mmakefile:
tests/debugger/interactive.inp:
tests/debugger/interactive.inp.subdirs:
tests/debugger/interactive.inp.nosubdirs:
tests/debugger/interactive.exp:
tests/debugger/interactive.exp2:
	Generate the input file to this test so that MCFLAGS
	and MC_MAKE_FLAGS (from Mmake.workspace) are used when
	compiling queries.

	tests/debugger/Mmakefile now sets SHELL to /usr/local/bash
	to allow the use of $(...) style command substitution
	(`...` style command substitution can't be nested).

tests/warnings/Mmakefile:
tests/dppd/Mmakefile:
	Include tests/Mmake.common.

tools/*:
scripts/c2init.in:
scripts/ml.in:
	Update the lists of files containing the library names.
2002-04-29 08:22:08 +00:00
Simon Taylor
b99e6cc370 Allow alternative locations for the standard library files
Estimated hours taken: 6
Branches: main

Allow alternative locations for the standard library files
to be specified using options to the various Mercury scripts
rather than environment variables.  This change is necessary
to allow the compiler to be compiled using `mmc --make', because
`mmc --make' does not support the environment variables.

All of the Mercury scripts now accept an option
`--mercury-standard-library-directory' to specify the installed
library to use, or `--no-mercury-standard-library-directory' to
disable the use of the installed library. The location
of the alternate files to use can then be specified
using ordinary options to the scripts.

There is a new environment variable MERCURY_STDLIB_DIR, which has
the same effect as the `--mercury-standard-library-directory' option.

scripts/parse_ml_options.sh-subr.in:
scripts/mgnuc.in:
scripts/mmc.in:
scripts/mmake.in:
scripts/Mmake.vars.in:
scripts/Mmake.rules:
	Handle MERCURY_STDLIB_DIR and `--mercury-standard-library-directory'.

	Remove support for the MERCURY_C_INCL_DIR, MERCURY_MOD_LIB_DIRS
	and MERCURY_TRACE_LIB_DIRS environment variables -- they aren't
	used anywhere. MERCURY_C_INCL_DIR is being removed because the
	assumption it makes (that all header files are installed into
	a single directory) will not hold for much longer because the
	generated header files for hl* grades are grade dependent.

compiler/options.m:
compiler/compile_target_code.m:
	Add an option `--trace-init-file', used to specify `.init'
	files which should only be used when tracing is enabled,
	such as browser/mer_browse.init.

	Allow `--mercury-stdlib-dir' as an abbreviation for
	`--mercury-standard-library-directory'.

tools/lmc:
	Use options rather than environment variables.

doc/user_guide.texi:
	Document MERCURY_STDLIB_DIR, MERCURY_TRACE_LIB_MODS
	and the `--trace-init-file' mmc option.

	Remove documentation for the no longer used MERCURY_C_INCL_DIR,
	MERCURY_MOD_LIB_DIRS, MERCURY_TRACE_LIB_DIRS and
	MERCURY_NC_BUILTIN environment variables.
2002-04-19 14:59:37 +00:00
Simon Taylor
dead626652 Allow Mercury runtime options to be set at compile time.
Estimated hours taken: 1.5
Branches: main

Allow Mercury runtime options to be set at compile time.

scripts/parse_ml_options.sh-subr.in:
	Add an initialization option `--runtime-flags'.

runtime/mercury_wrapper.h:
	Add a global variable MR_runtime_flags.

util/mkinit.c:
	Set MR_runtime_flags.

runtime/mercury_wrapper.c:
	Add the value of MR_runtime_flags to the dummy
	command line passed to getopt().

tests/hard_coded/Mmakefile:
	Use `--runtime-flags' rather than MERCURY_OPTIONS.
2002-01-13 10:13:20 +00:00
Simon Taylor
93f2516efb Write the grade in the header comment in the generated `<module>_init.c' file.
Estimated hours taken: 0.25
Branches: main

Write the grade in the header comment in the generated `<module>_init.c' file.
The `<module>_init.c' file contains grade dependent conditional compilation,
so the `<module>_init.o' file must be rebuilt when the grade changes.

util/mkinit.c:
	Add an option `-g' for the grade.
	Add the grade to the header comment.

scripts/c2init.in:
	Pass the grade to mkinit.

scripts/Mmakefile:
scripts/canonical_grade.sh-subr:
	canonical_grade.sh-subr is now used by c2init.
2001-12-18 05:44:17 +00:00
Simon Taylor
5c9f6f5841 Combine the options for ml and c2init. Once mmake has been
Estimated hours taken: 1
Branches: main

Combine the options for ml and c2init. Once mmake has been
altered to pass MLFLAGS to c2init users will be able to
mostly ignore the existence of c2init.

This change requires an installed compiler which uses `--init-c-file'
rather than `-o' to name c2init's output file. This is difficult to
test for in configure.in.

Bootstrap CVS tag: bootstrap_20011203_init_c_file_c2init_option

scripts/parse_ml_options.sh-subr.in:
	Parse the combined options for ml and c2init.

	The `-o' and `--output' options for c2init have been removed
	(`-o' conflicts with a linker option), use `--init-c-file' instead.

configure.in:
	Add parse_ml_options.sh-subr.in to the list of files to substitute.

scripts/ml.in:
scripts/c2init.in:
	Include parse_ml_options.sh-subr.

scripts/Mmakefile:
	ml and c2init depend on parse_ml_options.sh-subr.
2001-12-03 03:11:26 +00:00
Simon Taylor
161226cc22 This is the first part of a change to make c2init and ml take
Estimated hours taken: 0.25

This is the first part of a change to make c2init and ml take
the same set of options (the c2init options will be added as
an "Initialization options" section of the ml options). When
this change is complete, users will only need to add `--trace'
to MLFLAGS, not C2INITFLAGS as well. c2init is an implementation
detail that users shouldn't need to know about.

scripts/c2init.in:
	Remove the `-l' short form of the `--library' option,
	since it conflicts with the use of `-l' as a linker option.

	Add `--no-main' as a synonym for `--library', which will
	cause less confusion with the `--make-shared-lib' ml
	option. `--library' will still be accepted for backwards
	compatability because the C interface samples refer to it.

	Add `--init-c-file' as a synonym for `-o' and `--output'.
	The latter two will be removed after mmake and mmc are
	changed to use `--init-c-file' because they don't make
	sense as ml options.
2001-11-13 08:28:05 +00:00
Fergus Henderson
c08e710e54 Fix a bug in c2init where, if an error occurred, it would leave the
Estimated hours taken: 2
Branches: main

Fix a bug in c2init where, if an error occurred, it would leave the
invalid output file around, causing problems the next time you ran Mmake.

This change also eliminates a dependency on using shell redirection (">")
when invoking system commands.

util/mkinit.c:
	Add new option `-o' for specifying the output file name.
	Also, if this option is specified, and there are any errors,
	then remove the output file. This fixes the bug mentioned above.
	Also, consistently use exit(EXIT_FAILURE) rather than exit(1).

scripts/c2init.in:
	Add new option `-o'/`--output', which just passes `-o' to mkinit.

compiler/modules.m:
compiler/mercury_compile.m:
	Use `-o' rather than shell redirection when invoking c2init.
2001-05-08 12:48:34 +00:00
Fergus Henderson
018fc359f2 Delete some debugging code (`set -x') that zs left in
Estimated hours taken: 0.1

scripts/c2init.in:
	Delete some debugging code (`set -x') that zs left in
	(apparently accidentally) in his last commit.
2000-11-05 04:15:34 +00:00
Zoltan Somogyi
2ac218f9a7 This is part 2 of a change that provides a register of all the types defined
Estimated hours taken: 4

This is part 2 of a change that provides a register of all the types defined
in the program.

util/mkinit.c:
	After part 1 of this change, each compiler-generated module has three
	initialization functions: the old one (to register label addresses
	etc), one to register type_ctor_infos, and one to register module
	layouts for the debugger. However, only the first was invoked from
	the mkinit generated <mainmodule>_init.c file.

	This change invokes the other two as well. One complication is that
	hand-written "modules" do not have the two new kinds of initialization
	functions, so only their first initialization function should be
	called. We do this by requiring those "modules" to have one of two
	specific forms: an initial prefix of either sys_init or
	mercury_sys_init.

scripts/c2init.in:
	Rerrange the mechanism we use to allow the overriding of the locations
	of the init files to be passed to mkinit. The previous mechanism used
	a single environment variable, MERCURY_MOD_LIB_MODS, to hold the names
	of these init files. While the default setting of this variable was
	conditional on whether the --trace option was given to c2init
	(including the init file for the browser only with --trace),
	there was no way to override the default value in a similarly
	conditional manner. This is now a problem, because including the
	browser init file in the list of init files passed to mkinit will
	cause mkinit to emit code that causes the browser's modules to be
	linked in, without also linking in the libraries (e.g. -ldl) on which
	the browser depends. The reason why this hasn't bitten us earlier
	is that the code that drags in the browser was #ifdef'ed out
	in the first initialization function; the reason why it would
	bite us now is that it is *not* #ifdef'ed out in the second
	initialization function (the one that register type_ctor_infos).

	The new mechanism uses two environment variables, MERCURY_MOD_LIB_MODS
	and MERCURY_TRACE_LIB_MODS, with the first normally containing
	the filenames of the init files of the runtime and library directories
	and the second the filename of the init file of the browser directory.
	The value of the second environment variable is passed to mkinit
	only if c2init is invoked with the --trace flag.

	There is also a new environment variable MERCURY_TRACE_LIB_DIR,
	which has a role parallel to MERCURY_MOD_LIB_DIR.

compiler/Mmakefile:
profiler/Mmakefile:
tools/bootcheck:
	Specify the filename of the browser init file in
	MERCURY_TRACE_LIB_MODS.

library/array.m:
library/builtin.m:
library/private_builtin.m:
library/std_util.m:
	Add code to initialization functions to register the type_ctor_infos
	of hand-defined types.

	Note that this code is in the usual initialization function, the one
	called by do_init_modules(). Putting this code in a separate
	initialization function that is called by do_init_modules_type_tables()
	would require complicating mkinit.c considerably.

runtime/mercury_wrapper.c:
	Make do_init_modules_type_tables() call do_init_modules(), so that
	calling do_init_modules_type_tables() guarantees the registration
	of all the type_ctor_infos in the program, including the hand-defined
	ones.

runtime/mercury_context.c:
	Make the name of the handwritten module follow the convention now
	required by mkinit.
2000-10-31 07:54:11 +00:00
Simon Taylor
247a5bd308 Fix a bug in the handling of the `--aditi' option -- it was
Estimated hours taken: 0.25

scripts/c2init.in:
	Fix a bug in the handling of the `--aditi' option -- it was
	performing a shift even though `--aditi' does not take an
	argument.
2000-05-12 05:13:33 +00:00
Fergus Henderson
aa3f54f73f More work on the MLDS back-end.
Estimated hours taken: 6

More work on the MLDS back-end.

runtime/mercury.c:
	Fix a cut-and-paste bug in the code for compare/3:
	I forgot to add `break' after each case of a `switch' statement.

library/builtin.m:
library/private_builtin.m:
	Replace the hand-coded definition of builtin_{compare,unify}_pred
	in builtin.m with ordinary Mercury clauses in private_builtin.m.
	This ensures that it works with the MLDS back-end.
	(It also means that these procedures call error/1 rather than
	MR_fatal_error(), so you get an exception rather than a
	program abort.)

runtime/mercury.h:
runtime/mercury.c:
	Add declarations and definitions of the compare and unify
	procedures for the builtin types.  (For some types,
	the definitions here are still just stubs.)

runtime/mercury.h:
runtime/mercury.c:
runtime/mercury_init.h:
	Add some hacks to work-around the current lack of support
	for `pragma export'.

runtime/mercury_type_info.c:
	If MR_HIGHLEVEL_CODE is defined, don't #include "mercury_imp.h",
	since it is not needed.

runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
runtime/mercury_init.h:
util/mkinit.c:
scripts/c2init.in:
	Add support for the MLDS back-end to the program start-up
	code.
2000-05-08 16:11:22 +00:00
Zoltan Somogyi
22840901fd Fix potential problems with the way we were handling grade components: the
Estimated hours taken: 5

Fix potential problems with the way we were handling grade components: the
places that know about grade components were not being kept totally in sync.
This change fixes previous damage and aims to prevent future damage.

The file runtime/mercury_grade.h contains a list of all the files in the
compiler that know about grade components. All these files now process the
grade components in the same order, so that they can be checked for consistency
more easily.

runtime/mercury_grade.h:
	Add the list.

runtime/mercury_conf_param.h:
	Remove a comment about an obsolete grade component.

scripts/init_grade_options.sh-subr:
	Remove initializations of variables that do not correspond to grade
	components, add missing initializations of shell variables that do
	correspond to grade components, and concentrate the grade options
	component of usage messages here, to prevent double maintenance.

	Update list of user scripts.

scripts/final_grade_options.sh-subr:
	Add missing initializations in processing the --grade superoption.

	Standardize the order of processing options, and the indentation.

	Update list of user scripts.

scripts/c2init.in:
	Take the usage message for grade component options from
	init_grade_options.sh-subr.

scripts/mgnuc.in:
	Take the usage message for grade component options from
	init_grade_options.sh-subr.

	Standardize the order of processing grade options, and separate the
	processing of grade options and non-grade options.

scripts/ml.in:
	Take the usage message for grade component options from
	init_grade_options.sh-subr.

	Standardize the order of processing grade options. Process some missing
	ones.

compiler/handle_options.m:
	Standardize the order of processing grade options.

	Remove code to handle an obsolete grade component.
1999-11-09 01:45:43 +00:00
Warwick Harvey
a7b1401531 Allow the user to conveniently use Mercury libraries installed in
Estimated hours taken: 70

Allow the user to conveniently use Mercury libraries installed in
non-standard places, by specifying the variables `EXTRA_LIBRARIES' and
`EXTRA_LIB_DIRS' in their Mmakefile.

doc/user_guide.texi:
	Documented the new `EXTRA_LIBRARIES' and `EXTRA_LIB_DIRS' Mmake
	variables.

scripts/Mmake.vars.in:
	Added/changed definitions appropriately to support the new
	variables.
	This included adding a `GRADESTRING' variable which holds the
	canonical name of the grade being used, taking into account all the
	grade flags.

scripts/c2init.in:
	Added a new option to `c2init':
	-I/--init-file-directory <directory> adds the directory to the list
		of directories to search for `.init' files.

util/mkinit.c:
	Added a new option `-I' to add a directory to the list of
	directories to search for `.init' files.
1999-07-26 02:52:46 +00:00
Zoltan Somogyi
c6812299c2 Remove support for --args simple. We don't use it, we won't use it even for
Estimated hours taken: 4.5

Remove support for --args simple. We don't use it, we won't use it even for
experiments, and it is unnecessary complication.

If anybody were using --args simple, this would need bootstrapping, but
since nobody does, there is no need, and this can be committed as an
ordinary change.

compiler/options.m:
doc/user_guide.texi:
scripts/*.in:
scripts/*.sh-subr:
	Remove the --args option.

compiler/globals.m:
	Remove the args_method global and its access predicates.

compiler/handle_options.m:
	Don't set the args_method global from the option.

compiler/arg_info.m:
	Remove support for --args simple. This allows us to remove a now
	redundant argument from an exported predicate.

compiler/mercury_compile.m:
	Remove the code for passing -DCOMPACT_ARGS to the C compiler.

compiler/bytecode_gen.m:
compiler/fact_table.m:
compiler/follow_vars.m:
compiler/live_vars.m:
compiler/call_gen.m:
	Don't pass the unnecessary argument to arg_info.

compiler/call_gen.m:
compiler/unify_gen.m:
	Remove now unnecessary assertions.

compiler/hlds_pred.m:
	Don't include an args_method in proc_infos; instead, include
	a slot that says whether the procedure's address is taken or not.
	(In most cases, this determined whether the args_method was
	simple or compact.) We will need this bool in the near future
	(when we generate layout structures for procedures whose address
	is taken).

	Modify the signatures of exported predicates to accommodate
	this change to the data structure.

compiler/hlds_out.m:
	Print the new slot, not the args_method.

compiler/lambda.m:
	When creating procedures from lambdas, set the address-taken slot
	to address_is_taken instead of setting up its args_method.

compiler/make_hlds.m:
	Minor changes to conform to the changes in the signatures of
	the predicates exported from hlds_pred.m.

compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/dnf.m:
compiler/magic.m:
compiler/magic_util.m:
compiler/modecheck_call.m:
compiler/pd_info.m:
compiler/post_typecheck.m:
compiler/unify_gen.m:
	Minor changes to conform to the changes in the signatures of
	the predicates exported from hlds_pred.m and make_hlds.m.

runtime/mercury_type_info.h:
	Remove the conditional definition of the macros that provided
	an argument-method-independent way of referring to the registers
	holding the inputs and outputs of e.g. unification procedures.
	We don't need the independence anymore, and using registers instead
	of macros in the code ensures that maintainers are aware of register
	reuse issues (e.g. they copy an input from r1 before overwriting it
	with an output).

runtime/mercury_conf_param.h:
runtime/mercury_grade.h:
	Remove support for the args method component of the grade.

runtime/mercury_ho_call.c:
runtime/mercury_tabling.c:
library/*.m:
	Conform to the changes in runtime/mercury_type_info.h by effectively
	applying the #defines appropriate to compact args by hand.

	Remove code and data structures only needed for simple args.
	Remove comments needed only in the presence of uncertainty about
	the args method.
1999-06-01 09:46:20 +00:00
Fergus Henderson
c66dbd7265 Include the grade options in the help message.
Estimated hours taken: 0.25

scripts/c2init.in:
	Include the grade options in the help message.
	Include the file `final_grade_options.sh-subr' so
	that options will get properly post-processed.
1999-04-26 03:10:23 +00:00
Fergus Henderson
77b319d2a5 Fix a bug where it was generating code that referred to
Estimated hours taken: 0.5

scripts/c2init.in:
	Fix a bug where it was generating code that referred to
	the initialization functions for the browser library
	even when `--trace' was not specified on the command line
	and the grade was not a debugging grade.
1999-03-21 04:40:31 +00:00
Simon Taylor
18430aaef1 Aditi compilation.
Estimated hours taken: 1200

Aditi compilation.

compiler/options.m:
	The documentation for these is commented out because the Aditi
	system is not currently useful to the general public.
	--aditi: enable Aditi compilation.
	--dump-rl: write the intermediate RL to `<module>.rl_dump'.
	--dump-rl-bytecode: write a text version of the bytecodes
		to `<module>.rla'
	--aditi-only: don't produce a `.c' file.
	--filenames-from-stdin: accept a list of filenames to compile
		from stdin. This is used by the query shell.
	--optimize-rl, --optimize-rl-cse, --optimize-rl-invariants,
	--optimize-rl-index, --detect-rl-streams:
		Options to control RL optimization passes.
	--aditi-user:
		Default owner of any Aditi procedures,
		defaults to $USER or "guest".
	--generate-schemas:
		write schemas for base relations to `<module>'.base_schema
		and schemas for derived relations to `<module>'.derived_schema.
		This is used by the query shell.

compiler/handle_options.m:
	Handle the default for --aditi-user.

compiler/hlds_pred.m:
compiler/prog_data.m:
compiler/prog_io_pragma.m:
compiler/make_hlds.m:
	Add some Aditi pragma declarations - `aditi', `supp_magic', `context',
	`naive', `psn' (predicate semi-naive), `aditi_memo', `aditi_no_memo',
	`base_relation', `owner' and `index'.
	Separate out code to parse a predicate name and arity.

compiler/hlds_pred.m:
	Add predicates to identify Aditi procedures.
	Added markers `generate_inline' and `aditi_interface', which
	are used internally for Aditi code generation.
	Add an `owner' field to pred_infos, which is used for database
	security checks.
	Add a field to pred_infos to hold the list of indexes for a base
	relation.

compiler/make_hlds.m:
	Some pragmas must be exported if the corresponding predicates
	are exported, check this.
	Make sure stratification of Aditi procedures is checked.
	Predicates with a mode declaration but no type declaration
	are no longer assumed to be local.
	Set the `do_aditi_compilation' field of the module_info if there
	are any local Aditi procedures or base relations.
	Check that `--aditi' is set if Aditi compilation is required.

compiler/post_typecheck.m:
	Check that every Aditi predicate has an `aditi__state' argument,
	which is used to ensure sequencing of updates and that Aditi
	procedures are only called within transactions.

compiler/dnf.m:
	Changed the definition of disjunctive normal form slightly
	so that a call followed by some atomic goals not including
	any database calls is considered atomic. magic.m can handle
	this kind of goal, and it results in more efficient RL code.

compiler/hlds_module.m:
compiler/dependency_graph.m:
	Added dependency_graph__get_scc_entry_points which finds
	the procedures in an SCC which could be called from outside.
	Added a new field to the dependency_info, the
	aditi_dependency_ordering. This contains all Aditi SCCs of
	the original program, with multiple SCCs merged where
	possible to improve the effectiveness of differential evaluation
	and the low level RL optimizations.

compiler/hlds_module.m:
	Add a field to record whether there are any local Aditi procedures
	in the current module.
	Added versions of module_info_pred_proc_info and
	module_info_set_pred_proc_info which take a pred_proc_id,
	not a separate pred_id and proc_id.

compiler/polymorphism.m:
compiler/lambda.m:
	Make sure that predicates created for closures in Aditi procedures
	have the correct markers.

compiler/goal_util.m:
	Added goal_util__switch_to_disjunction,
	goal_util__case_to_disjunct (factored out from simplify.m)
	and goal_util__if_then_else_to_disjunction. These are
	require because supplementary magic sets can't handle
	if-then-elses or switches.

compiler/type_util.m:
	Added type_is_aditi_state/1.

compiler/mode_util.m:
	Added partition_args/5 which partitions a list of arguments
	into inputs and others.

compiler/inlining.m:
	Don't inline memoed procedures.
	Don't inline Aditi procedures into non-Aditi procedures.

compiler/intermod.m:
	Handle Aditi markers.
	Clean up handling of markers which should not appear in `.opt' files.

compiler/simplify.m:
	Export a slightly different interface for use by magic.m.
	Remove explicit quantifications where possible.
	Merge multiple nested quantifications.
	Don't report infinite recursion warnings for Aditi procedures.

compiler/prog_out.m:
	Generalised the code to output a module list to write any list.

compiler/code_gen.m:
compiler/arg_info.m:
	Don't process Aditi procedures.

compiler/mercury_compile.m:
	Call magic.m and rl_gen.m.
	Don't perform the low-level annotation passes on Aditi procedures.
	Remove calls to constraint.m - sometime soon a rewritten version
	will be called directly from deforestation.

compiler/passes_aux.m:
	Add predicates to process only non-Aditi procedures.

compiler/llds.m:
compiler/llds_out.m:
	Added new `code_addr' enum members, do_{det,semidet,nondet}_aditi_call,
	which are defined in extras/aditi/aditi.m.

compiler/call_gen.m:
	Handle generation of do_*_aditi_call.

compiler/llds_out.m:
	Write the RL code for the module as a constant char array
	in the `.c' file.

compiler/term_errors.m:
compiler/error_util.m:
	Move code to describe predicates into error_util.m
	Allow the caller to explicitly add line breaks.
	Added error_util:list_to_pieces to format a list of
	strings.
	Reordered some arguments for currying.

compiler/hlds_out.m:
	Don't try to print clauses if there are none.

runtime/mercury_init.h:
util/mkinit.c:
scripts/c2init.in:
	Added a function `mercury__load_aditi_rl_code()' to the generated
	`<module>_init.c' file which throws all the RL code for the program
	at the database. This should be called at connection time by
	`aditi__connect'.
	Added an option `--aditi' which controls the output
	`mercury__load_aditi_rl_code()'.

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

Mmakefile:
bindist/Mmakefile:
	Don't distribute extras/aditi yet.

New files:

compiler/magic.m:
compiler/magic_util.m:
	Supplementary magic sets transformation. Report errors
	for constructs that Aditi can't handle.

compiler/context.m:
	Supplementary context transformation.

compiler/rl_gen.m:
compiler/rl_relops.m:
	Aditi code generation.

compiler/rl_info.m:
	Code generator state.

compiler/rl.m:
	Intermediate RL representation.

compiler/rl_util:
	Predicates to collect information about RL instructions.

compiler/rl_dump.m:
	Print out the representation in rl.m.

compiler/rl_opt.m:
	Control low-level RL optimizations.

compiler/rl_block.m:
	Break a procedure into basic blocks.

compiler/rl_analyse.m:
	Generic dataflow analysis for RL procedures.

compiler/rl_liveness.m:
	Make sure all relations are initialised before used, clear
	references to relations that are no longer required.

compiler/rl_loop.m:
	Loop invariant removal.

compiler/rl_block_opt.m:
	CSE and instruction merging on basic blocks.

compiler/rl_key.m:
	Detect upper/lower bounds for which a goal could succeed.

compiler/rl_sort.m:
	Use indexing for joins and projections.
	Optimize away unnecessary sorting and indexing.

compiler/rl_stream.m:
	Detect relations which don't need to be materialised.

compiler/rl_code.m:
	RL bytecode definitions. Automatically generated from the Aditi
	header files.

compiler/rl_out.m:
compiler/rl_file.m:
	Output the RL bytecodes in binary to <module>.rlo (for use by Aditi)
	and in text to <module>.rla (for use by the RL interpreter).
	Also output the schema information if --generate-schemas is set.

compiler/rl_exprn.m:
	Generate bytecodes for join conditions.

extras/aditi/Mmakefile:
extras/aditi/aditi.m:
	Definitions of some Aditi library predicates and the
	interfacing and transaction processing code.
1998-12-06 23:49:14 +00:00
David Overton
ed91b801be Fix some scripts in the tools directory to work with the new
Estimated hours taken: 0.5

Fix some scripts in the tools directory to work with the new
directories and library names.

tools/binary:
tools/binary_step:
tools/linear:
	Update these scripts to work properly with the new browser and
	trace directories and the renamed libraries.

Mmake.common.in:
scripts/c2init.in:
scripts/ml.in:
	Add tools/binary, tools/binary_step and tools/linear to the
	list of files that know about library names.
1998-10-09 05:41:58 +00:00
Zoltan Somogyi
f633c977f6 Update the comments about the other locations that know the names of
Estimated hours taken: 0.2

Mmake.common.in:
scripts/ml.in:
tools/bootcheck:
	Update the comments about the other locations that know the names of
	the libraries, now that c2init knows them too.

scripts/c2init.in:
	Add a comment about the other locations.
1998-10-01 09:11:10 +00:00
Fergus Henderson
1f6694098b Fix a bug introduced in zs's change to add two new directories.
Estimated hours taken: 0.5

Fix a bug introduced in zs's change to add two new directories.

scripts/c2init.in:
	Update the list of `.init' files to match the new names
	and to include the init file for the `browser' library.
1998-10-01 04:19:49 +00:00
Zoltan Somogyi
8ddce575d4 Introduce two new directories, trace and browser, containing libraries
Estimated hours taken: 10

Introduce two new directories, trace and browser, containing libraries
holding the C and Mercury code of the debugger respectively. (Although
the browser directory does not have a browser in it yet, the browser
should soon become its biggest component.) Take the opportunity to
rename the existing libraries, for consistency.

After this change, the linking order becomes:

	the object of the auto-generated init file
	program object files
	trace library (libmer_trace.a)
	browser library (libmer_browser.a)
	standard library (libmer_std.a)
	runtime library (libmer_rt.a)
	Boehm collector (libgc.a)

To avoid circularities, libraries cannot contain direct calls to
any routines that are defined in libraries (or object files) that
occur earlier in the above list.  Any such calls must be made into
indirect calls via function pointers.

In particular, there was a circularity caused by the library calling
MR_trace() which invokes the tracer which in turn invokes the
library.  This circularity was broken by having MR_trace(),
which is defined in the runtime, call the tracer indirectly via
a global variable named MR_trace_func_ptr.  This global variable
is initialized by the auto-generated *_init.c file.

To avoid linking in the tracer even when it is not being used,
this global variable is only set to point to MR_trace_real()
if you're using a debugging grade or if c2init was invoked
with the `-t' flag.  Otherwise it is set to MR_trace_fake()
which just prints an error message telling the user to
rebuild the executable with debugging enabled.

Makefile.DLLs:
	Reserve random locations for the two new libraries. Whether they work
	will be decided by testing on Windows.

Mmake.common.in:
	Add variables naming the new directories, and create variables
	naming the libraries.

Mmakefile:
	Add targets for the new directories, and modify existing rules
	as appropriate.

browser/Mmakefile:
	Mmakefile for the new directory, modelled on library/Mmakefile.

browser/browser_library.m:
	Umbrella file for the new directory, modelled on library/library.m.

{browser,library}/debugger_interface.m:
	Moved this file from library to browser without change.

browser/help.m:
	A new module for the help system of the debugger. Not yet used.

compiler/Mmakefile:
	Update to refer to the new directories and libraries where
	appropriate.

compiler/mercury_compile.m:
	If we are doing tracing, then pass -t instead of -i to c2init.

compiler/modules.m:
	When generating the .dep file, get the grade flags passed to c2init.

doc/Mmakefile:
	Remove the special treatment of library/debugger_interface.m.

library/Mmakefile:
	Update to refer to the new directories and libraries where
	appropriate, and to conform to the new name of the library.

library/library.m:
	Do not import debugger_interface.

profiler/Mmakefile:
	Update to refer to the new directories and libraries where
	appropriate.

runtime/Mmakefile:
	Update to refer to the new directories and libraries where
	appropriate, and to conform to the new name of the library.

	Remove references to files being moved to the trace directory.

runtime/mercury_init.h:
	Refer to the automatically generated dll header file by its new name
	(renamed because the runtime library is renamed).

	Add declarations to support the new global variable MR_trace_func_ptr.

runtime/mercury_memory_handlers.c:
runtime/mercury_memory_zones.c:
runtime/mercury_misc.c:
	Remove inappropriate #includes of "mercury_trace.h", and substitute
	a #include of "mercury_trace_base.h" if necessary.

{runtime,trace}/mercury_trace.[ch]:
{runtime,trace}/mercury_trace_external.[ch]:
{runtime,trace}/mercury_trace_internal.[ch]:
	Move these files from the runtime to the trace directory.

	The only changes are the removal from mercury_trace.h of declarations
	added to runtime/mercury_trace_base.h, and the change from MR_trace
	to MR_trace_real.

runtime/mercury_trace_base.[ch]:
	Define MR_trace(), which does an indirect call through
	MR_trace_func_ptr if the event should be traced.

	Define MR_trace_fake, which just prints an error message.
	Its address will be assigned to MR_trace_func_ptr if tracing
	is not enabled.

	Define the types needed by the signature of MR_trace.

	Fix an old bug: s/MERCURY_TRACE_PERMANENT_H/MERCURY_TRACE_BASE_H/.

runtime/mercury_wrapper.[ch]:
	Add the new global variable MR_trace_func_ptr.

scripts/c2init.in:
	Add a new option, -t/--trace, which enables tracing by causing the
	address of MR_trace_real to be assigned to MR_trace_func_ptr.

	Have this option be implied by the grade. Also have the old option
	-i (need initialization code) be implied by the grade, as well as by
	-t.

scripts/ml.in:
	Include the new libraries in the link command.

tests/debugger/Mmakefile:
	Include -t instead of -i in the list of c2init options. (-t implies
	-i.)

tools/bootcheck:
	Copy and build the new directories as appropriate. The trace directory
	is treated like the runtime, the browser directory is treated like the
	library.

trace/Mmakefile:
	Mmakefile for the new directory, modelled on runtime/Mmakefile.

util/mkinit.c:
	Add the new option -t, as discussed above.
	Mmakefile for the new directory, modelled on runtime/Mmakefile.

util/Mmakefile:
	Specify -O0, since with the default optimization level, gcc on
	cyclone ignores the assignment of TRUE to need_tracing when -t is
	given (!!!).
1998-09-29 05:12:06 +00:00
Zoltan Somogyi
4ada219856 Reorganize the label table to better fit the needs of accurate gc
Estimated hours taken: 25

Reorganize the label table to better fit the needs of accurate gc
and the tracer, and reduce the size of executables.

With these changes, the size of hello world, compiled with static
Mercury libraries but dynamic C libraries, goes from 150+ Kb to
138+ Kb, much of which is beyond our control (e.g. Boehm gc).

runtime/mercury_label.[ch]:
	The old label table contained both entry labels and internal labels,
	even though they had different kinds of layouts associated with them
	(proc layouts and label layouts respectively). The two kinds of labels
	have different usage patterns. Internal labels are needed for stack
	walking, which requires random access by exact label address. Entry
	labels are needed for finding which procedure a program counter is in
	for accurate GC, which requires lower-bound inexact search.

	The module now has two separate data structures for the two
	different kinds of labels. Internal labels are in a hash table,
	as before. Entry labels are in an array (resized on demand),
	which is sorted for binary search. The entry label array and
	its associated functions are present only if they are needed.

runtime/mercury_goto.h:
	Call the new functions in mercury_label.c from the
	init_{local,label,entry}{,_sl} macros.

runtime/mercury_misc.[ch]
	Use the new functions in mercury_label. Fix some software rot,
	so that the code now compiles with MR_DEBUG_GOTOS. (It still does not
	compile with MR_LOWLEVEL_DEBUG, but the fix for that would conflict
	with Tom's planned change to zone handling, so that fix should be
	done after Tom is done.)

	Note that mercury_misc.c still defines newmem() and oldmem()
	although they are declared in mercury_std.h.

runtime/mercury_stack_trace.c:
	Use the new functions in mercury_label. As a result, we also need
	to make a few more pointers const.

runtime/mercury_table.[ch]:
	Add a new traversal predicate to support a new function in
	mercury_label.c. (That function is not used yet, but will be soon.)

runtime/mercury_trace.[ch]:
runtime/mercury_trace_base.[ch]:
	Split the old mercury_trace module into two. The functions and
	variables that will always be linked in (because they are referenced
	from modules such as mercury_wrapper which are always needed) are
	now in mercury_trace_base; the other functions and variables
	stay in mercury_trace. This way, mercury_trace.o will be linked in
	only if some module was compiled with execution tracing. Since
	mercury_trace.o drags in mercury_trace_internal.o which drags in
	everything needed for printing arbitrary terms (which is a lot),
	this can be a significant win.

runtime/Mmakefile:
	Include the new module in the library.

runtime/mercury_wrapper.c:
runtime/mercury_conf_param.h:
	Remove some obsolete MERCURY_OPTIONS options, which would be
	difficult to support with the new label table.

	Move the #ifdefs around the -P option, so that programs not
	compiled with MR_THREAD_SAFE will accept but ignore the option,
	instead of aborting with the usage message.

	Replace the long usage message for malformed MERCURY_OPTIONS
	environment variables with a pointer to the user's guide.
	This saves about 1 Kb on every executable.

runtime/mercury_conf_param.h:
	Document MR_STACK_TRACE_THIS_MODULE.

util/mkinit.c:
	Add a new flag, -i. If this flag is given, include the initialization
	code regardless of grade. If it is not given, include the init code
	only if the grade requires it.

	The -i should be given if you want the executable to support stack
	tracing, or uplevel printing in execution tracing, at the cost of
	making the executable link in the init functions of all the modules
	in the library.

	Put the option handling code in alphabetical order.

	Fix the wrong default name of the entry point. (It only worked because
	c2init was always overriding the default.)

scripts/c2init.in:
	Pass through the -i flag to mkinit.

	Put the option handling code in alphabetical order.

compiler/mercury_compile.m:
	If the trace level specifies any kind of tracing, pass -i to c2init.

tests/debugger/Mmakefile:
	Add -i to the c2init flags.

tests/debugger/*
	Update the other half the test cases (those which assume a traced
	library) to conform to the changes in the debugger interface.
	The first half were updated earlier.

doc/user_guide.texi:
	In the environment variable section, modify the entry for
	MERCURY_OPTIONS to document all the options it makes sense
	for non-developers to use.

	Slight changes to two other parts of the guide to reduce duplication
	with the new material.
1998-07-03 02:36:09 +00:00
Fergus Henderson
38ae5fe0c5 Fix a bug which caused link errors in some grades for some test cases
Estimated hours taken: 1

Fix a bug which caused link errors in some grades for some test cases
where the module name wasn't the same as the file name, and which
probably would have caused runtime errors in some grades for test
cases using nested modules.

compiler/modules.m:
	Call $(C2INIT) with $(foo.cs) instead of $(foo.ms).
	This is necessary now that a single .m file can get compiled
	to multiple .c files, if it contains nested modules,
	or to a .c file whose name reflects the module name rather
	than the source file name.

util/mkinit.c:
scripts/c2init.in:
	For efficiency, change c2init and mkinit so that when c2init's
	arguments are `.c' files, it computes the init function based
	on the filename (like it used to do with `.m' files), rather
	than by reading the file contents and searching for "** INIT"
	comments.  Add a new option `-x' (`--extra-inits') which keeps
	the old behaviour.

compiler/modules.m:
scripts/Mmake.rules:
	Instead of deleting the `_init.c' file every time we recreate
	the `.dep' file, just tell make that the `_init.c' file depends on
	the `.dep' file, so that make will remake it if the `.dep' file
	changes.  (I don't know why I didn't do it that way in the
	first place.)
1998-05-30 13:34:17 +00:00
Fergus Henderson
a6357c33bb Fix a small quoting bug in my previous change.
Estimated hours taken: 0.1

scripts/c2init.in:
	Fix a small quoting bug in my previous change.
1997-09-06 12:04:15 +00:00
Fergus Henderson
8bc9cf2d1c Use only libmercury.init and runtime.init in $MERCURY_MOD_LIB_DIR,
Estimated hours taken: 0.25

scripts/c2init.in:
	Use only libmercury.init and runtime.init in $MERCURY_MOD_LIB_DIR,
	rather than using `$MERCURY_MOD_LIB_DIR/*'.  This avoids problems
	if other .init files (e.g. cfloat_lib.init) are installed in
	the same directory.
1997-09-06 11:44:02 +00:00
Fergus Henderson
d1cc2ddee4 Split up the startup interface so that there are seperate
Estimated hours taken: 8

Split up the startup interface so that there are seperate
initialization and termination functions, rather than just a single
mercury_runtime_main() function which does everything.
Also change things so that the io__state data is stored in global
variables.

runtime/init.h:
util/mkinit.c:
runtime/wrapper.h:
runtime/wrapper.mod:
	Move declarations for stuff defined in wrapper.mod from init.h
	to wrapper.h.  Clean up the remainder of init.h so that it
	is clear which parts are interface and which are just there
	for use by *_init.c.

	Change the automatically-generated *_init.c files
	so that they call mercury_runtime_init(),
	mercury_runtime_main(), and mercury_runtime_terminate(),
	rather than just mercury_runtime_main().
	Define these new two functions in wrapper.mod.

	Delete the library_entry_point; change do_interpreter
	to call program_entry_point directly, rather than via
	library_entry_point.

runtime/engine.h:
runtime/engine.mod:
	Add new function terminate_engine().
	Delete the function start_mercury_engine();
	move the code that used to be there to the end
	of init_engine().

runtime/context.h:
runtime/context.mod:
	Add new function shutdown_processes().
	(The current implementation is just a stub.)
	Add a call to debug_memory() in init_process_context().

runtime/memory.h:
runtime/memory.c:
	Export the debug_memory() function, for use by context.c.

library/io.m:
library/io.nu.nl:
	Change things so that the io__state data is stored in C global
	variables (or, for Prolog, using assert/retract), rather than
	passing around a data structure.  (Actually we still pass the
	data structure around, but it is just a dummy Word that never
	gets used.)

	Delete the old hand-coded io__run predicate, which was
	the library entry point; instead export C functions
	ML_io_init_state() and ML_io_finalize_state().	Move the
	code for handling profiling from io__run to do_interpreter
	in runtime/wrapper.mod.

scripts/c2init.in:
	Change the default entry point from io__run_0_0 to main_2_0
1997-09-05 22:38:58 +00:00
Fergus Henderson
04b720630b Update the copyright messages so that (a) they contain the correct years
and (b) they say "Copyright (C) ... _The_ University of Melbourne".
1997-07-27 15:09:59 +00:00
Fergus Henderson
8ce103cc76 Add Unix-style man pages for most of the Mercury development tools.
scripts/c2init.in:
scripts/mmake.in:
scripts/msc.in:
	Small changes to the help messages to make them come out
	better when converted to man pages.

scripts/mgnuc.in:
	Add a `--help' option.
1997-02-07 14:17:41 +00:00
Fergus Henderson
d14bdd2eee More stuff to support non-Mercury main() programs.
Estimated hours taken: 0.5

More stuff to support non-Mercury main() programs.

util/c2init.c:
	Implement a new `-l' / `--libary' option.
	If this option is enabled, we pass `-l' to mkinit,
	which has the end result that we don't emit a main(),
	but instead we emit a mercury_main(argc, argv, stack_bottom)
	function that can be called from C.
1997-02-01 00:12:06 +00:00
Fergus Henderson
62377e8bf2 Fix a portability problem: ULTRIX's /bin/sh does not understand
Estimated hours taken: 0.5

scripts/{c2init,mnc,mnl,msc,msl}.in:
	Fix a portability problem: ULTRIX's /bin/sh does not understand
	`shift 2', so I've replaced all occurrences of this with
	`shift; shift'.  (Thanks to Jeff Schultz for the bug report.)
1996-05-13 06:12:48 +00:00
Fergus Henderson
8cf86fd1ef Replace all uses of
scripts/*.in:
	Replace all uses of

		... "$@" ...

	with

		case $# in
			0) ... ...
			*) ... "$@" ...
		esac

	since on ULTRIX and OSF, "$@" does the wrong thing if $# is 0.
1995-09-18 07:14:09 +00:00
Fergus Henderson
eaf2c48c34 Don't use `getopts', since it is not portable.
c2init.in:
	Don't use `getopts', since it is not portable.
	Add long versions of all the options.
	Improve usage message.
1995-07-21 08:13:26 +00:00
Zoltan Somogyi
1849d45e77 Fixed usage message.
c2init.in:
	Fixed usage message.
1995-05-29 01:49:39 +00:00
Fergus Henderson
60bc8f3ef9 Change "#!/bin/sh" to "#! /bin/sh", since the latter is more portable.
scripts/*.in:
	Change "#!/bin/sh" to "#! /bin/sh", since the latter is more portable.
	Add "# @configure_input@" to the start of each file.
1995-05-19 08:17:46 +00:00
Fergus Henderson
1a468516f1 Another correction to the comments.
scripts/c2init.in:
	Another correction to the comments.
1995-05-19 07:35:01 +00:00
Fergus Henderson
aada31a38f Update the comments, which had become obsolete.
scripts/c2init.in:
	Update the comments, which had become obsolete.
1995-05-19 07:30:35 +00:00
Fergus Henderson
b02471a037 Change things so that we invoke a new `c2init' script to create the init files,
rather than invoking `mkinit' directly.  The reason is that `mkinit' only
does part of `mod2init's old job; `c2init' collects the filenames of the
standard library modules (possibly overridden by environment variables)
and passes these, together with the modules named on the command line,
to `mkinit'.
1995-05-13 05:51:35 +00:00