[m-dev.] [reuse] diff: remove --no-static-ground-terms constraint on reuse
Peter Ross
petdr at miscrit.be
Tue Oct 17 23:33:49 AEDT 2000
Hi,
===================================================================
Estimated hours taken: 8
Remove the constraint the --infer-structure-reuse implies
--no-static-ground-terms.
handle_options.m:
--infer-structure-reuse no longer implies --no-static-ground-terms.
mercury_compile.m:
Call mark static ground terms before calling structure reuse phase
so that we know which variables are constructed static.
sr_data.m:
We cannot reuse a variable which was constructed statically.
sr_indirect.m:
Keep track of which variables are constructed statically.
Index: handle_options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/handle_options.m,v
retrieving revision 1.90.2.4
diff -u -r1.90.2.4 handle_options.m
--- handle_options.m 2000/10/09 09:10:00 1.90.2.4
+++ handle_options.m 2000/10/17 12:27:03
@@ -307,8 +307,6 @@
bool(yes)),
option_implies(infer_structure_reuse, infer_possible_aliases,
bool(yes)),
- option_implies(infer_structure_reuse, static_ground_terms,
- bool(no)),
option_implies(infer_possible_aliases, warn_missing_trans_opt_files,
bool(yes)),
option_implies(infer_possible_aliases, transitive_optimization,
Index: mercury_compile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mercury_compile.m,v
retrieving revision 1.175.2.8
diff -u -r1.175.2.8 mercury_compile.m
--- mercury_compile.m 2000/10/12 15:03:41 1.175.2.8
+++ mercury_compile.m 2000/10/17 12:27:06
@@ -1084,8 +1084,12 @@
mercury_compile__maybe_dead_procs(HLDS46, Verbose, Stats, HLDS47),
mercury_compile__maybe_dump_hlds(HLDS47, "47", "dead_procs"),
+ mercury_compile__maybe_mark_static_terms(HLDS47, Verbose, Stats,
+ HLDS47a),
+ mercury_compile__maybe_dump_hlds(HLDS47a, "47a", "mark_static"),
+
% possible aliases
- mercury_compile__possible_aliases(HLDS47, Verbose,
+ mercury_compile__possible_aliases(HLDS47a, Verbose,
Stats, HLDS48),
mercury_compile__maybe_dump_hlds(HLDS48,"48",
"possible_aliases"),
@@ -2448,9 +2452,12 @@
process_all_nonimported_nonaditi_procs, HLDS53),
mercury_compile__maybe_dump_hlds(HLDS53, "53", "simplify2"),
+ /*
mercury_compile__maybe_mark_static_terms(HLDS53, Verbose, Stats,
HLDS60),
mercury_compile__maybe_dump_hlds(HLDS60, "60", "mark_static"),
+ */
+ { HLDS60 = HLDS53 },
{ HLDS = HLDS60 },
mercury_compile__maybe_dump_hlds(HLDS, "99", "final"),
Index: sr_data.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_data.m,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 sr_data.m
--- sr_data.m 2000/10/16 09:03:48 1.1.2.9
+++ sr_data.m 2000/10/17 12:27:07
@@ -92,8 +92,8 @@
% check whether the given live_set and alias_as satisfy
% the condition for reuse.
:- pred reuse_condition_verify( proc_info, module_info,
- live_set, alias_as, reuse_condition ).
-:- mode reuse_condition_verify( in, in, in, in, in ) is semidet.
+ live_set, alias_as, set(prog_var), reuse_condition ).
+:- mode reuse_condition_verify( in, in, in, in, in, in ) is semidet.
:- pred reuse_condition_update( proc_info, module_info,
set(prog_var), set(prog_var),
@@ -119,7 +119,8 @@
:- pred memo_reuse_parse( term(T)::in, memo_reuse::out,
maybe(sym_name)::out) is semidet.
:- pred memo_reuse_verify_reuse( proc_info::in, module_info::in,
- memo_reuse::in, live_set::in, alias_as::in) is semidet.
+ memo_reuse::in, live_set::in, alias_as::in,
+ set(prog_var)::in) is semidet.
:- pred memo_reuse_is_conditional( memo_reuse::in ) is semidet.
:- pred memo_reuse_is_unconditional( memo_reuse::in) is semidet.
:- pred memo_reuse_simplify( memo_reuse::in, memo_reuse::out) is det.
@@ -266,9 +267,18 @@
io__write_string(")").
-reuse_condition_verify( _ProcInfo, _HLDS, _Live0, _Alias0, always).
-reuse_condition_verify( ProcInfo, HLDS, Live0, Alias0,
+reuse_condition_verify( _ProcInfo, _HLDS, _Live0, _Alias0, _Static, always).
+reuse_condition_verify( ProcInfo, HLDS, Live0, Alias0, Static,
condition( Nodes, LUiH, LAiH ) ):-
+
+ % We cannot reuse a variable which was statically
+ % constructed.
+ list__filter_map(
+ (pred(Node::in, Var::out) is semidet :-
+ get_var(Node, Var),
+ set__member(Var, Static)
+ ), set__to_sorted_list(Nodes), []),
+
pa_alias_as__extend( ProcInfo, HLDS, Alias0, LAiH, Alias),
pa_alias_as__live( LUiH, Live0, Alias, Live),
set__to_sorted_list(Nodes, NodesList),
@@ -588,10 +598,10 @@
error("(sr_data) condition_rest_parse: term not a functor")
).
-memo_reuse_verify_reuse( ProcInfo, HLDS, TREUSE, Live0, Alias0 ) :-
+memo_reuse_verify_reuse( ProcInfo, HLDS, TREUSE, Live0, Alias0, Static ) :-
TREUSE = yes(CONDITIONS),
list__takewhile( reuse_condition_verify( ProcInfo, HLDS,
- Live0, Alias0 ),
+ Live0, Alias0, Static ),
CONDITIONS, _, [] ).
memo_reuse_is_conditional( yes([_|_]) ).
Index: sr_indirect.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_indirect.m,v
retrieving revision 1.1.2.9
diff -u -r1.1.2.9 sr_indirect.m
--- sr_indirect.m 2000/10/17 11:19:57 1.1.2.9
+++ sr_indirect.m 2000/10/17 12:27:07
@@ -210,8 +210,10 @@
% 5. analyse_goal
analyse_goal( ProcInfo, HLDS,
Goal0, Goal,
- analysis_info(Alias0, Pool0, FPin),
- analysis_info(_Alias, Pool, FP1)),
+ analysis_info(Alias0, Pool0,
+ set__init, FPin),
+ analysis_info(_Alias, Pool,
+ _Static, FP1)),
/*
analyse_goal( ProcInfo, HLDS,
Goal0, Goal,
@@ -253,6 +255,7 @@
---> analysis_info(
alias :: alias_as,
pool :: indirect_reuse_pool,
+ static :: set(prog_var),
table :: sr_fixpoint_table__table
).
@@ -292,9 +295,17 @@
analyse_goal( ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
Expr0 = unify(_Var, _Rhs, _Mode, Unification, _Context),
+
+ % Record the statically constructed variables.
+ ( Unification = construct(Var, _, _, _,
+ construct_statically(_), _, _) ->
+ AI1 = AI0 ^ static := set__insert(AI0 ^ static, Var)
+ ;
+ AI1 = AI0
+ ),
pa_alias_as__extend_unification(ProcInfo, HLDS,
Unification, Info, AI0 ^ alias, Alias),
- AI = AI0 ^ alias := Alias,
+ AI = AI1 ^ alias := Alias,
Info = Info0,
Expr = Expr0,
Goal = Expr - Info.
@@ -305,18 +316,20 @@
(pred( case(ConsId, Gin)::in, Tuple::out,
FPin::in, FPout::out) is det :-
analyse_goal(ProcInfo, HLDS, Gin, Gout,
- analysis_info(AI0 ^ alias,
- AI0 ^ pool, FPin),
+ analysis_info(AI0 ^ alias, AI0 ^ pool,
+ AI0 ^ static, FPin),
analysis_info(NewAlias,
- NewPool, FPout)),
- Tuple = { case(ConsId, Gout), NewAlias, NewPool }
+ NewPool, NewStatic, FPout)),
+ Tuple = { case(ConsId, Gout), NewAlias, NewPool,
+ NewStatic }
),
Cases0, Tuples,
AI0 ^ table, FP),
- Cases = list__map((func({C, _A, _P}) = C), Tuples),
- ListPools = list__map((func({_G, _A, P}) = P), Tuples),
- ListAliases = list__map((func({_G, A, _P}) = A), Tuples),
+ Cases = list__map((func({C, _A, _P, _S}) = C), Tuples),
+ ListPools = list__map((func({_G, _A, P, _S}) = P), Tuples),
+ ListAliases = list__map((func({_G, A, _P, _S}) = A), Tuples),
+ ListStatic = list__map((func({_G, _A, _P, S}) = S), Tuples),
indirect_reuse_pool_least_upper_bound_disjunction(
ListPools,
@@ -324,12 +337,13 @@
pa_alias_as__least_upper_bound_list(ProcInfo, HLDS,
ListAliases,
Alias1),
+ set__power_union(set__list_to_set(ListStatic), Static),
% reduce the aliases
goal_info_get_outscope(Info, Outscope),
pa_alias_as__project_set(Outscope, Alias1, Alias),
- AI = analysis_info(Alias, Pool, FP),
+ AI = analysis_info(Alias, Pool, Static, FP),
Info = Info0,
Expr = switch(Var, CanFail, Cases, SM),
@@ -348,18 +362,20 @@
(pred( Gin::in, Tuple::out,
FPin::in, FPout::out) is det :-
analyse_goal(ProcInfo, HLDS, Gin, Gout,
- analysis_info(AI0 ^ alias,
- AI0 ^ pool, FPin),
- analysis_info(NewAlias,
- NewPool, FPout)),
- Tuple = { Gout, NewAlias, NewPool }
+ analysis_info(AI0 ^ alias, AI0 ^ pool,
+ AI0 ^ static, FPin),
+ analysis_info(NewAlias, NewPool,
+ NewStatic, FPout)),
+ Tuple = { Gout, NewAlias, NewPool, NewStatic }
),
Goals0, Tuples,
AI0 ^ table, FP),
- Goals = list__map((func({G, _A, _P}) = G), Tuples),
- ListPools = list__map((func({_G, _A, P}) = P), Tuples),
- ListAliases = list__map((func({_G, A, _P}) = A), Tuples),
+ Goals = list__map((func({G, _A, _P, _S}) = G), Tuples),
+ ListPools = list__map((func({_G, _A, P, _S}) = P), Tuples),
+ ListAliases = list__map((func({_G, A, _P, _S}) = A), Tuples),
+ ListStatic = list__map((func({_G, _A, _P, S}) = S), Tuples),
+ set__power_union(set__list_to_set(ListStatic), Static),
indirect_reuse_pool_least_upper_bound_disjunction(
ListPools,
@@ -372,7 +388,7 @@
goal_info_get_outscope(Info, Outscope),
pa_alias_as__project_set(Outscope, Alias1, Alias),
- AI = analysis_info(Alias, Pool, FP)
+ AI = analysis_info(Alias, Pool, Static, FP)
),
Info = Info0,
@@ -408,11 +424,13 @@
pa_alias_as__least_upper_bound_list(ProcInfo, HLDS,
[AI_Then ^ alias, AI_Else ^ alias],
Alias1),
+ Static = AI_Then ^ static `set__union` AI_Else ^ static,
+
% reduce the aliases
goal_info_get_outscope( Info, Outscope ),
pa_alias_as__project_set( Outscope, Alias1, Alias ),
- AI = analysis_info(Alias, Pool, AI1 ^ table),
+ AI = analysis_info(Alias, Pool, Static, AI1 ^ table),
Info = Info0,
Expr = if_then_else( Vars, Cond, Then, Else, SM),
@@ -469,7 +487,7 @@
FP = FP0
;
call_verify_reuse( ProcInfo, HLDS,
- PredId, ProcId, ActualVars, Alias0,
+ PredId, ProcId, ActualVars, Alias0, set__init,
Pool0, Pool,
Info0, Info,
FP0, FP, _)
@@ -668,24 +686,21 @@
analysis_info::in, analysis_info::out, bool::out) is det.
call_verify_reuse(ProcInfo, ModuleInfo, PredId, ProcId, ActualVars,
- GoalInfo0, GoalInfo, analysis_info(Alias0, Pool0, FP0),
- analysis_info(Alias0, Pool, FP), YesNo) :-
+ GoalInfo0, GoalInfo, analysis_info(Alias0, Pool0, Static, FP0),
+ analysis_info(Alias0, Pool, Static, FP), YesNo) :-
call_verify_reuse(ProcInfo, ModuleInfo, PredId, ProcId, ActualVars,
- Alias0, Pool0, Pool, GoalInfo0, GoalInfo,
+ Alias0, Static, Pool0, Pool, GoalInfo0, GoalInfo,
FP0, FP, YesNo).
-:- pred call_verify_reuse( proc_info, module_info, pred_id, proc_id,
- list(prog_var), alias_as,
- indirect_reuse_pool, indirect_reuse_pool,
- hlds_goal_info , hlds_goal_info,
- sr_fixpoint_table__table, sr_fixpoint_table__table,
- bool).
-:- mode call_verify_reuse( in, in, in, in, in, in,
- in, out,
- in, out,
- in, out, out) is det.
+:- pred call_verify_reuse( proc_info::in, module_info::in, pred_id::in,
+ proc_id::in, list(prog_var)::in, alias_as::in,
+ set(prog_var)::in, indirect_reuse_pool::in,
+ indirect_reuse_pool::out, hlds_goal_info::in ,
+ hlds_goal_info::out, sr_fixpoint_table__table::in,
+ sr_fixpoint_table__table::out, bool::out) is det.
call_verify_reuse( ProcInfo, HLDS, PredId0, ProcId0, ActualVars, Alias0,
+ StaticTerms,
Pool0, Pool,
Info0, Info, FP0, FP, YesNo ) :-
@@ -737,7 +752,7 @@
% static set!
memo_reuse_verify_reuse( ProcInfo, HLDS,
Memo, ActualLive_i, ActualAlias_i,
- set__init)
+ StaticTerms)
->
indirect_reuse_pool_add( HLDS, ProcInfo,
Memo, LFUi, LBUi,
--------------------------------------------------------------------------
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