MLIR 22.0.0git
IRDL.cpp
Go to the documentation of this file.
1//===- IRDL.cpp - C Interface for IRDL dialect ----------------------------===//
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
13
14MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(IRDL, irdl, mlir::irdl::IRDLDialect)
15
17 return wrap(mlir::irdl::loadDialects(unwrap(module)));
18}
19
20//===----------------------------------------------------------------------===//
21// VariadicityAttr
22//===----------------------------------------------------------------------===//
23
24MlirAttribute mlirIRDLVariadicityAttrGet(MlirContext ctx, MlirStringRef value) {
25 return wrap(mlir::irdl::VariadicityAttr::get(
26 unwrap(ctx), mlir::irdl::symbolizeVariadicity(unwrap(value)).value()));
27}
28
29//===----------------------------------------------------------------------===//
30// VariadicityArrayAttr
31//===----------------------------------------------------------------------===//
32
33MlirAttribute mlirIRDLVariadicityArrayAttrGet(MlirContext ctx, intptr_t nValues,
34 MlirAttribute const *values) {
36 llvm::ArrayRef<mlir::Attribute> unwrappedAttrs =
37 unwrapList(nValues, values, attrs);
38
40 for (auto attr : unwrappedAttrs)
41 variadicities.push_back(llvm::cast<mlir::irdl::VariadicityAttr>(attr));
42
43 return wrap(
44 mlir::irdl::VariadicityArrayAttr::get(unwrap(ctx), variadicities));
45}
MlirAttribute mlirIRDLVariadicityArrayAttrGet(MlirContext ctx, intptr_t nValues, MlirAttribute const *values)
Definition IRDL.cpp:33
MlirAttribute mlirIRDLVariadicityAttrGet(MlirContext ctx, MlirStringRef value)
Definition IRDL.cpp:24
#define MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Name, Namespace, ClassName)
static llvm::ArrayRef< CppTy > unwrapList(size_t size, CTy *first, llvm::SmallVectorImpl< CppTy > &storage)
Definition Wrap.h:40
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
Definition Diagnostics.h:24
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
Definition Diagnostics.h:19
MLIR_CAPI_EXPORTED MlirLogicalResult mlirLoadIRDLDialects(MlirModule module)
Loads all IRDL dialects in the provided module, registering the dialects in the module's associated c...
Definition IRDL.cpp:16
llvm::LogicalResult loadDialects(ModuleOp op)
Load all the dialects defined in the module.
A logical result value, essentially a boolean with named states.
Definition Support.h:116
A pointer to a sized fragment of a string, not necessarily null-terminated.
Definition Support.h:73