Commit Graph

237 Commits

Author SHA1 Message Date
Peter Ross
f157783eea Fixes for the testing infrastructure for the il grade.
Estimated hours taken: 4
Branches: main

Fixes for the testing infrastructure for the il grade.

hard_coded/Mmakefile:
	Don't do the fact table tests in the il and java grades.

hard_coded/string_strip.m:
hard_coded/string_strip.exp:
	Add a new line at the end of the program, so that the last
	line is complete.

hard_coded/string_strip.exp2:
	The IL grade does string comparison in a different order to
	the C grades, thus the second version of string_strip.

hard_coded/user_compare.m:
	Add il versions of the foreign procs.

invalid/Mmakefile:
valid/Mmakefile:
	Remove the reserve_tag tests from the il and java grades.

invalid/foreign_type_2.err_exp2:
	Update the expected output now that '.' is the module
	seperator.

warnings/singleton_test.m:
warnings/singleton_test.exp2:
	Modify this test to include tests for the IL backend.
2003-10-26 12:43:34 +00:00
Zoltan Somogyi
f007b45df8 Implement the infrastructure for term size profiling.
Estimated hours taken: 400
Branches: main

Implement the infrastructure for term size profiling. This means adding two
new grade components, tsw and tsc, and implementing them in the LLDS code
generator. In grades including tsw (term size words), each term is augmented
with an extra word giving the number of heap words it contains; in grades
including tsc (term size cells), each term is augmented with an extra word
giving the number of heap cells it contains. The extra word is at the start,
at offset -1, to leave almost all of the machinery for accessing the heap
unchanged.

For now, the only way to access term sizes is with a new mdb command,
"term_size <varspec>". Later, we will use term sizes in conjunction with
deep profiling to do experimental complexity analysis, but that requires
a lot more research. This diff is a necessary first step.

The implementation of term size profiling consists of three main parts:

- a source-to-source transform that computes the size of each heap cell
  when it is constructed (and increments it in the rare cases when a free
  argument of an existing heap cell is bound),

- a relatively small change to the code generator that reserves the extra
  slot in new heap cells, and

- extensions to the facilities for creating cells from C code to record
  the extra information we now need.

The diff overhauls polymorphism.m to make the source-to-source transform
possible. This overhaul includes separating type_ctor_infos and type_infos
as strictly as possible from each other, converting type_ctor_infos into
type_infos only as necessary. It also includes separating type_ctor_infos,
type_infos, base_typeclass_infos and typeclass_infos (as well as voids,
for clarity) from plain user-defined type constructors in type categorizations.
This change needs this separation because values of those four types do not
have size slots, but they ought to be treated specially in other situations
as well (e.g. by tabling).

The diff adds a new mdb command, term_size. It also replaces the proc_body
mdb command with new ways of using the existing print and browse commands
("print proc_body" and "browse proc_body") in order to make looking at
procedure bodies more controllable. This was useful in debugging the effect
of term size profiling on some test case outputs. It is not strictly tied
to term size profiling, but turns out to be difficult to disentangle.

compiler/size_prof.m:
	A new module implementing the source-to-source transform.

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

compiler/transform_hlds.m:
	Include size_prof as a submodule of transform_hlds.

compiler/mercury_compile.m:
	If term size profiling is enabled, invoke its source-to-source
	transform.

compiler/hlds_goal.m:
	Extend construction unifications with an optional slot for recording
	the size of the term if the size is a constant, or the identity of the
	variable holding the size, if the size is not constant. This is
	needed by the source-to-source transform.

compiler/quantification.m:
	Treat the variable reference that may be in this slot as a nonlocal
	variable of construction unifications, since the code generator needs
	this.

compiler/compile_target_code.m:
	Handle the new grade components.

compiler/options.m:
	Implement the options that control term size profiling.

doc/user_guide.texi:
	Document the options and grade components that control term size
	profiling, and the term_size mdb command. The documentation is
	commented out for now.

	Modify the wording of the 'u' HLDS dump flag to include other details
	of unifications (e.g. term size info) rather than just unification
	categories.

	Document the new alternatives of the print and browse commands. Since
	they are for developers only, the documentation is commented out.

compiler/handle_options.m:
	Handle the implications of term size profiling grades.

	Add a -D flag value to print HLDS components relevant to HLDS
	transformations.

compiler/modules.m:
	Import the new builtin library module that implements the operations
	needed by term size profiling automatically in term size profiling
	grades.

	Switch the predicate involved to use state var syntax.

compiler/prog_util.m:
	Add predicates and functions that return the sym_names of the modules
	needed by term size profiling.

compiler/code_info.m:
compiler/unify_gen.m:
compiler/var_locn.m:
 	Reserve an extra slot in heap cells and fill them in in unifications
	marked by size_prof.

compiler/builtin_ops.m:
	Add term_size_prof_builtin.term_size_plus as a builtin, with the same
	implementation as int.+.

compiler/make_hlds.m:
	Disable warnings about clauses for builtins while the change to
	builtin_ops is bootstrapped.

compiler/polymorphism.m:
	Export predicates that generate goals to create type_infos and
	type_ctor_infos to add_to_construct.m. Rewrite their documentation
	to make it more detailed.

	Make orders of arguments amenable to the use of state variable syntax.

	Consolidate knowledge of which type categories have builtin unify and
	compare predicates in one place.

	Add code to leave the types of type_ctor_infos alone: instead of
	changing their types to type_info when used as arguments of other
	type_infos, create a new variable of type type_info instead, and
	use an unsafe_cast. This would make the HLDS closer to being type
	correct, but this new code is currently commented out, for two
	reasons. First, common.m is currently not smart enough to figure out
	that if X and Y are equal, then similar unsafe_casts of X and Y
	are also equal, and this causes the compiler do not detect some
	duplicate calls it used to detect. Second, the code generators
	are also not smart enough to know that if Z is an unsafe_cast of X,
	then X and Z do not need separate stack slots, but can use the same
	slot.

compiler/type_util.m:
	Add utility predicates for returning the types of type_infos and
	type_ctor_infos, for use by new code in polymorphism.m.

	Move some utility predicates here from other modules, since they
	are now used by more than one module.

	Rename the type `builtin_type' as `type_category', to better reflect
	what it does. Extend it to put the type_info, type_ctor_info,
	typeclass_info, base_typeclass_info and void types into categories
	of their own: treating these types as if they were a user-defined
	type (which is how they used to be classified) is not always correct.
	Rename the functor polymorphic_type to variable_type, since types
	such as list(T) are polymorphic, but they fall into the user-defined
	category. Rename user_type as user_ctor_type, since list(int) is not
	wholly user-defined but falls into this category. Rename pred_type
	as higher_order_type, since it also encompasses functions.

	Replace code that used to check for a few of the alternatives
	of this type with code that does a full switch on the type,
	to ensure that they are updated if the type definition ever
	changes again.

compiler/pseudo_type_info.m:
	Delete a predicate whose updated implementation is now in type_util.m.

compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
	Still treat type_infos, type_ctor_infos, typeclass_infos and
	base_typeclass_infos as user-defined types, but prepare for when
	they won't be.

compiler/hlds_pred.m:
	Require interface typeinfo liveness when term size profiling is
	enabled.

	Add term_size_profiling_builtin.increase_size as a
	no_type_info_builtin.

