[m-dev.] for review: move code_model to new module

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Nov 20 16:56:48 AEDT 2000


Estimated hours taken: 6

Eliminated a lot of the dependencies on the the `code_model' type,
and move that type from llds.m into a new module `code_model'.
The aim of this change is to improve the modularity of the compiler by
reducing the number of places in the compiler front-end that depend
on back-end concepts and the number of places in the MLDS back-end
which depend on the LLDS.

compiler/code_model.m:
	New module.  Contains the code_model type and associated
	procedures.

compiler/llds.m:
	Move the code_model type into code_model.m.

compiler/hlds_goal.m:
	Move the goal_info_get_code_model procedure into code_model.m,
	to avoid having the HLDS modules import code_model.

compiler/hlds_pred.m:
	Move the proc_info_interface_code_model procedure into code_model.m,
	to avoid having the HLDS modules import code_model.

compiler/hlds_out.m:
	Delete `hlds_out__write_code_model', since it wasn't being used.

compiler/goal_path.m:
	When computing the `maybe_cut' field for `some' goals,
	compute it by comparing the determinism rather than by
	comparing the goal_infos.

compiler/unique_modes.m:
	Use determinism and test for soln_count = at_most_many
	rather than using code_model and testing for model_non.

compiler/inlining.m:
	Test for determinism nondet/multi rather than testing
	for code_model model_non.

compiler/hlds_pred.m:
compiler/det_report.m:
	Change valid_code_model_for_eval_method, which succeeded unless
	the eval_method was minimal_model and the code_model was model_det,
	to valid_determinism_for_eval_method, which succeeds unless the
	eval_method is minimal_model and the determinism cannot fail.
	As well as avoiding a dependency on code_model in the HLDS
	modules, this also fixes a bug where det_report could give
	misleading error messages, saying that `multi' was a valid
	determinism for `minimal_model' predicates, when in fact the
	compiler will always report a determinism error if you declare
	a `minimal_model' predicate with determinism `multi'.
	(Actually the code in which this bug occurs is in fact
	unreachable, but this is no doubt also a bug... I'll address
	that one in a separate change.)

compiler/lookup_switch.m:
	Simplify the code a bit by using globals__lookup_*_option
	rather than globals__get_option and then getopt__lookup_option.

