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 | #include "mlir/IR/Diagnostics.h" |
15 | #include "mlir/IR/Location.h" |
16 | |
17 | MLIR_DEFINE_CAPI_DIALECT_REGISTRATION(PythonTest, python_test, |
18 | python_test::PythonTestDialect) |
19 | |
20 | bool mlirAttributeIsAPythonTestTestAttribute(MlirAttribute attr) { |
21 | return llvm::isa<python_test::TestAttrAttr>(unwrap(attr)); |
22 | } |
23 | |
24 | MlirAttribute mlirPythonTestTestAttributeGet(MlirContext context) { |
25 | return wrap(python_test::TestAttrAttr::get(unwrap(context))); |
26 | } |
27 | |
28 | MlirTypeID mlirPythonTestTestAttributeGetTypeID(void) { |
29 | return wrap(python_test::TestAttrAttr::getTypeID()); |
30 | } |
31 | |
32 | bool mlirTypeIsAPythonTestTestType(MlirType type) { |
33 | return llvm::isa<python_test::TestTypeType>(unwrap(type)); |
34 | } |
35 | |
36 | MlirType mlirPythonTestTestTypeGet(MlirContext context) { |
37 | return wrap(python_test::TestTypeType::get(unwrap(context))); |
38 | } |
39 | |
40 | MlirTypeID mlirPythonTestTestTypeGetTypeID(void) { |
41 | return wrap(python_test::TestTypeType::getTypeID()); |
42 | } |
43 | |
44 | bool mlirTypeIsAPythonTestTestTensorValue(MlirValue value) { |
45 | return mlirTypeIsATensor(type: wrap(cpp: unwrap(c: value).getType())); |
46 | } |
47 | |
48 | void mlirPythonTestEmitDiagnosticWithNote(MlirContext ctx) { |
49 | auto diag = |
50 | mlir::emitError(loc: unwrap(c: mlirLocationUnknownGet(context: ctx)), message: "created error"); |
51 | diag.attachNote() << "attached note"; |
52 | } |
53 |