[m-rev.] For review: Loop invariant hoisting optimization

Ralph Becket rafe at cs.mu.OZ.AU
Fri Jul 5 14:08:03 AEST 2002


Simon asked for the short names to be expanded:


diff -u loop_inv.m loop_inv.m
--- loop_inv.m	24 Jun 2002 03:33:06 -0000
+++ loop_inv.m	5 Jul 2002 03:54:07 -0000
@@ -268,8 +268,8 @@
 
 :- type rec_calls == list(rec_call).
 
-:- type igcs_acc
-    --->    igcs_acc(
+:- type invariant_goal_candidates_acc
+    --->    invariant_goal_candidates_acc(
                     % path_candidates is the list of accumulated invariant
                     % goal candidates.
                     %
@@ -295,65 +295,97 @@
 
 invariant_goal_candidates(PredProcId, Body,
         CandidateInvGoals, RecCallGoals) :-
-    igcs_acc(_, RecCalls) = igcs(PredProcId, Body, igcs_acc([], [])),
+    invariant_goal_candidates_acc(_, RecCalls) =
+        invariant_goal_candidates_2(PredProcId, Body,
+            invariant_goal_candidates_acc([], [])),
     assoc_list__keys_and_values(RecCalls, RecCallGoals, CandidateInvGoalsList),
     CandidateInvGoals = intersect_candidate_inv_goals(CandidateInvGoalsList).
 
 %------------------------------------------------------------------------------%
 
-:- func igcs(pred_proc_id, hlds_goal, igcs_acc) = igcs_acc.
+:- func invariant_goal_candidates_2(pred_proc_id, hlds_goal,
+            invariant_goal_candidates_acc
+        ) = invariant_goal_candidates_acc.
 
-igcs(PPId, Call @ call(PredId, ProcId, _, _, _, _)      - GoalInfo,  IGCs) =
+invariant_goal_candidates_2(PPId,
+        Call @ call(PredId, ProcId, _, _, _, _)      - GoalInfo,  IGCs) =
     ( if   proc(PredId, ProcId) = PPId
       then add_recursive_call(Call - GoalInfo, IGCs)
-      else igcs_handle_non_recursive_call(Call - GoalInfo, IGCs)
+      else invariant_goal_candidates_handle_non_recursive_call(Call - GoalInfo,
+                IGCs)
     ).
 
-igcs(_PPId, Call @ generic_call(_, _, _, _)             - GoalInfo,  IGCs) =
-    igcs_handle_non_recursive_call(Call - GoalInfo, IGCs).
+invariant_goal_candidates_2(_PPId,
+        Call @ generic_call(_, _, _, _)             - GoalInfo,  IGCs) =
+    invariant_goal_candidates_handle_non_recursive_call(Call - GoalInfo,
+        IGCs).
+
+invariant_goal_candidates_2(_PPId,
+        Unification @ unify(_, _, _, _, _)          - GoalInfo,  IGCs) =
+    invariant_goal_candidates_handle_non_recursive_call(Unification - GoalInfo,
+        IGCs).
+
+invariant_goal_candidates_2(_PPId,
+        ForeignProc @ foreign_proc(_,_,_,_,_,_,_)   - GoalInfo,  IGCs) =
+    invariant_goal_candidates_handle_non_recursive_call(ForeignProc - GoalInfo,
+        IGCs).
+
+invariant_goal_candidates_2(PPId,
+        conj(Conjuncts)                              - _GoalInfo, IGCs) =
+    list__foldl(invariant_goal_candidates_2(PPId),
+                Conjuncts,
+                IGCs).
+
+invariant_goal_candidates_2(PPId,
+        par_conj(ParConjuncts)                       - _GoalInfo, IGCs) =
+    list__foldl(invariant_goal_candidates_keeping_path_candidates(PPId),
+                ParConjuncts,
+                IGCs).
+
+invariant_goal_candidates_2(PPId,
+        disj(Disjuncts)                              - _GoalInfo, IGCs) =
+    list__foldl(invariant_goal_candidates_keeping_path_candidates(PPId),
+                Disjuncts,
+                IGCs).
+
+invariant_goal_candidates_2(PPId,
+        switch(_, _, Cases)                          - _GoalInfo, IGCs) =
+    list__foldl(invariant_goal_candidates_keeping_path_candidates(PPId),
+                case_goals(Cases),
+                IGCs).
+
+invariant_goal_candidates_2(PPId,
+        not(NegatedGoal)                             - _GoalInfo, IGCs) =
+    invariant_goal_candidates_keeping_path_candidates(PPId, NegatedGoal, IGCs).
+
+invariant_goal_candidates_2(PPId,
+        some(_, _, QuantifiedGoal)                   - _GoalInfo, IGCs) =
+    invariant_goal_candidates_2(PPId, QuantifiedGoal, IGCs).
 
-igcs(_PPId, Unification @ unify(_, _, _, _, _)          - GoalInfo,  IGCs) =
-    igcs_handle_non_recursive_call(Unification - GoalInfo, IGCs).
-
-igcs(_PPId, ForeignProc @ foreign_proc(_,_,_,_,_,_,_)   - GoalInfo,  IGCs) =
-    igcs_handle_non_recursive_call(ForeignProc - GoalInfo, IGCs).
-
-igcs(PPId, conj(Conjuncts)                              - _GoalInfo, IGCs) =
-    list__foldl(igcs(PPId), Conjuncts, IGCs).
-
-igcs(PPId, par_conj(ParConjuncts)                       - _GoalInfo, IGCs) =
-    list__foldl(igcs_keeping_path_candidates(PPId), ParConjuncts, IGCs).
-
-igcs(PPId, disj(Disjuncts)                              - _GoalInfo, IGCs) =
-    list__foldl(igcs_keeping_path_candidates(PPId), Disjuncts, IGCs).
-
-igcs(PPId, switch(_, _, Cases)                          - _GoalInfo, IGCs) =
-    list__foldl(igcs_keeping_path_candidates(PPId), case_goals(Cases), IGCs).
-
-igcs(PPId, not(NegatedGoal)                             - _GoalInfo, IGCs) =
-    igcs_keeping_path_candidates(PPId, NegatedGoal, IGCs).
-
-igcs(PPId, some(_, _, QuantifiedGoal)                   - _GoalInfo, IGCs) =
-    igcs(PPId, QuantifiedGoal, IGCs).
-
-igcs(PPId, if_then_else(_XVs, Cond, Then, Else)         - GoalInfo,  IGCs0) =
-    IGCs
+invariant_goal_candidates_2(PPId,
+        if_then_else(_XVs, Cond, Then, Else)         - GoalInfo,  IGCs0) = IGCs
  :-
     CondThenGoal = conj([Cond, Then]) - GoalInfo,
-    IGCs1        = igcs_keeping_path_candidates(PPId, CondThenGoal, IGCs0),
+    IGCs1        = invariant_goal_candidates_keeping_path_candidates(PPId,
+                        CondThenGoal, IGCs0),
     ElseGoal     = Else,
-    IGCs         = igcs_keeping_path_candidates(PPId, ElseGoal,     IGCs1).
+    IGCs         = invariant_goal_candidates_keeping_path_candidates(PPId,
+                        ElseGoal,     IGCs1).
 
-igcs(_PPId, shorthand(_) - _GoalInfo, _IGCs) = _ :-
-    unexpected(this_file, "igcs/3: shorthand/1 in hlds_goal").
+invariant_goal_candidates_2(_PPId,
+        shorthand(_)                                 - _GoalInfo, _IGCs) = _ :-
+    unexpected(this_file,
+        "invariant_goal_candidates_2/3: shorthand/1 in hlds_goal").
 
 %------------------------------------------------------------------------------%
 
-:- func igcs_keeping_path_candidates(pred_proc_id, hlds_goal, igcs_acc) =
-            igcs_acc.
+:- func invariant_goal_candidates_keeping_path_candidates(pred_proc_id,
+            hlds_goal, invariant_goal_candidates_acc
+        ) = invariant_goal_candidates_acc.
 
-igcs_keeping_path_candidates(PPId, Goal, IGCs) =
-    igcs(PPId, Goal, IGCs) ^ path_candidates := IGCs ^ path_candidates.
+invariant_goal_candidates_keeping_path_candidates(PPId, Goal, IGCs) =
+    ( invariant_goal_candidates_2(PPId, Goal, IGCs) ^ path_candidates :=
+        IGCs ^ path_candidates ).
 
 %------------------------------------------------------------------------------%
 
@@ -364,7 +396,8 @@
 
 %------------------------------------------------------------------------------%
 
-:- func add_recursive_call(hlds_goal, igcs_acc) = igcs_acc.
+:- func add_recursive_call(hlds_goal, invariant_goal_candidates_acc) =
+            invariant_goal_candidates_acc.
 
     % We have to reverse the path_candidates because they are
     % accumulated in reverse order, whereas we need them in
@@ -380,9 +413,12 @@
     % impure goals, but that's a very low-level optimization that
     % is not entirely trivial to implement.
     %
-:- func igcs_handle_non_recursive_call(hlds_goal, igcs_acc) = igcs_acc.
+:- func invariant_goal_candidates_handle_non_recursive_call(
+            hlds_goal, invariant_goal_candidates_acc
+        ) = invariant_goal_candidates_acc.
 
-igcs_handle_non_recursive_call(Goal @ (_GoalExpr - GoalInfo), IGCs) =
+invariant_goal_candidates_handle_non_recursive_call(
+        Goal @ (_GoalExpr - GoalInfo), IGCs) =
     ( if   not model_non(GoalInfo),
            not ( goal_info_has_feature(GoalInfo, (impure) )
                ; goal_info_has_feature(GoalInfo, (semipure) )
@@ -469,17 +505,20 @@
 
 refine_candidate_inv_args(RecCall - _RecCallInfo, MaybeInvArgs) =
     ( if   RecCall = call(_, _, CallArgs, _, _, _)
-      then list__map_corresponding(rcias, MaybeInvArgs, CallArgs)
+      then list__map_corresponding(refine_candidate_inv_args_2,
+                                   MaybeInvArgs,
+                                   CallArgs)
       else func_error("refine_candidate_inv_args/2: non call/6 \
 found in argument 1")
     ).
 
 
 
-:- func rcias(maybe(prog_var), prog_var) = maybe(prog_var).
+:- func refine_candidate_inv_args_2(maybe(prog_var), prog_var) =
+            maybe(prog_var).
 
-rcias(no,     _) = no.
-rcias(yes(X), Y) = ( if X = Y then yes(X) else no ).
+refine_candidate_inv_args_2(no,     _) = no.
+refine_candidate_inv_args_2(yes(X), Y) = ( if X = Y then yes(X) else no ).
 
 %------------------------------------------------------------------------------%
 
@@ -501,7 +540,7 @@
 inv_goals_vars(ModuleInfo, UniquelyUsedVars,
         InvGoals0, InvGoals, InvVars0, InvVars) :-
     list__foldl2(
-        igvs(ModuleInfo, UniquelyUsedVars),
+        inv_goals_vars_2(ModuleInfo, UniquelyUsedVars),
         InvGoals0,
         [],         InvGoals,
         InvVars0,   InvVars
@@ -509,11 +548,11 @@
 
 %------------------------------------------------------------------------------%
 
-:- pred igvs(module_info, prog_vars, hlds_goal, hlds_goals, hlds_goals,
-            prog_vars, prog_vars).
-:- mode igvs(in, in, in, in, out, in, out) is det.
+:- pred inv_goals_vars_2(module_info, prog_vars, hlds_goal,
+            hlds_goals, hlds_goals, prog_vars, prog_vars).
+:- mode inv_goals_vars_2(in, in, in, in, out, in, out) is det.
 
-igvs(MI, UUVs, Goal, IGs0, IGs, IVs0, IVs) :-
+inv_goals_vars_2(MI, UUVs, Goal, IGs0, IGs, IVs0, IVs) :-
     ( if
         not invariant_goal(IGs0, Goal),
         input_args_are_invariant(MI, Goal, IVs0)
@@ -769,8 +808,8 @@
 
 %------------------------------------------------------------------------------%
 
-:- type gap_info
-    --->    gap_info(
+:- type gen_aux_proc_info
+    --->    gen_aux_proc_info(
                 module_info             :: module_info,
                 inv_goals               :: hlds_goals,
                 pred_proc_id            :: pred_proc_id,
@@ -796,8 +835,8 @@
 
         % Compute the aux proc body.
         %
-    GapInfo = gap_info(ModuleInfo0, InvGoals, PredProcId, CallAux),
-    AuxBody = gap(GapInfo, Body),
+    GapInfo = gen_aux_proc_info(ModuleInfo0, InvGoals, PredProcId, CallAux),
+    AuxBody = gen_aux_proc_2(GapInfo, Body),
 
         % Put the new proc body and instmap into the module_info.
         %
@@ -821,74 +860,77 @@
 
 %------------------------------------------------------------------------------%
 
-:- func gap(gap_info, hlds_goal) = hlds_goal.
+:- func gen_aux_proc_2(gen_aux_proc_info, hlds_goal) = hlds_goal.
 
-gap(Info, Call @ call(PredId, ProcId, _,_,_,_)    - GoalInfo) =
-    ( if proc(PredId, ProcId) = Info ^ pred_proc_id then
-        gen_aux_call(Info ^ call_aux_goal, Call - GoalInfo)
-      else
-        gap_handle_non_recursive_call(Info, Call - GoalInfo)
+gen_aux_proc_2(Info, Call @ call(PredId, ProcId, _,_,_,_)    - GoalInfo) =
+    ( if   proc(PredId, ProcId) = Info ^ pred_proc_id
+      then gen_aux_call(Info ^ call_aux_goal, Call - GoalInfo)
+      else gen_aux_proc_handle_non_recursive_call(Info, Call - GoalInfo)
     ).
 
-gap(Info, Call @ generic_call(_, _, _, _) - GoalInfo) =
-    gap_handle_non_recursive_call(Info, Call - GoalInfo).
+gen_aux_proc_2(Info, Call @ generic_call(_, _, _, _) - GoalInfo) =
+    gen_aux_proc_handle_non_recursive_call(Info, Call - GoalInfo).
 
-gap(Info, Unification @ unify(_, _, _, _, _) - GoalInfo) =
-    gap_handle_non_recursive_call(Info, Unification - GoalInfo).
+gen_aux_proc_2(Info, Unification @ unify(_, _, _, _, _) - GoalInfo) =
+    gen_aux_proc_handle_non_recursive_call(Info, Unification - GoalInfo).
 
-gap(Info, ForeignProc @ foreign_proc(_, _, _, _, _, _, _) - GoalInfo) =
-    gap_handle_non_recursive_call(Info, ForeignProc - GoalInfo).
+gen_aux_proc_2(Info, ForeignProc @ foreign_proc(_, _, _, _, _, _, _) -
+        GoalInfo) =
+    gen_aux_proc_handle_non_recursive_call(Info, ForeignProc - GoalInfo).
 
-gap(Info, conj(Conjuncts) - GoalInfo) =
-    conj(gap_list(Info, Conjuncts)) - GoalInfo.
+gen_aux_proc_2(Info, conj(Conjuncts) - GoalInfo) =
+    conj(gen_aux_proc_list(Info, Conjuncts)) - GoalInfo.
 
-gap(Info, par_conj(Conjs) - GoalInfo) =
-    par_conj(gap_list(Info, Conjs)) - GoalInfo.
+gen_aux_proc_2(Info, par_conj(Conjs) - GoalInfo) =
+    par_conj(gen_aux_proc_list(Info, Conjs)) - GoalInfo.
 
-gap(Info, disj(Disjuncts) - GoalInfo) =
-    disj(gap_list(Info, Disjuncts)) - GoalInfo.
+gen_aux_proc_2(Info, disj(Disjuncts) - GoalInfo) =
+    disj(gen_aux_proc_list(Info, Disjuncts)) - GoalInfo.
 
-gap(Info, switch(Var, CanFail, Cases) - GoalInfo) =
-    switch(Var, CanFail, gap_switch(Info, Cases)) - GoalInfo.
+gen_aux_proc_2(Info, switch(Var, CanFail, Cases) - GoalInfo) =
+    switch(Var, CanFail, gen_aux_proc_switch(Info, Cases)) - GoalInfo.
 
-gap(Info, not(NegatedGoal) - GoalInfo) =
-    not(gap(Info, NegatedGoal)) - GoalInfo.
+gen_aux_proc_2(Info, not(NegatedGoal) - GoalInfo) =
+    not(gen_aux_proc_2(Info, NegatedGoal)) - GoalInfo.
 
-gap(Info, some(XVars, CanRemove, QuantifiedGoal) - GoalInfo) =
-    some(XVars, CanRemove, gap(Info, QuantifiedGoal)) - GoalInfo.
+gen_aux_proc_2(Info, some(XVars, CanRemove, QuantifiedGoal) - GoalInfo) =
+    some(XVars, CanRemove, gen_aux_proc_2(Info, QuantifiedGoal)) - GoalInfo.
 
-gap(Info, if_then_else(XVars, Cond, Then, Else) - GoalInfo) =
-    if_then_else(XVars, gap(Info, Cond), gap(Info, Then), gap(Info, Else)) -
-        GoalInfo.
+gen_aux_proc_2(Info, if_then_else(XVars, Cond, Then, Else) - GoalInfo) =
+    if_then_else(XVars,
+                 gen_aux_proc_2(Info, Cond),
+                 gen_aux_proc_2(Info, Then),
+                 gen_aux_proc_2(Info, Else)
+    ) - GoalInfo.
 
-gap(_Info, shorthand(_) - _GoalInfo) = _ :-
-    unexpected(this_file, "gap/2: shorthand/1 in hlds_goal").
+gen_aux_proc_2(_Info, shorthand(_) - _GoalInfo) = _ :-
+    unexpected(this_file, "gen_aux_proc_2/2: shorthand/1 in hlds_goal").
 
 %------------------------------------------------------------------------------%
 
-:- func gap_list(gap_info, hlds_goals) = hlds_goals.
+:- func gen_aux_proc_list(gen_aux_proc_info, hlds_goals) = hlds_goals.
 
-gap_list(Info, Goals) = list__map(gap(Info), Goals).
+gen_aux_proc_list(Info, Goals) = list__map(gen_aux_proc_2(Info), Goals).
 
 %------------------------------------------------------------------------------%
 
-:- func gap_switch(gap_info, list(case)) = list(case).
+:- func gen_aux_proc_switch(gen_aux_proc_info, list(case)) = list(case).
 
-gap_switch(Info, Cases) =
+gen_aux_proc_switch(Info, Cases) =
     list__map(
-        func(case(CaseId, Goal)) = case(CaseId, gap(Info, Goal)),
+        func(case(CaseId, Goal)) = case(CaseId, gen_aux_proc_2(Info, Goal)),
         Cases
     ).
 
 %------------------------------------------------------------------------------%
 
-:- func gap_handle_non_recursive_call(gap_info, hlds_goal) = hlds_goal.
+:- func gen_aux_proc_handle_non_recursive_call(gen_aux_proc_info, hlds_goal) =
+            hlds_goal.
 
-gap_handle_non_recursive_call(Info, Goal0) = Goal :-
-    ( if invariant_goal(Info ^ inv_goals, Goal0) then
-        true_goal(Goal)
-      else
-        Goal = Goal0
+gen_aux_proc_handle_non_recursive_call(Info, Goal0) = Goal :-
+    ( if   invariant_goal(Info ^ inv_goals, Goal0)
+      then true_goal(Goal)
+      else Goal = Goal0
     ).
 
 %------------------------------------------------------------------------------%
@@ -907,7 +949,7 @@
 
         % Compute the new procedure body.
         %
-    Body = gop(PredProcId, CallAux, Body0),
+    Body = gen_out_proc_2(PredProcId, CallAux, Body0),
 
         % Put the new procedure body into the module_info.
         %
@@ -931,57 +973,71 @@
 
 %------------------------------------------------------------------------------%
 
-    % gop(PredProcId, CallAux, Goal0) = Goal:
+    % gen_out_proc_2(PredProcId, CallAux, Goal0) = Goal:
     %   Goal is Goal0 with calls to PredProcId replaced with CallAux.
     %
-:- func gop(pred_proc_id, hlds_goal, hlds_goal) = hlds_goal.
+:- func gen_out_proc_2(pred_proc_id, hlds_goal, hlds_goal) = hlds_goal.
 
-gop(PPId, CallAux, Call @ call(PredId, ProcId, _, _, _, _)        - GoalInfo) =
+gen_out_proc_2(PPId, CallAux,
+        Call @ call(PredId, ProcId, _, _, _, _)        - GoalInfo) =
     ( if   proc(PredId, ProcId) = PPId
       then gen_aux_call(CallAux, Call - GoalInfo)
       else Call - GoalInfo
     ).
 
-gop(_PPId, _CallAux, Call @ generic_call(_, _, _, _)              - GoalInfo) =
+gen_out_proc_2(_PPId, _CallAux,
+        Call @ generic_call(_, _, _, _)              - GoalInfo) =
     Call - GoalInfo.
 
-gop(_PPId, _CallAux, Unification @ unify(_, _, _, _, _)           - GoalInfo) =
+gen_out_proc_2(_PPId, _CallAux,
+        Unification @ unify(_, _, _, _, _)           - GoalInfo) =
     Unification - GoalInfo.
 
-gop(_PPId, _CallAux, ForeignProc @ foreign_proc(_,_,_,_,_,_,_)    - GoalInfo) =
+gen_out_proc_2(_PPId, _CallAux,
+        ForeignProc @ foreign_proc(_,_,_,_,_,_,_)    - GoalInfo) =
     ForeignProc - GoalInfo.
 
-gop(PPId, CallAux, conj(Conjuncts)                                - GoalInfo) =
-    conj(list__map(gop(PPId, CallAux), Conjuncts)) - GoalInfo.
+gen_out_proc_2(PPId, CallAux,
+        conj(Conjuncts)                                - GoalInfo) =
+    conj(list__map(gen_out_proc_2(PPId, CallAux), Conjuncts)) - GoalInfo.
+
+gen_out_proc_2(PPId, CallAux,
+        par_conj(ParConjuncts)                         - GoalInfo) =
+    par_conj(list__map(gen_out_proc_2(PPId, CallAux), ParConjuncts)) - GoalInfo.
+
+gen_out_proc_2(PPId, CallAux,
+        disj(Disjuncts)                                - GoalInfo) =
+    disj(list__map(gen_out_proc_2(PPId, CallAux), Disjuncts)) - GoalInfo.
 
-gop(PPId, CallAux, par_conj(ParConjuncts)                         - GoalInfo) =
-    par_conj(list__map(gop(PPId, CallAux), ParConjuncts)) - GoalInfo.
-
-gop(PPId, CallAux, disj(Disjuncts)                                - GoalInfo) =
-    disj(list__map(gop(PPId, CallAux), Disjuncts)) - GoalInfo.
-
-gop(PPId, CallAux, switch(Var, CanFail, Cases)                    - GoalInfo) =
+gen_out_proc_2(PPId, CallAux,
+        switch(Var, CanFail, Cases)                    - GoalInfo) =
     switch(Var, CanFail, list__map(GOPCase, Cases)) - GoalInfo
  :-
     GOPCase =
-        ( func(case(ConsId, Goal)) = case(ConsId, gop(PPId, CallAux, Goal)) ).
-
-gop(PPId, CallAux, not(NegatedGoal)                               - GoalInfo) =
-    not(gop(PPId, CallAux, NegatedGoal)) - GoalInfo.
+        ( func(case(ConsId, Goal)) =
+                case(ConsId, gen_out_proc_2(PPId, CallAux, Goal)) ).
 
-gop(PPId, CallAux, some(XVars, CanRemove, QuantifiedGoal)         - GoalInfo) =
-    some(XVars, CanRemove, gop(PPId, CallAux, QuantifiedGoal)) - GoalInfo.
+gen_out_proc_2(PPId, CallAux,
+        not(NegatedGoal)                               - GoalInfo) =
+    not(gen_out_proc_2(PPId, CallAux, NegatedGoal)) - GoalInfo.
+
+gen_out_proc_2(PPId, CallAux,
+        some(XVars, CanRemove, QuantifiedGoal)         - GoalInfo) =
+    some(XVars, CanRemove, gen_out_proc_2(PPId, CallAux, QuantifiedGoal)) -
+            GoalInfo.
 
-gop(PPId, CallAux, if_then_else(XVars, Cond, Then, Else)          - GoalInfo) =
+gen_out_proc_2(PPId, CallAux,
+        if_then_else(XVars, Cond, Then, Else)          - GoalInfo) =
     if_then_else(
         XVars,
-        gop(PPId, CallAux, Cond),
-        gop(PPId, CallAux, Then),
-        gop(PPId, CallAux, Else)
+        gen_out_proc_2(PPId, CallAux, Cond),
+        gen_out_proc_2(PPId, CallAux, Then),
+        gen_out_proc_2(PPId, CallAux, Else)
     ) - GoalInfo.
 
-gop(_PPId, _CallAux, shorthand(_) - _GoalInfo) = _ :-
-    unexpected(this_file, "gop/3: shorthand/1 in hlds_goal").
+gen_out_proc_2(_PPId, _CallAux,
+        shorthand(_)                                   - _GoalInfo) = _ :-
+    unexpected(this_file, "gen_out_proc_2/3: shorthand/1 in hlds_goal").
 
 %------------------------------------------------------------------------------%
 
@@ -1030,54 +1086,62 @@
 :- func uniquely_used_vars(module_info, hlds_goal) = prog_vars.
 
 uniquely_used_vars(ModuleInfo, Goal) =
-    list__sort_and_remove_dups(uuvs(ModuleInfo, Goal)).
+    list__sort_and_remove_dups(uniquely_used_vars_2(ModuleInfo, Goal)).
 
 %------------------------------------------------------------------------------%
 
-:- func uuvs(module_info, hlds_goal) = prog_vars.
+:- func uniquely_used_vars_2(module_info, hlds_goal) = prog_vars.
 
-uuvs(MI, call(PredId, ProcId, Args, _, _, _) - _) =
-    list__filter_map_corresponding(uuas(MI), Args, argmodes(MI,PredId,ProcId)).
+uniquely_used_vars_2(MI, call(PredId, ProcId, Args, _, _, _) - _) =
+    list__filter_map_corresponding(uniquely_used_args(MI),
+                                   Args,
+                                   argmodes(MI,PredId,ProcId)).
 
-uuvs(MI, generic_call(_, Args, Modes, _) - _) =
-    list__filter_map_corresponding(uuas(MI), Args, Modes).
+uniquely_used_vars_2(MI, generic_call(_, Args, Modes, _) - _) =
+    list__filter_map_corresponding(uniquely_used_args(MI),
+                                   Args,
+                                   Modes).
 
-uuvs(MI, foreign_proc(_, PredId, ProcId, Args, _, _, _) - _) =
-    list__filter_map_corresponding(uuas(MI), Args, argmodes(MI,PredId,ProcId)).
+uniquely_used_vars_2(MI, foreign_proc(_, PredId, ProcId, Args, _, _, _) - _) =
+    list__filter_map_corresponding(uniquely_used_args(MI),
+                                   Args,
+                                   argmodes(MI,PredId,ProcId)).
 
     % XXX This is very conservative!
     %
-uuvs(_MI, unify(_LHS, _RHS, _UMode, _UKind, _) - _) = [].
+uniquely_used_vars_2(_MI, unify(_LHS, _RHS, _UMode, _UKind, _) - _) = [].
 
-uuvs(MI, conj(Conjuncts) - _) =
-    list__condense(list__map(uuvs(MI), Conjuncts)).
+uniquely_used_vars_2(MI, conj(Conjuncts) - _) =
+    list__condense(list__map(uniquely_used_vars_2(MI), Conjuncts)).
 
-uuvs(MI, par_conj(ParConjuncts) - _) =
-    list__condense(list__map(uuvs(MI), ParConjuncts)).
+uniquely_used_vars_2(MI, par_conj(ParConjuncts) - _) =
+    list__condense(list__map(uniquely_used_vars_2(MI), ParConjuncts)).
 
-uuvs(MI, disj(Disjuncts) - _) =
-    list__condense(list__map(uuvs(MI), Disjuncts)).
+uniquely_used_vars_2(MI, disj(Disjuncts) - _) =
+    list__condense(list__map(uniquely_used_vars_2(MI), Disjuncts)).
 
-uuvs(MI, switch(_, _, Cases) - _) =
-    list__condense(list__map(uuvs(MI), case_goals(Cases))).
+uniquely_used_vars_2(MI, switch(_, _, Cases) - _) =
+    list__condense(list__map(uniquely_used_vars_2(MI), case_goals(Cases))).
 
-uuvs(MI, not(NegatedGoal) - _) =
-    uuvs(MI, NegatedGoal).
+uniquely_used_vars_2(MI, not(NegatedGoal) - _) =
+    uniquely_used_vars_2(MI, NegatedGoal).
 
-uuvs(MI, some(_, _, QuantifiedGoal) - _) =
-    uuvs(MI, QuantifiedGoal).
+uniquely_used_vars_2(MI, some(_, _, QuantifiedGoal) - _) =
+    uniquely_used_vars_2(MI, QuantifiedGoal).
 
-uuvs(MI, if_then_else(_, Cond, Then, Else) - _) =
-    uuvs(MI, Cond) ++ uuvs(MI, Then) ++ uuvs(MI, Else).
+uniquely_used_vars_2(MI, if_then_else(_, Cond, Then, Else) - _) =
+    uniquely_used_vars_2(MI, Cond) ++
+        uniquely_used_vars_2(MI, Then) ++
+            uniquely_used_vars_2(MI, Else).
 
-uuvs(_MI, shorthand(_) - _) = _ :-
-    unexpected(this_file, "uuvs/3: shorthand/1 in hlds_goal").
+uniquely_used_vars_2(_MI, shorthand(_) - _) = _ :-
+    unexpected(this_file, "uniquely_used_vars_2/3: shorthand/1 in hlds_goal").
 
 %------------------------------------------------------------------------------%
 
-:- func uuas(module_info, prog_var, mode) = prog_var is semidet.
+:- func uniquely_used_args(module_info, prog_var, mode) = prog_var is semidet.
 
-uuas(MI, X, M) = X :-
+uniquely_used_args(MI, X, M) = X :-
     mode_util__mode_get_insts(MI, M, InInst, _OutInst),
     not inst_match__inst_is_not_partly_unique(MI, InInst).
 
--------------------------------------------------------------------------
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