[m-rev.] [reuse] trivial diff: remove sr_util, clean sr_direct.

Nancy Mazur Nancy.Mazur at cs.kuleuven.ac.be
Wed Jun 30 14:42:31 AEST 2004


Hi,


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


Estimated hours taken: 0.5
Branches: reuse

Clean up sr_util (which boils down to removing the file altogether),
and a first clean up of module sr_direct.

make_hlds.m:
pa_alias.m:
sr_data.m:
sr_dead.m:
sr_direct.m:
sr_indirect.m:
sr_top.m:
sr_util.m:
structure_reuse.m:



Index: make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.347.2.26
diff -u -r1.347.2.26 make_hlds.m
--- make_hlds.m	28 Jun 2004 06:56:39 -0000	1.347.2.26
+++ make_hlds.m	30 Jun 2004 04:37:48 -0000
@@ -120,7 +120,6 @@
 :- import_module possible_alias.
 :- import_module possible_alias__pa_run.
 :- import_module possible_alias__pa_alias_as.
-:- import_module possible_alias__pa_sr_util.
 :- import_module structure_reuse.
 :- import_module structure_reuse__sr_data.
 :- import_module structure_reuse__sr_split.
Index: pa_alias.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_alias.m,v
retrieving revision 1.1.2.21
diff -u -r1.1.2.21 pa_alias.m
--- pa_alias.m	25 Jun 2004 07:11:35 -0000	1.1.2.21
+++ pa_alias.m	30 Jun 2004 04:37:49 -0000
@@ -56,7 +56,6 @@
 :- import_module parse_tree__prog_io_pasr.
 :- import_module possible_alias__pa_datastruct.
 :- import_module possible_alias__pa_selector.
-:- import_module possible_alias__pa_sr_util.
 
 :- import_module varset, require, int, map, std_util, string.
 
Index: sr_data.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_data.m,v
retrieving revision 1.1.2.30
diff -u -r1.1.2.30 sr_data.m
--- sr_data.m	29 Jun 2004 05:12:22 -0000	1.1.2.30
+++ sr_data.m	30 Jun 2004 04:38:00 -0000
@@ -188,7 +188,6 @@
 :- import_module possible_alias__pa_alias_as.
 :- import_module possible_alias__pa_datastruct.
 :- import_module possible_alias__pa_sr_util.
-:- import_module structure_reuse__sr_util.
 
 :- import_module list, string, require, varset, bool, assoc_list.
 %-----------------------------------------------------------------------------%
@@ -448,13 +447,10 @@
 	->
 		Acc = Acc0
 	;
-		list_ho_member(reuse_condition_equal, 
-				Condition, 
-				Acc0)
-	->
-		Acc = Acc0
-	;
-		Acc = [Condition | Acc0]
+		% Remove all the occurrences of Condition in Acc0, and then add
+		% the Condition back to the list. 
+		list__filter(reuse_condition_equal(Condition), Acc0, _, Acc1),
+		Acc = [Condition | Acc1]
 	).
 		
 
@@ -464,20 +460,16 @@
 memo_reuse_equal(yes(C1), yes(C2)):- 
 	list__length(C1, L),
 	list__length(C2, L), 
-	list__filter(
-		pred(COND::in) is semidet :- 
+	list__foldl(
+		pred(Cond::in, Conditions0::in, Conditions::out) is det :- 
 		    (
-			(sr_util__list_ho_member(reuse_condition_equal,
-					COND, 	
-					C1)
-			-> 
-				fail
-			; 
-				true
-			)
+		    	% remove all the occurrences of Cond from the
+			% accumulator. 
+		    	list__filter(reuse_condition_equal(Cond), 
+				Conditions0, _, Conditions)
 		   ),
-		C2, 
-		[]).
+		C1, C2, Result), 
+	Result = []. 
 			
 memo_reuse_init(no).
 memo_reuse_top(no).
