diff --git a/mlir/include/mlir-c/IR.h b/mlir/include/mlir-c/IR.h --- a/mlir/include/mlir-c/IR.h +++ b/mlir/include/mlir-c/IR.h @@ -18,6 +18,7 @@ #ifndef MLIR_C_IR_H #define MLIR_C_IR_H +#include #include #include "mlir-c/Support.h" @@ -82,10 +83,10 @@ 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; } @@ -126,14 +127,14 @@ 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); @@ -177,7 +178,7 @@ 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); @@ -287,12 +288,12 @@ 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); @@ -388,7 +389,7 @@ 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); @@ -430,11 +431,11 @@ 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. */ @@ -489,10 +490,10 @@ //===----------------------------------------------------------------------===// /// 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); @@ -543,10 +544,10 @@ 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 @@ -572,10 +573,10 @@ 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 @@ -600,8 +601,8 @@ 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); diff --git a/mlir/lib/CAPI/IR/IR.cpp b/mlir/lib/CAPI/IR/IR.cpp --- a/mlir/lib/CAPI/IR/IR.cpp +++ b/mlir/lib/CAPI/IR/IR.cpp @@ -30,7 +30,7 @@ return wrap(context); } -int mlirContextEqual(MlirContext ctx1, MlirContext ctx2) { +bool mlirContextEqual(MlirContext ctx1, MlirContext ctx2) { return unwrap(ctx1) == unwrap(ctx2); } @@ -66,7 +66,7 @@ return wrap(unwrap(dialect)->getContext()); } -int mlirDialectEqual(MlirDialect dialect1, MlirDialect dialect2) { +bool mlirDialectEqual(MlirDialect dialect1, MlirDialect dialect2) { return unwrap(dialect1) == unwrap(dialect2); } @@ -245,7 +245,7 @@ void mlirOperationDestroy(MlirOperation op) { unwrap(op)->erase(); } -int mlirOperationEqual(MlirOperation op, MlirOperation other) { +bool mlirOperationEqual(MlirOperation op, MlirOperation other) { return unwrap(op) == unwrap(other); } @@ -398,7 +398,7 @@ return wrap(b); } -int mlirBlockEqual(MlirBlock block, MlirBlock other) { +bool mlirBlockEqual(MlirBlock block, MlirBlock other) { return unwrap(block) == unwrap(other); } @@ -480,7 +480,7 @@ // Value API. //===----------------------------------------------------------------------===// -int mlirValueEqual(MlirValue value1, MlirValue value2) { +bool mlirValueEqual(MlirValue value1, MlirValue value2) { return unwrap(value1) == unwrap(value2); } @@ -538,7 +538,9 @@ 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); @@ -563,7 +565,7 @@ return wrap(unwrap(attribute).getType()); } -int mlirAttributeEqual(MlirAttribute a1, MlirAttribute a2) { +bool mlirAttributeEqual(MlirAttribute a1, MlirAttribute a2) { return unwrap(a1) == unwrap(a2); } @@ -588,7 +590,7 @@ 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); }