compiler/*.m:
	Add `import_module' declarations for `code_model', and in some
	cases remove `import_module' declarations for `llds'.

Workspace: /home/pgrad/fjh/ws/hg3
Index: compiler/code_model.m
===================================================================
RCS file: code_model.m
diff -N code_model.m
--- /dev/null	Thu Mar 30 14:06:13 2000
+++ code_model.m	Mon Nov 20 13:27:29 2000
@@ -0,0 +1,62 @@
+%-----------------------------------------------------------------------------%
+% Copyright (C) 2000 The University of Melbourne.
+% This file may only be copied under the terms of the GNU General
+% Public License - see the file COPYING in the Mercury distribution.
+%-----------------------------------------------------------------------------%
+
+:- module code_model.
+
+% This module defines the `code_model' data type, and associated procedures.
+% The `code_model' type is a simplified version of the `determinism' type
+% that is defined in prog_data.m.  It ignores most of the distinctions in
+% the determinism type and keeps only the distinctions that are important
+% for code generation.
+
+% We define this in a different module than the `determinism' type because
+% it is only used by some of the different back-ends, not all of them.
+% It is used by the MLDS, LLDS, and bytecode back-ends, but not by the
+% Aditi-RL back-end.
+
+%-----------------------------------------------------------------------------%
+
+:- interface.
+:- import_module prog_data.
+:- import_module hlds_pred, hlds_goal.
+
+:- type code_model
+	--->	model_det		% functional & total
+	;	model_semi		% just functional
+	;	model_non.		% not functional
+
+:- pred determinism_to_code_model(determinism, code_model).
+:- mode determinism_to_code_model(in, out) is det.
+:- mode determinism_to_code_model(out, in) is multi.
+
+:- pred proc_info_interface_code_model(proc_info, code_model).
+:- mode proc_info_interface_code_model(in, out) is det.
+
+:- pred goal_info_get_code_model(hlds_goal_info, code_model).
+:- mode goal_info_get_code_model(in, out) is det.
+
+%-----------------------------------------------------------------------------%
+
+:- implementation.
+
+determinism_to_code_model(det,         model_det).
+determinism_to_code_model(semidet,     model_semi).
+determinism_to_code_model(nondet,      model_non).
+determinism_to_code_model(multidet,    model_non).
+determinism_to_code_model(cc_nondet,   model_semi).
+determinism_to_code_model(cc_multidet, model_det).
+determinism_to_code_model(erroneous,   model_det).
+determinism_to_code_model(failure,     model_semi).
+
+proc_info_interface_code_model(ProcInfo, CodeModel) :-
+	proc_info_interface_determinism(ProcInfo, Determinism),
+	determinism_to_code_model(Determinism, CodeModel).
+
+goal_info_get_code_model(GoalInfo, CodeModel) :-
+	goal_info_get_determinism(GoalInfo, Determinism),
+	determinism_to_code_model(Determinism, CodeModel).
+
+%-----------------------------------------------------------------------------%
Index: compiler/det_report.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/det_report.m,v
retrieving revision 1.63
diff -u -d -r1.63 det_report.m
--- compiler/det_report.m	2000/11/17 17:47:04	1.63
+++ compiler/det_report.m	2000/11/20 05:25:18
@@ -14,8 +14,10 @@
 
 :- interface.
 
+:- import_module prog_data.
 :- import_module hlds_module, hlds_pred, hlds_goal.
-:- import_module det_util, prog_data.
+:- import_module det_util.
+
 :- import_module io, list.
 
 :- type det_msg	--->
@@ -120,10 +122,13 @@
 
 :- implementation.
 
+:- import_module prog_out. 
 :- import_module hlds_data, type_util, mode_util, inst_match.
-:- import_module globals, options, prog_out, hlds_out, mercury_to_mercury.
-:- import_module passes_aux, term, varset.
+:- import_module hlds_out, mercury_to_mercury.
+:- import_module passes_aux.
+:- import_module globals, options.
 
+:- import_module term, varset.
 :- import_module bool, int, map, set, std_util, require, string.
 
 %-----------------------------------------------------------------------------%
@@ -204,9 +209,8 @@
 	
 	% make sure the code model is valid given the eval method
 	{ proc_info_eval_method(ProcInfo0, EvalMethod) },
-	{ determinism_to_code_model(InferredDetism, CodeMod) },
 	( 
-		{ valid_code_model_for_eval_method(EvalMethod, CodeMod) }
+		{ valid_determinism_for_eval_method(EvalMethod, InferredDetism) }
 	->
 		{
 		    proc_info_set_eval_method(ProcInfo0, EvalMethod, ProcInfo),
@@ -240,11 +244,25 @@
 	).
 
 :- pred get_valid_dets(eval_method, determinism).
-:- mode get_valid_dets(in, out) is multidet.
+:- mode get_valid_dets(in, out) is nondet.
 
-get_valid_dets(EvalMethod, Det) :-
-	valid_code_model_for_eval_method(EvalMethod, CodeModel),
-	determinism_to_code_model(Det, CodeModel).
+get_valid_dets(EvalMethod, Detism) :-
+	determinism(Detism),
+	valid_determinism_for_eval_method(EvalMethod, Detism).
+
+	% generate all the possible determinisms
+:- pred determinism(determinism).
+:- mode determinism(out) is multi.
+:- mode determinism(in) is det. % to ensure we don't forget any
+
+determinism(det).
+determinism(semidet).
+determinism(multidet).
+determinism(nondet).
+determinism(cc_multidet).
+determinism(cc_nondet).
+determinism(erroneous).
+determinism(failure).
 
 :- pred print_dets(list(determinism), io__state, io__state).
 :- mode print_dets(in, di, uo) is det.
Index: compiler/goal_path.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/goal_path.m,v
retrieving revision 1.11
diff -u -d -r1.11 goal_path.m
--- compiler/goal_path.m	2000/11/17 17:47:11	1.11
+++ compiler/goal_path.m	2000/11/20 04:07:09
@@ -72,9 +72,9 @@
 fill_expr_slots(some(A, B, Goal0), OuterInfo, Path0, SlotInfo,
 		some(A, B, Goal)) :-
 	Goal0 = _ - InnerInfo,
-	goal_info_get_code_model(OuterInfo, OuterModel),
-	goal_info_get_code_model(InnerInfo, InnerModel),
-	( InnerModel = OuterModel ->
+	goal_info_get_determinism(OuterInfo, OuterDetism),
+	goal_info_get_determinism(InnerInfo, InnerDetism),
+	( InnerDetism = OuterDetism ->
 		MaybeCut = no_cut
 	;
 		MaybeCut = cut
Index: compiler/hlds_goal.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.81
diff -u -d -r1.81 hlds_goal.m
--- compiler/hlds_goal.m	2000/11/17 17:47:18	1.81
+++ compiler/hlds_goal.m	2000/11/20 02:09:13
@@ -602,9 +602,7 @@
 :- pred goal_info_set_post_deaths(hlds_goal_info, set(prog_var), hlds_goal_info).
 :- mode goal_info_set_post_deaths(in, in, out) is det.
 
-:- pred goal_info_get_code_model(hlds_goal_info, code_model).
-:- mode goal_info_get_code_model(in, out) is det.
-
+	% see also goal_info_get_code_model in code_model.m
 :- pred goal_info_get_determinism(hlds_goal_info, determinism).
 :- mode goal_info_get_determinism(in, out) is det.
 
@@ -1312,10 +1310,6 @@
 
 goal_info_set_goal_path(GoalInfo0, GoalPath,
 		GoalInfo0 ^ goal_path := GoalPath).
-
-goal_info_get_code_model(GoalInfo, CodeModel) :-
-	goal_info_get_determinism(GoalInfo, Determinism),
-	determinism_to_code_model(Determinism, CodeModel).
 
 goal_info_add_feature(GoalInfo0, Feature, GoalInfo) :-
 	goal_info_get_features(GoalInfo0, Features0),
Index: compiler/hlds_pred.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_pred.m,v
retrieving revision 1.86
diff -u -d -r1.86 hlds_pred.m
--- compiler/hlds_pred.m	2000/11/03 03:11:47	1.86
+++ compiler/hlds_pred.m	2000/11/20 04:38:33
@@ -13,14 +13,25 @@
 
 :- interface.
 
-:- import_module hlds_data, hlds_goal, hlds_module, llds, prog_data, instmap.
-:- import_module globals, term_util.
+:- import_module prog_data.
+:- import_module hlds_data, hlds_goal, hlds_module, instmap, term_util.
+:- import_module globals.
+
 :- import_module bool, list, set, map, std_util, term, varset.
 
 :- implementation.
 
-:- import_module code_aux, goal_util, make_hlds, prog_util.
-:- import_module inst_match, mode_util, type_util, options.
+% Parse tree modules.
+:- import_module prog_util.
+
+% HLDS modules.
+:- import_module code_aux, goal_util, make_hlds.
+:- import_module inst_match, mode_util, type_util.
+
+% Misc
+:- import_module options.
+
+% Standard library modules.
 :- import_module int, string, require, assoc_list.
 
 %-----------------------------------------------------------------------------%
@@ -1269,12 +1280,10 @@
 :- pred proc_info_inferred_determinism(proc_info, determinism).
 :- mode proc_info_inferred_determinism(in, out) is det.
 
+	% See also proc_info_interface_code_model in code_model.m.
 :- pred proc_info_interface_determinism(proc_info, determinism).
 :- mode proc_info_interface_determinism(in, out) is det.
 
-:- pred proc_info_interface_code_model(proc_info, code_model).
-:- mode proc_info_interface_code_model(in, out) is det.
-
 	% proc_info_never_succeeds(ProcInfo, Result):
 	% return Result = yes if the procedure is known to never succeed
 	% according to the declared determinism.
@@ -1699,10 +1708,6 @@
 		MaybeDeterminism = yes(Determinism)
 	).
 
-proc_info_interface_code_model(ProcInfo, CodeModel) :-
-	proc_info_interface_determinism(ProcInfo, Determinism),
-	determinism_to_code_model(Determinism, CodeModel).
-
 	% Return Result = yes if the called predicate is known to never succeed.
 	%
 proc_info_never_succeeds(ProcInfo, Result) :-
@@ -2274,10 +2279,9 @@
 :- interface.
 
 	% Check if the given evaluation method is allowed with
-	% the given code model.
-:- pred valid_code_model_for_eval_method(eval_method, code_model).
-:- mode valid_code_model_for_eval_method(in, in) is semidet.
-:- mode valid_code_model_for_eval_method(in, out) is multidet.
+	% the given determinism.
+:- pred valid_determinism_for_eval_method(eval_method, determinism).
+:- mode valid_determinism_for_eval_method(in, in) is semidet.
 
 	% Convert an evaluation method to a string.
 :- pred eval_method_to_string(eval_method, string).
@@ -2314,17 +2318,11 @@
 
 :- import_module det_analysis.
 
-valid_code_model_for_eval_method(eval_normal, model_det).
-valid_code_model_for_eval_method(eval_normal, model_semi).
-valid_code_model_for_eval_method(eval_normal, model_non).
-valid_code_model_for_eval_method(eval_memo, model_det).
-valid_code_model_for_eval_method(eval_memo, model_semi).
-valid_code_model_for_eval_method(eval_memo, model_non).
-valid_code_model_for_eval_method(eval_loop_check, model_det).
-valid_code_model_for_eval_method(eval_loop_check, model_semi).
-valid_code_model_for_eval_method(eval_loop_check, model_non).
-valid_code_model_for_eval_method(eval_minimal, model_semi).
-valid_code_model_for_eval_method(eval_minimal, model_non).
+valid_determinism_for_eval_method(eval_normal, _).
+valid_determinism_for_eval_method(eval_memo, _).
+valid_determinism_for_eval_method(eval_loop_check, _).
+valid_determinism_for_eval_method(eval_minimal, Determinism) :-
+	determinism_components(Determinism, can_fail, _).
 
 eval_method_to_string(eval_normal,		"normal").
 eval_method_to_string(eval_memo,		"memo").
Index: compiler/llds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/llds.m,v
retrieving revision 1.269
diff -u -d -r1.269 llds.m
--- compiler/llds.m	2000/11/17 17:47:36	1.269
+++ compiler/llds.m	2000/11/20 02:34:31
@@ -16,17 +16,12 @@
 
 :- interface.
 
-:- import_module hlds_pred, hlds_goal, hlds_data, tree, prog_data, (inst).
-:- import_module rtti, builtin_ops.
+:- import_module prog_data, (inst).
+:- import_module hlds_pred, hlds_goal, hlds_data.
+:- import_module code_model, rtti, builtin_ops.
+:- import_module tree.
 
 :- import_module bool, assoc_list, list, map, set, std_util, counter.
-
-%-----------------------------------------------------------------------------%
-
-:- type code_model
-	--->	model_det		% functional & total
-	;	model_semi		% just functional
-	;	model_non.		% not functional
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/arg_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/arg_info.m,v
retrieving revision 1.34
diff -u -d -r1.34 arg_info.m
--- compiler/arg_info.m	2000/09/20 00:21:34	1.34
+++ compiler/arg_info.m	2000/11/20 04:12:05
@@ -17,7 +17,7 @@
 
 :- module arg_info.
 :- interface. 
-:- import_module hlds_module, hlds_pred, llds, prog_data.
+:- import_module prog_data, hlds_module, hlds_pred, code_model, llds.
 :- import_module list, assoc_list.
 
 	% Annotate every non-aditi procedure in the module with information
Index: compiler/bytecode_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/bytecode_gen.m,v
retrieving revision 1.52
diff -u -d -r1.52 bytecode_gen.m
--- compiler/bytecode_gen.m	2000/11/17 17:46:54	1.52
+++ compiler/bytecode_gen.m	2000/11/20 02:33:19
@@ -37,10 +37,12 @@
 % arg_info.m so that it didn't depend on the LLDS.
 
 :- import_module arg_info, call_gen. % XXX for arg passing convention
-:- import_module llds.		% XXX for code_model
 :- import_module code_util.	% XXX for cons_id_to_tag
-:- import_module hlds_pred, hlds_goal, hlds_data, prog_data, type_util.
-:- import_module passes_aux, mode_util, goal_util, builtin_ops.
+
+:- import_module prog_data.
+:- import_module hlds_pred, hlds_goal, hlds_data.
+:- import_module type_util, mode_util, goal_util.
+:- import_module builtin_ops, code_model, passes_aux.
 :- import_module globals, tree.
 
 :- import_module bool, int, string, list, assoc_list, set, map, varset.
Index: compiler/call_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/call_gen.m,v
retrieving revision 1.145
diff -u -d -r1.145 call_gen.m
--- compiler/call_gen.m	2000/10/13 04:04:10	1.145
+++ compiler/call_gen.m	2000/11/20 05:01:17
@@ -18,7 +18,7 @@
 
 :- interface.
 
-:- import_module prog_data, hlds_pred, hlds_goal, llds, code_info.
+:- import_module prog_data, hlds_pred, hlds_goal, code_model, llds, code_info.
 :- import_module list, assoc_list.
 
 :- pred call_gen__generate_call(code_model::in, pred_id::in, proc_id::in,
@@ -53,9 +53,13 @@
 
 :- implementation.
 
-:- import_module hlds_module, hlds_data, code_util, builtin_ops, rl.
-:- import_module arg_info, type_util, mode_util, unify_proc, instmap.
-:- import_module polymorphism, trace, globals, options.
+:- import_module hlds_module, hlds_data.
+:- import_module polymorphism, type_util, mode_util, unify_proc, instmap.
+:- import_module builtin_ops.
+:- import_module arg_info, code_util, trace.
+:- import_module rl.
+:- import_module globals, options.
+
 :- import_module std_util, bool, int, tree, map, set.
 :- import_module varset, require, string.
 
Index: compiler/code_aux.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_aux.m,v
retrieving revision 1.60
diff -u -d -r1.60 code_aux.m
--- compiler/code_aux.m	2000/11/17 17:46:55	1.60
+++ compiler/code_aux.m	2000/11/20 04:36:20
@@ -54,6 +54,7 @@
 	% set dependening on whether the recursive call is last in the
 	% conjunction or not.
 
+	% XXX should avoid the dependency on code_info here
 :- pred code_aux__contains_simple_recursive_call(hlds_goal, code_info, bool).
 :- mode code_aux__contains_simple_recursive_call(in, in, out) is semidet.
 
Index: compiler/code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_gen.m,v
retrieving revision 1.88
diff -u -d -r1.88 code_gen.m
--- compiler/code_gen.m	2000/11/17 17:46:56	1.88
+++ compiler/code_gen.m	2000/11/20 04:16:36
@@ -30,7 +30,10 @@
 
 :- interface.
 
-:- import_module hlds_module, hlds_pred, hlds_goal, llds, code_info.
+:- import_module hlds_module, hlds_pred, hlds_goal.
+:- import_module code_model.
+:- import_module llds, code_info.
+
 :- import_module list, io, counter.
 
 		% Translate a HLDS module to LLDS.
@@ -59,12 +62,22 @@
 
 :- implementation.
 
+% Parse tree modules
+:- import_module prog_data, prog_out, prog_util.
+
+% HLDS modules
+:- import_module hlds_out, instmap, type_util, mode_util, goal_util.
+
+% LLDS code generator modules.
 :- import_module call_gen, unify_gen, ite_gen, switch_gen, disj_gen.
 :- import_module par_conj_gen, pragma_c_gen, commit_gen.
-:- import_module continuation_info, trace, trace_params, options, hlds_out.
-:- import_module code_aux, middle_rec, passes_aux, llds_out.
-:- import_module code_util, type_util, mode_util, goal_util.
-:- import_module prog_data, prog_out, prog_util, instmap, globals.
+:- import_module continuation_info, trace, trace_params.
+:- import_module code_aux, code_util, middle_rec, passes_aux, llds_out.
+
+% Misc compiler modules
+:- import_module globals, options.
+
+% Standard library modules
 :- import_module bool, char, int, string.
 :- import_module map, assoc_list, set, term, tree, std_util, require, varset.
 
Index: compiler/code_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_info.m,v
retrieving revision 1.257
diff -u -d -r1.257 code_info.m
--- compiler/code_info.m	2000/10/13 04:04:14	1.257
+++ compiler/code_info.m	2000/11/20 04:13:17
@@ -29,20 +29,25 @@
 
 :- interface.
 
-:- import_module hlds_module, hlds_pred, hlds_goal, llds, instmap, trace.
-:- import_module continuation_info, prog_data, hlds_data, globals.
+:- import_module prog_data.
+:- import_module hlds_module, hlds_pred, hlds_goal, hlds_data, instmap.
+:- import_module code_model.
+:- import_module llds, continuation_info, trace.
+:- import_module globals.
 
 :- import_module bool, set, list, map, std_util, assoc_list, counter.
 
 :- implementation.
 
-:- import_module code_util, code_exprn, var_locn, llds_out, prog_out.
-:- import_module exprn_aux, arg_info, type_util, mode_util.
-:- import_module trace_params, options.
+:- import_module prog_out.
+:- import_module type_util, mode_util.
+:- import_module arg_info, code_util, code_exprn, exprn_aux, var_locn.
+:- import_module trace_params, llds_out.
+:- import_module options, tree.
 
 :- import_module term, varset.
 :- import_module set, stack.
-:- import_module string, require, char, bimap, tree, int.
+:- import_module string, require, char, bimap, int.
 
 %---------------------------------------------------------------------------%
 
Index: compiler/code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_util.m,v
retrieving revision 1.128
diff -u -d -r1.128 code_util.m
--- compiler/code_util.m	2000/11/17 17:46:58	1.128
+++ compiler/code_util.m	2000/11/20 02:44:29
@@ -186,7 +186,7 @@
 
 :- implementation.
 
-:- import_module builtin_ops, prog_util, type_util, special_pred.
+:- import_module prog_util, type_util, special_pred, builtin_ops, code_model.
 
 :- import_module char, int, string, set, map, term, varset.
 :- import_module require, std_util, assoc_list.
Index: compiler/commit_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/commit_gen.m,v
retrieving revision 1.1
diff -u -d -r1.1 commit_gen.m
--- compiler/commit_gen.m	1998/07/21 02:26:00	1.1
+++ compiler/commit_gen.m	2000/11/20 02:44:53
@@ -16,7 +16,7 @@
 
 :- interface.
 
-:- import_module hlds_goal, llds, code_info.
+:- import_module hlds_goal, code_model, llds, code_info.
 
 :- pred commit_gen__generate_commit(code_model::in, hlds_goal::in,
 	code_tree::out, code_info::in, code_info::out) is det.
Index: compiler/dense_switch.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/dense_switch.m,v
retrieving revision 1.37
diff -u -d -r1.37 dense_switch.m
--- compiler/dense_switch.m	2000/11/16 10:48:41	1.37
+++ compiler/dense_switch.m	2000/11/20 05:02:00
@@ -16,7 +16,7 @@
 
 :- interface.
 
-:- import_module prog_data, hlds_data, hlds_goal.
+:- import_module prog_data, hlds_data, hlds_goal, code_model.
 :- import_module switch_util, type_util.
 :- import_module llds, code_info.
 
Index: compiler/disj_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/disj_gen.m,v
retrieving revision 1.72
diff -u -d -r1.72 disj_gen.m
--- compiler/disj_gen.m	2000/09/20 00:21:47	1.72
+++ compiler/disj_gen.m	2000/11/20 02:47:19
@@ -17,7 +17,7 @@
 
 :- interface.
 
-:- import_module hlds_goal, llds, code_info.
+:- import_module hlds_goal, code_model, llds, code_info.
 :- import_module list.
 
 :- pred disj_gen__generate_disj(code_model::in, list(hlds_goal)::in,
@@ -29,6 +29,7 @@
 
 :- import_module prog_data, hlds_data, code_gen, code_util, trace.
 :- import_module options, globals, tree.
+
 :- import_module bool, set, tree, map, std_util, term, require.
 
 disj_gen__generate_disj(CodeModel, Goals, StoreMap, Code) -->
Index: compiler/export.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/export.m,v
retrieving revision 1.39
diff -u -d -r1.39 export.m
--- compiler/export.m	2000/11/17 17:47:07	1.39
+++ compiler/export.m	2000/11/20 02:48:27
@@ -18,7 +18,7 @@
 
 :- interface.
 
-:- import_module hlds_module, prog_data, llds.
+:- import_module prog_data, hlds_module, llds.
 :- import_module io.
 
 	% From the module_info, get a list of foreign_export_decls,
@@ -70,8 +70,10 @@
 
 :- implementation.
 
-:- import_module code_gen, code_util, hlds_pred, llds_out, modules.
-:- import_module type_util.
+:- import_module modules.
+:- import_module hlds_pred, type_util.
+:- import_module code_model.
+:- import_module code_gen, code_util, llds_out.
 
 :- import_module term, varset.
 :- import_module library, map, int, string, std_util, assoc_list, require.
Index: compiler/fact_table.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/fact_table.m,v
retrieving revision 1.33
diff -u -d -r1.33 fact_table.m
--- compiler/fact_table.m	2000/10/27 06:26:49	1.33
+++ compiler/fact_table.m	2000/11/20 05:03:27
@@ -86,13 +86,21 @@
 
 :- implementation.
 
+% Standard library modules
 :- import_module int, map, std_util, assoc_list, char, require, library, bool.
 :- import_module float, math, getopt, string.
-:- import_module parser, term_io.
+:- import_module parser, term, term_io.
 
-:- import_module prog_util, prog_out, llds_out, modules, hlds_out, hlds_data.
-:- import_module globals, options, passes_aux, arg_info, llds, mode_util.
-:- import_module prog_io, code_util, export, inst_match, term.
+% Parse tree modules
+:- import_module prog_util, prog_io, prog_out, modules.
+% HLDS modules
+:- import_module hlds_out, hlds_data, mode_util, inst_match.
+% LLDS back-end modules
+:- import_module arg_info, llds, llds_out, code_util, export.
+% Modules shared between different back-ends.
+:- import_module passes_aux, code_model.
+% Misc
+:- import_module globals, options.
 
 :- type fact_result
 	--->	ok ; error.
Index: compiler/follow_vars.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/follow_vars.m,v
retrieving revision 1.59
diff -u -d -r1.59 follow_vars.m
--- compiler/follow_vars.m	2000/11/17 17:47:09	1.59
+++ compiler/follow_vars.m	2000/11/20 02:49:58
@@ -43,8 +43,12 @@
 
 :- implementation.
 
-:- import_module hlds_data, llds, mode_util, prog_data, call_gen.
-:- import_module code_util, quantification, arg_info, globals.
+:- import_module prog_data.
+:- import_module hlds_data, quantification, mode_util.
+:- import_module code_model.
+:- import_module llds, call_gen, code_util, arg_info.
+:- import_module globals.
+
 :- import_module bool, int, list, assoc_list, map, set, std_util, require.
 
 %-----------------------------------------------------------------------------%
Index: compiler/foreign.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/foreign.m,v
retrieving revision 1.1
diff -u -d -r1.1 foreign.m
--- compiler/foreign.m	2000/11/17 17:47:10	1.1
+++ compiler/foreign.m	2000/11/20 02:50:58
@@ -18,8 +18,9 @@
 
 :- interface.
 
-:- import_module prog_data, llds.
+:- import_module prog_data.
 :- import_module hlds_module, hlds_pred.
+:- import_module llds.
 
 :- import_module list.
 
@@ -76,6 +77,7 @@
 :- import_module require.
 
 :- import_module hlds_pred, hlds_module, type_util, mode_util.
+:- import_module code_model.
 
 foreign__filter_decls(WantedLang, Decls0, LangDecls, NotLangDecls) :-
 	list__filter((pred(foreign_decl_code(Lang, _, _)::in) is semidet :-
Index: compiler/hlds_data.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_data.m,v
retrieving revision 1.50
diff -u -d -r1.50 hlds_data.m
--- compiler/hlds_data.m	2000/11/01 05:11:52	1.50
+++ compiler/hlds_data.m	2000/11/20 04:07:40
@@ -13,7 +13,7 @@
 
 :- interface.
 
-:- import_module hlds_pred, llds, prog_data, (inst), term.
+:- import_module hlds_pred, prog_data, (inst), term.
 :- import_module bool, list, map, std_util.
 
 %-----------------------------------------------------------------------------%
@@ -742,6 +742,7 @@
 
 %
 % Types and procedures for decomposing and analysing determinism.
+% See also the `code_model' type in code_model.m.
 % The `determinism' type itself is defined in prog_data.m.
 %
 
@@ -763,10 +764,6 @@
 :- mode determinism_components(in, out, out) is det.
 :- mode determinism_components(out, in, in) is det.
 
-:- pred determinism_to_code_model(determinism, code_model).
-:- mode determinism_to_code_model(in, out) is det.
-:- mode determinism_to_code_model(out, in) is multidet.
-
 :- implementation.
 
 determinism_components(det,         cannot_fail, at_most_one).
@@ -777,15 +774,6 @@
 determinism_components(cc_nondet,   can_fail,    at_most_many_cc).
 determinism_components(erroneous,   cannot_fail, at_most_zero).
 determinism_components(failure,     can_fail,    at_most_zero).
-
-determinism_to_code_model(det,         model_det).
-determinism_to_code_model(semidet,     model_semi).
-determinism_to_code_model(nondet,      model_non).
-determinism_to_code_model(multidet,    model_non).
-determinism_to_code_model(cc_nondet,   model_semi).
-determinism_to_code_model(cc_multidet, model_det).
-determinism_to_code_model(erroneous,   model_det).
-determinism_to_code_model(failure,     model_semi).
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.250
diff -u -d -r1.250 hlds_out.m
--- compiler/hlds_out.m	2000/11/17 17:47:22	1.250
+++ compiler/hlds_out.m	2000/11/20 05:03:55
@@ -32,10 +32,13 @@
 
 :- interface.
 
-:- import_module hlds_module, hlds_pred, hlds_goal, hlds_data.
-:- import_module prog_data, llds, instmap, term.
-:- import_module io, bool, list.
+% Parse tree modules
+:- import_module prog_data.
+% HLDS modules
+:- import_module hlds_module, hlds_pred, hlds_goal, hlds_data, instmap.
 
+:- import_module io, bool, list, term.
+
 %-----------------------------------------------------------------------------%
 
 :- pred hlds_out__write_type_id(type_id, io__state, io__state).
@@ -131,9 +134,6 @@
 :- pred hlds_out__write_can_fail(can_fail, io__state, io__state).
 :- mode hlds_out__write_can_fail(in, di, uo) is det.
 
-:- pred hlds_out__write_code_model(code_model, io__state, io__state).
-:- mode hlds_out__write_code_model(in, di, uo) is det.
-
 :- pred hlds_out__write_import_status(import_status, io__state, io__state).
 :- mode hlds_out__write_import_status(in, di, uo) is det.
 
@@ -243,10 +243,23 @@
 
 :- implementation.
 
-:- import_module mercury_to_mercury, globals, options, purity, special_pred.
-:- import_module llds_out, prog_out, prog_util, (inst), instmap, trace.
-:- import_module rl, code_util, termination, term_errors, check_typeclass.
+% Parse tree modules.
+:- import_module prog_out, prog_util, (inst).
+
+% HLDS modules.
+:- import_module mercury_to_mercury, purity, special_pred, instmap.
+:- import_module termination, term_errors, check_typeclass.
+
+% RL back-end modules (XXX should avoid using those here).
+:- import_module rl.
+
+% LLDS back-end modules (XXX should avoid using those here).
+:- import_module code_util, llds, llds_out, trace.
+
+% Misc
+:- import_module globals, options.
 
+% Standard library modules
 :- import_module int, string, set, assoc_list, map, multi_map.
 :- import_module require, getopt, std_util, term_io, varset.
 
@@ -1039,6 +1052,7 @@
 	( { string__contains_char(Verbose, 'P') } ->
 		{ goal_info_get_goal_path(GoalInfo, Path) },
 		( { Path \= [] } ->
+			% XXX should avoid dependency on trace.m here
 			{ trace__path_to_string(Path, PathStr) },
 			hlds_out__write_indent(Indent),
 			io__write_string("% goal path: "),
@@ -1676,6 +1690,7 @@
 		Indent, Follow) -->
 	hlds_out__write_indent(Indent),	
 	io__write_string("aditi_call "),
+	% XXX should avoid dependency on rl.m here
 	{ rl__get_entry_proc_name(ModuleInfo, PredProcId, ProcName) },
 	io__write(ProcName),
 	io__write_string("("),
@@ -3044,13 +3059,6 @@
 	io__write_string("can_fail").
 hlds_out__write_can_fail(cannot_fail) -->
 	io__write_string("cannot_fail").
-
-hlds_out__write_code_model(model_det) -->
-	io__write_string("model_det").
-hlds_out__write_code_model(model_semi) -->
-	io__write_string("model_semi").
-hlds_out__write_code_model(model_non) -->
-	io__write_string("model_non").
 
 :- pred hlds_out__write_indent(int, io__state, io__state).
 :- mode hlds_out__write_indent(in, di, uo) is det.
Index: compiler/inlining.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/inlining.m,v
retrieving revision 1.93
diff -u -d -r1.93 inlining.m
--- compiler/inlining.m	2000/11/18 20:04:43	1.93
+++ compiler/inlining.m	2000/11/20 05:05:51
@@ -138,14 +138,21 @@
 
 :- implementation.
 
-:- import_module globals, options, llds.
-:- import_module term, varset.
-:- import_module dead_proc_elim, type_util, mode_util, goal_util.
-:- import_module passes_aux, code_aux, quantification, det_analysis, prog_data.
+% Parse tree modules
+:- import_module prog_data.
 
-:- import_module bool, int, list, assoc_list, set, std_util.
-:- import_module require, hlds_data, dependency_graph.
+% HLDS modules
+:- import_module hlds_data, type_util, mode_util, goal_util, det_analysis.
+:- import_module quantification, code_aux, dead_proc_elim, dependency_graph.
+:- import_module passes_aux.
+
+% Misc
+:- import_module globals, options.
 
+% Standard library modules
+:- import_module bool, int, list, assoc_list, set, std_util, require.
+:- import_module term, varset.
+
 %-----------------------------------------------------------------------------%
 
 	% this structure holds option values, extracted from the globals
@@ -824,7 +831,8 @@
 	\+ (
 		HighLevelCode = no,
 		CalledGoal = pragma_foreign_code(_,_,_,_,_,_,_) - _,
-		proc_info_interface_code_model(ProcInfo, model_non)
+		proc_info_interface_determinism(ProcInfo, Detism),
+		( Detism = nondet ; Detism = multidet )
 	),
 
 	% Don't inline memoed Aditi predicates.
Index: compiler/ite_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ite_gen.m,v
retrieving revision 1.64
diff -u -d -r1.64 ite_gen.m
--- compiler/ite_gen.m	2000/03/20 05:24:49	1.64
+++ compiler/ite_gen.m	2000/11/20 04:13:41
@@ -18,7 +18,7 @@
 
 :- interface.
 
-:- import_module hlds_goal, llds, code_info.
+:- import_module hlds_goal, code_model, llds, code_info.
 
 :- pred ite_gen__generate_ite(code_model::in, hlds_goal::in, hlds_goal::in,
 	hlds_goal::in, store_map::in, code_tree::out,
Index: compiler/lambda.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/lambda.m,v
retrieving revision 1.69
diff -u -d -r1.69 lambda.m
--- compiler/lambda.m	2000/11/17 17:47:30	1.69
+++ compiler/lambda.m	2000/11/20 05:06:44
@@ -82,10 +82,17 @@
 
 :- implementation.
 
-:- import_module hlds_goal, prog_data, quantification.
-:- import_module hlds_data, globals, options, type_util.
-:- import_module goal_util, prog_util, mode_util, inst_match, llds, arg_info.
+:- import_module code_model. % XXX for some back-end dependent optimizations
 
+% Parse tree modules
+:- import_module prog_data, prog_util.
+% HLDS modules
+:- import_module hlds_goal, hlds_data, quantification.
+:- import_module type_util, goal_util, mode_util, inst_match.
+% Misc
+:- import_module globals, options.
+
+% Standard library modules
 :- import_module list, map, set.
 :- import_module term, varset, bool, string, std_util, require.
 
Index: compiler/liveness.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/liveness.m,v
retrieving revision 1.113
diff -u -d -r1.113 liveness.m
--- compiler/liveness.m	2000/11/17 17:47:34	1.113
+++ compiler/liveness.m	2000/11/20 04:52:26
@@ -160,11 +160,19 @@
 
 :- implementation.
 
-:- import_module hlds_goal, hlds_data, llds, quantification, (inst), instmap.
-:- import_module hlds_out, mode_util, code_util, quantification, options.
-:- import_module polymorphism, passes_aux, prog_util.
-:- import_module trace_params, trace, globals.
+% Parse tree modules
+:- import_module prog_util, (inst).
+% HLDS modules
+:- import_module hlds_goal, hlds_data, hlds_out, instmap, mode_util.
+:- import_module quantification, polymorphism.
+% Modules shared between different back-ends.
+:- import_module code_model, passes_aux.
+% LLDS modules
+:- import_module llds, code_util, trace_params, trace.
+% Misc
+:- import_module globals, options.
 
+% Standard library modules
 :- import_module bool, string, map, std_util, list, assoc_list, require.
 :- import_module term, varset.
 
Index: compiler/live_vars.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/live_vars.m,v
retrieving revision 1.94
diff -u -d -r1.94 live_vars.m
--- compiler/live_vars.m	2000/11/17 17:47:32	1.94
+++ compiler/live_vars.m	2000/11/20 04:55:42
@@ -33,9 +33,24 @@
 
 :- implementation.
 
-:- import_module llds, arg_info, prog_data, hlds_goal, hlds_data, mode_util.
-:- import_module liveness, code_aux, globals, trace_params, trace.
-:- import_module graph_colour, instmap, options.
+% Parse tree modules
+:- import_module prog_data.
+
+% HLDS modules
+:- import_module hlds_goal, hlds_data, mode_util, instmap, code_aux.
+:- import_module liveness.
+
+% Modules shared between different back-ends.
+:- import_module code_model.
+
+% LLDS modules
+:- import_module llds, arg_info, trace_params, trace.
+
+% Misc
+:- import_module globals, options, graph_colour.
+
+
+% Standard library modules
 :- import_module list, map, set, std_util, assoc_list, bool.
 :- import_module int, require.
 
Index: compiler/lookup_switch.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/lookup_switch.m,v
retrieving revision 1.40
diff -u -d -r1.40 lookup_switch.m
--- compiler/lookup_switch.m	2000/11/16 10:48:42	1.40
+++ compiler/lookup_switch.m	2000/11/20 05:24:41
@@ -41,8 +41,9 @@
 
 :- interface.
 
-:- import_module prog_data, hlds_goal, hlds_data.
-:- import_module switch_util.
+:- import_module prog_data.
+:- import_module hlds_goal, hlds_data, switch_util.
+:- import_module code_model.
 :- import_module llds, code_info.
 
 :- import_module std_util, map, set, list.
@@ -68,9 +69,11 @@
 
 :- implementation.
 
-:- import_module builtin_ops, code_gen, type_util, tree.
-:- import_module dense_switch, globals, options, mode_util.
-:- import_module exprn_aux, getopt, prog_data, instmap.
+:- import_module prog_data.
+:- import_module type_util, mode_util, instmap.
+:- import_module builtin_ops.
+:- import_module dense_switch, code_gen, exprn_aux.
+:- import_module globals, options, tree.
 
 :- import_module int, require, bool, assoc_list.
 
@@ -92,8 +95,7 @@
 		% heuristic to get it right, so, lets just use a simple
 		% one - no static ground terms, no lookup switch.
 	code_info__get_globals(Globals),
-	{ globals__get_options(Globals, Options) },
-	{ getopt__lookup_bool_option(Options, static_ground_terms, yes) },
+	{ globals__lookup_bool_option(Globals, static_ground_terms, yes) },
 	{
 		% We want to generate a lookup switch for any switch
 		% that is dense enough - we don't care how many cases
@@ -397,8 +399,7 @@
 lookup_switch__get_word_bits(WordBits, Log2WordBits) -->
 	{ int__bits_per_int(HostWordBits) },
 	code_info__get_globals(Globals),
-	{ globals__get_options(Globals, Options) },
-	{ getopt__lookup_int_option(Options, bits_per_word, TargetWordBits) },
+	{ globals__lookup_int_option(Globals, bits_per_word, TargetWordBits) },
 	{ int__min(HostWordBits, TargetWordBits, WordBits0) },
 	% round down to the nearest power of 2
 	{ Log2WordBits = log2_rounded_down(WordBits0) },
Index: compiler/mercury_to_mercury.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_to_mercury.m,v
retrieving revision 1.180
diff -u -d -r1.180 mercury_to_mercury.m
--- compiler/mercury_to_mercury.m	2000/11/17 17:47:52	1.180
+++ compiler/mercury_to_mercury.m	2000/11/20 04:32:39
@@ -14,6 +14,11 @@
 :- module mercury_to_mercury.
 :- interface.
 
+:- import_module prog_data, (inst).
+:- import_module hlds_goal, hlds_data.
+
+:- import_module bool, std_util, list, io, varset, term.
+
 :- type needs_brackets
 	--->	needs_brackets		% needs brackets, if it is an op
 	;	does_not_need_brackets.	% doesn't need brackets
@@ -22,9 +27,6 @@
 	--->	next_to_graphic_token		% needs quotes, if it
 						% is another graphic token
 	;	not_next_to_graphic_token.	% doesn't need quotes
-
-:- import_module hlds_goal, hlds_data, prog_data, (inst).
-:- import_module bool, std_util, list, io, varset, term.
 
 %	convert_to_mercury(ModuleName, OutputFileName, Items)
 :- pred convert_to_mercury(module_name, string, list(item_and_context),
Index: compiler/middle_rec.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/middle_rec.m,v
retrieving revision 1.85
diff -u -d -r1.85 middle_rec.m
--- compiler/middle_rec.m	2000/10/13 04:05:01	1.85
+++ compiler/middle_rec.m	2000/11/20 05:09:04
@@ -27,6 +27,7 @@
 
 :- import_module builtin_ops, hlds_module, hlds_data, prog_data, prog_out.
 :- import_module code_gen, unify_gen, code_util, code_aux, opt_util.
+:- import_module code_model.
 
 :- import_module bool, set, int, std_util, tree, list, assoc_list, require.
 :- import_module string.
Index: compiler/ml_call_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_call_gen.m,v
retrieving revision 1.17
diff -u -d -r1.17 ml_call_gen.m
--- compiler/ml_call_gen.m	2000/10/30 07:09:00	1.17
+++ compiler/ml_call_gen.m	2000/11/20 02:13:17
@@ -18,8 +18,8 @@
 
 :- import_module prog_data.
 :- import_module hlds_pred, hlds_goal.
+:- import_module code_model.
 :- import_module mlds, ml_code_util.
-:- import_module llds. % XXX for `code_model'
 
 :- import_module list.
 
Index: compiler/ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.67
diff -u -d -r1.67 ml_code_gen.m
--- compiler/ml_code_gen.m	2000/11/20 01:45:10	1.67
+++ compiler/ml_code_gen.m	2000/11/20 05:10:21
@@ -696,8 +696,8 @@
 :- interface.
 
 :- import_module hlds_module, hlds_goal.
+:- import_module code_model.
 :- import_module mlds, ml_code_util.
-:- import_module llds. % XXX needed for `code_model'.
 :- import_module io.
 
 %-----------------------------------------------------------------------------%
@@ -732,7 +732,7 @@
 
 :- import_module ml_type_gen, ml_call_gen, ml_unify_gen, ml_switch_gen.
 :- import_module ml_code_util.
-:- import_module arg_info, llds_out. % XXX needed for pragma foreign code
+:- import_module arg_info, llds, llds_out. % XXX needed for pragma foreign code
 :- import_module export, foreign. % XXX needed for pragma foreign code
 :- import_module hlds_pred, hlds_goal, hlds_data, prog_data.
 :- import_module goal_util, type_util, mode_util, builtin_ops.
Index: compiler/ml_code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_util.m,v
retrieving revision 1.30
diff -u -d -r1.30 ml_code_util.m
--- compiler/ml_code_util.m	2000/11/14 07:40:50	1.30
+++ compiler/ml_code_util.m	2000/11/20 02:13:57
@@ -17,9 +17,8 @@
 
 :- import_module prog_data.
 :- import_module hlds_module, hlds_pred.
-:- import_module rtti.
+:- import_module rtti, code_model.
 :- import_module mlds.
-:- import_module llds. % XXX for `code_model'.
 :- import_module globals.
 
 :- import_module bool, int, list, map, std_util.
Index: compiler/ml_dense_switch.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_dense_switch.m,v
retrieving revision 1.2
diff -u -d -r1.2 ml_dense_switch.m
--- compiler/ml_dense_switch.m	2000/11/16 10:48:42	1.2
+++ compiler/ml_dense_switch.m	2000/11/20 02:22:47
@@ -20,8 +20,8 @@
 
 :- import_module prog_data.
 :- import_module hlds_data, switch_util, type_util.
+:- import_module code_model.
 :- import_module mlds, ml_code_util.
-:- import_module llds. % XXX for code_model
 
 	% Should this switch be implemented as a dense jump table?
 	% If so, we return the starting and ending values for the table,
Index: compiler/ml_string_switch.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_string_switch.m,v
retrieving revision 1.2
diff -u -d -r1.2 ml_string_switch.m
--- compiler/ml_string_switch.m	2000/11/16 08:45:40	1.2
+++ compiler/ml_string_switch.m	2000/11/20 02:23:08
@@ -21,8 +21,8 @@
 
 :- import_module prog_data.
 :- import_module hlds_data, switch_util.
+:- import_module code_model.
 :- import_module mlds, ml_code_util.
-:- import_module llds. % XXX for code_model.
 
 :- pred ml_string_switch__generate(cases_list::in, prog_var::in,
 		code_model::in, can_fail::in, prog_context::in,
Index: compiler/ml_switch_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_switch_gen.m,v
retrieving revision 1.4
diff -u -d -r1.4 ml_switch_gen.m
--- compiler/ml_switch_gen.m	2000/11/16 08:45:41	1.4
+++ compiler/ml_switch_gen.m	2000/11/20 02:14:58
@@ -62,8 +62,10 @@
 
 :- interface.
 
-:- import_module prog_data, hlds_goal, hlds_data, mlds, ml_code_util.
-:- import_module llds. % XXX for code_model
+:- import_module prog_data.
+:- import_module hlds_goal, hlds_data.
+:- import_module code_model.
+:- import_module mlds, ml_code_util.
 :- import_module globals.
 
 :- import_module list.
Index: compiler/ml_tag_switch.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_tag_switch.m,v
retrieving revision 1.2
diff -u -d -r1.2 ml_tag_switch.m
--- compiler/ml_tag_switch.m	2000/11/16 08:45:41	1.2
+++ compiler/ml_tag_switch.m	2000/11/20 02:24:18
@@ -17,8 +17,8 @@
 
 :- import_module prog_data.
 :- import_module hlds_data, switch_util.
+:- import_module code_model.
 :- import_module mlds, ml_code_util.
-:- import_module llds. % XXX for code_model
 
 :- import_module list.
 
Index: compiler/ml_unify_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_unify_gen.m,v
retrieving revision 1.24
diff -u -d -r1.24 ml_unify_gen.m
--- compiler/ml_unify_gen.m	2000/11/15 04:44:58	1.24
+++ compiler/ml_unify_gen.m	2000/11/20 02:24:25
@@ -17,8 +17,8 @@
 
 :- import_module prog_data.
 :- import_module hlds_module, hlds_pred, hlds_data, hlds_goal.
+:- import_module code_model.
 :- import_module mlds, ml_code_util.
-:- import_module llds. % XXX for `code_model'
 
 %-----------------------------------------------------------------------------%
 
Index: compiler/opt_debug.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/opt_debug.m,v
retrieving revision 1.109
diff -u -d -r1.109 opt_debug.m
--- compiler/opt_debug.m	2000/11/01 05:12:07	1.109
+++ compiler/opt_debug.m	2000/11/20 04:20:56
@@ -14,8 +14,9 @@
 
 :- interface.
 
-:- import_module vn_type, vn_table, livemap.
-:- import_module llds, rtti, builtin_ops, atsort.
+:- import_module llds, vn_type, vn_table, livemap.
+:- import_module code_model, rtti, builtin_ops.
+:- import_module atsort.
 
 :- import_module io, bool, list, assoc_list, std_util.
 
@@ -194,8 +195,10 @@
 
 :- implementation.
 
-:- import_module llds_out, opt_util, vn_util, hlds_pred, globals, options.
 :- import_module prog_out.
+:- import_module hlds_pred.
+:- import_module llds_out, opt_util, vn_util.
+:- import_module globals, options.
 
 :- import_module int, set, map, string.
 
Index: compiler/par_conj_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/par_conj_gen.m,v
retrieving revision 1.7
diff -u -d -r1.7 par_conj_gen.m
--- compiler/par_conj_gen.m	2000/09/04 22:33:46	1.7
+++ compiler/par_conj_gen.m	2000/11/20 04:14:00
@@ -96,7 +96,7 @@
 
 :- interface.
 
-:- import_module hlds_goal, llds, code_info.
+:- import_module hlds_goal, code_model, llds, code_info.
 :- import_module list.
 
 :- pred par_conj_gen__generate_par_conj(list(hlds_goal), hlds_goal_info,
Index: compiler/pragma_c_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/pragma_c_gen.m,v
retrieving revision 1.38
diff -u -d -r1.38 pragma_c_gen.m
--- compiler/pragma_c_gen.m	2000/09/20 00:21:52	1.38
+++ compiler/pragma_c_gen.m	2000/11/20 04:14:28
@@ -21,8 +21,11 @@
 
 :- interface.
 
-:- import_module hlds_goal, hlds_pred, prog_data.
+:- import_module prog_data.
+:- import_module hlds_goal, hlds_pred.
+:- import_module code_model.
 :- import_module llds, code_info.
+
 :- import_module list, std_util.
 
 :- pred pragma_c_gen__generate_pragma_c_code(code_model::in,
Index: compiler/rtti.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/rtti.m,v
retrieving revision 1.10
diff -u -d -r1.10 rtti.m
--- compiler/rtti.m	2000/11/15 14:00:16	1.10
+++ compiler/rtti.m	2000/11/20 02:25:27
@@ -24,9 +24,9 @@
 
 :- interface.
 
-:- import_module llds.	% XXX for code_model
+:- import_module prog_data.
 :- import_module hlds_module, hlds_pred, hlds_data.
-:- import_module prog_data, pseudo_type_info.
+:- import_module pseudo_type_info, code_model.
 
 :- import_module bool, list, std_util.
 
Index: compiler/string_switch.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/string_switch.m,v
retrieving revision 1.35
diff -u -d -r1.35 string_switch.m
--- compiler/string_switch.m	2000/11/16 08:45:41	1.35
+++ compiler/string_switch.m	2000/11/20 05:25:55
@@ -18,7 +18,7 @@
 :- interface.
 
 :- import_module prog_data, hlds_data, hlds_goal.
-:- import_module switch_util.
+:- import_module switch_util, code_model.
 :- import_module llds, code_info.
 
 :- pred string_switch__generate(cases_list, prog_var, code_model,
Index: compiler/switch_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/switch_gen.m,v
retrieving revision 1.74
diff -u -d -r1.74 switch_gen.m
--- compiler/switch_gen.m	2000/11/16 08:45:42	1.74
+++ compiler/switch_gen.m	2000/11/20 04:15:21
@@ -45,7 +45,7 @@
 
 :- interface.
 
-:- import_module prog_data, hlds_goal, hlds_data, code_info, llds.
+:- import_module prog_data, hlds_goal, hlds_data, code_model, code_info, llds.
 :- import_module list.
 
 :- pred switch_gen__generate_switch(code_model, prog_var, can_fail, list(case),
Index: compiler/table_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/table_gen.m,v
retrieving revision 1.25
diff -u -d -r1.25 table_gen.m
--- compiler/table_gen.m	2000/10/13 13:55:59	1.25
+++ compiler/table_gen.m	2000/11/20 05:29:27
@@ -177,6 +177,7 @@
 :- import_module hlds_module, hlds_goal, hlds_data, (inst), inst_match.
 :- import_module globals, options, passes_aux, prog_data, mode_util, type_util.
 :- import_module code_util, quantification, modes, purity, prog_util.
+:- import_module code_model.
 
 :- import_module term, varset.
 :- import_module bool, list, set, map, require, std_util, int.
Index: compiler/tag_switch.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/tag_switch.m,v
retrieving revision 1.50
diff -u -d -r1.50 tag_switch.m
--- compiler/tag_switch.m	2000/11/16 08:45:43	1.50
+++ compiler/tag_switch.m	2000/11/20 05:26:23
@@ -15,7 +15,7 @@
 :- interface.
 
 :- import_module prog_data, hlds_goal, hlds_data.
-:- import_module switch_util.
+:- import_module switch_util, code_model.
 :- import_module llds, code_info.
 
 :- import_module list.
Index: compiler/trace.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/trace.m,v
retrieving revision 1.38
diff -u -d -r1.38 trace.m
--- compiler/trace.m	2000/11/07 15:17:39	1.38
+++ compiler/trace.m	2000/11/20 05:28:03
@@ -202,6 +202,8 @@
 	% for a redo event. Otherwise, generate empty code.
 :- pred trace__maybe_setup_redo_event(trace_info::in, code_tree::out) is det.
 
+	% Convert a goal path to a string, using the format documented
+	% in the Mercury user's guide.
 :- pred trace__path_to_string(goal_path::in, string::out) is det.
 
 %-----------------------------------------------------------------------------%
@@ -210,6 +212,8 @@
 
 :- import_module continuation_info, trace_params, type_util, llds_out, tree.
 :- import_module (inst), instmap, inst_match, code_util, mode_util, options.
+:- import_module code_model.
+
 :- import_module list, bool, int, string, map, std_util, require, term, varset.
 
 	% Information specific to a trace port.
Index: compiler/unify_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unify_gen.m,v
retrieving revision 1.111
diff -u -d -r1.111 unify_gen.m
--- compiler/unify_gen.m	2000/10/06 10:18:36	1.111
+++ compiler/unify_gen.m	2000/11/20 04:14:52
@@ -18,8 +18,10 @@
 
 :- interface.
 
-:- import_module hlds_goal, hlds_data, llds, code_info.
 :- import_module prog_data.
+:- import_module hlds_goal, hlds_data.
+:- import_module code_model.
+:- import_module llds, code_info.
 
 :- type test_sense
 	--->	branch_on_success
Index: compiler/unique_modes.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unique_modes.m,v
retrieving revision 1.68
diff -u -d -r1.68 unique_modes.m
--- compiler/unique_modes.m	2000/11/17 17:48:50	1.68
+++ compiler/unique_modes.m	2000/11/20 05:28:59
@@ -112,8 +112,8 @@
 	% If the goal is not nondet, then nothing is nondet-live,
 	% so reset the bag of nondet-live vars to be empty.
 	%
-	goal_info_get_code_model(GoalInfo0, CodeModel),
-	( CodeModel = model_non ->
+	goal_info_get_determinism(GoalInfo0, Detism),
+	( determinism_components(Detism, _, at_most_many) ->
 		ModeInfo2 = ModeInfo1
 	;
 		mode_info_set_nondet_live_vars([], ModeInfo1, ModeInfo2)
@@ -295,9 +295,9 @@
 		% disjunct, in unique_modes__check_disj.
 		%
 		{ goal_info_get_nonlocals(GoalInfo0, NonLocals) },
-		{ goal_info_get_code_model(GoalInfo0, CodeModel) },
+		{ goal_info_get_determinism(GoalInfo0, Determinism) },
 		% does this disjunction create a choice point?
-		( { CodeModel = model_non } ->
+		( { determinism_components(Determinism, _, at_most_many) } ->
 			mode_info_add_live_vars(NonLocals),
 			make_all_nondet_live_vars_mostly_uniq,
 			mode_info_remove_live_vars(NonLocals)
@@ -309,7 +309,7 @@
 		% Now just modecheck each disjunct in turn, and then
 		% merge the resulting instmaps.
 		%
-		unique_modes__check_disj(List0, CodeModel, NonLocals,
+		unique_modes__check_disj(List0, Determinism, NonLocals,
 			List, InstMapList),
 		instmap__merge(NonLocals, InstMapList, disj)
 	),
@@ -436,7 +436,6 @@
 	;
 		NeverSucceeds = no
 	},
-	{ determinism_to_code_model(Det, CodeModel) },
 
 	{
 		GenericCall = higher_order(_, _, _),
@@ -462,7 +461,7 @@
 	},
 
 	unique_modes__check_call_modes(Args, Modes, ArgOffset,
-		CodeModel, NeverSucceeds),
+		Det, NeverSucceeds),
 	{ Goal = generic_call(GenericCall, Args, Modes, Det) },
 	mode_info_unset_call_context,
 	mode_checkpoint(exit, "generic_call").
@@ -549,10 +548,11 @@
 		PredInfo, ProcInfo),
 	compute_arg_offset(PredInfo, ArgOffset),
 	proc_info_argmodes(ProcInfo, ProcArgModes0),
-	proc_info_interface_code_model(ProcInfo, CodeModel),
+	proc_info_interface_determinism(ProcInfo, InterfaceDeterminism),
 	proc_info_never_succeeds(ProcInfo, NeverSucceeds),
 	unique_modes__check_call_modes(ArgVars, ProcArgModes0, ArgOffset,
-			CodeModel, NeverSucceeds, ModeInfo1, ModeInfo2),
+			InterfaceDeterminism, NeverSucceeds,
+			ModeInfo1, ModeInfo2),
 
 	%
 	% see whether or not that worked
@@ -608,12 +608,12 @@
 	% inst was unique.
 
 :- pred unique_modes__check_call_modes(list(prog_var), list(mode), int,
-		code_model, bool, mode_info, mode_info).
+		determinism, bool, mode_info, mode_info).
 :- mode unique_modes__check_call_modes(in, in, in, in, in,
 			mode_info_di, mode_info_uo) is det.
 
 unique_modes__check_call_modes(ArgVars, ProcArgModes, ArgOffset,
-		CodeModel, NeverSucceeds, ModeInfo0, ModeInfo) :-
+		Determinism, NeverSucceeds, ModeInfo0, ModeInfo) :-
 	mode_info_get_module_info(ModeInfo0, ModuleInfo),
 	mode_list_get_initial_insts(ProcArgModes, ModuleInfo,
 				InitialInsts),
@@ -639,7 +639,7 @@
 		% If so, mark all the currently nondet-live variables
 		% whose inst is `unique' as instead being only `mostly_unique'.
 		%
-		( CodeModel = model_non ->
+		( determinism_components(Determinism, _, at_most_many) ->
 			make_all_nondet_live_vars_mostly_uniq(ModeInfo2,
 				ModeInfo)
 		;
@@ -754,22 +754,22 @@
 	% the original instmap before processing the next one.
 	% Collect up a list of the resulting instmaps.
 
-:- pred unique_modes__check_disj(list(hlds_goal), code_model, set(prog_var),
+:- pred unique_modes__check_disj(list(hlds_goal), determinism, set(prog_var),
 		list(hlds_goal), list(instmap), mode_info, mode_info).
 :- mode unique_modes__check_disj(in, in, in, out, out,
 		mode_info_di, mode_info_uo) is det.
 
 unique_modes__check_disj([], _, _, [], []) --> [].
-unique_modes__check_disj([Goal0 | Goals0], DisjCodeModel, DisjNonLocals,
+unique_modes__check_disj([Goal0 | Goals0], DisjDetism, DisjNonLocals,
 		[Goal | Goals], [InstMap | InstMaps]) -->
 	mode_info_dcg_get_instmap(InstMap0),
 	(
 		%
 		% If the disjunction was model_nondet, then we already marked
 		% all the non-locals as only being mostly-unique, so we
-		% don't need to do anything speical here...
+		% don't need to do anything special here...
 		%
-		{ DisjCodeModel \= model_non },
+		{ \+ determinism_components(DisjDetism, _, at_most_many) },
 
 		%
 		% ... but for model_semi or model_det disjunctions, if the
@@ -791,7 +791,7 @@
 	unique_modes__check_goal(Goal0, Goal),
 	mode_info_dcg_get_instmap(InstMap),
 	mode_info_set_instmap(InstMap0),
-	unique_modes__check_disj(Goals0, DisjCodeModel, DisjNonLocals,
+	unique_modes__check_disj(Goals0, DisjDetism, DisjNonLocals,
 		Goals, InstMaps).
 
 %-----------------------------------------------------------------------------%

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions:          mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------



More information about the developers mailing list