[PATCH] D145871: TableGen: Introduce `!range` operator for half-opened interval
Nicolai Hähnle via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 16 01:58:57 PDT 2023
nhaehnle added a comment.
`!range` makes sense to me because I also see the analogy to Python's `range`.
I have some minor notes inline, apart from that the code looks good to me.
================
Comment at: llvm/lib/TableGen/TGParser.cpp:1508
+ Init *LHS, *RHS;
+ auto *Arg0 = dyn_cast<TypedInit>(InitList[0]);
+ switch (InitList.size()) {
----------------
You're relying here on the cast always being successful (which makes sense), so you should use `cast` instead of `dyn_cast`. (This has the benefit of raising an assertion if the cast fails.)
================
Comment at: llvm/lib/TableGen/TGParser.cpp:1509
+ auto *Arg0 = dyn_cast<TypedInit>(InitList[0]);
+ switch (InitList.size()) {
+ case 1:
----------------
Using a `switch` for this instead of an `if/else` chain is a bit unorthodox, but I suppose we can live with it.
================
Comment at: llvm/lib/TableGen/TGParser.cpp:1525
+ assert(isa<IntRecTy>(Arg0->getType()));
+ assert(isa<IntRecTy>(dyn_cast<TypedInit>(InitList[1])->getType()));
+ LHS = Arg0;
----------------
Also here: use `cast` instead of `dyn_cast`
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D145871/new/
https://reviews.llvm.org/D145871
More information about the llvm-commits
mailing list