Skip to content

Commit f625f52

Browse files
committed
[mlir] Remove the default template parameters from AttrBase and TypeBase.
MSVC 2017 doesn't support the case where a trailing variadic template list comes after template types with default parameters. Until we upgrade to VS 2019, we can't use the simplified definitions.
1 parent 83fae3f commit f625f52

File tree

8 files changed

+31
-22
lines changed

8 files changed

+31
-22
lines changed

flang/include/flang/Optimizer/Dialect/FIRAttr.h

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ class SubclassAttr
7575
/// A case selector of `CASE (n:m)` corresponds to any value from `n` to `m` and
7676
/// is encoded as `#fir.interval, %n, %m`.
7777
class ClosedIntervalAttr
78-
: public mlir::Attribute::AttrBase<ClosedIntervalAttr> {
78+
: public mlir::Attribute::AttrBase<ClosedIntervalAttr, mlir::Attribute,
79+
mlir::AttributeStorage> {
7980
public:
8081
using Base::Base;
8182

@@ -91,7 +92,9 @@ class ClosedIntervalAttr
9192
/// an ssa-value.
9293
/// A case selector of `CASE (:m)` corresponds to any value up to and including
9394
/// `m` and is encoded as `#fir.upper, %m`.
94-
class UpperBoundAttr : public mlir::Attribute::AttrBase<UpperBoundAttr> {
95+
class UpperBoundAttr
96+
: public mlir::Attribute::AttrBase<UpperBoundAttr, mlir::Attribute,
97+
mlir::AttributeStorage> {
9598
public:
9699
using Base::Base;
97100

@@ -107,7 +110,9 @@ class UpperBoundAttr : public mlir::Attribute::AttrBase<UpperBoundAttr> {
107110
/// an ssa-value.
108111
/// A case selector of `CASE (n:)` corresponds to any value down to and
109112
/// including `n` and is encoded as `#fir.lower, %n`.
110-
class LowerBoundAttr : public mlir::Attribute::AttrBase<LowerBoundAttr> {
113+
class LowerBoundAttr
114+
: public mlir::Attribute::AttrBase<LowerBoundAttr, mlir::Attribute,
115+
mlir::AttributeStorage> {
111116
public:
112117
using Base::Base;
113118

@@ -123,7 +128,9 @@ class LowerBoundAttr : public mlir::Attribute::AttrBase<LowerBoundAttr> {
123128
/// interval contains exactly one value.
124129
/// A case selector of `CASE (p)` corresponds to exactly the value `p` and is
125130
/// encoded as `#fir.point, %p`.
126-
class PointIntervalAttr : public mlir::Attribute::AttrBase<PointIntervalAttr> {
131+
class PointIntervalAttr
132+
: public mlir::Attribute::AttrBase<PointIntervalAttr, mlir::Attribute,
133+
mlir::AttributeStorage> {
127134
public:
128135
using Base::Base;
129136

mlir/docs/Tutorials/DefiningAttributesAndTypes.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,10 +75,11 @@ to provide our own storage class.
7575
```c++
7676
/// This class defines a simple parameterless type. All derived types must
7777
/// inherit from the CRTP class 'Type::TypeBase'. It takes as template
78-
/// parameters the concrete type (SimpleType), and the base class to use (Type).
78+
/// parameters the concrete type (SimpleType), the base class to use (Type),
79+
/// using the default storage class (TypeStorage) as the storage type.
7980
/// 'Type::TypeBase' also provides several utility methods to simplify type
8081
/// construction.
81-
class SimpleType : public Type::TypeBase<SimpleType, Type> {
82+
class SimpleType : public Type::TypeBase<SimpleType, Type, TypeStorage> {
8283
public:
8384
/// Inherit some necessary constructors from 'TypeBase'.
8485
using Base::Base;

mlir/include/mlir/Dialect/Linalg/IR/LinalgTypes.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ enum LinalgTypes {
3232
/// %0 = linalg.range %arg0:%arg1:%arg2 : !linalg.range
3333
/// }
3434
/// ```
35-
class RangeType : public Type::TypeBase<RangeType, Type> {
35+
class RangeType : public Type::TypeBase<RangeType, Type, TypeStorage> {
3636
public:
3737
// Used for generic hooks in TypeBase.
3838
using Base::Base;

mlir/include/mlir/Dialect/Shape/IR/Shape.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ enum Kind {
3939
} // namespace ShapeTypes
4040

4141
/// The component type corresponding to shape, element type and attribute.
42-
class ComponentType : public Type::TypeBase<ComponentType, Type> {
42+
class ComponentType : public Type::TypeBase<ComponentType, Type, TypeStorage> {
4343
public:
4444
using Base::Base;
4545

@@ -54,7 +54,7 @@ class ComponentType : public Type::TypeBase<ComponentType, Type> {
5454
};
5555

5656
/// The element type of the shaped type.
57-
class ElementType : public Type::TypeBase<ElementType, Type> {
57+
class ElementType : public Type::TypeBase<ElementType, Type, TypeStorage> {
5858
public:
5959
using Base::Base;
6060

@@ -69,7 +69,7 @@ class ElementType : public Type::TypeBase<ElementType, Type> {
6969
};
7070

7171
/// The shape descriptor type represents rank and dimension sizes.
72-
class ShapeType : public Type::TypeBase<ShapeType, Type> {
72+
class ShapeType : public Type::TypeBase<ShapeType, Type, TypeStorage> {
7373
public:
7474
using Base::Base;
7575

@@ -82,7 +82,7 @@ class ShapeType : public Type::TypeBase<ShapeType, Type> {
8282
};
8383

8484
/// The type of a single dimension.
85-
class SizeType : public Type::TypeBase<SizeType, Type> {
85+
class SizeType : public Type::TypeBase<SizeType, Type, TypeStorage> {
8686
public:
8787
using Base::Base;
8888

@@ -95,7 +95,8 @@ class SizeType : public Type::TypeBase<SizeType, Type> {
9595
};
9696

9797
/// The ValueShape represents a (potentially unknown) runtime value and shape.
98-
class ValueShapeType : public Type::TypeBase<ValueShapeType, Type> {
98+
class ValueShapeType
99+
: public Type::TypeBase<ValueShapeType, Type, TypeStorage> {
99100
public:
100101
using Base::Base;
101102

@@ -111,7 +112,7 @@ class ValueShapeType : public Type::TypeBase<ValueShapeType, Type> {
111112

112113
/// The Witness represents a runtime constraint, to be used as shape related
113114
/// preconditions on code execution.
114-
class WitnessType : public Type::TypeBase<WitnessType, Type> {
115+
class WitnessType : public Type::TypeBase<WitnessType, Type, TypeStorage> {
115116
public:
116117
using Base::Base;
117118

mlir/include/mlir/IR/Attributes.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ class Attribute {
6363
};
6464

6565
/// Utility class for implementing attributes.
66-
template <typename ConcreteType, typename BaseType = Attribute,
67-
typename StorageType = AttributeStorage,
66+
template <typename ConcreteType, typename BaseType, typename StorageType,
6867
template <typename T> class... Traits>
6968
using AttrBase = detail::StorageUserBase<ConcreteType, BaseType, StorageType,
7069
detail::AttributeUniquer, Traits...>;
@@ -636,7 +635,8 @@ class TypeAttr : public Attribute::AttrBase<TypeAttr, Attribute,
636635

637636
/// Unit attributes are attributes that hold no specific value and are given
638637
/// meaning by their existence.
639-
class UnitAttr : public Attribute::AttrBase<UnitAttr> {
638+
class UnitAttr
639+
: public Attribute::AttrBase<UnitAttr, Attribute, AttributeStorage> {
640640
public:
641641
using Base::Base;
642642

mlir/include/mlir/IR/Location.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ class NameLoc : public Attribute::AttrBase<NameLoc, LocationAttr,
208208

209209
/// Represents an unknown location. This is always a singleton for a given
210210
/// MLIRContext.
211-
class UnknownLoc : public Attribute::AttrBase<UnknownLoc, LocationAttr> {
211+
class UnknownLoc
212+
: public Attribute::AttrBase<UnknownLoc, LocationAttr, AttributeStorage> {
212213
public:
213214
using Base::Base;
214215

mlir/include/mlir/IR/StandardTypes.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class ComplexType
102102

103103
/// Index is a special integer-like type with unknown platform-dependent bit
104104
/// width.
105-
class IndexType : public Type::TypeBase<IndexType, Type> {
105+
class IndexType : public Type::TypeBase<IndexType, Type, TypeStorage> {
106106
public:
107107
using Base::Base;
108108

@@ -188,7 +188,7 @@ class IntegerType
188188
// FloatType
189189
//===----------------------------------------------------------------------===//
190190

191-
class FloatType : public Type::TypeBase<FloatType, Type> {
191+
class FloatType : public Type::TypeBase<FloatType, Type, TypeStorage> {
192192
public:
193193
using Base::Base;
194194

@@ -227,7 +227,7 @@ class FloatType : public Type::TypeBase<FloatType, Type> {
227227

228228
/// NoneType is a unit type, i.e. a type with exactly one possible value, where
229229
/// its value does not have a defined dynamic representation.
230-
class NoneType : public Type::TypeBase<NoneType, Type> {
230+
class NoneType : public Type::TypeBase<NoneType, Type, TypeStorage> {
231231
public:
232232
using Base::Base;
233233

mlir/include/mlir/IR/Types.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,7 @@ class Type {
100100
};
101101

102102
/// Utility class for implementing types.
103-
template <typename ConcreteType, typename BaseType,
104-
typename StorageType = DefaultTypeStorage,
103+
template <typename ConcreteType, typename BaseType, typename StorageType,
105104
template <typename T> class... Traits>
106105
using TypeBase = detail::StorageUserBase<ConcreteType, BaseType, StorageType,
107106
detail::TypeUniquer, Traits...>;

0 commit comments

Comments
 (0)