[PATCH] D151842: [TableGen] Add !setdagarg and !setdagname
Simon Tatham via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 5 02:24:38 PDT 2023
simon_tatham added inline comments.
================
Comment at: llvm/lib/TableGen/Record.cpp:1296-1321
if (IntInit *Idx = dyn_cast<IntInit>(RHS)) {
int64_t Pos = Idx->getValue();
if (Pos < 0) {
// The index is negative.
PrintFatalError(CurRec->getLoc(), Twine("!getdagarg index ") +
std::to_string(Pos) +
Twine(" is negative"));
----------------
I'd intended to suggest that //all of this code//, not just the name lookup, could be factored out into a function that took an `Init *` and returned an `optional<unsigned>` argument number. It would handle both the integer and string cases, and construct an appropriate error message on failure (perhaps also given the name of the bang-operator it was being used by).
Then you'd only need one if statement in this case handler, and also for the ones in SETDAGARG and SETDAGNAME.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D151842/new/
https://reviews.llvm.org/D151842
More information about the llvm-commits
mailing list