[PATCH] D71407: [TableGen] Introduce a `defvar` statement.

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 13 05:49:10 PST 2019


hfinkel added a comment.

In D71407#1781506 <https://reviews.llvm.org/D71407#1781506>, @simon_tatham wrote:

> I've been working around the lack of this for a while, so I thought it was worth at least trying to get it accepted.


I think that this is a good idea. We spend a lot of time programming in TableGen, and we should do ourselves the favor of giving it reasonable programming-language features, and I think that local variables seem like just the kind of feature that it would be reasonable to add. This prevents unnecessary repetition of expressions or the unnecessarily-verbose uses of foreach or multiclasses.

> This is something of a first draft. Things I'm not certain of:
> 
> - should a defvar in a foreach be local to it? (Probably)

I agree. This seems like the consistent behavior.

> - should I allow defvar inside a class or def as well as in a multiclass, defining variables that vanish at the closing brace but can be referred to by the definitions of proper class member values? (Possibly)

This also seems consistent with the feature overall. Are there reasons why we might not want to do this?

> - is defvar the sensible name? (`def` and `let` were already taken; I considered C++ `using`, but thought `defvar` fits reasonably well with the existing `defset`)

Or just `var`? `defvar` seems fine to me, and seems consistent with other TableGen syntax.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71407/new/

https://reviews.llvm.org/D71407





More information about the llvm-commits mailing list