[m-dev.] [reuse] diff: structure reuse pragma's should update HLDS

Nancy Mazur Nancy.Mazur at cs.kuleuven.ac.be
Fri Oct 13 02:25:25 AEDT 2000


Hi,


===================================================================


Estimated hours taken: 0.10

	Fix make_hlds so that the structure reuse pragma's update the HLDS with their
	information. 

make_hlds.m:
	Fix make_hlds so that the structure reuse pragma's update the HLDS with their
	information. 
	
sr_split.m:
	Add predicate create_reuse_pred to the interface. This is needed when
	reading in the reuse_info pragma's (make_hlds). 


Index: make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.347.2.5
diff -u -r1.347.2.5 make_hlds.m
--- make_hlds.m	2000/10/12 15:03:35	1.347.2.5
+++ make_hlds.m	2000/10/12 15:18:08
@@ -99,10 +99,12 @@
 :- import_module fact_table, purity, goal_util, term_util, export, llds.
 :- import_module error_util.
 :- import_module pa_run, pa_alias_as.
+:- import_module sr_data, sr_split.
 
 :- import_module string, char, int, set, bintree, map, multi_map, require.
 :- import_module bag, term, varset, getopt, assoc_list, term_io.
 
+
 parse_tree_to_hlds(module(Name, Items), MQInfo0, EqvMap, Module, QualInfo,
 		UndefTypes, UndefModes) -->
 	globals__io_get_globals(Globals),
@@ -535,16 +537,11 @@
                                         HeadVars,MaybeAlias, Module0, Module)
 		
 	;
-		{ Pragma = sr_reuse_info(_PredOrFunc, _SymName, _ModeList,
-			_HeadVars, _TREUSE, _MaybeReuseSymName) },
-		{ Module = Module0 }
-		/** DO NOTHING
 		{ Pragma = sr_reuse_info(PredOrFunc, SymName, ModeList,
-			HeadVars, TREUSE, MaybeReuseSymName) },
+			HeadVars, Memo, MaybeReuseSymName) },
 		add_pragma_reuse_info( PredOrFunc, SymName, ModeList, 
-					HeadVars, TREUSE, MaybeReuseSymName,
+					HeadVars, Memo, MaybeReuseSymName,
 					Module0, Module)
-		**/
 	;
 		{ Pragma = terminates(Name, Arity) },
 		add_pred_marker(Module0, "terminates", Name, Arity,
@@ -1486,9 +1483,8 @@
 
 %-----------------------------------------------------------------------------%
 
-/**********
 :- pred add_pragma_reuse_info( pred_or_func, sym_name, list(mode),
-		list(var(T)), sr_reuse__tabled_reuse, maybe(sym_name),
+		list(var(T)), sr_data__memo_reuse, maybe(sym_name),
 		module_info, module_info, 
 		io__state, io__state).
 :- mode add_pragma_reuse_info( in, in, in, in, in, in, in, out, di, uo) 
@@ -1519,9 +1515,10 @@
 			{ list__map( term__coerce_var, HeadVars, CHeadVars )},
 			{ map__from_corresponding_lists(CHeadVars,
 				ProcHeadVars, MapHeadVars) },
-			{ sr_reuse__tabled_reuse_rename( MapHeadVars, TREUSE, 
+			{ sr_data__memo_reuse_rename( MapHeadVars, TREUSE, 
 						RenTREUSE) },
-			{ create_reuse_pred(proc(PredId, ProcId), RenTREUSE,
+			{ sr_split__create_reuse_pred(proc(PredId, ProcId),
+					RenTREUSE,
 					no, Module0, Module) }
 		;
 
@@ -1552,8 +1549,6 @@
 	   io__set_exit_status(1)
 	   % { module_info_incr_errors(Module0, Module) }
 	).
-
-************/
 
 %-----------------------------------------------------------------------------%
 
Index: sr_split.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_split.m,v
retrieving revision 1.1.2.1
diff -u -r1.1.2.1 sr_split.m
--- sr_split.m	2000/10/12 15:03:48	1.1.2.1
+++ sr_split.m	2000/10/12 15:18:26
@@ -15,6 +15,7 @@
 :- interface.
 
 :- import_module hlds_module, io.
+:- import_module hlds_pred, sr_data, std_util, hlds_goal.
 
 	% create_multiple_versions( VirginHLDS, ReuseHLDS, FinalHLDS ).
 	% Starting from the VirginHLDS, it computes a new HLDS where for
@@ -24,6 +25,9 @@
 :- pred sr_split__create_multiple_versions( module_info::in, module_info::in,
 		module_info::out, io__state::di, io__state::uo) is det.
 
+:- pred create_reuse_pred(pred_proc_id::in, memo_reuse::in,
+		maybe(hlds_goal)::in,
+		module_info::in, module_info::out) is det.
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
 
@@ -131,6 +135,40 @@
 	).
 
 	
+create_reuse_pred(PRED_PROC_ID, TREUSE, MaybeHLDS_GOAL, HLDSin, HLDSout) :-
+	module_info_pred_proc_info(HLDSin, PRED_PROC_ID, PredInfo0, 
+					ProcInfo0),
+	( memo_reuse_is_conditional(TREUSE) ->
+		create_reuse_pred(TREUSE, MaybeHLDS_GOAL, PredInfo0, ProcInfo0,
+				ReusePredInfo, _ReuseProcInfo,
+				ReuseProcId, ReuseName),
+
+		module_info_get_predicate_table(HLDSin, PredTable0),
+		predicate_table_insert(PredTable0, ReusePredInfo,
+				ReusePredId, PredTable),
+		module_info_structure_reuse_info(HLDSin, StrReuseInfo0),
+		StrReuseInfo0 = structure_reuse_info(ReuseMap0),
+		map__det_insert(ReuseMap0, PRED_PROC_ID,
+				proc(ReusePredId, ReuseProcId) - ReuseName,
+				ReuseMap),
+		StrReuseInfo = structure_reuse_info(ReuseMap),
+		module_info_set_structure_reuse_info(HLDSin,
+				StrReuseInfo, HLDSin1),
+		module_info_set_predicate_table(HLDSin1, PredTable, HLDSout)
+	% ; contains_unconditional_reuse(TREUSE) ->
+	;
+		proc_info_set_reuse_information(ProcInfo0, 
+						TREUSE, ProcInfo1),
+		(
+			MaybeHLDS_GOAL = yes(HLDS_GOAL),
+			proc_info_set_goal(ProcInfo1, HLDS_GOAL, ProcInfo)
+		;
+			MaybeHLDS_GOAL = no,
+			ProcInfo = ProcInfo1
+		),
+		module_info_set_pred_proc_info(HLDSin, PRED_PROC_ID, 
+				PredInfo0, ProcInfo, HLDSout)
+	).
 
 :- pred create_reuse_pred(memo_reuse::in, maybe(hlds_goal)::in,
 		pred_info::in, proc_info::in,

--------------------------------------------------------------------------
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