[llvm-branch-commits] [mlir] 62195b7 - [mlir][CAPI] Convert the rest of the API int -> bool.

Stella Laurenzo via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Sun Nov 29 20:42:08 PST 2020


Author: Stella Laurenzo
Date: 2020-11-29T20:36:42-08:00
New Revision: 62195b75481890f3d86422710338a15bfbc57bcf

URL: https://github.com/llvm/llvm-project/commit/62195b75481890f3d86422710338a15bfbc57bcf
DIFF: https://github.com/llvm/llvm-project/commit/62195b75481890f3d86422710338a15bfbc57bcf.diff

LOG: [mlir][CAPI] Convert the rest of the API int -> bool.

* Follows on https://reviews.llvm.org/D92193
* I had a mid-air collision with some additional occurrences and then noticed that there were a lot more. Think I got them all.

Differential Revision: https://reviews.llvm.org/D92292

Added: 
    

Modified: 
    mlir/include/mlir-c/AffineExpr.h
    mlir/include/mlir-c/AffineMap.h
    mlir/include/mlir-c/IR.h
    mlir/include/mlir-c/Pass.h
    mlir/include/mlir-c/StandardAttributes.h
    mlir/include/mlir-c/StandardTypes.h
    mlir/include/mlir-c/Support.h
    mlir/lib/Bindings/Python/IRModules.cpp
    mlir/lib/CAPI/IR/AffineExpr.cpp
    mlir/lib/CAPI/IR/AffineMap.cpp
    mlir/lib/CAPI/IR/IR.cpp
    mlir/lib/CAPI/IR/StandardAttributes.cpp
    mlir/lib/CAPI/IR/StandardTypes.cpp
    mlir/test/Bindings/Python/ir_attributes.py

Removed: 
    


