Commit Graph

57 Commits

Author SHA1 Message Date
Zoltan Somogyi
f9fe8dcf61 Improve the error messages generated for determinism errors involving committed
Estimated hours taken: 8
Branches: main

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

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

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

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

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

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

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

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

compiler/libs.m:
	Include compiler_util.m.

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

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

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

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

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

tests/invalid/det_errors.err_exp:
tests/invalid/magicbox.err_exp:
	Change the expected output to conform to the change in det_report.m,
	which is now more consistent.
2005-10-28 02:11:03 +00:00
Zoltan Somogyi
d609181cb9 Consider types of the form
Estimated hours taken: 30
Branches: main

Consider types of the form

	:- type x ---> f.

to be dummy types, since they contain no information. Optimize them the same
way we currently optimize io.state and store.store.

runtime/mercury_type_info.h:
	Add a new type_ctor_rep for dummy types.

runtime/mercury_tabling.h:
	Add a representation for "tabled" dummy types, which don't actually
	have a level in the trie, so that the runtime system can handle that
	fact.

runtime/mercury_ml_expand_body.h:
	When deconstructing a value of a dummy type, ignore the actual value
	(since it will contain garbage) and instead return the only possible
	value of the type.

runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.c:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
library/rtti_implementation.m:
	Handle the type_ctor_rep of dummy types.

runtime/mercury_builtin_types.c:
	Provide a place to record profiling information about unifications and
	comparisons for dummy types.

runtime/mercury_mcpp.h:
java/runtime/TypeCtorRep.java:
library/private_builtin.m:
	Add a new type_ctor_rep for dummy types, and fix some previous
	discrepancies in type_ctor_reps.

mdbcomp/prim_data.m:
	Move a bunch of predicates for manipulating special_pred_ids here from
	the browser and compiler directories.

	Rename the function symbols of the special_pred_id type to avoid the
	need to parenthesize the old `initialise' function symbol.

	Convert to four-space indentation.

mdbcomp/rtti_access.m:
	Don't hardcode the names of special preds: use the predicates in
	prim_data.m.

	Convert to four-space indentation.

browser/declarative_execution.m:
	Delete some predicates whose functionality is now in
	mdbcomp/prim_data.m.

compiler/hlds_data.m:
	Replace the part of du type that says whether a type an enum, which
	used to be a bool, with something that also says whether the type is a
	dummy type.

	Convert to four-space indentation.

compiler/make_tags.m:
	Compute the value for the new field of du type definitions.

compiler/hlds_out.m:
	Write out the new field of du type definitions.

compiler/rtti.m:
	Modify the data structures we use to create type_ctor_infos to allow
	for dummy types.

	Convert to four-space indentation.

compiler/type_ctor_info.m:
	Modify the code that generates type_ctor_infos to handle dummy types.

compiler/type_util.m:
	Provide predicates for recognizing dummy types.

	Convert to four-space indentation.

compiler/unify_proc.m:
	Generate the unify and compare predicates of dummy types using a new
	code scheme that avoids referencing arguments that contain garbage.

	When generating code for unifying or comparing other types, ignore
	any arguments of function symbols that are dummy types.

	Don't use DCG style access predicates.

compiler/higher_order.m:
	Specialize the unification and comparison of values of dummy types.

	Break up an excessively large predicate, and factor out common code
	from the conditions of a chain of if-then-elses.

compiler/llds.m:
	For each input and output of a foreign_proc, include a field saying
	whether the value is of a dummy type.

compiler/pragma_c_gen.m:
	Fill in the new fields in foreign_proc arguments.

compiler/hlds_goal.m:
	Rename some predicates for constructing unifications to avoid
	unnecessary ad-hoc overloading. Clarify their documentation.

	Rename a predicate to make clear the restriction on its use,
	and document the restriction.

	Add a predicate for creating simple tests.

	Add a utility predicate for setting the context of a goal directly.

compiler/modules.m:
	Include dummy types interface files, even if they are private to the
	module. This is necessary because with the MLDS backend, the generated
	code inside the module and outside the module must agree whether a
	function returning a value of the type returns a real value or a void
	value, and this requires them to agree on whether the type is dummy
	or not.

	The impact on interface files is minimal, since very few types are
	dummy types, and changing a type from a dummy type to a non-dummy type
	or vice versa is an ever rarer change.

compiler/hlds_pred.m:
	Provide a representation in the compiler of the trie step for dummy
	types.

compiler/layout_out.m:
	Print the trie step for dummy types.

compiler/table_gen.m:
	Don't table values of dummy types, and record the fact that we don't
	by including a dummy trie step in the list of trie steps.

compiler/add_pragma.m:
compiler/add_special_pred.m:
compiler/add_type.m:
compiler/aditi_builtin_ops.m:
compiler/bytecode.m:
compiler/bytecode_gen.m:
compiler/code_gen.m:
compiler/code_info.m:
compiler/continuation_info.m:
compiler/cse_detection.m:
compiler/det_report.m:
compiler/exception_analysis.m:
compiler/inst_match.m:
compiler/livemap.m:
compiler/llds_out.m:
compiler/llds_out.m:
compiler/middle_rec.m:
compiler/ml_call_gen.m:
compiler/ml_closure_gen.m:
compiler/ml_code_gen.m:
compiler/ml_code_util.m:
compiler/ml_type_gen.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_il.m:
compiler/modecheck_unify.m:
compiler/modes.m:
compiler/opt_util.m:
compiler/post_term_analysis.m:
compiler/post_typecheck.m:
compiler/qual_info.m:
compiler/rl.m:
compiler/rl_exprn.m:
compiler/rl_key.m:
compiler/rtti_out.m:
compiler/simplify.m:
compiler/size_prof.m:
compiler/term_constr_initial.m:
compiler/term_constr_util.m:
compiler/term_norm.m:
compiler/termination.m:
compiler/trace.m:
compiler/typecheck.m:
compiler/unify_gen.m:
	Conform to the changes above.

compiler/export.m:
compiler/exprn_aux.m:
compiler/foreign.m:
compiler/polymorphism.m:
compiler/proc_label.m:
compiler/rtti_to_mlds.m:
compiler/special_pred.m:
compiler/stack_alloc.m:
compiler/stack_layout.m:
compiler/state_var.m:
compiler/switch_util.m:
compiler/trace_params.m:
	Conform to the changes above.

	Convert to four-space indentation.

compiler/mlds_to_java.m:
compiler/var_locn.m:
	Conform to the changes above, which requires threading the module_info
	through the module.

	Convert to four-space indentation.

compiler/mercury_compile.m:
	Pass the module_info to mlds_to_java.m.

compiler/ml_util.m:
compiler/polymorphism.m:
compiler/type_ctor_info.m:
compiler/type_util.m:
	Delete some previously missed references to the temporary types used
	to bootstrap the change to the type_info type's arity.

compiler/polymorphism.m:
	Turn back on an optimization that avoids passing parameters (such as
	type_infos) to foreign_procs if they are not actually referred to.

compiler/prog_data.m:
	Convert to four-space indentation.

library/svvarset.m:
	Add a missing predicate.

trace/mercury_trace.c:
	Delete the unused function that used to check for dummy types.

tests/debugger/field_names.{m,inp,exp}:
	Add to this test case a test of the handling of dummy types. Check that
	their values can be printed out during normal execution, and that the
	debugger doesn't consider them live nondummy variables, just as it
	doesn't consider I/O states live nondummy variables.
2005-10-05 06:34:27 +00:00
Zoltan Somogyi
2842fe4ffb Some style fixes. Make some predicates into functions, and delete
Estimated hours taken: 0.3
Branches: main

compiler/llds_out.m:
	Some style fixes. Make some predicates into functions, and delete
	redundant llds_out__ prefixes to eliminate some excessively long lines.
	There are no algorithmic changes.

compiler/opt_debug.m:
compiler/fact_table.m:
	Conform to the changes in llds_out.m.

compiler/rtti_out.m:
	Conform to the changes in llds_out.m.

	Convert to four-space indentation.
2005-09-22 06:29:28 +00:00
Zoltan Somogyi
34d5181f3a Bring these modules up to date with our current style guidelines.
Estimated hours taken: 4
Branches: main

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

compiler/*.m:
	Minor style fixes.
2005-03-30 00:50:21 +00:00
Zoltan Somogyi
3c60c0e485 Change a bunch of modules to import only one module per line, even
Estimated hours taken: 4
Branches: main

compiler/*.m:
	Change a bunch of modules to import only one module per line, even
	from the library.

compiler/mlds_to_il.m:
compiler/mlds_to_managed.m:
	Convert these modules to our current coding style. Use state variables
	where appropriate. Use predmode declarations where possible.
2005-03-22 06:40:32 +00:00
Julien Fischer
601fe20aba Simplify the structure of the compiler by removing the cycle
Estimated hours taken: 3.5
Branches: main

Simplify the structure of the compiler by removing the cycle
parse_tree -> backend_libs -> check_hlds -> parse_tree
from the package dependency graph.

I've done this by factoring out the code in backend_libs.foreign
and backend_libs.name_mangle that is needed by the frontend of
the compiler and putting it in a new module, parse_tree.prog_foreign.
This removes the dependency between the parse_tree and backend_libs
packages.

The obvious downside to this is that the name mangler is now
split in two, although such a division was always in implicit
in the predicates of the name_mangle module anyway, ie. between
those bits that operate on the HLDS/MLDS/LLDS level data structures
and those that don't.

compiler/name_mangle.m:
compiler/foreign.m:
compiler/prog_foreign.m:
	Move code for dealing with foreign language procedures that
	is required by the parse_tree package into a new module,
	prog_foreign.

	Update the formatting in some of these modules so that
	they match our current coding standard.

compiler/*.m:
	Update to reflect the above change.

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

	Fix some spelling errors.
2005-03-21 04:45:51 +00:00
Ian MacLarty
4970242093 Use proc_label data structure defined in mdbcomp.prim_data instead of proc_id
Estimated hours taken: 4
Branches: main

Use proc_label data structure defined in mdbcomp.prim_data instead of proc_id
defined in mdb.declarative_execution and delete proc_id, since these data
structures are almost identical.

browser/declarative_execution.m
	Remove proc_id and flat_module_name types.  Use
	mdbcomp.prim_data.proc_label and mdbcomp.prim_data.module_name instead.

browser/declarative_debugger.m
browser/declarative_oracle.m
browser/declarative_tree.m
browser/declarative_user.m
	Use mdbcomp.prim_data.proc_label and mdbcomp.prim_data.module_name
	instead of mdb.declarative_execution.proc_id and
	mdb.declarative_execution.module_name.

mdbcomp/prim_data.m
compiler/prog_out.m
	Move sym_name_to_string from prog_out to prim_data.
	Fix comment for prog_out.sym_name_and_arity_to_string.

compiler/bytecode.m
compiler/check_typeclass.m
compiler/code_gen.m
compiler/deforest.m
compiler/higher_order.m
compiler/hlds_code_util.m
compiler/hlds_error_util.m
compiler/hlds_module.m
compiler/hlds_out.m
compiler/intermod.m
compiler/layout_out.m
compiler/make.module_target.m
compiler/make_hlds.m
compiler/mercury_compile.m
compiler/mercury_to_mercury.m
compiler/ml_elim_nested.m
compiler/mlds_to_c.m
compiler/mlds_to_gcc.m
compiler/mlds_to_il.m
compiler/mlds_to_java.m
compiler/mlds_to_managed.m
compiler/modes.m
compiler/modules.m
compiler/opt_debug.m
compiler/options_file.m
compiler/polymorphism.m
compiler/prog_io.m
compiler/prog_rep.m
compiler/rl.m
compiler/rl_exprn.m
compiler/rl_gen.m
compiler/rl_info.m
compiler/rl_out.pp
compiler/rtti.m
compiler/rtti_out.m
compiler/rtti_to_mlds.m
compiler/source_file_map.m
compiler/table_gen.m
compiler/trans_opt.m
compiler/unify_gen.m
compiler/unique_modes.m
compiler/unused_args.m
	Use mdbcomp.prim_data.sym_name_to_string instead of
	prog_out.sym_name_to_string.
2005-02-01 07:11:42 +00:00
Peter Wang
59d2d4a573 This adds a module mdbcomp__trace_counts that reads in the
Estimated hours taken: 17
Branches: main

This adds a module mdbcomp__trace_counts that reads in the
.mercury_trace_counts files produced by the compiler's trace mechanism.
The format of said files was slightly changed.

As the new module is to be used by the compiler and the debugger, it is
placed in the mdbcomp module.  This required bringing some types from the
compiler into a new module within mdbcomp.

browser/trace_counts.m:
	New module for reading execution trace summaries.

browser/prim_data.m:
	New module holding types and predicates moved in from the compiler.
	Types:
		pred_or_func, sym_name, module_name, proc_label,
		special_pred_id, trace_port
	Predicates:
		string_to_sym_name, insert_module_qualifier

	The mode field of proc_label is now an int instead of a proc_id
	to avoid pulling proc_id into mdbcomp.

browser/mdbcomp.m:
	Add trace_counts and prim_data to the mdbcomp module.

browser/declarative_execution.m:
	Renamed mdb's definition of module_name to flat_module_name
	to avoid conflicts with the definition in mdbcomp__prim_data.

runtime/mercury_trace_base.c:
	In the format of .mercury_trace_counts, write module and predicate
	names now use quoted atom syntax so that names with spaces and
	non-printable characters can be machine-parsed.

browser/:
compiler/:
	Many changes to account for movement of types, and the change to
	proc_label.
2005-01-19 03:11:22 +00:00
Simon Taylor
42025cecfc Allow Aditi to call Mercury. At the moment, this involves Aditi
Estimated hours taken: 200
Branches: main

Allow Aditi to call Mercury.  At the moment, this involves Aditi
loading a shared library containing the user's code.

runtime/mercury_aditi.h:
	Define a structure MR_Aditi_Proc_Info used to describe
	a procedure called by Aditi.  Aditi will use dlsym() to
	look up these structures in the shared library supplied
	by the user.

compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/ml_code_util.m:
compiler/mlds_to_gcc.m:
compiler/opt_debug.m:
	Add an aditi_proc_info alternative to the rtti_data type,
	which corresponds to an MR_AditiProcInfo structure in
	the generated code.

	In the rtti_proc_label type, record the determinism rather
	than the code_model for use by Aditi.

compiler/options.m:
doc/user_guide.texi:
	Add an option `--aditi-calls-mercury'.
	This is needed for the Aditi tests, which currently don't
	handle loading the shared libraries for user defined code.

	Move `--aditi' into the compilation model options section.

compiler/rl.m:
	Sort the constructors for d.u. types when creating an Aditi
	type declaration to make it easier to find a particular
	constructor.

compiler/code_model.m:
compiler/stack_layout.m:
	Move represent_determinism into code_model.m, for use
	by rtti_to_mlds.m.

compiler/rl_exprn.m:
compiler/rl_file.pp:
compiler/rl_out.pp:
compiler/hlds_module.m:
compiler/mercury_compile.m:
	Create the procedures for each top-down Mercury goal which
	needs to be called from Aditi.
	Each created procedure has one input and one output argument,
	both of which will have a `{}/N' type.

	Allow nondet join conditions.

