18
18
#include " mlir/IR/DialectInterface.h"
19
19
#include " mlir/IR/OpDefinition.h"
20
20
#include " llvm/ADT/DenseMap.h"
21
+ #include " llvm/Support/TypeSize.h"
21
22
22
23
namespace mlir {
23
24
class DataLayout ;
@@ -34,25 +35,25 @@ class ModuleOp;
34
35
namespace detail {
35
36
// / Default handler for the type size request. Computes results for built-in
36
37
// / types and dispatches to the DataLayoutTypeInterface for other types.
37
- unsigned getDefaultTypeSize (Type type, const DataLayout &dataLayout,
38
- DataLayoutEntryListRef params);
38
+ llvm::TypeSize getDefaultTypeSize (Type type, const DataLayout &dataLayout,
39
+ DataLayoutEntryListRef params);
39
40
40
41
// / Default handler for the type size in bits request. Computes results for
41
42
// / built-in types and dispatches to the DataLayoutTypeInterface for other
42
43
// / types.
43
- unsigned getDefaultTypeSizeInBits (Type type, const DataLayout &dataLayout,
44
- DataLayoutEntryListRef params);
44
+ llvm::TypeSize getDefaultTypeSizeInBits (Type type, const DataLayout &dataLayout,
45
+ DataLayoutEntryListRef params);
45
46
46
- // / Default handler for the required alignemnt request. Computes results for
47
+ // / Default handler for the required alignment request. Computes results for
47
48
// / built-in types and dispatches to the DataLayoutTypeInterface for other
48
49
// / types.
49
- unsigned getDefaultABIAlignment (Type type, const DataLayout &dataLayout,
50
+ uint64_t getDefaultABIAlignment (Type type, const DataLayout &dataLayout,
50
51
ArrayRef<DataLayoutEntryInterface> params);
51
52
52
- // / Default handler for the preferred alignemnt request. Computes results for
53
+ // / Default handler for the preferred alignment request. Computes results for
53
54
// / built-in types and dispatches to the DataLayoutTypeInterface for other
54
55
// / types.
55
- unsigned
56
+ uint64_t
56
57
getDefaultPreferredAlignment (Type type, const DataLayout &dataLayout,
57
58
ArrayRef<DataLayoutEntryInterface> params);
58
59
@@ -62,7 +63,7 @@ Attribute getDefaultAllocaMemorySpace(DataLayoutEntryInterface entry);
62
63
63
64
// / Default handler for the stack alignment request. Dispatches to the
64
65
// / DataLayoutInterface if specified, otherwise returns the default.
65
- unsigned getDefaultStackAlignment (DataLayoutEntryInterface entry);
66
+ uint64_t getDefaultStackAlignment (DataLayoutEntryInterface entry);
66
67
67
68
// / Given a list of data layout entries, returns a new list containing the
68
69
// / entries with keys having the given type ID, i.e. belonging to the same type
@@ -85,6 +86,10 @@ LogicalResult verifyDataLayoutOp(Operation *op);
85
86
// / entry verifiers, and then to the verifiers implemented by the relevant type
86
87
// / and dialect interfaces for type and identifier keys respectively.
87
88
LogicalResult verifyDataLayoutSpec (DataLayoutSpecInterface spec, Location loc);
89
+
90
+ // / Divides the known min value of the numerator by the denominator and rounds
91
+ // / the result up to the next integer. Preserves the scalable flag.
92
+ llvm::TypeSize divideCeil (llvm::TypeSize numerator, uint64_t denominator);
88
93
} // namespace detail
89
94
} // namespace mlir
90
95
@@ -156,16 +161,16 @@ class DataLayout {
156
161
static DataLayout closest (Operation *op);
157
162
158
163
// / Returns the size of the given type in the current scope.
159
- unsigned getTypeSize (Type t) const ;
164
+ llvm::TypeSize getTypeSize (Type t) const ;
160
165
161
166
// / Returns the size in bits of the given type in the current scope.
162
- unsigned getTypeSizeInBits (Type t) const ;
167
+ llvm::TypeSize getTypeSizeInBits (Type t) const ;
163
168
164
169
// / Returns the required alignment of the given type in the current scope.
165
- unsigned getTypeABIAlignment (Type t) const ;
170
+ uint64_t getTypeABIAlignment (Type t) const ;
166
171
167
172
// / Returns the preferred of the given type in the current scope.
168
- unsigned getTypePreferredAlignment (Type t) const ;
173
+ uint64_t getTypePreferredAlignment (Type t) const ;
169
174
170
175
// / Returns the memory space used for AllocaOps.
171
176
Attribute getAllocaMemorySpace () const ;
@@ -174,7 +179,7 @@ class DataLayout {
174
179
// / stack variables should be limited to the natural stack alignment to
175
180
// / prevent dynamic stack alignment. Returns zero if the stack alignment is
176
181
// / unspecified.
177
- unsigned getStackAlignment () const ;
182
+ uint64_t getStackAlignment () const ;
178
183
179
184
private:
180
185
// / Combined layout spec at the given scope.
@@ -193,16 +198,16 @@ class DataLayout {
193
198
Operation *scope;
194
199
195
200
// / Caches for individual requests.
196
- mutable DenseMap<Type, unsigned > sizes;
197
- mutable DenseMap<Type, unsigned > bitsizes;
198
- mutable DenseMap<Type, unsigned > abiAlignments;
199
- mutable DenseMap<Type, unsigned > preferredAlignments;
201
+ mutable DenseMap<Type, llvm::TypeSize > sizes;
202
+ mutable DenseMap<Type, llvm::TypeSize > bitsizes;
203
+ mutable DenseMap<Type, uint64_t > abiAlignments;
204
+ mutable DenseMap<Type, uint64_t > preferredAlignments;
200
205
201
206
// / Cache for alloca memory space.
202
207
mutable std::optional<Attribute> allocaMemorySpace;
203
208
204
209
// / Cache for stack alignment.
205
- mutable std::optional<unsigned > stackAlignment;
210
+ mutable std::optional<uint64_t > stackAlignment;
206
211
};
207
212
208
213
} // namespace mlir
0 commit comments