14 #ifndef MLIR_TARGET_LLVMIR_DATALAYOUTIMPORTER_H
15 #define MLIR_TARGET_LLVMIR_DATALAYOUTIMPORTER_H
20 #include "llvm/ADT/MapVector.h"
39 FloatType
getFloatType(MLIRContext *context,
unsigned width);
50 : dataLayoutStr(dataLayoutStr), context(context) {
60 dataLayoutSpec = dataLayoutSpecFromDataLayoutStr();
78 DataLayoutSpecInterface dataLayoutSpecFromDataLayoutStr();
82 FailureOr<StringRef> tryToParseAlphaPrefix(StringRef &token)
const;
86 FailureOr<uint64_t> tryToParseInt(StringRef &token)
const;
89 FailureOr<SmallVector<uint64_t>> tryToParseIntList(StringRef token)
const;
92 FailureOr<DenseIntElementsAttr> tryToParseAlignment(StringRef token)
const;
95 FailureOr<DenseIntElementsAttr>
96 tryToParsePointerAlignment(StringRef token)
const;
99 LogicalResult tryToEmplaceAlignmentEntry(
Type type, StringRef token);
102 LogicalResult tryToEmplacePointerAlignmentEntry(LLVMPointerType type,
106 LogicalResult tryToEmplaceEndiannessEntry(StringRef endianness,
110 LogicalResult tryToEmplaceAddrSpaceEntry(StringRef token,
111 llvm::StringLiteral spaceKey);
114 LogicalResult tryToEmplaceManglingModeEntry(StringRef token,
115 llvm::StringLiteral manglingKey);
118 LogicalResult tryToEmplaceStackAlignmentEntry(StringRef token);
122 tryToEmplaceFunctionPointerAlignmentEntry(StringRef fnPtrAlignEntry,
126 LogicalResult tryToEmplaceLegalIntWidthsEntry(StringRef token);
128 std::string dataLayoutStr = {};
129 DataLayoutSpecInterface dataLayoutSpec;
131 StringRef lastToken = {};
133 llvm::MapVector<StringAttr, DataLayoutEntryInterface> keyEntries;
134 llvm::MapVector<TypeAttr, DataLayoutEntryInterface> typeEntries;
Helper class that translates an LLVM data layout string to an MLIR data layout specification.
StringRef getLastToken() const
Returns the last data layout token that has been processed before the data layout translation failed.
ArrayRef< StringRef > getUnhandledTokens() const
Returns the data layout tokens that have not been handled during the data layout translation.
DataLayoutImporter(MLIRContext *context, StringRef dataLayoutStr)
DataLayoutSpecInterface getDataLayoutSpec() const
Returns the MLIR data layout specification translated from the LLVM data layout.
MLIRContext is the top-level object for a collection of MLIR operations.
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
The OpAsmOpInterface, see OpAsmInterface.td for more details.
FloatType getFloatType(MLIRContext *context, unsigned width)
Returns a supported MLIR floating point type of the given bit width or null if the bit width is not s...
Include the generated interface declarations.