compiler/rl_exprn.m:
	Use record syntax.

compiler/rl_out.pp:
	Minor changes to the support for memoing.

runtime/Mmakefile:
runtime/mercury_imp.h:
runtime/mercury.h:
	Add mercury_aditi.h.

runtime/mercury_stack_layout.m:
	Add a comment about the duplication between MR_DETISM_*
	and code_model.represent_determinism.

tests/valid/Mmakefile:
tests/valid/Mercury.options:
tests/valid/aditi_calls_mercury.m:
	Test case.

	Also, enable the Aditi tests in hlc grades.
2004-10-20 09:45:11 +00:00
Zoltan Somogyi
d332038ee1 Bring these modules up to date with our coding guidelines.
Estimated hours taken: 16
Branches: main

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

	There are no changes in algorithms.
2004-06-30 02:48:20 +00:00
Zoltan Somogyi
e4b0328ade Provide a mechanism for declaring foreign types that can be operated on by
Estimated hours taken: 4
Branches: main

Provide a mechanism for declaring foreign types that can be operated on by
compare_representation. The intended use of the mechanism is to declare
a foreign type to represent proc_layouts in the declarative debugger,
as part of the representation of atoms; since atoms are keys in maps
in the oracle, they are input to compare_representation.

Since we don't want the result of compare_representation to change as
execution proceeds, we require an assertion that the foreign value is
stable, i.e. that the value of the foreign type variable completely
determines the data it points to, directly and indirectly. Proc_layouts
are static, so this is not a problem. Being able to do the comparison
requires the foreign type to be an integral type or a pointer, which
is what the existing can_pass_as_mercury_type assertion promises.
The stability is promised by a new assertion.

For foreign types that have both assertions, we use a new type_ctor_rep,
which differs from the existing type_ctor_rep for foreign types by doing
a real comparison instead of an abort in compare_representation.

doc/reference_manual.texi:
	Document the new kind of assertion.

compiler/prog_data.m:
	Add the new kind of assertion.

compiler/prog_io_pragma.m:
	Parse the new kind of assertion.

compiler/rtti.m:
	Add the representation of the new type_ctor_rep. Factor out the
	stability of c_pointers as well as foreign types.

compiler/type_ctor_info.m:
	Generate the new type_ctor_rep for types with both assertions.

compiler/foreign.m:
	Export a predicate for use by type_ctor_info.m.

compiler/mercury_to_mercury.m:
	Print the new assertion.