################################################################################
diff  --git a/mlir/include/mlir-c/AffineExpr.h b/mlir/include/mlir-c/AffineExpr.h
index 7ddd0289d8a5..93b8e832b44f 100644
--- a/mlir/include/mlir-c/AffineExpr.h
+++ b/mlir/include/mlir-c/AffineExpr.h
@@ -57,12 +57,12 @@ MLIR_CAPI_EXPORTED void mlirAffineExprDump(MlirAffineExpr affineExpr);
 
 /** 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 @@ MLIR_CAPI_EXPORTED int64_t
 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 @@ mlirAffineConstantExprGetValue(MlirAffineExpr affineExpr);
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineAddExprGet(MlirAffineExpr lhs,
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineMulExprGet(MlirAffineExpr lhs,
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineModExprGet(MlirAffineExpr lhs,
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineFloorDivExprGet(MlirAffineExpr lhs,
 //===----------------------------------------------------------------------===//
 
 /// 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
index 567faced6b85..c52fe6826251 100644
--- a/mlir/include/mlir-c/AffineMap.h
+++ b/mlir/include/mlir-c/AffineMap.h
@@ -44,12 +44,12 @@ DEFINE_C_API_STRUCT(MlirAffineMap, const void);
 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 @@ MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapPermutationGet(
 /** 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 @@ MLIR_CAPI_EXPORTED intptr_t mlirAffineMapGetNumInputs(MlirAffineMap affineMap);
 
 /** 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
index e3bfe76560f1..d8f63263763b 100644
--- a/mlir/include/mlir-c/IR.h
+++ b/mlir/include/mlir-c/IR.h
@@ -95,10 +95,10 @@ MLIR_CAPI_EXPORTED void mlirContextDestroy(MlirContext context);
 
 /// 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 MlirLocation mlirLocationUnknownGet(MlirContext context);
 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 @@ mlirOpPrintingFlagsElideLargeElementsAttrs(MlirOpPrintingFlags flags,
  * 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 @@ MLIR_CAPI_EXPORTED void mlirOperationSetAttributeByName(MlirOperation op,
                                                         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 @@ static inline bool mlirValueIsNull(MlirValue value) { return !value.ptr; }
 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
index a059c4608197..1b408b6361ed 100644
--- a/mlir/include/mlir-c/Pass.h
+++ b/mlir/include/mlir-c/Pass.h
@@ -54,7 +54,7 @@ MLIR_CAPI_EXPORTED MlirPassManager mlirPassManagerCreate(MlirContext ctx);
 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
index f86b5b73265c..20382c3a78cd 100644
--- a/mlir/include/mlir-c/StandardAttributes.h
+++ b/mlir/include/mlir-c/StandardAttributes.h
@@ -27,7 +27,7 @@ extern "C" {
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapAttrGetValue(MlirAttribute attr);
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ MLIR_CAPI_EXPORTED MlirAttribute mlirArrayAttrGetElement(MlirAttribute attr,
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ mlirDictionaryAttrGetElementByName(MlirAttribute attr, const char *name);
  * 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 @@ MLIR_CAPI_EXPORTED double mlirFloatAttrGetValueDouble(MlirAttribute attr);
  * 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 @@ MLIR_CAPI_EXPORTED int64_t mlirIntegerAttrGetValueInt(MlirAttribute attr);
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ MLIR_CAPI_EXPORTED MlirStringRef mlirOpaqueAttrGetData(MlirAttribute attr);
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ MLIR_CAPI_EXPORTED MlirStringRef mlirStringAttrGetValue(MlirAttribute attr);
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ mlirSymbolRefAttrGetNestedReference(MlirAttribute attr, intptr_t pos);
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ mlirFlatSymbolRefAttrGetValue(MlirAttribute attr);
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ MLIR_CAPI_EXPORTED MlirType mlirTypeAttrGetValue(MlirAttribute attr);
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ MLIR_CAPI_EXPORTED MlirAttribute mlirUnitAttrGet(MlirContext ctx);
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ MLIR_CAPI_EXPORTED MlirAttribute mlirElementsAttrGetValue(MlirAttribute attr,
 
 /** 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 @@ MLIR_CAPI_EXPORTED int64_t mlirElementsAttrGetNumElements(MlirAttribute attr);
  * 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 mlirDenseElementsAttrGet(
 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 @@ mlirDenseElementsAttrReshapeGet(MlirAttribute attr, MlirType shapedType);
 
 /** 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 @@ mlirDenseElementsAttrGetStringSplatValue(MlirAttribute attr);
 
 /** 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 @@ mlirDenseElementsAttrGetRawData(MlirAttribute attr);
 // 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
index 9839a1946ad9..14d9bcc51986 100644
--- a/mlir/include/mlir-c/StandardTypes.h
+++ b/mlir/include/mlir-c/StandardTypes.h
@@ -23,7 +23,7 @@ extern "C" {
 //===----------------------------------------------------------------------===//
 
 /// 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 MlirType mlirIntegerTypeUnsignedGet(MlirContext ctx,
 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 @@ MLIR_CAPI_EXPORTED MlirType mlirIndexTypeGet(MlirContext ctx);
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ MLIR_CAPI_EXPORTED MlirType mlirF64TypeGet(MlirContext ctx);
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ MLIR_CAPI_EXPORTED MlirType mlirNoneTypeGet(MlirContext ctx);
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ MLIR_CAPI_EXPORTED MlirType mlirComplexTypeGetElementType(MlirType type);
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDimSize(MlirType type,
 
 /** 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 @@ MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGetChecked(intptr_t rank,
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ mlirUnrankedTensorTypeGetChecked(MlirType elementType, MlirLocation loc);
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ MLIR_CAPI_EXPORTED unsigned mlirUnrankedMemrefGetMemorySpace(MlirType type);
 //===----------------------------------------------------------------------===//
 
 /// 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 @@ MLIR_CAPI_EXPORTED MlirType mlirTupleTypeGetType(MlirType type, intptr_t pos);
 //===----------------------------------------------------------------------===//
 
 /// 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
index afa094a41fcb..558b68f9d8d0 100644
--- a/mlir/include/mlir-c/Support.h
+++ b/mlir/include/mlir-c/Support.h
@@ -95,12 +95,12 @@ struct MlirLogicalResult {
 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
index d270e44debae..8beed22e5372 100644
--- a/mlir/lib/Bindings/Python/IRModules.cpp
+++ b/mlir/lib/Bindings/Python/IRModules.cpp
@@ -1147,7 +1147,7 @@ class PyConcreteValue : public PyValue {
   //   const char *pyClassName
   // and redefine bindDerived.
   using ClassTy = py::class_<DerivedTy, PyValue>;
-  using IsAFunctionTy = int (*)(MlirValue);
+  using IsAFunctionTy = bool (*)(MlirValue);
 
   PyConcreteValue() = default;
   PyConcreteValue(PyOperationRef operationRef, MlirValue value)
@@ -1407,7 +1407,7 @@ class PyConcreteAttribute : public BaseTy {
   //   IsAFunctionTy isaFunction
   //   const char *pyClassName
   using ClassTy = py::class_<DerivedTy, BaseTy>;
-  using IsAFunctionTy = int (*)(MlirAttribute);
+  using IsAFunctionTy = bool (*)(MlirAttribute);
 
   PyConcreteAttribute() = default;
   PyConcreteAttribute(PyMlirContextRef contextRef, MlirAttribute attr)
@@ -1934,7 +1934,7 @@ class PyConcreteType : public BaseTy {
   //   IsAFunctionTy isaFunction
   //   const char *pyClassName
   using ClassTy = py::class_<DerivedTy, BaseTy>;
-  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
index c74751d49eb1..01793192b05c 100644
--- a/mlir/lib/CAPI/IR/AffineExpr.cpp
+++ b/mlir/lib/CAPI/IR/AffineExpr.cpp
@@ -31,11 +31,11 @@ void mlirAffineExprDump(MlirAffineExpr affineExpr) {
   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 @@ int64_t mlirAffineExprGetLargestKnownDivisor(MlirAffineExpr affineExpr) {
   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 @@ int64_t mlirAffineConstantExprGetValue(MlirAffineExpr affineExpr) {
 // Affine Add Expression.
 //===----------------------------------------------------------------------===//
 
-int mlirAffineExprIsAAdd(MlirAffineExpr affineExpr) {
+bool mlirAffineExprIsAAdd(MlirAffineExpr affineExpr) {
   return unwrap(affineExpr).getKind() == mlir::AffineExprKind::Add;
 }
 
@@ -105,7 +105,7 @@ MlirAffineExpr mlirAffineAddExprGet(MlirAffineExpr lhs, MlirAffineExpr rhs) {
 // Affine Mul Expression.
 //===----------------------------------------------------------------------===//
 
-int mlirAffineExprIsAMul(MlirAffineExpr affineExpr) {
+bool mlirAffineExprIsAMul(MlirAffineExpr affineExpr) {
   return unwrap(affineExpr).getKind() == mlir::AffineExprKind::Mul;
 }
 
@@ -118,7 +118,7 @@ MlirAffineExpr mlirAffineMulExprGet(MlirAffineExpr lhs, MlirAffineExpr rhs) {
 // Affine Mod Expression.
 //===----------------------------------------------------------------------===//
 
-int mlirAffineExprIsAMod(MlirAffineExpr affineExpr) {
+bool mlirAffineExprIsAMod(MlirAffineExpr affineExpr) {
   return unwrap(affineExpr).getKind() == mlir::AffineExprKind::Mod;
 }
 
@@ -131,7 +131,7 @@ MlirAffineExpr mlirAffineModExprGet(MlirAffineExpr lhs, MlirAffineExpr rhs) {
 // Affine FloorDiv Expression.
 //===----------------------------------------------------------------------===//
 
-int mlirAffineExprIsAFloorDiv(MlirAffineExpr affineExpr) {
+bool mlirAffineExprIsAFloorDiv(MlirAffineExpr affineExpr) {
   return unwrap(affineExpr).getKind() == mlir::AffineExprKind::FloorDiv;
 }
 
@@ -145,7 +145,7 @@ MlirAffineExpr mlirAffineFloorDivExprGet(MlirAffineExpr lhs,
 // 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
index f8e78bcd46b2..ac81586144f5 100644
--- a/mlir/lib/CAPI/IR/AffineMap.cpp
+++ b/mlir/lib/CAPI/IR/AffineMap.cpp
@@ -21,7 +21,7 @@ MlirContext mlirAffineMapGetContext(MlirAffineMap affineMap) {
   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 @@ MlirAffineMap mlirAffineMapPermutationGet(MlirContext ctx, intptr_t size,
       llvm::makeArrayRef(permutation, static_cast<size_t>(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 @@ intptr_t mlirAffineMapGetNumInputs(MlirAffineMap affineMap) {
   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
index 475a062cb3f5..139c878d76e0 100644
--- a/mlir/lib/CAPI/IR/IR.cpp
+++ b/mlir/lib/CAPI/IR/IR.cpp
@@ -36,11 +36,11 @@ bool mlirContextEqual(MlirContext ctx1, MlirContext ctx2) {
 
 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 mlirOpPrintingFlagsElideLargeElementsAttrs(MlirOpPrintingFlags flags,
 }
 
 void mlirOpPrintingFlagsEnableDebugInfo(MlirOpPrintingFlags flags,
-                                        int prettyForm) {
+                                        bool prettyForm) {
   unwrap(flags)->enableDebugInfo(/*prettyForm=*/prettyForm);
 }
 
