[clang] [CIR][OpenCL] Add kernel argument metadata attribute (PR #199530)
Akimasa Watanuki via cfe-commits
cfe-commits at lists.llvm.org
Sat May 30 08:24:01 PDT 2026
================
@@ -0,0 +1,61 @@
+//===- 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 isLangAddressSpaceArray = [](ArrayAttr attr) {
+ return llvm::all_of(attr, [](Attribute elem) {
+ return mlir::isa<cir::LangAddressSpaceAttr>(elem);
----------------
Men-cotton wrote:
Good point. However, as mentioned above, this attribute represents source-level metadata and intentionally retains the lang AS. It is never lowered to a target AS during the target lowering pass.
https://github.com/llvm/llvm-project/pull/199530
More information about the cfe-commits
mailing list