[m-dev.] for review: clip instmap deltas to typeinfo completed nonlocals
Zoltan Somogyi
zs at cs.mu.OZ.AU
Sun Jul 30 08:35:45 AEST 2000
For review by anyone.
If we are using typeinfo liveness, then clip the instmap delta fields in
goal_infos not to the nonlocals, but to the nonlocals plus the
type info or typeclass info variables needed to describe the types of the
nonlocals (this set is now called the "typeinfo completed nonlocals").
This is necessary for the proper handling of code such as resume_typeinfos.m
in tests/debugger. This involves a call to a procedure with an existentially
typed argument, where the returned argument is processed only in ways that do
not need the typeinfo describing it. The typeinfo therefore used to be local
to the call binding it. Its binding was therefore not recorded in the instmap
delta, which in turn meant that in the absence of a value-giving occurrence,
liveness.m considered it not to be born anywhere. On the other hand, with
typeinfo liveness, occurrences of the argument are also considered value-using
occurrences of the typeinfo, so the typeinfo was considered to die at the last
such occurrence. Therefore the typeinfo died without being born. The current
code generator is sloppy enough not to mind this, but the upcoming eager code
generator isn't.
compiler/hlds_goal.m:
Document the new semantics of instmap_deltas.
compiler/quantification.m:
compiler/mode_util.m:
compiler/modes.m:
compiler/unique_modes.m:
If typeinfo liveness is set, include the relevant typeinfo variables
in the set of variables the instmap is limited to.
compiler/modes.m:
Delete some unused predicates.
compiler/hlds_pred.m:
Centralize the code for (maybe) completing a set of vars with the set
of typeinfo vars describing their types here.
compiler/call_gen.m:
compiler/live_vars.m:
Use the central code in hlds_pred.m.
compiler/accumulator.m:
compiler/cse_detection.m:
compiler/follow_code.m:
compiler/higher_order.m:
compiler/lambda.m:
compiler/liveness.m:
compiler/magic.m:
compiler/make_hlds.m:
compiler/mode_info.m:
compiler/pd_util.m:
compiler/polymorphism.m:
compiler/simplify.m:
compiler/unify_proc.m:
compiler/unneeded_code.m:
compiler/unused_args.m:
Call quantification and/or mode_util with the right arguments.
In some cases, introduce field names, predmode declarations and/or
shorter type names to make this change easier.
Zoltan.
cvs diff: Diffing .
cvs diff: Diffing bindist
cvs diff: Diffing boehm_gc
cvs diff: Diffing boehm_gc/Mac_files
cvs diff: Diffing boehm_gc/cord
cvs diff: Diffing boehm_gc/cord/private
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/accumulator.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/accumulator.m,v
retrieving revision 1.14
diff -u -b -r1.14 accumulator.m
--- compiler/accumulator.m 2000/07/27 09:00:56 1.14
+++ compiler/accumulator.m 2000/07/29 02:08:42
@@ -1554,7 +1554,9 @@
proc_info_set_varset(OrigProcInfo1, VarSet, OrigProcInfo2),
proc_info_set_vartypes(OrigProcInfo2, VarTypes, OrigProcInfo3),
- OrigProcInfo = requantify_procedure(OrigProcInfo3),
+ module_info_globals(ModuleInfo1, Globals),
+ body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness),
+ OrigProcInfo = requantify_procedure(TypeInfoLiveness, OrigProcInfo3),
update_accumulator_pred(AccPredId, AccProcId, AccGoal,
ModuleInfo1, ModuleInfo).
@@ -1961,26 +1963,19 @@
proc_info_set_goal(ProcInfo0, AccGoal, ProcInfo),
+ module_info_globals(ModuleInfo0, Globals),
+ body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness),
module_info_set_pred_proc_info(ModuleInfo0, NewPredId, NewProcId,
- PredInfo, requantify_procedure(ProcInfo), ModuleInfo).
+ PredInfo, requantify_procedure(TypeInfoLiveness, ProcInfo),
+ ModuleInfo).
%
% Recalculate the non-locals of a procedure.
%
-:- func requantify_procedure(proc_info) = proc_info.
+:- func requantify_procedure(bool, proc_info) = proc_info.
-requantify_procedure(ProcInfo0) = ProcInfo :-
- proc_info_headvars(ProcInfo0, HeadVars),
- proc_info_vartypes(ProcInfo0, VarTypes0),
- proc_info_varset(ProcInfo0, Varset0),
- proc_info_goal(ProcInfo0, Goal0),
-
- implicitly_quantify_clause_body(HeadVars, Goal0, Varset0,
- VarTypes0, Goal, Varset, VarTypes, _Warnings),
-
- proc_info_set_goal(ProcInfo0, Goal, ProcInfo1),
- proc_info_set_varset(ProcInfo1, Varset, ProcInfo2),
- proc_info_set_vartypes(ProcInfo2, VarTypes, ProcInfo).
+requantify_procedure(TypeInfoLiveness, ProcInfo0) = ProcInfo :-
+ requantify_proc(TypeInfoLiveness, ProcInfo0, ProcInfo).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
Index: compiler/call_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/call_gen.m,v
retrieving revision 1.140
diff -u -b -r1.140 call_gen.m
--- compiler/call_gen.m 2000/05/24 07:12:23 1.140
+++ compiler/call_gen.m 2000/07/28 09:39:37
@@ -585,16 +585,11 @@
{ set__list_to_set(Variables0, Vars0) },
code_info__get_globals(Globals),
{ body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness) },
- (
- { TypeInfoLiveness = yes }
- ->
code_info__get_proc_info(ProcInfo),
- { proc_info_get_typeinfo_vars_setwise(ProcInfo, Vars0,
- TypeInfoVars) },
- { set__union(Vars0, TypeInfoVars, Vars1) }
- ;
- { Vars1 = Vars0 }
- ),
+ { proc_info_vartypes(ProcInfo, VarTypes) },
+ { proc_info_typeinfo_varmap(ProcInfo, TVarMap) },
+ { proc_info_maybe_complete_with_typeinfo_vars(Vars0, TypeInfoLiveness,
+ VarTypes, TVarMap, Vars1) },
{ set__difference(Vars1, OutArgs, Vars) },
{ set__to_sorted_list(Vars, Variables) },
call_gen__save_variables_2(Variables, Code).
Index: compiler/cse_detection.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/cse_detection.m,v
retrieving revision 1.59
diff -u -b -r1.59 cse_detection.m
--- compiler/cse_detection.m 2000/01/13 06:15:15 1.59
+++ compiler/cse_detection.m 2000/07/29 02:12:57
@@ -152,9 +152,13 @@
% ModuleInfo should not be changed by detect_cse_in_goal
CseInfo = cse_info(Varset1, VarTypes1, _),
proc_info_headvars(ProcInfo0, HeadVars),
+ proc_info_typeinfo_varmap(ProcInfo0, TVarMap),
+ module_info_globals(ModuleInfo0, Globals),
+ body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness),
implicitly_quantify_clause_body(HeadVars, Goal1, Varset1,
- VarTypes1, Goal, Varset, VarTypes, _Warnings),
+ VarTypes1, TVarMap, TypeInfoLiveness,
+ Goal, Varset, VarTypes, _Warnings),
proc_info_set_goal(ProcInfo0, Goal, ProcInfo1),
proc_info_set_varset(ProcInfo1, Varset, ProcInfo2),
Index: compiler/deforest.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/deforest.m,v
retrieving revision 1.12
diff -u -b -r1.12 deforest.m
--- compiler/deforest.m 1999/10/25 03:48:42 1.12
+++ compiler/deforest.m 2000/07/29 02:16:48
@@ -117,13 +117,17 @@
( { Changed = yes } ->
pd_info_get_module_info(ModuleInfo2),
- { requantify_proc(ProcInfo2, ProcInfo3) },
+ { module_info_globals(ModuleInfo2, Globals0) },
+ { body_should_use_typeinfo_liveness(Globals0,
+ TypeInfoLiveness) },
+ { requantify_proc(TypeInfoLiveness, ProcInfo2, ProcInfo3) },
{ proc_info_goal(ProcInfo3, Goal3) },
{ proc_info_get_initial_instmap(ProcInfo3,
ModuleInfo2, InstMap0) },
{ proc_info_vartypes(ProcInfo3, VarTypes) },
- { recompute_instmap_delta(yes, Goal3, Goal,
- VarTypes, InstMap0, ModuleInfo2, ModuleInfo3) },
+ { proc_info_typeinfo_varmap(ProcInfo3, TVarMap) },
+ { recompute_instmap_delta(yes, Goal3, Goal, VarTypes,
+ TVarMap, InstMap0, ModuleInfo2, ModuleInfo3) },
pd_info_set_module_info(ModuleInfo3),
pd_info_get_pred_info(PredInfo),
Index: compiler/follow_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/follow_code.m,v
retrieving revision 1.54
diff -u -b -r1.54 follow_code.m
--- compiler/follow_code.m 1999/10/25 03:48:48 1.54
+++ compiler/follow_code.m 2000/07/29 02:19:59
@@ -1,5 +1,5 @@
%-----------------------------------------------------------------------------%
-% Copyright (C) 1994-1999 The University of Melbourne.
+% Copyright (C) 1994-2000 The University of Melbourne.
% This file may only be copied under the terms of the GNU General
% Public License - see the file COPYING in the Mercury distribution.
%-----------------------------------------------------------------------------%
@@ -53,12 +53,15 @@
% we need to fix up the goal_info by recalculating
% the nonlocal vars and the non-atomic instmap deltas.
proc_info_headvars(ProcInfo0, HeadVars),
+ proc_info_typeinfo_varmap(ProcInfo0, TVarMap),
+ body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness),
implicitly_quantify_clause_body(HeadVars, Goal1,
- Varset0, VarTypes0, Goal2, Varset, VarTypes, _Warnings),
+ Varset0, VarTypes0, TVarMap, TypeInfoLiveness,
+ Goal2, Varset, VarTypes, _Warnings),
proc_info_get_initial_instmap(ProcInfo0,
ModuleInfo0, InstMap0),
- recompute_instmap_delta(no, Goal2, Goal, VarTypes, InstMap0,
- ModuleInfo0, ModuleInfo)
+ recompute_instmap_delta(no, Goal2, Goal, VarTypes, TVarMap,
+ InstMap0, ModuleInfo0, ModuleInfo)
;
Goal = Goal0,
Varset = Varset0,
Index: compiler/higher_order.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/higher_order.m,v
retrieving revision 1.64
diff -u -b -r1.64 higher_order.m
--- compiler/higher_order.m 2000/04/11 07:56:56 1.64
+++ compiler/higher_order.m 2000/07/29 02:20:32
@@ -387,13 +387,16 @@
Info0 = info(A, B, C, D, E, ProcInfo0, ModuleInfo0, H, Changed),
( (Changed = changed ; MustRecompute = yes) ->
proc_info_set_goal(ProcInfo0, Goal0, ProcInfo1),
- requantify_proc(ProcInfo1, ProcInfo2),
+ module_info_globals(ModuleInfo0, Globals),
+ body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness),
+ requantify_proc(TypeInfoLiveness, ProcInfo1, ProcInfo2),
proc_info_goal(ProcInfo2, Goal2),
RecomputeAtomic = no,
proc_info_get_initial_instmap(ProcInfo2, ModuleInfo0, InstMap),
proc_info_vartypes(ProcInfo2, VarTypes),
+ proc_info_typeinfo_varmap(ProcInfo2, TVarMap),
recompute_instmap_delta(RecomputeAtomic, Goal2, Goal3,
- VarTypes, InstMap, ModuleInfo0, ModuleInfo),
+ VarTypes, TVarMap, InstMap, ModuleInfo0, ModuleInfo),
proc_info_set_goal(ProcInfo2, Goal3, ProcInfo),
Info = info(A, B, C, D, E, ProcInfo, ModuleInfo, H, Changed)
;
Index: compiler/hlds_goal.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_goal.m,v
retrieving revision 1.72
diff -u -b -r1.72 hlds_goal.m
--- compiler/hlds_goal.m 2000/07/25 09:27:20 1.72
+++ compiler/hlds_goal.m 2000/07/29 03:33:46
@@ -721,6 +721,13 @@
% unreachability, but both will be
% conservative approximations, so if either
% says a goal is unreachable then it is.
+ %
+ % Normally the instmap_delta will list only
+ % the nonlocal variables of the goal. However,
+ % with typeinfo liveness, it may also list
+ % typeinfo or typeclass info variables that
+ % describe (part of) the type of a nonlocal
+ % variable.
context :: prog_context,
Index: compiler/hlds_pred.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_pred.m,v
retrieving revision 1.77
diff -u -b -r1.77 hlds_pred.m
--- compiler/hlds_pred.m 2000/07/25 09:27:20 1.77
+++ compiler/hlds_pred.m 2000/07/28 09:44:09
@@ -1392,10 +1392,15 @@
% for accurate garbage collection - live variables need to have
% their typeinfos stay live too.
-:- pred proc_info_get_typeinfo_vars_setwise(proc_info, set(prog_var),
+:- pred proc_info_get_typeinfo_vars(set(prog_var), vartypes, type_info_varmap,
set(prog_var)).
-:- mode proc_info_get_typeinfo_vars_setwise(in, in, out) is det.
+:- mode proc_info_get_typeinfo_vars(in, in, in, out) is det.
+:- pred proc_info_maybe_complete_with_typeinfo_vars(set(prog_var), bool,
+ vartypes, type_info_varmap, set(prog_var)).
+:- mode proc_info_maybe_complete_with_typeinfo_vars(in, in, in, in, out)
+ is det.
+
:- pred proc_info_ensure_unique_names(proc_info, proc_info).
:- mode proc_info_ensure_unique_names(in, out) is det.
@@ -1681,35 +1686,32 @@
proc_info_set_address_taken(ProcInfo, AT, ProcInfo^is_address_taken := AT).
proc_info_set_rl_exprn_id(ProcInfo, ID, ProcInfo^maybe_aditi_rl_id := yes(ID)).
-proc_info_get_typeinfo_vars_setwise(ProcInfo, Vars, TypeInfoVars) :-
+proc_info_get_typeinfo_vars(Vars, VarTypes, TVarMap, TypeInfoVars) :-
set__to_sorted_list(Vars, VarList),
- proc_info_get_typeinfo_vars_2(ProcInfo, VarList, TypeInfoVarList),
+ proc_info_get_typeinfo_vars_2(VarList, VarTypes, TVarMap,
+ TypeInfoVarList),
set__list_to_set(TypeInfoVarList, TypeInfoVars).
% auxiliary predicate - traverses variables and builds a list of
% variables that store typeinfos for these variables.
-:- pred proc_info_get_typeinfo_vars_2(proc_info, list(prog_var),
- list(prog_var)).
-:- mode proc_info_get_typeinfo_vars_2(in, in, out) is det.
+:- pred proc_info_get_typeinfo_vars_2(list(prog_var)::in,
+ vartypes::in, type_info_varmap::in, list(prog_var)::out) is det.
-proc_info_get_typeinfo_vars_2(_, [], []).
-proc_info_get_typeinfo_vars_2(ProcInfo, [Var | Vars1], TypeInfoVars) :-
- proc_info_vartypes(ProcInfo, VarTypeMap),
- (
- map__search(VarTypeMap, Var, Type)
+proc_info_get_typeinfo_vars_2([], _, _, []).
+proc_info_get_typeinfo_vars_2([Var | Vars], VarTypes, TVarMap, TypeInfoVars) :-
+ ( map__search(VarTypes, Var, Type)
->
type_util__real_vars(Type, TypeVars),
(
% Optimize common case
TypeVars = []
->
- proc_info_get_typeinfo_vars_2(ProcInfo, Vars1,
+ proc_info_get_typeinfo_vars_2(Vars, VarTypes, TVarMap,
TypeInfoVars)
;
% XXX It's possible there are some complications with
% higher order pred types here -- if so, maybe
% treat them specially.
- proc_info_typeinfo_varmap(ProcInfo, TVarMap),
% The type_info is either stored in a variable,
% or in a typeclass_info. Either get the
@@ -1722,12 +1724,25 @@
)),
list__map(LookupVar, TypeVars, TypeInfoVars0),
- proc_info_get_typeinfo_vars_2(ProcInfo, Vars1,
+ proc_info_get_typeinfo_vars_2(Vars, VarTypes, TVarMap,
TypeInfoVars1),
- list__append(TypeInfoVars0, TypeInfoVars1, TypeInfoVars)
+ list__append(TypeInfoVars0, TypeInfoVars1,
+ TypeInfoVars)
)
;
error("proc_info_get_typeinfo_vars_2: var not found in typemap")
+ ).
+
+proc_info_maybe_complete_with_typeinfo_vars(Vars0, TypeInfoLiveness,
+ VarTypes, TVarMap, Vars) :-
+ (
+ TypeInfoLiveness = yes,
+ proc_info_get_typeinfo_vars(Vars0, VarTypes, TVarMap,
+ TypeInfoVars),
+ set__union(Vars0, TypeInfoVars, Vars)
+ ;
+ TypeInfoLiveness = no,
+ Vars = Vars0
).
proc_info_ensure_unique_names(ProcInfo0, ProcInfo) :-
Index: compiler/lambda.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/lambda.m,v
retrieving revision 1.62
diff -u -b -r1.62 lambda.m
--- compiler/lambda.m 2000/05/22 17:59:31 1.62
+++ compiler/lambda.m 2000/07/29 02:22:43
@@ -191,9 +191,11 @@
% check if we need to requantify
( MustRecomputeNonLocals = yes ->
+ module_info_globals(ModuleInfo, Globals),
+ body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness),
implicitly_quantify_clause_body(HeadVars,
- Goal1, VarSet1, VarTypes1, Goal, VarSet, VarTypes,
- _Warnings)
+ Goal1, VarSet1, VarTypes1, TVarMap, TypeInfoLiveness,
+ Goal, VarSet, VarTypes, _Warnings)
;
Goal = Goal1,
VarSet = VarSet1,
Index: compiler/live_vars.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/live_vars.m,v
retrieving revision 1.86
diff -u -b -r1.86 live_vars.m
--- compiler/live_vars.m 2000/02/10 04:47:42 1.86
+++ compiler/live_vars.m 2000/07/28 09:41:18
@@ -526,9 +526,11 @@
(
TypeInfoLiveness = yes
->
- proc_info_get_typeinfo_vars_setwise(ProcInfo, LiveVars1,
+ proc_info_vartypes(ProcInfo, VarTypes),
+ proc_info_typeinfo_varmap(ProcInfo, TVarMap),
+ proc_info_get_typeinfo_vars(LiveVars1, VarTypes, TVarMap,
TypeInfoVarsLive),
- proc_info_get_typeinfo_vars_setwise(ProcInfo, OutVars,
+ proc_info_get_typeinfo_vars(OutVars, VarTypes, TVarMap,
TypeInfoVarsOut),
set__union(LiveVars1, TypeInfoVarsOut, LiveVars2),
set__union(LiveVars2, TypeInfoVarsLive, LiveVars)
Index: compiler/liveness.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/liveness.m,v
retrieving revision 1.104
diff -u -b -r1.104 liveness.m
--- compiler/liveness.m 2000/07/22 11:32:40 1.104
+++ compiler/liveness.m 2000/07/29 02:30:12
@@ -152,11 +152,14 @@
:- import_module string.
detect_liveness_proc(ProcInfo0, PredId, ModuleInfo, ProcInfo) :-
- requantify_proc(ProcInfo0, ProcInfo1),
+ module_info_globals(ModuleInfo, Globals),
+ body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness0),
+ requantify_proc(TypeInfoLiveness0, ProcInfo0, ProcInfo1),
+
proc_info_goal(ProcInfo1, Goal0),
proc_info_varset(ProcInfo1, Varset),
proc_info_vartypes(ProcInfo1, VarTypes),
- module_info_globals(ModuleInfo, Globals),
+ proc_info_typeinfo_varmap(ProcInfo1, TVarMap),
module_info_pred_info(ModuleInfo, PredId, PredInfo),
pred_info_module(PredInfo, PredModule),
@@ -168,10 +171,10 @@
->
TypeInfoLiveness = no
;
- body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness)
+ TypeInfoLiveness = TypeInfoLiveness0
),
- live_info_init(ModuleInfo, ProcInfo1, TypeInfoLiveness,
- VarTypes, Varset, LiveInfo),
+ live_info_init(ModuleInfo, TypeInfoLiveness, VarTypes, TVarMap, Varset,
+ LiveInfo),
initial_liveness(ProcInfo1, PredId, ModuleInfo, Liveness0),
detect_liveness_in_goal(Goal0, Liveness0, LiveInfo,
@@ -952,7 +955,7 @@
->
true
;
- live_info_get_varset(LiveInfo, Varset),
+ Varset = LiveInfo^varset,
set__to_sorted_list(LivenessFirst, FirstVarsList),
set__to_sorted_list(LivenessRest, RestVarsList),
list__map(varset__lookup_name(Varset),
@@ -1009,7 +1012,8 @@
\+ polymorphism__no_type_info_builtin(PredModule,
PredName, PredArity)
->
- proc_info_get_typeinfo_vars_setwise(ProcInfo, NonLocals0,
+ proc_info_typeinfo_varmap(ProcInfo, TVarMap),
+ proc_info_get_typeinfo_vars(NonLocals0, VarTypes, TVarMap,
TypeInfoNonLocals),
set__union(NonLocals0, TypeInfoNonLocals, NonLocals)
;
@@ -1056,11 +1060,11 @@
% If doing alternate liveness, the corresponding
% typeinfos need to be added to these.
- live_info_get_typeinfo_liveness(LiveInfo, TypeinfoLiveness),
(
- TypeinfoLiveness = yes
+ LiveInfo^typeinfo_liveness = yes
->
- proc_info_get_typeinfo_vars_setwise(ProcInfo, Deadness2,
+ proc_info_typeinfo_varmap(ProcInfo, TVarMap),
+ proc_info_get_typeinfo_vars(Deadness2, VarTypes, TVarMap,
TypeInfoVars),
set__union(Deadness2, TypeInfoVars, Deadness)
;
@@ -1120,11 +1124,11 @@
find_value_giving_occurrences([], _, _, ValueVars, ValueVars).
find_value_giving_occurrences([Var | Vars], LiveInfo, InstMapDelta,
ValueVars0, ValueVars) :-
- live_info_get_var_types(LiveInfo, VarTypes),
- live_info_get_module_info(LiveInfo, ModuleInfo),
+ VarTypes = LiveInfo^vartypes,
map__lookup(VarTypes, Var, Type),
(
instmap_delta_search_var(InstMapDelta, Var, Inst),
+ ModuleInfo = LiveInfo^module_info,
mode_to_arg_mode(ModuleInfo, (free -> Inst), Type, top_out)
->
set__insert(ValueVars0, Var, ValueVars1)
@@ -1135,52 +1139,6 @@
ValueVars1, ValueVars).
%-----------------------------------------------------------------------------%
-%-----------------------------------------------------------------------------%
-
-:- type live_info ---> live_info(
- module_info,
- proc_info,
- bool, % Do we use typeinfo
- % liveness for this
- % proc?
- map(prog_var, type),
- prog_varset
- ).
-
-:- pred live_info_init(module_info, proc_info, bool, map(prog_var, type),
- prog_varset, live_info).
-:- mode live_info_init(in, in, in, in, in, out) is det.
-
-live_info_init(ModuleInfo, ProcInfo, TypeInfoLiveness, VarTypes, Varset,
- live_info(ModuleInfo, ProcInfo, TypeInfoLiveness, VarTypes, Varset)).
-
-:- pred live_info_get_module_info(live_info, module_info).
-:- mode live_info_get_module_info(in, out) is det.
-
-live_info_get_module_info(live_info(ModuleInfo, _, _, _, _), ModuleInfo).
-
-:- pred live_info_get_proc_info(live_info, proc_info).
-:- mode live_info_get_proc_info(in, out) is det.
-
-live_info_get_proc_info(live_info(_, ProcInfo, _, _, _), ProcInfo).
-
-:- pred live_info_get_typeinfo_liveness(live_info, bool).
-:- mode live_info_get_typeinfo_liveness(in, out) is det.
-
-live_info_get_typeinfo_liveness(live_info(_, _, TypeInfoLiveness, _, _),
- TypeInfoLiveness).
-
-:- pred live_info_get_var_types(live_info, map(prog_var, type)).
-:- mode live_info_get_var_types(in, out) is det.
-
-live_info_get_var_types(live_info(_, _, _, VarTypes, _), VarTypes).
-
-:- pred live_info_get_varset(live_info, prog_varset).
-:- mode live_info_get_varset(in, out) is det.
-
-live_info_get_varset(live_info(_, _, _, _, Varset), Varset).
-
-%-----------------------------------------------------------------------------%
% Get the nonlocals, and, if doing alternate liveness, add the
% typeinfo vars for the nonlocals.
@@ -1198,14 +1156,26 @@
set(prog_var)::in, set(prog_var)::out) is det.
liveness__maybe_complete_with_typeinfos(LiveInfo, Vars0, Vars) :-
- live_info_get_typeinfo_liveness(LiveInfo, TypeinfoLiveness),
- ( TypeinfoLiveness = yes ->
- live_info_get_proc_info(LiveInfo, ProcInfo),
- proc_info_get_typeinfo_vars_setwise(ProcInfo, Vars0,
- TypeInfoVars),
- set__union(Vars0, TypeInfoVars, Vars)
- ;
- Vars = Vars0
+ proc_info_maybe_complete_with_typeinfo_vars(Vars0,
+ LiveInfo^typeinfo_liveness, LiveInfo^vartypes,
+ LiveInfo^type_info_varmap, Vars).
+
+%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
+
+:- type live_info
+ ---> live_info(
+ module_info :: module_info,
+ typeinfo_liveness :: bool,
+ vartypes :: vartypes,
+ type_info_varmap :: type_info_varmap,
+ varset :: prog_varset
).
+
+:- pred live_info_init(module_info::in, bool::in, vartypes::in,
+ type_info_varmap::in, prog_varset::in, live_info::out) is det.
+
+live_info_init(ModuleInfo, ProcInfo, TypeInfoLiveness, VarTypes, Varset,
+ live_info(ModuleInfo, ProcInfo, TypeInfoLiveness, VarTypes, Varset)).
%-----------------------------------------------------------------------------%
Index: compiler/magic.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/magic.m,v
retrieving revision 1.19
diff -u -b -r1.19 magic.m
--- compiler/magic.m 2000/05/26 08:14:42 1.19
+++ compiler/magic.m 2000/07/29 02:25:33
@@ -276,7 +276,9 @@
% Requantify the goal to rename apart the variables
% in the copies of the condition.
- requantify_proc(ProcInfo1, ProcInfo3),
+ module_info_globals(ModuleInfo0, Globals),
+ body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness),
+ requantify_proc(TypeInfoLiveness, ProcInfo1, ProcInfo3),
ModuleInfo1 = ModuleInfo0
; Goal0 = switch(Var, _Canfail, Cases, _SM) - GoalInfo ->
proc_info_varset(ProcInfo0, VarSet0),
Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.338
diff -u -b -r1.338 make_hlds.m
--- compiler/make_hlds.m 2000/07/20 11:24:03 1.338
+++ compiler/make_hlds.m 2000/07/29 02:30:22
@@ -4980,9 +4980,17 @@
HldsGoal1, VarSet2, transform_info(ModuleInfo0, Info0),
transform_info(ModuleInfo, Info)),
{
- map__init(Empty),
+ map__init(EmptyVarTypes),
+ % Since the we haven't done mode analysis yet, the
+ % instmap_delta fields in goal_infos are not yet
+ % meaningful. Therefore there no point in clipping
+ % them to the set of typeinfo-liveness-completed
+ % nonlocals.
+ map__init(EmptyTVarMap),
+ TypeInfoLiveness = no,
implicitly_quantify_clause_body(HeadVars, HldsGoal1,
- VarSet2, Empty, HldsGoal, VarSet, _, _Warnings),
+ VarSet2, EmptyVarTypes, EmptyTVarMap, TypeInfoLiveness,
+ HldsGoal, VarSet, _, _Warnings),
NewClause = clause([ModeId], HldsGoal, Context),
ClausesInfo = clauses_info(VarSet, VarTypes, VarTypes1,
HeadVars, [NewClause|ClauseList],
@@ -5021,7 +5029,6 @@
Arity, IsAssertion, Goal, VarSet, Warnings, Info0, Info) -->
transform_goal(Body, VarSet0, Subst, Goal1, VarSet1, Info0, Info1),
{ term__apply_substitution_to_list(Args0, Subst, Args) },
- { map__init(Empty) },
% The head variables of an assertion will always be
% variables, so it is unnecessary to insert unifications.
@@ -5036,7 +5043,16 @@
insert_arg_unifications(HeadVars, Args, Context, ArgContext,
no, Goal1, VarSet1, Goal2, VarSet2, Info1, Info)
),
- { implicitly_quantify_clause_body(HeadVars, Goal2, VarSet2, Empty,
+ { map__init(EmptyVarTypes) },
+ % Since the we haven't done mode analysis yet, the
+ % instmap_delta fields in goal_infos are not yet
+ % meaningful. Therefore there no point in clipping
+ % them to the set of typeinfo-liveness-completed
+ % nonlocals.
+ { map__init(EmptyTVarMap) },
+ { TypeInfoLiveness = no },
+ { implicitly_quantify_clause_body(HeadVars, Goal2, VarSet2,
+ EmptyVarTypes, EmptyTVarMap, TypeInfoLiveness,
Goal, VarSet, _, Warnings) }.
%-----------------------------------------------------------------------------%
Index: compiler/mode_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mode_info.m,v
retrieving revision 1.52
diff -u -b -r1.52 mode_info.m
--- compiler/mode_info.m 2000/07/28 01:52:41 1.52
+++ compiler/mode_info.m 2000/07/28 09:34:49
@@ -275,6 +275,23 @@
:- mode mode_info_set_checking_extra_goals(in,
mode_info_di, mode_info_uo) is det.
+:- pred mode_info_get_typeinfo_liveness(mode_info, bool).
+:- mode mode_info_get_typeinfo_liveness(mode_info_no_io, out) is det.
+
+:- pred mode_info_get_completed_nonlocals_base(hlds_goal_info,
+ vartypes, type_info_varmap, bool, set(prog_var)).
+:- mode mode_info_get_completed_nonlocals_base(in, in, in, in, out) is det.
+
+:- pred mode_info_get_completed_nonlocals(hlds_goal_info, set(prog_var),
+ mode_info, mode_info).
+:- mode mode_info_get_completed_nonlocals(in, out,
+ mode_info_di, mode_info_uo) is det.
+
+:- pred mode_info_get_goal_completed_nonlocals(hlds_goal, set(prog_var),
+ mode_info, mode_info).
+:- mode mode_info_get_goal_completed_nonlocals(in, out,
+ mode_info_di, mode_info_uo) is det.
+
% Find the simple_call_id to use in error messages
% for the given pred_id.
:- pred mode_info_get_call_id(mode_info, pred_id, simple_call_id).
@@ -333,7 +350,7 @@
:- implementation.
-:- import_module delay_info, mode_errors, mode_util.
+:- import_module delay_info, mode_errors, mode_util, globals.
:- import_module term, varset.
:- import_module require, std_util, queue.
@@ -345,7 +362,7 @@
procid :: proc_id, % The mode which we are checking
varset :: prog_varset,
% The variables in the current proc
- var_types :: map(prog_var, type),
+ var_types :: vartypes,
% The types of the variables
context :: prog_context,
% The line number of the subgoal we
@@ -414,7 +431,7 @@
% to change which procedure
% is called?
- checking_extra_goals :: bool
+ checking_extra_goals :: bool,
% Are we rechecking a goal after
% introducing unifications for
% complicated sub-unifications
@@ -422,6 +439,9 @@
% If so, redoing the mode check
% should not introduce more
% extra unifications.
+
+ typeinfo_liveness :: bool,
+ type_info_varmap :: type_info_varmap
).
% The normal inst of a mode_info struct: ground, with
@@ -445,19 +465,23 @@
map__lookup(Procs, ProcId, ProcInfo),
proc_info_varset(ProcInfo, VarSet),
proc_info_vartypes(ProcInfo, VarTypes),
+ proc_info_typeinfo_varmap(ProcInfo, TVarMap),
LiveVarsList = [LiveVars],
NondetLiveVarsList = [LiveVars],
Changed = no,
-
CheckingExtraGoals = no,
+ module_info_globals(ModuleInfo, Globals),
+ body_should_use_typeinfo_liveness(Globals, TypeinfoLiveness),
+
ModeInfo = mode_info(
IOState, ModuleInfo, PredId, ProcId, VarSet, VarTypes,
Context, ModeContext, InstMapping0, LockedVars, DelayInfo,
ErrorList, LiveVarsList, NondetLiveVarsList, [], [],
- Changed, HowToCheck, MayChangeProc, CheckingExtraGoals
+ Changed, HowToCheck, MayChangeProc, CheckingExtraGoals,
+ TypeinfoLiveness, TVarMap
).
%-----------------------------------------------------------------------------%
@@ -468,79 +492,57 @@
% XXX
unsafe_promise_unique(ModeInfo^io_state, IOState).
-%-----------------------------------------------------------------------------%
-
mode_info_set_io_state(ModeInfo, IOState0, ModeInfo^io_state := IOState) :-
% XXX
unsafe_promise_unique(IOState0, IOState).
-%-----------------------------------------------------------------------------%
-
-mode_info_get_module_info(ModeInfo, ModeInfo^module_info).
-
-%-----------------------------------------------------------------------------%
-
-mode_info_set_module_info(ModeInfo, ModuleInfo,
- ModeInfo^module_info := ModuleInfo).
-
-%-----------------------------------------------------------------------------%
-
mode_info_get_preds(ModeInfo, Preds) :-
module_info_preds(ModeInfo^module_info, Preds).
-%-----------------------------------------------------------------------------%
-
mode_info_get_modes(ModeInfo, Modes) :-
module_info_modes(ModeInfo^module_info, Modes).
-%-----------------------------------------------------------------------------%
-
mode_info_get_insts(ModeInfo, Insts) :-
module_info_insts(ModeInfo^module_info, Insts).
-
-%-----------------------------------------------------------------------------%
-
-mode_info_get_predid(ModeInfo, ModeInfo^predid).
-
-%-----------------------------------------------------------------------------%
-
-mode_info_get_procid(ModeInfo, ModeInfo^procid).
-%-----------------------------------------------------------------------------%
-
-mode_info_get_varset(ModeInfo, ModeInfo^varset).
-
-%-----------------------------------------------------------------------------%
-
-mode_info_set_varset(VarSet) -->
- ^varset := VarSet.
-
-%-----------------------------------------------------------------------------%
-
-mode_info_get_var_types(ModeInfo, ModeInfo^var_types).
-
-%-----------------------------------------------------------------------------%
-
-mode_info_set_var_types(VTypes) -->
- ^var_types := VTypes.
-
-%-----------------------------------------------------------------------------%
-
-mode_info_get_context(ModeInfo, ModeInfo^context).
-
-%-----------------------------------------------------------------------------%
-
-mode_info_set_context(Context) -->
- ^context := Context.
-
-%-----------------------------------------------------------------------------%
-
-mode_info_get_mode_context(ModeInfo, ModeInfo^mode_context).
-
-%-----------------------------------------------------------------------------%
-
-mode_info_set_mode_context(ModeContext) -->
- ^mode_context := ModeContext.
+mode_info_get_module_info(MI, MI^module_info).
+mode_info_get_predid(MI, MI^predid).
+mode_info_get_procid(MI, MI^procid).
+mode_info_get_varset(MI, MI^varset).
+mode_info_get_var_types(MI, MI^var_types).
+mode_info_get_context(MI, MI^context).
+mode_info_get_mode_context(MI, MI^mode_context).
+mode_info_get_instmap(MI, MI^instmap).
+mode_info_get_locked_vars(MI, MI^locked_vars).
+mode_info_get_errors(MI, MI^errors).
+mode_info_get_delay_info(MI, MI^delay_info).
+mode_info_get_live_vars(MI, MI^live_vars).
+mode_info_get_nondet_live_vars(MI, MI^nondet_live_vars).
+mode_info_get_last_checkpoint_insts(MI, MI^last_checkpoint_insts).
+mode_info_get_parallel_vars(PVars) --> PVars =^ parallel_vars.
+mode_info_get_changed_flag(MI, MI^changed_flag).
+mode_info_get_how_to_check(MI, MI^how_to_check).
+mode_info_get_may_change_called_proc(MI, MI^may_change_called_proc).
+mode_info_get_typeinfo_liveness(MI, MI^typeinfo_liveness).
+
+mode_info_set_module_info(MI, ModuleInfo, MI^module_info := ModuleInfo).
+mode_info_set_varset(VarSet) --> ^varset := VarSet.
+mode_info_set_var_types(VTypes) --> ^var_types := VTypes.
+mode_info_set_context(Context) --> ^context := Context.
+mode_info_set_mode_context(ModeContext) --> ^mode_context := ModeContext.
+mode_info_set_locked_vars(MI, LockedVars, MI^locked_vars := LockedVars).
+mode_info_set_errors(Errors) --> ^errors := Errors.
+mode_info_set_delay_info(DelayInfo) --> ^delay_info := DelayInfo.
+mode_info_set_live_vars(LiveVarsList) --> ^live_vars := LiveVarsList.
+mode_info_set_nondet_live_vars(NondetLiveVars) -->
+ ^nondet_live_vars := NondetLiveVars.
+mode_info_set_last_checkpoint_insts(LastCheckpointInsts) -->
+ ^last_checkpoint_insts := LastCheckpointInsts.
+mode_info_set_parallel_vars(PVars) --> ^parallel_vars := PVars.
+mode_info_set_changed_flag(Changed) --> ^changed_flag := Changed.
+mode_info_set_how_to_check(How) --> ^how_to_check := How.
+mode_info_set_may_change_called_proc(MayChange) -->
+ ^may_change_called_proc := MayChange.
%-----------------------------------------------------------------------------%
@@ -568,8 +570,6 @@
%-----------------------------------------------------------------------------%
-mode_info_get_instmap(ModeInfo, ModeInfo^instmap).
-
% mode_info_dcg_get_instmap/3 is the same as mode_info_get_instmap/2
% except that it's easier to use inside a DCG.
@@ -594,29 +594,11 @@
%-----------------------------------------------------------------------------%
-mode_info_get_locked_vars(ModeInfo, ModeInfo^locked_vars).
-
-%-----------------------------------------------------------------------------%
-
-mode_info_set_locked_vars(ModeInfo, LockedVars,
- ModeInfo^locked_vars := LockedVars).
-
-%-----------------------------------------------------------------------------%
-
-mode_info_get_errors(ModeInfo, ModeInfo^errors).
-
-%-----------------------------------------------------------------------------%
-
mode_info_get_num_errors(ModeInfo, NumErrors) :-
list__length(ModeInfo^errors, NumErrors).
%-----------------------------------------------------------------------------%
-mode_info_set_errors(Errors) -->
- ^errors := Errors.
-
-%-----------------------------------------------------------------------------%
-
% We keep track of the live variables and the nondet-live variables
% a bag, represented as a list of sets of vars.
% This allows us to easily add and remove sets of variables.
@@ -698,11 +680,6 @@
set__union(LiveVars0, LiveVarsSet, LiveVars1),
mode_info_get_liveness_2(LiveVarsList, LiveVars1, LiveVars).
-mode_info_get_live_vars(ModeInfo, ModeInfo^live_vars).
-
-mode_info_set_live_vars(LiveVarsList) -->
- ^live_vars := LiveVarsList.
-
%-----------------------------------------------------------------------------%
% Since we don't yet handle polymorphic modes, the inst varset
@@ -754,43 +731,6 @@
mode_info_var_is_locked_2(Sets, Var, Reason)
).
-mode_info_get_delay_info(ModeInfo, ModeInfo^delay_info).
-
-mode_info_set_delay_info(DelayInfo) -->
- ^delay_info := DelayInfo.
-
-mode_info_get_nondet_live_vars(ModeInfo, ModeInfo^nondet_live_vars).
-
-mode_info_set_nondet_live_vars(NondetLiveVars) -->
- ^nondet_live_vars := NondetLiveVars.
-
-mode_info_get_last_checkpoint_insts(ModeInfo, ModeInfo^last_checkpoint_insts).
-
-mode_info_set_last_checkpoint_insts(LastCheckpointInsts) -->
- ^last_checkpoint_insts := LastCheckpointInsts.
-
-mode_info_get_parallel_vars(PVars) -->
- PVars =^ parallel_vars.
-
-mode_info_set_parallel_vars(PVars) -->
- ^parallel_vars := PVars.
-
-mode_info_get_changed_flag(ModeInfo, ModeInfo^changed_flag).
-
-mode_info_set_changed_flag(Changed) -->
- ^changed_flag := Changed.
-
-mode_info_get_how_to_check(ModeInfo, ModeInfo^how_to_check).
-
-mode_info_set_how_to_check(How) -->
- ^how_to_check := How.
-
-mode_info_get_may_change_called_proc(ModeInfo,
- ModeInfo^may_change_called_proc).
-
-mode_info_set_may_change_called_proc(MayChange) -->
- ^may_change_called_proc := MayChange.
-
mode_info_set_checking_extra_goals(Checking) -->
( yes =^ checking_extra_goals, { Checking = yes } ->
% This should never happen - once the extra goals are
@@ -823,4 +763,27 @@
mode_info_set_errors(Errors, ModeInfo0, ModeInfo).
%-----------------------------------------------------------------------------%
+
+mode_info_get_completed_nonlocals_base(GoalInfo, VarTypes, TVarMap,
+ TypeinfoLiveness, CompletedNonlocals) :-
+ goal_info_get_nonlocals(GoalInfo, NonLocals),
+ (
+ TypeinfoLiveness = yes,
+ proc_info_get_typeinfo_vars(NonLocals, VarTypes, TVarMap,
+ TypeInfoVars),
+ set__union(NonLocals, TypeInfoVars, CompletedNonlocals)
+ ;
+ TypeinfoLiveness = no,
+ CompletedNonlocals = NonLocals
+ ).
+
+mode_info_get_completed_nonlocals(GoalInfo, CompletedNonlocals,
+ ModeInfo, ModeInfo) :-
+ mode_info_get_completed_nonlocals_base(GoalInfo,
+ ModeInfo^var_types, ModeInfo^type_info_varmap,
+ ModeInfo^typeinfo_liveness, CompletedNonlocals).
+
+mode_info_get_goal_completed_nonlocals(_ - GoalInfo, CompletedNonlocals) -->
+ mode_info_get_completed_nonlocals(GoalInfo, CompletedNonlocals).
+
%-----------------------------------------------------------------------------%
Index: compiler/mode_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mode_util.m,v
retrieving revision 1.123
diff -u -b -r1.123 mode_util.m
--- compiler/mode_util.m 2000/05/05 06:07:47 1.123
+++ compiler/mode_util.m 2000/07/28 09:56:10
@@ -116,9 +116,9 @@
module_info, module_info).
:- mode recompute_instmap_delta_proc(in, in, out, in, out) is det.
-:- pred recompute_instmap_delta(bool, hlds_goal, hlds_goal, vartypes, instmap,
- module_info, module_info).
-:- mode recompute_instmap_delta(in, in, out, in, in, in, out) is det.
+:- pred recompute_instmap_delta(bool, hlds_goal, hlds_goal, vartypes,
+ type_info_varmap, instmap, module_info, module_info).
+:- mode recompute_instmap_delta(in, in, out, in, in, in, in, out) is det.
% Given corresponding lists of types and modes, produce a new
% list of modes which includes the information provided by the
@@ -197,9 +197,9 @@
%-----------------------------------------------------------------------------%
:- implementation.
-:- import_module require, int, map, set, std_util, assoc_list.
-:- import_module prog_util, prog_io, type_util.
-:- import_module inst_match, inst_util, term.
+:- import_module prog_util, prog_io, type_util, globals.
+:- import_module inst_match, inst_util, mode_info.
+:- import_module require, int, map, set, term, std_util, assoc_list.
%-----------------------------------------------------------------------------%
@@ -1108,21 +1108,31 @@
=(ModuleInfo0),
{ proc_info_get_initial_instmap(ProcInfo0, ModuleInfo0, InstMap0) },
{ proc_info_vartypes(ProcInfo0, VarTypes) },
+ { proc_info_typeinfo_varmap(ProcInfo0, TVarMap) },
{ proc_info_goal(ProcInfo0, Goal0) },
+ { module_info_globals(ModuleInfo0, Globals) },
+ { body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness) },
recompute_instmap_delta(RecomputeAtomic, Goal0, Goal,
- VarTypes, InstMap0),
+ VarTypes, TVarMap, InstMap0, TypeInfoLiveness, _),
{ proc_info_set_goal(ProcInfo0, Goal, ProcInfo) }.
-recompute_instmap_delta(RecomputeAtomic, Goal0, Goal, VarTypes, InstMap0) -->
+recompute_instmap_delta(RecomputeAtomic, Goal0, Goal, VarTypes, TVarMap,
+ InstMap0) -->
+ =(ModuleInfo0),
+ { module_info_globals(ModuleInfo0, Globals) },
+ { body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness) },
recompute_instmap_delta(RecomputeAtomic, Goal0, Goal, VarTypes,
- InstMap0, _).
+ TVarMap, InstMap0, TypeInfoLiveness, _).
-:- pred recompute_instmap_delta(bool, hlds_goal, hlds_goal, vartypes, instmap,
- instmap_delta, module_info, module_info).
-:- mode recompute_instmap_delta(in, in, out, in, in, out, in, out) is det.
+:- pred recompute_instmap_delta(bool, hlds_goal, hlds_goal, vartypes,
+ type_info_varmap, instmap, bool, instmap_delta,
+ module_info, module_info).
+:- mode recompute_instmap_delta(in, in, out, in, in, in, in, out, in, out)
+ is det.
recompute_instmap_delta(RecomputeAtomic, Goal0 - GoalInfo0, Goal - GoalInfo,
- VarTypes, InstMap0, InstMapDelta) -->
+ VarTypes, TVarMap, InstMap0, TypeInfoLiveness, InstMapDelta)
+ -->
(
{ RecomputeAtomic = no },
(
@@ -1137,8 +1147,10 @@
{ GoalInfo1 = GoalInfo0 }
;
recompute_instmap_delta_2(RecomputeAtomic, Goal0,
- GoalInfo0, Goal, VarTypes, InstMap0, InstMapDelta0),
- { goal_info_get_nonlocals(GoalInfo0, NonLocals) },
+ GoalInfo0, Goal, VarTypes, TVarMap, InstMap0,
+ TypeInfoLiveness, InstMapDelta0),
+ { mode_info_get_completed_nonlocals_base(GoalInfo0,
+ VarTypes, TVarMap, TypeInfoLiveness, NonLocals) },
{ instmap_delta_restrict(InstMapDelta0,
NonLocals, InstMapDelta1) },
{ goal_info_set_instmap_delta(GoalInfo0,
@@ -1156,72 +1168,88 @@
{ goal_info_get_instmap_delta(GoalInfo, InstMapDelta) }.
:- pred recompute_instmap_delta_2(bool, hlds_goal_expr, hlds_goal_info,
- hlds_goal_expr, vartypes, instmap, instmap_delta,
- module_info, module_info).
-:- mode recompute_instmap_delta_2(in, in, in, out, in, in, out, in, out) is det.
+ hlds_goal_expr, vartypes, type_info_varmap, instmap, bool,
+ instmap_delta, module_info, module_info).
+:- mode recompute_instmap_delta_2(in, in, in, out, in, in, in, in, out,
+ in, out) is det.
recompute_instmap_delta_2(Atomic, switch(Var, Det, Cases0, SM), GoalInfo,
- switch(Var, Det, Cases, SM), VarTypes, InstMap,
- InstMapDelta) -->
- { goal_info_get_nonlocals(GoalInfo, NonLocals) },
+ switch(Var, Det, Cases, SM), VarTypes, TVarMap, InstMap,
+ TypeInfoLiveness, InstMapDelta) -->
+ { mode_info_get_completed_nonlocals_base(GoalInfo,
+ VarTypes, TVarMap, TypeInfoLiveness, NonLocals) },
recompute_instmap_delta_cases(Atomic, Var, Cases0, Cases,
- VarTypes, InstMap, NonLocals, InstMapDelta).
+ VarTypes, TVarMap, InstMap, NonLocals, TypeInfoLiveness,
+ InstMapDelta).
recompute_instmap_delta_2(Atomic, conj(Goals0), _, conj(Goals),
- VarTypes, InstMap, InstMapDelta) -->
+ VarTypes, TVarMap, InstMap, TypeInfoLiveness, InstMapDelta) -->
recompute_instmap_delta_conj(Atomic, Goals0, Goals,
- VarTypes, InstMap, InstMapDelta).
+ VarTypes, TVarMap, InstMap, TypeInfoLiveness, InstMapDelta).
recompute_instmap_delta_2(Atomic, par_conj(Goals0, SM), GoalInfo,
- par_conj(Goals, SM), VarTypes, InstMap, InstMapDelta) -->
- { goal_info_get_nonlocals(GoalInfo, NonLocals) },
+ par_conj(Goals, SM), VarTypes, TVarMap, InstMap,
+ TypeInfoLiveness, InstMapDelta) -->
+ { mode_info_get_completed_nonlocals_base(GoalInfo,
+ VarTypes, TVarMap, TypeInfoLiveness, NonLocals) },
recompute_instmap_delta_par_conj(Atomic, Goals0, Goals,
- VarTypes, InstMap, NonLocals, InstMapDelta).
+ VarTypes, TVarMap, InstMap, NonLocals, TypeInfoLiveness,
+ InstMapDelta).
recompute_instmap_delta_2(Atomic, disj(Goals0, SM), GoalInfo, disj(Goals, SM),
- VarTypes, InstMap, InstMapDelta) -->
- { goal_info_get_nonlocals(GoalInfo, NonLocals) },
+ VarTypes, TVarMap, InstMap, TypeInfoLiveness, InstMapDelta)
+ -->
+ { mode_info_get_completed_nonlocals_base(GoalInfo,
+ VarTypes, TVarMap, TypeInfoLiveness, NonLocals) },
recompute_instmap_delta_disj(Atomic, Goals0, Goals,
- VarTypes, InstMap, NonLocals, InstMapDelta).
+ VarTypes, TVarMap, InstMap, NonLocals, TypeInfoLiveness,
+ InstMapDelta).
recompute_instmap_delta_2(Atomic, not(Goal0), _, not(Goal),
- VarTypes, InstMap, InstMapDelta) -->
+ VarTypes, TVarMap, InstMap, TypeInfoLiveness, InstMapDelta) -->
{ instmap_delta_init_reachable(InstMapDelta) },
- recompute_instmap_delta(Atomic, Goal0, Goal, VarTypes, InstMap).
+ recompute_instmap_delta(Atomic, Goal0, Goal, VarTypes, TVarMap,
+ InstMap, TypeInfoLiveness, _).
recompute_instmap_delta_2(Atomic, if_then_else(Vars, A0, B0, C0, SM), GoalInfo,
- if_then_else(Vars, A, B, C, SM), VarTypes, InstMap0, InstMapDelta) -->
- recompute_instmap_delta(Atomic, A0, A, VarTypes, InstMap0, InstMapDelta1),
+ if_then_else(Vars, A, B, C, SM), VarTypes, TVarMap, InstMap0,
+ TypeInfoLiveness, InstMapDelta) -->
+ recompute_instmap_delta(Atomic, A0, A, VarTypes, TVarMap, InstMap0,
+ TypeInfoLiveness, InstMapDelta1),
{ instmap__apply_instmap_delta(InstMap0, InstMapDelta1, InstMap1) },
- recompute_instmap_delta(Atomic, B0, B, VarTypes, InstMap1, InstMapDelta2),
- recompute_instmap_delta(Atomic, C0, C, VarTypes, InstMap0, InstMapDelta3),
+ recompute_instmap_delta(Atomic, B0, B, VarTypes, TVarMap, InstMap1,
+ TypeInfoLiveness, InstMapDelta2),
+ recompute_instmap_delta(Atomic, C0, C, VarTypes, TVarMap, InstMap0,
+ TypeInfoLiveness, InstMapDelta3),
{ instmap_delta_apply_instmap_delta(InstMapDelta1, InstMapDelta2,
InstMapDelta4) },
- { goal_info_get_nonlocals(GoalInfo, NonLocals) },
+ { mode_info_get_completed_nonlocals_base(GoalInfo,
+ VarTypes, TVarMap, TypeInfoLiveness, NonLocals) },
merge_instmap_delta(InstMap0, NonLocals, InstMapDelta3,
InstMapDelta4, InstMapDelta).
recompute_instmap_delta_2(Atomic, some(Vars, CanRemove, Goal0), _,
- some(Vars, CanRemove, Goal),
- VarTypes, InstMap, InstMapDelta) -->
- recompute_instmap_delta(Atomic, Goal0, Goal, VarTypes, InstMap, InstMapDelta).
+ some(Vars, CanRemove, Goal), VarTypes, TVarMap, InstMap,
+ TypeInfoLiveness, InstMapDelta) -->
+ recompute_instmap_delta(Atomic, Goal0, Goal, VarTypes, TVarMap,
+ InstMap, TypeInfoLiveness, InstMapDelta).
recompute_instmap_delta_2(_, generic_call(A, Vars, Modes, D), _,
- generic_call(A, Vars, Modes, D),
- _VarTypes, _InstMap, InstMapDelta) -->
+ generic_call(A, Vars, Modes, D), _VarTypes, _TVarMap, _InstMap,
+ _TypeInfoLiveness, InstMapDelta) -->
=(ModuleInfo),
{ instmap_delta_from_mode_list(Vars, Modes,
ModuleInfo, InstMapDelta) }.
recompute_instmap_delta_2(_, call(PredId, ProcId, Args, D, E, F), _,
- call(PredId, ProcId, Args, D, E, F), _VarTypes,
- InstMap, InstMapDelta) -->
+ call(PredId, ProcId, Args, D, E, F), _VarTypes, _TVarMap,
+ InstMap, _TypeInfoLiveness, InstMapDelta) -->
recompute_instmap_delta_call(PredId, ProcId,
Args, InstMap, InstMapDelta).
recompute_instmap_delta_2(Atomic, unify(A, Rhs0, UniMode0, Uni, E), GoalInfo,
- unify(A, Rhs, UniMode, Uni, E), VarTypes, InstMap0,
- InstMapDelta) -->
+ unify(A, Rhs, UniMode, Uni, E), VarTypes, TVarMap, InstMap0,
+ TypeInfoLiveness, InstMapDelta) -->
(
{ Rhs0 = lambda_goal(PorF, EvalMethod, FixModes, NonLocals,
LambdaVars, Modes, Det, Goal0) }
@@ -1229,7 +1257,8 @@
=(ModuleInfo0),
{ instmap__pre_lambda_update(ModuleInfo0, LambdaVars, Modes,
InstMap0, InstMap) },
- recompute_instmap_delta(Atomic, Goal0, Goal, VarTypes, InstMap),
+ recompute_instmap_delta(Atomic, Goal0, Goal, VarTypes,
+ TVarMap, InstMap, TypeInfoLiveness, _),
{ Rhs = lambda_goal(PorF, EvalMethod, FixModes, NonLocals,
LambdaVars, Modes, Det, Goal) }
;
@@ -1245,100 +1274,110 @@
recompute_instmap_delta_2(_, pragma_c_code(A, PredId, ProcId, Args, E, F,
G), _, pragma_c_code(A, PredId, ProcId, Args, E, F, G),
- _VarTypes, InstMap, InstMapDelta) -->
+ _VarTypes, _TVarMap, InstMap, _TypeInfoLiveness, InstMapDelta)
+ -->
recompute_instmap_delta_call(PredId, ProcId,
Args, InstMap, InstMapDelta).
-recompute_instmap_delta_2(_, bi_implication(_, _), _, _, _, _, _) -->
+recompute_instmap_delta_2(_, bi_implication(_, _), _, _, _, _, _, _, _) -->
% these should have been expanded out by now
{ error("recompute_instmap_delta_2: unexpected bi_implication") }.
%-----------------------------------------------------------------------------%
:- pred recompute_instmap_delta_conj(bool, list(hlds_goal), list(hlds_goal),
- vartypes, instmap, instmap_delta, module_info, module_info).
-:- mode recompute_instmap_delta_conj(in, in, out, in, in, out, in, out) is det.
+ vartypes, type_info_varmap, instmap, bool, instmap_delta,
+ module_info, module_info).
+:- mode recompute_instmap_delta_conj(in, in, out, in, in, in, in, out,
+ in, out) is det.
-recompute_instmap_delta_conj(_, [], [], _VarTypes, _InstMap, InstMapDelta) -->
+recompute_instmap_delta_conj(_, [], [], _, _, _, _, InstMapDelta) -->
{ instmap_delta_init_reachable(InstMapDelta) }.
recompute_instmap_delta_conj(Atomic, [Goal0 | Goals0], [Goal | Goals],
- VarTypes, InstMap0, InstMapDelta) -->
+ VarTypes, TVarMap, InstMap0, TypeInfoLiveness, InstMapDelta)
+ -->
recompute_instmap_delta(Atomic, Goal0, Goal,
- VarTypes, InstMap0, InstMapDelta0),
+ VarTypes, TVarMap, InstMap0, TypeInfoLiveness, InstMapDelta0),
{ instmap__apply_instmap_delta(InstMap0, InstMapDelta0, InstMap1) },
recompute_instmap_delta_conj(Atomic, Goals0, Goals,
- VarTypes, InstMap1, InstMapDelta1),
+ VarTypes, TVarMap, InstMap1, TypeInfoLiveness, InstMapDelta1),
{ instmap_delta_apply_instmap_delta(InstMapDelta0, InstMapDelta1,
InstMapDelta) }.
%-----------------------------------------------------------------------------%
:- pred recompute_instmap_delta_disj(bool, list(hlds_goal), list(hlds_goal),
- vartypes, instmap, set(prog_var), instmap_delta,
- module_info, module_info).
-:- mode recompute_instmap_delta_disj(in, in, out, in, in, in, out, in, out)
- is det.
+ vartypes, type_info_varmap, instmap, set(prog_var), bool,
+ instmap_delta, module_info, module_info).
+:- mode recompute_instmap_delta_disj(in, in, out, in, in, in, in, in, out,
+ in, out) is det.
-recompute_instmap_delta_disj(_, [], [], _, _, _, InstMapDelta) -->
+recompute_instmap_delta_disj(_, [], [], _, _, _, _, _, InstMapDelta) -->
{ instmap_delta_init_unreachable(InstMapDelta) }.
-recompute_instmap_delta_disj(Atomic, [Goal0], [Goal],
- VarTypes, InstMap, _, InstMapDelta) -->
- recompute_instmap_delta(Atomic, Goal0, Goal, VarTypes, InstMap,
- InstMapDelta).
+recompute_instmap_delta_disj(Atomic, [Goal0], [Goal], VarTypes, TVarMap,
+ InstMap, _, TypeInfoLiveness, InstMapDelta) -->
+ recompute_instmap_delta(Atomic, Goal0, Goal, VarTypes, TVarMap,
+ InstMap, TypeInfoLiveness, InstMapDelta).
recompute_instmap_delta_disj(Atomic, [Goal0 | Goals0], [Goal | Goals],
- VarTypes, InstMap, NonLocals, InstMapDelta) -->
+ VarTypes, TVarMap, InstMap, NonLocals, TypeInfoLiveness,
+ InstMapDelta) -->
{ Goals0 = [_|_] },
recompute_instmap_delta(Atomic, Goal0, Goal,
- VarTypes, InstMap, InstMapDelta0),
+ VarTypes, TVarMap, InstMap, TypeInfoLiveness, InstMapDelta0),
recompute_instmap_delta_disj(Atomic, Goals0, Goals,
- VarTypes, InstMap, NonLocals, InstMapDelta1),
+ VarTypes, TVarMap, InstMap, NonLocals, TypeInfoLiveness,
+ InstMapDelta1),
merge_instmap_delta(InstMap, NonLocals, InstMapDelta0,
InstMapDelta1, InstMapDelta).
:- pred recompute_instmap_delta_par_conj(bool, list(hlds_goal),
- list(hlds_goal), vartypes, instmap, set(prog_var),
- instmap_delta, module_info, module_info).
-:- mode recompute_instmap_delta_par_conj(in, in, out, in, in, in, out,
+ list(hlds_goal), vartypes, type_info_varmap, instmap,
+ set(prog_var), bool, instmap_delta, module_info, module_info).
+:- mode recompute_instmap_delta_par_conj(in, in, out, in, in, in, in, in, out,
in, out) is det.
-recompute_instmap_delta_par_conj(_, [], [], _, _, _, InstMapDelta) -->
+recompute_instmap_delta_par_conj(_, [], [], _, _, _, _, _, InstMapDelta) -->
{ instmap_delta_init_unreachable(InstMapDelta) }.
-recompute_instmap_delta_par_conj(Atomic, [Goal0], [Goal],
- VarTypes, InstMap, _, InstMapDelta) -->
- recompute_instmap_delta(Atomic, Goal0, Goal, VarTypes, InstMap,
- InstMapDelta).
+recompute_instmap_delta_par_conj(Atomic, [Goal0], [Goal], VarTypes, TVarMap,
+ InstMap, _, TypeInfoLiveness, InstMapDelta) -->
+ recompute_instmap_delta(Atomic, Goal0, Goal, VarTypes, TVarMap,
+ InstMap, TypeInfoLiveness, InstMapDelta).
recompute_instmap_delta_par_conj(Atomic, [Goal0 | Goals0], [Goal | Goals],
- VarTypes, InstMap, NonLocals, InstMapDelta) -->
+ VarTypes, TVarMap, InstMap, NonLocals, TypeInfoLiveness,
+ InstMapDelta) -->
{ Goals0 = [_|_] },
recompute_instmap_delta(Atomic, Goal0, Goal,
- VarTypes, InstMap, InstMapDelta0),
+ VarTypes, TVarMap, InstMap, TypeInfoLiveness, InstMapDelta0),
recompute_instmap_delta_par_conj(Atomic, Goals0, Goals,
- VarTypes, InstMap, NonLocals, InstMapDelta1),
+ VarTypes, TVarMap, InstMap, NonLocals, TypeInfoLiveness,
+ InstMapDelta1),
unify_instmap_delta(InstMap, NonLocals, InstMapDelta0,
InstMapDelta1, InstMapDelta).
%-----------------------------------------------------------------------------%
:- pred recompute_instmap_delta_cases(bool, prog_var, list(case), list(case),
- vartypes, instmap, set(prog_var), instmap_delta,
- module_info, module_info).
+ vartypes, type_info_varmap, instmap, set(prog_var), bool,
+ instmap_delta, module_info, module_info).
:- mode recompute_instmap_delta_cases(in, in, in, out,
- in, in, in, out, in, out) is det.
+ in, in, in, in, in, out, in, out) is det.
-recompute_instmap_delta_cases(_, _, [], [], _, _, _, InstMapDelta) -->
+recompute_instmap_delta_cases(_, _, [], [], _, _, _, _, _, InstMapDelta) -->
{ instmap_delta_init_unreachable(InstMapDelta) }.
recompute_instmap_delta_cases(Atomic, Var, [Case0 | Cases0], [Case | Cases],
- VarTypes, InstMap0, NonLocals, InstMapDelta) -->
+ VarTypes, TVarMap, InstMap0, NonLocals, TypeInfoLiveness,
+ InstMapDelta) -->
{ Case0 = case(Functor, Goal0) },
{ map__lookup(VarTypes, Var, Type) },
instmap__bind_var_to_functor(Var, Type, Functor, InstMap0, InstMap),
- recompute_instmap_delta(Atomic, Goal0, Goal, VarTypes, InstMap,
- InstMapDelta0),
+ recompute_instmap_delta(Atomic, Goal0, Goal, VarTypes, TVarMap,
+ InstMap, TypeInfoLiveness, InstMapDelta0),
instmap_delta_bind_var_to_functor(Var, Type, Functor,
InstMap0, InstMapDelta0, InstMapDelta1),
{ Case = case(Functor, Goal) },
recompute_instmap_delta_cases(Atomic, Var, Cases0, Cases,
- VarTypes, InstMap0, NonLocals, InstMapDelta2),
+ VarTypes, TVarMap, InstMap0, NonLocals, TypeInfoLiveness,
+ InstMapDelta2),
merge_instmap_delta(InstMap0, NonLocals, InstMapDelta1,
InstMapDelta2, InstMapDelta).
Index: compiler/modes.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/modes.m,v
retrieving revision 1.242
diff -u -b -r1.242 modes.m
--- compiler/modes.m 2000/07/24 11:36:04 1.242
+++ compiler/modes.m 2000/07/28 06:18:07
@@ -190,11 +190,11 @@
% Modecheck a unification.
- % given the right-hand-side of a unification, return a list of
- % the potentially non-local variables of that unification.
- %
-:- pred unify_rhs_vars(unify_rhs, list(prog_var)).
-:- mode unify_rhs_vars(in, out) is det.
+% % given the right-hand-side of a unification, return a list of
+% % the potentially non-local variables of that unification.
+% %
+% :- pred unify_rhs_vars(unify_rhs, list(prog_var)).
+% :- mode unify_rhs_vars(in, out) is det.
% Given a list of variables, and a list of livenesses,
% select the live variables.
@@ -977,10 +977,11 @@
%
mode_info_get_instmap(ModeInfo1, InstMap0),
- modecheck_goal_expr(Goal0, GoalInfo0, Goal, ModeInfo1, ModeInfo),
+ modecheck_goal_expr(Goal0, GoalInfo0, Goal, ModeInfo1, ModeInfo2),
mode_info_get_instmap(ModeInfo, InstMap),
- goal_info_get_nonlocals(GoalInfo0, NonLocals),
+ mode_info_get_completed_nonlocals(GoalInfo0, NonLocals,
+ ModeInfo2, ModeInfo),
compute_instmap_delta(InstMap0, InstMap, NonLocals, DeltaInstMap),
goal_info_set_instmap_delta(GoalInfo0, DeltaInstMap, GoalInfo).
@@ -1016,7 +1017,7 @@
% conjunctions properly.
modecheck_goal_expr(par_conj(List0, SM), GoalInfo0, par_conj(List, SM)) -->
mode_checkpoint(enter, "par_conj"),
- { goal_info_get_nonlocals(GoalInfo0, NonLocals) },
+ mode_info_get_completed_nonlocals(GoalInfo0, NonLocals),
modecheck_par_conj_list(List0, List, NonLocals, InstMapNonlocalList),
instmap__unify(NonLocals, InstMapNonlocalList),
mode_checkpoint(exit, "par_conj").
@@ -1028,7 +1029,7 @@
{ instmap__init_unreachable(InstMap) },
mode_info_set_instmap(InstMap)
;
- { goal_info_get_nonlocals(GoalInfo0, NonLocals) },
+ mode_info_get_completed_nonlocals(GoalInfo0, NonLocals),
modecheck_disj_list(List0, List, InstMapList),
instmap__merge(NonLocals, InstMapList, disj),
{ disj_list_to_goal(List, GoalInfo0, Goal - _GoalInfo) }
@@ -1037,8 +1038,8 @@
modecheck_goal_expr(if_then_else(Vs, A0, B0, C0, SM), GoalInfo0, Goal) -->
mode_checkpoint(enter, "if-then-else"),
- { goal_info_get_nonlocals(GoalInfo0, NonLocals) },
- { goal_get_nonlocals(B0, B_Vars) },
+ mode_info_get_completed_nonlocals(GoalInfo0, NonLocals),
+ mode_info_get_goal_completed_nonlocals(B0, B_Vars),
mode_info_dcg_get_instmap(InstMap0),
%
% We need to lock the non-local variables, to ensure
@@ -1070,7 +1071,7 @@
modecheck_goal_expr(not(A0), GoalInfo0, not(A)) -->
mode_checkpoint(enter, "not"),
- { goal_info_get_nonlocals(GoalInfo0, NonLocals) },
+ mode_info_get_completed_nonlocals(GoalInfo0, NonLocals),
mode_info_dcg_get_instmap(InstMap0),
%
% when analyzing a negated goal, nothing is forward-live
@@ -1178,7 +1179,7 @@
{ instmap__init_unreachable(InstMap) },
mode_info_set_instmap(InstMap)
;
- { goal_info_get_nonlocals(GoalInfo0, NonLocals) },
+ mode_info_get_completed_nonlocals(GoalInfo0, NonLocals),
modecheck_case_list(Cases0, Var, Cases, InstMapList),
instmap__merge(NonLocals, InstMapList, disj)
),
@@ -1213,14 +1214,14 @@
% given the right-hand-side of a unification, return a list of
% the potentially non-local variables of that unification.
-unify_rhs_vars(var(Var), [Var]).
-unify_rhs_vars(functor(_Functor, Vars), Vars).
-unify_rhs_vars(lambda_goal(_PredOrFunc, _EvalMethod, _Fix, LambdaNonLocals,
- LambdaVars, _Modes, _Det, _Goal - GoalInfo), Vars) :-
- goal_info_get_nonlocals(GoalInfo, NonLocals0),
- set__delete_list(NonLocals0, LambdaVars, NonLocals1),
- set__insert_list(NonLocals1, LambdaNonLocals, NonLocals),
- set__to_sorted_list(NonLocals, Vars).
+% unify_rhs_vars(var(Var), [Var]).
+% unify_rhs_vars(functor(_Functor, Vars), Vars).
+% unify_rhs_vars(lambda_goal(_PredOrFunc, _EvalMethod, _Fix, LambdaNonLocals,
+% LambdaVars, _Modes, _Det, _Goal - GoalInfo), Vars) :-
+% mode_info_get_completed_nonlocals(GoalInfo, NonLocals0),
+% set__delete_list(NonLocals0, LambdaVars, NonLocals1),
+% set__insert_list(NonLocals1, LambdaNonLocals, NonLocals),
+% set__to_sorted_list(NonLocals, Vars).
append_extra_goals(no_extra_goals, ExtraGoals, ExtraGoals).
append_extra_goals(extra_goals(BeforeGoals, AfterGoals),
@@ -1261,7 +1262,8 @@
%
% recompute the new set of non-local variables for the main goal
- goal_info_get_nonlocals(GoalInfo0, NonLocals0),
+ mode_info_get_completed_nonlocals(GoalInfo0, NonLocals0,
+ ModeInfo0, ModeInfo1),
set__list_to_set(Args0, OldArgVars),
set__list_to_set(Args, NewArgVars),
set__difference(NewArgVars, OldArgVars, IntroducedVars),
@@ -1276,19 +1278,19 @@
handle_extra_goals_contexts(AfterGoals0, Context, AfterGoals),
list__append(BeforeGoals, [Goal0 | AfterGoals], GoalList0),
- mode_info_get_may_change_called_proc(ModeInfo0,
+ mode_info_get_may_change_called_proc(ModeInfo1,
MayChangeCalledProc0),
% Make sure we don't go into an infinite loop if
% there is a bug in the code to add extra goals.
- mode_info_set_checking_extra_goals(yes, ModeInfo0, ModeInfo1),
+ mode_info_set_checking_extra_goals(yes, ModeInfo1, ModeInfo2),
% We've already worked out which procedure should be called,
% we don't need to do it again.
mode_info_set_may_change_called_proc(
- may_not_change_called_proc, ModeInfo1, ModeInfo2),
+ may_not_change_called_proc, ModeInfo2, ModeInfo3),
- mode_info_set_instmap(InstMap0, ModeInfo2, ModeInfo3),
+ mode_info_set_instmap(InstMap0, ModeInfo3, ModeInfo4),
% Recheck the goals to compute the instmap_deltas.
%
@@ -1302,13 +1304,13 @@
% is not, the main unification will be delayed until after the
% argument unifications, which turns them into assignments,
% and we end up repeating the process forever.
- mode_info_add_goals_live_vars(GoalList0, ModeInfo3, ModeInfo4),
+ mode_info_add_goals_live_vars(GoalList0, ModeInfo4, ModeInfo5),
modecheck_conj_list_no_delay(GoalList0, GoalList,
- ModeInfo4, ModeInfo5),
+ ModeInfo5, ModeInfo6),
Goal = conj(GoalList),
- mode_info_set_checking_extra_goals(no, ModeInfo5, ModeInfo6),
+ mode_info_set_checking_extra_goals(no, ModeInfo6, ModeInfo7),
mode_info_set_may_change_called_proc(MayChangeCalledProc0,
- ModeInfo6, ModeInfo)
+ ModeInfo7, ModeInfo)
;
Goal = MainGoal,
ModeInfo = ModeInfo0
@@ -1325,12 +1327,6 @@
goal_info_set_context(GoalInfo0, Context, GoalInfo),
handle_extra_goals_contexts(Goals0, Context, Goals).
-:- pred goal_get_nonlocals(hlds_goal, set(prog_var)).
-:- mode goal_get_nonlocals(in, out) is det.
-
-goal_get_nonlocals(_Goal - GoalInfo, NonLocals) :-
- goal_info_get_nonlocals(GoalInfo, NonLocals).
-
%-----------------------------------------------------------------------------%
% Modecheck a conjunction without doing any reordering.
@@ -1342,7 +1338,7 @@
modecheck_conj_list_no_delay([], []) --> [].
modecheck_conj_list_no_delay([Goal0 | Goals0], [Goal | Goals]) -->
- { goal_get_nonlocals(Goal0, NonLocals) },
+ mode_info_get_goal_completed_nonlocals(Goal0, NonLocals),
mode_info_remove_live_vars(NonLocals),
modecheck_goal(Goal0, Goal),
mode_info_dcg_get_instmap(InstMap),
@@ -1424,12 +1420,12 @@
% at the start of the list of live vars sets, which
% makes them cheaper to remove.
mode_info_add_goals_live_vars(Goals),
- { goal_get_nonlocals(Goal, Vars) },
+ mode_info_get_goal_completed_nonlocals(Goal, Vars),
mode_info_add_live_vars(Vars).
mode_info_remove_goals_live_vars([]) --> [].
mode_info_remove_goals_live_vars([Goal | Goals]) -->
- { goal_get_nonlocals(Goal, Vars) },
+ mode_info_get_goal_completed_nonlocals(Goal, Vars),
mode_info_remove_live_vars(Vars),
mode_info_remove_goals_live_vars(Goals).
@@ -1469,7 +1465,7 @@
% Modecheck the goal, noting first that the non-locals
% which occur in the goal might not be live anymore.
- { goal_get_nonlocals(Goal0, NonLocalVars) },
+ mode_info_get_goal_completed_nonlocals(Goal0, NonLocalVars),
mode_info_remove_live_vars(NonLocalVars),
modecheck_goal(Goal0, Goal),
@@ -1699,11 +1695,11 @@
mode_info_di, mode_info_uo) is det.
modecheck_par_conj_list([], [], _NonLocals, []) --> [].
-modecheck_par_conj_list([Goal0|Goals0], [Goal|Goals], NonLocals,
- [InstMap - GoalNonLocals|InstMaps]) -->
+modecheck_par_conj_list([Goal0 | Goals0], [Goal|Goals], NonLocals,
+ [InstMap - GoalNonLocals | InstMaps]) -->
mode_info_dcg_get_instmap(InstMap0),
{ Goal0 = _ - GoalInfo },
- { goal_info_get_nonlocals(GoalInfo, GoalNonLocals) },
+ mode_info_get_completed_nonlocals(GoalInfo, GoalNonLocals),
mode_info_get_parallel_vars(PVars0),
{ set__init(Bound0) },
mode_info_set_parallel_vars([NonLocals - Bound0|PVars0]),
@@ -1731,18 +1727,6 @@
mode_info_lock_vars(par_conj, Bound1),
modecheck_par_conj_list(Goals0, Goals, NonLocals, InstMaps),
mode_info_unlock_vars(par_conj, Bound1).
-
-:- pred get_all_conjunct_nonlocals(list(hlds_goal), set(prog_var),
- set(prog_var)).
-:- mode get_all_conjunct_nonlocals(in, in, out) is det.
-
-get_all_conjunct_nonlocals([], NonLocals, NonLocals).
-get_all_conjunct_nonlocals([G|Gs], NonLocals0, NonLocals) :-
- G = _ - GoalInfo,
- goal_info_get_nonlocals(GoalInfo, GoalNonLocals),
- set__union(GoalNonLocals, NonLocals0, NonLocals1),
- get_all_conjunct_nonlocals(Gs, NonLocals1, NonLocals).
-
%-----------------------------------------------------------------------------%
Index: compiler/pd_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/pd_util.m,v
retrieving revision 1.8
diff -u -b -r1.8 pd_util.m
--- compiler/pd_util.m 2000/04/14 08:38:14 1.8
+++ compiler/pd_util.m 2000/07/29 03:29:13
@@ -157,8 +157,9 @@
pd_info_get_proc_info(ProcInfo0),
{ proc_info_varset(ProcInfo0, VarSet0) },
{ proc_info_vartypes(ProcInfo0, VarTypes0) },
+ { proc_info_typeinfo_varmap(ProcInfo0, TVarMap) },
{ simplify_info_init(DetInfo0, Simplifications, InstMap0,
- VarSet0, VarTypes0, SimplifyInfo0) },
+ VarSet0, VarTypes0, TVarMap, SimplifyInfo0) },
{ simplify__process_goal(Goal0, Goal, SimplifyInfo0, SimplifyInfo) },
@@ -666,7 +667,12 @@
pd_info_get_proc_info(ProcInfo0),
{ proc_info_varset(ProcInfo0, VarSet0) },
{ proc_info_vartypes(ProcInfo0, VarTypes0) },
- { implicitly_quantify_goal(Goal0, VarSet0, VarTypes0, NonLocals,
+ { proc_info_typeinfo_varmap(ProcInfo0, TVarMap) },
+ pd_info_get_module_info(ModuleInfo0),
+ { module_info_globals(ModuleInfo0, Globals) },
+ { body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness) },
+ { implicitly_quantify_goal(Goal0, VarSet0, VarTypes0,
+ TVarMap, TypeInfoLiveness, NonLocals,
Goal, VarSet, VarTypes, _) },
{ proc_info_set_varset(ProcInfo0, VarSet, ProcInfo1) },
{ proc_info_set_vartypes(ProcInfo1, VarTypes, ProcInfo) },
@@ -677,7 +683,8 @@
pd_info_get_instmap(InstMap),
pd_info_get_proc_info(ProcInfo),
{ proc_info_vartypes(ProcInfo, VarTypes) },
- { recompute_instmap_delta(yes, Goal0, Goal, VarTypes, InstMap,
+ { proc_info_typeinfo_varmap(ProcInfo, TVarMap) },
+ { recompute_instmap_delta(yes, Goal0, Goal, VarTypes, TVarMap, InstMap,
ModuleInfo0, ModuleInfo) },
pd_info_set_module_info(ModuleInfo).
Index: compiler/polymorphism.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/polymorphism.m,v
retrieving revision 1.190
diff -u -b -r1.190 polymorphism.m
--- compiler/polymorphism.m 2000/07/20 11:24:08 1.190
+++ compiler/polymorphism.m 2000/07/29 02:53:41
@@ -1825,8 +1825,13 @@
poly_info_get_varset(Info0, VarSet0),
poly_info_get_var_types(Info0, VarTypes0),
set__list_to_set(HeadVars, OutsideVars),
+ poly_info_get_type_info_map(Info0, TVarMap),
+ poly_info_get_module_info(Info0, ModuleInfo),
+ module_info_globals(ModuleInfo, Globals),
+ body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness),
implicitly_quantify_goal(Goal0, VarSet0, VarTypes0,
- OutsideVars, Goal, VarSet, VarTypes, _Warnings),
+ TVarMap, TypeInfoLiveness, OutsideVars,
+ Goal, VarSet, VarTypes, _Warnings),
poly_info_set_varset_and_types(VarSet, VarTypes, Info0, Info)
).
@@ -1869,8 +1874,13 @@
TypeClassVarMap, VarTypes0, ExistQVars,
NonLocalsPlusArgs, NewOutsideVars),
set__union(NonLocals, NewOutsideVars, OutsideVars),
+ poly_info_get_type_info_map(Info0, TVarMap),
+ poly_info_get_module_info(Info0, ModuleInfo),
+ module_info_globals(ModuleInfo, Globals),
+ body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness),
implicitly_quantify_goal(Goal0, VarSet0, VarTypes0,
- OutsideVars, Goal, VarSet, VarTypes, _Warnings),
+ TVarMap, TypeInfoLiveness, OutsideVars,
+ Goal, VarSet, VarTypes, _Warnings),
poly_info_set_varset_and_types(VarSet, VarTypes, Info0, Info)
).
@@ -1954,8 +1964,7 @@
ClassId = class_id(ClassName, ClassArity),
Info0 = poly_info(VarSet0, VarTypes0, TypeVarSet, TypeInfoMap0,
- TypeClassInfoMap0, Proofs, PredName, ModuleInfo,
- unit, unit),
+ TypeClassInfoMap0, Proofs, PredName, ModuleInfo),
(
map__search(TypeClassInfoMap0, Constraint, Location)
@@ -2099,7 +2108,7 @@
Info1 = poly_info(VarSet1, VarTypes1, TypeVarSet,
TypeInfoMap0, TypeClassInfoMap0, Proofs,
- PredName, ModuleInfo, unit, unit),
+ PredName, ModuleInfo),
% Make the typeclass_info for the subclass
polymorphism__make_typeclass_info_var(
@@ -3204,20 +3213,24 @@
:- type poly_info --->
poly_info(
- prog_varset, % from the proc_info
- map(prog_var, type), % from the proc_info
- tvarset, % from the proc_info
- map(tvar, type_info_locn),
+ % the first three fields are from the proc_info
+ varset :: prog_varset,
+ vartypes :: vartypes,
+ typevarset :: tvarset,
+
+ type_info_varmap :: type_info_varmap,
% specifies the location of
% the type_info var
% for each of the pred's type
% parameters
+ typeclass_info_map ::
map(class_constraint, prog_var),
% specifies the location of
% the typeclass_info var
% for each of the pred's class
% constraints
+ proof_map ::
map(class_constraint, constraint_proof),
% specifies why each constraint
% that was eliminated from the
@@ -3233,10 +3246,8 @@
% calculated here in
% polymorphism.m
- pred_info,
- module_info,
- unit,
- unit
+ pred_info :: pred_info,
+ module_info :: module_info
).
%---------------------------------------------------------------------------%
@@ -3256,7 +3267,7 @@
map__init(TypeClassInfoMap),
PolyInfo = poly_info(VarSet, VarTypes, TypeVarSet,
TypeInfoMap, TypeClassInfoMap,
- Proofs, PredInfo, ModuleInfo, unit, unit).
+ Proofs, PredInfo, ModuleInfo).
% create_poly_info creates a poly_info for an existing procedure.
% (See also init_poly_info.)
@@ -3269,13 +3280,12 @@
proc_info_typeclass_info_varmap(ProcInfo, TypeClassInfoMap),
PolyInfo = poly_info(VarSet, VarTypes, TypeVarSet,
TypeInfoMap, TypeClassInfoMap,
- Proofs, PredInfo, ModuleInfo, unit, unit).
+ Proofs, PredInfo, ModuleInfo).
poly_info_extract(Info, PredInfo0, PredInfo,
ProcInfo0, ProcInfo, ModuleInfo) :-
Info = poly_info(VarSet, VarTypes, TypeVarSet, TypeInfoMap,
- TypeclassInfoLocations, _Proofs, _OldPredInfo, ModuleInfo,
- _, _),
+ TypeclassInfoLocations, _Proofs, _OldPredInfo, ModuleInfo),
% set the new values of the fields in proc_info and pred_info
proc_info_set_varset(ProcInfo0, VarSet, ProcInfo1),
@@ -3286,110 +3296,52 @@
pred_info_set_typevarset(PredInfo0, TypeVarSet, PredInfo).
%---------------------------------------------------------------------------%
-
-:- pred poly_info_get_varset(poly_info, prog_varset).
-:- mode poly_info_get_varset(in, out) is det.
-
-poly_info_get_varset(PolyInfo, VarSet) :-
- PolyInfo = poly_info(VarSet, _, _, _, _, _, _, _, _, _).
-
-:- pred poly_info_get_var_types(poly_info, map(prog_var, type)).
-:- mode poly_info_get_var_types(in, out) is det.
-
-poly_info_get_var_types(PolyInfo, VarTypes) :-
- PolyInfo = poly_info(_, VarTypes, _, _, _, _, _, _, _, _).
-
-:- pred poly_info_get_typevarset(poly_info, tvarset).
-:- mode poly_info_get_typevarset(in, out) is det.
-
-poly_info_get_typevarset(PolyInfo, TypeVarSet) :-
- PolyInfo = poly_info(_, _, TypeVarSet, _, _, _, _, _, _, _).
-
-:- pred poly_info_get_type_info_map(poly_info, map(tvar, type_info_locn)).
-:- mode poly_info_get_type_info_map(in, out) is det.
-
-poly_info_get_type_info_map(PolyInfo, TypeInfoMap) :-
- PolyInfo = poly_info(_, _, _, TypeInfoMap, _, _, _, _, _, _).
-
-:- pred poly_info_get_typeclass_info_map(poly_info,
- map(class_constraint, prog_var)).
-:- mode poly_info_get_typeclass_info_map(in, out) is det.
-
-poly_info_get_typeclass_info_map(PolyInfo, TypeClassInfoMap) :-
- PolyInfo = poly_info(_, _, _, _, TypeClassInfoMap, _, _, _, _, _).
-
-:- pred poly_info_get_proofs(poly_info,
- map(class_constraint, constraint_proof)).
-:- mode poly_info_get_proofs(in, out) is det.
-
-poly_info_get_proofs(PolyInfo, Proofs) :-
- PolyInfo = poly_info(_, _, _, _, _, Proofs, _, _, _, _).
-
-:- pred poly_info_get_pred_info(poly_info, pred_info).
-:- mode poly_info_get_pred_info(in, out) is det.
-
-poly_info_get_pred_info(PolyInfo, PredInfo) :-
- PolyInfo = poly_info(_, _, _, _, _, _, PredInfo, _, _, _).
-
-:- pred poly_info_get_module_info(poly_info, module_info).
-:- mode poly_info_get_module_info(in, out) is det.
-poly_info_get_module_info(PolyInfo, ModuleInfo) :-
- PolyInfo = poly_info(_, _, _, _, _, _, _, ModuleInfo, _, _).
-
-:- pred poly_info_set_varset(prog_varset, poly_info, poly_info).
-:- mode poly_info_set_varset(in, in, out) is det.
-
-poly_info_set_varset(VarSet, PolyInfo0, PolyInfo) :-
- PolyInfo0 = poly_info(_, B, C, D, E, F, G, H, I, J),
- PolyInfo = poly_info(VarSet, B, C, D, E, F, G, H, I, J).
-
-:- pred poly_info_set_varset_and_types(prog_varset, map(prog_var, type),
- poly_info, poly_info).
-:- mode poly_info_set_varset_and_types(in, in, in, out) is det.
-
-poly_info_set_varset_and_types(VarSet, VarTypes, PolyInfo0, PolyInfo) :-
- PolyInfo0 = poly_info(_, _, C, D, E, F, G, H, I, J),
- PolyInfo = poly_info(VarSet, VarTypes, C, D, E, F, G, H, I, J).
-
-:- pred poly_info_set_typevarset(tvarset, poly_info, poly_info).
-:- mode poly_info_set_typevarset(in, in, out) is det.
-
-poly_info_set_typevarset(TypeVarSet, PolyInfo0, PolyInfo) :-
- PolyInfo0 = poly_info(A, B, _, D, E, F, G, H, I, J),
- PolyInfo = poly_info(A, B, TypeVarSet, D, E, F, G, H, I, J).
-
-:- pred poly_info_set_type_info_map(map(tvar, type_info_locn),
- poly_info, poly_info).
-:- mode poly_info_set_type_info_map(in, in, out) is det.
-
-poly_info_set_type_info_map(TypeInfoMap, PolyInfo0, PolyInfo) :-
- PolyInfo0 = poly_info(A, B, C, _, E, F, G, H, I, J),
- PolyInfo = poly_info(A, B, C, TypeInfoMap, E, F, G, H, I, J).
-
-:- pred poly_info_set_typeclass_info_map(map(class_constraint, prog_var),
- poly_info, poly_info).
-:- mode poly_info_set_typeclass_info_map(in, in, out) is det.
-
-poly_info_set_typeclass_info_map(TypeClassInfoMap, PolyInfo0, PolyInfo) :-
- PolyInfo0 = poly_info(A, B, C, D, _, F, G, H, I, J),
- PolyInfo = poly_info(A, B, C, D, TypeClassInfoMap, F, G, H, I, J).
-
-
-:- pred poly_info_set_proofs(map(class_constraint, constraint_proof),
- poly_info, poly_info).
-:- mode poly_info_set_proofs(in, in, out) is det.
-
-poly_info_set_proofs(Proofs, PolyInfo0, PolyInfo) :-
- PolyInfo0 = poly_info(A, B, C, D, E, _, G, H, I, J),
- PolyInfo = poly_info(A, B, C, D, E, Proofs, G, H, I, J).
-
-:- pred poly_info_set_module_info(module_info, poly_info, poly_info).
-:- mode poly_info_set_module_info(in, in, out) is det.
-
-poly_info_set_module_info(ModuleInfo, PolyInfo0, PolyInfo) :-
- PolyInfo0 = poly_info(A, B, C, D, E, F, G, _, I, J),
- PolyInfo = poly_info(A, B, C, D, E, F, G, ModuleInfo, I, J).
+:- pred poly_info_get_varset(poly_info::in, prog_varset::out) is det.
+:- pred poly_info_get_var_types(poly_info::in, vartypes::out) is det.
+:- pred poly_info_get_typevarset(poly_info::in, tvarset::out) is det.
+:- pred poly_info_get_type_info_map(poly_info::in, type_info_varmap::out)
+ is det.
+:- pred poly_info_get_typeclass_info_map(poly_info::in,
+ map(class_constraint, prog_var)::out) is det.
+:- pred poly_info_get_proofs(poly_info::in,
+ map(class_constraint, constraint_proof)::out) is det.
+:- pred poly_info_get_pred_info(poly_info::in, pred_info::out) is det.
+:- pred poly_info_get_module_info(poly_info::in, module_info::out) is det.
+
+poly_info_get_varset(PolyInfo, PolyInfo^varset).
+poly_info_get_var_types(PolyInfo, PolyInfo^vartypes).
+poly_info_get_typevarset(PolyInfo, PolyInfo^typevarset).
+poly_info_get_type_info_map(PolyInfo, PolyInfo^type_info_varmap).
+poly_info_get_typeclass_info_map(PolyInfo, PolyInfo^typeclass_info_map).
+poly_info_get_proofs(PolyInfo, PolyInfo^proof_map).
+poly_info_get_pred_info(PolyInfo, PolyInfo^pred_info).
+poly_info_get_module_info(PolyInfo, PolyInfo^module_info).
+
+:- pred poly_info_set_varset(prog_varset::in, poly_info::in,
+ poly_info::out) is det.
+:- pred poly_info_set_varset_and_types(prog_varset::in, vartypes::in,
+ poly_info::in, poly_info::out) is det.
+:- pred poly_info_set_typevarset(tvarset::in, poly_info::in,
+ poly_info::out) is det.
+:- pred poly_info_set_type_info_map(type_info_varmap::in,
+ poly_info::in, poly_info::out) is det.
+:- pred poly_info_set_typeclass_info_map(map(class_constraint, prog_var)::in,
+ poly_info::in, poly_info::out) is det.
+:- pred poly_info_set_proofs(map(class_constraint, constraint_proof)::in,
+ poly_info::in, poly_info::out) is det.
+:- pred poly_info_set_module_info(module_info::in, poly_info::in,
+ poly_info::out) is det.
+
+poly_info_set_varset(VarSet, PI, PI^varset := VarSet).
+poly_info_set_varset_and_types(VarSet, VarTypes, PI,
+ (PI ^varset := VarSet) ^vartypes := VarTypes).
+poly_info_set_typevarset(TVarSet, PI, PI^typevarset := TVarSet).
+poly_info_set_type_info_map(TVarMap, PI, PI^type_info_varmap := TVarMap).
+poly_info_set_typeclass_info_map(TypeClassInfoMap, PI,
+ PI^typeclass_info_map := TypeClassInfoMap).
+poly_info_set_proofs(Proofs, PI, PI^proof_map := Proofs).
+poly_info_set_module_info(ModuleInfo, PI, PI^module_info := ModuleInfo).
%---------------------------------------------------------------------------%
%---------------------------------------------------------------------------%
Index: compiler/quantification.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/quantification.m,v
retrieving revision 1.73
diff -u -b -r1.73 quantification.m
--- compiler/quantification.m 2000/05/22 18:00:52 1.73
+++ compiler/quantification.m 2000/07/28 10:24:02
@@ -39,7 +39,7 @@
:- interface.
:- import_module hlds_goal, hlds_pred, prog_data.
-:- import_module map, list, set.
+:- import_module bool, list, set.
%
% When the compiler performs structure reuse, using
@@ -71,40 +71,38 @@
---> ordinary_nonlocals
; code_gen_nonlocals.
-:- pred implicitly_quantify_clause_body(nonlocals_to_recompute, list(prog_var),
- hlds_goal, prog_varset, map(prog_var, type),
- hlds_goal, prog_varset, map(prog_var, type),
- list(quant_warning)).
-:- mode implicitly_quantify_clause_body(in, in, in, in, in, out, out, out, out)
- is det.
+:- pred implicitly_quantify_clause_body(
+ nonlocals_to_recompute::in, list(prog_var)::in,
+ hlds_goal::in, prog_varset::in, vartypes::in,
+ type_info_varmap::in, bool::in,
+ hlds_goal::out, prog_varset::out, vartypes::out,
+ list(quant_warning)::out) is det.
-
% As above, with `ordinary_nonlocals' passed as the first argument.
-:- pred implicitly_quantify_clause_body(list(prog_var),
- hlds_goal, prog_varset, map(prog_var, type),
- hlds_goal, prog_varset, map(prog_var, type),
- list(quant_warning)).
-:- mode implicitly_quantify_clause_body(in, in, in, in, out, out, out, out)
- is det.
-
-:- pred implicitly_quantify_goal(nonlocals_to_recompute, hlds_goal, prog_varset,
- map(prog_var, type), set(prog_var), hlds_goal, prog_varset,
- map(prog_var, type), list(quant_warning)).
-:- mode implicitly_quantify_goal(in, in, in, in, in,
- out, out, out, out) is det.
+:- pred implicitly_quantify_clause_body(list(prog_var)::in,
+ hlds_goal::in, prog_varset::in, vartypes::in,
+ type_info_varmap::in, bool::in,
+ hlds_goal::out, prog_varset::out, vartypes::out,
+ list(quant_warning)::out) is det.
+
+:- pred implicitly_quantify_goal(nonlocals_to_recompute::in,
+ hlds_goal::in, prog_varset::in, vartypes::in,
+ type_info_varmap::in, bool::in, set(prog_var)::in,
+ hlds_goal::out, prog_varset::out, vartypes::out,
+ list(quant_warning)::out) is det.
% As above, with `ordinary_nonlocals' passed as the first argument.
-:- pred implicitly_quantify_goal(hlds_goal, prog_varset, map(prog_var, type),
- set(prog_var), hlds_goal, prog_varset,
- map(prog_var, type), list(quant_warning)).
-:- mode implicitly_quantify_goal(in, in, in, in, out, out, out, out) is det.
+:- pred implicitly_quantify_goal(
+ hlds_goal::in, prog_varset::in, vartypes::in,
+ type_info_varmap::in, bool::in, set(prog_var)::in,
+ hlds_goal::out, prog_varset::out, vartypes::out,
+ list(quant_warning)::out) is det.
-:- pred requantify_proc(nonlocals_to_recompute, proc_info, proc_info) is det.
-:- mode requantify_proc(in, in, out) is det.
+:- pred requantify_proc(nonlocals_to_recompute::in, bool::in,
+ proc_info::in, proc_info::out) is det.
% As above, with `ordinary_nonlocals' passed as the first argument.
-:- pred requantify_proc(proc_info, proc_info) is det.
-:- mode requantify_proc(in, out) is det.
+:- pred requantify_proc(bool::in, proc_info::in, proc_info::out) is det.
% We return a list of warnings back to make_hlds.m.
% Currently the only thing we warn about is variables with
@@ -116,13 +114,11 @@
% quantification__goal_vars(Goal, Vars):
% Vars is the set of variables that are free (unquantified)
% in Goal.
-:- pred quantification__goal_vars(nonlocals_to_recompute,
- hlds_goal, set(prog_var)).
-:- mode quantification__goal_vars(in, in, out) is det.
+:- pred quantification__goal_vars(nonlocals_to_recompute::in,
+ hlds_goal::in, set(prog_var)::out) is det.
% As above, with `ordinary_nonlocals' passed as the first argument.
-:- pred quantification__goal_vars(hlds_goal, set(prog_var)).
-:- mode quantification__goal_vars(in, out) is det.
+:- pred quantification__goal_vars(hlds_goal::in, set(prog_var)::out) is det.
%-----------------------------------------------------------------------------%
@@ -130,7 +126,7 @@
:- import_module instmap, goal_util.
-:- import_module term, varset.
+:- import_module map, term, varset.
:- import_module std_util, bool, require.
% The `outside vars', `lambda outside vars', and `quant vars'
@@ -150,6 +146,8 @@
seen :: set(prog_var),
varset :: prog_varset,
vartypes :: vartypes,
+ type_info_varmap :: type_info_varmap,
+ typeinfo_liveness :: bool,
warnings :: list(quant_warning)
).
@@ -183,40 +181,48 @@
%-----------------------------------------------------------------------------%
implicitly_quantify_clause_body(HeadVars, Goal0, Varset0, VarTypes0,
- Goal, Varset, VarTypes, Warnings) :-
+ TVarMap, TypeInfoLiveness, Goal, Varset, VarTypes, Warnings) :-
implicitly_quantify_clause_body(ordinary_nonlocals,
- HeadVars, Goal0, Varset0, VarTypes0,
+ HeadVars, Goal0, Varset0, VarTypes0, TVarMap, TypeInfoLiveness,
Goal, Varset, VarTypes, Warnings).
implicitly_quantify_clause_body(RecomputeNonLocals, HeadVars, Goal0,
- Varset0, VarTypes0, Goal, Varset, VarTypes, Warnings) :-
+ Varset0, VarTypes0, TVarMap, TypeInfoLiveness,
+ Goal, Varset, VarTypes, Warnings) :-
set__list_to_set(HeadVars, OutsideVars),
implicitly_quantify_goal(RecomputeNonLocals, Goal0, Varset0, VarTypes0,
- OutsideVars, Goal, Varset, VarTypes, Warnings).
+ TVarMap, TypeInfoLiveness, OutsideVars,
+ Goal, Varset, VarTypes, Warnings).
-requantify_proc(ProcInfo0, ProcInfo) :-
- requantify_proc(ordinary_nonlocals, ProcInfo0, ProcInfo).
+requantify_proc(TypeInfoLiveness, ProcInfo0, ProcInfo) :-
+ requantify_proc(ordinary_nonlocals, TypeInfoLiveness,
+ ProcInfo0, ProcInfo).
-requantify_proc(RecomputeNonLocals, ProcInfo0, ProcInfo) :-
+requantify_proc(RecomputeNonLocals, TypeInfoLiveness, ProcInfo0, ProcInfo) :-
proc_info_varset(ProcInfo0, Varset0),
proc_info_vartypes(ProcInfo0, VarTypes0),
+ proc_info_typeinfo_varmap(ProcInfo0, TVarMap),
proc_info_headvars(ProcInfo0, HeadVars),
proc_info_goal(ProcInfo0, Goal0),
implicitly_quantify_clause_body(RecomputeNonLocals, HeadVars,
- Goal0, Varset0, VarTypes0, Goal, Varset, VarTypes, _),
+ Goal0, Varset0, VarTypes0, TVarMap, TypeInfoLiveness,
+ Goal, Varset, VarTypes, _),
proc_info_set_varset(ProcInfo0, Varset, ProcInfo1),
proc_info_set_vartypes(ProcInfo1, VarTypes, ProcInfo2),
proc_info_set_goal(ProcInfo2, Goal, ProcInfo).
-implicitly_quantify_goal(Goal0, Varset0, VarTypes0, OutsideVars,
- Goal, Varset, VarTypes, Warnings) :-
+implicitly_quantify_goal(Goal0, Varset0, VarTypes0, TVarMap, TypeInfoLiveness,
+ OutsideVars, Goal, Varset, VarTypes, Warnings) :-
implicitly_quantify_goal(ordinary_nonlocals, Goal0, Varset0, VarTypes0,
- OutsideVars, Goal, Varset, VarTypes, Warnings).
+ TVarMap, TypeInfoLiveness, OutsideVars,
+ Goal, Varset, VarTypes, Warnings).
implicitly_quantify_goal(RecomputeNonLocals, Goal0, Varset0, VarTypes0,
- OutsideVars, Goal, Varset, VarTypes, Warnings) :-
+ TVarMap, TypeInfoLiveness, OutsideVars,
+ Goal, Varset, VarTypes, Warnings) :-
implicitly_quantify_goal_2(ordinary_nonlocals,
- Goal0, Varset0, VarTypes0, OutsideVars,
+ Goal0, Varset0, VarTypes0,
+ TVarMap, TypeInfoLiveness, OutsideVars,
Goal1, Varset1, VarTypes1, Warnings),
(
RecomputeNonLocals = code_gen_nonlocals,
@@ -227,7 +233,8 @@
goal_contains_reconstruction(Goal1)
->
implicitly_quantify_goal_2(code_gen_nonlocals,
- Goal1, Varset1, VarTypes1, OutsideVars,
+ Goal1, Varset1, VarTypes1,
+ TVarMap, TypeInfoLiveness, OutsideVars,
Goal, Varset, VarTypes, _)
;
Goal = Goal1,
@@ -235,26 +242,26 @@
VarTypes = VarTypes1
).
-:- pred implicitly_quantify_goal_2(nonlocals_to_recompute, hlds_goal,
- prog_varset, vartypes, set(prog_var), hlds_goal,
- prog_varset, vartypes, list(quant_warning)).
-:- mode implicitly_quantify_goal_2(in, in, in, in, in,
- out, out, out, out) is det.
+:- pred implicitly_quantify_goal_2(nonlocals_to_recompute::in,
+ hlds_goal::in, prog_varset::in, vartypes::in,
+ type_info_varmap::in, bool::in, set(prog_var)::in,
+ hlds_goal::out, prog_varset::out, vartypes::out,
+ list(quant_warning)::out) is det.
implicitly_quantify_goal_2(RecomputeNonLocals,
- Goal0, Varset0, VarTypes0, OutsideVars,
+ Goal0, Varset0, VarTypes0,
+ TVarMap, TypeInfoLiveness, OutsideVars,
Goal, Varset, VarTypes, Warnings) :-
quantification__init(RecomputeNonLocals, OutsideVars,
- Varset0, VarTypes0, QuantInfo0),
+ Varset0, VarTypes0, TVarMap, TypeInfoLiveness, QuantInfo0),
implicitly_quantify_goal(Goal0, Goal, QuantInfo0, QuantInfo),
quantification__get_varset(Varset, QuantInfo, _),
quantification__get_vartypes(VarTypes, QuantInfo, _),
quantification__get_warnings(Warnings0, QuantInfo, _),
list__reverse(Warnings0, Warnings).
-:- pred implicitly_quantify_goal(hlds_goal, hlds_goal,
- quant_info, quant_info).
-:- mode implicitly_quantify_goal(in, out, in, out) is det.
+:- pred implicitly_quantify_goal(hlds_goal::in, hlds_goal::out,
+ quant_info::in, quant_info::out) is det.
implicitly_quantify_goal(Goal0 - GoalInfo0, Goal - GoalInfo) -->
quantification__get_seen(SeenVars),
@@ -285,13 +292,18 @@
% to become local when previously it was non-local),
% then we may need to likewise shrink the instmap delta.
%
+ quantification__get_typeinfo_liveness(TypeInfoLiveness),
+ quantification__get_vartypes(VarTypes),
+ quantification__get_type_info_varmap(TVarMap),
+ { proc_info_maybe_complete_with_typeinfo_vars(NonLocalVars,
+ TypeInfoLiveness, VarTypes, TVarMap, CompletedNonLocalVars) },
{ goal_info_get_instmap_delta(GoalInfo2, InstMapDelta0) },
- { instmap_delta_restrict(InstMapDelta0, NonLocalVars, InstMapDelta) },
+ { instmap_delta_restrict(InstMapDelta0, CompletedNonLocalVars,
+ InstMapDelta) },
{ goal_info_set_instmap_delta(GoalInfo2, InstMapDelta, GoalInfo) }.
-:- pred implicitly_quantify_goal_2(hlds_goal_expr, prog_context,
- hlds_goal_expr, quant_info, quant_info).
-:- mode implicitly_quantify_goal_2(in, in, out, in, out) is det.
+:- pred implicitly_quantify_goal_2(hlds_goal_expr::in, prog_context::in,
+ hlds_goal_expr::out, quant_info::in, quant_info::out) is det.
% After this pass, explicit quantifiers are redundant,
% since all variables which were explicitly quantified
@@ -1148,12 +1160,12 @@
%-----------------------------------------------------------------------------%
-:- pred quantification__init(nonlocals_to_recompute, set(prog_var),
- prog_varset, map(prog_var, type), quant_info).
-:- mode quantification__init(in, in, in, in, out) is det.
+:- pred quantification__init(nonlocals_to_recompute::in, set(prog_var)::in,
+ prog_varset::in, vartypes::in, type_info_varmap::in, bool::in,
+ quant_info::out) is det.
quantification__init(RecomputeNonLocals, OutsideVars,
- Varset, VarTypes, QuantInfo) :-
+ Varset, VarTypes, TVarMap, TypeInfoLiveness, QuantInfo) :-
set__init(QuantVars),
set__init(NonLocals),
set__init(LambdaOutsideVars),
@@ -1161,98 +1173,101 @@
OverlapWarnings = [],
QuantInfo = quant_info(RecomputeNonLocals, OutsideVars, QuantVars,
LambdaOutsideVars, NonLocals, Seen, Varset, VarTypes,
- OverlapWarnings).
+ TVarMap, TypeInfoLiveness, OverlapWarnings).
-:- pred quantification__get_nonlocals_to_recompute(nonlocals_to_recompute,
- quant_info, quant_info).
-:- mode quantification__get_nonlocals_to_recompute(out, in, out) is det.
+:- pred quantification__get_nonlocals_to_recompute(nonlocals_to_recompute::out,
+ quant_info::in, quant_info::out) is det.
quantification__get_nonlocals_to_recompute(Q ^ nonlocals_to_recompute, Q, Q).
-:- pred quantification__get_outside(set(prog_var), quant_info, quant_info).
-:- mode quantification__get_outside(out, in, out) is det.
+:- pred quantification__get_outside(set(prog_var)::out,
+ quant_info::in, quant_info::out) is det.
quantification__get_outside(Q ^ outside, Q, Q).
-:- pred quantification__set_outside(set(prog_var), quant_info, quant_info).
-:- mode quantification__set_outside(in, in, out) is det.
+:- pred quantification__set_outside(set(prog_var)::in,
+ quant_info::in, quant_info::out) is det.
quantification__set_outside(Outside, Q0, Q0 ^ outside := Outside).
-:- pred quantification__get_quant_vars(set(prog_var), quant_info, quant_info).
-:- mode quantification__get_quant_vars(out, in, out) is det.
+:- pred quantification__get_quant_vars(set(prog_var)::out,
+ quant_info::in, quant_info::out) is det.
quantification__get_quant_vars(Q ^ quant_vars, Q, Q).
-:- pred quantification__set_quant_vars(set(prog_var), quant_info, quant_info).
-:- mode quantification__set_quant_vars(in, in, out) is det.
+:- pred quantification__set_quant_vars(set(prog_var)::in,
+ quant_info::in, quant_info::out) is det.
quantification__set_quant_vars(QuantVars, Q0, Q0 ^ quant_vars := QuantVars).
-:- pred quantification__get_lambda_outside(set(prog_var),
- quant_info, quant_info).
-:- mode quantification__get_lambda_outside(out, in, out) is det.
+:- pred quantification__get_lambda_outside(set(prog_var)::out,
+ quant_info::in, quant_info::out) is det.
quantification__get_lambda_outside(Q ^ lambda_outside, Q, Q).
-:- pred quantification__set_lambda_outside(set(prog_var),
- quant_info, quant_info).
-:- mode quantification__set_lambda_outside(in, in, out) is det.
+:- pred quantification__set_lambda_outside(set(prog_var)::in,
+ quant_info::in, quant_info::out) is det.
quantification__set_lambda_outside(LambdaOutsideVars, Q0,
Q0 ^ lambda_outside := LambdaOutsideVars).
-:- pred quantification__get_nonlocals(set(prog_var), quant_info, quant_info).
-:- mode quantification__get_nonlocals(out, in, out) is det.
+:- pred quantification__get_nonlocals(set(prog_var)::out,
+ quant_info::in, quant_info::out) is det.
quantification__get_nonlocals(Q ^ nonlocals, Q, Q).
-:- pred quantification__set_nonlocals(set(prog_var), quant_info, quant_info).
-:- mode quantification__set_nonlocals(in, in, out) is det.
+:- pred quantification__set_nonlocals(set(prog_var)::in,
+ quant_info::in, quant_info::out) is det.
quantification__set_nonlocals(NonLocals, Q0, Q0 ^ nonlocals := NonLocals).
-:- pred quantification__get_seen(set(prog_var), quant_info, quant_info).
-:- mode quantification__get_seen(out, in, out) is det.
+:- pred quantification__get_seen(set(prog_var)::out,
+ quant_info::in, quant_info::out) is det.
quantification__get_seen(Q ^ seen, Q, Q).
-:- pred quantification__set_seen(set(prog_var), quant_info, quant_info).
-:- mode quantification__set_seen(in, in, out) is det.
+:- pred quantification__set_seen(set(prog_var)::in,
+ quant_info::in, quant_info::out) is det.
quantification__set_seen(Seen, Q0, Q0 ^ seen := Seen).
-:- pred quantification__get_varset(prog_varset, quant_info, quant_info).
-:- mode quantification__get_varset(out, in, out) is det.
+:- pred quantification__get_varset(prog_varset::out,
+ quant_info::in, quant_info::out) is det.
quantification__get_varset(Q ^ varset, Q, Q).
-:- pred quantification__set_varset(prog_varset, quant_info, quant_info).
-:- mode quantification__set_varset(in, in, out) is det.
+:- pred quantification__set_varset(prog_varset::in,
+ quant_info::in, quant_info::out) is det.
quantification__set_varset(Varset, Q0, Q0 ^ varset := Varset).
-:- pred quantification__get_vartypes(map(prog_var, type),
- quant_info, quant_info).
-:- mode quantification__get_vartypes(out, in, out) is det.
+:- pred quantification__get_vartypes(vartypes::out,
+ quant_info::in, quant_info::out) is det.
quantification__get_vartypes(Q ^ vartypes, Q, Q).
-:- pred quantification__set_vartypes(map(prog_var, type),
- quant_info, quant_info).
-:- mode quantification__set_vartypes(in, in, out) is det.
+:- pred quantification__set_vartypes(vartypes::in,
+ quant_info::in, quant_info::out) is det.
quantification__set_vartypes(VarTypes, Q0, Q0 ^ vartypes := VarTypes).
-:- pred quantification__get_warnings(list(quant_warning),
- quant_info, quant_info).
-:- mode quantification__get_warnings(out, in, out) is det.
+:- pred quantification__get_type_info_varmap(type_info_varmap::out,
+ quant_info::in, quant_info::out) is det.
+quantification__get_type_info_varmap(Q ^ type_info_varmap, Q, Q).
+
+:- pred quantification__get_typeinfo_liveness(bool::out,
+ quant_info::in, quant_info::out) is det.
+
+quantification__get_typeinfo_liveness(Q ^ typeinfo_liveness, Q, Q).
+
+:- pred quantification__get_warnings(list(quant_warning)::out,
+ quant_info::in, quant_info::out) is det.
+
quantification__get_warnings(Q ^ warnings, Q, Q).
-:- pred quantification__set_warnings(list(quant_warning),
- quant_info, quant_info).
-:- mode quantification__set_warnings(in, in, out) is det.
+:- pred quantification__set_warnings(list(quant_warning)::in,
+ quant_info::in, quant_info::out) is det.
quantification__set_warnings(Warnings, Q0, Q0 ^ warnings := Warnings).
Index: compiler/saved_vars.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/saved_vars.m,v
retrieving revision 1.23
diff -u -b -r1.23 saved_vars.m
--- compiler/saved_vars.m 2000/03/28 03:40:32 1.23
+++ compiler/saved_vars.m 2000/07/29 02:55:47
@@ -58,6 +58,7 @@
proc_info_goal(ProcInfo0, Goal0),
proc_info_varset(ProcInfo0, Varset0),
proc_info_vartypes(ProcInfo0, VarTypes0),
+ proc_info_typeinfo_varmap(ProcInfo0, TVarMap),
init_slot_info(Varset0, VarTypes0, SlotInfo0),
saved_vars_in_goal(Goal0, SlotInfo0, Goal1, SlotInfo),
@@ -68,10 +69,13 @@
% hlds_out__write_goal(Goal1, ModuleInfo, Varset1, 0, "\n"),
% recompute the nonlocals for each goal
+ module_info_globals(ModuleInfo0, Globals),
+ body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness),
implicitly_quantify_clause_body(HeadVars, Goal1, Varset1,
- VarTypes1, Goal2, Varset, VarTypes, _Warnings),
+ VarTypes1, TVarMap, TypeInfoLiveness,
+ Goal2, Varset, VarTypes, _Warnings),
proc_info_get_initial_instmap(ProcInfo0, ModuleInfo0, InstMap0),
- recompute_instmap_delta(no, Goal2, Goal, VarTypes, InstMap0,
+ recompute_instmap_delta(no, Goal2, Goal, VarTypes, TVarMap, InstMap0,
ModuleInfo0, ModuleInfo),
% hlds_out__write_goal(Goal, ModuleInfo, Varset, 0, "\n"),
Index: compiler/simplify.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/simplify.m,v
retrieving revision 1.77
diff -u -b -r1.77 simplify.m
--- compiler/simplify.m 2000/04/05 06:28:28 1.77
+++ compiler/simplify.m 2000/07/29 03:02:39
@@ -154,10 +154,11 @@
proc_info_get_initial_instmap(ProcInfo0, ModuleInfo0, InstMap0),
proc_info_varset(ProcInfo0, VarSet0),
proc_info_vartypes(ProcInfo0, VarTypes0),
+ proc_info_typeinfo_varmap(ProcInfo0, TVarMap),
proc_info_goal(ProcInfo0, Goal0),
simplify_info_init(DetInfo0, Simplifications, InstMap0,
- VarSet0, VarTypes0, Info0),
+ VarSet0, VarTypes0, TVarMap, Info0),
simplify__process_goal(Goal0, Goal, Info0, Info),
simplify_info_get_varset(Info, VarSet),
@@ -207,8 +208,12 @@
( simplify_info_requantify(Info1) ->
Goal1 = _ - GoalInfo1,
goal_info_get_nonlocals(GoalInfo1, NonLocals),
-
- implicitly_quantify_goal(Goal1, VarSet0, VarTypes0, NonLocals,
+ simplify_info_get_type_info_varmap(Info1, TVarMap),
+ simplify_info_get_module_info(Info1, ModuleInfo1),
+ module_info_globals(ModuleInfo1, Globals),
+ body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness),
+ implicitly_quantify_goal(Goal1, VarSet0, VarTypes0,
+ TVarMap, TypeInfoLiveness, NonLocals,
Goal2, VarSet, VarTypes, _),
simplify_info_set_varset(Info1, VarSet, Info2),
@@ -222,7 +227,7 @@
simplify_info_get_module_info(Info3, ModuleInfo3),
recompute_instmap_delta(RecomputeAtomic, Goal2, Goal3,
- VarTypes, InstMap0, ModuleInfo3, ModuleInfo4),
+ VarTypes, TVarMap, InstMap0, ModuleInfo3, ModuleInfo4),
simplify_info_set_module_info(Info3, ModuleInfo4, Info4)
;
Goal3 = Goal1,
@@ -1319,7 +1324,7 @@
simplify__type_info_locn(TypeVar, TypeInfoVar, Goals) -->
=(Info0),
- { simplify_info_get_typeinfo_map(Info0, TypeInfoMap) },
+ { simplify_info_get_type_info_varmap(Info0, TypeInfoMap) },
{ map__lookup(TypeInfoMap, TypeVar, TypeInfoLocn) },
(
% If the typeinfo is available in a variable,
@@ -1882,31 +1887,38 @@
:- type simplify_info
---> simplify_info(
- det_info,
- set(det_msg),
- set(simplification),
- common_info, % Info about common subexpressions.
- instmap,
- prog_varset,
- map(prog_var, type),
- bool, % Does the goal need requantification.
- bool, % Do we need to recompute
+ det_info :: det_info,
+ msgs :: set(det_msg),
+ simplifications :: set(simplification),
+ common_info :: common_info,
+ % Info about common subexpressions.
+ instmap :: instmap,
+ varset :: prog_varset,
+ var_types :: map(prog_var, type),
+ requantify :: bool,
+ % Does the goal need requantification.
+ recompute_atomic :: bool,
+ % Do we need to recompute
% instmap_deltas for atomic goals
- bool, % Does determinism analysis need to
+ rerun_det :: bool,
+ % Does determinism analysis need to
% be rerun.
- int, % Measure of the improvement in
+ cost_delta :: int,
+ % Measure of the improvement in
% the goal from simplification.
- int % Count of the number of lambdas
+ lambdas :: int,
+ % Count of the number of lambdas
% which enclose the current goal.
+ type_info_varmap :: type_info_varmap
).
simplify_info_init(DetInfo, Simplifications0, InstMap,
- VarSet, VarTypes, Info) :-
+ VarSet, VarTypes, TVarMap, Info) :-
common_info_init(CommonInfo),
set__init(Msgs),
set__list_to_set(Simplifications0, Simplifications),
Info = simplify_info(DetInfo, Msgs, Simplifications, CommonInfo,
- InstMap, VarSet, VarTypes, no, no, no, 0, 0).
+ InstMap, VarSet, VarTypes, no, no, no, 0, 0, TVarMap).
% Reinitialise the simplify_info before reprocessing a goal.
:- pred simplify_info_reinit(set(simplification)::in, instmap::in,
@@ -1914,10 +1926,10 @@
simplify_info_reinit(Simplifications, InstMap0, Info0, Info) :-
Info0 = simplify_info(DetInfo, Msgs, _, _, _,
- VarSet, VarTypes, _, _, _, CostDelta, _),
+ VarSet, VarTypes, _, _, _, CostDelta, _, TVarMap),
common_info_init(Common),
Info = simplify_info(DetInfo, Msgs, Simplifications, Common, InstMap0,
- VarSet, VarTypes, no, no, no, CostDelta, 0).
+ VarSet, VarTypes, no, no, no, CostDelta, 0, TVarMap).
% exported for common.m
:- interface.
@@ -1926,8 +1938,8 @@
:- import_module set.
:- pred simplify_info_init(det_info, list(simplification), instmap,
- prog_varset, map(prog_var, type), simplify_info).
-:- mode simplify_info_init(in, in, in, in, in, out) is det.
+ prog_varset, vartypes, type_info_varmap, simplify_info).
+:- mode simplify_info_init(in, in, in, in, in, in, out) is det.
:- pred simplify_info_get_det_info(simplify_info::in, det_info::out) is det.
:- pred simplify_info_get_msgs(simplify_info::in, set(det_msg)::out) is det.
@@ -1938,33 +1950,34 @@
common_info::out) is det.
:- pred simplify_info_get_varset(simplify_info::in, prog_varset::out) is det.
:- pred simplify_info_get_var_types(simplify_info::in,
- map(prog_var, type)::out) is det.
+ vartypes::out) is det.
:- pred simplify_info_requantify(simplify_info::in) is semidet.
:- pred simplify_info_recompute_atomic(simplify_info::in) is semidet.
:- pred simplify_info_rerun_det(simplify_info::in) is semidet.
:- pred simplify_info_get_cost_delta(simplify_info::in, int::out) is det.
+:- pred simplify_info_get_type_info_varmap(simplify_info::in,
+ type_info_varmap::out) is det.
:- pred simplify_info_get_module_info(simplify_info::in,
module_info::out) is det.
:- implementation.
-simplify_info_get_det_info(simplify_info(Det, _,_,_,_,_,_,_,_,_,_,_), Det).
-simplify_info_get_msgs(simplify_info(_, Msgs, _,_,_,_,_,_,_,_,_,_), Msgs).
-simplify_info_get_simplifications(simplify_info(_,_,Simplify,_,_,_,_,_,_,_,_,_),
- Simplify).
-simplify_info_get_common_info(simplify_info(_,_,_,Common, _,_,_,_,_,_,_,_),
- Common).
-simplify_info_get_instmap(simplify_info(_,_,_,_, InstMap,_,_,_,_,_,_,_),
- InstMap).
-simplify_info_get_varset(simplify_info(_,_,_,_,_, VarSet, _,_,_,_,_,_), VarSet).
-simplify_info_get_var_types(simplify_info(_,_,_,_,_,_, VarTypes, _,_,_,_,_),
- VarTypes).
-simplify_info_requantify(simplify_info(_,_,_,_,_,_,_, yes, _,_,_,_)).
-simplify_info_recompute_atomic(simplify_info(_,_,_,_,_,_,_,_, yes,_,_,_)).
-simplify_info_rerun_det(simplify_info(_,_,_,_,_,_,_,_,_, yes,_,_)).
-simplify_info_get_cost_delta(simplify_info(_,_,_,_,_,_,_,_,_,_,CostDelta, _),
- CostDelta).
+simplify_info_get_det_info(SI, SI^det_info).
+simplify_info_get_msgs(SI, SI^msgs).
+simplify_info_get_simplifications(SI, SI^simplifications).
+simplify_info_get_common_info(SI, SI^common_info).
+simplify_info_get_instmap(SI, SI^instmap).
+simplify_info_get_varset(SI, SI^varset).
+simplify_info_get_var_types(SI, SI^var_types).
+simplify_info_requantify(SI) :-
+ SI^requantify = yes.
+simplify_info_recompute_atomic(SI) :-
+ SI^recompute_atomic = yes.
+simplify_info_rerun_det(SI) :-
+ SI^rerun_det = yes.
+simplify_info_get_cost_delta(SI, SI^cost_delta).
+simplify_info_get_type_info_varmap(SI, SI^type_info_varmap).
simplify_info_get_module_info(Info, ModuleInfo) :-
simplify_info_get_det_info(Info, DetInfo),
@@ -2012,38 +2025,20 @@
:- implementation.
-simplify_info_set_det_info(simplify_info(_, B, C, D, E, F, G, H, I, J, K, L),
- Det, simplify_info(Det, B, C, D, E, F, G, H, I, J, K, L)).
-simplify_info_set_msgs(simplify_info(A, _, C, D, E, F, G, H, I, J, K, L), Msgs,
- simplify_info(A, Msgs, C, D, E, F, G, H, I, J, K, L)).
-simplify_info_set_simplifications(
- simplify_info(A, B, _, D, E, F, G, H, I, J, K, L),
- Simp, simplify_info(A, B, Simp, D, E, F, G, H, I, J, K, L)).
-simplify_info_set_instmap(simplify_info(A, B, C, D, _, F, G, H, I, J, K, L),
- InstMap,
- simplify_info(A, B, C, D, InstMap, F, G, H, I, J, K, L)).
-simplify_info_set_common_info(simplify_info(A, B, C, _, E, F, G, H, I, J, K, L),
- Common,
- simplify_info(A, B, C, Common, E, F, G, H, I, J, K, L)).
-simplify_info_set_varset(simplify_info(A, B, C, D, E, _, G, H, I, J, K, L),
- VarSet,
- simplify_info(A, B, C, D, E, VarSet, G, H, I, J, K, L)).
-simplify_info_set_var_types(simplify_info(A, B, C, D, E, F, _, H, I, J, K, L),
- VarTypes, simplify_info(A, B, C, D, E, F, VarTypes, H,I,J,K,L)).
-simplify_info_set_requantify(simplify_info(A, B, C, D, E, F, G, _, I, J, K, L),
- simplify_info(A, B, C, D, E, F, G, yes, I, J, K, L)).
-simplify_info_set_recompute_atomic(simplify_info(A, B, C, D, E, F, G,H,_,J,K,L),
- simplify_info(A, B, C, D, E, F, G, H, yes, J, K, L)).
-simplify_info_set_rerun_det(simplify_info(A, B, C, D, E, F, G,H,I,_,K,L),
- simplify_info(A, B, C, D, E, F, G, H, I, yes, K, L)).
-simplify_info_set_cost_delta(simplify_info(A, B, C, D, E, F, G, H, I, J, _, L),
- Delta, simplify_info(A, B, C, D, E, F, G, H, I, J, Delta, L)).
-
-simplify_info_incr_cost_delta(
- simplify_info(A, B, C, D, E, F,G,H,I,J, Delta0, L),
- Incr, simplify_info(A, B, C, D, E, F, G, H, I, J, Delta, L)) :-
- Delta is Delta0 + Incr.
+simplify_info_set_det_info(SI, Det, SI^det_info := Det).
+simplify_info_set_msgs(SI, Msgs, SI^msgs := Msgs).
+simplify_info_set_simplifications(SI, Simp, SI^simplifications := Simp).
+simplify_info_set_instmap(SI, InstMap, SI^instmap := InstMap).
+simplify_info_set_common_info(SI, Common, SI^common_info := Common).
+simplify_info_set_varset(SI, VarSet, SI^varset := VarSet).
+simplify_info_set_var_types(SI, VarTypes, SI^var_types := VarTypes).
+simplify_info_set_requantify(SI, SI^requantify := yes).
+simplify_info_set_recompute_atomic(SI, SI^recompute_atomic := yes).
+simplify_info_set_rerun_det(SI, SI^rerun_det := yes).
+simplify_info_set_cost_delta(SI, Delta, SI^cost_delta := Delta).
+simplify_info_incr_cost_delta(SI, Incr, SI^cost_delta := SI^cost_delta + Incr).
+
simplify_info_add_msg(Info0, Msg, Info) :-
( simplify_do_warn(Info0) ->
simplify_info_do_add_msg(Info0, Msg, Info)
@@ -2056,14 +2051,9 @@
set__insert(Msgs0, Msg, Msgs),
simplify_info_set_msgs(Info0, Msgs, Info).
-simplify_info_enter_lambda(
- simplify_info(A, B, C, D, E, F, G, H, I, J, K, LambdaCount0),
- simplify_info(A, B, C, D, E, F, G, H, I, J, K, LambdaCount)) :-
- LambdaCount is LambdaCount0 + 1.
-simplify_info_leave_lambda(
- simplify_info(A, B, C, D, E, F, G, H, I, J, K, LambdaCount0),
- simplify_info(A, B, C, D, E, F, G, H, I, J, K, LambdaCount)) :-
- LambdaCount1 is LambdaCount0 - 1,
+simplify_info_enter_lambda(SI, SI^lambdas := SI^lambdas + 1).
+simplify_info_leave_lambda(SI, SI^lambdas := LambdaCount) :-
+ LambdaCount1 is SI^lambdas - 1,
(
LambdaCount1 >= 0
->
@@ -2071,9 +2061,8 @@
;
error("simplify_info_leave_lambda: Left too many lambdas")
).
-simplify_info_inside_lambda(
- simplify_info(_,_,_,_,_,_,_,_,_,_,_,LambdaCount)) :-
- LambdaCount > 0.
+simplify_info_inside_lambda(SI) :-
+ SI^lambdas > 0.
simplify_info_set_module_info(Info0, ModuleInfo, Info) :-
simplify_info_get_det_info(Info0, DetInfo0),
@@ -2118,25 +2107,11 @@
simplify_info_get_simplifications(Info, Simplifications),
set__member(extra_common_struct, Simplifications).
-:- pred simplify_info_get_typeinfo_map(simplify_info::in,
- map(tvar, type_info_locn)::out) is det.
-
-simplify_info_get_typeinfo_map(Info0, TypeInfoMap) :-
- simplify_info_get_det_info(Info0, DetInfo0),
- det_info_get_module_info(DetInfo0, ModuleInfo),
- det_info_get_pred_id(DetInfo0, ThisPredId),
- det_info_get_proc_id(DetInfo0, ThisProcId),
- module_info_pred_proc_info(ModuleInfo, ThisPredId, ThisProcId,
- _PredInfo, ProcInfo),
- proc_info_typeinfo_varmap(ProcInfo, TypeInfoMap).
-
:- pred simplify_info_update_instmap(simplify_info::in, hlds_goal::in,
simplify_info::out) is det.
-simplify_info_update_instmap(
- simplify_info(A, B, C, D, InstMap0, F, G, H, I, J, K, L), Goal,
- simplify_info(A, B, C, D, InstMap, F, G, H, I, J, K, L)) :-
- update_instmap(Goal, InstMap0, InstMap).
+simplify_info_update_instmap(SI, Goal, SI^instmap := InstMap) :-
+ update_instmap(Goal, SI^instmap, InstMap).
:- type before_after
---> before
Index: compiler/unify_proc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unify_proc.m,v
retrieving revision 1.83
diff -u -b -r1.83 unify_proc.m
--- compiler/unify_proc.m 2000/04/18 03:35:36 1.83
+++ compiler/unify_proc.m 2000/07/29 03:23:06
@@ -700,8 +700,10 @@
unify_proc__quantify_clause_body(HeadVars, Goal, Context, Clauses) -->
unify_proc__info_get_varset(Varset0),
unify_proc__info_get_types(Types0),
- { implicitly_quantify_clause_body(HeadVars, Goal,
- Varset0, Types0, Body, Varset, Types, _Warnings) },
+ unify_proc__info_get_type_info_varmap(TVarMap),
+ { TypeInfoLiveness = no },
+ { implicitly_quantify_clause_body(HeadVars, Goal, Varset0, Types0,
+ TVarMap, TypeInfoLiveness, Body, Varset, Types, _Warnings) },
unify_proc__info_set_varset(Varset),
unify_proc__info_set_types(Types),
{ Clauses = [clause([], Body, Context)] }.
@@ -765,8 +767,10 @@
{ conj_list_to_goal(GoalList, GoalInfo, Goal) },
unify_proc__info_get_varset(Varset0),
unify_proc__info_get_types(Types0),
- { implicitly_quantify_clause_body([H1, H2], Goal,
- Varset0, Types0, Body, Varset, Types, _Warnings) },
+ unify_proc__info_get_type_info_varmap(TVarMap),
+ { TypeInfoLiveness = no },
+ { implicitly_quantify_clause_body([H1, H2], Goal, Varset0, Types0,
+ TVarMap, TypeInfoLiveness, Body, Varset, Types, _Warnings) },
unify_proc__info_set_varset(Varset),
unify_proc__info_set_types(Types),
{ Clause = clause([], Body, Context) },
@@ -820,8 +824,10 @@
{ conj_list_to_goal(GoalList, GoalInfo, Goal) },
unify_proc__info_get_varset(Varset0),
unify_proc__info_get_types(Types0),
- { implicitly_quantify_clause_body([X, Index], Goal,
- Varset0, Types0, Body, Varset, Types, _Warnings) },
+ unify_proc__info_get_type_info_varmap(TVarMap),
+ { TypeInfoLiveness = no },
+ { implicitly_quantify_clause_body([X, Index], Goal, Varset0, Types0,
+ TVarMap, TypeInfoLiveness, Body, Varset, Types, _Warnings) },
unify_proc__info_set_varset(Varset),
unify_proc__info_set_types(Types),
{ Clause = clause([], Body, Context) },
@@ -885,8 +891,10 @@
{ ArgVars = [Res, X, Y] },
unify_proc__info_get_varset(Varset0),
unify_proc__info_get_types(Types0),
- { implicitly_quantify_clause_body(ArgVars, Goal,
- Varset0, Types0, Body, Varset, Types, _Warnings) },
+ unify_proc__info_get_type_info_varmap(TVarMap),
+ { TypeInfoLiveness = no },
+ { implicitly_quantify_clause_body(ArgVars, Goal, Varset0, Types0,
+ TVarMap, TypeInfoLiveness, Body, Varset, Types, _Warnings) },
unify_proc__info_set_varset(Varset),
unify_proc__info_set_types(Types),
{ Clause = clause([], Body, Context) }.
@@ -1288,40 +1296,25 @@
:- type unify_proc_info.
-:- pred unify_proc__info_init(module_info, unify_proc_info).
-:- mode unify_proc__info_init(in, out) is det.
-
-:- pred unify_proc__info_new_var(type, prog_var,
- unify_proc_info, unify_proc_info).
-:- mode unify_proc__info_new_var(in, out, in, out) is det.
-
-:- pred unify_proc__info_new_named_var(type, string, prog_var,
- unify_proc_info, unify_proc_info).
-:- mode unify_proc__info_new_named_var(in, in, out, in, out) is det.
-
-:- pred unify_proc__info_extract(unify_proc_info, prog_varset,
- map(prog_var, type)).
-:- mode unify_proc__info_extract(in, out, out) is det.
-
-:- pred unify_proc__info_get_varset(prog_varset,
- unify_proc_info, unify_proc_info).
-:- mode unify_proc__info_get_varset(out, in, out) is det.
-
-:- pred unify_proc__info_set_varset(prog_varset,
- unify_proc_info, unify_proc_info).
-:- mode unify_proc__info_set_varset(in, in, out) is det.
-
-:- pred unify_proc__info_get_types(map(prog_var, type),
- unify_proc_info, unify_proc_info).
-:- mode unify_proc__info_get_types(out, in, out) is det.
-
-:- pred unify_proc__info_set_types(map(prog_var, type),
- unify_proc_info, unify_proc_info).
-:- mode unify_proc__info_set_types(in, in, out) is det.
-
-:- pred unify_proc__info_get_module_info(module_info,
- unify_proc_info, unify_proc_info).
-:- mode unify_proc__info_get_module_info(out, in, out) is det.
+:- pred unify_proc__info_init(module_info::in, unify_proc_info::out) is det.
+:- pred unify_proc__info_new_var((type)::in, prog_var::out,
+ unify_proc_info::in, unify_proc_info::out) is det.
+:- pred unify_proc__info_new_named_var((type)::in, string::in, prog_var::out,
+ unify_proc_info::in, unify_proc_info::out) is det.
+:- pred unify_proc__info_extract(unify_proc_info::in,
+ prog_varset::out, vartypes::out) is det.
+:- pred unify_proc__info_get_varset(prog_varset::out,
+ unify_proc_info::in, unify_proc_info::out) is det.
+:- pred unify_proc__info_set_varset(prog_varset::in,
+ unify_proc_info::in, unify_proc_info::out) is det.
+:- pred unify_proc__info_get_types(vartypes::out,
+ unify_proc_info::in, unify_proc_info::out) is det.
+:- pred unify_proc__info_set_types(vartypes::in,
+ unify_proc_info::in, unify_proc_info::out) is det.
+:- pred unify_proc__info_get_type_info_varmap(type_info_varmap::out,
+ unify_proc_info::in, unify_proc_info::out) is det.
+:- pred unify_proc__info_get_module_info(module_info::out,
+ unify_proc_info::in, unify_proc_info::out) is det.
%-----------------------------------------------------------------------------%
@@ -1329,46 +1322,36 @@
:- type unify_proc_info
---> unify_proc_info(
- prog_varset,
- map(prog_var, type),
- module_info
+ varset :: prog_varset,
+ vartypes :: vartypes,
+ type_info_varmap :: type_info_varmap,
+ module_info :: module_info
).
-unify_proc__info_init(ModuleInfo, VarTypeInfo) :-
+unify_proc__info_init(ModuleInfo, UPI) :-
varset__init(VarSet),
map__init(Types),
- VarTypeInfo = unify_proc_info(VarSet, Types, ModuleInfo).
-
-unify_proc__info_new_var(Type, Var,
- unify_proc_info(VarSet0, Types0, ModuleInfo),
- unify_proc_info(VarSet, Types, ModuleInfo)) :-
- varset__new_var(VarSet0, Var, VarSet),
- map__det_insert(Types0, Var, Type, Types).
-
-unify_proc__info_new_named_var(Type, Name, Var,
- unify_proc_info(VarSet0, Types0, ModuleInfo),
- unify_proc_info(VarSet, Types, ModuleInfo)) :-
- varset__new_named_var(VarSet0, Name, Var, VarSet),
- map__det_insert(Types0, Var, Type, Types).
-
-unify_proc__info_extract(unify_proc_info(VarSet, Types, _ModuleInfo),
- VarSet, Types).
-
-unify_proc__info_get_varset(VarSet, ProcInfo, ProcInfo) :-
- ProcInfo = unify_proc_info(VarSet, _Types, _ModuleInfo).
-
-unify_proc__info_set_varset(VarSet, unify_proc_info(_VarSet, Types, ModuleInfo),
- unify_proc_info(VarSet, Types, ModuleInfo)).
-
-unify_proc__info_get_types(Types, ProcInfo, ProcInfo) :-
- ProcInfo = unify_proc_info(_VarSet, Types, _ModuleInfo).
-
-unify_proc__info_set_types(Types, unify_proc_info(VarSet, _Types, ModuleInfo),
- unify_proc_info(VarSet, Types, ModuleInfo)).
+ map__init(TVarMap),
+ UPI = unify_proc_info(VarSet, Types, TVarMap, ModuleInfo).
-unify_proc__info_get_module_info(ModuleInfo, VarTypeInfo, VarTypeInfo) :-
- VarTypeInfo = unify_proc_info(_VarSet, _Types, ModuleInfo).
+unify_proc__info_new_var(Type, Var, UPI,
+ (UPI^varset := VarSet) ^vartypes := Types) :-
+ varset__new_var(UPI^varset, Var, VarSet),
+ map__det_insert(UPI^vartypes, Var, Type, Types).
+
+unify_proc__info_new_named_var(Type, Name, Var, UPI,
+ (UPI^varset := VarSet) ^vartypes := Types) :-
+ varset__new_named_var(UPI^varset, Name, Var, VarSet),
+ map__det_insert(UPI^vartypes, Var, Type, Types).
+
+unify_proc__info_extract(UPI, UPI^varset, UPI^vartypes).
+
+unify_proc__info_get_varset(UPI^varset, UPI, UPI).
+unify_proc__info_get_types(UPI^vartypes, UPI, UPI).
+unify_proc__info_get_type_info_varmap(UPI^type_info_varmap, UPI, UPI).
+unify_proc__info_get_module_info(UPI^module_info, UPI, UPI).
-% :- end_module unify_proc_info.
+unify_proc__info_set_varset(VarSet, UPI, UPI^varset := VarSet).
+unify_proc__info_set_types(Types, UPI, UPI^vartypes := Types).
%-----------------------------------------------------------------------------%
Index: compiler/unique_modes.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unique_modes.m,v
retrieving revision 1.61
diff -u -b -r1.61 unique_modes.m
--- compiler/unique_modes.m 2000/04/14 08:38:32 1.61
+++ compiler/unique_modes.m 2000/07/28 09:08:12
@@ -128,14 +128,15 @@
%
% Restore the original bag of nondet-live vars
%
- mode_info_set_nondet_live_vars(NondetLiveVars0, ModeInfo3, ModeInfo),
+ mode_info_set_nondet_live_vars(NondetLiveVars0, ModeInfo3, ModeInfo4),
%
% Grab the final instmap, compute the change in insts
% over this goal, and save that instmap_delta in the goal_info.
%
mode_info_get_instmap(ModeInfo, InstMap),
- goal_info_get_nonlocals(GoalInfo0, NonLocals),
+ mode_info_get_completed_nonlocals(GoalInfo0, NonLocals,
+ ModeInfo4, ModeInfo),
compute_instmap_delta(InstMap0, InstMap, NonLocals, DeltaInstMap),
goal_info_set_instmap_delta(GoalInfo0, DeltaInstMap, GoalInfo),
@@ -263,12 +264,12 @@
unique_modes__check_goal_2(par_conj(List0, SM), GoalInfo0,
par_conj(List, SM)) -->
mode_checkpoint(enter, "par_conj"),
- { goal_info_get_nonlocals(GoalInfo0, NonLocals) },
+ mode_info_get_completed_nonlocals(GoalInfo0, NonLocals),
mode_info_add_live_vars(NonLocals),
% Build a multiset of the nonlocals of the conjuncts
% so that we can figure out which variables must be
% made shared at the start of the parallel conjunction.
- { make_par_conj_nonlocal_multiset(List0, NonLocalsBag) },
+ make_par_conj_nonlocal_multiset(List0, NonLocalsBag),
unique_modes__check_par_conj(List0, NonLocalsBag, List, InstMapList),
instmap__unify(NonLocals, InstMapList),
mode_info_remove_live_vars(NonLocals),
@@ -294,7 +295,7 @@
% disjuncts. But we handle that seperately for each
% disjunct, in unique_modes__check_disj.
%
- { goal_info_get_nonlocals(GoalInfo0, NonLocals) },
+ mode_info_get_completed_nonlocals(GoalInfo0, NonLocals),
{ goal_info_get_code_model(GoalInfo0, CodeModel) },
% does this disjunction create a choice point?
( { CodeModel = model_non } ->
@@ -318,10 +319,10 @@
unique_modes__check_goal_2(if_then_else(Vs, A0, B0, C0, SM), GoalInfo0, Goal)
-->
mode_checkpoint(enter, "if-then-else"),
- { goal_info_get_nonlocals(GoalInfo0, NonLocals) },
- { unique_modes__goal_get_nonlocals(A0, A_Vars) },
- { unique_modes__goal_get_nonlocals(B0, B_Vars) },
- { unique_modes__goal_get_nonlocals(C0, C_Vars) },
+ mode_info_get_completed_nonlocals(GoalInfo0, NonLocals),
+ mode_info_get_goal_completed_nonlocals(A0, A_Vars),
+ mode_info_get_goal_completed_nonlocals(B0, B_Vars),
+ mode_info_get_goal_completed_nonlocals(C0, C_Vars),
mode_info_dcg_get_instmap(InstMap0),
mode_info_lock_vars(if_then_else, NonLocals),
@@ -396,7 +397,7 @@
% negation will succeed, and so these variables
% can be accessed again after backtracking.
%
- { goal_info_get_nonlocals(GoalInfo0, NonLocals) },
+ mode_info_get_completed_nonlocals(GoalInfo0, NonLocals),
{ set__to_sorted_list(NonLocals, NonLocalsList) },
=(ModeInfo),
{ select_live_vars(NonLocalsList, ModeInfo, LiveNonLocals) },
@@ -500,7 +501,7 @@
{ instmap__init_unreachable(InstMap) },
mode_info_set_instmap(InstMap)
;
- { goal_info_get_nonlocals(GoalInfo0, NonLocals) },
+ mode_info_get_completed_nonlocals(GoalInfo0, NonLocals),
unique_modes__check_case_list(Cases0, Var, Cases, InstMapList),
instmap__merge(NonLocals, InstMapList, disj)
),
@@ -656,7 +657,7 @@
unique_modes__check_conj([], []) --> [].
unique_modes__check_conj([Goal0 | Goals0], [Goal | Goals]) -->
- { unique_modes__goal_get_nonlocals(Goal0, NonLocals) },
+ mode_info_get_goal_completed_nonlocals(Goal0, NonLocals),
mode_info_remove_live_vars(NonLocals),
unique_modes__check_goal(Goal0, Goal),
mode_info_dcg_get_instmap(InstMap),
@@ -675,17 +676,20 @@
% make_par_conj_nonlocal_multiset builds a multiset (bag) of all
% the nonlocals of the conjuncts.
-:- pred make_par_conj_nonlocal_multiset(list(hlds_goal), bag(prog_var)).
-:- mode make_par_conj_nonlocal_multiset(in, out) is det.
+:- pred make_par_conj_nonlocal_multiset(list(hlds_goal), bag(prog_var),
+ mode_info, mode_info).
+:- mode make_par_conj_nonlocal_multiset(in, out, mode_info_di, mode_info_uo)
+ is det.
-make_par_conj_nonlocal_multiset([], Empty) :-
- bag__init(Empty).
-make_par_conj_nonlocal_multiset([G|Gs], NonLocalsMultiSet) :-
- make_par_conj_nonlocal_multiset(Gs, NonLocalsMultiSet0),
- unique_modes__goal_get_nonlocals(G, NonLocals),
- set__to_sorted_list(NonLocals, NonLocalsList),
- bag__from_list(NonLocalsList, NonLocalsMultiSet1),
- bag__union(NonLocalsMultiSet0, NonLocalsMultiSet1, NonLocalsMultiSet).
+make_par_conj_nonlocal_multiset([], Empty) -->
+ { bag__init(Empty) }.
+make_par_conj_nonlocal_multiset([Goal | Goals], NonLocalsMultiSet) -->
+ make_par_conj_nonlocal_multiset(Goals, NonLocalsMultiSet0),
+ mode_info_get_goal_completed_nonlocals(Goal, NonLocals),
+ { set__to_sorted_list(NonLocals, NonLocalsList) },
+ { bag__from_list(NonLocalsList, NonLocalsMultiSet1) },
+ { bag__union(NonLocalsMultiSet0, NonLocalsMultiSet1,
+ NonLocalsMultiSet) }.
% To unique-modecheck a parallel conjunction, we find the variables
% that are nonlocal to more than one conjunct and make them shared,
@@ -738,7 +742,7 @@
unique_modes__check_par_conj_1([], [], []) --> [].
unique_modes__check_par_conj_1([Goal0 | Goals0], [Goal | Goals],
[InstMap - NonLocals|InstMaps]) -->
- { unique_modes__goal_get_nonlocals(Goal0, NonLocals) },
+ mode_info_get_goal_completed_nonlocals(Goal0, NonLocals),
mode_info_dcg_get_instmap(InstMap0),
unique_modes__check_goal(Goal0, Goal),
mode_info_dcg_get_instmap(InstMap),
@@ -825,13 +829,5 @@
mode_info_set_instmap(InstMap0),
unique_modes__check_case_list(Cases0, Var, Cases, InstMaps).
-
-%-----------------------------------------------------------------------------%
-
-:- pred unique_modes__goal_get_nonlocals(hlds_goal, set(prog_var)).
-:- mode unique_modes__goal_get_nonlocals(in, out) is det.
-
-unique_modes__goal_get_nonlocals(_Goal - GoalInfo, NonLocals) :-
- goal_info_get_nonlocals(GoalInfo, NonLocals).
%-----------------------------------------------------------------------------%
Index: compiler/unneeded_code.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unneeded_code.m,v
retrieving revision 1.1
diff -u -b -r1.1 unneeded_code.m
--- compiler/unneeded_code.m 2000/07/25 09:27:28 1.1
+++ compiler/unneeded_code.m 2000/07/29 03:25:39
@@ -196,13 +196,17 @@
unneeded_code__process_proc_msg(PredId, ProcId, ProcInfo0, ProcInfo,
ModuleInfo0, ModuleInfo) -->
globals__io_lookup_bool_option(very_verbose, VeryVerbose),
+ { module_info_globals(ModuleInfo0, Globals) },
+ { body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness) },
( { VeryVerbose = yes } ->
io__write_string("% Removing dead code in "),
- hlds_out__write_pred_proc_id(ModuleInfo, PredId, ProcId),
+ hlds_out__write_pred_proc_id(ModuleInfo0, PredId, ProcId),
io__write_string(": "),
- { unneeded_code__pre_process_proc(ProcInfo0, ProcInfo1) },
+ { unneeded_code__pre_process_proc(TypeInfoLiveness,
+ ProcInfo0, ProcInfo1) },
{ unneeded_code__process_proc(ProcInfo1, ProcInfo,
- ModuleInfo0, ModuleInfo, Successful) },
+ ModuleInfo0, ModuleInfo, TypeInfoLiveness,
+ Successful) },
(
{ Successful = yes },
io__write_string("done.\n")
@@ -211,20 +215,23 @@
io__write_string("none found.\n")
)
;
- { unneeded_code__pre_process_proc(ProcInfo0, ProcInfo1) },
+ { unneeded_code__pre_process_proc(TypeInfoLiveness,
+ ProcInfo0, ProcInfo1) },
{ unneeded_code__process_proc(ProcInfo1, ProcInfo,
- ModuleInfo0, ModuleInfo, _) }
+ ModuleInfo0, ModuleInfo, TypeInfoLiveness, _) }
).
-:- pred unneeded_code__pre_process_proc(proc_info::in, proc_info::out) is det.
+:- pred unneeded_code__pre_process_proc(bool::in, proc_info::in,
+ proc_info::out) is det.
-unneeded_code__pre_process_proc(ProcInfo0, ProcInfo) :-
+unneeded_code__pre_process_proc(TypeInfoLiveness, ProcInfo0, ProcInfo) :-
proc_info_headvars(ProcInfo0, HeadVars),
proc_info_goal(ProcInfo0, Goal0),
proc_info_varset(ProcInfo0, Varset0),
proc_info_vartypes(ProcInfo0, VarTypes0),
- implicitly_quantify_clause_body(HeadVars, Goal0,
- Varset0, VarTypes0, Goal, Varset, VarTypes, _Warnings),
+ proc_info_typeinfo_varmap(ProcInfo0, TVarMap),
+ implicitly_quantify_clause_body(HeadVars, Goal0, Varset0, VarTypes0,
+ TVarMap, TypeInfoLiveness, Goal, Varset, VarTypes, _Warnings),
proc_info_set_goal(ProcInfo0, Goal, ProcInfo1),
proc_info_set_varset(ProcInfo1, Varset, ProcInfo2),
proc_info_set_vartypes(ProcInfo2, VarTypes, ProcInfo).
@@ -263,10 +270,10 @@
).
:- pred unneeded_code__process_proc(proc_info::in, proc_info::out,
- module_info::in, module_info::out, bool::out) is det.
+ module_info::in, module_info::out, bool::in, bool::out) is det.
unneeded_code__process_proc(ProcInfo0, ProcInfo, ModuleInfo0, ModuleInfo,
- Successful) :-
+ TypeInfoLiveness, Successful) :-
goal_path__fill_slots(ProcInfo0, ModuleInfo0, ProcInfo1),
proc_info_goal(ProcInfo1, Goal0),
proc_info_varset(ProcInfo1, Varset0),
@@ -301,15 +308,18 @@
% We need to fix up the goal_info by recalculating
% the nonlocal vars and the non-atomic instmap deltas.
proc_info_headvars(ProcInfo0, HeadVars),
- implicitly_quantify_clause_body(HeadVars, Goal2,
- Varset0, VarTypes0, Goal3, Varset, VarTypes, _Warnings),
- recompute_instmap_delta(no, Goal3, Goal, VarTypes, InstMap0,
- ModuleInfo0, ModuleInfo1),
+ proc_info_typeinfo_varmap(ProcInfo0, TVarMap),
+ implicitly_quantify_clause_body(HeadVars,
+ Goal2, Varset0, VarTypes0,
+ TVarMap, TypeInfoLiveness,
+ Goal3, Varset, VarTypes, _Warnings),
+ recompute_instmap_delta(no, Goal3, Goal, VarTypes, TVarMap,
+ InstMap0, ModuleInfo0, ModuleInfo1),
proc_info_set_goal(ProcInfo1, Goal, ProcInfo2),
proc_info_set_varset(ProcInfo2, Varset, ProcInfo3),
proc_info_set_vartypes(ProcInfo3, VarTypes, ProcInfo4),
unneeded_code__process_proc(ProcInfo4, ProcInfo,
- ModuleInfo1, ModuleInfo, _),
+ ModuleInfo1, ModuleInfo, TypeInfoLiveness, _),
Successful = yes
;
ProcInfo = ProcInfo0,
Index: compiler/unused_args.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/unused_args.m,v
retrieving revision 1.63
diff -u -b -r1.63 unused_args.m
--- compiler/unused_args.m 2000/07/25 09:27:28 1.63
+++ compiler/unused_args.m 2000/07/29 03:24:36
@@ -829,6 +829,8 @@
map__det_insert(ProcCallInfo0, proc(PredId, ProcId),
call_info(NewPredId, NewProcId, PredSymName, UnusedArgs),
ProcCallInfo),
+ module_info_globals(ModuleInfo0, Globals),
+ body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness),
(
Status0 = exported,
IntermodUnusedArgs = yes(UnusedArgs2)
@@ -840,7 +842,8 @@
UnusedArgs2, "__ua", exported,
proc(PredId, ProcId), ExtraPredInfo0),
create_call_goal(UnusedArgs, NewPredId, NewProcId,
- PredModule, PredName, OldProc0, ExtraProc0),
+ PredModule, PredName, TypeInfoLiveness,
+ OldProc0, ExtraProc0),
proc_info_headvars(OldProc0, HeadVars0),
remove_listof_elements(HeadVars0, 1, UnusedArgs2,
IntermodHeadVars),
@@ -866,7 +869,8 @@
predicate_table_get_preds(PredTable2, Preds0),
pred_info_procedures(PredInfo0, Procs0),
create_call_goal(UnusedArgs, NewPredId, NewProcId,
- PredModule, PredName, OldProc0, OldProc),
+ PredModule, PredName, TypeInfoLiveness,
+ OldProc0, OldProc),
map__set(Procs0, ProcId, OldProc, Procs),
pred_info_set_procedures(PredInfo0, Procs, PredInfo),
map__det_update(Preds0, PredId, PredInfo, Preds1),
@@ -965,11 +969,11 @@
% Replace the goal in the procedure with one to call the given
% pred_id and proc_id.
:- pred create_call_goal(list(int)::in, pred_id::in, proc_id::in,
- module_name::in, string::in, proc_info::in, proc_info::out)
- is det.
+ module_name::in, string::in, bool::in, proc_info::in,
+ proc_info::out) is det.
create_call_goal(UnusedArgs, NewPredId, NewProcId, PredModule,
- PredName, OldProc0, OldProc) :-
+ PredName, TypeInfoLiveness, OldProc0, OldProc) :-
proc_info_headvars(OldProc0, HeadVars),
proc_info_goal(OldProc0, Goal0),
Goal0 = _GoalExpr - GoalInfo0,
@@ -984,13 +988,14 @@
GoalExpr = call(NewPredId, NewProcId, NewHeadVars,
not_builtin, no, qualified(PredModule, PredName)),
Goal1 = GoalExpr - GoalInfo0,
- implicitly_quantify_goal(Goal1, Varset0, VarTypes1, NonLocals,
+ proc_info_typeinfo_varmap(OldProc0, TVarMap),
+ implicitly_quantify_goal(Goal1, Varset0, VarTypes1,
+ TVarMap, TypeInfoLiveness, NonLocals,
Goal, Varset, VarTypes, _),
proc_info_set_goal(OldProc0, Goal, OldProc1),
proc_info_set_varset(OldProc1, Varset, OldProc2),
proc_info_set_vartypes(OldProc2, VarTypes, OldProc).
-
% Create a pred_info for an imported pred with a pragma unused_args
% in the .opt file.
:- pred make_imported_unused_args_pred_infos(pred_proc_list::in,
@@ -1151,7 +1156,11 @@
Changed = yes,
% if anything has changed, rerun quantification
set__list_to_set(HeadVars, NonLocals),
- implicitly_quantify_goal(Goal1, Varset0, VarTypes0, NonLocals,
+ proc_info_typeinfo_varmap(ProcInfo0, TVarMap),
+ module_info_globals(Mod0, Globals),
+ body_should_use_typeinfo_liveness(Globals, TypeInfoLiveness),
+ implicitly_quantify_goal(Goal1, Varset0, VarTypes0,
+ TVarMap, TypeInfoLiveness, NonLocals,
Goal, Varset, VarTypes, _),
proc_info_set_goal(FixedProc2, Goal, FixedProc3),
proc_info_set_varset(FixedProc3, Varset, FixedProc4),
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
cvs diff: Diffing extras/clpr
cvs diff: Diffing extras/clpr/clpr
cvs diff: Diffing extras/clpr/samples
cvs diff: Diffing extras/complex_numbers
cvs diff: Diffing extras/complex_numbers/samples
cvs diff: Diffing extras/complex_numbers/tests
cvs diff: Diffing extras/concurrency
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/mercury_opengl
cvs diff: Diffing extras/graphics/mercury_tcltk
cvs diff: Diffing extras/graphics/samples
cvs diff: Diffing extras/graphics/samples/calc
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/morphine
cvs diff: Diffing extras/morphine/non-regression-tests
cvs diff: Diffing extras/morphine/scripts
cvs diff: Diffing extras/morphine/source
cvs diff: Diffing extras/odbc
cvs diff: Diffing extras/posix
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing library
cvs diff: Diffing profiler
cvs diff: Diffing robdd
cvs diff: Diffing runtime
cvs diff: Diffing runtime/GETOPT
cvs diff: Diffing runtime/machdeps
cvs diff: Diffing samples
cvs diff: Diffing samples/c_interface
cvs diff: Diffing samples/c_interface/c_calls_mercury
cvs diff: Diffing samples/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/c_interface/mercury_calls_c
cvs diff: Diffing samples/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/diff
cvs diff: Diffing samples/muz
cvs diff: Diffing samples/rot13
cvs diff: Diffing samples/solutions
cvs diff: Diffing samples/tests
cvs diff: Diffing samples/tests/c_interface
cvs diff: Diffing samples/tests/c_interface/c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/cplusplus_calls_mercury
cvs diff: Diffing samples/tests/c_interface/mercury_calls_c
cvs diff: Diffing samples/tests/c_interface/mercury_calls_cplusplus
cvs diff: Diffing samples/tests/c_interface/mercury_calls_fortran
cvs diff: Diffing samples/tests/c_interface/simpler_c_calls_mercury
cvs diff: Diffing samples/tests/c_interface/simpler_cplusplus_calls_mercury
cvs diff: Diffing samples/tests/diff
cvs diff: Diffing samples/tests/muz
cvs diff: Diffing samples/tests/rot13
cvs diff: Diffing samples/tests/solutions
cvs diff: Diffing samples/tests/toplevel
cvs diff: Diffing scripts
cvs diff: Diffing tests
cvs diff: Diffing tests/benchmarks
cvs diff: Diffing tests/debugger
cvs diff: Diffing tests/debugger/declarative
cvs diff: Diffing tests/dppd
cvs diff: Diffing tests/general
cvs diff: Diffing tests/general/accumulator
cvs diff: Diffing tests/hard_coded
cvs diff: Diffing tests/hard_coded/exceptions
cvs diff: Diffing tests/hard_coded/purity
cvs diff: Diffing tests/hard_coded/sub-modules
cvs diff: Diffing tests/hard_coded/typeclasses
cvs diff: Diffing tests/invalid
cvs diff: Diffing tests/invalid/purity
cvs diff: Diffing tests/misc_tests
cvs diff: Diffing tests/tabling
cvs diff: Diffing tests/term
cvs diff: Diffing tests/valid
cvs diff: Diffing tests/warnings
cvs diff: Diffing tools
cvs diff: Diffing trace
cvs diff: Diffing trial
cvs diff: Diffing util
--------------------------------------------------------------------------
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