[llvm] [Tablegen] Add keywork `dump`. (PR #68793)
Francesco Petrogalli via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 11 04:21:03 PDT 2023
================
@@ -4359,3 +4390,27 @@ LLVM_DUMP_METHOD void MultiClass::dump() const {
E.dump();
}
#endif
+
+bool TGParser::ParseDump(MultiClass *CurMultiClass, Record *CurRec) {
+ assert(Lex.getCode() == tgtok::Dump && "Unknown tok");
+ Lex.Lex(); // eat the operation
+
+ Init *Message = ParseValue(CurRec);
+ if (!Message)
+ return true;
+
+ std::string Msg;
+ if (auto SI = dyn_cast<StringInit>(Message))
+ Msg = SI->getValue();
+
+ if (!consume(tgtok::semi))
+ return TokError("expected ';'");
+
+ SMLoc ConditionLoc = Lex.getLoc();
+ if (CurRec)
+ CurRec->addDump(ConditionLoc, Message);
+ else
+ addEntry(std::make_unique<Record::DumpInfo>(ConditionLoc, Message));
----------------
fpetrogalli wrote:
```suggestion
SMLoc Loc = Lex.getLoc();
if (CurRec)
CurRec->addDump(Loc, Message);
else
addEntry(std::make_unique<Record::DumpInfo>(Loc, Message));
```
https://github.com/llvm/llvm-project/pull/68793
More information about the llvm-commits
mailing list