Commit edcd83a6 authored by Rainer Orth's avatar Rainer Orth Committed by Hans Wennborg
Browse files

[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

(cherry picked from commit 002ec79f)
parent 50eedc13
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -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;
      });
+3 −3
Original line number Diff line number Diff line
@@ -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;
};
@@ -310,7 +310,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;
+2 −2
Original line number Diff line number Diff line
@@ -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());
  }
+1 −1
Original line number Diff line number Diff line
@@ -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());
+1 −1
Original line number Diff line number Diff line
@@ -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();
Loading