mlir currently fails to build on Solaris:
/vol/llvm/src/llvm-project/dist/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp:78:20: error: reference to 'index_t' is ambiguous
IndexHandle zero(index_t(0)), one(index_t(1));
^
/usr/include/sys/types.h:103:16: note: candidate found by name lookup is 'index_t'
typedef short index_t;
^
/vol/llvm/src/llvm-project/dist/mlir/include/mlir/EDSC/Builders.h:27:8: note: candidate found by name lookup is 'mlir::edsc::index_t'
struct index_t {
^
and many more.
Given that POSIX reserves all identifiers ending in `_t` 2.2.2 The Name Space <https://pubs.opengroup.org/onlinepubs/9699919799/functions/V2_chap02.html>, it seems
quite unwise to use such identifiers in user code, even more so without a distinguished
prefix.
The following patch fixes this by renaming `index_t` to `index_type`.
cases.
Tested on `amd64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.
Differential Revision: https://reviews.llvm.org/D72619
53 lines
1.6 KiB
C++
53 lines
1.6 KiB
C++
//===- Helpers.cpp - MLIR Declarative Helper Functionality ----------------===//
|
|
//
|
|
// Part of the MLIR Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "mlir/EDSC/Helpers.h"
|
|
#include "mlir/Dialect/StandardOps/Ops.h"
|
|
#include "mlir/IR/AffineExpr.h"
|
|
|
|
using namespace mlir;
|
|
using namespace mlir::edsc;
|
|
|
|
static SmallVector<ValueHandle, 8> getMemRefSizes(Value memRef) {
|
|
MemRefType memRefType = memRef.getType().cast<MemRefType>();
|
|
assert(isStrided(memRefType) && "Expected strided MemRef type");
|
|
|
|
SmallVector<ValueHandle, 8> res;
|
|
res.reserve(memRefType.getShape().size());
|
|
const auto &shape = memRefType.getShape();
|
|
for (unsigned idx = 0, n = shape.size(); idx < n; ++idx) {
|
|
if (shape[idx] == -1) {
|
|
res.push_back(ValueHandle::create<DimOp>(memRef, idx));
|
|
} else {
|
|
res.push_back(static_cast<index_type>(shape[idx]));
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
|
|
mlir::edsc::MemRefView::MemRefView(Value v) : base(v) {
|
|
assert(v.getType().isa<MemRefType>() && "MemRefType expected");
|
|
|
|
auto memrefSizeValues = getMemRefSizes(v);
|
|
for (auto &size : memrefSizeValues) {
|
|
lbs.push_back(static_cast<index_type>(0));
|
|
ubs.push_back(size);
|
|
steps.push_back(1);
|
|
}
|
|
}
|
|
|
|
mlir::edsc::VectorView::VectorView(Value v) : base(v) {
|
|
auto vectorType = v.getType().cast<VectorType>();
|
|
|
|
for (auto s : vectorType.getShape()) {
|
|
lbs.push_back(static_cast<index_type>(0));
|
|
ubs.push_back(static_cast<index_type>(s));
|
|
steps.push_back(1);
|
|
}
|
|
}
|