[llvm] [mlir] [MLIR][NVVM] Add NVVMRequiresSM op traits (PR #126886)
Guray Ozen via llvm-commits
llvm-commits at lists.llvm.org
Sun May 18 23:51:38 PDT 2025
================
@@ -27,12 +27,17 @@ def RequiresSMInterface: OpInterface<"RequiresSMInterface"> {
];
}
-class NVVMRequiresSM<int minVersion, string isArchAccelerated = "false",
- string exactMatch = "false"> :
- ParamNativeOpTrait<"NVVMRequiresSM",
- !cast<string>(minVersion) # "," # isArchAccelerated # ","
- # exactMatch>;
-
-class NVVMRequiresSMa<int version> : NVVMRequiresSM<version, "true", "true">;
+class NVVMRequiresSM<int minVersion> :
+ ParamNativeOpTrait<"NVVMRequiresSM", !cast<string>(minVersion)>;
+
+class StrJoin<string sep, list<string> str_list> {
+ string ret = !foldl("", str_list, a, b,
+ !if(!eq(a, ""), b, !if(!eq(b, ""), a, !strconcat(a, sep, b))));
+}
+
+class NVVMRequiresSMa<list<int> smVersions> :
+ ParamNativeOpTrait<"NVVMRequiresSMa",
+ StrJoin<",", !foreach(vers, smVersions,
+ !cast<string>(vers))>.ret>;
----------------
grypp wrote:
```suggestion
// OP requires an exact SM match along with
// architecture acceleration.
class NVVMRequiresSMa<list<int> smVersions> :
ParamNativeOpTrait<"NVVMRequiresSMa",
StrJoin<",", !foreach(vers, smVersions,
!cast<string>(vers))>.ret>;
```
https://github.com/llvm/llvm-project/pull/126886
More information about the llvm-commits
mailing list