[all-commits] [llvm/llvm-project] 45ea4d: [TableGen] Unify the priority of variables
Wang Pengcheng via All-commits
all-commits at lists.llvm.org
Tue May 23 21:44:47 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 45ea4d6256186b7869cd46907e88d8d2b1ea3df0
https://github.com/llvm/llvm-project/commit/45ea4d6256186b7869cd46907e88d8d2b1ea3df0
Author: wangpc <pc.wang at linux.alibaba.com>
Date: 2023-05-24 (Wed, 24 May 2023)
Changed paths:
M llvm/docs/TableGen/ProgRef.rst
M llvm/lib/TableGen/TGParser.cpp
M llvm/lib/TableGen/TGParser.h
M llvm/test/TableGen/defvar.td
Log Message:
-----------
[TableGen] Unify the priority of variables
In D148197, we have made `defvar` statement able to refer to class
template arguments. However, the priority of class/multiclass
template argument is higher than variables defined by `defvar`, which
is a little counterintuitive.
In this patch, we unify the priority of variables. Each pair of
braces introduces a new scope, which may contain some additional
variables like template arguments, loop iterators, etc. We can
define local variables inside this scope via `defvar` and these
variables are of higher priority than additional variables. This
means that `defvar` will shadow additional variables with the same
name. The scope can be nested, and we use the innermost variable.
This make variables defined by `defvar` prior to class/multiclass
template arguments, loop iterators, etc. The shadow rules now are:
* `V` in a record body shadows a global `V`.
* `V` in a record body shadows template argument `V`.
* `V` in template arguments shadows a global `V`.
* `V` in a `foreach` statement list shadows any `V` in surrounding record or global scopes.
Reviewed By: tra
Differential Revision: https://reviews.llvm.org/D149016
More information about the All-commits
mailing list