compiler/hlds_out.m:
	Print the size annotations on unifications if HLDS dump flags call
	for unification details. (The flag test is in the caller of the
	modified predicate.)

compiler/llds.m:
	Extend incr_hp instructions and data_addr_consts with optional fields
	that allow the code generator to refer to N words past the start of
	a static or dynamic cell. Term size profiling uses this with N=1.

compiler/llds_out.m:
	When allocating memory on the heap, use the macro variants that
	specify an optional offset, and specify the offset when required.

compiler/bytecode_gen.m:
compiler/dense_switch.m:
compiler/dupelim.m:
compiler/exprn_aux.m:
compiler/goal_form.m:
compiler/goal_util.m:
compiler/higher_order.m:
compiler/inst_match.m:
compiler/intermod.m:
compiler/jumpopt.m:
compiler/lambda.m:
compiler/livemap.m:
compiler/ll_pseudo_type_info.m:
compiler/lookup_switch.m:
compiler/magic_util.m:
compiler/middle_rec.m:
compiler/ml_code_util.m:
compiler/ml_switch_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/modecheck_unify.m:
compiler/opt_debug.m:
compiler/opt_util.m:
compiler/par_conj_gen.m:
compiler/post_typecheck.m:
compiler/reassign.m:
compiler/rl.m:
compiler/rl_key.m:
compiler/special_pred.m:
compiler/stack_layout.m:
compiler/static_term.m:
compiler/string_switch.m:
compiler/switch_gen.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unused_args.m:
compiler/use_local_vars.m:
	Minor updates to conform to the changes above.

library/term_size_prof_builtin.m:
	New module containing helper predicates for term size profiling.
	size_prof.m generates call to these predicates.

library/library.m:
	Include the new module in the library.

doc/Mmakefile:
	Do not include the term_size_prof_builtin module in the library
	documentation.

library/array.m:
library/benchmarking.m:
library/construct.m:
library/deconstruct.m:
library/io.m:
library/sparse_bitset.m:
library/store.m:
library/string.m:
	Replace all uses of MR_incr_hp with MR_offset_incr_hp, to ensure
	that we haven't overlooked any places where offsets may need to be
	specified.

	Fix formatting of foreign_procs.

	Use new macros defined by the runtime system when constructing
	terms (which all happen to be lists) in C code. These new macros
	specify the types of the cell arguments, allowing the implementation
	to figure out the size of the new cell based on the sizes of its
	fields.

library/private_builtin.m:
	Define some constant type_info structures for use by these macros.
	They cannot be defined in the runtime, since they refer to types
	defined in the library (list.list and std_util.univ).

util/mkinit.c:
	Make the addresses of these type_info structures available to the
	runtime.

runtime/mercury_init.h:
	Declare these type_info structures, for use in mkinit-generated
	*_init.c files.

runtime/mercury_wrapper.[ch]:
	Declare and define the variables that hold these addresses, for use
	in the new macros for constructing typed lists.

	Since term size profiling can refer to a memory cell by a pointer
	that is offset by one word, register the extra offsets with the Boehm
	collector if is being used.

	Document the incompatibility of MR_HIGHTAGS and the Boehm collector.

runtime/mercury_tags.h:
	Define new macros for constructing typed lists.

	Provide macros for preserving the old interface presented by this file
	to the extent possible. Uses of the old MR_list_cons macro will
	continue to work in grades without term size profiling. In term
	size profiling grades, their use will get a C compiler error.

	Fix a bug caused by a missing backslash.

runtime/mercury_heap.h:
	Change the basic macros for allocating new heap cells to take
	an optional offset argument. If this is nonzero, the macros
	increment the returned address by the given number of words.
	Term size profiling specifies offset=1, reserving the extra
	word at the start (which is ignored by all components of the
	system except term size profiling) for holding the size of the term.

	Provide macros for preserving the old interface presented by this file
	to the extent possible. Since the old MR_create[123] and MR_list_cons
	macros did not specify type information, they had to be changed
	to take additional arguments. This affects only hand-written C code.

	Call new diagnostic macros that can help debug heap allocations.

	Document why the macros in this files must expand to expressions
	instead of statements, evn though the latter would be preferable
	(e.g. by allowing them to declare and use local variables without
	depending on gcc extensions).

runtime/mercury_debug.[ch]:
	Add diagnostic macros to debug heap allocations, and the functions
	behind them if MR_DEBUG_HEAP_ALLOC is defined.

	Update the debugging routines for hand-allocated cells to print the
	values of the term size slot as well as the other slots in the relevant
	grades.

runtime/mercury_string.h:
	Provide some needed variants of the macro for copying strings.

runtime/mercury_deconstruct_macros.h:
runtime/mercury_type_info.c:
	Supply type information when constructing terms.

runtime/mercury_deep_copy_body.h:
	Preserve the term size slot when copying terms.

runtime/mercury_deep_copy_body.h:
runtime/mercury_ho_call.c:
runtime/mercury_ml_expand_body.h:
	Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
	that allocate cells also allocate space for the term size slot if
	necessary.

	Reduce code duplication by using a now standard macro for copying
	strings.

runtime/mercury_grade.h:
	Handle the two new grade components.

runtime/mercury_conf_param.h:
	Document the C macros used to control the two new grade components,
	as well as MR_DEBUG_HEAP_ALLOC.

	Detect incompatibilities between high level code and profiling.

runtime/mercury_term_size.[ch]:
	A new module to house a function to find and return term sizes
	stored in heap cells.

runtime/mercury_proc_id.h:
runtime/mercury_univ.h:
	New header files. mercury_proc_id.h contains the (unchanged)
	definition of MR_Proc_Id, while mercury_univ.h contains the
	definitions of the macros for manipulating univs that used to be
	in mercury_type_info.h, updated to use the new macros for allocating
	memory.

	In the absence of these header files, the following circularity
	would ensue:

	mercury_deep_profiling.h includes mercury_stack_layout.h
		- needs definition of MR_Proc_Id
	mercury_stack_layout.h needs mercury_type_info.h
		- needs definition of MR_PseudoTypeInfo
	mercury_type_info.h needs mercury_heap.h
		- needs heap allocation macros for MR_new_univ_on_hp
	mercury_heap.h includes mercury_deep_profiling.h
		- needs MR_current_call_site_dynamic for recording allocations

	Breaking the circular dependency in two places, not just one, is to
	minimize similar problems in the future.

runtime/mercury_stack_layout.h:
	Delete the definition of MR_Proc_Id, which is now in mercury_proc_id.h.

runtime/mercury_type_info.h:
	Delete the macros for manipulating univs, which are now in
	mercury_univ.h.

runtime/Mmakefile:
	Mention the new files.

runtime/mercury_imp.h:
runtime/mercury.h:
runtime/mercury_construct.c:
runtime/mercury_deep_profiling.h:
	Include the new files at appropriate points.

runtime/mercury.c:
	Change the names of the functions that create heap cells for
	hand-written code, since the interface to hand-written code has
	changed to include type information.

runtime/mercury_tabling.h:
	Delete some unused macros.

runtime/mercury_trace_base.c:
runtime/mercury_type_info.c:
	Use the new macros supplying type information when constructing lists.

scripts/canonical_grade_options.sh-subr:
	Fix an undefined sh variable bug that could cause error messages
	to come out without identifying the program they were from.

scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
scripts/canonical_grade_options.sh-subr:
scripts/mgnuc.in:
	Handle the new grade components and the options controlling them.

trace/mercury_trace_internal.c:
	Implement the mdb command "term_size <varspec>", which is like
	"print <varspec>", but prints the size of a term instead of its value.
	In non-term-size-profiling grades, it prints an error message.

	Replace the "proc_body" command with optional arguments to the "print"
	and "browse" commands.

doc/user_guide.tex:
	Add documentation of the term_size mdb command. Since the command is
	for implementors only, and works only in grades that are not yet ready
	for public consumption, the documentation is commented out.

	Add documentation of the new arguments of the print and browse mdb
	commands. Since they are for implementors only, the documentation
	is commented out.

trace/mercury_trace_vars.[ch]:
	Add the functions needed to implement the term_size command, and
	factor out the code common to the "size" and "print"/"browse" commands.

	Decide whether to print the name of a variable before invoking the
	supplied print or browse predicate on it based on a flag design for
	this purpose, instead of overloading the meaning of the output FILE *
	variable. This arrangement is much clearer.

trace/mercury_trace_browse.c:
trace/mercury_trace_external.c:
trace/mercury_trace_help.c:
	Supply type information when constructing terms.

browser/program_representation.m:
	Since the new library module term_size_prof_builtin never generates
	any events, mark it as such, so that the declarative debugger doesn't
	expect it to generate any.

	Do the same for the deep profiling builtin module.

tests/debugger/term_size_words.{m,inp,exp}:
tests/debugger/term_size_cells.{m,inp,exp}:
	Two new test cases, each testing one of the new grades.

tests/debugger/Mmakefile:
	Enable the two new test cases in their grades.

	Disable the tests sensitive to stack frame sizes in term size profiling
	grades.

tests/debugger/completion.exp:
	Add the new "term_size" mdb command to the list of command completions,
	and delete "proc_body".

tests/debugger/declarative/dependency.{inp,exp}:
	Use "print proc_body" instead of "proc_body".

tests/hard_coded/nondet_c.m:
tests/hard_coded/pragma_inline.m:
	Use MR_offset_incr_hp instead of MR_incr_hp to ensure that all places
	that allocate cells also allocate space for the term size slot if
	necessary.

tests/valid/Mmakefile:
	Disable the IL tests in term size profiling grades, since the term size
	profiling primitives haven't been (and probably won't be) implemented
	for the MLDS backends, and handle_options causes a compiler abort
	for grades that combine term size profiling and any one of IL, Java
	and high level C.
2003-10-20 07:29:59 +00:00
Fergus Henderson
397bb639ef Avoid issuing warnings about infinite recursion in the case
Estimated hours taken: 1
Branches: main

compiler/simplify.m:
	Avoid issuing warnings about infinite recursion in the case
	when the recursive call involves input arguments whose inst
	is `any', since such warnings may be spurious.

tests/valid/Mmakefile:
tests/valid/Mercury.options:
tests/valid/solv.m:
	Regression test.
2003-10-13 02:29:42 +00:00
Simon Taylor
3b1e8044d9 Updated for the new Aditi API.
Estimated hours taken: 0.1
Branches: main

tests/{valid,invalid}/aditi.m:
tests/{valid,invalid}/aditi_private_builtin.m:
	Updated for the new Aditi API.
2003-08-23 14:01:58 +00:00
Fergus Henderson
ccdf57b820 Compile the lambda_inference test with `--infer-all', since it
Estimated hours taken: 0.25
Branches: main

tests/valid/Mercury.options:
	Compile the lambda_inference test with `--infer-all', since it
	relies on mode and determinism inference.
	(Until yesterday, the compiler incorrectly allowed this code,
	but the bug fix I committed yesterday means that the compiler
	now correctly rejects this code unless inference is enabled.)
2003-07-26 07:19:08 +00:00
David Overton
2ad2f0a28e Allow types to be declared as "solver" types using the syntax
Estimated hours taken: 120
Branches: main

Allow types to be declared as "solver" types using the syntax
`:- solver type ...'.

