[m-dev.] diff: fix reuse codegen problem
Peter Ross
peter.ross at miscrit.be
Sat Mar 10 01:33:42 AEDT 2001
On Fri, Mar 09, 2001 at 01:38:49AM +1100, Fergus Henderson wrote:
> On 08-Mar-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> > On Thu, Mar 08, 2001 at 11:50:35PM +1100, Fergus Henderson wrote:
> > > On 08-Mar-2001, Peter Ross <peter.ross at miscrit.be> wrote:
> > > >
> > > > compiler/ml_unify_gen.m:
> > > > Change from using the depreceated body binop to the unmkbody unop.
> > >
> > > s/depreceated/deprecated/
> > >
> > > What makes you think that the `body' binop is deprecated?
> > > If it is, why is it deprecated?
> >
> > Because mlds_output_binop no longer handles this case,
>
> Ah, I see.
>
> > and it used to work at some previous point,
>
> Hmm, I'm quite skeptical about that.
> It looks to me like it can never have worked.
>
> > so I assumed that we were no longer using this operator.
> >
> > > > +++ compiler/ml_unify_gen.m 2001/03/08 09:36:41
> > > > @@ -1065,8 +1065,8 @@
> > > > Var2Rval = lval(Var2Lval)
> > > > ;
> > > > Var2Rval = mkword(PrimaryTag,
> > > > - binop(body, lval(Var2Lval),
> > > > - ml_gen_mktag(ReusePrimaryTag)))
> > > > + unop(std_unop(unmkbody),
> > > > + lval(Var2Lval)))
> > >
> > > Could you explain that one for me in more detail?
> >
> > When reusing a cell, we must ensure that the tag is correct. If the tag
> > on the cell we wish to reuse is different to the one which should be on
> > the new cell, then we replace the old tag with the new tag.
>
> OK, that much I understood. I understand what the code is intended to do.
> What I don't understand is how your modification helps it to do that.
> The old code there
>
> Var2Rval = mkword(PrimaryTag,
> binop(body, lval(Var2Lval),
> ml_gen_mktag(ReusePrimaryTag)))
>
> looks fine to me. If mlds_to_c is not handling the `body' binop,
> then mlds_to_c should be fixed, not the code here.
>
> The new code that you replaced it with, namely
>
> Var2Rval = mkword(PrimaryTag,
> unop(std_unop(unmkbody),
> lval(Var2Lval)))
>
> looks completely wrong. You can't just replace `body'
> with `unmkbody', since they do opposite things.
>
> In particular,
>
> (1) the argument to `unmkbody' is supposed to be something that
> resulted from a call to `mkbody', i.e. something without a tag.
> But the argument that you pass to it, i.e. `Var2Lval', might have
> a tag on it.
>
> (2) the second argument to `mkword' is supposed to be either
> a pointer or something that resulted from a call to `mkbody',
> but you pass it the result of a call to `unmkbody', which
> is neither of those two.
>
Thanks for pointing out my stupid mistakes. I have backed the change
out. I think what the problem was that previously code with the body
binop was never generated by the MLDS backend (including my previous
incarnations of the reuse branch), yet I thought it was. That
compounded by misread of the unmkbody macro and you end up with the
above.
===================================================================
Estimated hours taken: 0.5
Branches: main, reuse
Back out my previous change to ml_unify_gen, and fix mlds_to_c instead
to handle the body binop.
compiler/ml_unify_gen.m:
Back out my previous broken change.
compiler/mlds_to_c.m:
Handle the body binop.
Index: compiler/ml_unify_gen.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/ml_unify_gen.m,v
retrieving revision 1.16.2.9
diff -u -r1.16.2.9 ml_unify_gen.m
--- compiler/ml_unify_gen.m 2001/03/08 09:42:44 1.16.2.9
+++ compiler/ml_unify_gen.m 2001/03/09 14:07:14
@@ -1065,8 +1065,8 @@
Var2Rval = lval(Var2Lval)
;
Var2Rval = mkword(PrimaryTag,
- unop(std_unop(unmkbody),
- lval(Var2Lval)))
+ binop(body, lval(Var2Lval),
+ ml_gen_mktag(ReusePrimaryTag)))
},
{ MLDS_Statement = ml_gen_assign(Var1Lval, Var2Rval, Context) },
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.55.2.7
diff -u -r1.55.2.7 mlds_to_c.m
--- compiler/mlds_to_c.m 2001/03/09 12:49:22 1.55.2.7
+++ compiler/mlds_to_c.m 2001/03/09 14:07:16
@@ -2837,6 +2837,14 @@
mlds_output_rval(Y),
io__write_string("]")
;
+ { Op = body }
+ ->
+ io__write_string("MR_body("),
+ mlds_output_rval(X),
+ io__write_string(", "),
+ mlds_output_rval(Y),
+ io__write_string(")")
+ ;
{ c_util__string_compare_op(Op, OpStr) }
->
io__write_string("(strcmp("),
--------------------------------------------------------------------------
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