| 1 | //===-- mlir-c/Dialect/Complex.h - C API for Complex dialect ------*- C -*-===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM |
| 4 | // Exceptions. |
| 5 | // See https://llvm.org/LICENSE.txt for license information. |
| 6 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | #ifndef MLIR_C_DIALECT_COMPLEX_H |
| 11 | #define MLIR_C_DIALECT_COMPLEX_H |
| 12 | |
| 13 | #include "mlir-c/IR.h" |
| 14 | |
| 15 | #ifdef __cplusplus |
| 16 | extern "C" { |
| 17 | #endif |
| 18 | |
| 19 | MLIR_DECLARE_CAPI_DIALECT_REGISTRATION(Complex, complex); |
| 20 | |
| 21 | /// Checks whether the given attribute is a complex attribute. |
| 22 | MLIR_CAPI_EXPORTED bool mlirAttributeIsAComplex(MlirAttribute attr); |
| 23 | |
| 24 | /// Creates a complex attribute in the given context with the given |
| 25 | /// double real and imaginary values and double-precision FP semantics. |
| 26 | MLIR_CAPI_EXPORTED MlirAttribute mlirComplexAttrDoubleGet(MlirContext ctx, |
| 27 | MlirType type, |
| 28 | double real, |
| 29 | double imag); |
| 30 | |
| 31 | /// Same as "mlirComplexAttrDoubleGet", but if the type is not valid for a |
| 32 | /// construction of a ComplexAttr, returns a null MlirAttribute. |
| 33 | MLIR_CAPI_EXPORTED MlirAttribute mlirComplexAttrDoubleGetChecked( |
| 34 | MlirLocation loc, MlirType type, double real, double imag); |
| 35 | |
| 36 | /// Returns the real value stored in the given complex attribute, interpreting |
| 37 | /// the value as double. |
| 38 | MLIR_CAPI_EXPORTED double mlirComplexAttrGetRealDouble(MlirAttribute attr); |
| 39 | |
| 40 | /// Returns the imaginaryvalue stored in the given complex attribute, |
| 41 | /// interpreting the value as double. |
| 42 | MLIR_CAPI_EXPORTED double mlirComplexAttrGetImagDouble(MlirAttribute attr); |
| 43 | |
| 44 | /// Returns the typeID of a Complex attribute. |
| 45 | MLIR_CAPI_EXPORTED MlirTypeID mlirComplexAttrGetTypeID(void); |
| 46 | |
| 47 | #ifdef __cplusplus |
| 48 | } |
| 49 | #endif |
| 50 | |
| 51 | #endif // MLIR_C_DIALECT_COMPLEX_H |
| 52 | |