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 MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(PythonTest,python_test,python_test::PythonTestDialect)15MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(PythonTest, python_test, 16 python_test::PythonTestDialect) 17 18 bool mlirAttributeIsAPythonTestTestAttribute(MlirAttribute attr) { 19 return llvm::isa<python_test::TestAttrAttr>(unwrap(attr)); 20 } 21 mlirPythonTestTestAttributeGet(MlirContext context)22MlirAttribute mlirPythonTestTestAttributeGet(MlirContext context) { 23 return wrap(python_test::TestAttrAttr::get(unwrap(context))); 24 } 25 mlirPythonTestTestAttributeGetTypeID(void)26MlirTypeID mlirPythonTestTestAttributeGetTypeID(void) { 27 return wrap(python_test::TestAttrAttr::getTypeID()); 28 } 29 mlirTypeIsAPythonTestTestType(MlirType type)30bool mlirTypeIsAPythonTestTestType(MlirType type) { 31 return llvm::isa<python_test::TestTypeType>(unwrap(type)); 32 } 33 mlirPythonTestTestTypeGet(MlirContext context)34MlirType mlirPythonTestTestTypeGet(MlirContext context) { 35 return wrap(python_test::TestTypeType::get(unwrap(context))); 36 } 37 mlirPythonTestTestTypeGetTypeID(void)38MlirTypeID mlirPythonTestTestTypeGetTypeID(void) { 39 return wrap(python_test::TestTypeType::getTypeID()); 40 } 41 mlirTypeIsAPythonTestTestTensorValue(MlirValue value)42bool mlirTypeIsAPythonTestTestTensorValue(MlirValue value) { 43 return mlirTypeIsATensor(wrap(unwrap(value).getType())); 44 } 45