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,
83 unsigned &addressSpace) {
102 unsigned addressSpace) {
105 if (addressSpace != 0) {
130 if (intResult.has_value() && !
failed(*intResult)) {
132 intParams.push_back(i);
142 typeParams.push_back(t);
150 "failed to parse parameter list for target extension type");
159 if (!typeParams.empty() && !intParams.empty())
176 #include "mlir/Dialect/LLVMIR/LLVMTypeInterfaces.cpp.inc"
178 #define GET_TYPEDEF_CLASSES
179 #include "mlir/Dialect/LLVMIR/LLVMTypes.cpp.inc"
185 bool LLVMArrayType::isValidElementType(
Type type) {
186 return !llvm::isa<LLVMVoidType, LLVMLabelType, LLVMMetadataType,
187 LLVMFunctionType, LLVMTokenType, LLVMScalableVectorType>(
192 assert(elementType &&
"expected non-null subtype");
198 Type elementType,
unsigned numElements) {
199 assert(elementType &&
"expected non-null subtype");
206 Type elementType,
unsigned numElements) {
207 if (!isValidElementType(elementType))
208 return emitError() <<
"invalid array element type: " << elementType;
215 unsigned LLVMArrayType::getTypeSizeInBits(
const DataLayout &dataLayout,
217 return kBitsInByte * getTypeSize(dataLayout, params);
220 unsigned LLVMArrayType::getTypeSize(
const DataLayout &dataLayout,
227 unsigned LLVMArrayType::getABIAlignment(
const DataLayout &dataLayout,
233 LLVMArrayType::getPreferredAlignment(
const DataLayout &dataLayout,
242 bool LLVMFunctionType::isValidArgumentType(
Type type) {
243 return !llvm::isa<LLVMVoidType, LLVMFunctionType>(type);
246 bool LLVMFunctionType::isValidResultType(
Type type) {
247 return !llvm::isa<LLVMFunctionType, LLVMMetadataType, LLVMLabelType>(type);
252 assert(result &&
"expected non-null result");
260 assert(result &&
"expected non-null result");
267 assert(results.size() == 1 &&
"expected a single result type");
268 return get(results[0], llvm::to_vector(inputs), isVarArg());
272 return static_cast<detail::LLVMFunctionTypeStorage *
>(getImpl())->returnType;
278 if (!isValidResultType(result))
279 return emitError() <<
"invalid function result type: " << result;
281 for (
Type arg : arguments)
282 if (!isValidArgumentType(arg))
283 return emitError() <<
"invalid function argument type: " << arg;
292 bool LLVMPointerType::isValidElementType(
Type type) {
296 ? !llvm::isa<LLVMVoidType, LLVMTokenType, LLVMMetadataType,
298 : llvm::isa<PointerElementTypeInterface>(type);
302 assert(pointee &&
"expected non-null subtype, pass the context instead if "
303 "the opaque pointer type is desired");
309 Type pointee,
unsigned) {
310 if (!isValidElementType(pointee))
311 return emitError() <<
"invalid pointer element type: " << pointee;
323 auto spec = llvm::cast<DenseIntElementsAttr>(attr);
324 auto idx =
static_cast<unsigned>(pos);
325 if (idx >= spec.size())
327 return spec.getValues<
unsigned>()[idx];
334 static std::optional<unsigned>
339 for (DataLayoutEntryInterface entry : params) {
340 if (!entry.isTypeEntry())
342 if (llvm::cast<LLVMPointerType>(entry.getKey().get<
Type>())
343 .getAddressSpace() == type.getAddressSpace()) {
344 currentEntry = entry.getValue();
355 if (type.getAddressSpace() == 0) {
364 LLVMPointerType::getTypeSizeInBits(
const DataLayout &dataLayout,
366 if (std::optional<unsigned> size =
377 unsigned LLVMPointerType::getABIAlignment(
const DataLayout &dataLayout,
379 if (std::optional<unsigned> alignment =
389 LLVMPointerType::getPreferredAlignment(
const DataLayout &dataLayout,
391 if (std::optional<unsigned> alignment =
402 for (DataLayoutEntryInterface newEntry : newLayout) {
403 if (!newEntry.isTypeEntry())
407 auto newType = llvm::cast<LLVMPointerType>(newEntry.getKey().get<
Type>());
409 llvm::find_if(oldLayout, [&](DataLayoutEntryInterface entry) {
410 if (
auto type = llvm::dyn_cast_if_present<Type>(entry.getKey())) {
411 return llvm::cast<LLVMPointerType>(type).getAddressSpace() ==
412 newType.getAddressSpace();
416 if (it == oldLayout.end()) {
417 llvm::find_if(oldLayout, [&](DataLayoutEntryInterface entry) {
418 if (
auto type = llvm::dyn_cast_if_present<Type>(entry.getKey())) {
419 return llvm::cast<LLVMPointerType>(type).getAddressSpace() == 0;
424 if (it != oldLayout.end()) {
429 Attribute newSpec = llvm::cast<DenseIntElementsAttr>(newEntry.getValue());
432 if (size != newSize || abi < newAbi || abi % newAbi != 0)
440 for (DataLayoutEntryInterface entry : entries) {
441 if (!entry.isTypeEntry())
443 auto key = llvm::cast<LLVMPointerType>(entry.getKey().get<
Type>());
444 auto values = llvm::dyn_cast<DenseIntElementsAttr>(entry.getValue());
445 if (!values || (values.size() != 3 && values.size() != 4)) {
447 <<
"expected layout attribute for " << entry.getKey().get<
Type>()
448 <<
" to be a dense integer elements attribute with 3 or 4 "
451 if (key.getElementType() && !key.getElementType().isInteger(8)) {
452 return emitError(loc) <<
"unexpected layout attribute for pointer to "
453 << key.getElementType();
457 return emitError(loc) <<
"preferred alignment is expected to be at least "
458 "as large as ABI alignment";
469 return !llvm::isa<LLVMVoidType, LLVMLabelType, LLVMMetadataType,
470 LLVMFunctionType, LLVMTokenType, LLVMScalableVectorType>(
482 return Base::getChecked(
emitError, context, name,
false);
489 std::string stringName = name.str();
490 unsigned counter = 0;
493 if (type.isInitialized() ||
failed(type.setBody(elements,
isPacked))) {
495 stringName = (Twine(name) +
"." + std::to_string(counter)).str();
521 return Base::getChecked(
emitError, context, name,
true);
525 assert(
isIdentified() &&
"can only set bodies of identified structs");
527 "expected valid body types");
528 return Base::mutate(types,
isPacked);
534 return getImpl()->isIdentified() &&
554 return emitError() <<
"invalid LLVM structure element type: " << t;
562 unsigned structSize = 0;
563 unsigned structAlignment = 1;
565 unsigned elementAlignment =
569 structSize = llvm::alignTo(structSize, elementAlignment);
574 structAlignment =
std::max(elementAlignment, structAlignment);
578 structSize = llvm::alignTo(structSize, structAlignment);
586 static std::optional<unsigned>
588 StructDLEntryPos pos) {
589 const auto *currentEntry =
590 llvm::find_if(params, [](DataLayoutEntryInterface entry) {
591 return entry.isTypeEntry();
593 if (currentEntry == params.end())
596 auto attr = llvm::cast<DenseIntElementsAttr>(currentEntry->getValue());
597 if (pos == StructDLEntryPos::Preferred &&
598 attr.size() <=
static_cast<unsigned>(StructDLEntryPos::Preferred))
600 pos = StructDLEntryPos::Abi;
602 return attr.getValues<
unsigned>()[
static_cast<unsigned>(pos)];
608 StructDLEntryPos pos) {
610 if (pos == StructDLEntryPos::Abi && type.
isPacked()) {
616 unsigned structAlignment = 1;
623 if (std::optional<unsigned> entryResult =
627 return structAlignment;
633 StructDLEntryPos::Abi);
640 StructDLEntryPos::Preferred);
644 return llvm::cast<DenseIntElementsAttr>(attr)
645 .getValues<
unsigned>()[
static_cast<unsigned>(pos)];
650 for (DataLayoutEntryInterface newEntry : newLayout) {
651 if (!newEntry.isTypeEntry())
654 const auto *previousEntry =
655 llvm::find_if(oldLayout, [](DataLayoutEntryInterface entry) {
656 return entry.isTypeEntry();
658 if (previousEntry == oldLayout.end())
662 StructDLEntryPos::Abi);
665 if (abi < newAbi || abi % newAbi != 0)
673 for (DataLayoutEntryInterface entry : entries) {
674 if (!entry.isTypeEntry())
677 auto key = llvm::cast<LLVMStructType>(entry.getKey().get<
Type>());
678 auto values = llvm::dyn_cast<DenseIntElementsAttr>(entry.getValue());
679 if (!values || (values.size() != 2 && values.size() != 1)) {
681 <<
"expected layout attribute for " << entry.getKey().get<
Type>()
682 <<
" to be a dense integer elements attribute of 1 or 2 elements";
685 if (key.isIdentified() || !key.getBody().empty()) {
686 return emitError(loc) <<
"unexpected layout attribute for struct " << key;
689 if (values.size() == 1)
694 return emitError(loc) <<
"preferred alignment is expected to be at least "
695 "as large as ABI alignment";
706 template <
typename VecTy>
709 Type elementType,
unsigned numElements) {
710 if (numElements == 0)
711 return emitError() <<
"the number of vector elements must be positive";
713 if (!VecTy::isValidElementType(elementType))
714 return emitError() <<
"invalid vector element type";
720 unsigned numElements) {
721 assert(elementType &&
"expected non-null subtype");
727 Type elementType,
unsigned numElements) {
728 assert(elementType &&
"expected non-null subtype");
733 bool LLVMFixedVectorType::isValidElementType(
Type type) {
734 return llvm::isa<LLVMPointerType, LLVMPPCFP128Type>(type);
739 Type elementType,
unsigned numElements) {
740 return verifyVectorConstructionInvariants<LLVMFixedVectorType>(
749 unsigned minNumElements) {
750 assert(elementType &&
"expected non-null subtype");
754 LLVMScalableVectorType
756 Type elementType,
unsigned minNumElements) {
757 assert(elementType &&
"expected non-null subtype");
762 bool LLVMScalableVectorType::isValidElementType(
Type type) {
763 if (
auto intType = llvm::dyn_cast<IntegerType>(type))
764 return intType.isSignless();
767 llvm::isa<LLVMPointerType>(type);
772 Type elementType,
unsigned numElements) {
773 return verifyVectorConstructionInvariants<LLVMScalableVectorType>(
784 bool LLVM::LLVMTargetExtType::hasProperty(Property prop)
const {
786 uint64_t properties = 0;
790 (LLVMTargetExtType::HasZeroInit | LLVM::LLVMTargetExtType::CanBeGlobal);
792 return (properties & prop) == prop;
795 bool LLVM::LLVMTargetExtType::supportsMemOps()
const {
830 LLVMScalableVectorType,
840 if (
auto intType = llvm::dyn_cast<IntegerType>(type))
841 return intType.isSignless();
844 if (
auto vecType = llvm::dyn_cast<VectorType>(type))
845 return vecType.getRank() == 1;
851 if (!compatibleTypes.insert(type).second)
854 auto isCompatible = [&](
Type type) {
861 return llvm::all_of(structType.getBody(), isCompatible);
863 .Case<LLVMFunctionType>([&](
auto funcType) {
864 return isCompatible(funcType.getReturnType()) &&
865 llvm::all_of(funcType.getParams(), isCompatible);
867 .Case<IntegerType>([](
auto intType) {
return intType.isSignless(); })
868 .Case<VectorType>([&](
auto vecType) {
869 return vecType.getRank() == 1 &&
870 isCompatible(vecType.getElementType());
872 .Case<LLVMPointerType>([&](
auto pointerType) {
873 if (pointerType.isOpaque())
875 return isCompatible(pointerType.getElementType());
877 .Case<LLVMTargetExtType>([&](
auto extType) {
878 return llvm::all_of(extType.getTypeParams(), isCompatible);
883 LLVMScalableVectorType,
885 >([&](
auto containerType) {
886 return isCompatible(containerType.getElementType());
903 >([](
Type) {
return true; })
905 .Default([](
Type) {
return false; });
908 compatibleTypes.erase(type);
914 if (
auto *llvmDialect =
927 return llvm::isa<BFloat16Type, Float16Type, Float32Type, Float64Type,
928 Float80Type, Float128Type, LLVMPPCFP128Type>(type);
932 if (llvm::isa<LLVMFixedVectorType, LLVMScalableVectorType>(type))
935 if (
auto vecType = llvm::dyn_cast<VectorType>(type)) {
936 if (vecType.getRank() != 1)
938 Type elementType = vecType.getElementType();
939 if (
auto intType = llvm::dyn_cast<IntegerType>(elementType))
940 return intType.isSignless();
941 return llvm::isa<BFloat16Type, Float16Type, Float32Type, Float64Type,
942 Float80Type, Float128Type>(elementType);
949 .Case<LLVMFixedVectorType, LLVMScalableVectorType, VectorType>(
950 [](
auto ty) {
return ty.getElementType(); })
952 llvm_unreachable(
"incompatible with LLVM vector type");
958 .Case([](VectorType ty) {
960 return llvm::ElementCount::getScalable(ty.getNumElements());
961 return llvm::ElementCount::getFixed(ty.getNumElements());
963 .Case([](LLVMFixedVectorType ty) {
964 return llvm::ElementCount::getFixed(ty.getNumElements());
966 .Case([](LLVMScalableVectorType ty) {
967 return llvm::ElementCount::getScalable(ty.getMinNumElements());
969 .Default([](
Type) -> llvm::ElementCount {
970 llvm_unreachable(
"incompatible with LLVM vector type");
975 assert((llvm::isa<LLVMFixedVectorType, LLVMScalableVectorType, VectorType>(
977 "expected LLVM-compatible vector type");
978 return !llvm::isa<LLVMFixedVectorType>(vectorType) &&
979 (llvm::isa<LLVMScalableVectorType>(vectorType) ||
980 llvm::cast<VectorType>(vectorType).isScalable());
985 bool useLLVM = LLVMFixedVectorType::isValidElementType(elementType);
986 bool useBuiltIn = VectorType::isValidElementType(elementType);
988 assert((useLLVM ^ useBuiltIn) &&
"expected LLVM-compatible fixed-vector type "
989 "to be either builtin or LLVM dialect type");
1002 const llvm::ElementCount &numElements) {
1003 if (numElements.isScalable())
1004 return getVectorType(elementType, numElements.getKnownMinValue(),
1006 return getVectorType(elementType, numElements.getFixedValue(),
1011 bool useLLVM = LLVMFixedVectorType::isValidElementType(elementType);
1012 bool useBuiltIn = VectorType::isValidElementType(elementType);
1014 assert((useLLVM ^ useBuiltIn) &&
"expected LLVM-compatible fixed-vector type "
1015 "to be either builtin or LLVM dialect type");
1022 bool useLLVM = LLVMScalableVectorType::isValidElementType(elementType);
1023 bool useBuiltIn = VectorType::isValidElementType(elementType);
1025 assert((useLLVM ^ useBuiltIn) &&
"expected LLVM-compatible scalable-vector "
1026 "type to be either builtin or LLVM dialect "
1038 "expected a type compatible with the LLVM dialect");
1041 .Case<BFloat16Type, Float16Type>(
1042 [](
Type) {
return llvm::TypeSize::Fixed(16); })
1043 .Case<Float32Type>([](
Type) {
return llvm::TypeSize::Fixed(32); })
1044 .Case<Float64Type, LLVMX86MMXType>(
1045 [](
Type) {
return llvm::TypeSize::Fixed(64); })
1046 .Case<Float80Type>([](
Type) {
return llvm::TypeSize::Fixed(80); })
1047 .Case<Float128Type>([](
Type) {
return llvm::TypeSize::Fixed(128); })
1048 .Case<IntegerType>([](IntegerType intTy) {
1049 return llvm::TypeSize::Fixed(intTy.getWidth());
1051 .Case<LLVMPPCFP128Type>([](
Type) {
return llvm::TypeSize::Fixed(128); })
1052 .Case<LLVMFixedVectorType>([](LLVMFixedVectorType t) {
1053 llvm::TypeSize elementSize =
1055 return llvm::TypeSize(elementSize.getFixedValue() * t.getNumElements(),
1056 elementSize.isScalable());
1058 .Case<VectorType>([](VectorType t) {
1060 "unexpected incompatible with LLVM vector type");
1061 llvm::TypeSize elementSize =
1063 return llvm::TypeSize(elementSize.getFixedValue() * t.getNumElements(),
1064 elementSize.isScalable());
1066 .Default([](
Type ty) {
1067 assert((llvm::isa<LLVMVoidType, LLVMLabelType, LLVMMetadataType,
1069 LLVMPointerType, LLVMFunctionType, LLVMTargetExtType>(
1071 "unexpected missing support for primitive type");
1072 return llvm::TypeSize::Fixed(0);
1080 void LLVMDialect::registerTypes() {
1082 #define GET_TYPEDEF_LIST
1083 #include "mlir/Dialect/LLVMIR/LLVMTypes.cpp.inc"
static MLIRContext * getContext(OpFoldResult val)
static unsigned calculateStructAlignment(const DataLayout &dataLayout, DataLayoutEntryListRef params, LLVMStructType type, StructDLEntryPos pos)
static void printExtTypeParams(AsmPrinter &p, ArrayRef< Type > typeParams, ArrayRef< unsigned int > intParams)
static LLVM_ATTRIBUTE_UNUSED OptionalParseResult generatedTypeParser(AsmParser &parser, StringRef *mnemonic, Type &value)
These are unused for now.
constexpr static const unsigned kDefaultPointerAlignment
static void printFunctionTypes(AsmPrinter &p, ArrayRef< Type > params, bool isVarArg)
static bool isCompatibleImpl(Type type, DenseSet< Type > &compatibleTypes)
static void printPointer(AsmPrinter &p, Type elementType, unsigned addressSpace)
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)
static unsigned extractStructSpecValue(Attribute attr, StructDLEntryPos pos)
static constexpr llvm::StringRef kArmSVCount
constexpr static const unsigned kDefaultPointerSizeBits
static std::optional< unsigned > 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 ...
constexpr static const unsigned kBitsInByte
static std::optional< unsigned > getStructDataLayoutEntry(DataLayoutEntryListRef params, LLVMStructType type, StructDLEntryPos pos)
static ParseResult parsePointer(AsmParser &p, Type &elementType, unsigned &addressSpace)
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,...
static int64_t getNumElements(ShapedType type)
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.
ParseResult parseInteger(IntT &result)
Parse an integer value from the stream.
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.
unsigned getTypeABIAlignment(Type t) const
Returns the required alignment of the given type in the current scope.
unsigned getTypeSizeInBits(Type t) const
Returns the size in bits of the given type in the current scope.
unsigned getTypePreferredAlignment(Type t) const
Returns the preferred of the given type in the current scope.
unsigned getTypeSize(Type t) const
Returns the size 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.
unsigned getTypeSizeInBits(const DataLayout &dataLayout, DataLayoutEntryListRef params) const
Hooks for DataLayoutTypeInterface.
static bool isValidElementType(Type type)
Checks if the given type can be contained in a structure type.
unsigned getPreferredAlignment(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.
static LogicalResult verify(function_ref< InFlightDiagnostic()> emitError, StringRef, bool)
Verifies that the type about to be constructed is well-formed.
bool areCompatible(DataLayoutEntryListRef oldLayout, DataLayoutEntryListRef newLayout) const
unsigned getABIAlignment(const DataLayout &dataLayout, DataLayoutEntryListRef params) const
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.
bool isIdentified() const
Checks if a struct is identified.
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.
ParseResult value() const
Access the internal ParseResult value.
bool has_value() const
Returns true if we contain a valid ParseResult value.
This class represents success/failure for parsing-like operations that find it important to chain tog...
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.
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.
std::optional< unsigned > extractPointerSpecValue(Attribute attr, PtrDLEntryPos pos)
Returns the value that corresponds to named position pos from the data layout entry attr assuming it'...
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.
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.
This header declares functions that assist transformations in the MemRef dialect.
LogicalResult failure(bool isFailure=true)
Utility function to generate a LogicalResult.
InFlightDiagnostic emitError(Location loc)
Utility method to emit an error message using this location.
bool succeeded(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a success value.
LogicalResult success(bool isSuccess=true)
Utility function to generate a LogicalResult.
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,...
bool failed(LogicalResult result)
Utility function that returns true if the provided LogicalResult corresponds to a failure value.
This class represents an efficient way to signal success or failure.