[Mlir-commits] [mlir] [MLIR][NVVM] Add NVVMRequiresSM op trait (PR #126886)
Pradeep Kumar
llvmlistbot at llvm.org
Thu Feb 13 21:58:03 PST 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) {
+ ArchAccelerated = (SMVersion[SMVersion.size() - 1] == 'a');
----------------
schwarzschild-radius wrote:
Maybe replace `SMVersion[SMVersion.size()]` with `SMVersion.back()`?
https://github.com/llvm/llvm-project/pull/126886
More information about the Mlir-commits
mailing list