MLIR  16.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 
9 #include "mlir-c/Dialect/PDL.h"
10 #include "mlir/CAPI/Registration.h"
14 
15 using namespace mlir;
16 
17 MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(PDL, pdl, pdl::PDLDialect)
18 
19 //===---------------------------------------------------------------------===//
20 // PDLType
21 //===---------------------------------------------------------------------===//
22 
23 bool mlirTypeIsAPDLType(MlirType type) {
24  return unwrap(type).isa<pdl::PDLType>();
25 }
26 
27 //===---------------------------------------------------------------------===//
28 // AttributeType
29 //===---------------------------------------------------------------------===//
30 
31 bool mlirTypeIsAPDLAttributeType(MlirType type) {
32  return unwrap(type).isa<pdl::AttributeType>();
33 }
34 
35 MlirType mlirPDLAttributeTypeGet(MlirContext ctx) {
36  return wrap(pdl::AttributeType::get(unwrap(ctx)));
37 }
38 
39 //===---------------------------------------------------------------------===//
40 // OperationType
41 //===---------------------------------------------------------------------===//
42 
43 bool mlirTypeIsAPDLOperationType(MlirType type) {
44  return unwrap(type).isa<pdl::OperationType>();
45 }
46 
47 MlirType mlirPDLOperationTypeGet(MlirContext ctx) {
48  return wrap(pdl::OperationType::get(unwrap(ctx)));
49 }
50 
51 //===---------------------------------------------------------------------===//
52 // RangeType
53 //===---------------------------------------------------------------------===//
54 
55 bool mlirTypeIsAPDLRangeType(MlirType type) {
56  return unwrap(type).isa<pdl::RangeType>();
57 }
58 
59 MlirType mlirPDLRangeTypeGet(MlirType elementType) {
60  return wrap(pdl::RangeType::get(unwrap(elementType)));
61 }
62 
63 MlirType mlirPDLRangeTypeGetElementType(MlirType type) {
64  return wrap(unwrap(type).cast<pdl::RangeType>().getElementType());
65 }
66 
67 //===---------------------------------------------------------------------===//
68 // TypeType
69 //===---------------------------------------------------------------------===//
70 
71 bool mlirTypeIsAPDLTypeType(MlirType type) {
72  return unwrap(type).isa<pdl::TypeType>();
73 }
74 
75 MlirType mlirPDLTypeTypeGet(MlirContext ctx) {
76  return wrap(pdl::TypeType::get(unwrap(ctx)));
77 }
78 
79 //===---------------------------------------------------------------------===//
80 // ValueType
81 //===---------------------------------------------------------------------===//
82 
83 bool mlirTypeIsAPDLValueType(MlirType type) {
84  return unwrap(type).isa<pdl::ValueType>();
85 }
86 
87 MlirType mlirPDLValueTypeGet(MlirContext ctx) {
88  return wrap(pdl::ValueType::get(unwrap(ctx)));
89 }
Include the generated interface declarations.
MlirType mlirPDLAttributeTypeGet(MlirContext ctx)
Definition: PDL.cpp:35
static Type getElementType(Type type, ArrayRef< int32_t > indices, function_ref< InFlightDiagnostic(StringRef)> emitErrorFn)
Walks the given type hierarchy with the given indices, potentially down to component granularity...
Definition: SPIRVOps.cpp:694
This class represents the base class of all PDL types.
Definition: PDLTypes.h:25
MlirType mlirPDLTypeTypeGet(MlirContext ctx)
Definition: PDL.cpp:75
bool mlirTypeIsAPDLRangeType(MlirType type)
Definition: PDL.cpp:55
MlirType mlirPDLRangeTypeGetElementType(MlirType type)
Definition: PDL.cpp:63
MlirType mlirPDLValueTypeGet(MlirContext ctx)
Definition: PDL.cpp:87
bool mlirTypeIsAPDLAttributeType(MlirType type)
Definition: PDL.cpp:31
bool mlirTypeIsAPDLTypeType(MlirType type)
Definition: PDL.cpp:71
MlirType mlirPDLOperationTypeGet(MlirContext ctx)
Definition: PDL.cpp:47
MlirDiagnostic wrap(mlir::Diagnostic &diagnostic)
Definition: Diagnostics.h:24
bool mlirTypeIsAPDLValueType(MlirType type)
Definition: PDL.cpp:83
bool mlirTypeIsAPDLType(MlirType type)
Definition: PDL.cpp:23
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(SparseTensor, sparse_tensor, mlir::sparse_tensor::SparseTensorDialect) static_assert(static_cast< int >(MLIR_SPARSE_TENSOR_DIM_LEVEL_DENSE)
mlir::Diagnostic & unwrap(MlirDiagnostic diagnostic)
Definition: Diagnostics.h:19
MlirType mlirPDLRangeTypeGet(MlirType elementType)
Definition: PDL.cpp:59
bool mlirTypeIsAPDLOperationType(MlirType type)
Definition: PDL.cpp:43