1//===- PDL.cpp - C Interface for PDL 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
9#include "mlir-c/Dialect/PDL.h"
10#include "mlir/CAPI/Registration.h"
11#include "mlir/Dialect/PDL/IR/PDL.h"
12#include "mlir/Dialect/PDL/IR/PDLOps.h"
13#include "mlir/Dialect/PDL/IR/PDLTypes.h"
14
15using namespace mlir;
16
17MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(PDL, pdl, pdl::PDLDialect)
18
19//===---------------------------------------------------------------------===//
20// PDLType
21//===---------------------------------------------------------------------===//
22
23bool mlirTypeIsAPDLType(MlirType type) {
24 return isa<pdl::PDLType>(Val: unwrap(c: type));
25}
26
27//===---------------------------------------------------------------------===//
28// AttributeType
29//===---------------------------------------------------------------------===//
30
31bool mlirTypeIsAPDLAttributeType(MlirType type) {
32 return isa<pdl::AttributeType>(unwrap(type));
33}
34
35MlirType mlirPDLAttributeTypeGet(MlirContext ctx) {
36 return wrap(pdl::AttributeType::get(unwrap(ctx)));
37}
38
39//===---------------------------------------------------------------------===//
40// OperationType
41//===---------------------------------------------------------------------===//
42
43bool mlirTypeIsAPDLOperationType(MlirType type) {
44 return isa<pdl::OperationType>(unwrap(type));
45}
46
47MlirType mlirPDLOperationTypeGet(MlirContext ctx) {
48 return wrap(pdl::OperationType::get(unwrap(ctx)));
49}
50
51//===---------------------------------------------------------------------===//
52// RangeType
53//===---------------------------------------------------------------------===//
54
55bool mlirTypeIsAPDLRangeType(MlirType type) {
56 return isa<pdl::RangeType>(unwrap(type));
57}
58
59MlirType mlirPDLRangeTypeGet(MlirType elementType) {
60 return wrap(pdl::RangeType::get(unwrap(elementType)));
61}
62
63MlirType mlirPDLRangeTypeGetElementType(MlirType type) {
64 return wrap(cast<pdl::RangeType>(unwrap(type)).getElementType());
65}
66
67//===---------------------------------------------------------------------===//
68// TypeType
69//===---------------------------------------------------------------------===//
70
71bool mlirTypeIsAPDLTypeType(MlirType type) {
72 return isa<pdl::TypeType>(unwrap(type));
73}
74
75MlirType mlirPDLTypeTypeGet(MlirContext ctx) {
76 return wrap(pdl::TypeType::get(unwrap(ctx)));
77}
78
79//===---------------------------------------------------------------------===//
80// ValueType
81//===---------------------------------------------------------------------===//
82
83bool mlirTypeIsAPDLValueType(MlirType type) {
84 return isa<pdl::ValueType>(unwrap(type));
85}
86
87MlirType mlirPDLValueTypeGet(MlirContext ctx) {
88 return wrap(pdl::ValueType::get(unwrap(ctx)));
89}
90

source code of mlir/lib/CAPI/Dialect/PDL.cpp