2018-10-10 07:39:24 +08:00
|
|
|
//===- AffineMapDetail.h - MLIR Affine Map details Class --------*- C++ -*-===//
|
|
|
|
//
|
2020-01-26 11:58:30 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
2019-12-24 01:35:36 +08:00
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2018-10-10 07:39:24 +08:00
|
|
|
//
|
2019-12-24 01:35:36 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2018-10-10 07:39:24 +08:00
|
|
|
//
|
|
|
|
// This holds implementation details of AffineMap.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef AFFINEMAPDETAIL_H_
|
|
|
|
#define AFFINEMAPDETAIL_H_
|
|
|
|
|
|
|
|
#include "mlir/IR/AffineExpr.h"
|
|
|
|
#include "mlir/IR/AffineMap.h"
|
2021-12-03 06:49:02 +08:00
|
|
|
#include "mlir/Support/StorageUniquer.h"
|
2018-10-10 07:39:24 +08:00
|
|
|
#include "llvm/ADT/ArrayRef.h"
|
|
|
|
|
|
|
|
namespace mlir {
|
|
|
|
namespace detail {
|
|
|
|
|
2021-12-03 06:49:02 +08:00
|
|
|
struct AffineMapStorage : public StorageUniquer::BaseStorage {
|
|
|
|
/// The hash key used for uniquing.
|
|
|
|
using KeyTy = std::tuple<unsigned, unsigned, ArrayRef<AffineExpr>>;
|
|
|
|
|
2018-10-10 07:39:24 +08:00
|
|
|
unsigned numDims;
|
|
|
|
unsigned numSymbols;
|
|
|
|
|
|
|
|
/// The affine expressions for this (multi-dimensional) map.
|
|
|
|
/// TODO: use trailing objects for this.
|
|
|
|
ArrayRef<AffineExpr> results;
|
2019-08-21 01:43:45 +08:00
|
|
|
|
|
|
|
MLIRContext *context;
|
2021-12-03 06:49:02 +08:00
|
|
|
|
|
|
|
bool operator==(const KeyTy &key) const {
|
|
|
|
return std::get<0>(key) == numDims && std::get<1>(key) == numSymbols &&
|
|
|
|
std::get<2>(key) == results;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Constructs an AffineMapStorage from a key. The context must be set by the
|
|
|
|
// caller.
|
|
|
|
static AffineMapStorage *
|
|
|
|
construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key) {
|
|
|
|
auto *res = new (allocator.allocate<AffineMapStorage>()) AffineMapStorage();
|
|
|
|
res->numDims = std::get<0>(key);
|
|
|
|
res->numSymbols = std::get<1>(key);
|
|
|
|
res->results = allocator.copyInto(std::get<2>(key));
|
|
|
|
return res;
|
|
|
|
}
|
2018-10-10 07:39:24 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace detail
|
|
|
|
} // end namespace mlir
|
|
|
|
|
|
|
|
#endif // AFFINEMAPDETAIL_H_
|