Index: sr_dead.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_dead.m,v
retrieving revision 1.1.2.24
diff -u -r1.1.2.24 sr_dead.m
--- sr_dead.m	24 Jun 2004 06:05:10 -0000	1.1.2.24
+++ sr_dead.m	30 Jun 2004 04:38:00 -0000
@@ -40,7 +40,6 @@
 :- import_module possible_alias__pa_run.
 :- import_module structure_reuse__sr_data.
 :- import_module structure_reuse__sr_live.
-:- import_module structure_reuse__sr_util.
 
 :- import_module assoc_list, int, require. 
 :- import_module set, list, map, std_util.
@@ -63,7 +62,7 @@
 annotate_goal(ProcInfo, HLDS, AliasTable, Expr0 - Info0, Goal,
 		Pool0, Pool, Alias0, Alias) :- 
 	Expr0 = conj(Goals0),
-	sr_util__list_map_foldl2(
+	list__map_foldl2(
 		annotate_goal(ProcInfo, HLDS, AliasTable),
 		Goals0, Goals,
 		Pool0, Pool,
@@ -95,7 +94,7 @@
 			Pool0, Pool, Alias0, Alias) :- 
 	Expr0 = switch(A, B, Cases0),
 	goal_info_get_outscope(Info0, Outscope), 
-	sr_util__list_map3(annotate_case(ProcInfo, HLDS, AliasTable, 
+	list__map3(annotate_case(ProcInfo, HLDS, AliasTable, 
 			Pool0, Alias0),
 			Cases0, Cases, ListPools, ListAliases),
 	dead_cell_pool_least_upper_bound_disj(Outscope, ListPools, Pool), 
@@ -130,7 +129,7 @@
 		Pool = Pool0, 
 		Alias = Alias0
 	;
-		list_map3(
+		list__map3(
 			pred(Gin::in, Gout::out, P::out, A::out)
 				is det :- 
 			(
Index: sr_direct.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_direct.m,v
retrieving revision 1.1.2.21
diff -u -r1.1.2.21 sr_direct.m
--- sr_direct.m	24 Jun 2004 06:05:10 -0000	1.1.2.21
+++ sr_direct.m	30 Jun 2004 04:38:00 -0000
@@ -55,86 +55,83 @@
 :- import_module require.
 
 	% The direct-reuse analysis consists of three steps: 
-	% 1. pre-annotations (local forward use, local backward use)
-	% 2. 'deadness' analysis, i.e. identifying where datastructures
-	% potentially die. 
-	% 3. 'choice' analysis, i.e. identify where dead datastructure can be
-	% reused. 
-process_proc(AliasTable, PredId, ProcId, 
-		ProcInfo0, ProcInfo, ModuleInfo0, ModuleInfo) -->
-	% Some pre-processing: 
-	% - Initialise the reuse information.
-	% - Annotate goals with local forward use (lfu).
-	% - Annotate goals with local backward use (lbu). 
-	% - Annotate the goals with their goal-paths (used to identify the
-	% unifications, later in the choice analysis)
-	% XXX these goal-paths should become the main way of identifying the
-	% places of reuse, instead of annotating the actual goals.
-	{ sr_lfu__process_proc(ProcInfo0, ProcInfo1) },
-	{ sr_lbu__process_proc(ModuleInfo0, ProcInfo1, ProcInfo2b) },
-	{ goal_path__fill_slots(ProcInfo2b, ModuleInfo0, ProcInfo2) }, 
+	% 1. pre-annotate the analysed goal with lfu and lbu information. 
+	% 2. determine where datastructures die, i.e. have a sort of "deadness"
+	%  	analyis. 
+	% 3. determine how to reuse the detected dead data structures. This is
+	% 	the so called "choice analysis". 
+	% 
+	% XXX 
+	% During the choice analysis, program points are identified by the
+	% goal-paths leading to thes points. This should become the main way of
+	% identifying placed of reuse, instead of annotating the actual goals. 
+process_proc(AliasTable, PredId, ProcId, !ProcInfo, !ModuleInfo, !IO) :- 
+	globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO),
+
+	sr_lfu__process_proc(!ProcInfo), 
+	sr_lbu__process_proc(!.ModuleInfo, !ProcInfo), 
+	goal_path__fill_slots(!.ProcInfo, !.ModuleInfo, !:ProcInfo),
 
-	globals__io_lookup_bool_option(very_verbose, VeryVerbose),
 
-	% After the preliminary annotations, perform the actual analysis of the
-	% procedure goal. 
 	passes_aux__write_proc_progress_message("% Analysing ", 
-			PredId, ProcId, ModuleInfo0), 
+			PredId, ProcId, !.ModuleInfo, !IO), 
 
-	{ proc_info_goal(ProcInfo2, Goal0) },
+	proc_info_goal(!.ProcInfo, Goal0),
 
 	% 'Deadness' analysis: determine the deconstructions in which data
 	% structures potentially die. 
-	passes_aux__maybe_write_string(VeryVerbose, "%\tdeadness analysis..."),
-	{ sr_dead__process_goal(PredId, ProcInfo0, ModuleInfo0, 
-			AliasTable, Goal0,Goal1) },
-	passes_aux__maybe_write_string(VeryVerbose, "done.\n"),
+	passes_aux__maybe_write_string(VeryVerbose, 
+		"%\tdeadness analysis...", !IO),
+	sr_dead__process_goal(PredId, !.ProcInfo, !.ModuleInfo, 
+			AliasTable, Goal0, Goal1) ,
+	passes_aux__maybe_write_string(VeryVerbose, "done.\n", !IO),
 
 	% 'Choice' analysis: determine how the detected dead data structures
 	% can be reused locally. 
-	passes_aux__maybe_write_string(VeryVerbose, "%\tchoice analysis..."),
-	{ proc_info_vartypes(ProcInfo0, VarTypes) }, 
+	passes_aux__maybe_write_string(VeryVerbose, 
+		"%\tchoice analysis...", !IO),
+	proc_info_vartypes(!.ProcInfo, VarTypes), 
 
 	% XXX Getting the strategy also performs the check whether the
 	% arguments given to the mmc were correct. This is definitely not the
 	% right moment to check these arguments. Should be done way earlier. 
-	sr_choice_util__get_strategy(Strategy, ModuleInfo0, ModuleInfo),
-	{ Strategy = strategy(Constraint, Selection) },
+	sr_choice_util__get_strategy(Strategy, !ModuleInfo, !IO), 
+	Strategy = strategy(Constraint, Selection),
 	(
-		{ Selection = graph }
+		Selection = graph 
 	->
-		{ sr_choice_graphing__set_background_info(Constraint, 
-			ModuleInfo, VarTypes, Background) }, 
+		sr_choice_graphing__set_background_info(Constraint, 
+			!.ModuleInfo, VarTypes, Background), 
 		sr_choice_graphing__process_goal(Background, Goal1, Goal,
-			MaybeReuseConditions)
+			MaybeReuseConditions, !IO)
 	;
-		{ sr_choice__process_goal(Strategy, VarTypes, ModuleInfo, 
-			ProcInfo0, Goal1, Goal, MaybeReuseConditions) }
+		sr_choice__process_goal(Strategy, VarTypes, !.ModuleInfo, 
+			!.ProcInfo, Goal1, Goal, MaybeReuseConditions)
 	),
 	(
-		{ VeryVerbose = yes } 
+		VeryVerbose = yes 
 	->
 		(
-			{ MaybeReuseConditions = yes(Cs) }
+			MaybeReuseConditions = yes(Cs)
 		->
-			{ list__length(Cs, LCs) },
-			{ reuse_conditions_simplify(Cs, RCs) }, 
-			{ list__length(RCs, LRCs) }, 
-			{ string__int_to_string(LCs, LCS)}, 
-			{ string__int_to_string(LRCs, LRCS) }, 
-			{ string__append_list([" done (", LCS, " / ", 
-					LRCS, ").\n"], Msg3) }, 
-			io__write_string(Msg3)
+			list__length(Cs, LCs),
+			reuse_conditions_simplify(Cs, RCs), 
+			list__length(RCs, LRCs), 
+			string__int_to_string(LCs, LCS), 
+			string__int_to_string(LRCs, LRCS), 
+			string__append_list([" done (", LCS, " / ", 
+					LRCS, ").\n"], Msg3) , 
+			io__write_string(Msg3, !IO)
 		; 
-			io__write_string("done (no direct reuse).\n")
+			io__write_string("done (no direct reuse).\n", !IO)
 		)
 	; 
-		[]
+		true
 	), 
 	
-	{ memo_reuse_simplify(MaybeReuseConditions, MaybeReuseConditions1) },
-	{ proc_info_set_reuse_information(ProcInfo2, MaybeReuseConditions1, 
-			ProcInfo3) },
-	{ proc_info_set_goal(ProcInfo3, Goal, ProcInfo) }.
+	memo_reuse_simplify(MaybeReuseConditions, MaybeReuseConditions1),
+	proc_info_set_reuse_information(!.ProcInfo, 
+			MaybeReuseConditions1, !:ProcInfo), 
+	proc_info_set_goal(!.ProcInfo, Goal, !:ProcInfo).
 
 
Index: sr_indirect.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_indirect.m,v
retrieving revision 1.1.2.34
diff -u -r1.1.2.34 sr_indirect.m
--- sr_indirect.m	29 Jun 2004 05:12:23 -0000	1.1.2.34
+++ sr_indirect.m	30 Jun 2004 04:38:01 -0000
@@ -43,7 +43,6 @@
 :- import_module structure_reuse__sr_data.
 :- import_module structure_reuse__sr_fixpoint_table.
 :- import_module structure_reuse__sr_live.
-:- import_module structure_reuse__sr_util.
 :- import_module transform_hlds__dependency_graph.
 
 :- import_module map, list, std_util, require, set, string, bool.
Index: sr_top.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_top.m,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 sr_top.m
--- sr_top.m	29 Jun 2004 05:12:23 -0000	1.1.2.5
+++ sr_top.m	30 Jun 2004 04:38:01 -0000
@@ -77,7 +77,6 @@
 :- import_module structure_reuse__sr_profile_run.
 :- import_module structure_reuse__sr_split.
 :- import_module structure_reuse__sr_split.
-:- import_module structure_reuse__sr_util.
 
 :- import_module list, map, varset, std_util, int, bool.
 :- import_module term, require.
Index: sr_util.m
===================================================================
RCS file: sr_util.m
diff -N sr_util.m
--- sr_util.m	2 Jun 2004 10:30:55 -0000	1.1.2.5
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,132 +0,0 @@
-%-----------------------------------------------------------------------------%
-% Copyright (C) 2000-2002,2004 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:	sr_util.
-% Main authors: nancy
-% 
-%-----------------------------------------------------------------------------%
-
-:- module structure_reuse__sr_util.
-:- interface.
-
-:- import_module list.
-
-:- pred sr_util__list_drop_det(int,list(T),list(T)).
-:- mode sr_util__list_drop_det(in,in,out) is det.
-
-
-:- pred sr_util__list_map3(pred(T, T1, T2, T3), list(T), list(T1), list(T2), 
-			list(T3)).
-:- mode sr_util__list_map3(pred(in, out, out, out) is det, in, 
-			out, out, out) is det.
-
-:- pred sr_util__list_map_foldl2(
-		pred(T, T1, T2, T2, T3, T3), 
-		list(T), 
-		list(T1),
-		T2, T2, T3, T3).
-:- mode sr_util__list_map_foldl2(pred(in, out, in, out, in, out) is det,
-			in, out, in, out, in, out) is det.
-
-:- pred sr_util__list_map3_foldl(pred(T1, T2, T3, T4, T5, T5), 
-			list(T1), list(T2), list(T3), list(T4),
-			T5, T5).
-:- mode sr_util__list_map3_foldl(pred(in, out, out, out, in, out) is det,
-			in, out, out, out, in, out) is det.
-
-:- pred sr_util__list_map_foldl3(pred(T1, T2, T3, T3, T4, T4, T5, T5), 
-			list(T1), list(T2),
-			T3, T3, T4, T4, T5, T5).
-:- mode sr_util__list_map_foldl3(pred(in, out, in, out, in, out, in, out) is det,
-			in, out, in, out, in, out, in, out) is det.
-
-:- pred sr_util__list_ho_member(pred(T,T), T, list(T)).
-:- mode sr_util__list_ho_member(pred(in, in) is semidet, in, in) is semidet.
-
-%-----------------------------------------------------------------------------%
-%-----------------------------------------------------------------------------%
-
-:- implementation.
-
-:- import_module int.
-
-list_drop_det(Len,List,End):-
-        (
-                list__drop(Len,List,End0)
-        ->
-                End = End0
-        ;
-                End = List
-       ).
-	
-
-list_map3(P, L, A, B, C) :- 
-	(
-		L = [ L1 | LR ]
-	->
-		P(L1, A1, B1, C1),
-		list_map3(P, LR, AR, BR, CR),
-		A = [ A1 | AR ],
-		B = [ B1 | BR ],
-		C = [ C1 | CR ]
-	;
-		A = [],
-		B = [],
-		C = []
-	).
-
-list_map_foldl2(P, L0, L1, A0, A, B0, B) :- 
-	(
-		L0 = [ LE0 | LR0 ]
-	->
-		P(LE0, LE1, A0, A1, B0, B1), 
-		list_map_foldl2(P, LR0, LR1, A1, A, B1, B),
-		L1 = [ LE1 | LR1 ]
-	;
-		L1 = [],
-		A = A0, 
-		B = B0
-	).
-
-list_map3_foldl(P, L0, L1, L2, L3, A0, A) :- 
-	(
-		L0 = [ X | Xs ]
-	->
-		P(X, Y1, Y2, Y3, A0, A1),
-		list_map3_foldl(P, Xs, Ys1, Ys2, Ys3, A1, A),
-		L1 = [ Y1 | Ys1 ],
-		L2 = [ Y2 | Ys2 ],
-		L3 = [ Y3 | Ys3 ]
-	;
-		L1 = [],
-		L2 = [], 
-		L3 = [],
-		A = A0
-	).
-		
-list_map_foldl3(P, L1, L, A1, A, B1, B, C1, C) :-
-	(
-		L1 = [ X | Xs ]
-	->
-		P(X, Y, A1, A2, B1, B2, C1, C2),
-		list_map_foldl3(P, Xs, Ys, A2, A, B2, B, C2, C),
-		L = [ Y | Ys ]
-	;
-		L = [],
-		A = A1, 
-		B = B1, 
-		C = C1
-	).
-
-list_ho_member(EQUALITY_TEST, ELEMENT, LIST) :- 
-	LIST = [ HEAD | TAIL ],
-	(
-		EQUALITY_TEST(HEAD, ELEMENT)
-	->
-		true
-	;	
-		list_ho_member(EQUALITY_TEST, ELEMENT, TAIL)
-	).
Index: structure_reuse.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/structure_reuse.m,v
retrieving revision 1.1.2.12
diff -u -r1.1.2.12 structure_reuse.m
--- structure_reuse.m	2 Jun 2004 10:30:55 -0000	1.1.2.12
+++ structure_reuse.m	30 Jun 2004 04:38:01 -0000
@@ -25,7 +25,6 @@
 :- include_module sr_profile_run.
 :- include_module sr_split.
 :- include_module sr_top.
-:- include_module sr_util.
 
 :- import_module parse_tree.
 :- import_module hlds.


-- 
nancy.mazur at cs.kuleuven.ac.be ------------ Katholieke Universiteit Leuven -
tel: +32-16-327596 - fax: +32-16-327996 ------- Dept. of Computer Science -
--------------------------------------------------------------------------
mercury-reviews mailing list
post:  mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the reviews mailing list