diff --git a/mlir/include/mlir-c/AffineExpr.h b/mlir/include/mlir-c/AffineExpr.h --- a/mlir/include/mlir-c/AffineExpr.h +++ b/mlir/include/mlir-c/AffineExpr.h @@ -57,12 +57,12 @@ /** Checks whether the given affine expression is made out of only symbols and * constants. */ -MLIR_CAPI_EXPORTED int +MLIR_CAPI_EXPORTED bool mlirAffineExprIsSymbolicOrConstant(MlirAffineExpr affineExpr); /** Checks whether the given affine expression is a pure affine expression, i.e. * mul, floordiv, ceildic, and mod is only allowed w.r.t constants. */ -MLIR_CAPI_EXPORTED int mlirAffineExprIsPureAffine(MlirAffineExpr affineExpr); +MLIR_CAPI_EXPORTED bool mlirAffineExprIsPureAffine(MlirAffineExpr affineExpr); /** Returns the greatest known integral divisor of this affine expression. The * result is always positive. */ @@ -70,13 +70,13 @@ mlirAffineExprGetLargestKnownDivisor(MlirAffineExpr affineExpr); /// Checks whether the given affine expression is a multiple of 'factor'. -MLIR_CAPI_EXPORTED int mlirAffineExprIsMultipleOf(MlirAffineExpr affineExpr, - int64_t factor); +MLIR_CAPI_EXPORTED bool mlirAffineExprIsMultipleOf(MlirAffineExpr affineExpr, + int64_t factor); /** Checks whether the given affine expression involves AffineDimExpr * 'position'. */ -MLIR_CAPI_EXPORTED int mlirAffineExprIsFunctionOfDim(MlirAffineExpr affineExpr, - intptr_t position); +MLIR_CAPI_EXPORTED bool mlirAffineExprIsFunctionOfDim(MlirAffineExpr affineExpr, + intptr_t position); //===----------------------------------------------------------------------===// // Affine Dimension Expression. @@ -119,7 +119,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given affine expression is an add expression. -MLIR_CAPI_EXPORTED int mlirAffineExprIsAAdd(MlirAffineExpr affineExpr); +MLIR_CAPI_EXPORTED bool mlirAffineExprIsAAdd(MlirAffineExpr affineExpr); /// Creates an affine add expression with 'lhs' and 'rhs'. MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineAddExprGet(MlirAffineExpr lhs, @@ -130,7 +130,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given affine expression is an mul expression. -MLIR_CAPI_EXPORTED int mlirAffineExprIsAMul(MlirAffineExpr affineExpr); +MLIR_CAPI_EXPORTED bool mlirAffineExprIsAMul(MlirAffineExpr affineExpr); /// Creates an affine mul expression with 'lhs' and 'rhs'. MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineMulExprGet(MlirAffineExpr lhs, @@ -141,7 +141,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given affine expression is an mod expression. -MLIR_CAPI_EXPORTED int mlirAffineExprIsAMod(MlirAffineExpr affineExpr); +MLIR_CAPI_EXPORTED bool mlirAffineExprIsAMod(MlirAffineExpr affineExpr); /// Creates an affine mod expression with 'lhs' and 'rhs'. MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineModExprGet(MlirAffineExpr lhs, @@ -152,7 +152,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given affine expression is an floordiv expression. -MLIR_CAPI_EXPORTED int mlirAffineExprIsAFloorDiv(MlirAffineExpr affineExpr); +MLIR_CAPI_EXPORTED bool mlirAffineExprIsAFloorDiv(MlirAffineExpr affineExpr); /// Creates an affine floordiv expression with 'lhs' and 'rhs'. MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineFloorDivExprGet(MlirAffineExpr lhs, @@ -163,7 +163,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given affine expression is an ceildiv expression. -MLIR_CAPI_EXPORTED int mlirAffineExprIsACeilDiv(MlirAffineExpr affineExpr); +MLIR_CAPI_EXPORTED bool mlirAffineExprIsACeilDiv(MlirAffineExpr affineExpr); /// Creates an affine ceildiv expression with 'lhs' and 'rhs'. MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineCeilDivExprGet(MlirAffineExpr lhs, diff --git a/mlir/include/mlir-c/AffineMap.h b/mlir/include/mlir-c/AffineMap.h --- a/mlir/include/mlir-c/AffineMap.h +++ b/mlir/include/mlir-c/AffineMap.h @@ -44,12 +44,12 @@ MLIR_CAPI_EXPORTED MlirContext mlirAffineMapGetContext(MlirAffineMap affineMap); /// Checks whether an affine map is null. -static inline int mlirAffineMapIsNull(MlirAffineMap affineMap) { +static inline bool mlirAffineMapIsNull(MlirAffineMap affineMap) { return !affineMap.ptr; } /// Checks if two affine maps are equal. -MLIR_CAPI_EXPORTED int mlirAffineMapEqual(MlirAffineMap a1, MlirAffineMap a2); +MLIR_CAPI_EXPORTED bool mlirAffineMapEqual(MlirAffineMap a1, MlirAffineMap a2); /** Prints an affine map by sending chunks of the string representation and * forwarding `userData to `callback`. Note that the callback may be called @@ -98,17 +98,17 @@ /** Checks whether the given affine map is an identity affine map. The function * asserts that the number of dimensions is greater or equal to the number of * results. */ -MLIR_CAPI_EXPORTED int mlirAffineMapIsIdentity(MlirAffineMap affineMap); +MLIR_CAPI_EXPORTED bool mlirAffineMapIsIdentity(MlirAffineMap affineMap); /// Checks whether the given affine map is a minor identity affine map. -MLIR_CAPI_EXPORTED int mlirAffineMapIsMinorIdentity(MlirAffineMap affineMap); +MLIR_CAPI_EXPORTED bool mlirAffineMapIsMinorIdentity(MlirAffineMap affineMap); /// Checks whether the given affine map is an empty affine map. -MLIR_CAPI_EXPORTED int mlirAffineMapIsEmpty(MlirAffineMap affineMap); +MLIR_CAPI_EXPORTED bool mlirAffineMapIsEmpty(MlirAffineMap affineMap); /** Checks whether the given affine map is a single result constant affine * map. */ -MLIR_CAPI_EXPORTED int mlirAffineMapIsSingleConstant(MlirAffineMap affineMap); +MLIR_CAPI_EXPORTED bool mlirAffineMapIsSingleConstant(MlirAffineMap affineMap); /** Returns the constant result of the given affine map. The function asserts * that the map has a single constant result. */ @@ -130,12 +130,12 @@ /** Checks whether the given affine map represents a subset of a symbol-less * permutation map. */ -MLIR_CAPI_EXPORTED int +MLIR_CAPI_EXPORTED bool mlirAffineMapIsProjectedPermutation(MlirAffineMap affineMap); /** Checks whether the given affine map represents a symbol-less permutation * map. */ -MLIR_CAPI_EXPORTED int mlirAffineMapIsPermutation(MlirAffineMap affineMap); +MLIR_CAPI_EXPORTED bool mlirAffineMapIsPermutation(MlirAffineMap affineMap); /// Returns the affine map consisting of the `resultPos` subset. MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapGetSubMap(MlirAffineMap affineMap, 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 @@ -95,10 +95,10 @@ /// Sets whether unregistered dialects are allowed in this context. MLIR_CAPI_EXPORTED void -mlirContextSetAllowUnregisteredDialects(MlirContext context, int allow); +mlirContextSetAllowUnregisteredDialects(MlirContext context, bool allow); /// Returns whether the context allows unregistered dialects. -MLIR_CAPI_EXPORTED int +MLIR_CAPI_EXPORTED bool mlirContextGetAllowUnregisteredDialects(MlirContext context); /** Returns the number of dialects registered with the given context. A @@ -154,12 +154,12 @@ MLIR_CAPI_EXPORTED MlirContext mlirLocationGetContext(MlirLocation location); /// Checks if the location is null. -static inline int mlirLocationIsNull(MlirLocation location) { +static inline bool mlirLocationIsNull(MlirLocation location) { return !location.ptr; } /// Checks if two locations are equal. -MLIR_CAPI_EXPORTED int mlirLocationEqual(MlirLocation l1, MlirLocation l2); +MLIR_CAPI_EXPORTED bool mlirLocationEqual(MlirLocation l1, MlirLocation l2); /** Prints a location by sending chunks of the string representation and * forwarding `userData to `callback`. Note that the callback may be called @@ -271,7 +271,7 @@ * debug information is printed in a more readable 'pretty' form. Note: The * IR generated with 'prettyForm' is not parsable. */ MLIR_CAPI_EXPORTED void -mlirOpPrintingFlagsEnableDebugInfo(MlirOpPrintingFlags flags, int prettyForm); +mlirOpPrintingFlagsEnableDebugInfo(MlirOpPrintingFlags flags, bool prettyForm); /// Always print operations in the generic form. MLIR_CAPI_EXPORTED void @@ -364,10 +364,10 @@ MlirStringRef name, MlirAttribute attr); -/** Removes an attribute by name. Returns 0 if the attribute was not found - * and !0 if removed. */ -MLIR_CAPI_EXPORTED int mlirOperationRemoveAttributeByName(MlirOperation op, - MlirStringRef name); +/** Removes an attribute by name. Returns false if the attribute was not found + * and true if removed. */ +MLIR_CAPI_EXPORTED bool mlirOperationRemoveAttributeByName(MlirOperation op, + MlirStringRef name); /** Prints an operation by sending chunks of the string representation and * forwarding `userData to `callback`. Note that the callback may be called @@ -504,10 +504,10 @@ 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 bool mlirValueIsABlockArgument(MlirValue value); /// Returns 1 if the value is an operation result, 0 otherwise. -MLIR_CAPI_EXPORTED int mlirValueIsAOpResult(MlirValue value); +MLIR_CAPI_EXPORTED bool mlirValueIsAOpResult(MlirValue value); /** Returns the block in which this value is defined as an argument. Asserts if * the value is not a block argument. */ diff --git a/mlir/include/mlir-c/Pass.h b/mlir/include/mlir-c/Pass.h --- a/mlir/include/mlir-c/Pass.h +++ b/mlir/include/mlir-c/Pass.h @@ -54,7 +54,7 @@ MLIR_CAPI_EXPORTED void mlirPassManagerDestroy(MlirPassManager passManager); /// Checks if a PassManager is null. -static inline int mlirPassManagerIsNull(MlirPassManager passManager) { +static inline bool mlirPassManagerIsNull(MlirPassManager passManager) { return !passManager.ptr; } diff --git a/mlir/include/mlir-c/StandardAttributes.h b/mlir/include/mlir-c/StandardAttributes.h --- a/mlir/include/mlir-c/StandardAttributes.h +++ b/mlir/include/mlir-c/StandardAttributes.h @@ -27,7 +27,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given attribute is an affine map attribute. -MLIR_CAPI_EXPORTED int mlirAttributeIsAAffineMap(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsAAffineMap(MlirAttribute attr); /** Creates an affine map attribute wrapping the given map. The attribute * belongs to the same context as the affine map. */ @@ -41,7 +41,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given attribute is an array attribute. -MLIR_CAPI_EXPORTED int mlirAttributeIsAArray(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsAArray(MlirAttribute attr); /** Creates an array element containing the given list of elements in the given * context. */ @@ -61,7 +61,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given attribute is a dictionary attribute. -MLIR_CAPI_EXPORTED int mlirAttributeIsADictionary(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsADictionary(MlirAttribute attr); /** Creates a dictionary attribute containing the given list of elements in the * provided context. */ @@ -89,7 +89,7 @@ * relevant functions here. */ /// Checks whether the given attribute is a floating point attribute. -MLIR_CAPI_EXPORTED int mlirAttributeIsAFloat(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsAFloat(MlirAttribute attr); /** Creates a floating point attribute in the given context with the given * double value and double-precision FP semantics. */ @@ -114,7 +114,7 @@ * relevant functions here. */ /// Checks whether the given attribute is an integer attribute. -MLIR_CAPI_EXPORTED int mlirAttributeIsAInteger(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsAInteger(MlirAttribute attr); /** Creates an integer attribute of the given type with the given integer * value. */ @@ -130,27 +130,27 @@ //===----------------------------------------------------------------------===// /// Checks whether the given attribute is a bool attribute. -MLIR_CAPI_EXPORTED int mlirAttributeIsABool(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsABool(MlirAttribute attr); /// Creates a bool attribute in the given context with the given value. MLIR_CAPI_EXPORTED MlirAttribute mlirBoolAttrGet(MlirContext ctx, int value); /// Returns the value stored in the given bool attribute. -MLIR_CAPI_EXPORTED int mlirBoolAttrGetValue(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirBoolAttrGetValue(MlirAttribute attr); //===----------------------------------------------------------------------===// // Integer set attribute. //===----------------------------------------------------------------------===// /// Checks whether the given attribute is an integer set attribute. -MLIR_CAPI_EXPORTED int mlirAttributeIsAIntegerSet(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsAIntegerSet(MlirAttribute attr); //===----------------------------------------------------------------------===// // Opaque attribute. //===----------------------------------------------------------------------===// /// Checks whether the given attribute is an opaque attribute. -MLIR_CAPI_EXPORTED int mlirAttributeIsAOpaque(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsAOpaque(MlirAttribute attr); /** Creates an opaque attribute in the given context associated with the dialect * identified by its namespace. The attribute contains opaque byte data of the @@ -175,7 +175,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given attribute is a string attribute. -MLIR_CAPI_EXPORTED int mlirAttributeIsAString(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsAString(MlirAttribute attr); /** Creates a string attribute in the given context containing the given string. * The string need not be null-terminated and its length must be specified. */ @@ -199,7 +199,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given attribute is a symbol reference attribute. -MLIR_CAPI_EXPORTED int mlirAttributeIsASymbolRef(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsASymbolRef(MlirAttribute attr); /** Creates a symbol reference attribute in the given context referencing a * symbol identified by the given string inside a list of nested references. @@ -233,7 +233,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given attribute is a flat symbol reference attribute. -MLIR_CAPI_EXPORTED int mlirAttributeIsAFlatSymbolRef(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsAFlatSymbolRef(MlirAttribute attr); /** Creates a flat symbol reference attribute in the given context referencing a * symbol identified by the given string. The string need not be null-terminated @@ -252,7 +252,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given attribute is a type attribute. -MLIR_CAPI_EXPORTED int mlirAttributeIsAType(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsAType(MlirAttribute attr); /** Creates a type attribute wrapping the given type in the same context as the * type. */ @@ -266,7 +266,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given attribute is a unit attribute. -MLIR_CAPI_EXPORTED int mlirAttributeIsAUnit(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsAUnit(MlirAttribute attr); /// Creates a unit attribute in the given context. MLIR_CAPI_EXPORTED MlirAttribute mlirUnitAttrGet(MlirContext ctx); @@ -276,7 +276,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given attribute is an elements attribute. -MLIR_CAPI_EXPORTED int mlirAttributeIsAElements(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsAElements(MlirAttribute attr); /// Returns the element at the given rank-dimensional index. MLIR_CAPI_EXPORTED MlirAttribute mlirElementsAttrGetValue(MlirAttribute attr, @@ -285,7 +285,7 @@ /** Checks whether the given rank-dimensional index is valid in the given * elements attribute. */ -MLIR_CAPI_EXPORTED int +MLIR_CAPI_EXPORTED bool mlirElementsAttrIsValidIndex(MlirAttribute attr, intptr_t rank, uint64_t *idxs); /** Gets the total number of elements in the given elements attribute. In order @@ -302,9 +302,9 @@ * relevant functions here. */ /// Checks whether the given attribute is a dense elements attribute. -MLIR_CAPI_EXPORTED int mlirAttributeIsADenseElements(MlirAttribute attr); -MLIR_CAPI_EXPORTED int mlirAttributeIsADenseIntElements(MlirAttribute attr); -MLIR_CAPI_EXPORTED int mlirAttributeIsADenseFPElements(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseElements(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseIntElements(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseFPElements(MlirAttribute attr); /** Creates a dense elements attribute with the given Shaped type and elements * in the same context as the type. */ @@ -316,7 +316,7 @@ MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrSplatGet(MlirType shapedType, MlirAttribute element); MLIR_CAPI_EXPORTED MlirAttribute -mlirDenseElementsAttrBoolSplatGet(MlirType shapedType, int element); +mlirDenseElementsAttrBoolSplatGet(MlirType shapedType, bool element); MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrUInt32SplatGet(MlirType shapedType, uint32_t element); MLIR_CAPI_EXPORTED MlirAttribute @@ -362,7 +362,7 @@ /** Checks whether the given dense elements attribute contains a single * replicated value (splat). */ -MLIR_CAPI_EXPORTED int mlirDenseElementsAttrIsSplat(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirDenseElementsAttrIsSplat(MlirAttribute attr); /** Returns the single replicated value (splat) of a specific type contained by * the given dense elements attribute. */ @@ -387,8 +387,8 @@ /** Returns the pos-th value (flat contiguous indexing) of a specific type * contained by the given dense elements attribute. */ -MLIR_CAPI_EXPORTED int mlirDenseElementsAttrGetBoolValue(MlirAttribute attr, - intptr_t pos); +MLIR_CAPI_EXPORTED bool mlirDenseElementsAttrGetBoolValue(MlirAttribute attr, + intptr_t pos); MLIR_CAPI_EXPORTED int32_t mlirDenseElementsAttrGetInt32Value(MlirAttribute attr, intptr_t pos); MLIR_CAPI_EXPORTED uint32_t @@ -415,14 +415,14 @@ // TODO: expose Dialect to the bindings and implement accessors here. /// Checks whether the given attribute is an opaque elements attribute. -MLIR_CAPI_EXPORTED int mlirAttributeIsAOpaqueElements(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsAOpaqueElements(MlirAttribute attr); //===----------------------------------------------------------------------===// // Sparse elements attribute. //===----------------------------------------------------------------------===// /// Checks whether the given attribute is a sparse elements attribute. -MLIR_CAPI_EXPORTED int mlirAttributeIsASparseElements(MlirAttribute attr); +MLIR_CAPI_EXPORTED bool mlirAttributeIsASparseElements(MlirAttribute attr); /** Creates a sparse elements attribute of the given shape from a list of * indices and a list of associated values. Both lists are expected to be dense diff --git a/mlir/include/mlir-c/StandardTypes.h b/mlir/include/mlir-c/StandardTypes.h --- a/mlir/include/mlir-c/StandardTypes.h +++ b/mlir/include/mlir-c/StandardTypes.h @@ -23,7 +23,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given type is an integer type. -MLIR_CAPI_EXPORTED int mlirTypeIsAInteger(MlirType type); +MLIR_CAPI_EXPORTED bool mlirTypeIsAInteger(MlirType type); /** Creates a signless integer type of the given bitwidth in the context. The * type is owned by the context. */ @@ -44,20 +44,20 @@ MLIR_CAPI_EXPORTED unsigned mlirIntegerTypeGetWidth(MlirType type); /// Checks whether the given integer type is signless. -MLIR_CAPI_EXPORTED int mlirIntegerTypeIsSignless(MlirType type); +MLIR_CAPI_EXPORTED bool mlirIntegerTypeIsSignless(MlirType type); /// Checks whether the given integer type is signed. -MLIR_CAPI_EXPORTED int mlirIntegerTypeIsSigned(MlirType type); +MLIR_CAPI_EXPORTED bool mlirIntegerTypeIsSigned(MlirType type); /// Checks whether the given integer type is unsigned. -MLIR_CAPI_EXPORTED int mlirIntegerTypeIsUnsigned(MlirType type); +MLIR_CAPI_EXPORTED bool mlirIntegerTypeIsUnsigned(MlirType type); //===----------------------------------------------------------------------===// // Index type. //===----------------------------------------------------------------------===// /// Checks whether the given type is an index type. -MLIR_CAPI_EXPORTED int mlirTypeIsAIndex(MlirType type); +MLIR_CAPI_EXPORTED bool mlirTypeIsAIndex(MlirType type); /** Creates an index type in the given context. The type is owned by the * context. */ @@ -68,28 +68,28 @@ //===----------------------------------------------------------------------===// /// Checks whether the given type is a bf16 type. -MLIR_CAPI_EXPORTED int mlirTypeIsABF16(MlirType type); +MLIR_CAPI_EXPORTED bool mlirTypeIsABF16(MlirType type); /** Creates a bf16 type in the given context. The type is owned by the * context. */ MLIR_CAPI_EXPORTED MlirType mlirBF16TypeGet(MlirContext ctx); /// Checks whether the given type is an f16 type. -MLIR_CAPI_EXPORTED int mlirTypeIsAF16(MlirType type); +MLIR_CAPI_EXPORTED bool mlirTypeIsAF16(MlirType type); /** Creates an f16 type in the given context. The type is owned by the * context. */ MLIR_CAPI_EXPORTED MlirType mlirF16TypeGet(MlirContext ctx); /// Checks whether the given type is an f32 type. -MLIR_CAPI_EXPORTED int mlirTypeIsAF32(MlirType type); +MLIR_CAPI_EXPORTED bool mlirTypeIsAF32(MlirType type); /** Creates an f32 type in the given context. The type is owned by the * context. */ MLIR_CAPI_EXPORTED MlirType mlirF32TypeGet(MlirContext ctx); /// Checks whether the given type is an f64 type. -MLIR_CAPI_EXPORTED int mlirTypeIsAF64(MlirType type); +MLIR_CAPI_EXPORTED bool mlirTypeIsAF64(MlirType type); /** Creates a f64 type in the given context. The type is owned by the * context. */ @@ -100,7 +100,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given type is a None type. -MLIR_CAPI_EXPORTED int mlirTypeIsANone(MlirType type); +MLIR_CAPI_EXPORTED bool mlirTypeIsANone(MlirType type); /** Creates a None type in the given context. The type is owned by the * context. */ @@ -111,7 +111,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given type is a Complex type. -MLIR_CAPI_EXPORTED int mlirTypeIsAComplex(MlirType type); +MLIR_CAPI_EXPORTED bool mlirTypeIsAComplex(MlirType type); /** Creates a complex type with the given element type in the same context as * the element type. The type is owned by the context. */ @@ -125,22 +125,22 @@ //===----------------------------------------------------------------------===// /// Checks whether the given type is a Shaped type. -MLIR_CAPI_EXPORTED int mlirTypeIsAShaped(MlirType type); +MLIR_CAPI_EXPORTED bool mlirTypeIsAShaped(MlirType type); /// Returns the element type of the shaped type. MLIR_CAPI_EXPORTED MlirType mlirShapedTypeGetElementType(MlirType type); /// Checks whether the given shaped type is ranked. -MLIR_CAPI_EXPORTED int mlirShapedTypeHasRank(MlirType type); +MLIR_CAPI_EXPORTED bool mlirShapedTypeHasRank(MlirType type); /// Returns the rank of the given ranked shaped type. MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetRank(MlirType type); /// Checks whether the given shaped type has a static shape. -MLIR_CAPI_EXPORTED int mlirShapedTypeHasStaticShape(MlirType type); +MLIR_CAPI_EXPORTED bool mlirShapedTypeHasStaticShape(MlirType type); /// Checks wither the dim-th dimension of the given shaped type is dynamic. -MLIR_CAPI_EXPORTED int mlirShapedTypeIsDynamicDim(MlirType type, intptr_t dim); +MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicDim(MlirType type, intptr_t dim); /// Returns the dim-th dimension of the given ranked shaped type. MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDimSize(MlirType type, @@ -148,18 +148,18 @@ /** Checks whether the given value is used as a placeholder for dynamic sizes * in shaped types. */ -MLIR_CAPI_EXPORTED int mlirShapedTypeIsDynamicSize(int64_t size); +MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicSize(int64_t size); /** Checks whether the given value is used as a placeholder for dynamic strides * and offsets in shaped types. */ -MLIR_CAPI_EXPORTED int mlirShapedTypeIsDynamicStrideOrOffset(int64_t val); +MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicStrideOrOffset(int64_t val); //===----------------------------------------------------------------------===// // Vector type. //===----------------------------------------------------------------------===// /// Checks whether the given type is a Vector type. -MLIR_CAPI_EXPORTED int mlirTypeIsAVector(MlirType type); +MLIR_CAPI_EXPORTED bool mlirTypeIsAVector(MlirType type); /** Creates a vector type of the shape identified by its rank and dimensions, * with the given element type in the same context as the element type. The type @@ -180,13 +180,13 @@ //===----------------------------------------------------------------------===// /// Checks whether the given type is a Tensor type. -MLIR_CAPI_EXPORTED int mlirTypeIsATensor(MlirType type); +MLIR_CAPI_EXPORTED bool mlirTypeIsATensor(MlirType type); /// Checks whether the given type is a ranked tensor type. -MLIR_CAPI_EXPORTED int mlirTypeIsARankedTensor(MlirType type); +MLIR_CAPI_EXPORTED bool mlirTypeIsARankedTensor(MlirType type); /// Checks whether the given type is an unranked tensor type. -MLIR_CAPI_EXPORTED int mlirTypeIsAUnrankedTensor(MlirType type); +MLIR_CAPI_EXPORTED bool mlirTypeIsAUnrankedTensor(MlirType type); /** Creates a tensor type of a fixed rank with the given shape and element type * in the same context as the element type. The type is owned by the context. */ @@ -215,10 +215,10 @@ //===----------------------------------------------------------------------===// /// Checks whether the given type is a MemRef type. -MLIR_CAPI_EXPORTED int mlirTypeIsAMemRef(MlirType type); +MLIR_CAPI_EXPORTED bool mlirTypeIsAMemRef(MlirType type); /// Checks whether the given type is an UnrankedMemRef type. -MLIR_CAPI_EXPORTED int mlirTypeIsAUnrankedMemRef(MlirType type); +MLIR_CAPI_EXPORTED bool mlirTypeIsAUnrankedMemRef(MlirType type); /** Creates a MemRef type with the given rank and shape, a potentially empty * list of affine layout maps, the given memory space and element type, in the @@ -270,7 +270,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given type is a tuple type. -MLIR_CAPI_EXPORTED int mlirTypeIsATuple(MlirType type); +MLIR_CAPI_EXPORTED bool mlirTypeIsATuple(MlirType type); /** Creates a tuple type that consists of the given list of elemental types. The * type is owned by the context. */ @@ -289,7 +289,7 @@ //===----------------------------------------------------------------------===// /// Checks whether the given type is a function type. -MLIR_CAPI_EXPORTED int mlirTypeIsAFunction(MlirType type); +MLIR_CAPI_EXPORTED bool mlirTypeIsAFunction(MlirType type); /// Creates a function type, mapping a list of input types to result types. MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGet(MlirContext ctx, diff --git a/mlir/include/mlir-c/Support.h b/mlir/include/mlir-c/Support.h --- a/mlir/include/mlir-c/Support.h +++ b/mlir/include/mlir-c/Support.h @@ -95,12 +95,12 @@ typedef struct MlirLogicalResult MlirLogicalResult; /// Checks if the given logical result represents a success. -inline static int mlirLogicalResultIsSuccess(MlirLogicalResult res) { +inline static bool mlirLogicalResultIsSuccess(MlirLogicalResult res) { return res.value != 0; } /// Checks if the given logical result represents a failure. -inline static int mlirLogicalResultIsFailure(MlirLogicalResult res) { +inline static bool mlirLogicalResultIsFailure(MlirLogicalResult res) { return res.value == 0; } diff --git a/mlir/lib/Bindings/Python/IRModules.cpp b/mlir/lib/Bindings/Python/IRModules.cpp --- a/mlir/lib/Bindings/Python/IRModules.cpp +++ b/mlir/lib/Bindings/Python/IRModules.cpp @@ -1147,7 +1147,7 @@ // const char *pyClassName // and redefine bindDerived. using ClassTy = py::class_; - using IsAFunctionTy = int (*)(MlirValue); + using IsAFunctionTy = bool (*)(MlirValue); PyConcreteValue() = default; PyConcreteValue(PyOperationRef operationRef, MlirValue value) @@ -1407,7 +1407,7 @@ // IsAFunctionTy isaFunction // const char *pyClassName using ClassTy = py::class_; - using IsAFunctionTy = int (*)(MlirAttribute); + using IsAFunctionTy = bool (*)(MlirAttribute); PyConcreteAttribute() = default; PyConcreteAttribute(PyMlirContextRef contextRef, MlirAttribute attr) @@ -1934,7 +1934,7 @@ // IsAFunctionTy isaFunction // const char *pyClassName using ClassTy = py::class_; - using IsAFunctionTy = int (*)(MlirType); + using IsAFunctionTy = bool (*)(MlirType); PyConcreteType() = default; PyConcreteType(PyMlirContextRef contextRef, MlirType t) diff --git a/mlir/lib/CAPI/IR/AffineExpr.cpp b/mlir/lib/CAPI/IR/AffineExpr.cpp --- a/mlir/lib/CAPI/IR/AffineExpr.cpp +++ b/mlir/lib/CAPI/IR/AffineExpr.cpp @@ -31,11 +31,11 @@ unwrap(affineExpr).dump(); } -int mlirAffineExprIsSymbolicOrConstant(MlirAffineExpr affineExpr) { +bool mlirAffineExprIsSymbolicOrConstant(MlirAffineExpr affineExpr) { return unwrap(affineExpr).isSymbolicOrConstant(); } -int mlirAffineExprIsPureAffine(MlirAffineExpr affineExpr) { +bool mlirAffineExprIsPureAffine(MlirAffineExpr affineExpr) { return unwrap(affineExpr).isPureAffine(); } @@ -43,12 +43,12 @@ return unwrap(affineExpr).getLargestKnownDivisor(); } -int mlirAffineExprIsMultipleOf(MlirAffineExpr affineExpr, int64_t factor) { +bool mlirAffineExprIsMultipleOf(MlirAffineExpr affineExpr, int64_t factor) { return unwrap(affineExpr).isMultipleOf(factor); } -int mlirAffineExprIsFunctionOfDim(MlirAffineExpr affineExpr, - intptr_t position) { +bool mlirAffineExprIsFunctionOfDim(MlirAffineExpr affineExpr, + intptr_t position) { return unwrap(affineExpr).isFunctionOfDim(position); } @@ -92,7 +92,7 @@ // Affine Add Expression. //===----------------------------------------------------------------------===// -int mlirAffineExprIsAAdd(MlirAffineExpr affineExpr) { +bool mlirAffineExprIsAAdd(MlirAffineExpr affineExpr) { return unwrap(affineExpr).getKind() == mlir::AffineExprKind::Add; } @@ -105,7 +105,7 @@ // Affine Mul Expression. //===----------------------------------------------------------------------===// -int mlirAffineExprIsAMul(MlirAffineExpr affineExpr) { +bool mlirAffineExprIsAMul(MlirAffineExpr affineExpr) { return unwrap(affineExpr).getKind() == mlir::AffineExprKind::Mul; } @@ -118,7 +118,7 @@ // Affine Mod Expression. //===----------------------------------------------------------------------===// -int mlirAffineExprIsAMod(MlirAffineExpr affineExpr) { +bool mlirAffineExprIsAMod(MlirAffineExpr affineExpr) { return unwrap(affineExpr).getKind() == mlir::AffineExprKind::Mod; } @@ -131,7 +131,7 @@ // Affine FloorDiv Expression. //===----------------------------------------------------------------------===// -int mlirAffineExprIsAFloorDiv(MlirAffineExpr affineExpr) { +bool mlirAffineExprIsAFloorDiv(MlirAffineExpr affineExpr) { return unwrap(affineExpr).getKind() == mlir::AffineExprKind::FloorDiv; } @@ -145,7 +145,7 @@ // Affine CeilDiv Expression. //===----------------------------------------------------------------------===// -int mlirAffineExprIsACeilDiv(MlirAffineExpr affineExpr) { +bool mlirAffineExprIsACeilDiv(MlirAffineExpr affineExpr) { return unwrap(affineExpr).getKind() == mlir::AffineExprKind::CeilDiv; } diff --git a/mlir/lib/CAPI/IR/AffineMap.cpp b/mlir/lib/CAPI/IR/AffineMap.cpp --- a/mlir/lib/CAPI/IR/AffineMap.cpp +++ b/mlir/lib/CAPI/IR/AffineMap.cpp @@ -21,7 +21,7 @@ return wrap(unwrap(affineMap).getContext()); } -int mlirAffineMapEqual(MlirAffineMap a1, MlirAffineMap a2) { +bool mlirAffineMapEqual(MlirAffineMap a1, MlirAffineMap a2) { return unwrap(a1) == unwrap(a2); } @@ -62,19 +62,19 @@ llvm::makeArrayRef(permutation, static_cast(size)), unwrap(ctx))); } -int mlirAffineMapIsIdentity(MlirAffineMap affineMap) { +bool mlirAffineMapIsIdentity(MlirAffineMap affineMap) { return unwrap(affineMap).isIdentity(); } -int mlirAffineMapIsMinorIdentity(MlirAffineMap affineMap) { +bool mlirAffineMapIsMinorIdentity(MlirAffineMap affineMap) { return unwrap(affineMap).isMinorIdentity(); } -int mlirAffineMapIsEmpty(MlirAffineMap affineMap) { +bool mlirAffineMapIsEmpty(MlirAffineMap affineMap) { return unwrap(affineMap).isEmpty(); } -int mlirAffineMapIsSingleConstant(MlirAffineMap affineMap) { +bool mlirAffineMapIsSingleConstant(MlirAffineMap affineMap) { return unwrap(affineMap).isSingleConstant(); } @@ -98,11 +98,11 @@ return unwrap(affineMap).getNumInputs(); } -int mlirAffineMapIsProjectedPermutation(MlirAffineMap affineMap) { +bool mlirAffineMapIsProjectedPermutation(MlirAffineMap affineMap) { return unwrap(affineMap).isProjectedPermutation(); } -int mlirAffineMapIsPermutation(MlirAffineMap affineMap) { +bool mlirAffineMapIsPermutation(MlirAffineMap affineMap) { return unwrap(affineMap).isPermutation(); } 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 @@ -36,11 +36,11 @@ void mlirContextDestroy(MlirContext context) { delete unwrap(context); } -void mlirContextSetAllowUnregisteredDialects(MlirContext context, int allow) { +void mlirContextSetAllowUnregisteredDialects(MlirContext context, bool allow) { unwrap(context)->allowUnregisteredDialects(allow); } -int mlirContextGetAllowUnregisteredDialects(MlirContext context) { +bool mlirContextGetAllowUnregisteredDialects(MlirContext context) { return unwrap(context)->allowsUnregisteredDialects(); } intptr_t mlirContextGetNumRegisteredDialects(MlirContext context) { @@ -92,7 +92,7 @@ } void mlirOpPrintingFlagsEnableDebugInfo(MlirOpPrintingFlags flags, - int prettyForm) { + bool prettyForm) { unwrap(flags)->enableDebugInfo(/*prettyForm=*/prettyForm); } @@ -119,7 +119,7 @@ return wrap(UnknownLoc::get(unwrap(context))); } -int mlirLocationEqual(MlirLocation l1, MlirLocation l2) { +bool mlirLocationEqual(MlirLocation l1, MlirLocation l2) { return unwrap(l1) == unwrap(l2); } @@ -320,7 +320,7 @@ unwrap(op)->setAttr(unwrap(name), unwrap(attr)); } -int mlirOperationRemoveAttributeByName(MlirOperation op, MlirStringRef name) { +bool mlirOperationRemoveAttributeByName(MlirOperation op, MlirStringRef name) { auto removeResult = unwrap(op)->removeAttr(unwrap(name)); return removeResult == MutableDictionaryAttr::RemoveResult::Removed; } @@ -488,11 +488,11 @@ return unwrap(value1) == unwrap(value2); } -int mlirValueIsABlockArgument(MlirValue value) { +bool mlirValueIsABlockArgument(MlirValue value) { return unwrap(value).isa(); } -int mlirValueIsAOpResult(MlirValue value) { +bool mlirValueIsAOpResult(MlirValue value) { return unwrap(value).isa(); } diff --git a/mlir/lib/CAPI/IR/StandardAttributes.cpp b/mlir/lib/CAPI/IR/StandardAttributes.cpp --- a/mlir/lib/CAPI/IR/StandardAttributes.cpp +++ b/mlir/lib/CAPI/IR/StandardAttributes.cpp @@ -19,7 +19,7 @@ // Affine map attribute. //===----------------------------------------------------------------------===// -int mlirAttributeIsAAffineMap(MlirAttribute attr) { +bool mlirAttributeIsAAffineMap(MlirAttribute attr) { return unwrap(attr).isa(); } @@ -35,7 +35,7 @@ // Array attribute. //===----------------------------------------------------------------------===// -int mlirAttributeIsAArray(MlirAttribute attr) { +bool mlirAttributeIsAArray(MlirAttribute attr) { return unwrap(attr).isa(); } @@ -59,7 +59,7 @@ // Dictionary attribute. //===----------------------------------------------------------------------===// -int mlirAttributeIsADictionary(MlirAttribute attr) { +bool mlirAttributeIsADictionary(MlirAttribute attr) { return unwrap(attr).isa(); } @@ -94,7 +94,7 @@ // Floating point attribute. //===----------------------------------------------------------------------===// -int mlirAttributeIsAFloat(MlirAttribute attr) { +bool mlirAttributeIsAFloat(MlirAttribute attr) { return unwrap(attr).isa(); } @@ -116,7 +116,7 @@ // Integer attribute. //===----------------------------------------------------------------------===// -int mlirAttributeIsAInteger(MlirAttribute attr) { +bool mlirAttributeIsAInteger(MlirAttribute attr) { return unwrap(attr).isa(); } @@ -132,7 +132,7 @@ // Bool attribute. //===----------------------------------------------------------------------===// -int mlirAttributeIsABool(MlirAttribute attr) { +bool mlirAttributeIsABool(MlirAttribute attr) { return unwrap(attr).isa(); } @@ -140,7 +140,7 @@ return wrap(BoolAttr::get(value, unwrap(ctx))); } -int mlirBoolAttrGetValue(MlirAttribute attr) { +bool mlirBoolAttrGetValue(MlirAttribute attr) { return unwrap(attr).cast().getValue(); } @@ -148,7 +148,7 @@ // Integer set attribute. //===----------------------------------------------------------------------===// -int mlirAttributeIsAIntegerSet(MlirAttribute attr) { +bool mlirAttributeIsAIntegerSet(MlirAttribute attr) { return unwrap(attr).isa(); } @@ -156,7 +156,7 @@ // Opaque attribute. //===----------------------------------------------------------------------===// -int mlirAttributeIsAOpaque(MlirAttribute attr) { +bool mlirAttributeIsAOpaque(MlirAttribute attr) { return unwrap(attr).isa(); } @@ -180,7 +180,7 @@ // String attribute. //===----------------------------------------------------------------------===// -int mlirAttributeIsAString(MlirAttribute attr) { +bool mlirAttributeIsAString(MlirAttribute attr) { return unwrap(attr).isa(); } @@ -202,7 +202,7 @@ // SymbolRef attribute. //===----------------------------------------------------------------------===// -int mlirAttributeIsASymbolRef(MlirAttribute attr) { +bool mlirAttributeIsASymbolRef(MlirAttribute attr) { return unwrap(attr).isa(); } @@ -238,7 +238,7 @@ // Flat SymbolRef attribute. //===----------------------------------------------------------------------===// -int mlirAttributeIsAFlatSymbolRef(MlirAttribute attr) { +bool mlirAttributeIsAFlatSymbolRef(MlirAttribute attr) { return unwrap(attr).isa(); } @@ -255,7 +255,7 @@ // Type attribute. //===----------------------------------------------------------------------===// -int mlirAttributeIsAType(MlirAttribute attr) { +bool mlirAttributeIsAType(MlirAttribute attr) { return unwrap(attr).isa(); } @@ -271,7 +271,7 @@ // Unit attribute. //===----------------------------------------------------------------------===// -int mlirAttributeIsAUnit(MlirAttribute attr) { +bool mlirAttributeIsAUnit(MlirAttribute attr) { return unwrap(attr).isa(); } @@ -283,7 +283,7 @@ // Elements attributes. //===----------------------------------------------------------------------===// -int mlirAttributeIsAElements(MlirAttribute attr) { +bool mlirAttributeIsAElements(MlirAttribute attr) { return unwrap(attr).isa(); } @@ -293,8 +293,8 @@ llvm::makeArrayRef(idxs, rank))); } -int mlirElementsAttrIsValidIndex(MlirAttribute attr, intptr_t rank, - uint64_t *idxs) { +bool mlirElementsAttrIsValidIndex(MlirAttribute attr, intptr_t rank, + uint64_t *idxs) { return unwrap(attr).cast().isValidIndex( llvm::makeArrayRef(idxs, rank)); } @@ -310,13 +310,13 @@ //===----------------------------------------------------------------------===// // IsA support. -int mlirAttributeIsADenseElements(MlirAttribute attr) { +bool mlirAttributeIsADenseElements(MlirAttribute attr) { return unwrap(attr).isa(); } -int mlirAttributeIsADenseIntElements(MlirAttribute attr) { +bool mlirAttributeIsADenseIntElements(MlirAttribute attr) { return unwrap(attr).isa(); } -int mlirAttributeIsADenseFPElements(MlirAttribute attr) { +bool mlirAttributeIsADenseFPElements(MlirAttribute attr) { return unwrap(attr).isa(); } @@ -338,9 +338,9 @@ unwrap(element))); } MlirAttribute mlirDenseElementsAttrBoolSplatGet(MlirType shapedType, - int element) { - return wrap(DenseElementsAttr::get(unwrap(shapedType).cast(), - static_cast(element))); + bool element) { + return wrap( + DenseElementsAttr::get(unwrap(shapedType).cast(), element)); } MlirAttribute mlirDenseElementsAttrUInt32SplatGet(MlirType shapedType, uint32_t element) { @@ -444,7 +444,7 @@ //===----------------------------------------------------------------------===// // Splat accessors. -int mlirDenseElementsAttrIsSplat(MlirAttribute attr) { +bool mlirDenseElementsAttrIsSplat(MlirAttribute attr) { return unwrap(attr).cast().isSplat(); } @@ -480,7 +480,7 @@ //===----------------------------------------------------------------------===// // Indexed accessors. -int mlirDenseElementsAttrGetBoolValue(MlirAttribute attr, intptr_t pos) { +bool mlirDenseElementsAttrGetBoolValue(MlirAttribute attr, intptr_t pos) { return *(unwrap(attr).cast().getValues().begin() + pos); } @@ -529,7 +529,7 @@ // Opaque elements attribute. //===----------------------------------------------------------------------===// -int mlirAttributeIsAOpaqueElements(MlirAttribute attr) { +bool mlirAttributeIsAOpaqueElements(MlirAttribute attr) { return unwrap(attr).isa(); } @@ -537,7 +537,7 @@ // Sparse elements attribute. //===----------------------------------------------------------------------===// -int mlirAttributeIsASparseElements(MlirAttribute attr) { +bool mlirAttributeIsASparseElements(MlirAttribute attr) { return unwrap(attr).isa(); } diff --git a/mlir/lib/CAPI/IR/StandardTypes.cpp b/mlir/lib/CAPI/IR/StandardTypes.cpp --- a/mlir/lib/CAPI/IR/StandardTypes.cpp +++ b/mlir/lib/CAPI/IR/StandardTypes.cpp @@ -21,7 +21,7 @@ // Integer types. //===----------------------------------------------------------------------===// -int mlirTypeIsAInteger(MlirType type) { +bool mlirTypeIsAInteger(MlirType type) { return unwrap(type).isa(); } @@ -41,15 +41,15 @@ return unwrap(type).cast().getWidth(); } -int mlirIntegerTypeIsSignless(MlirType type) { +bool mlirIntegerTypeIsSignless(MlirType type) { return unwrap(type).cast().isSignless(); } -int mlirIntegerTypeIsSigned(MlirType type) { +bool mlirIntegerTypeIsSigned(MlirType type) { return unwrap(type).cast().isSigned(); } -int mlirIntegerTypeIsUnsigned(MlirType type) { +bool mlirIntegerTypeIsUnsigned(MlirType type) { return unwrap(type).cast().isUnsigned(); } @@ -57,7 +57,7 @@ // Index type. //===----------------------------------------------------------------------===// -int mlirTypeIsAIndex(MlirType type) { return unwrap(type).isa(); } +bool mlirTypeIsAIndex(MlirType type) { return unwrap(type).isa(); } MlirType mlirIndexTypeGet(MlirContext ctx) { return wrap(IndexType::get(unwrap(ctx))); @@ -67,25 +67,25 @@ // Floating-point types. //===----------------------------------------------------------------------===// -int mlirTypeIsABF16(MlirType type) { return unwrap(type).isBF16(); } +bool mlirTypeIsABF16(MlirType type) { return unwrap(type).isBF16(); } MlirType mlirBF16TypeGet(MlirContext ctx) { return wrap(FloatType::getBF16(unwrap(ctx))); } -int mlirTypeIsAF16(MlirType type) { return unwrap(type).isF16(); } +bool mlirTypeIsAF16(MlirType type) { return unwrap(type).isF16(); } MlirType mlirF16TypeGet(MlirContext ctx) { return wrap(FloatType::getF16(unwrap(ctx))); } -int mlirTypeIsAF32(MlirType type) { return unwrap(type).isF32(); } +bool mlirTypeIsAF32(MlirType type) { return unwrap(type).isF32(); } MlirType mlirF32TypeGet(MlirContext ctx) { return wrap(FloatType::getF32(unwrap(ctx))); } -int mlirTypeIsAF64(MlirType type) { return unwrap(type).isF64(); } +bool mlirTypeIsAF64(MlirType type) { return unwrap(type).isF64(); } MlirType mlirF64TypeGet(MlirContext ctx) { return wrap(FloatType::getF64(unwrap(ctx))); @@ -95,7 +95,7 @@ // None type. //===----------------------------------------------------------------------===// -int mlirTypeIsANone(MlirType type) { return unwrap(type).isa(); } +bool mlirTypeIsANone(MlirType type) { return unwrap(type).isa(); } MlirType mlirNoneTypeGet(MlirContext ctx) { return wrap(NoneType::get(unwrap(ctx))); @@ -105,7 +105,7 @@ // Complex type. //===----------------------------------------------------------------------===// -int mlirTypeIsAComplex(MlirType type) { +bool mlirTypeIsAComplex(MlirType type) { return unwrap(type).isa(); } @@ -121,13 +121,13 @@ // Shaped type. //===----------------------------------------------------------------------===// -int mlirTypeIsAShaped(MlirType type) { return unwrap(type).isa(); } +bool mlirTypeIsAShaped(MlirType type) { return unwrap(type).isa(); } MlirType mlirShapedTypeGetElementType(MlirType type) { return wrap(unwrap(type).cast().getElementType()); } -int mlirShapedTypeHasRank(MlirType type) { +bool mlirShapedTypeHasRank(MlirType type) { return unwrap(type).cast().hasRank(); } @@ -135,11 +135,11 @@ return unwrap(type).cast().getRank(); } -int mlirShapedTypeHasStaticShape(MlirType type) { +bool mlirShapedTypeHasStaticShape(MlirType type) { return unwrap(type).cast().hasStaticShape(); } -int mlirShapedTypeIsDynamicDim(MlirType type, intptr_t dim) { +bool mlirShapedTypeIsDynamicDim(MlirType type, intptr_t dim) { return unwrap(type).cast().isDynamicDim( static_cast(dim)); } @@ -148,11 +148,11 @@ return unwrap(type).cast().getDimSize(static_cast(dim)); } -int mlirShapedTypeIsDynamicSize(int64_t size) { +bool mlirShapedTypeIsDynamicSize(int64_t size) { return ShapedType::isDynamic(size); } -int mlirShapedTypeIsDynamicStrideOrOffset(int64_t val) { +bool mlirShapedTypeIsDynamicStrideOrOffset(int64_t val) { return ShapedType::isDynamicStrideOrOffset(val); } @@ -160,7 +160,7 @@ // Vector type. //===----------------------------------------------------------------------===// -int mlirTypeIsAVector(MlirType type) { return unwrap(type).isa(); } +bool mlirTypeIsAVector(MlirType type) { return unwrap(type).isa(); } MlirType mlirVectorTypeGet(intptr_t rank, const int64_t *shape, MlirType elementType) { @@ -180,13 +180,13 @@ // Ranked / Unranked tensor type. //===----------------------------------------------------------------------===// -int mlirTypeIsATensor(MlirType type) { return unwrap(type).isa(); } +bool mlirTypeIsATensor(MlirType type) { return unwrap(type).isa(); } -int mlirTypeIsARankedTensor(MlirType type) { +bool mlirTypeIsARankedTensor(MlirType type) { return unwrap(type).isa(); } -int mlirTypeIsAUnrankedTensor(MlirType type) { +bool mlirTypeIsAUnrankedTensor(MlirType type) { return unwrap(type).isa(); } @@ -218,7 +218,7 @@ // Ranked / Unranked MemRef type. //===----------------------------------------------------------------------===// -int mlirTypeIsAMemRef(MlirType type) { return unwrap(type).isa(); } +bool mlirTypeIsAMemRef(MlirType type) { return unwrap(type).isa(); } MlirType mlirMemRefTypeGet(MlirType elementType, intptr_t rank, const int64_t *shape, intptr_t numMaps, @@ -261,7 +261,7 @@ return unwrap(type).cast().getMemorySpace(); } -int mlirTypeIsAUnrankedMemRef(MlirType type) { +bool mlirTypeIsAUnrankedMemRef(MlirType type) { return unwrap(type).isa(); } @@ -284,7 +284,7 @@ // Tuple type. //===----------------------------------------------------------------------===// -int mlirTypeIsATuple(MlirType type) { return unwrap(type).isa(); } +bool mlirTypeIsATuple(MlirType type) { return unwrap(type).isa(); } MlirType mlirTupleTypeGet(MlirContext ctx, intptr_t numElements, MlirType const *elements) { @@ -305,7 +305,7 @@ // Function type. //===----------------------------------------------------------------------===// -int mlirTypeIsAFunction(MlirType type) { +bool mlirTypeIsAFunction(MlirType type) { return unwrap(type).isa(); } diff --git a/mlir/test/Bindings/Python/ir_attributes.py b/mlir/test/Bindings/Python/ir_attributes.py --- a/mlir/test/Bindings/Python/ir_attributes.py +++ b/mlir/test/Bindings/Python/ir_attributes.py @@ -155,7 +155,7 @@ def testBoolAttr(): with Context() as ctx: battr = BoolAttr(Attribute.parse("true")) - # CHECK: iattr value: 1 + # CHECK: iattr value: True print("iattr value:", battr.value) # Test factory methods.