[m-dev.] for review: semantic eval_method tests

Zoltan Somogyi zs at cs.mu.OZ.AU
Thu Mar 9 18:26:59 AEDT 2000


Make a separate enquery function for each possible semantic test on
eval_methods. The answers are the same now, but will be different when
tabled I/O is implemented.

compiler/hlds_pred.m:
	Make a separate enquery function for each possible semantic test on
	eval_methods.

compiler/code_gen.m:
compiler/ml_code_gen.m:
compiler/make_hlds.m:
compiler/modes.m:
compiler/table_gen.m:
	Use the new enquery functions.

Zoltan.

cvs diff: Diffing .
Index: code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/code_gen.m,v
retrieving revision 1.73
diff -u -b -r1.73 code_gen.m
--- code_gen.m	2000/02/10 04:37:29	1.73
+++ code_gen.m	2000/03/09 07:08:55
@@ -278,9 +278,7 @@
 maybe_add_tabling_pointer_var(ModuleInfo, PredId, ProcId, ProcInfo,
 		GlobalData0, GlobalData) :-
 	proc_info_eval_method(ProcInfo, EvalMethod),
-	(
-		eval_method_uses_table(EvalMethod) = yes
-	->
+	( eval_method_has_per_proc_tabling_pointer(EvalMethod) = yes ->
 		code_util__make_proc_label(ModuleInfo, PredId, ProcId,
 			ProcLabel),
 		module_info_name(ModuleInfo, ModuleName),
Index: hlds_pred.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_pred.m,v
retrieving revision 1.74
diff -u -b -r1.74 hlds_pred.m
--- hlds_pred.m	2000/03/03 06:02:23	1.74
+++ hlds_pred.m	2000/03/09 06:03:18
@@ -2070,13 +2070,24 @@
 
 	% Return true if the given evaluation method requires a
 	% stratification check.
-:- pred eval_method_need_stratification(eval_method).
-:- mode eval_method_need_stratification(in) is semidet.
+:- func eval_method_needs_stratification(eval_method) = bool.
 
-	% Return true if the given evaluation method uses a table.
-	% If so, the back-end must generate a declaration for the
-	% variable to hold the table.
-:- func eval_method_uses_table(eval_method) = bool.
+	% Return true if the given evaluation method uses a per-procedure
+	% tabling pointer. If so, the back-end must generate a declaration
+	% for the variable to hold the table.
+:- func eval_method_has_per_proc_tabling_pointer(eval_method) = bool.
+
+	% Return true if the given evaluation method requires the body
+	% of the procedure using it to be transformed by table_gen.m.
+:- func eval_method_requires_tabling_transform(eval_method) = bool.
+
+	% Return true if the given evaluation method requires the arguments
+	% of the procedure using it to be ground.
+:- func eval_method_requires_ground_args(eval_method) = bool.
+
+	% Return true if the given evaluation method requires the arguments
+	% of the procedure using it to be non-unique.
+:- func eval_method_destroys_uniqueness(eval_method) = bool.
 
 	% Return the change a given evaluation method can do to a given 
 	% determinism.
@@ -2105,16 +2116,34 @@
 eval_method_to_string(eval_loop_check,		"loop_check").
 eval_method_to_string(eval_minimal, 		"minimal_model").
 	
-eval_method_need_stratification(eval_minimal).
+eval_method_needs_stratification(eval_normal) = no.
+eval_method_needs_stratification(eval_loop_check) = no.
+eval_method_needs_stratification(eval_memo) = no.
+eval_method_needs_stratification(eval_minimal) = yes.
+
+eval_method_has_per_proc_tabling_pointer(eval_normal) = no.
+eval_method_has_per_proc_tabling_pointer(eval_loop_check) = yes.
+eval_method_has_per_proc_tabling_pointer(eval_memo) = yes.
+eval_method_has_per_proc_tabling_pointer(eval_minimal) = yes.
+
+eval_method_requires_tabling_transform(eval_normal) = no.
+eval_method_requires_tabling_transform(eval_loop_check) = yes.
+eval_method_requires_tabling_transform(eval_memo) = yes.
+eval_method_requires_tabling_transform(eval_minimal) = yes.
+
+eval_method_requires_ground_args(eval_normal) = no.
+eval_method_requires_ground_args(eval_loop_check) = yes.
+eval_method_requires_ground_args(eval_memo) = yes.
+eval_method_requires_ground_args(eval_minimal) = yes.
+
+eval_method_destroys_uniqueness(eval_normal) = no.
+eval_method_destroys_uniqueness(eval_loop_check) = yes.
+eval_method_destroys_uniqueness(eval_memo) = yes.
+eval_method_destroys_uniqueness(eval_minimal) = yes.
 
-eval_method_uses_table(eval_normal) = no.
-eval_method_uses_table(eval_memo) = yes.
-eval_method_uses_table(eval_loop_check) = yes.
-eval_method_uses_table(eval_minimal) = yes.
-
 eval_method_change_determinism(eval_normal, Detism, Detism).
-eval_method_change_determinism(eval_memo, Detism, Detism).
 eval_method_change_determinism(eval_loop_check, Detism, Detism).
+eval_method_change_determinism(eval_memo, Detism, Detism).
 eval_method_change_determinism(eval_minimal, Det0, Det) :-
 	det_conjunction_detism(semidet, Det0, Det).
 
Index: make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.324
diff -u -b -r1.324 make_hlds.m
--- make_hlds.m	2000/02/16 07:27:01	1.324
+++ make_hlds.m	2000/03/09 06:03:21
@@ -3923,7 +3923,7 @@
 	;
 		% do we have to make sure the tabled preds are stratified?
 		(
-			{ eval_method_need_stratification(EvalMethod) }
+			{ eval_method_needs_stratification(EvalMethod) = yes }
 		->
 			{ module_info_stratified_preds(ModuleInfo0, 
 				StratPredIds0) },
Index: ml_code_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_gen.m,v
retrieving revision 1.30
diff -u -b -r1.30 ml_code_gen.m
--- ml_code_gen.m	2000/02/17 16:01:27	1.30
+++ ml_code_gen.m	2000/03/09 06:03:22
@@ -765,7 +765,7 @@
 		Defns0, Defns) :-
 	proc_info_eval_method(ProcInfo, EvalMethod),
 	(
-		eval_method_uses_table(EvalMethod) = yes
+		eval_method_has_per_proc_tabling_pointer(EvalMethod) = yes
 	->
 		ml_gen_pred_label(ModuleInfo, PredId, ProcId,
 			MLDS_PredLabel, _MLDS_PredModule),
Index: modes.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modes.m,v
retrieving revision 1.239
diff -u -b -r1.239 modes.m
--- modes.m	2000/02/24 18:36:35	1.239
+++ modes.m	2000/03/09 06:03:23
@@ -2160,15 +2160,13 @@
 	{ module_info_pred_proc_info(ModuleInfo0, PredId, ProcId, 
 		_, ProcInfo) },
 	{ proc_info_eval_method(ProcInfo, EvalMethod) },
-	( { eval_method_uses_table(EvalMethod) = yes } ->
 		{ proc_info_context(ProcInfo, Context) },
 		{ eval_method_to_string(EvalMethod, EvalMethodS) },
-		globals__io_lookup_bool_option(verbose_errors, 
-			VerboseErrors),
+	globals__io_lookup_bool_option(verbose_errors, VerboseErrors),
 		{ proc_info_argmodes(ProcInfo, Modes) },
 		( 
-			\+ { only_fully_in_out_modes(Modes, 
-				ModuleInfo0) } 
+		{ eval_method_requires_ground_args(EvalMethod) = yes },
+		\+ { only_fully_in_out_modes(Modes, ModuleInfo0) } 
 		->
 			prog_out__write_context(Context),
 			io__write_string("Sorry, not implemented: `pragma "),
@@ -2183,7 +2181,7 @@
 			( { VerboseErrors = yes } ->
 				io__write_string(
 "	Tabling of predicates/functions with partially instantiated modes
-	is not currently implemented.\n")
+is not currently implemented.\n")
 			;
 				[]
 			),
@@ -2192,8 +2190,8 @@
 			{ ModuleInfo1 = ModuleInfo0 }	
 		),	
 		( 
-			\+ { only_nonunique_modes(Modes, 
-				ModuleInfo1) } 
+		{ eval_method_destroys_uniqueness(EvalMethod) = yes },
+		\+ { only_nonunique_modes(Modes, ModuleInfo1) } 
 		->
 			prog_out__write_context(Context),
 			io__write_string("Error: `pragma "),
@@ -2207,17 +2205,14 @@
 			( { VerboseErrors = yes } ->
 				io__write_string(
 "	Tabling of predicates/functions with unique modes is not allowed
-	as this would lead to a copying of the unique arguments which 
-	would result in them no longer being unique.\n")
+as this would lead to a copying of the unique arguments which 
+would result in them no longer being unique.\n")
 			;
 				[]
 			),
 			{ module_info_incr_errors(ModuleInfo1, ModuleInfo2) }
 		;
 			{ ModuleInfo2 = ModuleInfo1 }	
-		)
-	;
-		{ ModuleInfo2 = ModuleInfo0 }	
 		
 	),
 	proc_check_eval_methods(Rest, PredId, ModuleInfo2, ModuleInfo).
Index: table_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/table_gen.m,v
retrieving revision 1.16
diff -u -b -r1.16 table_gen.m
--- table_gen.m	2000/02/07 00:31:10	1.16
+++ table_gen.m	2000/03/09 06:03:24
@@ -218,9 +218,7 @@
 
 	proc_info_eval_method(ProcInfo, EvalMethod),
 
-	(
-		eval_method_uses_table(EvalMethod) = yes
-	->
+	( eval_method_requires_tabling_transform(EvalMethod) = yes ->
 		table_gen__process_proc(EvalMethod, PredId, ProcId, ProcInfo,
 			PredInfo, Module0, Module1)
 	;
cvs diff: Diffing notes
--------------------------------------------------------------------------
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