For a non-solver type t (i.e. any type declared without using the
`solver' keyword), the inst `any' should be considered to be equivalent
to a bound inst i where i contains all the functors of the type t and
each argument has inst `any'.  For solver types, `any' retains its
previous meaning.

This is required to allow us to represent HAL's `old' inst using `any'.
In HAL, `old' is like `any' if the type is an instance of a particular
type class (`solver/1').  However, for types that are not instances of
`solver/1', `old' needs to be treated as though it is `bound'.

library/ops.m:
	Add `solver' as a unary prefix operator.

compiler/prog_data.m:
	Add a field to the type `type_defn' to record whether or not the
	type is a solver type.

compiler/hlds_data.m:
	Add an equivalent field to the type `hlds_type_body'.

compiler/prog_io.m:
compiler/make_hlds.m:
compiler/modules.m:
compiler/mercury_to_mercury.m:
compiler/hlds_out.m:
	Handle the new ":- solver type ..." syntax.

compiler/det_report.m:
compiler/equiv_type.m:
compiler/foreign.m:
compiler/hlds_code_util.m:
compiler/hlds_out.m:
compiler/intermod.m:
compiler/magic_util.m:
compiler/ml_code_gen.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds.m:
compiler/module_qual.m:
compiler/post_typecheck.m:
compiler/pragma_c_gen.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/recompilation.version.m:
compiler/special_pred.m:
compiler/stack_opt.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
	Handle the changes to `type_defn' and `hlds_type_body'.

compiler/type_util.m:
	Add predicates `type_util__is_solver_type' and
	`type_body_is_solver_type'.

compiler/inst_match.m:
compiler/inst_util.m:
	In inst_matches_{initial,final,binding} and
	abstractly_unify_inst_functor, when we are comparing `any' insts, check
	whether or not the type is a solver type and treat it appropriately.

compiler/instmap.m:
compiler/modecheck_unify.m:
	Pass type information to abstractly_unify_inst_functor.

compiler/mode_util.m:
	Add a predicate `constructors_to_bound_any_insts' which is the same as
	`constructors_to_bound_insts' except that it makes the arguments of the
	bound inst `any' instead of `ground'.

tests/invalid/any_mode.m:
tests/invalid/any_mode.err_exp:
tests/hard_coded/any_free_unify.m:
	Modify these test cases to use a "solver" type instead of `int'.

tests/valid/any_matches_bound.m:
tests/valid/Mmakefile:
tests/invalid/Mmakefile:
tests/invalid/any_should_not_match_bound.m:
tests/invalid/any_should_not_match_bound.err_exp:
	Add new test cases.

extras/trailed_update/var.m:
clpr/cfloat.m:
	Modify to use the new `:- solver type' syntax.
2003-07-25 02:27:37 +00:00
Zoltan Somogyi
6554ef7daa Replace "is" with "=".
Estimated hours taken: 2
Branches: main

Replace "is" with "=".
Add field names where relevant.
Replace integers with counters where relevant.
2003-05-26 09:01:46 +00:00
Simon Taylor
4801cf8700 Fix a bug reported by Zoltan where higher_order.m was
Estimated hours taken: 5
Branches: main, release

Fix a bug reported by Zoltan where higher_order.m was
generating code containing references to undefined
type-info variables.

compiler/higher_order.m:
	Specialize all calls as if the procedure interface
	requires type-info liveness. The type-infos may
	be needed when specializing calls in the body of
	the specialized procedure to procedures whose
	interface requires type-info liveness.

tests/valid/Mmakefile:
tests/valid/higher_order5.m:
	Test case.
2003-05-17 04:31:54 +00:00
Simon Taylor
370cbb6f00 Fix syntax errors in the `.int' files for foreign types
Estimated hours taken: 0.25
Branches: main

compiler/mercury_to_mercury.m:
	Fix syntax errors in the `.int' files for foreign types
	with user-defined equality.

tests/valid/Mmakefile:
tests/valid/exported_foreign_type{,2}.m:
	Test case.
2003-05-13 06:25:56 +00:00
Zoltan Somogyi
cbd6a7c56a Delete the old, lazy LLDS code generator, since we won't be maintaining it
Estimated hours taken: 3
Branches: main

Delete the old, lazy LLDS code generator, since we won't be maintaining it
anymore. Its deletion speeds up the compiler by 0.2% when using the LLDS
back end.

compiler/code_exprn.m:
	Delete the module.

compiler/ll_backend.m:
	Delete code_exprn from the list of submodules of this module.

compiler/notes/compiler_design.html:
	Delete the documentation of code_exprn.m, and update the documentation
	of var_locn.m.

compiler/options.m:
	Delete the --lazy-code option that used to select code_exprn over
	var_locn.

	Delete the follow_vars option, since the LLDS backend now always
	executes the follow_vars pass.

compiler/handle_options.m:
	Delete the code setting the follow_vars option.

	Make the setting of static_ground_terms conditional on the use of the
	LLDS backend (which now implies the eager code generator).

compiler/code_info.m:
	Delete lots of code that switches between code_exprn.m and var_locn.m.

	Simplify the data structures accordingly.

compiler/store_alloc.m:
	Delete the code and data structures required to cater for the case
	where the follow_vars pass isn't run.

compiler/pragma_c_gen.m:
compiler/var_locn.m:
compiler/hlds_goal.m:
compiler/lookup_switch.m:
	Update a comment.

doc/user_guide.texi:
	Delete the documentation of --follow-vars. --lazy-code was already
	undocumented.

tests/valid/Mercury.options:
	Delete a setting of --no-follow-vars.
2003-05-07 00:50:34 +00:00
Simon Taylor
82a950c0d9 Make Aditi work with `--highlevel-code'.
Estimated hours taken: 80
Branches: main

Make Aditi work with `--highlevel-code'.

(Note that this doesn't work with the current CVS version
of Aditi. The Aditi developers have rewritten the Aditi client
API, and haven't maintained the old version of the API, so Mercury
queries don't work at the moment. extras/aditi will be updated to
use the new interface as a separate change.)

extras/aditi/aditi_private_builtin.m:
extras/aditi/aditi.m:
	Move code to implement Aditi calls and updates into
	a aditi_private_builtin.m. These operations are now
	implemented using ordinary Mercury foreign procedures,
	rather than hand-coded C modules.

compiler/magic.m:
	Use calls to ordinary calls to predicates defined in
	extras/aditi/aditi_private_builtin.m to implement the
	procedures which interface between top-down Mercury
	code and Aditi procedures.

compiler/aditi_backend.pp:
compiler/aditi_builtin_ops.m:
compiler/mercury_compile.m:
compiler/notes/compiler_design.html:
	Add a pass to convert Aditi builtins (calls and updates)
	into ordinary calls to predicates defined in
	extras/aditi/aditi_private_builtin.m.

compiler/hlds_goal.m:
compiler/hlds_pred.m:
	Add a new generic_call type -- `unsafe_cast'.
	aditi_builtin_ops.m needs to be able to cast
	closures from one type and inst to another.

	Delete the `aditi_call' alternative for `aditi_builtin',
	which is not needed after the change to magic.m described
	above.

	Add predicates `construct_tuple' and `deconstruct_tuple'.

compiler/*hlds.*.m:
compiler/call_gen.m:
compiler/ml_call_gen.m:
	Handle unsafe cast goals.

compiler/common.m:
compiler/higher_order.m:
compiler/unify_proc.m:
	Generate unsafe_cast goals instead of calls to
	private_builtin.unsafe_type_cast.

compiler/purity.m:
compiler/notes/compiler_design.html:
	Convert calls to private_builtin.unsafe_type_cast into
	unsafe_cast goals.

compiler/ml_code_gen.m:
	Don't attempt to generate code for Aditi procedures.

	Remove special case handling of calls to
	private_builtin.unsafe_type_cast -- such
	calls are now transformed away.

compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/maybe_mlds_to_gcc.m:
	Add the RL code to the generated C file.

compiler/llds_out.m:
compiler/c_util.m:
compiler/compile_target_code.m:
	Move code to generate a `.rlo' file and work out the
	name of the RL constant embeeded in the C file for
	a module into c_util.m, for use by the MLDS backend.

compiler/modules.m:
	Automatically import aditi_private_builtin when compiling
	with `--aditi'.

	We generate a C constant for the RL code for each module,
	so modules compiled with `--aditi' need to be treated
	by the build system as if they contain foreign code.

compiler/polymorphism.m:
	Tuple insertion and deletion no longer need special treatment.

compiler/llds.m:
compiler/ll_backend.*.m:
	Delete the Aditi alternatives of the `code_addr' type.

compiler/mode_util.m:
	Add function versions of in_mode, out_mode, etc.

compiler/prog_util.m:
	Add aditi_public_builtin_module (returns `aditi') and
	aditi_private_builtin_module (returns `aditi_private_builtin').

tests/valid/aditi_private_builtin.m:
tests/invalid/aditi_private_builtin.m:
tests/valid/Mercury.options:
tests/invalid/Mercury.options:
	Add a cut down version of extras/aditi/aditi_private_builtin.m
	for use in running the tests.
2003-03-18 02:43:52 +00:00
David Overton
785beb075e In eliminate_constraint_by_class_rules', if type_unify_list'
Estimated hours taken: 5
Branches: main

compiler/typecheck.m:
	In `eliminate_constraint_by_class_rules', if `type_unify_list'
	fails for a subclass, remove that subclass from the list of
	constraints being examined rather than aborting.
	`type_unify_list' may fail if one of the arguments to the
	superclass constraint is not a type variable and does not unify
	with the corresponding argument of the subclass.
	In such cases, this particular superclass-subclass relationship
	is not relevant to the constraint we are trying to prove so it is safe
	to remove it.

tests/valid/Mmakefile:
tests/valid/typeclass_constraint_nonvar_bug.m:
	Test case.
2003-03-13 11:53:36 +00:00
Simon Taylor
660a24a7ad Fix a bug reported by Michael Day which caused spurious
Estimated hours taken: 8
Branches: main, release

Fix a bug reported by Michael Day which caused spurious
"predicate multiply defined" errors if there were predicates
`module1.p' and `module2.module1.p'.

compiler/hlds_module.m:
	For each of the predicate table search predicates which
	takes a module, add an extra argument which states whether
	the module name passed in is fully qualified. If it is, then
	a search for `module1.p' will not return `module2.module1.p'.
	The module name is guaranteed to be fully qualified for
	the head of predicate, clause, etc. items, and for calls
	occurring in `.opt' files.

	Add a predicate `lookup_builtin_pred_proc_id', for
	looking up the builtin predicates in the predicate table.

compiler/goal_util.m:
	Move code to look up builtin predicates into hlds_module.m.

	Set the builtin_state field of the call goal returned
	by generate_simple_call correctly.

compiler/hlds_pred.m:
	Add a function `calls_are_fully_qualified' which takes
	an import_status, and returns whether calls from goals
	with that status are always fully qualified, which is
	true iff the call is in a `.opt' file.

compiler/prog_io.m:
	Module qualify the sym_names in `:- external' items.

compiler/*.m:
	Fill in the extra argument of predicate table searches.

	Use `lookup_builtin_pred_proc_id' rather than
	`predicate_table_search_*'.

compiler/prog_util.m:
	Add function versions of mercury_*_builtin_module.

compiler/polymorphism.m:
compiler/simplify.m:
compiler/unify_proc.m:
	Use goal_util__generate_simple_call to call builtins,
	rather than duplicating the code.

tests/valid/Mmakefile:
tests/valid/nested_module_bug.m:
tests/valid/intermod_bug_nested.m:
	Test cases.
2003-02-22 13:18:34 +00:00
Simon Taylor
f2b8ce92b4 Fix a bug which caused an abort on unifications of the form
Estimated hours taken: 1
Branches: main, release

compiler/typecheck.m:
	Fix a bug which caused an abort on unifications of the form
	`X = X', where `X' hadn't been seen before in the goal.

tests/valid/Mmakefile:
tests/valid/id_type_bug.m:
	Test case.
2003-02-22 01:06:10 +00:00
Simon Taylor
6f3d876533 Fix a bug in inter-mdule optimization reported by Michael Day.
Estimated hours taken: 2
Branches: main, release

Fix a bug in inter-mdule optimization reported by Michael Day.

compiler/intermod.m:
	Write declarations for `exported_to_submodules' predicates
	and functions to the `.opt' file.

tests/valid/Mmakefile:
tests/valid/Mercury.options:
tests/valid/intermod_nested{,2}.m:
	Test case.
2003-02-17 06:07:15 +00:00
Mark Brown
5d572d708b New test case (disabled, since we don't yet pass).
Estimated hours taken: 0.5
Branches: main

tests/valid/Mmakefile:
tests/valid/unify_inst_bug.m:
	New test case (disabled, since we don't yet pass).
2003-01-21 03:39:50 +00:00
Fergus Henderson
17f53149a4 Implement `:- pragma reserve_tag(<TypeName>/<Arity>).'.
Estimated hours taken: 6
Branches: main

Implement `:- pragma reserve_tag(<TypeName>/<Arity>).'.
This has the same effect as the `--reserve-tag' option,
except that it only applies to specified type, rather than
to all types.

doc/reference_manual.texi:
	Document the new feature.
	(However, the documentation is currently commented out.)

compiler/prog_data.m:
	Add `reserve_tag(sym_name, arity)' to the `pragma_type' type.

compiler/hlds_data.m:
	Add a new boolean field to the representation of discriminated union
	type bodies to record whether or not the type has a reserved tag.

compiler/prog_io_pragma.m:
	Add code to parse the new pragma.

compiler/make_hlds.m:
	Add code to process the new pragma:
	- check all the appropriate semantic restrictions:
		- the pragma must have the same visibility as the type
		- the type must be defined
		- the type must be a discriminated union type
	- warn if there are multiple such pragmas for the same type
	- call make_tags.m to recompute the tags used for the constructor.
	- record the presence of the reserve_tag pragma in the HLDS type
	  definition body

compiler/make_tags.m:
compiler/type_util.m:
	Add an extra argument to assign_constructor_tags (in make_tags.m)
	and type_constructors_should_be_no_tag (in type_util.m)
	to specify whether or not there was a `reserve_tag' pragma.
	Reserve a tag if either this argument or the global `reserve_tag'
	option is set.

compiler/intermod.m:
	Output a `:- reserve_tag' pragma whenever outputting a type
	to which such a pragma applies.

compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
	Ignore the reserved_tag field.
	XXX This means that the `reserve_tag' pragma (or the compiler
	    option) won't have much effect if --high-level-data is set.

compiler/code_util.m:
compiler/det_report.m:
compiler/hlds_out.m:
compiler/magic_util.m:
compiler/mercury_to_mercury.m:
compiler/mode_util.m:
compiler/module_qual.m:
compiler/modules.m:
compiler/post_typecheck.m:
compiler/recompilation.usage.m:
compiler/recompilation.version.m:
compiler/special_pred.m:
compiler/stack_opt.m:
compiler/switch_util.m:
compiler/table_gen.m:
compiler/term_util.m:
compiler/type_ctor_info.m:
compiler/unify_gen.m:
compiler/unify_proc.m:
	Trivial changes to handle the new reserved_tag field of
	hlds_type_defn_body.

tests/valid/Mmakefile:
tests/valid/reserve_tag.m:
tests/invalid/Mmakefile:
tests/invalid/reserve_tag.m:
tests/invalid/reserve_tag.err_exp:
	Some tests of the new feature.
2003-01-14 16:42:44 +00:00
Simon Taylor
557c4dc9e6 Fix a bug in `--optimize-higher-order' which caused compilation of
Estimated hours taken: 5
Branches: main, release

compiler/higher_order.m:
	Fix a bug in `--optimize-higher-order' which caused compilation of
	analysis/analysis.file.m to fail with inter-module optimization.
	The problem was that type-infos for curried arguments of a higher-order
	term were not being added to the typeinfo_varmap for the specialized
	procedure.

tests/valid/Mmakefile:
tests/valid/Mercury.options:
tests/valid/higher_order4.m:
	Test case.
2003-01-14 13:47:44 +00:00
Michael Wybrow
483d0c71a2 Modifications to the test suite to allow testing in grade java.
Estimated hours taken: 14
Branches: main

Modifications to the test suite to allow testing in grade java.


mercury/tools/test_mercury:
        Set-up the required CLASSPATH variable.

tests/Mmake.common:
        Added a rule to build `.out' files when the grade is java.

tests/benchmarks/Mmakefile:
        Enable only the working tests for the benckmarks directory.

tests/dppd/Mmakefile:
tests/general/Mmakefile:
tests/general/accumulator/Mmakefile:
tests/general/string_format/Mmakefile:
tests/general/structure_reuse/Mmakefile:a
tests/grade_subdirs/Mmakefile:
tests/hard_coded/Mmakefile:
tests/hard_coded/exceptions/Mmakefile:
tests/hard_coded/purity/Mmakefile:
tests/hard_coded/sub-modules/Mmakefile:
tests/hard_coded/typeclasses/Mmakefile:
tests/recompilation/Mmakefile
tests/term/Mmakefile:
tests/valid/Mmakefile:
        Disable test cases for grade java.

tests/recompilation/test_functions:
        Add framework needed to do recompilation testing for the java grade.
2003-01-12 22:33:35 +00:00
Simon Taylor
87e3d611f1 Fix another occurrence of the GCC "fixed or forbidden register was spilled"
Estimated hours taken: 2
Branches: main, release

Fix another occurrence of the GCC "fixed or forbidden register was spilled"
bug, this time caused by foreign types.

runtime/mercury_heap.h:
	In the code to copy, box or unbox foreign type arguments of
	a foreign_proc, use MR_memcpy rather than direct structure
	assignment on platforms where the GCC bug occurs.

runtime/mercury_reg_workarounds.{c,h}:
	Add a macro MR_assign_structure() to assign structures
	without triggering the GCC bug.

	Define MR_memcpy to call memcpy if the GCC bug won't be
	triggered.

runtime/mercury_array_macros.h:
	Use MR_assign_structure() rather than a specialized
	version for assigning between two elements of an array.

tests/valid/Mmakefile:
tests/valid/Mercury.options:
tests/valid/reg_bug.m:
	Test case.
2002-11-22 08:50:44 +00:00
Fergus Henderson
c639934101 A few fixes to petdr's recent change to fix test case failures for the IL
Estimated hours taken: 0.75
Branches: main

A few fixes to petdr's recent change to fix test case failures for the IL
grade.

tests/valid/two_pragma_c_codes.m:
	Fix a compilation error for non-IL grades:
	add a `pragma promise_pure' for a
	procedure defined with both C code and clauses.

tests/invalid/Mmakefile:
tests/invalid/purity/pragma_c_and_mercury.m:
tests/invalid/purity/pragma_c_and_mercury.err_exp:
	Add a test to check that we detect an error in the case mentioned
	above.	Currently the test is disabled, since we don't pass it
	in IL or Java grades.

tests/invalid/purity/Mmakefile:
tests/invalid/purity/Mercury.options:
	Put --no-automatic-intermodule-optimization in MCFLAGS
	rather than in MCFLAGS-*, to be consistent with what we do
	for --no-intermodule-optimization.
2002-11-08 03:12:57 +00:00
Peter Ross
2a3cfce258 Fix spurious errors in the test cases so that they pass in the grade il.
Estimated hours taken: 2
Branches: main

Fix spurious errors in the test cases so that they pass in the grade il.

tests/valid/big_foreign_type.m:
	Add C# implementations of the foreign types.

tests/valid/int64.m:
tests/valid/liveness_nonlocals.m:
tests/valid/subtype_switch.m:
tests/valid/tabled_for_io.m:
tests/valid/two_pragma_c_codes.m:
tests/valid/zero_arity.m:
	Provide default implementations of C pragma foreign_code.

tests/valid/intermod_impure2.m:
	Provide an il implementation of C pragma foreign_code.

tests/valid/spurious_purity_warning.m:
	Fix some determinism warnings.

tests/valid/typeclass_inlining_bug.m:
	Remove an unneeded abstract type.
2002-11-07 12:52:59 +00:00
Peter Ross
226f450b70 Don't run tests which aren't compatible with the IL grade.
Estimated hours taken: 0.5
Branches: main

Don't run tests which aren't compatible with the IL grade.

tests/valid/Mmakefile:
	Don't run the accurate gc tests in the IL grade.
	Don't run the aditi tests for all possible IL grades.
2002-11-05 10:46:03 +00:00
Simon Taylor
333884f5b8 Add "--grade il" to GRADEFLAGS for the csharp_hello test case.
Estimated hours taken: 0.25
Branches: main

tests/valid/Mercury.options:
	Add "--grade il" to GRADEFLAGS for the csharp_hello test case.
	This is needed to prevent failures in grades such as
	asm_fast.gc.profdeep.
2002-11-01 02:16:35 +00:00
Fergus Henderson
c6de5002b4 Add a new test case to test foreign types whose size is different
Estimated hours taken: 0.75

tests/valid/Mmakefile:
tests/valid/big_foreign_type.m:
	Add a new test case to test foreign types whose size is different
	than "MR_Word".
2002-10-30 03:30:24 +00:00
Simon Taylor
2e3956f594 Fix a compiler abort with `--use-subdirs'.
Estimated hours taken: 1
Branches: main

compiler/mlds_to_ilasm.m:
	Fix a compiler abort with `--use-subdirs'.

tests/valid/Mmakefile:
tests/valid/csharp_hello.m:
	Test case.
2002-10-29 07:01:11 +00:00
Fergus Henderson
c319648ea3 For IL grades, build the .dll file rather than the .o file.
Estimated hours taken: 0.25
Branches: main

tests/valid/Mmakefile:
	For IL grades, build the .dll file rather than the .o file.
2002-10-23 13:16:42 +00:00
Fergus Henderson
63b5e79cc1 Enable the agc_* tests for hl*.agc* grades, since they now pass.
Estimated hours taken: 0.25
Branches: main

tests/valid/Mmakefile:
	Enable the agc_* tests for hl*.agc* grades, since they now pass.
2002-10-22 07:29:27 +00:00
Mark Brown
06f2029688 Allow typeclass constraints on ground types.
Estimated hours taken: 3
Branches: main

Allow typeclass constraints on ground types.

compiler/prog_io_typeclass.m:
	Remove the check that typeclass constraints are non-ground.

compiler/polymorphism.m:
compiler/typecheck.m:
	Change tests for monomorphic calls to also test for no constraints.
	The optimizations that are applied if these tests succeed assume
	that there are no constraints.

	Remove "sanity" checks which are no longer applicable.

tests/hard_coded/typeclasses/Mmakefile:
tests/hard_coded/typeclasses/ground_constraint.exp:
tests/hard_coded/typeclasses/ground_constraint.m:
	Test the new feature.

tests/invalid/Mmakefile:
tests/invalid/typeclass_constraint_no_var.err_exp:
tests/invalid/typeclass_constraint_no_var.m:
tests/valid/Mmakefile:
tests/valid/typeclass_constraint_no_var.m:
	Move this test from invalid to valid, since it should compile
	successfully now.
2002-09-25 06:49:43 +00:00
Simon Taylor
47a4d62dc1 Improve the test framework to make it easier to find out which tests
Estimated hours taken: 30
Branches: main

Improve the test framework to make it easier to find out which tests
failed and to reduce disk usage (important in debug grades).

Allow the tests to be run with `mmc --make' (still some failures).

Allow the user to run only the failing tests from a previous
run by using `mmake ERROR_FILE=runtests.errs', where runtests.errs
is the log file from the previous run.

tests/Mmake.common:
tests/*/Mmakefile:
	Move common code (such as the code to deal with subdirectories)
	to Mmake.common.

	Run the tests using `mmake runtests' rather than using slightly
	different runtests scripts in each directory.

	Add to the output from `mmake runtests' to make it easier to
	identify which tests failed in which grades.

	Move per-module options into Mercury.options files so they
	can be read by `mmc --make'.

	Remove the last of the NU-Prolog support.

	Consistently use the main module name when listing tests.
	Some directories (e.g. invalid) were using the source file
	name.

tests/process_log.awk:
	Collect the parts of the output relating to failing tests.

tests/generate_exp:
tests/handle_options:
tests/subdir_runtests:
tests/startup:
tests/shutdown:
tests/*/runtests:
tests/recompilation/TESTS:
	Removed.

tests/recompilation/test_functions:
	Make sure the old result file is removed before starting
	each test.

	Put the mmake output for tests which are supposed to fail
	into a different file for each test.

tests/warnings/Mmakefile:
	Use %.c rather than $(cs_subdir)%.c in a rule.
	The $(cs_subdir) part doesn't work with `mmc --make',
	and isn't necessary any more (modules.m generates a rule
	`module.c: $(cs_subdir)module.c').

tests/README:
	Updated.

tools/bootcheck:
tools/test_mercury:
	Use `mmake runtests' instead of the `runtests' script.

	Add a `-f' (`--failing-tests') option to bootcheck which
	runs only the failing tests from the last run.

tools/test_mercury:
tools/run_all_tests_from_cron:
	Use the new framework to summarize test failures.
2002-08-17 13:52:35 +00:00
David Overton
cf56419e70 Fix a couple of bugs related to abstract unification.
Estimated hours taken: 3
Branches: main

Fix a couple of bugs related to abstract unification.

compiler/inst_util.m:
	Add cases to `make_ground_inst' and `make_any_inst' to handle
	`constrained_inst_vars'.

	When `make_ground_inst' is called with a higher-order inst, do not
	discard the higher-order information from the resulting inst
	(`make_any_inst' already handles this correctly).

tests/valid/Mmakefile:
tests/valid/constrained_poly_bound_arg.m:
	Add the test case from Fergus's bug report.
2002-08-12 07:35:00 +00:00
Simon Taylor
90a6dbebcb Fix a bug which caused a compiler abort when compiling
Estimated hours taken: 1.5
Branches: main

Fix a bug which caused a compiler abort when compiling
make_hlds.m with `--smart-recompilation'.

compiler/recompilation.m:
	Don't attempt to record builtin items as used.
	The bug was caused by attempting to record tuple
	types as used when generating the unification
	predicate for them.

tests/valid/Mmakefile:
tests/valid/tuple_eqv.m:
	Test case.
2002-07-29 16:28:32 +00:00
Simon Taylor
6c788ae45f Put instance declarations in the `.int2' files to avoid
Estimated hours taken: 0.5
Branches: main

compiler/modules.m:
	Put instance declarations in the `.int2' files to avoid
	producing `superclass constraints not satisfied' errors
	for instance declarations for subclasses defined in the
	interface of importing modules.

	Without this change, all modules importing the module defining
	the instance for the subclass must also import the module
	defining the instance for the superclass.

tests/valid/Mmakefile:
tests/valid/transitive_instance.m:
	Test case.
2002-07-23 13:34:04 +00:00
Simon Taylor
18156bf164 Fix a bug in inlining of procedures with typeclass constraints.
Estimated hours taken: 3
Branches: main

compiler/inlining.m:
	Fix a bug in inlining of procedures with typeclass constraints.
	The type_info location for the callee overwrote the location
	in the caller, but the location in the callee may have been
	computed by extracting type_infos from typeclass_infos in the
	caller, so it wouldn't be valid when computing the locations of
	the type variables in the head of the caller.

	Remove a partial work-around for this bug, which disabled
	inlining of procedures with class constraints when tracing
	is enabled. The work-around didn't prevent the code generator
	abort occurring when constructing closure layouts.

tests/valid/Mmakefile:
tests/valid/typeclass_inlining_bug.m:
	Test case.
2002-07-21 08:00:54 +00:00
Simon Taylor
cc992dba59 Fix a bug in inter-module optimization with sub-modules reported
Estimated hours taken: 2
Branches: main

Fix a bug in inter-module optimization with sub-modules reported
by Michael Day <mikeday@bigpond.net.au>. The symptom was a compiler
abort due to an attempt to take the address of a predicate with
multiple modes. The predicate only had multiple mode declarations
because the declarations were read from both the `.int0' and `.opt'
files for the module.

compiler/post_typecheck.m:
compiler/purity.m:
	Remove duplicate modes and report other errors in type
	declarations for all predicates in a separate pass before
	purity checking and overloading resolution.

tests/valid/Mmakefile:
tests/valid/intermod_nested_module_bug.m:
tests/valid/intermod_nested_module_bug2.m:
	Test case.

tests/valid/assoc_list.m:
tests/valid/assoc_list_bug.m:
	Rename the assoc_list test case -- it interfered with
	other test cases attempting to import the assoc_list
	library module.
2002-07-14 15:12:42 +00:00
David Overton
1569520fdf Back out a change which permitted unification of variables of
Estimated hours taken: 0.1
Branches: main

compiler/inst_util.m:
tests/valid/Mmakefile:
tests/valid/any_functor_unify.m:
	Back out a change which permitted unification of variables of
	inst `any' with functors.  Having this feature would require
	support from the code generator which does not exist.  The
	change was originally made in response to a bug report from the
	HAL project, but it turns out that this was actually a bug in
	the HAL compiler -- it is supposed to convert such unifications
	to a predicate call in the generated Mercury code but was not
	doing that.
2002-07-04 23:25:50 +00:00
Simon Taylor
8833ca832d Fix spurious "`_Var' occurs more than once" warnings for
Estimated hours taken: 0.5 (+4 by petdr)
Branches: main

compiler/make_hlds.m:
	Fix spurious "`_Var' occurs more than once" warnings for
	underscore variables in `:- pragma foreign_proc' declarations
	for predicates which also have Mercury clauses.

tests/invalid/Mmakefile:
tests/invalid/foreign_singleton.m:
tests/invalid/foreign_singleton.err_exp:
tests/valid/Mmakefile:
tests/valid/foreign_underscore_var.m:
	Test cases.
2002-06-01 13:34:45 +00:00
Simon Taylor
585813999f Fix an undefined variable warning caused by my last change.
Estimated hours taken: 0.1
Branches: main

tests/valid/Mmakefile:
	Fix an undefined variable warning caused by my last change.
2002-06-01 10:58:52 +00:00
Simon Taylor
b396d0b578 Don't set GRADEFLAGS when compiling using the installed libraries,
Estimated hours taken: 0.1
Branches: main

tests/valid/Mmakefile:
	Don't set GRADEFLAGS when compiling using the installed libraries,
	because it may cause mgnuc to look for the `.mih' files for a
	non-installed grade (e.g. hlc.agc.tr).
2002-06-01 08:34:23 +00:00
Simon Taylor
2255eff8b6 Fix a code generator abort reported by rafe.
Estimated hours taken: 2.5

Fix a code generator abort reported by rafe.

compiler/simplify.m:
	Recompute instmap deltas and rerun determinism analysis
	after optimizing away part of an if-then-else, to avoid
	a case where a conjunction with determinism `erroneous'
	was being given determinism `det' (which was the
	determinism of the enclosing if-then-else).

compiler/common.m:
	Rerun determininsm analysis after optimizing away a
	duplicate call or unification with determinism other
	than `det'.

tests/valid/Mmakefile:
tests/valid/simplify_bug2.m:
	Test case.
2002-05-14 14:34:44 +00:00
David Overton
cfca6ff29b Allow var-functor unifications where the variable has inst `any'.
Estimated hours taken: 0.5
Branches: main

Allow var-functor unifications where the variable has inst `any'.

compiler/inst_util.m:
	Handle `any' insts in abstractly_unify_inst_functor.

tests/valid/Mmakefile:
tests/valid/any_functor_unify.m:
	Add a test case.
2002-05-09 05:00:55 +00:00
Peter Ross
731a203aa0 Don't test foreign_type, as the error is detected only when trying
Estimated hours taken: 1
Branches: main

invalid/Mmakefile:
    Don't test foreign_type, as the error is detected only when trying
    to compile the generated code and the current Mmakefile scheme can't
    capture that sort of failure.

valid/Mmakefile:
valid/pragma_c_code_and_clauses1.m:
valid/pragma_c_code_and_clauses2.m:
    Remove these two test cases because they are already being checked
    by hard_coded/foreign_type.m.
2002-05-08 14:31:51 +00:00
Mark Brown
f5d666756c Move the pragma_c_code_and_clauses tests from invalid to valid,
Estimated hours taken: 0.1
Branches: main

tests/invalid/Mmakefile:
tests/invalid/pragma_c_code_and_clauses1.err_exp:
tests/invalid/pragma_c_code_and_clauses1.m:
tests/invalid/pragma_c_code_and_clauses2.err_exp:
tests/invalid/pragma_c_code_and_clauses2.m:
tests/valid/Mmakefile:
tests/valid/pragma_c_code_and_clauses1.m:
tests/valid/pragma_c_code_and_clauses2.m:
	Move the pragma_c_code_and_clauses tests from invalid to valid,
	since this sort of code is now allowed.
2002-05-06 14:06:48 +00:00
Simon Taylor
86e7b51241 foreign_type_spec.m contains a `pragma foreign_type(il, ...)'
Estimated hours taken: 0.1
Branches: main

tests/valid/Mmakefile:
	foreign_type_spec.m contains a `pragma foreign_type(il, ...)'
	declaration, so always compile it in grade `il'.
2002-04-25 08:34:23 +00:00
Simon Taylor
3ec99babcb Fix a bug reported by Peter Ross.
Estimated hours taken: 0.5
Branches: main

Fix a bug reported by Peter Ross.

compiler/special_pred.m:
	Don't generate unification predicates for foreign types lazily.
	The clauses contain calls to a polymorphic predicate
	(private_builtin__nyi_foreign_type_unify) which
	polymorphism__process_generated_pred can't handle
	after polymorphism has been run.

tests/valid/Mmakefile:
tests/valid/foreign_type_spec.m:
	Test case.
2002-04-23 17:49:20 +00:00
David Overton
da2ed598e0 Extend constrained polymorphic modes to allow inst parameters to be
Estimated hours taken: 80
Branches: main

Extend constrained polymorphic modes to allow inst parameters to be
constrained to insts other than `ground'.  The main motivation for this
is that for HAL we want inst parameters constrained to `any', however
this change is more general and allows inst parameters to be constrained
to any valid inst.

Introduce the syntax `InstParam =< Inst' to constrain an inst parameter
`InstParam' to an inst `Inst' in a predicate or function mode
declaration.

compiler/inst.m:
	Add a new alternative `constrained_inst_var(inst_var, inst)' to
	the `inst' type.
	Remove `constrained_inst_var(inst_var)' alternative from the
	`ground_inst_info' type.

compiler/inst_match.m:
compiler/inst_util.m:
compiler/modecheck_unify.m:
	Make changes required to the core mode checking algorithms to
	handle the change.

compiler/prog_io.m:
compiler/prog_io_util.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
compiler/prog_io_typeclass.m:
compiler/make_hlds.m:
	Add support for `=<'/2 insts, but only when parsing predicate
	and function mode declarations, lambda argument modes, and
	pragmas.
	Also add support for specifying inst constraints in the constraints list
	for a declaration.
	Make sure any unconstrained inst parameters in these
	declarations are constrained to be `ground'.
	Check that all constraints for a declaration are consistent,
	i.e. the same constraint for every occurrence of an inst
	parameter.

compiler/hlds_out.m:
compiler/mercury_to_mercury.m:
	Support printing of `=<'/2 insts.

compiler/mode_util.m:
compiler/module_qual.m:
compiler/pd_util.m:
compiler/recompilation_usage.m:
	Handle the changes to the definition of the `inst' type.

doc/reference_manual.texi:
	Document the change.

tests/valid/Mmakefile:
tests/valid/constrained_poly_insts.m:
tests/invalid/Mmakefile:
tests/invalid/constrained_poly_insts.m:
	Add some test cases.
2002-03-14 01:10:44 +00:00
Simon Taylor
b7c4a317e9 Add MR_ prefixes to the remaining non-prefixed symbols.
Estimated hours taken: 4
Branches: main

Add MR_ prefixes to the remaining non-prefixed symbols.

This change will require all workspaces to be updated
The compiler will start generating references to MR_TRUE,
MR_bool, etc., which are not defined in the old runtime
header files.

runtime/mercury_std.h:
	Add MR_ prefixes to bool, TRUE, FALSE, max, min,
	streq, strdiff, strtest, strntest, strneq, strndiff,
	strntest, NO_RETURN.

	Delete a commented out definition of `reg'.

runtime/mercury_tags.h:
	Add an MR_ prefix to TAGBITS.

configure.in:
runtime/mercury_goto.h:
runtime/machdeps/i386_regs.h/mercury_goto.h:
	Add an MR_ prefix to PIC.

runtime/mercury_conf_param.h:
	Allow non-prefixed PIC and HIGHTAGS to be defined on
	the command line.

runtime/mercury_bootstrap.h:
	Add backwards compatibility definitions.

RESERVED_MACRO_NAMES:
	Remove the renamed macros.

compiler/export.m:
compiler/ml_code_gen.m:
	Use MR_bool rather than MR_Bool (MR_Bool is
	meant to be for references to the Mercury type
	bool__bool).

runtime/mercury_types.h:
	Add a comment the MR_Bool is for references to
	bool__bool.

*/*.c:
*/*.h:
*/*.m:
	Add MR_ prefixes.
2002-02-18 07:01:33 +00:00
Simon Taylor
c66cea0665 Add MR_ prefixes to uses of configuration macros.
Estimated hours taken: 2.5
Branches: main

Add MR_ prefixes to uses of configuration macros.
Bootcheck now succeeds with MR_NO_CONF_BACKWARDS_COMPAT.

Mmake.common.in:
	Define MR_NO_CONF_BACKWARDS_COMPAT when checking
	for namespace cleanliness.

RESERVED_MACRO_NAMES:
	Remove the configuration macros.

runtime/mercury_conf_bootstrap.h:
	Remove a duplicate definition of BOXED_FLOAT.

configure.in:
*/*.c:
*/*.h:
*/*.m:
	Add MR_ prefixes.
2002-02-13 09:56:49 +00:00
Zoltan Somogyi
66d7c9bc39 Remove obsolete predicates whose jobs are now done by functions.
Estimated hours taken: 1
Branches: main

library/float.m:
library/math.m:
	Remove obsolete predicates whose jobs are now done by functions.
	The existence of the predicate versions made uses of the functions
	ambiguous, as (e.g.) X = math__sin(Y) could be read both as a function
	application and as the creation of a closure.

	The removed predicates were marked obsolete in March 1999, so there has
	been ample notice.

tests/general/float_test.m:
tests/valid/vn_float.m:
	Replace the predicate forms with the function forms.
2002-01-04 07:49:14 +00:00
Fergus Henderson
d341ed079d A regression test for a bug in purity analysis that I fixed on
Estimated hours taken: 0.75
Branches: main

tests/valid/Mmakefile:
tests/valid/spurious_purity_warning.m:
	A regression test for a bug in purity analysis that I fixed on
	Dec 13th 2001.
2002-01-04 05:56:40 +00:00