[mlir] NFC: Rename index_t to index_type

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
This commit is contained in:
Rainer Orth 2020-01-18 22:10:46 +01:00
parent e3d92b7442
commit 002ec79f97
7 changed files with 20 additions and 20 deletions

View File

@ -54,11 +54,11 @@ concise and structured loop nests.
i7(constant_int(7, 32)),
i13(constant_int(13, 32));
AffineLoopNestBuilder(&i, lb, ub, 3)([&]{
lb * index_t(3) + ub;
lb + index_t(3);
lb * index_type(3) + ub;
lb + index_type(3);
AffineLoopNestBuilder(&j, lb, ub, 2)([&]{
ceilDiv(index_t(31) * floorDiv(i + j * index_t(3), index_t(32)),
index_t(32));
ceilDiv(index_type(31) * floorDiv(i + j * index_type(3), index_type(32)),
index_type(32));
((f7 + f13) / f7) % f13 - f7 * f13;
((i7 + i13) / i7) % i13 - i7 * i13;
});

View File

@ -24,8 +24,8 @@ namespace mlir {
namespace edsc {
struct index_t {
explicit index_t(int64_t v) : v(v) {}
struct index_type {
explicit index_type(int64_t v) : v(v) {}
explicit operator int64_t() { return v; }
int64_t v;
};
@ -320,7 +320,7 @@ public:
/// This implicit constructor is provided to each build an eager Value for a
/// constant at the current insertion point in the IR. An implicit constructor
/// allows idiomatic expressions mixing ValueHandle and literals.
ValueHandle(index_t cst);
ValueHandle(index_type cst);
/// ValueHandle is a value type, use the default copy constructor.
ValueHandle(const ValueHandle &other) = default;

View File

@ -34,7 +34,7 @@ namespace edsc {
struct IndexHandle : public ValueHandle {
explicit IndexHandle()
: ValueHandle(ScopedContext::getBuilder().getIndexType()) {}
explicit IndexHandle(index_t v) : ValueHandle(v) {}
explicit IndexHandle(index_type v) : ValueHandle(v) {}
explicit IndexHandle(Value v) : ValueHandle(v) {
assert(v.getType() == ScopedContext::getBuilder().getIndexType() &&
"Expected index type");
@ -96,7 +96,7 @@ public:
ValueHandleArray(ArrayRef<IndexHandle> vals) {
values.append(vals.begin(), vals.end());
}
ValueHandleArray(ArrayRef<index_t> vals) {
ValueHandleArray(ArrayRef<index_type> vals) {
SmallVector<IndexHandle, 8> tmp(vals.begin(), vals.end());
values.append(tmp.begin(), tmp.end());
}

View File

@ -75,7 +75,7 @@ static SmallVector<edsc::ValueHandle, 8> clip(TransferOpTy transfer,
using namespace edsc::op;
using edsc::intrinsics::select;
IndexHandle zero(index_t(0)), one(index_t(1));
IndexHandle zero(index_type(0)), one(index_type(1));
SmallVector<edsc::ValueHandle, 8> memRefAccess(transfer.indices());
SmallVector<edsc::ValueHandle, 8> clippedScalarAccessExprs(
memRefAccess.size(), edsc::IndexHandle());

View File

@ -65,7 +65,7 @@ MLIRContext *mlir::edsc::ScopedContext::getContext() {
return getBuilder().getContext();
}
mlir::edsc::ValueHandle::ValueHandle(index_t cst) {
mlir::edsc::ValueHandle::ValueHandle(index_type cst) {
auto &b = ScopedContext::getBuilder();
auto loc = ScopedContext::getLocation();
v = b.create<ConstantIndexOp>(loc, cst.v).getResult();

View File

@ -24,7 +24,7 @@ static SmallVector<ValueHandle, 8> getMemRefSizes(Value memRef) {
if (shape[idx] == -1) {
res.push_back(ValueHandle::create<DimOp>(memRef, idx));
} else {
res.push_back(static_cast<index_t>(shape[idx]));
res.push_back(static_cast<index_type>(shape[idx]));
}
}
return res;
@ -35,7 +35,7 @@ mlir::edsc::MemRefView::MemRefView(Value v) : base(v) {
auto memrefSizeValues = getMemRefSizes(v);
for (auto &size : memrefSizeValues) {
lbs.push_back(static_cast<index_t>(0));
lbs.push_back(static_cast<index_type>(0));
ubs.push_back(size);
steps.push_back(1);
}
@ -45,8 +45,8 @@ 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_t>(0));
ubs.push_back(static_cast<index_t>(s));
lbs.push_back(static_cast<index_type>(0));
ubs.push_back(static_cast<index_type>(s));
steps.push_back(1);
}
}

View File

@ -67,11 +67,11 @@ TEST_FUNC(builder_dynamic_for_func_args) {
ValueHandle i7(constant_int(7, 32));
ValueHandle i13(constant_int(13, 32));
AffineLoopNestBuilder(&i, lb, ub, 3)([&] {
lb *index_t(3) + ub;
lb + index_t(3);
lb *index_type(3) + ub;
lb + index_type(3);
AffineLoopNestBuilder(&j, lb, ub, 2)([&] {
ceilDiv(index_t(31) * floorDiv(i + j * index_t(3), index_t(32)),
index_t(32));
ceilDiv(index_type(31) * floorDiv(i + j * index_type(3), index_type(32)),
index_type(32));
((f7 + f13) / f7) % f13 - f7 *f13;
((i7 + i13) / i7) % i13 - i7 *i13;
});
@ -411,7 +411,7 @@ TEST_FUNC(custom_ops) {
ValueHandle vh(indexType), vh20(indexType), vh21(indexType);
OperationHandle ih0, ih2;
IndexHandle m, n, M(f.getArgument(0)), N(f.getArgument(1));
IndexHandle ten(index_t(10)), twenty(index_t(20));
IndexHandle ten(index_type(10)), twenty(index_type(20));
AffineLoopNestBuilder({&m, &n}, {M, N}, {M + ten, N + twenty}, {1, 1})([&]{
vh = MY_CUSTOM_OP({m, m + n}, {indexType}, {});
ih0 = MY_CUSTOM_OP_0({m, m + n}, {});