22 #include "llvm/ADT/ScopeExit.h"
23 #include "llvm/ADT/TypeSwitch.h"
24 #include "llvm/Support/TypeSize.h"
53 params.push_back(type);
61 params.push_back(type);
68 llvm::interleaveComma(params, p,
93 auto typeOrIntParser = [&]() -> ParseResult {
96 if (intResult.has_value() && !failed(*intResult)) {
98 intParams.push_back(i);
108 typeParams.push_back(t);
116 "failed to parse parameter list for target extension type");
125 if (!typeParams.empty() && !intParams.empty())
139 LLVM_ATTRIBUTE_UNUSED
static LogicalResult
142 #include "mlir/Dialect/LLVMIR/LLVMTypeInterfaces.cpp.inc"
144 #define GET_TYPEDEF_CLASSES
145 #include "mlir/Dialect/LLVMIR/LLVMTypes.cpp.inc"
151 bool LLVMArrayType::isValidElementType(
Type type) {
152 return !llvm::isa<LLVMVoidType, LLVMLabelType, LLVMMetadataType,
153 LLVMFunctionType, LLVMTokenType, LLVMScalableVectorType>(
158 assert(elementType &&
"expected non-null subtype");
164 Type elementType, uint64_t numElements) {
165 assert(elementType &&
"expected non-null subtype");
172 Type elementType, uint64_t numElements) {
173 if (!isValidElementType(elementType))
174 return emitError() <<
"invalid array element type: " << elementType;
182 LLVMArrayType::getTypeSizeInBits(
const DataLayout &dataLayout,
185 getTypeSize(dataLayout, params));
188 llvm::TypeSize LLVMArrayType::getTypeSize(
const DataLayout &dataLayout,
195 uint64_t LLVMArrayType::getABIAlignment(
const DataLayout &dataLayout,
201 LLVMArrayType::getPreferredAlignment(
const DataLayout &dataLayout,
210 bool LLVMFunctionType::isValidArgumentType(
Type type) {
211 return !llvm::isa<LLVMVoidType, LLVMFunctionType>(type);
214 bool LLVMFunctionType::isValidResultType(
Type type) {
215 return !llvm::isa<LLVMFunctionType, LLVMMetadataType, LLVMLabelType>(type);
220 assert(result &&
"expected non-null result");
228 assert(result &&
"expected non-null result");
235 assert(results.size() == 1 &&
"expected a single result type");
236 return get(results[0], llvm::to_vector(inputs), isVarArg());
240 return static_cast<detail::LLVMFunctionTypeStorage *
>(getImpl())->returnType;
246 if (!isValidResultType(result))
247 return emitError() <<
"invalid function result type: " << result;
249 for (
Type arg : arguments)
250 if (!isValidArgumentType(arg))
251 return emitError() <<
"invalid function argument type: " << arg;
264 auto spec = cast<DenseIntElementsAttr>(attr);
265 auto idx =
static_cast<int64_t
>(pos);
266 if (idx >= spec.size())
268 return spec.getValues<uint64_t>()[idx];
275 static std::optional<uint64_t>
280 for (DataLayoutEntryInterface entry : params) {
281 if (!entry.isTypeEntry())
283 if (cast<LLVMPointerType>(entry.getKey().get<
Type>()).getAddressSpace() ==
284 type.getAddressSpace()) {
285 currentEntry = entry.getValue();
302 if (type.getAddressSpace() == 0) {
312 LLVMPointerType::getTypeSizeInBits(
const DataLayout &dataLayout,
314 if (std::optional<uint64_t> size =
316 return llvm::TypeSize::getFixed(*size);
323 uint64_t LLVMPointerType::getABIAlignment(
const DataLayout &dataLayout,
325 if (std::optional<uint64_t> alignment =
333 LLVMPointerType::getPreferredAlignment(
const DataLayout &dataLayout,
335 if (std::optional<uint64_t> alignment =
342 std::optional<uint64_t>
345 if (std::optional<uint64_t> indexBitwidth =
347 return *indexBitwidth;
354 for (DataLayoutEntryInterface newEntry : newLayout) {
355 if (!newEntry.isTypeEntry())
359 auto newType = llvm::cast<LLVMPointerType>(newEntry.getKey().get<
Type>());
361 llvm::find_if(oldLayout, [&](DataLayoutEntryInterface entry) {
362 if (
auto type = llvm::dyn_cast_if_present<Type>(entry.getKey())) {
363 return llvm::cast<LLVMPointerType>(type).getAddressSpace() ==
364 newType.getAddressSpace();
368 if (it == oldLayout.end()) {
369 llvm::find_if(oldLayout, [&](DataLayoutEntryInterface entry) {
370 if (
auto type = llvm::dyn_cast_if_present<Type>(entry.getKey())) {
371 return llvm::cast<LLVMPointerType>(type).getAddressSpace() == 0;
376 if (it != oldLayout.end()) {
381 Attribute newSpec = llvm::cast<DenseIntElementsAttr>(newEntry.getValue());
384 if (size != newSize || abi < newAbi || abi % newAbi != 0)
392 for (DataLayoutEntryInterface entry : entries) {
393 if (!entry.isTypeEntry())
395 auto key = entry.getKey().get<
Type>();
396 auto values = llvm::dyn_cast<DenseIntElementsAttr>(entry.getValue());
397 if (!values || (values.size() != 3 && values.size() != 4)) {
399 <<
"expected layout attribute for " << key
400 <<
" to be a dense integer elements attribute with 3 or 4 "
403 if (!values.getElementType().
isInteger(64))
404 return emitError(loc) <<
"expected i64 parameters for " << key;
408 return emitError(loc) <<
"preferred alignment is expected to be at least "
409 "as large as ABI alignment";
420 return !llvm::isa<LLVMVoidType, LLVMLabelType, LLVMMetadataType,
421 LLVMFunctionType, LLVMTokenType>(type);
439 std::string stringName =
name.str();
440 unsigned counter = 0;
443 if (type.isInitialized() || failed(type.setBody(elements,
isPacked))) {
445 stringName = (Twine(
name) +
"." + std::to_string(counter)).str();
475 assert(
isIdentified() &&
"can only set bodies of identified structs");
477 "expected valid body types");
478 return Base::mutate(types,
isPacked);
484 return getImpl()->isIdentified() &&
505 return emitError() <<
"invalid LLVM structure element type: " << t;
513 auto structSize = llvm::TypeSize::getFixed(0);
514 uint64_t structAlignment = 1;
516 uint64_t elementAlignment =
520 structSize = llvm::alignTo(structSize, elementAlignment);
525 structAlignment =
std::max(elementAlignment, structAlignment);
529 structSize = llvm::alignTo(structSize, structAlignment);
537 static std::optional<uint64_t>
539 StructDLEntryPos pos) {
540 const auto *currentEntry =
541 llvm::find_if(params, [](DataLayoutEntryInterface entry) {
542 return entry.isTypeEntry();
544 if (currentEntry == params.end())
547 auto attr = llvm::cast<DenseIntElementsAttr>(currentEntry->getValue());
548 if (pos == StructDLEntryPos::Preferred &&
549 attr.size() <=
static_cast<int64_t
>(StructDLEntryPos::Preferred))
551 pos = StructDLEntryPos::Abi;
553 return attr.getValues<uint64_t>()[
static_cast<size_t>(pos)];
559 StructDLEntryPos pos) {
561 if (pos == StructDLEntryPos::Abi && type.
isPacked()) {
567 uint64_t structAlignment = 1;
574 if (std::optional<uint64_t> entryResult =
578 return structAlignment;
584 StructDLEntryPos::Abi);
591 StructDLEntryPos::Preferred);
595 return llvm::cast<DenseIntElementsAttr>(attr)
596 .getValues<uint64_t>()[
static_cast<size_t>(pos)];
601 for (DataLayoutEntryInterface newEntry : newLayout) {
602 if (!newEntry.isTypeEntry())
605 const auto *previousEntry =
606 llvm::find_if(oldLayout, [](DataLayoutEntryInterface entry) {
607 return entry.isTypeEntry();
609 if (previousEntry == oldLayout.end())
613 StructDLEntryPos::Abi);
616 if (abi < newAbi || abi % newAbi != 0)
624 for (DataLayoutEntryInterface entry : entries) {
625 if (!entry.isTypeEntry())
628 auto key = llvm::cast<LLVMStructType>(entry.getKey().get<
Type>());
629 auto values = llvm::dyn_cast<DenseIntElementsAttr>(entry.getValue());
630 if (!values || (values.size() != 2 && values.size() != 1)) {
632 <<
"expected layout attribute for " << entry.getKey().get<
Type>()
633 <<
" to be a dense integer elements attribute of 1 or 2 elements";
635 if (!values.getElementType().
isInteger(64))
636 return emitError(loc) <<
"expected i64 entries for " << key;
638 if (key.isIdentified() || !key.getBody().empty()) {
639 return emitError(loc) <<
"unexpected layout attribute for struct " << key;
642 if (values.size() == 1)
647 return emitError(loc) <<
"preferred alignment is expected to be at least "
648 "as large as ABI alignment";
651 return mlir::success();
659 template <
typename VecTy>
662 Type elementType,
unsigned numElements) {
663 if (numElements == 0)
664 return emitError() <<
"the number of vector elements must be positive";
666 if (!VecTy::isValidElementType(elementType))
667 return emitError() <<
"invalid vector element type";
673 unsigned numElements) {
674 assert(elementType &&
"expected non-null subtype");
680 Type elementType,
unsigned numElements) {
681 assert(elementType &&
"expected non-null subtype");
686 bool LLVMFixedVectorType::isValidElementType(
Type type) {
687 return llvm::isa<LLVMPointerType, LLVMPPCFP128Type>(type);
692 Type elementType,
unsigned numElements) {
693 return verifyVectorConstructionInvariants<LLVMFixedVectorType>(
702 unsigned minNumElements) {
703 assert(elementType &&
"expected non-null subtype");
707 LLVMScalableVectorType
709 Type elementType,
unsigned minNumElements) {
710 assert(elementType &&
"expected non-null subtype");
715 bool LLVMScalableVectorType::isValidElementType(
Type type) {
716 if (
auto intType = llvm::dyn_cast<IntegerType>(type))
717 return intType.isSignless();
720 llvm::isa<LLVMPointerType>(type);
725 Type elementType,
unsigned numElements) {
726 return verifyVectorConstructionInvariants<LLVMScalableVectorType>(
737 bool LLVM::LLVMTargetExtType::hasProperty(Property prop)
const {
739 uint64_t properties = 0;
743 (LLVMTargetExtType::HasZeroInit | LLVM::LLVMTargetExtType::CanBeGlobal);
745 return (properties & prop) == prop;
748 bool LLVM::LLVMTargetExtType::supportsMemOps()
const {
781 LLVMScalableVectorType,
791 if (
auto intType = llvm::dyn_cast<IntegerType>(type))
792 return intType.isSignless();
795 if (
auto vecType = llvm::dyn_cast<VectorType>(type))
796 return vecType.getRank() == 1;
802 if (!compatibleTypes.insert(type).second)
805 auto isCompatible = [&](
Type type) {
812 return llvm::all_of(structType.getBody(), isCompatible);
814 .Case<LLVMFunctionType>([&](
auto funcType) {
815 return isCompatible(funcType.getReturnType()) &&
816 llvm::all_of(funcType.getParams(), isCompatible);
818 .Case<IntegerType>([](
auto intType) {
return intType.isSignless(); })
819 .Case<VectorType>([&](
auto vecType) {
820 return vecType.getRank() == 1 &&
821 isCompatible(vecType.getElementType());
823 .Case<LLVMPointerType>([&](
auto pointerType) {
return true; })
824 .Case<LLVMTargetExtType>([&](
auto extType) {
825 return llvm::all_of(extType.getTypeParams(), isCompatible);
830 LLVMScalableVectorType,
832 >([&](
auto containerType) {
833 return isCompatible(containerType.getElementType());
848 >([](
Type) {
return true; })
850 .Default([](
Type) {
return false; });
853 compatibleTypes.erase(type);
859 if (
auto *llvmDialect =
872 return llvm::isa<BFloat16Type, Float16Type, Float32Type, Float64Type,
873 Float80Type, Float128Type, LLVMPPCFP128Type>(type);
877 if (llvm::isa<LLVMFixedVectorType, LLVMScalableVectorType>(type))
880 if (
auto vecType = llvm::dyn_cast<VectorType>(type)) {
881 if (vecType.getRank() != 1)
883 Type elementType = vecType.getElementType();
884 if (
auto intType = llvm::dyn_cast<IntegerType>(elementType))
885 return intType.isSignless();
886 return llvm::isa<BFloat16Type, Float16Type, Float32Type, Float64Type,
887 Float80Type, Float128Type>(elementType);
894 .Case<LLVMFixedVectorType, LLVMScalableVectorType, VectorType>(
895 [](
auto ty) {
return ty.getElementType(); })
897 llvm_unreachable(
"incompatible with LLVM vector type");
903 .Case([](VectorType ty) {
905 return llvm::ElementCount::getScalable(ty.getNumElements());
906 return llvm::ElementCount::getFixed(ty.getNumElements());
908 .Case([](LLVMFixedVectorType ty) {
909 return llvm::ElementCount::getFixed(ty.getNumElements());
911 .Case([](LLVMScalableVectorType ty) {
912 return llvm::ElementCount::getScalable(ty.getMinNumElements());
914 .Default([](
Type) -> llvm::ElementCount {
915 llvm_unreachable(
"incompatible with LLVM vector type");
920 assert((llvm::isa<LLVMFixedVectorType, LLVMScalableVectorType, VectorType>(
922 "expected LLVM-compatible vector type");
923 return !llvm::isa<LLVMFixedVectorType>(vectorType) &&
924 (llvm::isa<LLVMScalableVectorType>(vectorType) ||
925 llvm::cast<VectorType>(vectorType).isScalable());
930 bool useLLVM = LLVMFixedVectorType::isValidElementType(elementType);
931 bool useBuiltIn = VectorType::isValidElementType(elementType);
933 assert((useLLVM ^ useBuiltIn) &&
"expected LLVM-compatible fixed-vector type "
934 "to be either builtin or LLVM dialect type");
947 const llvm::ElementCount &numElements) {
948 if (numElements.isScalable())
949 return getVectorType(elementType, numElements.getKnownMinValue(),
951 return getVectorType(elementType, numElements.getFixedValue(),
956 bool useLLVM = LLVMFixedVectorType::isValidElementType(elementType);
957 bool useBuiltIn = VectorType::isValidElementType(elementType);
959 assert((useLLVM ^ useBuiltIn) &&
"expected LLVM-compatible fixed-vector type "
960 "to be either builtin or LLVM dialect type");
967 bool useLLVM = LLVMScalableVectorType::isValidElementType(elementType);
968 bool useBuiltIn = VectorType::isValidElementType(elementType);
970 assert((useLLVM ^ useBuiltIn) &&
"expected LLVM-compatible scalable-vector "
971 "type to be either builtin or LLVM dialect "
983 "expected a type compatible with the LLVM dialect");
986 .Case<BFloat16Type, Float16Type>(
987 [](
Type) {
return llvm::TypeSize::getFixed(16); })
988 .Case<Float32Type>([](
Type) {
return llvm::TypeSize::getFixed(32); })
989 .Case<Float64Type>([](
Type) {
return llvm::TypeSize::getFixed(64); })
990 .Case<Float80Type>([](
Type) {
return llvm::TypeSize::getFixed(80); })
991 .Case<Float128Type>([](
Type) {
return llvm::TypeSize::getFixed(128); })
992 .Case<IntegerType>([](IntegerType intTy) {
993 return llvm::TypeSize::getFixed(intTy.getWidth());
995 .Case<LLVMPPCFP128Type>(
996 [](
Type) {
return llvm::TypeSize::getFixed(128); })
997 .Case<LLVMFixedVectorType>([](LLVMFixedVectorType t) {
998 llvm::TypeSize elementSize =
1000 return llvm::TypeSize(elementSize.getFixedValue() * t.getNumElements(),
1001 elementSize.isScalable());
1003 .Case<VectorType>([](VectorType t) {
1005 "unexpected incompatible with LLVM vector type");
1006 llvm::TypeSize elementSize =
1008 return llvm::TypeSize(elementSize.getFixedValue() * t.getNumElements(),
1009 elementSize.isScalable());
1011 .Default([](
Type ty) {
1012 assert((llvm::isa<LLVMVoidType, LLVMLabelType, LLVMMetadataType,
1014 LLVMPointerType, LLVMFunctionType, LLVMTargetExtType>(
1016 "unexpected missing support for primitive type");
1017 return llvm::TypeSize::getFixed(0);
1025 void LLVMDialect::registerTypes() {
1027 #define GET_TYPEDEF_LIST
1028 #include "mlir/Dialect/LLVMIR/LLVMTypes.cpp.inc"
static LogicalResult verifyEntries(function_ref< InFlightDiagnostic()> emitError, ArrayRef< DataLayoutEntryInterface > entries, bool allowTypes=true)
Verify entries, with the option to disallow types as keys.
static uint64_t getIndexBitwidth(DataLayoutEntryListRef params)
Returns the bitwidth of the index type if specified in the param list.
static MLIRContext * getContext(OpFoldResult val)
static int64_t getNumElements(Type t)
Compute the total number of elements in the given type, also taking into account nested types.
constexpr static const uint64_t kDefaultPointerAlignment
static void printExtTypeParams(AsmPrinter &p, ArrayRef< Type > typeParams, ArrayRef< unsigned int > intParams)
constexpr static const uint64_t kDefaultPointerSizeBits
static LLVM_ATTRIBUTE_UNUSED OptionalParseResult generatedTypeParser(AsmParser &parser, StringRef *mnemonic, Type &value)
These are unused for now.
static void printFunctionTypes(AsmPrinter &p, ArrayRef< Type > params, bool isVarArg)
static bool isCompatibleImpl(Type type, DenseSet< Type > &compatibleTypes)
static ParseResult parseExtTypeParams(AsmParser &p, SmallVectorImpl< Type > &typeParams, SmallVectorImpl< unsigned int > &intParams)
Parses the parameter list for a target extension type.
static LLVM_ATTRIBUTE_UNUSED LogicalResult generatedTypePrinter(Type def, AsmPrinter &printer)
static constexpr llvm::StringRef kSpirvPrefix
static LogicalResult verifyVectorConstructionInvariants(function_ref< InFlightDiagnostic()> emitError, Type elementType, unsigned numElements)
Verifies that the type about to be constructed is well-formed.
static ParseResult parseFunctionTypes(AsmParser &p, SmallVector< Type > ¶ms, bool &isVarArg)
constexpr static const uint64_t kBitsInByte
static constexpr llvm::StringRef kArmSVCount
static std::optional< uint64_t > getPointerDataLayoutEntry(DataLayoutEntryListRef params, LLVMPointerType type, PtrDLEntryPos pos)
Returns the part of the data layout entry that corresponds to pos for the given type by interpreting ...
static std::optional< uint64_t > getStructDataLayoutEntry(DataLayoutEntryListRef params, LLVMStructType type, StructDLEntryPos pos)
static uint64_t extractStructSpecValue(Attribute attr, StructDLEntryPos pos)
static uint64_t calculateStructAlignment(const DataLayout &dataLayout, DataLayoutEntryListRef params, LLVMStructType type, StructDLEntryPos pos)
static SmallVector< Type > getReturnTypes(SmallVector< func::ReturnOp > returnOps)
Helper function that returns the return types (skipping casts) of the given func.return ops.
static Value max(ImplicitLocOpBuilder &builder, Value value, Value bound)
static Type getElementType(Type type, ArrayRef< int32_t > indices, function_ref< InFlightDiagnostic(StringRef)> emitErrorFn)
Walks the given type hierarchy with the given indices, potentially down to component granularity,...
This base class exposes generic asm parser hooks, usable across the various derived parsers.
virtual OptionalParseResult parseOptionalInteger(APInt &result)=0
Parse an optional integer value from the stream.
virtual ParseResult parseCommaSeparatedList(Delimiter delimiter, function_ref< ParseResult()> parseElementFn, StringRef contextMessage=StringRef())=0
Parse a list of comma-separated items with an optional delimiter.
virtual ParseResult parseRParen()=0
Parse a ) token.
virtual InFlightDiagnostic emitError(SMLoc loc, const Twine &message={})=0
Emit a diagnostic at the specified location and return failure.
virtual ParseResult parseOptionalRParen()=0
Parse a ) token if present.
virtual SMLoc getCurrentLocation()=0
Get the location of the next token and store it into the argument.
virtual ParseResult parseOptionalComma()=0
Parse a , token if present.
virtual ParseResult parseOptionalEllipsis()=0
Parse a ... token if present;.
This base class exposes generic asm printer hooks, usable across the various derived printers.
Attributes are known-constant values of operations.
The main mechanism for performing data layout queries.
std::optional< uint64_t > getTypeIndexBitwidth(Type t) const
Returns the bitwidth that should be used when performing index computations for the given pointer-lik...
llvm::TypeSize getTypeSize(Type t) const
Returns the size of the given type in the current scope.
uint64_t getTypePreferredAlignment(Type t) const
Returns the preferred of the given type in the current scope.
uint64_t getTypeABIAlignment(Type t) const
Returns the required alignment of the given type in the current scope.
llvm::TypeSize getTypeSizeInBits(Type t) const
Returns the size in bits of the given type in the current scope.
The DialectAsmParser has methods for interacting with the asm parser when parsing attributes and type...
This is a pure-virtual base class that exposes the asmprinter hooks necessary to implement a custom p...
This class represents a diagnostic that is inflight and set to be reported.
LLVM dialect structure type representing a collection of different-typed elements manipulated togethe...
static LLVMStructType getLiteralChecked(function_ref< InFlightDiagnostic()> emitError, MLIRContext *context, ArrayRef< Type > types, bool isPacked=false)
LogicalResult setBody(ArrayRef< Type > types, bool isPacked)
Set the body of an identified struct.
static bool isValidElementType(Type type)
Checks if the given type can be contained in a structure type.
uint64_t getABIAlignment(const DataLayout &dataLayout, DataLayoutEntryListRef params) const
StringRef getName()
Returns the name of an identified struct.
static LLVMStructType getOpaqueChecked(function_ref< InFlightDiagnostic()> emitError, MLIRContext *context, StringRef name)
LogicalResult verifyEntries(DataLayoutEntryListRef entries, Location loc) const
bool isPacked() const
Checks if a struct is packed.
static LLVMStructType getIdentifiedChecked(function_ref< InFlightDiagnostic()> emitError, MLIRContext *context, StringRef name)
ArrayRef< Type > getBody() const
Returns the list of element types contained in a non-opaque struct.
bool isInitialized()
Checks if a struct is initialized.
bool isOpaque()
Checks if a struct is opaque.
bool areCompatible(DataLayoutEntryListRef oldLayout, DataLayoutEntryListRef newLayout) const
llvm::TypeSize getTypeSizeInBits(const DataLayout &dataLayout, DataLayoutEntryListRef params) const
Hooks for DataLayoutTypeInterface.
static LLVMStructType getLiteral(MLIRContext *context, ArrayRef< Type > types, bool isPacked=false)
Gets or creates a literal struct with the given body in the provided context.
static LLVMStructType getNewIdentified(MLIRContext *context, StringRef name, ArrayRef< Type > elements, bool isPacked=false)
Gets a new identified struct with the given body.
static LLVMStructType getIdentified(MLIRContext *context, StringRef name)
Gets or creates an identified struct with the given name in the provided context.
static LLVMStructType getOpaque(StringRef name, MLIRContext *context)
Gets or creates an intentionally-opaque identified struct.
uint64_t getPreferredAlignment(const DataLayout &dataLayout, DataLayoutEntryListRef params) const
static LogicalResult verifyInvariants(function_ref< InFlightDiagnostic()> emitError, StringRef, bool)
Verifies that the type about to be constructed is well-formed.
bool isIdentified() const
Checks if a struct is identified.
static constexpr StringLiteral name
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
MLIRContext is the top-level object for a collection of MLIR operations.
Dialect * getLoadedDialect(StringRef name)
Get a registered IR dialect with the given namespace.
This class implements Optional functionality for ParseResult.
This class provides an abstraction over the various different ranges of value types.
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 isInteger() const
Return true if this is an integer type (with the specified width).
ImplType * getImpl() const
Utility for easy access to the storage instance.
void printType(Type type, AsmPrinter &printer)
Prints an LLVM Dialect type.
Type parseType(DialectAsmParser &parser)
Parses an LLVM dialect type.
Type getVectorType(Type elementType, unsigned numElements, bool isScalable=false)
Creates an LLVM dialect-compatible vector type with the given element type and length.
llvm::TypeSize getPrimitiveTypeSizeInBits(Type type)
Returns the size of the given primitive LLVM dialect-compatible type (including vectors) in bits,...
void printPrettyLLVMType(AsmPrinter &p, Type type)
Print any MLIR type or a concise syntax for LLVM types.
bool isScalableVectorType(Type vectorType)
Returns whether a vector type is scalable or not.
ParseResult parsePrettyLLVMType(AsmParser &p, Type &type)
Parse any MLIR type or a concise syntax for LLVM types.
bool isCompatibleVectorType(Type type)
Returns true if the given type is a vector type compatible with the LLVM dialect.
bool isCompatibleOuterType(Type type)
Returns true if the given outer type is compatible with the LLVM dialect without checking its potenti...
Type getFixedVectorType(Type elementType, unsigned numElements)
Creates an LLVM dialect-compatible type with the given element type and length.
PtrDLEntryPos
The positions of different values in the data layout entry for pointers.
std::optional< uint64_t > extractPointerSpecValue(Attribute attr, PtrDLEntryPos pos)
Returns the value that corresponds to named position pos from the data layout entry attr assuming it'...
bool isCompatibleType(Type type)
Returns true if the given type is compatible with the LLVM dialect.
Type getScalableVectorType(Type elementType, unsigned numElements)
Creates an LLVM dialect-compatible type with the given element type and length.
bool isCompatibleFloatingPointType(Type type)
Returns true if the given type is a floating-point type compatible with the LLVM dialect.
llvm::ElementCount getVectorNumElements(Type type)
Returns the element count of any LLVM-compatible vector type.
Type getVectorElementType(Type type)
Returns the element type of any vector type compatible with the LLVM dialect.
Include the generated interface declarations.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
Operation * clone(OpBuilder &b, Operation *op, TypeRange newResultTypes, ValueRange newOperands)
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...
Type parseType(llvm::StringRef typeStr, MLIRContext *context, size_t *numRead=nullptr, bool isKnownNullTerminated=false)
This parses a single MLIR type to an MLIR context if it was valid.
LogicalResult verify(Operation *op, bool verifyRecursively=true)
Perform (potentially expensive) checks of invariants, used to detect compiler bugs,...