#ifndef MLIR_C_IR_H
#define MLIR_C_IR_H
+#include <stdbool.h>
#include <stdint.h>
#include "mlir-c/Support.h"
MLIR_CAPI_EXPORTED MlirContext mlirContextCreate();
/// Checks if two contexts are equal.
-MLIR_CAPI_EXPORTED int mlirContextEqual(MlirContext ctx1, MlirContext ctx2);
+MLIR_CAPI_EXPORTED bool mlirContextEqual(MlirContext ctx1, MlirContext ctx2);
/// Checks whether a context is null.
-static inline int mlirContextIsNull(MlirContext context) {
+static inline bool mlirContextIsNull(MlirContext context) {
return !context.ptr;
}
MLIR_CAPI_EXPORTED MlirContext mlirDialectGetContext(MlirDialect dialect);
/// Checks if the dialect is null.
-static inline int mlirDialectIsNull(MlirDialect dialect) {
+static inline bool mlirDialectIsNull(MlirDialect dialect) {
return !dialect.ptr;
}
/** Checks if two dialects that belong to the same context are equal. Dialects
* from different contexts will not compare equal. */
-MLIR_CAPI_EXPORTED int mlirDialectEqual(MlirDialect dialect1,
- MlirDialect dialect2);
+MLIR_CAPI_EXPORTED bool mlirDialectEqual(MlirDialect dialect1,
+ MlirDialect dialect2);
/// Returns the namespace of the given dialect.
MLIR_CAPI_EXPORTED MlirStringRef mlirDialectGetNamespace(MlirDialect dialect);
MLIR_CAPI_EXPORTED MlirBlock mlirModuleGetBody(MlirModule module);
/// Checks whether a module is null.
-static inline int mlirModuleIsNull(MlirModule module) { return !module.ptr; }
+static inline bool mlirModuleIsNull(MlirModule module) { return !module.ptr; }
/// Takes a module owned by the caller and deletes it.
MLIR_CAPI_EXPORTED void mlirModuleDestroy(MlirModule module);
MLIR_CAPI_EXPORTED void mlirOperationDestroy(MlirOperation op);
/// Checks whether the underlying operation is null.
-static inline int mlirOperationIsNull(MlirOperation op) { return !op.ptr; }
+static inline bool mlirOperationIsNull(MlirOperation op) { return !op.ptr; }
/** Checks whether two operation handles point to the same operation. This does
* not perform deep comparison. */
-MLIR_CAPI_EXPORTED int mlirOperationEqual(MlirOperation op,
- MlirOperation other);
+MLIR_CAPI_EXPORTED bool mlirOperationEqual(MlirOperation op,
+ MlirOperation other);
/// Gets the name of the operation as an identifier.
MLIR_CAPI_EXPORTED MlirIdentifier mlirOperationGetName(MlirOperation op);
MLIR_CAPI_EXPORTED void mlirRegionDestroy(MlirRegion region);
/// Checks whether a region is null.
-static inline int mlirRegionIsNull(MlirRegion region) { return !region.ptr; }
+static inline bool mlirRegionIsNull(MlirRegion region) { return !region.ptr; }
/// Gets the first block in the region.
MLIR_CAPI_EXPORTED MlirBlock mlirRegionGetFirstBlock(MlirRegion region);
MLIR_CAPI_EXPORTED void mlirBlockDestroy(MlirBlock block);
/// Checks whether a block is null.
-static inline int mlirBlockIsNull(MlirBlock block) { return !block.ptr; }
+static inline bool mlirBlockIsNull(MlirBlock block) { return !block.ptr; }
/** Checks whether two blocks handles point to the same block. This does not
* perform deep comparison. */
-MLIR_CAPI_EXPORTED int mlirBlockEqual(MlirBlock block, MlirBlock other);
+MLIR_CAPI_EXPORTED bool mlirBlockEqual(MlirBlock block, MlirBlock other);
/** Returns the block immediately following the given block in its parent
* region. */
//===----------------------------------------------------------------------===//
/// Returns whether the value is null.
-static inline int mlirValueIsNull(MlirValue value) { return !value.ptr; }
+static inline bool mlirValueIsNull(MlirValue value) { return !value.ptr; }
/// Returns 1 if two values are equal, 0 otherwise.
-int mlirValueEqual(MlirValue value1, MlirValue value2);
+bool mlirValueEqual(MlirValue value1, MlirValue value2);
/// Returns 1 if the value is a block argument, 0 otherwise.
MLIR_CAPI_EXPORTED int mlirValueIsABlockArgument(MlirValue value);
MLIR_CAPI_EXPORTED MlirContext mlirTypeGetContext(MlirType type);
/// Checks whether a type is null.
-static inline int mlirTypeIsNull(MlirType type) { return !type.ptr; }
+static inline bool mlirTypeIsNull(MlirType type) { return !type.ptr; }
/// Checks if two types are equal.
-MLIR_CAPI_EXPORTED int mlirTypeEqual(MlirType t1, MlirType t2);
+MLIR_CAPI_EXPORTED bool mlirTypeEqual(MlirType t1, MlirType t2);
/** Prints a location by sending chunks of the string representation and
* forwarding `userData to `callback`. Note that the callback may be called
MLIR_CAPI_EXPORTED MlirType mlirAttributeGetType(MlirAttribute attribute);
/// Checks whether an attribute is null.
-static inline int mlirAttributeIsNull(MlirAttribute attr) { return !attr.ptr; }
+static inline bool mlirAttributeIsNull(MlirAttribute attr) { return !attr.ptr; }
/// Checks if two attributes are equal.
-MLIR_CAPI_EXPORTED int mlirAttributeEqual(MlirAttribute a1, MlirAttribute a2);
+MLIR_CAPI_EXPORTED bool mlirAttributeEqual(MlirAttribute a1, MlirAttribute a2);
/** Prints an attribute by sending chunks of the string representation and
* forwarding `userData to `callback`. Note that the callback may be called
MlirStringRef str);
/// Checks whether two identifiers are the same.
-MLIR_CAPI_EXPORTED int mlirIdentifierEqual(MlirIdentifier ident,
- MlirIdentifier other);
+MLIR_CAPI_EXPORTED bool mlirIdentifierEqual(MlirIdentifier ident,
+ MlirIdentifier other);
/// Gets the string value of the identifier.
MLIR_CAPI_EXPORTED MlirStringRef mlirIdentifierStr(MlirIdentifier ident);
return wrap(context);
}
-int mlirContextEqual(MlirContext ctx1, MlirContext ctx2) {
+bool mlirContextEqual(MlirContext ctx1, MlirContext ctx2) {
return unwrap(ctx1) == unwrap(ctx2);
}
return wrap(unwrap(dialect)->getContext());
}
-int mlirDialectEqual(MlirDialect dialect1, MlirDialect dialect2) {
+bool mlirDialectEqual(MlirDialect dialect1, MlirDialect dialect2) {
return unwrap(dialect1) == unwrap(dialect2);
}
void mlirOperationDestroy(MlirOperation op) { unwrap(op)->erase(); }
-int mlirOperationEqual(MlirOperation op, MlirOperation other) {
+bool mlirOperationEqual(MlirOperation op, MlirOperation other) {
return unwrap(op) == unwrap(other);
}
return wrap(b);
}
-int mlirBlockEqual(MlirBlock block, MlirBlock other) {
+bool mlirBlockEqual(MlirBlock block, MlirBlock other) {
return unwrap(block) == unwrap(other);
}
// Value API.
//===----------------------------------------------------------------------===//
-int mlirValueEqual(MlirValue value1, MlirValue value2) {
+bool mlirValueEqual(MlirValue value1, MlirValue value2) {
return unwrap(value1) == unwrap(value2);
}
return wrap(unwrap(type).getContext());
}
-int mlirTypeEqual(MlirType t1, MlirType t2) { return unwrap(t1) == unwrap(t2); }
+bool mlirTypeEqual(MlirType t1, MlirType t2) {
+ return unwrap(t1) == unwrap(t2);
+}
void mlirTypePrint(MlirType type, MlirStringCallback callback, void *userData) {
detail::CallbackOstream stream(callback, userData);
return wrap(unwrap(attribute).getType());
}
-int mlirAttributeEqual(MlirAttribute a1, MlirAttribute a2) {
+bool mlirAttributeEqual(MlirAttribute a1, MlirAttribute a2) {
return unwrap(a1) == unwrap(a2);
}
return wrap(Identifier::get(unwrap(str), unwrap(context)));
}
-int mlirIdentifierEqual(MlirIdentifier ident, MlirIdentifier other) {
+bool mlirIdentifierEqual(MlirIdentifier ident, MlirIdentifier other) {
return unwrap(ident) == unwrap(other);
}