for review: improve printing of instmaps (alias branch)
David Matthew Overton
dmo at cs.mu.OZ.AU
Mon Nov 9 15:33:57 AEDT 1998
Pete Ross,
Would you please review this?
David
Estimated hours taken: 4
Improve printing of instmap_deltas in hlds dumps.
compiler/hlds_out.m:
Thread an instmap through the predicates used for printing
goals. This is necessary because the full inst_key_sub from
the instmap needs to be available when printing insts.
Also print the inst_key_sub for instmaps and instmap_deltas.
compiler/instmap.m:
Add a couple of predicates for accessing the inst_key_sub from
within instmaps and instmap_deltas.
compiler/constraint.m:
compiler/mode_erros.m:
compiler/pd_debug.m:
Pass instmaps where required to calls to hlds_out__write_goal.
compiler/pd_info.m:
Remove an unused module import from the interface.
Index: constraint.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/constraint.m,v
retrieving revision 1.35.2.8
diff -u -r1.35.2.8 constraint.m
--- 1.35.2.8 1998/06/17 04:12:12
+++ constraint.m 1998/11/06 13:14:49
@@ -369,8 +369,9 @@
mode_info_get_module_info(ModeInfo0, ModuleInfo),
mode_info_get_varset(ModeInfo0, VarSet),
mode_info_get_inst_table(ModeInfo0, InstTable),
- hlds_out__write_goal(Goal, InstTable, ModuleInfo, VarSet, no,
- Indent, "", IOState1, IOState)
+ mode_info_get_instmap(ModeInfo0, InstMap),
+ hlds_out__write_goal(Goal, InstMap, InstTable, ModuleInfo,
+ VarSet, no, Indent, "", IOState1, IOState)
;
IOState = IOState1
),
Index: hlds_out.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/hlds_out.m,v
retrieving revision 1.172.2.19
diff -u -r1.172.2.19 hlds_out.m
--- 1.172.2.19 1998/11/03 03:09:21
+++ hlds_out.m 1998/11/09 04:17:10
@@ -132,9 +132,9 @@
% print out an hlds goal.
-:- pred hlds_out__write_goal(hlds_goal, inst_table, module_info, varset,
- bool, int, string, io__state, io__state).
-:- mode hlds_out__write_goal(in, in, in, in, in, in, in, di, uo) is det.
+:- pred hlds_out__write_goal(hlds_goal, instmap, inst_table, module_info,
+ varset, bool, int, string, io__state, io__state).
+:- mode hlds_out__write_goal(in, in, in, in, in, in, in, in, di, uo) is det.
% print out a functor and its arguments
@@ -654,8 +654,9 @@
io__write_string(".\n")
;
io__write_string(" :-\n"),
- hlds_out__write_goal_a(Goal, InstTable, ModuleInfo, VarSet,
- AppendVarnums, Indent1, ".", TypeQual)
+ { instmap__init_reachable(InstMap0) }, % YYY
+ hlds_out__write_goal_a(Goal, InstMap0, InstTable, ModuleInfo,
+ VarSet, AppendVarnums, Indent1, ".", TypeQual)
).
:- pred hlds_out__write_intlist(list(int), io__state, io__state).
@@ -712,20 +713,21 @@
term__atom(PredName), HeadVars, VarSet, AppendVarnums)
).
-hlds_out__write_goal(Goal, InstTable, ModuleInfo, VarSet, AppendVarnums,
- Indent, Follow) -->
+hlds_out__write_goal(Goal, InstMap, InstTable, ModuleInfo, VarSet,
+ AppendVarnums, Indent, Follow) -->
% don't type qualify everything
- hlds_out__write_goal_a(Goal, InstTable, ModuleInfo, VarSet, AppendVarnums,
- Indent, Follow, no).
+ hlds_out__write_goal_a(Goal, InstMap, InstTable, ModuleInfo, VarSet,
+ AppendVarnums, Indent, Follow, no).
% TypeQual is yes(TVarset, VarTypes) if all constructors should
% be module qualified.
-:- pred hlds_out__write_goal_a(hlds_goal, inst_table, module_info, varset,
- bool, int, string, vartypes, io__state, io__state).
-:- mode hlds_out__write_goal_a(in, in, in, in, in, in, in, in, di, uo) is det.
+:- pred hlds_out__write_goal_a(hlds_goal, instmap, inst_table,
+ module_info, varset, bool, int, string, vartypes, io__state, io__state).
+:- mode hlds_out__write_goal_a(in, in, in, in, in, in, in, in, in, di, uo)
+ is det.
-hlds_out__write_goal_a(Goal - GoalInfo, InstTable, ModuleInfo, VarSet, AppendVarnums,
- Indent, Follow, TypeQual) -->
+hlds_out__write_goal_a(Goal - GoalInfo, InstMap0, InstTable, ModuleInfo,
+ VarSet, AppendVarnums, Indent, Follow, TypeQual) -->
globals__io_lookup_string_option(dump_hlds_options, Verbose),
( { string__contains_char(Verbose, 'c') } ->
{ goal_info_get_context(GoalInfo, Context) },
@@ -824,8 +826,8 @@
;
[]
),
- hlds_out__write_goal_2(Goal, InstTable, ModuleInfo, VarSet, AppendVarnums,
- Indent, Follow, TypeQual),
+ hlds_out__write_goal_2(Goal, InstMap0, InstTable, ModuleInfo, VarSet,
+ AppendVarnums, Indent, Follow, TypeQual),
( { string__contains_char(Verbose, 'i') } ->
{ goal_info_get_instmap_delta(GoalInfo, InstMapDelta) },
(
@@ -838,8 +840,8 @@
;
hlds_out__write_indent(Indent),
io__write_string("% new insts: "),
- hlds_out__write_instmap_delta(InstMapDelta, VarSet,
- AppendVarnums, Indent, InstTable),
+ hlds_out__write_instmap_delta(InstMapDelta, InstMap0,
+ VarSet, AppendVarnums, Indent, InstTable),
io__write_string("\n")
)
;
@@ -944,12 +946,13 @@
[]
).
-:- pred hlds_out__write_goal_2(hlds_goal_expr, inst_table, module_info,
- varset, bool, int, string, vartypes, io__state, io__state).
-:- mode hlds_out__write_goal_2(in, in, in, in, in, in, in, in, di, uo) is det.
+:- pred hlds_out__write_goal_2(hlds_goal_expr, instmap, inst_table,
+ module_info, varset, bool, int, string, vartypes, io__state, io__state).
+:- mode hlds_out__write_goal_2(in, in, in, in, in, in, in, in, in, di, uo)
+ is det.
-hlds_out__write_goal_2(switch(Var, CanFail, CasesList, _), InstTable, ModuleInfo,
- VarSet, AppendVarnums, Indent, Follow, TypeQual) -->
+hlds_out__write_goal_2(switch(Var, CanFail, CasesList, _), InstMap0, InstTable,
+ ModuleInfo, VarSet, AppendVarnums, Indent, Follow, TypeQual) -->
hlds_out__write_indent(Indent),
io__write_string("( % "),
hlds_out__write_can_fail(CanFail),
@@ -958,10 +961,10 @@
io__write_string("'\n"),
{ Indent1 is Indent + 1 },
( { CasesList = [Case | Cases] } ->
- hlds_out__write_case(Case, Var, InstTable, ModuleInfo,
+ hlds_out__write_case(Case, Var, InstMap0, InstTable, ModuleInfo,
VarSet, AppendVarnums, Indent1, TypeQual),
- hlds_out__write_cases(Cases, Var, InstTable, ModuleInfo,
- VarSet, AppendVarnums, Indent, TypeQual)
+ hlds_out__write_cases(Cases, Var, InstMap0, InstTable,
+ ModuleInfo, VarSet, AppendVarnums, Indent, TypeQual)
;
hlds_out__write_indent(Indent1),
io__write_string("fail\n")
@@ -971,33 +974,37 @@
io__write_string(Follow),
io__write_string("\n").
-hlds_out__write_goal_2(some(Vars, Goal), InstTable, ModuleInfo, VarSet, AppendVarnums,
- Indent, Follow, TypeQual) -->
+hlds_out__write_goal_2(some(Vars, Goal), InstMap0, InstTable, ModuleInfo,
+ VarSet, AppendVarnums, Indent, Follow, TypeQual) -->
hlds_out__write_indent(Indent),
io__write_string("some ["),
mercury_output_vars(Vars, VarSet, AppendVarnums),
io__write_string("] (\n"),
{ Indent1 is Indent + 1 },
- hlds_out__write_goal_a(Goal, InstTable, ModuleInfo, VarSet, AppendVarnums,
- Indent1, "", TypeQual),
+ hlds_out__write_goal_a(Goal, InstMap0, InstTable, ModuleInfo, VarSet,
+ AppendVarnums, Indent1, "", TypeQual),
hlds_out__write_indent(Indent),
io__write_string(")"),
io__write_string(Follow),
io__write_string("\n").
-hlds_out__write_goal_2(if_then_else(Vars, Cond, Then, Else, _), InstTable, ModuleInfo,
- VarSet, AppendVarnums, Indent, Follow, TypeQual) -->
+hlds_out__write_goal_2(if_then_else(Vars, Cond, Then, Else, _), InstMap0,
+ InstTable, ModuleInfo, VarSet, AppendVarnums, Indent, Follow,
+ TypeQual) -->
hlds_out__write_indent(Indent),
io__write_string("(if"),
hlds_out__write_some(Vars, VarSet),
io__write_string("\n"),
{ Indent1 is Indent + 1 },
- hlds_out__write_goal_a(Cond, InstTable, ModuleInfo, VarSet, AppendVarnums,
- Indent1, "", TypeQual),
+ hlds_out__write_goal_a(Cond, InstMap0, InstTable, ModuleInfo, VarSet,
+ AppendVarnums, Indent1, "", TypeQual),
hlds_out__write_indent(Indent),
io__write_string("then\n"),
- hlds_out__write_goal_a(Then, InstTable, ModuleInfo, VarSet, AppendVarnums,
- Indent1, "", TypeQual),
+ { Cond = _ - CondInfo },
+ { goal_info_get_instmap_delta(CondInfo, IMD) },
+ { instmap__apply_instmap_delta(InstMap0, IMD, InstMap1) },
+ hlds_out__write_goal_a(Then, InstMap1, InstTable, ModuleInfo, VarSet,
+ AppendVarnums, Indent1, "", TypeQual),
hlds_out__write_indent(Indent),
io__write_string("else\n"),
globals__io_lookup_string_option(dump_hlds_options, Verbose),
@@ -1005,11 +1012,11 @@
{ Verbose \= "" },
{ Else = if_then_else(_, _, _, _, _) - _ }
->
- hlds_out__write_goal_a(Else, InstTable, ModuleInfo, VarSet,
- AppendVarnums, Indent, "", TypeQual)
+ hlds_out__write_goal_a(Else, InstMap0, InstTable, ModuleInfo,
+ VarSet, AppendVarnums, Indent, "", TypeQual)
;
- hlds_out__write_goal_a(Else, InstTable, ModuleInfo, VarSet,
- AppendVarnums, Indent1, "", TypeQual)
+ hlds_out__write_goal_a(Else, InstMap0, InstTable, ModuleInfo,
+ VarSet, AppendVarnums, Indent1, "", TypeQual)
),
hlds_out__write_indent(Indent),
io__write_string(")"),
@@ -1016,20 +1023,20 @@
io__write_string(Follow),
io__write_string("\n").
-hlds_out__write_goal_2(not(Goal), InstTable, ModuleInfo, VarSet, AppendVarnums,
- Indent, Follow, TypeQual) -->
+hlds_out__write_goal_2(not(Goal), InstMap0, InstTable, ModuleInfo, VarSet,
+ AppendVarnums, Indent, Follow, TypeQual) -->
hlds_out__write_indent(Indent),
io__write_string("\\+ (\n"),
{ Indent1 is Indent + 1 },
- hlds_out__write_goal_a(Goal, InstTable, ModuleInfo, VarSet, AppendVarnums,
- Indent1, "", TypeQual),
+ hlds_out__write_goal_a(Goal, InstMap0, InstTable, ModuleInfo, VarSet,
+ AppendVarnums, Indent1, "", TypeQual),
hlds_out__write_indent(Indent),
io__write_string(")"),
io__write_string(Follow),
io__write_string("\n").
-hlds_out__write_goal_2(conj(List), InstTable, ModuleInfo, VarSet, AppendVarnums,
- Indent, Follow, TypeQual) -->
+hlds_out__write_goal_2(conj(List), InstMap0, InstTable, ModuleInfo, VarSet,
+ AppendVarnums, Indent, Follow, TypeQual) -->
( { List = [Goal | Goals] } ->
globals__io_lookup_string_option(dump_hlds_options, Verbose),
( { Verbose \= "" } ->
@@ -1036,17 +1043,17 @@
{ Indent1 is Indent + 1 },
hlds_out__write_indent(Indent),
io__write_string("( % conjunction\n"),
- hlds_out__write_conj(Goal, Goals, InstTable, ModuleInfo,
- VarSet, AppendVarnums, Indent1, "", Verbose,
- ",\n", TypeQual),
+ hlds_out__write_conj(Goal, Goals, InstMap0, InstTable,
+ ModuleInfo, VarSet, AppendVarnums, Indent1, "",
+ Verbose, ",\n", TypeQual),
hlds_out__write_indent(Indent),
io__write_string(")"),
io__write_string(Follow),
io__write_string("\n")
;
- hlds_out__write_conj(Goal, Goals, InstTable, ModuleInfo,
- VarSet, AppendVarnums, Indent, Follow, Verbose,
- ",\n", TypeQual)
+ hlds_out__write_conj(Goal, Goals, InstMap0, InstTable,
+ ModuleInfo, VarSet, AppendVarnums, Indent,
+ Follow, Verbose, ",\n", TypeQual)
)
;
hlds_out__write_indent(Indent),
@@ -1055,17 +1062,18 @@
io__write_string("\n")
).
-hlds_out__write_goal_2(par_conj(List, _), InstTable, ModuleInfo, VarSet,
- AppendVarnums, Indent, Follow, TypeQual) -->
+hlds_out__write_goal_2(par_conj(List, _), InstMap0, InstTable, ModuleInfo,
+ VarSet, AppendVarnums, Indent, Follow, TypeQual) -->
hlds_out__write_indent(Indent),
( { List = [Goal | Goals] } ->
io__write_string("( % parallel conjunction\n"),
{ Indent1 is Indent + 1 },
- hlds_out__write_goal_a(Goal, InstTable, ModuleInfo, VarSet,
- AppendVarnums, Indent1, "", TypeQual),
+ hlds_out__write_goal_a(Goal, InstMap0, InstTable, ModuleInfo,
+ VarSet, AppendVarnums, Indent1, "", TypeQual),
% See comments at hlds_out__write_goal_list.
- hlds_out__write_goal_list(Goals, InstTable, ModuleInfo, VarSet,
- AppendVarnums, Indent, "&", TypeQual),
+ hlds_out__write_goal_list(Goals, InstMap0, InstTable,
+ ModuleInfo, VarSet, AppendVarnums, Indent, "&",
+ TypeQual),
hlds_out__write_indent(Indent),
io__write_string(")"),
io__write_string(Follow),
@@ -1077,16 +1085,17 @@
).
-hlds_out__write_goal_2(disj(List, _), InstTable, ModuleInfo, VarSet, AppendVarnums,
- Indent, Follow, TypeQual) -->
+hlds_out__write_goal_2(disj(List, _), InstMap0, InstTable, ModuleInfo, VarSet,
+ AppendVarnums, Indent, Follow, TypeQual) -->
hlds_out__write_indent(Indent),
( { List = [Goal | Goals] } ->
io__write_string("( % disjunction\n"),
{ Indent1 is Indent + 1 },
- hlds_out__write_goal_a(Goal, InstTable, ModuleInfo, VarSet,
- AppendVarnums, Indent1, "", TypeQual),
- hlds_out__write_goal_list(Goals, InstTable, ModuleInfo, VarSet,
- AppendVarnums, Indent, ";", TypeQual),
+ hlds_out__write_goal_a(Goal, InstMap0, InstTable, ModuleInfo,
+ VarSet, AppendVarnums, Indent1, "", TypeQual),
+ hlds_out__write_goal_list(Goals, InstMap0, InstTable,
+ ModuleInfo, VarSet, AppendVarnums, Indent, ";",
+ TypeQual),
hlds_out__write_indent(Indent),
io__write_string(")"),
io__write_string(Follow),
@@ -1098,8 +1107,8 @@
).
hlds_out__write_goal_2(higher_order_call(PredVar, ArgVars, _, _, _, PredOrFunc),
- _InstTable, _ModuleInfo, VarSet, AppendVarnums, Indent,
- Follow, _) -->
+ _InstMap0, _InstTable, _ModuleInfo, VarSet, AppendVarnums,
+ Indent, Follow, _) -->
% XXX we should print more info here
globals__io_lookup_string_option(dump_hlds_options, Verbose),
hlds_out__write_indent(Indent),
@@ -1133,8 +1142,8 @@
io__write_string("\n").
hlds_out__write_goal_2(class_method_call(TCInfoVar, _, ArgVars, _, _, _),
- _InstTable, _ModuleInfo, VarSet, AppendVarnums, Indent,
- Follow, _) -->
+ _InstMap0, _InstTable, _ModuleInfo, VarSet, AppendVarnums,
+ Indent, Follow, _) -->
% XXX we should print more info here too
globals__io_lookup_string_option(dump_hlds_options, Verbose),
hlds_out__write_indent(Indent),
@@ -1151,8 +1160,8 @@
hlds_out__write_goal_2(call(PredId, ProcId, ArgVars, Builtin,
MaybeUnifyContext, PredName),
- InstTable, ModuleInfo, VarSet, AppendVarnums, Indent, Follow,
- TypeQual) -->
+ _InstMap0, InstTable, ModuleInfo, VarSet, AppendVarnums,
+ Indent, Follow, TypeQual) -->
globals__io_lookup_string_option(dump_hlds_options, Verbose),
( { string__contains_char(Verbose, 'b') } ->
(
@@ -1210,9 +1219,9 @@
io__write_string("% unify context: "),
mercury_output_var(Var, VarSet, AppendVarnums),
io__write_string(" = "),
- hlds_out__write_unify_rhs_2(RHS, InstTable, ModuleInfo,
- VarSet, AppendVarnums, Indent, Follow, VarType,
- TypeQual)
+ hlds_out__write_unify_rhs_2(RHS, InstTable,
+ ModuleInfo, VarSet, AppendVarnums,
+ Indent, Follow, VarType, TypeQual)
;
[]
)
@@ -1220,8 +1229,8 @@
[]
).
-hlds_out__write_goal_2(unify(A, B, _, Unification, _), InstTable, ModuleInfo, VarSet,
- AppendVarnums, Indent, Follow, TypeQual) -->
+hlds_out__write_goal_2(unify(A, B, _, Unification, _), InstMap0, InstTable,
+ ModuleInfo, VarSet, AppendVarnums, Indent, Follow, TypeQual) -->
hlds_out__write_indent(Indent),
mercury_output_var(A, VarSet, AppendVarnums),
io__write_string(" = "),
@@ -1231,8 +1240,8 @@
;
VarType = no
},
- hlds_out__write_unify_rhs_2(B, InstTable, ModuleInfo, VarSet, AppendVarnums,
- Indent, Follow, VarType, TypeQual),
+ hlds_out__write_unify_rhs_2(B, InstTable, ModuleInfo, VarSet,
+ AppendVarnums, Indent, Follow, VarType, TypeQual),
globals__io_lookup_string_option(dump_hlds_options, Verbose),
( { string__contains_char(Verbose, 'u') } ->
(
@@ -1246,8 +1255,9 @@
hlds_out__write_indent(Indent),
io__write_string("% Not yet classified\n")
;
- hlds_out__write_unification(Unification, InstTable,
- ModuleInfo, VarSet, AppendVarnums, Indent)
+ hlds_out__write_unification(Unification, InstMap0,
+ InstTable, ModuleInfo, VarSet, AppendVarnums,
+ Indent)
)
;
[]
@@ -1254,7 +1264,7 @@
).
hlds_out__write_goal_2(pragma_c_code(_, _, _, ArgVars, ArgNames, _,
- PragmaCode), _, _, _, _, Indent, Follow, _) -->
+ PragmaCode), _, _, _, _, _, Indent, Follow, _) -->
hlds_out__write_indent(Indent),
io__write_string("$pragma_c_code(["),
hlds_out__write_varnum_list(ArgVars),
@@ -1343,11 +1353,11 @@
io__write_string(", "),
hlds_out__write_string_list([Name2 | Names]).
-:- pred hlds_out__write_unification(unification, inst_table, module_info,
- varset, bool, int, io__state, io__state).
-:- mode hlds_out__write_unification(in, in, in, in, in, in, di, uo) is det.
+:- pred hlds_out__write_unification(unification, instmap, inst_table,
+ module_info, varset, bool, int, io__state, io__state).
+:- mode hlds_out__write_unification(in, in, in, in, in, in, in, di, uo) is det.
-hlds_out__write_unification(assign(X, Y), _, _, VarSet, AppendVarnums,
+hlds_out__write_unification(assign(X, Y), _, _, _, VarSet, AppendVarnums,
Indent) -->
hlds_out__write_indent(Indent),
io__write_string("% "),
@@ -1355,7 +1365,7 @@
io__write_string(" := "),
mercury_output_var(Y, VarSet, AppendVarnums),
io__write_string("\n").
-hlds_out__write_unification(simple_test(X, Y), _, _, VarSet, AppendVarnums,
+hlds_out__write_unification(simple_test(X, Y), _, _, _, VarSet, AppendVarnums,
Indent) -->
hlds_out__write_indent(Indent),
io__write_string("% "),
@@ -1363,7 +1373,7 @@
io__write_string(" == "),
mercury_output_var(Y, VarSet, AppendVarnums),
io__write_string("\n").
-hlds_out__write_unification(construct(Var, ConsId, ArgVars, ArgModes),
+hlds_out__write_unification(construct(Var, ConsId, ArgVars, ArgModes), InstMap,
InstTable, ModuleInfo, VarSet, AppendVarnums, Indent) -->
hlds_out__write_indent(Indent),
io__write_string("% "),
@@ -1370,9 +1380,10 @@
mercury_output_var(Var, VarSet, AppendVarnums),
io__write_string(" := "),
hlds_out_write_functor_and_submodes(ConsId, ArgVars, ArgModes,
- InstTable, ModuleInfo, VarSet, AppendVarnums, Indent).
+ InstMap, InstTable, ModuleInfo, VarSet, AppendVarnums, Indent).
hlds_out__write_unification(deconstruct(Var, ConsId, ArgVars, ArgModes,
- CanFail), InstTable, ModuleInfo, VarSet, AppendVarnums, Indent) -->
+ CanFail), InstMap0, InstTable, ModuleInfo, VarSet,
+ AppendVarnums, Indent) -->
hlds_out__write_indent(Indent),
io__write_string("% "),
mercury_output_var(Var, VarSet, AppendVarnums),
@@ -1383,9 +1394,9 @@
),
!,
hlds_out_write_functor_and_submodes(ConsId, ArgVars, ArgModes,
- InstTable, ModuleInfo, VarSet, AppendVarnums, Indent).
+ InstMap0, InstTable, ModuleInfo, VarSet, AppendVarnums, Indent).
hlds_out__write_unification(complicated_unify(Mode, CanFail),
- InstTable, _ModuleInfo, VarSet, _, Indent) -->
+ _InstMap0, InstTable, _ModuleInfo, VarSet, _, Indent) -->
hlds_out__write_indent(Indent),
io__write_string("% "),
( { CanFail = can_fail },
@@ -1395,16 +1406,19 @@
),
!,
io__write_string("mode: "),
+
+ % XXX may need to pass InstMap0 here.
mercury_output_uni_mode(Mode, VarSet, InstTable),
io__write_string("\n").
:- pred hlds_out_write_functor_and_submodes(cons_id, list(var), list(uni_mode),
- inst_table, module_info, varset, bool, int, io__state, io__state).
-:- mode hlds_out_write_functor_and_submodes(in, in, in, in, in, in, in, in,
+ instmap, inst_table, module_info, varset, bool, int,
+ io__state, io__state).
+:- mode hlds_out_write_functor_and_submodes(in, in, in, in, in, in, in, in, in,
di, uo) is det.
-hlds_out_write_functor_and_submodes(ConsId, ArgVars, ArgModes, InstTable, _ModuleInfo,
- VarSet, AppendVarnums, Indent) -->
+hlds_out_write_functor_and_submodes(ConsId, ArgVars, ArgModes, _InstMap0,
+ InstTable, _ModuleInfo, VarSet, AppendVarnums, Indent) -->
hlds_out__write_cons_id(ConsId),
( { ArgVars = [] } ->
io__write_string("\n")
@@ -1416,7 +1430,10 @@
( { string__contains_char(Verbose, 'a') } ->
hlds_out__write_indent(Indent),
io__write_string("% arg-modes "),
- mercury_output_uni_mode_list(ArgModes, VarSet, InstTable),
+
+ % XXX may need to pass InstMap0 here.
+ mercury_output_uni_mode_list(ArgModes, VarSet,
+ InstTable),
io__write_string("\n")
;
[]
@@ -1425,8 +1442,8 @@
hlds_out__write_unify_rhs(Rhs, InstTable, ModuleInfo, VarSet, AppendVarnums,
Indent) -->
- hlds_out__write_unify_rhs_3(Rhs, InstTable, ModuleInfo, VarSet, AppendVarnums,
- Indent, no, no).
+ hlds_out__write_unify_rhs_3(Rhs, InstTable, ModuleInfo, VarSet,
+ AppendVarnums, Indent, no, no).
:- pred hlds_out__write_unify_rhs_2(unify_rhs, inst_table, module_info,
varset, bool, int, string, maybe(type), vartypes, io__state, io__state).
@@ -1435,8 +1452,8 @@
hlds_out__write_unify_rhs_2(Rhs, InstTable, ModuleInfo, VarSet, AppendVarnums,
Indent, Follow, MaybeType, TypeQual) -->
- hlds_out__write_unify_rhs_3(Rhs, InstTable, ModuleInfo, VarSet, AppendVarnums,
- Indent, MaybeType, TypeQual),
+ hlds_out__write_unify_rhs_3(Rhs, InstTable, ModuleInfo, VarSet,
+ AppendVarnums, Indent, MaybeType, TypeQual),
io__write_string(Follow),
io__write_string("\n").
@@ -1471,8 +1488,9 @@
io__write_string(") is "),
mercury_output_det(Det),
io__write_string(" :-\n"),
- hlds_out__write_goal_a(Goal, InstTable, ModuleInfo, VarSet,
- AppendVarnums, Indent1, "", TypeQual),
+ { instmap__init_reachable(InstMap0) }, % YYY
+ hlds_out__write_goal_a(Goal, InstMap0, InstTable, ModuleInfo,
+ VarSet, AppendVarnums, Indent1, "", TypeQual),
hlds_out__write_indent(Indent),
io__write_string(")")
;
@@ -1488,8 +1506,9 @@
io__write_string(") is "),
mercury_output_det(Det),
io__write_string(" :-\n"),
- hlds_out__write_goal_a(Goal, InstTable, ModuleInfo, VarSet,
- AppendVarnums, Indent1, "", TypeQual),
+ { instmap__init_reachable(InstMap0) }, % YYY
+ hlds_out__write_goal_a(Goal, InstMap0, InstTable, ModuleInfo,
+ VarSet, AppendVarnums, Indent1, "", TypeQual),
hlds_out__write_indent(Indent),
io__write_string(")")
),
@@ -1621,13 +1640,13 @@
io__write_string("::"),
mercury_output_mode(Mode, VarSet, InstTable).
-:- pred hlds_out__write_conj(hlds_goal, list(hlds_goal), inst_table,
+:- pred hlds_out__write_conj(hlds_goal, list(hlds_goal), instmap, inst_table,
module_info, varset, bool, int, string, string, string, vartypes,
io__state, io__state).
-:- mode hlds_out__write_conj(in, in, in, in, in, in, in, in, in, in, in,
+:- mode hlds_out__write_conj(in, in, in, in, in, in, in, in, in, in, in, in,
di, uo) is det.
-hlds_out__write_conj(Goal1, Goals1, InstTable, ModuleInfo, VarSet,
+hlds_out__write_conj(Goal1, Goals1, InstMap0, InstTable, ModuleInfo, VarSet,
AppendVarnums, Indent, Follow, Verbose, Separator, TypeQual) -->
(
{ Goals1 = [Goal2 | Goals2] }
@@ -1638,31 +1657,36 @@
% since that way it visually separates
% the lines after one goal
% and the lines before the next
- hlds_out__write_goal_a(Goal1, InstTable, ModuleInfo, VarSet,
- AppendVarnums, Indent, "", TypeQual),
+ hlds_out__write_goal_a(Goal1, InstMap0, InstTable,
+ ModuleInfo, VarSet, AppendVarnums, Indent,
+ "", TypeQual),
hlds_out__write_indent(Indent),
io__write_string(Separator)
;
- hlds_out__write_goal_a(Goal1, InstTable, ModuleInfo, VarSet,
- AppendVarnums, Indent, ",", TypeQual)
+ hlds_out__write_goal_a(Goal1, InstMap0, InstTable,
+ ModuleInfo, VarSet, AppendVarnums, Indent,
+ ",", TypeQual)
),
- hlds_out__write_conj(Goal2, Goals2, InstTable, ModuleInfo,
- VarSet, AppendVarnums, Indent, Follow, Verbose,
- Separator, TypeQual)
+ { Goal1 = _ - GoalInfo },
+ { goal_info_get_instmap_delta(GoalInfo, IMD) },
+ { instmap__apply_instmap_delta(InstMap0, IMD, InstMap1) },
+ hlds_out__write_conj(Goal2, Goals2, InstMap1, InstTable,
+ ModuleInfo, VarSet, AppendVarnums, Indent, Follow,
+ Verbose, Separator, TypeQual)
;
- hlds_out__write_goal_a(Goal1, InstTable, ModuleInfo, VarSet,
- AppendVarnums, Indent, Follow, TypeQual)
+ hlds_out__write_goal_a(Goal1, InstMap0, InstTable, ModuleInfo,
+ VarSet, AppendVarnums, Indent, Follow, TypeQual)
).
% hlds_out__write_goal_list is used to write both disjunctions and
% parallel conjunctions.
-:- pred hlds_out__write_goal_list(list(hlds_goal), inst_table, module_info,
- varset, bool, int, string, vartypes, io__state, io__state).
-:- mode hlds_out__write_goal_list(in, in, in, in, in, in, in, in, di, uo)
+:- pred hlds_out__write_goal_list(list(hlds_goal), instmap, inst_table,
+ module_info, varset, bool, int, string, vartypes, io__state, io__state).
+:- mode hlds_out__write_goal_list(in, in, in, in, in, in, in, in, in, di, uo)
is det.
-hlds_out__write_goal_list(GoalList, InstTable, ModuleInfo, VarSet,
+hlds_out__write_goal_list(GoalList, InstMap0, InstTable, ModuleInfo, VarSet,
AppendVarnums, Indent, Separator, TypeQual) -->
(
{ GoalList = [Goal | Goals] }
@@ -1671,20 +1695,21 @@
io__write_string(Separator),
io__write_string("\n"),
{ Indent1 is Indent + 1 },
- hlds_out__write_goal_a(Goal, InstTable, ModuleInfo, VarSet,
- AppendVarnums, Indent1, "", TypeQual),
- hlds_out__write_goal_list(Goals, InstTable, ModuleInfo, VarSet,
- AppendVarnums, Indent, Separator, TypeQual)
+ hlds_out__write_goal_a(Goal, InstMap0, InstTable, ModuleInfo,
+ VarSet, AppendVarnums, Indent1, "", TypeQual),
+ hlds_out__write_goal_list(Goals, InstMap0, InstTable,
+ ModuleInfo, VarSet, AppendVarnums, Indent, Separator,
+ TypeQual)
;
[]
).
-:- pred hlds_out__write_case(case, var, inst_table, module_info, varset,
- bool, int, vartypes, io__state, io__state).
-:- mode hlds_out__write_case(in, in, in, in, in, in, in, in, di, uo) is det.
+:- pred hlds_out__write_case(case, var, instmap, inst_table, module_info,
+ varset, bool, int, vartypes, io__state, io__state).
+:- mode hlds_out__write_case(in, in, in, in, in, in, in, in, in, di, uo) is det.
-hlds_out__write_case(case(ConsId, IMDelta, Goal), Var, InstTable, ModuleInfo,
- VarSet, AppendVarnums, Indent, VarTypes) -->
+hlds_out__write_case(case(ConsId, IMDelta, Goal), Var, InstMap0, InstTable,
+ ModuleInfo, VarSet, AppendVarnums, Indent, VarTypes) -->
hlds_out__write_indent(Indent),
io__write_string("% "),
mercury_output_var(Var, VarSet, AppendVarnums),
@@ -1705,7 +1730,7 @@
;
hlds_out__write_indent(Indent),
io__write_string("% new insts: "),
- hlds_out__write_instmap_delta(IMDelta, VarSet,
+ hlds_out__write_instmap_delta(IMDelta, InstMap0, VarSet,
AppendVarnums, Indent, InstTable),
io__write_string("\n")
)
@@ -1712,6 +1737,7 @@
;
[]
),
+ { instmap__apply_instmap_delta(InstMap0, IMDelta, InstMap1) },
% XXX if the output of this is to be used, e.g. in
% inter-module optimization, output a unification to bind the
@@ -1718,15 +1744,16 @@
% Var to the functor, since simplify.m and unused_args.m remove
% the unification. At the moment this is not a problem, since
% intermod.m works on the unoptimized clauses.
- hlds_out__write_goal_a(Goal, InstTable, ModuleInfo, VarSet,
+ hlds_out__write_goal_a(Goal, InstMap1, InstTable, ModuleInfo, VarSet,
AppendVarnums, Indent, "", VarTypes).
-:- pred hlds_out__write_cases(list(case), var, inst_table, module_info,
- varset, bool, int, vartypes, io__state, io__state).
-:- mode hlds_out__write_cases(in, in, in, in, in, in, in, in, di, uo) is det.
+:- pred hlds_out__write_cases(list(case), var, instmap, inst_table,
+ module_info, varset, bool, int, vartypes, io__state, io__state).
+:- mode hlds_out__write_cases(in, in, in, in, in, in, in, in, in, di, uo)
+ is det.
-hlds_out__write_cases(CasesList, Var, InstTable, ModuleInfo, VarSet, AppendVarnums,
- Indent, VarTypes) -->
+hlds_out__write_cases(CasesList, Var, InstMap0, InstTable, ModuleInfo, VarSet,
+ AppendVarnums, Indent, VarTypes) -->
(
{ CasesList = [Case | Cases] }
->
@@ -1733,10 +1760,10 @@
hlds_out__write_indent(Indent),
io__write_string(";\n"),
{ Indent1 is Indent + 1 },
- hlds_out__write_case(Case, Var, InstTable, ModuleInfo,
+ hlds_out__write_case(Case, Var, InstMap0, InstTable, ModuleInfo,
VarSet, AppendVarnums, Indent1, VarTypes),
- hlds_out__write_cases(Cases, Var, InstTable, ModuleInfo,
- VarSet, AppendVarnums, Indent, VarTypes)
+ hlds_out__write_cases(Cases, Var, InstMap0, InstTable,
+ ModuleInfo, VarSet, AppendVarnums, Indent, VarTypes)
;
[]
).
@@ -1755,7 +1782,10 @@
;
{ instmap__to_assoc_list(InstMap, AssocList) },
hlds_out__write_instmap_2(AssocList, VarSet, AppendVarnums,
- Indent, InstMap, InstTable)
+ Indent, InstMap, InstTable),
+ { inst_table_get_inst_key_table(InstTable, IKT) },
+ { instmap__get_inst_key_sub(InstMap, Sub) },
+ hlds_out__write_inst_key_sub(Sub, IKT, Indent)
).
:- pred hlds_out__write_instmap_2(assoc_list(var, inst), varset, bool, int,
@@ -1779,26 +1809,51 @@
InstMap, InstTable)
).
-:- pred hlds_out__write_instmap_delta(instmap_delta, varset, bool, int,
- inst_table, io__state, io__state).
-:- mode hlds_out__write_instmap_delta(in, in, in, in, in, di, uo) is det.
+:- pred hlds_out__write_instmap_delta(instmap_delta, instmap, varset, bool,
+ int, inst_table, io__state, io__state).
+:- mode hlds_out__write_instmap_delta(in, in, in, in, in, in, di, uo) is det.
-hlds_out__write_instmap_delta(InstMapDelta, VarSet, AppendVarnums, Indent,
- InstTable) -->
+hlds_out__write_instmap_delta(InstMapDelta, InstMap0, VarSet, AppendVarnums,
+ Indent, InstTable) -->
( { instmap_delta_is_unreachable(InstMapDelta) } ->
io__write_string("unreachable")
;
- % YYY need to thread the instmap through the
- % goal so that inst_key_subn stays up to date.
- { instmap__init_reachable(InstMap0) },
{ instmap__apply_instmap_delta(InstMap0, InstMapDelta,
InstMap) },
- { instmap__to_assoc_list(InstMap, AssocList) },
+ { instmap_delta_to_assoc_list(InstMapDelta, AssocList) },
hlds_out__write_instmap_2(AssocList, VarSet, AppendVarnums,
- Indent, InstMap, InstTable)
+ Indent, InstMap, InstTable),
+ { inst_table_get_inst_key_table(InstTable, IKT) },
+ { instmap_delta_get_inst_key_sub(InstMapDelta, Sub) },
+ hlds_out__write_inst_key_sub(Sub, IKT, Indent)
).
+:- pred hlds_out__write_inst_key_sub(inst_key_sub, inst_key_table, int,
+ io__state, io__state).
+:- mode hlds_out__write_inst_key_sub(in, in, in, di, uo) is det.
+
+hlds_out__write_inst_key_sub(Sub, IKT, Indent) -->
+ mercury_output_newline(Indent),
+ io__write_string("% Inst key substitutions:"),
+ { map__to_assoc_list(Sub, SubAL) },
+ hlds_out__write_inst_key_sub_2(SubAL, IKT, Indent).
+
+:- pred hlds_out__write_inst_key_sub_2(assoc_list(inst_key), inst_key_table,
+ int, io__state, io__state).
+:- mode hlds_out__write_inst_key_sub_2(in, in, in, di, uo) is det.
+
+hlds_out__write_inst_key_sub_2([], _, _) --> io__nl.
+hlds_out__write_inst_key_sub_2([OldIK - NewIK | Sub], IKT, Indent) -->
+ mercury_output_newline(Indent),
+ io__write_string("% "),
+ inst_key_table_write_inst_key(IKT, OldIK),
+ io__write_string(" -> "),
+ inst_key_table_write_inst_key(IKT, NewIK),
+ hlds_out__write_inst_key_sub_2(Sub, IKT, Indent).
+
+
+
hlds_out__write_import_status(local) -->
io__write_string("local").
hlds_out__write_import_status(exported) -->
@@ -2390,6 +2445,7 @@
{ proc_info_inst_table(Proc, InstTable) },
{ proc_info_typeclass_info_varmap(Proc, TypeClassInfoMap) },
{ proc_info_args_method(Proc, ArgsMethod) },
+ { proc_info_get_initial_instmap(Proc, ModuleInfo, InstMap) },
{ Indent1 is Indent + 1 },
hlds_out__write_indent(Indent1),
@@ -2460,8 +2516,8 @@
hlds_out__write_clause_head(ModuleInfo, PredId, VarSet,
AppendVarnums, HeadVars, PredOrFunc),
io__write_string(" :-\n"),
- hlds_out__write_goal(Goal, InstTable, ModuleInfo, VarSet,
- AppendVarnums, Indent1, ".")
+ hlds_out__write_goal(Goal, InstMap, InstTable, ModuleInfo,
+ VarSet, AppendVarnums, Indent1, ".")
).
% :- pred hlds_out__write_varnames(int, map(var, string), io__state, io__state).
Index: instmap.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/instmap.m,v
retrieving revision 1.15.2.17
diff -u -r1.15.2.17 instmap.m
--- 1.15.2.17 1998/08/07 05:17:29
+++ instmap.m 1998/11/09 00:19:13
@@ -264,7 +264,15 @@
:- mode instmap__inst_key_table_lookup(in, in, in, out) is det.
%-----------------------------------------------------------------------------%
+
+:- pred instmap__get_inst_key_sub(instmap, inst_key_sub).
+:- mode instmap__get_inst_key_sub(in, out) is det.
+
+:- pred instmap_delta_get_inst_key_sub(instmap_delta, inst_key_sub).
+:- mode instmap_delta_get_inst_key_sub(in, out) is det.
+
%-----------------------------------------------------------------------------%
+%-----------------------------------------------------------------------------%
:- implementation.
@@ -1105,3 +1113,10 @@
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
+
+instmap__get_inst_key_sub(unreachable, Sub) :-
+ map__init(Sub).
+instmap__get_inst_key_sub(reachable(_, Sub), Sub).
+
+instmap_delta_get_inst_key_sub(IMD, Sub) :-
+ instmap__get_inst_key_sub(IMD, Sub).
Index: mode_errors.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/mode_errors.m,v
retrieving revision 1.47.4.11
diff -u -r1.47.4.11 mode_errors.m
--- 1.47.4.11 1998/07/27 05:30:47
+++ mode_errors.m 1998/11/06 14:04:21
@@ -345,8 +345,10 @@
( { VeryVerbose = yes } ->
io__write_string("\t\t"),
{ mode_info_get_module_info(ModeInfo, ModuleInfo) },
- hlds_out__write_goal(Goal, InstTable, ModuleInfo, VarSet, no,
- 2, ".")
+ { mode_info_get_instmap(ModeInfo, InstMap) },
+ % YYY is this the right instmap?
+ hlds_out__write_goal(Goal, InstMap, InstTable, ModuleInfo,
+ VarSet, no, 2, ".")
;
[]
),
Index: pd_debug.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/pd_debug.m,v
retrieving revision 1.1.6.3
diff -u -r1.1.6.3 pd_debug.m
--- 1.1.6.3 1998/10/29 22:33:49
+++ pd_debug.m 1998/11/06 14:04:56
@@ -130,8 +130,8 @@
{ instmap__restrict(InstMap, NonLocals, InstMap1) },
hlds_out__write_instmap(InstMap1, VarSet, yes, 1, InstTable),
io__nl,
- hlds_out__write_goal(Goal - GoalInfo, InstTable, ModuleInfo, VarSet,
- no, 1, ""),
+ hlds_out__write_goal(Goal - GoalInfo, InstMap, InstTable, ModuleInfo,
+ VarSet, no, 1, ""),
io__nl,
io__write_string("Parents: "),
{ set__to_sorted_list(Parents, ParentsList) },
@@ -140,8 +140,10 @@
io__nl,
( { WriteUnfoldedGoal = yes } ->
{ proc_info_goal(ProcInfo, ProcGoal) },
+ { proc_info_get_initial_instmap(ProcInfo, ModuleInfo,
+ ProcInstMap) },
io__write_string("Unfolded goal\n"),
- hlds_out__write_goal(ProcGoal, InstTable,
+ hlds_out__write_goal(ProcGoal, ProcInstMap, InstTable,
ModuleInfo, VarSet, no, 1, ""),
io__nl
;
@@ -191,8 +193,8 @@
hlds_out__write_instmap(InstMap1, VarSet, yes, 1, InstTable,
IO1, IO2),
io__nl(IO2, IO3),
- hlds_out__write_goal(Goal - GoalInfo, InstTable, ModuleInfo,
- VarSet, yes, 1, "", IO3, IO4),
+ hlds_out__write_goal(Goal - GoalInfo, InstMap, InstTable,
+ ModuleInfo, VarSet, yes, 1, "", IO3, IO4),
io__nl(IO4, IO5),
io__flush_output(IO5, IO)
},
Index: pd_info.m
===================================================================
RCS file: /home/staff/zs/imp/mercury/compiler/pd_info.m,v
retrieving revision 1.1.6.4
diff -u -r1.1.6.4 pd_info.m
--- 1.1.6.4 1998/10/29 22:33:50
+++ pd_info.m 1998/11/06 13:33:59
@@ -14,7 +14,7 @@
:- interface.
:- import_module pd_term, hlds_module, hlds_pred, options, instmap.
-:- import_module hlds_goal, hlds_data, prog_data.
+:- import_module hlds_goal, prog_data.
:- import_module bool, map, list, io, set, std_util, term, getopt.
:- type pd_info
--
David Overton Department of Computer Science & Software Engineering
MEngSc Student The University of Melbourne, Australia
More information about the developers
mailing list