MLIR  16.0.0git
Namespaces | Classes | Typedefs | Enumerations | Functions | Variables
mlir::LLVM Namespace Reference

Namespaces

 detail
 

Classes

class  GEPArg
 Class used for building a 'llvm.getelementptr'. More...
 
class  GEPIndicesAdaptor
 Class used for convenient access and iteration over GEP indices. More...
 
class  LLVMArrayType
 LLVM dialect array type. More...
 
class  LLVMFixedVectorType
 LLVM dialect fixed vector type, represents a sequence of elements of known length that can be processed as one. More...
 
class  LLVMFunctionType
 LLVM dialect function type. More...
 
class  LLVMPointerType
 LLVM dialect pointer type. More...
 
class  LLVMScalableVectorType
 LLVM dialect scalable vector type, represents a sequence of elements of unknown length that is known to be divisible by some constant. More...
 
class  LLVMStructType
 LLVM dialect structure type representing a collection of different-typed elements manipulated together. More...
 
class  LoopOptionsAttrBuilder
 Builder class for LoopOptionsAttr. More...
 
class  ModuleTranslation
 Implementation class for module translation. More...
 
class  TypeFromLLVMIRTranslator
 Utility class to translate LLVM IR types to the MLIR LLVM dialect. More...
 
class  TypeToLLVMIRTranslator
 Utility class to translate MLIR LLVM dialect types to LLVM IR. More...
 

Typedefs

using GEPConstantIndex = llvm::PointerEmbeddedInt< int32_t, kGEPConstantBitWidth >
 Wrapper around a int32_t for use in a PointerUnion. More...
 

Enumerations

enum  PtrDLEntryPos { PtrDLEntryPos::Size = 0, PtrDLEntryPos::Abi = 1, PtrDLEntryPos::Preferred = 2, PtrDLEntryPos::Index = 3 }
 The positions of different values in the data layout entry for pointers. More...
 

Functions

LLVM::LLVMFuncOp lookupOrCreatePrintI64Fn (ModuleOp moduleOp)
 Helper functions to lookup or create the declaration for commonly used external C function calls. More...
 
LLVM::LLVMFuncOp lookupOrCreatePrintU64Fn (ModuleOp moduleOp)
 
LLVM::LLVMFuncOp lookupOrCreatePrintF32Fn (ModuleOp moduleOp)
 
LLVM::LLVMFuncOp lookupOrCreatePrintF64Fn (ModuleOp moduleOp)
 
LLVM::LLVMFuncOp lookupOrCreatePrintOpenFn (ModuleOp moduleOp)
 
LLVM::LLVMFuncOp lookupOrCreatePrintCloseFn (ModuleOp moduleOp)
 
LLVM::LLVMFuncOp lookupOrCreatePrintCommaFn (ModuleOp moduleOp)
 
LLVM::LLVMFuncOp lookupOrCreatePrintNewlineFn (ModuleOp moduleOp)
 
LLVM::LLVMFuncOp lookupOrCreateMallocFn (ModuleOp moduleOp, Type indexType)
 
LLVM::LLVMFuncOp lookupOrCreateAlignedAllocFn (ModuleOp moduleOp, Type indexType)
 
LLVM::LLVMFuncOp lookupOrCreateFreeFn (ModuleOp moduleOp)
 
LLVM::LLVMFuncOp lookupOrCreateGenericAllocFn (ModuleOp moduleOp, Type indexType)
 
LLVM::LLVMFuncOp lookupOrCreateGenericAlignedAllocFn (ModuleOp moduleOp, Type indexType)
 
LLVM::LLVMFuncOp lookupOrCreateGenericFreeFn (ModuleOp moduleOp)
 
LLVM::LLVMFuncOp lookupOrCreateMemRefCopyFn (ModuleOp moduleOp, Type indexType, Type unrankedDescriptorType)
 
