1 | //===- Transform.cpp - C Interface for Transform 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/Transform.h" |
10 | #include "mlir-c/Support.h" |
11 | #include "mlir/CAPI/Registration.h" |
12 | #include "mlir/Dialect/Transform/IR/TransformDialect.h" |
13 | #include "mlir/Dialect/Transform/IR/TransformTypes.h" |
14 | |
15 | using namespace mlir; |
16 | |
17 | MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(Transform, transform, |
18 | transform::TransformDialect) |
19 | |
20 | //===---------------------------------------------------------------------===// |
21 | // AnyOpType |
22 | //===---------------------------------------------------------------------===// |
23 | |
24 | bool mlirTypeIsATransformAnyOpType(MlirType type) { |
25 | return isa<transform::AnyOpType>(unwrap(type)); |
26 | } |
27 | |
28 | MlirTypeID mlirTransformAnyOpTypeGetTypeID(void) { |
29 | return wrap(transform::AnyOpType::getTypeID()); |
30 | } |
31 | |
32 | MlirType mlirTransformAnyOpTypeGet(MlirContext ctx) { |
33 | return wrap(transform::AnyOpType::get(unwrap(ctx))); |
34 | } |
35 | |
36 | //===---------------------------------------------------------------------===// |
37 | // AnyParamType |
38 | //===---------------------------------------------------------------------===// |
39 | |
40 | bool mlirTypeIsATransformAnyParamType(MlirType type) { |
41 | return isa<transform::AnyParamType>(unwrap(type)); |
42 | } |
43 | |
44 | MlirTypeID mlirTransformAnyParamTypeGetTypeID(void) { |
45 | return wrap(transform::AnyParamType::getTypeID()); |
46 | } |
47 | |
48 | MlirType mlirTransformAnyParamTypeGet(MlirContext ctx) { |
49 | return wrap(transform::AnyParamType::get(unwrap(ctx))); |
50 | } |
51 | |
52 | //===---------------------------------------------------------------------===// |
53 | // AnyValueType |
54 | //===---------------------------------------------------------------------===// |
55 | |
56 | bool mlirTypeIsATransformAnyValueType(MlirType type) { |
57 | return isa<transform::AnyValueType>(unwrap(type)); |
58 | } |
59 | |
60 | MlirTypeID mlirTransformAnyValueTypeGetTypeID(void) { |
61 | return wrap(transform::AnyValueType::getTypeID()); |
62 | } |
63 | |
64 | MlirType mlirTransformAnyValueTypeGet(MlirContext ctx) { |
65 | return wrap(transform::AnyValueType::get(unwrap(ctx))); |
66 | } |
67 | |
68 | //===---------------------------------------------------------------------===// |
69 | // OperationType |
70 | //===---------------------------------------------------------------------===// |
71 | |
72 | bool mlirTypeIsATransformOperationType(MlirType type) { |
73 | return isa<transform::OperationType>(unwrap(type)); |
74 | } |
75 | |
76 | MlirTypeID mlirTransformOperationTypeGetTypeID(void) { |
77 | return wrap(transform::OperationType::getTypeID()); |
78 | } |
79 | |
80 | MlirType mlirTransformOperationTypeGet(MlirContext ctx, |
81 | MlirStringRef operationName) { |
82 | return wrap( |
83 | transform::OperationType::get(unwrap(ctx), unwrap(operationName))); |
84 | } |
85 | |
86 | MlirStringRef mlirTransformOperationTypeGetOperationName(MlirType type) { |
87 | return wrap(cast<transform::OperationType>(unwrap(type)).getOperationName()); |
88 | } |
89 | |
90 | //===---------------------------------------------------------------------===// |
91 | // ParamType |
92 | //===---------------------------------------------------------------------===// |
93 | |
94 | bool mlirTypeIsATransformParamType(MlirType type) { |
95 | return isa<transform::ParamType>(unwrap(type)); |
96 | } |
97 | |
98 | MlirTypeID mlirTransformParamTypeGetTypeID(void) { |
99 | return wrap(transform::ParamType::getTypeID()); |
100 | } |
101 | |
102 | MlirType mlirTransformParamTypeGet(MlirContext ctx, MlirType type) { |
103 | return wrap(transform::ParamType::get(unwrap(ctx), unwrap(type))); |
104 | } |
105 | |
106 | MlirType mlirTransformParamTypeGetType(MlirType type) { |
107 | return wrap(cast<transform::ParamType>(unwrap(type)).getType()); |
108 | } |
109 | |