[llvm] [mlir] [MLIR][NVVM] Add NVVMRequiresSM op trait (PR #126886)
Guray Ozen via llvm-commits
llvm-commits at lists.llvm.org
Thu May 8 23:08:31 PDT 2025
================
@@ -0,0 +1,96 @@
+//===--- 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 {
+
+// Structure to store and check compatibility of SM versions.
+struct NVVMCheckSMVersion {
+ int archVersion;
+
+ // true if the SM version is accelerated (Ex. sm_90a vs sm_90)
+ bool archAccelerated;
+
+ // true if the target SM version must exactly match this one
+ // (both archVersion and archAccelerated)
+ // Ex. sm_90a with exactMatch = false will also match with
+ // sm_100a, sm_120a, etc...
+ bool exactMatch;
+
+ NVVMCheckSMVersion()
+ : archVersion(0), archAccelerated(false), exactMatch(false) {}
+ NVVMCheckSMVersion(StringRef smVersion, bool exactMatch = false)
+ : exactMatch(exactMatch) {
+ parse(smVersion);
+ }
+ NVVMCheckSMVersion(int archVersion, bool archAccelerated, bool exactMatch)
+ : archVersion(archVersion), archAccelerated(archAccelerated),
+ exactMatch(exactMatch) {}
+
+ // Parses the SM version string and sets the archVersion (integer) and
+ // the archAccelerated flag.
----------------
grypp wrote:
```suggestion
// Parses the SM version string and sets the archVersion (as an integer)
// and the archAccelerated flag.
```
https://github.com/llvm/llvm-project/pull/126886
More information about the llvm-commits
mailing list