[m-rev.] for review: copy packed args all at once

Julien Fischer jfischer at opturion.com
Sun Jun 3 01:17:24 AEST 2018



On Thu, 31 May 2018, Zoltan Somogyi wrote:

> For review by anyone.
>
> Copy packed arguments all at once.
> 
> Copy words containing packed-together sub-word-sized arguments all
> in one piece if possible.

I would change this summary to add that this diff applies to the
high-level C backend.

> Given a type such as
> 
> :- type t
>     --->    f1(int8, bool, int8, int, bool, int8, bool).
> 
> whose first three and last three arguments are packed into one word each,
> and a predicate such as

...


> diff --git a/compiler/mlds.m b/compiler/mlds.m
> index 2555e0d..d40069e 100644
> --- a/compiler/mlds.m
> +++ b/compiler/mlds.m

...

> @@ -2391,6 +2393,33 @@
>              % allocated from a counter that is shared between all
>              % lvnc_aux_vars.
> 
> +    ;       lvnc_packed_args(int).
> +            % Each of these MLDS variables contains a copy of one word
> +            % in a structured term's memory cell, where that word contains
> +            % the values of two or more arguments packed together. The idea
> +            % is that for HLDS code such as
> +            %
> +            % ...
> +            % X0 = f(A0, B0, C0),   % deconstruction
> +            % ...
> +            % X  = f(A , B0, C0),   % construction
> +            % ...
> +            %
> +            % where the B0 and C0 arguments are packed together into one word,
> +            % we should generate code that copies B0 and C0 from X0 to X
> +            % using just one load and one store. The shifts and masks needed
> +            % to compute the values of B0 and C0 should be needed only if
> +            % the HLDS code actually uses those variables in their own right.
> +            %
> +            % When the MLDS code generator seens a construction such as the

s/seens/sees/

> +            % above, which contains a word containing two or more arguments
> +            % all of which are being generated, it allocates a unique integer
> +            % for a new lvnc_packed_args variable and assigns that word to it.
> +            % Later code that needs those same argument variables packed
> +            % the same way may use this new variable instead. As its name
> +            % indicates, the ml_unused_assign optimization will delete
> +            % the unused assignments.

The diff looks fine otherwise.

Julien.


More information about the reviews mailing list