[PATCH] D71407: [TableGen] Introduce a `defvar` statement.
Simon Tatham via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 13 06:16:53 PST 2019
simon_tatham added a comment.
> This also seems consistent with the feature overall. Are there reasons why we might not want to do this?
I can't think of a reason it's a //bad// idea. It's less vital in a class because you can define variables //anyway// (if you don't mind them showing up in the eventual records under some throwaway names you never look at). But yes, I think as long as I'm doing this anyway, I might as well make it work everywhere it might be needed, to avoid confusion.
> We spend a lot of time programming in TableGen, and we should do ourselves the favor of giving it reasonable programming-language features
Another thing on my wish list is an `if` statement, which you could use in (say) a multiclass or foreach to make one or more entire `def`s conditional on some function of the current parameters. Similar to defvar, that's a thing you can already fake up with a weird-looking foreach:
foreach dummyVar = !if(condition, [1], []<int>) in {
def only_defined_if_condition_is_true { ... }
}
but it would be shorter and clearer not to have to! (Plus it could have an `else` clause.)
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