xref: /llvm-project/mlir/lib/CAPI/Dialect/Transform.cpp (revision 3e1f6d02f755e34a0a12a8dd439fb65f84d6621f)
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 unwrap(type).isa<transform::AnyOpType>();
26 }
27 
28 MlirType mlirTransformAnyOpTypeGet(MlirContext ctx) {
29   return wrap(transform::AnyOpType::get(unwrap(ctx)));
30 }
31 
32 //===---------------------------------------------------------------------===//
33 // OperationType
34 //===---------------------------------------------------------------------===//
35 
36 bool mlirTypeIsATransformOperationType(MlirType type) {
37   return unwrap(type).isa<transform::OperationType>();
38 }
39 
40 MlirType mlirTransformOperationTypeGet(MlirContext ctx,
41                                        MlirStringRef operationName) {
42   return wrap(
43       transform::OperationType::get(unwrap(ctx), unwrap(operationName)));
44 }
45 
46 MlirStringRef mlirTransformOperationTypeGetOperationName(MlirType type) {
47   return wrap(unwrap(type).cast<transform::OperationType>().getOperationName());
48 }
49