MLIR 23.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
30 return wrap(mlir::irdl::VariadicityAttr::name);
31}
32
33//===----------------------------------------------------------------------===//
34// VariadicityArrayAttr
35//===----------------------------------------------------------------------===//
36
37MlirAttribute mlirIRDLVariadicityArrayAttrGet(MlirContext ctx, intptr_t nValues,
38 MlirAttribute const *values) {
40 llvm::ArrayRef<mlir::Attribute> unwrappedAttrs =
41 unwrapList(nValues, values, attrs);
42
44 for (auto attr : unwrappedAttrs)
45 variadicities.push_back(llvm::cast<mlir::irdl::VariadicityAttr>(attr));
46
47 return wrap(
48 mlir::irdl::VariadicityArrayAttr::get(unwrap(ctx), variadicities));
49}
50
52 return wrap(mlir::irdl::VariadicityArrayAttr::name);
53}
MlirAttribute mlirIRDLVariadicityArrayAttrGet(MlirContext ctx, intptr_t nValues, MlirAttribute const *values)
Definition IRDL.cpp:37
MlirStringRef mlirIRDLVariadicityAttrGetName(void)
Definition IRDL.cpp:29
MlirStringRef mlirIRDLVariadicityArrayAttrGetName(void)
Definition IRDL.cpp:51
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:118
A pointer to a sized fragment of a string, not necessarily null-terminated.
Definition Support.h:75