Improve IR variable naming #317

Merged
sb10q merged 3 commits from irname-improvements into master 2023-09-06 16:42:50 +08:00
Collaborator

In the past, local variables (specifically those created from gen_var_alloc and gen_store_target) are named using vague identifiers like tmp, attr and loadarrgep, which do not tell the use case of these variables.

This MR addresses this problem by (1) allowing callers to specify a name for these local variables (or none to indicate they are temporaries to an expression), and (2) Rename these variables to better reflect what they possibly do.

This MR does not retroactively rename all IR variables, only variables which are changed in this MR.

In the past, local variables (specifically those created from `gen_var_alloc` and `gen_store_target`) are named using vague identifiers like `tmp`, `attr` and `loadarrgep`, which do not tell the use case of these variables. This MR addresses this problem by (1) allowing callers to specify a name for these local variables (or none to indicate they are temporaries to an expression), and (2) Rename these variables to better reflect what they possibly do. This MR does *not* retroactively rename all IR variables, only variables which are changed in this MR.
sb10q was assigned by derppening 2023-09-06 15:04:59 +08:00
derppening added 3 commits 2023-09-06 15:05:00 +08:00
ff23968544 core: Add name parameter to gen_{var_alloc,store_target}
This allows variables in the IR to be assigned a custom name as opposed
to names with a default prefix.
f1b0e05b3d core: Rename IR variables
Because it is unclear which variables are expressions and
subexpressions, all variables which are previously anonymous are named
using (1) the control flow statement if available, (2) the possible name
of the variable as inferred from the variable name in Rust, and (3) the
"addr" prefix to indicate that the values are pointers. These three
strings are joint together using '.', forming "for.i.addr" for instance.
6de0884dc1 core: Use anonymous name for variables if unspecified
The current default prefix is only derived from the instruction type,
which is not helpful during the comprehension of the IR. Changing to
anonymous names (e.g. %1) helps understand that the variable is only
needed as part of a larger (possibly named) expression.
sb10q reviewed 2023-09-06 16:04:01 +08:00
sb10q merged commit 6de0884dc1 into master 2023-09-06 16:42:50 +08:00
Sign in to join this conversation.
No reviewers
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: M-Labs/nac3#317
There is no content yet.