[m-rev.] [reuse] diff: small changes (beautify code)
Nancy Mazur
Nancy.Mazur at cs.kuleuven.ac.be
Fri Mar 23 21:39:09 AEDT 2001
Hi,
===================================================================
Estimated hours taken: 2
Branches: reuse
Small changes and in general fix the parentheses.
hlds_goal.m:
Document the lbu and outscope fields.
pa_alias_as.m:
Factorise the projection of the aliases unto the live-vars
at some goal (new predicate: project_on_live_vars).
sr_indirect.m:
Instead of projecting the alias_set unto the outscope
vars, project them on the live (= LFU, LBU, HVS) vars.
pa_alias_as.m:
pa_alias.m:
pa_alias_set.m:
pa_datastruct.m:
pa_prelim_run.m:
pa_run.m:
pa_selector.m:
pa_sr_util.m:
pa_util.m:
sr_direct.m:
sr_fixpoint_table.m:
sr_lbu.m:
sr_lfu.m:
sr_live.m:
sr_profile.m:
sr_profile_run.m:
sr_split.m:
sr_util.m:
sr_indirect.m:
Beautify code.
Index: hlds_goal.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.76.2.11
diff -u -r1.76.2.11 hlds_goal.m
--- hlds_goal.m 2001/03/13 09:51:44 1.76.2.11
+++ hlds_goal.m 2001/03/23 10:22:52
@@ -1182,9 +1182,27 @@
% analysis in the context of memory
% reuse.
lbu :: set(prog_var), % the local backward use set
- % XXX, documentation needed
+ % This set contains the instantiated
+ % variables that will still be needed upon
+ % backtracking (i.e. syntactically appearing
+ % in a nondet call preceding this
+ % goal.
+
outscope :: set(prog_var), % outscope-vars
- % XXX, documentation needed
+ % This is a generalisation of the
+ % concept of nonlocal variables. While
+ % nonlocals variables are limited to
+ % those variables appearing in the current
+ % goal and which are also needed outside
+ % the goal. The set of outscope vars is
+ % the set of all variables appearing outside
+ % of this goal, limited though to those
+ % variables of which the scope reaches to
+ % this goal. This information is especially
+ % being used when checking for reuse
+ % (the dead-cells being potentially reusable
+ % must be in the scope of the unification
+ % where it can be reused).
reuse :: reuse_goal_info,
% Any structure reuse information
Index: pa_alias.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_alias.m,v
retrieving revision 1.1.2.8
diff -u -r1.1.2.8 pa_alias.m
--- pa_alias.m 2001/03/15 13:11:36 1.1.2.8
+++ pa_alias.m 2001/03/23 10:22:52
@@ -76,11 +76,11 @@
print(ProcInfo, PredInfo, FrontString, EndString, Alias0) -->
{ Alias0 = D1 - D2 },
io__write_string(FrontString),
- io__write_string("pair( "),
+ io__write_string("pair("),
pa_datastruct__print(D1, ProcInfo, PredInfo),
io__write_string(" , "),
pa_datastruct__print(D2, ProcInfo, PredInfo),
- io__write_string(" ) "),
+ io__write_string(") "),
io__write_string(EndString).
%-------------------------------------------------------------------%
@@ -91,7 +91,7 @@
(
Term = term__functor(term__atom(Cons), Args, _)
->
- (
+ (
Cons = "pair"
->
(
@@ -136,7 +136,7 @@
Alias = Data1 - Data2,
pa_datastruct__get_var(Data1, Var1),
pa_datastruct__get_var(Data2, Var2),
- (
+ (
set__member(Var1, Set)
->
not(set__member(Var2, Set)),
@@ -156,12 +156,12 @@
:- pred number_args(list(prog_var)::in,
list(pair(int, prog_var))::out) is det.
number_args(Args, NumberedArgs) :-
- list__map_foldl(
+ list__map_foldl(
pred(A::in, AP::out, Nin::in, Nout::out) is det:-
- (
+ (
AP = std_util:'-'(Nin, A),
Nout = Nin + 1
- ),
+ ),
Args,
NumberedArgs,
1, _).
@@ -202,14 +202,14 @@
pred(ProgVar::in, List0::in, List::out) is det :-
(
map__lookup(FrequencyMap0, ProgVar, Positions),
- (
- ( Positions = [] ; Positions = [_] )
+ (
+ (Positions = [] ; Positions = [_])
->
List = List0
;
List = [Positions | List0]
)
- ),
+ ),
Keys,
[],
PosList).
@@ -223,7 +223,7 @@
solutions_set(two_by_two(Positions), SetPairs),
set__to_sorted_list(SetPairs, Pairs),
list__append(Pairs, List0, List)
- ),
+ ),
PositionLists,
[],
PositionPairs),
@@ -305,7 +305,7 @@
hlds_goal__goal_info_get_pre_births(Info, PreB),
keep_only_the_prebirths_v2(PreB, Args, ReducedArgs).
-:- pred keep_only_the_prebirths_v2(set( prog_var)::in,
+:- pred keep_only_the_prebirths_v2(set(prog_var)::in,
list(pair(int, prog_var))::in,
list(pair(int, prog_var))::out) is det.
@@ -321,7 +321,7 @@
(
PreB = [ X | Xs ]
->
- (
+ (
list_find(X, Arg, AllArgs, AllArgs0)
->
ACC0 = [ Arg | ACC ],
@@ -444,7 +444,7 @@
one_of_vars_is_live_ordered(ModuleInfo, ProcInfo, List, ALIAS, List_Xsx1) :-
ALIAS = Xsx - Ysy,
pa_datastruct__get_var(Ysy, Y),
- list__filter(
+ list__filter(
pred(D::in) is semidet :-
(pa_datastruct__get_var(D,Y)),
List,
@@ -455,7 +455,7 @@
% Ys1 in Y_List (sy = s1.s2)
list__filter(
pred(Ys1::in) is semidet :-
- (pa_datastruct__less_or_equal( ModuleInfo,
+ (pa_datastruct__less_or_equal(ModuleInfo,
ProcInfo, Ysy, Ys1, _s2)),
Y_List,
FY_List),
@@ -471,7 +471,7 @@
% is not minimal, while this should be somehow guaranteed).
list__filter_map(
pred(Ys1::in, S2::out) is semidet :-
- (pa_datastruct__less_or_equal( ModuleInfo,
+ (pa_datastruct__less_or_equal(ModuleInfo,
ProcInfo, Ysy, Ys1, S2)),
Y_List,
SelectorList),
Index: pa_alias_as.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_alias_as.m,v
retrieving revision 1.1.2.18
diff -u -r1.1.2.18 pa_alias_as.m
--- pa_alias_as.m 2001/03/22 19:55:34 1.1.2.18
+++ pa_alias_as.m 2001/03/23 10:22:53
@@ -48,6 +48,9 @@
:- pred project(list(prog_var), alias_as, alias_as).
:- mode project(in, in, out) is det.
+:- pred project_on_live_vars(proc_info::in, hlds_goal_info::in,
+ alias_as::in, alias_as::out) is det.
+
:- pred project_set(set(prog_var), alias_as, alias_as).
:- mode project_set(in, in, out) is det.
@@ -63,10 +66,10 @@
% to a procedure with given pred_proc_id.
% rename_call_alias(PredProcId, ModuleInfo, ActualVars,
% ActualTypes, FormalAlias, ActualAlias).
-:- pred rename_call_alias( pred_proc_id, module_info, list(prog_var),
- list( (type) ),
+:- pred rename_call_alias(pred_proc_id, module_info, list(prog_var),
+ list((type)),
alias_as, alias_as).
-:- mode rename_call_alias( in, in, in, in, in, out) is det.
+:- mode rename_call_alias(in, in, in, in, in, out) is det.
% rename abstract substitution according to a mapping
% of prog_vars (map (FROM_VARS, TO_VARS)).
@@ -279,6 +282,17 @@
set__to_sorted_list(SetVar, ListVar),
project(ListVar, ASin, ASout).
+project_on_live_vars(ProcInfo, GoalInfo, Alias0, Alias):-
+ goal_info_get_lfu(GoalInfo, LFUi),
+ goal_info_get_lbu(GoalInfo, LBUi),
+ proc_info_real_headvars(ProcInfo, ListRealHeadVars),
+ set__list_to_set(ListRealHeadVars, RealHeadVars),
+ set__union(LFUi, LBUi, IN_USEi),
+ set__union(IN_USEi, RealHeadVars, AliveVars),
+ project_set(AliveVars, Alias0, Alias).
+
+
+
collect_aliases_of_datastruct(ModuleInfo, ProcInfo, Datastruct, AS,
AliasList):-
(
@@ -483,7 +497,7 @@
(
ASin = real_as(Aliases0)
->
- (
+ (
DeathsList = []
->
ASout = ASin
@@ -503,7 +517,7 @@
from_foreign_code(ProcInfo, HLDS, Info, Attrs, Vars,
MaybeModes, Types, ForeignAlias),
(
- ( is_bottom(ForeignAlias); is_top(ForeignAlias) )
+ (is_bottom(ForeignAlias); is_top(ForeignAlias))
->
% easy extend
pa_alias_as__extend(ProcInfo, HLDS, ForeignAlias, Ain, A)
@@ -558,9 +572,9 @@
->
Alias = bottom
;
- list__map(
+ list__map(
pred(Trio::in, Type::out) is det:-
- (
+ (
Trio = trio(_, _, Type)
),
OutputVars,
@@ -937,7 +951,7 @@
VarTerm = term__variable(GenericVar),
term__coerce_var(GenericVar, ProgVar)
->
- (
+ (
parse_list_term(TypesTerm, ListTypesTerms)
->
list__map(term__coerce, ListTypesTerms, Types),
Index: pa_alias_set.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_alias_set.m,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 pa_alias_set.m
--- pa_alias_set.m 2001/03/20 17:34:48 1.1.2.2
+++ pa_alias_set.m 2001/03/23 10:22:53
@@ -40,49 +40,49 @@
%-----------------------------------------------------------------------------%
%-- exported predicates
-:- pred init( alias_set::out) is det.
+:- pred init(alias_set::out) is det.
:- func init = alias_set is det.
-:- pred is_empty( alias_set::in) is semidet.
-:- pred get_size( alias_set::in, int::out) is det.
+:- pred is_empty(alias_set::in) is semidet.
+:- pred get_size(alias_set::in, int::out) is det.
% conversion between list of aliases to alias_set's
-:- pred from_pair_alias_list( list(alias)::in, alias_set::out) is det.
-:- pred to_pair_alias_list( alias_set::in, list(alias)::out) is det.
+:- pred from_pair_alias_list(list(alias)::in, alias_set::out) is det.
+:- pred to_pair_alias_list(alias_set::in, list(alias)::out) is det.
% projection-operations. Given a list or set of prog_vars,
% keep only that part of the alias_set which relates to those
% prog_vars.
-:- pred project( list(prog_var)::in, alias_set::in, alias_set::out ) is det.
-:- pred project_set( set(prog_var)::in, alias_set::in,
+:- pred project(list(prog_var)::in, alias_set::in, alias_set::out) is det.
+:- pred project_set(set(prog_var)::in, alias_set::in,
alias_set::out) is det.
% compute all the datastructures to which a certain datastruct
% is aliased. This returns a list of datastructs.
-:- pred collect_aliases_of_datastruct( module_info::in, proc_info::in,
+:- pred collect_aliases_of_datastruct(module_info::in, proc_info::in,
pa_datastruct__datastruct::in, alias_set::in,
list(pa_datastruct__datastruct)::out) is det.
% rename the prog_vars occurring in the alias_set, using
% a map which maps the to-be-replaced-vars with unto the
% new prog_vars.
-:- pred rename( map(prog_var,prog_var)::in, alias_set::in,
+:- pred rename(map(prog_var,prog_var)::in, alias_set::in,
alias_set::out) is det.
% rename the types occurring in the alias_set, applying
% the given substitution to each of the types encountered.
-:- pred rename_types( term__substitution(tvar_type)::in,
+:- pred rename_types(term__substitution(tvar_type)::in,
alias_set::in, alias_set::out) is det.
% equality test. Needed for the fixpoint computation.
-:- pred equal( alias_set::in, alias_set::in) is semidet.
+:- pred equal(alias_set::in, alias_set::in) is semidet.
% compute the least upper bound of alias_sets.
-:- pred least_upper_bound( module_info::in, proc_info::in,
+:- pred least_upper_bound(module_info::in, proc_info::in,
alias_set::in, alias_set::in, alias_set::out) is det.
-:- pred least_upper_bound_list( module_info::in, proc_info::in,
+:- pred least_upper_bound_list(module_info::in, proc_info::in,
list(alias_set)::in, alias_set::out) is det.
- % extend( ModuleInfo, ProcInfo, NewAliasSet, OldAliasSet,
+ % extend(ModuleInfo, ProcInfo, NewAliasSet, OldAliasSet,
% ComputedAliasSet).
% Extend a given OldAliasSet with the information contained
% in the NewAliasSet. Note that order here is very important!
@@ -91,37 +91,37 @@
% with the aliases which already existed at the program point
% corresponding with this atom (the OldAliasSet).
% ==> alternating closure.
-:- pred extend( module_info::in, proc_info::in, alias_set::in,
+:- pred extend(module_info::in, proc_info::in, alias_set::in,
alias_set::in, alias_set::out) is det.
% add two alias_sets together without bothering to extend
% one against the other.
-:- pred add( alias_set::in, alias_set::in, alias_set::out) is det.
+:- pred add(alias_set::in, alias_set::in, alias_set::out) is det.
% normalize all the selectors within the alias_set and
% simplify if necessary.
-:- pred normalize( module_info::in, proc_info::in,
+:- pred normalize(module_info::in, proc_info::in,
alias_set::in, alias_set::out) is det.
- % less_or_equal( ModuleInfo, ProcInfo, AliasSet1, AliasSet2).
-:- pred less_or_equal( module_info::in, proc_info::in,
+ % less_or_equal(ModuleInfo, ProcInfo, AliasSet1, AliasSet2).
+:- pred less_or_equal(module_info::in, proc_info::in,
alias_set::in, alias_set::in) is semidet.
% remove all the information regading the given list of
% variables.
-:- pred remove_vars( list(prog_var)::in, alias_set::in,
- alias_set::out ) is det.
+:- pred remove_vars(list(prog_var)::in, alias_set::in,
+ alias_set::out) is det.
:- pred apply_widening(module_info::in, proc_info::in, alias_set::in,
alias_set::out) is det.
% printing predicates
- % print( PredInfo, ProcInfo, AliasSet, StartingString, EndString )
+ % print(PredInfo, ProcInfo, AliasSet, StartingString, EndString)
% Prints each alias as a parsable pair of datastructs, each
% alias preceded with the StartingString, and ended with the
% EndString.
-:- pred print( pred_info::in, proc_info::in, alias_set::in,
+:- pred print(pred_info::in, proc_info::in, alias_set::in,
string::in, string::in,
io__state::di, io__state::uo) is det.
@@ -173,119 +173,119 @@
%-----------------------------------------------------------------------------%
%-- predicate definitions
-pa_alias_set__init( Init ) :- Init = pa_alias_set__init.
-pa_alias_set__init = alias_set( 0, map__init ).
-pa_alias_set__is_empty( alias_set( 0, Map ) ):- map__is_empty( Map ).
-pa_alias_set__get_size( alias_set( Size, _) , Size).
+pa_alias_set__init(Init) :- Init = pa_alias_set__init.
+pa_alias_set__init = alias_set(0, map__init).
+pa_alias_set__is_empty(alias_set(0, Map)):- map__is_empty(Map).
+pa_alias_set__get_size(alias_set(Size, _) , Size).
-pa_alias_set__from_pair_alias_list( Aliases, AliasSet ):-
- pa_alias_set__new_entries( Aliases, pa_alias_set__init, AliasSet).
+pa_alias_set__from_pair_alias_list(Aliases, AliasSet):-
+ pa_alias_set__new_entries(Aliases, pa_alias_set__init, AliasSet).
-:- pred pa_alias_set__new_entries( list(alias)::in,
+:- pred pa_alias_set__new_entries(list(alias)::in,
alias_set::in, alias_set::out) is det.
-pa_alias_set__new_entries( Aliases, AliasSet0, AliasSet) :-
+pa_alias_set__new_entries(Aliases, AliasSet0, AliasSet) :-
list__foldl(
pa_alias_set__new_entry,
Aliases,
AliasSet0,
- AliasSet ).
+ AliasSet).
% Alias = From - To
% This will be entered as From = Var - Selector --> To in DataSet
-:- pred pa_alias_set__new_directed_entries( list(alias)::in,
- alias_set::in, alias_set::out ) is det.
-pa_alias_set__new_directed_entries( Aliases, AliasSet0, AliasSet):-
- list__foldl(
- pred( A::in, S0::in, S::out) is det:-
- (
+:- pred pa_alias_set__new_directed_entries(list(alias)::in,
+ alias_set::in, alias_set::out) is det.
+pa_alias_set__new_directed_entries(Aliases, AliasSet0, AliasSet):-
+ list__foldl(
+ pred(A::in, S0::in, S::out) is det:-
+ (
A = From - To,
- pa_alias_set__new_entry( From, To, S0, S )
- ),
+ pa_alias_set__new_entry(From, To, S0, S)
+ ),
Aliases,
AliasSet0,
- AliasSet ).
+ AliasSet).
-:- pred pa_alias_set__new_entry( alias::in, alias_set::in,
+:- pred pa_alias_set__new_entry(alias::in, alias_set::in,
alias_set::out) is det.
-pa_alias_set__new_entry( Alias, AliasSet0, AliasSet ):-
+pa_alias_set__new_entry(Alias, AliasSet0, AliasSet):-
Alias = Data1 - Data2,
- pa_alias_set__new_entry( Data1, Data2, AliasSet0, AliasSet1 ),
+ pa_alias_set__new_entry(Data1, Data2, AliasSet0, AliasSet1),
(
- pa_datastruct__equal( Data1, Data2 )
+ pa_datastruct__equal(Data1, Data2)
->
AliasSet = AliasSet1
;
- pa_alias_set__new_entry( Data2, Data1, AliasSet1, AliasSet )
+ pa_alias_set__new_entry(Data2, Data1, AliasSet1, AliasSet)
).
-:- pred pa_alias_set__new_entry( datastruct::in, datastruct::in,
- alias_set::in, alias_set::out ) is det.
-pa_alias_set__new_entry( FromData, ToData, AliasSet0, AliasSet ):-
- AliasSet0 = alias_set( Size0, Map0 ),
- get_var( FromData, Var ),
- get_selector( FromData, Selector),
+:- pred pa_alias_set__new_entry(datastruct::in, datastruct::in,
+ alias_set::in, alias_set::out) is det.
+pa_alias_set__new_entry(FromData, ToData, AliasSet0, AliasSet):-
+ AliasSet0 = alias_set(Size0, Map0),
+ get_var(FromData, Var),
+ get_selector(FromData, Selector),
(
- map__search( Map0, Var, Selectors0 )
+ map__search(Map0, Var, Selectors0)
->
- alias_set2_new_entry( Selector, ToData, Selectors0, Added,
- Selectors ),
+ alias_set2_new_entry(Selector, ToData, Selectors0, Added,
+ Selectors),
(
Added = yes
->
- map__det_update( Map0, Var, Selectors, Map ),
+ map__det_update(Map0, Var, Selectors, Map),
Size = Size0 + 1
;
Map = Map0,
Size = Size0
)
;
- alias_set2_empty( Selectors0 ),
- alias_set2_new_entry( Selector, ToData, Selectors0,
- Selectors ),
- map_det_insert( Map0, Var, Selectors, Map,
+ alias_set2_empty(Selectors0),
+ alias_set2_new_entry(Selector, ToData, Selectors0,
+ Selectors),
+ map_det_insert(Map0, Var, Selectors, Map,
"(pa_alias_set) pa_alias_set__new entry/4"),
Size = Size0 + 1
),
- AliasSet = alias_set( Size, Map ).
+ AliasSet = alias_set(Size, Map).
-to_pair_alias_list( AliasSet, Aliases ):-
- AliasSet = alias_set( _, Map ),
- map__to_assoc_list( Map, Pairs ),
+to_pair_alias_list(AliasSet, Aliases):-
+ AliasSet = alias_set(_, Map),
+ map__to_assoc_list(Map, Pairs),
list__foldl(
- pred( Pair::in, S0::in, S::out ) is det :-
+ pred(Pair::in, S0::in, S::out) is det :-
(
Pair = Var - Selectors,
- term__var_to_int( Var, VarInt),
- alias_set2_unfold( Selectors, SelDatas ),
+ term__var_to_int(Var, VarInt),
+ alias_set2_unfold(Selectors, SelDatas),
list__filter_map(
- pred( SelData::in, Alias::out ) is semidet:-
+ pred(SelData::in, Alias::out) is semidet:-
(
SelData = Selector - Datastruct,
- pa_datastruct__get_var( Datastruct,
- DataVar ),
- term__var_to_int( DataVar,
+ pa_datastruct__get_var(Datastruct,
+ DataVar),
+ term__var_to_int(DataVar,
DataVarInt),
DataVarInt =< VarInt,
- pa_datastruct__create( Var,
+ pa_datastruct__create(Var,
Selector, NewDatastruct),
Alias = NewDatastruct - Datastruct
- ),
+ ),
SelDatas,
- Aliases0 ),
- set__insert_list( S0, Aliases0, S )
- ),
+ Aliases0),
+ set__insert_list(S0, Aliases0, S)
+ ),
Pairs,
set__init,
AliasesSet),
- set__to_sorted_list( AliasesSet, Aliases ).
+ set__to_sorted_list(AliasesSet, Aliases).
-project( Vars, AliasSet0, AliasSet ):-
+project(Vars, AliasSet0, AliasSet):-
AliasSet0 = alias_set(_, Map0),
- map__select( Map0, set__list_to_set(Vars ), Map1),
+ map__select(Map0, set__list_to_set(Vars), Map1),
map__foldl(
- pred( Var::in, SelSet0::in, M0::in, M::out) is det :-
+ pred(Var::in, SelSet0::in, M0::in, M::out) is det :-
(
alias_set2_project(Vars, SelSet0, SelSet),
(
@@ -293,323 +293,323 @@
->
M = M0
;
- map_det_insert( M0, Var, SelSet, M,
+ map_det_insert(M0, Var, SelSet, M,
"(pa_alias_set) project/3")
)
- ),
+ ),
Map1,
map__init,
Map),
- recount( alias_set(0, Map), AliasSet ).
+ recount(alias_set(0, Map), AliasSet).
-:- pred pa_alias_set__recount( alias_set::in, alias_set::out) is det.
+:- pred pa_alias_set__recount(alias_set::in, alias_set::out) is det.
pa_alias_set__recount(AliasSet0, AliasSet):-
- AliasSet0 = alias_set( _, Map ),
- map__foldl(
- pred( _K::in, Selectors::in,
+ AliasSet0 = alias_set(_, Map),
+ map__foldl(
+ pred(_K::in, Selectors::in,
Counter0::in, Counter::out) is det :-
- (
- alias_set2_get_size( Selectors, S ),
+ (
+ alias_set2_get_size(Selectors, S),
Counter = Counter0 + S
- ),
+ ),
Map,
0,
Size),
- AliasSet = alias_set( Size, Map ).
+ AliasSet = alias_set(Size, Map).
-project_set( VarsSet, AliasSet0, AliasSet ):-
- set__to_sorted_list( VarsSet, Vars ),
- project( Vars, AliasSet0, AliasSet).
+project_set(VarsSet, AliasSet0, AliasSet):-
+ set__to_sorted_list(VarsSet, Vars),
+ project(Vars, AliasSet0, AliasSet).
-collect_aliases_of_datastruct( ModuleInfo, ProcInfo, Datastruct,
+collect_aliases_of_datastruct(ModuleInfo, ProcInfo, Datastruct,
AliasSet, Datastructs):-
- AliasSet = alias_set( _Size, Map ),
+ AliasSet = alias_set(_Size, Map),
get_var(Datastruct, Var),
- proc_info_vartypes( ProcInfo, VarTypes),
- map__lookup( VarTypes, Var, VarType),
+ proc_info_vartypes(ProcInfo, VarTypes),
+ map__lookup(VarTypes, Var, VarType),
get_selector(Datastruct, Selector),
(
- map__search( Map, Var, SelectorSet )
+ map__search(Map, Var, SelectorSet)
->
- alias_set2_collect_aliases( ModuleInfo, VarType,
+ alias_set2_collect_aliases(ModuleInfo, VarType,
Selector, SelectorSet, Datastructs)
;
Datastructs = []
).
-rename( Dict, AliasSet0, AliasSet ):-
- AliasSet0 = alias_set( Size, Map0 ),
+rename(Dict, AliasSet0, AliasSet):-
+ AliasSet0 = alias_set(Size, Map0),
map__foldl(
- pred( Var0::in, SelectorSet0::in, M0::in, M::out ) is det:-
+ pred(Var0::in, SelectorSet0::in, M0::in, M::out) is det:-
(
alias_set2_rename(Dict, SelectorSet0,
SelectorSet1),
- map__lookup( Dict, Var0, Var ),
+ map__lookup(Dict, Var0, Var),
(
- map__search( M0, Var, SelectorSet2 )
+ map__search(M0, Var, SelectorSet2)
->
% can occur when 2 vars are renamed to
% the same var (call: append(X,X,Y))
- alias_set2_add( SelectorSet1,
- SelectorSet2, SelectorSet ),
- map__det_update( M0, Var, SelectorSet, M )
+ alias_set2_add(SelectorSet1,
+ SelectorSet2, SelectorSet),
+ map__det_update(M0, Var, SelectorSet, M)
;
- map_det_insert( M0, Var, SelectorSet1, M,
+ map_det_insert(M0, Var, SelectorSet1, M,
"(pa_alias_set) rename/3")
)
- ),
+ ),
Map0,
map__init,
Map),
- AliasSet = alias_set( Size, Map ).
+ AliasSet = alias_set(Size, Map).
-rename_types( Subst, AliasSet0, AliasSet ):-
- alias_set_map_values( alias_set2_rename_types(Subst), AliasSet0,
+rename_types(Subst, AliasSet0, AliasSet):-
+ alias_set_map_values(alias_set2_rename_types(Subst), AliasSet0,
AliasSet).
-equal( AliasSet0, AliasSet1 ):-
- AliasSet0 = alias_set( Size, Map0 ),
- AliasSet1 = alias_set( Size, Map1 ),
- map__keys( Map0, Keys0 ),
- map__values( Map0, Values0),
- equal2( Keys0, Values0, Map1).
-:- pred equal2( list(prog_var)::in, list(alias_set2)::in,
- map( prog_var, alias_set2 )::in) is semidet.
-equal2( [], [], Map) :- map__is_empty( Map ).
-equal2( [ Var0 | Vars ], [SelectorSet0 | SelectorSets], Map0 ) :-
- map__remove( Map0, Var0, SelectorSet1, Map ),
- alias_set2_equal( SelectorSet0, SelectorSet1 ),
- equal2( Vars, SelectorSets, Map ).
-
-least_upper_bound( ModuleInfo, ProcInfo, AliasSet0, AliasSet1, AliasSet):-
- AliasSet0 = alias_set( Size0, Map0),
- AliasSet1 = alias_set( Size1, Map1),
+equal(AliasSet0, AliasSet1):-
+ AliasSet0 = alias_set(Size, Map0),
+ AliasSet1 = alias_set(Size, Map1),
+ map__keys(Map0, Keys0),
+ map__values(Map0, Values0),
+ equal2(Keys0, Values0, Map1).
+:- pred equal2(list(prog_var)::in, list(alias_set2)::in,
+ map(prog_var, alias_set2)::in) is semidet.
+equal2([], [], Map) :- map__is_empty(Map).
+equal2([ Var0 | Vars ], [SelectorSet0 | SelectorSets], Map0) :-
+ map__remove(Map0, Var0, SelectorSet1, Map),
+ alias_set2_equal(SelectorSet0, SelectorSet1),
+ equal2(Vars, SelectorSets, Map).
+
+least_upper_bound(ModuleInfo, ProcInfo, AliasSet0, AliasSet1, AliasSet):-
+ AliasSet0 = alias_set(Size0, Map0),
+ AliasSet1 = alias_set(Size1, Map1),
(
Size0 < Size1
->
- least_upper_bound2( ModuleInfo, ProcInfo, Map0, Map1, AliasSet)
+ least_upper_bound2(ModuleInfo, ProcInfo, Map0, Map1, AliasSet)
;
- least_upper_bound2( ModuleInfo, ProcInfo, Map1, Map0, AliasSet)
+ least_upper_bound2(ModuleInfo, ProcInfo, Map1, Map0, AliasSet)
).
% least_upper_bound2(ModuleInfo, ProcInfo, SmallMap, BigMap, Result).
-:- pred least_upper_bound2( module_info::in, proc_info::in,
- map( prog_var, alias_set2 )::in,
- map( prog_var, alias_set2 )::in,
+:- pred least_upper_bound2(module_info::in, proc_info::in,
+ map(prog_var, alias_set2)::in,
+ map(prog_var, alias_set2)::in,
alias_set::out) is det.
-least_upper_bound2( ModuleInfo, ProcInfo, Map0, Map1, AliasSet ):-
- map__keys( Map0, Vars),
+least_upper_bound2(ModuleInfo, ProcInfo, Map0, Map1, AliasSet):-
+ map__keys(Map0, Vars),
list__foldl(
- pred( Var::in, M0::in, M::out) is det :-
- (
- map__lookup( Map0, Var, SelectorSet0 ),
+ pred(Var::in, M0::in, M::out) is det :-
+ (
+ map__lookup(Map0, Var, SelectorSet0),
(
- map__search( M0, Var, SelectorSet1 )
+ map__search(M0, Var, SelectorSet1)
->
- proc_info_vartypes( ProcInfo, VarTypes ),
- map__lookup( VarTypes, Var, VarType ),
- alias_set2_least_upper_bound(
+ proc_info_vartypes(ProcInfo, VarTypes),
+ map__lookup(VarTypes, Var, VarType),
+ alias_set2_least_upper_bound(
ModuleInfo, VarType,
SelectorSet0, SelectorSet1,
SelectorSet),
- map__det_update( M0, Var, SelectorSet, M)
+ map__det_update(M0, Var, SelectorSet, M)
;
- map_det_insert( M0, Var, SelectorSet0, M,
- "(pa_alias_set) least_upper_bound2/5" )
+ map_det_insert(M0, Var, SelectorSet0, M,
+ "(pa_alias_set) least_upper_bound2/5")
)
- ),
+ ),
Vars,
Map1,
Map),
- pa_alias_set__recount( alias_set(0, Map), AliasSet ).
+ pa_alias_set__recount(alias_set(0, Map), AliasSet).
-least_upper_bound_list( ModuleInfo, ProcInfo, List, AliasSet):-
+least_upper_bound_list(ModuleInfo, ProcInfo, List, AliasSet):-
list__foldl(
- least_upper_bound( ModuleInfo, ProcInfo),
+ least_upper_bound(ModuleInfo, ProcInfo),
List,
pa_alias_set__init,
- AliasSet ).
+ AliasSet).
-extend( ModuleInfo, ProcInfo, NewAliasSet, OldAliasSet, AliasSet):-
+extend(ModuleInfo, ProcInfo, NewAliasSet, OldAliasSet, AliasSet):-
% first find the New-Old aliases resulting in an
% aliasSet containing only the directional New-Old (stored
% as Old-New) aliasSet, and the full resulting aliasSet.
- altclos_two( ModuleInfo, ProcInfo, NewAliasSet, OldAliasSet,
- OldNewAliasSet, FullOldNewAliasSet ),
+ altclos_two(ModuleInfo, ProcInfo, NewAliasSet, OldAliasSet,
+ OldNewAliasSet, FullOldNewAliasSet),
% With the OldNewAliasSet, compute the NewOldNewAliasSet
% in the same-way.
- altclos_two( ModuleInfo, ProcInfo, OldNewAliasSet, NewAliasSet,
- _, FullNewOldNewAliasSet ),
+ altclos_two(ModuleInfo, ProcInfo, OldNewAliasSet, NewAliasSet,
+ _, FullNewOldNewAliasSet),
list__foldl(
pa_alias_set__add,
[ NewAliasSet, FullOldNewAliasSet,
FullNewOldNewAliasSet ],
OldAliasSet,
- AliasSet ).
+ AliasSet).
-:- pred altclos_two( module_info::in, proc_info::in, alias_set::in,
+:- pred altclos_two(module_info::in, proc_info::in, alias_set::in,
alias_set::in, alias_set::out, alias_set::out) is det.
-altclos_two( ModuleInfo, ProcInfo, NewAliasSet, OldAliasSet,
+altclos_two(ModuleInfo, ProcInfo, NewAliasSet, OldAliasSet,
PartialAliasSet, FullResult) :-
- proc_info_vartypes( ProcInfo, VarTypes ),
- NewAliasSet = alias_set( _, NewMap ),
- OldAliasSet = alias_set( _, OldMap ),
+ proc_info_vartypes(ProcInfo, VarTypes),
+ NewAliasSet = alias_set(_, NewMap),
+ OldAliasSet = alias_set(_, OldMap),
% compute the common variables
- map__keys( NewMap, NewVars ),
- map__keys( OldMap, OldVars ),
- set__list_to_set( NewVars, NewVarsSet ),
- set__list_to_set( OldVars, OldVarsSet ),
- set__intersect( NewVarsSet, OldVarsSet, CommonVarsSet),
- set__to_sorted_list( CommonVarsSet, CommonVars ),
+ map__keys(NewMap, NewVars),
+ map__keys(OldMap, OldVars),
+ set__list_to_set(NewVars, NewVarsSet),
+ set__list_to_set(OldVars, OldVarsSet),
+ set__intersect(NewVarsSet, OldVarsSet, CommonVarsSet),
+ set__to_sorted_list(CommonVarsSet, CommonVars),
% for each common var, compute the aliases it generates
- list__foldl2(
- pred( Var::in, PM0::in, PM::out, FM0::in, FM::out ) is det:-
- (
- map__lookup( VarTypes, Var, Type ),
- map__lookup( NewMap, Var, NewSelectorSet),
- map__lookup( OldMap, Var, OldSelectorSet),
- alias_set2_altclos( ModuleInfo, ProcInfo,
+ list__foldl2(
+ pred(Var::in, PM0::in, PM::out, FM0::in, FM::out) is det:-
+ (
+ map__lookup(VarTypes, Var, Type),
+ map__lookup(NewMap, Var, NewSelectorSet),
+ map__lookup(OldMap, Var, OldSelectorSet),
+ alias_set2_altclos(ModuleInfo, ProcInfo,
Type, NewSelectorSet, OldSelectorSet,
- DirectedAliases ),
+ DirectedAliases),
% Directed = FromOld to ToNew
- pa_alias_set__new_directed_entries( DirectedAliases,
- PM0, PM ),
- pa_alias_set__new_entries( DirectedAliases,
- FM0, FM )
- ),
+ pa_alias_set__new_directed_entries(DirectedAliases,
+ PM0, PM),
+ pa_alias_set__new_entries(DirectedAliases,
+ FM0, FM)
+ ),
CommonVars,
pa_alias_set__init,
PartialAliasSet,
pa_alias_set__init,
- FullResult ).
+ FullResult).
- % alias_set2_altclos( ModuleInfo, ProcInfo, Type,
+ % alias_set2_altclos(ModuleInfo, ProcInfo, Type,
% NewSelectorSet, OldSelectorSet,
- % OldNewDirectedAliases ).
-:- pred alias_set2_altclos( module_info::in, proc_info::in, (type)::in,
+ % OldNewDirectedAliases).
+:- pred alias_set2_altclos(module_info::in, proc_info::in, (type)::in,
alias_set2::in, alias_set2::in,
list(alias)::out) is det.
-alias_set2_altclos( ModuleInfo, ProcInfo, Type,
+alias_set2_altclos(ModuleInfo, ProcInfo, Type,
NewSelectorSet, OldSelectorSet,
- DirectedAliases ) :-
- NewSelectorSet = alias_sel_set( _, NewMap ),
- OldSelectorSet = alias_sel_set( _, OldMap ),
+ DirectedAliases) :-
+ NewSelectorSet = alias_sel_set(_, NewMap),
+ OldSelectorSet = alias_sel_set(_, OldMap),
% get the selectors
- map__keys( NewMap, NewSelectors),
- map__keys( OldMap, OldSelectors),
+ map__keys(NewMap, NewSelectors),
+ map__keys(OldMap, OldSelectors),
list__foldl(
- pred( NewSel::in, L0::in, L::out) is det:-
+ pred(NewSel::in, L0::in, L::out) is det:-
list__foldl(
- altclos_basic( ModuleInfo, ProcInfo, Type,
+ altclos_basic(ModuleInfo, ProcInfo, Type,
NewMap, OldMap,
- NewSel ),
+ NewSel),
OldSelectors,
L0,
- L ),
+ L),
NewSelectors,
[],
- DirectedAliases ).
+ DirectedAliases).
-:- pred altclos_basic( module_info::in, proc_info::in, (type)::in,
+:- pred altclos_basic(module_info::in, proc_info::in, (type)::in,
map(selector, data_set)::in,
map(selector, data_set)::in,
selector::in, selector::in,
list(alias)::in, list(alias)::out) is det.
-altclos_basic( ModuleInfo, _ProcInfo, Type, NewMap, OldMap,
+altclos_basic(ModuleInfo, _ProcInfo, Type, NewMap, OldMap,
NewSel, OldSel,
- AccList, List ) :-
- map__lookup( NewMap, NewSel, NewDataSet0),
- map__lookup( OldMap, OldSel, OldDataSet0),
+ AccList, List) :-
+ map__lookup(NewMap, NewSel, NewDataSet0),
+ map__lookup(OldMap, OldSel, OldDataSet0),
(
% NewSel = OldSel.Extension
- pa_selector__less_or_equal( ModuleInfo, NewSel, OldSel,
- Type, Extension )
+ pa_selector__less_or_equal(ModuleInfo, NewSel, OldSel,
+ Type, Extension)
->
- data_set_termshift( OldDataSet0, Extension, OldDataSet),
- data_set_generate_directed_aliases( OldDataSet, NewDataSet0,
- NewDirectedAliases )
+ data_set_termshift(OldDataSet0, Extension, OldDataSet),
+ data_set_generate_directed_aliases(OldDataSet, NewDataSet0,
+ NewDirectedAliases)
;
% NewSel.Extension = OldSel
- pa_selector__less_or_equal( ModuleInfo, OldSel, NewSel,
+ pa_selector__less_or_equal(ModuleInfo, OldSel, NewSel,
Type, Extension)
->
- data_set_termshift( NewDataSet0, Extension, NewDataSet),
- data_set_generate_directed_aliases( OldDataSet0, NewDataSet,
- NewDirectedAliases )
+ data_set_termshift(NewDataSet0, Extension, NewDataSet),
+ data_set_generate_directed_aliases(OldDataSet0, NewDataSet,
+ NewDirectedAliases)
;
NewDirectedAliases = []
),
List = append(NewDirectedAliases, AccList).
-add( AliasSet0, AliasSet1, AliasSet):-
- AliasSet0 = alias_set(_, Map0 ),
- AliasSet1 = alias_set(_, Map1 ),
+add(AliasSet0, AliasSet1, AliasSet):-
+ AliasSet0 = alias_set(_, Map0),
+ AliasSet1 = alias_set(_, Map1),
- map__foldl(
+ map__foldl(
pred(Var::in, SelectorSet0::in, M0::in, M::out) is det:-
- (
- map__search( M0, Var, SelectorSet1 )
+ (
+ map__search(M0, Var, SelectorSet1)
->
- alias_set2_add( SelectorSet1, SelectorSet0,
+ alias_set2_add(SelectorSet1, SelectorSet0,
SelectorSet),
- map__det_update( M0, Var, SelectorSet, M )
+ map__det_update(M0, Var, SelectorSet, M)
;
- map_det_insert( M0, Var, SelectorSet0, M,
- "(pa_alias_set) add/3" )
- ),
+ map_det_insert(M0, Var, SelectorSet0, M,
+ "(pa_alias_set) add/3")
+ ),
Map0,
Map1,
- Map ),
- pa_alias_set__recount( alias_set(0,Map), AliasSet).
+ Map),
+ pa_alias_set__recount(alias_set(0,Map), AliasSet).
-normalize( ModuleInfo, ProcInfo, AliasSet0, AliasSet) :-
- proc_info_vartypes( ProcInfo, VarTypes),
- AliasSet0 = alias_set( _, Map0 ),
- map__keys( Map0, Vars ),
+normalize(ModuleInfo, ProcInfo, AliasSet0, AliasSet) :-
+ proc_info_vartypes(ProcInfo, VarTypes),
+ AliasSet0 = alias_set(_, Map0),
+ map__keys(Map0, Vars),
list__foldl(
- pred( Var::in, M0::in, M::out) is det :-
- (
- map__lookup( Map0, Var, SelectorSet0 ),
- map__lookup( VarTypes, Var, VarType),
- alias_set2_normalize( ModuleInfo, ProcInfo, VarType,
+ pred(Var::in, M0::in, M::out) is det :-
+ (
+ map__lookup(Map0, Var, SelectorSet0),
+ map__lookup(VarTypes, Var, VarType),
+ alias_set2_normalize(ModuleInfo, ProcInfo, VarType,
SelectorSet0, SelectorSet),
- map_det_insert( M0, Var, SelectorSet, M,
- "(pa_alias_set) normalize/4" )
- ),
+ map_det_insert(M0, Var, SelectorSet, M,
+ "(pa_alias_set) normalize/4")
+ ),
Vars,
map__init,
- Map ),
- pa_alias_set__recount( alias_set(0, Map), AliasSet ).
+ Map),
+ pa_alias_set__recount(alias_set(0, Map), AliasSet).
-less_or_equal( ModuleInfo, ProcInfo, AliasSet1, AliasSet2 ):-
- AliasSet1 = alias_set( _, Map1 ),
- AliasSet2 = alias_set( _, Map2 ),
+less_or_equal(ModuleInfo, ProcInfo, AliasSet1, AliasSet2):-
+ AliasSet1 = alias_set(_, Map1),
+ AliasSet2 = alias_set(_, Map2),
% check whether the variable-sets are identical
- set__equal( set__list_to_set( map__keys( Map1 ) ),
- set__list_to_set( map__keys( Map2 ) ) ),
+ set__equal(set__list_to_set(map__keys(Map1)),
+ set__list_to_set(map__keys(Map2))),
% compute the least_upper_bound of both alias_sets
- least_upper_bound( ModuleInfo, ProcInfo, AliasSet1, AliasSet2,
- AliasSetLUB ),
+ least_upper_bound(ModuleInfo, ProcInfo, AliasSet1, AliasSet2,
+ AliasSetLUB),
% the result should then be equal to the original
% aliasSet (AliasSet2)
- equal( AliasSet2, AliasSetLUB ).
+ equal(AliasSet2, AliasSetLUB).
-remove_vars( Vars, AliasSet0, AliasSet ):-
- AliasSet0 = alias_set( _, Map0 ),
- map__delete_list( Map0, Vars, Map1 ),
+remove_vars(Vars, AliasSet0, AliasSet):-
+ AliasSet0 = alias_set(_, Map0),
+ map__delete_list(Map0, Vars, Map1),
alias_set_map_values(
alias_set2_remove_vars(Vars),
alias_set(0, Map1),
AliasSet1),
- recount( AliasSet1, AliasSet).
+ recount(AliasSet1, AliasSet).
apply_widening(ModuleInfo, ProcInfo, AliasSet0, AliasSet):-
@@ -620,16 +620,16 @@
recount(AliasSet1, AliasSet).
-print( PredInfo, ProcInfo, AliasSet, StartingString, EndString) -->
- { pa_alias_set__to_pair_alias_list( AliasSet, AliasList ) },
- io__write_list( AliasList, ",",
+print(PredInfo, ProcInfo, AliasSet, StartingString, EndString) -->
+ { pa_alias_set__to_pair_alias_list(AliasSet, AliasList) },
+ io__write_list(AliasList, ",",
pa_alias__print(ProcInfo, PredInfo, StartingString,
- EndString ) ).
+ EndString)).
-:- pred alias_set_fold( pred( alias_set2, alias_set2),
+:- pred alias_set_fold(pred(alias_set2, alias_set2),
alias_set, alias_set).
-:- mode alias_set_fold( pred( in, in) is det, in, out) is det.
+:- mode alias_set_fold(pred(in, in) is det, in, out) is det.
alias_set_fold(_Pred, AliasSet, AliasSet).
% XXXXXXXXXX
@@ -639,11 +639,11 @@
:- mode alias_set_map_values(pred(in, out) is det, in, out) is det.
alias_set_map_values(Pred, AliasSet0, AliasSet) :-
AliasSet0 = alias_set(Size, Map0),
- map__map_values(
+ map__map_values(
pred(_K::in, S0::in, S::out) is det:-
- (
+ (
Pred(S0, S)
- ),
+ ),
Map0,
Map),
AliasSet = alias_set(Size, Map).
@@ -654,11 +654,11 @@
in, out) is det.
alias_set_map_values_with_key(Pred, AliasSet0, AliasSet) :-
AliasSet0 = alias_set(Size, Map0),
- map__map_values(
+ map__map_values(
pred(K::in, S0::in, S::out) is det:-
- (
+ (
Pred(K, S0, S)
- ),
+ ),
Map0,
Map),
AliasSet = alias_set(Size, Map).
@@ -670,49 +670,49 @@
% alias_set2 = structure to keep track of mappings from selectors unto
% concrete datastructures.
-:- pred alias_set2_empty( alias_set2 ).
-:- mode alias_set2_empty( out ) is det.
-:- mode alias_set2_empty( in ) is semidet.
+:- pred alias_set2_empty(alias_set2).
+:- mode alias_set2_empty(out) is det.
+:- mode alias_set2_empty(in) is semidet.
:- func alias_set2_init = alias_set2.
-:- pred alias_set2_new_entry( selector::in, datastruct::in,
+:- pred alias_set2_new_entry(selector::in, datastruct::in,
alias_set2::in, bool::out, alias_set2::out) is det.
-:- pred alias_set2_new_entry( selector::in, datastruct::in,
+:- pred alias_set2_new_entry(selector::in, datastruct::in,
alias_set2::in, alias_set2::out) is det.
-:- pred alias_set2_get_size( alias_set2::in, int::out) is det.
-:- pred alias_set2_unfold( alias_set2::in,
- list(pair(selector, datastruct) )::out) is det.
-:- pred alias_set2_project( list(prog_var)::in, alias_set2::in,
- alias_set2::out ) is det.
-:- pred alias_set2_rename( map(prog_var, prog_var)::in,
+:- pred alias_set2_get_size(alias_set2::in, int::out) is det.
+:- pred alias_set2_unfold(alias_set2::in,
+ list(pair(selector, datastruct))::out) is det.
+:- pred alias_set2_project(list(prog_var)::in, alias_set2::in,
+ alias_set2::out) is det.
+:- pred alias_set2_rename(map(prog_var, prog_var)::in,
alias_set2::in, alias_set2::out) is det.
-:- pred alias_set2_rename_types( term__substitution(tvar_type)::in,
+:- pred alias_set2_rename_types(term__substitution(tvar_type)::in,
alias_set2::in, alias_set2::out) is det.
-:- pred alias_set2_equal( alias_set2::in, alias_set2::in) is semidet.
-:- pred alias_set2_add( alias_set2::in, alias_set2::in,
+:- pred alias_set2_equal(alias_set2::in, alias_set2::in) is semidet.
+:- pred alias_set2_add(alias_set2::in, alias_set2::in,
alias_set2::out) is det.
-:- pred alias_set2_collect_aliases( module_info::in, (type)::in,
+:- pred alias_set2_collect_aliases(module_info::in, (type)::in,
selector::in, alias_set2::in,
- list(datastruct)::out ) is det.
-:- pred alias_set2_least_upper_bound( module_info::in, (type)::in,
+ list(datastruct)::out) is det.
+:- pred alias_set2_least_upper_bound(module_info::in, (type)::in,
alias_set2::in, alias_set2::in,
- alias_set2::out ) is det.
-:- pred alias_set2_normalize( module_info::in, proc_info::in, (type)::in,
+ alias_set2::out) is det.
+:- pred alias_set2_normalize(module_info::in, proc_info::in, (type)::in,
alias_set2::in, alias_set2::out) is det.
-:- pred alias_set2_remove_vars( list(prog_var)::in, alias_set2::in,
+:- pred alias_set2_remove_vars(list(prog_var)::in, alias_set2::in,
alias_set2::out) is det.
:- pred alias_set2_apply_widening(module_info::in, proc_info::in,
prog_var::in, alias_set2::in, alias_set2::out) is det.
-alias_set2_empty( alias_sel_set( 0, map__init ) ).
+alias_set2_empty(alias_sel_set(0, map__init)).
alias_set2_init = AliasSet :- alias_set2_empty(AliasSet).
-alias_set2_new_entry( Selector, Datastruct, AliasSet0, Added, AliasSet ):-
- AliasSet0 = alias_sel_set( Size0, Map0 ),
+alias_set2_new_entry(Selector, Datastruct, AliasSet0, Added, AliasSet):-
+ AliasSet0 = alias_sel_set(Size0, Map0),
(
- map__search( Map0, Selector, DataSet0 )
+ map__search(Map0, Selector, DataSet0)
->
- data_set_new_entry( Datastruct, DataSet0, Addition, DataSet),
- (
+ data_set_new_entry(Datastruct, DataSet0, Addition, DataSet),
+ (
Addition = yes,
Size = Size0 + 1,
Added = yes
@@ -721,262 +721,262 @@
Size = Size0,
Added = no
),
- map__det_update( Map0, Selector, DataSet, Map)
+ map__det_update(Map0, Selector, DataSet, Map)
;
- data_set_empty( EmptyDataSet ),
- data_set_new_entry( Datastruct, EmptyDataSet, DataSet),
+ data_set_empty(EmptyDataSet),
+ data_set_new_entry(Datastruct, EmptyDataSet, DataSet),
Size = Size0 + 1,
Added = yes,
- map_det_insert( Map0, Selector, DataSet, Map,
- "(pa_alias_set) alias_set2_new_entry/5" )
+ map_det_insert(Map0, Selector, DataSet, Map,
+ "(pa_alias_set) alias_set2_new_entry/5")
),
- AliasSet = alias_sel_set( Size, Map).
+ AliasSet = alias_sel_set(Size, Map).
-alias_set2_new_entry( Selector, Datastruct, AliasSet0, AliasSet ):-
- alias_set2_new_entry( Selector, Datastruct, AliasSet0, _, AliasSet).
+alias_set2_new_entry(Selector, Datastruct, AliasSet0, AliasSet):-
+ alias_set2_new_entry(Selector, Datastruct, AliasSet0, _, AliasSet).
-alias_set2_get_size( alias_sel_set( Size, _ ), Size ).
-alias_set2_unfold( AliasSet, List ):-
- AliasSet = alias_sel_set( _, Map ),
- map__to_assoc_list( Map, Pairs ),
+alias_set2_get_size(alias_sel_set(Size, _), Size).
+alias_set2_unfold(AliasSet, List):-
+ AliasSet = alias_sel_set(_, Map),
+ map__to_assoc_list(Map, Pairs),
list__foldl(
- pred( Pair::in, L0::in, L::out ) is det:-
- (
+ pred(Pair::in, L0::in, L::out) is det:-
+ (
Pair = Selector - DataSet,
- data_set_get_datastructs( DataSet, Datastructs),
- list__map(
- pred( Datastruct::in, P::out ) is det :-
- (
+ data_set_get_datastructs(DataSet, Datastructs),
+ list__map(
+ pred(Datastruct::in, P::out) is det :-
+ (
P = Selector - Datastruct
- ),
+ ),
Datastructs,
SelectorDatastructs),
- list__append( SelectorDatastructs, L0, L )
- ),
+ list__append(SelectorDatastructs, L0, L)
+ ),
Pairs,
[],
- List ).
+ List).
-alias_set2_project( Vars, AliasSet0, AliasSet ):-
- AliasSet0 = alias_sel_set(_, Map0 ),
+alias_set2_project(Vars, AliasSet0, AliasSet):-
+ AliasSet0 = alias_sel_set(_, Map0),
map__foldl(
- pred( Sel0::in, DataSet0::in, M0::in, M::out) is det:-
- (
- data_set_project( Vars, DataSet0, DataSet),
+ pred(Sel0::in, DataSet0::in, M0::in, M::out) is det:-
+ (
+ data_set_project(Vars, DataSet0, DataSet),
(
- data_set_empty( DataSet )
+ data_set_empty(DataSet)
->
M0 = M
;
- map_det_insert( M0, Sel0, DataSet, M,
- "(pa_alias_set) alias_set2_project/3" )
+ map_det_insert(M0, Sel0, DataSet, M,
+ "(pa_alias_set) alias_set2_project/3")
)
- ),
+ ),
Map0,
map__init,
Map),
- alias_set2_recount( alias_sel_set(0, Map), AliasSet).
+ alias_set2_recount(alias_sel_set(0, Map), AliasSet).
-:- pred alias_set2_recount( alias_set2::in, alias_set2::out) is det.
-alias_set2_recount( AliasSet0, AliasSet ):-
- AliasSet0 = alias_sel_set( _, Map ),
- map__foldl(
- pred( _K::in, DataSet::in,
+:- pred alias_set2_recount(alias_set2::in, alias_set2::out) is det.
+alias_set2_recount(AliasSet0, AliasSet):-
+ AliasSet0 = alias_sel_set(_, Map),
+ map__foldl(
+ pred(_K::in, DataSet::in,
Counter0::in, Counter::out) is det :-
- (
- data_set_get_size( DataSet, S ),
+ (
+ data_set_get_size(DataSet, S),
Counter = Counter0 + S
- ),
+ ),
Map,
0,
Size),
- AliasSet = alias_sel_set( Size, Map ).
+ AliasSet = alias_sel_set(Size, Map).
-alias_set2_rename( Dict, AliasSet0, AliasSet ):-
- alias_set2_map_values( data_set_rename( Dict), AliasSet0, AliasSet).
+alias_set2_rename(Dict, AliasSet0, AliasSet):-
+ alias_set2_map_values(data_set_rename(Dict), AliasSet0, AliasSet).
-alias_set2_rename_types( Subst, AliasSet0, AliasSet ):-
- AliasSet0 = alias_sel_set( Size, Map0 ),
- map__to_assoc_list( Map0, AssocList0 ),
+alias_set2_rename_types(Subst, AliasSet0, AliasSet):-
+ AliasSet0 = alias_sel_set(Size, Map0),
+ map__to_assoc_list(Map0, AssocList0),
list__foldl(
- pred( Pair::in, M0::in, M::out) is det :-
- (
+ pred(Pair::in, M0::in, M::out) is det :-
+ (
Pair = Sel0 - DataSet0,
- pa_selector__rename_types( Subst, Sel0, Sel),
- data_set_rename_types( Subst, DataSet0, DataSet),
- map__det_insert( M0, Sel, DataSet, M )
- ),
+ pa_selector__rename_types(Subst, Sel0, Sel),
+ data_set_rename_types(Subst, DataSet0, DataSet),
+ map__det_insert(M0, Sel, DataSet, M)
+ ),
AssocList0,
map__init,
Map),
- AliasSet = alias_sel_set( Size, Map).
+ AliasSet = alias_sel_set(Size, Map).
-alias_set2_equal( AliasSet0, AliasSet1 ):-
- AliasSet0 = alias_sel_set( Size, Map0 ),
- AliasSet1 = alias_sel_set( Size, Map ),
- map__keys( Map0, Keys0 ),
- map__values( Map0, Values0 ),
- alias_set2_equal2( Keys0, Values0, Map).
+alias_set2_equal(AliasSet0, AliasSet1):-
+ AliasSet0 = alias_sel_set(Size, Map0),
+ AliasSet1 = alias_sel_set(Size, Map),
+ map__keys(Map0, Keys0),
+ map__values(Map0, Values0),
+ alias_set2_equal2(Keys0, Values0, Map).
-:- pred alias_set2_equal2( list(selector)::in, list(data_set)::in,
+:- pred alias_set2_equal2(list(selector)::in, list(data_set)::in,
map(selector, data_set)::in) is semidet.
-alias_set2_equal2( [], [], Map) :- map__is_empty( Map ).
-alias_set2_equal2( [ Sel0 | Sels ], [ DataSet0 | DataSets ], Map0 ):-
- map__remove( Map0, Sel0, DataSet1, Map ),
- data_set_equal( DataSet0, DataSet1 ),
- alias_set2_equal2( Sels, DataSets, Map ).
-
-alias_set2_add( AliasSet0, AliasSet1, AliasSet ):-
- AliasSet0 = alias_sel_set( _, Map0 ),
- AliasSet1 = alias_sel_set( _, Map1 ),
- map__to_assoc_list( Map0, Pairs),
+alias_set2_equal2([], [], Map) :- map__is_empty(Map).
+alias_set2_equal2([ Sel0 | Sels ], [ DataSet0 | DataSets ], Map0):-
+ map__remove(Map0, Sel0, DataSet1, Map),
+ data_set_equal(DataSet0, DataSet1),
+ alias_set2_equal2(Sels, DataSets, Map).
+
+alias_set2_add(AliasSet0, AliasSet1, AliasSet):-
+ AliasSet0 = alias_sel_set(_, Map0),
+ AliasSet1 = alias_sel_set(_, Map1),
+ map__to_assoc_list(Map0, Pairs),
list__foldl(
- pred( Pair::in, M0::in, M::out) is det :-
- (
+ pred(Pair::in, M0::in, M::out) is det :-
+ (
Pair = Sel - DataSet0,
(
- map__search( M0, Sel, DataSet1 )
+ map__search(M0, Sel, DataSet1)
->
- data_set_add( DataSet0, DataSet1, DataSet),
- map__det_update( M0, Sel, DataSet, M)
+ data_set_add(DataSet0, DataSet1, DataSet),
+ map__det_update(M0, Sel, DataSet, M)
;
- map__det_insert( M0, Sel, DataSet0, M)
+ map__det_insert(M0, Sel, DataSet0, M)
)
- ),
+ ),
Pairs,
Map1,
Map),
- alias_set2_recount( alias_sel_set(0, Map), AliasSet ).
+ alias_set2_recount(alias_sel_set(0, Map), AliasSet).
-:- pred alias_set2_map_values( pred(data_set, data_set),
+:- pred alias_set2_map_values(pred(data_set, data_set),
alias_set2, alias_set2).
-:- mode alias_set2_map_values( pred(in, out) is det, in, out) is det.
-alias_set2_map_values( Pred, AliasSet0, AliasSet ):-
- AliasSet0 = alias_sel_set( Size, Map0),
+:- mode alias_set2_map_values(pred(in, out) is det, in, out) is det.
+alias_set2_map_values(Pred, AliasSet0, AliasSet):-
+ AliasSet0 = alias_sel_set(Size, Map0),
map__map_values(
- pred( _K::in, D0::in, D::out) is det :-
- ( Pred( D0, D) ), Map0, Map),
- AliasSet = alias_sel_set( Size, Map).
+ pred(_K::in, D0::in, D::out) is det :-
+ (Pred(D0, D)), Map0, Map),
+ AliasSet = alias_sel_set(Size, Map).
-alias_set2_collect_aliases( ModuleInfo, Type,
+alias_set2_collect_aliases(ModuleInfo, Type,
Selector, SelectorSet, Datastructs):-
- SelectorSet = alias_sel_set( _Size, Map),
- map__keys( Map, Selectors ),
+ SelectorSet = alias_sel_set(_Size, Map),
+ map__keys(Map, Selectors),
list__foldl(
- pred( Sel::in, Data0::in, Data::out) is det:-
- (
+ pred(Sel::in, Data0::in, Data::out) is det:-
+ (
% if Sel is more general than Selector, i.e.
% Selector = Sel.Extension, apply this extension
% to all the datastructs associated with that Sel.
(
- less_or_equal( ModuleInfo, Selector,
- Sel, Type, Extension )
+ less_or_equal(ModuleInfo, Selector,
+ Sel, Type, Extension)
->
- map__lookup( Map, Sel, DataSet0 ),
- data_set_termshift( DataSet0, Extension,
+ map__lookup(Map, Sel, DataSet0),
+ data_set_termshift(DataSet0, Extension,
DataSet),
- data_set_add( Data0, DataSet, Data)
+ data_set_add(Data0, DataSet, Data)
;
Data = Data0
)
- ),
+ ),
Selectors,
data_set_empty,
- CollectedDataSet ),
- data_set_get_datastructs( CollectedDataSet, Datastructs).
+ CollectedDataSet),
+ data_set_get_datastructs(CollectedDataSet, Datastructs).
-alias_set2_least_upper_bound( ModuleInfo, Type,
+alias_set2_least_upper_bound(ModuleInfo, Type,
SelectorSet0, SelectorSet1, SelectorSet):-
- SelectorSet0 = alias_sel_set( _Size0, Map0 ),
- SelectorSet1 = alias_sel_set( _Size1, Map1 ),
- map__to_assoc_list( Map0, Assoc0 ),
+ SelectorSet0 = alias_sel_set(_Size0, Map0),
+ SelectorSet1 = alias_sel_set(_Size1, Map1),
+ map__to_assoc_list(Map0, Assoc0),
list__foldl(
- alias_set2_lub( ModuleInfo, Type ),
+ alias_set2_lub(ModuleInfo, Type),
Assoc0,
Map1,
Map),
- alias_set2_add( alias_sel_set(0,Map), SelectorSet0, SelectorSet).
+ alias_set2_add(alias_sel_set(0,Map), SelectorSet0, SelectorSet).
- % alias_set2_lub( ModuleInfo, Type, Pair, Map0, Map):-
+ % alias_set2_lub(ModuleInfo, Type, Pair, Map0, Map):-
% Least upper bound between a real selectorset (Map0), and one
% single entry of another selectorset (Pair).
% precondition: the first selectorset is minimal (i.e., does
% not contain superfluous entries, e.g. Hv1/[] - Hv2/[] and
% in the same time Hv1/el - Hv2/el .
-:- pred alias_set2_lub( module_info::in, (type)::in,
+:- pred alias_set2_lub(module_info::in, (type)::in,
pair(selector,data_set)::in,
map(selector, data_set)::in,
- map(selector, data_set)::out ) is det.
-alias_set2_lub( ModuleInfo, Type, Pair0, M0, M):-
- map__keys( M0, Selectors ),
+ map(selector, data_set)::out) is det.
+alias_set2_lub(ModuleInfo, Type, Pair0, M0, M):-
+ map__keys(M0, Selectors),
Pair0 = Sel0 - DataSet0,
list__foldl2(
- alias_set2_lub2( ModuleInfo, Type, Sel0 ),
+ alias_set2_lub2(ModuleInfo, Type, Sel0),
Selectors,
DataSet0,
DataSet,
M0,
M1),
% and finally, add what is remaining of DataSet
- (
+ (
data_set_empty(DataSet)
->
M = M1
;
(
- map__search( M1, Sel0, DataSetA)
+ map__search(M1, Sel0, DataSetA)
->
- data_set_add( DataSetA, DataSet, DataSetNew),
- map__det_update( M1, Sel0, DataSetNew, M)
+ data_set_add(DataSetA, DataSet, DataSetNew),
+ map__det_update(M1, Sel0, DataSetNew, M)
;
- map__det_insert( M1, Sel0, DataSet0, M)
+ map__det_insert(M1, Sel0, DataSet0, M)
)
).
- % alias_set2_lub2( ModuleInfo, Type, FirstSel0, OtherSel,
+ % alias_set2_lub2(ModuleInfo, Type, FirstSel0, OtherSel,
% FirstDataSet0, FirstDataSet,
- % OtherMap0, OtherMap ).
+ % OtherMap0, OtherMap).
% OtherSel is a selector from OtherMap0. FirstDataSet0 corresponds
% with FirstSel0, and comes from a first SelectorSet.
-:- pred alias_set2_lub2( module_info::in, (type)::in,
+:- pred alias_set2_lub2(module_info::in, (type)::in,
selector::in, selector::in,
data_set::in, data_set::out,
map(selector, data_set)::in,
- map(selector, data_set)::out ) is det.
-alias_set2_lub2( ModuleInfo, Type, FirstSel0, OtherSel,
+ map(selector, data_set)::out) is det.
+alias_set2_lub2(ModuleInfo, Type, FirstSel0, OtherSel,
FirstDataSet0, FirstDataSet,
- OtherMap0, OtherMap ):-
- (
- data_set_empty( FirstDataSet0 )
+ OtherMap0, OtherMap):-
+ (
+ data_set_empty(FirstDataSet0)
->
FirstDataSet = FirstDataSet0,
OtherMap = OtherMap0
;
(
% FirstSel0 = OtherSel.Extension
- pa_selector__less_or_equal( ModuleInfo,
+ pa_selector__less_or_equal(ModuleInfo,
FirstSel0, OtherSel, Type, Extension)
->
- map__lookup( OtherMap0, OtherSel, OtherDataSet0 ),
- data_set_termshift( OtherDataSet0, Extension,
- OtherDataSetOTS ),
+ map__lookup(OtherMap0, OtherSel, OtherDataSet0),
+ data_set_termshift(OtherDataSet0, Extension,
+ OtherDataSetOTS),
% remove the OtherDataSetOTS entries from
% FirstDataSet0
- data_set_difference( FirstDataSet0, OtherDataSetOTS,
- FirstDataSet ),
+ data_set_difference(FirstDataSet0, OtherDataSetOTS,
+ FirstDataSet),
OtherMap = OtherMap0
;
- pa_selector__less_or_equal( ModuleInfo,
+ pa_selector__less_or_equal(ModuleInfo,
OtherSel, FirstSel0, Type, Extension)
->
- map__lookup( OtherMap0, OtherSel, OtherDataSet0 ),
- data_set_termshift( FirstDataSet0, Extension,
- FirstDataSet0TS ),
- data_set_difference( OtherDataSet0,
+ map__lookup(OtherMap0, OtherSel, OtherDataSet0),
+ data_set_termshift(FirstDataSet0, Extension,
+ FirstDataSet0TS),
+ data_set_difference(OtherDataSet0,
FirstDataSet0TS,
- OtherDataSet ),
- map__det_update( OtherMap0, OtherSel, OtherDataSet,
- OtherMap ),
+ OtherDataSet),
+ map__det_update(OtherMap0, OtherSel, OtherDataSet,
+ OtherMap),
FirstDataSet = FirstDataSet0
;
FirstDataSet = FirstDataSet0,
@@ -985,53 +985,53 @@
).
-alias_set2_normalize( ModuleInfo, ProcInfo, Type, SelectorSet0,
- SelectorSet ):-
- SelectorSet0 = alias_sel_set( _, Map0 ),
- map__keys( Map0, Selectors),
+alias_set2_normalize(ModuleInfo, ProcInfo, Type, SelectorSet0,
+ SelectorSet):-
+ SelectorSet0 = alias_sel_set(_, Map0),
+ map__keys(Map0, Selectors),
list__foldl(
- pred( Sel0::in, M0::in, M::out) is det:-
- (
- pa_selector__normalize_wti( Type, ModuleInfo,
- Sel0, Sel0Norm ),
- map__lookup( Map0, Sel0, DataSet0 ),
- data_set_normalize( ModuleInfo, ProcInfo,
- DataSet0, DataSet1 ),
+ pred(Sel0::in, M0::in, M::out) is det:-
+ (
+ pa_selector__normalize_wti(Type, ModuleInfo,
+ Sel0, Sel0Norm),
+ map__lookup(Map0, Sel0, DataSet0),
+ data_set_normalize(ModuleInfo, ProcInfo,
+ DataSet0, DataSet1),
(
- map__search( M0, Sel0Norm, DataSetM )
+ map__search(M0, Sel0Norm, DataSetM)
->
- data_set_add( DataSetM, DataSet1, DataSet ),
- map__det_update( M0, Sel0Norm, DataSet, M)
+ data_set_add(DataSetM, DataSet1, DataSet),
+ map__det_update(M0, Sel0Norm, DataSet, M)
;
- map__det_insert( M0, Sel0Norm, DataSet1, M)
+ map__det_insert(M0, Sel0Norm, DataSet1, M)
)
- ),
+ ),
Selectors,
map__init,
Map),
- alias_set2_recount( alias_sel_set( 0, Map), SelectorSet ).
+ alias_set2_recount(alias_sel_set(0, Map), SelectorSet).
-alias_set2_remove_vars( Vars, SelectorSet0, SelectorSet ):-
- SelectorSet0 = alias_sel_set( _, Map0 ),
- map__keys( Map0, Selectors0 ),
+alias_set2_remove_vars(Vars, SelectorSet0, SelectorSet):-
+ SelectorSet0 = alias_sel_set(_, Map0),
+ map__keys(Map0, Selectors0),
list__foldl(
- pred( Sel0::in, M0::in, M::out) is det :-
- (
- map__lookup( Map0, Sel0, DataSet0 ),
- data_set_remove_vars( Vars, DataSet0, DataSet ),
+ pred(Sel0::in, M0::in, M::out) is det :-
+ (
+ map__lookup(Map0, Sel0, DataSet0),
+ data_set_remove_vars(Vars, DataSet0, DataSet),
(
- data_set_empty( DataSet )
+ data_set_empty(DataSet)
->
M = M0
;
- map__det_insert( M0, Sel0, DataSet, M )
+ map__det_insert(M0, Sel0, DataSet, M)
)
- ),
+ ),
Selectors0,
map__init,
- Map ),
- alias_set2_recount( alias_sel_set( 0, Map), SelectorSet).
+ Map),
+ alias_set2_recount(alias_sel_set(0, Map), SelectorSet).
alias_set2_apply_widening(ModuleInfo, ProcInfo, ProgVar,
SelectorSet0, SelectorSet):-
@@ -1039,7 +1039,7 @@
map__keys(Map0, Selectors),
list__foldl(
pred(Sel0::in, M0::in, M::out) is det:-
- (
+ (
% widening of the associated datastructures
map__lookup(Map0, Sel0, DataSet0),
data_set_apply_widening(ModuleInfo, ProcInfo,
@@ -1080,44 +1080,44 @@
% data_set
-:- pred data_set_empty( data_set ).
+:- pred data_set_empty(data_set).
:- func data_set_empty = data_set.
-:- mode data_set_empty( out ) is det.
-:- mode data_set_empty( in ) is semidet.
+:- mode data_set_empty(out) is det.
+:- mode data_set_empty(in) is semidet.
-:- pred data_set_new_entry( datastruct::in, data_set::in,
- bool::out, data_set::out ) is det.
-:- pred data_set_new_entry( datastruct::in, data_set::in, data_set::out) is det.
-:- pred data_set_member( datastruct::in, data_set::in) is semidet.
-:- pred data_set_get_size( data_set::in, int::out) is det.
-:- pred data_set_get_datastructs( data_set::in, list(datastruct)::out) is det.
-:- pred data_set_project( list(prog_var)::in,
+:- pred data_set_new_entry(datastruct::in, data_set::in,
+ bool::out, data_set::out) is det.
+:- pred data_set_new_entry(datastruct::in, data_set::in, data_set::out) is det.
+:- pred data_set_member(datastruct::in, data_set::in) is semidet.
+:- pred data_set_get_size(data_set::in, int::out) is det.
+:- pred data_set_get_datastructs(data_set::in, list(datastruct)::out) is det.
+:- pred data_set_project(list(prog_var)::in,
data_set::in, data_set::out) is det.
-:- pred data_set_rename( map(prog_var, prog_var)::in,
+:- pred data_set_rename(map(prog_var, prog_var)::in,
data_set::in, data_set::out) is det.
-:- pred data_set_rename_types( term__substitution(tvar_type)::in,
+:- pred data_set_rename_types(term__substitution(tvar_type)::in,
data_set::in, data_set::out) is det.
-:- pred data_set_equal( data_set::in, data_set::in ) is semidet.
-:- pred data_set_add( data_set::in, data_set::in, data_set::out) is det.
-:- pred data_set_termshift( data_set::in, selector::in, data_set::out) is det.
-:- pred data_set_normalize( module_info::in, proc_info::in,
+:- pred data_set_equal(data_set::in, data_set::in) is semidet.
+:- pred data_set_add(data_set::in, data_set::in, data_set::out) is det.
+:- pred data_set_termshift(data_set::in, selector::in, data_set::out) is det.
+:- pred data_set_normalize(module_info::in, proc_info::in,
data_set::in, data_set::out) is det.
-:- pred data_set_generate_directed_aliases( data_set::in,
+:- pred data_set_generate_directed_aliases(data_set::in,
data_set::in, list(alias)::out) is det.
-:- pred data_set_remove_vars( list(prog_var)::in, data_set::in,
+:- pred data_set_remove_vars(list(prog_var)::in, data_set::in,
data_set::out) is det.
- % data_set_difference( A, B, C ):- C = A - B.
-:- pred data_set_difference( data_set::in, data_set::in,
+ % data_set_difference(A, B, C):- C = A - B.
+:- pred data_set_difference(data_set::in, data_set::in,
data_set::out) is det.
:- pred data_set_apply_widening(module_info::in, proc_info::in,
data_set::in, data_set::out) is det.
-data_set_empty( datastructs(0, set__init ) ).
+data_set_empty(datastructs(0, set__init)).
data_set_empty = D :- data_set_empty(D).
-data_set_new_entry( Data, DataSet0, NewAddition, DataSet ):-
- DataSet0 = datastructs( Size0, Datastructs0 ),
+data_set_new_entry(Data, DataSet0, NewAddition, DataSet):-
+ DataSet0 = datastructs(Size0, Datastructs0),
(
- set__member( Data, Datastructs0 )
+ set__member(Data, Datastructs0)
->
NewAddition = bool__no,
DataSet = DataSet0
@@ -1125,121 +1125,121 @@
set__insert(Datastructs0, Data, Datastructs),
Size = Size0 + 1,
NewAddition = bool__yes,
- DataSet = datastructs( Size, Datastructs )
+ DataSet = datastructs(Size, Datastructs)
).
-data_set_new_entry( Data, DataSet0, DataSet) :-
- data_set_new_entry( Data, DataSet0, _, DataSet).
-data_set_member( Data, DataSet ) :-
- DataSet = datastructs( N, DataStructs),
+data_set_new_entry(Data, DataSet0, DataSet) :-
+ data_set_new_entry(Data, DataSet0, _, DataSet).
+data_set_member(Data, DataSet) :-
+ DataSet = datastructs(N, DataStructs),
N \= 0,
- set__member( Data, DataStructs ).
-data_set_get_size( DataSet, Size ):-
- DataSet = datastructs( Size, _ ).
-data_set_get_datastructs( DataSet, ListDatastructs ):-
- DataSet = datastructs( _, SetDatastructs),
- set__to_sorted_list( SetDatastructs, ListDatastructs).
-data_set_project( Vars, DataSet0, DataSet ):-
- data_set_filter(
- pred( Data::in ) is semidet :-
- (
+ set__member(Data, DataStructs).
+data_set_get_size(DataSet, Size):-
+ DataSet = datastructs(Size, _).
+data_set_get_datastructs(DataSet, ListDatastructs):-
+ DataSet = datastructs(_, SetDatastructs),
+ set__to_sorted_list(SetDatastructs, ListDatastructs).
+data_set_project(Vars, DataSet0, DataSet):-
+ data_set_filter(
+ pred(Data::in) is semidet :-
+ (
get_var(Data, Var),
- list__member( Var, Vars )
- ),
+ list__member(Var, Vars)
+ ),
DataSet0,
- DataSet ).
-data_set_rename( Dict, DataSet0, DataSet) :-
- data_set_map( pa_datastruct__rename( Dict ), DataSet0, DataSet).
-data_set_rename_types( Subst, DataSet0, DataSet ):-
- data_set_map( pa_datastruct__rename_types( Subst ),
- DataSet0, DataSet ).
-data_set_equal( DataSet0, DataSet1 ):-
- DataSet0 = datastructs( Size0, Data0 ),
- DataSet1 = datastructs( Size0, Data1 ),
+ DataSet).
+data_set_rename(Dict, DataSet0, DataSet) :-
+ data_set_map(pa_datastruct__rename(Dict), DataSet0, DataSet).
+data_set_rename_types(Subst, DataSet0, DataSet):-
+ data_set_map(pa_datastruct__rename_types(Subst),
+ DataSet0, DataSet).
+data_set_equal(DataSet0, DataSet1):-
+ DataSet0 = datastructs(Size0, Data0),
+ DataSet1 = datastructs(Size0, Data1),
set__to_sorted_list(Data0, LData0),
set__to_sorted_list(Data1, LData1),
list__foldl(
- ho_delete( pa_datastruct__equal),
+ ho_delete(pa_datastruct__equal),
LData0,
LData1,
- [] ).
+ []).
- % ho_delete( EqualityTest, Elem, List0, List): delete element Elem
+ % ho_delete(EqualityTest, Elem, List0, List): delete element Elem
% from the given list (List0) using the EqualityTest.
-:- pred ho_delete( pred(T, T), T, list(T), list(T)).
-:- mode ho_delete( pred( in, in) is semidet, in, in, out) is semidet.
-ho_delete( Equal, Elem, List0, List) :-
+:- pred ho_delete(pred(T, T), T, list(T), list(T)).
+:- mode ho_delete(pred(in, in) is semidet, in, in, out) is semidet.
+ho_delete(Equal, Elem, List0, List) :-
List0 = [ H | T ],
(
- Equal( Elem, H )
+ Equal(Elem, H)
->
List = T
;
- ho_delete( Equal, Elem, T, Rest ),
+ ho_delete(Equal, Elem, T, Rest),
List = [ H | Rest ]
).
-data_set_add( DataSet0, DataSet1, DataSet) :-
- DataSet0 = datastructs( _Size0, Data0 ),
- DataSet1 = datastructs( _Size1, Data1 ),
- Data = set__union( Data0, Data1 ),
- DataSet = datastructs( set__count(Data), Data ).
+data_set_add(DataSet0, DataSet1, DataSet) :-
+ DataSet0 = datastructs(_Size0, Data0),
+ DataSet1 = datastructs(_Size1, Data1),
+ Data = set__union(Data0, Data1),
+ DataSet = datastructs(set__count(Data), Data).
-data_set_termshift( DataSet0, Sel, DataSet ):-
+data_set_termshift(DataSet0, Sel, DataSet):-
data_set_map(
- pred( D0::in, D::out) is det :-
- (
- pa_datastruct__termshift( D0, Sel, D)
- ),
+ pred(D0::in, D::out) is det :-
+ (
+ pa_datastruct__termshift(D0, Sel, D)
+ ),
DataSet0,
- DataSet ).
+ DataSet).
% higher order predicates for handling data_set's.
-:- pred data_set_map( pred( datastruct, datastruct), data_set, data_set).
-:- mode data_set_map( pred(in, out) is det, in, out) is det.
-data_set_map( Pred, DataSet0, DataSet ):-
- DataSet0 = datastructs( _Size, Datastructs0 ),
- Datastructs = set__map( tofunc(Pred), Datastructs0),
- DataSet = datastructs( set__count(Datastructs), Datastructs ).
-
-:- func tofunc( pred(X,Y), X ) = Y.
-:- mode tofunc( pred(in,out) is det, in) = out is det.
-
-tofunc( Pred, X ) = Y :- Pred(X, Y).
-
-:- pred data_set_filter( pred(datastruct), data_set, data_set).
-:- mode data_set_filter( pred(in) is semidet, in, out) is det.
-data_set_filter( Pred, DataSet0, DataSet):-
- DataSet0 = datastructs( _, Datastructs0),
- Datastructs = set__filter( Pred, Datastructs0),
- DataSet = datastructs( set__count(Datastructs), Datastructs).
-
-data_set_normalize( ModuleInfo, ProcInfo, DataSet0, DataSet ):-
- data_set_map(
- pa_datastruct__normalize_wti( ProcInfo, ModuleInfo ),
+:- pred data_set_map(pred(datastruct, datastruct), data_set, data_set).
+:- mode data_set_map(pred(in, out) is det, in, out) is det.
+data_set_map(Pred, DataSet0, DataSet):-
+ DataSet0 = datastructs(_Size, Datastructs0),
+ Datastructs = set__map(tofunc(Pred), Datastructs0),
+ DataSet = datastructs(set__count(Datastructs), Datastructs).
+
+:- func tofunc(pred(X,Y), X) = Y.
+:- mode tofunc(pred(in,out) is det, in) = out is det.
+
+tofunc(Pred, X) = Y :- Pred(X, Y).
+
+:- pred data_set_filter(pred(datastruct), data_set, data_set).
+:- mode data_set_filter(pred(in) is semidet, in, out) is det.
+data_set_filter(Pred, DataSet0, DataSet):-
+ DataSet0 = datastructs(_, Datastructs0),
+ Datastructs = set__filter(Pred, Datastructs0),
+ DataSet = datastructs(set__count(Datastructs), Datastructs).
+
+data_set_normalize(ModuleInfo, ProcInfo, DataSet0, DataSet):-
+ data_set_map(
+ pa_datastruct__normalize_wti(ProcInfo, ModuleInfo),
DataSet0,
- DataSet ).
+ DataSet).
-data_set_generate_directed_aliases( FromDataSet, ToDataSet, Aliases):-
- FromDataSet = datastructs( _, FromData),
- ToDataSet = datastructs( _, ToData ),
- set_cross_product( FromData, ToData, AliasesSet),
- set__to_sorted_list( AliasesSet, Aliases ).
-
-data_set_remove_vars( Vars, DataSet0, DataSet ):-
- data_set_filter(
- pred( DataStruct::in ) is semidet :-
- (
- get_var( DataStruct, Var ),
- \+ list__member( Var, Vars )
- ),
+data_set_generate_directed_aliases(FromDataSet, ToDataSet, Aliases):-
+ FromDataSet = datastructs(_, FromData),
+ ToDataSet = datastructs(_, ToData),
+ set_cross_product(FromData, ToData, AliasesSet),
+ set__to_sorted_list(AliasesSet, Aliases).
+
+data_set_remove_vars(Vars, DataSet0, DataSet):-
+ data_set_filter(
+ pred(DataStruct::in) is semidet :-
+ (
+ get_var(DataStruct, Var),
+ \+ list__member(Var, Vars)
+ ),
DataSet0,
- DataSet ).
+ DataSet).
-data_set_difference( DataSet1, DataSet2, DataSet ):-
- DataSet1 = datastructs( _, Data1),
- DataSet2 = datastructs( _, Data2),
- Data = set__difference( Data1, Data2 ),
- DataSet = datastructs( set__count( Data ), Data ).
+data_set_difference(DataSet1, DataSet2, DataSet):-
+ DataSet1 = datastructs(_, Data1),
+ DataSet2 = datastructs(_, Data2),
+ Data = set__difference(Data1, Data2),
+ DataSet = datastructs(set__count(Data), Data).
data_set_apply_widening(ModuleInfo, ProcInfo, DataSet0, DataSet):-
DataSet0 = datastructs(_, Data0),
@@ -1249,31 +1249,31 @@
DataSet = datastructs(set__count(Data), Data).
-:- pred set_cross_product( set(T1)::in, set(T2)::in,
+:- pred set_cross_product(set(T1)::in, set(T2)::in,
set(pair(T1, T2))::out) is det.
-set_cross_product( Set0, Set1, CrossProduct ):-
+set_cross_product(Set0, Set1, CrossProduct):-
solutions_set(
- pred( Pair::out ) is nondet :-
- (
- set__member( Elem0, Set0 ),
- set__member( Elem1, Set1 ),
+ pred(Pair::out) is nondet :-
+ (
+ set__member(Elem0, Set0),
+ set__member(Elem1, Set1),
Pair = Elem0 - Elem1
- ),
+ ),
CrossProduct).
%-----------------------------------------------------------------------------%
:- import_module require, string.
-:- pred map_det_insert( map(K,V)::in, K::in, V::in,
+:- pred map_det_insert(map(K,V)::in, K::in, V::in,
map(K,V)::out, string::in) is det.
-map_det_insert( Map0, K, V, Map, Msg ) :-
+map_det_insert(Map0, K, V, Map, Msg) :-
(
- map__insert( Map0, K, V, Map1 )
+ map__insert(Map0, K, V, Map1)
->
Map = Map1
;
string__append_list([ Msg, ": map_det_insert-problem"], Msg2),
- require__error( Msg2 )
+ require__error(Msg2)
).
Index: pa_datastruct.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_datastruct.m,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 pa_datastruct.m
--- pa_datastruct.m 2001/03/20 17:34:48 1.1.2.5
+++ pa_datastruct.m 2001/03/23 10:22:53
@@ -58,7 +58,7 @@
:- pred init(prog_var, cons_id, int, datastruct).
:- mode init(in, in, in, out) is det.
-:- pred create( prog_var::in, selector::in, datastruct::out) is det.
+:- pred create(prog_var::in, selector::in, datastruct::out) is det.
% Extend the given datastructure with an additional path.
:- pred termshift(datastruct, selector, datastruct).
@@ -84,7 +84,7 @@
:- pred rename(map(prog_var,prog_var), datastruct, datastruct).
:- mode rename(in, in, out) is det.
-:- pred rename_types( term__substitution(tvar_type)::in,
+:- pred rename_types(term__substitution(tvar_type)::in,
datastruct::in, datastruct::out) is det.
% Printing routines
@@ -92,13 +92,13 @@
:- mode print(in, in, in, di, uo) is det.
% Parsing routines
-:- pred parse_term( term(T), datastruct ).
-:- mode parse_term( in, out ) is det.
+:- pred parse_term(term(T), datastruct).
+:- mode parse_term(in, out) is det.
:- pred normalize_wti(proc_info, module_info, datastruct, datastruct).
:- mode normalize_wti(in, in, in, out) is det.
-:- pred apply_widening( module_info::in, proc_info::in, datastruct::in,
+:- pred apply_widening(module_info::in, proc_info::in, datastruct::in,
datastruct::out) is det.
:- func apply_widening(module_info, proc_info, datastruct) = datastruct.
@@ -118,17 +118,17 @@
get_selector(cel(_Var, SEL), SEL).
-rename( MAP, DATAin, DATAout) :-
+rename(MAP, DATAin, DATAout) :-
DATAin = cel(VAR, SEL),
- map__lookup( MAP, VAR, RVAR),
+ map__lookup(MAP, VAR, RVAR),
DATAout = cel(RVAR, SEL).
-rename_types( Subst, Data0, Data) :-
- Data0 = cel( Var, Sel0),
- pa_selector__rename_types( Subst, Sel0, Sel),
- Data = cel( Var, Sel).
+rename_types(Subst, Data0, Data) :-
+ Data0 = cel(Var, Sel0),
+ pa_selector__rename_types(Subst, Sel0, Sel),
+ Data = cel(Var, Sel).
-equal( D1, D2 ):- D1 = D2.
+equal(D1, D2):- D1 = D2.
same_vars(D1, D2):-
get_var(D1,V),
@@ -138,7 +138,7 @@
same_vars(D1,D2),
get_var(D1,ProgVar),
proc_info_vartypes(ProcInfo, VarTypes),
- map__lookup( VarTypes, ProgVar, ProgVarType),
+ map__lookup(VarTypes, ProgVar, ProgVarType),
(
equal(D1,D2)
->
@@ -154,30 +154,30 @@
pa_selector__termshift(Sin,S,Sout),
Dout = cel(V,Sout).
-init( V, CONS, INDEX, Dout) :-
+init(V, CONS, INDEX, Dout) :-
pa_selector__init(CONS,INDEX, SEL),
Dout = cel(V,SEL).
-init( V, Dout) :-
+init(V, Dout) :-
SEL = [],
Dout = cel(V, SEL).
-create( V, Sel, Dout ) :-
- Dout = cel( V, Sel).
+create(V, Sel, Dout) :-
+ Dout = cel(V, Sel).
-print( D, ProcInfo, PredInfo) -->
- { D = cel( ProgVar, SEL ) },
+print(D, ProcInfo, PredInfo) -->
+ { D = cel(ProgVar, SEL) },
{ proc_info_varset(ProcInfo, ProgVarset) },
- { varset__lookup_name( ProgVarset, ProgVar, ProgName ) },
+ { varset__lookup_name(ProgVarset, ProgVar, ProgName) },
io__write_string("cel("),
- io__write_string( ProgName ),
+ io__write_string(ProgName),
io__write_string(", "),
- { pred_info_typevarset( PredInfo, TypeVarSet ) },
+ { pred_info_typevarset(PredInfo, TypeVarSet) },
pa_selector__print(SEL, TypeVarSet),
io__write_string(")").
-parse_term( TERM, Data ) :-
+parse_term(TERM, Data) :-
(
- TERM = term__functor( term__atom( CONS ), Args, _ )
+ TERM = term__functor(term__atom(CONS), Args, _)
->
(
CONS = "cel"
@@ -196,7 +196,7 @@
)
;
list__length(Args, L),
- string__int_to_string( L, LS),
+ string__int_to_string(L, LS),
string__append_list(["(pa_datastruct) parse_term: wrong number of arguments. cel/",LS,
"should be cel/2"],Msg),
error(Msg)
@@ -212,26 +212,26 @@
normalize_wti(ProcInfo, HLDS, Din, Dout):-
- proc_info_vartypes( ProcInfo, VarTypes ),
- normalize_wti_2( VarTypes, HLDS, Din, Dout).
+ proc_info_vartypes(ProcInfo, VarTypes),
+ normalize_wti_2(VarTypes, HLDS, Din, Dout).
% normalize with type information
-:- pred normalize_wti_2( vartypes, module_info,
- datastruct, datastruct ).
-:- mode normalize_wti_2( in, in, in, out) is det.
+:- pred normalize_wti_2(vartypes, module_info,
+ datastruct, datastruct).
+:- mode normalize_wti_2(in, in, in, out) is det.
-normalize_wti_2( VarTypes, HLDS, D0, D ):-
- D0 = cel( ProgVar, SEL0 ),
+normalize_wti_2(VarTypes, HLDS, D0, D):-
+ D0 = cel(ProgVar, SEL0),
map__lookup(VarTypes, ProgVar, VarType),
- pa_selector__normalize_wti( VarType, HLDS, SEL0, SEL),
- D = cel( ProgVar, SEL ).
+ pa_selector__normalize_wti(VarType, HLDS, SEL0, SEL),
+ D = cel(ProgVar, SEL).
-apply_widening( ModuleInfo, ProcInfo, D0, D ):-
- D0 = cel( ProgVar, Sel0 ),
+apply_widening(ModuleInfo, ProcInfo, D0, D):-
+ D0 = cel(ProgVar, Sel0),
proc_info_vartypes(ProcInfo, VarTypes),
- map__lookup( VarTypes, ProgVar, ProgVarType),
- pa_selector__apply_widening( ModuleInfo, ProgVarType, Sel0, Sel),
- D = cel( ProgVar, Sel ).
+ map__lookup(VarTypes, ProgVar, ProgVarType),
+ pa_selector__apply_widening(ModuleInfo, ProgVarType, Sel0, Sel),
+ D = cel(ProgVar, Sel).
apply_widening(ModuleInfo, ProcInfo, D0) = D :-
apply_widening(ModuleInfo, ProcInfo, D0, D).
Index: pa_prelim_run.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_prelim_run.m,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 pa_prelim_run.m
--- pa_prelim_run.m 2001/03/06 11:13:33 1.1.2.5
+++ pa_prelim_run.m 2001/03/23 10:22:53
@@ -57,11 +57,11 @@
module_info::out, io__state::di, io__state::uo) is det.
annotate_all_liveness_in_module_2(PredId, HLDSin, HLDSout) -->
- { module_info_pred_info( HLDSin, PredId, PredInfo0) },
+ { module_info_pred_info(HLDSin, PredId, PredInfo0) },
{ pred_info_procids(PredInfo0, ProcIds) },
list__foldl2(annotate_all_liveness_in_pred(PredId, HLDSin),
ProcIds, PredInfo0, PredInfo),
- { module_info_set_pred_info( HLDSin, PredId, PredInfo, HLDSout) }.
+ { module_info_set_pred_info(HLDSin, PredId, PredInfo, HLDSout) }.
:- pred annotate_all_liveness_in_pred(pred_id::in, module_info::in,
proc_id::in, pred_info::in, pred_info::out,
@@ -89,7 +89,7 @@
module_info).
:- mode annotate_all_outscope_vars_in_module_2(in, in, out) is det.
-annotate_all_outscope_vars_in_module_2(PredId, HLDSin, HLDSout ):-
+annotate_all_outscope_vars_in_module_2(PredId, HLDSin, HLDSout):-
module_info_pred_info(HLDSin, PredId, PredInfo0),
pred_info_procids(PredInfo0, ProcIds),
list__foldl(annotate_all_outscope_vars_in_pred,
@@ -101,8 +101,8 @@
annotate_all_outscope_vars_in_pred(ProcId, PredInfo0, PredInfo) :-
pred_info_procedures(PredInfo0, Procedures0),
- map__lookup(Procedures0, ProcId, ProcInfo0 ),
- proc_info_goal(ProcInfo0, Goal0 ),
+ map__lookup(Procedures0, ProcId, ProcInfo0),
+ proc_info_goal(ProcInfo0, Goal0),
set__init(Outscope),
annotate_all_outscope_vars_in_goal(Goal0, Outscope, Goal, _NewOutscope),
proc_info_set_goal(ProcInfo0, Goal, ProcInfo),
@@ -117,9 +117,9 @@
Goal0 = Expr0 - Info0,
(
% 1. conjunction
- Expr0 = conj( Goals0 )
+ Expr0 = conj(Goals0)
->
- list__map_foldl(
+ list__map_foldl(
(pred(G0::in, G::out, OSin::in, OSout::out) is det :-
annotate_all_outscope_vars_in_goal(G0,
OSin, G, OSout)
@@ -138,7 +138,7 @@
Expr0 = switch(A, B, Cases0, D)
->
list__map(
- (pred( C0::in, C::out) is det :-
+ (pred(C0::in, C::out) is det :-
C0 = case(ConsId, G0),
annotate_all_outscope_vars_in_goal(G0,
Outscope, G, _),
Index: pa_run.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_run.m,v
retrieving revision 1.1.2.20
diff -u -r1.1.2.20 pa_run.m
--- pa_run.m 2001/03/22 19:55:34 1.1.2.20
+++ pa_run.m 2001/03/23 10:22:54
@@ -23,14 +23,14 @@
% the main pass
-:- pred pa_run__aliases_pass( module_info, module_info, io__state, io__state).
-:- mode pa_run__aliases_pass( in, out, di, uo) is det.
+:- pred pa_run__aliases_pass(module_info, module_info, io__state, io__state).
+:- mode pa_run__aliases_pass(in, out, di, uo) is det.
% write the pa_info pragma for the given pred_id (if that
% pred_id does not belong to the list(pred_id).
-:- pred pa_run__write_pred_pa_info( module_info, list(pred_id), pred_id,
+:- pred pa_run__write_pred_pa_info(module_info, list(pred_id), pred_id,
io__state, io__state).
-:- mode pa_run__write_pred_pa_info( in, in, in, di, uo) is det.
+:- mode pa_run__write_pred_pa_info(in, in, in, di, uo) is det.
% lookup the alias-information for some pred_id proc_id in the
% module_info. Rename the alias-information to the given
@@ -51,11 +51,11 @@
% proc is called
% AliasIN = alias at moment of call
% AliasOUT = alias at end of call
-:- pred pa_run__extend_with_call_alias( module_info, proc_info,
+:- pred pa_run__extend_with_call_alias(module_info, proc_info,
pred_id, proc_id,
list(prog_var),
- list( (type) ), alias_as, alias_as).
-:- mode pa_run__extend_with_call_alias( in, in, in, in, in, in, in, out) is det.
+ list((type)), alias_as, alias_as).
+:- mode pa_run__extend_with_call_alias(in, in, in, in, in, in, in, out) is det.
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
@@ -80,50 +80,50 @@
%-----------------------------------------------------------------------------%
-pa_run__aliases_pass( HLDSin, HLDSout ) -->
+pa_run__aliases_pass(HLDSin, HLDSout) -->
% preliminary steps:
% 1. annotate all the liveness
- pa_prelim_run__annotate_all_liveness_in_module( HLDSin, HLDS1 ),
+ pa_prelim_run__annotate_all_liveness_in_module(HLDSin, HLDS1),
% 2. annotate all the outscope vars
{ pa_prelim_run__annotate_all_outscope_vars_in_module(HLDS1,HLDS2) },
% 3. and finally do the actual aliases pass
- aliases_pass_2( HLDS2, HLDSout ).
+ aliases_pass_2(HLDS2, HLDSout).
-:- pred aliases_pass_2( module_info, module_info, io__state, io__state).
-:- mode aliases_pass_2( in, out, di, uo) is det.
+:- pred aliases_pass_2(module_info, module_info, io__state, io__state).
+:- mode aliases_pass_2(in, out, di, uo) is det.
-pa_run__aliases_pass_2( HLDSin, HLDSout ) -->
+pa_run__aliases_pass_2(HLDSin, HLDSout) -->
% strongly connected components needed
- { module_info_ensure_dependency_info( HLDSin, HLDS1) },
- { module_info_get_maybe_dependency_info( HLDS1, MaybeDepInfo) } ,
+ { module_info_ensure_dependency_info(HLDSin, HLDS1) },
+ { module_info_get_maybe_dependency_info(HLDS1, MaybeDepInfo) } ,
(
{ MaybeDepInfo = yes(DepInfo) }
->
- { hlds_dependency_info_get_dependency_ordering( DepInfo, DepOrdering ) },
+ { hlds_dependency_info_get_dependency_ordering(DepInfo, DepOrdering) },
% perform the analysis, and annotate the procedures
- run_with_dependencies( DepOrdering, HLDS1, HLDSout) %,
+ run_with_dependencies(DepOrdering, HLDS1, HLDSout) %,
% write out the results of the exported procedures into
% a separate interface-file.
- % pa_run__make_pa_interface( HLDSout )
+ % pa_run__make_pa_interface(HLDSout)
;
{ error("(pa) pa_run module: no dependency info") }
).
-:- pred run_with_dependencies( dependency_ordering, module_info,
+:- pred run_with_dependencies(dependency_ordering, module_info,
module_info, io__state, io__state).
-:- mode run_with_dependencies( in, in, out, di, uo) is det.
+:- mode run_with_dependencies(in, in, out, di, uo) is det.
-run_with_dependencies( Deps, HLDSin, HLDSout) -->
- list__foldl2( run_with_dependency, Deps, HLDSin, HLDSout ).
+run_with_dependencies(Deps, HLDSin, HLDSout) -->
+ list__foldl2(run_with_dependency, Deps, HLDSin, HLDSout).
-:- pred run_with_dependency( list(pred_proc_id), module_info, module_info,
+:- pred run_with_dependency(list(pred_proc_id), module_info, module_info,
io__state, io__state).
-:- mode run_with_dependency( in, in, out, di, uo ) is det.
+:- mode run_with_dependency(in, in, out, di, uo) is det.
-run_with_dependency( SCC , HLDSin, HLDSout ) -->
+run_with_dependency(SCC , HLDSin, HLDSout) -->
(
% analysis ignores special predicates
{ pa_sr_util__some_are_special_preds(SCC, HLDSin) }
@@ -132,40 +132,40 @@
;
% for each list of strongly connected components,
% perform a fixpoint computation.
- { pa_util__pa_fixpoint_table_init( SCC, FPtable0 ) } ,
- run_with_dependency_until_fixpoint( SCC, FPtable0,
- HLDSin, HLDSout )
+ { pa_util__pa_fixpoint_table_init(SCC, FPtable0) } ,
+ run_with_dependency_until_fixpoint(SCC, FPtable0,
+ HLDSin, HLDSout)
).
-:- pred run_with_dependency_until_fixpoint( list(pred_proc_id),
+:- pred run_with_dependency_until_fixpoint(list(pred_proc_id),
pa_util__pa_fixpoint_table, module_info, module_info,
- io__state, io__state ).
-:- mode run_with_dependency_until_fixpoint( in, in, in, out, di, uo) is det.
+ io__state, io__state).
+:- mode run_with_dependency_until_fixpoint(in, in, in, out, di, uo) is det.
-run_with_dependency_until_fixpoint( SCC, FPtable0, HLDSin, HLDSout ) -->
- list__foldl2( analyse_pred_proc( HLDSin), SCC, FPtable0, FPtable),
+run_with_dependency_until_fixpoint(SCC, FPtable0, HLDSin, HLDSout) -->
+ list__foldl2(analyse_pred_proc(HLDSin), SCC, FPtable0, FPtable),
(
- { pa_fixpoint_table_all_stable( FPtable ) }
+ { pa_fixpoint_table_all_stable(FPtable) }
->
- { list__foldl( update_alias_in_module_info(FPtable), SCC, HLDSin, HLDSout) }
+ { list__foldl(update_alias_in_module_info(FPtable), SCC, HLDSin, HLDSout) }
;
{ pa_util__pa_fixpoint_table_new_run(FPtable,FPtable1) },
- run_with_dependency_until_fixpoint( SCC, FPtable1,
- HLDSin, HLDSout )
+ run_with_dependency_until_fixpoint(SCC, FPtable1,
+ HLDSin, HLDSout)
).
%-----------------------------------------------------------------------------%
% THE KERNEL
%-----------------------------------------------------------------------------%
-:- pred analyse_pred_proc( module_info, pred_proc_id, pa_fixpoint_table,
+:- pred analyse_pred_proc(module_info, pred_proc_id, pa_fixpoint_table,
pa_fixpoint_table, io__state, io__state).
-:- mode analyse_pred_proc( in, in, in, out, di, uo) is det.
+:- mode analyse_pred_proc(in, in, in, out, di, uo) is det.
-analyse_pred_proc( HLDS, PRED_PROC_ID , FPtable0, FPtable) -->
+analyse_pred_proc(HLDS, PRED_PROC_ID , FPtable0, FPtable) -->
globals__io_lookup_bool_option(very_verbose,Verbose),
globals__io_lookup_int_option(possible_alias_widening, WideningLimit),
- { module_info_pred_proc_info( HLDS, PRED_PROC_ID,_PredInfo,
+ { module_info_pred_proc_info(HLDS, PRED_PROC_ID,_PredInfo,
ProcInfo_tmp) },
% XXX annotate all lbu/lfu stuff
@@ -177,16 +177,16 @@
{ PRED_PROC_ID = proc(PredId, ProcId) },
{ pa_util__pa_fixpoint_table_which_run(FPtable0, Run) },
- { string__int_to_string(Run, SRun )},
- { string__append_list( ["% Alias analysing (run ",SRun,") "],
- Msg ) },
- passes_aux__write_proc_progress_message( Msg,
- PredId, ProcId, HLDS ),
+ { string__int_to_string(Run, SRun)},
+ { string__append_list(["% Alias analysing (run ",SRun,") "],
+ Msg) },
+ passes_aux__write_proc_progress_message(Msg,
+ PredId, ProcId, HLDS),
{
% begin non-io
- proc_info_goal( ProcInfo, Goal),
- proc_info_headvars( ProcInfo, HeadVars),
+ proc_info_goal(ProcInfo, Goal),
+ proc_info_headvars(ProcInfo, HeadVars),
Goal = _ - GoalInfo,
goal_info_get_instmap_delta(GoalInfo, InstMapDelta),
instmap__init_reachable(InitIM),
@@ -194,15 +194,15 @@
pa_alias_as__init(Alias0),
- analyse_goal( ProcInfo, HLDS, Goal,
- FPtable0, FPtable1, Alias0, Alias1 ),
- FullSize = pa_alias_as__size( Alias1 ),
+ analyse_goal(ProcInfo, HLDS, Goal,
+ FPtable0, FPtable1, Alias0, Alias1),
+ FullSize = pa_alias_as__size(Alias1),
- pa_alias_as__project( HeadVars, Alias1, Alias2),
- ProjectSize = pa_alias_as__size( Alias2 ),
+ pa_alias_as__project(HeadVars, Alias1, Alias2),
+ ProjectSize = pa_alias_as__size(Alias2),
- pa_alias_as__normalize( ProcInfo, HLDS, InstMap, Alias2, Alias3 ),
- NormSize = pa_alias_as__size( Alias3 ),
+ pa_alias_as__normalize(ProcInfo, HLDS, InstMap, Alias2, Alias3),
+ NormSize = pa_alias_as__size(Alias3),
(
WideningLimit \= 0, NormSize > WideningLimit
@@ -217,7 +217,7 @@
WidenSize = NormSize
),
- pa_fixpoint_table_new_as( HLDS, ProcInfo,
+ pa_fixpoint_table_new_as(HLDS, ProcInfo,
PRED_PROC_ID, Alias, FPtable1, FPtable)
% end non-io
},
@@ -228,9 +228,9 @@
% io__write_string("\n")
% []
{
- string__int_to_string( FullSize, FullS ),
- string__int_to_string( ProjectSize, ProjectS ),
- string__int_to_string( NormSize, NormS )
+ string__int_to_string(FullSize, FullS),
+ string__int_to_string(ProjectSize, ProjectS),
+ string__int_to_string(NormSize, NormS)
},
io__write_strings(["\t\t: ", FullS, "/", ProjectS, "/",
NormS]),
@@ -248,7 +248,7 @@
(
{ dummy_test(PRED_PROC_ID) }
->
- { dummy_test_here( Alias ) },
+ { dummy_test_here(Alias) },
io__write_string("Alias = "),
pa_alias_as__print_aliases(Alias, ProcInfo,PredInfo),
io__write_string("\n\n")
@@ -261,9 +261,9 @@
[]
).
-:- pred dummy_test( pred_proc_id::in) is semidet.
-dummy_test( proc(PredId, _) ):- pred_id_to_int(PredId, 16).
-:- pred dummy_test_here( alias_as::in ) is det.
+:- pred dummy_test(pred_proc_id::in) is semidet.
+dummy_test(proc(PredId, _)):- pred_id_to_int(PredId, 16).
+:- pred dummy_test_here(alias_as::in) is det.
dummy_test_here(_).
% analyse a given goal, with module_info and fixpoint table
@@ -271,82 +271,61 @@
% substitution, and creating a new one. During this process,
% the fixpoint table might change (when recursive predicates are
% encountered).
- % analyse_goal( ProcInfo, HLDS, Goal, TableIn, TableOut,
- % AliasIn, AliasOut ).
-:- pred analyse_goal( proc_info, module_info, hlds_goal,
+ % analyse_goal(ProcInfo, HLDS, Goal, TableIn, TableOut,
+ % AliasIn, AliasOut).
+:- pred analyse_goal(proc_info, module_info, hlds_goal,
pa_fixpoint_table, pa_fixpoint_table,
alias_as, alias_as).
-:- mode analyse_goal( in, in, in, in, out, in, out) is det.
+:- mode analyse_goal(in, in, in, in, out, in, out) is det.
-analyse_goal( ProcInfo, HLDS,
- Goal, FPtable0, FPtable, Alias0, Alias ) :-
+analyse_goal(ProcInfo, HLDS,
+ Goal, FPtable0, FPtable, Alias0, Alias) :-
Goal = GoalExpr - GoalInfo ,
- /*
- extra: before even starting the analysis of the current goal,
- first project the entering alias-set (Alias0) to the set
- LFUi + LBUi + HeadVars
- */
- goal_info_get_lfu(GoalInfo, LFUi),
- goal_info_get_lbu(GoalInfo, LBUi),
- proc_info_real_headvars(ProcInfo, ListRealHeadVars),
- set__list_to_set(ListRealHeadVars, RealHeadVars),
- set__union(LFUi, LBUi, IN_USEi),
- set__union(IN_USEi, RealHeadVars, AliveVars),
-
- analyse_goal_expr( GoalExpr, GoalInfo,
+ analyse_goal_expr(GoalExpr, GoalInfo,
ProcInfo, HLDS,
FPtable0, FPtable, Alias0, Alias1),
-
- % projecting is too expensive to be done for each goal,
- % let's do it only on non-atomic goals:
- (
- goal_is_atomic( GoalExpr )
+ % extra: after the analysis of the current goal,
+ % project the obtained alias-set (Alias1) to the set
+ % LFUi + LBUi + HeadVars
+ (
+ % projecting is too expensive to be done for each goal,
+ % let's do it only on non-atomic goals:
+ goal_is_atomic(GoalExpr)
->
Alias = Alias1 % projection operation is not worthwhile
;
- pa_alias_as__project_set( AliveVars, Alias1, Alias)
+ pa_alias_as__project_on_live_vars(ProcInfo, GoalInfo,
+ Alias1, Alias)
).
-/**
- % XXX Lets' see what it all costs to remove local vars:
- (
- goal_is_atomic( GoalExpr )
- ->
- Alias = Alias1 % projection operation is not worthwhile
- ;
- goal_info_get_outscope( GoalInfo, Outscope),
- pa_alias_as__project_set( Outscope, Alias1, Alias)
- ).
-**/
-
-:- pred analyse_goal_expr( hlds_goal_expr,
+:- pred analyse_goal_expr(hlds_goal_expr,
hlds_goal_info,
proc_info, module_info,
pa_fixpoint_table, pa_fixpoint_table,
alias_as, alias_as).
-:- mode analyse_goal_expr( in, in, in, in, in, out, in, out) is det.
+:- mode analyse_goal_expr(in, in, in, in, in, out, in, out) is det.
-analyse_goal_expr( conj(Goals), _Info, ProcInfo, HLDS , T0, T, A0, A) :-
- list__foldl2( analyse_goal(ProcInfo, HLDS), Goals,
+analyse_goal_expr(conj(Goals), _Info, ProcInfo, HLDS , T0, T, A0, A) :-
+ list__foldl2(analyse_goal(ProcInfo, HLDS), Goals,
T0, T, A0, A).
-analyse_goal_expr( call(PredID, ProcID, ARGS, _,_, _PName), _Info,
+analyse_goal_expr(call(PredID, ProcID, ARGS, _,_, _PName), _Info,
ProcInfo, HLDS, T0, T, A0, A):-
PRED_PROC_ID = proc(PredID, ProcID),
- lookup_call_alias( PRED_PROC_ID, HLDS, T0, T, CallAlias),
- proc_info_vartypes( ProcInfo, VarTypes),
+ lookup_call_alias(PRED_PROC_ID, HLDS, T0, T, CallAlias),
+ proc_info_vartypes(ProcInfo, VarTypes),
list__map(
- map__lookup( VarTypes ),
+ map__lookup(VarTypes),
ARGS,
ActualTypes),
- rename_call_alias( PRED_PROC_ID, HLDS, ARGS, ActualTypes,
+ rename_call_alias(PRED_PROC_ID, HLDS, ARGS, ActualTypes,
CallAlias, RenamedCallAlias),
- pa_alias_as__extend( ProcInfo, HLDS, RenamedCallAlias, A0, A ).
+ pa_alias_as__extend(ProcInfo, HLDS, RenamedCallAlias, A0, A).
-analyse_goal_expr( generic_call( GenCall,_,_,_), Info,
+analyse_goal_expr(generic_call(GenCall,_,_,_), Info,
_ProcInfo, _HLDS , T, T, A0, A):-
(
GenCall = higher_order(_, _, _),
@@ -369,61 +348,61 @@
pa_alias_as__top(A0, Msg, A).
% error("(pa) generic_call not handled") .
-analyse_goal_expr( switch(_Var,_CF,Cases,_SM), Info,
- ProcInfo, HLDS, T0, T, A0, A ):-
- list__map_foldl( analyse_case(ProcInfo, HLDS, A0),
+analyse_goal_expr(switch(_Var,_CF,Cases,_SM), Info,
+ ProcInfo, HLDS, T0, T, A0, A):-
+ list__map_foldl(analyse_case(ProcInfo, HLDS, A0),
Cases, SwitchAliases, T0, T),
pa_alias_as__least_upper_bound_list(ProcInfo,HLDS,Info,
- SwitchAliases, A ).
+ SwitchAliases, A).
-:- pred analyse_case( proc_info, module_info,
+:- pred analyse_case(proc_info, module_info,
alias_as, case, alias_as,
pa_fixpoint_table,
- pa_fixpoint_table ).
-:- mode analyse_case( in, in, in, in, out, in, out ) is det.
+ pa_fixpoint_table).
+:- mode analyse_case(in, in, in, in, out, in, out) is det.
-analyse_case( ProcInfo, HLDS, Alias0, CASE, Alias, T0, T ):-
- CASE = case( _, Goal),
- analyse_goal( ProcInfo, HLDS, Goal, T0, T, Alias0, Alias).
-
-analyse_goal_expr( unify(_,_,_,Unification,_), Info, ProcInfo, HLDS,
- T, T, A0, A ):-
- pa_alias_as__extend_unification( ProcInfo, HLDS, Unification,
+analyse_case(ProcInfo, HLDS, Alias0, CASE, Alias, T0, T):-
+ CASE = case(_, Goal),
+ analyse_goal(ProcInfo, HLDS, Goal, T0, T, Alias0, Alias).
+
+analyse_goal_expr(unify(_,_,_,Unification,_), Info, ProcInfo, HLDS,
+ T, T, A0, A):-
+ pa_alias_as__extend_unification(ProcInfo, HLDS, Unification,
Info, A0, A).
-analyse_goal_expr( disj(Goals, _SM), Info, ProcInfo, HLDS, T0, T, A0, A ):-
- list__map_foldl(
- pred( Goal::in, Alias::out, FPT0::in, FPT::out) is det :-
- ( analyse_goal( ProcInfo, HLDS, Goal,
+analyse_goal_expr(disj(Goals, _SM), Info, ProcInfo, HLDS, T0, T, A0, A):-
+ list__map_foldl(
+ pred(Goal::in, Alias::out, FPT0::in, FPT::out) is det :-
+ (analyse_goal(ProcInfo, HLDS, Goal,
FPT0, FPT, A0, Alias)),
Goals,
DisjAliases,
- T0, T ),
- pa_alias_as__least_upper_bound_list( ProcInfo, HLDS, Info,
- DisjAliases, A ).
+ T0, T),
+ pa_alias_as__least_upper_bound_list(ProcInfo, HLDS, Info,
+ DisjAliases, A).
-analyse_goal_expr( not(Goal), _Info, ProcInfo, HLDS , T0, T, A0, A ):-
- analyse_goal( ProcInfo, HLDS, Goal, T0, T, A0, A).
+analyse_goal_expr(not(Goal), _Info, ProcInfo, HLDS , T0, T, A0, A):-
+ analyse_goal(ProcInfo, HLDS, Goal, T0, T, A0, A).
-analyse_goal_expr( some(Vars,_,Goal), _Info, ProcInfo, HLDS , T0, T, A0, A):-
+analyse_goal_expr(some(Vars,_,Goal), _Info, ProcInfo, HLDS , T0, T, A0, A):-
(
Vars = []
->
% XXX
- analyse_goal( ProcInfo, HLDS, Goal, T0, T, A0, A)
+ analyse_goal(ProcInfo, HLDS, Goal, T0, T, A0, A)
;
require__error("(pa_run) analyse_goal_expr: some should have empty vars.")
).
% pa_alias_as__top("some not handled", A).
- % error( "(pa) some goal not handled") .
+ % error("(pa) some goal not handled") .
-analyse_goal_expr( if_then_else(_VARS, IF, THEN, ELSE, _SM), _Info,
+analyse_goal_expr(if_then_else(_VARS, IF, THEN, ELSE, _SM), _Info,
ProcInfo,
HLDS , T0, T, A0, A) :-
- analyse_goal( ProcInfo, HLDS, IF, T0, T1, A0, A1),
- analyse_goal( ProcInfo, HLDS, THEN, T1, T2, A1, A2),
- analyse_goal( ProcInfo, HLDS, ELSE, T2, T, A0, A3),
- pa_alias_as__least_upper_bound( ProcInfo, HLDS, A2, A3, A).
+ analyse_goal(ProcInfo, HLDS, IF, T0, T1, A0, A1),
+ analyse_goal(ProcInfo, HLDS, THEN, T1, T2, A1, A2),
+ analyse_goal(ProcInfo, HLDS, ELSE, T2, T, A0, A3),
+ pa_alias_as__least_upper_bound(ProcInfo, HLDS, A2, A3, A).
analyse_goal_expr(pragma_foreign_code(Attrs, PredId, ProcId,
Vars, MaybeModes, Types, _),
@@ -432,8 +411,8 @@
extend_foreign_code(HLDS, ProcInfo, Attrs, PredId, ProcId,
Vars, MaybeModes, Types, Info, Ain, A).
- % error( "(pa) pragma_c_code not handled") .
-analyse_goal_expr( par_conj( _Goals, _SM), Info, _, _ , T, T, A0, A) :-
+ % error("(pa) pragma_c_code not handled") .
+analyse_goal_expr(par_conj(_Goals, _SM), Info, _, _ , T, T, A0, A) :-
goal_info_get_context(Info, Context),
term__context_line(Context, ContextLine),
term__context_file(Context, ContextFile),
@@ -444,8 +423,8 @@
ContextLineS, ")"], Msg),
pa_alias_as__top(A0, Msg, A).
- % error( "(pa) par_conj not handled") .
-analyse_goal_expr( bi_implication( _G1, _G2),Info, _, _ , T, T, A0, A) :-
+ % error("(pa) par_conj not handled") .
+analyse_goal_expr(bi_implication(_G1, _G2),Info, _, _ , T, T, A0, A) :-
goal_info_get_context(Info, Context),
term__context_line(Context, ContextLine),
term__context_file(Context, ContextFile),
@@ -469,40 +448,40 @@
% 4 - react appropriately if the calls happen to be to
% * either compiler generated predicates
% * or predicates from builtin.m and private_builtin.m
-:- pred lookup_call_alias( pred_proc_id, module_info, pa_fixpoint_table,
- pa_fixpoint_table, alias_as ).
-:- mode lookup_call_alias( in, in, in, out, out) is det.
+:- pred lookup_call_alias(pred_proc_id, module_info, pa_fixpoint_table,
+ pa_fixpoint_table, alias_as).
+:- mode lookup_call_alias(in, in, in, out, out) is det.
-lookup_call_alias( PRED_PROC_ID, HLDS, FPtable0, FPtable, Alias) :-
+lookup_call_alias(PRED_PROC_ID, HLDS, FPtable0, FPtable, Alias) :-
(
% 1 - check in table
- pa_fixpoint_table_get_as( PRED_PROC_ID, Alias1,
+ pa_fixpoint_table_get_as(PRED_PROC_ID, Alias1,
FPtable0, FPtable1)
->
FPtable = FPtable1,
Alias = Alias1
;
% 2 - look up in module_info
- lookup_call_alias_in_module_info( HLDS, PRED_PROC_ID,
+ lookup_call_alias_in_module_info(HLDS, PRED_PROC_ID,
Alias),
FPtable = FPtable0
).
% exported predicate
-extend_with_call_alias( HLDS, ProcInfo,
- PRED_ID, PROC_ID, ARGS, ActualTypes, ALIASin, ALIASout ):-
+extend_with_call_alias(HLDS, ProcInfo,
+ PRED_ID, PROC_ID, ARGS, ActualTypes, ALIASin, ALIASout):-
PRED_PROC_ID = proc(PRED_ID, PROC_ID),
- lookup_call_alias_in_module_info( HLDS, PRED_PROC_ID, ALIAS_tmp),
- rename_call_alias( PRED_PROC_ID, HLDS, ARGS, ActualTypes,
+ lookup_call_alias_in_module_info(HLDS, PRED_PROC_ID, ALIAS_tmp),
+ rename_call_alias(PRED_PROC_ID, HLDS, ARGS, ActualTypes,
ALIAS_tmp, ALIAS_call),
- pa_alias_as__extend( ProcInfo, HLDS, ALIAS_call, ALIASin, ALIASout).
+ pa_alias_as__extend(ProcInfo, HLDS, ALIAS_call, ALIASin, ALIASout).
-:- pred lookup_call_alias_in_module_info( module_info, pred_proc_id,
+:- pred lookup_call_alias_in_module_info(module_info, pred_proc_id,
alias_as).
-:- mode lookup_call_alias_in_module_info( in, in, out) is det.
+:- mode lookup_call_alias_in_module_info(in, in, out) is det.
-lookup_call_alias_in_module_info( HLDS, PRED_PROC_ID, Alias) :-
- module_info_pred_proc_info( HLDS, PRED_PROC_ID, PredInfo,
+lookup_call_alias_in_module_info(HLDS, PRED_PROC_ID, Alias) :-
+ module_info_pred_proc_info(HLDS, PRED_PROC_ID, PredInfo,
ProcInfo),
(
% If the determinism of the called procedure is
@@ -519,7 +498,7 @@
init(Alias)
;
proc_info_possible_aliases(ProcInfo, MaybeAliases),
- MaybeAliases = yes( SomeAL)
+ MaybeAliases = yes(SomeAL)
->
Alias = SomeAL
;
@@ -536,7 +515,7 @@
(
special_pred_name_arity(_, Name, _, Arity),
pred_info_module(PredInfo, ModuleName),
- (
+ (
mercury_private_builtin_module(ModuleName)
;
mercury_public_builtin_module(ModuleName)
@@ -554,7 +533,7 @@
% even annotate their aliases manually then just considering
% them as non-alias by default.
pred_info_module(PredInfo, ModuleName),
- (
+ (
mercury_private_builtin_module(ModuleName)
;
mercury_public_builtin_module(ModuleName)
@@ -596,10 +575,10 @@
module_info).
:- mode update_alias_in_module_info(in, in, in, out) is det.
-update_alias_in_module_info( FPtable, PRED_PROC_ID, HLDSin, HLDSout) :-
+update_alias_in_module_info(FPtable, PRED_PROC_ID, HLDSin, HLDSout) :-
module_info_pred_proc_info(HLDSin, PRED_PROC_ID, PredInfo, ProcInfo),
- pa_fixpoint_table_get_final_as( PRED_PROC_ID, ALIAS_AS, FPtable),
- proc_info_set_possible_aliases( ProcInfo, ALIAS_AS, NewProcInfo),
+ pa_fixpoint_table_get_final_as(PRED_PROC_ID, ALIAS_AS, FPtable),
+ proc_info_set_possible_aliases(ProcInfo, ALIAS_AS, NewProcInfo),
module_info_set_pred_proc_info(HLDSin, PRED_PROC_ID, PredInfo,
NewProcInfo, HLDSout).
@@ -615,107 +594,107 @@
:- import_module pa_sr_util.
% inspiration taken from termination.m
-:- pred pa_run__make_pa_interface( module_info, io__state, io__state ).
-:- mode pa_run__make_pa_interface( in, di, uo ) is det.
+:- pred pa_run__make_pa_interface(module_info, io__state, io__state).
+:- mode pa_run__make_pa_interface(in, di, uo) is det.
-pa_run__make_pa_interface( HLDS ) -->
- { module_info_name( HLDS, ModuleName ) },
- modules__module_name_to_file_name( ModuleName, ".opt.pa", bool__no, KaFileName),
+pa_run__make_pa_interface(HLDS) -->
+ { module_info_name(HLDS, ModuleName) },
+ modules__module_name_to_file_name(ModuleName, ".opt.pa", bool__no, KaFileName),
globals__io_lookup_bool_option(verbose, Verbose),
maybe_write_string(Verbose, "% -> writing possible aliases to `"),
- maybe_write_string(Verbose, KaFileName ),
+ maybe_write_string(Verbose, KaFileName),
maybe_write_string(Verbose, "'..."),
maybe_flush_output(Verbose),
- io__open_output( KaFileName, KaFileRes ),
+ io__open_output(KaFileName, KaFileRes),
(
{ KaFileRes = ok(KaFile) },
- io__set_output_stream( KaFile, OldStream ),
- pa_run__make_pa_interface_2( HLDS ),
- io__set_output_stream( OldStream, _ ),
- io__close_output( KaFile ),
+ io__set_output_stream(KaFile, OldStream),
+ pa_run__make_pa_interface_2(HLDS),
+ io__set_output_stream(OldStream, _),
+ io__close_output(KaFile),
maybe_write_string(Verbose, " done.\n"),
maybe_flush_output(Verbose)
;
- { KaFileRes = error( IOError ) },
+ { KaFileRes = error(IOError) },
maybe_write_string(Verbose, " failed!\n"),
maybe_flush_output(Verbose),
- { io__error_message( IOError, IOErrorMsg ) },
+ { io__error_message(IOError, IOErrorMsg) },
io__write_strings(["Error opening file `",
KaFileName, "' for output: ", IOErrorMsg]),
io__set_exit_status(1)
- ).
+ ).
-:- pred pa_run__make_pa_interface_2( module_info,
+:- pred pa_run__make_pa_interface_2(module_info,
io__state, io__state).
-:- mode pa_run__make_pa_interface_2( in, di, uo) is det.
+:- mode pa_run__make_pa_interface_2(in, di, uo) is det.
-pa_run__make_pa_interface_2( HLDS ) -->
- { module_info_name( HLDS, ModuleName ) },
- { module_info_predids( HLDS, PredIds ) },
- { module_info_get_special_pred_map( HLDS, MAP ) },
- { map__values( MAP, SpecPredIds ) },
+pa_run__make_pa_interface_2(HLDS) -->
+ { module_info_name(HLDS, ModuleName) },
+ { module_info_predids(HLDS, PredIds) },
+ { module_info_get_special_pred_map(HLDS, MAP) },
+ { map__values(MAP, SpecPredIds) },
io__write_string(":- module "),
- mercury_output_sym_name( ModuleName ),
+ mercury_output_sym_name(ModuleName),
io__write_string(".\n\n"),
io__write_string(":- interface. \n"),
- list__foldl( make_pa_interface_pred(HLDS, SpecPredIds), PredIds ).
+ list__foldl(make_pa_interface_pred(HLDS, SpecPredIds), PredIds).
-pa_run__write_pred_pa_info( HLDS, SpecPredIds, PredId) -->
- pa_run__make_pa_interface_pred( HLDS, SpecPredIds, PredId).
+pa_run__write_pred_pa_info(HLDS, SpecPredIds, PredId) -->
+ pa_run__make_pa_interface_pred(HLDS, SpecPredIds, PredId).
:- pred pa_run__make_pa_interface_pred(module_info, list(pred_id),pred_id,
io__state, io__state).
-:- mode pa_run__make_pa_interface_pred( in, in, in, di ,uo) is det.
+:- mode pa_run__make_pa_interface_pred(in, in, in, di ,uo) is det.
-pa_run__make_pa_interface_pred( HLDS, SpecPredIds, PredId ) -->
- { module_info_pred_info( HLDS, PredId, PredInfo ) },
+pa_run__make_pa_interface_pred(HLDS, SpecPredIds, PredId) -->
+ { module_info_pred_info(HLDS, PredId, PredInfo) },
(
- { pred_info_is_exported( PredInfo ) ;
- pred_info_is_opt_exported( PredInfo ) }
+ { pred_info_is_exported(PredInfo) ;
+ pred_info_is_opt_exported(PredInfo) }
->
- (
- { list__member( PredId, SpecPredIds ) }
+ (
+ { list__member(PredId, SpecPredIds) }
->
[]
;
{ pred_info_procids(PredInfo, ProcIds) },
- { pred_info_procedures( PredInfo, ProcTable ) },
- list__foldl( make_pa_interface_pred_proc( PredInfo, ProcTable),
- ProcIds )
+ { pred_info_procedures(PredInfo, ProcTable) },
+ list__foldl(make_pa_interface_pred_proc(PredInfo, ProcTable),
+ ProcIds)
)
;
[]
).
-:- pred pa_run__make_pa_interface_pred_proc( pred_info, proc_table, proc_id,
+:- pred pa_run__make_pa_interface_pred_proc(pred_info, proc_table, proc_id,
io__state, io__state).
-:- mode pa_run__make_pa_interface_pred_proc( in, in, in, di, uo) is det.
+:- mode pa_run__make_pa_interface_pred_proc(in, in, in, di, uo) is det.
-pa_run__make_pa_interface_pred_proc( PredInfo, ProcTable, ProcId) -->
+pa_run__make_pa_interface_pred_proc(PredInfo, ProcTable, ProcId) -->
io__write_string(":- pragma pa_alias_info("),
% write a simple predicate declaration
- { varset__init( InitVarSet ) },
- { pred_info_name( PredInfo, PredName ) },
- { pred_info_get_is_pred_or_func( PredInfo, PredOrFunc ) },
- { pred_info_module( PredInfo, ModuleName ) },
- { pred_info_context( PredInfo, Context ) },
- { SymName = qualified( ModuleName, PredName ) },
+ { varset__init(InitVarSet) },
+ { pred_info_name(PredInfo, PredName) },
+ { pred_info_get_is_pred_or_func(PredInfo, PredOrFunc) },
+ { pred_info_module(PredInfo, ModuleName) },
+ { pred_info_context(PredInfo, Context) },
+ { SymName = qualified(ModuleName, PredName) },
- { map__lookup( ProcTable, ProcId, ProcInfo ) },
- { proc_info_declared_argmodes( ProcInfo, Modes ) },
+ { map__lookup(ProcTable, ProcId, ProcInfo) },
+ { proc_info_declared_argmodes(ProcInfo, Modes) },
(
{ PredOrFunc = predicate },
- mercury_output_pred_mode_subdecl( InitVarSet, SymName, Modes,
- std_util__no, Context )
+ mercury_output_pred_mode_subdecl(InitVarSet, SymName, Modes,
+ std_util__no, Context)
;
{ PredOrFunc = function },
- { pred_args_to_func_args( Modes, FuncModes, RetMode ) },
- mercury_output_func_mode_subdecl( InitVarSet, SymName,
- FuncModes, RetMode, std_util__no, Context )
+ { pred_args_to_func_args(Modes, FuncModes, RetMode) },
+ mercury_output_func_mode_subdecl(InitVarSet, SymName,
+ FuncModes, RetMode, std_util__no, Context)
),
io__write_string(", "),
@@ -723,14 +702,14 @@
% write headvars vars(HeadVar__1, ... HeadVar__n)
{ proc_info_varset(ProcInfo, ProgVarset) },
{ proc_info_real_headvars(ProcInfo, RealHeadVars) },
- { proc_info_vartypes( ProcInfo, VarTypes) },
- { pred_info_typevarset( PredInfo, TypeVarSet ) },
+ { proc_info_vartypes(ProcInfo, VarTypes) },
+ { pred_info_typevarset(PredInfo, TypeVarSet) },
pa_sr_util__trans_opt_output_vars_and_types(
ProgVarset,
VarTypes,
TypeVarSet,
- RealHeadVars ),
+ RealHeadVars),
io__write_string(", "),
@@ -738,26 +717,8 @@
{ proc_info_possible_aliases(ProcInfo, MaybeAliases) },
- pa_alias_as__print_maybe_interface_aliases( MaybeAliases,
+ pa_alias_as__print_maybe_interface_aliases(MaybeAliases,
ProcInfo, PredInfo),
io__write_string(").\n").
-
- % list_drop_det(Len,List,End):
- % deterministic version of list__drop.
- % If `List' has less than `Len' elements, return the
- % entire list.
-
-:- pred list_drop_det(int,list(T),list(T)).
-:- mode list_drop_det(in,in,out) is det.
-
-list_drop_det(Len,List,End):-
- (
- list__drop(Len,List,End0)
- ->
- End = End0
- ;
- End = List
- ).
-
Index: pa_selector.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_selector.m,v
retrieving revision 1.1.2.6
diff -u -r1.1.2.6 pa_selector.m
--- pa_selector.m 2001/03/22 19:55:35 1.1.2.6
+++ pa_selector.m 2001/03/23 10:22:54
@@ -34,8 +34,8 @@
:- type selector == list(unit_sel).
:- type unit_sel --->
- us( hlds_data__cons_id, int ) ; % normal selector
- ts( prog_data__type ). % type selector
+ us(hlds_data__cons_id, int) ; % normal selector
+ ts(prog_data__type). % type selector
%-------------------------------------------------------------------%
@@ -69,29 +69,29 @@
:- pred termshift(selector, selector, selector).
:- mode termshift(in, in, out) is det.
- % less_or_equal( HLDS, S1, S2, T, EXT):
+ % less_or_equal(HLDS, S1, S2, T, EXT):
% Find out whether selector S1 of a variable of type T is
% less or equal to another selector S2 belonging to the same
% variable of type T. If so, return the extension such that
% S1 == S2.EXT
-:- pred less_or_equal( module_info::in, selector::in, selector::in,
+:- pred less_or_equal(module_info::in, selector::in, selector::in,
(type)::in, selector::out) is semidet.
-:- pred rename_types( term__substitution(tvar_type)::in,
+:- pred rename_types(term__substitution(tvar_type)::in,
selector::in, selector::out) is det.
-:- pred print( selector::in, tvarset::in,
+:- pred print(selector::in, tvarset::in,
io__state::di, io__state::uo) is det.
-:- pred parse_term( term(T), selector).
-:- mode parse_term( in, out ) is det.
+:- pred parse_term(term(T), selector).
+:- mode parse_term(in, out) is det.
% normalize with type information
-:- pred normalize_wti( (type), module_info, selector, selector).
-:- mode normalize_wti( in, in, in, out) is det.
+:- pred normalize_wti((type), module_info, selector, selector).
+:- mode normalize_wti(in, in, in, out) is det.
% widening
-:- pred apply_widening( module_info::in, (type)::in,
+:- pred apply_widening(module_info::in, (type)::in,
selector::in, selector::out) is det.
%-------------------------------------------------------------------%
@@ -121,7 +121,7 @@
top([]).
-select_first_part( SEL0, US, SEL ):-
+select_first_part(SEL0, US, SEL):-
(
SEL0 = [ F | R ]
->
@@ -130,7 +130,7 @@
error("(pa_selector): trying to split empty selector!")
).
-unit_termshift( S0, US, S ):-
+unit_termshift(S0, US, S):-
termshift(S0,[US],S).
termshift(S1,S2,S):- list__append(S1,S2,S).
@@ -142,59 +142,59 @@
:- pred less_or_equal(selector, selector, selector).
:- mode less_or_equal(in, in, out) is semidet.
-less_or_equal( S1, S2, EXT ) :-
+less_or_equal(S1, S2, EXT) :-
list__append(S2, EXT , S1).
-rename_types( Subst, Sel0, Sel ):-
- list__map( unit_selector_rename_types( Subst ), Sel0, Sel ).
+rename_types(Subst, Sel0, Sel):-
+ list__map(unit_selector_rename_types(Subst), Sel0, Sel).
-:- pred unit_selector_rename_types( term__substitution(tvar_type)::in,
- unit_sel::in, unit_sel::out ) is det.
+:- pred unit_selector_rename_types(term__substitution(tvar_type)::in,
+ unit_sel::in, unit_sel::out) is det.
-unit_selector_rename_types( Subst, US0, US ) :-
+unit_selector_rename_types(Subst, US0, US) :-
(
US0 = us(_,_),
US = US0
;
- US0 = ts( Type0 ),
- term__apply_substitution( Type0, Subst, Type ),
- US = ts( Type )
+ US0 = ts(Type0),
+ term__apply_substitution(Type0, Subst, Type),
+ US = ts(Type)
).
-print( Selector, ProgVarSet ) -->
+print(Selector, ProgVarSet) -->
io__write_string("["),
- io__write_list(Selector, ",", print_unit_selector(ProgVarSet) ),
+ io__write_list(Selector, ",", print_unit_selector(ProgVarSet)),
io__write_string("]").
-:- pred print_unit_selector( tvarset, unit_sel, io__state, io__state).
-:- mode print_unit_selector( in, in, di, uo) is det.
+:- pred print_unit_selector(tvarset, unit_sel, io__state, io__state).
+:- mode print_unit_selector(in, in, di, uo) is det.
-print_unit_selector( _ProgVarSet, us( Cons, Index ) ) -->
- { hlds_data__cons_id_arity( Cons, Arity ) },
- io__write_string( "sel("),
+print_unit_selector(_ProgVarSet, us(Cons, Index)) -->
+ { hlds_data__cons_id_arity(Cons, Arity) },
+ io__write_string("sel("),
mercury_output_cons_id(Cons, needs_brackets),
- io__write_string( "," ),
- io__write_int( Arity ),
io__write_string(","),
+ io__write_int(Arity),
+ io__write_string(","),
io__write_int(Index),
+ io__write_string(")").
+print_unit_selector(ProgVarSet, ts(Type)) -->
+ io__write_string("typesel("),
+ mercury_output_term(Type, ProgVarSet, bool__no),
io__write_string(")").
-print_unit_selector( ProgVarSet, ts( Type )) -->
- io__write_string( "typesel("),
- mercury_output_term( Type, ProgVarSet, bool__no),
- io__write_string( ")").
-parse_term( TERM, SEL ):-
+parse_term(TERM, SEL):-
(
- TERM = term__functor( term__atom(CONS), Args, _)
+ TERM = term__functor(term__atom(CONS), Args, _)
->
(
CONS = ".",
Args = [ First , Rest ]
->
- parse_unit_selector( First, US),
- parse_term( Rest, SELrest ),
+ parse_unit_selector(First, US),
+ parse_term(Rest, SELrest),
SEL = [ US | SELrest ]
;
SEL = []
@@ -203,40 +203,40 @@
error("(pa_selector) parse_term: term not a functor")
).
-:- pred parse_unit_selector( term(T), unit_sel).
-:- mode parse_unit_selector( in, out) is det.
+:- pred parse_unit_selector(term(T), unit_sel).
+:- mode parse_unit_selector(in, out) is det.
-parse_unit_selector( TERM, US ):-
+parse_unit_selector(TERM, US):-
(
- TERM = term__functor( term__atom(CONS), Args, _)
+ TERM = term__functor(term__atom(CONS), Args, _)
->
(
CONS = "sel",
Args = [ CONS_TERM, ARITY_TERM, POS_TERM ]
->
- (
- prog_io__sym_name_and_args( CONS_TERM, ConsID_SN, ConsID_ARGS ),
+ (
+ prog_io__sym_name_and_args(CONS_TERM, ConsID_SN, ConsID_ARGS),
ConsID_ARGS = [],
- ARITY_TERM = term__functor( term__integer( Arity ), _, _),
- POS_TERM = term__functor( term__integer( Pos ), _, _ )
+ ARITY_TERM = term__functor(term__integer(Arity), _, _),
+ POS_TERM = term__functor(term__integer(Pos), _, _)
->
- ConsID = cons( ConsID_SN, Arity ),
- US = us( ConsID, Pos )
+ ConsID = cons(ConsID_SN, Arity),
+ US = us(ConsID, Pos)
;
- CONS_TERM = term__functor( term__integer( X ), _, _)
+ CONS_TERM = term__functor(term__integer(X), _, _)
->
- ConsID = int_const( X ),
- US = us( ConsID, 0 )
+ ConsID = int_const(X),
+ US = us(ConsID, 0)
;
- CONS_TERM = term__functor( term__float( X ), _, _)
+ CONS_TERM = term__functor(term__float(X), _, _)
->
- ConsID = float_const( X ),
- US = us( ConsID, 0)
+ ConsID = float_const(X),
+ US = us(ConsID, 0)
;
- CONS_TERM = term__functor( term__string( S ), _, _)
+ CONS_TERM = term__functor(term__string(S), _, _)
->
- ConsID = string_const( S ),
- US = us( ConsID, 0 )
+ ConsID = string_const(S),
+ US = us(ConsID, 0)
;
error("(pa_selector) parse_unit_selector: unknown cons_id in unit selector")
)
@@ -245,8 +245,8 @@
CONS = "typesel",
Args = [ TypeSelectorTerm ]
->
- term__coerce( TypeSelectorTerm, TypeSelector ),
- US = ts( TypeSelector )
+ term__coerce(TypeSelectorTerm, TypeSelector),
+ US = ts(TypeSelector)
;
error("(pa_selector) parse_unit_selector: top constructor should be sel/3 or typesel/1.")
)
@@ -255,27 +255,27 @@
).
-normalize_wti( VarType, HLDS, SEL0, SEL ):-
+normalize_wti(VarType, HLDS, SEL0, SEL):-
(
type_util__is_introduced_type_info_type(VarType)
->
SEL = SEL0
;
- branch_map_init( B0 ),
- init( TOP ),
- branch_map_insert( VarType, TOP, B0, B1 ),
- normalize_wti_2( VarType, HLDS, B1, TOP, SEL0, SEL)
+ branch_map_init(B0),
+ init(TOP),
+ branch_map_insert(VarType, TOP, B0, B1),
+ normalize_wti_2(VarType, HLDS, B1, TOP, SEL0, SEL)
).
-:- pred normalize_wti_2( type, module_info, branch_map,
+:- pred normalize_wti_2(type, module_info, branch_map,
selector, selector, selector).
-:- mode normalize_wti_2( in, in, in, in, in, out) is det.
+:- mode normalize_wti_2(in, in, in, in, in, out) is det.
-normalize_wti_2( VarType, HLDS, B0, Acc0, SEL0, SEL ):-
+normalize_wti_2(VarType, HLDS, B0, Acc0, SEL0, SEL):-
(
SEL0 = [ US | SELR ]
->
- type_util__classify_type( VarType, HLDS, Class ),
+ type_util__classify_type(VarType, HLDS, Class),
(
Class = user_type
->
@@ -285,9 +285,9 @@
(
US = us(CONS, INDEX),
type_util__get_cons_id_non_existential_arg_types(HLDS,
- VarType, CONS, ArgTypes ),
+ VarType, CONS, ArgTypes),
(
- list__index1(ArgTypes, INDEX, SubType )
+ list__index1(ArgTypes, INDEX, SubType)
->
CType = SubType
;
@@ -295,32 +295,32 @@
VarType, CONS, INDEX))
)
;
- US = ts( CType )
+ US = ts(CType)
)
->
- (
- branch_map_search( B0, CType,
- BSel )
+ (
+ branch_map_search(B0, CType,
+ BSel)
->
- normalize_wti_2( CType, HLDS,
- B0, BSel, SELR, SEL )
+ normalize_wti_2(CType, HLDS,
+ B0, BSel, SELR, SEL)
;
- unit_termshift( Acc0, US,
- Acc1 ),
- branch_map_insert( CType,
- Acc1, B0, B1 ),
- normalize_wti_2( CType, HLDS,
- B1, Acc1, SELR, SEL )
+ unit_termshift(Acc0, US,
+ Acc1),
+ branch_map_insert(CType,
+ Acc1, B0, B1),
+ normalize_wti_2(CType, HLDS,
+ B1, Acc1, SELR, SEL)
)
;
% existentially typed functor.
- append( Acc0, SEL0, SEL)
+ append(Acc0, SEL0, SEL)
)
;
% if it's not a user type, SELR will be empty
% anyhow, and normalization stops.
% Resulting selector = accumulator.sel0
- % selector_add_us( Acc0, US, SEL)
+ % selector_add_us(Acc0, US, SEL)
append(Acc0,SEL0,SEL)
)
@@ -329,8 +329,8 @@
SEL = Acc0
).
-:- func index_error_message( module_info, (type), cons_id, int ) = string.
-index_error_message( HLDS, VarType, CONS, INDEX ) = Msg :-
+:- func index_error_message(module_info, (type), cons_id, int) = string.
+index_error_message(HLDS, VarType, CONS, INDEX) = Msg :-
get_type_defn(HLDS,VarType,TypeDefn),
get_type_id(VarType,TypeID),
hlds_data__get_type_defn_status(TypeDefn, TypeImportStatus),
@@ -356,7 +356,7 @@
:- pred get_type_id((type),type_id).
:- mode get_type_id(in,out) is det.
-get_type_id( Type, TypeID ):-
+get_type_id(Type, TypeID):-
(
type_util__type_to_type_id(Type, TypeID0, _)
->
@@ -416,7 +416,7 @@
% The two types are considered equal if they
% unify
% under an empty substitution
- (
+ (
type_unify(T1, T2, [], Empty, Subst),
map__is_empty(Subst)
->
@@ -431,20 +431,20 @@
% additional predicates
%-------------------------------------------------------------------%
- % split_upto_type_selector( Sin, S1, TS, S2 ):
+ % split_upto_type_selector(Sin, S1, TS, S2):
% this predicate succeeds if there exists a typeselector
- % TS, such that Sin is equivalent to append(S1, [TS | S2] )
+ % TS, such that Sin is equivalent to append(S1, [TS | S2])
% and S1 contains no other type selector. It fails otherwise.
:- pred split_upto_type_selector(selector::in, selector::out,
unit_sel::out,
selector::out) is semidet.
-split_upto_type_selector( Sin, S1, TS, S2 ):-
- split_upto_type_selector_acc( Sin, [], S1, TS, S2).
+split_upto_type_selector(Sin, S1, TS, S2):-
+ split_upto_type_selector_acc(Sin, [], S1, TS, S2).
-:- pred split_upto_type_selector_acc( selector::in, selector::in,
+:- pred split_upto_type_selector_acc(selector::in, selector::in,
selector::out, unit_sel::out, selector::out) is semidet.
-split_upto_type_selector_acc( [ US | SEL ], ACC, S1, TS, S2 ):-
+split_upto_type_selector_acc([ US | SEL ], ACC, S1, TS, S2):-
(
US = ts(_)
->
@@ -453,18 +453,18 @@
S2 = SEL
;
append(ACC, [US], ACC2),
- split_upto_type_selector_acc( SEL, ACC2, S1, TS, S2 )
+ split_upto_type_selector_acc(SEL, ACC2, S1, TS, S2)
).
-less_or_equal( HLDS, S1, S2, MainType, EXT ):-
+less_or_equal(HLDS, S1, S2, MainType, EXT):-
(
- split_upto_type_selector(S2, S2_part1, TS, S2_part2 ),
- TS = ts( SubType )
+ split_upto_type_selector(S2, S2_part1, TS, S2_part2),
+ TS = ts(SubType)
->
(
- less_or_equal( HLDS, S1, S2_part1, MainType, Rest)
+ less_or_equal(HLDS, S1, S2_part1, MainType, Rest)
% append(S2_part1, Rest, S1) % walk past S2_part1
% S1 = S2_part1.Rest
->
@@ -472,10 +472,10 @@
% can be formulated as: starting from S2_part1,
% does the remainder of the path Rest lead through
- get_type_of_node( HLDS, MainType, S2_part1, NodeType),
+ get_type_of_node(HLDS, MainType, S2_part1, NodeType),
% from NodeType, to TS
- type_on_path( HLDS, NodeType, SubType, Rest, Remainder),
- less_or_equal( HLDS, Remainder, S2_part2, SubType, EXT)
+ type_on_path(HLDS, NodeType, SubType, Rest, Remainder),
+ less_or_equal(HLDS, Remainder, S2_part2, SubType, EXT)
;
fail % the walks do not correspond
)
@@ -486,49 +486,49 @@
% correspond exactly to the first steps of S1,
% so just: S1 = S2.ext, or rather:
% less_or_equal(S2, S1, Extension) (the simple case)
- less_or_equal(S1, S2, EXT )
+ less_or_equal(S1, S2, EXT)
).
-apply_widening( ModuleInfo, MainType, Selector0, Selector ) :-
+apply_widening(ModuleInfo, MainType, Selector0, Selector) :-
(
Selector0 = []
->
Selector = Selector0
;
- get_type_of_node( ModuleInfo, MainType, Selector0, SubType),
- Selector = [ ts( SubType ) ]
+ get_type_of_node(ModuleInfo, MainType, Selector0, SubType),
+ Selector = [ ts(SubType) ]
).
- % get_type_of_node( ModuleInfo, StartType, Selector, SubType)
+ % get_type_of_node(ModuleInfo, StartType, Selector, SubType)
% determines the type SybType of the node obtained by traversing
% the StartType using the path Selector.
-:- pred get_type_of_node( module_info::in, (type)::in, selector::in,
+:- pred get_type_of_node(module_info::in, (type)::in, selector::in,
(type)::out) is det.
-get_type_of_node( ModuleInfo, StartType, Selector, SubType ):-
+get_type_of_node(ModuleInfo, StartType, Selector, SubType):-
(
Selector = [ US | RestSelector ]
->
(
- US = us( CONS_ID, CHOICE ),
- select_subtype( ModuleInfo, StartType, CONS_ID,
- CHOICE, SubType0 )
+ US = us(CONS_ID, CHOICE),
+ select_subtype(ModuleInfo, StartType, CONS_ID,
+ CHOICE, SubType0)
;
- US = ts( SubType0 )
+ US = ts(SubType0)
),
- get_type_of_node( ModuleInfo, SubType0,
- RestSelector, SubType )
+ get_type_of_node(ModuleInfo, SubType0,
+ RestSelector, SubType)
;
SubType = StartType
).
- % select_subtype( ModuleInfo, Type, ConsID, Position, SubType):
+ % select_subtype(ModuleInfo, Type, ConsID, Position, SubType):
% select the subtype of a type Type, selecting ConsId's position
% Position. Position counts starting from 1 (and not 0).
% Predicate aborts if subtype cannot be determined.
-:- pred select_subtype( module_info::in, (type)::in,
+:- pred select_subtype(module_info::in, (type)::in,
cons_id::in, int::in, (type)::out) is det.
-select_subtype( ModuleInfo, Type, ConsID, Choice, SubType) :-
+select_subtype(ModuleInfo, Type, ConsID, Choice, SubType) :-
(
type_util__get_cons_id_non_existential_arg_types(ModuleInfo,
Type, ConsID, ArgTypes)
@@ -553,22 +553,22 @@
% XXX this predicate should be nondet as Path might lead through
% different nodes of type ToType, each yielding a different
% Remainder.
-:- pred type_on_path( module_info::in, (type)::in, (type)::in,
+:- pred type_on_path(module_info::in, (type)::in, (type)::in,
selector::in, selector::out) is semidet.
-type_on_path( ModuleInfo, FromType, ToType, Path, RemainderPath) :-
+type_on_path(ModuleInfo, FromType, ToType, Path, RemainderPath) :-
% require at least one step!
% notation of any non-zero selector which selects a node of
% the type described in the type-selector.
- type_on_path_2( first, ModuleInfo, FromType,
+ type_on_path_2(first, ModuleInfo, FromType,
ToType, Path, RemainderPath).
:- type step ---> first ; subsequent.
-:- pred type_on_path_2( step::in, module_info::in, (type)::in, (type)::in,
+:- pred type_on_path_2(step::in, module_info::in, (type)::in, (type)::in,
selector::in, selector::out) is semidet.
-type_on_path_2( Step, ModuleInfo, FromType, ToType, Path, RemainderPath) :-
+type_on_path_2(Step, ModuleInfo, FromType, ToType, Path, RemainderPath) :-
(
FromType = ToType,
Step = subsequent
@@ -577,26 +577,26 @@
;
Path = [ US | Rest ],
(
- US = ts( SubType ),
+ US = ts(SubType),
(
SubType = ToType
->
RemainderPath = Rest
;
- type_on_path_2( subsequent, ModuleInfo,
+ type_on_path_2(subsequent, ModuleInfo,
SubType, ToType,
Rest, RemainderPath)
)
;
- US = us( CONS_ID, CHOICE ),
- select_subtype( ModuleInfo, FromType, CONS_ID,
- CHOICE, SubType ),
+ US = us(CONS_ID, CHOICE),
+ select_subtype(ModuleInfo, FromType, CONS_ID,
+ CHOICE, SubType),
(
SubType = ToType
->
RemainderPath = Rest
;
- type_on_path_2( subsequent,
+ type_on_path_2(subsequent,
ModuleInfo, SubType, ToType,
Rest, RemainderPath)
)
Index: pa_sr_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_sr_util.m,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 pa_sr_util.m
--- pa_sr_util.m 2001/03/16 17:15:47 1.1.2.3
+++ pa_sr_util.m 2001/03/23 10:22:54
@@ -17,7 +17,7 @@
:- import_module hlds_pred, prog_data.
:- import_module hlds_module.
-:- pred trans_opt_output_vars_and_types(
+:- pred trans_opt_output_vars_and_types(
prog_varset::in,
vartypes::in,
tvarset::in,
@@ -25,9 +25,9 @@
io__state::di,
io__state::uo) is det.
-:- pred rename_type_det( pair( (type), (type) )::in,
+:- pred rename_type_det(pair((type), (type))::in,
term__substitution(tvar_type)::in,
- term__substitution(tvar_type)::out ) is det.
+ term__substitution(tvar_type)::out) is det.
:- pred some_are_special_preds(list(pred_proc_id)::in,
module_info::in) is semidet.
@@ -39,9 +39,9 @@
:- import_module mercury_to_mercury.
-trans_opt_output_vars_and_types( ProgVarSet, VarTypes, TypeVarSet,
- RealHeadVars ) -->
- (
+trans_opt_output_vars_and_types(ProgVarSet, VarTypes, TypeVarSet,
+ RealHeadVars) -->
+ (
{ RealHeadVars = [] }
->
io__write_string("vars, types")
@@ -54,83 +54,27 @@
% extra info:
io__write_string("types("),
io__write_list(RealHeadVars, ",",
- output_type_of_var(VarTypes, TypeVarSet) ),
+ output_type_of_var(VarTypes, TypeVarSet)),
io__write_string(")")
).
-:- pred output_type_of_var( vartypes::in, tvarset::in, prog_var::in,
+:- pred output_type_of_var(vartypes::in, tvarset::in, prog_var::in,
io__state::di, io__state::uo) is det.
-output_type_of_var( VarTypes, TypeVarSet, SomeVar ) -->
- { map__lookup( VarTypes, SomeVar, Type ) },
+output_type_of_var(VarTypes, TypeVarSet, SomeVar) -->
+ { map__lookup(VarTypes, SomeVar, Type) },
mercury_output_term(Type, TypeVarSet, bool__no).
-rename_type_det( FromType - ToType, S0, S ) :-
+rename_type_det(FromType - ToType, S0, S) :-
(
- term__unify( FromType, ToType, S0, S1 )
+ term__unify(FromType, ToType, S0, S1)
->
S = S1
;
S = S0
-/**
- term_to_tmp_string( FromType, FromTypeString),
- term_to_tmp_string( ToType, ToTypeString),
- string__append_list( [
- "(pa_sr_util) rename_type_det: types are not unifiable. \n",
- "\tFromType = ", FromTypeString, "\n",
- "\tToType = ", ToTypeString ], Msg ),
- require__error(Msg)
-**/
- ).
-
-:- import_module string.
-:- pred term_to_tmp_string( term(T)::in, string::out) is det.
-
-term_to_tmp_string( functor( Const, Args, _Cxt ), String ):-
- const_to_tmp_string( Const, S0 ),
- list__map( term_to_tmp_string, Args, ArgStrings),
- (
- ArgStrings = []
- ->
- Arguments = ""
- ;
- to_comma_separated_list( ArgStrings, Args0),
- string__append_list( ["(", Args0, ")" ], Arguments)
- ),
- string__append_list( [ S0, Arguments ], String).
-term_to_tmp_string( variable( _ ), "var").
-
-:- pred context_to_tmp_string( term__context::in, string::out) is det.
-context_to_tmp_string( context( File, LineNumber ), String ):-
- string__int_to_string( LineNumber, Line),
- string__append_list( [ File, ":", Line ], String).
-
-:- pred to_comma_separated_list( list(string)::in, string::out) is det.
-to_comma_separated_list( [], "").
-to_comma_separated_list( [ First | Rest ], String ):-
- (
- Rest = []
- ->
- String = First
- ;
- to_comma_separated_list( Rest, StringRest),
- string__append_list( [First, ",", StringRest ], String)
- ).
+ ).
-:- pred const_to_tmp_string( const::in, string::out) is det.
-const_to_tmp_string( Const, String ):-
- (
- Const = atom(String)
- ;
- Const = integer(Int),
- string__int_to_string(Int,String)
- ;
- Const = string(String)
- ;
- Const = float(Float),
- string__float_to_string(Float, String)
- ).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
Index: pa_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/pa_util.m,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 pa_util.m
--- pa_util.m 2001/02/28 13:00:41 1.1.2.5
+++ pa_util.m 2001/03/23 10:22:54
@@ -25,37 +25,37 @@
% the datastructure keeps track of the number of fixpoint runs
% performed, this predicates adds one.
-:- pred pa_fixpoint_table_new_run( pa_fixpoint_table::in, pa_fixpoint_table::out) is det.
+:- pred pa_fixpoint_table_new_run(pa_fixpoint_table::in, pa_fixpoint_table::out) is det.
-:- pred pa_fixpoint_table_which_run( pa_fixpoint_table::in, int::out) is det.
+:- pred pa_fixpoint_table_which_run(pa_fixpoint_table::in, int::out) is det.
% check whether all entries are stable. If so, one has reached
% a fixpoint
-:- pred pa_fixpoint_table_all_stable( pa_fixpoint_table:: in ) is semidet.
+:- pred pa_fixpoint_table_all_stable(pa_fixpoint_table:: in) is semidet.
% at the end of the analysis of one single pred_proc_id,
% the new exit alias information is stored. This might
% change the stability of the table.
% if the pred_proc_id is not in the table --> error
-:- pred pa_fixpoint_table_new_as( module_info, proc_info,
+:- pred pa_fixpoint_table_new_as(module_info, proc_info,
pred_proc_id, alias_as,
pa_fixpoint_table, pa_fixpoint_table).
-:- mode pa_fixpoint_table_new_as( in, in, in, in, in, out) is det.
+:- mode pa_fixpoint_table_new_as(in, in, in, in, in, out) is det.
% retreive the alias abstract substitution of a given
% pred_proc_id. If this information is not available,
% the general character of the fixpoint-table will be
% set to `recursive'
% if the pred_proc_id is not in the table --> fail
-:- pred pa_fixpoint_table_get_as( pred_proc_id, alias_as,
+:- pred pa_fixpoint_table_get_as(pred_proc_id, alias_as,
pa_fixpoint_table, pa_fixpoint_table).
-:- mode pa_fixpoint_table_get_as( in, out, in, out) is semidet.
+:- mode pa_fixpoint_table_get_as(in, out, in, out) is semidet.
% retreive alias_as information, without changing the
% table. To be used after fixpoint has been reached.
-:- pred pa_fixpoint_table_get_final_as( pred_proc_id, alias_as,
+:- pred pa_fixpoint_table_get_final_as(pred_proc_id, alias_as,
pa_fixpoint_table).
-:- mode pa_fixpoint_table_get_final_as( in, out, in) is det.
+:- mode pa_fixpoint_table_get_final_as(in, out, in) is det.
%-----------------------------------------------------------------------------%
@@ -63,43 +63,43 @@
:- implementation.
:- type pa_fixpoint_table ==
- fixpoint_table( pred_proc_id,
- pa_alias_as__alias_as ).
+ fixpoint_table(pred_proc_id,
+ pa_alias_as__alias_as).
:- import_module fixpoint_table.
-:- pred wrapped_init( pred_proc_id, pa_alias_as__alias_as).
-:- mode wrapped_init( in, out ) is det.
-wrapped_init( _, E ) :- pa_alias_as__init(E).
+:- pred wrapped_init(pred_proc_id, pa_alias_as__alias_as).
+:- mode wrapped_init(in, out) is det.
+wrapped_init(_, E) :- pa_alias_as__init(E).
-pa_fixpoint_table_init( KEYS, TABLE):-
- fp_init( wrapped_init, KEYS, TABLE).
+pa_fixpoint_table_init(KEYS, TABLE):-
+ fp_init(wrapped_init, KEYS, TABLE).
-pa_fixpoint_table_new_run( Tin, Tout ) :-
+pa_fixpoint_table_new_run(Tin, Tout) :-
fp_new_run(Tin,Tout).
-pa_fixpoint_table_which_run( Tin, Run ) :-
+pa_fixpoint_table_which_run(Tin, Run) :-
Run = fp_which_run(Tin).
-pa_fixpoint_table_all_stable( TABLE ) :-
+pa_fixpoint_table_all_stable(TABLE) :-
fp_stable(TABLE).
-pa_fixpoint_table_new_as( ModuleInfo, ProcInfo,
+pa_fixpoint_table_new_as(ModuleInfo, ProcInfo,
PRED_PROC_ID, ALIAS_AS, Tin, Tout) :-
fp_add(
pred(TabledElem::in, Elem::in) is semidet :-
- (
+ (
pa_alias_as__less_or_equal(ModuleInfo, ProcInfo,
Elem, TabledElem)
- ),
+ ),
PRED_PROC_ID, ALIAS_AS, Tin, Tout).
-pa_fixpoint_table_get_as( PRED_PROC_ID, ALIAS_AS, Tin, Tout) :-
+pa_fixpoint_table_get_as(PRED_PROC_ID, ALIAS_AS, Tin, Tout) :-
fp_get(PRED_PROC_ID, ALIAS_AS, Tin, Tout).
-pa_fixpoint_table_get_final_as( PRED_PROC_ID, ALIAS_AS, T ):-
- fp_get_final( PRED_PROC_ID, ALIAS_AS, T).
+pa_fixpoint_table_get_final_as(PRED_PROC_ID, ALIAS_AS, T):-
+ fp_get_final(PRED_PROC_ID, ALIAS_AS, T).
%-----------------------------------------------------------------------------%
@@ -113,7 +113,7 @@
:- pred arg_types_are_all_primitive(module_info, pred_info).
:- mode arg_types_are_all_primitive(in,in) is semidet.
-:- pred types_are_primitive( module_info::in, list(type)::in) is semidet.
+:- pred types_are_primitive(module_info::in, list(type)::in) is semidet.
:- implementation.
@@ -121,14 +121,14 @@
arg_types_are_all_primitive(HLDS, PredInfo):-
hlds_pred__pred_info_arg_types(PredInfo, ArgTypes),
- types_are_primitive( HLDS, ArgTypes).
+ types_are_primitive(HLDS, ArgTypes).
-types_are_primitive( HLDS, TYPES ) :-
- list__filter( pred( TYPE::in ) is semidet :-
- (
- type_util__type_is_atomic(TYPE,HLDS)
- ),
- TYPES,
- _TrueList,
- [] ).
+types_are_primitive(HLDS, TYPES) :-
+ list__filter(pred(TYPE::in) is semidet :-
+ (
+ type_util__type_is_atomic(TYPE,HLDS)
+ ),
+ TYPES,
+ _TrueList,
+ []).
Index: sr_direct.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_direct.m,v
retrieving revision 1.1.2.12
diff -u -r1.1.2.12 sr_direct.m
--- sr_direct.m 2001/03/16 09:09:57 1.1.2.12
+++ sr_direct.m 2001/03/23 10:22:54
@@ -47,10 +47,10 @@
% the conditions on that reuse are
{ proc_info_goal(ProcInfo2, Goal0) },
- (
+ (
{ VeryVerbose = yes }
->
- passes_aux__write_proc_progress_message(
+ passes_aux__write_proc_progress_message(
"% Analysing ", PredId, ProcId, ModuleInfo0),
io__write_string("%\tdeadness analysis...")
;
@@ -73,22 +73,22 @@
(
{ 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 ) },
+ { 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__write_string(Msg3)
;
- io__write_string( "done (no direct reuse).\n")
+ io__write_string("done (no direct reuse).\n")
)
;
[]
),
- { proc_info_set_reuse_information( ProcInfo2, MaybeReuseConditions,
- ProcInfo3 ) },
- { proc_info_set_goal( ProcInfo3, Goal, ProcInfo ) }.
+ { proc_info_set_reuse_information(ProcInfo2, MaybeReuseConditions,
+ ProcInfo3) },
+ { proc_info_set_goal(ProcInfo3, Goal, ProcInfo) }.
Index: sr_fixpoint_table.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_fixpoint_table.m,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 sr_fixpoint_table.m
--- sr_fixpoint_table.m 2001/02/28 13:00:41 1.1.2.2
+++ sr_fixpoint_table.m 2001/03/23 10:22:54
@@ -26,40 +26,40 @@
% the datastructure keeps track of the number of fixpoint runs
% performed, this predicates adds one.
-:- pred sr_fixpoint_table_new_run( table::in,
+:- pred sr_fixpoint_table_new_run(table::in,
table::out) is det.
-:- pred sr_fixpoint_table_which_run( table::in,
+:- pred sr_fixpoint_table_which_run(table::in,
int::out) is det.
% check whether all entries are stable. If so, one has reached
% a fixpoint
-:- pred sr_fixpoint_table_all_stable( table:: in ) is semidet.
+:- pred sr_fixpoint_table_all_stable(table:: in) is semidet.
% at the end of the analysis of one single pred_proc_id,
% the new exit reuse information is stored. This might
% change the stability of the table.
% if the pred_proc_id is not in the table --> error
-:- pred sr_fixpoint_table_new_reuse( pred_proc_id, memo_reuse,
+:- pred sr_fixpoint_table_new_reuse(pred_proc_id, memo_reuse,
hlds_goal__hlds_goal,
table, table).
-:- mode sr_fixpoint_table_new_reuse( in, in, in, in, out) is det.
+:- mode sr_fixpoint_table_new_reuse(in, in, in, in, out) is det.
% retreive the reuse information of a given
% pred_proc_id. If this information is not available,
% the general character of the fixpoint-table will be
% set to `recursive'
% if the pred_proc_id is not in the table --> fail
-:- pred sr_fixpoint_table_get_reuse( pred_proc_id, memo_reuse,
+:- pred sr_fixpoint_table_get_reuse(pred_proc_id, memo_reuse,
table, table).
-:- mode sr_fixpoint_table_get_reuse( in, out, in, out) is semidet.
+:- mode sr_fixpoint_table_get_reuse(in, out, in, out) is semidet.
% retreive reuse information, without changing the
% table. To be used after fixpoint has been reached.
-:- pred sr_fixpoint_table_get_final_reuse( pred_proc_id, memo_reuse,
+:- pred sr_fixpoint_table_get_final_reuse(pred_proc_id, memo_reuse,
hlds_goal__hlds_goal,
table).
-:- mode sr_fixpoint_table_get_final_reuse( in, out, out, in) is det.
+:- mode sr_fixpoint_table_get_final_reuse(in, out, out, in) is det.
%-------------------------------------------------------------------%
@@ -69,36 +69,36 @@
:- import_module std_util, require.
:- type fixpoint_entry --->
- sr_fp(
+ sr_fp(
memo_reuse,
hlds_goal__hlds_goal
).
-:- pred fixpoint_entry_equal( fixpoint_entry, fixpoint_entry ).
-:- mode fixpoint_entry_equal( in, in) is semidet.
+:- pred fixpoint_entry_equal(fixpoint_entry, fixpoint_entry).
+:- mode fixpoint_entry_equal(in, in) is semidet.
fixpoint_entry_equal(A, B) :-
- A = sr_fp( TRA, _),
- B = sr_fp( TRB, _),
+ A = sr_fp(TRA, _),
+ B = sr_fp(TRB, _),
sr_data__memo_reuse_equal(TRA, TRB).
-:- pred pick_reuse_information( module_info, pred_proc_id, fixpoint_entry).
-:- mode pick_reuse_information( in, in, out) is det.
+:- pred pick_reuse_information(module_info, pred_proc_id, fixpoint_entry).
+:- mode pick_reuse_information(in, in, out) is det.
-pick_reuse_information( HLDS, PredProc, Entry) :-
+pick_reuse_information(HLDS, PredProc, Entry) :-
module_info_pred_proc_info(HLDS, PredProc, _PredInfo, ProcInfo),
proc_info_reuse_information(ProcInfo, Memo),
proc_info_goal(ProcInfo, Goal),
- Entry = sr_fp( Memo, Goal ).
+ Entry = sr_fp(Memo, Goal).
:- import_module fixpoint_table.
:- type table ==
- fixpoint_table( pred_proc_id, fixpoint_entry ).
+ fixpoint_table(pred_proc_id, fixpoint_entry).
-sr_fixpoint_table_init( HLDS, PredProcs, Table ) :-
+sr_fixpoint_table_init(HLDS, PredProcs, Table) :-
fp_init(
pred(K::in, E::out) is det:-
(
@@ -108,26 +108,26 @@
Table
).
-sr_fixpoint_table_new_run( Tin, Tout ) :-
+sr_fixpoint_table_new_run(Tin, Tout) :-
fp_new_run(Tin,Tout).
-sr_fixpoint_table_which_run( Tin, Run ) :-
+sr_fixpoint_table_which_run(Tin, Run) :-
Run = fp_which_run(Tin).
-sr_fixpoint_table_all_stable( TABLE ) :-
+sr_fixpoint_table_all_stable(TABLE) :-
fp_stable(TABLE).
-sr_fixpoint_table_new_reuse( PRED_PROC_ID, TREUSE, GOAL, Tin, Tout) :-
- ENTRY = sr_fp( TREUSE, GOAL ),
+sr_fixpoint_table_new_reuse(PRED_PROC_ID, TREUSE, GOAL, Tin, Tout) :-
+ ENTRY = sr_fp(TREUSE, GOAL),
fp_add(fixpoint_entry_equal, PRED_PROC_ID, ENTRY, Tin, Tout).
-sr_fixpoint_table_get_reuse( PRED_PROC_ID, TREUSE, Tin, Tout) :-
+sr_fixpoint_table_get_reuse(PRED_PROC_ID, TREUSE, Tin, Tout) :-
fp_get(PRED_PROC_ID, ENTRY, Tin, Tout),
- ENTRY = sr_fp( TREUSE, _GOAL ).
+ ENTRY = sr_fp(TREUSE, _GOAL).
-sr_fixpoint_table_get_final_reuse( PRED_PROC_ID, TREUSE, GOAL, T ):-
- fp_get_final( PRED_PROC_ID, ENTRY, T),
- ENTRY = sr_fp( TREUSE, GOAL ).
+sr_fixpoint_table_get_final_reuse(PRED_PROC_ID, TREUSE, GOAL, T):-
+ fp_get_final(PRED_PROC_ID, ENTRY, T),
+ ENTRY = sr_fp(TREUSE, GOAL).
Index: sr_indirect.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_indirect.m,v
retrieving revision 1.1.2.22
diff -u -r1.1.2.22 sr_indirect.m
--- sr_indirect.m 2001/03/22 19:55:35 1.1.2.22
+++ sr_indirect.m 2001/03/23 10:22:54
@@ -36,32 +36,32 @@
compute_fixpoint(HLDS0, HLDSout) -->
% compute the strongly connected components
- { module_info_ensure_dependency_info( HLDS0, HLDS1) },
- { module_info_get_maybe_dependency_info( HLDS1, MaybeDepInfo) } ,
+ { module_info_ensure_dependency_info(HLDS0, HLDS1) },
+ { module_info_get_maybe_dependency_info(HLDS1, MaybeDepInfo) } ,
(
{ MaybeDepInfo = yes(DepInfo) }
->
- { hlds_dependency_info_get_dependency_ordering( DepInfo,
- DepOrdering ) },
+ { hlds_dependency_info_get_dependency_ordering(DepInfo,
+ DepOrdering) },
% perform the analysis, and annotate the procedures
- run_with_dependencies( DepOrdering, HLDS1, HLDS2),
+ run_with_dependencies(DepOrdering, HLDS1, HLDS2),
{ HLDSout = HLDS2 }
;
{ error("(sr_indirect) compute_fixpoint: no dependency info") }
).
-:- pred run_with_dependencies( dependency_ordering, module_info,
+:- pred run_with_dependencies(dependency_ordering, module_info,
module_info, io__state, io__state).
-:- mode run_with_dependencies( in, in, out, di, uo) is det.
+:- mode run_with_dependencies(in, in, out, di, uo) is det.
-run_with_dependencies( Deps, HLDSin, HLDSout) -->
- list__foldl2( run_with_dependency, Deps, HLDSin, HLDSout ).
+run_with_dependencies(Deps, HLDSin, HLDSout) -->
+ list__foldl2(run_with_dependency, Deps, HLDSin, HLDSout).
-:- pred run_with_dependency( list(pred_proc_id), module_info, module_info,
+:- pred run_with_dependency(list(pred_proc_id), module_info, module_info,
io__state, io__state).
-:- mode run_with_dependency( in, in, out, di, uo ) is det.
+:- mode run_with_dependency(in, in, out, di, uo) is det.
-run_with_dependency(SCC, HLDSin, HLDSout ) -->
+run_with_dependency(SCC, HLDSin, HLDSout) -->
(
% analysis ignores special predicates
{ pa_sr_util__some_are_special_preds(SCC, HLDSin) }
@@ -70,28 +70,28 @@
;
% for each list of strongly connected components,
% perform a fixpoint computation.
- { sr_fixpoint_table_init( HLDSin, SCC, FPtable0 ) } ,
- run_with_dependency_until_fixpoint( SCC, FPtable0,
- HLDSin, HLDSout )
+ { sr_fixpoint_table_init(HLDSin, SCC, FPtable0) } ,
+ run_with_dependency_until_fixpoint(SCC, FPtable0,
+ HLDSin, HLDSout)
).
%-----------------------------------------------------------------------------%
-:- pred run_with_dependency_until_fixpoint( list(pred_proc_id),
+:- pred run_with_dependency_until_fixpoint(list(pred_proc_id),
sr_fixpoint_table__table, module_info, module_info,
- io__state, io__state ).
-:- mode run_with_dependency_until_fixpoint( in, in, in, out, di, uo) is det.
+ io__state, io__state).
+:- mode run_with_dependency_until_fixpoint(in, in, in, out, di, uo) is det.
-run_with_dependency_until_fixpoint( SCC, FPtable0, HLDSin, HLDSout ) -->
- list__foldl2( analyse_pred_proc( HLDSin ), SCC, FPtable0, FPtable),
+run_with_dependency_until_fixpoint(SCC, FPtable0, HLDSin, HLDSout) -->
+ list__foldl2(analyse_pred_proc(HLDSin), SCC, FPtable0, FPtable),
(
- { sr_fixpoint_table_all_stable( FPtable) }
+ { sr_fixpoint_table_all_stable(FPtable) }
->
- { list__foldl( update_goal_in_module_info(FPtable), SCC,
+ { list__foldl(update_goal_in_module_info(FPtable), SCC,
HLDSin, HLDSout) }
;
{ sr_fixpoint_table_new_run(FPtable,
FPtable1) },
- run_with_dependency_until_fixpoint( SCC, FPtable1, HLDSin,
+ run_with_dependency_until_fixpoint(SCC, FPtable1, HLDSin,
HLDSout)
).
@@ -137,11 +137,11 @@
PredId, ProcId, HLDS),
{ sr_fixpoint_table_get_final_reuse(PredProcId, M, _, FPin) },
- (
+ (
{ M = yes(Conditions) }
->
{ list__length(Conditions, Length) },
- { string__int_to_string(Length, LengthS ) },
+ { string__int_to_string(Length, LengthS) },
{ string__append_list(
["%\tNumber of conditions (before):\t",
LengthS, "\n"], Msg2) } ,
@@ -177,11 +177,11 @@
analysis_info(_Alias, Pool,
_Static, FP1)),
/*
- analyse_goal( ProcInfo, HLDS,
+ analyse_goal(ProcInfo, HLDS,
Goal0, Goal,
Pool0, Pool,
Alias0, _Alias,
- FPin, FP1 ),
+ FPin, FP1),
*/
% OK
% 6. update all kind of information
@@ -196,11 +196,11 @@
;
{ sr_fixpoint_table_get_final_reuse(PredProcId,M1,_,FPout) },
- (
- { M1 = yes( Conditions1 ) }
+ (
+ { M1 = yes(Conditions1) }
->
{ list__length(Conditions1, Length1) },
- { string__int_to_string(Length1, LengthS1 ) },
+ { string__int_to_string(Length1, LengthS1) },
{ string__append_list(
["%\tNumber of conditions (after):\t",
LengthS1, "\n"], Msg21) } ,
@@ -225,36 +225,36 @@
hlds_goal::in, hlds_goal::out,
analysis_info::in, analysis_info::out) is det.
-analyse_goal( ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
+analyse_goal(ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
Expr0 = conj(Goals0),
list__map_foldl(analyse_goal(ProcInfo, HLDS), Goals0, Goals, AI0, AI),
Expr = conj(Goals),
Info = Info0,
Goal = Expr - Info.
-analyse_goal( ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
+analyse_goal(ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
Expr0 = call(PredId, ProcId, ActualVars, _, _, _),
- proc_info_vartypes( ProcInfo, VarTypes),
- list__map(
- map__lookup( VarTypes ),
+ proc_info_vartypes(ProcInfo, VarTypes),
+ list__map(
+ map__lookup(VarTypes),
ActualVars,
ActualTypes),
- call_verify_reuse( ProcInfo, HLDS,
+ call_verify_reuse(ProcInfo, HLDS,
PredId, ProcId, ActualVars,
ActualTypes, Info0, Info, AI0, AI1, _),
- pa_run__extend_with_call_alias( HLDS, ProcInfo,
+ pa_run__extend_with_call_alias(HLDS, ProcInfo,
PredId, ProcId, ActualVars, ActualTypes, AI0 ^ alias, Alias),
AI = AI1 ^ alias := Alias,
Expr = Expr0,
Goal = Expr - Info.
-analyse_goal( _ProcInfo, _HLDS, Expr0 - Info0, Goal, AI0, AI) :-
+analyse_goal(_ProcInfo, _HLDS, Expr0 - Info0, Goal, AI0, AI) :-
Expr0 = generic_call(_, _, _, _),
pa_alias_as__top("unhandled goal", Alias),
AI = AI0 ^ alias := Alias,
Goal = Expr0 - Info0.
-analyse_goal( ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
+analyse_goal(ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
Expr0 = unify(_Var, _Rhs, _Mode, Unification, _Context),
% Record the statically constructed variables.
@@ -271,10 +271,10 @@
Expr = Expr0,
Goal = Expr - Info.
-analyse_goal( ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
+analyse_goal(ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
Expr0 = switch(Var, CanFail, Cases0, SM),
list__map_foldl(
- (pred( case(ConsId, Gin)::in, Tuple::out,
+ (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,
@@ -301,8 +301,7 @@
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),
+ project_on_live_vars(ProcInfo, Info0, Alias1, Alias),
AI = analysis_info(Alias, Pool, Static, FP),
@@ -310,8 +309,8 @@
Expr = switch(Var, CanFail, Cases, SM),
Goal = Expr - Info.
-analyse_goal( ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
- Expr0 = disj( Goals0, SM ),
+analyse_goal(ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
+ Expr0 = disj(Goals0, SM),
(
Goals0 = []
->
@@ -320,7 +319,7 @@
;
% XXX up to here
list__map_foldl(
- (pred( Gin::in, Tuple::out,
+ (pred(Gin::in, Tuple::out,
FPin::in, FPout::out) is det :-
analyse_goal(ProcInfo, HLDS, Gin, Gout,
analysis_info(AI0 ^ alias, AI0 ^ pool,
@@ -346,8 +345,8 @@
Alias1),
% reduce the aliases
- goal_info_get_outscope(Info, Outscope),
- pa_alias_as__project_set(Outscope, Alias1, Alias),
+ pa_alias_as__project_on_live_vars(ProcInfo, Info, Alias1,
+ Alias),
AI = analysis_info(Alias, Pool, Static, FP)
),
@@ -356,29 +355,29 @@
Expr = disj(Goals, SM),
Goal = Expr - Info.
-analyse_goal( ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
+analyse_goal(ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
Expr0 = not(NegatedGoal0),
analyse_goal(ProcInfo, HLDS, NegatedGoal0, NegatedGoal, AI0, AI),
Info = Info0,
Expr = not(NegatedGoal),
Goal = Expr - Info.
-analyse_goal( ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
+analyse_goal(ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
Expr0 = some(A, B, SomeGoal0),
analyse_goal(ProcInfo, HLDS, SomeGoal0, SomeGoal, AI0, AI),
Info = Info0,
Expr = some(A, B, SomeGoal),
Goal = Expr - Info.
-analyse_goal( ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
- Expr0 = if_then_else( Vars, Cond0, Then0, Else0, SM),
+analyse_goal(ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
+ Expr0 = if_then_else(Vars, Cond0, Then0, Else0, SM),
analyse_goal(ProcInfo, HLDS, Cond0, Cond, AI0, AI_Cond),
analyse_goal(ProcInfo, HLDS, Then0, Then, AI_Cond, AI_Then),
AI1 = AI0 ^ table := AI_Then ^ table,
analyse_goal(ProcInfo, HLDS, Else0, Else, AI1, AI_Else),
- indirect_reuse_pool_least_upper_bound_disjunction(
+ indirect_reuse_pool_least_upper_bound_disjunction(
[AI_Then ^ pool, AI_Else ^ pool],
Pool),
@@ -388,18 +387,18 @@
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 ),
+ goal_info_get_outscope(Info, Outscope),
+ pa_alias_as__project_set(Outscope, Alias1, Alias),
AI = analysis_info(Alias, Pool, Static, AI1 ^ table),
Info = Info0,
- Expr = if_then_else( Vars, Cond, Then, Else, SM),
+ Expr = if_then_else(Vars, Cond, Then, Else, SM),
Goal = Expr - Info.
analyse_goal(ProcInfo, HLDS, Expr0 - Info0, Goal, AI0, AI) :-
Expr0 = pragma_foreign_code(Attrs, PredId, ProcId,
- Vars, MaybeModes, Types, _ ),
+ Vars, MaybeModes, Types, _),
pa_alias_as__extend_foreign_code(HLDS, ProcInfo, Attrs,
PredId, ProcId, Vars,
MaybeModes, Types, Info0, AI0 ^ alias, Alias),
@@ -407,7 +406,7 @@
Goal = Expr0 - Info0.
analyse_goal(_ProcInfo, _HLDS, Expr0 - Info0, Goal, AI0, AI) :-
- Expr0 = par_conj( _, _),
+ Expr0 = par_conj(_, _),
pa_alias_as__top("unhandled goal (par_conj)", Alias),
AI = AI0 ^ alias := Alias,
Goal = Expr0 - Info0.
@@ -419,9 +418,9 @@
Goal = Expr0 - Info0.
-:- pred call_verify_reuse( proc_info::in, module_info::in,
+:- pred call_verify_reuse(proc_info::in, module_info::in,
pred_id::in, proc_id::in, list(prog_var)::in,
- list( (type) )::in,
+ list((type))::in,
hlds_goal_info::in, hlds_goal_info::out,
analysis_info::in, analysis_info::out, bool::out) is det.
@@ -434,22 +433,22 @@
Alias0, Static, Pool0, Pool, GoalInfo0, GoalInfo,
FP0, FP, YesNo).
-:- pred call_verify_reuse( proc_info::in, module_info::in, pred_id::in,
- proc_id::in, list(prog_var)::in, list( (type) )::in,
+:- pred call_verify_reuse(proc_info::in, module_info::in, pred_id::in,
+ proc_id::in, list(prog_var)::in, list((type))::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,
+call_verify_reuse(ProcInfo, HLDS, PredId0, ProcId0,
ActualVars, ActualTypes, Alias0,
StaticTerms, Pool0, Pool,
- Info0, Info, FP0, FP, YesNo ) :-
+ Info0, Info, FP0, FP, YesNo) :-
module_info_structure_reuse_info(HLDS, ReuseInfo),
ReuseInfo = structure_reuse_info(ReuseMap),
- ( map__search(ReuseMap, proc(PredId0, ProcId0), Result) ->
+ (map__search(ReuseMap, proc(PredId0, ProcId0), Result) ->
Result = proc(PredId, ProcId) - _Name
;
PredId = PredId0,
@@ -457,10 +456,10 @@
),
% 0. fetch the procinfo of the called procedure:
- module_info_pred_proc_info( HLDS, PredId, ProcId, PredInfo,
+ module_info_pred_proc_info(HLDS, PredId, ProcId, PredInfo,
ProcInfo0),
% 1. find the tabled reuse for the called predicate
- lookup_memo_reuse( PredId, ProcId, HLDS, FP0, FP,
+ lookup_memo_reuse(PredId, ProcId, HLDS, FP0, FP,
FormalMemo),
% 2. once found, we can immediately handle the case where
% the tabled reuse would say that reuse is not possible anyway:
@@ -468,12 +467,12 @@
% unconditional reuse
FormalMemo = yes([])
->
- indirect_reuse_pool_add_unconditional( Pool0, Pool ),
+ indirect_reuse_pool_add_unconditional(Pool0, Pool),
Info = Info0,
YesNo = yes
;
% no reuse possible anyway
- (
+ (
memo_reuse_top(FormalMemo) ;
pa_alias_as__is_top(Alias0)
)
@@ -482,10 +481,10 @@
Info = Info0,
YesNo = no
;
- memo_reuse_rename( ProcInfo0, ActualVars, FormalMemo,
- Memo0 ),
- pred_info_arg_types( PredInfo, FormalTypes) ,
- memo_reuse_rename_types( FormalTypes, ActualTypes,
+ memo_reuse_rename(ProcInfo0, ActualVars, FormalMemo,
+ Memo0),
+ pred_info_arg_types(PredInfo, FormalTypes) ,
+ memo_reuse_rename_types(FormalTypes, ActualTypes,
Memo0, Memo),
% 3. compute the Live variables upon a procedure entry:
% 3.a. compute the full live set at the program point of
@@ -499,19 +498,19 @@
goal_info_get_lfu(Info0, LFUi),
goal_info_get_lbu(Info0, LBUi),
set__union(LFUi, LBUi, LUi),
- pa_alias_as__live( HLDS, ProcInfo, LUi, LIVE0, Alias0, Live_i),
+ pa_alias_as__live(HLDS, ProcInfo, LUi, LIVE0, Alias0, Live_i),
% 3.b. project the live-set to the actual vars:
- sr_live__project( ActualVars, Live_i, ActualLive_i ),
+ sr_live__project(ActualVars, Live_i, ActualLive_i),
% 4. project the aliases to the actual vars
- pa_alias_as__project( ActualVars, Alias0, ActualAlias_i),
+ pa_alias_as__project(ActualVars, Alias0, ActualAlias_i),
(
% XXX replace that with the actual
% static set!
- memo_reuse_verify_reuse( ProcInfo, HLDS,
+ memo_reuse_verify_reuse(ProcInfo, HLDS,
Memo, ActualLive_i, ActualAlias_i,
StaticTerms)
->
- indirect_reuse_pool_add( HLDS, ProcInfo,
+ indirect_reuse_pool_add(HLDS, ProcInfo,
Memo, LFUi, LBUi,
Alias0, ConditionalReuse, Pool0, Pool),
goal_info_set_reuse(Info0,
@@ -521,10 +520,10 @@
;
Pool = Pool0,
- examine_cause_of_missed_reuse( HLDS, ProcInfo,
+ examine_cause_of_missed_reuse(HLDS, ProcInfo,
LFUi, LBUi,
StaticTerms, Memo,
- Cause ),
+ Cause),
goal_info_set_reuse(Info0,
reuse(missed_reuse_call(Cause)), Info),
@@ -532,15 +531,15 @@
)
).
-:- pred examine_cause_of_missed_reuse( module_info::in,
+:- pred examine_cause_of_missed_reuse(module_info::in,
proc_info::in,
set(prog_var)::in,
set(prog_var)::in,
set(prog_var)::in,
memo_reuse::in, list(string)::out) is det.
-examine_cause_of_missed_reuse( ModuleInfo, ProcInfo,
- LFU, LBU, Static, Memo, Causes ) :-
- (
+examine_cause_of_missed_reuse(ModuleInfo, ProcInfo,
+ LFU, LBU, Static, Memo, Causes) :-
+ (
Memo = yes(Conditions)
->
list__filter_map(
@@ -554,7 +553,7 @@
Causes = [Cause]
).
-:- pred examine_cause_of_missed_condition( module_info::in,
+:- pred examine_cause_of_missed_condition(module_info::in,
proc_info::in,
set(prog_var)::in,
set(prog_var)::in,
@@ -562,15 +561,15 @@
reuse_condition::in,
string::out) is semidet.
-examine_cause_of_missed_condition( ModuleInfo, ProcInfo,
- LFU, LBU, StaticVars, Condition, Cause ) :-
+examine_cause_of_missed_condition(ModuleInfo, ProcInfo,
+ LFU, LBU, StaticVars, Condition, Cause) :-
sr_live__init(DummyLive),
- pa_alias_as__init( BottomAlias),
- pa_alias_as__live( ModuleInfo, ProcInfo,
+ pa_alias_as__init(BottomAlias),
+ pa_alias_as__live(ModuleInfo, ProcInfo,
LFU, DummyLive, BottomAlias, LFU_Live),
- pa_alias_as__live( ModuleInfo, ProcInfo,
+ pa_alias_as__live(ModuleInfo, ProcInfo,
LBU, DummyLive, BottomAlias, LBU_Live),
- Condition = condition( Nodes, _LU, _LA ),
+ Condition = condition(Nodes, _LU, _LA),
%
NodesL = set__to_sorted_list(Nodes),
(
@@ -590,8 +589,8 @@
% not due to static vars
% check for LFU
list__filter(
- ( pred(D::in) is semidet :-
- sr_live__is_live_datastruct( ModuleInfo,
+ (pred(D::in) is semidet :-
+ sr_live__is_live_datastruct(ModuleInfo,
ProcInfo, D, LFU_Live)
),
NodesL,
@@ -604,8 +603,8 @@
% not due to LFU
% check LBU
list__filter(
- ( pred(D::in) is semidet :-
- sr_live__is_live_datastruct( ModuleInfo,
+ (pred(D::in) is semidet :-
+ sr_live__is_live_datastruct(ModuleInfo,
ProcInfo, D, LBU_Live)
),
NodesL,
@@ -621,31 +620,31 @@
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
-:- pred lookup_memo_reuse( pred_id, proc_id, module_info,
+:- pred lookup_memo_reuse(pred_id, proc_id, module_info,
sr_fixpoint_table__table, sr_fixpoint_table__table,
- memo_reuse ).
-:- mode lookup_memo_reuse( in, in, in, in, out, out) is det.
+ memo_reuse).
+:- mode lookup_memo_reuse(in, in, in, in, out, out) is det.
% similar to the lookup_call_alias from pa_run:
% 1. check in fixpoint table
% 2. check in module_info (already fully analysed or imported pred)
% no special treatment necessary for primitive predicates and
% alike, as the default of predicates is no reuse anyway.
-lookup_memo_reuse( PredId, ProcId, HLDS, FP0, FP, Memo ):-
+lookup_memo_reuse(PredId, ProcId, HLDS, FP0, FP, Memo):-
PredProcId = proc(PredId, ProcId),
(
% 1 - check in table
- sr_fixpoint_table_get_reuse( PredProcId,
- Memo1, FP0, FP1 )
+ sr_fixpoint_table_get_reuse(PredProcId,
+ Memo1, FP0, FP1)
->
Memo = Memo1,
FP = FP1
;
FP = FP0,
% 2 - lookup in module_info
- module_info_pred_proc_info( HLDS, PredProcId, _PredInfo,
- ProcInfo ),
- proc_info_reuse_information( ProcInfo, Memo)
+ module_info_pred_proc_info(HLDS, PredProcId, _PredInfo,
+ ProcInfo),
+ proc_info_reuse_information(ProcInfo, Memo)
).
%-----------------------------------------------------------------------------%
@@ -660,16 +659,16 @@
:- pred indirect_reuse_pool_init(list(prog_var)::in,
memo_reuse::in,
indirect_reuse_pool::out) is det.
-:- pred indirect_reuse_pool_get_memo_reuse( indirect_reuse_pool::in,
+:- pred indirect_reuse_pool_get_memo_reuse(indirect_reuse_pool::in,
memo_reuse::out) is det.
-:- pred indirect_reuse_pool_least_upper_bound_disjunction(
+:- pred indirect_reuse_pool_least_upper_bound_disjunction(
list(indirect_reuse_pool)::in,
indirect_reuse_pool::out) is det.
-:- pred indirect_reuse_pool_least_upper_bound(
+:- pred indirect_reuse_pool_least_upper_bound(
indirect_reuse_pool::in,
indirect_reuse_pool::in,
- indirect_reuse_pool::out ) is det.
-:- pred indirect_reuse_pool_add( module_info::in, proc_info::in,
+ indirect_reuse_pool::out) is det.
+:- pred indirect_reuse_pool_add(module_info::in, proc_info::in,
memo_reuse::in,
set(prog_var)::in, set(prog_var)::in, alias_as::in, bool::out,
indirect_reuse_pool::in, indirect_reuse_pool::out) is det.
@@ -677,10 +676,10 @@
indirect_reuse_pool::out) is det.
-indirect_reuse_pool_init( HVs, MEMO, pool( HVs, MEMO) ).
-indirect_reuse_pool_get_memo_reuse( pool(_, MEMO), MEMO).
+indirect_reuse_pool_init(HVs, MEMO, pool(HVs, MEMO)).
+indirect_reuse_pool_get_memo_reuse(pool(_, MEMO), MEMO).
-indirect_reuse_pool_least_upper_bound_disjunction( List, Pool ):-
+indirect_reuse_pool_least_upper_bound_disjunction(List, Pool):-
(
List = [ P1 | R ]
->
@@ -695,13 +694,13 @@
:- import_module instmap.
-indirect_reuse_pool_least_upper_bound( Pool1, Pool2, Pool ):-
- Pool1 = pool( HVS, Memo1 ),
- Pool2 = pool( _, Memo2 ),
- memo_reuse_merge( Memo1, Memo2, Memo),
+indirect_reuse_pool_least_upper_bound(Pool1, Pool2, Pool):-
+ Pool1 = pool(HVS, Memo1),
+ Pool2 = pool(_, Memo2),
+ memo_reuse_merge(Memo1, Memo2, Memo),
Pool = pool(HVS, Memo).
-indirect_reuse_pool_add( HLDS, ProcInfo, MemoReuse,
+indirect_reuse_pool_add(HLDS, ProcInfo, MemoReuse,
LFUi, LBUi, Alias0, ConditionalReuse, Pool0, Pool) :-
(
@@ -710,13 +709,13 @@
% XXX instmap here simply initialized, as currently
% it's not used in the normalization anyway..
instmap__init_reachable(InstMap0),
- pa_alias_as__normalize( ProcInfo, HLDS, InstMap0,
+ pa_alias_as__normalize(ProcInfo, HLDS, InstMap0,
Alias0, Alias),
- Pool0 = pool( HVS, ExistingMemo),
+ Pool0 = pool(HVS, ExistingMemo),
list__map(
reuse_condition_update(ProcInfo, HLDS,
- LFUi, LBUi, Alias, HVS ),
+ LFUi, LBUi, Alias, HVS),
OldConditions,
NewConditions0),
reuse_conditions_simplify(NewConditions0, NewConditions),
@@ -729,13 +728,13 @@
),
memo_reuse_merge(ExistingMemo, yes(NewConditions),
NewMemo),
- Pool = pool( HVS, NewMemo )
+ Pool = pool(HVS, NewMemo)
;
error("indirect_reuse_pool_add: never enter.")
).
-indirect_reuse_pool_add_unconditional( Pool0, Pool ) :-
- Pool0 = pool( Hvs, Memo0 ),
+indirect_reuse_pool_add_unconditional(Pool0, Pool) :-
+ Pool0 = pool(Hvs, Memo0),
(
Memo0 = no
->
@@ -743,7 +742,7 @@
;
Memo = Memo0
),
- Pool = pool( Hvs, Memo).
+ Pool = pool(Hvs, Memo).
Index: sr_lbu.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_lbu.m,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 sr_lbu.m
--- sr_lbu.m 2000/10/15 11:26:17 1.1.2.3
+++ sr_lbu.m 2001/03/23 10:22:54
@@ -38,8 +38,8 @@
:- import_module io.
:- import_module hlds_module, hlds_pred.
-:- pred sr_lbu__lbu_pass( module_info, module_info, io__state, io__state).
-:- mode sr_lbu__lbu_pass( in, out, di, uo) is det.
+:- pred sr_lbu__lbu_pass(module_info, module_info, io__state, io__state).
+:- mode sr_lbu__lbu_pass(in, out, di, uo) is det.
:- pred sr_lbu__process_proc(module_info::in,
proc_info::in, proc_info::out) is det.
@@ -62,21 +62,21 @@
:- import_module sr_live.
-sr_lbu__lbu_pass( HLDSin , HLDSout) -->
+sr_lbu__lbu_pass(HLDSin , HLDSout) -->
% get all the predicate id's
- { hlds_module__module_info_predids( HLDSin, ALL_PRED_IDS ) },
+ { hlds_module__module_info_predids(HLDSin, ALL_PRED_IDS) },
% get all the id's of special predicates
- { hlds_module__module_info_get_special_pred_map( HLDSin, SPEC_MAP) },
- { map__values( SPEC_MAP, SPEC_PRED_IDS) },
+ { hlds_module__module_info_get_special_pred_map(HLDSin, SPEC_MAP) },
+ { map__values(SPEC_MAP, SPEC_PRED_IDS) },
% remove the special pred_ids from the set of pred_ids
- { list__delete_elems( ALL_PRED_IDS, SPEC_PRED_IDS, PRED_IDS0) },
+ { list__delete_elems(ALL_PRED_IDS, SPEC_PRED_IDS, PRED_IDS0) },
% filter out the predids of predicates not defined in this
% module
- { list__filter(
+ { list__filter(
pred_defined_in_this_module(HLDSin),
- PRED_IDS0, PRED_IDS ) },
+ PRED_IDS0, PRED_IDS) },
- list__foldl2( annotate_lbu_in_pred, PRED_IDS, HLDSin, HLDSout ).
+ list__foldl2(annotate_lbu_in_pred, PRED_IDS, HLDSin, HLDSout).
:- pred pred_defined_in_this_module(module_info, pred_id).
:- mode pred_defined_in_this_module(in,in) is semidet.
@@ -88,10 +88,10 @@
io__state).
:- mode annotate_lbu_in_pred(in,in,out,di,uo) is det.
-annotate_lbu_in_pred( PRED_ID, HLDSin, HLDSout ) -->
- { hlds_module__module_info_pred_info( HLDSin, PRED_ID, PredInfo) },
+annotate_lbu_in_pred(PRED_ID, HLDSin, HLDSout) -->
+ { hlds_module__module_info_pred_info(HLDSin, PRED_ID, PredInfo) },
globals__io_lookup_bool_option(very_verbose, VeryVerbose),
- (
+ (
{ VeryVerbose = yes }
->
passes_aux__write_pred_progress_message(
@@ -106,27 +106,27 @@
{ pred_info_procids(PredInfo, PROC_IDS) },
% handling all procids
- { list__foldl( annotate_lbu_in_proc(HLDSin, PRED_ID),
+ { list__foldl(annotate_lbu_in_proc(HLDSin, PRED_ID),
PROC_IDS, PredInfo, NewPredInfo) } ,
% and updating the module_info with the new predinfo-state.
- { module_info_set_pred_info( HLDSin, PRED_ID, NewPredInfo,
+ { module_info_set_pred_info(HLDSin, PRED_ID, NewPredInfo,
HLDSout) }.
-:- pred annotate_lbu_in_proc( module_info, pred_id, proc_id,
- pred_info, pred_info ).
-:- mode annotate_lbu_in_proc( in, in, in, in, out) is det.
+:- pred annotate_lbu_in_proc(module_info, pred_id, proc_id,
+ pred_info, pred_info).
+:- mode annotate_lbu_in_proc(in, in, in, in, out) is det.
-annotate_lbu_in_proc( HLDS, _PRED_ID, PROC_ID, PredInfo0,
+annotate_lbu_in_proc(HLDS, _PRED_ID, PROC_ID, PredInfo0,
PredInfo) :-
- pred_info_procedures( PredInfo0, Procedures0 ) ,
- map__lookup(Procedures0, PROC_ID, ProcInfo0 ) ,
+ pred_info_procedures(PredInfo0, Procedures0) ,
+ map__lookup(Procedures0, PROC_ID, ProcInfo0) ,
sr_lbu__process_proc(HLDS, ProcInfo0, ProcInfo),
map__det_update(Procedures0, PROC_ID, ProcInfo, Procedures) ,
- pred_info_set_procedures( PredInfo0, Procedures, PredInfo) .
+ pred_info_set_procedures(PredInfo0, Procedures, PredInfo) .
sr_lbu__process_proc(HLDS, ProcInfo0, ProcInfo) :-
proc_info_goal(ProcInfo0, Goal0),
@@ -139,7 +139,7 @@
% new Alias set
set__init(Lbu0),
- annotate_lbu_in_goal( HLDS, ProcInfo0,
+ annotate_lbu_in_goal(HLDS, ProcInfo0,
Lbu0, _Lbu, Goal0, Goal),
proc_info_set_goal(ProcInfo0, Goal, ProcInfo).
@@ -220,12 +220,12 @@
%%%%%%%%%%%%%%%%%%%%
% (6) if_then_else %
%%%%%%%%%%%%%%%%%%%%
- Expr0 = if_then_else( Vars, Cond0, Then0, Else0, SM)
+ Expr0 = if_then_else(Vars, Cond0, Then0, Else0, SM)
->
% annotating the condition
% starting from Lbu_01 (where resume_vars are
% taken into account)
- annotate_lbu_in_goal( HLDS, ProcInfo, Lbu_01,
+ annotate_lbu_in_goal(HLDS, ProcInfo, Lbu_01,
_LbuCond, Cond0, Cond),
% when annotating the then-part,
% the lbu used for it may not contain the
@@ -236,14 +236,14 @@
goal_info_set_resume_point(CondInfo0, no_resume_point,
InfoTmp),
CondTmp = CondGoal0 - InfoTmp,
- annotate_lbu_in_goal( HLDS, ProcInfo, Lbu_01,
+ annotate_lbu_in_goal(HLDS, ProcInfo, Lbu_01,
Lbu0Then, CondTmp, _),
- annotate_lbu_in_goal( HLDS, ProcInfo, Lbu0Then,
+ annotate_lbu_in_goal(HLDS, ProcInfo, Lbu0Then,
LbuThen, Then0, Then),
- annotate_lbu_in_goal( HLDS, ProcInfo, Lbu_01,
+ annotate_lbu_in_goal(HLDS, ProcInfo, Lbu_01,
LbuElse, Else0, Else),
set__union(LbuThen, LbuElse, Lbu),
- Expr = if_then_else( Vars, Cond, Then, Else, SM),
+ Expr = if_then_else(Vars, Cond, Then, Else, SM),
Info = Info0
;
%%%%%%%%%%%
@@ -252,7 +252,7 @@
Expr0 = not(Goal0)
% handled as if(Goal0) then fail else true
->
- annotate_lbu_in_goal( HLDS, ProcInfo, Lbu_01,
+ annotate_lbu_in_goal(HLDS, ProcInfo, Lbu_01,
Lbu, Goal0, Goal),
% in the if_then_else context as above this would be:
% Lbu = union(LbuThen, LbuElse),
@@ -267,11 +267,11 @@
%%%%%%%%%%%%
% (8) some %
%%%%%%%%%%%%
- Expr0 = some( Vars, CR, Goal0 )
+ Expr0 = some(Vars, CR, Goal0)
->
- annotate_lbu_in_goal( HLDS, ProcInfo, Lbu_01,
+ annotate_lbu_in_goal(HLDS, ProcInfo, Lbu_01,
Lbu, Goal0, Goal),
- Expr = some( Vars, CR, Goal ),
+ Expr = some(Vars, CR, Goal),
Info = Info0
;
%%%%%%%%%%%%%%%%%%%%%%%
@@ -287,57 +287,57 @@
goal_info_set_lbu(Info, Lbu, Info_new),
TopGoal = Expr - Info_new.
-:- pred annotate_lbu_in_conj( module_info, proc_info, set(prog_var),
+:- pred annotate_lbu_in_conj(module_info, proc_info, set(prog_var),
set(prog_var),
list(hlds_goal), list(hlds_goal)).
:- mode annotate_lbu_in_conj(in, in, in, out, in, out) is det.
-annotate_lbu_in_conj( HLDS, ProcInfo, Lbu0,
+annotate_lbu_in_conj(HLDS, ProcInfo, Lbu0,
Lbu, Goals0, Goals) :-
list__map_foldl(
- pred( Goal0::in, Goal::out,
- L0::in, L::out ) is det :-
- ( annotate_lbu_in_goal( HLDS, ProcInfo, L0,
- L, Goal0, Goal) ),
+ pred(Goal0::in, Goal::out,
+ L0::in, L::out) is det :-
+ (annotate_lbu_in_goal(HLDS, ProcInfo, L0,
+ L, Goal0, Goal)),
Goals0, Goals,
Lbu0, Lbu).
-:- pred annotate_lbu_in_switch( module_info, proc_info,
+:- pred annotate_lbu_in_switch(module_info, proc_info,
set(prog_var),
set(prog_var),
list(case), list(case)).
-:- mode annotate_lbu_in_switch( in, in, in, out, in, out) is det.
+:- mode annotate_lbu_in_switch(in, in, in, out, in, out) is det.
-annotate_lbu_in_switch( HLDS, ProcInfo, Lbu0, Lbu,
+annotate_lbu_in_switch(HLDS, ProcInfo, Lbu0, Lbu,
Cases0, Cases) :-
list__map_foldl(
- pred( Case0::in, Case::out,
+ pred(Case0::in, Case::out,
L0::in, L::out) is det :-
- (
+ (
Case0 = case(CONS,Goal0),
- annotate_lbu_in_goal( HLDS, ProcInfo, Lbu0,
+ annotate_lbu_in_goal(HLDS, ProcInfo, Lbu0,
Lnew, Goal0, Goal),
Case = case(CONS,Goal),
- set__union( L0, Lnew, L )
+ set__union(L0, Lnew, L)
),
Cases0, Cases,
Lbu0, Lbu).
-:- pred annotate_lbu_in_disj( module_info, proc_info,
+:- pred annotate_lbu_in_disj(module_info, proc_info,
set(prog_var),
set(prog_var),
list(hlds_goal), list(hlds_goal)).
-:- mode annotate_lbu_in_disj( in, in, in, out, in, out) is det.
+:- mode annotate_lbu_in_disj(in, in, in, out, in, out) is det.
-annotate_lbu_in_disj( HLDS, ProcInfo, Lbu0, Lbu,
+annotate_lbu_in_disj(HLDS, ProcInfo, Lbu0, Lbu,
Goals0, Goals) :-
list__map_foldl(
- pred( Goal0::in, Goal::out,
- L0::in, L::out ) is det :-
- (
- annotate_lbu_in_goal( HLDS, ProcInfo, Lbu0,
+ pred(Goal0::in, Goal::out,
+ L0::in, L::out) is det :-
+ (
+ annotate_lbu_in_goal(HLDS, ProcInfo, Lbu0,
Lnew, Goal0, Goal),
- set__union( L0, Lnew, L )
+ set__union(L0, Lnew, L)
),
Goals0, Goals,
Lbu0, Lbu).
Index: sr_lfu.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_lfu.m,v
retrieving revision 1.1.2.3
diff -u -r1.1.2.3 sr_lfu.m
--- sr_lfu.m 2000/10/15 11:26:18 1.1.2.3
+++ sr_lfu.m 2001/03/23 10:22:54
@@ -17,8 +17,8 @@
:- import_module io.
:- import_module hlds_module, hlds_pred.
-:- pred sr_lfu__lfu_pass( module_info, module_info, io__state, io__state).
-:- mode sr_lfu__lfu_pass( in, out, di, uo) is det.
+:- pred sr_lfu__lfu_pass(module_info, module_info, io__state, io__state).
+:- mode sr_lfu__lfu_pass(in, out, di, uo) is det.
:- pred sr_lfu__process_proc(proc_info::in, proc_info::out) is det.
@@ -40,21 +40,21 @@
:- import_module liveness.
-sr_lfu__lfu_pass( HLDSin , HLDSout) -->
+sr_lfu__lfu_pass(HLDSin , HLDSout) -->
% get all the predicate id's
- { hlds_module__module_info_predids( HLDSin, ALL_PRED_IDS ) },
+ { hlds_module__module_info_predids(HLDSin, ALL_PRED_IDS) },
% get all the id's of special predicates
- { hlds_module__module_info_get_special_pred_map( HLDSin, SPEC_MAP) },
- { map__values( SPEC_MAP, SPEC_PRED_IDS) },
+ { hlds_module__module_info_get_special_pred_map(HLDSin, SPEC_MAP) },
+ { map__values(SPEC_MAP, SPEC_PRED_IDS) },
% remove the special pred_ids from the set of pred_ids
- { list__delete_elems( ALL_PRED_IDS, SPEC_PRED_IDS, PRED_IDS0) },
+ { list__delete_elems(ALL_PRED_IDS, SPEC_PRED_IDS, PRED_IDS0) },
% filter out the predids of predicates not defined in this
% module
- { list__filter(
+ { list__filter(
pred_defined_in_this_module(HLDSin),
- PRED_IDS0, PRED_IDS ) },
+ PRED_IDS0, PRED_IDS) },
- list__foldl2( annotate_lfu_in_pred, PRED_IDS, HLDSin, HLDSout ).
+ list__foldl2(annotate_lfu_in_pred, PRED_IDS, HLDSin, HLDSout).
:- pred pred_defined_in_this_module(module_info, pred_id).
:- mode pred_defined_in_this_module(in,in) is semidet.
@@ -66,10 +66,10 @@
io__state).
:- mode annotate_lfu_in_pred(in,in,out,di,uo) is det.
-annotate_lfu_in_pred( PRED_ID, HLDSin, HLDSout ) -->
- { hlds_module__module_info_pred_info( HLDSin, PRED_ID, PredInfo) },
+annotate_lfu_in_pred(PRED_ID, HLDSin, HLDSout) -->
+ { hlds_module__module_info_pred_info(HLDSin, PRED_ID, PredInfo) },
globals__io_lookup_bool_option(very_verbose, VeryVerbose),
- (
+ (
{ VeryVerbose = yes }
->
passes_aux__write_pred_progress_message(
@@ -84,21 +84,21 @@
{ pred_info_procids(PredInfo, PROC_IDS) },
% handling all procids
- { list__foldl( annotate_lfu_in_proc(HLDSin, PRED_ID),
+ { list__foldl(annotate_lfu_in_proc(HLDSin, PRED_ID),
PROC_IDS, PredInfo, NewPredInfo) },
% and updating the module_info with the new predinfo-state.
- { module_info_set_pred_info( HLDSin, PRED_ID, NewPredInfo,
+ { module_info_set_pred_info(HLDSin, PRED_ID, NewPredInfo,
HLDSout) }.
-:- pred annotate_lfu_in_proc( module_info, pred_id, proc_id,
+:- pred annotate_lfu_in_proc(module_info, pred_id, proc_id,
pred_info, pred_info).
-:- mode annotate_lfu_in_proc( in, in, in, in, out) is det.
+:- mode annotate_lfu_in_proc(in, in, in, in, out) is det.
-annotate_lfu_in_proc( _HLDS, _PRED_ID, PROC_ID, PredInfo0, PredInfo) :-
- pred_info_procedures( PredInfo0, Procedures0 ) ,
- map__lookup(Procedures0, PROC_ID, ProcInfo0 ) ,
+annotate_lfu_in_proc(_HLDS, _PRED_ID, PROC_ID, PredInfo0, PredInfo) :-
+ pred_info_procedures(PredInfo0, Procedures0) ,
+ map__lookup(Procedures0, PROC_ID, ProcInfo0) ,
% fill the 4 liveness-related fields:
/** this should already have been done in the alias-pass
liveness__detect_liveness_proc(ProcInfo0, PRED_ID, HLDS,
@@ -109,7 +109,7 @@
sr_lfu__process_proc(ProcInfo01, ProcInfo),
map__det_update(Procedures0, PROC_ID, ProcInfo, Procedures) ,
- pred_info_set_procedures( PredInfo0, Procedures, PredInfo).
+ pred_info_set_procedures(PredInfo0, Procedures, PredInfo).
process_proc(ProcInfo01, ProcInfo) :-
proc_info_goal(ProcInfo01, Goal0),
@@ -121,7 +121,7 @@
set__init(DeadVars0),
% annotate each of the goals
- annotate_lfu_in_goal( InstVars0, DeadVars0, Inst, Dead, Goal0, Goal01),
+ annotate_lfu_in_goal(InstVars0, DeadVars0, Inst, Dead, Goal0, Goal01),
% explicitly make the lfu-set of the top-level goal to be
@@ -147,10 +147,10 @@
% annotate_lfu_in_goal(InstantiatedVars0, DiedVars0,
% InstantiatedVars, DiedVars, Goalin, Goalout).
-:- pred annotate_lfu_in_goal( set(prog_var), set(prog_var),
+:- pred annotate_lfu_in_goal(set(prog_var), set(prog_var),
set(prog_var), set(prog_var),
hlds_goal, hlds_goal).
-:- mode annotate_lfu_in_goal( in, in, out, out, in, out) is det.
+:- mode annotate_lfu_in_goal(in, in, out, out, in, out) is det.
annotate_lfu_in_goal(Inst0, Dead0, Inst, Dead, Goal0, Goal):-
Goal0 = Expr0 - Info0,
@@ -166,13 +166,13 @@
annotate_lfu_in_goal_2(Inst0, Dead0, Inst, Dead, Goal0, Goal)
).
- % calculateInstDead( info, instantiatedvars0, deadvars0,
+ % calculateInstDead(info, instantiatedvars0, deadvars0,
% instantiatedvars, deadvars)
-:- pred calculateInstDead( hlds_goal_info, set(prog_var), set(prog_var),
+:- pred calculateInstDead(hlds_goal_info, set(prog_var), set(prog_var),
set(prog_var), set(prog_var)).
-:- mode calculateInstDead( in, in, in, out, out) is det.
+:- mode calculateInstDead(in, in, in, out, out) is det.
-calculateInstDead( Info, Inst0, Dead0, Inst, Dead) :-
+calculateInstDead(Info, Inst0, Dead0, Inst, Dead) :-
% Inst = Inst0 + birth-set
% Dead = Dead0 + death-set
goal_info_get_pre_births(Info, PreBirths),
@@ -186,32 +186,32 @@
set__union(Births, Inst0, Inst),
set__union(Deaths, Dead0, Dead).
-:- pred annotate_lfu_in_goal_2( set(prog_var), set(prog_var),
+:- pred annotate_lfu_in_goal_2(set(prog_var), set(prog_var),
set(prog_var), set(prog_var),
hlds_goal, hlds_goal).
-:- mode annotate_lfu_in_goal_2( in, in, out, out, in, out) is det.
+:- mode annotate_lfu_in_goal_2(in, in, out, out, in, out) is det.
-annotate_lfu_in_goal_2( Inst0, Dead0, Inst, Dead, TopGoal0, TopGoal) :-
+annotate_lfu_in_goal_2(Inst0, Dead0, Inst, Dead, TopGoal0, TopGoal) :-
TopGoal0 = Expr0 - Info0,
(
Expr0 = conj(Goals0)
->
- annotate_lfu_in_conj( Inst0, Dead0, Inst, Dead, Goals0, Goals),
+ annotate_lfu_in_conj(Inst0, Dead0, Inst, Dead, Goals0, Goals),
Expr = conj(Goals)
;
Expr0 = switch(A,B,Cases0,C)
->
- annotate_lfu_in_cases( Inst0, Dead0, Inst, Dead, Cases0, Cases),
+ annotate_lfu_in_cases(Inst0, Dead0, Inst, Dead, Cases0, Cases),
Expr = switch(A,B,Cases,C)
;
Expr0 = disj(Disj0,S)
->
- annotate_lfu_in_disjs( Inst0, Dead0, Inst, Dead, Disj0, Disj),
+ annotate_lfu_in_disjs(Inst0, Dead0, Inst, Dead, Disj0, Disj),
Expr = disj(Disj, S)
;
Expr0 = not(Goal0)
->
- annotate_lfu_in_goal( Inst0, Dead0, Inst, Dead, Goal0, Goal),
+ annotate_lfu_in_goal(Inst0, Dead0, Inst, Dead, Goal0, Goal),
Expr = not(Goal)
;
Expr0 = some(V, C, Goal0)
@@ -238,62 +238,62 @@
goal_info_set_lfu(Info0, LFU, Info),
TopGoal = Expr - Info.
-:- pred annotate_lfu_in_conj( set(prog_var), set(prog_var),
+:- pred annotate_lfu_in_conj(set(prog_var), set(prog_var),
set(prog_var), set(prog_var),
list(hlds_goal), list(hlds_goal)).
-:- mode annotate_lfu_in_conj( in, in, out, out, in, out) is det.
+:- mode annotate_lfu_in_conj(in, in, out, out, in, out) is det.
-annotate_lfu_in_conj( Inst0, Dead0, Inst, Dead, Goals0, Goals) :-
- map_foldl2(
- pred( Goal0::in, Goal::out,
+annotate_lfu_in_conj(Inst0, Dead0, Inst, Dead, Goals0, Goals) :-
+ map_foldl2(
+ pred(Goal0::in, Goal::out,
I0::in, I::out,
- D0::in, D::out ) is det :-
- ( annotate_lfu_in_goal(I0, D0, I, D, Goal0, Goal) ),
+ D0::in, D::out) is det :-
+ (annotate_lfu_in_goal(I0, D0, I, D, Goal0, Goal)),
Goals0,
Goals,
Inst0, Inst,
Dead0, Dead).
-:- pred annotate_lfu_in_cases( set(prog_var), set(prog_var),
+:- pred annotate_lfu_in_cases(set(prog_var), set(prog_var),
set(prog_var), set(prog_var),
list(case), list(case)).
-:- mode annotate_lfu_in_cases( in, in, out, out, in, out) is det.
+:- mode annotate_lfu_in_cases(in, in, out, out, in, out) is det.
-annotate_lfu_in_cases( Inst0, Dead0, Inst, Dead, Cases0, Cases) :-
+annotate_lfu_in_cases(Inst0, Dead0, Inst, Dead, Cases0, Cases) :-
map_foldl2(
- pred( Case0::in, Case::out,
+ pred(Case0::in, Case::out,
I0::in, I::out,
- D0::in, D::out ) is det :-
- ( Case0 = case(Cons,Goal0),
- annotate_lfu_in_goal( Inst0, Dead0, NI, ND ,
+ D0::in, D::out) is det :-
+ (Case0 = case(Cons,Goal0),
+ annotate_lfu_in_goal(Inst0, Dead0, NI, ND ,
Goal0, Goal),
Case = case(Cons,Goal),
set__union(I0, NI, I),
- set__union(D0, ND, D) ),
+ set__union(D0, ND, D)),
Cases0,
Cases,
Inst0, Inst,
- Dead0, Dead ).
+ Dead0, Dead).
-:- pred annotate_lfu_in_disjs( set(prog_var), set(prog_var),
+:- pred annotate_lfu_in_disjs(set(prog_var), set(prog_var),
set(prog_var), set(prog_var),
list(hlds_goal), list(hlds_goal)).
-:- mode annotate_lfu_in_disjs( in, in, out, out, in, out ) is det.
+:- mode annotate_lfu_in_disjs(in, in, out, out, in, out) is det.
-annotate_lfu_in_disjs( Inst0, Dead0, Inst, Dead, Goals0, Goals) :-
+annotate_lfu_in_disjs(Inst0, Dead0, Inst, Dead, Goals0, Goals) :-
map_foldl2(
- pred( Goal0::in, Goal::out,
+ pred(Goal0::in, Goal::out,
I0::in, I::out,
- D0::in, D::out ) is det :-
- (
- annotate_lfu_in_goal( Inst0, Dead0, NI, ND ,
+ D0::in, D::out) is det :-
+ (
+ annotate_lfu_in_goal(Inst0, Dead0, NI, ND ,
Goal0, Goal),
set__union(I0, NI, I),
- set__union(D0, ND, D) ),
+ set__union(D0, ND, D)),
Goals0,
Goals,
Inst0, Inst,
- Dead0, Dead ).
+ Dead0, Dead).
:- pred map_foldl2(pred(T1,T2,T3,T3,T4,T4), list(T1), list(T2), T3, T3,
Index: sr_live.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_live.m,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 sr_live.m
--- sr_live.m 2001/02/07 10:19:11 1.1.2.2
+++ sr_live.m 2001/03/23 10:22:54
@@ -123,8 +123,8 @@
Live = live(List)
).
-get_datastructs( LiveSet, List ):-
- (
+get_datastructs(LiveSet, List):-
+ (
LiveSet = live(L)
->
List = L
@@ -137,8 +137,8 @@
require__error("(sr_live) get_datastructure: trying to collect datastructures from top-live-set.")
).
-union( LIVE_SETS, LIVE_SET ) :-
- list__foldl(
+union(LIVE_SETS, LIVE_SET) :-
+ list__foldl(
union,
LIVE_SETS,
bottom,
@@ -155,7 +155,7 @@
list__append(D1,D2,D),
from_datastructs(D, L)
;
- ( top(L1) ; top(L2) )
+ (top(L1) ; top(L2))
->
top(L)
;
@@ -188,11 +188,11 @@
Live = live(Datastructs)
->
list__filter(
- pred( D::in ) is semidet :-
- ( pa_datastruct__less_or_equal(ModuleInfo,
- ProcInfo, Data, D, _S) ),
+ pred(D::in) is semidet :-
+ (pa_datastruct__less_or_equal(ModuleInfo,
+ ProcInfo, Data, D, _S)),
Datastructs,
- R ),
+ R),
R = [_ | _ ]
;
@@ -204,16 +204,16 @@
fail
).
-project( VARS, Lin, Lout ) :-
+project(VARS, Lin, Lout) :-
(
Lin = live(Datastructs)
->
list__filter(
- pred( D::in ) is semidet :-
+ pred(D::in) is semidet :-
(
- pa_datastruct__get_var( D, Var ),
- list__member( Var, VARS )
- ),
+ pa_datastruct__get_var(D, Var),
+ list__member(Var, VARS)
+ ),
Datastructs,
FilteredDatastructs),
live_wrap(FilteredDatastructs, Lout)
Index: sr_profile.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_profile.m,v
retrieving revision 1.1.2.5
diff -u -r1.1.2.5 sr_profile.m
--- sr_profile.m 2001/03/05 12:06:07 1.1.2.5
+++ sr_profile.m 2001/03/23 10:22:55
@@ -42,33 +42,33 @@
no_reuse_calls :: int
).
-:- pred init( profiling_info::out ) is det.
+:- pred init(profiling_info::out) is det.
-:- pred inc_procs_defined( profiling_info::in, profiling_info::out ) is det.
-:- pred inc_reuse_procs( profiling_info::in, profiling_info::out ) is det.
-:- pred inc_uncond_reuse_procs( profiling_info::in,
- profiling_info::out ) is det.
-:- pred inc_procs_counted( profiling_info::in, profiling_info::out ) is det.
-:- pred inc_exported_procs( profiling_info::in, profiling_info::out ) is det.
-:- pred inc_exported_reuse_procs( profiling_info::in,
- profiling_info::out ) is det.
-:- pred inc_exported_uncond_reuse_procs( profiling_info::in,
- profiling_info::out ) is det.
-
-:- pred inc_aliases( int::in, profiling_info::in, profiling_info::out ) is det.
-:- pred inc_bottom_procs( profiling_info::in, profiling_info::out ) is det.
-:- pred inc_top_procs( profiling_info::in, profiling_info::out ) is det.
-:- pred inc_deconstructs( profiling_info::in, profiling_info::out ) is det.
-:- pred inc_direct_reuses( profiling_info::in, profiling_info::out ) is det.
-:- pred inc_direct_conditions( profiling_info::in, profiling_info::out ) is
+:- pred inc_procs_defined(profiling_info::in, profiling_info::out) is det.
+:- pred inc_reuse_procs(profiling_info::in, profiling_info::out) is det.
+:- pred inc_uncond_reuse_procs(profiling_info::in,
+ profiling_info::out) is det.
+:- pred inc_procs_counted(profiling_info::in, profiling_info::out) is det.
+:- pred inc_exported_procs(profiling_info::in, profiling_info::out) is det.
+:- pred inc_exported_reuse_procs(profiling_info::in,
+ profiling_info::out) is det.
+:- pred inc_exported_uncond_reuse_procs(profiling_info::in,
+ profiling_info::out) is det.
+
+:- pred inc_aliases(int::in, profiling_info::in, profiling_info::out) is det.
+:- pred inc_bottom_procs(profiling_info::in, profiling_info::out) is det.
+:- pred inc_top_procs(profiling_info::in, profiling_info::out) is det.
+:- pred inc_deconstructs(profiling_info::in, profiling_info::out) is det.
+:- pred inc_direct_reuses(profiling_info::in, profiling_info::out) is det.
+:- pred inc_direct_conditions(profiling_info::in, profiling_info::out) is
det.
-:- pred inc_pred_calls( profiling_info::in, profiling_info::out ) is det.
-:- pred inc_reuse_calls( profiling_info::in, profiling_info::out ) is det.
-:- pred inc_no_reuse_calls( profiling_info::in, profiling_info::out ) is det.
+:- pred inc_pred_calls(profiling_info::in, profiling_info::out) is det.
+:- pred inc_reuse_calls(profiling_info::in, profiling_info::out) is det.
+:- pred inc_no_reuse_calls(profiling_info::in, profiling_info::out) is det.
-:- pred write_profiling( string::in, profiling_info::in, module_info::in,
- io__state::di, io__state::uo ) is det.
+:- pred write_profiling(string::in, profiling_info::in, module_info::in,
+ io__state::di, io__state::uo) is det.
%-----------------------------------------------------------------------------%
@@ -77,68 +77,68 @@
:- import_module bool, relation, require, set, time, list, std_util, map.
:- import_module dependency_graph, hlds_out, hlds_pred.
-init( P ) :-
- P = prof( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0).
+init(P) :-
+ P = prof(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0).
-inc_procs_defined( P0, P0 ^ procs_defined := (P0 ^ procs_defined + 1)).
-inc_reuse_procs( P0, P0 ^ reuse_procs := (P0 ^ reuse_procs + 1)).
-inc_uncond_reuse_procs( P0,
+inc_procs_defined(P0, P0 ^ procs_defined := (P0 ^ procs_defined + 1)).
+inc_reuse_procs(P0, P0 ^ reuse_procs := (P0 ^ reuse_procs + 1)).
+inc_uncond_reuse_procs(P0,
P0 ^ uncond_reuse_procs := (P0 ^ uncond_reuse_procs + 1)).
-inc_procs_counted( P0, P0 ^ procs_counted := (P0 ^ procs_counted + 1)).
-inc_exported_procs( P0, P0 ^ exported_procs := (P0 ^ exported_procs + 1)).
-inc_exported_reuse_procs( P0,
+inc_procs_counted(P0, P0 ^ procs_counted := (P0 ^ procs_counted + 1)).
+inc_exported_procs(P0, P0 ^ exported_procs := (P0 ^ exported_procs + 1)).
+inc_exported_reuse_procs(P0,
P0 ^ exported_reuse_procs := (P0 ^ exported_reuse_procs + 1)).
-inc_exported_uncond_reuse_procs( P0,
+inc_exported_uncond_reuse_procs(P0,
P0 ^ exported_uncond_reuse_procs
:= (P0 ^ exported_uncond_reuse_procs + 1)).
-inc_aliases( N, P0, P0 ^ aliases := (P0 ^ aliases + N)).
-inc_bottom_procs( P0, P0 ^ bottom_procs := (P0 ^ bottom_procs + 1)).
-inc_top_procs( P0, P0 ^ top_procs := (P0 ^ top_procs + 1)).
-inc_deconstructs( P0, P0 ^ deconstructs := (P0 ^ deconstructs + 1)).
-inc_direct_reuses( P0, P0 ^ direct_reuses := (P0 ^ direct_reuses + 1)).
-inc_direct_conditions( P0, P0 ^ direct_conditions := (P0 ^ direct_conditions + 1)).
-inc_pred_calls( P0, P0 ^ pred_calls := (P0 ^ pred_calls + 1)).
-inc_reuse_calls( P0, P0 ^ reuse_calls := (P0 ^ reuse_calls + 1)).
-inc_no_reuse_calls( P0, P0 ^ no_reuse_calls := (P0 ^ no_reuse_calls + 1)).
-
-:- pred procs_defined( profiling_info::in, int::out) is det.
-:- pred reuse_procs( profiling_info::in, int::out) is det.
-:- pred uncond_reuse_procs( profiling_info::in, int::out) is det.
-:- pred procs_counted( profiling_info::in, int::out) is det.
-:- pred exported_procs( profiling_info::in, int::out) is det.
-:- pred exported_reuse_procs( profiling_info::in, int::out) is det.
-:- pred exported_uncond_reuse_procs( profiling_info::in, int::out) is det.
-:- pred aliases( profiling_info::in, int::out) is det.
-:- pred bottom_procs( profiling_info::in, int::out) is det.
-:- pred top_procs( profiling_info::in, int::out) is det.
-:- pred deconstructs( profiling_info::in, int::out) is det.
-:- pred direct_reuses( profiling_info::in, int::out) is det.
-:- pred direct_conditions( profiling_info::in,int::out) is det.
-:- pred pred_calls( profiling_info::in, int::out) is det.
-:- pred reuse_calls( profiling_info::in, int::out) is det.
-:- pred no_reuse_calls( profiling_info::in, int::out) is det.
-
-
-procs_defined( P0, P0 ^ procs_defined ).
-reuse_procs( P0, P0 ^ reuse_procs ).
-uncond_reuse_procs( P0, P0 ^ uncond_reuse_procs ).
-procs_counted( P0, P0 ^ procs_counted ).
-exported_procs( P0, P0 ^ exported_procs ).
-exported_reuse_procs( P0, P0 ^ exported_reuse_procs ).
-exported_uncond_reuse_procs( P0, P0 ^ exported_uncond_reuse_procs ).
-aliases( P0, P0 ^ aliases ).
-bottom_procs( P0, P0 ^ bottom_procs ).
-top_procs( P0, P0 ^ top_procs ).
-deconstructs( P0, P0 ^ deconstructs ).
-direct_reuses( P0, P0 ^ direct_reuses ).
-direct_conditions( P0, P0 ^ direct_conditions ).
-pred_calls( P0, P0 ^ pred_calls ).
-reuse_calls( P0, P0 ^ reuse_calls ).
-no_reuse_calls( P0, P0 ^ no_reuse_calls ).
+inc_aliases(N, P0, P0 ^ aliases := (P0 ^ aliases + N)).
+inc_bottom_procs(P0, P0 ^ bottom_procs := (P0 ^ bottom_procs + 1)).
+inc_top_procs(P0, P0 ^ top_procs := (P0 ^ top_procs + 1)).
+inc_deconstructs(P0, P0 ^ deconstructs := (P0 ^ deconstructs + 1)).
+inc_direct_reuses(P0, P0 ^ direct_reuses := (P0 ^ direct_reuses + 1)).
+inc_direct_conditions(P0, P0 ^ direct_conditions := (P0 ^ direct_conditions + 1)).
+inc_pred_calls(P0, P0 ^ pred_calls := (P0 ^ pred_calls + 1)).
+inc_reuse_calls(P0, P0 ^ reuse_calls := (P0 ^ reuse_calls + 1)).
+inc_no_reuse_calls(P0, P0 ^ no_reuse_calls := (P0 ^ no_reuse_calls + 1)).
+
+:- pred procs_defined(profiling_info::in, int::out) is det.
+:- pred reuse_procs(profiling_info::in, int::out) is det.
+:- pred uncond_reuse_procs(profiling_info::in, int::out) is det.
+:- pred procs_counted(profiling_info::in, int::out) is det.
+:- pred exported_procs(profiling_info::in, int::out) is det.
+:- pred exported_reuse_procs(profiling_info::in, int::out) is det.
+:- pred exported_uncond_reuse_procs(profiling_info::in, int::out) is det.
+:- pred aliases(profiling_info::in, int::out) is det.
+:- pred bottom_procs(profiling_info::in, int::out) is det.
+:- pred top_procs(profiling_info::in, int::out) is det.
+:- pred deconstructs(profiling_info::in, int::out) is det.
+:- pred direct_reuses(profiling_info::in, int::out) is det.
+:- pred direct_conditions(profiling_info::in,int::out) is det.
+:- pred pred_calls(profiling_info::in, int::out) is det.
+:- pred reuse_calls(profiling_info::in, int::out) is det.
+:- pred no_reuse_calls(profiling_info::in, int::out) is det.
+
+
+procs_defined(P0, P0 ^ procs_defined).
+reuse_procs(P0, P0 ^ reuse_procs).
+uncond_reuse_procs(P0, P0 ^ uncond_reuse_procs).
+procs_counted(P0, P0 ^ procs_counted).
+exported_procs(P0, P0 ^ exported_procs).
+exported_reuse_procs(P0, P0 ^ exported_reuse_procs).
+exported_uncond_reuse_procs(P0, P0 ^ exported_uncond_reuse_procs).
+aliases(P0, P0 ^ aliases).
+bottom_procs(P0, P0 ^ bottom_procs).
+top_procs(P0, P0 ^ top_procs).
+deconstructs(P0, P0 ^ deconstructs).
+direct_reuses(P0, P0 ^ direct_reuses).
+direct_conditions(P0, P0 ^ direct_conditions).
+pred_calls(P0, P0 ^ pred_calls).
+reuse_calls(P0, P0 ^ reuse_calls).
+no_reuse_calls(P0, P0 ^ no_reuse_calls).
-write_profiling( String, Prof, HLDS ) -->
+write_profiling(String, Prof, HLDS) -->
{ string__append(String, ".profile", String2) },
- io__open_output( String2, IOResult),
+ io__open_output(String2, IOResult),
(
{ IOResult = ok(Stream) },
% top
@@ -146,51 +146,51 @@
io__write_string(Stream, String),
io__nl(Stream),
% date
- time__time( TimeT ),
+ time__time(TimeT),
{ TimeS = time__ctime(TimeT) },
io__write_string(Stream, "Current time: "),
- io__write_string(Stream, TimeS ),
+ io__write_string(Stream, TimeS),
io__nl(Stream),
io__nl(Stream),
io__write_string(Stream, "General info:\n"),
- write_prof_item( Stream, procs_defined, Prof,
+ write_prof_item(Stream, procs_defined, Prof,
"# declared procedures"),
- write_prof_item( Stream, reuse_procs, Prof,
+ write_prof_item(Stream, reuse_procs, Prof,
"# reuse-procedures"),
- write_prof_item( Stream, uncond_reuse_procs, Prof,
+ write_prof_item(Stream, uncond_reuse_procs, Prof,
"# unconditional reuse-procedures"),
- write_prof_item( Stream, procs_counted, Prof,
+ write_prof_item(Stream, procs_counted, Prof,
"# procedures (total)"),
io__write_string(Stream, "Exported info:\n"),
- write_prof_item( Stream, exported_procs, Prof,
+ write_prof_item(Stream, exported_procs, Prof,
"# exported procedures"),
- write_prof_item( Stream, exported_reuse_procs, Prof,
+ write_prof_item(Stream, exported_reuse_procs, Prof,
"# exported procedures with reuse"),
- write_prof_item( Stream, exported_uncond_reuse_procs, Prof,
+ write_prof_item(Stream, exported_uncond_reuse_procs, Prof,
"# exported unconditional procedures with reuse"),
io__write_string(Stream, "Alias info:\n"),
- write_prof_item( Stream, aliases, Prof,
+ write_prof_item(Stream, aliases, Prof,
"# aliases over all the procedures"),
- write_prof_item( Stream, bottom_procs, Prof,
+ write_prof_item(Stream, bottom_procs, Prof,
"# procedures with alias = bottom"),
- write_prof_item( Stream, top_procs, Prof,
+ write_prof_item(Stream, top_procs, Prof,
"# procedures with alias = top"),
- io__write_string( Stream, "About direct reuses:\n"),
- write_prof_item( Stream, deconstructs, Prof,
+ io__write_string(Stream, "About direct reuses:\n"),
+ write_prof_item(Stream, deconstructs, Prof,
"# deconstructs"),
- write_prof_item( Stream, direct_reuses, Prof,
+ write_prof_item(Stream, direct_reuses, Prof,
"# direct reuses"),
- write_prof_item( Stream, direct_conditions, Prof,
+ write_prof_item(Stream, direct_conditions, Prof,
"# conditions implied by direct reuses"),
- io__write_string( Stream, "About indirect reuses:\n"),
- write_prof_item( Stream, pred_calls, Prof,
+ io__write_string(Stream, "About indirect reuses:\n"),
+ write_prof_item(Stream, pred_calls, Prof,
"# procedure calls"),
- write_prof_item( Stream, reuse_calls, Prof,
+ write_prof_item(Stream, reuse_calls, Prof,
"# calls to procedures with reuse"),
- write_prof_item( Stream, no_reuse_calls, Prof,
+ write_prof_item(Stream, no_reuse_calls, Prof,
"# failed calls to procedures with reuse"),
- io__write_string( Stream, "*/\ndigraph "),
+ io__write_string(Stream, "*/\ndigraph "),
io__write_string(Stream, String),
io__write_string(Stream, " {\nrankdir=LR;\n"),
{ dependency_graph__build_dependency_graph(HLDS,
@@ -200,7 +200,7 @@
{ relation__components(DepGraph, ComponentsSet) },
{ list__filter_map(
(pred(ComponentSet::in, Component::out) is semidet :-
- ( set__singleton_set(ComponentSet, C0) ->
+ (set__singleton_set(ComponentSet, C0) ->
relation__lookup_key(DepGraph, C0, C),
C = proc(PredId, _ProcId),
module_info_pred_info(HLDS,
@@ -213,7 +213,7 @@
HLDS, SpecialPredMap),
map__values(SpecialPredMap,
SpecialPredIds),
- \+ list__member( PredId,
+ \+ list__member(PredId,
SpecialPredIds)
;
\+ set__singleton_set(ComponentSet, _)
@@ -242,7 +242,7 @@
write_procedure_node(HLDS, Stream, PredProcId) -->
{ module_info_structure_reuse_info(HLDS, HLDSReuseInfo) },
- { HLDSReuseInfo = structure_reuse_info( ReuseMap ) },
+ { HLDSReuseInfo = structure_reuse_info(ReuseMap) },
io__set_output_stream(Stream, OldStream),
{ PredProcId = proc(PredId, ProcId) },
{ module_info_pred_proc_info(HLDS, PredProcId, PredInfo, ProcInfo) },
@@ -250,7 +250,7 @@
{ pred_info_import_status(PredInfo, ImportStatus) },
{
- (
+ (
ImportStatus = exported
->
Shape = "box",
@@ -286,10 +286,10 @@
Color = "color=black"
)
) },
- { string__append_list( ["[", Color,
+ { string__append_list(["[", Color,
",shape=",Shape,
",peripheries=", Periferies, "];\n"],
- Options ) },
+ Options) },
write_node_name(HLDS, PredId, ProcId),
@@ -306,34 +306,34 @@
{ Parent = proc(ParentPredId, ParentProcId) },
{ Child = proc(ChildPredId, ChildProcId) },
- write_node_name( HLDS, ParentPredId, ParentProcId),
+ write_node_name(HLDS, ParentPredId, ParentProcId),
io__write_string(" -> "),
- write_node_name( HLDS, ChildPredId, ChildProcId),
+ write_node_name(HLDS, ChildPredId, ChildProcId),
io__write_string(";\n"),
io__set_output_stream(OldStream, _).
-:- pred write_node_name( module_info::in, pred_id::in, proc_id::in,
+:- pred write_node_name(module_info::in, pred_id::in, proc_id::in,
io__state::di, io__state::uo) is det.
-write_node_name( HLDS, PredId, ProcId ) -->
- { pred_id_to_int( PredId, PredIdInt ) },
- { proc_id_to_int( ProcId, ProcIdInt ) },
+write_node_name(HLDS, PredId, ProcId) -->
+ { pred_id_to_int(PredId, PredIdInt) },
+ { proc_id_to_int(ProcId, ProcIdInt) },
io__write_char('"'),
- hlds_out__write_pred_proc_id( HLDS, PredId, ProcId),
+ hlds_out__write_pred_proc_id(HLDS, PredId, ProcId),
io__write_string("\\n"),
io__write_int(PredIdInt),
io__write_char('/'),
io__write_int(ProcIdInt),
io__write_char('"').
-:- pred write_prof_item( io__output_stream, pred(profiling_info, int),
+:- pred write_prof_item(io__output_stream, pred(profiling_info, int),
profiling_info,
string, io__state, io__state).
-:- mode write_prof_item( in, pred(in, out) is det, in, in, di, uo) is det.
+:- mode write_prof_item(in, pred(in, out) is det, in, in, di, uo) is det.
-write_prof_item( Str, Getter, Prof, Text ) -->
+write_prof_item(Str, Getter, Prof, Text) -->
{ Getter(Prof,Count) },
io__format(Str, "%8d %s\n", [i(Count),s(Text)]).
Index: sr_profile_run.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_profile_run.m,v
retrieving revision 1.1.2.4
diff -u -r1.1.2.4 sr_profile_run.m
--- sr_profile_run.m 2001/03/07 17:20:33 1.1.2.4
+++ sr_profile_run.m 2001/03/23 10:22:55
@@ -13,7 +13,7 @@
:- import_module io, hlds_module.
-:- pred structure_reuse_profiling( module_info::in, io__state::di,
+:- pred structure_reuse_profiling(module_info::in, io__state::di,
io__state::uo) is det.
%-----------------------------------------------------------------------------%
@@ -28,61 +28,61 @@
:- import_module hlds_goal.
-structure_reuse_profiling( HLDS ) -->
+structure_reuse_profiling(HLDS) -->
globals__io_lookup_bool_option(very_verbose, Verbose),
- maybe_write_string( Verbose,
- "% Collecting reuse-profiling information... " ),
+ maybe_write_string(Verbose,
+ "% Collecting reuse-profiling information... "),
- { collect_profiling_information( HLDS, Profiling) },
- { module_info_name( HLDS, ModuleName ) },
- { prog_out__sym_name_to_string( ModuleName, ModuleNameString) },
- sr_profile__write_profiling( ModuleNameString, Profiling, HLDS ),
- maybe_write_string( Verbose, "done.\n").
+ { collect_profiling_information(HLDS, Profiling) },
+ { module_info_name(HLDS, ModuleName) },
+ { prog_out__sym_name_to_string(ModuleName, ModuleNameString) },
+ sr_profile__write_profiling(ModuleNameString, Profiling, HLDS),
+ maybe_write_string(Verbose, "done.\n").
-:- pred collect_profiling_information( module_info::in,
- profiling_info::out ) is det.
+:- pred collect_profiling_information(module_info::in,
+ profiling_info::out) is det.
-collect_profiling_information( HLDS, Prof ) :-
+collect_profiling_information(HLDS, Prof) :-
sr_profile__init(Prof0),
- module_info_predids( HLDS, PredIds0 ),
- module_info_get_special_pred_map( HLDS, Map),
- map__values( Map, SpecialPredIds ),
+ module_info_predids(HLDS, PredIds0),
+ module_info_get_special_pred_map(HLDS, Map),
+ map__values(Map, SpecialPredIds),
list__filter(
- pred( Id::in ) is semidet :-
+ pred(Id::in) is semidet :-
( \+ member(Id, SpecialPredIds),
\+ hlds_module__pred_not_defined_in_this_module(HLDS, Id)
),
PredIds0,
PredIds),
list__foldl(
- collect_profiling_information_2( HLDS ),
+ collect_profiling_information_2(HLDS),
PredIds,
Prof0,
Prof).
-:- pred collect_profiling_information_2( module_info::in, pred_id::in,
+:- pred collect_profiling_information_2(module_info::in, pred_id::in,
profiling_info::in, profiling_info::out) is det.
-collect_profiling_information_2( HLDS, PredId, Prof0, Prof):-
- module_info_pred_info( HLDS, PredId, PredInfo),
- pred_info_import_status( PredInfo, ImportStatus),
- pred_info_procedures( PredInfo, Procedures ),
- map__values( Procedures, ProcInfos ),
+collect_profiling_information_2(HLDS, PredId, Prof0, Prof):-
+ module_info_pred_info(HLDS, PredId, PredInfo),
+ pred_info_import_status(PredInfo, ImportStatus),
+ pred_info_procedures(PredInfo, Procedures),
+ map__values(Procedures, ProcInfos),
list__foldl(
- collect_profiling_information_3( HLDS, ImportStatus),
+ collect_profiling_information_3(HLDS, ImportStatus),
ProcInfos,
Prof0,
Prof).
-:- pred collect_profiling_information_3( module_info::in,
+:- pred collect_profiling_information_3(module_info::in,
import_status::in, proc_info::in,
profiling_info::in, profiling_info::out) is det.
-collect_profiling_information_3( HLDS, ImportStatus, ProcInfo) -->
+collect_profiling_information_3(HLDS, ImportStatus, ProcInfo) -->
% first record some info about the procedure in general...
{
status_is_exported(ImportStatus, IsExported),
- proc_info_reuse_information( ProcInfo, ReuseInfo),
+ proc_info_reuse_information(ProcInfo, ReuseInfo),
(
ReuseInfo = yes(List)
->
@@ -101,7 +101,7 @@
UnconditionalReuse = no,
DefinedInModule = yes
),
- proc_info_possible_aliases( ProcInfo, PosAliases ),
+ proc_info_possible_aliases(ProcInfo, PosAliases),
(
PosAliases = yes(As)
->
@@ -153,41 +153,41 @@
% 10. alias top?
maybe_increment([TopAlias], inc_top_procs),
- { proc_info_goal( ProcInfo, Goal ) },
- collect_profiling_information_4( HLDS, Goal ).
+ { proc_info_goal(ProcInfo, Goal) },
+ collect_profiling_information_4(HLDS, Goal).
-:- pred collect_profiling_information_4( module_info::in, hlds_goal::in,
+:- pred collect_profiling_information_4(module_info::in, hlds_goal::in,
profiling_info::in, profiling_info::out) is det.
-collect_profiling_information_4( HLDS, Expr - _Info, Prof0, Prof ) :-
+collect_profiling_information_4(HLDS, Expr - _Info, Prof0, Prof) :-
Expr = conj(Goals),
- list__foldl( collect_profiling_information_4(HLDS),
+ list__foldl(collect_profiling_information_4(HLDS),
Goals, Prof0, Prof).
-collect_profiling_information_4( HLDS, Expr - Info, Prof0, Prof ) :-
- Expr = call( PredId, ProcId, _, _, _, _),
+collect_profiling_information_4(HLDS, Expr - Info, Prof0, Prof) :-
+ Expr = call(PredId, ProcId, _, _, _, _),
inc_pred_calls(Prof0, Prof1),
- goal_info_get_reuse( Info, Reuse ),
+ goal_info_get_reuse(Info, Reuse),
(
Reuse = reuse(ShortReuse),
ShortReuse = reuse_call(_)
->
- inc_reuse_calls( Prof1, Prof )
+ inc_reuse_calls(Prof1, Prof)
;
module_info_structure_reuse_info(HLDS, ReuseInfo),
ReuseInfo = structure_reuse_info(ReuseMap),
(
map__contains(ReuseMap, proc(PredId, ProcId))
->
- inc_no_reuse_calls( Prof1, Prof )
+ inc_no_reuse_calls(Prof1, Prof)
;
Prof = Prof1
)
).
-collect_profiling_information_4( _HLDS, Expr - _Info, Prof, Prof ) :-
- Expr = generic_call( _, _, _, _).
-collect_profiling_information_4( HLDS, Expr - _Info, Prof0, Prof ) :-
+collect_profiling_information_4(_HLDS, Expr - _Info, Prof, Prof) :-
+ Expr = generic_call(_, _, _, _).
+collect_profiling_information_4(HLDS, Expr - _Info, Prof0, Prof) :-
Expr = switch(_, _, Cases, _),
- list__foldl(
+ list__foldl(
pred(C::in, P0::in, P::out) is det :-
(
C = case(_, G),
@@ -196,58 +196,58 @@
Cases,
Prof0,
Prof).
-collect_profiling_information_4( _HLDS, Expr - Info, Prof0, Prof ) :-
+collect_profiling_information_4(_HLDS, Expr - Info, Prof0, Prof) :-
Expr = unify(_, _, _, Unification, _),
(
Unification = deconstruct(_, _, _, _, _, _)
->
- inc_deconstructs( Prof0, Prof1),
- goal_info_get_reuse( Info, Reuse),
+ inc_deconstructs(Prof0, Prof1),
+ goal_info_get_reuse(Info, Reuse),
(
Reuse = reuse(ShortReuse),
ShortReuse = cell_died
->
- inc_direct_reuses( Prof1, Prof)
+ inc_direct_reuses(Prof1, Prof)
;
Prof = Prof1
)
;
Prof = Prof0
).
-collect_profiling_information_4( HLDS, Expr - _Info, Prof0, Prof ) :-
+collect_profiling_information_4(HLDS, Expr - _Info, Prof0, Prof) :-
Expr = disj(Goals, _),
- list__foldl( collect_profiling_information_4(HLDS),
+ list__foldl(collect_profiling_information_4(HLDS),
Goals, Prof0, Prof).
-collect_profiling_information_4( HLDS, Expr - _Info, Prof0, Prof ) :-
+collect_profiling_information_4(HLDS, Expr - _Info, Prof0, Prof) :-
Expr = not(Goal),
- collect_profiling_information_4( HLDS, Goal, Prof0, Prof).
-collect_profiling_information_4( HLDS, Expr - _Info, Prof0, Prof ) :-
+ collect_profiling_information_4(HLDS, Goal, Prof0, Prof).
+collect_profiling_information_4(HLDS, Expr - _Info, Prof0, Prof) :-
Expr = some(_, _, Goal),
- collect_profiling_information_4( HLDS, Goal, Prof0, Prof).
-collect_profiling_information_4( HLDS, Expr - _Info, Prof0, Prof ) :-
+ collect_profiling_information_4(HLDS, Goal, Prof0, Prof).
+collect_profiling_information_4(HLDS, Expr - _Info, Prof0, Prof) :-
Expr = if_then_else(_, If, Then, Else, _),
- collect_profiling_information_4( HLDS, If, Prof0, Prof1),
- collect_profiling_information_4( HLDS, Then, Prof1, Prof2),
- collect_profiling_information_4( HLDS, Else, Prof2, Prof).
-collect_profiling_information_4( _HLDS, Expr - _Info, Prof, Prof ) :-
+ collect_profiling_information_4(HLDS, If, Prof0, Prof1),
+ collect_profiling_information_4(HLDS, Then, Prof1, Prof2),
+ collect_profiling_information_4(HLDS, Else, Prof2, Prof).
+collect_profiling_information_4(_HLDS, Expr - _Info, Prof, Prof) :-
Expr = pragma_foreign_code(_, _, _, _, _, _, _).
-collect_profiling_information_4( _HLDS, Expr - _Info, Prof, Prof ) :-
+collect_profiling_information_4(_HLDS, Expr - _Info, Prof, Prof) :-
Expr = par_conj(_, _).
-collect_profiling_information_4( _HLDS, Expr - _Info, Prof, Prof ) :-
+collect_profiling_information_4(_HLDS, Expr - _Info, Prof, Prof) :-
Expr = bi_implication(_, _).
-:- pred maybe_increment( list(bool), pred( profiling_info, profiling_info),
+:- pred maybe_increment(list(bool), pred(profiling_info, profiling_info),
profiling_info, profiling_info).
-:- mode maybe_increment( in, pred(in, out) is det, in, out) is det.
+:- mode maybe_increment(in, pred(in, out) is det, in, out) is det.
-maybe_increment( Bools, IncOp, Prof0, Prof ) :-
- bool__and_list( Bools, Result ),
+maybe_increment(Bools, IncOp, Prof0, Prof) :-
+ bool__and_list(Bools, Result),
(
Result = yes
->
- IncOp( Prof0, Prof)
+ IncOp(Prof0, Prof)
;
Prof = Prof0
).
Index: sr_split.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_split.m,v
retrieving revision 1.1.2.12
diff -u -r1.1.2.12 sr_split.m
--- sr_split.m 2001/03/16 09:09:57 1.1.2.12
+++ sr_split.m 2001/03/23 10:22:55
@@ -17,12 +17,12 @@
:- import_module hlds_module, io, string.
:- import_module hlds_pred, sr_data, std_util, hlds_goal.
- % create_multiple_versions( VirginHLDS, ReuseHLDS, FinalHLDS ).
+ % create_multiple_versions(VirginHLDS, ReuseHLDS, FinalHLDS).
% Starting from the VirginHLDS, it computes a new HLDS where for
% each procedure having conditional reuse (ReuseHLDS), a new
% separate reuse-procedure is added. The calls can then also
% be corrected so that they point to the correct reuse-versions.
-:- pred sr_split__create_multiple_versions( module_info::in, module_info::in,
+:- 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,
@@ -46,47 +46,47 @@
reuse_predicate_name(PredName) :-
string__prefix(PredName, "reuse__").
-sr_split__create_multiple_versions( VirginHLDS, ReuseHLDS, HLDS) -->
+sr_split__create_multiple_versions(VirginHLDS, ReuseHLDS, HLDS) -->
% compute the strongly connected components
- { create_versions( VirginHLDS, ReuseHLDS, HLDS1) },
- { reprocess_all_goals( HLDS1, HLDS ) }.
+ { create_versions(VirginHLDS, ReuseHLDS, HLDS1) },
+ { reprocess_all_goals(HLDS1, HLDS) }.
% reprocess each of the procedures to make sure that all calls
% to reuse preds are correct.
:- pred reprocess_all_goals(module_info::in, module_info::out) is det.
-reprocess_all_goals( HLDS0, HLDS ) :-
- module_info_predids( HLDS0, PredIds),
+reprocess_all_goals(HLDS0, HLDS) :-
+ module_info_predids(HLDS0, PredIds),
list__foldl(
reprocess_all_goals_2,
PredIds,
HLDS0,
HLDS).
-:- pred reprocess_all_goals_2( pred_id::in, module_info::in,
- module_info::out ) is det.
-reprocess_all_goals_2( PredId, HLDS0, HLDS ) :-
- module_info_pred_info( HLDS0, PredId, PredInfo0 ),
- pred_info_procids( PredInfo0, ProcIds ),
- pred_info_procedures( PredInfo0, Procedures0 ),
+:- pred reprocess_all_goals_2(pred_id::in, module_info::in,
+ module_info::out) is det.
+reprocess_all_goals_2(PredId, HLDS0, HLDS) :-
+ module_info_pred_info(HLDS0, PredId, PredInfo0),
+ pred_info_procids(PredInfo0, ProcIds),
+ pred_info_procedures(PredInfo0, Procedures0),
list__foldl(
reprocess_all_goals_3(HLDS0),
ProcIds,
Procedures0,
Procedures
),
- pred_info_set_procedures( PredInfo0, Procedures, PredInfo),
- module_info_set_pred_info( HLDS0, PredId, PredInfo, HLDS ).
+ pred_info_set_procedures(PredInfo0, Procedures, PredInfo),
+ module_info_set_pred_info(HLDS0, PredId, PredInfo, HLDS).
-:- pred reprocess_all_goals_3( module_info::in, proc_id::in,
+:- pred reprocess_all_goals_3(module_info::in, proc_id::in,
proc_table::in, proc_table::out) is det.
-reprocess_all_goals_3( HLDS, ProcId, ProcTable0, ProcTable) :-
- map__lookup( ProcTable0, ProcId, ProcInfo0),
- proc_info_reuse_information( ProcInfo0 , Memo ),
+reprocess_all_goals_3(HLDS, ProcId, ProcTable0, ProcTable) :-
+ map__lookup(ProcTable0, ProcId, ProcInfo0),
+ proc_info_reuse_information(ProcInfo0 , Memo),
(
Memo = yes(Conditions)
->
- proc_info_goal( ProcInfo0, Goal0),
+ proc_info_goal(ProcInfo0, Goal0),
% If the conditions on the reuse are empty, then
% we have unconditional reuse, so make sure when
% processing the goal we don't do any actions
@@ -96,35 +96,35 @@
;
LocalReuseOnly = no
),
- process_goal(LocalReuseOnly, Goal0, Goal, HLDS, _ ),
- proc_info_set_goal( ProcInfo0, Goal, ProcInfo),
- map__det_update( ProcTable0, ProcId, ProcInfo, ProcTable)
+ process_goal(LocalReuseOnly, Goal0, Goal, HLDS, _),
+ proc_info_set_goal(ProcInfo0, Goal, ProcInfo),
+ map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable)
;
ProcTable = ProcTable0
).
-:- pred create_versions( module_info, module_info, module_info).
-:- mode create_versions( in, in, out) is det.
+:- pred create_versions(module_info, module_info, module_info).
+:- mode create_versions(in, in, out) is det.
-create_versions( VirginHLDS, ReuseHLDS, HLDS) :-
- module_info_predids( ReuseHLDS, PredIds),
+create_versions(VirginHLDS, ReuseHLDS, HLDS) :-
+ module_info_predids(ReuseHLDS, PredIds),
list__foldl(
create_versions_2(VirginHLDS),
PredIds,
ReuseHLDS,
HLDS).
-:- pred create_versions_2( module_info::in, pred_id::in,
+:- pred create_versions_2(module_info::in, pred_id::in,
module_info::in, module_info::out) is det.
-create_versions_2( VirginHLDS, PredId , HLDS0, HLDS ) :-
- module_info_pred_info( HLDS0, PredId, PredInfo0 ),
- pred_info_procids( PredInfo0, ProcIds ),
+create_versions_2(VirginHLDS, PredId , HLDS0, HLDS) :-
+ module_info_pred_info(HLDS0, PredId, PredInfo0),
+ pred_info_procids(PredInfo0, ProcIds),
list__foldl(
- pred( Id::in, H0::in, H::out ) is det :-
+ pred(Id::in, H0::in, H::out) is det :-
(
- create_versions_3( VirginHLDS,
+ create_versions_3(VirginHLDS,
proc(PredId, Id),
H0, H)
),
@@ -133,25 +133,25 @@
HLDS
).
-:- pred create_versions_3( module_info::in, pred_proc_id::in,
+:- pred create_versions_3(module_info::in, pred_proc_id::in,
module_info::in, module_info::out) is det.
-create_versions_3( VirginHLDS, PredProcId, WorkingHLDS, HLDS):-
- module_info_pred_proc_info( WorkingHLDS, PredProcId,
+create_versions_3(VirginHLDS, PredProcId, WorkingHLDS, HLDS):-
+ module_info_pred_proc_info(WorkingHLDS, PredProcId,
PredInfo0, ProcInfo0),
- proc_info_reuse_information( ProcInfo0, Memo),
- module_info_pred_proc_info( VirginHLDS, PredProcId, _,
+ proc_info_reuse_information(ProcInfo0, Memo),
+ module_info_pred_proc_info(VirginHLDS, PredProcId, _,
CleanProcInfo),
- proc_info_goal( ProcInfo0, ReuseGoal),
+ proc_info_goal(ProcInfo0, ReuseGoal),
(
Memo = no
->
% restore the old status of the procedure
- module_info_set_pred_proc_info( WorkingHLDS, PredProcId,
+ module_info_set_pred_proc_info(WorkingHLDS, PredProcId,
PredInfo0, CleanProcInfo, HLDS)
;
- (
+ (
memo_reuse_is_conditional(Memo)
->
% fetch the reuse goal
@@ -184,7 +184,7 @@
proc_info_set_reuse_information(ProcInfo0,
yes([]), ProcInfo),
- module_info_set_pred_proc_info( WorkingHLDS2,
+ module_info_set_pred_proc_info(WorkingHLDS2,
PredProcId, PredInfo0, ProcInfo, HLDS)
;
% memo_reuse is unconditional -- perfect --
@@ -199,7 +199,7 @@
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) ->
+ (memo_reuse_is_conditional(TREUSE) ->
create_reuse_pred(TREUSE, PRED_PROC_ID,
MaybeHLDS_GOAL, PredInfo0, ProcInfo0,
ReusePredInfo, _ReuseProcInfo,
Index: sr_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/Attic/sr_util.m,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 sr_util.m
--- sr_util.m 2001/02/07 13:56:07 1.1.2.2
+++ sr_util.m 2001/03/23 10:22:55
@@ -18,29 +18,29 @@
:- 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,
+:- 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 ),
+:- 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,
+:- 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),
+:- 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,
+:- 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),
+:- 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,
+:- 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)).
@@ -60,15 +60,15 @@
End = End0
;
End = List
- ).
+ ).
-list_map3( P, L, A, B, C) :-
+list_map3(P, L, A, B, C) :-
(
L = [ L1 | LR ]
->
- P( L1, A1, B1, C1),
- list_map3( P, LR, AR, BR, CR ),
+ P(L1, A1, B1, C1),
+ list_map3(P, LR, AR, BR, CR),
A = [ A1 | AR ],
B = [ B1 | BR ],
C = [ C1 | CR ]
@@ -78,12 +78,12 @@
C = []
).
-list_map_foldl2( P, L0, L1, A0, A, B0, B) :-
+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),
+ P(LE0, LE1, A0, A1, B0, B1),
+ list_map_foldl2(P, LR0, LR1, A1, A, B1, B),
L1 = [ LE1 | LR1 ]
;
L1 = [],
@@ -91,12 +91,12 @@
B = B0
).
-list_map3_foldl( P, L0, L1, L2, L3, A0, A) :-
+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),
+ 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 ]
@@ -107,12 +107,12 @@
A = A0
).
-list_map_foldl3( P, L1, L, A1, A, B1, B, C1, C) :-
+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),
+ 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 = [],
@@ -121,12 +121,12 @@
C = C1
).
-list_ho_member( EQUALITY_TEST, ELEMENT, LIST ) :-
+list_ho_member(EQUALITY_TEST, ELEMENT, LIST) :-
LIST = [ HEAD | TAIL ],
(
EQUALITY_TEST(HEAD, ELEMENT)
->
true
;
- list_ho_member( EQUALITY_TEST, ELEMENT, TAIL )
+ list_ho_member(EQUALITY_TEST, ELEMENT, TAIL)
).
--------------------------------------------------------------------------
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