[m-rev.] diff: dump out structure reuse conditions
Peter Wang
novalazy at gmail.com
Thu Apr 10 14:13:14 AEST 2008
Branches: main
compiler/hlds_out.m:
compiler/prog_ctgc.m:
Dump out structure reuse condition information with
`--dump-hlds-options R'.
Move some predicates from the interface section of prog_ctgc.m into
the implementation.
Index: compiler/hlds_out.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/hlds_out.m,v
retrieving revision 1.448
diff -u -r1.448 hlds_out.m
--- compiler/hlds_out.m 7 Apr 2008 02:32:50 -0000 1.448
+++ compiler/hlds_out.m 10 Apr 2008 04:11:07 -0000
@@ -3937,6 +3937,7 @@
proc_info_get_maybe_arg_size_info(Proc, MaybeArgSize),
proc_info_get_maybe_termination_info(Proc, MaybeTermination),
proc_info_get_structure_sharing(Proc, MaybeStructureSharing),
+ proc_info_get_structure_reuse(Proc, MaybeStructureReuse),
proc_info_get_rtti_varmaps(Proc, RttiVarMaps),
proc_info_get_eval_method(Proc, EvalMethod),
proc_info_get_is_address_taken(Proc, IsAddressTaken),
@@ -3978,7 +3979,7 @@
true
),
- % Dump structure sharing information.
+ % Dump structure sharing information.
( string.contains_char(Verbose, 'S') ->
write_indent(Indent, !IO),
io.write_string("% Structure sharing: \n", !IO),
@@ -3995,6 +3996,22 @@
true
),
+ % Dump structure reuse information.
+ ( string.contains_char(Verbose, 'R') ->
+ write_indent(Indent, !IO),
+ io.write_string("% Structure reuse: \n", !IO),
+ (
+ MaybeStructureReuse = yes(ReuseAs),
+ dump_maybe_structure_reuse_domain(VarSet, TVarSet, yes(ReuseAs),
+ !IO)
+ ;
+ MaybeStructureReuse = no,
+ dump_maybe_structure_reuse_domain(VarSet, TVarSet, no, !IO)
+ )
+ ;
+ true
+ ),
+
write_indent(Indent, !IO),
write_var_types(Indent, VarSet, AppendVarNums, VarTypes, TVarSet, !IO),
write_rtti_varmaps(Indent, AppendVarNums, RttiVarMaps, VarSet, TVarSet,
Index: compiler/prog_ctgc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/prog_ctgc.m,v
retrieving revision 1.17
diff -u -r1.17 prog_ctgc.m
--- compiler/prog_ctgc.m 27 Mar 2008 02:29:42 -0000 1.17
+++ compiler/prog_ctgc.m 10 Apr 2008 04:11:07 -0000
@@ -114,18 +114,12 @@
:- pred dump_maybe_structure_sharing_domain(prog_varset::in, tvarset::in,
maybe(structure_sharing_domain)::in, io::di, io::uo) is det.
+:- pred dump_maybe_structure_reuse_domain(prog_varset::in, tvarset::in,
+ maybe(structure_reuse_domain)::in, io::di, io::uo) is det.
+
:- pred print_interface_structure_sharing_domain(prog_varset::in,
tvarset::in, maybe(structure_sharing_domain)::in, io::di, io::uo) is det.
-:- pred print_structure_reuse_condition(prog_varset::in, tvarset::in,
- structure_reuse_condition::in, io::di, io::uo) is det.
-
-:- pred print_structure_reuse_conditions(prog_varset::in, tvarset::in,
- structure_reuse_conditions::in, io::di, io::uo) is det.
-
-:- pred print_structure_reuse_domain(prog_varset::in, tvarset::in,
- structure_reuse_domain::in, io::di, io::uo) is det.
-
:- pred print_interface_maybe_structure_reuse_domain(prog_varset::in,
tvarset::in, maybe(structure_reuse_domain)::in, io::di, io::uo) is det.
@@ -563,7 +557,7 @@
print_datastructs(ProgVarSet, TypeVarSet, Datastructs, !IO) :-
io.write_string("[", !IO),
- io.write_list(Datastructs, ",", print_datastruct(ProgVarSet, TypeVarSet),
+ io.write_list(Datastructs, ", ", print_datastruct(ProgVarSet, TypeVarSet),
!IO),
io.write_string("]", !IO).
@@ -609,7 +603,7 @@
print_structure_sharing_domain(ProgVarSet, TypeVarSet, VerboseTop,
MaybeThreshold, SharingAs, !IO) :-
do_print_structure_sharing_domain(ProgVarSet, TypeVarSet, VerboseTop,
- MaybeThreshold, "", ",", "", SharingAs, !IO).
+ MaybeThreshold, "", ", ", "", SharingAs, !IO).
:- pred do_print_structure_sharing_domain(prog_varset::in, tvarset::in,
bool::in, maybe(int)::in, string::in, string::in, string::in,
@@ -635,7 +629,7 @@
;
SharingAs = structure_sharing_real(SharingPairs),
print_structure_sharing(ProgVarSet, TypeVarSet,
- MaybeThreshold, "[", Separator, "]", SharingPairs, !IO)
+ MaybeThreshold, "[", Separator, "]", SharingPairs, !IO)
),
io.write_string(End, !IO).
@@ -655,24 +649,38 @@
!IO),
io.write_string(")", !IO).
+dump_maybe_structure_reuse_domain(_, _, no, !IO) :-
+ io.write_string("% no reuse information available.\n", !IO).
+dump_maybe_structure_reuse_domain(ProgVarSet, TypeVarSet, yes(ReuseAs), !IO) :-
+ print_structure_reuse_domain(ProgVarSet, TypeVarSet, ReuseAs, !IO).
+
+:- pred print_structure_reuse_condition(prog_varset::in, tvarset::in,
+ structure_reuse_condition::in, io::di, io::uo) is det.
+
print_structure_reuse_condition(ProgVarSet, TypeVarSet, ReuseCond, !IO) :-
ReuseCond = structure_reuse_condition(DeadNodes, InUseNodes, Sharing),
io.write_string("condition(", !IO),
print_datastructs(ProgVarSet, TypeVarSet, DeadNodes, !IO),
- io.write_string(",", !IO),
+ io.write_string(", ", !IO),
print_datastructs(ProgVarSet, TypeVarSet, InUseNodes, !IO),
- io.write_string(",", !IO),
+ io.write_string(", ", !IO),
print_structure_sharing_domain(ProgVarSet, TypeVarSet, no, no,
Sharing, !IO),
io.write_string(")", !IO).
-print_structure_reuse_conditions(ProgVarSet, TypeVarSet, ReuseConds, !IO) :-
- io.write_string("[", !IO),
- io.write_list(ReuseConds, ",",
- print_structure_reuse_condition(ProgVarSet, TypeVarSet), !IO),
- io.write_string("]", !IO).
+:- pred print_structure_reuse_conditions(prog_varset::in, tvarset::in,
+ string::in, structure_reuse_conditions::in, io::di, io::uo) is det.
+
+print_structure_reuse_conditions(ProgVarSet, TypeVarSet, Separator, ReuseConds,
+ !IO) :-
+ io.write_list(ReuseConds, Separator,
+ print_structure_reuse_condition(ProgVarSet, TypeVarSet), !IO).
+
+:- pred print_structure_reuse_domain(prog_varset::in, tvarset::in,
+ structure_reuse_domain::in, io::di, io::uo) is det.
print_structure_reuse_domain(ProgVarSet, TypeVarSet, ReuseDomain, !IO) :-
+ io.write_string("%\t ", !IO),
(
ReuseDomain = has_no_reuse,
io.write_string("has_no_reuse", !IO)
@@ -681,11 +689,12 @@
io.write_string("has_only_unconditional_reuse", !IO)
;
ReuseDomain = has_conditional_reuse(ReuseConditions),
- io.write_string("has_conditional_reuse(", !IO),
+ io.write_string("has_conditional_reuse([\n%\t\t ", !IO),
print_structure_reuse_conditions(ProgVarSet, TypeVarSet,
- ReuseConditions, !IO),
- io.write_string(")", !IO)
- ).
+ ", \n%\t\t ", ReuseConditions, !IO),
+ io.write_string("\n%\t ])", !IO)
+ ),
+ io.write_string("\n", !IO).
print_interface_maybe_structure_reuse_domain(_, _, no, !IO) :-
io.write_string("not_available", !IO).
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to: mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions: mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------
More information about the reviews
mailing list