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

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