[Mlir-commits] [mlir] [MLIR][NVVM] Add NVVMRequiresSM op trait (PR #126886)

Durgadoss R llvmlistbot at llvm.org
Tue Mar 11 02:52:31 PDT 2025


================
@@ -0,0 +1,91 @@
+//===--- NVVMTraits.h - NVVM Traits -----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+//
+// This file defines op traits for the NVVM Dialect in MLIR
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef NVVM_DIALECT_NVVM_IR_NVVMTRAITS_H_
+#define NVVM_DIALECT_NVVM_IR_NVVMTRAITS_H_
+
+#include "mlir/IR/OpDefinition.h"
+#include "llvm/ADT/StringExtras.h"
+
+namespace mlir {
+
+namespace NVVM {
+
+struct NVVMCheckSMVersion {
+  int ArchVersion;
+  bool ArchAccelerated;
+  std::string ArchString;
+
+  NVVMCheckSMVersion() {}
+  NVVMCheckSMVersion(StringRef SMVersion) : ArchString(SMVersion) {
+    parse(SMVersion);
+  }
+  NVVMCheckSMVersion(int ArchVersion, bool ArchAccelerated)
+      : ArchVersion(ArchVersion), ArchAccelerated(ArchAccelerated) {
+    ArchString = (llvm::Twine("sm_") + llvm::Twine(ArchVersion) +
+                  (ArchAccelerated ? "a" : "\0"))
+                     .str();
+  }
+
+  const StringRef getArchString() const { return ArchString; }
+
+  void parse(StringRef SMVersion) {
----------------
durga4github wrote:

Can you add a few lines of comment on the input/output of this parse function?

https://github.com/llvm/llvm-project/pull/126886


More information about the Mlir-commits mailing list