[m-rev.] diff: switch some modules to four-space indentation
Zoltan Somogyi
zs at cs.mu.OZ.AU
Mon Aug 8 12:56:45 AEST 2005
compiler/abstract_mode_constraints.m:
compiler/accumulator.m:
compiler/arg_info.m:
compiler/assertion.m:
compiler/atsort.m:
compiler/basic_block.m:
compiler/build_mode_constraints.m:
compiler/call_gen.m:
compiler/clause_to_proc.m:
Convert these modules to four-space indentation to reduce the number
of bad line breaks.
Various minor cleanups.
There are no algorithmic changes.
Zoltan.
cvs diff: Diffing .
cvs diff: Diffing analysis
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/doc
cvs diff: Diffing boehm_gc/include
cvs diff: Diffing boehm_gc/include/private
cvs diff: Diffing boehm_gc/tests
cvs diff: Diffing browser
cvs diff: Diffing bytecode
cvs diff: Diffing compiler
Index: compiler/abstract_mode_constraints.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/abstract_mode_constraints.m,v
retrieving revision 1.3
diff -u -b -r1.3 abstract_mode_constraints.m
--- compiler/abstract_mode_constraints.m 24 Mar 2005 02:00:11 -0000 1.3
+++ compiler/abstract_mode_constraints.m 7 Aug 2005 03:15:55 -0000
@@ -1,4 +1,6 @@
%-----------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et
+%-----------------------------------------------------------------------------%
% Copyright (C) 2004-2005 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,6 +55,7 @@
:- type constraint_formulae == list(constraint_formula).
:- type constraint_formula
---> atomic_constraint(var_constraint)
+
; disj(constraint_formulae)
% Initially included for the purposes of
% representing the mode declaration constraints,
@@ -60,6 +63,7 @@
% other constraints. The intended form is:
% disj([conj(...), ..., conj(...)]) Note
% disj([]) represents false.
+
; conj(constraint_formulae).
% See disj.
% Note that conj([]) is the empty constraint, or true.
@@ -70,27 +74,32 @@
---> equiv_bool(var(T), bool)
% equiv_bool(X, yes) gives the constraint (X)
% equiv_bool(X, no) gives the constraint not(X)
+
; equivalent(list(var(T)))
% equivalent(Xs) gives (all Xi, Xj in Xs).(Xi<->Xj)
+
; implies(var(T), var(T))
% implies(X, Y) gives X->Y
+
; equiv_disj(var(T), list(var(T)))
% equiv_disj(X, [Y1,...,Yn]) gives X<->OR(Y1,...,Yn)
% XXX Thinking of making a constraint that is
% the conjunction of equiv_disj and at_most_one
% because they occur together so often.
+
; at_most_one(list(var(T)))
% at_most_one(Xs) gives
% (all Xi, Xj in Xs).(i = j or not(Xi and Xj))
+
; at_least_one(list(var(T)))
% at_least_one(Xs) gives OR(Xs)
+
; exactly_one(list(var(T))).
% exactly_one(Xs) gives
% at_least_one(Xs) and at_most_one(Xs)
% Attempts to print the constraint_formulae it is passed in a
- % human readable format. Always puts a new line after it is
- % finished.
+ % human readable format. Always puts a new line after it is finished.
%
:- pred pretty_print_constraints(mc_varset::in, constraint_formulae::in,
io::di, io::uo) is det.
@@ -139,8 +148,7 @@
% Constraining the variables in the var_map.
var_map :: map(mc_var, var_state),
- % The variables this constraint system
- % constrains.
+ % The variables this constraint system constrains.
id_counter :: counter
% Supplies unique IDs for the constraint map.
@@ -191,16 +199,12 @@
% The constraint that finally bound it.
history :: list(mc_var)
- % The variables in the constraint
- % that bound this variable that
- % had already been bound at that
- % point - their binding_constraint
- % and history can be looked at
- % recursively to build the full
- % history. I strongly prefer this
- % to listing the full history
- % each time a variable is bound,
- % for space considerations.
+ % The variables in the constraint that bound this
+ % variable that had already been bound at that point
+ % - their binding_constraint and history can be looked
+ % at recursively to build the full history. I strongly
+ % prefer this to listing the full history each time
+ % a variable is bound, for space considerations.
).
:- type constrainment_info --->
@@ -251,7 +255,7 @@
% Initiates all the parts of a mode_constraints_info type.
%
abstract_mode_constraints.init(ModeConstraintsInfo) :-
- % Start allocating ids from 0
+ % Start allocating ids from 0.
ModeConstraintsInfo = mode_constraints_info(map.init, map.init,
counter.init(0)).
@@ -265,10 +269,8 @@
abstract_mode_constraints.add_constraint(ConstraintFormula,
!ModeConstraintsInfo) :-
formula_to_formula_and_vars(ConstraintFormula, Vars, FormulaAndVars),
- counter.allocate(NewID, !.ModeConstraintsInfo ^ id_counter,
- NewCounter),
- !:ModeConstraintsInfo =
- !.ModeConstraintsInfo ^ id_counter := NewCounter,
+ counter.allocate(NewID, !.ModeConstraintsInfo ^ id_counter, NewCounter),
+ !:ModeConstraintsInfo = !.ModeConstraintsInfo ^ id_counter := NewCounter,
update_vars_map_with_constrainment_info(constrainment_info(NewID),
Vars, !ModeConstraintsInfo),
Constraint = constraint(NewID, FormulaAndVars, FormulaAndVars),
@@ -282,10 +284,10 @@
abstract_mode_constraints.add_constraint(CF, MCI0) = MCI :-
abstract_mode_constraints.add_constraint(CF, MCI0, MCI).
-% update_vars_map_with_constrainment_info adds the supplied
-% constrainment_info to the list of constraints associated with each of
-% the variables supplied in the mode_constraints_info structure.
-
+ % update_vars_map_with_constrainment_info adds the supplied
+ % constrainment_info to the list of constraints associated with each of
+ % the variables supplied in the mode_constraints_info structure.
+ %
:- pred update_vars_map_with_constrainment_info(constrainment_info::in,
list(mc_var)::in,
mode_constraints_info::in, mode_constraints_info::out) is det.
@@ -373,9 +375,9 @@
% Pretty printing predicates for the formulae type, and others
%
-pretty_print_constraints(Varset, Constraints, !IO) :-
+pretty_print_constraints(VarSet, Constraints, !IO) :-
Indent = "",
- pretty_print_constraints(Varset, Constraints, Indent, !IO).
+ pretty_print_constraints(VarSet, Constraints, Indent, !IO).
% Same as before, but with an indent argument used to indent
% conjunctions and disjunctions of constraints.
@@ -383,10 +385,10 @@
:- pred pretty_print_constraints(mc_varset::in, constraint_formulae::in,
string::in, io::di, io::uo) is det.
-pretty_print_constraints(_Varset, [], _Indent, !IO).
-pretty_print_constraints(Varset, [Constr | Constrs], Indent, !IO) :-
- pretty_print_constraint(Varset, Constr, Indent, !IO),
- pretty_print_constraints(Varset, Constrs, Indent, !IO).
+pretty_print_constraints(_VarSet, [], _Indent, !IO).
+pretty_print_constraints(VarSet, [Constr | Constrs], Indent, !IO) :-
+ pretty_print_constraint(VarSet, Constr, Indent, !IO),
+ pretty_print_constraints(VarSet, Constrs, Indent, !IO).
% Prints one constraint_formulae to the output stream. Always
% puts a new line at the end.
@@ -394,25 +396,23 @@
:- pred pretty_print_constraint(mc_varset::in, constraint_formula::in,
string::in, io::di, io::uo) is det.
-pretty_print_constraint(Varset, disj(Constraints), Indent, !IO) :-
- io.print(Indent, !IO),
- io.print("disj(\n", !IO),
- pretty_print_constraints(Varset, Constraints, "\t" ++ Indent, !IO),
- io.print(Indent, !IO),
- io.print(") end disj", !IO),
- io.nl(!IO).
-
-pretty_print_constraint(Varset, conj(Constraints), Indent, !IO) :-
- io.print(Indent, !IO),
- io.print("conj(\n", !IO),
- pretty_print_constraints(Varset, Constraints, "\t" ++ Indent, !IO),
- io.print(Indent, !IO),
- io.print(") end conj", !IO),
- io.nl(!IO).
-
-pretty_print_constraint(Varset, atomic_constraint(Constraint), Indent, !IO) :-
- io.print(Indent, !IO),
- pretty_print_var_constraint(Varset, Constraint, !IO),
+pretty_print_constraint(VarSet, disj(Constraints), Indent, !IO) :-
+ io.write_string(Indent, !IO),
+ io.write_string("disj(\n", !IO),
+ pretty_print_constraints(VarSet, Constraints, "\t" ++ Indent, !IO),
+ io.write_string(Indent, !IO),
+ io.write_string(") end disj\n", !IO).
+
+pretty_print_constraint(VarSet, conj(Constraints), Indent, !IO) :-
+ io.write_string(Indent, !IO),
+ io.write_string("conj(\n", !IO),
+ pretty_print_constraints(VarSet, Constraints, "\t" ++ Indent, !IO),
+ io.write_string(Indent, !IO),
+ io.write_string(") end conj\n", !IO).
+
+pretty_print_constraint(VarSet, atomic_constraint(Constraint), Indent, !IO) :-
+ io.write_string(Indent, !IO),
+ pretty_print_var_constraint(VarSet, Constraint, !IO),
io.nl(!IO).
% Prints a var_constraint to the screen. No indents, no line
@@ -421,75 +421,64 @@
:- pred pretty_print_var_constraint(mc_varset::in, var_constraint::in,
io::di, io::uo) is det.
-pretty_print_var_constraint(Varset, equiv_bool(X, TF), !IO) :-
- pretty_print_mc_var(Varset, X, !IO),
- io.print(" = ", !IO),
+pretty_print_var_constraint(VarSet, equiv_bool(X, TF), !IO) :-
+ pretty_print_mc_var(VarSet, X, !IO),
+ io.write_string(" = ", !IO),
io.print(TF, !IO).
-pretty_print_var_constraint(Varset, equivalent(Xs), !IO) :-
- io.print("equivalent(", !IO),
- pretty_print_mc_vars(Varset, Xs, !IO),
- io.print(")", !IO).
-
-pretty_print_var_constraint(Varset, implies(X, Y), !IO) :-
- pretty_print_mc_var(Varset, X, !IO),
- io.print(" -> ", !IO),
- pretty_print_mc_var(Varset, Y, !IO).
-
-pretty_print_var_constraint(Varset, equiv_disj(X, Xs), !IO) :-
- pretty_print_mc_var(Varset, X, !IO),
- io.print(" <-> disj(", !IO),
- pretty_print_mc_vars(Varset, Xs, !IO),
- io.print(")", !IO).
-
-pretty_print_var_constraint(Varset, at_most_one(Xs), !IO) :-
- io.print("at_most_one(", !IO),
- pretty_print_mc_vars(Varset, Xs, !IO),
- io.print(")", !IO).
-
-pretty_print_var_constraint(Varset, at_least_one(Xs), !IO) :-
- io.print("at_least_one(", !IO),
- pretty_print_mc_vars(Varset, Xs, !IO),
- io.print(")", !IO).
-
-pretty_print_var_constraint(Varset, exactly_one(Xs), !IO) :-
- io.print("exactly_one(", !IO),
- pretty_print_mc_vars(Varset, Xs, !IO),
- io.print(")", !IO).
+pretty_print_var_constraint(VarSet, equivalent(Xs), !IO) :-
+ io.write_string("equivalent(", !IO),
+ pretty_print_mc_vars(VarSet, Xs, !IO),
+ io.write_string(")", !IO).
+
+pretty_print_var_constraint(VarSet, implies(X, Y), !IO) :-
+ pretty_print_mc_var(VarSet, X, !IO),
+ io.write_string(" -> ", !IO),
+ pretty_print_mc_var(VarSet, Y, !IO).
+
+pretty_print_var_constraint(VarSet, equiv_disj(X, Xs), !IO) :-
+ pretty_print_mc_var(VarSet, X, !IO),
+ io.write_string(" <-> disj(", !IO),
+ pretty_print_mc_vars(VarSet, Xs, !IO),
+ io.write_string(")", !IO).
+
+pretty_print_var_constraint(VarSet, at_most_one(Xs), !IO) :-
+ io.write_string("at_most_one(", !IO),
+ pretty_print_mc_vars(VarSet, Xs, !IO),
+ io.write_string(")", !IO).
+
+pretty_print_var_constraint(VarSet, at_least_one(Xs), !IO) :-
+ io.write_string("at_least_one(", !IO),
+ pretty_print_mc_vars(VarSet, Xs, !IO),
+ io.write_string(")", !IO).
+
+pretty_print_var_constraint(VarSet, exactly_one(Xs), !IO) :-
+ io.write_string("exactly_one(", !IO),
+ pretty_print_mc_vars(VarSet, Xs, !IO),
+ io.write_string(")", !IO).
- % Prints a constraint var to the screen. No indents, no line
- % return. Simply uses the variable's name from the varset.
+ % Prints a constraint var to the screen. No indents, no line return.
+ % Simply uses the variable's name from the varset.
%
:- pred pretty_print_mc_var(mc_varset::in, mc_var::in,
io::di, io::uo) is det.
-pretty_print_mc_var(Varset, Var, !IO) :-
- varset.lookup_name(Varset, Var, VarName),
- io.print(VarName, !IO).
+pretty_print_mc_var(VarSet, Var, !IO) :-
+ varset.lookup_name(VarSet, Var, VarName),
+ io.write_string(VarName, !IO).
% Prints a comma separated list of constraint variables.
%
:- pred pretty_print_mc_vars(mc_varset::in, list(mc_var)::in,
io::di, io::uo) is det.
-pretty_print_mc_vars(_Varset, [], !IO).
-pretty_print_mc_vars(Varset, [Var | Tail], !IO) :-
- pretty_print_mc_var(Varset, Var, !IO),
- pretty_print_mc_vars_tail(Varset, Tail, !IO).
-
- % Prints a comma separated list of constraint variables under
- % the assumption that at least one has already been printed - ie
- % prints a divider then prints the rest of the list. If there
- % is no more list it does nothing.
- %
-:- pred pretty_print_mc_vars_tail(mc_varset::in, list(mc_var)::in,
- io::di, io::uo) is det.
-
-pretty_print_mc_vars_tail(_Varset, [], !IO).
-pretty_print_mc_vars_tail(Varset, [Var | Vars], !IO) :-
- io.print(", ", !IO),
- pretty_print_mc_vars(Varset, [Var | Vars], !IO).
-
-%-----------------------------------------------------------------------------%
-:- end_module abstract_mode_constraints.
-%-----------------------------------------------------------------------------%
+pretty_print_mc_vars(_VarSet, [], !IO).
+pretty_print_mc_vars(VarSet, [Var | Vars], !IO) :-
+ pretty_print_mc_var(VarSet, Var, !IO),
+ (
+ Vars = []
+ ;
+ Vars = [_ | _],
+ io.write_string(", ", !IO),
+ pretty_print_mc_vars(VarSet, Vars, !IO)
+ ).
Index: compiler/accumulator.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/accumulator.m,v
retrieving revision 1.38
diff -u -b -r1.38 accumulator.m
--- compiler/accumulator.m 22 Jul 2005 12:31:51 -0000 1.38
+++ compiler/accumulator.m 7 Aug 2005 04:05:13 -0000
@@ -1,4 +1,6 @@
%-----------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et
+%-----------------------------------------------------------------------------%
% Copyright (C) 1999-2000,2002-2005 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.
@@ -29,19 +31,17 @@
% ).
%
% XXX What about exceptions and non-termination?
-% The promise declarations above only provide promises
-% about the declarative semantics, but in order to
-% apply this optimization, we ought to check that
-% it will preserve the operational semantics
-% (modulo whatever changes are allowed by the
-% language semantics options).
-% Currently we check and respect the --fully-strict option,
-% but not the --no-reorder-conj option.
-% XXX we should check --no-reorder-conj!
-% If --no-reorder-conj was set, it would still be OK to
-% apply this transformation, but ONLY in cases where
-% the goals which get reordered are guaranteed not to
-% throw any exceptions.
+%
+% The promise declarations above only provide promises about the declarative
+% semantics, but in order to apply this optimization, we ought to check that
+% it will preserve the operational semantics (modulo whatever changes are
+% allowed by the language semantics options).
+%
+% Currently we check and respect the --fully-strict option, but not the
+% --no-reorder-conj option. XXX we should check --no-reorder-conj!
+% If --no-reorder-conj was set, it would still be OK to apply this
+% transformation, but ONLY in cases where the goals which get reordered
+% are guaranteed not to throw any exceptions.
%
% The algorithm implemented is a combination of the algorithms from
% "Making Mercury Programs Tail Recursive" and
@@ -213,26 +213,20 @@
:- type subst == map(prog_var, prog_var).
:- type warning
- % warn that two prog_vars in call to pred_id
+ ---> warn(prog_context, pred_id, prog_var, prog_var).
+ % Warn that two prog_vars in call to pred_id
% at prog_context were swapped, which may cause
% an efficiency problem.
- ---> warn(prog_context, pred_id, prog_var, prog_var).
:- type warnings == list(warning).
%-----------------------------------------------------------------------------%
- %
- % process_proc
- %
- % Attempt to transform a procedure into accumulator
- % recursive form.
+ % Attempt to transform a procedure into accumulator recursive form.
%
process_proc(PredId, ProcId, !ProcInfo, !ModuleInfo, !IO) :-
- globals__io_lookup_bool_option(optimize_constructor_last_call, DoLCO,
- !IO),
- globals__io_lookup_bool_option(fully_strict, FullyStrict,
- !IO),
+ globals__io_lookup_bool_option(optimize_constructor_last_call, DoLCO, !IO),
+ globals__io_lookup_bool_option(fully_strict, FullyStrict, !IO),
(
module_info_pred_info(!.ModuleInfo, PredId, PredInfo),
attempt_transform(ProcId, PredId, PredInfo, DoLCO, FullyStrict,
@@ -240,87 +234,65 @@
->
globals__io_lookup_bool_option(very_verbose, VeryVerbose, !IO),
(
- VeryVerbose = yes
- ->
- io__write_string("% Accumulators introduced into ",
- !IO),
+ VeryVerbose = yes,
+ io__write_string("% Accumulators introduced into ", !IO),
hlds_out__write_pred_id(!.ModuleInfo, PredId, !IO),
io__write_string("\n", !IO)
;
- true
+ VeryVerbose = no
),
globals__io_lookup_bool_option(inhibit_accumulator_warnings,
InhibitWarnings, !IO),
(
- ( InhibitWarnings = yes ; Warnings = [] )
+ ( InhibitWarnings = yes
+ ; Warnings = []
+ )
->
true
;
+ pred_info_context(PredInfo, Context),
PredPieces = describe_one_pred_name(!.ModuleInfo,
should_module_qualify, PredId),
- pred_info_context(PredInfo, Context),
-
- error_util__write_error_pieces(Context, 0,
- [words("In") | PredPieces], !IO),
+ write_error_pieces(Context, 0, [words("In") | PredPieces], !IO),
proc_info_varset(!.ProcInfo, VarSet),
output_warnings(Warnings, VarSet, !.ModuleInfo, !IO),
- error_util__write_error_pieces(Context, 2,
- [
- words("Please ensure that these"),
- words("argument rearrangements"),
- words("do not introduce"),
+ Pieces1 = [words("Please ensure that these"),
+ words("argument rearrangements do not introduce"),
words("performance problems."),
- words("These warnings can"),
- words("be suppressed by"),
- words("`--inhibit-accumulator-warnings'.")
- ], !IO),
-
- globals__io_lookup_bool_option(verbose_errors,
- VerboseErrors, !IO),
- (
- VerboseErrors = yes
- ->
- error_util__write_error_pieces(Context, 2,
- [
- words("If a predicate has been"),
- words("declared associative via"),
- words("a `promise' declaration,"),
- words("the compiler will"),
- words("rearrange the order"),
- words("of the arguments"),
- words("in calls to that"),
- words("predicate, if by so doing"),
- words("it makes the containing"),
- words("predicate tail recursive."),
- words("In such situations, the"),
- words("compiler will issue"),
- words("this warning."),
- words("If this reordering changes the"),
- words("performance characteristics"),
- words("of the call to the"),
- words("predicate, use"),
- words("`--no-accumulator-introduction'"),
- words("to turn the optimization"),
- words("off, or"),
- words("`--inhibit-accumulator-warnings'"),
- words("to turn off the warnings.")
- ], !IO)
+ words("These warnings can be suppressed by"),
+ words("`--inhibit-accumulator-warnings'.")],
+ write_error_pieces(Context, 2, Pieces1, !IO),
+
+ globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
+ (
+ VerboseErrors = yes,
+ Pieces2 = [words("If a predicate has been declared"),
+ words("associative via a `promise' declaration,"),
+ words("the compiler will rearrange the order of"),
+ words("the arguments in calls to that predicate,"),
+ words("if by so doing it makes the containing predicate"),
+ words("tail recursive. In such situations, the compiler"),
+ words("will issue this warning. If this reordering"),
+ words("changes the performance characteristics"),
+ words("of the call to the predicate, use"),
+ words("`--no-accumulator-introduction' to turn"),
+ words("the optimization off, or "),
+ words("`--inhibit-accumulator-warnings' to turn off"),
+ words("the warnings.")],
+ write_error_pieces(Context, 2, Pieces2, !IO)
;
- true
+ VerboseErrors = no
),
-
- globals__io_lookup_bool_option(halt_at_warn,
- HaltAtWarn, !IO),
+ globals__io_lookup_bool_option(halt_at_warn, HaltAtWarn, !IO),
(
- HaltAtWarn = yes
- ->
+ HaltAtWarn = yes,
io__set_exit_status(1, !IO),
module_info_incr_errors(!ModuleInfo)
;
- true
+ HaltAtWarn = no
)
)
;
@@ -336,7 +308,7 @@
output_warnings([], _, _, !IO).
output_warnings([W | Ws], VarSet, ModuleInfo, !IO) :-
output_warning(W, VarSet, ModuleInfo, Context, Format),
- error_util__write_error_pieces(Context, 2, Format, !IO),
+ write_error_pieces(Context, 2, Format, !IO),
output_warnings(Ws, VarSet, ModuleInfo, !IO).
:- pred output_warning(warning::in, prog_varset::in, module_info::in,
@@ -355,13 +327,11 @@
Formats = [words("warning: the call to")] ++ PredPieces ++
[words("has had the location of the variables"),
words(VarAStr), words("and"), words(VarBStr),
- words("swapped to allow accumulator introduction.")
- ].
+ words("swapped to allow accumulator introduction.")].
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
- %
% attempt_transform is only true iff the current
% proc has been transformed to call the newly created
% accumulator proc.
@@ -387,7 +357,6 @@
TopLevel, DoLCO, FullyStrict, PredId, PredInfo,
!ProcInfo, !ModuleInfo, Warnings).
- %
% attempt_transform_2 takes a list of locations of the recursive
% calls, and attempts to introduce accumulator into each of the
% recursive calls, stopping at the first one that succeeds.
@@ -410,32 +379,27 @@
Warnings) :-
(
proc_info_vartypes(!.ProcInfo, VarTypes0),
- identify_out_and_out_prime(Id, Rec, HeadVars,
- InitialInstMap, VarTypes0, !.ModuleInfo, Out,
- OutPrime, HeadToCallSubst, CallToHeadSubst),
- stage1(Id, M, C, DoLCO, FullyStrict, VarTypes0, !.ModuleInfo,
- Sets),
+ identify_out_and_out_prime(Id, Rec, HeadVars, InitialInstMap,
+ VarTypes0, !.ModuleInfo, Out, OutPrime,
+ HeadToCallSubst, CallToHeadSubst),
+ stage1(Id, M, C, DoLCO, FullyStrict, VarTypes0, !.ModuleInfo, Sets),
stage2(Id, C, Sets, OutPrime, Out, !.ModuleInfo, !.ProcInfo,
- VarSet, VarTypes, Accs, BaseCase, BasePairs,
- Substs, CS, Warnings0),
+ VarSet, VarTypes, Accs, BaseCase, BasePairs, Substs, CS,
+ WarningsPrime),
stage3(Id, Accs, VarSet, VarTypes, C, CS, Substs,
- HeadToCallSubst, CallToHeadSubst,
- BaseCase, BasePairs, Sets, Out, TopLevel,
- PredId, PredInfo, !ProcInfo, !ModuleInfo)
+ HeadToCallSubst, CallToHeadSubst, BaseCase, BasePairs, Sets, Out,
+ TopLevel, PredId, PredInfo, !ProcInfo, !ModuleInfo)
->
- Warnings = Warnings0
+ Warnings = WarningsPrime
;
attempt_transform_2(Ids, C, M, Rec, HeadVars, InitialInstMap,
- TopLevel, DoLCO, FullyStrict,
- PredId, PredInfo, !ProcInfo, !ModuleInfo, Warnings)
+ TopLevel, DoLCO, FullyStrict, PredId, PredInfo, !ProcInfo,
+ !ModuleInfo, Warnings)
).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
- %
- % standardize
- %
% Transform the goal into a standard form that is amenable to
% introducing accumulators.
%
@@ -464,7 +428,6 @@
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
- %
% This predicate takes the original goal and identifies the
% `shape' of the goal around the recursive and base cases.
% Note that the base case can contain a recursive call, as the
@@ -529,16 +492,16 @@
Rec = GoalAList,
BaseInstMap = InitialInstMap,
- instmap__apply_instmap_delta(InitialInstMap,
- IfInstMapDelta, RecInstMap)
+ instmap__apply_instmap_delta(InitialInstMap, IfInstMapDelta,
+ RecInstMap)
; is_recursive_case(GoalBList, proc(PredId, ProcId)) ->
Type = ite_base_rec,
Base = GoalAList,
Rec = GoalBList,
RecInstMap = InitialInstMap,
- instmap__apply_instmap_delta(InitialInstMap,
- IfInstMapDelta, BaseInstMap)
+ instmap__apply_instmap_delta(InitialInstMap, IfInstMapDelta,
+ BaseInstMap)
;
fail
)
@@ -546,7 +509,6 @@
fail
).
- %
% is_recursive_case(Gs, Id) is true iff the list of goals, Gs,
% contains a call to the procedure specified by Id, where the
% call is located in a position that can be used by the
@@ -565,13 +527,12 @@
% represent the base and recursive case conjunctions.
:- type store_info
---> store_info(
- int, % the location of the goal in
- % the conjunction.
- instmap,
- goal_store
+ store_loc :: int,
+ % The location of the goal in the conjunction.
+ store_instmap :: instmap,
+ store_goals :: goal_store
).
- %
% Initialise the goal_store, which will hold the C_{a,b} goals.
%
:- func initialize_goal_store(hlds_goals, instmap, hlds_goals, instmap)
@@ -584,7 +545,6 @@
list__foldl(store(base), Base, store_info(1, BaseInstMap, C1),
store_info(_, _, C)).
- %
% store(Id, G, SI0, SI) is true iff the goal G is stored inside
% the goal_store (which is part of SI) with the correct
% identifier and instmap associatied with the goal.
@@ -619,9 +579,6 @@
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
- %
- % identify_out_and_out_prime
- %
% Determine the variables which are members of the sets Out and
% Out', and initialize the substitutions between the two sets.
%
@@ -670,13 +627,12 @@
list__map((pred(X-Y::in, Y-X::out) is det), HeadArg, ArgHead),
map__from_assoc_list(ArgHead, CallToHeadSubst)
;
- error("accumulator__identify_out_and_out_prime")
+ unexpected(this_file, "identify_out_and_out_prime")
).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
- %
% For each goal after the recursive call, we place that goal
% into a set according to what properties that goal has.
% For the definition of what goes into each set, inspect the
@@ -692,7 +648,6 @@
reject :: set(goal_id)
).
- %
% Stage 1 is responsible for identifying which goals are
% associative, which can be moved before the recursive call and
% so on.
@@ -728,65 +683,55 @@
DoLCO = yes
).
- %
- % For each goal after the recursive call decide which set the
- % goal belongs to.
+ % For each goal after the recursive call decide which set
+ % the goal belongs to.
%
:- pred stage1_2(goal_id::in, int::in, int::in, goal_store::in,
bool::in, vartypes::in, module_info::in, sets::in, sets::out) is det.
-stage1_2(N - I, K, M, GoalStore, FullyStrict, VarTypes, ModuleInfo,
- Sets0, Sets) :-
+stage1_2(N - I, K, M, GoalStore, FullyStrict, VarTypes, ModuleInfo, !Sets) :-
( I > M ->
- Sets0 = Sets
+ true
;
(
- before(N - I, K, GoalStore, Sets0,
- FullyStrict, VarTypes, ModuleInfo)
+ before(N - I, K, GoalStore, !.Sets, FullyStrict, VarTypes,
+ ModuleInfo)
+ ->
+ !:Sets = !.Sets ^ before := set__insert(!.Sets ^ before, N - I),
+ stage1_2(N - (I+1), K, M, GoalStore, FullyStrict, VarTypes,
+ ModuleInfo, !Sets)
+ ;
+ assoc(N - I, K, GoalStore, !.Sets, FullyStrict, VarTypes,
+ ModuleInfo)
+ ->
+ !:Sets = !.Sets ^ assoc := set__insert(!.Sets ^ assoc, N - I),
+ stage1_2(N - (I+1), K, M, GoalStore, FullyStrict, VarTypes,
+ ModuleInfo, !Sets)
+ ;
+ construct(N - I, K, GoalStore, !.Sets, FullyStrict, VarTypes,
+ ModuleInfo)
->
- stage1_2(N - (I+1), K, M, GoalStore,
- FullyStrict, VarTypes, ModuleInfo,
- Sets0^before :=
- set__insert(Sets0^before, N - I),
- Sets)
- ;
- assoc(N - I, K, GoalStore, Sets0,
- FullyStrict, VarTypes, ModuleInfo)
- ->
- stage1_2(N - (I+1), K, M, GoalStore,
- FullyStrict, VarTypes, ModuleInfo,
- Sets0^assoc :=
- set__insert(Sets0^assoc, N - I),
- Sets)
- ;
- construct(N - I, K, GoalStore, Sets0,
- FullyStrict, VarTypes, ModuleInfo)
- ->
- stage1_2(N - (I+1), K, M, GoalStore,
- FullyStrict, VarTypes, ModuleInfo,
- Sets0^construct :=
- set__insert(Sets0^construct, N - I),
- Sets)
- ;
- construct_assoc(N - I, K, GoalStore, Sets0,
- FullyStrict, VarTypes, ModuleInfo)
- ->
- stage1_2(N - (I+1), K, M, GoalStore,
- FullyStrict, VarTypes, ModuleInfo,
- Sets0^construct_assoc :=
- set__insert(Sets0^construct_assoc, N-I),
- Sets)
- ;
- update(N - I, K, GoalStore, Sets0,
- FullyStrict, VarTypes, ModuleInfo)
- ->
- stage1_2(N - (I+1), K, M, GoalStore,
- FullyStrict, VarTypes, ModuleInfo,
- Sets0^update :=
- set__insert(Sets0^update, N - I),
- Sets)
+ !:Sets = !.Sets ^ construct :=
+ set__insert(!.Sets ^ construct, N - I),
+ stage1_2(N - (I+1), K, M, GoalStore, FullyStrict, VarTypes,
+ ModuleInfo, !Sets)
;
- Sets = Sets0^reject := set__insert(Sets0^reject, N - I)
+ construct_assoc(N - I, K, GoalStore, !.Sets, FullyStrict, VarTypes,
+ ModuleInfo)
+ ->
+ !:Sets = !.Sets ^ construct_assoc :=
+ set__insert(!.Sets ^ construct_assoc, N-I),
+ stage1_2(N - (I+1), K, M, GoalStore, FullyStrict, VarTypes,
+ ModuleInfo, !Sets)
+ ;
+ update(N - I, K, GoalStore, !.Sets, FullyStrict, VarTypes,
+ ModuleInfo)
+ ->
+ !:Sets = !.Sets ^ update := set__insert(!.Sets ^ update, N - I),
+ stage1_2(N - (I+1), K, M, GoalStore, FullyStrict, VarTypes,
+ ModuleInfo, !Sets)
+ ;
+ !:Sets = !.Sets ^ reject := set__insert(!.Sets ^ reject, N - I)
)
).
@@ -804,8 +749,7 @@
Reject = EmptySet,
Sets = sets(Before, Assoc, ConstructAssoc, Construct, Update, Reject).
- %
- % set_upto(N, K) returns the set {(N,1)...(N,K)}
+ % set_upto(N, K) returns the set {(N,1)...(N,K)}.
%
:- func set_upto(int, int) = set(goal_id).
@@ -842,7 +786,6 @@
set__member(N - J, set_upto(N, K-1) `union` Before)
).
- %
% A goal is a member of the assoc set iff the goal only depends
% on goals upto and including the recursive call and goals which
% can be moved before the recursive call (member of the before
@@ -854,21 +797,19 @@
assoc(N - I, K, GoalStore, sets(Before, _, _, _, _, _),
FullyStrict, VarTypes, ModuleInfo) :-
goal_store__lookup(GoalStore, N - I, LaterGoal - LaterInstMap),
- LaterGoal = call(PredId, ProcId, Args, _, _, _) - _,
- is_associative(PredId, ProcId, ModuleInfo, Args, _),
+ LaterGoal = call(PredId, _, Args, _, _, _) - _,
+ is_associative(PredId, ModuleInfo, Args, _),
(
member_lessthan_goalid(GoalStore, N - I, _N - J,
EarlierGoal - EarlierInstMap),
- not goal_util__can_reorder_goals(ModuleInfo, VarTypes,
- FullyStrict, EarlierInstMap, EarlierGoal,
- LaterInstMap, LaterGoal)
+ not goal_util__can_reorder_goals(ModuleInfo, VarTypes, FullyStrict,
+ EarlierInstMap, EarlierGoal, LaterInstMap, LaterGoal)
)
=>
(
set__member(N - J, set_upto(N, K) `union` Before)
).
- %
% A goal is a member of the construct set iff the goal only depends
% on goals upto and including the recursive call and goals which
% can be moved before the recursive call (member of the before
@@ -885,9 +826,8 @@
(
member_lessthan_goalid(GoalStore, N - I, _N - J,
EarlierGoal - EarlierInstMap),
- not goal_util__can_reorder_goals(ModuleInfo, VarTypes,
- FullyStrict, EarlierInstMap, EarlierGoal,
- LaterInstMap, LaterGoal)
+ not goal_util__can_reorder_goals(ModuleInfo, VarTypes, FullyStrict,
+ EarlierInstMap, EarlierGoal, LaterInstMap, LaterGoal)
)
=>
(
@@ -895,7 +835,6 @@
Construct)
).
- %
% A goal is a member of the construct_assoc set iff the goal
% only depends on goals upto and including the recursive call
% and goals which can be moved before the recursive call (member
@@ -926,9 +865,8 @@
(
member_lessthan_goalid(GoalStore, N - I, _N - J,
EarlierGoal - EarlierInstMap),
- not goal_util__can_reorder_goals(ModuleInfo, VarTypes,
- FullyStrict, EarlierInstMap, EarlierGoal,
- LaterInstMap, LaterGoal)
+ not goal_util__can_reorder_goals(ModuleInfo, VarTypes, FullyStrict,
+ EarlierInstMap, EarlierGoal, LaterInstMap, LaterGoal)
)
=>
(
@@ -936,7 +874,6 @@
Assoc `union` ConstructAssoc)
).
- %
% A goal is a member of the update set iff the goal only depends
% on goals upto and including the recursive call and goals which
% can be moved before the recursive call (member of the before
@@ -948,21 +885,19 @@
update(N - I, K, GoalStore, sets(Before, _, _, _, _, _),
FullyStrict, VarTypes, ModuleInfo) :-
goal_store__lookup(GoalStore, N - I, LaterGoal - LaterInstMap),
- LaterGoal = call(PredId, ProcId, Args, _, _, _) - _,
- is_update(PredId, ProcId, ModuleInfo, Args, _),
+ LaterGoal = call(PredId, _, Args, _, _, _) - _,
+ is_update(PredId, ModuleInfo, Args, _),
(
member_lessthan_goalid(GoalStore, N - I, _N - J,
EarlierGoal - EarlierInstMap),
- not goal_util__can_reorder_goals(ModuleInfo, VarTypes,
- FullyStrict, EarlierInstMap, EarlierGoal,
- LaterInstMap, LaterGoal)
+ not goal_util__can_reorder_goals(ModuleInfo, VarTypes, FullyStrict,
+ EarlierInstMap, EarlierGoal, LaterInstMap, LaterGoal)
)
=>
(
set__member(N - J, set_upto(N, K) `union` Before)
).
- %
% member_lessthan_goalid(GS, IdA, IdB, GB) is true iff the
% goal_id, IdB, and its associated goal, GB, is a member of the
% goal_store, GS, and IdB is less than IdA.
@@ -983,21 +918,19 @@
bool % is the predicate commutative?
).
- %
% If accumulator_is_associative is true, it returns the two
% arguments which are associative and the variable which depends
% on those two arguments, and an indicator of whether or not
% the predicate is commutative.
%
-:- pred is_associative(pred_id::in, proc_id::in, module_info::in,
- prog_vars::in, assoc::out) is semidet.
+:- pred is_associative(pred_id::in, module_info::in, prog_vars::in, assoc::out)
+ is semidet.
-is_associative(PredId, ProcId, ModuleInfo, Args, Result) :-
- module_info_pred_proc_info(ModuleInfo, PredId, ProcId,
- PredInfo, _ProcInfo),
+is_associative(PredId, ModuleInfo, Args, Result) :-
+ module_info_pred_info(ModuleInfo, PredId, PredInfo),
pred_info_get_assertions(PredInfo, Assertions),
- associativity_assertion(set__to_sorted_list(Assertions),
- ModuleInfo, Args, AssociativeVars, OutputVar),
+ associativity_assertion(set__to_sorted_list(Assertions), ModuleInfo,
+ Args, AssociativeVars, OutputVar),
(
commutativity_assertion(set__to_sorted_list(Assertions),
ModuleInfo, Args, _CommutativeVars)
@@ -1008,9 +941,6 @@
),
Result = assoc(AssociativeVars, OutputVar, IsCommutative).
- %
- % associativity_assertion
- %
% Does there exist one (and only one) associativity assertion for the
% current predicate.
% The 'and only one condition' is required because we currently
@@ -1031,13 +961,9 @@
VarAB = set__list_to_set([VarA, VarB]),
OutputVar = OutputVar0
;
- associativity_assertion(AssertIds, ModuleInfo, Args0,
- VarAB, OutputVar)
+ associativity_assertion(AssertIds, ModuleInfo, Args0, VarAB, OutputVar)
).
- %
- % commutativity_assertion
- %
% Does there exist one (and only one) commutativity assertion for the
% current predicate.
% The 'and only one condition' is required because we currently
@@ -1063,15 +989,13 @@
%-----------------------------------------------------------------------------%
- %
% Does the current predicate update some state?
%
-:- pred is_update(pred_id::in, proc_id::in, module_info::in,
- prog_vars::in, pair(prog_var)::out) is semidet.
+:- pred is_update(pred_id::in, module_info::in, prog_vars::in,
+ pair(prog_var)::out) is semidet.
-is_update(PredId, ProcId, ModuleInfo, Args, ResultStateVars) :-
- module_info_pred_proc_info(ModuleInfo, PredId, ProcId,
- PredInfo, _ProcInfo),
+is_update(PredId, ModuleInfo, Args, ResultStateVars) :-
+ module_info_pred_info(ModuleInfo, PredId, PredInfo),
pred_info_get_assertions(PredInfo, Assertions),
@@ -1088,7 +1012,6 @@
%-----------------------------------------------------------------------------%
- %
% Can the construction unification be expressed as a call to the
% specified predicate.
%
@@ -1097,9 +1020,7 @@
is_associative_construction(ConsId, PredId, ModuleInfo) :-
module_info_pred_info(ModuleInfo, PredId, PredInfo),
-
pred_info_get_assertions(PredInfo, Assertions),
-
list__filter(
(pred(AssertId::in) is semidet :-
assertion__is_construction_equivalence_assertion(
@@ -1129,7 +1050,6 @@
% other goals
).
- %
% Stage 2 is responsible for identifying the substitutions which
% are needed to mimic the unfold/fold process that was used as
% the justification of the algorithm in the paper.
@@ -1163,25 +1083,22 @@
goal_info_get_nonlocals(GoalInfo, NonLocals),
Set = NonLocals `union` Set0
),
- list__foldl(P, set__to_sorted_list(Before), set__init,
- BeforeNonLocals),
- list__foldl(P, set__to_sorted_list(After), set__init,
- AfterNonLocals),
+ list__foldl(P, set__to_sorted_list(Before), set__init, BeforeNonLocals),
+ list__foldl(P, set__to_sorted_list(After), set__init, AfterNonLocals),
InitAccs = BeforeNonLocals `intersect` AfterNonLocals,
proc_info_varset(ProcInfo0, !:VarSet),
proc_info_vartypes(ProcInfo0, !:VarTypes),
- substs_init(set__to_sorted_list(InitAccs), !VarSet, !VarTypes,
- !:Substs),
+ substs_init(set__to_sorted_list(InitAccs), !VarSet, !VarTypes, !:Substs),
set__list_to_set(OutPrime, OutPrimeSet),
process_assoc_set(set__to_sorted_list(Assoc), GoalStore, OutPrimeSet,
ModuleInfo, !Substs, !VarSet, !VarTypes, CS, Warnings),
process_update_set(set__to_sorted_list(Update), GoalStore, OutPrimeSet,
- ModuleInfo, !Substs, !VarSet, !VarTypes, UpdateOut,
- UpdateAccOut, BasePairs),
+ ModuleInfo, !Substs, !VarSet, !VarTypes, UpdateOut, UpdateAccOut,
+ BasePairs),
Accs = set__to_sorted_list(InitAccs) `append` UpdateAccOut,
@@ -1204,7 +1121,6 @@
Substs = substs(AccVarSubst, RecCallSubst, AssocCallSubst,
UpdateSubst).
- %
% Initialise the acc_var_subst to be from Var to A_Var where
% Var is a member of InitAccs and A_Var is a fresh variable of
% the same type of Var.
@@ -1218,7 +1134,6 @@
acc_var_subst_init(Vars, !VarSet, !VarTypes, Subst0),
map__det_insert(Subst0, Var, AccVar, Subst).
- %
% Create a fresh variable which is the same type as the old
% variable and has the same name except that it begins with the
% prefix.
@@ -1235,7 +1150,6 @@
%-----------------------------------------------------------------------------%
- %
% For each member of the assoc set determine the substitutions
% needed, and also check the efficiency of the procedure isn't
% worsened by reordering the arguments to a call.
@@ -1255,8 +1169,8 @@
lookup_call(GS, Id, Goal - InstMap),
- Goal = call(PredId, ProcId, Args, _, _, _) - GoalInfo,
- is_associative(PredId, ProcId, ModuleInfo, Args, AssocInfo),
+ Goal = call(PredId, _, Args, _, _, _) - GoalInfo,
+ is_associative(PredId, ModuleInfo, Args, AssocInfo),
AssocInfo = assoc(Vars, AssocOutput, IsCommutative),
set__singleton_set(Vars `intersect` OutPrime, DuringAssocVar),
set__singleton_set(Vars `difference` (Vars `intersect` OutPrime),
@@ -1265,16 +1179,12 @@
map__lookup(AccVarSubst, BeforeAssocVar, AccVar),
create_new_var(BeforeAssocVar, "NewAcc_", NewAcc, !VarSet, !VarTypes),
- map__det_insert(AssocCallSubst0, DuringAssocVar, AccVar,
- AssocCallSubst1),
- map__det_insert(AssocCallSubst1, AssocOutput, NewAcc,
- AssocCallSubst),
- map__det_insert(RecCallSubst0, DuringAssocVar, AssocOutput,
- RecCallSubst1),
+ map__det_insert(AssocCallSubst0, DuringAssocVar, AccVar, AssocCallSubst1),
+ map__det_insert(AssocCallSubst1, AssocOutput, NewAcc, AssocCallSubst),
+ map__det_insert(RecCallSubst0, DuringAssocVar, AssocOutput, RecCallSubst1),
map__det_insert(RecCallSubst1, BeforeAssocVar, NewAcc, RecCallSubst),
- !:Substs = substs(AccVarSubst, RecCallSubst, AssocCallSubst,
- UpdateSubst),
+ !:Substs = substs(AccVarSubst, RecCallSubst, AssocCallSubst, UpdateSubst),
% ONLY swap the order of the variables if the goal is
% associative and not commutative.
@@ -1285,8 +1195,7 @@
;
IsCommutative = no,
- % Ensure that the reordering doesn't cause a
- % efficiency problem
+ % Ensure that the reordering doesn't cause a efficiency problem.
module_info_pred_info(ModuleInfo, PredId, PredInfo),
ModuleName = pred_info_module(PredInfo),
PredName = pred_info_name(PredInfo),
@@ -1294,21 +1203,18 @@
(
has_heuristic(ModuleName, PredName, Arity)
->
- % Only do the transformation if the
- % accumulator variable is *not* in a
- % position where it will control the
- % running time of the predicate.
-
+ % Only do the transformation if the accumulator variable is
+ % *not* in a position where it will control the running time
+ % of the predicate.
heuristic(ModuleName, PredName, Arity, Args,
PossibleDuringAssocVars),
set__member(DuringAssocVar, PossibleDuringAssocVars),
Warning = []
;
goal_info_get_context(GoalInfo, ProgContext),
- Warning = [warn(ProgContext, PredId,
- BeforeAssocVar, DuringAssocVar)]
+ Warning = [warn(ProgContext, PredId, BeforeAssocVar,
+ DuringAssocVar)]
),
-
% Swap the arguments.
[A, B] = set__to_sorted_list(Vars),
map__from_assoc_list([A-B, B-A], Subst),
@@ -1325,7 +1231,6 @@
has_heuristic(unqualified("list"), "append", 3).
- %
% heuristic returns the set of which head variables are
% important in the running time of the predicate.
%
@@ -1337,7 +1242,6 @@
%-----------------------------------------------------------------------------%
- %
% For each member of the update set determine the substitions
% needed (creating the accumulator variables when needed).
% Also associate with each Output variable which accumulator
@@ -1346,20 +1250,18 @@
:- pred process_update_set(list(goal_id)::in, goal_store::in, set(prog_var)::in,
module_info::in, substs::in, substs::out,
prog_varset::in, prog_varset::out, vartypes::in, vartypes::out,
- prog_vars::out, prog_vars::out,
- list(pair(prog_var))::out) is semidet.
+ prog_vars::out, prog_vars::out, list(pair(prog_var))::out) is semidet.
process_update_set([], _GS, _OutPrime, _ModuleInfo, !Substs,
!VarSet, !VarTypes, [], [], []).
process_update_set([Id | Ids], GS, OutPrime, ModuleInfo, !Substs,
!VarSet, !VarTypes, StateOutputVars, Accs, BasePairs) :-
-
!.Substs = substs(AccVarSubst0, RecCallSubst0, AssocCallSubst,
UpdateSubst0),
lookup_call(GS, Id, Goal - _InstMap),
- Goal = call(PredId, ProcId, Args, _, _, _) - _GoalInfo,
- is_update(PredId, ProcId, ModuleInfo, Args, StateVarA - StateVarB),
+ Goal = call(PredId, _, Args, _, _, _) - _GoalInfo,
+ is_update(PredId, ModuleInfo, Args, StateVarA - StateVarB),
( set__member(StateVarA, OutPrime) ->
StateInputVar = StateVarA,
@@ -1377,18 +1279,16 @@
map__det_insert(RecCallSubst0, StateInputVar, StateOutputVar,
RecCallSubst),
map__det_insert(AccVarSubst0, Acc, Acc0, AccVarSubst),
- !:Substs = substs(AccVarSubst, RecCallSubst, AssocCallSubst,
- UpdateSubst),
+ !:Substs = substs(AccVarSubst, RecCallSubst, AssocCallSubst, UpdateSubst),
process_update_set(Ids, GS, OutPrime, ModuleInfo, !Substs,
!VarSet, !VarTypes, StateOutputVars0, Accs0, BasePairs0),
- % Rather then concatenating to start of the list we
- % concatenate to the end of the list. This allows the
- % accumulator introduction to be applied as the
- % heuristic will succeed (remember after transforming the
- % two input variables will have their order swapped, so
- % they must be in the inefficient order to start with)
+ % Rather then concatenating to start of the list we concatenate to the end
+ % of the list. This allows the accumulator introduction to be applied
+ % as the heuristic will succeed (remember after transforming the two
+ % input variables will have their order swapped, so they must be in the
+ % inefficient order to start with)
append(StateOutputVars0, [StateOutputVar], StateOutputVars),
append(Accs0, [Acc], Accs),
@@ -1396,8 +1296,7 @@
%-----------------------------------------------------------------------------%
- %
- % divide_base_case(UpdateOut, Out, U, A, O)
+ % divide_base_case(UpdateOut, Out, U, A, O):
%
% is true iff given the output variables which are instantiated
% by update goals, UpdateOut, and all the variables that need to
@@ -1435,8 +1334,7 @@
(base_case_ids_set(C) `intersect`
set__power_union(set__list_to_set(OtherBaseList))).
- %
- % related(GS, MI, V, Ids)
+ % related(GS, MI, V, Ids):
%
% Return all the goal_ids, Ids, which are needed to initialize
% the variable, V, from the goal store, GS.
@@ -1457,14 +1355,12 @@
set__singleton_set(ChangedVars, Var)
), Ids),
( Ids = [Id] ->
- goal_store__all_ancestors(GS, Id, VarTypes, ModuleInfo, no,
- Ancestors),
+ goal_store__all_ancestors(GS, Id, VarTypes, ModuleInfo, no, Ancestors),
list__filter((pred((base - _)::in) is semidet),
- set__to_sorted_list(set__insert(Ancestors, Id)),
- RelatedList),
+ set__to_sorted_list(set__insert(Ancestors, Id)), RelatedList),
Related = set__list_to_set(RelatedList)
;
- error("accumulator:related")
+ unexpected(this_file, "related")
).
%-----------------------------------------------------------------------------%
@@ -1473,8 +1369,8 @@
:- inst hlds_call ---> call - ground.
:- inst call_goal ---> hlds_call - ground.
- % Do a goal_store__lookup where the result is known to be a
- % call.
+ % Do a goal_store__lookup where the result is known to be a call.
+ %
:- pred lookup_call(goal_store::in, goal_id::in,
goal_store__goal::out(call_goal)) is det.
@@ -1483,13 +1379,12 @@
( Goal = call(_, _, _, _, _, _) - _ ->
Call = Goal
;
- error("accumulator__lookup_call: not a call.")
+ unexpected(this_file, "lookup_call: not a call.")
).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
- %
% stage3 creates the accumulator version of the predicate using
% the substitutions determined in stage2, it also redefines the
% original procedure to call the accumulator version of the
@@ -1506,7 +1401,6 @@
HeadToCallSubst, CallToHeadSubst, BaseCase, BasePairs,
Sets, Out, TopLevel, OrigPredId, OrigPredInfo, !OrigProcInfo,
!ModuleInfo) :-
-
acc_proc_info(Accs, VarSet, VarTypes, Substs, !.OrigProcInfo,
AccTypes, AccProcInfo),
acc_pred_info(AccTypes, Out, AccProcInfo, OrigPredId, OrigPredInfo,
@@ -1517,9 +1411,8 @@
predicate_table_insert(AccPredInfo, AccPredId, PredTable0, PredTable),
module_info_set_predicate_table(PredTable, !ModuleInfo),
create_goal(RecCallId, Accs, AccPredId, AccProcId, AccName, Substs,
- HeadToCallSubst, CallToHeadSubst, BaseCase,
- BasePairs, Sets, C, CS, OrigBaseGoal,
- OrigRecGoal, AccBaseGoal, AccRecGoal),
+ HeadToCallSubst, CallToHeadSubst, BaseCase, BasePairs, Sets, C, CS,
+ OrigBaseGoal, OrigRecGoal, AccBaseGoal, AccRecGoal),
proc_info_goal(!.OrigProcInfo, OrigGoal0),
top_level(TopLevel, OrigGoal0, OrigBaseGoal, OrigRecGoal,
@@ -1534,9 +1427,6 @@
%-----------------------------------------------------------------------------%
- %
- % acc_proc_info
- %
% Construct a proc_info for the introduced predicate.
%
:- pred acc_proc_info(prog_vars::in, prog_varset::in, vartypes::in,
@@ -1544,7 +1434,6 @@
acc_proc_info(Accs0, VarSet, VarTypes, Substs,
OrigProcInfo, AccTypes, AccProcInfo) :-
-
% ProcInfo Stuff that must change.
proc_info_headvars(OrigProcInfo, HeadVars0),
proc_info_argmodes(OrigProcInfo, HeadModes0),
@@ -1560,17 +1449,15 @@
_UpdateSubst),
list__map(map__lookup(AccVarSubst), Accs0, Accs),
- % We place the extra accumulator variables at the start,
- % because placing them at the end breaks the convention
- % that the last variable of a function is the output
- % variable.
+ % We place the extra accumulator variables at the start, because placing
+ % them at the end breaks the convention that the last variable of a
+ % function is the output variable.
HeadVars = Accs `append` HeadVars0,
- % XXX we don't want to use the inst of the var as it can
- % be more specific than it should be. ie int_const(1)
- % when it should be any integer.
- % However this will no longer handle partially
- % instantiated data structures.
+ % XXX we don't want to use the inst of the var as it can be more specific
+ % than it should be. ie int_const(1) when it should be any integer.
+ % However this will no longer handle partially instantiated data
+ % structures.
Inst = ground(shared, none),
inst_lists_to_mode_list([Inst], [Inst], Mode),
list__duplicate(list__length(Accs), list__det_head(Mode), AccModes),
@@ -1579,22 +1466,17 @@
list__map(map__lookup(VarTypes), Accs, AccTypes),
proc_info_create(Context, VarSet, VarTypes, HeadVars, InstVarSet,
- HeadModes, Detism, Goal, RttiVarMaps, IsAddressTaken,
- AccProcInfo).
+ HeadModes, Detism, Goal, RttiVarMaps, IsAddressTaken, AccProcInfo).
%-----------------------------------------------------------------------------%
- %
- % acc_pred_info
- %
- % Construct the pred_info for the introduced predicate
+ % Construct the pred_info for the introduced predicate.
%
:- pred acc_pred_info(list(type)::in, prog_vars::in, proc_info::in,
pred_id::in, pred_info::in, proc_id::out, pred_info::out) is det.
acc_pred_info(NewTypes, OutVars, NewProcInfo, OrigPredId, OrigPredInfo,
NewProcId, NewPredInfo) :-
-
% PredInfo stuff that must change.
pred_info_arg_types(OrigPredInfo, TypeVarSet, ExistQVars, Types0),
@@ -1626,7 +1508,6 @@
%-----------------------------------------------------------------------------%
- %
% create_goal creates the new base and recursive case of the
% original procedure (OrigBaseGoal and OrigRecGoal) and the base
% and recursive cases of accumulator version (AccBaseGoal and
@@ -1639,8 +1520,7 @@
create_goal(RecCallId, Accs, AccPredId, AccProcId, AccName, Substs,
HeadToCallSubst, CallToHeadSubst, BaseIds, BasePairs,
- Sets, C, CS, OrigBaseGoal, OrigRecGoal, AccBaseGoal,
- AccRecGoal) :-
+ Sets, C, CS, OrigBaseGoal, OrigRecGoal, AccBaseGoal, AccRecGoal) :-
lookup_call(C, RecCallId, OrigCall - _InstMap),
Call = create_acc_call(OrigCall, Accs, AccPredId, AccProcId, AccName),
@@ -1649,7 +1529,6 @@
create_acc_goal(Call, Substs, HeadToCallSubst, BaseIds, BasePairs,
Sets, C, CS, AccBaseGoal, AccRecGoal).
- %
% create_acc_call takes the original call and generates a call
% to the accumulator version of the call, which can have the
% substitutions applied to it easily.
@@ -1662,7 +1541,6 @@
Call = call(AccPredId, AccProcId, Accs `append` Args,
Builtin, Context, AccName) - GI.
- %
% Create the goals which are to replace the original predicate.
%
:- pred create_orig_goal(hlds_goal::in, substs::in, subst::in,
@@ -1671,13 +1549,10 @@
create_orig_goal(Call, Substs, HeadToCallSubst, CallToHeadSubst,
BaseIds, Sets, C, OrigBaseGoal, OrigRecGoal) :-
-
- Substs = substs(_AccVarSubst, _RecCallSubst, _AssocCallSubst,
- UpdateSubst),
+ Substs = substs(_AccVarSubst, _RecCallSubst, _AssocCallSubst, UpdateSubst),
BaseIds = base(UpdateBase, _AssocBase, _OtherBase),
- Sets = sets(Before, _Assoc, _ConstructAssoc, _Construct, Update,
- _Reject),
+ Sets = sets(Before, _Assoc, _ConstructAssoc, _Construct, Update, _Reject),
U = create_new_orig_recursive_goals(UpdateBase, Update,
HeadToCallSubst, UpdateSubst, C),
@@ -1691,7 +1566,6 @@
OrigRecGoal),
calculate_goal_info(conj(Cbase), OrigBaseGoal).
- %
% Create the goals which are to go in the new accumulator
% version of the predicate.
%
@@ -1701,19 +1575,16 @@
create_acc_goal(Call, Substs, HeadToCallSubst,
BaseIds, BasePairs, Sets, C, CS, AccBaseGoal, AccRecGoal) :-
- Substs = substs(AccVarSubst, RecCallSubst, AssocCallSubst,
- UpdateSubst),
+ Substs = substs(AccVarSubst, RecCallSubst, AssocCallSubst, UpdateSubst),
BaseIds = base(_UpdateBase, AssocBase, OtherBase),
- Sets = sets(Before, Assoc, ConstructAssoc,
- Construct, Update, _Reject),
+ Sets = sets(Before, Assoc, ConstructAssoc, Construct, Update, _Reject),
goal_util__rename_vars_in_goal(Call, RecCallSubst, RecCall),
Cbefore = goal_list(set__to_sorted_list(Before), C),
- % Create the goals which will be used in the new
- % recursive case.
+ % Create the goals which will be used in the new recursive case.
R = create_new_recursive_goals(Assoc, Construct `union` ConstructAssoc,
Update, AssocCallSubst, AccVarSubst, UpdateSubst, C, CS),
@@ -1722,8 +1593,7 @@
Rconstruct = goal_list(set__to_sorted_list(Construct `union`
ConstructAssoc), R),
- % Create the goals which will be used in the new
- % base case.
+ % Create the goals which will be used in the new base case.
B = create_new_base_goals(Assoc `union` Construct `union`
ConstructAssoc, C, AccVarSubst, HeadToCallSubst),
Bafter = set__to_sorted_list(Assoc `union`
@@ -1738,7 +1608,6 @@
Rupdate `append` [RecCall] `append` Rconstruct), AccRecGoal),
calculate_goal_info(conj(UpdateBase `append` BaseCase), AccBaseGoal).
- %
% Create the U set of goals (those that will be used in the
% original recursive case) by renaming all the goals which are
% used to initialize the update state variable using the
@@ -1752,18 +1621,15 @@
UpdateSubst, C)
= rename(set__to_sorted_list(Update), UpdateSubst, C, Ubase) :-
Ubase = rename(set__to_sorted_list(UpdateBase),
- chain_subst(HeadToCallSubst, UpdateSubst), C,
- goal_store__init).
+ chain_subst(HeadToCallSubst, UpdateSubst), C, goal_store__init).
- %
% Create the R set of goals (those that will be used in the new
% recursive case) by renaming all the members of assoc in CS
% using assoc_call_subst and all the members of (construct U
% construct_assoc) in C with acc_var_subst.
%
:- func create_new_recursive_goals(set(goal_id), set(goal_id), set(goal_id),
- subst, subst, subst,
- goal_store, goal_store) = goal_store.
+ subst, subst, subst, goal_store, goal_store) = goal_store.
create_new_recursive_goals(Assoc, Constructs, Update,
AssocCallSubst, AccVarSubst, UpdateSubst, C, CS)
@@ -1772,7 +1638,6 @@
goal_store__init),
RBase = rename(set__to_sorted_list(Update), UpdateSubst, C, RBase0).
- %
% Create the B set of goals (those that will be used in the new
% base case) by renaming all the base case goals of C with
% head_to_call and all the members of (assoc U construct U
@@ -1785,8 +1650,7 @@
= rename(set__to_sorted_list(Ids), AccVarSubst, C, Bbase) :-
Bbase = rename(base_case_ids(C), HeadToCallSubst, C, goal_store__init).
- %
- % acc_unification(O-A, G)
+ % acc_unification(O-A, G):
%
% is true if G represents the assignment unification Out = Acc.
%
@@ -1799,14 +1663,12 @@
Context = unify_context(explicit, []),
Expr = unify(Out, var(Acc), UniMode, assign(Out,Acc), Context),
set__list_to_set([Out,Acc], NonLocalVars),
- instmap_delta_from_assoc_list([Out - ground(shared, none)],
- InstMapDelta),
+ instmap_delta_from_assoc_list([Out - ground(shared, none)], InstMapDelta),
goal_info_init(NonLocalVars, InstMapDelta, det, pure, Info),
Goal = Expr - Info.
%-----------------------------------------------------------------------------%
- %
% Given the top level structure of the goal create new version
% with new base and recursive cases plugged in.
%
@@ -1826,7 +1688,7 @@
NewCases = [case(IdA, NewBaseGoal), case(IdB, NewRecGoal)],
NewGoal = switch(Var, CanFail, NewCases) - GoalInfo
;
- error("top_level: not the correct top level")
+ unexpected(this_file, "top_level: not the correct top level")
).
top_level(switch_rec_base, Goal, OrigBaseGoal, OrigRecGoal,
NewBaseGoal, NewRecGoal, OrigGoal, NewGoal) :-
@@ -1840,7 +1702,7 @@
NewCases = [case(IdA, NewRecGoal), case(IdB, NewBaseGoal)],
NewGoal = switch(Var, CanFail, NewCases) - GoalInfo
;
- error("top_level: not the correct top level")
+ unexpected(this_file, "top_level: not the correct top level")
).
top_level(disj_base_rec, Goal, OrigBaseGoal,
OrigRecGoal, NewBaseGoal, NewRecGoal, OrigGoal, NewGoal) :-
@@ -1854,7 +1716,7 @@
NewGoals = [NewBaseGoal, NewRecGoal],
NewGoal = disj(NewGoals) - GoalInfo
;
- error("top_level: not the correct top level")
+ unexpected(this_file, "top_level: not the correct top level")
).
top_level(disj_rec_base, Goal, OrigBaseGoal,
OrigRecGoal, NewBaseGoal, NewRecGoal, OrigGoal, NewGoal) :-
@@ -1868,7 +1730,7 @@
NewGoals = [NewRecGoal, NewBaseGoal],
NewGoal = disj(NewGoals) - GoalInfo
;
- error("top_level: not the correct top level")
+ unexpected(this_file, "top_level: not the correct top level")
).
top_level(ite_base_rec, Goal, OrigBaseGoal,
OrigRecGoal, NewBaseGoal, NewRecGoal, OrigGoal, NewGoal) :-
@@ -1881,7 +1743,7 @@
NewGoal = if_then_else(Vars, If, NewBaseGoal, NewRecGoal)
- GoalInfo
;
- error("top_level: not the correct top level")
+ unexpected(this_file, "top_level: not the correct top level")
).
top_level(ite_rec_base, Goal, OrigBaseGoal,
OrigRecGoal, NewBaseGoal, NewRecGoal, OrigGoal, NewGoal) :-
@@ -1894,14 +1756,11 @@
NewGoal = if_then_else(Vars, If, NewRecGoal, NewBaseGoal)
- GoalInfo
;
- error("top_level: not the correct top level")
+ unexpected(this_file, "top_level: not the correct top level")
).
%-----------------------------------------------------------------------------%
- %
- % update_accumulator_pred
- %
% Place the accumulator version of the predicate in the
% module_info structure.
%
@@ -1919,13 +1778,11 @@
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
+ % rename(Ids, Subst, From, Initial):
%
- % rename(Ids, Subst, From, Initial)
- %
- % return a goal_store, Final, which is the result of looking up each
- % member of set of goal_ids, Ids, in the goal_store, From,
- % applying the substitution and then storing the goal into
- % the goal_store, Initial.
+ % Return a goal_store, Final, which is the result of looking up each
+ % member of set of goal_ids, Ids, in the goal_store, From, applying
+ % the substitution and then storing the goal into the goal_store, Initial.
%
:- func rename(list(goal_id), subst, goal_store, goal_store) = goal_store.
@@ -1937,7 +1794,6 @@
goal_store__det_insert(GS0, Id, Goal - InstMap, GS)
), Ids, Initial, Final).
- %
% Return all the goal_ids which belong in the base case.
%
:- func base_case_ids(goal_store) = list(goal_id).
@@ -1953,7 +1809,6 @@
base_case_ids_set(GS) = set__list_to_set(base_case_ids(GS)).
- %
% Given a list of goal_ids, return the list of hlds_goals from
% the goal_store.
%
@@ -1978,21 +1833,24 @@
goal_list_instmap_delta(GoalList, InstMapDelta),
goal_list_determinism(GoalList, Determinism),
- goal_info_init(NonLocals, InstMapDelta,
- Determinism, pure, GoalInfo)
+ goal_info_init(NonLocals, InstMapDelta, Determinism, pure, GoalInfo)
;
- error("calculate_goal_info: not a conj.")
+ unexpected(this_file, "calculate_goal_info: not a conj.")
).
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
% The number which indicates the base case.
+ %
:- func base = int.
+
base = 2.
% The number which indicates the recursive case.
+ %
:- func rec = int.
+
rec = 1.
%-----------------------------------------------------------------------------%
@@ -2026,4 +1884,9 @@
).
%-----------------------------------------------------------------------------%
+
+:- func this_file = string.
+
+this_file = "accumulator.m".
+
%-----------------------------------------------------------------------------%
Index: compiler/arg_info.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/arg_info.m,v
retrieving revision 1.44
diff -u -b -r1.44 arg_info.m
--- compiler/arg_info.m 24 Mar 2005 02:00:12 -0000 1.44
+++ compiler/arg_info.m 7 Aug 2005 03:51:21 -0000
@@ -1,4 +1,6 @@
%-----------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et
+%-----------------------------------------------------------------------------%
% Copyright (C) 1994-2000,2002-2005 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.
@@ -29,31 +31,36 @@
% Annotate every non-aditi procedure in the module with information
% about its argument passing interface.
+ %
:- pred generate_arg_info(module_info::in, module_info::out) is det.
% Annotate a single procedure with information
% about its argument passing interface.
+ %
:- pred generate_proc_arg_info(list(type)::in, module_info::in,
proc_info::in, proc_info::out) is det.
% Given the list of types and modes of the arguments of a procedure
% and its code model, return its argument passing interface.
+ %
:- pred make_arg_infos(list(type)::in, list(mode)::in, code_model::in,
module_info::in, list(arg_info)::out) is det.
% Divide the given list of arguments into those treated as inputs
% by the calling convention and those treated as outputs.
+ %
:- pred arg_info__compute_in_and_out_vars(module_info::in,
list(prog_var)::in, list(mode)::in, list(type)::in,
list(prog_var)::out, list(prog_var)::out) is det.
% Return the arg_infos for the two input arguments of a unification
% of the specified code model.
+ %
:- pred arg_info__unify_arg_info(code_model::in, list(arg_info)::out) is det.
- % Divide the given list of arguments and the arg_infos into three
- % lists: the inputs, the outputs, and the unused arguments, in that
- % order.
+ % Divide the given list of arguments and the arg_infos into three lists:
+ % the inputs, the outputs, and the unused arguments, in that order.
+ %
:- pred arg_info__partition_args(assoc_list(prog_var, arg_info)::in,
assoc_list(prog_var, arg_info)::out,
assoc_list(prog_var, arg_info)::out,
@@ -62,6 +69,7 @@
% Divide the given list of arguments and the arg_infos into two
% lists: those which are treated as inputs by the calling convention
% and those which are treated as outputs by the calling convention.
+ %
:- pred arg_info__partition_args(assoc_list(prog_var, arg_info)::in,
assoc_list(prog_var, arg_info)::out,
assoc_list(prog_var, arg_info)::out) is det.
@@ -69,8 +77,8 @@
% Partition the head variables of the given procedure into three sets:
% the inputs, the outputs, and the unused arguments. This is done based
% on the arg_info annotations of the arguments, which means that this
- % predicate should only be called after the arg_info pass has been
- % run.
+ % predicate should only be called after the arg_info pass has been run.
+ %
:- pred arg_info__partition_proc_args(proc_info::in, module_info::in,
set(prog_var)::out, set(prog_var)::out, set(prog_var)::out) is det.
@@ -79,14 +87,15 @@
% head variables. Since the first (proc_info) argument is now the
% proc_info of the callee, we need to pass the types of the arguments
% (in the caller) separately.
+ %
:- pred arg_info__partition_proc_call_args(proc_info::in, vartypes::in,
module_info::in, list(prog_var)::in, set(prog_var)::out,
set(prog_var)::out, set(prog_var)::out) is det.
% Like arg_info__partition_proc_call_args, but partitions the actual
- % arguments of a generic call, so instead of looking up the types and
- % modes of the arguments in the module_info, we get them from the
- % arguments.
+ % arguments of a generic call, so instead of looking up the types and modes
+ % of the arguments in the module_info, we get them from the arguments.
+ %
:- pred arg_info__partition_generic_call_args(module_info::in,
list(prog_var)::in, list(type)::in, list(mode)::in,
set(prog_var)::out, set(prog_var)::out, set(prog_var)::out) is det.
@@ -105,8 +114,8 @@
:- import_module svset.
%-----------------------------------------------------------------------------%
-
- % This whole section just traverses the module structure.
+%
+% This whole section just traverses the module structure.
generate_arg_info(ModuleInfo0, ModuleInfo) :-
module_info_preds(ModuleInfo0, Preds),
@@ -138,8 +147,7 @@
pred_info_arg_types(PredInfo0, ArgTypes),
map__lookup(ProcTable0, ProcId, ProcInfo0),
- generate_proc_arg_info(ArgTypes, !.ModuleInfo,
- ProcInfo0, ProcInfo),
+ generate_proc_arg_info(ArgTypes, !.ModuleInfo, ProcInfo0, ProcInfo),
map__det_update(ProcTable0, ProcId, ProcInfo, ProcTable),
pred_info_set_procedures(ProcTable, PredInfo0, PredInfo),
@@ -157,35 +165,34 @@
%---------------------------------------------------------------------------%
% This is the useful part of the code ;-).
-
+ %
% This code is one of the places where we make assumptions
% about the calling convention. This is the only place in
% the compiler that makes such assumptions, but there are
% other places scattered around the runtime and the library
% which also rely on it.
-
+ %
% We assume all input arguments always go in sequentially numbered
% registers starting at register number 1. We also assume that
% all output arguments go in sequentially numbered registers
% starting at register number 1, except for model_semi procedures,
% where the first register is reserved for the result and hence
% the output arguments start at register number 2.
-
+ %
% We allocate unused args as if they were outputs. The calling
% convention requires that we allocate them a register, and the choice
% should not matter since unused args should be rare. However, we
% do have to make sure that all the predicates in this module
% implement this decision consistently. (No code outside this module
% should know about the outcome of this decision.)
-
+ %
make_arg_infos(ArgTypes, ArgModes, CodeModel, ModuleInfo, ArgInfo) :-
( CodeModel = model_semi ->
StartReg = 2
;
StartReg = 1
),
- make_arg_infos_list(ArgModes, ArgTypes, 1, StartReg,
- ModuleInfo, ArgInfo).
+ make_arg_infos_list(ArgModes, ArgTypes, 1, StartReg, ModuleInfo, ArgInfo).
:- pred make_arg_infos_list(list(mode)::in, list(type)::in, int::in, int::in,
module_info::in, list(arg_info)::out) is det.
@@ -202,8 +209,7 @@
!:OutReg = !.OutReg + 1
),
ArgInfo = arg_info(ArgReg, ArgMode),
- make_arg_infos_list(Modes, Types, !.InReg, !.OutReg,
- ModuleInfo, ArgInfos).
+ make_arg_infos_list(Modes, Types, !.InReg, !.OutReg, ModuleInfo, ArgInfos).
make_arg_infos_list([], [_|_], _, _, _, _) :-
error("make_arg_infos_list: length mis-match").
make_arg_infos_list([_|_], [], _, _, _, _) :-
Index: compiler/assertion.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/assertion.m,v
retrieving revision 1.36
diff -u -b -r1.36 assertion.m
--- compiler/assertion.m 23 May 2005 03:15:33 -0000 1.36
+++ compiler/assertion.m 7 Aug 2005 03:57:22 -0000
@@ -1,4 +1,6 @@
%-----------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et
+%-----------------------------------------------------------------------------%
% Copyright (C) 1999-2005 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.
@@ -27,24 +29,17 @@
:- import_module io.
:- import_module std_util.
- %
- % assertion__goal
- %
% Get the hlds_goal which represents the assertion.
%
:- pred assertion__goal(assert_id::in, module_info::in, hlds_goal::out) is det.
- %
- % assertion__record_preds_used_in
- %
% Record into the pred_info of each pred used in the assertion
% the assert_id.
%
:- pred assertion__record_preds_used_in(hlds_goal::in, assert_id::in,
module_info::in, module_info::out) is det.
- %
- % assertion__is_commutativity_assertion(Id, MI, Vs, CVs)
+ % assertion__is_commutativity_assertion(Id, MI, Vs, CVs):
%
% Does the assertion represented by the assertion id, Id,
% state the commutativity of a pred/func?
@@ -63,9 +58,7 @@
:- pred assertion__is_commutativity_assertion(assert_id::in, module_info::in,
prog_vars::in, pair(prog_var)::out) is semidet.
- %
- %
- % assertion__is_associativity_assertion(Id, MI, Vs, CVs, OV)
+ % assertion__is_associativity_assertion(Id, MI, Vs, CVs, OV):
%
% Does the assertion represented by the assertion id, Id,
% state the associativity of a pred/func?
@@ -92,8 +85,7 @@
:- pred assertion__is_associativity_assertion(assert_id::in, module_info::in,
prog_vars::in, pair(prog_var)::out, prog_var::out) is semidet.
- %
- % assertion__is_associativity_assertion(Id, MI, PId, Vs, SPair)
+ % assertion__is_associativity_assertion(Id, MI, PId, Vs, SPair):
%
% Recognise assertions in the form
% all [A,B,S0,S]
@@ -108,8 +100,7 @@
:- pred assertion__is_update_assertion(assert_id::in, module_info::in,
pred_id::in, prog_vars::in, pair(prog_var)::out) is semidet.
- %
- % assertion__is_construction_equivalence_assertion(Id, MI, C, P)
+ % assertion__is_construction_equivalence_assertion(Id, MI, C, P):
%
% Can a single construction unification whose functor is
% determined by the cons_id, C, be expressed as a call
@@ -122,9 +113,6 @@
:- pred assertion__is_construction_equivalence_assertion(assert_id::in,
module_info::in, cons_id::in, pred_id::in) is semidet.
- %
- % assertion__in_interface_check
- %
% Ensure that an assertion which is defined in an interface
% doesn't refer to any constructors, functions and predicates
% defined in the implementation of that module.
@@ -132,9 +120,6 @@
:- pred assertion__in_interface_check(hlds_goal::in, pred_info::in,
module_info::in, module_info::out, io::di, io::uo) is det.
- %
- % assertion__normalise_goal
- %
% Place a hlds_goal into a standard form. Currently all the
% code does is replace conj([G]) with G.
%
@@ -177,8 +162,7 @@
Q = call(PredId, _, VarsQ, _, _, _) - _,
commutative_var_ordering(VarsP, VarsQ, CallVars, CommutativeVars).
- %
- % commutative_var_ordering(Ps, Qs, Vs, CommutativeVs)
+ % commutative_var_ordering(Ps, Qs, Vs, CommutativeVs):
%
% Check that the two list of variables are identical except that
% the position of two variables has been swapped.
@@ -238,7 +222,7 @@
promise_only_solution(associative(PCalls, QCalls,
UniversiallyQuantifiedVars, CallVars)).
- % associative(Ps, Qs, Us, R)
+ % associative(Ps, Qs, Us, R):
%
% If the assertion was in the form
% all [Us] (some [] (Ps)) <=> (some [] (Qs))
@@ -247,7 +231,7 @@
%
% compose( A, B, AB), compose(B, C, BC),
% compose(AB, C, ABC) <=> compose(A, BC, ABC)
-
+ %
:- pred associative(hlds_goals::in, hlds_goals::in,
set(prog_var)::in, prog_vars::in,
pair(pair(prog_var), prog_var)::out) is cc_nondet.
@@ -260,12 +244,11 @@
process_one_side(RHSCalls, UniversiallyQuantifiedVars, PredId,
BC, PairsR, _),
- % If you read the predicate documentation, you will note
- % that for each pair of variables on the left hand side
- % there are an equivalent pair of variables on the right
- % hand side. As the pairs of variables are not
- % symmetric, the call to list__perm will only succeed
- % once, if at all.
+ % If you read the predicate documentation, you will note that
+ % for each pair of variables on the left hand side there are an equivalent
+ % pair of variables on the right hand side. As the pairs of variables
+ % are not symmetric, the call to list__perm will only succeed once,
+ % if at all.
assoc_list__from_corresponding_lists(PairsL, PairsR, Pairs),
list__perm(Pairs, [(A - AB) - (B - A), (B - C) - (C - BC),
(AB - ABC) - (BC - ABC)]),
@@ -278,11 +261,10 @@
list__filter((pred(X-_Y::in) is semidet :- X = B),
AssocList, [_B - CallVarB]).
- % reorder(Ps, Qs, Ls, Rs)
+ % reorder(Ps, Qs, Ls, Rs):
+ %
+ % Given both sides of the equivalence return another possible ordering.
%
- % Given both sides of the equivalence return another possible
- % ordering.
-
:- pred reorder(hlds_goals::in, hlds_goals::in,
hlds_goals::out, hlds_goals::out) is multi.
@@ -293,7 +275,7 @@
list__perm(PCalls, RHSCalls),
list__perm(QCalls, LHSCalls).
- % process_one_side(Gs, Us, L, Ps)
+ % process_one_side(Gs, Us, L, Ps):
%
% Given the list of goals, Gs, which are one side of a possible
% associative equivalence, and the universally quantified
@@ -301,9 +283,9 @@
% quantified variable that links the two calls and Ps the list
% of variables which are not invariants.
%
- % ie for app(TypeInfo, X, Y, XY), app(TypeInfo, XY, Z, XYZ)
+ % i.e. for app(TypeInfo, X, Y, XY), app(TypeInfo, XY, Z, XYZ)
% L <= XY and Ps <= [X - XY, Y - Z, XY - XYZ]
-
+ %
:- pred process_one_side(hlds_goals::in, set(prog_var)::in, pred_id::out,
prog_var::out, assoc_list(prog_var)::out, prog_vars::out) is semidet.
@@ -312,8 +294,8 @@
process_two_linked_calls(Goals, UniversiallyQuantifiedVars, PredId,
LinkingVar, Vars0, VarsA),
- % Filter out all the invariant arguments, and then make
- % sure that their is only 3 arguments left.
+ % Filter out all the invariant arguments, and then make sure that
+ % their is only 3 arguments left.
list__filter((pred(X-Y::in) is semidet :- not X = Y), Vars0, Vars),
list__length(Vars, number_of_associative_vars).
@@ -324,15 +306,14 @@
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
- %
- % assertion__is_update_assertion(Id, MI, PId, Ss)
+ % assertion__is_update_assertion(Id, MI, PId, Ss):
%
% is true iff the assertion, Id, is about a predicate, PId,
% which takes some state as input and produces some state as
% output and the same state is produced as input regardless of
% the order that the state is updated.
%
- % ie the promise should look something like this, note that A
+ % i.e. the promise should look something like this, note that A
% and B could be vectors of variables.
% :- promise all [A,B,SO,S]
% (
@@ -363,7 +344,6 @@
solutions(update(PCalls, QCalls, UniversiallyQuantifiedVars, CallVars),
[StateA - StateB | _]).
- %
% compose(S0, A, SA), compose(SB, A, S),
% compose(SA, B, S) <=> compose(S0, B, SB)
%
@@ -381,12 +361,11 @@
list__filter((pred(X-Y::in) is semidet :- X \= Y), Pairs0, Pairs),
list__length(Pairs) = 2,
- % If you read the predicate documentation, you will note
- % that for each pair of variables on the left hand side
- % there is an equivalent pair of variables on the right
- % hand side. As the pairs of variables are not
- % symmetric, the call to list__perm will only succeed
- % once, if at all.
+ % If you read the predicate documentation, you will note that
+ % for each pair of variables on the left hand side there is an equivalent
+ % pair of variables on the right hand side. As the pairs of variables
+ % are not symmetric, the call to list__perm will only succeed once,
+ % if at all.
list__perm(Pairs, [(S0 - SA) - (SB - S0), (SA - S) - (S - SB)]),
assoc_list__from_corresponding_lists(Vs, CallVars, AssocList),
@@ -397,8 +376,7 @@
%-----------------------------------------------------------------------------%
- %
- % process_two_linked_calls(Gs, UQVs, PId, LV, AL, VAs)
+ % process_two_linked_calls(Gs, UQVs, PId, LV, AL, VAs):
%
% is true iff the list of goals, Gs, with universally quantified
% variables, UQVs, is two calls to the same predicate, PId, with
@@ -433,16 +411,13 @@
ConsId, PredId) :-
assertion__goal(AssertId, Module, Goal),
equivalent(Goal, P, Q),
- (
- single_construction(P, ConsId)
- ->
+ ( single_construction(P, ConsId) ->
predicate_call(Q, PredId)
;
single_construction(Q, ConsId),
predicate_call(P, PredId)
).
- %
% One side of the equivalence must be just the single
% unification with the correct cons_id.
%
@@ -453,7 +428,6 @@
UnifyRhs = functor(cons(UnqualifiedSymName, Arity), _, _),
match_sym_name(UnqualifiedSymName, QualifiedSymName).
- %
% The side containing the predicate call must be a single call
% to the predicate with 0 or more construction unifications
% which setup the arguments to the predicates.
@@ -488,7 +462,7 @@
( Clauses = [clause(_ProcIds, Goal0, _Lang, _Context)] ->
assertion__normalise_goal(Goal0, Goal)
;
- error("assertion__goal: not an assertion")
+ unexpected(this_file, "assertion__goal: not an assertion")
).
%-----------------------------------------------------------------------------%
@@ -523,11 +497,9 @@
%-----------------------------------------------------------------------------%
%-----------------------------------------------------------------------------%
+ % equal_goals(GA, GB):
%
- % equal_goals(GA, GB)
- %
- % Do these two goals represent the same hlds_goal modulo
- % renaming.
+ % Do these two goals represent the same hlds_goal modulo renaming?
%
:- pred equal_goals(hlds_goal::in, hlds_goal::in,
subst::in, subst::out) is semidet.
@@ -563,7 +535,7 @@
equal_goals(foreign_proc(Attribs, PredId, _, ArgsA, ExtraA, _) - _,
foreign_proc(Attribs, PredId, _, ArgsB, ExtraB, _) - _,
!Subst) :-
- % foreign_procs with extra args are compiler generated,
+ % Foreign_procs with extra args are compiler generated,
% and as such will not participate in assertions.
ExtraA = [],
ExtraB = [],
@@ -661,8 +633,7 @@
%-----------------------------------------------------------------------------%
- %
- % update_pred_info(Id, A, M0, M)
+ % update_pred_info(Id, A, !Module):
%
% Record in the pred_info pointed to by Id that that predicate
% is used in the assertion pointed to by A.
@@ -708,8 +679,6 @@
assertion__normalise_goal_shorthand(ShortHandGoal0 - GI0,
ShortHandGoal - GI).
- % assertion__normalise_goal_shorthand
- %
% Place a shorthand goal into a standard form. Currently
% all the code does is replace conj([G]) with G.
%
@@ -789,7 +758,8 @@
assertion__in_interface_check(conj(Goals) - _, PredInfo, !Module, !IO) :-
assertion__in_interface_check_list(Goals, PredInfo, !Module, !IO).
assertion__in_interface_check(switch(_, _, _) - _, _, _, _, !IO) :-
- error("assertion__in_interface_check: assertion contains switch.").
+ unexpected(this_file,
+ "assertion__in_interface_check: assertion contains switch.").
assertion__in_interface_check(disj(Goals) - _, PredInfo, !Module, !IO) :-
assertion__in_interface_check_list(Goals, PredInfo, !Module, !IO).
assertion__in_interface_check(not(Goal) - _, PredInfo, !Module, !IO) :-
@@ -840,7 +810,8 @@
true
)
;
- error("assertion__in_interface_check_unify_rhs: " ++
+ unexpected(this_file,
+ "assertion__in_interface_check_unify_rhs: " ++
"type_to_ctor_and_args failed.")
).
assertion__in_interface_check_unify_rhs(lambda_goal(_,_,_,_,_,_,_,_,Goal),
@@ -859,7 +830,6 @@
%-----------------------------------------------------------------------------%
- %
% Returns yes if the import_status indicates the item came form
% the implementation section.
%
@@ -897,9 +867,7 @@
module_info_name(!.Module, ModuleName),
ModuleStr = describe_sym_name(ModuleName),
write_error_pieces(Context, 0,
- [words("In interface for module"), fixed(ModuleStr ++ ":")],
- !IO),
-
+ [words("In interface for module"), fixed(ModuleStr ++ ":")], !IO),
(
Type = call(PredOrFunc, SymName, Arity),
IdStr = simple_call_id_to_string(PredOrFunc, SymName, Arity)
@@ -908,13 +876,11 @@
ConsIdStr = cons_id_to_string(ConsId),
IdStr = "constructor `" ++ ConsIdStr ++ "'"
),
-
write_error_pieces_not_first_line(Context, 0,
[words("error: exported promise refers to"),
words(IdStr), words("which is defined in the "),
words("implementation section of module"),
fixed(ModuleStr ++ ".")], !IO),
-
globals__io_lookup_bool_option(verbose_errors, VerboseErrors, !IO),
(
VerboseErrors = yes,
@@ -927,4 +893,9 @@
).
%-----------------------------------------------------------------------------%
+
+:- func this_file = string.
+
+this_file = "assertion.m".
+
%-----------------------------------------------------------------------------%
Index: compiler/atsort.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/atsort.m,v
retrieving revision 1.14
diff -u -b -r1.14 atsort.m
--- compiler/atsort.m 24 Mar 2005 02:00:12 -0000 1.14
+++ compiler/atsort.m 7 Aug 2005 04:09:51 -0000
@@ -1,4 +1,6 @@
%-----------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et
+%-----------------------------------------------------------------------------%
% Copyright (C) 1994-1995, 1997, 2004-2005 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.
@@ -20,8 +22,7 @@
:- type relmap(T) == map(T, list(T)).
- % atsort(Succmap, Predmap, MustSuccmap, MustPredmap, PrefOrder,
- % Sortlist):
+ % atsort(Succmap, Predmap, MustSuccmap, MustPredmap, PrefOrder, Sortlist):
%
% Succmap and Predmap describe the graph to sort: they map nodes to
% the list of their successors and predecessors respectively. This
@@ -29,7 +30,7 @@
% acyclic subset of this graph. The final node order, Sortlist, must
% obey the order described by MustSuccmap and MustPredmap. PrefOrder
% gives a preference for the order of the nodes.
-
+ %
:- pred atsort(relmap(T)::in, relmap(T)::in, relmap(T)::in, relmap(T)::in,
list(T)::in, list(list(T))::out) is det.
@@ -38,7 +39,7 @@
% Set Reachable to the set of nodes reachable from Nodes via Map.
% Reachable is in no particular order, and won't include members of
% Nodes unless they are reachable from other members.
-
+ %
:- pred atsort__closure(list(T)::in, relmap(T)::in, list(T)::out) is det.
%-----------------------------------------------------------------------------%
@@ -93,27 +94,25 @@
list__reverse(Source1, Source1rev),
list__append(Source1rev, Sink1, Sorted)
;
- atsort__choose(Mid1, !Succmap, !Predmap,
- MustSuccmap, MustPredmap, PrefOrder, Chosen, Mid2),
+ atsort__choose(Mid1, !Succmap, !Predmap, MustSuccmap, MustPredmap,
+ PrefOrder, Chosen, Mid2),
% write('Chosen: '),
% write(Chosen),
% nl,
% write('Not chosen: '),
% write(Mid2),
% nl,
- atsort__main(Mid2, !.Succmap, !.Predmap,
- MustSuccmap, MustPredmap, PrefOrder, MidSorted),
+ atsort__main(Mid2, !.Succmap, !.Predmap, MustSuccmap, MustPredmap,
+ PrefOrder, MidSorted),
list__reverse(Source1, Source1rev),
- list__condense([Source1rev, [[Chosen]], MidSorted, Sink1],
- Sorted)
+ list__condense([Source1rev, [[Chosen]], MidSorted, Sink1], Sorted)
).
%-----------------------------------------------------------------------------%
:- pred atsort__choose(list(T)::in,
relmap(T)::in, relmap(T)::out, relmap(T)::in, relmap(T)::out,
- relmap(T)::in, relmap(T)::in, list(T)::in, T::out, list(T)::out)
- is det.
+ relmap(T)::in, relmap(T)::in, list(T)::in, T::out, list(T)::out) is det.
atsort__choose(Nodes, !Succmap, !Predmap, _MustSuccmap, MustPredmap, PrefOrder,
Chosen, NotChosen) :-
@@ -129,7 +128,7 @@
% See whether this node can be chosen ahead of the given list of nodes.
% Do not give preference to nodes that occur in MustPredmap.
-
+ %
:- pred atsort__can_choose(list(T)::in, list(T)::in, relmap(T)::in,
list(T)::in, list(T)::out) is det.
@@ -147,7 +146,7 @@
atsort__can_choose(Nodes, All, MustPredmap, !CanChoose).
% None of the members of the first list occur in the second.
-
+ %
:- pred atsort__must_avoid(list(T)::in, list(T)::in) is semidet.
atsort__must_avoid([], _).
@@ -177,7 +176,10 @@
Sink0, Sink) :-
atsort__source_sink(Nodes0, !.Succmap, !.Predmap,
[], Source1, [], Mid1, [], Sink1),
- ( Source1 = [], Sink1 = [] ->
+ (
+ Source1 = [],
+ Sink1 = []
+ ->
Source = Source0,
Sink = Sink0,
Mid = Mid1
@@ -186,10 +188,8 @@
list__delete_elems(Nodes1, Sink1, Nodes2),
Succmap0 = !.Succmap,
Predmap0 = !.Predmap,
- atsort__map_delete_all_source_links(Source1,
- Succmap0, !Predmap),
- atsort__map_delete_all_sink_links(Sink1,
- Predmap0, !Succmap),
+ atsort__map_delete_all_source_links(Source1, Succmap0, !Predmap),
+ atsort__map_delete_all_sink_links(Sink1, Predmap0, !Succmap),
atsort__map_delete_all_nodes(Source1, !Succmap),
atsort__map_delete_all_nodes(Source1, !Predmap),
atsort__map_delete_all_nodes(Sink1, !Succmap),
@@ -284,9 +284,9 @@
% The first argument is a list of nodes to look at. If they have
% not been seen before, we insert them into the reachable list,
% and schedule their neighbours to be looked at too.
-
+ %
% XXX Should think about making Reachable be a bintree set.
-
+ %
:- pred atsort__closure_2(list(T)::in, relmap(T)::in,
list(T)::in, list(T)::out) is det.
Index: compiler/basic_block.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/basic_block.m,v
retrieving revision 1.19
diff -u -b -r1.19 basic_block.m
--- compiler/basic_block.m 24 Mar 2005 02:00:12 -0000 1.19
+++ compiler/basic_block.m 7 Aug 2005 04:13:28 -0000
@@ -1,4 +1,6 @@
%-----------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et
+%-----------------------------------------------------------------------------%
% Copyright (C) 1997-2001,2003-2005 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.
@@ -29,17 +31,17 @@
:- type block_info
---> block_info(
- label,
+ starting_label :: label,
% The label starting the block.
- instruction,
+ label_instr :: instruction,
% The instruction containing the label.
- list(instruction),
+ later_instrs :: list(instruction),
% The code of the block without the initial
% label.
- list(label),
+ jump_dests :: list(label),
% The labels we can jump to
% (not falling through).
- maybe(label)
+ fall_dest :: maybe(label)
% The label we fall through to
% (if there is one).
).
@@ -62,16 +64,15 @@
:- import_module require.
create_basic_blocks(Instrs0, Comments, ProcLabel, !C, LabelSeq, BlockMap) :-
- opt_util__get_prologue(Instrs0, LabelInstr, Comments,
- AfterLabelInstrs),
+ opt_util__get_prologue(Instrs0, LabelInstr, Comments, AfterLabelInstrs),
Instrs1 = [LabelInstr | AfterLabelInstrs],
build_block_map(Instrs1, LabelSeq, ProcLabel, map__init, BlockMap, !C).
- % Add labels to the given instruction sequence so that
- % every basic block has labels around it.
-
%-----------------------------------------------------------------------------%
+ % Build up the block map. As we go along, we add labels to the given
+ % instruction sequence so that every basic block has labels around it.
+ %
:- pred build_block_map(list(instruction)::in, list(label)::out,
proc_label::in, block_map::in, block_map::out,
counter::in, counter::out) is det.
@@ -95,12 +96,13 @@
( list__last(BlockInstrs, LastInstr) ->
LastInstr = LastUinstr - _,
opt_util__possible_targets(LastUinstr, SideLabels),
- opt_util__can_instr_fall_through(LastUinstr,
- CanFallThrough),
- ( CanFallThrough = yes ->
+ opt_util__can_instr_fall_through(LastUinstr, CanFallThrough),
+ (
+ CanFallThrough = yes,
get_fallthrough_from_seq(LabelSeq0,
MaybeFallThrough)
;
+ CanFallThrough = no,
MaybeFallThrough = no
)
;
Index: compiler/build_mode_constraints.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/build_mode_constraints.m,v
retrieving revision 1.4
diff -u -b -r1.4 build_mode_constraints.m
--- compiler/build_mode_constraints.m 24 Mar 2005 05:33:58 -0000 1.4
+++ compiler/build_mode_constraints.m 7 Aug 2005 04:29:59 -0000
@@ -242,15 +242,12 @@
{!:Varset, !:VarMap} = set.fold(
(func(Nonlocal, {Vset0, Vmap0}) = {Vset, Vmap} :-
RepVar = (Nonlocal `in` PredId) `at` GoalPath,
- ( bimap.search(Vmap0, RepVar, _)
- -> Vset = Vset0,
+ ( bimap.search(Vmap0, RepVar, _) ->
+ Vset = Vset0,
Vmap = Vmap0
- ; varset.new_named_var(
- Vset0,
- rep_var_to_string(ProgVarset, RepVar),
- NewMCvar,
- Vset
- ),
+ ;
+ varset.new_named_var(Vset0,
+ rep_var_to_string(ProgVarset, RepVar), NewMCvar, Vset),
bimap.det_insert(Vmap0, RepVar, NewMCvar, Vmap)
)
),
@@ -260,12 +257,8 @@
% Switch on GoalExpr for recursion
(
GoalExpr = conj(Goals),
- list.foldl2(
- add_mc_vars_for_goal(PredId, ProgVarset),
- Goals,
- !Varset,
- !VarMap
- )
+ list.foldl2(add_mc_vars_for_goal(PredId, ProgVarset), Goals,
+ !Varset, !VarMap)
;
GoalExpr = call(_, _, _, _, _, _)
;
@@ -279,30 +272,18 @@
GoalExpr = unify(_, _, _, _, _)
;
GoalExpr = disj(Goals),
- list.foldl2(
- add_mc_vars_for_goal(PredId, ProgVarset),
- Goals,
- !Varset,
- !VarMap
- )
+ list.foldl2(add_mc_vars_for_goal(PredId, ProgVarset), Goals,
+ !Varset, !VarMap)
;
GoalExpr = not(Goal),
- add_mc_vars_for_goal(
- PredId, ProgVarset, Goal, !Varset, !VarMap
- )
+ add_mc_vars_for_goal(PredId, ProgVarset, Goal, !Varset, !VarMap)
; GoalExpr = scope(_, Goal),
- add_mc_vars_for_goal(
- PredId, ProgVarset, Goal, !Varset, !VarMap
- )
+ add_mc_vars_for_goal(PredId, ProgVarset, Goal, !Varset, !VarMap)
;
GoalExpr = if_then_else(_, Cond, Then, Else),
Goals = [Cond, Then, Else],
- list.foldl2(
- add_mc_vars_for_goal(PredId, ProgVarset),
- Goals,
- !Varset,
- !VarMap
- )
+ list.foldl2(add_mc_vars_for_goal(PredId, ProgVarset), Goals,
+ !Varset, !VarMap)
;
GoalExpr = foreign_proc(_, _, _, _, _, _)
;
@@ -322,8 +303,7 @@
%-----------------------------------------------------------------------------%
- % goal_constraints gives the mode constraints for the supplied
- % hlds_goal
+ % Goal_constraints gives the mode constraints for the supplied hlds_goal.
%
:- pred goal_constraints(module_info::in, mc_var_map::in, pred_id::in,
hlds_goal::in, mode_constraints::out) is det.
@@ -335,12 +315,8 @@
goal_expr_constraints(ModuleInfo, VarMap, PredId, GoalExpr, GoalPath,
Nonlocals, Constraints).
- % Goal:
- % G1, ..., Gn where Goals = [G1, ..., Gn]
- %
goal_expr_constraints(ModuleInfo, VarMap, PredId,
conj(Goals), GoalPath, Nonlocals, Constraints) :-
-
list.map(
goal_constraints(ModuleInfo, VarMap, PredId),
Goals, ConjunctConstraints
@@ -352,23 +328,16 @@
Constraints0, Constraints1
),
list.foldl(
- fold_nonlocal_var_into_conj_constraints(
- VarMap,
- PredId,
- NonlocalsPositions,
- GoalPath
- ),
+ fold_nonlocal_var_into_conj_constraints(VarMap, PredId,
+ NonlocalsPositions, GoalPath),
multi_map.keys(NonlocalsPositions),
% Nonlocal variables that are nonlocals to subgoals.
Constraints1, Constraints
),
EmptyMultiMap = multi_map.init,
- list.foldl2(
- fold_goal_into_var_position_maps(VarMap, PredId, Nonlocals),
- Goals,
- EmptyMultiMap,
- LocalsPositions,
+ list.foldl2(fold_goal_into_var_position_maps(VarMap, PredId, Nonlocals),
+ Goals, EmptyMultiMap, LocalsPositions,
% A map from each local variable to
% its corresponding constraint
% variables for the paths at each of
@@ -376,8 +345,7 @@
% if such conjuncts exist. (If a
% variable is local to one conjunct we
% need not deal with it here).
- EmptyMultiMap,
- NonlocalsPositions
+ EmptyMultiMap, NonlocalsPositions
% A map from each non-local variable
% to its corresponding constraint
% variables at the paths of each of the
@@ -390,17 +358,12 @@
% conjuncts.
).
- % Pred Call
- %
goal_expr_constraints(ModuleInfo, VarMap, PredId,
call(CalledPred, _ProcID, Args, _Builtin, _UnifyContext, _Name),
GoalPath, _Nonlocals, Constraints) :-
-
- % Get the declared modes (if any exist)
module_info_pred_info(ModuleInfo, CalledPred, PredInfo),
pred_info_procedures(PredInfo, ProcTable),
map.values(ProcTable, ProcInfos),
-
list.filter_map(
(pred(PInfo::in, MDecl::out) is semidet :-
proc_info_maybe_declared_argmodes(PInfo, yes(_)),
@@ -409,7 +372,6 @@
ProcInfos,
ArgModeDecls
),
-
(
% No modes declared, must be in the same SCC as
% the calling predicate.
@@ -437,33 +399,29 @@
GoalPath, Args, Constraints)
).
- % XXX Need to do something here.
- %
goal_expr_constraints(_ModuleInfo, _VarMap, _PredId,
generic_call(_, _, _, _), _GoalPath, _Nonlocals, _Constraints) :-
+ % XXX Need to do something here.
sorry(this_file, "generic_call NYI.").
- % XXX Need to do something here.
- %
goal_expr_constraints(_ModuleInfo, _VarMap, _PredId,
switch(_, _, _), _GoalPath, _Nonlocals, _Constraints) :-
+ % XXX Need to do something here.
sorry(this_file, "switch NYI.").
- % Unification Goals
- %
goal_expr_constraints(_ModuleInfo, VarMap, PredId,
unify(LHSvar, RHS, _Mode, _Kind, _Context),
GoalPath, _Nonlocals, Constraints) :-
(
RHS = var(RHSvar),
% Goal: LHSvar = RHSvar
+ % At most one of the left and right hand sides of a unification
+ % is produced at the unification.
Constraints = [
atomic_constraint(at_most_one([
prog_var_at_path(VarMap, PredId, GoalPath, LHSvar),
prog_var_at_path(VarMap, PredId, GoalPath, RHSvar)
- ])) % At most one of the left and right hand
- % sides of a unification is produced
- % at the unification.
+ ]))
]
;
RHS = functor(_Functor, _IsExistConstr, Args),
@@ -475,18 +433,18 @@
(
ArgsProducedHere = [OneArgProducedHere, _Two| _],
% Goal: LHSvar = functor(Args)
+ % (a): If one arg is produced here, then they all are.
+ % (b): At most one side of the unification is produced.
Constraints = [
- % If one arg is produced here, then they all are.
atomic_constraint(equivalent(ArgsProducedHere)),
- % At most one side of the unification is produced.
atomic_constraint(
at_most_one([LHSproducedHere, OneArgProducedHere]))
]
;
ArgsProducedHere = [OneArgProducedHere],
% Goal: LHSvar = functor(Arg)
- Constraints = [
% At most one side of the unification is produced.
+ Constraints = [
atomic_constraint(
at_most_one([LHSproducedHere, OneArgProducedHere]))
]
@@ -503,9 +461,6 @@
sorry(this_file, "unify with lambda goal NYI")
).
- % Goal:
- % G1; ...; Gn where Goals = [G1, ..., Gn]
- %
goal_expr_constraints(ModuleInfo, VarMap, PredId,
disj(Goals), GoalPath, Nonlocals, Constraints) :-
@@ -526,19 +481,14 @@
Constraints = list.condense([
list.map_corresponding(
func(X, Ys) = atomic_constraint(equivalent([X | Ys])),
- % A variable bound at any disjunct is
- % bound for the disjunct as a whole. If
- % a variable can be bound at one
- % conjunct it must be able to be bound
- % at any.
+ % A variable bound at any disjunct is bound for the disjunct
+ % as a whole. If a variable can be bound at one conjunct
+ % it must be able to be bound at any.
NonlocalsHere, NonlocalsAtDisjuncts
) |
DisjunctConstraints
]).
- % Goal:
- % not (Goal)
- %
goal_expr_constraints(ModuleInfo, VarMap, PredId,
not(Goal), GoalPath, Nonlocals, Constraints) :-
Goal = _ - NegatedGoalInfo,
@@ -559,18 +509,14 @@
Constraints = list.foldl(
func(MCVar, Cnstrnts) = [
atomic_constraint(equiv_bool(MCVar, no))|
- % The variables non-local to the
- % negation are not to be produced at the
- % negation or any deeper.
+ % The variables non-local to the negation are not to be
+ % produced at the negation or any deeper.
Cnstrnts
],
NonlocalsConstraintVars,
NegatedGoalConstraints
).
- % Goal:
- % some Xs Goal
- %
goal_expr_constraints(ModuleInfo, VarMap, PredId,
scope(_Reason, Goal),
GoalPath, Nonlocals, Constraints) :-
@@ -578,28 +524,15 @@
goal_info_get_goal_path(SomeGoalInfo, SomeGoalPath),
Constraints = set.fold(
func(NL, NLConstraints) = [
+ % If a program variable is produced by the sub-goal of the some
+ % statement, it is produced at the main goal as well.
atomic_constraint(equivalent([
prog_var_at_path(VarMap, PredId, GoalPath, NL),
- prog_var_at_path(
- VarMap, PredId, SomeGoalPath, NL
- )
- ]))| % If a program variable is produced
- % by the sub-goal of the some
- % statement, it is produced at the
- % main goal as well.
- NLConstraints
- ],
- Nonlocals,
- SomeGoalConstraints % Include the constraints from the
- % recursive call on the sub-goal.
- ),
- goal_constraints(
- ModuleInfo, VarMap, PredId, Goal, SomeGoalConstraints
- ).
+ prog_var_at_path(VarMap, PredId, SomeGoalPath, NL)
+ ])) | NLConstraints],
+ Nonlocals, SomeGoalConstraints),
+ goal_constraints(ModuleInfo, VarMap, PredId, Goal, SomeGoalConstraints).
- % Goal:
- % If -> Then; Else
- %
goal_expr_constraints(ModuleInfo, VarMap, PredId,
if_then_else(ExistVars, If, Then, Else),
GoalPath, Nonlocals, Constraints) :-
@@ -608,36 +541,22 @@
goal_info_get_goal_path(ThenInfo, ThenPath),
goal_info_get_goal_path(ElseInfo, ElsePath),
- NonlocalsHere = list.map(
- prog_var_at_path(VarMap, PredId, GoalPath),
- NonlocalsList
- ),
- NonlocalsAtCond = list.map(
- prog_var_at_path(VarMap, PredId, CondPath),
- NonlocalsList
- ),
- NonlocalsAtThen = list.map(
- prog_var_at_path(VarMap, PredId, ThenPath),
- NonlocalsList
- ),
- NonlocalsAtElse = list.map(
- prog_var_at_path(VarMap, PredId, ElsePath),
- NonlocalsList
- ),
+ NonlocalsHere = list.map(prog_var_at_path(VarMap, PredId, GoalPath),
+ NonlocalsList),
+ NonlocalsAtCond = list.map(prog_var_at_path(VarMap, PredId, CondPath),
+ NonlocalsList),
+ NonlocalsAtThen = list.map(prog_var_at_path(VarMap, PredId, ThenPath),
+ NonlocalsList),
+ NonlocalsAtElse = list.map(prog_var_at_path(VarMap, PredId, ElsePath),
+ NonlocalsList),
NonlocalsList = set.to_sorted_list(Nonlocals),
- % The existentially quantified variables shared between
- % the condition and the then-part have special
- % constraints
- %
- LocalAndSharedAtCond = list.map(
- prog_var_at_path(VarMap, PredId, CondPath),
- ExistVars
- ),
- LocalAndSharedAtThen = list.map(
- prog_var_at_path(VarMap, PredId, ThenPath),
- ExistVars
- ),
+ % The existentially quantified variables shared between the condition
+ % and the then-part have special constraints.
+ LocalAndSharedAtCond = list.map(prog_var_at_path(VarMap, PredId, CondPath),
+ ExistVars),
+ LocalAndSharedAtThen = list.map(prog_var_at_path(VarMap, PredId, ThenPath),
+ ExistVars),
goal_constraints(ModuleInfo, VarMap, PredId, If, IfConstraints),
goal_constraints(ModuleInfo, VarMap, PredId, Then, ThenConstraints),
@@ -646,42 +565,24 @@
Constraints = list.condense([
list.map_corresponding3(
func(NLHere, NLAtThen, NLAtElse) =
- atomic_constraint(equivalent(
- [NLHere, NLAtThen, NLAtElse]
- )), % If a variable is to be produced
- % at this path the then and else
- % parts must be able to produce it.
- NonlocalsHere,
- NonlocalsAtThen,
- NonlocalsAtElse
- ),
- list.map(
- func(Cond) = atomic_constraint(equiv_bool(Cond, no)),
- NonlocalsAtCond
- ), % No nonlocal is produced in the condition.
+ % If a variable is to be produced at this path,
+ % the then and else parts must be able to produce it.
+ atomic_constraint(equivalent([NLHere, NLAtThen, NLAtElse])),
+ NonlocalsHere, NonlocalsAtThen, NonlocalsAtElse),
+ % No nonlocal is produced in the condition.
+ list.map(func(Cond) = atomic_constraint(equiv_bool(Cond, no)),
+ NonlocalsAtCond),
+ % XXX Do we want this, or do we just constrain 'Cond true and 'Then
+ % false? Maybe a local variable shared between the condition and
+ % then-part should always be bound in the condition, but I'm not sure
+ % about the possibility of checking the variable's type in the Cond
+ % and then binding it in the Then...
list.map_corresponding(
(func(LocalAtCond, LocalAtThen) =
- atomic_constraint(exactly_one(
- [LocalAtCond, LocalAtThen]
- ))
- ),
- LocalAndSharedAtCond,
- LocalAndSharedAtThen
- ), % XXX Do we want this, or do we just constrain
- % 'Cond true and 'Then false? Maybe a local
- % variable shared between the condition and
- % then-part should always be bound in the
- % condition, but I'm not sure about the
- % possibility of checking the variable's type in
- % the Cond and then binding it in the Then...
- IfConstraints,
- ThenConstraints,
- ElseConstraints
-
- ]).
+ atomic_constraint(exactly_one([LocalAtCond, LocalAtThen]))),
+ LocalAndSharedAtCond, LocalAndSharedAtThen),
+ IfConstraints, ThenConstraints, ElseConstraints]).
- % Foreign procedure
- %
goal_expr_constraints(ModuleInfo, VarMap, PredId,
foreign_proc(_, CalledPred, ProcID, ForeignArgs, _, _),
GoalPath, _Nonlocals, Constraints) :-
@@ -689,7 +590,6 @@
module_info_pred_proc_info(ModuleInfo, CalledPred, ProcID, _, ProcInfo),
( proc_info_maybe_declared_argmodes(ProcInfo, yes(_OrigDecl)) ->
proc_info_argmodes(ProcInfo, Decl),
-
% add_sufficient_in_modes_for_type_info_args(
% CallArgs,
% Decl,
@@ -698,35 +598,31 @@
% % should be 'in' so that is what this predicate
% % adds however, I am not happy with it.
- % This pred should strip the disj(conj()) for the
- % single declaration.
+ % This pred should strip the disj(conj()) for the single declaration.
call_mode_decls_constraints(ModuleInfo, VarMap, PredId, [Decl],
GoalPath, CallArgs, Constraints)
;
unexpected(this_file, "no mode declaration for foreign proc")
).
- % Parallel conjunction
- %
- % XXX What to do here?
- %
goal_expr_constraints(_ModuleInfo, _VarMap, _PredId,
par_conj(_Goals), _GoalPath, _Nonlocals, _Constraints) :-
+ % XXX What to do here?
sorry(this_file, "NYI par_conj").
- % Shorthand goals. Should not exist at this point in compilation.
- %
goal_expr_constraints(_ModuleInfo, _VarMap, _PredId,
shorthand(_ShorthandGoalExpr), _GoalPath, _Nonlocals, _Constraints) :-
+ % Shorthand goals not exist at this point in compilation.
unexpected(this_file, "shorthand goal").
%-----------------------------------------------------------------------------%
- % prog_var_at_path(VarMap, PredId, GoalPath, ProgVar) =
- % ConstraintVar consults the map to get the constraint variable
- % ConstraintVar that says that ProgVar is produced at GoalPath.
- % The lookup function will report an error if the key (ProgVar
- % `in` PredId) `at` GoalPath does not exist in the map.
+ % prog_var_at_path(VarMap, PredId, GoalPath, ProgVar) = ConstraintVar:
+ %
+ % consults the map to get the constraint variable ConstraintVar that says
+ % that ProgVar is produced at GoalPath. The lookup function will report
+ % an error if the key (ProgVar `in` PredId) `at` GoalPath does not exist
+ % in the map.
%
:- func prog_var_at_path(mc_var_map, pred_id, goal_path, prog_var) = (mc_var).
@@ -745,16 +641,13 @@
prog_var_at_paths(VarMap, PredId, GoalPaths, ProgVar) =
list.map(
- func(GoalPath) = bimap.lookup(
- VarMap,
- (ProgVar `in` PredId) `at` GoalPath
- ),
+ func(GoalPath) = bimap.lookup(VarMap,
+ (ProgVar `in` PredId) `at` GoalPath),
GoalPaths
).
% nonlocals_at_path_and_subpaths(VarMap, GoalPath,
- % SubPaths, Nonlocals, NonlocalsAtPath,
- % NonlocalsAtSubPaths)
+ % SubPaths, Nonlocals, NonlocalsAtPath, NonlocalsAtSubPaths)
% consults the VarMap to find constraint variables associated
% with each of the program variables in the Nonlocals set for a
% GoalPath eg a conjunction and its SubPaths (ie the individual
@@ -771,14 +664,10 @@
nonlocals_at_path_and_subpaths(VarMap, PredId, GoalPath, SubPaths, Nonlocals,
NonlocalsAtPath, NonlocalsAtSubPaths) :-
- NonlocalsAtPath = list.map(
- prog_var_at_path(VarMap, PredId, GoalPath),
- NonlocalsList
- ),
- NonlocalsAtSubPaths = list.map(
- prog_var_at_paths(VarMap, PredId, SubPaths),
- NonlocalsList
- ),
+ NonlocalsAtPath = list.map(prog_var_at_path(VarMap, PredId, GoalPath),
+ NonlocalsList),
+ NonlocalsAtSubPaths = list.map(prog_var_at_paths(VarMap, PredId, SubPaths),
+ NonlocalsList),
NonlocalsList = set.to_sorted_list(Nonlocals).
%----------------------------------------------------------------------------%
@@ -787,10 +676,7 @@
ModuleInfo, VarMap, PredId, Decls, HeadVarsList, Constraints) :-
ConstraintsList = list.map_corresponding(
mode_decl_constraints(ModuleInfo),
- list.map(
- list.map(prog_var_at_path(VarMap, PredId, [])),
- HeadVarsList
- ),
+ list.map(list.map(prog_var_at_path(VarMap, PredId, [])), HeadVarsList),
Decls
),
Constraints0 = list.condense(ConstraintsList),
@@ -904,12 +790,9 @@
CallArgs),
Constraints = list.map_corresponding(
(func(HeadVarThere, CallArgHere) =
- atomic_constraint(equivalent(
- [HeadVarThere, CallArgHere]
- ))
+ atomic_constraint(equivalent([HeadVarThere, CallArgHere]))
),
- HeadVarsAtHome,
- CallArgsHere
+ HeadVarsAtHome, CallArgsHere
).
%-----------------------------------------------------------------------------%
Index: compiler/call_gen.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/call_gen.m,v
retrieving revision 1.162
diff -u -b -r1.162 call_gen.m
--- compiler/call_gen.m 24 Mar 2005 02:00:15 -0000 1.162
+++ compiler/call_gen.m 7 Aug 2005 04:38:19 -0000
@@ -1,4 +1,6 @@
%---------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et
+%---------------------------------------------------------------------------%
% Copyright (C) 1994-2005 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.
@@ -43,6 +45,7 @@
% call_gen__generic_call_info(CodeModel, GenericCall,
% CodeAddr, FirstImmediateInputReg).
+ %
:- pred call_gen__generic_call_info(code_model::in, generic_call::in,
code_addr::out, assoc_list(prog_var, arg_info)::out, int::out) is det.
@@ -72,6 +75,7 @@
:- import_module libs__tree.
:- import_module ll_backend__code_util.
:- import_module ll_backend__trace.
+:- import_module parse_tree__error_util.
:- import_module bool.
:- import_module int.
@@ -109,13 +113,10 @@
goal_info_get_context(GoalInfo, Context),
goal_info_get_goal_path(GoalInfo, GoalPath),
CallCode = node([
- livevals(LiveVals)
- - "",
+ livevals(LiveVals) - "",
call(Address, label(ReturnLabel), ReturnLiveLvalues, Context,
- GoalPath, CallModel)
- - CallComment,
- label(ReturnLabel)
- - "continuation label"
+ GoalPath, CallModel) - CallComment,
+ label(ReturnLabel) - "continuation label"
]),
% Figure out what variables will be live at the return point,
@@ -138,17 +139,14 @@
%---------------------------------------------------------------------------%
- %
- % For a generic_call,
- % we split the arguments into inputs and outputs, put the inputs
- % in the locations expected by mercury__do_call_closure in
- % runtime/mercury_ho_call.c, generate the call to that code,
- % and pick up the outputs from the locations that we know
- % the runtime system leaves them in.
- %
-
call_gen__generate_generic_call(OuterCodeModel, GenericCall, Args0,
Modes0, Det, GoalInfo, Code, !CI) :-
+ % For a generic_call, we split the arguments into inputs and outputs,
+ % put the inputs in the locations expected by mercury__do_call_closure in
+ % runtime/mercury_ho_call.c, generate the call to that code, and pick up
+ % the outputs from the locations that we know the runtime system leaves
+ % them in.
+
% `unsafe_cast' differs from the other generic call types in
% that there is no address. Also, live_vars.m assumes that
% unsafe_casts do not require live variables to be saved to the stack.
@@ -157,8 +155,8 @@
call_gen__generate_assign_builtin(OutputArg,
leaf(InputArg), Code, !CI)
;
- error(
- "call_gen__generate_generic_call: invalid unsafe_cast call")
+ unexpected(this_file,
+ "generate_generic_call: invalid unsafe_cast call")
)
;
call_gen__generate_generic_call_2(OuterCodeModel,
@@ -229,13 +227,10 @@
ReturnInstMap, ReturnLiveLvalues, !CI),
CallCode = node([
- livevals(LiveVals)
- - "",
+ livevals(LiveVals) - "",
call(CodeAddr, label(ReturnLabel), ReturnLiveLvalues,
- Context, GoalPath, CallModel)
- - "Setup and call",
- label(ReturnLabel)
- - "Continuation label"
+ Context, GoalPath, CallModel) - "Setup and call",
+ label(ReturnLabel) - "Continuation label"
]),
% If the call can fail, generate code to check for and
@@ -248,6 +243,7 @@
%---------------------------------------------------------------------------%
% The registers before the first input argument are all live.
+ %
:- pred call_gen__extra_livevals(int::in, list(lval)::out) is det.
call_gen__extra_livevals(FirstInput, ExtraLiveVals) :-
@@ -285,7 +281,7 @@
% call_gen__generic_call_info. call_gen__generic_call_nonvar_setup
% generates code to pass to the dispatch routine the parts of the
% indirectly called code's identifier that come from constants.
-
+ %
:- pred call_gen__generic_call_nonvar_setup(generic_call::in,
list(prog_var)::in, list(prog_var)::in, code_tree::out,
code_info::in, code_info::out) is det.
@@ -346,13 +342,11 @@
;
code_info__get_next_label(ContLab, !CI),
FailTestCode = node([
- if_val(lval(reg(r, 1)), label(ContLab))
- - "test for success"
+ if_val(lval(reg(r, 1)), label(ContLab)) - "test for success"
]),
code_info__generate_failure(FailCode, !CI),
ContLabelCode = node([
- label(ContLab)
- - ""
+ label(ContLab) - ""
]),
FailHandlingCode = tree_list([FailTestCode,
FailCode, ContLabelCode])
@@ -383,11 +377,11 @@
% called procedure.) We handle such variables not by making them
% forward-dead but by simply never making them forward-live in the
% first place.
-
+ %
% ArgsInfos should list all the output arguments of the call.
% It may contain the input arguments as well; kill_dead_input_vars
% and handle_return ignore them.
-
+ %
:- pred call_gen__kill_dead_input_vars(assoc_list(prog_var, arg_info)::in,
hlds_goal_info::in, set(prog_var)::out,
code_info::in, code_info::out) is det.
@@ -474,9 +468,7 @@
),
(
CodeModel = model_det,
- (
- SimpleCode = assign(Var, AssignExpr)
- ->
+ ( SimpleCode = assign(Var, AssignExpr) ->
call_gen__generate_assign_builtin(Var,
AssignExpr, Code, !CI)
;
@@ -484,9 +476,7 @@
)
;
CodeModel = model_semi,
- (
- SimpleCode = test(TestExpr)
- ->
+ ( SimpleCode = test(TestExpr) ->
call_gen__generate_simple_test(TestExpr, Rval,
ArgCode, !CI),
code_info__fail_if_rval_is_false(Rval, TestCode, !CI),
@@ -599,4 +589,9 @@
call_gen__give_vars_consecutive_arg_infos(Vars, N1, ArgMode, ArgInfos).
%---------------------------------------------------------------------------%
+
+:- func this_file = string.
+
+this_file = "call_gen.m".
+
%---------------------------------------------------------------------------%
Index: compiler/clause_to_proc.m
===================================================================
RCS file: /home/mercury/mercury1/repository/mercury/compiler/clause_to_proc.m,v
retrieving revision 1.49
diff -u -b -r1.49 clause_to_proc.m
--- compiler/clause_to_proc.m 26 Jul 2005 01:56:22 -0000 1.49
+++ compiler/clause_to_proc.m 7 Aug 2005 04:36:05 -0000
@@ -1,4 +1,6 @@
%-----------------------------------------------------------------------------%
+% vim: ft=mercury ts=4 sw=4 et
+%-----------------------------------------------------------------------------%
% Copyright (C) 1995-2005 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.
@@ -106,8 +108,7 @@
% No inst_vars in default func mode.
add_new_proc(InstVarSet, PredArity, PredArgModes,
yes(PredArgModes), MaybePredArgLives, yes(Determinism),
- Context, address_is_not_taken, PredInfo0, PredInfo,
- ProcId),
+ Context, address_is_not_taken, PredInfo0, PredInfo, ProcId),
MaybeProcId = yes(ProcId)
;
PredInfo = PredInfo0,
@@ -126,8 +127,8 @@
copy_module_clauses_to_procs_2([PredId | PredIds], Preds0, Preds) :-
map__lookup(Preds0, PredId, PredInfo0),
(
- % don't process typeclass methods, because their proc_infos
- % are generated already mode-correct
+ % Don't process typeclass methods, because their proc_infos
+ % are generated already mode-correct.
pred_info_get_markers(PredInfo0, PredMarkers),
check_marker(PredMarkers, class_method)
->
@@ -138,7 +139,6 @@
),
copy_module_clauses_to_procs_2(PredIds, Preds1, Preds).
-
copy_clauses_to_procs(!PredInfo) :-
pred_info_procedures(!.PredInfo, Procs0),
pred_info_clauses_info(!.PredInfo, ClausesInfo),
@@ -171,8 +171,7 @@
% `HeadVar__n' names.
%
VarSet = list__foldl(set_arg_names, Args, VarSet0),
- require(unify(ExtraArgs, []),
- "copy_clauses_to_proc: extra_args")
+ require(unify(ExtraArgs, []), "copy_clauses_to_proc: extra_args")
;
VarSet = VarSet0
),
@@ -212,8 +211,7 @@
( contains_nonpure_goal(GoalList) ->
list__map(get_purity, GoalList, PurityList),
Purity = list__foldl(worst_purity, PurityList, (pure)),
- add_goal_info_purity_feature(GoalInfo2, Purity,
- GoalInfo)
+ add_goal_info_purity_feature(GoalInfo2, Purity, GoalInfo)
;
GoalInfo2 = GoalInfo
),
cvs diff: Diffing compiler/notes
cvs diff: Diffing debian
cvs diff: Diffing deep_profiler
cvs diff: Diffing deep_profiler/notes
cvs diff: Diffing doc
cvs diff: Diffing extras
cvs diff: Diffing extras/aditi
cvs diff: Diffing extras/cgi
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/curs
cvs diff: Diffing extras/curs/samples
cvs diff: Diffing extras/curses
cvs diff: Diffing extras/curses/sample
cvs diff: Diffing extras/dynamic_linking
cvs diff: Diffing extras/error
cvs diff: Diffing extras/graphics
cvs diff: Diffing extras/graphics/easyx
cvs diff: Diffing extras/graphics/easyx/samples
cvs diff: Diffing extras/graphics/mercury_glut
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/gears
cvs diff: Diffing extras/graphics/samples/maze
cvs diff: Diffing extras/graphics/samples/pent
cvs diff: Diffing extras/lazy_evaluation
cvs diff: Diffing extras/lex
cvs diff: Diffing extras/lex/samples
cvs diff: Diffing extras/lex/tests
cvs diff: Diffing extras/logged_output
cvs diff: Diffing extras/moose
cvs diff: Diffing extras/moose/samples
cvs diff: Diffing extras/moose/tests
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/quickcheck
cvs diff: Diffing extras/quickcheck/tutes
cvs diff: Diffing extras/references
cvs diff: Diffing extras/references/samples
cvs diff: Diffing extras/references/tests
cvs diff: Diffing extras/stream
cvs diff: Diffing extras/trailed_update
cvs diff: Diffing extras/trailed_update/samples
cvs diff: Diffing extras/trailed_update/tests
cvs diff: Diffing extras/xml
cvs diff: Diffing extras/xml/samples
cvs diff: Diffing extras/xml_stylesheets
cvs diff: Diffing java
cvs diff: Diffing java/runtime
cvs diff: Diffing library
cvs diff: Diffing mdbcomp
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 slice
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/general/string_format
cvs diff: Diffing tests/general/structure_reuse
cvs diff: Diffing tests/grade_subdirs
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/mmc_make
cvs diff: Diffing tests/mmc_make/lib
cvs diff: Diffing tests/recompilation
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 util
cvs diff: Diffing vim
cvs diff: Diffing vim/after
cvs diff: Diffing vim/ftplugin
cvs diff: Diffing vim/syntax
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list