LLVM::LLVMFuncOp lookupOrCreateFn (ModuleOp moduleOp, StringRef name, ArrayRef< Type > paramTypes={}, Type resultType={})
 Create a FuncOp with signature resultType(paramTypes)and namename`. More...
 
Value createGlobalString (Location loc, OpBuilder &builder, StringRef name, StringRef value, Linkage linkage)
 Create an LLVM global containing the string "value" at the module containing surrounding the insertion point of builder. More...
 
bool satisfiesLLVMModule (Operation *op)
 LLVM requires some operations to be inside of a Module operation. More...
 
template<typename IntT = int64_t>
SmallVector< IntT > convertArrayToIndices (ArrayRef< Attribute > attrs)
 Convert an array of integer attributes to a vector of integers that can be used as indices in LLVM operations. More...
 
template<typename IntT = int64_t>
SmallVector< IntT > convertArrayToIndices (ArrayAttr attrs)
 Convert an ArrayAttr of integer attributes to a vector of integers that can be used as indices in LLVM operations. More...
 
 DEFINE_TRIVIAL_LLVM_TYPE (LLVMVoidType)
 
 DEFINE_TRIVIAL_LLVM_TYPE (LLVMPPCFP128Type)
 
 DEFINE_TRIVIAL_LLVM_TYPE (LLVMX86MMXType)
 
 DEFINE_TRIVIAL_LLVM_TYPE (LLVMTokenType)
 
 DEFINE_TRIVIAL_LLVM_TYPE (LLVMLabelType)
 
 DEFINE_TRIVIAL_LLVM_TYPE (LLVMMetadataType)
 
bool isCompatibleType (Type type)
 Returns true if the given type is compatible with the LLVM dialect. More...
 
bool isCompatibleOuterType (Type type)
 Returns true if the given outer type is compatible with the LLVM dialect without checking its potential nested types such as struct elements. More...
 
bool isCompatibleFloatingPointType (Type type)
 Returns true if the given type is a floating-point type compatible with the LLVM dialect. More...
 
bool isCompatibleVectorType (Type type)
 Returns true if the given type is a vector type compatible with the LLVM dialect. More...
 
Type getVectorElementType (Type type)
 Returns the element type of any vector type compatible with the LLVM dialect. More...
 
llvm::ElementCount getVectorNumElements (Type type)
 Returns the element count of any LLVM-compatible vector type. More...
 
bool isScalableVectorType (Type vectorType)
 Returns whether a vector type is scalable or not. More...
 
Type getVectorType (Type elementType, unsigned numElements, bool isScalable=false)
 Creates an LLVM dialect-compatible vector type with the given element type and length. More...
 
Type getFixedVectorType (Type elementType, unsigned numElements)
 Creates an LLVM dialect-compatible type with the given element type and length. More...
 
Type getScalableVectorType (Type elementType, unsigned numElements)
 Creates an LLVM dialect-compatible type with the given element type and length. More...
 
llvm::TypeSize getPrimitiveTypeSizeInBits (Type type)
 Returns the size of the given primitive LLVM dialect-compatible type (including vectors) in bits, for example, the size of i16 is 16 and the size of vector<4xi16> is 64. More...
 
Optional< unsignedextractPointerSpecValue (Attribute attr, PtrDLEntryPos pos)
 Returns the value that corresponds to named position pos from the data layout entry attr assuming it's a dense integer elements attribute. More...
 
void ensureDistinctSuccessors (Operation *op)
 Make argument-taking successors of each block distinct. More...
 
std::unique_ptr< PasscreateLegalizeForExportPass ()
 Creates a pass that legalizes the LLVM dialect operations so that they can be translated to LLVM IR. More...
 
std::unique_ptr< PasscreateRequestCWrappersPass ()
 

Variables

constexpr int kGEPConstantBitWidth = 29
 Bit-width of a 'GEPConstantIndex' within GEPArg. More...
 

Typedef Documentation

◆ GEPConstantIndex

using mlir::LLVM::GEPConstantIndex = typedef llvm::PointerEmbeddedInt<int32_t, kGEPConstantBitWidth>

Wrapper around a int32_t for use in a PointerUnion.

Definition at line 85 of file LLVMDialect.h.

Enumeration Type Documentation

◆ PtrDLEntryPos

The positions of different values in the data layout entry for pointers.

Enumerator
Size 
Abi 
Preferred 
Index 

Definition at line 539 of file LLVMTypes.h.

Function Documentation

◆ convertArrayToIndices() [1/2]

template<typename IntT = int64_t>
SmallVector<IntT> mlir::LLVM::convertArrayToIndices ( ArrayRef< Attribute attrs)

Convert an array of integer attributes to a vector of integers that can be used as indices in LLVM operations.

Definition at line 282 of file LLVMDialect.h.

Referenced by convertStructType().

◆ convertArrayToIndices() [2/2]

template<typename IntT = int64_t>
SmallVector<IntT> mlir::LLVM::convertArrayToIndices ( ArrayAttr  attrs)

Convert an ArrayAttr of integer attributes to a vector of integers that can be used as indices in LLVM operations.

Definition at line 293 of file LLVMDialect.h.

◆ createGlobalString()

Value mlir::LLVM::createGlobalString ( Location  loc,
OpBuilder builder,
StringRef  name,
StringRef  value,
LLVM::Linkage  linkage 
)

Create an LLVM global containing the string "value" at the module containing surrounding the insertion point of builder.

Obtain the address of that global and use it to compute the address of the first character in the string (operations inserted at the builder insertion point).

Definition at line 2799 of file LLVMDialect.cpp.

References mlir::OpBuilder::create(), mlir::LLVM::LLVMArrayType::get(), mlir::LLVM::LLVMPointerType::get(), mlir::Builder::getContext(), mlir::OpBuilder::getInsertionBlock(), mlir::OpBuilder::getListener(), mlir::Operation::getParentOfType(), mlir::Block::getParentOp(), and mlir::Builder::getStringAttr().

Referenced by mlir::LLVM::GEPIndicesAdaptor< DynamicRange >::end(), and isDefinedByCallTo().

◆ createLegalizeForExportPass()

std::unique_ptr< Pass > mlir::LLVM::createLegalizeForExportPass ( )

Creates a pass that legalizes the LLVM dialect operations so that they can be translated to LLVM IR.

Definition at line 86 of file LegalizeForExport.cpp.

◆ createRequestCWrappersPass()

std::unique_ptr< Pass > mlir::LLVM::createRequestCWrappersPass ( )

Definition at line 34 of file RequestCWrappers.cpp.

◆ DEFINE_TRIVIAL_LLVM_TYPE() [1/6]

mlir::LLVM::DEFINE_TRIVIAL_LLVM_TYPE ( LLVMVoidType  )

◆ DEFINE_TRIVIAL_LLVM_TYPE() [2/6]

mlir::LLVM::DEFINE_TRIVIAL_LLVM_TYPE ( LLVMPPCFP128Type  )

◆ DEFINE_TRIVIAL_LLVM_TYPE() [3/6]

mlir::LLVM::DEFINE_TRIVIAL_LLVM_TYPE ( LLVMX86MMXType  )

◆ DEFINE_TRIVIAL_LLVM_TYPE() [4/6]

mlir::LLVM::DEFINE_TRIVIAL_LLVM_TYPE ( LLVMTokenType  )

◆ DEFINE_TRIVIAL_LLVM_TYPE() [5/6]

mlir::LLVM::DEFINE_TRIVIAL_LLVM_TYPE ( LLVMLabelType  )

◆ DEFINE_TRIVIAL_LLVM_TYPE() [6/6]

mlir::LLVM::DEFINE_TRIVIAL_LLVM_TYPE ( LLVMMetadataType  )

◆ ensureDistinctSuccessors()

void mlir::LLVM::ensureDistinctSuccessors ( Operation op)

Make argument-taking successors of each block distinct.

PHI nodes in LLVM IR use the predecessor ID to identify which value to take. They do not support different values coming from the same predecessor. If a block has another block as a successor more than once with different values, insert a new dummy block for LLVM PHI nodes to tell the sources apart.

Definition at line 67 of file LegalizeForExport.cpp.

References mlir::Operation::getRegions(), and mlir::Operation::walk().

Referenced by prepareLLVMModule().

◆ extractPointerSpecValue()

Optional< unsigned > mlir::LLVM::extractPointerSpecValue ( Attribute  attr,
PtrDLEntryPos  pos 
)

Returns the value that corresponds to named position pos from the data layout entry attr assuming it's a dense integer elements attribute.

Returns None if pos is not present in the entry. Currently only PtrDLEntryPos::Index is optional, and all other positions may be assumed to be present.

Definition at line 235 of file LLVMTypes.cpp.

References mlir::Attribute::cast(), and None.

Referenced by mlir::LLVM::LLVMPointerType::areCompatible(), getPointerDataLayoutEntry(), translateDataLayout(), and mlir::LLVM::LLVMPointerType::verifyEntries().

◆ getFixedVectorType()

Type mlir::LLVM::getFixedVectorType ( Type  elementType,
unsigned  numElements 
)

◆ getPrimitiveTypeSizeInBits()

llvm::TypeSize mlir::LLVM::getPrimitiveTypeSizeInBits ( Type  type)

Returns the size of the given primitive LLVM dialect-compatible type (including vectors) in bits, for example, the size of i16 is 16 and the size of vector<4xi16> is 64.

Returns 0 for non-primitive (aggregates such as struct) or types that don't have a size (such as void).

Definition at line 960 of file LLVMTypes.cpp.

References mlir::LLVM::LLVMFixedVectorType::getElementType(), mlir::LLVM::LLVMFixedVectorType::getNumElements(), mlir::Type::isa(), isCompatibleType(), and isCompatibleVectorType().

◆ getScalableVectorType()

Type mlir::LLVM::getScalableVectorType ( Type  elementType,
unsigned  numElements 
)

Creates an LLVM dialect-compatible type with the given element type and length.

Definition at line 948 of file LLVMTypes.cpp.

References mlir::LLVM::LLVMScalableVectorType::get(), and mlir::LLVM::LLVMScalableVectorType::isValidElementType().

◆ getVectorElementType()

Type mlir::LLVM::getVectorElementType ( Type  type)

Returns the element type of any vector type compatible with the LLVM dialect.

Definition at line 885 of file LLVMTypes.cpp.

Referenced by getLLVMTypeBitWidth(), getLoadStoreElementType(), isZeroAttribute(), and parseShuffleType().

◆ getVectorNumElements()

llvm::ElementCount mlir::LLVM::getVectorNumElements ( Type  type)

Returns the element count of any LLVM-compatible vector type.

Definition at line 894 of file LLVMTypes.cpp.

References mlir::LLVM::LLVMScalableVectorType::getMinNumElements(), and mlir::LLVM::LLVMFixedVectorType::getNumElements().

Referenced by castDataPtr().

◆ getVectorType()

Type mlir::LLVM::getVectorType ( Type  elementType,
unsigned  numElements,
bool  isScalable = false 
)

Creates an LLVM dialect-compatible vector type with the given element type and length.

Definition at line 922 of file LLVMTypes.cpp.

References mlir::LLVM::LLVMFixedVectorType::get(), mlir::LLVM::LLVMScalableVectorType::get(), and mlir::LLVM::LLVMFixedVectorType::isValidElementType().

Referenced by isZeroAttribute(), and parseShuffleType().

◆ isCompatibleFloatingPointType()

bool mlir::LLVM::isCompatibleFloatingPointType ( Type  type)

Returns true if the given type is a floating-point type compatible with the LLVM dialect.

Definition at line 864 of file LLVMTypes.cpp.

References mlir::Type::isa().

Referenced by mlir::LLVM::LLVMScalableVectorType::isValidElementType().

◆ isCompatibleOuterType()

bool mlir::LLVM::isCompatibleOuterType ( Type  type)

Returns true if the given outer type is compatible with the LLVM dialect without checking its potential nested types such as struct elements.

Definition at line 756 of file LLVMTypes.cpp.

References mlir::Type::dyn_cast(), and mlir::Type::isa().

Referenced by mlir::LLVM::LLVMPointerType::isValidElementType().

◆ isCompatibleType()

bool mlir::LLVM::isCompatibleType ( Type  type)

◆ isCompatibleVectorType()

bool mlir::LLVM::isCompatibleVectorType ( Type  type)

Returns true if the given type is a vector type compatible with the LLVM dialect.

Compatible types include 1D built-in vector types of built-in integers and floating-point values, LLVM dialect fixed vector types of LLVM dialect pointers and LLVM dialect scalable vector types.

Definition at line 869 of file LLVMTypes.cpp.

References mlir::Type::dyn_cast(), and mlir::Type::isa().

Referenced by mlir::LLVMTypeConverter::canConvertToBarePtr(), mlir::LLVM::detail::extractNDVectorTypeInfo(), getLLVMTypeBitWidth(), getPrimitiveTypeSizeInBits(), parseShuffleType(), and mlir::LLVM::detail::TypeToLLVMIRTranslatorImpl::translateType().

◆ isScalableVectorType()

bool mlir::LLVM::isScalableVectorType ( Type  vectorType)

Returns whether a vector type is scalable or not.

Definition at line 912 of file LLVMTypes.cpp.

References mlir::Type::cast(), and mlir::Type::isa().

Referenced by isZeroAttribute(), parseShuffleType(), and printShuffleType().

◆ lookupOrCreateAlignedAllocFn()

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateAlignedAllocFn ( ModuleOp  moduleOp,
Type  indexType 
)

◆ lookupOrCreateFn()

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateFn ( ModuleOp  moduleOp,
StringRef  name,
ArrayRef< Type paramTypes = {},
Type  resultType = {} 
)

◆ lookupOrCreateFreeFn()

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateFreeFn ( ModuleOp  moduleOp)

◆ lookupOrCreateGenericAlignedAllocFn()

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateGenericAlignedAllocFn ( ModuleOp  moduleOp,
Type  indexType 
)

◆ lookupOrCreateGenericAllocFn()

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateGenericAllocFn ( ModuleOp  moduleOp,
Type  indexType 
)

◆ lookupOrCreateGenericFreeFn()

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateGenericFreeFn ( ModuleOp  moduleOp)

◆ lookupOrCreateMallocFn()

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateMallocFn ( ModuleOp  moduleOp,
Type  indexType 
)

◆ lookupOrCreateMemRefCopyFn()

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreateMemRefCopyFn ( ModuleOp  moduleOp,
Type  indexType,
Type  unrankedDescriptorType 
)

Definition at line 145 of file FunctionCallUtils.cpp.

References kMemRefCopy, and lookupOrCreateFn().

◆ lookupOrCreatePrintCloseFn()

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintCloseFn ( ModuleOp  moduleOp)

Definition at line 86 of file FunctionCallUtils.cpp.

References kPrintClose, and lookupOrCreateFn().

◆ lookupOrCreatePrintCommaFn()

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintCommaFn ( ModuleOp  moduleOp)

Definition at line 91 of file FunctionCallUtils.cpp.

References kPrintComma, and lookupOrCreateFn().

◆ lookupOrCreatePrintF32Fn()

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintF32Fn ( ModuleOp  moduleOp)

Definition at line 69 of file FunctionCallUtils.cpp.

References kPrintF32, and lookupOrCreateFn().

◆ lookupOrCreatePrintF64Fn()

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintF64Fn ( ModuleOp  moduleOp)

Definition at line 75 of file FunctionCallUtils.cpp.

References kPrintF64, and lookupOrCreateFn().

◆ lookupOrCreatePrintI64Fn()

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintI64Fn ( ModuleOp  moduleOp)

Helper functions to lookup or create the declaration for commonly used external C function calls.

The list of functions provided here must be implemented separately (e.g. as part of a support runtime library or as part of the libc).

Definition at line 57 of file FunctionCallUtils.cpp.

References kPrintI64, and lookupOrCreateFn().

◆ lookupOrCreatePrintNewlineFn()

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintNewlineFn ( ModuleOp  moduleOp)

Definition at line 96 of file FunctionCallUtils.cpp.

References kPrintNewline, and lookupOrCreateFn().

◆ lookupOrCreatePrintOpenFn()

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintOpenFn ( ModuleOp  moduleOp)

Definition at line 81 of file FunctionCallUtils.cpp.

References kPrintOpen, and lookupOrCreateFn().

◆ lookupOrCreatePrintU64Fn()

LLVM::LLVMFuncOp mlir::LLVM::lookupOrCreatePrintU64Fn ( ModuleOp  moduleOp)

Definition at line 63 of file FunctionCallUtils.cpp.

References kPrintU64, and lookupOrCreateFn().

◆ satisfiesLLVMModule()

bool mlir::LLVM::satisfiesLLVMModule ( Operation op)

Variable Documentation

◆ kGEPConstantBitWidth

constexpr int mlir::LLVM::kGEPConstantBitWidth = 29

Bit-width of a 'GEPConstantIndex' within GEPArg.

Definition at line 82 of file LLVMDialect.h.

Referenced by destructureIndices().