[mlir] Use more C99 comments in C API header files

These were left over from the original reformatting commit.

Reviewed By: stellaraccident

Differential Revision: https://reviews.llvm.org/D95357
This commit is contained in:
Alex Zinenko 2021-01-25 15:22:16 +01:00
parent c3324450b2
commit 1e739552ee
8 changed files with 404 additions and 409 deletions

View File

@ -17,17 +17,16 @@ extern "C" {
#endif #endif
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/** Opaque type declarations. // Opaque type declarations.
* //
* Types are exposed to C bindings as structs containing opaque pointers. They // Types are exposed to C bindings as structs containing opaque pointers. They
* are not supposed to be inspected from C. This allows the underlying // are not supposed to be inspected from C. This allows the underlying
* representation to change without affecting the API users. The use of structs // representation to change without affecting the API users. The use of structs
* instead of typedefs enables some type safety as structs are not implicitly // instead of typedefs enables some type safety as structs are not implicitly
* convertible to each other. // convertible to each other.
* //
* Instances of these types may or may not own the underlying object. The // Instances of these types may or may not own the underlying object. The
* ownership semantics is defined by how an instance of the type was obtained. // ownership semantics is defined by how an instance of the type was obtained.
*/
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEFINE_C_API_STRUCT(name, storage) \ #define DEFINE_C_API_STRUCT(name, storage) \
@ -54,9 +53,9 @@ inline static bool mlirAffineExprIsNull(MlirAffineExpr affineExpr) {
return affineExpr.ptr == NULL; return affineExpr.ptr == NULL;
} }
/** Prints an affine expression by sending chunks of the string representation /// Prints an affine expression by sending chunks of the string representation
* and forwarding `userData to `callback`. Note that the callback may be called /// and forwarding `userData to `callback`. Note that the callback may be called
* several times with consecutive chunks of the string. */ /// several times with consecutive chunks of the string.
MLIR_CAPI_EXPORTED void mlirAffineExprPrint(MlirAffineExpr affineExpr, MLIR_CAPI_EXPORTED void mlirAffineExprPrint(MlirAffineExpr affineExpr,
MlirStringCallback callback, MlirStringCallback callback,
void *userData); void *userData);
@ -64,17 +63,17 @@ MLIR_CAPI_EXPORTED void mlirAffineExprPrint(MlirAffineExpr affineExpr,
/// Prints the affine expression to the standard error stream. /// Prints the affine expression to the standard error stream.
MLIR_CAPI_EXPORTED void mlirAffineExprDump(MlirAffineExpr affineExpr); MLIR_CAPI_EXPORTED void mlirAffineExprDump(MlirAffineExpr affineExpr);
/** Checks whether the given affine expression is made out of only symbols and /// Checks whether the given affine expression is made out of only symbols and
* constants. */ /// constants.
MLIR_CAPI_EXPORTED bool MLIR_CAPI_EXPORTED bool
mlirAffineExprIsSymbolicOrConstant(MlirAffineExpr affineExpr); mlirAffineExprIsSymbolicOrConstant(MlirAffineExpr affineExpr);
/** Checks whether the given affine expression is a pure affine expression, i.e. /// 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. */ /// mul, floordiv, ceildic, and mod is only allowed w.r.t constants.
MLIR_CAPI_EXPORTED bool mlirAffineExprIsPureAffine(MlirAffineExpr affineExpr); MLIR_CAPI_EXPORTED bool mlirAffineExprIsPureAffine(MlirAffineExpr affineExpr);
/** Returns the greatest known integral divisor of this affine expression. The /// Returns the greatest known integral divisor of this affine expression. The
* result is always positive. */ /// result is always positive.
MLIR_CAPI_EXPORTED int64_t MLIR_CAPI_EXPORTED int64_t
mlirAffineExprGetLargestKnownDivisor(MlirAffineExpr affineExpr); mlirAffineExprGetLargestKnownDivisor(MlirAffineExpr affineExpr);
@ -82,8 +81,8 @@ mlirAffineExprGetLargestKnownDivisor(MlirAffineExpr affineExpr);
MLIR_CAPI_EXPORTED bool mlirAffineExprIsMultipleOf(MlirAffineExpr affineExpr, MLIR_CAPI_EXPORTED bool mlirAffineExprIsMultipleOf(MlirAffineExpr affineExpr,
int64_t factor); int64_t factor);
/** Checks whether the given affine expression involves AffineDimExpr /// Checks whether the given affine expression involves AffineDimExpr
* 'position'. */ /// 'position'.
MLIR_CAPI_EXPORTED bool mlirAffineExprIsFunctionOfDim(MlirAffineExpr affineExpr, MLIR_CAPI_EXPORTED bool mlirAffineExprIsFunctionOfDim(MlirAffineExpr affineExpr,
intptr_t position); intptr_t position);
@ -194,13 +193,13 @@ MLIR_CAPI_EXPORTED MlirAffineExpr mlirAffineCeilDivExprGet(MlirAffineExpr lhs,
/// Checks whether the given affine expression is binary. /// Checks whether the given affine expression is binary.
MLIR_CAPI_EXPORTED bool mlirAffineExprIsABinary(MlirAffineExpr affineExpr); MLIR_CAPI_EXPORTED bool mlirAffineExprIsABinary(MlirAffineExpr affineExpr);
/** Returns the left hand side affine expression of the given affine binary /// Returns the left hand side affine expression of the given affine binary
* operation expression. */ /// operation expression.
MLIR_CAPI_EXPORTED MlirAffineExpr MLIR_CAPI_EXPORTED MlirAffineExpr
mlirAffineBinaryOpExprGetLHS(MlirAffineExpr affineExpr); mlirAffineBinaryOpExprGetLHS(MlirAffineExpr affineExpr);
/** Returns the right hand side affine expression of the given affine binary /// Returns the right hand side affine expression of the given affine binary
* operation expression. */ /// operation expression.
MLIR_CAPI_EXPORTED MlirAffineExpr MLIR_CAPI_EXPORTED MlirAffineExpr
mlirAffineBinaryOpExprGetRHS(MlirAffineExpr affineExpr); mlirAffineBinaryOpExprGetRHS(MlirAffineExpr affineExpr);

View File

@ -18,17 +18,16 @@ extern "C" {
#endif #endif
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/** Opaque type declarations. // Opaque type declarations.
* //
* Types are exposed to C bindings as structs containing opaque pointers. They // Types are exposed to C bindings as structs containing opaque pointers. They
* are not supposed to be inspected from C. This allows the underlying // are not supposed to be inspected from C. This allows the underlying
* representation to change without affecting the API users. The use of structs // representation to change without affecting the API users. The use of structs
* instead of typedefs enables some type safety as structs are not implicitly // instead of typedefs enables some type safety as structs are not implicitly
* convertible to each other. // convertible to each other.
* //
* Instances of these types may or may not own the underlying object. The // Instances of these types may or may not own the underlying object. The
* ownership semantics is defined by how an instance of the type was obtained. // ownership semantics is defined by how an instance of the type was obtained.
*/
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEFINE_C_API_STRUCT(name, storage) \ #define DEFINE_C_API_STRUCT(name, storage) \
@ -52,9 +51,9 @@ static inline bool mlirAffineMapIsNull(MlirAffineMap affineMap) {
/// Checks if two affine maps are equal. /// Checks if two affine maps are equal.
MLIR_CAPI_EXPORTED bool 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 /// Prints an affine map by sending chunks of the string representation and
* forwarding `userData to `callback`. Note that the callback may be called /// forwarding `userData to `callback`. Note that the callback may be called
* several times with consecutive chunks of the string. */ /// several times with consecutive chunks of the string.
MLIR_CAPI_EXPORTED void mlirAffineMapPrint(MlirAffineMap affineMap, MLIR_CAPI_EXPORTED void mlirAffineMapPrint(MlirAffineMap affineMap,
MlirStringCallback callback, MlirStringCallback callback,
void *userData); void *userData);
@ -62,52 +61,52 @@ MLIR_CAPI_EXPORTED void mlirAffineMapPrint(MlirAffineMap affineMap,
/// Prints the affine map to the standard error stream. /// Prints the affine map to the standard error stream.
MLIR_CAPI_EXPORTED void mlirAffineMapDump(MlirAffineMap affineMap); MLIR_CAPI_EXPORTED void mlirAffineMapDump(MlirAffineMap affineMap);
/** Creates a zero result affine map with no dimensions or symbols in the /// Creates a zero result affine map with no dimensions or symbols in the
* context. The affine map is owned by the context. */ /// context. The affine map is owned by the context.
MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapEmptyGet(MlirContext ctx); MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapEmptyGet(MlirContext ctx);
/** Creates a zero result affine map of the given dimensions and symbols in the /// Creates a zero result affine map of the given dimensions and symbols in the
* context. The affine map is owned by the context. */ /// context. The affine map is owned by the context.
MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapZeroResultGet( MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapZeroResultGet(
MlirContext ctx, intptr_t dimCount, intptr_t symbolCount); MlirContext ctx, intptr_t dimCount, intptr_t symbolCount);
/** Creates an affine map with results defined by the given list of affine /// Creates an affine map with results defined by the given list of affine
* expressions. The map resulting map also has the requested number of input /// expressions. The map resulting map also has the requested number of input
* dimensions and symbols, regardless of them being used in the results. /// dimensions and symbols, regardless of them being used in the results.
*/
MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapGet(MlirContext ctx, MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapGet(MlirContext ctx,
intptr_t dimCount, intptr_t dimCount,
intptr_t symbolCount, intptr_t symbolCount,
intptr_t nAffineExprs, intptr_t nAffineExprs,
MlirAffineExpr *affineExprs); MlirAffineExpr *affineExprs);
/** Creates a single constant result affine map in the context. The affine map /// Creates a single constant result affine map in the context. The affine map
* is owned by the context. */ /// is owned by the context.
MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapConstantGet(MlirContext ctx, MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapConstantGet(MlirContext ctx,
int64_t val); int64_t val);
/** Creates an affine map with 'numDims' identity in the context. The affine map /// Creates an affine map with 'numDims' identity in the context. The affine map
* is owned by the context. */ /// is owned by the context.
MLIR_CAPI_EXPORTED MlirAffineMap MLIR_CAPI_EXPORTED MlirAffineMap
mlirAffineMapMultiDimIdentityGet(MlirContext ctx, intptr_t numDims); mlirAffineMapMultiDimIdentityGet(MlirContext ctx, intptr_t numDims);
/** Creates an identity affine map on the most minor dimensions in the context. /// Creates an identity affine map on the most minor dimensions in the context.
* The affine map is owned by the context. The function asserts that the number /// The affine map is owned by the context. The function asserts that the number
* of dimensions is greater or equal to the number of results. */ /// of dimensions is greater or equal to the number of results.
MLIR_CAPI_EXPORTED MlirAffineMap MLIR_CAPI_EXPORTED MlirAffineMap
mlirAffineMapMinorIdentityGet(MlirContext ctx, intptr_t dims, intptr_t results); mlirAffineMapMinorIdentityGet(MlirContext ctx, intptr_t dims, intptr_t results);
/** Creates an affine map with a permutation expression and its size in the /// Creates an affine map with a permutation expression and its size in the
* context. The permutation expression is a non-empty vector of integers. /// context. The permutation expression is a non-empty vector of integers.
* The elements of the permutation vector must be continuous from 0 and cannot /// The elements of the permutation vector must be continuous from 0 and cannot
* be repeated (i.e. `[1,2,0]` is a valid permutation. `[2,0]` or `[1,1,2]` is /// be repeated (i.e. `[1,2,0]` is a valid permutation. `[2,0]` or `[1,1,2]` is
* an invalid invalid permutation.) The affine map is owned by the context. */ /// an invalid invalid permutation.) The affine map is owned by the context.
MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapPermutationGet( MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapPermutationGet(
MlirContext ctx, intptr_t size, unsigned *permutation); MlirContext ctx, intptr_t size, unsigned *permutation);
/** Checks whether the given affine map is an identity affine map. The function /// 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 /// asserts that the number of dimensions is greater or equal to the number of
* results. */ /// results.
MLIR_CAPI_EXPORTED bool mlirAffineMapIsIdentity(MlirAffineMap affineMap); MLIR_CAPI_EXPORTED bool mlirAffineMapIsIdentity(MlirAffineMap affineMap);
/// Checks whether the given affine map is a minor identity affine map. /// Checks whether the given affine map is a minor identity affine map.
@ -116,12 +115,12 @@ MLIR_CAPI_EXPORTED bool mlirAffineMapIsMinorIdentity(MlirAffineMap affineMap);
/// Checks whether the given affine map is an empty affine map. /// Checks whether the given affine map is an empty affine map.
MLIR_CAPI_EXPORTED bool mlirAffineMapIsEmpty(MlirAffineMap affineMap); MLIR_CAPI_EXPORTED bool mlirAffineMapIsEmpty(MlirAffineMap affineMap);
/** Checks whether the given affine map is a single result constant affine /// Checks whether the given affine map is a single result constant affine
* map. */ /// map.
MLIR_CAPI_EXPORTED bool mlirAffineMapIsSingleConstant(MlirAffineMap affineMap); MLIR_CAPI_EXPORTED bool mlirAffineMapIsSingleConstant(MlirAffineMap affineMap);
/** Returns the constant result of the given affine map. The function asserts /// Returns the constant result of the given affine map. The function asserts
* that the map has a single constant result. */ /// that the map has a single constant result.
MLIR_CAPI_EXPORTED int64_t MLIR_CAPI_EXPORTED int64_t
mlirAffineMapGetSingleConstantResult(MlirAffineMap affineMap); mlirAffineMapGetSingleConstantResult(MlirAffineMap affineMap);
@ -138,17 +137,17 @@ MLIR_CAPI_EXPORTED intptr_t mlirAffineMapGetNumResults(MlirAffineMap affineMap);
MLIR_CAPI_EXPORTED MlirAffineExpr MLIR_CAPI_EXPORTED MlirAffineExpr
mlirAffineMapGetResult(MlirAffineMap affineMap, intptr_t pos); mlirAffineMapGetResult(MlirAffineMap affineMap, intptr_t pos);
/** Returns the number of inputs (dimensions + symbols) of the given affine /// Returns the number of inputs (dimensions + symbols) of the given affine
* map. */ /// map.
MLIR_CAPI_EXPORTED intptr_t mlirAffineMapGetNumInputs(MlirAffineMap affineMap); MLIR_CAPI_EXPORTED intptr_t mlirAffineMapGetNumInputs(MlirAffineMap affineMap);
/** Checks whether the given affine map represents a subset of a symbol-less /// Checks whether the given affine map represents a subset of a symbol-less
* permutation map. */ /// permutation map.
MLIR_CAPI_EXPORTED bool MLIR_CAPI_EXPORTED bool
mlirAffineMapIsProjectedPermutation(MlirAffineMap affineMap); mlirAffineMapIsProjectedPermutation(MlirAffineMap affineMap);
/** Checks whether the given affine map represents a symbol-less permutation /// Checks whether the given affine map represents a symbol-less permutation
* map. */ /// map.
MLIR_CAPI_EXPORTED bool mlirAffineMapIsPermutation(MlirAffineMap affineMap); MLIR_CAPI_EXPORTED bool mlirAffineMapIsPermutation(MlirAffineMap affineMap);
/// Returns the affine map consisting of the `resultPos` subset. /// Returns the affine map consisting of the `resultPos` subset.
@ -156,17 +155,17 @@ MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapGetSubMap(MlirAffineMap affineMap,
intptr_t size, intptr_t size,
intptr_t *resultPos); intptr_t *resultPos);
/** Returns the affine map consisting of the most major `numResults` results. /// Returns the affine map consisting of the most major `numResults` results.
* Returns the null AffineMap if the `numResults` is equal to zero. /// Returns the null AffineMap if the `numResults` is equal to zero.
* Returns the `affineMap` if `numResults` is greater or equals to number of /// Returns the `affineMap` if `numResults` is greater or equals to number of
* results of the given affine map. */ /// results of the given affine map.
MLIR_CAPI_EXPORTED MlirAffineMap MLIR_CAPI_EXPORTED MlirAffineMap
mlirAffineMapGetMajorSubMap(MlirAffineMap affineMap, intptr_t numResults); mlirAffineMapGetMajorSubMap(MlirAffineMap affineMap, intptr_t numResults);
/** Returns the affine map consisting of the most minor `numResults` results. /// Returns the affine map consisting of the most minor `numResults` results.
* Returns the null AffineMap if the `numResults` is equal to zero. /// Returns the null AffineMap if the `numResults` is equal to zero.
* Returns the `affineMap` if `numResults` is greater or equals to number of /// Returns the `affineMap` if `numResults` is greater or equals to number of
* results of the given affine map. */ /// results of the given affine map.
MLIR_CAPI_EXPORTED MlirAffineMap MLIR_CAPI_EXPORTED MlirAffineMap
mlirAffineMapGetMinorSubMap(MlirAffineMap affineMap, intptr_t numResults); mlirAffineMapGetMinorSubMap(MlirAffineMap affineMap, intptr_t numResults);

View File

@ -29,8 +29,8 @@ extern "C" {
/// Checks whether the given attribute is an affine map attribute. /// Checks whether the given attribute is an affine map attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsAAffineMap(MlirAttribute attr); MLIR_CAPI_EXPORTED bool mlirAttributeIsAAffineMap(MlirAttribute attr);
/** Creates an affine map attribute wrapping the given map. The attribute /// Creates an affine map attribute wrapping the given map. The attribute
* belongs to the same context as the affine map. */ /// belongs to the same context as the affine map.
MLIR_CAPI_EXPORTED MlirAttribute mlirAffineMapAttrGet(MlirAffineMap map); MLIR_CAPI_EXPORTED MlirAttribute mlirAffineMapAttrGet(MlirAffineMap map);
/// Returns the affine map wrapped in the given affine map attribute. /// Returns the affine map wrapped in the given affine map attribute.
@ -43,8 +43,8 @@ MLIR_CAPI_EXPORTED MlirAffineMap mlirAffineMapAttrGetValue(MlirAttribute attr);
/// Checks whether the given attribute is an array attribute. /// Checks whether the given attribute is an array attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsAArray(MlirAttribute attr); MLIR_CAPI_EXPORTED bool mlirAttributeIsAArray(MlirAttribute attr);
/** Creates an array element containing the given list of elements in the given /// Creates an array element containing the given list of elements in the given
* context. */ /// context.
MLIR_CAPI_EXPORTED MlirAttribute mlirArrayAttrGet( MLIR_CAPI_EXPORTED MlirAttribute mlirArrayAttrGet(
MlirContext ctx, intptr_t numElements, MlirAttribute const *elements); MlirContext ctx, intptr_t numElements, MlirAttribute const *elements);
@ -62,8 +62,8 @@ MLIR_CAPI_EXPORTED MlirAttribute mlirArrayAttrGetElement(MlirAttribute attr,
/// Checks whether the given attribute is a dictionary attribute. /// Checks whether the given attribute is a dictionary attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsADictionary(MlirAttribute attr); MLIR_CAPI_EXPORTED bool mlirAttributeIsADictionary(MlirAttribute attr);
/** Creates a dictionary attribute containing the given list of elements in the /// Creates a dictionary attribute containing the given list of elements in the
* provided context. */ /// provided context.
MLIR_CAPI_EXPORTED MlirAttribute mlirDictionaryAttrGet( MLIR_CAPI_EXPORTED MlirAttribute mlirDictionaryAttrGet(
MlirContext ctx, intptr_t numElements, MlirNamedAttribute const *elements); MlirContext ctx, intptr_t numElements, MlirNamedAttribute const *elements);
@ -75,8 +75,8 @@ mlirDictionaryAttrGetNumElements(MlirAttribute attr);
MLIR_CAPI_EXPORTED MlirNamedAttribute MLIR_CAPI_EXPORTED MlirNamedAttribute
mlirDictionaryAttrGetElement(MlirAttribute attr, intptr_t pos); mlirDictionaryAttrGetElement(MlirAttribute attr, intptr_t pos);
/** Returns the dictionary attribute element with the given name or NULL if the /// Returns the dictionary attribute element with the given name or NULL if the
* given name does not exist in the dictionary. */ /// given name does not exist in the dictionary.
MLIR_CAPI_EXPORTED MlirAttribute MLIR_CAPI_EXPORTED MlirAttribute
mlirDictionaryAttrGetElementByName(MlirAttribute attr, MlirStringRef name); mlirDictionaryAttrGetElementByName(MlirAttribute attr, MlirStringRef name);
@ -84,44 +84,44 @@ mlirDictionaryAttrGetElementByName(MlirAttribute attr, MlirStringRef name);
// Floating point attribute. // Floating point attribute.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/* TODO: add support for APFloat and APInt to LLVM IR C API, then expose the // TODO: add support for APFloat and APInt to LLVM IR C API, then expose the
* relevant functions here. */ // relevant functions here.
/// Checks whether the given attribute is a floating point attribute. /// Checks whether the given attribute is a floating point attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsAFloat(MlirAttribute attr); MLIR_CAPI_EXPORTED bool mlirAttributeIsAFloat(MlirAttribute attr);
/** Creates a floating point attribute in the given context with the given /// Creates a floating point attribute in the given context with the given
* double value and double-precision FP semantics. */ /// double value and double-precision FP semantics.
MLIR_CAPI_EXPORTED MlirAttribute mlirFloatAttrDoubleGet(MlirContext ctx, MLIR_CAPI_EXPORTED MlirAttribute mlirFloatAttrDoubleGet(MlirContext ctx,
MlirType type, MlirType type,
double value); double value);
/** Same as "mlirFloatAttrDoubleGet", but if the type is not valid for a /// Same as "mlirFloatAttrDoubleGet", but if the type is not valid for a
* construction of a FloatAttr, returns a null MlirAttribute. */ /// construction of a FloatAttr, returns a null MlirAttribute.
MLIR_CAPI_EXPORTED MlirAttribute MLIR_CAPI_EXPORTED MlirAttribute
mlirFloatAttrDoubleGetChecked(MlirType type, double value, MlirLocation loc); mlirFloatAttrDoubleGetChecked(MlirType type, double value, MlirLocation loc);
/** Returns the value stored in the given floating point attribute, interpreting /// Returns the value stored in the given floating point attribute, interpreting
* the value as double. */ /// the value as double.
MLIR_CAPI_EXPORTED double mlirFloatAttrGetValueDouble(MlirAttribute attr); MLIR_CAPI_EXPORTED double mlirFloatAttrGetValueDouble(MlirAttribute attr);
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// Integer attribute. // Integer attribute.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/* TODO: add support for APFloat and APInt to LLVM IR C API, then expose the // TODO: add support for APFloat and APInt to LLVM IR C API, then expose the
* relevant functions here. */ // relevant functions here.
/// Checks whether the given attribute is an integer attribute. /// Checks whether the given attribute is an integer attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsAInteger(MlirAttribute attr); MLIR_CAPI_EXPORTED bool mlirAttributeIsAInteger(MlirAttribute attr);
/** Creates an integer attribute of the given type with the given integer /// Creates an integer attribute of the given type with the given integer
* value. */ /// value.
MLIR_CAPI_EXPORTED MlirAttribute mlirIntegerAttrGet(MlirType type, MLIR_CAPI_EXPORTED MlirAttribute mlirIntegerAttrGet(MlirType type,
int64_t value); int64_t value);
/** Returns the value stored in the given integer attribute, assuming the value /// Returns the value stored in the given integer attribute, assuming the value
* fits into a 64-bit integer. */ /// fits into a 64-bit integer.
MLIR_CAPI_EXPORTED int64_t mlirIntegerAttrGetValueInt(MlirAttribute attr); MLIR_CAPI_EXPORTED int64_t mlirIntegerAttrGetValueInt(MlirAttribute attr);
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -151,20 +151,20 @@ MLIR_CAPI_EXPORTED bool mlirAttributeIsAIntegerSet(MlirAttribute attr);
/// Checks whether the given attribute is an opaque attribute. /// Checks whether the given attribute is an opaque attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsAOpaque(MlirAttribute attr); MLIR_CAPI_EXPORTED bool mlirAttributeIsAOpaque(MlirAttribute attr);
/** Creates an opaque attribute in the given context associated with the dialect /// Creates an opaque attribute in the given context associated with the dialect
* identified by its namespace. The attribute contains opaque byte data of the /// identified by its namespace. The attribute contains opaque byte data of the
* specified length (data need not be null-terminated). */ /// specified length (data need not be null-terminated).
MLIR_CAPI_EXPORTED MlirAttribute MLIR_CAPI_EXPORTED MlirAttribute
mlirOpaqueAttrGet(MlirContext ctx, MlirStringRef dialectNamespace, mlirOpaqueAttrGet(MlirContext ctx, MlirStringRef dialectNamespace,
intptr_t dataLength, const char *data, MlirType type); intptr_t dataLength, const char *data, MlirType type);
/** Returns the namespace of the dialect with which the given opaque attribute /// Returns the namespace of the dialect with which the given opaque attribute
* is associated. The namespace string is owned by the context. */ /// is associated. The namespace string is owned by the context.
MLIR_CAPI_EXPORTED MlirStringRef MLIR_CAPI_EXPORTED MlirStringRef
mlirOpaqueAttrGetDialectNamespace(MlirAttribute attr); mlirOpaqueAttrGetDialectNamespace(MlirAttribute attr);
/** Returns the raw data as a string reference. The data remains live as long as /// Returns the raw data as a string reference. The data remains live as long as
* the context in which the attribute lives. */ /// the context in which the attribute lives.
MLIR_CAPI_EXPORTED MlirStringRef mlirOpaqueAttrGetData(MlirAttribute attr); MLIR_CAPI_EXPORTED MlirStringRef mlirOpaqueAttrGetData(MlirAttribute attr);
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -174,18 +174,18 @@ MLIR_CAPI_EXPORTED MlirStringRef mlirOpaqueAttrGetData(MlirAttribute attr);
/// Checks whether the given attribute is a string attribute. /// Checks whether the given attribute is a string attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsAString(MlirAttribute attr); MLIR_CAPI_EXPORTED bool mlirAttributeIsAString(MlirAttribute attr);
/** Creates a string attribute in the given context containing the given string. /// Creates a string attribute in the given context containing the given string.
*/
MLIR_CAPI_EXPORTED MlirAttribute mlirStringAttrGet(MlirContext ctx, MLIR_CAPI_EXPORTED MlirAttribute mlirStringAttrGet(MlirContext ctx,
MlirStringRef str); MlirStringRef str);
/** Creates a string attribute in the given context containing the given string. /// Creates a string attribute in the given context containing the given string.
* Additionally, the attribute has the given type. */ /// Additionally, the attribute has the given type.
MLIR_CAPI_EXPORTED MlirAttribute mlirStringAttrTypedGet(MlirType type, MLIR_CAPI_EXPORTED MlirAttribute mlirStringAttrTypedGet(MlirType type,
MlirStringRef str); MlirStringRef str);
/** Returns the attribute values as a string reference. The data remains live as /// Returns the attribute values as a string reference. The data remains live as
* long as the context in which the attribute lives. */ /// long as the context in which the attribute lives.
MLIR_CAPI_EXPORTED MlirStringRef mlirStringAttrGetValue(MlirAttribute attr); MLIR_CAPI_EXPORTED MlirStringRef mlirStringAttrGetValue(MlirAttribute attr);
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -195,25 +195,25 @@ MLIR_CAPI_EXPORTED MlirStringRef mlirStringAttrGetValue(MlirAttribute attr);
/// Checks whether the given attribute is a symbol reference attribute. /// Checks whether the given attribute is a symbol reference attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsASymbolRef(MlirAttribute attr); MLIR_CAPI_EXPORTED bool mlirAttributeIsASymbolRef(MlirAttribute attr);
/** Creates a symbol reference attribute in the given context referencing a /// Creates a symbol reference attribute in the given context referencing a
* symbol identified by the given string inside a list of nested references. /// symbol identified by the given string inside a list of nested references.
* Each of the references in the list must not be nested. */ /// Each of the references in the list must not be nested.
MLIR_CAPI_EXPORTED MlirAttribute MLIR_CAPI_EXPORTED MlirAttribute
mlirSymbolRefAttrGet(MlirContext ctx, MlirStringRef symbol, mlirSymbolRefAttrGet(MlirContext ctx, MlirStringRef symbol,
intptr_t numReferences, MlirAttribute const *references); intptr_t numReferences, MlirAttribute const *references);
/** Returns the string reference to the root referenced symbol. The data remains /// Returns the string reference to the root referenced symbol. The data remains
* live as long as the context in which the attribute lives. */ /// live as long as the context in which the attribute lives.
MLIR_CAPI_EXPORTED MlirStringRef MLIR_CAPI_EXPORTED MlirStringRef
mlirSymbolRefAttrGetRootReference(MlirAttribute attr); mlirSymbolRefAttrGetRootReference(MlirAttribute attr);
/** Returns the string reference to the leaf referenced symbol. The data remains /// Returns the string reference to the leaf referenced symbol. The data remains
* live as long as the context in which the attribute lives. */ /// live as long as the context in which the attribute lives.
MLIR_CAPI_EXPORTED MlirStringRef MLIR_CAPI_EXPORTED MlirStringRef
mlirSymbolRefAttrGetLeafReference(MlirAttribute attr); mlirSymbolRefAttrGetLeafReference(MlirAttribute attr);
/** Returns the number of references nested in the given symbol reference /// Returns the number of references nested in the given symbol reference
* attribute. */ /// attribute.
MLIR_CAPI_EXPORTED intptr_t MLIR_CAPI_EXPORTED intptr_t
mlirSymbolRefAttrGetNumNestedReferences(MlirAttribute attr); mlirSymbolRefAttrGetNumNestedReferences(MlirAttribute attr);
@ -228,13 +228,13 @@ mlirSymbolRefAttrGetNestedReference(MlirAttribute attr, intptr_t pos);
/// Checks whether the given attribute is a flat symbol reference attribute. /// Checks whether the given attribute is a flat symbol reference attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsAFlatSymbolRef(MlirAttribute attr); MLIR_CAPI_EXPORTED bool mlirAttributeIsAFlatSymbolRef(MlirAttribute attr);
/** Creates a flat symbol reference attribute in the given context referencing a /// Creates a flat symbol reference attribute in the given context referencing a
* symbol identified by the given string. */ /// symbol identified by the given string.
MLIR_CAPI_EXPORTED MlirAttribute mlirFlatSymbolRefAttrGet(MlirContext ctx, MLIR_CAPI_EXPORTED MlirAttribute mlirFlatSymbolRefAttrGet(MlirContext ctx,
MlirStringRef symbol); MlirStringRef symbol);
/** Returns the referenced symbol as a string reference. The data remains live /// Returns the referenced symbol as a string reference. The data remains live
* as long as the context in which the attribute lives. */ /// as long as the context in which the attribute lives.
MLIR_CAPI_EXPORTED MlirStringRef MLIR_CAPI_EXPORTED MlirStringRef
mlirFlatSymbolRefAttrGetValue(MlirAttribute attr); mlirFlatSymbolRefAttrGetValue(MlirAttribute attr);
@ -245,8 +245,8 @@ mlirFlatSymbolRefAttrGetValue(MlirAttribute attr);
/// Checks whether the given attribute is a type attribute. /// Checks whether the given attribute is a type attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsAType(MlirAttribute attr); MLIR_CAPI_EXPORTED bool mlirAttributeIsAType(MlirAttribute attr);
/** Creates a type attribute wrapping the given type in the same context as the /// Creates a type attribute wrapping the given type in the same context as the
* type. */ /// type.
MLIR_CAPI_EXPORTED MlirAttribute mlirTypeAttrGet(MlirType type); MLIR_CAPI_EXPORTED MlirAttribute mlirTypeAttrGet(MlirType type);
/// Returns the type stored in the given type attribute. /// Returns the type stored in the given type attribute.
@ -274,14 +274,14 @@ MLIR_CAPI_EXPORTED MlirAttribute mlirElementsAttrGetValue(MlirAttribute attr,
intptr_t rank, intptr_t rank,
uint64_t *idxs); uint64_t *idxs);
/** Checks whether the given rank-dimensional index is valid in the given /// Checks whether the given rank-dimensional index is valid in the given
* elements attribute. */ /// elements attribute.
MLIR_CAPI_EXPORTED bool MLIR_CAPI_EXPORTED bool
mlirElementsAttrIsValidIndex(MlirAttribute attr, intptr_t rank, uint64_t *idxs); mlirElementsAttrIsValidIndex(MlirAttribute attr, intptr_t rank, uint64_t *idxs);
/** Gets the total number of elements in the given elements attribute. In order /// Gets the total number of elements in the given elements attribute. In order
* to iterate over the attribute, obtain its type, which must be a statically /// to iterate over the attribute, obtain its type, which must be a statically
* shaped type and use its sizes to build a multi-dimensional index. */ /// shaped type and use its sizes to build a multi-dimensional index.
MLIR_CAPI_EXPORTED int64_t mlirElementsAttrGetNumElements(MlirAttribute attr); MLIR_CAPI_EXPORTED int64_t mlirElementsAttrGetNumElements(MlirAttribute attr);
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -289,21 +289,21 @@ MLIR_CAPI_EXPORTED int64_t mlirElementsAttrGetNumElements(MlirAttribute attr);
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// TODO: decide on the interface and add support for complex elements. // TODO: decide on the interface and add support for complex elements.
/* TODO: add support for APFloat and APInt to LLVM IR C API, then expose the // TODO: add support for APFloat and APInt to LLVM IR C API, then expose the
* relevant functions here. */ // relevant functions here.
/// Checks whether the given attribute is a dense elements attribute. /// Checks whether the given attribute is a dense elements attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseElements(MlirAttribute attr); MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseElements(MlirAttribute attr);
MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseIntElements(MlirAttribute attr); MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseIntElements(MlirAttribute attr);
MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseFPElements(MlirAttribute attr); MLIR_CAPI_EXPORTED bool mlirAttributeIsADenseFPElements(MlirAttribute attr);
/** Creates a dense elements attribute with the given Shaped type and elements /// Creates a dense elements attribute with the given Shaped type and elements
* in the same context as the type. */ /// in the same context as the type.
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrGet( MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrGet(
MlirType shapedType, intptr_t numElements, MlirAttribute const *elements); MlirType shapedType, intptr_t numElements, MlirAttribute const *elements);
/** Creates a dense elements attribute with the given Shaped type containing a /// Creates a dense elements attribute with the given Shaped type containing a
* single replicated element (splat). */ /// single replicated element (splat).
MLIR_CAPI_EXPORTED MlirAttribute MLIR_CAPI_EXPORTED MlirAttribute
mlirDenseElementsAttrSplatGet(MlirType shapedType, MlirAttribute element); mlirDenseElementsAttrSplatGet(MlirType shapedType, MlirAttribute element);
MLIR_CAPI_EXPORTED MlirAttribute MLIR_CAPI_EXPORTED MlirAttribute
@ -321,9 +321,9 @@ mlirDenseElementsAttrFloatSplatGet(MlirType shapedType, float element);
MLIR_CAPI_EXPORTED MlirAttribute MLIR_CAPI_EXPORTED MlirAttribute
mlirDenseElementsAttrDoubleSplatGet(MlirType shapedType, double element); mlirDenseElementsAttrDoubleSplatGet(MlirType shapedType, double element);
/** Creates a dense elements attribute with the given shaped type from elements /// Creates a dense elements attribute with the given shaped type from elements
* of a specific type. Expects the element type of the shaped type to match the /// of a specific type. Expects the element type of the shaped type to match the
* data element type. */ /// data element type.
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrBoolGet( MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrBoolGet(
MlirType shapedType, intptr_t numElements, const int *elements); MlirType shapedType, intptr_t numElements, const int *elements);
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrUInt32Get( MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrUInt32Get(
@ -339,23 +339,23 @@ MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrFloatGet(
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrDoubleGet( MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrDoubleGet(
MlirType shapedType, intptr_t numElements, const double *elements); MlirType shapedType, intptr_t numElements, const double *elements);
/** Creates a dense elements attribute with the given shaped type from string /// Creates a dense elements attribute with the given shaped type from string
* elements. */ /// elements.
MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrStringGet( MLIR_CAPI_EXPORTED MlirAttribute mlirDenseElementsAttrStringGet(
MlirType shapedType, intptr_t numElements, MlirStringRef *strs); MlirType shapedType, intptr_t numElements, MlirStringRef *strs);
/** Creates a dense elements attribute that has the same data as the given dense /// Creates a dense elements attribute that has the same data as the given dense
* elements attribute and a different shaped type. The new type must have the /// elements attribute and a different shaped type. The new type must have the
* same total number of elements. */ /// same total number of elements.
MLIR_CAPI_EXPORTED MlirAttribute MLIR_CAPI_EXPORTED MlirAttribute
mlirDenseElementsAttrReshapeGet(MlirAttribute attr, MlirType shapedType); mlirDenseElementsAttrReshapeGet(MlirAttribute attr, MlirType shapedType);
/** Checks whether the given dense elements attribute contains a single /// Checks whether the given dense elements attribute contains a single
* replicated value (splat). */ /// replicated value (splat).
MLIR_CAPI_EXPORTED bool mlirDenseElementsAttrIsSplat(MlirAttribute attr); MLIR_CAPI_EXPORTED bool mlirDenseElementsAttrIsSplat(MlirAttribute attr);
/** Returns the single replicated value (splat) of a specific type contained by /// Returns the single replicated value (splat) of a specific type contained by
* the given dense elements attribute. */ /// the given dense elements attribute.
MLIR_CAPI_EXPORTED MlirAttribute MLIR_CAPI_EXPORTED MlirAttribute
mlirDenseElementsAttrGetSplatValue(MlirAttribute attr); mlirDenseElementsAttrGetSplatValue(MlirAttribute attr);
MLIR_CAPI_EXPORTED int MLIR_CAPI_EXPORTED int
@ -375,8 +375,8 @@ mlirDenseElementsAttrGetDoubleSplatValue(MlirAttribute attr);
MLIR_CAPI_EXPORTED MlirStringRef MLIR_CAPI_EXPORTED MlirStringRef
mlirDenseElementsAttrGetStringSplatValue(MlirAttribute attr); mlirDenseElementsAttrGetStringSplatValue(MlirAttribute attr);
/** Returns the pos-th value (flat contiguous indexing) of a specific type /// Returns the pos-th value (flat contiguous indexing) of a specific type
* contained by the given dense elements attribute. */ /// contained by the given dense elements attribute.
MLIR_CAPI_EXPORTED bool mlirDenseElementsAttrGetBoolValue(MlirAttribute attr, MLIR_CAPI_EXPORTED bool mlirDenseElementsAttrGetBoolValue(MlirAttribute attr,
intptr_t pos); intptr_t pos);
MLIR_CAPI_EXPORTED int32_t MLIR_CAPI_EXPORTED int32_t
@ -394,7 +394,7 @@ mlirDenseElementsAttrGetDoubleValue(MlirAttribute attr, intptr_t pos);
MLIR_CAPI_EXPORTED MlirStringRef MLIR_CAPI_EXPORTED MlirStringRef
mlirDenseElementsAttrGetStringValue(MlirAttribute attr, intptr_t pos); mlirDenseElementsAttrGetStringValue(MlirAttribute attr, intptr_t pos);
/** Returns the raw data of the given dense elements attribute. */ /// Returns the raw data of the given dense elements attribute.
MLIR_CAPI_EXPORTED const void * MLIR_CAPI_EXPORTED const void *
mlirDenseElementsAttrGetRawData(MlirAttribute attr); mlirDenseElementsAttrGetRawData(MlirAttribute attr);
@ -414,21 +414,21 @@ MLIR_CAPI_EXPORTED bool mlirAttributeIsAOpaqueElements(MlirAttribute attr);
/// Checks whether the given attribute is a sparse elements attribute. /// Checks whether the given attribute is a sparse elements attribute.
MLIR_CAPI_EXPORTED bool mlirAttributeIsASparseElements(MlirAttribute attr); MLIR_CAPI_EXPORTED bool mlirAttributeIsASparseElements(MlirAttribute attr);
/** Creates a sparse elements attribute of the given shape from a list of /// 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 /// indices and a list of associated values. Both lists are expected to be dense
* elements attributes with the same number of elements. The list of indices is /// elements attributes with the same number of elements. The list of indices is
* expected to contain 64-bit integers. The attribute is created in the same /// expected to contain 64-bit integers. The attribute is created in the same
* context as the type. */ /// context as the type.
MLIR_CAPI_EXPORTED MlirAttribute mlirSparseElementsAttribute( MLIR_CAPI_EXPORTED MlirAttribute mlirSparseElementsAttribute(
MlirType shapedType, MlirAttribute denseIndices, MlirAttribute denseValues); MlirType shapedType, MlirAttribute denseIndices, MlirAttribute denseValues);
/** Returns the dense elements attribute containing 64-bit integer indices of /// Returns the dense elements attribute containing 64-bit integer indices of
* non-null elements in the given sparse elements attribute. */ /// non-null elements in the given sparse elements attribute.
MLIR_CAPI_EXPORTED MlirAttribute MLIR_CAPI_EXPORTED MlirAttribute
mlirSparseElementsAttrGetIndices(MlirAttribute attr); mlirSparseElementsAttrGetIndices(MlirAttribute attr);
/** Returns the dense elements attribute containing the non-null elements in the /// Returns the dense elements attribute containing the non-null elements in the
* given sparse elements attribute. */ /// given sparse elements attribute.
MLIR_CAPI_EXPORTED MlirAttribute MLIR_CAPI_EXPORTED MlirAttribute
mlirSparseElementsAttrGetValues(MlirAttribute attr); mlirSparseElementsAttrGetValues(MlirAttribute attr);

View File

@ -25,18 +25,18 @@ extern "C" {
/// Checks whether the given type is an integer type. /// Checks whether the given type is an integer type.
MLIR_CAPI_EXPORTED bool mlirTypeIsAInteger(MlirType type); MLIR_CAPI_EXPORTED bool mlirTypeIsAInteger(MlirType type);
/** Creates a signless integer type of the given bitwidth in the context. The /// Creates a signless integer type of the given bitwidth in the context. The
* type is owned by the context. */ /// type is owned by the context.
MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeGet(MlirContext ctx, MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeGet(MlirContext ctx,
unsigned bitwidth); unsigned bitwidth);
/** Creates a signed integer type of the given bitwidth in the context. The type /// Creates a signed integer type of the given bitwidth in the context. The type
* is owned by the context. */ /// is owned by the context.
MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeSignedGet(MlirContext ctx, MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeSignedGet(MlirContext ctx,
unsigned bitwidth); unsigned bitwidth);
/** Creates an unsigned integer type of the given bitwidth in the context. The /// Creates an unsigned integer type of the given bitwidth in the context. The
* type is owned by the context. */ /// type is owned by the context.
MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeUnsignedGet(MlirContext ctx, MLIR_CAPI_EXPORTED MlirType mlirIntegerTypeUnsignedGet(MlirContext ctx,
unsigned bitwidth); unsigned bitwidth);
@ -59,8 +59,8 @@ MLIR_CAPI_EXPORTED bool mlirIntegerTypeIsUnsigned(MlirType type);
/// Checks whether the given type is an index type. /// Checks whether the given type is an index type.
MLIR_CAPI_EXPORTED bool mlirTypeIsAIndex(MlirType type); MLIR_CAPI_EXPORTED bool mlirTypeIsAIndex(MlirType type);
/** Creates an index type in the given context. The type is owned by the /// Creates an index type in the given context. The type is owned by the
* context. */ /// context.
MLIR_CAPI_EXPORTED MlirType mlirIndexTypeGet(MlirContext ctx); MLIR_CAPI_EXPORTED MlirType mlirIndexTypeGet(MlirContext ctx);
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -70,29 +70,29 @@ MLIR_CAPI_EXPORTED MlirType mlirIndexTypeGet(MlirContext ctx);
/// Checks whether the given type is a bf16 type. /// Checks whether the given type is a bf16 type.
MLIR_CAPI_EXPORTED bool mlirTypeIsABF16(MlirType type); MLIR_CAPI_EXPORTED bool mlirTypeIsABF16(MlirType type);
/** Creates a bf16 type in the given context. The type is owned by the /// Creates a bf16 type in the given context. The type is owned by the
* context. */ /// context.
MLIR_CAPI_EXPORTED MlirType mlirBF16TypeGet(MlirContext ctx); MLIR_CAPI_EXPORTED MlirType mlirBF16TypeGet(MlirContext ctx);
/// Checks whether the given type is an f16 type. /// Checks whether the given type is an f16 type.
MLIR_CAPI_EXPORTED bool mlirTypeIsAF16(MlirType type); MLIR_CAPI_EXPORTED bool mlirTypeIsAF16(MlirType type);
/** Creates an f16 type in the given context. The type is owned by the /// Creates an f16 type in the given context. The type is owned by the
* context. */ /// context.
MLIR_CAPI_EXPORTED MlirType mlirF16TypeGet(MlirContext ctx); MLIR_CAPI_EXPORTED MlirType mlirF16TypeGet(MlirContext ctx);
/// Checks whether the given type is an f32 type. /// Checks whether the given type is an f32 type.
MLIR_CAPI_EXPORTED bool mlirTypeIsAF32(MlirType type); MLIR_CAPI_EXPORTED bool mlirTypeIsAF32(MlirType type);
/** Creates an f32 type in the given context. The type is owned by the /// Creates an f32 type in the given context. The type is owned by the
* context. */ /// context.
MLIR_CAPI_EXPORTED MlirType mlirF32TypeGet(MlirContext ctx); MLIR_CAPI_EXPORTED MlirType mlirF32TypeGet(MlirContext ctx);
/// Checks whether the given type is an f64 type. /// Checks whether the given type is an f64 type.
MLIR_CAPI_EXPORTED bool mlirTypeIsAF64(MlirType type); MLIR_CAPI_EXPORTED bool mlirTypeIsAF64(MlirType type);
/** Creates a f64 type in the given context. The type is owned by the /// Creates a f64 type in the given context. The type is owned by the
* context. */ /// context.
MLIR_CAPI_EXPORTED MlirType mlirF64TypeGet(MlirContext ctx); MLIR_CAPI_EXPORTED MlirType mlirF64TypeGet(MlirContext ctx);
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -102,8 +102,8 @@ MLIR_CAPI_EXPORTED MlirType mlirF64TypeGet(MlirContext ctx);
/// Checks whether the given type is a None type. /// Checks whether the given type is a None type.
MLIR_CAPI_EXPORTED bool mlirTypeIsANone(MlirType type); MLIR_CAPI_EXPORTED bool mlirTypeIsANone(MlirType type);
/** Creates a None type in the given context. The type is owned by the /// Creates a None type in the given context. The type is owned by the
* context. */ /// context.
MLIR_CAPI_EXPORTED MlirType mlirNoneTypeGet(MlirContext ctx); MLIR_CAPI_EXPORTED MlirType mlirNoneTypeGet(MlirContext ctx);
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -113,8 +113,8 @@ MLIR_CAPI_EXPORTED MlirType mlirNoneTypeGet(MlirContext ctx);
/// Checks whether the given type is a Complex type. /// Checks whether the given type is a Complex type.
MLIR_CAPI_EXPORTED bool mlirTypeIsAComplex(MlirType type); MLIR_CAPI_EXPORTED bool mlirTypeIsAComplex(MlirType type);
/** Creates a complex type with the given element type in the same context as /// Creates a complex type with the given element type in the same context as
* the element type. The type is owned by the context. */ /// the element type. The type is owned by the context.
MLIR_CAPI_EXPORTED MlirType mlirComplexTypeGet(MlirType elementType); MLIR_CAPI_EXPORTED MlirType mlirComplexTypeGet(MlirType elementType);
/// Returns the element type of the given complex type. /// Returns the element type of the given complex type.
@ -146,12 +146,12 @@ MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicDim(MlirType type, intptr_t dim);
MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDimSize(MlirType type, MLIR_CAPI_EXPORTED int64_t mlirShapedTypeGetDimSize(MlirType type,
intptr_t dim); intptr_t dim);
/** Checks whether the given value is used as a placeholder for dynamic sizes /// Checks whether the given value is used as a placeholder for dynamic sizes
* in shaped types. */ /// in shaped types.
MLIR_CAPI_EXPORTED bool 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 /// Checks whether the given value is used as a placeholder for dynamic strides
* and offsets in shaped types. */ /// and offsets in shaped types.
MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicStrideOrOffset(int64_t val); MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicStrideOrOffset(int64_t val);
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
@ -161,15 +161,15 @@ MLIR_CAPI_EXPORTED bool mlirShapedTypeIsDynamicStrideOrOffset(int64_t val);
/// Checks whether the given type is a Vector type. /// Checks whether the given type is a Vector type.
MLIR_CAPI_EXPORTED bool mlirTypeIsAVector(MlirType type); MLIR_CAPI_EXPORTED bool mlirTypeIsAVector(MlirType type);
/** Creates a vector type of the shape identified by its rank and dimensions, /// 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 /// with the given element type in the same context as the element type. The
* is owned by the context. */ /// type is owned by the context.
MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGet(intptr_t rank, MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGet(intptr_t rank,
const int64_t *shape, const int64_t *shape,
MlirType elementType); MlirType elementType);
/** Same as "mlirVectorTypeGet" but returns a nullptr wrapping MlirType on /// Same as "mlirVectorTypeGet" but returns a nullptr wrapping MlirType on
* illegal arguments, emitting appropriate diagnostics. */ /// illegal arguments, emitting appropriate diagnostics.
MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGetChecked(intptr_t rank, MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGetChecked(intptr_t rank,
const int64_t *shape, const int64_t *shape,
MlirType elementType, MlirType elementType,
@ -188,25 +188,25 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsARankedTensor(MlirType type);
/// Checks whether the given type is an unranked tensor type. /// Checks whether the given type is an unranked tensor type.
MLIR_CAPI_EXPORTED bool 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 /// 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. */ /// in the same context as the element type. The type is owned by the context.
MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGet(intptr_t rank, MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGet(intptr_t rank,
const int64_t *shape, const int64_t *shape,
MlirType elementType); MlirType elementType);
/** Same as "mlirRankedTensorTypeGet" but returns a nullptr wrapping MlirType on /// Same as "mlirRankedTensorTypeGet" but returns a nullptr wrapping MlirType on
* illegal arguments, emitting appropriate diagnostics. */ /// illegal arguments, emitting appropriate diagnostics.
MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGetChecked(intptr_t rank, MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGetChecked(intptr_t rank,
const int64_t *shape, const int64_t *shape,
MlirType elementType, MlirType elementType,
MlirLocation loc); MlirLocation loc);
/** Creates an unranked tensor type with the given element type in the same /// Creates an unranked tensor type with the given element type in the same
* context as the element type. The type is owned by the context. */ /// context as the element type. The type is owned by the context.
MLIR_CAPI_EXPORTED MlirType mlirUnrankedTensorTypeGet(MlirType elementType); MLIR_CAPI_EXPORTED MlirType mlirUnrankedTensorTypeGet(MlirType elementType);
/** Same as "mlirUnrankedTensorTypeGet" but returns a nullptr wrapping MlirType /// Same as "mlirUnrankedTensorTypeGet" but returns a nullptr wrapping MlirType
* on illegal arguments, emitting appropriate diagnostics. */ /// on illegal arguments, emitting appropriate diagnostics.
MLIR_CAPI_EXPORTED MlirType MLIR_CAPI_EXPORTED MlirType
mlirUnrankedTensorTypeGetChecked(MlirType elementType, MlirLocation loc); mlirUnrankedTensorTypeGetChecked(MlirType elementType, MlirLocation loc);
@ -220,41 +220,41 @@ MLIR_CAPI_EXPORTED bool mlirTypeIsAMemRef(MlirType type);
/// Checks whether the given type is an UnrankedMemRef type. /// Checks whether the given type is an UnrankedMemRef type.
MLIR_CAPI_EXPORTED bool mlirTypeIsAUnrankedMemRef(MlirType type); MLIR_CAPI_EXPORTED bool mlirTypeIsAUnrankedMemRef(MlirType type);
/** Creates a MemRef type with the given rank and shape, a potentially empty /// 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 /// list of affine layout maps, the given memory space and element type, in the
* same context as element type. The type is owned by the context. */ /// same context as element type. The type is owned by the context.
MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGet( MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGet(
MlirType elementType, intptr_t rank, const int64_t *shape, intptr_t numMaps, MlirType elementType, intptr_t rank, const int64_t *shape, intptr_t numMaps,
MlirAffineMap const *affineMaps, unsigned memorySpace); MlirAffineMap const *affineMaps, unsigned memorySpace);
/** Same as "mlirMemRefTypeGet" but returns a nullptr-wrapping MlirType o /// Same as "mlirMemRefTypeGet" but returns a nullptr-wrapping MlirType o
* illegal arguments, emitting appropriate diagnostics. */ /// illegal arguments, emitting appropriate diagnostics.
MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGetChecked( MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGetChecked(
MlirType elementType, intptr_t rank, const int64_t *shape, intptr_t numMaps, MlirType elementType, intptr_t rank, const int64_t *shape, intptr_t numMaps,
MlirAffineMap const *affineMaps, unsigned memorySpace, MlirLocation loc); MlirAffineMap const *affineMaps, unsigned memorySpace, MlirLocation loc);
/** Creates a MemRef type with the given rank, shape, memory space and element /// Creates a MemRef type with the given rank, shape, memory space and element
* type in the same context as the element type. The type has no affine maps, /// type in the same context as the element type. The type has no affine maps,
* i.e. represents a default row-major contiguous memref. The type is owned by /// i.e. represents a default row-major contiguous memref. The type is owned by
* the context. */ /// the context.
MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeContiguousGet(MlirType elementType, MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeContiguousGet(MlirType elementType,
intptr_t rank, intptr_t rank,
const int64_t *shape, const int64_t *shape,
unsigned memorySpace); unsigned memorySpace);
/** Same as "mlirMemRefTypeContiguousGet" but returns a nullptr wrapping /// Same as "mlirMemRefTypeContiguousGet" but returns a nullptr wrapping
* MlirType on illegal arguments, emitting appropriate diagnostics. */ /// MlirType on illegal arguments, emitting appropriate diagnostics.
MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeContiguousGetChecked( MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeContiguousGetChecked(
MlirType elementType, intptr_t rank, const int64_t *shape, MlirType elementType, intptr_t rank, const int64_t *shape,
unsigned memorySpace, MlirLocation loc); unsigned memorySpace, MlirLocation loc);
/** Creates an Unranked MemRef type with the given element type and in the given /// Creates an Unranked MemRef type with the given element type and in the given
* memory space. The type is owned by the context of element type. */ /// memory space. The type is owned by the context of element type.
MLIR_CAPI_EXPORTED MlirType mlirUnrankedMemRefTypeGet(MlirType elementType, MLIR_CAPI_EXPORTED MlirType mlirUnrankedMemRefTypeGet(MlirType elementType,
unsigned memorySpace); unsigned memorySpace);
/** Same as "mlirUnrankedMemRefTypeGet" but returns a nullptr wrapping /// Same as "mlirUnrankedMemRefTypeGet" but returns a nullptr wrapping
* MlirType on illegal arguments, emitting appropriate diagnostics. */ /// MlirType on illegal arguments, emitting appropriate diagnostics.
MLIR_CAPI_EXPORTED MlirType mlirUnrankedMemRefTypeGetChecked( MLIR_CAPI_EXPORTED MlirType mlirUnrankedMemRefTypeGetChecked(
MlirType elementType, unsigned memorySpace, MlirLocation loc); MlirType elementType, unsigned memorySpace, MlirLocation loc);
@ -278,8 +278,8 @@ MLIR_CAPI_EXPORTED unsigned mlirUnrankedMemrefGetMemorySpace(MlirType type);
/// Checks whether the given type is a tuple type. /// Checks whether the given type is a tuple type.
MLIR_CAPI_EXPORTED bool mlirTypeIsATuple(MlirType type); MLIR_CAPI_EXPORTED bool mlirTypeIsATuple(MlirType type);
/** Creates a tuple type that consists of the given list of elemental types. The /// Creates a tuple type that consists of the given list of elemental types. The
* type is owned by the context. */ /// type is owned by the context.
MLIR_CAPI_EXPORTED MlirType mlirTupleTypeGet(MlirContext ctx, MLIR_CAPI_EXPORTED MlirType mlirTupleTypeGet(MlirContext ctx,
intptr_t numElements, intptr_t numElements,
MlirType const *elements); MlirType const *elements);

View File

@ -21,8 +21,8 @@
extern "C" { extern "C" {
#endif #endif
/** An opaque reference to a diagnostic, always owned by the diagnostics engine /// An opaque reference to a diagnostic, always owned by the diagnostics engine
* (context). Must not be stored outside of the diagnostic handler. */ /// (context). Must not be stored outside of the diagnostic handler.
struct MlirDiagnostic { struct MlirDiagnostic {
void *ptr; void *ptr;
}; };
@ -40,12 +40,12 @@ typedef enum MlirDiagnosticSeverity MlirDiagnosticSeverity;
/// Opaque identifier of a diagnostic handler, useful to detach a handler. /// Opaque identifier of a diagnostic handler, useful to detach a handler.
typedef uint64_t MlirDiagnosticHandlerID; typedef uint64_t MlirDiagnosticHandlerID;
/** Diagnostic handler type. Accepts a reference to a diagnostic, which is only /// Diagnostic handler type. Accepts a reference to a diagnostic, which is only
* guaranteed to be live during the call. The handler is passed the `userData` /// guaranteed to be live during the call. The handler is passed the `userData`
* that was provided when the handler was attached to a context. If the handler /// that was provided when the handler was attached to a context. If the handler
* processed the diagnostic completely, it is expected to return success. /// processed the diagnostic completely, it is expected to return success.
* Otherwise, it is expected to return failure to indicate that other handlers /// Otherwise, it is expected to return failure to indicate that other handlers
* should attempt to process the diagnostic. */ /// should attempt to process the diagnostic.
typedef MlirLogicalResult (*MlirDiagnosticHandler)(MlirDiagnostic, typedef MlirLogicalResult (*MlirDiagnosticHandler)(MlirDiagnostic,
void *userData); void *userData);
@ -66,31 +66,31 @@ mlirDiagnosticGetSeverity(MlirDiagnostic diagnostic);
MLIR_CAPI_EXPORTED intptr_t MLIR_CAPI_EXPORTED intptr_t
mlirDiagnosticGetNumNotes(MlirDiagnostic diagnostic); mlirDiagnosticGetNumNotes(MlirDiagnostic diagnostic);
/** Returns `pos`-th note attached to the diagnostic. Expects `pos` to be a /// Returns `pos`-th note attached to the diagnostic. Expects `pos` to be a
* valid zero-based index into the list of notes. */ /// valid zero-based index into the list of notes.
MLIR_CAPI_EXPORTED MlirDiagnostic MLIR_CAPI_EXPORTED MlirDiagnostic
mlirDiagnosticGetNote(MlirDiagnostic diagnostic, intptr_t pos); mlirDiagnosticGetNote(MlirDiagnostic diagnostic, intptr_t pos);
/** Attaches the diagnostic handler to the context. Handlers are invoked in the /// Attaches the diagnostic handler to the context. Handlers are invoked in the
* reverse order of attachment until one of them processes the diagnostic /// reverse order of attachment until one of them processes the diagnostic
* completely. When a handler is invoked it is passed the `userData` that was /// completely. When a handler is invoked it is passed the `userData` that was
* provided when it was attached. If non-NULL, `deleteUserData` is called once /// provided when it was attached. If non-NULL, `deleteUserData` is called once
* the system no longer needs to call the handler (for instance after the /// the system no longer needs to call the handler (for instance after the
* handler is detached or the context is destroyed). Returns an identifier that /// handler is detached or the context is destroyed). Returns an identifier that
* can be used to detach the handler. /// can be used to detach the handler.
*/
MLIR_CAPI_EXPORTED MlirDiagnosticHandlerID mlirContextAttachDiagnosticHandler( MLIR_CAPI_EXPORTED MlirDiagnosticHandlerID mlirContextAttachDiagnosticHandler(
MlirContext context, MlirDiagnosticHandler handler, void *userData, MlirContext context, MlirDiagnosticHandler handler, void *userData,
void (*deleteUserData)(void *)); void (*deleteUserData)(void *));
/** Detaches an attached diagnostic handler from the context given its /// Detaches an attached diagnostic handler from the context given its
* identifier. */ /// identifier.
MLIR_CAPI_EXPORTED void MLIR_CAPI_EXPORTED void
mlirContextDetachDiagnosticHandler(MlirContext context, mlirContextDetachDiagnosticHandler(MlirContext context,
MlirDiagnosticHandlerID id); MlirDiagnosticHandlerID id);
/** Emits an error at the given location through the diagnostics engine. Used /// Emits an error at the given location through the diagnostics engine. Used
* for testing purposes. */ /// for testing purposes.
MLIR_CAPI_EXPORTED void mlirEmitError(MlirLocation location, MLIR_CAPI_EXPORTED void mlirEmitError(MlirLocation location,
const char *message); const char *message);

View File

@ -28,18 +28,18 @@ extern "C" {
#endif #endif
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/** Opaque type declarations. /// Opaque type declarations.
* ///
* Types are exposed to C bindings as structs containing opaque pointers. They /// Types are exposed to C bindings as structs containing opaque pointers. They
* are not supposed to be inspected from C. This allows the underlying /// are not supposed to be inspected from C. This allows the underlying
* representation to change without affecting the API users. The use of structs /// representation to change without affecting the API users. The use of structs
* instead of typedefs enables some type safety as structs are not implicitly /// instead of typedefs enables some type safety as structs are not implicitly
* convertible to each other. /// convertible to each other.
* ///
* Instances of these types may or may not own the underlying object (most often /// Instances of these types may or may not own the underlying object (most
* only point to an IR fragment without owning it). The ownership semantics is /// often only point to an IR fragment without owning it). The ownership
* defined by how an instance of the type was obtained. /// semantics is defined by how an instance of the type was obtained.
*/
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEFINE_C_API_STRUCT(name, storage) \ #define DEFINE_C_API_STRUCT(name, storage) \
@ -64,11 +64,11 @@ DEFINE_C_API_STRUCT(MlirValue, const void);
#undef DEFINE_C_API_STRUCT #undef DEFINE_C_API_STRUCT
/** Named MLIR attribute. /// Named MLIR attribute.
* ///
* A named attribute is essentially a (name, attribute) pair where the name is /// A named attribute is essentially a (name, attribute) pair where the name is
* a string. /// a string.
*/
struct MlirNamedAttribute { struct MlirNamedAttribute {
MlirIdentifier name; MlirIdentifier name;
MlirAttribute attribute; MlirAttribute attribute;
@ -101,21 +101,21 @@ mlirContextSetAllowUnregisteredDialects(MlirContext context, bool allow);
MLIR_CAPI_EXPORTED bool MLIR_CAPI_EXPORTED bool
mlirContextGetAllowUnregisteredDialects(MlirContext context); mlirContextGetAllowUnregisteredDialects(MlirContext context);
/** Returns the number of dialects registered with the given context. A /// Returns the number of dialects registered with the given context. A
* registered dialect will be loaded if needed by the parser. */ /// registered dialect will be loaded if needed by the parser.
MLIR_CAPI_EXPORTED intptr_t MLIR_CAPI_EXPORTED intptr_t
mlirContextGetNumRegisteredDialects(MlirContext context); mlirContextGetNumRegisteredDialects(MlirContext context);
/** Returns the number of dialects loaded by the context. /// Returns the number of dialects loaded by the context.
*/
MLIR_CAPI_EXPORTED intptr_t MLIR_CAPI_EXPORTED intptr_t
mlirContextGetNumLoadedDialects(MlirContext context); mlirContextGetNumLoadedDialects(MlirContext context);
/** Gets the dialect instance owned by the given context using the dialect /// Gets the dialect instance owned by the given context using the dialect
* namespace to identify it, loads (i.e., constructs the instance of) the /// namespace to identify it, loads (i.e., constructs the instance of) the
* dialect if necessary. If the dialect is not registered with the context, /// dialect if necessary. If the dialect is not registered with the context,
* returns null. Use mlirContextLoad<Name>Dialect to load an unregistered /// returns null. Use mlirContextLoad<Name>Dialect to load an unregistered
* dialect. */ /// dialect.
MLIR_CAPI_EXPORTED MlirDialect mlirContextGetOrLoadDialect(MlirContext context, MLIR_CAPI_EXPORTED MlirDialect mlirContextGetOrLoadDialect(MlirContext context,
MlirStringRef name); MlirStringRef name);
@ -131,8 +131,8 @@ static inline bool mlirDialectIsNull(MlirDialect dialect) {
return !dialect.ptr; return !dialect.ptr;
} }
/** Checks if two dialects that belong to the same context are equal. Dialects /// Checks if two dialects that belong to the same context are equal. Dialects
* from different contexts will not compare equal. */ /// from different contexts will not compare equal.
MLIR_CAPI_EXPORTED bool mlirDialectEqual(MlirDialect dialect1, MLIR_CAPI_EXPORTED bool mlirDialectEqual(MlirDialect dialect1,
MlirDialect dialect2); MlirDialect dialect2);
@ -165,9 +165,9 @@ static inline bool mlirLocationIsNull(MlirLocation location) {
/// Checks if two locations are equal. /// Checks if two locations are equal.
MLIR_CAPI_EXPORTED bool 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 /// Prints a location by sending chunks of the string representation and
* forwarding `userData to `callback`. Note that the callback may be called /// forwarding `userData to `callback`. Note that the callback may be called
* several times with consecutive chunks of the string. */ /// several times with consecutive chunks of the string.
MLIR_CAPI_EXPORTED void mlirLocationPrint(MlirLocation location, MLIR_CAPI_EXPORTED void mlirLocationPrint(MlirLocation location,
MlirStringCallback callback, MlirStringCallback callback,
void *userData); void *userData);
@ -202,16 +202,16 @@ MLIR_CAPI_EXPORTED MlirOperation mlirModuleGetOperation(MlirModule module);
// Operation state. // Operation state.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/** An auxiliary class for constructing operations. /// An auxiliary class for constructing operations.
* ///
* This class contains all the information necessary to construct the operation. /// This class contains all the information necessary to construct the
* It owns the MlirRegions it has pointers to and does not own anything else. /// operation. It owns the MlirRegions it has pointers to and does not own
* By default, the state can be constructed from a name and location, the latter /// anything else. By default, the state can be constructed from a name and
* being also used to access the context, and has no other components. These /// location, the latter being also used to access the context, and has no other
* components can be added progressively until the operation is constructed. /// components. These components can be added progressively until the operation
* Users are not expected to rely on the internals of this class and should use /// is constructed. Users are not expected to rely on the internals of this
* mlirOperationState* functions instead. /// class and should use mlirOperationState* functions instead.
*/
struct MlirOperationState { struct MlirOperationState {
MlirStringRef name; MlirStringRef name;
MlirLocation location; MlirLocation location;
@ -265,24 +265,24 @@ mlirOperationStateEnableResultTypeInference(MlirOperationState *state);
// functions to maximize the possibility of compatibility over time. // functions to maximize the possibility of compatibility over time.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/** Creates new printing flags with defaults, intended for customization. /// Creates new printing flags with defaults, intended for customization.
* Must be freed with a call to mlirOpPrintingFlagsDestroy(). */ /// Must be freed with a call to mlirOpPrintingFlagsDestroy().
MLIR_CAPI_EXPORTED MlirOpPrintingFlags mlirOpPrintingFlagsCreate(); MLIR_CAPI_EXPORTED MlirOpPrintingFlags mlirOpPrintingFlagsCreate();
/// Destroys printing flags created with mlirOpPrintingFlagsCreate. /// Destroys printing flags created with mlirOpPrintingFlagsCreate.
MLIR_CAPI_EXPORTED void mlirOpPrintingFlagsDestroy(MlirOpPrintingFlags flags); MLIR_CAPI_EXPORTED void mlirOpPrintingFlagsDestroy(MlirOpPrintingFlags flags);
/** Enables the elision of large elements attributes by printing a lexically /// Enables the elision of large elements attributes by printing a lexically
* valid but otherwise meaningless form instead of the element data. The /// valid but otherwise meaningless form instead of the element data. The
* `largeElementLimit` is used to configure what is considered to be a "large" /// `largeElementLimit` is used to configure what is considered to be a "large"
* ElementsAttr by providing an upper limit to the number of elements. */ /// ElementsAttr by providing an upper limit to the number of elements.
MLIR_CAPI_EXPORTED void MLIR_CAPI_EXPORTED void
mlirOpPrintingFlagsElideLargeElementsAttrs(MlirOpPrintingFlags flags, mlirOpPrintingFlagsElideLargeElementsAttrs(MlirOpPrintingFlags flags,
intptr_t largeElementLimit); intptr_t largeElementLimit);
/** Enable printing of debug information. If 'prettyForm' is set to true, /// Enable printing of debug information. If 'prettyForm' is set to true,
* debug information is printed in a more readable 'pretty' form. Note: The /// debug information is printed in a more readable 'pretty' form. Note: The
* IR generated with 'prettyForm' is not parsable. */ /// IR generated with 'prettyForm' is not parsable.
MLIR_CAPI_EXPORTED void MLIR_CAPI_EXPORTED void
mlirOpPrintingFlagsEnableDebugInfo(MlirOpPrintingFlags flags, bool prettyForm); mlirOpPrintingFlagsEnableDebugInfo(MlirOpPrintingFlags flags, bool prettyForm);
@ -290,10 +290,10 @@ mlirOpPrintingFlagsEnableDebugInfo(MlirOpPrintingFlags flags, bool prettyForm);
MLIR_CAPI_EXPORTED void MLIR_CAPI_EXPORTED void
mlirOpPrintingFlagsPrintGenericOpForm(MlirOpPrintingFlags flags); mlirOpPrintingFlagsPrintGenericOpForm(MlirOpPrintingFlags flags);
/** Use local scope when printing the operation. This allows for using the /// Use local scope when printing the operation. This allows for using the
* printer in a more localized and thread-safe setting, but may not /// printer in a more localized and thread-safe setting, but may not
* necessarily be identical to what the IR will look like when dumping /// necessarily be identical to what the IR will look like when dumping
* the full module. */ /// the full module.
MLIR_CAPI_EXPORTED void MLIR_CAPI_EXPORTED void
mlirOpPrintingFlagsUseLocalScope(MlirOpPrintingFlags flags); mlirOpPrintingFlagsUseLocalScope(MlirOpPrintingFlags flags);
@ -317,20 +317,20 @@ MLIR_CAPI_EXPORTED void mlirOperationDestroy(MlirOperation op);
/// Checks whether the underlying operation is null. /// Checks whether the underlying operation is null.
static inline bool mlirOperationIsNull(MlirOperation op) { return !op.ptr; } static inline bool mlirOperationIsNull(MlirOperation op) { return !op.ptr; }
/** Checks whether two operation handles point to the same operation. This does /// Checks whether two operation handles point to the same operation. This does
* not perform deep comparison. */ /// not perform deep comparison.
MLIR_CAPI_EXPORTED bool mlirOperationEqual(MlirOperation op, MLIR_CAPI_EXPORTED bool mlirOperationEqual(MlirOperation op,
MlirOperation other); MlirOperation other);
/// Gets the name of the operation as an identifier. /// Gets the name of the operation as an identifier.
MLIR_CAPI_EXPORTED MlirIdentifier mlirOperationGetName(MlirOperation op); MLIR_CAPI_EXPORTED MlirIdentifier mlirOperationGetName(MlirOperation op);
/** Gets the block that owns this operation, returning null if the operation is /// Gets the block that owns this operation, returning null if the operation is
* not owned. */ /// not owned.
MLIR_CAPI_EXPORTED MlirBlock mlirOperationGetBlock(MlirOperation op); MLIR_CAPI_EXPORTED MlirBlock mlirOperationGetBlock(MlirOperation op);
/** Gets the operation that owns this operation, returning null if the operation /// Gets the operation that owns this operation, returning null if the operation
* is not owned. */ /// is not owned.
MLIR_CAPI_EXPORTED MlirOperation MLIR_CAPI_EXPORTED MlirOperation
mlirOperationGetParentOperation(MlirOperation op); mlirOperationGetParentOperation(MlirOperation op);
@ -341,8 +341,8 @@ MLIR_CAPI_EXPORTED intptr_t mlirOperationGetNumRegions(MlirOperation op);
MLIR_CAPI_EXPORTED MlirRegion mlirOperationGetRegion(MlirOperation op, MLIR_CAPI_EXPORTED MlirRegion mlirOperationGetRegion(MlirOperation op,
intptr_t pos); intptr_t pos);
/** Returns an operation immediately following the given operation it its /// Returns an operation immediately following the given operation it its
* enclosing block. */ /// enclosing block.
MLIR_CAPI_EXPORTED MlirOperation mlirOperationGetNextInBlock(MlirOperation op); MLIR_CAPI_EXPORTED MlirOperation mlirOperationGetNextInBlock(MlirOperation op);
/// Returns the number of operands of the operation. /// Returns the number of operands of the operation.
@ -377,26 +377,26 @@ mlirOperationGetAttribute(MlirOperation op, intptr_t pos);
MLIR_CAPI_EXPORTED MlirAttribute MLIR_CAPI_EXPORTED MlirAttribute
mlirOperationGetAttributeByName(MlirOperation op, MlirStringRef name); mlirOperationGetAttributeByName(MlirOperation op, MlirStringRef name);
/** Sets an attribute by name, replacing the existing if it exists or /// Sets an attribute by name, replacing the existing if it exists or
* adding a new one otherwise. */ /// adding a new one otherwise.
MLIR_CAPI_EXPORTED void mlirOperationSetAttributeByName(MlirOperation op, MLIR_CAPI_EXPORTED void mlirOperationSetAttributeByName(MlirOperation op,
MlirStringRef name, MlirStringRef name,
MlirAttribute attr); MlirAttribute attr);
/** Removes an attribute by name. Returns false if the attribute was not found /// Removes an attribute by name. Returns false if the attribute was not found
* and true if removed. */ /// and true if removed.
MLIR_CAPI_EXPORTED bool mlirOperationRemoveAttributeByName(MlirOperation op, MLIR_CAPI_EXPORTED bool mlirOperationRemoveAttributeByName(MlirOperation op,
MlirStringRef name); MlirStringRef name);
/** Prints an operation by sending chunks of the string representation and /// Prints an operation by sending chunks of the string representation and
* forwarding `userData to `callback`. Note that the callback may be called /// forwarding `userData to `callback`. Note that the callback may be called
* several times with consecutive chunks of the string. */ /// several times with consecutive chunks of the string.
MLIR_CAPI_EXPORTED void mlirOperationPrint(MlirOperation op, MLIR_CAPI_EXPORTED void mlirOperationPrint(MlirOperation op,
MlirStringCallback callback, MlirStringCallback callback,
void *userData); void *userData);
/** Same as mlirOperationPrint but accepts flags controlling the printing /// Same as mlirOperationPrint but accepts flags controlling the printing
* behavior. */ /// behavior.
MLIR_CAPI_EXPORTED void mlirOperationPrintWithFlags(MlirOperation op, MLIR_CAPI_EXPORTED void mlirOperationPrintWithFlags(MlirOperation op,
MlirOpPrintingFlags flags, MlirOpPrintingFlags flags,
MlirStringCallback callback, MlirStringCallback callback,
@ -428,22 +428,22 @@ MLIR_CAPI_EXPORTED MlirBlock mlirRegionGetFirstBlock(MlirRegion region);
MLIR_CAPI_EXPORTED void mlirRegionAppendOwnedBlock(MlirRegion region, MLIR_CAPI_EXPORTED void mlirRegionAppendOwnedBlock(MlirRegion region,
MlirBlock block); MlirBlock block);
/** Takes a block owned by the caller and inserts it at `pos` to the given /// Takes a block owned by the caller and inserts it at `pos` to the given
* region. This is an expensive operation that linearly scans the region, prefer /// region. This is an expensive operation that linearly scans the region,
* insertAfter/Before instead. */ /// prefer insertAfter/Before instead.
MLIR_CAPI_EXPORTED void MLIR_CAPI_EXPORTED void
mlirRegionInsertOwnedBlock(MlirRegion region, intptr_t pos, MlirBlock block); mlirRegionInsertOwnedBlock(MlirRegion region, intptr_t pos, MlirBlock block);
/** Takes a block owned by the caller and inserts it after the (non-owned) /// Takes a block owned by the caller and inserts it after the (non-owned)
* reference block in the given region. The reference block must belong to the /// reference block in the given region. The reference block must belong to the
* region. If the reference block is null, prepends the block to the region. */ /// region. If the reference block is null, prepends the block to the region.
MLIR_CAPI_EXPORTED void mlirRegionInsertOwnedBlockAfter(MlirRegion region, MLIR_CAPI_EXPORTED void mlirRegionInsertOwnedBlockAfter(MlirRegion region,
MlirBlock reference, MlirBlock reference,
MlirBlock block); MlirBlock block);
/** Takes a block owned by the caller and inserts it before the (non-owned) /// Takes a block owned by the caller and inserts it before the (non-owned)
* reference block in the given region. The reference block must belong to the /// reference block in the given region. The reference block must belong to the
* region. If the reference block is null, appends the block to the region. */ /// region. If the reference block is null, appends the block to the region.
MLIR_CAPI_EXPORTED void mlirRegionInsertOwnedBlockBefore(MlirRegion region, MLIR_CAPI_EXPORTED void mlirRegionInsertOwnedBlockBefore(MlirRegion region,
MlirBlock reference, MlirBlock reference,
MlirBlock block); MlirBlock block);
@ -452,8 +452,8 @@ MLIR_CAPI_EXPORTED void mlirRegionInsertOwnedBlockBefore(MlirRegion region,
// Block API. // Block API.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/** Creates a new empty block with the given argument types and transfers /// Creates a new empty block with the given argument types and transfers
* ownership to the caller. */ /// ownership to the caller.
MLIR_CAPI_EXPORTED MlirBlock mlirBlockCreate(intptr_t nArgs, MLIR_CAPI_EXPORTED MlirBlock mlirBlockCreate(intptr_t nArgs,
MlirType const *args); MlirType const *args);
@ -463,12 +463,12 @@ MLIR_CAPI_EXPORTED void mlirBlockDestroy(MlirBlock block);
/// Checks whether a block is null. /// Checks whether a block is null.
static inline bool mlirBlockIsNull(MlirBlock block) { return !block.ptr; } static inline bool mlirBlockIsNull(MlirBlock block) { return !block.ptr; }
/** Checks whether two blocks handles point to the same block. This does not /// Checks whether two blocks handles point to the same block. This does not
* perform deep comparison. */ /// perform deep comparison.
MLIR_CAPI_EXPORTED bool mlirBlockEqual(MlirBlock block, MlirBlock other); MLIR_CAPI_EXPORTED bool mlirBlockEqual(MlirBlock block, MlirBlock other);
/** Returns the block immediately following the given block in its parent /// Returns the block immediately following the given block in its parent
* region. */ /// region.
MLIR_CAPI_EXPORTED MlirBlock mlirBlockGetNextInRegion(MlirBlock block); MLIR_CAPI_EXPORTED MlirBlock mlirBlockGetNextInRegion(MlirBlock block);
/// Returns the first operation in the block. /// Returns the first operation in the block.
@ -481,23 +481,23 @@ MLIR_CAPI_EXPORTED MlirOperation mlirBlockGetTerminator(MlirBlock block);
MLIR_CAPI_EXPORTED void mlirBlockAppendOwnedOperation(MlirBlock block, MLIR_CAPI_EXPORTED void mlirBlockAppendOwnedOperation(MlirBlock block,
MlirOperation operation); MlirOperation operation);
/** Takes an operation owned by the caller and inserts it as `pos` to the block. /// Takes an operation owned by the caller and inserts it as `pos` to the block.
This is an expensive operation that scans the block linearly, prefer /// This is an expensive operation that scans the block linearly, prefer
insertBefore/After instead. */ /// insertBefore/After instead.
MLIR_CAPI_EXPORTED void mlirBlockInsertOwnedOperation(MlirBlock block, MLIR_CAPI_EXPORTED void mlirBlockInsertOwnedOperation(MlirBlock block,
intptr_t pos, intptr_t pos,
MlirOperation operation); MlirOperation operation);
/** Takes an operation owned by the caller and inserts it after the (non-owned) /// Takes an operation owned by the caller and inserts it after the (non-owned)
* reference operation in the given block. If the reference is null, prepends /// reference operation in the given block. If the reference is null, prepends
* the operation. Otherwise, the reference must belong to the block. */ /// the operation. Otherwise, the reference must belong to the block.
MLIR_CAPI_EXPORTED void MLIR_CAPI_EXPORTED void
mlirBlockInsertOwnedOperationAfter(MlirBlock block, MlirOperation reference, mlirBlockInsertOwnedOperationAfter(MlirBlock block, MlirOperation reference,
MlirOperation operation); MlirOperation operation);
/** Takes an operation owned by the caller and inserts it before the (non-owned) /// Takes an operation owned by the caller and inserts it before the (non-owned)
* reference operation in the given block. If the reference is null, appends the /// reference operation in the given block. If the reference is null, appends
* operation. Otherwise, the reference must belong to the block. */ /// the operation. Otherwise, the reference must belong to the block.
MLIR_CAPI_EXPORTED void MLIR_CAPI_EXPORTED void
mlirBlockInsertOwnedOperationBefore(MlirBlock block, MlirOperation reference, mlirBlockInsertOwnedOperationBefore(MlirBlock block, MlirOperation reference,
MlirOperation operation); MlirOperation operation);
@ -509,9 +509,9 @@ MLIR_CAPI_EXPORTED intptr_t mlirBlockGetNumArguments(MlirBlock block);
MLIR_CAPI_EXPORTED MlirValue mlirBlockGetArgument(MlirBlock block, MLIR_CAPI_EXPORTED MlirValue mlirBlockGetArgument(MlirBlock block,
intptr_t pos); intptr_t pos);
/** Prints a block by sending chunks of the string representation and /// Prints a block by sending chunks of the string representation and
* forwarding `userData to `callback`. Note that the callback may be called /// forwarding `userData to `callback`. Note that the callback may be called
* several times with consecutive chunks of the string. */ /// several times with consecutive chunks of the string.
MLIR_CAPI_EXPORTED void MLIR_CAPI_EXPORTED void
mlirBlockPrint(MlirBlock block, MlirStringCallback callback, void *userData); mlirBlockPrint(MlirBlock block, MlirStringCallback callback, void *userData);
@ -531,8 +531,8 @@ MLIR_CAPI_EXPORTED bool mlirValueIsABlockArgument(MlirValue value);
/// Returns 1 if the value is an operation result, 0 otherwise. /// Returns 1 if the value is an operation result, 0 otherwise.
MLIR_CAPI_EXPORTED bool mlirValueIsAOpResult(MlirValue value); MLIR_CAPI_EXPORTED bool mlirValueIsAOpResult(MlirValue value);
/** Returns the block in which this value is defined as an argument. Asserts if /// Returns the block in which this value is defined as an argument. Asserts if
* the value is not a block argument. */ /// the value is not a block argument.
MLIR_CAPI_EXPORTED MlirBlock mlirBlockArgumentGetOwner(MlirValue value); MLIR_CAPI_EXPORTED MlirBlock mlirBlockArgumentGetOwner(MlirValue value);
/// Returns the position of the value in the argument list of its block. /// Returns the position of the value in the argument list of its block.
@ -542,12 +542,12 @@ MLIR_CAPI_EXPORTED intptr_t mlirBlockArgumentGetArgNumber(MlirValue value);
MLIR_CAPI_EXPORTED void mlirBlockArgumentSetType(MlirValue value, MLIR_CAPI_EXPORTED void mlirBlockArgumentSetType(MlirValue value,
MlirType type); MlirType type);
/** Returns an operation that produced this value as its result. Asserts if the /// Returns an operation that produced this value as its result. Asserts if the
* value is not an op result. */ /// value is not an op result.
MLIR_CAPI_EXPORTED MlirOperation mlirOpResultGetOwner(MlirValue value); MLIR_CAPI_EXPORTED MlirOperation mlirOpResultGetOwner(MlirValue value);
/** Returns the position of the value in the list of results of the operation /// Returns the position of the value in the list of results of the operation
* that produced it. */ /// that produced it.
MLIR_CAPI_EXPORTED intptr_t mlirOpResultGetResultNumber(MlirValue value); MLIR_CAPI_EXPORTED intptr_t mlirOpResultGetResultNumber(MlirValue value);
/// Returns the type of the value. /// Returns the type of the value.
@ -556,9 +556,9 @@ MLIR_CAPI_EXPORTED MlirType mlirValueGetType(MlirValue value);
/// Prints the value to the standard error stream. /// Prints the value to the standard error stream.
MLIR_CAPI_EXPORTED void mlirValueDump(MlirValue value); MLIR_CAPI_EXPORTED void mlirValueDump(MlirValue value);
/** Prints a value by sending chunks of the string representation and /// Prints a value by sending chunks of the string representation and
* forwarding `userData to `callback`. Note that the callback may be called /// forwarding `userData to `callback`. Note that the callback may be called
* several times with consecutive chunks of the string. */ /// several times with consecutive chunks of the string.
MLIR_CAPI_EXPORTED void MLIR_CAPI_EXPORTED void
mlirValuePrint(MlirValue value, MlirStringCallback callback, void *userData); mlirValuePrint(MlirValue value, MlirStringCallback callback, void *userData);
@ -579,9 +579,9 @@ static inline bool mlirTypeIsNull(MlirType type) { return !type.ptr; }
/// Checks if two types are equal. /// Checks if two types are equal.
MLIR_CAPI_EXPORTED bool mlirTypeEqual(MlirType t1, MlirType t2); MLIR_CAPI_EXPORTED bool mlirTypeEqual(MlirType t1, MlirType t2);
/** Prints a location by sending chunks of the string representation and /// Prints a location by sending chunks of the string representation and
* forwarding `userData to `callback`. Note that the callback may be called /// forwarding `userData to `callback`. Note that the callback may be called
* several times with consecutive chunks of the string. */ /// several times with consecutive chunks of the string.
MLIR_CAPI_EXPORTED void MLIR_CAPI_EXPORTED void
mlirTypePrint(MlirType type, MlirStringCallback callback, void *userData); mlirTypePrint(MlirType type, MlirStringCallback callback, void *userData);
@ -608,9 +608,9 @@ static inline bool mlirAttributeIsNull(MlirAttribute attr) { return !attr.ptr; }
/// Checks if two attributes are equal. /// Checks if two attributes are equal.
MLIR_CAPI_EXPORTED bool mlirAttributeEqual(MlirAttribute a1, MlirAttribute a2); MLIR_CAPI_EXPORTED bool mlirAttributeEqual(MlirAttribute a1, MlirAttribute a2);
/** Prints an attribute by sending chunks of the string representation and /// Prints an attribute by sending chunks of the string representation and
* forwarding `userData to `callback`. Note that the callback may be called /// forwarding `userData to `callback`. Note that the callback may be called
* several times with consecutive chunks of the string. */ /// several times with consecutive chunks of the string.
MLIR_CAPI_EXPORTED void mlirAttributePrint(MlirAttribute attr, MLIR_CAPI_EXPORTED void mlirAttributePrint(MlirAttribute attr,
MlirStringCallback callback, MlirStringCallback callback,
void *userData); void *userData);

View File

@ -22,17 +22,16 @@ extern "C" {
#endif #endif
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/** Opaque type declarations. // Opaque type declarations.
* //
* Types are exposed to C bindings as structs containing opaque pointers. They // Types are exposed to C bindings as structs containing opaque pointers. They
* are not supposed to be inspected from C. This allows the underlying // are not supposed to be inspected from C. This allows the underlying
* representation to change without affecting the API users. The use of structs // representation to change without affecting the API users. The use of structs
* instead of typedefs enables some type safety as structs are not implicitly // instead of typedefs enables some type safety as structs are not implicitly
* convertible to each other. // convertible to each other.
* //
* Instances of these types may or may not own the underlying object. The // Instances of these types may or may not own the underlying object. The
* ownership semantics is defined by how an instance of the type was obtained. // ownership semantics is defined by how an instance of the type was obtained.
*/
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
#define DEFINE_C_API_STRUCT(name, storage) \ #define DEFINE_C_API_STRUCT(name, storage) \
@ -66,42 +65,42 @@ mlirPassManagerGetAsOpPassManager(MlirPassManager passManager);
MLIR_CAPI_EXPORTED MlirLogicalResult MLIR_CAPI_EXPORTED MlirLogicalResult
mlirPassManagerRun(MlirPassManager passManager, MlirModule module); mlirPassManagerRun(MlirPassManager passManager, MlirModule module);
/** Nest an OpPassManager under the top-level PassManager, the nested /// Nest an OpPassManager under the top-level PassManager, the nested
* passmanager will only run on operations matching the provided name. /// passmanager will only run on operations matching the provided name.
* The returned OpPassManager will be destroyed when the parent is destroyed. /// The returned OpPassManager will be destroyed when the parent is destroyed.
* To further nest more OpPassManager under the newly returned one, see /// To further nest more OpPassManager under the newly returned one, see
* `mlirOpPassManagerNest` below. */ /// `mlirOpPassManagerNest` below.
MLIR_CAPI_EXPORTED MlirOpPassManager mlirPassManagerGetNestedUnder( MLIR_CAPI_EXPORTED MlirOpPassManager mlirPassManagerGetNestedUnder(
MlirPassManager passManager, MlirStringRef operationName); MlirPassManager passManager, MlirStringRef operationName);
/** Nest an OpPassManager under the provided OpPassManager, the nested /// Nest an OpPassManager under the provided OpPassManager, the nested
* passmanager will only run on operations matching the provided name. /// passmanager will only run on operations matching the provided name.
* The returned OpPassManager will be destroyed when the parent is destroyed. */ /// The returned OpPassManager will be destroyed when the parent is destroyed.
MLIR_CAPI_EXPORTED MlirOpPassManager mlirOpPassManagerGetNestedUnder( MLIR_CAPI_EXPORTED MlirOpPassManager mlirOpPassManagerGetNestedUnder(
MlirOpPassManager passManager, MlirStringRef operationName); MlirOpPassManager passManager, MlirStringRef operationName);
/** Add a pass and transfer ownership to the provided top-level mlirPassManager. /// Add a pass and transfer ownership to the provided top-level mlirPassManager.
* If the pass is not a generic operation pass or a ModulePass, a new /// If the pass is not a generic operation pass or a ModulePass, a new
* OpPassManager is implicitly nested under the provided PassManager. */ /// OpPassManager is implicitly nested under the provided PassManager.
MLIR_CAPI_EXPORTED void mlirPassManagerAddOwnedPass(MlirPassManager passManager, MLIR_CAPI_EXPORTED void mlirPassManagerAddOwnedPass(MlirPassManager passManager,
MlirPass pass); MlirPass pass);
/** Add a pass and transfer ownership to the provided mlirOpPassManager. If the /// Add a pass and transfer ownership to the provided mlirOpPassManager. If the
* pass is not a generic operation pass or matching the type of the provided /// pass is not a generic operation pass or matching the type of the provided
* PassManager, a new OpPassManager is implicitly nested under the provided /// PassManager, a new OpPassManager is implicitly nested under the provided
* PassManager. */ /// PassManager.
MLIR_CAPI_EXPORTED void MLIR_CAPI_EXPORTED void
mlirOpPassManagerAddOwnedPass(MlirOpPassManager passManager, MlirPass pass); mlirOpPassManagerAddOwnedPass(MlirOpPassManager passManager, MlirPass pass);
/** Print a textual MLIR pass pipeline by sending chunks of the string /// Print a textual MLIR pass pipeline by sending chunks of the string
* representation and forwarding `userData to `callback`. Note that the callback /// representation and forwarding `userData to `callback`. Note that the
* may be called several times with consecutive chunks of the string. */ /// callback may be called several times with consecutive chunks of the string.
MLIR_CAPI_EXPORTED void mlirPrintPassPipeline(MlirOpPassManager passManager, MLIR_CAPI_EXPORTED void mlirPrintPassPipeline(MlirOpPassManager passManager,
MlirStringCallback callback, MlirStringCallback callback,
void *userData); void *userData);
/** Parse a textual MLIR pass pipeline and add it to the provided OpPassManager. /// Parse a textual MLIR pass pipeline and add it to the provided OpPassManager.
*/
MLIR_CAPI_EXPORTED MlirLogicalResult MLIR_CAPI_EXPORTED MlirLogicalResult
mlirParsePassPipeline(MlirOpPassManager passManager, MlirStringRef pipeline); mlirParsePassPipeline(MlirOpPassManager passManager, MlirStringRef pipeline);

View File

@ -46,18 +46,18 @@ extern "C" {
// MlirStringRef. // MlirStringRef.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/** A pointer to a sized fragment of a string, not necessarily null-terminated. /// A pointer to a sized fragment of a string, not necessarily null-terminated.
* Does not own the underlying string. This is equivalent to llvm::StringRef. /// Does not own the underlying string. This is equivalent to llvm::StringRef.
*/
struct MlirStringRef { struct MlirStringRef {
const char *data; /**< Pointer to the first symbol. */ const char *data; ///< Pointer to the first symbol.
size_t length; /**< Length of the fragment. */ size_t length; ///< Length of the fragment.
}; };
typedef struct MlirStringRef MlirStringRef; typedef struct MlirStringRef MlirStringRef;
/** Constructs a string reference from the pointer and length. The pointer need /// Constructs a string reference from the pointer and length. The pointer need
* not reference to a null-terminated string. /// not reference to a null-terminated string.
*/
inline static MlirStringRef mlirStringRefCreate(const char *str, inline static MlirStringRef mlirStringRefCreate(const char *str,
size_t length) { size_t length) {
MlirStringRef result; MlirStringRef result;
@ -66,30 +66,28 @@ inline static MlirStringRef mlirStringRefCreate(const char *str,
return result; return result;
} }
/** Constructs a string reference from a null-terminated C string. Prefer /// Constructs a string reference from a null-terminated C string. Prefer
* mlirStringRefCreate if the length of the string is known. /// mlirStringRefCreate if the length of the string is known.
*/
MLIR_CAPI_EXPORTED MlirStringRef MLIR_CAPI_EXPORTED MlirStringRef
mlirStringRefCreateFromCString(const char *str); mlirStringRefCreateFromCString(const char *str);
/** A callback for returning string references. /// A callback for returning string references.
* ///
* This function is called back by the functions that need to return a reference /// This function is called back by the functions that need to return a
* to the portion of the string with the following arguments: /// reference to the portion of the string with the following arguments:
* - an MlirStringRef representing the current portion of the string /// - an MlirStringRef representing the current portion of the string
* - a pointer to user data forwarded from the printing call. /// - a pointer to user data forwarded from the printing call.
*/
typedef void (*MlirStringCallback)(MlirStringRef, void *); typedef void (*MlirStringCallback)(MlirStringRef, void *);
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
// MlirLogicalResult. // MlirLogicalResult.
//===----------------------------------------------------------------------===// //===----------------------------------------------------------------------===//
/** A logical result value, essentially a boolean with named states. LLVM /// A logical result value, essentially a boolean with named states. LLVM
* convention for using boolean values to designate success or failure of an /// convention for using boolean values to designate success or failure of an
* operation is a moving target, so MLIR opted for an explicit class. /// operation is a moving target, so MLIR opted for an explicit class.
* Instances of MlirLogicalResult must only be inspected using the associated /// Instances of MlirLogicalResult must only be inspected using the associated
* functions. */ /// functions.
struct MlirLogicalResult { struct MlirLogicalResult {
int8_t value; int8_t value;
}; };