MLIR 22.0.0git
PDL.cpp
Go to the documentation of this file.
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
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>(unwrap(type));
25}
26
27//===---------------------------------------------------------------------===//
28// AttributeType
29//===---------------------------------------------------------------------===//
30
31bool mlirTypeIsAPDLAttributeType(MlirType type) {
32 return isa<pdl::AttributeType>(unwrap(type));
33}
34
36 return wrap(pdl::AttributeType::getTypeID());
37}
38
39MlirType mlirPDLAttributeTypeGet(MlirContext ctx) {
40 return wrap(pdl::AttributeType::get(unwrap(ctx)));
41}
42
44 return wrap(pdl::AttributeType::name);
45}
46
47//===---------------------------------------------------------------------===//
48// OperationType
49//===---------------------------------------------------------------------===//
50
51bool mlirTypeIsAPDLOperationType(MlirType type) {
52 return isa<pdl::OperationType>(unwrap(type));
53}
54
56 return wrap(pdl::OperationType::getTypeID());
57}
58
59MlirType mlirPDLOperationTypeGet(MlirContext ctx) {
60 return wrap(pdl::OperationType::get(unwrap(ctx)));
61}
62
64 return wrap(pdl::OperationType::name);
65}
66
67//===---------------------------------------------------------------------===//
68// RangeType
69//===---------------------------------------------------------------------===//
70
71bool mlirTypeIsAPDLRangeType(MlirType type) {
72 return isa<pdl::RangeType>(unwrap(type));
73}
74
75MlirTypeID mlirPDLRangeTypeGetTypeID(void) {
76 return wrap(pdl::RangeType::getTypeID());
77}
78
79MlirType mlirPDLRangeTypeGet(MlirType elementType) {
80 return wrap(pdl::RangeType::get(unwrap(elementType)));
81}
82
84 return wrap(pdl::RangeType::name);
85}
86
87MlirType mlirPDLRangeTypeGetElementType(MlirType type) {
88 return wrap(cast<pdl::RangeType>(unwrap(type)).getElementType());
89}
90
91//===---------------------------------------------------------------------===//
92// TypeType
93//===---------------------------------------------------------------------===//
94
95bool mlirTypeIsAPDLTypeType(MlirType type) {
96 return isa<pdl::TypeType>(unwrap(type));
97}
98
99MlirTypeID mlirPDLTypeTypeGetTypeID(void) {
100 return wrap(pdl::TypeType::getTypeID());
101}
102
103MlirType mlirPDLTypeTypeGet(MlirContext ctx) {
104 return wrap(pdl::TypeType::get(unwrap(ctx)));
105}
106
107MlirStringRef mlirPDLTypeTypeGetName(void) { return wrap(pdl::TypeType::name); }
108
109//===---------------------------------------------------------------------===//
110// ValueType
111//===---------------------------------------------------------------------===//
112
113bool mlirTypeIsAPDLValueType(MlirType type) {
114 return isa<pdl::ValueType>(unwrap(type));
115}
116
118 return wrap(pdl::ValueType::getTypeID());
119}
120
121MlirType mlirPDLValueTypeGet(MlirContext ctx) {
122 return wrap(pdl::ValueType::get(unwrap(ctx)));
123}
124
126 return wrap(pdl::ValueType::name);
127}
bool mlirTypeIsAPDLRangeType(MlirType type)
Definition PDL.cpp:71
MlirTypeID mlirPDLRangeTypeGetTypeID(void)
Definition PDL.cpp:75
bool mlirTypeIsAPDLTypeType(MlirType type)
Definition PDL.cpp:95
MlirStringRef mlirPDLAttributeTypeGetName(void)
Definition PDL.cpp:43
MlirType mlirPDLOperationTypeGet(MlirContext ctx)
Definition PDL.cpp:59
bool mlirTypeIsAPDLValueType(MlirType type)
Definition PDL.cpp:113
MlirType mlirPDLAttributeTypeGet(MlirContext ctx)
Definition PDL.cpp:39
MlirStringRef mlirPDLTypeTypeGetName(void)
Definition PDL.cpp:107
bool mlirTypeIsAPDLOperationType(MlirType type)
Definition PDL.cpp:51
MlirStringRef mlirPDLOperationTypeGetName(void)
Definition PDL.cpp:63
MlirStringRef mlirPDLRangeTypeGetName(void)
Definition PDL.cpp:83
MlirTypeID mlirPDLAttributeTypeGetTypeID(void)
Definition PDL.cpp:35
MlirStringRef mlirPDLValueTypeGetName(void)
Definition PDL.cpp:125
MlirTypeID mlirPDLOperationTypeGetTypeID(void)
Definition PDL.cpp:55
MlirType mlirPDLRangeTypeGet(MlirType elementType)
Definition PDL.cpp:79
MlirType mlirPDLValueTypeGet(MlirContext ctx)
Definition PDL.cpp:121
MlirTypeID mlirPDLTypeTypeGetTypeID(void)
Definition PDL.cpp:99
MlirType mlirPDLRangeTypeGetElementType(MlirType type)
Definition PDL.cpp:87
MlirTypeID mlirPDLValueTypeGetTypeID(void)
Definition PDL.cpp:117
bool mlirTypeIsAPDLAttributeType(MlirType type)
Definition PDL.cpp:31
MlirType mlirPDLTypeTypeGet(MlirContext ctx)
Definition PDL.cpp:103
static Type getElementType(Type type)
Determine the element type of type.
#define MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Name, Namespace, ClassName)
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
Definition Diagnostics.h:24
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
Definition Diagnostics.h:19
MLIR_CAPI_EXPORTED bool mlirTypeIsAPDLType(MlirType type)
Definition PDL.cpp:23
Include the generated interface declarations.
A pointer to a sized fragment of a string, not necessarily null-terminated.
Definition Support.h:75