xref: /llvm-project/mlir/test/python/lib/PythonTestCAPI.cpp (revision 9315645834ea81cf9550364a4950f289e9706a26)
114c92070SAlex Zinenko //===- PythonTestCAPI.cpp - C API for the PythonTest dialect --------------===//
214c92070SAlex Zinenko //
314c92070SAlex Zinenko // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
414c92070SAlex Zinenko // See https://llvm.org/LICENSE.txt for license information.
514c92070SAlex Zinenko // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
614c92070SAlex Zinenko //
714c92070SAlex Zinenko //===----------------------------------------------------------------------===//
814c92070SAlex Zinenko 
914c92070SAlex Zinenko #include "PythonTestCAPI.h"
1014c92070SAlex Zinenko #include "PythonTestDialect.h"
1169cc3cfbSmax #include "mlir-c/BuiltinTypes.h"
1214c92070SAlex Zinenko #include "mlir/CAPI/Registration.h"
1389a92fb3SAlex Zinenko #include "mlir/CAPI/Wrap.h"
1414c92070SAlex Zinenko 
MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(PythonTest,python_test,python_test::PythonTestDialect)1514c92070SAlex Zinenko MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(PythonTest, python_test,
1614c92070SAlex Zinenko                                       python_test::PythonTestDialect)
1789a92fb3SAlex Zinenko 
1889a92fb3SAlex Zinenko bool mlirAttributeIsAPythonTestTestAttribute(MlirAttribute attr) {
19c1fa60b4STres Popp   return llvm::isa<python_test::TestAttrAttr>(unwrap(attr));
2089a92fb3SAlex Zinenko }
2189a92fb3SAlex Zinenko 
mlirPythonTestTestAttributeGet(MlirContext context)2289a92fb3SAlex Zinenko MlirAttribute mlirPythonTestTestAttributeGet(MlirContext context) {
2389a92fb3SAlex Zinenko   return wrap(python_test::TestAttrAttr::get(unwrap(context)));
2489a92fb3SAlex Zinenko }
2589a92fb3SAlex Zinenko 
mlirPythonTestTestAttributeGetTypeID(void)26*93156458SMaksim Levental MlirTypeID mlirPythonTestTestAttributeGetTypeID(void) {
27*93156458SMaksim Levental   return wrap(python_test::TestAttrAttr::getTypeID());
28*93156458SMaksim Levental }
29*93156458SMaksim Levental 
mlirTypeIsAPythonTestTestType(MlirType type)3089a92fb3SAlex Zinenko bool mlirTypeIsAPythonTestTestType(MlirType type) {
31c1fa60b4STres Popp   return llvm::isa<python_test::TestTypeType>(unwrap(type));
3289a92fb3SAlex Zinenko }
3389a92fb3SAlex Zinenko 
mlirPythonTestTestTypeGet(MlirContext context)3489a92fb3SAlex Zinenko MlirType mlirPythonTestTestTypeGet(MlirContext context) {
3589a92fb3SAlex Zinenko   return wrap(python_test::TestTypeType::get(unwrap(context)));
3689a92fb3SAlex Zinenko }
3769cc3cfbSmax 
mlirPythonTestTestTypeGetTypeID(void)38bfb1ba75Smax MlirTypeID mlirPythonTestTestTypeGetTypeID(void) {
39bfb1ba75Smax   return wrap(python_test::TestTypeType::getTypeID());
40bfb1ba75Smax }
41bfb1ba75Smax 
mlirTypeIsAPythonTestTestTensorValue(MlirValue value)4269cc3cfbSmax bool mlirTypeIsAPythonTestTestTensorValue(MlirValue value) {
4369cc3cfbSmax   return mlirTypeIsATensor(wrap(unwrap(value).getType()));
4469cc3cfbSmax }
45