forked from OSchip/llvm-project
Make array pointers in the CAPI const
These pointers do not need to be mutable. This has an affect that generated function signatures in the Swift bindings now use `UnsafePointer` instead of `UnsafeMutablePointer`. Reviewed By: ftynse, mehdi_amini Differential Revision: https://reviews.llvm.org/D91740
This commit is contained in:
parent
22ec72f803
commit
beb889c1ff
|
@ -224,19 +224,19 @@ MLIR_CAPI_EXPORTED MlirOperationState mlirOperationStateGet(const char *name,
|
|||
/// Adds a list of components to the operation state.
|
||||
MLIR_CAPI_EXPORTED void mlirOperationStateAddResults(MlirOperationState *state,
|
||||
intptr_t n,
|
||||
MlirType *results);
|
||||
MlirType const *results);
|
||||
MLIR_CAPI_EXPORTED void mlirOperationStateAddOperands(MlirOperationState *state,
|
||||
intptr_t n,
|
||||
MlirValue *operands);
|
||||
MlirValue const *operands);
|
||||
MLIR_CAPI_EXPORTED void
|
||||
mlirOperationStateAddOwnedRegions(MlirOperationState *state, intptr_t n,
|
||||
MlirRegion *regions);
|
||||
MlirRegion const *regions);
|
||||
MLIR_CAPI_EXPORTED void
|
||||
mlirOperationStateAddSuccessors(MlirOperationState *state, intptr_t n,
|
||||
MlirBlock *successors);
|
||||
MlirBlock const *successors);
|
||||
MLIR_CAPI_EXPORTED void
|
||||
mlirOperationStateAddAttributes(MlirOperationState *state, intptr_t n,
|
||||
MlirNamedAttribute *attributes);
|
||||
MlirNamedAttribute const *attributes);
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Op Printing flags API.
|
||||
|
@ -425,7 +425,7 @@ MLIR_CAPI_EXPORTED void mlirRegionInsertOwnedBlockBefore(MlirRegion region,
|
|||
|
||||
/** Creates a new empty block with the given argument types and transfers
|
||||
* ownership to the caller. */
|
||||
MLIR_CAPI_EXPORTED MlirBlock mlirBlockCreate(intptr_t nArgs, MlirType *args);
|
||||
MLIR_CAPI_EXPORTED MlirBlock mlirBlockCreate(intptr_t nArgs, MlirType const *args);
|
||||
|
||||
/// Takes a block owned by the caller and destroys it.
|
||||
MLIR_CAPI_EXPORTED void mlirBlockDestroy(MlirBlock block);
|
||||
|
|
|
@ -47,7 +47,7 @@ MLIR_CAPI_EXPORTED int mlirAttributeIsAArray(MlirAttribute attr);
|
|||
* context. */
|
||||
MLIR_CAPI_EXPORTED MlirAttribute mlirArrayAttrGet(MlirContext ctx,
|
||||
intptr_t numElements,
|
||||
MlirAttribute *elements);
|
||||
MlirAttribute const *elements);
|
||||
|
||||
/// Returns the number of elements stored in the given array attribute.
|
||||
MLIR_CAPI_EXPORTED intptr_t mlirArrayAttrGetNumElements(MlirAttribute attr);
|
||||
|
@ -66,7 +66,7 @@ MLIR_CAPI_EXPORTED int mlirAttributeIsADictionary(MlirAttribute attr);
|
|||
/** Creates a dictionary attribute containing the given list of elements in the
|
||||
* provided context. */
|
||||
MLIR_CAPI_EXPORTED MlirAttribute mlirDictionaryAttrGet(
|
||||
MlirContext ctx, intptr_t numElements, MlirNamedAttribute *elements);
|
||||
MlirContext ctx, intptr_t numElements, MlirNamedAttribute const *elements);
|
||||
|
||||
/// Returns the number of attributes contained in a dictionary attribute.
|
||||
MLIR_CAPI_EXPORTED intptr_t
|
||||
|
@ -207,7 +207,7 @@ MLIR_CAPI_EXPORTED int mlirAttributeIsASymbolRef(MlirAttribute attr);
|
|||
* null-terminated and its length must be specified. */
|
||||
MLIR_CAPI_EXPORTED MlirAttribute
|
||||
mlirSymbolRefAttrGet(MlirContext ctx, intptr_t length, const char *symbol,
|
||||
intptr_t numReferences, MlirAttribute *references);
|
||||
intptr_t numReferences, MlirAttribute const *references);
|
||||
|
||||
/** Returns the string reference to the root referenced symbol. The data remains
|
||||
* live as long as the context in which the attribute lives. */
|
||||
|
|
|
@ -225,7 +225,7 @@ MLIR_CAPI_EXPORTED int mlirTypeIsAUnrankedMemRef(MlirType type);
|
|||
MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGet(MlirType elementType,
|
||||
intptr_t rank, int64_t *shape,
|
||||
intptr_t numMaps,
|
||||
MlirAttribute *affineMaps,
|
||||
MlirAttribute const *affineMaps,
|
||||
unsigned memorySpace);
|
||||
|
||||
/** Creates a MemRef type with the given rank, shape, memory space and element
|
||||
|
@ -277,7 +277,7 @@ MLIR_CAPI_EXPORTED int mlirTypeIsATuple(MlirType type);
|
|||
* type is owned by the context. */
|
||||
MLIR_CAPI_EXPORTED MlirType mlirTupleTypeGet(MlirContext ctx,
|
||||
intptr_t numElements,
|
||||
MlirType *elements);
|
||||
MlirType const *elements);
|
||||
|
||||
/// Returns the number of types contained in a tuple.
|
||||
MLIR_CAPI_EXPORTED intptr_t mlirTupleTypeGetNumTypes(MlirType type);
|
||||
|
@ -295,9 +295,9 @@ MLIR_CAPI_EXPORTED int mlirTypeIsAFunction(MlirType type);
|
|||
/// Creates a function type, mapping a list of input types to result types.
|
||||
MLIR_CAPI_EXPORTED MlirType mlirFunctionTypeGet(MlirContext ctx,
|
||||
intptr_t numInputs,
|
||||
MlirType *inputs,
|
||||
MlirType const *inputs,
|
||||
intptr_t numResults,
|
||||
MlirType *results);
|
||||
MlirType const *results);
|
||||
|
||||
/// Returns the number of input types.
|
||||
MLIR_CAPI_EXPORTED intptr_t mlirFunctionTypeGetNumInputs(MlirType type);
|
||||
|
|
|
@ -188,24 +188,24 @@ MlirOperationState mlirOperationStateGet(const char *name, MlirLocation loc) {
|
|||
state->sizeName += n;
|
||||
|
||||
void mlirOperationStateAddResults(MlirOperationState *state, intptr_t n,
|
||||
MlirType *results) {
|
||||
MlirType const *results) {
|
||||
APPEND_ELEMS(MlirType, nResults, results);
|
||||
}
|
||||
|
||||
void mlirOperationStateAddOperands(MlirOperationState *state, intptr_t n,
|
||||
MlirValue *operands) {
|
||||
MlirValue const *operands) {
|
||||
APPEND_ELEMS(MlirValue, nOperands, operands);
|
||||
}
|
||||
void mlirOperationStateAddOwnedRegions(MlirOperationState *state, intptr_t n,
|
||||
MlirRegion *regions) {
|
||||
MlirRegion const *regions) {
|
||||
APPEND_ELEMS(MlirRegion, nRegions, regions);
|
||||
}
|
||||
void mlirOperationStateAddSuccessors(MlirOperationState *state, intptr_t n,
|
||||
MlirBlock *successors) {
|
||||
MlirBlock const *successors) {
|
||||
APPEND_ELEMS(MlirBlock, nSuccessors, successors);
|
||||
}
|
||||
void mlirOperationStateAddAttributes(MlirOperationState *state, intptr_t n,
|
||||
MlirNamedAttribute *attributes) {
|
||||
MlirNamedAttribute const *attributes) {
|
||||
APPEND_ELEMS(MlirNamedAttribute, nAttributes, attributes);
|
||||
}
|
||||
|
||||
|
@ -390,7 +390,7 @@ void mlirRegionDestroy(MlirRegion region) {
|
|||
// Block API.
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
MlirBlock mlirBlockCreate(intptr_t nArgs, MlirType *args) {
|
||||
MlirBlock mlirBlockCreate(intptr_t nArgs, MlirType const *args) {
|
||||
Block *b = new Block;
|
||||
for (intptr_t i = 0; i < nArgs; ++i)
|
||||
b->addArgument(unwrap(args[i]));
|
||||
|
|
|
@ -40,7 +40,7 @@ int mlirAttributeIsAArray(MlirAttribute attr) {
|
|||
}
|
||||
|
||||
MlirAttribute mlirArrayAttrGet(MlirContext ctx, intptr_t numElements,
|
||||
MlirAttribute *elements) {
|
||||
MlirAttribute const *elements) {
|
||||
SmallVector<Attribute, 8> attrs;
|
||||
return wrap(ArrayAttr::get(
|
||||
unwrapList(static_cast<size_t>(numElements), elements, attrs),
|
||||
|
@ -64,7 +64,7 @@ int mlirAttributeIsADictionary(MlirAttribute attr) {
|
|||
}
|
||||
|
||||
MlirAttribute mlirDictionaryAttrGet(MlirContext ctx, intptr_t numElements,
|
||||
MlirNamedAttribute *elements) {
|
||||
MlirNamedAttribute const *elements) {
|
||||
SmallVector<NamedAttribute, 8> attributes;
|
||||
attributes.reserve(numElements);
|
||||
for (intptr_t i = 0; i < numElements; ++i)
|
||||
|
@ -207,7 +207,7 @@ int mlirAttributeIsASymbolRef(MlirAttribute attr) {
|
|||
|
||||
MlirAttribute mlirSymbolRefAttrGet(MlirContext ctx, intptr_t length,
|
||||
const char *symbol, intptr_t numReferences,
|
||||
MlirAttribute *references) {
|
||||
MlirAttribute const *references) {
|
||||
SmallVector<FlatSymbolRefAttr, 4> refs;
|
||||
refs.reserve(numReferences);
|
||||
for (intptr_t i = 0; i < numReferences; ++i)
|
||||
|
@ -324,7 +324,7 @@ int mlirAttributeIsADenseFPElements(MlirAttribute attr) {
|
|||
|
||||
MlirAttribute mlirDenseElementsAttrGet(MlirType shapedType,
|
||||
intptr_t numElements,
|
||||
MlirAttribute *elements) {
|
||||
MlirAttribute const *elements) {
|
||||
SmallVector<Attribute, 8> attributes;
|
||||
return wrap(
|
||||
DenseElementsAttr::get(unwrap(shapedType).cast<ShapedType>(),
|
||||
|
@ -423,7 +423,7 @@ MlirAttribute mlirDenseElementsAttrDoubleGet(MlirType shapedType,
|
|||
|
||||
MlirAttribute mlirDenseElementsAttrStringGet(MlirType shapedType,
|
||||
intptr_t numElements,
|
||||
intptr_t *strLengths,
|
||||
intptr_t const *strLengths,
|
||||
const char **strs) {
|
||||
SmallVector<StringRef, 8> values;
|
||||
values.reserve(numElements);
|
||||
|
|
|
@ -221,7 +221,7 @@ MlirType mlirUnrankedTensorTypeGetChecked(MlirType elementType,
|
|||
int mlirTypeIsAMemRef(MlirType type) { return unwrap(type).isa<MemRefType>(); }
|
||||
|
||||
MlirType mlirMemRefTypeGet(MlirType elementType, intptr_t rank, int64_t *shape,
|
||||
intptr_t numMaps, MlirAffineMap *affineMaps,
|
||||
intptr_t numMaps, MlirAffineMap const *affineMaps,
|
||||
unsigned memorySpace) {
|
||||
SmallVector<AffineMap, 1> maps;
|
||||
(void)unwrapList(numMaps, affineMaps, maps);
|
||||
|
@ -285,7 +285,7 @@ unsigned mlirUnrankedMemrefGetMemorySpace(MlirType type) {
|
|||
int mlirTypeIsATuple(MlirType type) { return unwrap(type).isa<TupleType>(); }
|
||||
|
||||
MlirType mlirTupleTypeGet(MlirContext ctx, intptr_t numElements,
|
||||
MlirType *elements) {
|
||||
MlirType const *elements) {
|
||||
SmallVector<Type, 4> types;
|
||||
ArrayRef<Type> typeRef = unwrapList(numElements, elements, types);
|
||||
return wrap(TupleType::get(typeRef, unwrap(ctx)));
|
||||
|
@ -308,8 +308,8 @@ int mlirTypeIsAFunction(MlirType type) {
|
|||
}
|
||||
|
||||
MlirType mlirFunctionTypeGet(MlirContext ctx, intptr_t numInputs,
|
||||
MlirType *inputs, intptr_t numResults,
|
||||
MlirType *results) {
|
||||
MlirType const *inputs, intptr_t numResults,
|
||||
MlirType const *results) {
|
||||
SmallVector<Type, 4> inputsList;
|
||||
SmallVector<Type, 4> resultsList;
|
||||
(void)unwrapList(numInputs, inputs, inputsList);
|
||||
|
|
Loading…
Reference in New Issue