[m-dev.] diff: add eval_method_uses_table

Fergus Henderson fjh at cs.mu.OZ.AU
Wed Jan 26 16:00:19 AEDT 2000


On 26-Jan-2000, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 
> > +	% Return true if the given evaluation method uses a table.
> > +	% If so, the back-end must generate a declaration for the
> > +	% variable to hold the table.
> > +:- func eval_method_uses_table(eval_method) = bool.
> 
> Nope, this centralized test is not what I meant in my previous mail. What
> I meant is that *each individual piece of code that examines the eval method*
> must contain its own switch on eval method.

I don't think that is a good idea; if several places are making the same
semantic test, then that code should be abstracted out into a separate
predicate, not duplicated.

> The eval method I am adding is tabling of I/O actions. Inlining ought to
> ignore procedures with this eval method just as it ignore other kinds of tabled
> procedures. However, all I/O tabled procedures share the same tabling pointer,
> which is defined in the runtime and not in the user program, which means
> the code generator should not generate a tabling pointer for such procedures.

OK, my code is assuming that every procedure which uses tabling has its
own tabling pointer.  If you need to add something which breaks that
assumption, then I suggest you define a similar boolean function
called say `eval_method_needs_tabling_pointer', and then go through all
the calls to `eval_method_uses_table', changing some of them to
`eval_method_needs_tabling_pointer'.  There will still be significant
commonality, e.g. inlining and modes.m will both use eval_method_uses_table,
whereas table_gen.m, code_gen.m, and ml_code_gen.m will all use
`eval_method_uses_table'.

If at some later stage, we decide to add e.g. `pragma loopcheck_without_memoing'
(which we were considering at one point -- we decided that the additional
efficiency was minor, and so it wasn't useful enough to be worth the additional
complexity), having things abstracted in this way would mean that we only
need to modify two places (`eval_method_needs_tabling_pointer'
and `eval_method_uses_table') rather than five.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
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