[m-rev.] for review: var_table.m
Julien Fischer
jfischer at opturion.com
Sun Mar 27 15:15:35 AEDT 2022
Hi Zoltan,
On Sat, 26 Mar 2022, Zoltan Somogyi wrote:
> configure.ac:
> wider 79 < ml_code_util.m
Delete that.
> Introduce var_table.m.
>
> Most compiler passes need to know both the names and the types
> of the variables they operate on. Until now, they had to pass along
> two separate data structures for that, the varset and the vartypes,
> and many operations required looking a variable up in both of these.
>
> The var table is a single data structure that record for each variable
s/record/records/
>
> - its name, as the varset has traditionally done,
> - its type, as the vartypes has traditionally done,
> - the is_dummy_type flag which says whether its type is a dummy type,
> which traditionally had to computed from fresh at each lookup.
s/from fresh/afresh/
> Switch the MLDS code generator to use var_tables instead of varsets and
> vartypes. The code generator often needs to know the name and the type
> of a variable at the same time, and it often needs to know which variables'
> types are dummies, often enough that precomputing this info should be a win.
>
> compiler/var_table.m:
> Add this new module which defines the var_table.
>
> Its operations are modelled after the operation in var_types.m.
...
> diff --git a/compiler/notes/compiler_design.html b/compiler/notes/compiler_design.html
> index b0c28020b..3aa606a1c 100644
> --- a/compiler/notes/compiler_design.html
> +++ b/compiler/notes/compiler_design.html
> @@ -688,7 +688,11 @@ including the type module_info.
> status.m defines the type that record the import/export status
> of entities such as types, insts, modes, and predicates.
> <li>
> -vartypes.m defines the data structure that maps variables to their types.
> +vartypes.m defines the data structure that maps each variable to its types.
> +New code should use var_table.m, if possible.
> +<li>
> +var_table.m defines the data structure that each variable
that *maps* each ...
> +to its name, type, and an indication of whether that type is a dummy type.
> </ul>
>
> Some modules implement a pass that decides
...
> diff --git a/compiler/var_table.m b/compiler/var_table.m
> index e69de29bb..be6f45771 100644
> --- a/compiler/var_table.m
> +++ b/compiler/var_table.m
> @@ -0,0 +1,277 @@
> +%---------------------------------------------------------------------------%
> +% vim: ft=mercury ts=4 sw=4 et
> +%---------------------------------------------------------------------------%
> +% Copyright (C) 1996-2012 The University of Melbourne.
That copyright notice doesn't look correct.
> +% This file may only be copied under the terms of the GNU General
> +% Public License - see the file COPYING in the Mercury distribution.
> +%---------------------------------------------------------------------------%
> +%
> +% This module defines an ADT that records the types of the variables
> +% in a predicate or procedure.
That's just a copy-and-paste of the description from vartypes.m and is not
accurate for this module.
The rest looks fine.
Julien.
More information about the reviews
mailing list