[llvm-branch-commits] [mlir] 7f52131 - Use `const` for array pointers in `StandardTypes.h`
via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Sun Nov 29 10:18:33 PST 2020
Author: George
Date: 2020-11-29T10:13:35-08:00
New Revision: 7f521318e4f7d9e64907fad8c4bd83ddc037f8c6
URL: https://github.com/llvm/llvm-project/commit/7f521318e4f7d9e64907fad8c4bd83ddc037f8c6
DIFF: https://github.com/llvm/llvm-project/commit/7f521318e4f7d9e64907fad8c4bd83ddc037f8c6.diff
LOG: Use `const` for array pointers in `StandardTypes.h`
This mirrors the underlying C++ api.
Reviewed By: mehdi_amini
Differential Revision: https://reviews.llvm.org/D92252
Added:
Modified:
mlir/include/mlir-c/StandardTypes.h
mlir/lib/CAPI/IR/StandardTypes.cpp
Removed:
################################################################################
diff --git a/mlir/include/mlir-c/StandardTypes.h b/mlir/include/mlir-c/StandardTypes.h
index 7b51ad8d6a77..9839a1946ad9 100644
--- a/mlir/include/mlir-c/StandardTypes.h
+++ b/mlir/include/mlir-c/StandardTypes.h
@@ -164,13 +164,14 @@ MLIR_CAPI_EXPORTED int mlirTypeIsAVector(MlirType type);
/** Creates a vector type of the shape identified by its rank and dimensions,
* with the given element type in the same context as the element type. The type
* is owned by the context. */
-MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGet(intptr_t rank, int64_t *shape,
+MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGet(intptr_t rank,
+ const int64_t *shape,
MlirType elementType);
/** Same as "mlirVectorTypeGet" but returns a nullptr wrapping MlirType on
* illegal arguments, emitting appropriate diagnostics. */
MLIR_CAPI_EXPORTED MlirType mlirVectorTypeGetChecked(intptr_t rank,
- int64_t *shape,
+ const int64_t *shape,
MlirType elementType,
MlirLocation loc);
@@ -190,13 +191,13 @@ MLIR_CAPI_EXPORTED int mlirTypeIsAUnrankedTensor(MlirType type);
/** Creates a tensor type of a fixed rank with the given shape and element type
* in the same context as the element type. The type is owned by the context. */
MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGet(intptr_t rank,
- int64_t *shape,
+ const int64_t *shape,
MlirType elementType);
/** Same as "mlirRankedTensorTypeGet" but returns a nullptr wrapping MlirType on
* illegal arguments, emitting appropriate diagnostics. */
MLIR_CAPI_EXPORTED MlirType mlirRankedTensorTypeGetChecked(intptr_t rank,
- int64_t *shape,
+ const int64_t *shape,
MlirType elementType,
MlirLocation loc);
@@ -222,11 +223,9 @@ MLIR_CAPI_EXPORTED int mlirTypeIsAUnrankedMemRef(MlirType type);
/** Creates a MemRef type with the given rank and shape, a potentially empty
* list of affine layout maps, the given memory space and element type, in the
* same context as element type. The type is owned by the context. */
-MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGet(MlirType elementType,
- intptr_t rank, int64_t *shape,
- intptr_t numMaps,
- MlirAttribute const *affineMaps,
- unsigned memorySpace);
+MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGet(
+ MlirType elementType, intptr_t rank, const int64_t *shape, intptr_t numMaps,
+ MlirAttribute const *affineMaps, unsigned memorySpace);
/** 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,
@@ -234,14 +233,14 @@ MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeGet(MlirType elementType,
* the context. */
MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeContiguousGet(MlirType elementType,
intptr_t rank,
- int64_t *shape,
+ const int64_t *shape,
unsigned memorySpace);
/** Same as "mlirMemRefTypeContiguousGet" but returns a nullptr wrapping
* MlirType on illegal arguments, emitting appropriate diagnostics. */
MLIR_CAPI_EXPORTED MlirType mlirMemRefTypeContiguousGetChecked(
- MlirType elementType, intptr_t rank, int64_t *shape, unsigned memorySpace,
- MlirLocation loc);
+ MlirType elementType, intptr_t rank, const int64_t *shape,
+ unsigned memorySpace, MlirLocation loc);
/** 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. */
diff --git a/mlir/lib/CAPI/IR/StandardTypes.cpp b/mlir/lib/CAPI/IR/StandardTypes.cpp
index 9253058b1c6e..1f9b56b35b4d 100644
--- a/mlir/lib/CAPI/IR/StandardTypes.cpp
+++ b/mlir/lib/CAPI/IR/StandardTypes.cpp
@@ -162,14 +162,14 @@ int mlirShapedTypeIsDynamicStrideOrOffset(int64_t val) {
int mlirTypeIsAVector(MlirType type) { return unwrap(type).isa<VectorType>(); }
-MlirType mlirVectorTypeGet(intptr_t rank, int64_t *shape,
+MlirType mlirVectorTypeGet(intptr_t rank, const int64_t *shape,
MlirType elementType) {
return wrap(
VectorType::get(llvm::makeArrayRef(shape, static_cast<size_t>(rank)),
unwrap(elementType)));
}
-MlirType mlirVectorTypeGetChecked(intptr_t rank, int64_t *shape,
+MlirType mlirVectorTypeGetChecked(intptr_t rank, const int64_t *shape,
MlirType elementType, MlirLocation loc) {
return wrap(VectorType::getChecked(
llvm::makeArrayRef(shape, static_cast<size_t>(rank)), unwrap(elementType),
@@ -190,14 +190,14 @@ int mlirTypeIsAUnrankedTensor(MlirType type) {
return unwrap(type).isa<UnrankedTensorType>();
}
-MlirType mlirRankedTensorTypeGet(intptr_t rank, int64_t *shape,
+MlirType mlirRankedTensorTypeGet(intptr_t rank, const int64_t *shape,
MlirType elementType) {
return wrap(RankedTensorType::get(
llvm::makeArrayRef(shape, static_cast<size_t>(rank)),
unwrap(elementType)));
}
-MlirType mlirRankedTensorTypeGetChecked(intptr_t rank, int64_t *shape,
+MlirType mlirRankedTensorTypeGetChecked(intptr_t rank, const int64_t *shape,
MlirType elementType,
MlirLocation loc) {
return wrap(RankedTensorType::getChecked(
@@ -220,8 +220,9 @@ 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 const *affineMaps,
+MlirType mlirMemRefTypeGet(MlirType elementType, intptr_t rank,
+ const int64_t *shape, intptr_t numMaps,
+ MlirAffineMap const *affineMaps,
unsigned memorySpace) {
SmallVector<AffineMap, 1> maps;
(void)unwrapList(numMaps, affineMaps, maps);
@@ -231,14 +232,15 @@ MlirType mlirMemRefTypeGet(MlirType elementType, intptr_t rank, int64_t *shape,
}
MlirType mlirMemRefTypeContiguousGet(MlirType elementType, intptr_t rank,
- int64_t *shape, unsigned memorySpace) {
+ const int64_t *shape,
+ unsigned memorySpace) {
return wrap(
MemRefType::get(llvm::makeArrayRef(shape, static_cast<size_t>(rank)),
unwrap(elementType), llvm::None, memorySpace));
}
MlirType mlirMemRefTypeContiguousGetChecked(MlirType elementType, intptr_t rank,
- int64_t *shape,
+ const int64_t *shape,
unsigned memorySpace,
MlirLocation loc) {
return wrap(MemRefType::getChecked(
More information about the llvm-branch-commits
mailing list