[Mlir-commits] [mlir] [mlir][ODS] Add `OptionalTypesMatchWith` and remove a custom assemblyFormat (PR #68876)
Benjamin Maxwell
llvmlistbot at llvm.org
Thu Oct 12 07:30:59 PDT 2023
================
@@ -568,6 +568,21 @@ class TypesMatchWith<string summary, string lhsArg, string rhsArg,
string transformer = transform;
}
+// Helper which makes the first letter of a string uppercase.
+// e.g. cat -> Cat
+class first_char_to_upper<string str>
+{
+ string ret = !toupper(!substr(str, 0, 1)) # !substr(str, 1);
+}
+
+// The same as TypesMatchWith but if either `lhsArg` or `rhsArg` are optional
+// and not present returns success.
+class OptionalTypesMatchWith<string summary, string lhsArg, string rhsArg,
+ string transform, string comparator = "std::equal_to<>()">
+ : TypesMatchWith<summary, lhsArg, rhsArg, transform,
+ "!get" # first_char_to_upper<lhsArg>.ret # "()"
+ # " || !get" # first_char_to_upper<rhsArg>.ret # "() || " # comparator>;
----------------
MacDue wrote:
I've added a `snakeCaseToCamelCase<str>` helper to `Utils.td` for this...
https://github.com/llvm/llvm-project/pull/68876
More information about the Mlir-commits
mailing list