clang 23.0.0git
CIROpenCLAttrs.cpp
Go to the documentation of this file.
1//===- CIROpenCLAttrs.cpp - OpenCL specific attributes in CIR -------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file defines the OpenCL-specific attrs in the CIR dialect.
10//
11//===----------------------------------------------------------------------===//
12
14
15#include "mlir/IR/Attributes.h"
16#include "mlir/IR/Diagnostics.h"
17#include "llvm/ADT/STLExtras.h"
18
19using namespace mlir;
20using namespace cir;
21
22//===----------------------------------------------------------------------===//
23// OpenCLKernelArgMetadataAttr definitions
24//===----------------------------------------------------------------------===//
25
26LogicalResult OpenCLKernelArgMetadataAttr::verify(
27 function_ref<InFlightDiagnostic()> emitError, ArrayAttr addrSpaces,
28 ArrayAttr accessQuals, ArrayAttr types, ArrayAttr baseTypes,
29 ArrayAttr typeQuals, ArrayAttr argNames) {
30 if (!llvm::all_of(ArrayRef<ArrayAttr>{addrSpaces, accessQuals, types,
31 baseTypes, typeQuals, argNames},
32 [&](ArrayAttr attr) {
33 return !attr || attr.size() == addrSpaces.size();
34 }))
35 return emitError() << "all arrays must have the same number of elements";
36
37 return success();
38}
const internal::VariadicAllOfMatcher< Attr > attr