1//===- PythonTestCAPI.cpp - C API for the PythonTest 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 "PythonTestCAPI.h"
10#include "PythonTestDialect.h"
11#include "mlir-c/BuiltinTypes.h"
12#include "mlir/CAPI/Registration.h"
13#include "mlir/CAPI/Wrap.h"
14
15MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(PythonTest, python_test,
16 python_test::PythonTestDialect)
17
18bool mlirAttributeIsAPythonTestTestAttribute(MlirAttribute attr) {
19 return llvm::isa<python_test::TestAttrAttr>(unwrap(attr));
20}
21
22MlirAttribute mlirPythonTestTestAttributeGet(MlirContext context) {
23 return wrap(python_test::TestAttrAttr::get(unwrap(context)));
24}
25
26bool mlirTypeIsAPythonTestTestType(MlirType type) {
27 return llvm::isa<python_test::TestTypeType>(unwrap(type));
28}
29
30MlirType mlirPythonTestTestTypeGet(MlirContext context) {
31 return wrap(python_test::TestTypeType::get(unwrap(context)));
32}
33
34MlirTypeID mlirPythonTestTestTypeGetTypeID(void) {
35 return wrap(python_test::TestTypeType::getTypeID());
36}
37
38bool mlirTypeIsAPythonTestTestTensorValue(MlirValue value) {
39 return mlirTypeIsATensor(type: wrap(cpp: unwrap(c: value).getType()));
40}
41

source code of mlir/test/python/lib/PythonTestCAPI.cpp