[Mlir-commits] [llvm] [mlir] [MLIR][NVVM] Add NVVMRequiresSM op trait (PR #126886)
Mehdi Amini
llvmlistbot at llvm.org
Fri Mar 14 03:00:16 PDT 2025
================
@@ -0,0 +1,88 @@
+//===--- 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 "mlir/IR/StorageUniquerSupport.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; }
+
+ // Parses the SM version string and sets the archVersion (integer) and
+ // the archAccelerated flag.
+ void parse(StringRef SMVersion) {
----------------
joker-eph wrote:
```suggestion
void parse(StringRef smVersion) {
```
Nit: mlir style is lower-case variable
https://github.com/llvm/llvm-project/pull/126886
More information about the Mlir-commits
mailing list