My Project
SDBMExprDetail.h
Go to the documentation of this file.
1 //===- SDBMExprDetail.h - MLIR SDBM Expression storage details --*- C++ -*-===//
2 //
3 // Part of the MLIR 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 SDBMExpr, in particular underlying
10 // storage types.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef MLIR_IR_SDBMEXPRDETAIL_H
15 #define MLIR_IR_SDBMEXPRDETAIL_H
16 
19 
20 namespace mlir {
21 
22 class SDBMDialect;
23 
24 namespace detail {
25 
26 // Base storage class for SDBMExpr.
29  return static_cast<SDBMExprKind>(BaseStorage::getKind());
30  }
31 
33 };
34 
35 // Storage class for SDBM sum and stripe expressions.
37  using KeyTy = std::pair<SDBMDirectExpr, SDBMConstantExpr>;
38 
39  bool operator==(const KeyTy &key) const {
40  return std::get<0>(key) == lhs && std::get<1>(key) == rhs;
41  }
42 
43  static SDBMBinaryExprStorage *
45  auto *result = allocator.allocate<SDBMBinaryExprStorage>();
46  result->lhs = std::get<0>(key);
47  result->rhs = std::get<1>(key);
48  result->dialect = result->lhs.getDialect();
49  return result;
50  }
51 
54 };
55 
56 // Storage class for SDBM difference expressions.
58  using KeyTy = std::pair<SDBMDirectExpr, SDBMTermExpr>;
59 
60  bool operator==(const KeyTy &key) const {
61  return std::get<0>(key) == lhs && std::get<1>(key) == rhs;
62  }
63 
64  static SDBMDiffExprStorage *
66  auto *result = allocator.allocate<SDBMDiffExprStorage>();
67  result->lhs = std::get<0>(key);
68  result->rhs = std::get<1>(key);
69  result->dialect = result->lhs.getDialect();
70  return result;
71  }
72 
75 };
76 
77 // Storage class for SDBM constant expressions.
79  using KeyTy = int64_t;
80 
81  bool operator==(const KeyTy &key) const { return constant == key; }
82 
85  auto *result = allocator.allocate<SDBMConstantExprStorage>();
86  result->constant = key;
87  return result;
88  }
89 
90  int64_t constant;
91 };
92 
93 // Storage class for SDBM dimension and symbol expressions.
95  using KeyTy = unsigned;
96 
97  bool operator==(const KeyTy &key) const { return position == key; }
98 
99  static SDBMTermExprStorage *
101  auto *result = allocator.allocate<SDBMTermExprStorage>();
102  result->position = key;
103  return result;
104  }
105 
106  unsigned position;
107 };
108 
109 // Storage class for SDBM negation expressions.
112 
113  bool operator==(const KeyTy &key) const { return key == expr; }
114 
115  static SDBMNegExprStorage *
117  auto *result = allocator.allocate<SDBMNegExprStorage>();
118  result->expr = key;
119  result->dialect = key.getDialect();
120  return result;
121  }
122 
124 };
125 
126 } // end namespace detail
127 } // end namespace mlir
128 
129 #endif // MLIR_IR_SDBMEXPRDETAIL_H
Definition: InferTypeOpInterface.cpp:20
SDBMDialect * getDialect() const
Returns the SDBM dialect instance.
Definition: SDBMExpr.cpp:148
SDBMDirectExpr lhs
Definition: SDBMExprDetail.h:73
int64_t constant
Definition: SDBMExprDetail.h:90
Definition: SDBMExprDetail.h:27
static SDBMTermExprStorage * construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key)
Definition: SDBMExprDetail.h:100
SDBMDialect * dialect
Definition: SDBMExprDetail.h:32
Definition: StorageUniquer.h:89
static SDBMBinaryExprStorage * construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key)
Definition: SDBMExprDetail.h:44
int64_t KeyTy
Definition: SDBMExprDetail.h:79
SDBMDirectExpr lhs
Definition: SDBMExprDetail.h:52
bool operator==(const KeyTy &key) const
Definition: SDBMExprDetail.h:113
std::pair< SDBMDirectExpr, SDBMTermExpr > KeyTy
Definition: SDBMExprDetail.h:58
SDBMExprKind
Definition: SDBMExpr.h:26
SDBMDirectExpr expr
Definition: SDBMExprDetail.h:123
SDBMExprKind getKind()
Definition: SDBMExprDetail.h:28
SDBM constant expression, wraps a 64-bit integer.
Definition: SDBMExpr.h:155
T * allocate()
Allocate an instance of the provided type.
Definition: StorageUniquer.h:109
Definition: SDBMExprDetail.h:57
static SDBMDiffExprStorage * construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key)
Definition: SDBMExprDetail.h:65
Definition: SDBMExprDetail.h:36
unsigned KeyTy
Definition: SDBMExprDetail.h:95
bool operator==(const KeyTy &key) const
Definition: SDBMExprDetail.h:97
bool operator==(const KeyTy &key) const
Definition: SDBMExprDetail.h:39
SDBMConstantExpr rhs
Definition: SDBMExprDetail.h:53
Definition: SDBMExprDetail.h:110
ValueBuilder< mlir::LLVM::ConstantOp > constant
Definition: LinalgToLLVM.cpp:56
bool operator==(const KeyTy &key) const
Definition: SDBMExprDetail.h:60
SDBMTermExpr rhs
Definition: SDBMExprDetail.h:74
static SDBMNegExprStorage * construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key)
Definition: SDBMExprDetail.h:116
Definition: StorageUniquer.h:71
Definition: SDBMExpr.h:197
bool operator==(const KeyTy &key) const
Definition: SDBMExprDetail.h:81
unsigned position
Definition: SDBMExprDetail.h:106
Definition: SDBMExprDetail.h:94
std::pair< SDBMDirectExpr, SDBMConstantExpr > KeyTy
Definition: SDBMExprDetail.h:37
Definition: SDBMDialect.h:18
Definition: SDBMExprDetail.h:78
Definition: SDBMExpr.h:221
static SDBMConstantExprStorage * construct(StorageUniquer::StorageAllocator &allocator, const KeyTy &key)
Definition: SDBMExprDetail.h:84