[m-dev.] for review: --target option, IL grades and copy-in/copy-out for MLDS
Tyson Dowd
trd at cs.mu.OZ.AU
Thu Sep 14 14:59:39 AEDT 2000
On 11-Sep-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> Hi,
>
> Some more review comments on this change.
>
> On 04-Sep-2000, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> > diff -u -r1.19 ml_code_util.m
> > + % XXX this code is quite similar to some of the existing code
> > + % for calling continuations when doing copy-in/copy-out.
> > + % Sharing code should be investigated.
> > +
> > +ml_gen_call_current_success_cont_indirectly(Context, MLDS_Statement) -->
> ...
> > + % We generate a nested function that does the real call
> > + % to the continuation.
> > + %
> > + % All we do is change the call rvals to be the input
> > + % variables, and the func rval to be the input variable
> > + % for the continuation.
> > + ml_gen_cont_params(ArgTypes0, InnerFuncParams0),
> > + { InnerFuncParams0 = func_params(InnerArgs0, Rets) },
> > + { InnerArgRvals = list__filter_map(
> > + (func(data(var(VarName)) - _Type)
> > + = lval(var(qual(MLDS_Module, VarName))) is semidet),
> > + InnerArgs0) },
>
> Here I think it would be better to make that a call to list__map
> rather than list__filter_map, and to call error/1 for any arguments
> that don't match the pattern `data(var(_)) - _' rather than just ignoring
> them.
>
> > + % XXX is the ArgTypes0 right?
> > + { InnerFuncArgType = mlds__cont_type(ArgTypes0) },
>
> I think the answer to that question is yes, in which case
> you can delete that XXX.
> (Why wouldn't it be right?)
These two changes weren't part of this diff -- they had been removed
from the round 2 of this diff. However I have fixed these problems now
and will put this change up for review soon.
> > + { Defn = mlds__defn(function(PredLabel, ProcId, yes(SeqNum), _), _, _,
> > + function(_, _, yes(_)))
> > + ->
>
> The condition of that if-then-else should be indented.
>
> > @@ -1333,9 +1523,10 @@
> > % The `ml_gen_info' type holds information used during MLDS code generation
> > % for a given procedure.
> > %
> > -% Only the `func_label', `commit_label', `cond_var', `success_cont_stack',
> > -% and `extra_defns' fields are mutable; the others are set when the
> > -% `ml_gen_info' is created and then never modified.
> > +% Only the `func_label', `commit_label', `cond_var', `conv_var',
> > +% `var_lvals', `success_cont_stack', and `extra_defns' fields are mutable;
> > +% the others are set when the % ml_gen_info' is created and then never
> > +% modified.
>
> s/% ml_gen_info'/`ml_gen_info'/
> ^^ ^
>
> > @@ -2149,11 +2173,6 @@
> > % ...
> > % new_argN_value = argN_tmp_copy;
> > %
> > - % The temporaries are needed for the case where
> > - % we are e.g. assigning v1, v2 to v2, v1;
> > - % they ensure that we don't try to reference the old value of
> > - % a parameter after it has already been clobbered by the
> > - % new value.
>
> Why did that comment get deleted?
Accident while moving code to a different module. The whole predicate
should be deleted, but this comment (and others) need to be moved to the
replacement predicate in ml_optimize.
>
> > +:- pred options_help_mlds_mlds_optimization(io__state::di, io__state::uo) is det.
> > +
> > +options_help_mlds_mlds_optimization -->
> > + io__write_string("\n MLDS -> MLDS optimizations:\n"),
> > + write_tabbed_lines([
> > + "--no-llds-optimize",
> > + "\tDisable the MLDS->MLDS optimization passes."
> > + ]).
>
> s/llds-optimize/mlds-optimize/
> ^ ^
>
> > + at item @code{--target c} (grades: none, reg, jump, fast, asm_jump, asm_fast, hlc)
> > + at itemx @code{--il}, @code{--target il} (grades: ilc)
> > +Specify the target language used for compilation: C or IL.
> > +C means ANSI/ISO C, optionally with GNU C extensions (see below).
> > +IL means the Microsoft COM+ 2.0 Intermediate Language.
> > + at samp{--target il} implies @samp{--high-level-code}.
>
> s/COM+ 2.0/.NET/
>
> The --no-mlds-optimize option should be documented in user_guide.texi.
Done. A relative diff is below. I'll commit this now.
===================================================================
Estimated hours taken: 0.5
Various fixes for problems fjh pointed out in a review.
compiler/ml_code_util.m:
Fix a typo.
compiler/ml_optimize.m:
compiler/mlds_to_c.m:
Move some comments from mlds_output_assign_args to
generate_assign_args.
Remove mlds_output_assign_args as it is now dead code.
compiler/options.m:
Fix a typo, llds-optimize should be mlds-optimize.
doc/user_guide.texi:
Document --no-mlds-optimize.
Index: compiler/ml_code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_code_util.m,v
retrieving revision 1.20
diff -u -r1.20 ml_code_util.m
--- compiler/ml_code_util.m 2000/09/06 05:20:57 1.20
+++ compiler/ml_code_util.m 2000/09/12 04:59:09
@@ -1422,7 +1422,7 @@
%
% Only the `func_label', `commit_label', `cond_var', `conv_var',
% `var_lvals', `success_cont_stack', and `extra_defns' fields are mutable;
-% the others are set when the % ml_gen_info' is created and then never
+% the others are set when the `ml_gen_info' is created and then never
% modified.
%
Index: compiler/ml_optimize.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_optimize.m,v
retrieving revision 1.1
diff -u -r1.1 ml_optimize.m
--- compiler/ml_optimize.m 2000/08/31 03:00:21 1.1
+++ compiler/ml_optimize.m 2000/09/12 05:03:39
@@ -192,7 +192,8 @@
%----------------------------------------------------------------------------
- % Generate assigments of new values to a list of arguments.
+ % Assign the specified list of rvals to the arguments.
+ % This is used as part of tail recursion optimization (see above).
:- pred generate_assign_args(opt_info, mlds__arguments, list(mlds__rval),
list(mlds__statement), list(mlds__defn)).
@@ -206,6 +207,9 @@
generate_assign_args(OptInfo,
[Name - Type | Rest], [Arg | Args], Statements, TempDefns) :-
(
+ %
+ % extract the variable name
+ %
Name = data(var(VarName))
->
QualVarName = qual(OptInfo ^ module_name, VarName),
@@ -219,6 +223,15 @@
Statements, TempDefns)
;
+ % Declare a temporary variable, initialized it
+ % to the arg, recursively process the remaining
+ % args, and then assign the temporary to the
+ % parameter:
+ %
+ % SomeType argN__tmp_copy = new_argN_value;
+ % ...
+ % new_argN_value = argN_tmp_copy;
+ %
% The temporaries are needed for the case where
% we are e.g. assigning v1, v2 to v2, v1;
% they ensure that we don't try to reference the old
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.55
diff -u -r1.55 mlds_to_c.m
--- compiler/mlds_to_c.m 2000/09/06 05:20:58 1.55
+++ compiler/mlds_to_c.m 2000/09/12 05:03:37
@@ -2136,61 +2136,6 @@
SymName = qualified(unqualified("mercury"), "private_builtin"),
PredLabel = pred(predicate, _, "unsafe_type_cast", 2).
- % Assign the specified list of rvals to the arguments.
- % This is used as part of tail recursion optimization (see above).
-:- pred mlds_output_assign_args(indent, mlds_module_name, mlds__context,
- mlds__arguments, list(mlds__rval), io__state, io__state).
-:- mode mlds_output_assign_args(in, in, in, in, in, di, uo) is det.
-
-mlds_output_assign_args(_, _, _, [_|_], []) -->
- { error("mlds_output_assign_args: length mismatch") }.
-mlds_output_assign_args(_, _, _, [], [_|_]) -->
- { error("mlds_output_assign_args: length mismatch") }.
-mlds_output_assign_args(_, _, _, [], []) --> [].
-mlds_output_assign_args(Indent, ModuleName, Context,
- [Name - Type | Rest], [Arg | Args]) -->
- %
- % extract the variable name
- %
- { Name = data(var(VarName1)) ->
- VarName = VarName1
- ;
- error("mlds_output_assign_args: arg is not a variable!")
- },
- (
- %
- % don't bother assigning a variable to itself
- %
- { Arg = lval(var(qual(ModuleName, VarName))) }
- ->
- mlds_output_assign_args(Indent, ModuleName, Context, Rest, Args)
- ;
- % Declare a temporary variable, initialized it to the arg,
- % recursively process the remaining args,
- % and then assign the temporary to the parameter:
- %
- % SomeType argN__tmp_copy = new_argN_value;
- % ...
- % new_argN_value = argN_tmp_copy;
- %
-
- { string__append(VarName, "__tmp_copy", TempName) },
- { QualTempName = qual(ModuleName, data(var(TempName))) },
- { Initializer = init_obj(Arg) },
- { TempDefn = ml_gen_mlds_var_decl(var(TempName), Type,
- Initializer, Context) },
- mlds_output_defn(Indent, ModuleName, TempDefn),
-
- mlds_output_assign_args(Indent, ModuleName, Context, Rest,
- Args),
-
- mlds_indent(Context, Indent),
- mlds_output_fully_qualified_name(qual(ModuleName, Name)),
- io__write_string(" = "),
- mlds_output_fully_qualified_name(QualTempName),
- io__write_string(";\n")
- ).
-
%-----------------------------------------------------------------------------%
%
Index: compiler/options.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/options.m,v
retrieving revision 1.288
diff -u -r1.288 options.m
--- compiler/options.m 2000/09/06 05:21:00 1.288
+++ compiler/options.m 2000/09/12 13:38:24
@@ -2366,7 +2366,7 @@
options_help_mlds_mlds_optimization -->
io__write_string("\n MLDS -> MLDS optimizations:\n"),
write_tabbed_lines([
- "--no-llds-optimize",
+ "--no-mlds-optimize",
"\tDisable the MLDS->MLDS optimization passes."
]).
Index: doc/user_guide.texi
===================================================================
RCS file: /home/mercury1/repository/mercury/doc/user_guide.texi,v
retrieving revision 1.219
diff -u -r1.219 user_guide.texi
--- doc/user_guide.texi 2000/09/06 05:21:17 1.219
+++ doc/user_guide.texi 2000/09/12 13:44:17
@@ -3470,7 +3470,7 @@
@itemx @code{--il}, @code{--target il} (grades: ilc)
Specify the target language used for compilation: C or IL.
C means ANSI/ISO C, optionally with GNU C extensions (see below).
-IL means the Microsoft COM+ 2.0 Intermediate Language.
+IL means the Microsoft .NET Intermediate Language.
@samp{--target il} implies @samp{--high-level-code}.
@sp 1
@@ -3741,6 +3741,7 @@
@menu
* Overall optimization options::
* High-level (HLDS -> HLDS) optimization options::
+* MLDS backend (MLDS -> MLDS) optimization options::
* Medium-level (HLDS -> LLDS) optimization options::
* Low-level (LLDS -> LLDS) optimization options::
* Output-level (LLDS -> C) optimization options::
@@ -3971,6 +3972,18 @@
Enable deforestation. Deforestation is a program transformation whose aim
is to avoid the construction of intermediate data structures and to avoid
repeated traversals over data structures within a conjunction.
+
+ at end table
+
+ at node MLDS backend (MLDS -> MLDS) optimization options
+ at subsection MLDS backend (MLDS -> MLDS) optimization options
+
+These optimizations are applied to the medium level
+intermediate code.
+
+ at table @code
+ at item --no-mlds-optimize
+Disable the MLDS -> MLDS optimization passes.
@end table
--
Tyson Dowd #
# Surreal humour isn't everyone's cup of fur.
trd at cs.mu.oz.au #
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
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