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

Namespaces

 detail
 

Classes

class  DINodeAttr
 This class represents the base attribute for all debug info attributes. More...
 
class  DIScopeAttr
 This class represents a LLVM attribute that describes a debug info scope. More...
 
class  DILocalScopeAttr
 This class represents a LLVM attribute that describes a local debug info scope. More...
 
class  DITypeAttr
 This class represents a LLVM attribute that describes a debug info type. More...
 
class  GEPIndicesAdaptor
 Class used for convenient access and iteration over GEP indices. More...
 
class  GEPArg
 Class used for building a 'llvm.getelementptr'. More...
 
class  LLVMStructType
 LLVM dialect structure type representing a collection of different-typed elements manipulated together. More...
 
class  ModuleImport
 Module import implementation class that provides methods to import globals and functions from an LLVM module into an MLIR module. 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 class  PtrDLEntryPos { Size = 0 , Abi = 1 , Preferred = 2 , 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 lookupOrCreatePrintStrFn (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)
 
ParseResult parsePrettyLLVMType (AsmParser &p, Type &type)
 Parse any MLIR type or a concise syntax for LLVM types. More...
 
void printPrettyLLVMType (AsmPrinter &p, Type type)
 Print any MLIR type or a concise syntax for LLVM types. More...
 
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 getVectorType (Type elementType, const llvm::ElementCount &numElements)
 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...
 
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'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 67 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 276 of file LLVMTypes.h.

Function Documentation

◆ convertArrayToIndices() [1/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 231 of file LLVMDialect.h.

◆ convertArrayToIndices() [2/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 220 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 3252 of file LLVMDialect.cpp.

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

◆ 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 ( LLVMLabelType  )

◆ DEFINE_TRIVIAL_LLVM_TYPE() [2/6]

mlir::LLVM::DEFINE_TRIVIAL_LLVM_TYPE ( LLVMMetadataType  )

◆ DEFINE_TRIVIAL_LLVM_TYPE() [3/6]

mlir::LLVM::DEFINE_TRIVIAL_LLVM_TYPE ( LLVMPPCFP128Type  )

◆ 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 ( LLVMVoidType  )

◆ DEFINE_TRIVIAL_LLVM_TYPE() [6/6]

mlir::LLVM::DEFINE_TRIVIAL_LLVM_TYPE ( LLVMX86MMXType  )

◆ 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().

◆ extractPointerSpecValue()

std::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 std::nullopt 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 267 of file LLVMTypes.cpp.

References mlir::Attribute::cast().

Referenced by getPointerDataLayoutEntry(), and translateDataLayout().

◆ getFixedVectorType()

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

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

Definition at line 915 of file LLVMTypes.cpp.

Referenced by convertIntrinsicResult(), getIndexedPtrs(), mlir::nvgpu::getMmaSyncRegisterType(), inferIntrinsicResultType(), and unpackOperandVector().

◆ 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 938 of file LLVMTypes.cpp.

References 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 926 of file LLVMTypes.cpp.

◆ getVectorElementType()

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

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

Definition at line 854 of file LLVMTypes.cpp.

Referenced by getLLVMTypeBitWidth(), and parseShuffleType().

◆ getVectorNumElements()

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

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

Definition at line 863 of file LLVMTypes.cpp.

Referenced by getI1SameShape().

◆ getVectorType() [1/2]

Type mlir::LLVM::getVectorType ( Type  elementType,
const llvm::ElementCount &  numElements 
)

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

Definition at line 906 of file LLVMTypes.cpp.

References getVectorType().

◆ getVectorType() [2/2]

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 891 of file LLVMTypes.cpp.

Referenced by getI1SameShape(), getVectorType(), 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 833 of file LLVMTypes.cpp.

References mlir::Type::isa().

◆ 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 725 of file LLVMTypes.cpp.

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

◆ 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 838 of file LLVMTypes.cpp.

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

Referenced by mlir::LLVM::detail::extractNDVectorTypeInfo(), getI1SameShape(), getLLVMTypeBitWidth(), getPrimitiveTypeSizeInBits(), and parseShuffleType().

◆ isScalableVectorType()

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

Returns whether a vector type is scalable or not.

Definition at line 881 of file LLVMTypes.cpp.

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

Referenced by parseShuffleType().

◆ lookupOrCreateAlignedAllocFn()

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

Definition at line 116 of file FunctionCallUtils.cpp.

References kAlignedAlloc, and lookupOrCreateFn().

◆ 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 
)

Definition at line 138 of file FunctionCallUtils.cpp.

References kGenericAlignedAlloc, and lookupOrCreateFn().

◆ lookupOrCreateGenericAllocFn()

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

Definition at line 130 of file FunctionCallUtils.cpp.

References kGenericAlloc, and lookupOrCreateFn().

◆ lookupOrCreateGenericFreeFn()

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

Definition at line 145 of file FunctionCallUtils.cpp.

References kGenericFree, and lookupOrCreateFn().

◆ 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 153 of file FunctionCallUtils.cpp.

References kMemRefCopy, and lookupOrCreateFn().

◆ lookupOrCreatePrintCloseFn()

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

Definition at line 94 of file FunctionCallUtils.cpp.

References kPrintClose, and lookupOrCreateFn().

◆ lookupOrCreatePrintCommaFn()

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

Definition at line 99 of file FunctionCallUtils.cpp.

References kPrintComma, and lookupOrCreateFn().

◆ lookupOrCreatePrintF32Fn()

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

Definition at line 70 of file FunctionCallUtils.cpp.

References kPrintF32, and lookupOrCreateFn().

◆ lookupOrCreatePrintF64Fn()

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

Definition at line 76 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 58 of file FunctionCallUtils.cpp.

References kPrintI64, and lookupOrCreateFn().

◆ lookupOrCreatePrintNewlineFn()

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

Definition at line 104 of file FunctionCallUtils.cpp.

References kPrintNewline, and lookupOrCreateFn().

◆ lookupOrCreatePrintOpenFn()

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

Definition at line 89 of file FunctionCallUtils.cpp.

References kPrintOpen, and lookupOrCreateFn().

◆ lookupOrCreatePrintStrFn()

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

Definition at line 82 of file FunctionCallUtils.cpp.

References kPrintStr, and lookupOrCreateFn().

Referenced by createPrintMsg().

◆ lookupOrCreatePrintU64Fn()

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

Definition at line 64 of file FunctionCallUtils.cpp.

References kPrintU64, and lookupOrCreateFn().

◆ parsePrettyLLVMType()

ParseResult mlir::LLVM::parsePrettyLLVMType ( AsmParser p,
Type type 
)

Parse any MLIR type or a concise syntax for LLVM types.

Definition at line 359 of file LLVMTypeSyntax.cpp.

Referenced by parseFunctionTypes(), and parsePointer().

◆ printPrettyLLVMType()

void mlir::LLVM::printPrettyLLVMType ( AsmPrinter p,
Type  type 
)

Print any MLIR type or a concise syntax for LLVM types.

Definition at line 363 of file LLVMTypeSyntax.cpp.

Referenced by printFunctionTypes(), and printPointer().

◆ satisfiesLLVMModule()

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

LLVM requires some operations to be inside of a Module operation.

This function confirms that the Operation has the desired properties.

Definition at line 3277 of file LLVMDialect.cpp.

References mlir::Operation::hasTrait().

Referenced by parentLLVMModule().

Variable Documentation

◆ kGEPConstantBitWidth

constexpr int mlir::LLVM::kGEPConstantBitWidth = 29
constexpr

Bit-width of a 'GEPConstantIndex' within GEPArg.

Definition at line 65 of file LLVMDialect.h.

Referenced by destructureIndices().