[Mlir-commits] [mlir] [mlir][spirv] Lower mapped TOSA custom ops to ExperimentalML.Call (PR #202581)
Davide Grohmann
llvmlistbot at llvm.org
Tue Jun 9 06:04:19 PDT 2026
================
@@ -19,8 +19,44 @@
#include "mlir/Dialect/Tosa/IR/TosaOps.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Transforms/DialectConversion.h"
+#include "llvm/ADT/StringMap.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/CommandLine.h"
#include <algorithm>
+#include <string>
+#include <utility>
+
+namespace llvm::cl {
+template <>
+class parser<std::pair<std::string, int32_t>>
+ : public basic_parser<std::pair<std::string, int32_t>> {
+public:
+ parser(Option &option) : basic_parser(option) {}
+
+ bool parse(Option &option, StringRef argName, StringRef arg,
+ std::pair<std::string, int32_t> &value) {
+ auto [domain, opcodeString] = arg.rsplit(":");
+ if (domain.empty() || opcodeString.empty())
+ return option.error("expected <domain>:<opcode>", argName);
+
+ int32_t opcode;
+ if (opcodeString.getAsInteger(0, opcode))
+ return option.error("invalid opcode in custom op domain mapping",
+ argName);
+
+ value = {domain.str(), opcode};
+ return false;
----------------
davidegrohmann wrote:
`llvm::cl::parser::parse` returns `true` on error and `false` on success, so `false` is the expected success value here. The call to `option.error(...)` returns `true`.
https://github.com/llvm/llvm-project/pull/202581
More information about the Mlir-commits
mailing list