MLIR
20.0.0git
lib
IR
AffineExprDetail.h
Go to the documentation of this file.
1
//===- AffineExprDetail.h - MLIR Affine Expr storage details ----*- 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 AffineExpr. Ideally it would not be
10
// exposed and would be kept local to AffineExpr.cpp however, MLIRContext.cpp
11
// needs to know the sizes for placement-new style Allocation.
12
//
13
//===----------------------------------------------------------------------===//
14
#ifndef MLIR_IR_AFFINEEXPRDETAIL_H_
15
#define MLIR_IR_AFFINEEXPRDETAIL_H_
16
17
#include "
mlir/IR/AffineExpr.h
"
18
#include "
mlir/IR/MLIRContext.h
"
19
#include "
mlir/Support/StorageUniquer.h
"
20
21
namespace
mlir
{
22
23
class
MLIRContext;
24
25
namespace
detail {
26
27
/// Base storage class appearing in an affine expression.
28
struct
AffineExprStorage
:
public
StorageUniquer::BaseStorage
{
29
MLIRContext
*
context
;
30
AffineExprKind
kind
;
31
};
32
33
/// A binary operation appearing in an affine expression.
34
struct
AffineBinaryOpExprStorage
:
public
AffineExprStorage
{
35
using
KeyTy
= std::tuple<unsigned, AffineExpr, AffineExpr>;
36
37
bool
operator==
(
const
KeyTy
&key)
const
{
38
return
static_cast<
AffineExprKind
>
(std::get<0>(key)) ==
kind
&&
39
std::get<1>(key) ==
lhs
&& std::get<2>(key) ==
rhs
;
40
}
41
42
static
AffineBinaryOpExprStorage
*
43
construct
(
StorageUniquer::StorageAllocator
&allocator,
const
KeyTy
&key) {
44
auto
*result = allocator.
allocate
<
AffineBinaryOpExprStorage
>();
45
result->
kind
=
static_cast<
AffineExprKind
>
(std::get<0>(key));
46
result->lhs = std::get<1>(key);
47
result->rhs = std::get<2>(key);
48
result->context = result->lhs.getContext();
49
return
result;
50
}
51
52
AffineExpr
lhs
;
53
AffineExpr
rhs
;
54
};
55
56
/// A dimensional or symbolic identifier appearing in an affine expression.
57
struct
AffineDimExprStorage
:
public
AffineExprStorage
{
58
using
KeyTy
= std::pair<unsigned, unsigned>;
59
60
bool
operator==
(
const
KeyTy
&key)
const
{
61
return
kind
==
static_cast<
AffineExprKind
>
(key.first) &&
62
position
== key.second;
63
}
64
65
static
AffineDimExprStorage
*
66
construct
(
StorageUniquer::StorageAllocator
&allocator,
const
KeyTy
&key) {
67
auto
*result = allocator.
allocate
<
AffineDimExprStorage
>();
68
result->
kind
=
static_cast<
AffineExprKind
>
(key.first);
69
result->position = key.second;
70
return
result;
71
}
72
73
/// Position of this identifier in the argument list.
74
unsigned
position
;
75
};
76
77
/// An integer constant appearing in affine expression.
78
struct
AffineConstantExprStorage
:
public
AffineExprStorage
{
79
using
KeyTy
= int64_t;
80
81
bool
operator==
(
const
KeyTy
&key)
const
{
return
constant
== key; }
82
83
static
AffineConstantExprStorage
*
84
construct
(
StorageUniquer::StorageAllocator
&allocator,
const
KeyTy
&key) {
85
auto
*result = allocator.
allocate
<
AffineConstantExprStorage
>();
86
result->
kind
=
AffineExprKind::Constant
;
87
result->constant = key;
88
return
result;
89
}
90
91
// The constant.
92
int64_t
constant
;
93
};
94
95
}
// namespace detail
96
}
// namespace mlir
97
#endif
// MLIR_IR_AFFINEEXPRDETAIL_H_
MLIRContext.h
StorageUniquer.h
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
mlir
Include the generated interface declarations.
Definition:
LocalAliasAnalysis.h:20
mlir::AffineExprKind
AffineExprKind
Definition:
AffineExpr.h:40
mlir::AffineExprKind::Constant
@ Constant
Constant integer.
mlir::detail::AffineBinaryOpExprStorage
A binary operation appearing in an affine expression.
Definition:
AffineExprDetail.h:34
mlir::detail::AffineBinaryOpExprStorage::lhs
AffineExpr lhs
Definition:
AffineExprDetail.h:52
mlir::detail::AffineBinaryOpExprStorage::KeyTy
std::tuple< unsigned, AffineExpr, AffineExpr > KeyTy
Definition:
AffineExprDetail.h:35
mlir::detail::AffineBinaryOpExprStorage::operator==
bool operator==(const KeyTy &key) const
Definition:
AffineExprDetail.h:37
mlir::detail::AffineBinaryOpExprStorage::construct
static AffineBinaryOpExprStorage * construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key)
Definition:
AffineExprDetail.h:43
mlir::detail::AffineBinaryOpExprStorage::rhs
AffineExpr rhs
Definition:
AffineExprDetail.h:53
mlir::detail::AffineConstantExprStorage
An integer constant appearing in affine expression.
Definition:
AffineExprDetail.h:78
mlir::detail::AffineConstantExprStorage::construct
static AffineConstantExprStorage * construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key)
Definition:
AffineExprDetail.h:84
mlir::detail::AffineConstantExprStorage::constant
int64_t constant
Definition:
AffineExprDetail.h:92
mlir::detail::AffineConstantExprStorage::KeyTy
int64_t KeyTy
Definition:
AffineExprDetail.h:79
mlir::detail::AffineConstantExprStorage::operator==
bool operator==(const KeyTy &key) const
Definition:
AffineExprDetail.h:81
mlir::detail::AffineDimExprStorage
A dimensional or symbolic identifier appearing in an affine expression.
Definition:
AffineExprDetail.h:57
mlir::detail::AffineDimExprStorage::construct
static AffineDimExprStorage * construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key)
Definition:
AffineExprDetail.h:66
mlir::detail::AffineDimExprStorage::operator==
bool operator==(const KeyTy &key) const
Definition:
AffineExprDetail.h:60
mlir::detail::AffineDimExprStorage::position
unsigned position
Position of this identifier in the argument list.
Definition:
AffineExprDetail.h:74
mlir::detail::AffineDimExprStorage::KeyTy
std::pair< unsigned, unsigned > KeyTy
Definition:
AffineExprDetail.h:58
mlir::detail::AffineExprStorage
Base storage class appearing in an affine expression.
Definition:
AffineExprDetail.h:28
mlir::detail::AffineExprStorage::context
MLIRContext * context
Definition:
AffineExprDetail.h:29
mlir::detail::AffineExprStorage::kind
AffineExprKind kind
Definition:
AffineExprDetail.h:30
Generated on Sat Dec 21 2024 12:34:01 for MLIR by
1.9.1