Skip to content

Commit e10d551

Browse files
authored
[mlir][PDLL] Allow (and ignore) -D tablegen macros. (#124166)
Similar to #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.
1 parent 24b1373 commit e10d551

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

mlir/tools/mlir-pdll/mlir-pdll.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,15 @@ int main(int argc, char **argv) {
167167
"write-if-changed",
168168
llvm::cl::desc("Only write to the output file if it changed"));
169169

170+
// `ResetCommandLineParser` at the above unregistered the "D" option
171+
// of `llvm-tblgen`, which causes tblgen usage to fail due to
172+
// "Unknnown command line argument '-D...`" when a macros name is
173+
// present. The following is a workaround to re-register it again.
174+
llvm::cl::list<std::string> macroNames(
175+
"D",
176+
llvm::cl::desc("Name of the macro to be defined -- ignored by mlir-pdll"),
177+
llvm::cl::value_desc("macro name"), llvm::cl::Prefix);
178+
170179
llvm::InitLLVM y(argc, argv);
171180
llvm::cl::ParseCommandLineOptions(argc, argv, "PDLL Frontend");
172181

0 commit comments

Comments
 (0)