@@ -119,7 +119,7 @@ MlirLocation mlirLocationUnknownGet(MlirContext context) {
   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 @@ void mlirOperationSetAttributeByName(MlirOperation op, MlirStringRef name,
   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 @@ bool mlirValueEqual(MlirValue value1, MlirValue value2) {
   return unwrap(value1) == unwrap(value2);
 }
 
-int mlirValueIsABlockArgument(MlirValue value) {
+bool mlirValueIsABlockArgument(MlirValue value) {
   return unwrap(value).isa<BlockArgument>();
 }
 
-int mlirValueIsAOpResult(MlirValue value) {
+bool mlirValueIsAOpResult(MlirValue value) {
   return unwrap(value).isa<OpResult>();
 }
 

diff  --git a/mlir/lib/CAPI/IR/StandardAttributes.cpp b/mlir/lib/CAPI/IR/StandardAttributes.cpp
index 784c11aec740..c5a1178b7d92 100644
--- a/mlir/lib/CAPI/IR/StandardAttributes.cpp
+++ b/mlir/lib/CAPI/IR/StandardAttributes.cpp
@@ -19,7 +19,7 @@ using namespace mlir;
 // Affine map attribute.
 //===----------------------------------------------------------------------===//
 
-int mlirAttributeIsAAffineMap(MlirAttribute attr) {
+bool mlirAttributeIsAAffineMap(MlirAttribute attr) {
   return unwrap(attr).isa<AffineMapAttr>();
 }
 
@@ -35,7 +35,7 @@ MlirAffineMap mlirAffineMapAttrGetValue(MlirAttribute attr) {
 // Array attribute.
 //===----------------------------------------------------------------------===//
 
-int mlirAttributeIsAArray(MlirAttribute attr) {
+bool mlirAttributeIsAArray(MlirAttribute attr) {
   return unwrap(attr).isa<ArrayAttr>();
 }
 
@@ -59,7 +59,7 @@ MlirAttribute mlirArrayAttrGetElement(MlirAttribute attr, intptr_t pos) {
 // Dictionary attribute.
 //===----------------------------------------------------------------------===//
 
-int mlirAttributeIsADictionary(MlirAttribute attr) {
+bool mlirAttributeIsADictionary(MlirAttribute attr) {
   return unwrap(attr).isa<DictionaryAttr>();
 }
 
@@ -94,7 +94,7 @@ MlirAttribute mlirDictionaryAttrGetElementByName(MlirAttribute attr,
 // Floating point attribute.
 //===----------------------------------------------------------------------===//
 
-int mlirAttributeIsAFloat(MlirAttribute attr) {
+bool mlirAttributeIsAFloat(MlirAttribute attr) {
   return unwrap(attr).isa<FloatAttr>();
 }
 
@@ -116,7 +116,7 @@ double mlirFloatAttrGetValueDouble(MlirAttribute attr) {
 // Integer attribute.
 //===----------------------------------------------------------------------===//
 
-int mlirAttributeIsAInteger(MlirAttribute attr) {
+bool mlirAttributeIsAInteger(MlirAttribute attr) {
   return unwrap(attr).isa<IntegerAttr>();
 }
 
@@ -132,7 +132,7 @@ int64_t mlirIntegerAttrGetValueInt(MlirAttribute attr) {
 // Bool attribute.
 //===----------------------------------------------------------------------===//
 
-int mlirAttributeIsABool(MlirAttribute attr) {
+bool mlirAttributeIsABool(MlirAttribute attr) {
   return unwrap(attr).isa<BoolAttr>();
 }
 
@@ -140,7 +140,7 @@ MlirAttribute mlirBoolAttrGet(MlirContext ctx, int value) {
   return wrap(BoolAttr::get(value, unwrap(ctx)));
 }
 
-int mlirBoolAttrGetValue(MlirAttribute attr) {
+bool mlirBoolAttrGetValue(MlirAttribute attr) {
   return unwrap(attr).cast<BoolAttr>().getValue();
 }
 
@@ -148,7 +148,7 @@ int mlirBoolAttrGetValue(MlirAttribute attr) {
 // Integer set attribute.
 //===----------------------------------------------------------------------===//
 
-int mlirAttributeIsAIntegerSet(MlirAttribute attr) {
+bool mlirAttributeIsAIntegerSet(MlirAttribute attr) {
   return unwrap(attr).isa<IntegerSetAttr>();
 }
 
@@ -156,7 +156,7 @@ int mlirAttributeIsAIntegerSet(MlirAttribute attr) {
 // Opaque attribute.
 //===----------------------------------------------------------------------===//
 
-int mlirAttributeIsAOpaque(MlirAttribute attr) {
+bool mlirAttributeIsAOpaque(MlirAttribute attr) {
   return unwrap(attr).isa<OpaqueAttr>();
 }
 
@@ -180,7 +180,7 @@ MlirStringRef mlirOpaqueAttrGetData(MlirAttribute attr) {
 // String attribute.
 //===----------------------------------------------------------------------===//
 
-int mlirAttributeIsAString(MlirAttribute attr) {
+bool mlirAttributeIsAString(MlirAttribute attr) {
   return unwrap(attr).isa<StringAttr>();
 }
 
@@ -202,7 +202,7 @@ MlirStringRef mlirStringAttrGetValue(MlirAttribute attr) {
 // SymbolRef attribute.
 //===----------------------------------------------------------------------===//
 
-int mlirAttributeIsASymbolRef(MlirAttribute attr) {
+bool mlirAttributeIsASymbolRef(MlirAttribute attr) {
   return unwrap(attr).isa<SymbolRefAttr>();
 }
 
@@ -238,7 +238,7 @@ MlirAttribute mlirSymbolRefAttrGetNestedReference(MlirAttribute attr,
 // Flat SymbolRef attribute.
 //===----------------------------------------------------------------------===//
 
-int mlirAttributeIsAFlatSymbolRef(MlirAttribute attr) {
+bool mlirAttributeIsAFlatSymbolRef(MlirAttribute attr) {
   return unwrap(attr).isa<FlatSymbolRefAttr>();
 }
 
@@ -255,7 +255,7 @@ MlirStringRef mlirFlatSymbolRefAttrGetValue(MlirAttribute attr) {
 // Type attribute.
 //===----------------------------------------------------------------------===//
 
-int mlirAttributeIsAType(MlirAttribute attr) {
+bool mlirAttributeIsAType(MlirAttribute attr) {
   return unwrap(attr).isa<TypeAttr>();
 }
 
@@ -271,7 +271,7 @@ MlirType mlirTypeAttrGetValue(MlirAttribute attr) {
 // Unit attribute.
 //===----------------------------------------------------------------------===//
 
-int mlirAttributeIsAUnit(MlirAttribute attr) {
+bool mlirAttributeIsAUnit(MlirAttribute attr) {
   return unwrap(attr).isa<UnitAttr>();
 }
 
@@ -283,7 +283,7 @@ MlirAttribute mlirUnitAttrGet(MlirContext ctx) {
 // Elements attributes.
 //===----------------------------------------------------------------------===//
 
-int mlirAttributeIsAElements(MlirAttribute attr) {
+bool mlirAttributeIsAElements(MlirAttribute attr) {
   return unwrap(attr).isa<ElementsAttr>();
 }
 
@@ -293,8 +293,8 @@ MlirAttribute mlirElementsAttrGetValue(MlirAttribute attr, intptr_t rank,
       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<ElementsAttr>().isValidIndex(
       llvm::makeArrayRef(idxs, rank));
 }
@@ -310,13 +310,13 @@ int64_t mlirElementsAttrGetNumElements(MlirAttribute attr) {
 //===----------------------------------------------------------------------===//
 // IsA support.
 
-int mlirAttributeIsADenseElements(MlirAttribute attr) {
+bool mlirAttributeIsADenseElements(MlirAttribute attr) {
   return unwrap(attr).isa<DenseElementsAttr>();
 }
-int mlirAttributeIsADenseIntElements(MlirAttribute attr) {
+bool mlirAttributeIsADenseIntElements(MlirAttribute attr) {
   return unwrap(attr).isa<DenseIntElementsAttr>();
 }
-int mlirAttributeIsADenseFPElements(MlirAttribute attr) {
+bool mlirAttributeIsADenseFPElements(MlirAttribute attr) {
   return unwrap(attr).isa<DenseFPElementsAttr>();
 }
 
@@ -338,9 +338,9 @@ MlirAttribute mlirDenseElementsAttrSplatGet(MlirType shapedType,
                                      unwrap(element)));
 }
 MlirAttribute mlirDenseElementsAttrBoolSplatGet(MlirType shapedType,
-                                                int element) {
-  return wrap(DenseElementsAttr::get(unwrap(shapedType).cast<ShapedType>(),
-                                     static_cast<bool>(element)));
+                                                bool element) {
+  return wrap(
+      DenseElementsAttr::get(unwrap(shapedType).cast<ShapedType>(), element));
 }
 MlirAttribute mlirDenseElementsAttrUInt32SplatGet(MlirType shapedType,
                                                   uint32_t element) {
@@ -444,7 +444,7 @@ MlirAttribute mlirDenseElementsAttrReshapeGet(MlirAttribute attr,
 //===----------------------------------------------------------------------===//
 // Splat accessors.
 
-int mlirDenseElementsAttrIsSplat(MlirAttribute attr) {
+bool mlirDenseElementsAttrIsSplat(MlirAttribute attr) {
   return unwrap(attr).cast<DenseElementsAttr>().isSplat();
 }
 
@@ -480,7 +480,7 @@ MlirStringRef mlirDenseElementsAttrGetStringSplatValue(MlirAttribute attr) {
 //===----------------------------------------------------------------------===//
 // Indexed accessors.
 
-int mlirDenseElementsAttrGetBoolValue(MlirAttribute attr, intptr_t pos) {
+bool mlirDenseElementsAttrGetBoolValue(MlirAttribute attr, intptr_t pos) {
   return *(unwrap(attr).cast<DenseElementsAttr>().getValues<bool>().begin() +
            pos);
 }
@@ -529,7 +529,7 @@ const void *mlirDenseElementsAttrGetRawData(MlirAttribute attr) {
 // Opaque elements attribute.
 //===----------------------------------------------------------------------===//
 
-int mlirAttributeIsAOpaqueElements(MlirAttribute attr) {
+bool mlirAttributeIsAOpaqueElements(MlirAttribute attr) {
   return unwrap(attr).isa<OpaqueElementsAttr>();
 }
 
@@ -537,7 +537,7 @@ int mlirAttributeIsAOpaqueElements(MlirAttribute attr) {
 // Sparse elements attribute.
 //===----------------------------------------------------------------------===//
 
-int mlirAttributeIsASparseElements(MlirAttribute attr) {
+bool mlirAttributeIsASparseElements(MlirAttribute attr) {
   return unwrap(attr).isa<SparseElementsAttr>();
 }
 

diff  --git a/mlir/lib/CAPI/IR/StandardTypes.cpp b/mlir/lib/CAPI/IR/StandardTypes.cpp
index 1f9b56b35b4d..f920512474fa 100644
--- a/mlir/lib/CAPI/IR/StandardTypes.cpp
+++ b/mlir/lib/CAPI/IR/StandardTypes.cpp
@@ -21,7 +21,7 @@ using namespace mlir;
 // Integer types.
 //===----------------------------------------------------------------------===//
 
-int mlirTypeIsAInteger(MlirType type) {
+bool mlirTypeIsAInteger(MlirType type) {
   return unwrap(type).isa<IntegerType>();
 }
 
@@ -41,15 +41,15 @@ unsigned mlirIntegerTypeGetWidth(MlirType type) {
   return unwrap(type).cast<IntegerType>().getWidth();
 }
 
-int mlirIntegerTypeIsSignless(MlirType type) {
+bool mlirIntegerTypeIsSignless(MlirType type) {
   return unwrap(type).cast<IntegerType>().isSignless();
 }
 
-int mlirIntegerTypeIsSigned(MlirType type) {
+bool mlirIntegerTypeIsSigned(MlirType type) {
   return unwrap(type).cast<IntegerType>().isSigned();
 }
 
-int mlirIntegerTypeIsUnsigned(MlirType type) {
+bool mlirIntegerTypeIsUnsigned(MlirType type) {
   return unwrap(type).cast<IntegerType>().isUnsigned();
 }
 
@@ -57,7 +57,7 @@ int mlirIntegerTypeIsUnsigned(MlirType type) {
 // Index type.
 //===----------------------------------------------------------------------===//
 
-int mlirTypeIsAIndex(MlirType type) { return unwrap(type).isa<IndexType>(); }
+bool mlirTypeIsAIndex(MlirType type) { return unwrap(type).isa<IndexType>(); }
 
 MlirType mlirIndexTypeGet(MlirContext ctx) {
   return wrap(IndexType::get(unwrap(ctx)));
@@ -67,25 +67,25 @@ MlirType mlirIndexTypeGet(MlirContext ctx) {
 // 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 @@ MlirType mlirF64TypeGet(MlirContext ctx) {
 // None type.
 //===----------------------------------------------------------------------===//
 
-int mlirTypeIsANone(MlirType type) { return unwrap(type).isa<NoneType>(); }
+bool mlirTypeIsANone(MlirType type) { return unwrap(type).isa<NoneType>(); }
 
 MlirType mlirNoneTypeGet(MlirContext ctx) {
   return wrap(NoneType::get(unwrap(ctx)));
@@ -105,7 +105,7 @@ MlirType mlirNoneTypeGet(MlirContext ctx) {
 // Complex type.
 //===----------------------------------------------------------------------===//
 
-int mlirTypeIsAComplex(MlirType type) {
+bool mlirTypeIsAComplex(MlirType type) {
   return unwrap(type).isa<ComplexType>();
 }
 
@@ -121,13 +121,13 @@ MlirType mlirComplexTypeGetElementType(MlirType type) {
 // Shaped type.
 //===----------------------------------------------------------------------===//
 
-int mlirTypeIsAShaped(MlirType type) { return unwrap(type).isa<ShapedType>(); }
+bool mlirTypeIsAShaped(MlirType type) { return unwrap(type).isa<ShapedType>(); }
 
 MlirType mlirShapedTypeGetElementType(MlirType type) {
   return wrap(unwrap(type).cast<ShapedType>().getElementType());
 }
 
-int mlirShapedTypeHasRank(MlirType type) {
+bool mlirShapedTypeHasRank(MlirType type) {
   return unwrap(type).cast<ShapedType>().hasRank();
 }
 
@@ -135,11 +135,11 @@ int64_t mlirShapedTypeGetRank(MlirType type) {
   return unwrap(type).cast<ShapedType>().getRank();
 }
 
-int mlirShapedTypeHasStaticShape(MlirType type) {
+bool mlirShapedTypeHasStaticShape(MlirType type) {
   return unwrap(type).cast<ShapedType>().hasStaticShape();
 }
 
-int mlirShapedTypeIsDynamicDim(MlirType type, intptr_t dim) {
+bool mlirShapedTypeIsDynamicDim(MlirType type, intptr_t dim) {
   return unwrap(type).cast<ShapedType>().isDynamicDim(
       static_cast<unsigned>(dim));
 }
@@ -148,11 +148,11 @@ int64_t mlirShapedTypeGetDimSize(MlirType type, intptr_t dim) {
   return unwrap(type).cast<ShapedType>().getDimSize(static_cast<unsigned>(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 @@ int mlirShapedTypeIsDynamicStrideOrOffset(int64_t val) {
 // Vector type.
 //===----------------------------------------------------------------------===//
 
-int mlirTypeIsAVector(MlirType type) { return unwrap(type).isa<VectorType>(); }
+bool mlirTypeIsAVector(MlirType type) { return unwrap(type).isa<VectorType>(); }
 
 MlirType mlirVectorTypeGet(intptr_t rank, const int64_t *shape,
                            MlirType elementType) {
@@ -180,13 +180,13 @@ MlirType mlirVectorTypeGetChecked(intptr_t rank, const int64_t *shape,
 // Ranked / Unranked tensor type.
 //===----------------------------------------------------------------------===//
 
-int mlirTypeIsATensor(MlirType type) { return unwrap(type).isa<TensorType>(); }
+bool mlirTypeIsATensor(MlirType type) { return unwrap(type).isa<TensorType>(); }
 
-int mlirTypeIsARankedTensor(MlirType type) {
+bool mlirTypeIsARankedTensor(MlirType type) {
   return unwrap(type).isa<RankedTensorType>();
 }
 
-int mlirTypeIsAUnrankedTensor(MlirType type) {
+bool mlirTypeIsAUnrankedTensor(MlirType type) {
   return unwrap(type).isa<UnrankedTensorType>();
 }
 
@@ -218,7 +218,7 @@ MlirType mlirUnrankedTensorTypeGetChecked(MlirType elementType,
 // Ranked / Unranked MemRef type.
 //===----------------------------------------------------------------------===//
 
-int mlirTypeIsAMemRef(MlirType type) { return unwrap(type).isa<MemRefType>(); }
+bool mlirTypeIsAMemRef(MlirType type) { return unwrap(type).isa<MemRefType>(); }
 
 MlirType mlirMemRefTypeGet(MlirType elementType, intptr_t rank,
                            const int64_t *shape, intptr_t numMaps,
@@ -261,7 +261,7 @@ unsigned mlirMemRefTypeGetMemorySpace(MlirType type) {
   return unwrap(type).cast<MemRefType>().getMemorySpace();
 }
 
-int mlirTypeIsAUnrankedMemRef(MlirType type) {
+bool mlirTypeIsAUnrankedMemRef(MlirType type) {
   return unwrap(type).isa<UnrankedMemRefType>();
 }
 
@@ -284,7 +284,7 @@ unsigned mlirUnrankedMemrefGetMemorySpace(MlirType type) {
 // Tuple type.
 //===----------------------------------------------------------------------===//
 
-int mlirTypeIsATuple(MlirType type) { return unwrap(type).isa<TupleType>(); }
+bool mlirTypeIsATuple(MlirType type) { return unwrap(type).isa<TupleType>(); }
 
 MlirType mlirTupleTypeGet(MlirContext ctx, intptr_t numElements,
                           MlirType const *elements) {
@@ -305,7 +305,7 @@ MlirType mlirTupleTypeGetType(MlirType type, intptr_t pos) {
 // Function type.
 //===----------------------------------------------------------------------===//
 
-int mlirTypeIsAFunction(MlirType type) {
+bool mlirTypeIsAFunction(MlirType type) {
   return unwrap(type).isa<FunctionType>();
 }
 

diff  --git a/mlir/test/Bindings/Python/ir_attributes.py b/mlir/test/Bindings/Python/ir_attributes.py
index 6773c23cf8b3..0572220c750d 100644
--- a/mlir/test/Bindings/Python/ir_attributes.py
+++ b/mlir/test/Bindings/Python/ir_attributes.py
@@ -155,7 +155,7 @@ def testIntegerAttr():
 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.


        


More information about the llvm-branch-commits mailing list