5
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
6
//
7
7
// ===----------------------------------------------------------------------===//
8
- // FIXME(wrengr): The `DimLvlMap` class must be public so that it can
9
- // be named as the storage representation of the parameter for the tblgen
10
- // defn of STEA. We may well need to make the other classes public too,
11
- // so that the rest of the compiler can use them when necessary.
12
- // ===----------------------------------------------------------------------===//
13
8
14
9
#ifndef MLIR_DIALECT_SPARSETENSOR_IR_DETAIL_DIMLVLMAP_H
15
10
#define MLIR_DIALECT_SPARSETENSOR_IR_DETAIL_DIMLVLMAP_H
@@ -23,16 +18,8 @@ namespace sparse_tensor {
23
18
namespace ir_detail {
24
19
25
20
// ===----------------------------------------------------------------------===//
26
- // TODO(wrengr): Give this enum a better name, so that it fits together
27
- // with the name of the `DimLvlExpr` class (which may also want a better
28
- // name). Perhaps make this a nested-type too.
29
- //
30
- // NOTE: In the future we will extend this enum to include "counting
31
- // expressions" required for supporting ITPACK/ELL. Therefore the current
32
- // underlying-type and representation values should not be relied upon.
33
21
enum class ExprKind : bool { Dimension = false , Level = true };
34
22
35
- // TODO(wrengr): still needs a better name....
36
23
constexpr VarKind getVarKindAllowedInExpr (ExprKind ek) {
37
24
using VK = std::underlying_type_t <VarKind>;
38
25
return VarKind{2 * static_cast <VK>(!to_underlying (ek))};
@@ -41,19 +28,8 @@ static_assert(getVarKindAllowedInExpr(ExprKind::Dimension) == VarKind::Level &&
41
28
getVarKindAllowedInExpr (ExprKind::Level) == VarKind::Dimension);
42
29
43
30
// ===----------------------------------------------------------------------===//
44
- // TODO(wrengr): The goal of this class is to capture a proof that
45
- // we've verified that the given `AffineExpr` only has variables of the
46
- // appropriate kind(s). So we need to actually prove/verify that in the
47
- // ctor or all its callsites!
48
31
class DimLvlExpr {
49
32
private:
50
- // FIXME(wrengr): Per <https://llvm.org/docs/HowToSetUpLLVMStyleRTTI.html>,
51
- // the `kind` field should be private and const. However, beware
52
- // that if we mark any field as `const` or if the fields have differing
53
- // `private`/`protected` privileges then the `IsZeroCostAbstraction`
54
- // assertion will fail!
55
- // (Also, iirc, if we end up moving the `expr` to the subclasses
56
- // instead, that'll also cause `IsZeroCostAbstraction` to fail.)
57
33
ExprKind kind;
58
34
AffineExpr expr;
59
35
@@ -100,11 +76,6 @@ class DimLvlExpr {
100
76
//
101
77
// Getters for handling `AffineExpr` subclasses.
102
78
//
103
- // TODO(wrengr): is there any way to make these typesafe without too much
104
- // templating?
105
- // TODO(wrengr): Most if not all of these don't actually need to be
106
- // methods, they could be free-functions instead.
107
- //
108
79
Var castAnyVar () const ;
109
80
std::optional<Var> dyn_castAnyVar () const ;
110
81
SymVar castSymVar () const ;
@@ -131,9 +102,6 @@ class DimLvlExpr {
131
102
// Variant of `mlir::AsmPrinter::Impl::BindingStrength`
132
103
enum class BindingStrength : bool { Weak = false , Strong = true };
133
104
134
- // TODO(wrengr): Does our version of `printAffineExprInternal` really
135
- // need to be a method, or could it be a free-function instead? (assuming
136
- // `BindingStrength` goes with it).
137
105
void printAffineExprInternal (llvm::raw_ostream &os,
138
106
BindingStrength enclosingTightness) const ;
139
107
void printStrong (llvm::raw_ostream &os) const {
@@ -145,12 +113,7 @@ class DimLvlExpr {
145
113
};
146
114
static_assert (IsZeroCostAbstraction<DimLvlExpr>);
147
115
148
- // FUTURE_CL(wrengr): It would be nice to have the subclasses override
149
- // `getRHS`, `getLHS`, `unpackBinop`, and `castDimLvlVar` to give them
150
- // the proper covariant return types.
151
- //
152
116
class DimExpr final : public DimLvlExpr {
153
- // FIXME(wrengr): These two are needed for the current RTTI implementation.
154
117
friend class DimLvlExpr ;
155
118
constexpr explicit DimExpr (DimLvlExpr expr) : DimLvlExpr(expr) {}
156
119
@@ -170,7 +133,6 @@ class DimExpr final : public DimLvlExpr {
170
133
static_assert (IsZeroCostAbstraction<DimExpr>);
171
134
172
135
class LvlExpr final : public DimLvlExpr {
173
- // FIXME(wrengr): These two are needed for the current RTTI implementation.
174
136
friend class DimLvlExpr ;
175
137
constexpr explicit LvlExpr (DimLvlExpr expr) : DimLvlExpr(expr) {}
176
138
@@ -189,7 +151,6 @@ class LvlExpr final : public DimLvlExpr {
189
151
};
190
152
static_assert (IsZeroCostAbstraction<LvlExpr>);
191
153
192
- // FIXME(wrengr): See comments elsewhere re RTTI implementation issues/questions
193
154
template <typename U>
194
155
constexpr bool DimLvlExpr::isa () const {
195
156
if constexpr (std::is_same_v<U, DimExpr>)
@@ -247,18 +208,12 @@ class DimSpec final {
247
208
// / the result of this predicate.
248
209
[[nodiscard]] bool isValid (Ranks const &ranks) const ;
249
210
250
- // TODO(wrengr): Use it or loose it.
251
- bool isFunctionOf (Var var) const ;
252
- bool isFunctionOf (VarSet const &vars) const ;
253
- void getFreeVars (VarSet &vars) const ;
254
-
255
211
std::string str (bool wantElision = true ) const ;
256
212
void print (llvm::raw_ostream &os, bool wantElision = true ) const ;
257
213
void print (AsmPrinter &printer, bool wantElision = true ) const ;
258
214
void dump () const ;
259
215
};
260
- // Although this class is more than just a newtype/wrapper, we do want
261
- // to ensure that storing them into `SmallVector` is efficient.
216
+
262
217
static_assert (IsZeroCostAbstraction<DimSpec>);
263
218
264
219
// ===----------------------------------------------------------------------===//
@@ -270,13 +225,6 @@ class LvlSpec final {
270
225
// / whereas the `DimLvlMap` ctor will reset this as appropriate.
271
226
bool elideVar = false ;
272
227
// / The level-expression.
273
- //
274
- // NOTE: For now we use `LvlExpr` because all level-expressions must be
275
- // `AffineExpr`; however, in the future we will also want to allow "counting
276
- // expressions", and potentially other kinds of non-affine level-expressions.
277
- // Which kinds of `DimLvlExpr` are allowed will depend on the `DimLevelType`,
278
- // so we may consider defining another class for pairing those two together
279
- // to ensure that the pair is well-formed.
280
228
LvlExpr expr;
281
229
// / The level-type (== level-format + lvl-properties).
282
230
DimLevelType type;
@@ -298,23 +246,14 @@ class LvlSpec final {
298
246
299
247
// / Checks whether the variables bound/used by this spec are valid
300
248
// / with respect to the given ranks.
301
- //
302
- // NOTE: Once we introduce "counting expressions" this will need
303
- // a more sophisticated implementation than `DimSpec::isValid` does.
304
249
[[nodiscard]] bool isValid (Ranks const &ranks) const ;
305
250
306
- // TODO(wrengr): Use it or loose it.
307
- bool isFunctionOf (Var var) const ;
308
- bool isFunctionOf (VarSet const &vars) const ;
309
- void getFreeVars (VarSet &vars) const ;
310
-
311
251
std::string str (bool wantElision = true ) const ;
312
252
void print (llvm::raw_ostream &os, bool wantElision = true ) const ;
313
253
void print (AsmPrinter &printer, bool wantElision = true ) const ;
314
254
void dump () const ;
315
255
};
316
- // Although this class is more than just a newtype/wrapper, we do want
317
- // to ensure that storing them into `SmallVector` is efficient.
256
+
318
257
static_assert (IsZeroCostAbstraction<LvlSpec>);
319
258
320
259
// ===----------------------------------------------------------------------===//
0 commit comments