[m-dev.] for review: type specialisation round 2
Simon Taylor
stayl at cs.mu.OZ.AU
Wed Sep 9 10:47:19 AEST 1998
> > + % A constraint says nothing if the types are all ground.
> > + list__member(Type, Types),
> > + \+ term__is_ground(Type)
>
> This is not always true. Constraints on ground types can make sense
> if the instance declaration is visible in the caller but not in the
> callee.
OK, I'll remove the elimination of ground constraints -- it can't hurt
to have them lying around even if they aren't needed.
> > + (
> > + list__member(ConstrainedType, ConstrainedTypes),
> > + \+ term__is_ground(ConstrainedType)
> > + ->
> > + true
> > + ;
> > + fail
> > + )
>
> Hmm, `(A -> true ; fail)' is the same as `A'.
> I don't think the if-then-else improves readability here, does it?
What I meant was
some([ConstrainedType],
list__member(ConstrainedType, ConstrainedTypes),
\+ term__is_ground(ConstrainedType)
)
Here's a relative diff addressing your comments:
===================================================================
RCS file: RCS/higher_order.m,v
retrieving revision 1.6
diff -u -r1.6 higher_order.m
--- higher_order.m 1998/09/08 23:03:13 1.6
+++ higher_order.m 1998/09/09 00:35:19
@@ -1598,9 +1598,9 @@
%-----------------------------------------------------------------------------%
- % Collect the list class_constraints from the list of argument types.
- % The typeclass_info for universal constraints is input, output for
- % existential constraints.
+ % Collect the list of class_constraints from the list of argument
+ % types. The typeclass_info for universal constraints is input,
+ % output for existential constraints.
:- pred find_class_context(module_info::in, list(type)::in, list(mode)::in,
list(class_constraint)::in, list(class_constraint)::in,
class_constraints::out) is det.
@@ -1637,12 +1637,8 @@
strip_term_contexts(Types0, Types),
Constraint = constraint(ClassName, Types),
(
- % Remove duplicates
- \+ list__member(Constraint, Constraints0),
-
- % A constraint says nothing if the types are all ground.
- list__member(Type, Types),
- \+ term__is_ground(Type)
+ % Remove duplicates.
+ \+ list__member(Constraint, Constraints0)
->
Constraints = [Constraint | Constraints0]
;
@@ -1672,20 +1668,7 @@
add_extra_typeclass_infos_2([Var | Vars], [Type0 | Types],
TCVarMap0, TCVarMap) :-
strip_term_context(Type0, Type),
- (
- polymorphism__typeclass_info_class_constraint(Type,
- Constraint),
- Constraint = constraint(_, ConstrainedTypes),
-
- (
- list__member(ConstrainedType, ConstrainedTypes),
- \+ term__is_ground(ConstrainedType)
- ->
- true
- ;
- fail
- )
- ->
+ ( polymorphism__typeclass_info_class_constraint(Type, Constraint) ->
map__set(TCVarMap0, Constraint, Var, TCVarMap1)
;
TCVarMap1 = TCVarMap0
===================================================================
RCS file: RCS/type_util.m,v
retrieving revision 1.4
diff -u -r1.4 type_util.m
--- type_util.m 1998/09/08 23:03:13 1.4
+++ type_util.m 1998/09/09 00:39:04
@@ -158,8 +158,9 @@
:- mode apply_rec_substitution_to_type_map(in, in, out) is det.
% Update a map from tvar to type_info_locn, using the type renaming
- % and substitution to rename tvars and a variable substition to
- % rename vars.
+ % and substitution to rename tvars and a variable substitution to
+ % rename vars. The type renaming is applied before the type
+ % substitution.
%
% If tvar maps to a another type variable, we keep the new
% variable, if it maps to a type, we remove it from the map.
@@ -170,10 +171,8 @@
% Update a map from class_constraint to var, using the type renaming
% and substitution to rename tvars and a variable substition to
- % rename vars.
- %
- % If the constraint no longer constraints any type variables,
- % we remove it from the map.
+ % rename vars. The type renaming is applied before the type
+ % substitution.
:- pred apply_substitutions_to_typeclass_var_map(map(class_constraint, var),
tsubst, map(tvar, type), map(var, var), map(class_constraint, var)).
@@ -782,33 +781,20 @@
apply_substitutions_to_typeclass_var_map(VarMap0,
TRenaming, TSubst, Subst, VarMap) :-
map__to_assoc_list(VarMap0, VarAL0),
- list__filter_map(
- apply_substitutions_to_typeclass_var_map_2(TRenaming,
- TSubst, Subst),
- VarAL0, VarAL),
+ list__map(apply_substitutions_to_typeclass_var_map_2(TRenaming,
+ TSubst, Subst), VarAL0, VarAL),
map__from_assoc_list(VarAL, VarMap).
:- pred apply_substitutions_to_typeclass_var_map_2(tsubst, map(tvar, type),
map(var, var), pair(class_constraint, var),
pair(class_constraint, var)).
:- mode apply_substitutions_to_typeclass_var_map_2(in, in,
- in, in, out) is semidet.
+ in, in, out) is det.
apply_substitutions_to_typeclass_var_map_2(TRenaming, TSubst, VarRenaming,
Constraint0 - Var0, Constraint - Var) :-
apply_subst_to_constraint(TRenaming, Constraint0, Constraint1),
apply_rec_subst_to_constraint(TSubst, Constraint1, Constraint),
-
- % Check that the constraint still constrains some type variables.
- Constraint = constraint(_, Types),
- (
- list__member(Type, Types),
- \+ term__is_ground(Type)
- ->
- true
- ;
- fail
- ),
( map__search(VarRenaming, Var0, Var1) ->
Var = Var1
===================================================================
RCS file: RCS/options.m,v
retrieving revision 1.1
diff -u -r1.1 options.m
--- options.m 1998/09/08 00:08:40 1.1
+++ options.m 1998/09/09 00:35:42
@@ -1751,7 +1751,10 @@
"--no-disable-opt-for-trace",
"\tEnabling tracing usually disables optimizations which could",
"\tmake it difficult to relate the trace to the source code.",
- "\tThis option is useful when debugging those optimizations."
+ "\t`--no-disable-opt-for-trace' results in only those",
+ "\toptimizations which don't work with tracing being disabled.",
+ "\tThis is useful for debugging the optimization passes of",
+ "\tthe compiler."
]).
:- pred options_help_hlds_hlds_optimization(io__state::di, io__state::uo)
Index: user_guide.texi
===================================================================
RCS file: /home/staff/zs/imp/mercury/doc/user_guide.texi,v
retrieving revision 1.133
diff -u -t -u -r1.133 user_guide.texi
--- user_guide.texi 1998/08/10 07:17:09 1.133
+++ user_guide.texi 1998/09/09 00:33:21
@@ -2390,6 +2390,15 @@
@samp{@var{MODULE}.split} target, i.e. type @samp{mmake foo.split}
rather than @samp{mmake foo}.
+ at sp 1
+ at item --no-disable-opt-for-trace
+Enabling tracing usually disables optimizations which could
+make it difficult to relate the trace to the source code.
+ at samp{--no-disable-opt-for-trace} results in only those
+optimizations which don't work with tracing being disabled.
+This is useful for debugging the optimization passes of
+the compiler.
+
@end table
@node High-level (HLDS -> HLDS) optimization options
More information about the developers
mailing list