Skip to content

Commit

Permalink
[mlir][PDLL] Allow (and ignore) -D tablegen macros. (llvm#124166)
Browse files Browse the repository at this point in the history
Similar to llvm#91329, `mlir-pdll` is a tool used in tablegen macros that
unregisters from common flags, including `-D` macros. Because a macro
may be used globally, e.g. configured via `LLVM_TABLEGEN_FLAGS`, we want
this tool to just ignore the macro instead of a fatal failure due to the
unrecognized flag.
  • Loading branch information
rupprecht authored Jan 23, 2025
1 parent 24b1373 commit e10d551
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions mlir/tools/mlir-pdll/mlir-pdll.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,15 @@ int main(int argc, char **argv) {
"write-if-changed",
llvm::cl::desc("Only write to the output file if it changed"));

// `ResetCommandLineParser` at the above unregistered the "D" option
// of `llvm-tblgen`, which causes tblgen usage to fail due to
// "Unknnown command line argument '-D...`" when a macros name is
// present. The following is a workaround to re-register it again.
llvm::cl::list<std::string> macroNames(
"D",
llvm::cl::desc("Name of the macro to be defined -- ignored by mlir-pdll"),
llvm::cl::value_desc("macro name"), llvm::cl::Prefix);

llvm::InitLLVM y(argc, argv);
llvm::cl::ParseCommandLineOptions(argc, argv, "PDLL Frontend");

Expand Down

0 comments on commit e10d551

Please sign in to comment.