[m-dev.] diff: apply saved_vars to Aditi procs
Simon Taylor
stayl at cs.mu.OZ.AU
Wed Aug 25 15:55:59 AEST 1999
Estimated hours taken: 0.5
compiler/magic.m:
Run saved_vars on Aditi procedures to reduce the occurrence
of intermediate relations with constant attributes.
compiler/saved_vars.m:
Add a version of saved_vars_proc which does not require an
io__state (the io__state is used only for progress messages).
Index: magic.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/magic.m,v
retrieving revision 1.8
diff -u -u -r1.8 magic.m
--- magic.m 1999/07/16 05:58:23 1.8
+++ magic.m 1999/08/05 06:12:24
@@ -169,7 +169,7 @@
:- import_module dependency_graph, hlds_pred, hlds_goal, hlds_data, prog_data.
:- import_module passes_aux, mode_util, (inst), instmap, rl_gen, rl.
:- import_module globals, options, hlds_out, prog_out, goal_util, type_util.
-:- import_module polymorphism, quantification.
+:- import_module polymorphism, quantification, saved_vars.
:- import_module int, list, map, require, set, std_util, string, term, varset.
:- import_module assoc_list, bool, simplify.
@@ -1385,18 +1385,27 @@
{ simplify__proc_2(Simplifications, PredId, ProcId,
ModuleInfo2, ModuleInfo3, ProcInfo3, ProcInfo4, _) },
- { proc_info_goal(ProcInfo4, Goal2) },
+ %
+ % Run saved_vars so that constructions of constants are close
+ % to their uses, and constant attributes aren't unnecessarily
+ % added to relations. We should be more aggressive about this -
+ % constructions of constant compound terms should also be pushed.
+ %
+ { saved_vars_proc_no_io(PredId, ProcId, ProcInfo4, ProcInfo5,
+ ModuleInfo3, ModuleInfo4) },
+
+ { proc_info_goal(ProcInfo5, Goal2) },
magic_info_set_curr_pred_proc_id(PredProcId),
magic_info_set_pred_info(PredInfo),
- magic_info_set_proc_info(ProcInfo4),
- magic_info_set_module_info(ModuleInfo3),
+ magic_info_set_proc_info(ProcInfo5),
+ magic_info_set_module_info(ModuleInfo4),
{ Goal2 = _ - GoalInfo2 },
{ goal_to_disj_list(Goal2, GoalList2) },
list__map_foldl(magic__preprocess_disjunct,
GoalList2, GoalList),
{ disj_list_to_goal(GoalList, GoalInfo2, Goal) },
- magic_info_get_proc_info(ProcInfo5),
- { proc_info_set_goal(ProcInfo5, Goal, ProcInfo) }.
+ magic_info_get_proc_info(ProcInfo6),
+ { proc_info_set_goal(ProcInfo6, Goal, ProcInfo) }.
% Undo common structure elimination of higher-order terms in an
% attempt to avoid creating procedures with higher-order arguments
Index: saved_vars.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/saved_vars.m,v
retrieving revision 1.19
diff -u -u -r1.19 saved_vars.m
--- saved_vars.m 1999/07/13 08:53:30 1.19
+++ saved_vars.m 1999/08/05 06:05:36
@@ -32,6 +32,10 @@
module_info, module_info, io__state, io__state).
:- mode saved_vars_proc(in, in, in, out, in, out, di, uo) is det.
+:- pred saved_vars_proc_no_io(pred_id, proc_id, proc_info, proc_info,
+ module_info, module_info).
+:- mode saved_vars_proc_no_io(in, in, in, out, in, out) is det.
+
%-----------------------------------------------------------------------------%
:- implementation.
@@ -46,30 +50,35 @@
ModuleInfo0, ModuleInfo) -->
write_proc_progress_message("% Minimizing saved vars in ",
PredId, ProcId, ModuleInfo0),
- { proc_info_goal(ProcInfo0, Goal0) },
- { proc_info_varset(ProcInfo0, Varset0) },
- { proc_info_vartypes(ProcInfo0, VarTypes0) },
- { init_slot_info(Varset0, VarTypes0, SlotInfo0) },
+ { saved_vars_proc_no_io(PredId, ProcId, ProcInfo0, ProcInfo,
+ ModuleInfo0, ModuleInfo) }.
+
+saved_vars_proc_no_io(_PredId, _ProcId, ProcInfo0, ProcInfo,
+ ModuleInfo0, ModuleInfo) :-
+ proc_info_goal(ProcInfo0, Goal0),
+ proc_info_varset(ProcInfo0, Varset0),
+ proc_info_vartypes(ProcInfo0, VarTypes0),
+ init_slot_info(Varset0, VarTypes0, SlotInfo0),
- { saved_vars_in_goal(Goal0, SlotInfo0, Goal1, SlotInfo) },
+ saved_vars_in_goal(Goal0, SlotInfo0, Goal1, SlotInfo),
- { final_slot_info(Varset1, VarTypes1, SlotInfo) },
- { proc_info_headvars(ProcInfo0, HeadVars) },
+ final_slot_info(Varset1, VarTypes1, SlotInfo),
+ proc_info_headvars(ProcInfo0, HeadVars),
% hlds_out__write_goal(Goal1, ModuleInfo, Varset1, 0, "\n"),
% recompute the nonlocals for each goal
- { implicitly_quantify_clause_body(HeadVars, Goal1, Varset1,
- VarTypes1, Goal2, Varset, VarTypes, _Warnings) },
- { proc_info_get_initial_instmap(ProcInfo0, ModuleInfo0, InstMap0) },
- { recompute_instmap_delta(no, Goal2, Goal, InstMap0,
- ModuleInfo0, ModuleInfo) },
+ implicitly_quantify_clause_body(HeadVars, Goal1, Varset1,
+ VarTypes1, Goal2, Varset, VarTypes, _Warnings),
+ proc_info_get_initial_instmap(ProcInfo0, ModuleInfo0, InstMap0),
+ recompute_instmap_delta(no, Goal2, Goal, InstMap0,
+ ModuleInfo0, ModuleInfo),
% hlds_out__write_goal(Goal, ModuleInfo, Varset, 0, "\n"),
- { proc_info_set_goal(ProcInfo0, Goal, ProcInfo1) },
- { proc_info_set_varset(ProcInfo1, Varset, ProcInfo2) },
- { proc_info_set_vartypes(ProcInfo2, VarTypes, ProcInfo) }.
+ proc_info_set_goal(ProcInfo0, Goal, ProcInfo1),
+ proc_info_set_varset(ProcInfo1, Varset, ProcInfo2),
+ proc_info_set_vartypes(ProcInfo2, VarTypes, ProcInfo).
%-----------------------------------------------------------------------------%
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list