compiler/*.m:
	Minor changes to conform to the diffs above.

	Use state variable notation.

library/rtti_implementation.m:
	Handle the new type_ctor_rep.

runtime/mercury_mcpp.h:
runtime/mercury_type_info.h:
java/runtime/TypeCtorRep.java:
	Add the new type_ctor_rep to the runtime.

runtime/mercury_mcpp.h:
runtime/mercury_type_info.h:
compiler/type_ctor_info.m:
	Increment the rtti version number.

	When we rely on the availability of this new capability,
	we should add a test for the new rtti version number to configure.in.

runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_term_size.h:
	Handle stable foreign types the same way as other foreign types.

runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.h:
runtime/mercury_unify_compare_body.h:
	Handle stable foreign types in a useful manner, relying on the
	assertions behind them.

tests/hard_coded/stable_foreign.{m,exp}:
	A test case for the handling of values of a stable foreign type.

tests/hard_coded/Mmakefile:
	Enable the new test case.
2004-06-28 04:50:10 +00:00
Zoltan Somogyi
c80d143cc8 The following change is only 98% complete, not 100%.
Estimated hours taken: 120
Branches: main

The following change is only 98% complete, not 100%. I am committing it in
this state because (1) we pass many more test cases in deep profiling grade
with it than without it, and (2) the double maintanance involved in fixing
CVS conflicts is preventing me from doing the last 2%.

Get the deep profiler to work for code that sets up to catch exceptions,
which for the last year or more has included the compiler, and to get it
almost working for code that actually catching exceptions.

The basic problem is that code that throws exceptions will in general cause
several calls to "return" without executing the exit or fail port codes that
the deep profiling transformation inserted into their bodies, and this leaves
the data structure being built by the deep profiling inconsistent. The solution
uses the same approach as we have adopted for the debugger: have the code that
handles the throwing of exceptions simulate a return from each call between
the throw and the catch, updating the deep profiling data structures as needed.

This requires us to be able to walk the stack at runtime not just in debugging
grades but also in deep profiling grades. Since the debugger already has the
mechanisms required for this, we reuse them. The procedure layouts used by the
debugger were designed to have three segments: the procedure stack walk
information, the procedure id, and the execution tracing information. We now
modify this design to make the third segment contain two pointers: to the
execution tracing information (for use by the debugger), and to the procedure's
proc_static structure (for use by deep profiling). Each pointer will be null
unless the pointed-to structure is required by compile-time options.

This common use by the debugger and by deep profiling of the stack-walk
structure and the procedure id structure (which deep profiling used to
generate independently and possibly redundantly) required some rearrangement
of the compiler's version of these data structures.

To make this rearrangement simpler, this diff removes a capability that
we theoretically supported but never used: turning on stack traces without
turning on execution tracing and vice versa. After this diff, stack tracing
is enabled if and only if either execution tracing or deep profiling is
enabled.

The diff also includes improvements in the debugging infrastructure for
debugging deep profiling, which were necessary for the implementation of the
rest of the changes.

compiler/deep_profiling.m:
	The code in exception.m needs to know the locations of the variables
	that we would pass to the exit or fail port code, so it can simulate
	leaving the procedure invocation through the exception port. Without
	this information, throwing an exception leaves the deep profiling
	data structures of the procedure invocations between throw and catch
	in an inconsistent state.

	Deep_profiling.m creates these variables, but it doesn't know where
	they will be at runtime, so it records their identities; the code
	generator will allocate them stack slots and record the numbers of
	these stack slots for placement in the now expanded proc layout
	structures. Deep profiling used to generate static data structures
	separately from the HLDS, but since the code generator now needs
	access to them, we store their information in proc_infos in the HLDS.

	Instead of passing the addresses of proc_static structures to the deep
	profiling port procedures, pass the address of proc_layout structures,
	since the information about the identities of procedures are now stored
	not in the proc_static structure, but in the proc_layout structure
	that points to the proc_static structure.

compiler/hlds_pred.m:
compiler/layout.m:
	Move the definitions of the static data structures generated by deep
	profiling from layout.m to hlds_pred.m, to allow deep_profiling.m
	to store them in proc_infos.

compiler/hlds_pred.m:
compiler/rtti.m:
	Move the definition of rtti_proc_label from rtti.m to hlds_pred.m,
	since some of the new data structures in hlds_pred.m need it. Despite
	its name, the rtti_proc_label type doesn't contain any info that
	doesn't belong in the HLDS.

	Add some information to the rtti_proc_label type that is now needed
	by deep profiling, e.g. record determinisms instead of just code
	models. Record explicitly the outcome of some tests that used to be
	duplicated in more than one place in the compiler, e.g. for whether
	the procedure (as opposed to the predicate) is imported. Change some
	of the field names to be more precise about the field's meaning.

compiler/code_gen.m:
	Transmit the contents of the deep profiling data structures stored in
	the proc_info by deep_profiling.m to continuation_info.m, together
	with the layout structures created for execution tracing and the
	identities of the variables needed for handling exceptions,
	when code generation for a procedure is complete.

	After the goal that generates these variables, save them to stack
	for use by the exception handler.

compiler/hlds_goal.m:
	Add a feature to mark the goal that generates the deep profiling
	variables needed by the exception handler.

compiler/hlds_llds.m:
	Add a utility predicate for new code in code_gen.m

compiler/continuation_info.m:
	Hold the deep profiling information computed by code_gen.m for use by
	stack_layout.m.

compiler/layout.m:
compiler/layout_out.m:
	Update the definitions of the data structures describing procedure
	layouts, and the code writing them out, to reflect the use of some
	parts of procedure layouts by deep profiling as well as debugging.

	Change the layout structures generated by deep profiling to use
	rtti_proc_labels, which are backend independent, instead of
	proc_labels, which are specific to the LLDS backend.

	Conform to the changes in runtime/mercury_stack_layout.h.

compiler/stack_layout.m:
	Generate the updated version of proc_layout structures.

compiler/mercury_compile.m:
compiler/global_data.m:
	Conform to the fact that deep profiling no longer generates layout
	structures separate from proc_infos.

compiler/llds_out.m:
	Register proc_layout structures instead of proc_static structures
	for use by runtime/mercury_deep_profiling.c.

compiler/options.m:
compiler/handle_options.m:
	Rename the require_tracing option as exec_trace, since this more
	directly reflects its meaning.

	Instead of having --debug set both require_tracing and stack_trace,
	make it set (be the user-visible name of) just exec_trace;
	the value of stack_trace is implied.

	Turn off the specialization of deep profiling for self-tail-recursive
	procedures for now. Due to the changes made by this diff in the data
	structures involved in debugging, it cannot be debugged until this
	change has been installed. Handling the full language is more important
	than a specialization that reduces only stack space overheads, not
	runtime overheads.

compiler/compile_target_code.m:
	Conform to the changes in options.m and runtime/mercury_grade.h.

compiler/hlds_data.m:
	Replace the deep_profiling_proc_static cons_id, and its associated tag,
	to deep_profiling_proc_layout, since we now generate addresses of proc
	layout structures, not of proc_static structures.

compiler/code_util.m:
	Simplify some code based on the new info in rtti_proc_labels.

compiler/bytecode_gen.m:
compiler/dependency_graph.m:
compiler/higher_order.m:
compiler/hlds_out.m:
compiler/mercury_to_mercury.m:
compiler/ml_code_util.m:
compiler/ml_unify_gen.m:
compiler/opt_debug.m:
compiler/proc_label.m:
compiler/prog_rep.m:
compiler/rl_exprn.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/saved_vars.m:
compiler/switch_util.m:
compiler/unify_gen.m:
	Minor changes to conform to the change from deep_profiling_proc_static
	to deep_profiling_proc_layout, to the change in the structure of
	rtti_proc_labels, to the changes in types of layout.m, and/or to the
	new goal feature.

deep_profiler/measurements.m:
	Reserve space for exception counts.

deep_profiler/html_format.m:
	Add a column for exception counts.

deep_profiler/profile.m:
deep_profiler/read_profile.m:
	Rename the data structures referring to compiler generated unify,
	compare and index predicates to avoid misleading names: they are
	not the only compiler generated predicates.

deep_profiler/read_profile.m:
runtime/mercury_deep_profiling.c:
	Update the string that identifies deep profiling data files.
	This is necessary because the format has changed: it now includes
	information about exception port counts.

library/exception.m:
	In deep profiling grades, execute the exception port code for every
	procedure invocation between a throw and a catch, using the procedure
	layout structures now generated by the compiler for every procedure.
	Rename the function involved to reflect its new, more general purpose.

	Update the definitions of the hand-written proc_static and proc_layout
	structures for the procedures implemented via hand-written C code.

	Indent C preprocessor directives and foreign_procs according to our
	coding standards.

library/profiling_builtin.m:
	Change the parameters of the call port code procedures from proc_static
	to proc_layout. Reach the proc_static structure from the proc_layout
	structure when needed. Include the proc_layout structure in any
	messages from assertion failures.

	Add some conditionally compiled debugging code.

	Give some variables better names.

runtime/mercury_type_info.h:
runtime/mercury_builtin_types.c:
	Move the macros required to create the proc_static structures
	of unify and compare predicates from mercury_type_info.h
	to mercury_builtin_types.c, since the latter is the only file
	that needs them.

	Use the same macros for creating the proc_static structures
	of hand-written unify, compare and compare_reprentation predicates
	as for user defined predicates. This required changing their naming
	scheme.

runtime/mercury_unify_compare_body.h:
	Conform to the new naming scheme.

runtime/mercury_ho_call.c:
	Provide the mechanism for mercury_unify_compare_body.h to conform
	to the new naming scheme.

	Remove the definitions of the proc_static structures for
	hand-written unify, compare and compare_reprentation predicates,
	since these now have to be defined together with the corresponding
	proc_layout structures in mercury_builtin_types.c.

runtime/mercury_builtin_types.[ch]:
	Update the definitions of the hand-written proc_static and proc_layout
	structures for the procedures implemented via hand-written C code,
	and add the required declarations first.

	Handle deep profiling of compare_representation as well as unify
	and compare predicates on builtin types.

	Handle deep profiling of compare_representation on user-defined types,
	since this is done entirely in the runtime, not by compiler generated
	predicates.

runtime/mercury_builtin_types_proc_layouts.h:
	New header file containing the declarations of the proc layout
	structures of the unify, compare and index predicates of builtin types.
	Logically, these declarations belong in mercury_builtin_types.h,
	but putting them there causes problems for the linker; the details
	are explained in the file itself.

runtime/Mmakefile:
	Add the new header file.

runtime/mercury_minimal_model.[ch]:
	Update the definitions of the hand-written proc_static and proc_layout
	structures for the procedures implemented via hand-written C code,
	and add the required declarations first.

runtime/mercury_grade.h:
	Replace the MR_REQUIRE_TRACING grade option with MR_EXEC_TRACING.
	Besides being better named, the MR_EXEC_TRACING option implies
	MR_STACK_TRACE.

	Besides the overall binary compatibility version number, add subsidiary
	version numbers for binary compatibility in deep profiling and
	debugging grades. These will make it easier to bootstrap changes
	(such as this) that affect binary compatibility only in such grades.

runtime/mercury_trace_base.c:
trace/mercury_trace.c:
	Conform to the new names of the configuration parameters.

runtime/mercury_hand_compare_body.h:
runtime/mercury_hand_unify_body.h:
runtime/mercury_hand_unify_compare_body.h:
runtime/mercury_ho_call.c:
tools/make_port_code:
	Pass proc_layout structures instead of proc_static structures
	to deep profiling port routines.

runtime/mercury_conf_param.h:
	Make MR_DEEP_PROFILING as well as MR_EXEC_TRACING imply MR_STACK_TRACE,
	since deep profiling now needs stack tracing. (MR_STACK_TRACE needs
	to be set in this file, because tests in this file depend on knowing
	its value, and this file is among the first files included (in this
	case indirectly) in mercury_imp.h.)

	Document the macros controlling the debugging of deep profiling.

	Enable printing of label names when the relevant deep profiling
	debugging macro is set.

runtime/mercury_debug.c:
runtime/mercury_deep_rec_depth_actions.h:
runtime/mercury_deep_rec_depth_body.h:
runtime/mercury_exception_catch_body.h:
	Get to proc_statics via proc_layouts.

runtime/mercury_deep_call_port_body.c:
runtime/mercury_deep_leave_port_body.c:
	Get to proc_statics via proc_layouts.

	Allow the debugger to disable deep profiling in Mercury code that is
	part of the debugger, not of the user program being executed.

	Add some more assertions.

runtime/mercury_engine.[ch]:
	Add a new debugging flag that controls at runtime whether we generate
	a human readable Deep.debug equivalent to the binary Deep.data files.
	(We already had a mechanism for controlling this at compile time,
	but this isn't flexible enough.)

runtime/mercury_wrapper.c:
	Allow this new debugging flag to be set from MERCURY_OPTIONS.

runtime/mercury_deep_profiling.[ch]:
	Respect this new debugging flag.

	Update the hand-written proc_static structures representing the runtime
	system.

	Print out addresses of proc_layout as well as proc_static structures
	when assertions fail.

	Add a field to the measurement structure for exception port counts,
	and write out this field with the other port counts.

	Remove procedure id information from proc_static structures,
	deep profiling now uses the procedure id in the proc_layout structure.

	Add to proc_static structures fields that specify where, if anywhere,
	the variables needed by exception.m to executed the exception port code
	are in the procedure's stack frame.

	Define a global flag that allows the debugger to disable deep
	profiling in Mercury code that is part of the debugger, not of the
	user program being executed.

	Increase type safety by providing two versions of the function
	for registering proc_layouts, one for the proc_layout structures
	of user-defined predicates and one for unify, compare and index
	predicates.

	Fix a bug that occurs only if MR_DEEP_PROFILING_EXPLICIT_CALL_COUNTS is
	defined (which it usually isn't): the initial call count was wrong.

runtime/mercury_deep_profiling_hand.h:
	Fix a bug: the handwritten code saving deep profiling variables was
	saving them in slots that didn't belong to the relevant stack frame.

	Update to conform to the modified definitions of proc_static structures
	and the fact that we now reach them via proc_layout structures.

runtime/mercury_exception_catch_body.h:
runtime/mercury_stacks.h:
	Fix the other side of the bug in mercury_deep_profiling_hand.h
	by reserving the right number of stack slots in the stack frames
	of the various modes of exception__catch. Make it harder to make
	the same bug in the future by getting the needed info from the
	place in mercury_stacks.h that defines the structure of the relevant
	stack frame.

runtime/mercury_proc_id.h:
	Rename the procedure id structure fields referring to compiler
	generated unify, compare and index predicates: they are not the only
	compiler-generated predicates.

runtime/mercury_stack_layout.h:
	Change procedure layout structures to allow them to be used for deep
	profiling as well as for debugging, as described in the prologue above.

	We don't need the capability to support label layout structures with
	links to misnamed proc layout structures, and supporting it is
	inconvenient, so delete the capability.

runtime/mercury_debug.c:
runtime/mercury_deep_profiling_hand.h:
runtime/mercury_layout_util.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_stack_trace.c:
runtime/mercury_types.h:
trace/mercury_trace_external.c:
	Conform to the new names of the procedure id structure fields.

runtime/mercury_std.h:
	Add some more arities for MR_PASTE for use in some of the modified
	modules in the runtime.

trace/mercury_trace_internal.c:
	Disable deep profiling actions in Mercury code that is part of the
	debugger, not of the program being debugged.

scripts/init_grade_options.sh-subr:
scripts/parse_grade_options.sh-subr:
	Make changes parallel to the ones in runtime/mercury_grade.h: delete
	--stack-trace as an independent option, and make --debug set its
	own option, not --require-tracing.

scripts/canonical_grade.sh-subr:
scripts/final_grade_options.sh-subr:
scripts/c2init.in:
scripts/mgnuc.in:
scripts/ml.in:
	Conform to the changes in grade options for debugging and for deep
	profiling.

tools/bootcheck:
	If Mmake.stage.{browser,deep,library,runtime,trace}.params exist,
	copy them to become the file Mmake.$dir.params in stage2/$dir
	(where dir is derived from the name of the original file in the obvious
	way). This allows more flexibility in the creation of the stage2;
	for example, it allows some directories (e.g. runtime or library)
	to be compiled with more debugging than other directories (e.g.
	compiler). This may be required because compiling all directories
	with lots of debugging may cause the linker to thrash.

	Add an option, --disable-debug-libs, that clobbers the libraries
	that should be linked in only in debugging grades.

	To conserve disk space, remove Deep.data files created by the bootcheck
	by default. Add an option, --keep-deep-data, to preserve these files.

	Use a consistent mechanism (test -f) for testing the existence of
	all files whose existence is tested.

	When recording modification times, record the modification times
	of some more files.

tests/hard_coded/Mmakefile:
	In deep profiling grades, disable the test cases that we don't now
	pass in such grades, and document the reasons for their failure.

	Fix the misclassification of the write_binary test case.
2004-05-19 04:00:01 +00:00
Zoltan Somogyi
8f1d366f1d This commit commits two separate but related changes.
Estimated hours taken: 16
Branches: main

This commit commits two separate but related changes. The log messages for the
two changes follow.

-----------

Log message 1:

Reduce the size of compiler-generated C source files even further. The
reduction is 3 to 6% in non-debug LLDS grades, but 25 to 35% in debug grades.
Together with my previous change, the size of parse_tree.modules.c has gone
from more than 25 Mb to less than 8 Mb.

The changes to the header files will be committed first, followed some days
later by the changes to the compiler to generate the new macros. This gives
time for people to "cvs update" their workspaces at their own pace before
a change in the installed compiler forces them to do so.

compiler/llds_out.m:
	Group the declarations of common_data structures, so that a single
	mention of the type name can be amortized over the declaration of many
	structures.

	Do not emit macro invocations needed only by time profiling unless
	we are doing time profiling.

	When emitting rvals, look for special cases in which we can emit
	shorter code: references to common_data structures and to
	type_ctor_info structures. Both occur a lot in the data structures
	the compiler generates in debugging grades.

	Record which type names have been declared, so we don't declare them
	twice.

	Convert some affected predicates to state variable syntax.

compiler/layout_out.m:
	When possible, emit a shorthand macro that declares a label as it
	defines its label layout structure.

compiler/rtti_out.m:
	Group the declarations of rtti data structures, so that a single
	mention of the type name can be amortized over the declaration of many
	structures.

compiler/llds.m:
	Put common_data structures into a separate type, to allow them to be
	manipulated independently.

	Add a helper predicate.

compiler/global_data.m:
	Conform to the changed types in llds.m.

compiler/name_mangle.m:
	Add some helper predicates for use in llds_out.m and rtti_out.m.

	Reorder some predicate definitions for consistency with their
	declarations.

compiler/rtti.m:
	Add a helper predicate.

compiler/trace.m:
	Instead of generating long canned code fragments, generate calls to
	macros that expand to those canned code fragments.

library/multi_map.m:
	Add function forms of the predicates in this module, for use in the
	modified compiler modules.

runtime/mercury_misc.h:
runtime/mercury_stack_layout.h:
runtime/mercury_trace_base.h:
runtime/mercury_type_info.h:
	Define the macros that the compiler now generates.

runtime/mercury_goto.h:
	Define macros used to implement the macros in the above four header
	files.

runtime/mercury_bootstrap.h:
	Move the definitions of bool, TRUE and FALSE to the section where they
	are defined only if the user asks for them. This is to avoid conflict
	with the module name "bool".

tests/hard_coded/pragma_import.m:
	Rename bool to MR_bool.

-----------

Log message 2:

Generate even more compact output. These changes reduce the sizes of the C
files generated from modules.m and make_hlds.m by about a further 15% in debug
grades. The size of parse_tree.modules.c, originally about 25 Mb, is now down
to 6.5 Mb, less than twice the size of parse_tree.modules.o (which is about
3.5 Mb). Even more dramatically, they reduce the size of parse_tree.modules.c
and hlds.make_hlds.c by around 40% in non-debug grades, though the reduction
is still larger in debug grades than in non-debug grades when expressed in
bytes instead of as a percentage.

compiler/layout_out.m:
	Declare more than one layout structure at a time when possible.

compiler/llds_out.m:
	Declare and initialize more than one label at a time when possible.
	Even when declaring or initializing only one, get the macro definition
	to supply the mercury__ prefix.

	Use shorter macros to refer to stackvars and framevars.

	When referring to tagged pointers, use macros that supply the MR_mktag
	and MR_mkbody macros in the most common cases.

	When possible, emit calls in no-profiling forms, since these are
	shorter.
2004-04-08 05:35:10 +00:00
Zoltan Somogyi
0bad60f181 Fix a bug: we were generating improper output for the type_ctor_infos
Estimated hours taken: 1
Branches: main

compiler/rtti_out.m:
	Fix a bug: we were generating improper output for the type_ctor_infos
	of equivalence types in which the right hand side was a type variable.

tests/debugger/exported_eqv_type.{m,inp,exp}:
	A new test case checking for the proper handling of such types.

tests/debugger/Mmakefile:
	Enable the new test.
2004-04-01 04:34:24 +00:00
Zoltan Somogyi
ac354fc329 Eliminate an unnecessary difference between the compiler's representation of
Estimated hours taken: 4
Branches: main

Eliminate an unnecessary difference between the compiler's representation of
type constructor related RTTI structures and typeclass related RTTI structures.
Just as for the former we separate out the identity of the type constructor,
we now also separate out the identity of the type class for the latter.
(That we didn't always do so was a historical accident, due to the fact that
for a long time there was only one kind of type class related RTTI structure,
base_typeclass_info.)

compiler/rtti.m:
	Factor out the type class identity from tc_rtti_ids. Make
	base_typeclass_infos include a tc_name instead of a class_id
	(the same info in a different form) just as the other type class
	related tc_names do.

compiler/base_typeclass_info.m:
compiler/ml_unify_gen.m:
compiler/mlds_to_gcc.m:
compiler/name_mangle.m:
compiler/opt_debug.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/unify_gen.m:
	Conform to the change above. In some cases, the change in
	representation allows us to eliminate duplicated code that wasn't
	worth factoring out with the previous representation.

compiler/type_class_info.m:
	Export a function for use in the changed code in the above modules.
2004-03-24 02:57:13 +00:00
Zoltan Somogyi
c91313b32f Bring these modules up to date with our current coding style.
Estimated hours taken: 8
Branches: main

compiler/modules.m:
compiler/compile_target_code.m:
compiler/handle_options.m:
compiler/bytecode_data.m:
compiler/prog_io_util.m:
	Bring these modules up to date with our current coding style. Use
	predmode declarations and state variable syntax where appropriate.
	Fix inconsistent indentation. Print more error messages using
	error_util.m for printing error messages.

compiler/trace_param.m:
	Add a new predicate for use by the updated code in handle_options.m.

compiler/error_util.m:
compiler/hlds_error_util.m:
	Make error_util.m to be a submodule of parse_tree.m, not hlds.m.
	Most of its predicates are not dependent on HLDS data structures.
	Move the ones that are into a new module, hlds_error_util, that
	is a submodule of hlds.m. Overall, this reduces the dependence
	of submodules of parse_tree.m, including modules.m, on submodules
	of hlds.m.

compiler/notes/compiler_design.html:
	Update the documentation of compiler modes to account for
	hlds_error_util.m.

compiler/hlds.m:
compiler/parse_tree.m:
	Update the list of included submodules.

compiler/*.m:
	Update module imports and module qualifications as needed for the
	change above.

tests/invalid/*.{exp,exp2}:
	Update the expected outputs of a bunch of test cases to reflect the new
	format of some warning messages due to the user error_util; they now
	observe line length limits, and print contexts in some cases where they
	were previously missing.
2004-03-19 10:19:53 +00:00
Zoltan Somogyi
9d892fbada Augment the descriptors of du functors with information about the type class
Estimated hours taken: 8
Branches: main

Augment the descriptors of du functors with information about the type class
constraints on their existentially typed arguments (if any). This is not yet
used, but will be needed to perform type class membership tests (as we
discussed on wednesday). We will need to bump the binary compatibility version
number when we start relying on the newly generated data.

Turn on the generation of the new type class descriptor data structures, since
we now need them to describe functors with type class constraints.

This in turn required making the generation of those data structures work
for the MLDS backends as well as the LLDS backend. (The original diff that
added those data structures updated only the LLDS backend.)

compiler/mercury_compile.m:
	Always generate descriptors for type class declarations in both LLDS
	and MLDS backends. Generate descriptors for type class instances
	(which are not referred to from functor descriptors) only if
	--new-type-class-rtti is given.

compiler/rtti.m:
	Instead of recording just the number of constraints on existentially
	typed arguments of functors, record the constraints themselves.

	Add new rtti_ids to describe (arrays of) constraints in DuExistInfos.

	Add predicates to look up the types of not just the data structures
	denoted by rtti_ids, but also their element types if they are arrays.
	This is needed because functor desciptors may now contain arrays of
	MR_TypeClassConstraints, even though we generate no data structure
	of that type; we generate structures of type MR_TypeClassConstraintN
	for various values of N, and cast them to MR_TypeClassConstraint.

	Factor out some common code.

compiler/rtti_out.m:
	Implement the new field of DuExistInfos, and comment out the code
	needed to generate type class instances' method descriptors.

	Comment out the code for generating method addresses. (See the comment
	on mercury_typeclass_info.h below.)

	Fix a misleading variable name.

compiler/rtti_to_mlds.m:
	Replace "not yet implemented" aborts when translating the new style
	type class decl and instance structures with actual translation code.

	Implement the new field of DuExistInfos.

	Factor out common code for making arrays of pseudo-typeinfos.

compiler/mlds_to_gcc.m:
	Factor out the code for turning the type of an rtti data structure
	into the type of an array of them, to allow the latter step not to be
	done if we are want the type of the array elements.

	Add code for defining the types of type class declaration and instance
	descriptors.

	Implement the new field of DuExistInfos.

compiler/type_ctor_info.m:
	Instead of recording just the number of constraints on existentially
	typed arguments of functors, record the constraints themselves.

compiler/type_class_info.m:
	Generate instance descriptors only if requested.

	Export a function now needed by type_ctor_info.m.

compiler/mlds.m:
	Allow mlds__rtti_type to refer to the types of elements of the arrays
	we generate, even if there is no rtti_id that has that type.

compiler/mlds_to_c.m:
	Module qualify type class declaration and instance descriptors, at
	least for now; it is only base_typeclass_infos for which we need to
	detect duplicate definitions in different modules.

	Modify the types of du functor descriptors to include type class
	constraint information.

compiler/ml_closure_gen.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_java.m:
compiler/opt_debug.m:
	Trivial changes to conform to the changes above.

runtime/mercury_type_info.h:
	Add a field giving a list of type class constraints to MR_DuExistInfo.

	Move the definitions of the types describing type class constraints
	here from mercury_typeclass_info.h, since MR_DuExistInfo now refers
	to it. mercury_type_info.h cannot include mercury_typeclass_info.h
	without causing a circularity problem.

runtime/mercury_types.h:
	Move a bunch of typedefs of structs here from mercury_typeclass_info.h,
	again to avoid circularity problems.

runtime/mercury_typeclass_info.h:
	Remove the stuff moved to mercury_type_info.h and mercury_types.h.

	For now, do not include the code addresses of the procedure's
	representing an instance's methods in the instance structure,
	since the MLDS backend doesn't really have a notion of a generic code
	address, and even if it did it doesn't have an equivalent of the LLDS
	backend's code address to proc layout structure mapping, so the code
	addresses by themselves would be useless. (The code addresses needed
	for method calls are stored in the base_typeclass_info, not the
	instance structure.)

	When we want to start using information about instance methods
	in ways beyond what is afforded by the dictionary in the
	base_typeclass_info, we will need to revisit this decision, and will
	probably have to include the necessary information about the instance
	methods in the instance's data structure directly instead of via a
	pointer to the instance method implementations themselves.

runtime/mercury_type_info.h:
runtime/mercury_tags.h:
	Move a macro used to define enum constants that compiler generated code
	can refer to from mercury_type_info.h to mercury_tags.h (which already
	contains a similar macro whose definition is also dependent on
	--reserve-tag), since it is now also needed in mercury_proc_id.h.

runtime/mercury_proc_id.h:
	Use that macro define MR_PREDICATE and MR_FUNCTION, since the compiler
	now generates references to them.
2004-02-03 05:40:05 +00:00
Zoltan Somogyi
5e25af41f7 This diff changes the LLDS backend to make it easier to read and to maintain,
Estimated hours taken: 6
Branches: main

This diff changes the LLDS backend to make it easier to read and to maintain,
but contains no changes in algorithms whatsoever.

compiler/basic_block.m:
compiler/dupelim.m:
compiler/frameopt.m:
compiler/jumpopt.m:
compiler/layout_out.m:
compiler/livemap.m:
compiler/peephole.m:
compiler/reassign.m:
compiler/rtti_out.m:
compiler/use_local_vars.m:
	Convert these modules to our current coding standards. Use state
	variable notation when appropriate, reordering arguments as necessary.

compiler/llds_out.m:
	Convert these modules to our current coding standards. Use state
	variable notation when appropriate, reordering arguments as necessary.

	Delete predicates which are just specialized forms of foldl, using
	foldl (or foldl2 etc) directly instead.

	Factor out some common code.

compiler/livemap.m:
	Convert these modules to our current coding standards. Use state
	variable notation when appropriate, reordering arguments as necessary.

	Remove some special case handling that used to be required by the value
	numbering pass.

library/bintree_set.m:
	Provide a function version of the initialization predicate.
2003-11-11 03:35:13 +00:00
Zoltan Somogyi
666c4b785e Move toward the proposed structures for representing type class information at
Estimated hours taken: 32
Branches: main

Move toward the proposed structures for representing type class information at
runtime by adding code for generating the structures corresponding to
base_typeclass_infos. The structures corresponding to typeclass_infos will
be added in a later change.

Register the new data structures in a table at runtime.

Add four new mdb developer commands for checking the contents of the new
type class table, as well as the contents of the existing type constructor
table: class_decl, type_ctor, all_class_decls and all_type_ctors.

compiler/rtti.m:
	Add the data types required to represent the new runtime data
	structures that will eventually replace base_typeclass_infos
	inside the compiler.

	Add the required function symbols to the data types representing both
	the new RTTI data structures themselves and those representing
	references to them.

	Make the required changes to the predicates operating on the modified
	data types, and add some required new predicates.

compiler/rtti_out.m:
	Add code to write out the new data structures for the LLDS backend.

	Make some changes in existing predicates to allow them to be used
	in the new code.

compiler/layout_out.m:
	Factor out some code that is now common with rtti_out.m.

compiler/type_class_info.m:
	A new module to generate the new RTTI data structures.

compiler/backend_libs.m:
	Include the new module.

compiler/options.m:
	Add a new option, --new-type-class-rtti, to control whether we
	invoke the top level predicate of type_class_info.m to generate
	the new type class RTTI structures. We still generate and use
	base_typeclass_infos regardless of the value of this option.

compiler/mercury_compile.m:
	Invoke the code of the new module if --new-type-class-rtti is given.

compiler/opt_debug.m:
	Add code to dump descriptions of the new rtti_ids.

compiler/mlds_to_gcc.m:
compiler/rtti_to_mlds.m:
	Handle the new alternatives in the rtti data types, mostly by throwing
	exceptions. The actual code should be written later by Fergus.

compiler/pseudo_type_info.m:
	Module qualify the names of builtin types when generating
	pseudo-typeinfos for them. This makes the naming scheme more regular.

compiler/base_typeclass_info.m:
compiler/notes/type_class_transformation.html:
	Document the impending obsolescence of these files.

compiler/notes/work_in_progress.html:
	List type class RTTI as work in progress.

library/list.m:
	Add a utility predicate for use by compiler/rtti_out.m.

runtime/mercury_typeclass_info.h:
	Make some changes in the C data types representing type class
	information that I discovered to be necessary or advantageous
	in the process of generating values of those types automatically.

	Rename some types to make their names be better documentation.

	Change some arrays of pointers to structures into arrays of structures,
	where the structures at different array indexes are the same size.

	Removing consts that rtti_out.m supplies automatically avoids
	duplicate const errors from the C compiler.

	Add #includes to make the file namespace clean.

	Protect against multiple inclusion.

runtime/mercury_typeclass_info_example.c:
	Remove this file. After the changes to mercury_typeclass_info.h, its
	contents are no longer correct examples of the structures in
	mercury_typeclass_info.h, and since the compiler can now generate
	those structures automatically, hand-written examples no longer serve
	any useful pupose.

runtime/mercury_types.h:
	Add a new type, MR_CodePtr, for use in mercury_typeclass_info.h.
	The compiler predicate tc_rtti_name_type wants single-word names
	for types.

runtime/mercury_imp.h:
	#include mercury_typeclass_info.h.

runtime/mercury_type_tables.[ch]:
	Add functions to register and to look up type class declarations and
	type class instances.

	Add the functions and data structures required to look up all type
	constructors and all type classes. The debugger uses these to support
	the commands that let the programmer check the contents of these
	tables.

	Eventually, we should be able to use the type class tables to test
	whether a vector of types is a member of a given type class.

runtime/mercury_wrapper.c:
runtime/mercury_type_info.[ch]:
	Move the array of type_ctor_rep names from the mercury_wrapper module
	to the mercury_type_info module, and make it always-defined and public;
	the debugger also needs access to it now.

runtime/Mmakefile:
	Add mercury_typeclass_info.h to the list of header files that other
	files depend on.

trace/mercury_trace_internal.c:
	Add four new mdb commands: class_decl, type_ctor, all_class_decls
	and all_type_ctors.

	Make some existing code follow our coding conventions.

doc/user_guide.texi:
doc/mdb_categories:
	Document the four new mdb commands.

doc/reference_manual.texi:
	Document (in a comment) the compiler's reliance on each type in an
	instance declaration containing exactly one type constructor.

tests/debugger/class_decl.{m,inp,exp}:
	A new test case to test the new mdb commands.

tests/debugger/Mmakefile:
tests/debugger/Mercury.options:
	Add the new test case.

tests/debugger/completion.exp:
	Expect the new commands to appear in the command name completion.

tests/debugger/mdb_command_test.inp:
	Test the documentation of the new mdb commands.
	Expect the new commands to appear in the command name completion.
2003-10-23 02:02:45 +00:00
Fergus Henderson
1857be978f Fix a bug where we were generating invalid C code which resulted
Estimated hours taken: 1
Branches: main

Fix a bug where we were generating invalid C code which resulted
in compilation errors when compiling with lcc.  This bug showed up for
tests/dppd/run.m.

compiler/rtti_out.m:
	Ensure that we do not output "{}" as an initializer,
	since ISO C does not support empty initializers.
	Instead, output an initializer with a dummy element (0),
	with a comment explaining why.
2003-08-14 06:13:48 +00:00
Zoltan Somogyi
13bc17e046 Allow the compiler to generate type_ctor_infos for builtin and implementation
Estimated hours taken: 2
Branches: main

Allow the compiler to generate type_ctor_infos for builtin and implementation
artifact types if they are declared as foreign types with user-defined unify
and compare preds.

compiler/rtti.m:
	Define the full list of builtin and implementation artifact types
	(including robdds, which should be added shortly, and subgoals, which
	already exist, but don't yet have their own type_ctor_rep).
	Map them to their respective (possibly future) type_ctor_reps.

compiler/type_ctor_info.m:
	Recognize builtin and implementation artifact types if we encounter a
	foreign type declaration for them.

compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
	Add code to generate type_ctor_infos for builtin and implementation
	artifact types, if they are declared as foreign types.
2003-05-14 00:10:03 +00:00
Zoltan Somogyi
66eb5b46e4 Fix two related anomalies. One was that base_typeclass_infos were being
Estimated hours taken: 6
Branches: main

Fix two related anomalies. One was that base_typeclass_infos were being
created using the fcailities of rtti.m, but they were being referred to
using data_addr, not rtti_addr, in the LLDS backend, and they had similar
special treatment in the MLDS backend. The second is the special treatment of
base_typeclass_infos within rtti.m, rtti_out.m and rtti_to_mlds.m, due
to the fact that unlike the other data structures defined in rtti.m,
their id does not include an rtti_type_ctor. When we move over to the
proposed data structures for representing type class and instance
information, base_typeclass_infos won't be alone in not including
an rtti_type_ctor in their id.

compiler/rtti.m:
	Introduce the notion of an rtti_id, which includes an rtti_type_ctor
	only for references to data structures for which that is appropriate.

compiler/llds.m:
compiler/mlds.m:
	Delete the redundant data_name base_typeclass_info.

	Use rtti_ids where appropriate.

compiler/llds_out.m:
	Delete the code handling the deleted data_name base_typeclass_info.

	Conform to the changes to rtti.m and llds.m.

compiler/ll_pseudo_type_info.m:
compiler/ml_closure_gen.m:
compiler/ml_unify_gen.m:
compiler/ml_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
compiler/opt_debug.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/stack_layout.m:
compiler/unify_gen.m:
	Conform to the changes above, which in several cases allows us to
	eliminate the special handling of base_typeclass_infos.

compiler/base_typeclass_info.m:
	Follow up on an old XXX, and make a predicate tail recursive.
2003-05-09 00:45:13 +00:00
Zoltan Somogyi
7d13819073 Change the order of the arguments of decl_set_insert, to make it
Estimated hours taken: 0.2
Branches: main

compiler/llds_out.m:
	Change the order of the arguments of decl_set_insert, to make it
	possible to user state variable notation for decl_sets.

compiler/layout_out.m:
compiler/rtti_out.m:
	Conform to the above change.
2003-04-19 05:52:03 +00:00
Zoltan Somogyi
1cb657b998 Reduce inappropriate dependencies on ll_backend modules.
Estimated hours taken: 3
Branches: main

Reduce inappropriate dependencies on ll_backend modules. Except for
simplification of unnecessarily complicated logic in dependency_graph.m,
this change only moves functionality around.

compiler/llds_out.m:
compiler/c_util.m:
compiler/name_mangle.m:
	Move predicates that are used by multiple backends from
	ll_backend__llds_out to backend_libs__c_util and to a new module
	backend_libs__name_mangle. Make the relevant ones functions,
	and give some of them more meaningful names.

compiler/trace.m:
compiler/hlds_goal.m:
	Move a backend-independent predicate from ll_backend__trace
	to hlds__hlds_goal.

compiler/llds.m:
compiler/trace_params.m:
	Move the definition of the trace_port type from ll_backend__llds
	to libs__trace_params to avoid having libs__trace_params depend on
	ll_backend.

compiler/exprn_aux.m:
compiler/globals.m:
	Move the definition of the imported_is_constant from
	ll_backend__exprn_aux to libs__globals to avoid having libs__globals
	depend on ll_backend.

compiler/*.m:
	Conform to the above changes. This removes many inappropriate
	dependencies on the LLDS backend.
2003-03-16 08:01:31 +00:00
Zoltan Somogyi
9551640f55 Import only one compiler module per line. Sort the blocks of imports.
Estimated hours taken: 2
Branches: main

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

	In a couple of places, remove unnecessary imports.
2003-03-15 03:09:14 +00:00
Zoltan Somogyi
34a278b75b Add a facility for recording boolean flags in the RTTI structures
Estimated hours taken: 4
Branches: main

Add a facility for recording boolean flags in the RTTI structures
of type constructors. At the moment, the only flag records whether
the type constructor has a tag value reserved for HAL variables.
The flag is not used yet.

runtime/mercury_type_info.h:
	Add the extra field if MR_TYPE_CTOR_INFO_HAS_FLAG is defined.
	(The #ifdef will be deleted once bootstrapping is complete.)

runtime/mercury_mcpp.h:
	Add the extra field, since it will be needed after bootstrapping.

compiler/llds_out.m:
compiler/mlds_to_c.m:
	Define MR_TYPE_CTOR_INFO_HAS_FLAG for bootstrapping.

compiler/rtti.m:
	Add the field to the backend-independent RTTI description of
	type_ctor_infos, together with its encoding function.

compiler/type_ctor_info.m:
	Gather the information about the flags, for use when constructing
	the RTTI structure.

compiler/rtti_out.m:
	Add the flag field to the type_ctor_info structure for the LLDS backend.

compiler/rtti_to_mlds.m:
	Add the flag field to the type_ctor_info structure for the MLDS
	backends.

compiler/mlds_to_gcc.m:
	Add the flag field to the type_ctor_info structure for the gcc backend.

library/rtti_implementation.m:
	Add the flag field to list of fields of the type_ctor_info structure.
2003-02-26 06:37:01 +00:00
Zoltan Somogyi
7a69508ddf Fix a bug that caused duplicate symbol definitions with --split-c-files.
Estimated hours taken: 6
Branches: main

Fix a bug that caused duplicate symbol definitions with --split-c-files.

compiler/ll_pseudo_type_info.m:
	Represent type_ctor_infos directly; do not misrepresent them as arity
	zero pseudo_type_infos, even if they do have the same memory layout.

compiler/llds_out.m:
	Allow the caller to ask for static declarations even with
	--split-c-files.

compiler/rtti_out.m:
	Ask llds_out.m to generate static declarations even with
	--split-c-files. The data structures affected by this are typeinfos
	and pseudotypeinfos. With --split-c-files, we now generate a copy
	of a typeinfo or a pseudotypeinfo in each C file that refers to that
	typeinfo or pseudotypeinfo, rather than one per Mercury module.
	This will increase the size of the split archive, but only minimally.
2002-08-08 08:15:46 +00:00
Zoltan Somogyi
404abb0c57 Another step towards RTTI in Mercury.
Estimated hours taken: 32
Branches: main

Another step towards RTTI in Mercury.

This step redefines the representation of type_ctor_infos inside the compiler
to be identical to the representation we will need for efficient interpretation
of RTTI data structures in Mercury, following on from an earlier step which
did the same for (pseudo)typeinfos.

Instead of the type_ctor_info being broken down into its components in
type_ctor_info.m, the breakdown process is now performed in rtti_out.m (for the
LLDS backend) and rtti_to_mlds.m (for the MLDS backend). Eventually, the IL and
Java backends will stop using rtti_to_mlds.m for this purpose, and will instead
write out the type_ctor_data structures as static data to be interpreted
directly.

We now predefine the C types representing type_info and pseudo_type_infos
for types of arity up to 20 for the LLDS C backend as well as for the
MLDS C backend. The LLDS backend can define them for higher arities
on demand; the MLDS backend (for now) still cannot.

runtime/mercury_type_info.h:
	To be able to represent all the kinds of types we now support

	- add a data structure for converting values of reserved_addr types
	  from their printable representation to their internal representation
	  (it was previously missing), and

	- add a type_ctor_rep to represent foreign types.

	Add missing MR_ prefixes on some field names.

	Add typedefs for all the types that the rtti_names can refer to.
	There were already such typedefs in runtime/mercury.h for the MLDS
	grades, we now have them for the LLDS grades too.

	Predefine the C types representing type_info and pseudo_type_infos
	for types of arity up to 20. There were already such typedefs in
	runtime/mercury.h for the MLDS grades, we now have them for the
	LLDS grades too.

runtime/mercury.h:
	Delete the typedefs that are now in mercury_type_info.h.

runtime/mercury.h:
	Delete the definitions of the C types representing type_info and
	pseudo_type_infos, since these are now in mercury_type_info.h.
	#include mercury_type_info.h.

compiler/rtti.m:
	Add new, purely Mercury data structures for representing
	type_ctor_infos and their components, designed both for efficient
	interpretation and as a source for the generation of static data
	structures in C.

	This entailed deleting most of the alternatives of the rtti_data type
	while preserving their rtti_name equivalents; the deleted alternatives
	represent tables are no longer created in type_ctor_info.m but which
	are created dynamically in rtti_out.m and rtti_to_mlds.m (which need
	a way for one table to refer to another).

	Centralize the correspondence between rtti_names and the C and Java
	types of the corresponding structures (the C and Java names differ in
	prefixes only). Among other things, this remove the double maintenance
	problem we have previously with the LLDS and MLDS backends maintaining
	their own maps of the correspondence.

	Add utility predicates on the new data structures for use by both
	rtti_out.m and rtti_to_mlds.m.

compiler/hlds_module.m:
	Always store the ids of unification and comparison procedures in
	type_ctor_gen_infos, to simplify their handling.

compiler/type_ctor_info.m:
	Generate the new data structures for representing type_ctor_infos.

	Conform to the changed data structures for type_ctor_gen_infos.

compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
	Rewrite substantial parts of these modules to convert the new data
	structures for representing type_ctor_infos to sets of discrete
	structures dynamically.

	Most of the dynamically created structures are unique by construction,
	but this is not true for typeinfos and pseudo-typeinfos. Therefore
	add mechanisms to ensure that we don't generate redundant structures
	representing typeinfos and pseudo-typeinfos.

compiler/mlds_to_c.m:
compiler/mlds_to_java.m:
	Use the standard mechanisms for creating C and Java type names.

compiler/mlds_to_gcc.m:
	Conform to the changed data structures in rtti.m and
	mercury_type_info.h.

compiler/opt_debug.m:
	Conform to the changed data structures in rtti.m.

compiler/dead_proc_elim.m:
	Conform to the changed data structures for type_ctor_gen_infos.

compiler/pseudo_type_info.m:
	Add a predicate to construct a representation of a type that may or may
	not be ground.

compiler/mlds_to_gcc.m:
java/runtime/TypeCtorRep.java:
library/private_builtin.m:
library/rtti_implemenation.m:
runtime/mercury_mcpp.{cpp,h}:
	Add the type_ctor_rep for foreign types to the lists of type_ctor_reps.

library/construct.m:
library/deconstruct.m:
	Add missing MR_ prefixes on field names.

runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.c:
runtime/mercury_type_info.c:
runtime/mercury_unify_compare_body.h:
	Handle the type_ctor_rep for foreign types.

	Add missing MR_ prefixes on field names.

library/list.m:
	Add two utility predicates, is_empty and is_not_empty, for use with
	higher order code.

NEWS:
	Mention the new predicates in list.m. Delete a duplicate entry.
2002-08-01 11:52:29 +00:00
Zoltan Somogyi
f3c564e512 Fix test case failures involving type_ctor_descs in .rt grades.
Estimated hours taken: 6
Branches: main

Fix test case failures involving type_ctor_descs in .rt grades.

The cause of the failures was that the type_ctor_rep for type_ctor_descs (which
happens to be 35) does not fit into a signed 8-bit integer in .rt grades,
since those grade require 2 bits for a primary tag (3 bits on 64-bit machines).

The fix is to make the type_ctor_rep field in type_ctor_infos 16 bits in size.
To maintain alignment, this requires swapping that field with the num_ptags
field.

The second part of this change will remove the bootstrapping code and raise
the binary compatibility version number. That part cannot be committed until
this part has been installed on all our machines.

runtime/mercury_type_info.h:
	Define a new version of the type_ctor_info structure with this swap
	and size increase. Provide backward compatibility for bootstrapping.

runtime/mercury_mcpp.h:
library/rtti_implementation.m:
java/runtime/TypeCtorInfo_Struct.m:
	Make the same change.

compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/mlds_to_gcc.m:
	Generate the new type_ctor_info structure.

compiler/llds_out.m:
compiler/mlds_to_c.m:
	Generate a macro that selects the new version of the type_ctor_info
	structure.

compiler/type_ctor_info.m:
	Update the type_ctor_info version number.
2002-04-24 07:37:38 +00:00
Zoltan Somogyi
48531cda3d Cast the elements of the vectors inside TypeInfos and PseudoTypeInfos
Estimated hours taken: 1
Branches: main

compiler/rtti_out.m:
	Cast the elements of the vectors inside TypeInfos and PseudoTypeInfos
	to the right type, to shut up warnings. Do so systematically, instead
	of as a special hack for PseudoTypeInfos. (We cannot avoid casts
	altogether, because we want TypeCtorInfos to be acceptable as both
	TypeInfos and as PseudoTypeInfos.)
2002-04-17 05:31:37 +00:00
Zoltan Somogyi
43fbf4b956 A step towards RTTI in Mercury.
Estimated hours taken: 40
Branches: main

A step towards RTTI in Mercury.

This step redefines the representation of pseudo-typeinfos inside the compiler
to be identical to the representation we will need for efficient interpretation
of RTTI data structures in Mercury. Later steps will do likewise for
typectorinfos. In the end, we will have two implementations of RTTI:
the current low-level, very efficient one written in C, which will be used
by the C backends (both LLDS and MLDS), and a new, higher-level one
which will use Mercury data structures and Mercury predicates for
interpretation (along the lines of library/rtti_implementation.m)
for the Java and IL backends.

A large part of this change concerns the fact that pseudo-typeinfos can now
contain typeinfos as well as other pseudo-typeinfos, and they do in the
frequent case that the type of an argument is ground. Given that typeinfos
are just special cases of pseudo-typeinfos, the code for handling the two
types is usually similar, with common code factored out when relevant.

In the process of redesigning the data structures concerning (pseudo-)
typeinfos, I also fixed an old naming scheme that has become misleading.
The representation of a (pseudo-) typeinfo depends on whether the principal
type constructor is fixed arity or not. We used to denote this distinction
with the phrases first-order vs higher-order, since at first the only variable
arity type constructors were pred and func. However, this hasn't been true
since we added tuples. I have changed the naming scheme to be fixed-arity vs
variable-arity.

compiler/rtti.m:
	Add new, purely Mercury data structures for representing typeinfos
	and pseudo-typeinfos, designed both for efficient interpretation
	and as a source for the generation of static data structures in C.

compiler/pseudo_type_info.m:
	Delete the type definitions here, since they are superseded by the new
	definitions in rtti.m.

	Add predicates for constructing typeinfos as well as pseudo-typeinfos,
	since now we need those too.

	Conform to the changed data structures for (pseudo-) typeinfos.

compiler/ll_pseudo_type_info.m:
compiler/ml_closure_gen.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/opt_debug.m:
compiler/type_ctor_info.m:
	Conform to the changed data structures for (pseudo-) typeinfos.

compiler/mlds.m:
	Since the MLDS now refers to type_infos, add their type
	(mlds__type_info_type) to the list of types the MLDS knows about.

compiler/ml_code_util.m:
compiler/mlds_to_c.m:
compiler/mlds_to_il.m:
compiler/mlds_to_java.m:
	Handle mlds__type_info_type.

compiler/mlds_to_gcc.m:
	Conform to the changed data structures for (pseudo-) typeinfos,
	and handle mlds__type_info_type.

runtime/mercury_bootstrap.h:
	Override the compiler-generated names of the type_ctor_infos of the
	variable arity type constructors. The MLDS backend requires these
	to be module qualified; the LLDS backend requires them to be
	unqualified. This is a problem because the same code now generates
	the compiler's internal representation of pseudo-typeinfos for both
	backends.

	The temporary solution is to have the compiler generate these names
	module qualified, and have these macros convert them to the unqualified
	form. (The long term solution should be to always module qualify
	everything, but doing that is for another change.)

runtime/mercury_type_info.h:
	Change the naming scheme from first order vs higher order to fixed
	arity vs variable arity.

library/construct.m:
library/deconstruct.m:
runtime/mercury.c:
runtime/mercury_construct.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_make_type_info_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.c:
runtime/mercury_type_desc.c:
runtime/mercury_type_info.c:
runtime/mercury_unify_compare_body.h:
	Conform to the new naming scheme.

runtime/mercury.h:
	Conform to the new naming scheme.

	Declare fixed and variable arity types for typeinfos as well as
	pseudo-typeinfos, since pseudo-typeinfos can now refer to typeinfos.
2002-04-12 01:24:25 +00:00
Fergus Henderson
7597790760 Use sub-modules to structure the modules in the Mercury compiler directory.
The main aim of this change is to make the overall, high-level structure
of the compiler clearer, and to encourage better encapsulation of the
major components.

compiler/libs.m:
compiler/backend_libs.m:
compiler/parse_tree.m:
compiler/hlds.m:
compiler/check_hlds.m:
compiler/transform_hlds.m:
compiler/bytecode_backend.m:
compiler/aditi_backend.m:
compiler/ml_backend.m:
compiler/ll_backend.m:
compiler/top_level.m:
	New files.  One module for each of the major components of the
	Mercury compiler.  These modules contain (as separate sub-modules)
	all the other modules in the Mercury compiler, except gcc.m and
	mlds_to_gcc.m.

Mmakefile:
compiler/Mmakefile:
	Handle the fact that the top-level module is now `top_level',
	not `mercury_compile' (since `mercury_compile' is a sub-module
	of `top_level').

compiler/Mmakefile:
	Update settings of *FLAGS-<modulename> to use the appropriate
	nested module names.

compiler/recompilation_check.m:
compiler/recompilation_version.m:
compiler/recompilation_usage.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
compiler/recompilation.version.m:
	Convert the `recompilation_*' modules into sub-modules of the
	`recompilation' module.

compiler/*.m:
compiler/*.pp:
	Module-qualify the module names in `:- module', `:- import_module',
	and `:- use_module' declarations.

compiler/base_type_info.m:
compiler/base_type_layout.m:
	Deleted these unused empty modules.

compiler/prog_data.m:
compiler/globals.m:
	Move the `foreign_language' type from prog_data to globals.

compiler/mlds.m:
compiler/ml_util.m:
compiler/mlds_to_il.m:
	Import `globals', for `foreign_language'.

Mmake.common.in:
trace/Mmakefile:
runtime/Mmakefile:
	Rename the %.check.c targets as %.check_hdr.c,
	to avoid conflicts with compiler/recompilation.check.c.
2002-03-20 12:37:56 +00:00
Zoltan Somogyi
41a27af862 Change type_id to the more descriptive type_ctor everywhere.
Estimated hours taken: 6
Branches: main

compiler/*.m:
	Change type_id to the more descriptive type_ctor everywhere.
2002-03-07 08:30:28 +00:00
Zoltan Somogyi
b5c571c500 This is the first half of a change that removes redundant fields from
Estimated hours taken: 12
Branches: main

This is the first half of a change that removes redundant fields from
type_ctor_info structures.

configure.in:
	Do not require an exact match on the RTTI version number.

runtime/mercury_type_info.h:
	Update the RTTI version number.

	Add the new definition of type_ctor_infos.

	Add prefixes to the fields in type_ctor_infos that did not already have
	them.

	Provide macros to access the fields in the changed part of
	type_ctor_infos in a way that works with both the old and new
	type_ctor_info structures.

	Move some stuff so that macros that logically belong together are next
	to each other.

runtime/mercury_mcpp.h:
	Update the RTTI version number and the macros for defining
	type_ctor_infos.

library/rtti_implementation.m:
	Update the mechanism for access to type_ctor_info fields.

	Add prefixes to field names and use RTTI-version-independent macros
	as necessary.

compiler/hlds_module.m:
compiler/rtti.m:
	Delete obsolete fields from the terms from which type_ctor_info
	structures are derived.

compiler/dead_proc_elim.m:
	Minor changes to conform to this change in data structure.

compiler/type_ctor_info.m:
	Minor changes to conform to this change in data structure.
	Update the RTTI version number.

compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
	Output the new type_ctor_info structure.

compiler/llds_out.m:
compiler/mlds_to_c.m:
	Emit a #define to select the new type_ctor_info structure.

library/std_util.m:
runtime/mercury.c:
runtime/mercury_deconstruct.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_ho_call.c:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.c:
runtime/mercury_type_info.c:
runtime/mercury_type_tables.c:
runtime/mercury_unify_compare_body.h:
tests/hard_coded/type_tables.m:
trace/mercury_trace.c:
	Add prefixes to field names and use RTTI-version-independent macros
	as necessary.
2002-01-25 08:23:39 +00:00
Zoltan Somogyi
22f3d4ef9f This is the first half of a change that reduces the size of type_ctor_info
Estimated hours taken: 20
Branches: main

This is the first half of a change that reduces the size of type_ctor_info
structures, and moves the version number to the start (immediately after the
arity) to make future changes easier.

The second half can be committed only when the first half has been installed
on all our machines.

Note that when this change is installed on a machine, you will need to do a cvs
update in every workspace that uses that machine's installed compiler before
being able to continue working with that workspace. This is because the
compiler will generate the new MR_TypeCtorInfo structure, and you will get C
compiler errors if your runtime still contains a declaration only for the old
one.

Doing a cvs update after this change is checked but before it is installed
should be OK.

runtime/mercury_type_info.h:
	Define the new version of the type_ctor_info structure while keeping
	the old one temporarily; the presence of a macro definition, which
	is emitted only by new compiler versions, selects the new version.

	Increment the maximum supported rtti version number.

	Remove some obsolete stuff, and move some macro definitions to their
	proper place in the file.

	Define a macro to allow access to the type_ctor_rep field regardless
	of version.

	Define a macros to allow the declaration of type_ctor_info structures
	regardless of version.

runtime/mercury_ho_call.h:
	With the new type_ctor_info structures, take the address of the
	unify procedure from the new unify field, since the old one has
	been reused for other purposes.

compiler/type_ctor_info.m:
	Increment the rtti version number.

compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
	Generate the new type_info structure.

compiler/llds_out.m:
compiler/mlds_to_c.m:
	Generate a macro definition that selects the new type_ctor_info
	for use, since that is what we are generating.

library/rtti_implementation.m:
library/std_util.m:
runtime/mercury.c:
runtime/mercury_deep_copy_body.h:
runtime/mercury_make_type_info_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_tabling.c:
runtime/mercury_type_info.c:
runtime/mercury_unify_compare_body.h:
runtime/mercury_wrapper.c:
	Use the version-independent macro to access the type_ctor_rep field.

library/table_builtin.m:
	Use the version-independent macro to declare type_ctor_infos.
2001-12-31 04:26:54 +00:00
Fergus Henderson
def21a3675 Add RTTI support for the new reserved address data representations.
Estimated hours taken: 18
Branches: main

Add RTTI support for the new reserved address data representations.

runtime/mercury_type_info.h:
runtime/mercury_mcpp.h:
runtime/mercury.h:
library/private_builtin.m:
library/rtti_implementation.m:
	Add MR_TYPECTOR_REP_RESERVED_ADDR (with and without _USEREQ) to
	the MR_TypeCtorRep enum, for discriminated union types containing
	one or more functors represented using reserved addresses,
	and add new RTTI structs to hold information about how such
	types are represented.

compiler/type_ctor_info.m:
compiler/mlds_to_gcc.m:
compiler/opt_debug.m:
compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
	Add appropriate code to generate these new RTTI structs.

runtime/mercury_deep_copy_body.h:
runtime/mercury_ml_expand_body.h:
runtime/mercury_unify_compare_body.h:
runtime/mercury_tabling.c:
library/std_util.m:
	Add code to handle the MR_TYPECTOR_REP_RESERVED_ADDR alternative,
	using the information in the new RTTI structs.
2001-10-24 07:43:25 +00:00
David Jeffery
19ceeaf30f Merge the changes from the HAL branch onto the main branch.
Estimated hours taken: 40
                       (to do this merge... 100s of hours on the HAL branch
		        itself by myself and Warwick Harvey though).

Merge the changes from the HAL branch onto the main branch. With the recent
changes made to the HAL implementation, this means adding just one grade,
`.rt' or --reserve-tag, which reserves one tag (zero) in each type for
use by HAL's Herbrand constraint solver. This disables no-tag types and
enumerations.

This grade will now bootstrap, and passes all tests, except for a few failing
cases in the debugger and tabling directories.

compiler/options.m:
compiler/handle_options.m:
	Add the `.rt' or --reserve-tag grade option.
runtime/mercury_conf_param.h:
	Document the macro MR_RESERVE_TAG
doc/user_guide.texi:
	Document the `.rt' grade.

compiler/make_hlds.m:
	Don't record any types as no-tag types if we are in a .rt grade.
compiler/make_tags.m:
compiler/type_ctor_info.m:
	Allocate tags starting from `1' in .rt grades.
compiler/rtti_out.m:
	In .rt grades, output a dummy ptag definition for tag `0'.
compiler/type_util.m:
	Add predicates `type_util__constructors_are_dummy_argument_type' and
	`type_constructors_are_type_info' for use when allocating tags to
	ensure that type infos and dummy types (io__state/0 and store__store/1)
	are still treated as no-tag types in .rt grades.

library/sparse_bitset.m:
	When allocating a sparse bitset element, use tag `1' if we are in a
	.rt grade.

runtime/mercury_tags.h:
	Define a macro `MR_UNIV_TAG' which is `1' is we in a .rt grade and
	`0' otherwise. (Now that univ is a user defined type, it is a also
	assigned a `var' tag).
	Also make the definitions of MR_RAW_TAG_NIL and MR_RAW_TAG_CONS take the
	.rt grade into account.
runtime/mercury_type_info.h:
	Define `MR_unravel_univ' and
	`MR_initialise_univ' for taking apart and putting together univs.

	Add a new secondary tag alternative: MR_SECTAG_VARIABLE, used to
	represent Herbrand variables.

library/std_util.m:
	Use MR_UNIV_TAG, MR_unravel_univ and MR_initialise_univ when
	manipulating univs.

	Handle the new MR_SECTAG_VARIABLE secondary tag by aborting.

runtime/mercury_deep_copy_body.h:
runtime/mercury_tabling.c:
runtime/mercury_unify_compare_body.h:
	Handle the new MR_SECTAG_VARIABLE secondary tag by aborting.

library/std_util.m:
	Add a constant for MR_SECTAG_VARIABLE in the MC++ back end.

scripts/canonical_grade.sh-subr:
scripts/init_grade_options.sh-subr:
scripts/mgnuc.in:
scripts/parse_grade_options.sh-subr:
	Process the new grade.

scripts/mmake.in:
	Add an option `--include-makefile', which includes a Makefile given
	as a command line argument into the Makefile generated by mmake.
	This is used to implement `halmake', a make program for HAL which
	just passes a bunch of extra rules and variable definitions onto
	mmake.

tests/debugger/existential_type_classes.m:
tests/hard_coded/existential_types_test.m:
trace/mercury_trace_declarative.c:
trace/mercury_trace_external.c:
trace/mercury_trace_internal.c:
	Use MR_UNIV_TAG.

TODO:
	- The declarative debugger falls over in .rt grades. This is possibly
	  because compiler/static_term.m assumes that the generated code uses
	  the same data representation as the compiler itself. This should be
	  fixed, although it is not critical; the declarative debugger won't
	  work with trailing as is, and the .rt grade is only ever used in
	  conjunction with trailing (.tr) at this stage.
2001-03-18 23:10:17 +00:00
Zoltan Somogyi
2498d9d3fd Instead of generating the layout structures of labels, procs and modules
Estimated hours taken: 36

Instead of generating the layout structures of labels, procs and modules
as rvals, generate them almost entirely as C structures. This will make
future modifications much easier, since mismatches between what the runtime
expects and what the compiler generates will now be pointed out by the C
compiler. (It also reduces the size of the C source files generated with
debugging enabled by about 5%.) Layout structures contain a few components
that are not well-typed in C; we continue to generate these as rvals.

Closure layout structures used to have a well-typed part and a non-well-typed
part. We now generate the well-typed part as a separate structure, pointed to
from the other. We also extend the well-typed part, so that instead of
just giving the name the called procedure, it also identifies the source
location where the closure was constructed. This could be useful for
the debugger and for deep profiling.

This diff also includes a change to get the compiler to bootstrap with lcc
in grade none.gc.debug.tr: initializing the string tables in module layouts
not as a string but as an array of characters.

runtime/mercury_stack_layout.h:
	Reorganize the definitions of layout structures. Rename
	Stack_Layout_Entry structures as Proc_Layout structures,
	and Stack_Layout_Label structures as Label_Layout structures.
	(The debugger paper refers to the structures by the new names.)
	Fold the Stack_Layout_Vars structure into the structure that contains
	it, the Label_Layout structure. Add a Closure_Id structure that
	contains a Proc_Id structure as well as extra information identifying
	the source location where the closure was created.

	Create "short" versions of the Proc_Layout structures, which contain
	only the first one or two of the three groups of fields. Previously,
	the Mercury compiler would define new C types when it generated such
	short structures. Since we are not defining new C types anymore, there
	must be a C type for every kind of structure the Mercury compiler can
	generate. We now also have separate variants for the layouts of
	user-defined and compiler-generated procedures, since the format
	of their procedure id information is different. While the runtime
	system refers to their procedure id information through a union,
	the C types of the structures generated by the Mercury compiler
	do not use a union, since a union cannot be initialized through
	its second member.

	Make the constant fields of structures const, since we now generate
	values of those structure types, and initialize them with constant
	data.

	Move the documentation of layout structures here from stack_layout.m.

runtime/mercury_ho_call.h:
	Instead of bodily including an MR_Proc_Id structure in closures,
	include a pointer to the more detailed MR_Closure_Id structure.

runtime/mercury_accurate_gc.c:
runtime/mercury_agc_debug.c:
runtime/mercury_init.h:
runtime/mercury_label.[ch]:
runtime/mercury_layout_util.[ch]:
	Minor updates to conform to changes in mercury_stack_layout.h.

runtime/mercury_goto.h:
	Use separate naming schemes for label layout structures and proc layout
	structures.

library/exception.m:
	Minor updates to conform to changes in mercury_stack_layout.h.

compiler/layout.m:
	A new module that defines data structures for label, proc and module
	layout structures and for closure id structures.

compiler/layout_out.m:
	A new module that converts the Mercury data structures of layout.m into
	declarations and definitions of C data structures.

compiler/stack_layout.m:
	Generate the new layout structures instead of rvals.

	Move the documentation of layout structures from here to
	runtime/mercury_stack_layout.h, since this module is no longer
	aware of some of their details.

compiler/llds.m:
	Make layout structures a separate kind of compiler-generated data.

compiler/llds_out.m:
	Remove the code for the output of layout structures; call layout_out.m
	instead.

compiler/llds_out.m:
compiler/rtti_out.m:
	Turn some predicates into functions.

compiler/code_gen.m:
compiler/code_info.m:
compiler/llds.m:
compiler/mercury_compile.m:
compiler/unify_gen.m:
	Instead of handling closure layouts like other static data, handle
	them separately. Add a counter to the code_info structure in order
	to allow closure id structures to be identified uniquely by a pair
	consisting of the id of the procedure that generates them and a closure
	sequence number within that procedure.

compiler/llds_common.m:
	Look for common rvals among the rvals in layout structures.

compiler/opt_debug.m:
	Generate developer-friendly names for layout structure references.

browser/dl.m:
	Update the code for constructing closure layouts.
2001-01-18 01:19:17 +00:00
Zoltan Somogyi
50f1674dd5 In mdb's print and browse commands, allow the field to be printed to be
Estimated hours taken: 8

In mdb's print and browse commands, allow the field to be printed to be
specified by name as well as by number. This required extending the RTTI
for notag types to record field names.

trace/mercury_trace_vars.m:
	Allow the field to be printed to be specified by name as well as by
	number.

library/std_util.m:
	Add code to find out whether a term has a field with a given name,
	and if yes, which field that is. At the moment, this functionality
	is accessible only from C. (There is no point to adding to the
	user-visible interface before a redesign of that interface.)

	Fix an old bug: ML_arg() was not compensating for the extra type_info
	and/or typeclass_info arguments inserted at the start of a cell for
	functors with existentially typed arguments. Document the ML_expand
	data structure better to make that bug less likely in the future.

runtime/mercury_type_info.h:
	Add an extra field to the type for notag type functors, recording
	the field name of the argument, if it has one.

compiler/rtti.m:
	Add a maybe-argument-name field to the record for notag types.

compiler/type_ctor_info.m:
	Record the name of the single argument of the single functor of a
	notag type, if it has one.

compiler/type_util.m:
	Make that argument name available.

compiler/rtti_out.m:
	Print out that argument name.

compiler/make_tags.m:
compiler/make_hlds.m:
compiler/rtti_to_mlds.m:
	Ignore that argument name.

tests/debugger/field_names.{m,inp,exp}:
	A new test case to test the printing of subterms specified by field
	numbers and/or names.

tests/debugger/Mmakefile:
	Enable the new test case.
2000-12-18 07:43:05 +00:00
Fergus Henderson
c3306e4708 When generating RTTI for constructors with no arguments, don't
Estimated hours taken: 1.5

compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/type_ctor_info.m:
	When generating RTTI for constructors with no arguments, don't
	generate empty `field_types' arrays; not all C compilers
	support empty array initializers.  Instead, if there are no
	arguments, just use a null pointer.

	This is slightly more efficient than the previous approach to
	this problem which was to generate an array containing a
	single dummy element.  With this approach, we generate a null
	pointer rather than a pointer to an array containing a null pointer.

	The other advantage of this change is that it makes the
	treatment of the `field_types' array consistent with how we
	treat the `field_names' array.
2000-11-15 14:00:17 +00:00
Fergus Henderson
e6769ef622 Record the module that each instance declaration came from.
Estimated hours taken: 8

Record the module that each instance declaration came from.
This is needed for the IL back-end, which includes that
module name in the symbol name that it generates for each
instance declaration.

compiler/prog_data.m:
	Add a module_name field to the `instance' item.

compiler/prog_io_typeclass.m:
	When parsing `instance' declarations, store the
	module name that they came from in the module_name field
	of the `instance' item.

compiler/hlds_data.m:
	Add a module_name field to the `hlds_instance_defn' structure.

compiler/make_hlds.m:
	Copy the module_name field from the `instance' item to the
	`hlds_instance_defn' structure.

compiler/polymorphism.m:
	Fix an old XXX: when constructing `base_typeclass_info_const's,
	use the module name from the `hlds_instance_defn', rather than
	hard-coding the invalid value "some bogus module name".

compiler/rtti.m:
	Add a module_name field to the `base_typeclass_info' rtti_name
	and rtti_data.

compiler/base_typeclass_info.m:
	Copy the module_name field in the `hlds_instance_defn' to the
	module_name field in the `base_typeclass_info' rtti_data
	and rtti_name.

compiler/rtti_to_mlds.m:
	When constructing mlds `data_addr's, use the module_name from
	the `base_typeclass_info' rtti_name, rather than assuming that
	such references always refer to instance declarations in the
	current module.  (That assumption would be a safe one currently,
	but doing it this way is probably a bit more robust against
	future changes.)

compiler/*.m:
	Trivial changes to reflect the above data structure changes.
2000-11-01 05:12:14 +00:00
Zoltan Somogyi
d61b9df45d Declare type_ctor_infos before registering them only with
Estimated hours taken: 1

compiler/rtti_out.m:
	Declare type_ctor_infos before registering them only with
	--split-c-files.

compiler/llds_out.m:
	Pass the value of --split-c-files to rtti_out.m.
2000-10-26 03:28:00 +00:00
Zoltan Somogyi
a83529980e Declare the MR_TypeCtorInfo structures just before registering them,
Estimated hours taken: 0.2

compiler/rtti_out.m:
	Declare the MR_TypeCtorInfo structures just before registering them,
	in order to avoid C compiler errors with --split-c-files.
2000-10-16 02:56:34 +00:00
Zoltan Somogyi
1c8cb6faf2 Get the compiler to bootstrap with -DMR_NO_BACKWARDS_COMPAT.
Estimated hours taken: 2

Get the compiler to bootstrap with -DMR_NO_BACKWARDS_COMPAT.

compiler/c_util.m:
compiler/rtti_out.m:
	Add MR_ prefixes to various type names in generated code.

compiler/*.m:
browser/*.m:
library/*.m:
	Add MR_prefixes to various type and function names in pragma C code.

runtime/*.[ch]:
trace/*.[ch]:
	Add MR_prefixes to various type and function names in
	hand-written code.
2000-10-16 01:34:14 +00:00
Zoltan Somogyi
b32f9e573e This is part 1 of a change that provides a register of all the types defined
Estimated hours taken: 6

This is part 1 of a change that provides a register of all the types defined
in the program. After this change, every .c file generated by the compiler
will have three separate initialization functions:

	- One that does the initializations that must be performed before
	  any code is executed, such as recording the addresses of labels
	  in grades that don't allow direct jumps and filling in the code_addr
	  slots of type_ctor_infos.

	- One that registers the type_ctor_infos of the types defined in this
	  module in a global table.

	- One that initializes the data structures needed by the debugger;
	  i.e. registers the module layout in a global table.

For now, the first function calls the third, since this is required for
backwards compatibility of traced code; this call will go away later.

For now, the second function is not called from anywhere. Part 2 of this
change will add two functions to the _init.c file generated by c2init that
call the second function and third function respectively in each module
in the program.

This change affects only the LLDS backend; Fergus or Tyson should look into
providing this functionality for the MLDS backend as well.

This change only registers type_ctor_infos; it does not register
base_typeclass_infos. DJ and I have discussed this and agree that adding code
to register base_typeclass_infos would wasteful, because the work would almost
certainly have to be redone when constructor classes are implemented;
therefore registering base_typeclass_infos should be postponed until then.

compiler/llds_out.m:
compiler/rtti_out.m:
	Generate the code for the two new initialization functions.

runtime/mercury_wrapper.[ch]:
	Add the functions do_init_modules_{type_tables,debugger},
	which are intended to eventually invoke the corresponding
	initialization functions in the compiler-generated .c files
	through the c2init-generated _init.c file, which themselves
	are accessed through pointers in accordance with the link-order
	convention. For now, these pointers will be NULL; part 2
	will change that.

runtime/mercury_type_tables.[ch]:
	New module that provides a capability of looking up MR_TypeCtorInfos
	specified by a modulename/typename pair.

runtime/Mmakefile:
runtime/mercury_imp.h:
	Include the new header file.

runtime/mercury_tabling.[ch]:
	Allow a trie node to contain a list pointer; the type table is
	implemented as a expandable hash table whose slots are lists of
	type_ctor_infos.

runtime/mercury_dlist.[ch]:
	Make this module conform to our naming conventions. Make the type of
	list elements const, in order to avoid warnings when using lists in
	mercury_type_tables.c.

runtime/mercury_hash_table.[ch]:
	Minor changes to conform to the new names in mercury_dlist.[ch].

runtime/*.[ch]:
	Fix indentation problems caused by past automatic substitutions.
2000-10-11 03:01:32 +00:00
Peter Ross
a29d91a4b8 Bootcheck in the none.gc grade using MSVC.
Estimated hours taken: 4

Bootcheck in the none.gc grade using MSVC.

compiler/rtti_out.m:
    ANSI/ISO C doesn't allow empty arrays so place a dummy value in the
    array when necessary.
    ANSI/ISO C doesn't allow forward declarations of static data with
    incomplete types, so make the incomplete types extern.  The ideal
    solution would be to output the actual sizes of the array, however
    that is slightly more difficult then it seems.

runtime/mercury_type_info.h:
    Create new macro MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_NOCM, which is the
    same as MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL but with no cm field.

library/builtin.m:
    Use MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_NOCM instead of
    MR_DEFINE_BUILTIN_TYPE_CTOR_INFO_FULL when we have a blank cm field
    as the MSVC CPP doesn't like blank fields.

trace/mercury_trace_vars.c:
    Delete the local declarations of mercury_data___type_ctor_info_func_0
    and mercury_data___type_ctor_info_pred_0 because the true
    declarations from the header file are visibile.
2000-07-12 13:54:41 +00:00
Fergus Henderson
4bb527330e Implement typeclasses for the MLDS back-end.
Estimated hours taken: 15

Implement typeclasses for the MLDS back-end.

compiler/rtti.m:
	Add base_typeclass_info as a new alternative in the
	rtti_name and rtti_data types.

compiler/base_typeclass_info.m:
	Change it to define base_typeclass_infos as rtti_data
	rather than comp_gen_c_data.

compiler/mercury_compile.m:
	Modify to reflect the changes to base_typeclass_info.m's
	interface.
	Also change the order in which we run the MLDS passes: make
	sure to generate all the MLDS, including that generated by
	rtti_to_mlds.m, before running the MLDS transformation passes
	ml_tailcall.m and ml_elim_nested.m, since the wrapper
	functions that rtti_to_mlds.m generates for typeclass methods
	can contain code which those two MLDS transformation passes
	need to transform.

compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/mlds_to_c.m:
compiler/opt_debug.m:
	Handle base_typeclass_infos.

compiler/mlds_to_c.m:
	Fix a bug where it was not properly mangling variable names.
	Note that polymorphism.m can introduce variable names
	that contain operators, e.g. `TypeClassInfo_for_+'.
	This bug broke tests/hard_coded/operator_classname.m.
	I also changed it to mangle label names.

compiler/rtti_to_mlds.m:
	Pass down the module_info, so that ml_gen_init_method
	can use it when generate wrapper functions for type
	class methods.

compiler/ml_unify_gen.m:
	Export the ml_gen_closure_wrapper procedure, for use by
	rtti_to_mlds for type class methods.

compiler/ml_code_util.m:
	Add a new predicate `ml_gen_info_bump_func_label',
	for use by rtti_to_mlds.m when generating wrapper
	Add some functions defining magic numbers related to
	the representation of type_infos, base_typeclass_infos,
	and closures.

compiler/ml_call_gen.m:
	Handle type class method calls.

compiler/llds_out.m:
	Split the code for outputting a base_typeclass_info name
	into a separate subroutine, and export that subroutine,
	for use by rtti_out.m.

compiler/llds_out.m:
compiler/rtti_out.m:
	Change llds_out.m so that it calls a new predicate
	output_base_typeclass_info_storage_type_name, defined in
	rtti_out.m, when outputting base_typeclass_info declarations.
	This is needed because base_typeclass_infos are now defined
	as RTTI constants with type `Code * []', and so need to be
	handled as such by rtti_out.m rather than being assumed to
	be structs like the other LLDS data_names.
	Also move the code for handling dynamic initialization of
	method pointers from llds_out.m to rtti_out.m,
	at the same time changing it to handle their new definitions
	as rtti_data rather than comp_gen_c_data.

compiler/mlds.m:
	Delete the type `base_data', since it is no longer needed.

compiler/notes/type_class_transformation.html:
	Fix a documentation bug: the second field of
	base_typeclass_infos is the number of instance constraints,
	not the number of unconstrained type variables.

compiler/notes/compiler_design.html:
	Document the use of the rtti modules in the MLDS back-end,
	and improve the documentation of their use in the LLDS back-end.

runtime/mercury.h:
	Add a typedef for `MR_BaseTypeclassInfo', for use by the
	code generated by rtti_to_mlds.m and mlds_to_c.m
	for base_typeclass_infos.

	Also add another work-around declaration of an MR_TypeCtorInfo;
	with this, the browser directory now compiles.
2000-05-10 18:09:45 +00:00
Fergus Henderson
58b71d3a18 Address Tyson's review comments on my recent MLDS changes.
Estimated hours taken: 0.5

Address Tyson's review comments on my recent MLDS changes.

compiler/mlds_to_c.m:
compiler/rtti.m:
	Move the definition of rtti_name_has_array_type/1 from
	mlds_to_c.m to rtti.m, since it makes sense to put
	it in the same module as the rtti_name type.

compiler/rtti_out.m:
	Use rtti_name_has_array_type/1 rather than `rtti_name_c_type(..., "[]")'
	for testing whether an rtti_name has array type.

runtime/mercury.h:
	Document the fixed limit on type arities in more detail.
	Also change the limit from 4 to 5, to match the limit
	in runtime/mercury.c.
2000-04-25 11:32:09 +00:00
Fergus Henderson
018b0a57bb Implement RTTI support for the MLDS back-end using the rtti module.
Estimated hours taken: 10

Implement RTTI support for the MLDS back-end using the rtti module.

compiler/ml_base_type_info.m:
	Delete this file.

compiler/rtti_to_mlds.m:
	New file, replaces ml_base_type_info.
	This generates MLDS code from the RTTI data structures.

compiler/ml_code_gen.m:
	Don't call ml_base_type_info.

compiler/mercury_compile.m:
	Call rtti_to_mlds.
	Also add a few more comments to the list of
	imported modules.

compiler/mercury_compile.m:
compiler/type_ctor_info.m:
	Delete the unnecessary second `module_info' parameter from
	type_ctor_info_generate_rtti.

compiler/ml_code_util.m:
	Add ml_gen_proc_params_from_rtti, for use by gen_init_proc_id
	in rtti_to_mlds.
	Fix a bug where it was using Arity for both the PredArity
	and the TypeArity.

compiler/rtti.m:
compiler/rtti_out.m:
	Change the documentation for rtti_out.m to say that it
	_is_ intended to depend on LLDS.
	Move rtti_data_to_name from rtti_out.m to rtti.m,
	since that does not depend on the LLDS.
	Add rtti__name_is_exported/1, and implement
	rtti_name_linkage using that.
	Add some new fields to rtti_proc_label, for use by
	ml_gen_proc_params_from_rtti.

compiler/mlds.m:
	Add a new alternative `rtti_type(rtti_name)' to mlds__type type,
	and a new alternative `rtti_data(rtti_type_id, rtti_name)' to
	the mlds__data_name type, so we can represent the names and
	types of the RTTI data.
	Change the mlds__initializer type to make it a bit more expressive,
	so that it can represent e.g. initializers for arrays of structs,
	since this is needed for some of the RTTI data.

compiler/ml_code_util.m:
compiler/ml_elim_nested.m:
compiler/mlds_to_c.m:
	Handle the new definition of mlds__initializer,
	and the new alternatives in the rtti_name and
	mlds__data_name types.
2000-04-18 16:41:55 +00:00
Fergus Henderson
c202e2c7fc Restructure the RTTI implementation to eliminate dependencies on the LLDS,
Estimated hours taken: 7

Restructure the RTTI implementation to eliminate dependencies on the LLDS,
so that it can be used for the MLDS back-end as well as the LLDS back-end.
(Note that I have not yet modified the MLDS back-end to actually make
use of it; that will be a separate change.)

compiler/rtti.m:
	Eliminate the dependency on LLDS, by replacing code_addr with a new
	type `rtti_proc_label'.  Add a procedure `rtti__make_proc_label' for
	constructing these.

compiler/type_ctor_info.m:
	Eliminate the dependency on LLDS, by calling rtti__make_proc_label
	rather than code_util__make_entry_label.

compiler/ml_code_util.m:
	Add a new procedure `ml_gen_pred_label_from_rtti',
	for (eventual) use by ml_base_type_info.m.
	Restructure the implementation of ml_gen_pred_label so that it
	works by first calling rtti__make_proc_label and then calling
	ml_gen_pred_label_from_rtti.

compiler/code_util.m:
	Add new procedure `make_entry_label_from_rtti', for use by rtti_out.m.
	Restructure the implementation of the predicates make_entry_label,
	make_local_entry_label, and make_proc_label so that they work by first
	calling rtti__make_proc_label.  Change make_user_proc_label to take
	a boolean rather than an import_status.
	Also update the documentation for code_util__compiler_generated,
	adding an XXX comment saying that the name is misleading.

compiler/rtti_out.m:
	Call code_util__make_entry_label_from_rtti to
	convert the rtti_proc_labels in the RTTI into code_addrs.

compiler/rl.m:
	Update to reflect the changed interface to
	code_util__make_user_proc_label.
2000-04-17 10:32:10 +00:00