MLIR: lib/Interfaces/DataLayoutInterfaces.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
14
15#include "llvm/ADT/TypeSwitch.h"
16#include "llvm/Support/MathExtras.h"
17
18using namespace mlir;
19
20
21
22
23
24
25
27 std::string message;
28 llvm::raw_string_ostream os(message);
29 os << "neither the scoping op nor the type class provide data layout "
30 "information for "
31 << type;
32 llvm::report_fatal_error(Twine(message));
33}
34
35
36
38 if (params.empty())
39 return 64;
40 auto attr = cast(params.front().getValue());
41 return attr.getValue().getZExtValue();
42}
43
44llvm::TypeSize
50
51llvm::TypeSize
56
57 if (auto ctype = dyn_cast(type)) {
58 Type et = ctype.getElementType();
59 uint64_t innerAlignment =
62
63
64
65 return llvm::alignTo(innerSize, innerAlignment) + innerSize;
66 }
67
68
69 if (isa(type))
72
73
74
75
76
77
78 if (auto vecType = dyn_cast(type)) {
79 uint64_t baseSize = vecType.getNumElements() / vecType.getShape().back() *
80 llvm::PowerOf2Ceil(vecType.getShape().back()) *
81 dataLayout.getTypeSize(vecType.getElementType()) * 8;
82 return llvm::TypeSize::get(baseSize, vecType.isScalable());
83 }
84
85 if (auto typeInterface = dyn_cast(type))
86 return typeInterface.getTypeSizeInBits(dataLayout, params);
87
89}
90
91static DataLayoutEntryInterface
94 assert(!params.empty() && "expected non-empty parameter list");
95 std::map<unsigned, DataLayoutEntryInterface> sortedParams;
96 for (DataLayoutEntryInterface entry : params) {
97 sortedParams.insert(std::make_pair(
98 cast(entry.getKey()).getIntOrFloatBitWidth(), entry));
99 }
100 auto iter = sortedParams.lower_bound(intType.getWidth());
101 if (iter == sortedParams.end())
102 iter = std::prev(iter);
103
104 return iter->second;
105}
106
108
110 auto values =
111 cast(entry.getValue()).getValues<uint64_t>();
113}
114
115static uint64_t
118 constexpr uint64_t kDefaultSmallIntAlignment = 4u;
119 constexpr unsigned kSmallIntSize = 64;
120 if (params.empty()) {
121 return intType.getWidth() < kSmallIntSize
122 ? llvm::PowerOf2Ceil(
124 : kDefaultSmallIntAlignment;
125 }
126
128}
129
130static uint64_t
133 assert(params.size() <= 1 && "at most one data layout entry is expected for "
134 "the singleton floating-point type");
135 if (params.empty())
136 return llvm::PowerOf2Ceil(dataLayout.getTypeSize(fltType).getFixedValue());
138}
139
143
144
145 if (isa(type))
146 return llvm::PowerOf2Ceil(dataLayout.getTypeSize(type).getKnownMinValue());
147
148 if (auto fltType = dyn_cast(type))
150
151
152 if (isa(type))
155
156 if (auto intType = dyn_cast(type))
158
159 if (auto ctype = dyn_cast(type))
161
162 if (auto typeInterface = dyn_cast(type))
163 return typeInterface.getABIAlignment(dataLayout, params);
164
166}
167
169 auto values =
170 cast(entry.getValue()).getValues<uint64_t>();
171 return *std::next(values.begin(), values.size() - 1) / kDefaultBitsInByte;
172}
173
174static uint64_t
178 if (params.empty())
179 return llvm::PowerOf2Ceil(dataLayout.getTypeSize(intType).getFixedValue());
180
182}
183
184static uint64_t
187 assert(params.size() <= 1 && "at most one data layout entry is expected for "
188 "the singleton floating-point type");
189 if (params.empty())
192}
193
197
198 if (isa(type))
200
201 if (auto fltType = dyn_cast(type))
203
204
205
206 if (auto intType = dyn_cast(type))
208
209 if (isa(type)) {
212 }
213
214 if (auto ctype = dyn_cast(type))
216 params);
217
218 if (auto typeInterface = dyn_cast(type))
219 return typeInterface.getPreferredAlignment(dataLayout, params);
220
222}
223
227 if (isa(type))
229
230 if (auto typeInterface = dyn_cast(type))
231 if (std::optional<uint64_t> indexBitwidth =
232 typeInterface.getIndexBitwidth(dataLayout, params))
233 return *indexBitwidth;
234
235
236
237 return std::nullopt;
238}
239
240
241
243 if (entry == DataLayoutEntryInterface())
245
246 return entry.getValue();
247}
248
249
250
251
253 if (!entry)
255
256 return entry.getValue();
257}
258
259
260
261
264 if (entry == DataLayoutEntryInterface()) {
266 }
267
268 return entry.getValue();
269}
270
271
272
274 if (entry == DataLayoutEntryInterface())
276
277 return entry.getValue();
278}
279
280
281
282
285 if (entry == DataLayoutEntryInterface()) {
287 }
288
289 return entry.getValue();
290}
291
292
293
294
297 if (entry == DataLayoutEntryInterface()) {
299 }
300
301 return entry.getValue();
302}
303
304
305
306uint64_t
308 if (entry == DataLayoutEntryInterface())
309 return 0;
310
311 auto value = cast(entry.getValue());
312 return value.getValue().getZExtValue();
313}
314
315
316
318 DataLayoutEntryInterface entry) {
319 if (entry == DataLayoutEntryInterface())
321 return entry.getValue();
322}
323
324
325
326
329 if (entry == DataLayoutEntryInterface())
331 return entry.getValue();
332}
333
334std::optional
336 if (entry == DataLayoutEntryInterface())
337 return std::nullopt;
338
339 return entry.getValue();
340}
341
345 return llvm::filter_to_vector<4>(
346 entries, [typeID](DataLayoutEntryInterface entry) {
347 auto type = llvm::dyn_cast_if_present(entry.getKey());
348 return type && type.getTypeID() == typeID;
349 });
350}
351
352DataLayoutEntryInterface
354 StringAttr id) {
355 const auto *it = llvm::find_if(entries, [id](DataLayoutEntryInterface entry) {
356 if (auto attr = dyn_cast(entry.getKey()))
357 return attr == id;
358 return false;
359 });
360 return it == entries.end() ? DataLayoutEntryInterface() : *it;
361}
362
365 .Case<ModuleOp, DataLayoutOpInterface>(
366 [&](auto op) { return op.getDataLayoutSpec(); })
367 .DefaultUnreachable("expected an op with data layout spec");
368}
369
371 if (operation) {
372 ModuleOp moduleOp = dyn_cast(operation);
373 if (!moduleOp)
375 return moduleOp.getTargetSystemSpec();
376 }
377 return TargetSystemSpecInterface();
378}
379
380
381
382static void
386 if (!leaf)
387 return;
388
392 .Case([&](ModuleOp op) {
393
394
395
396
397
398 if (!op->getParentOp() && !op.getDataLayoutSpec())
399 return;
400 specs.push_back(op.getDataLayoutSpec());
401 if (opLocations)
402 opLocations->push_back(op.getLoc());
403 })
404 .Case([&](DataLayoutOpInterface op) {
405 specs.push_back(op.getDataLayoutSpec());
406 if (opLocations)
407 opLocations->push_back(op.getLoc());
408 });
409 }
410}
411
412
413
415 if (!leaf)
416 return {};
417
418 assert((isa<ModuleOp, DataLayoutOpInterface>(leaf)) &&
419 "expected an op with data layout spec");
420
423
424
425 if (specs.empty())
427
428
429
430 auto nonNullSpecs = llvm::filter_to_vector<2>(
431 llvm::reverse(specs),
432 [](DataLayoutSpecInterface iface) { return iface != nullptr; });
433
434
435 if (DataLayoutSpecInterface current = getSpec(leaf))
436 return current.combineWith(nonNullSpecs);
437 if (nonNullSpecs.empty())
438 return {};
439 return nonNullSpecs.back().combineWith(
441}
442
444 DataLayoutSpecInterface spec = getSpec(op);
445
446 if (!spec)
448
449 if (failed(spec.verifySpec(op->getLoc())))
450 return failure();
454 << "data layout does not combine with layouts of enclosing ops";
458 for (Location loc : opLocations)
459 diag.attachNote(loc) << "enclosing op with data layout";
461 }
463}
464
466 uint64_t denominator) {
467 uint64_t divided =
468 llvm::divideCeil(numerator.getKnownMinValue(), denominator);
469 return llvm::TypeSize::get(divided, numerator.isScalable());
470}
471
472
473
474
475
476template
478 if (!originalLayout) {
479 assert((!op || !op.getDataLayoutSpec()) &&
480 "could not compute layout information for an op (failed to "
481 "combine attributes?)");
482 }
483}
484
486
490 allocaMemorySpace(std::nullopt), programMemorySpace(std::nullopt),
491 globalMemorySpace(std::nullopt), stackAlignment(std::nullopt) {
492#if LLVM_ENABLE_ABI_BREAKING_CHECKS
495#endif
496}
497
501 allocaMemorySpace(std::nullopt), programMemorySpace(std::nullopt),
502 globalMemorySpace(std::nullopt), stackAlignment(std::nullopt) {
503#if LLVM_ENABLE_ABI_BREAKING_CHECKS
506#endif
507}
508
510
511
512 while (op) {
513 if (auto module = dyn_cast(op))
515 if (auto iface = dyn_cast(op))
518 }
520}
521
522void mlir::DataLayout::checkValid() const {
523#if LLVM_ENABLE_ABI_BREAKING_CHECKS
526 assert(specs.size() == layoutStack.size() &&
527 "data layout object used, but no longer valid due to the change in "
528 "number of nested layouts");
529 for (auto pair : llvm::zip(specs, layoutStack)) {
530 Attribute newLayout = std::get<0>(pair);
531 Attribute origLayout = std::get<1>(pair);
532 assert(newLayout == origLayout &&
533 "data layout object used, but no longer valid "
534 "due to the change in layout attributes");
535 }
536#endif
537 assert(((!scope && !this->originalLayout) ||
539 "data layout object used, but no longer valid due to the change in "
540 "layout spec");
541}
542
543
544
545
546template
549 auto it = cache.find(t);
550 if (it != cache.end())
551 return it->second;
552
553 auto result = cache.try_emplace(t, compute(t));
554 return result.first->second;
555}
556
558 checkValid();
561 if (originalLayout)
562 list = originalLayout.getSpecForType(ty.getTypeID());
563 if (auto iface = dyn_cast_or_null(scope))
564 return iface.getTypeSize(ty, *this, list);
566 });
567}
568
570 checkValid();
573 if (originalLayout)
574 list = originalLayout.getSpecForType(ty.getTypeID());
575 if (auto iface = dyn_cast_or_null(scope))
576 return iface.getTypeSizeInBits(ty, *this, list);
578 });
579}
580
582 checkValid();
585 if (originalLayout)
586 list = originalLayout.getSpecForType(ty.getTypeID());
587 if (auto iface = dyn_cast_or_null(scope))
588 return iface.getTypeABIAlignment(ty, *this, list);
590 });
591}
592
594 checkValid();
597 if (originalLayout)
598 list = originalLayout.getSpecForType(ty.getTypeID());
599 if (auto iface = dyn_cast_or_null(scope))
600 return iface.getTypePreferredAlignment(ty, *this, list);
602 });
603}
604
606 checkValid();
609 if (originalLayout)
610 list = originalLayout.getSpecForType(ty.getTypeID());
611 if (auto iface = dyn_cast_or_null(scope))
612 return iface.getIndexBitwidth(ty, *this, list);
614 });
615}
616
618 checkValid();
619 if (endianness)
620 return *endianness;
621 DataLayoutEntryInterface entry;
622 if (originalLayout)
623 entry = originalLayout.getSpecForIdentifier(
624 originalLayout.getEndiannessIdentifier(originalLayout.getContext()));
625
626 if (auto iface = dyn_cast_or_null(scope))
627 endianness = iface.getEndianness(entry);
628 else
630 return *endianness;
631}
632
634 checkValid();
635 if (defaultMemorySpace)
636 return *defaultMemorySpace;
637 DataLayoutEntryInterface entry;
638 if (originalLayout)
639 entry = originalLayout.getSpecForIdentifier(
640 originalLayout.getDefaultMemorySpaceIdentifier(
641 originalLayout.getContext()));
642 if (auto iface = dyn_cast_or_null(scope))
643 defaultMemorySpace = iface.getDefaultMemorySpace(entry);
644 else
646 return *defaultMemorySpace;
647}
648
650 checkValid();
651 if (allocaMemorySpace)
652 return *allocaMemorySpace;
653 DataLayoutEntryInterface entry;
654 if (originalLayout)
655 entry = originalLayout.getSpecForIdentifier(
656 originalLayout.getAllocaMemorySpaceIdentifier(
657 originalLayout.getContext()));
658 if (auto iface = dyn_cast_or_null(scope))
659 allocaMemorySpace = iface.getAllocaMemorySpace(entry);
660 else
662 return *allocaMemorySpace;
663}
664
666 checkValid();
667 if (manglingMode)
668 return *manglingMode;
669 DataLayoutEntryInterface entry;
670 if (originalLayout)
671 entry = originalLayout.getSpecForIdentifier(
672 originalLayout.getManglingModeIdentifier(originalLayout.getContext()));
673
674 if (auto iface = dyn_cast_or_null(scope))
675 manglingMode = iface.getManglingMode(entry);
676 else
678 return *manglingMode;
679}
680
682 checkValid();
683 if (programMemorySpace)
684 return *programMemorySpace;
685 DataLayoutEntryInterface entry;
686 if (originalLayout)
687 entry = originalLayout.getSpecForIdentifier(
688 originalLayout.getProgramMemorySpaceIdentifier(
689 originalLayout.getContext()));
690 if (auto iface = dyn_cast_or_null(scope))
691 programMemorySpace = iface.getProgramMemorySpace(entry);
692 else
694 return *programMemorySpace;
695}
696
698 checkValid();
699 if (globalMemorySpace)
700 return *globalMemorySpace;
701 DataLayoutEntryInterface entry;
702 if (originalLayout)
703 entry = originalLayout.getSpecForIdentifier(
704 originalLayout.getGlobalMemorySpaceIdentifier(
705 originalLayout.getContext()));
706 if (auto iface = dyn_cast_or_null(scope))
707 globalMemorySpace = iface.getGlobalMemorySpace(entry);
708 else
710 return *globalMemorySpace;
711}
712
714 checkValid();
715 if (stackAlignment)
716 return *stackAlignment;
717 DataLayoutEntryInterface entry;
718 if (originalLayout)
719 entry = originalLayout.getSpecForIdentifier(
720 originalLayout.getStackAlignmentIdentifier(
721 originalLayout.getContext()));
722 if (auto iface = dyn_cast_or_null(scope))
723 stackAlignment = iface.getStackAlignment(entry);
724 else
726 return *stackAlignment;
727}
728
730 checkValid();
731 if (functionPointerAlignment)
732 return *functionPointerAlignment;
733 DataLayoutEntryInterface entry;
734 if (originalLayout)
735 entry = originalLayout.getSpecForIdentifier(
736 originalLayout.getFunctionPointerAlignmentIdentifier(
737 originalLayout.getContext()));
738 if (auto iface = dyn_cast_or_null(scope))
739 functionPointerAlignment = iface.getFunctionPointerAlignment(entry);
740 else
741 functionPointerAlignment =
743 return *functionPointerAlignment;
744}
745
747 checkValid();
748 if (legalIntWidths)
749 return *legalIntWidths;
750 DataLayoutEntryInterface entry;
751 if (originalLayout)
752 entry = originalLayout.getSpecForIdentifier(
753 originalLayout.getLegalIntWidthsIdentifier(
754 originalLayout.getContext()));
755 if (auto iface = dyn_cast_or_null(scope))
756 legalIntWidths = iface.getLegalIntWidths(entry);
757 else
759 return *legalIntWidths;
760}
761
763 TargetSystemSpecInterface::DeviceID deviceID,
764 StringAttr propertyName) const {
765 checkValid();
766 DataLayoutEntryInterface entry;
767 if (originalTargetSystemDesc) {
768 if (std::optional device =
769 originalTargetSystemDesc.getDeviceSpecForDeviceID(deviceID))
770 entry = device->getSpecForIdentifier(propertyName);
771 }
772
773
774
775
776 if (auto iface = dyn_cast_or_null(scope))
777 return iface.getDevicePropertyValue(entry);
778 else
780}
781
782
783
784
785
786void DataLayoutSpecInterface::bucketEntriesByType(
787 llvm::MapVector<TypeID, DataLayoutEntryList> &types,
788 llvm::MapVector<StringAttr, DataLayoutEntryInterface> &ids) {
789 for (DataLayoutEntryInterface entry : getEntries()) {
790 if (auto type = llvm::dyn_cast_if_present(entry.getKey()))
791 types[type.getTypeID()].push_back(entry);
792 else
793 ids[llvm::cast(entry.getKey())] = entry;
794 }
795}
796
799
800 for (DataLayoutEntryInterface entry : spec.getEntries())
801 if (failed(entry.verifyEntry(loc)))
802 return failure();
803
804
805
806 llvm::MapVector<TypeID, DataLayoutEntryList> types;
807 llvm::MapVector<StringAttr, DataLayoutEntryInterface> ids;
808 spec.bucketEntriesByType(types, ids);
809
810 for (const auto &kvp : types) {
811 auto sampleType = cast(kvp.second.front().getKey());
812 if (isa(sampleType)) {
813 assert(kvp.second.size() == 1 &&
814 "expected one data layout entry for non-parametric 'index' type");
815 if (!isa(kvp.second.front().getValue()))
817 << "expected integer attribute in the data layout entry for "
818 << sampleType;
819 continue;
820 }
821
822 if (sampleType.isIntOrFloat()) {
823 for (DataLayoutEntryInterface entry : kvp.second) {
824 auto value = dyn_cast(entry.getValue());
825 if (!value || !value.getElementType().isSignlessInteger(64)) {
826 emitError(loc) << "expected a dense i64 elements attribute in the "
827 "data layout entry "
828 << entry;
829 return failure();
830 }
831
832 auto elements = llvm::to_vector<2>(value.getValues<uint64_t>());
833 unsigned numElements = elements.size();
834 if (numElements < 1 || numElements > 2) {
835 emitError(loc) << "expected 1 or 2 elements in the data layout entry "
836 << entry;
837 return failure();
838 }
839
840 uint64_t abi = elements[0];
841 uint64_t preferred = numElements == 2 ? elements[1] : abi;
842 if (preferred < abi) {
844 << "preferred alignment is expected to be greater than or equal "
845 "to the abi alignment in data layout entry "
846 << entry;
847 return failure();
848 }
849 }
850 continue;
851 }
852
853 if (isa(&sampleType.getDialect()))
854 return emitError(loc) << "unexpected data layout for a built-in type";
855
856 auto dlType = dyn_cast(sampleType);
857 if (!dlType)
859 << "data layout specified for a type that does not support it";
860 if (failed(dlType.verifyEntries(kvp.second, loc)))
861 return failure();
862 }
863
864 for (const auto &kvp : ids) {
865 StringAttr identifier = cast(kvp.second.getKey());
866 Dialect *dialect = identifier.getReferencedDialect();
867
868
869
870 if (!dialect)
871 continue;
872
873 const auto *iface = dyn_cast(dialect);
874 if (!iface) {
877 << "' dialect does not support identifier data layout entries";
878 }
879 if (failed(iface->verifyEntry(kvp.second, loc)))
880 return failure();
881 }
882
884}
885
886LogicalResult
891 for (const auto &entry : spec.getEntries()) {
892 auto targetDeviceSpec =
893 dyn_cast(entry.getValue());
894
895 if (!targetDeviceSpec)
896 return failure();
897
898
899 if (failed(targetDeviceSpec.verifyEntry(loc)))
900 return failure();
901
902
903 auto deviceID =
904 llvm::dyn_castTargetSystemSpecInterface::DeviceID(entry.getKey());
905 if (!deviceID)
906 return failure();
907
908 if (!deviceIDs.insert(deviceID).second) {
909 return failure();
910 }
911
912
913 for (DataLayoutEntryInterface entry : targetDeviceSpec.getEntries()) {
914 if (auto type = llvm::dyn_cast_if_present(entry.getKey())) {
915
916 return failure();
917 } else {
918 deviceDescKeys[cast(entry.getKey())] = entry;
919 }
920 }
921 }
922
923 for (const auto &[keyName, keyVal] : deviceDescKeys) {
924 Dialect *dialect = keyName.getReferencedDialect();
925
926
927
928 if (!dialect)
929 return failure();
930
931 const auto *iface = dyn_cast(dialect);
932 if (!iface) {
935 << "' dialect does not support identifier data layout entries";
936 }
937 if (failed(iface->verifyEntry(keyVal, loc)))
938 return failure();
939 }
940
942}
943
944#include "mlir/Interfaces/DataLayoutAttrInterface.cpp.inc"
945#include "mlir/Interfaces/DataLayoutOpInterface.cpp.inc"
946#include "mlir/Interfaces/DataLayoutTypeInterface.cpp.inc"
static uint64_t getIntegerTypePreferredAlignment(IntegerType intType, const DataLayout &dataLayout, ArrayRef< DataLayoutEntryInterface > params)
Definition DataLayoutInterfaces.cpp:175
static DataLayoutSpecInterface getCombinedDataLayout(Operation *leaf)
Returns a layout spec that is a combination of the layout specs attached to the given operation and a...
Definition DataLayoutInterfaces.cpp:414
static TargetSystemSpecInterface getTargetSystemSpec(Operation *operation)
Definition DataLayoutInterfaces.cpp:370
constexpr static const uint64_t kDefaultBitsInByte
Definition DataLayoutInterfaces.cpp:107
static uint64_t getIntegerTypeABIAlignment(IntegerType intType, ArrayRef< DataLayoutEntryInterface > params)
Definition DataLayoutInterfaces.cpp:116
static T cachedLookup(Type t, DenseMap< Type, T > &cache, function_ref< T(Type)> compute)
Looks up the value for the given type key in the given cache.
Definition DataLayoutInterfaces.cpp:547
static uint64_t extractPreferredAlignment(DataLayoutEntryInterface entry)
Definition DataLayoutInterfaces.cpp:168
static void collectParentLayouts(Operation *leaf, SmallVectorImpl< DataLayoutSpecInterface > &specs, SmallVectorImpl< Location > *opLocations=nullptr)
Populates opsWithLayout with the list of proper ancestors of leaf that are either modules or implemen...
Definition DataLayoutInterfaces.cpp:383
static uint64_t getFloatTypePreferredAlignment(FloatType fltType, const DataLayout &dataLayout, ArrayRef< DataLayoutEntryInterface > params)
Definition DataLayoutInterfaces.cpp:185
static uint64_t getFloatTypeABIAlignment(FloatType fltType, const DataLayout &dataLayout, ArrayRef< DataLayoutEntryInterface > params)
Definition DataLayoutInterfaces.cpp:131
static DataLayoutSpecInterface getSpec(Operation *operation)
Definition DataLayoutInterfaces.cpp:363
static uint64_t getIndexBitwidth(DataLayoutEntryListRef params)
Returns the bitwidth of the index type if specified in the param list.
Definition DataLayoutInterfaces.cpp:37
static uint64_t extractABIAlignment(DataLayoutEntryInterface entry)
Definition DataLayoutInterfaces.cpp:109
static DataLayoutEntryInterface findEntryForIntegerType(IntegerType intType, ArrayRef< DataLayoutEntryInterface > params)
Definition DataLayoutInterfaces.cpp:92
void checkMissingLayout(DataLayoutSpecInterface originalLayout, OpTy op)
Definition DataLayoutInterfaces.cpp:477
static void reportMissingDataLayout(Type type)
Reports that the given type is missing the data layout information and exits.
Definition DataLayoutInterfaces.cpp:26
static std::string diag(const llvm::Value &value)
Attributes are known-constant values of operations.
The main mechanism for performing data layout queries.
Attribute getAllocaMemorySpace() const
Returns the memory space used for AllocaOps.
Definition DataLayoutInterfaces.cpp:649
static DataLayout closest(Operation *op)
Returns the layout of the closest parent operation carrying layout info.
Definition DataLayoutInterfaces.cpp:509
std::optional< uint64_t > getTypeIndexBitwidth(Type t) const
Returns the bitwidth that should be used when performing index computations for the given pointer-lik...
Definition DataLayoutInterfaces.cpp:605
llvm::TypeSize getTypeSize(Type t) const
Returns the size of the given type in the current scope.
Definition DataLayoutInterfaces.cpp:557
Attribute getManglingMode() const
Returns the mangling mode.
Definition DataLayoutInterfaces.cpp:665
uint64_t getStackAlignment() const
Returns the natural alignment of the stack in bits.
Definition DataLayoutInterfaces.cpp:713
Attribute getProgramMemorySpace() const
Returns the memory space used for program memory operations.
Definition DataLayoutInterfaces.cpp:681
uint64_t getTypePreferredAlignment(Type t) const
Returns the preferred of the given type in the current scope.
Definition DataLayoutInterfaces.cpp:593
Attribute getFunctionPointerAlignment() const
Returns function pointer alignment.
Definition DataLayoutInterfaces.cpp:729
Attribute getGlobalMemorySpace() const
Returns the memory space used for global operations.
Definition DataLayoutInterfaces.cpp:697
uint64_t getTypeABIAlignment(Type t) const
Returns the required alignment of the given type in the current scope.
Definition DataLayoutInterfaces.cpp:581
DataLayout()
Definition DataLayoutInterfaces.cpp:485
llvm::TypeSize getTypeSizeInBits(Type t) const
Returns the size in bits of the given type in the current scope.
Definition DataLayoutInterfaces.cpp:569
Attribute getDefaultMemorySpace() const
Returns the default memory space used for memory operations.
Definition DataLayoutInterfaces.cpp:633
Attribute getEndianness() const
Returns the specified endianness.
Definition DataLayoutInterfaces.cpp:617
Attribute getLegalIntWidths() const
Returns the legal int widths.
Definition DataLayoutInterfaces.cpp:746
std::optional< Attribute > getDevicePropertyValue(TargetSystemSpecInterface::DeviceID, StringAttr propertyName) const
Returns the value of the specified property if the property is defined for the given device ID,...
Definition DataLayoutInterfaces.cpp:762
Dialects are groups of MLIR operations, types and attributes, as well as behavior associated with the...
StringRef getNamespace() const
This class represents a diagnostic that is inflight and set to be reported.
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Operation is the basic unit of execution within MLIR.
Location getLoc()
The source location the operation was defined or derived from.
Operation * getParentOp()
Returns the closest surrounding operation that contains this operation or nullptr if this is a top-le...
InFlightDiagnostic emitError(const Twine &message={})
Emit an error about fatal conditions with this operation, reporting up to any diagnostic handlers tha...
OpTy getParentOfType()
Return the closest surrounding parent operation that is of type 'OpTy'.
This class provides an efficient unique identifier for a specific C++ type.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
MLIRContext * getContext() const
Return the MLIRContext in which this type was uniqued.
bool isIntOrFloat() const
Return true if this is an integer (of any signedness) or a float type.
TypeID getTypeID()
Return a unique identifier for the concrete type.
unsigned getIntOrFloatBitWidth() const
Return the bit width of an integer or a float type, assert failure on other types.
Attribute getDefaultAllocaMemorySpace(DataLayoutEntryInterface entry)
Default handler for alloca memory space request.
Definition DataLayoutInterfaces.cpp:263
Attribute getDefaultProgramMemorySpace(DataLayoutEntryInterface entry)
Default handler for program memory space request.
Definition DataLayoutInterfaces.cpp:284
Attribute getDefaultEndianness(DataLayoutEntryInterface entry)
Default handler for endianness request.
Definition DataLayoutInterfaces.cpp:242
std::optional< uint64_t > getDefaultIndexBitwidth(Type type, const DataLayout &dataLayout, ArrayRef< DataLayoutEntryInterface > params)
Default handler for the index bitwidth request.
Definition DataLayoutInterfaces.cpp:224
DataLayoutEntryList filterEntriesForType(DataLayoutEntryListRef entries, TypeID typeID)
Given a list of data layout entries, returns a new list containing the entries with keys having the g...
Definition DataLayoutInterfaces.cpp:343
LogicalResult verifyTargetSystemSpec(TargetSystemSpecInterface spec, Location loc)
Verifies that a target system desc spec is valid.
Definition DataLayoutInterfaces.cpp:887
std::optional< Attribute > getDevicePropertyValue(DataLayoutEntryInterface entry)
Returns the value of the property from the specified DataLayoutEntry.
Definition DataLayoutInterfaces.cpp:335
Attribute getDefaultManglingMode(DataLayoutEntryInterface entry)
Default handler for mangling mode request.
Definition DataLayoutInterfaces.cpp:273
uint64_t getDefaultABIAlignment(Type type, const DataLayout &dataLayout, ArrayRef< DataLayoutEntryInterface > params)
Default handler for the required alignment request.
Definition DataLayoutInterfaces.cpp:140
Attribute getDefaultLegalIntWidths(DataLayoutEntryInterface entry)
Default handler for the legal int widths request.
Definition DataLayoutInterfaces.cpp:328
llvm::TypeSize getDefaultTypeSize(Type type, const DataLayout &dataLayout, DataLayoutEntryListRef params)
Default handler for the type size request.
Definition DataLayoutInterfaces.cpp:45
llvm::TypeSize getDefaultTypeSizeInBits(Type type, const DataLayout &dataLayout, DataLayoutEntryListRef params)
Default handler for the type size in bits request.
Definition DataLayoutInterfaces.cpp:52
uint64_t getDefaultPreferredAlignment(Type type, const DataLayout &dataLayout, ArrayRef< DataLayoutEntryInterface > params)
Default handler for the preferred alignment request.
Definition DataLayoutInterfaces.cpp:194
llvm::TypeSize divideCeil(llvm::TypeSize numerator, uint64_t denominator)
Divides the known min value of the numerator by the denominator and rounds the result up to the next ...
Definition DataLayoutInterfaces.cpp:465
uint64_t getDefaultStackAlignment(DataLayoutEntryInterface entry)
Default handler for the stack alignment request.
Definition DataLayoutInterfaces.cpp:307
Attribute getDefaultGlobalMemorySpace(DataLayoutEntryInterface entry)
Default handler for global memory space request.
Definition DataLayoutInterfaces.cpp:296
Attribute getDefaultMemorySpace(DataLayoutEntryInterface entry)
Default handler for the default memory space request.
Definition DataLayoutInterfaces.cpp:252
LogicalResult verifyDataLayoutOp(Operation *op)
Verifies that the operation implementing the data layout interface, or a module operation,...
Definition DataLayoutInterfaces.cpp:443
LogicalResult verifyDataLayoutSpec(DataLayoutSpecInterface spec, Location loc)
Verifies that a data layout spec is valid.
Definition DataLayoutInterfaces.cpp:797
Attribute getDefaultFunctionPointerAlignment(DataLayoutEntryInterface entry)
Default handler for the function pointer alignment request.
Definition DataLayoutInterfaces.cpp:317
DataLayoutEntryInterface filterEntryForIdentifier(DataLayoutEntryListRef entries, StringAttr id)
Given a list of data layout entries, returns the entry that has the given identifier as key,...
Definition DataLayoutInterfaces.cpp:353
Include the generated interface declarations.
llvm::SmallVector< DataLayoutEntryInterface, 4 > DataLayoutEntryList
llvm::DenseSet< ValueT, ValueInfoT > DenseSet
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
llvm::DenseMap< KeyT, ValueT, KeyInfoT, BucketT > DenseMap
llvm::ArrayRef< DataLayoutEntryInterface > DataLayoutEntryListRef
llvm::function_ref< Fn > function_ref