[m-dev.] Re: for review: convert MLDS assignments into initializers
Julien Fischer
juliensf at students.cs.mu.oz.au
Fri Feb 9 13:50:53 AEDT 2001
On Thu, 8 Feb 2001, Fergus Henderson wrote:
> Index: compiler/ml_optimize.m
> ===================================================================
> RCS file: /home/mercury1/repository/mercury/compiler/ml_optimize.m,v
> retrieving revision 1.4
> diff -u -d -r1.4 ml_optimize.m
> --- compiler/ml_optimize.m 2000/11/21 13:37:43 1.4
> +++ compiler/ml_optimize.m 2001/02/08 09:45:15
> @@ -9,7 +9,9 @@
>
> % This module runs various optimizations on the MLDS.
> %
> -% Currently the only optimization is turning tailcalls into loops.
> +% Currently the optimization we do here are
> +% - turning tailcalls into loops.
> +% - converting assignments to local variables into variable initializers
s/optimization/optimizations/
s/initializers/initializers./
> Index: compiler/ml_util.m
> +%
> +% routines that deal with lvals/rvals
> +%
> +
> +%
> +% initializer_contains_var:
> +% rvals_contains_var:
> +% maybe_rval_contains_var:
> +% rval_contains_var:
> +% lvals_contains_var:
> +% lval_contains_var:
> +% Succeeds iff the specified construct contains a reference to
> +% the specified variable.
> +%
> +
> +% initializer_contains_var(no_initializer, _) :- fail.
Why is this commented out? If it's not doing anything
it should probably be deleted. (and the ones below)
> +initializer_contains_var(init_obj(Rval), Name) :-
> + rval_contains_var(Rval, Name).
> +initializer_contains_var(init_struct(Inits), Name) :-
> + list__member(Init, Inits),
> + initializer_contains_var(Init, Name).
> +initializer_contains_var(init_array(Inits), Name) :-
> + list__member(Init, Inits),
> + initializer_contains_var(Init, Name).
> +
> +rvals_contains_var(Rvals, Name) :-
> + list__member(Rval, Rvals),
> + rval_contains_var(Rval, Name).
> +
> +% maybe_rval_contains_var(no, _Name) :- fail.
> +maybe_rval_contains_var(yes(Rval), Name) :-
> + rval_contains_var(Rval, Name).
> +
> +rval_contains_var(lval(Lval), Name) :-
> + lval_contains_var(Lval, Name).
> +rval_contains_var(mkword(_Tag, Rval), Name) :-
> + rval_contains_var(Rval, Name).
> +% rval_contains_var(const(_Const), _Name) :- fail.
> +rval_contains_var(unop(_Op, Rval), Name) :-
> + rval_contains_var(Rval, Name).
> Index: compiler/options.m
> ===================================================================
> % Optimization level 3: apply optimizations which usually have a good
> @@ -2539,7 +2545,10 @@
> "\tDisable the MLDS->MLDS optimization passes.",
> "--no-optimize-tailcalls",
> "\tTreat tailcalls as ordinary calls, rather than optimizing",
> - "\tby turning self-tailcalls into loops."
> + "\tby turning self-tailcalls into loops.",
> + "--no-optimize-initializations",
> + "\tLeave initializations of local variables as assignment statements,",
> + "\trather converting such assignments statements into initializers."
See comment below about last line.
> Index: doc/user_guide.texi
> ===================================================================
>
> + at item --no-optimize-initializations
> +Leave initializations of local variables as assignment statements,
> +rather converting such assignments statements into initializers.
That last line would make more sense as:
"rather than converting such assignment statements into initializers."
or even just:
"rather than converting such assignments into initializers."
Otherwise that looks good.
Julien
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list