[Mlir-commits] [mlir] [mlir][spirv] Refactor image operations (PR #128552)

Jakub Kuderski llvmlistbot at llvm.org
Mon Feb 24 13:04:05 PST 2025


================
@@ -0,0 +1,138 @@
+//===- ImageOps.cpp - MLIR SPIR-V Image Ops  ------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+//
+// Defines the image operations in the SPIR-V dialect.
+//
+//===----------------------------------------------------------------------===//
+
+#include "mlir/Dialect/SPIRV/IR/SPIRVOps.h"
+
+using namespace mlir;
+
+//===----------------------------------------------------------------------===//
+// Common utility functions
+//===----------------------------------------------------------------------===//
+
+template <typename Op>
+static LogicalResult verifyImageOperands(Op imageOp,
+                                         spirv::ImageOperandsAttr attr,
+                                         Operation::operand_range operands) {
+  if (!attr) {
+    if (operands.empty())
+      return success();
+
+    return imageOp.emitError("the Image Operands should encode what operands "
----------------
kuhar wrote:

Can we turn this into a non-template function by taking `imageOp` as `Operation *`? This is generally preferred due to code size (less duplication) and maintainability (code completion is better in plain functions).

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


More information about the Mlir-commits mailing list