MLIR
20.0.0git
lib
IR
AffineMapDetail.h
Go to the documentation of this file.
1
//===- AffineMapDetail.h - MLIR Affine Map details Class --------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// This holds implementation details of AffineMap.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef AFFINEMAPDETAIL_H_
14
#define AFFINEMAPDETAIL_H_
15
16
#include "
mlir/IR/AffineExpr.h
"
17
#include "
mlir/IR/AffineMap.h
"
18
#include "
mlir/Support/StorageUniquer.h
"
19
#include "llvm/ADT/ArrayRef.h"
20
#include "llvm/Support/TrailingObjects.h"
21
22
namespace
mlir
{
23
namespace
detail {
24
25
struct
AffineMapStorage
final
26
:
public
StorageUniquer::BaseStorage
,
27
public
llvm::TrailingObjects<AffineMapStorage, AffineExpr> {
28
/// The hash key used for uniquing.
29
using
KeyTy
= std::tuple<unsigned, unsigned, ArrayRef<AffineExpr>>;
30
31
unsigned
numDims
;
32
unsigned
numSymbols
;
33
unsigned
numResults
;
34
35
MLIRContext
*
context
;
36
37
/// The affine expressions for this (multi-dimensional) map.
38
ArrayRef<AffineExpr>
results
()
const
{
39
return
{getTrailingObjects<AffineExpr>(),
numResults
};
40
}
41
42
bool
operator==
(
const
KeyTy
&key)
const
{
43
return
std::get<0>(key) ==
numDims
&& std::get<1>(key) ==
numSymbols
&&
44
std::get<2>(key) ==
results
();
45
}
46
47
// Constructs an AffineMapStorage from a key. The context must be set by the
48
// caller.
49
static
AffineMapStorage
*
50
construct
(
StorageUniquer::StorageAllocator
&allocator,
const
KeyTy
&key) {
51
auto
results
= std::get<2>(key);
52
auto
byteSize =
53
AffineMapStorage::totalSizeToAlloc<AffineExpr>(
results
.size());
54
auto
*rawMem = allocator.
allocate
(byteSize,
alignof
(
AffineMapStorage
));
55
auto
*res =
new
(rawMem)
AffineMapStorage
();
56
res->
numDims
= std::get<0>(key);
57
res->numSymbols = std::get<1>(key);
58
res->numResults =
results
.size();
59
std::uninitialized_copy(
results
.begin(),
results
.end(),
60
res->getTrailingObjects<
AffineExpr
>());
61
return
res;
62
}
63
};
64
65
}
// namespace detail
66
}
// namespace mlir
67
68
#endif
// AFFINEMAPDETAIL_H_
StorageUniquer.h
llvm::ArrayRef
Definition:
LLVM.h:48
mlir::AffineExpr
Base type for affine expression.
Definition:
AffineExpr.h:68
mlir::MLIRContext
MLIRContext is the top-level object for a collection of MLIR operations.
Definition:
MLIRContext.h:60
mlir::StorageUniquer::BaseStorage
This class acts as the base storage that all storage classes must derived from.
Definition:
StorageUniquer.h:86
mlir::StorageUniquer::StorageAllocator
This is a utility allocator used to allocate memory for instances of derived types.
Definition:
StorageUniquer.h:93
mlir::StorageUniquer::StorageAllocator::allocate
T * allocate()
Allocate an instance of the provided type.
Definition:
StorageUniquer.h:120
AffineExpr.h
AffineMap.h
mlir
Include the generated interface declarations.
Definition:
LocalAliasAnalysis.h:20
mlir::detail::AffineMapStorage
Definition:
AffineMapDetail.h:27
mlir::detail::AffineMapStorage::numDims
unsigned numDims
Definition:
AffineMapDetail.h:31
mlir::detail::AffineMapStorage::numSymbols
unsigned numSymbols
Definition:
AffineMapDetail.h:32
mlir::detail::AffineMapStorage::results
ArrayRef< AffineExpr > results() const
The affine expressions for this (multi-dimensional) map.
Definition:
AffineMapDetail.h:38
mlir::detail::AffineMapStorage::context
MLIRContext * context
Definition:
AffineMapDetail.h:35
mlir::detail::AffineMapStorage::operator==
bool operator==(const KeyTy &key) const
Definition:
AffineMapDetail.h:42
mlir::detail::AffineMapStorage::KeyTy
std::tuple< unsigned, unsigned, ArrayRef< AffineExpr > > KeyTy
The hash key used for uniquing.
Definition:
AffineMapDetail.h:29
mlir::detail::AffineMapStorage::numResults
unsigned numResults
Definition:
AffineMapDetail.h:33
mlir::detail::AffineMapStorage::construct
static AffineMapStorage * construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key)
Definition:
AffineMapDetail.h:50
Generated on Mon Dec 23 2024 16:32:15 for MLIR by
1.9.1