[clang] [CIR][OpenCL] Add kernel argument metadata attribute (PR #199530)
Konstantinos Parasyris via cfe-commits
cfe-commits at lists.llvm.org
Tue May 26 06:28:31 PDT 2026
================
@@ -0,0 +1,69 @@
+//===- CIROpenCLAttrs.cpp - OpenCL specific attributes in CIR -------------===//
+//
+// 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 the OpenCL-specific attrs in the CIR dialect.
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/CIR/Dialect/IR/CIRAttrs.h"
+
+#include "mlir/IR/Attributes.h"
+#include "mlir/IR/Diagnostics.h"
+#include "llvm/ADT/STLExtras.h"
+
+using namespace mlir;
+using namespace cir;
+
+//===----------------------------------------------------------------------===//
+// OpenCLKernelArgMetadataAttr definitions
+//===----------------------------------------------------------------------===//
+
+LogicalResult OpenCLKernelArgMetadataAttr::verify(
+ function_ref<InFlightDiagnostic()> emitError, ArrayAttr addrSpaces,
+ ArrayAttr accessQuals, ArrayAttr types, ArrayAttr baseTypes,
+ ArrayAttr typeQuals, ArrayAttr argNames) {
+ auto isInt32Array = [](ArrayAttr attr) {
+ return llvm::all_of(attr, [](Attribute elem) {
+ auto intAttr = mlir::dyn_cast<IntegerAttr>(elem);
+ return intAttr && intAttr.getType().isInteger(32);
+ });
+ };
+ auto isNonNegativeIntArray = [](ArrayAttr attr) {
+ return llvm::all_of(attr, [](Attribute elem) {
+ return mlir::cast<IntegerAttr>(elem).getValue().isNonNegative();
+ });
+ };
+ auto isStrArray = [](ArrayAttr attr) {
+ return llvm::all_of(
+ attr, [](Attribute elem) { return mlir::isa<StringAttr>(elem); });
+ };
+
+ if (!isInt32Array(addrSpaces))
----------------
koparasy wrote:
Should we here use the [clang/include/clang/CIR/Dialect/IR/CIREnumAttr.td](https://github.com/llvm/llvm-project/blob/main/clang/include/clang/CIR/Dialect/IR/CIREnumAttr.td#L39)? instead of a raw integer?
https://github.com/llvm/llvm-project/pull/199530
More information about the cfe-commits
mailing list