MLIR  14.0.0git
Namespaces | Classes | Functions
mlir::LLVM Namespace Reference

Namespaces

 detail
 

Classes

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  LLVMVectorType
 LLVM dialect vector type, represents a sequence of elements that can be processed as one, typically in SIMD context. 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...
 

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 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...
 
Operation::result_range createLLVMCall (OpBuilder &b, Location loc, LLVM::LLVMFuncOp fn, ValueRange args={}, ArrayRef< Type > resultTypes={})
 Helper wrapper to create a call to fn with args and resultTypes. 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...
 
 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 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...
 
Type getFixedVectorType (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...
 
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...
 

Function Documentation

◆ 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 2402 of file LLVMDialect.cpp.

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

Referenced by 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 68 of file LegalizeForExport.cpp.

◆ createLLVMCall()

Operation::result_range mlir::LLVM::createLLVMCall ( OpBuilder b,
Location  loc,
LLVM::LLVMFuncOp  fn,
ValueRange  args = {},
ArrayRef< Type resultTypes = {} 
)

Helper wrapper to create a call to fn with args and resultTypes.

Definition at line 127 of file FunctionCallUtils.cpp.

References mlir::OpBuilder::create().

◆ 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 51 of file LegalizeForExport.cpp.

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

Referenced by prepareLLVMModule().

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

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

◆ getVectorElementType()

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

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

Definition at line 540 of file LLVMTypes.cpp.

Referenced by diag(), getLLVMTypeBitWidth(), parseCallOp(), parseExtractElementOp(), parseInsertElementOp(), parseShuffleVectorOp(), and verify().

◆ getVectorNumElements()

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

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

Definition at line 549 of file LLVMTypes.cpp.

References mlir::LLVM::LLVMScalableVectorType::getMinNumElements().

Referenced by diag(), and replaceTransferOpWithMubuf().

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

References mlir::Type::isa().

Referenced by mlir::LLVM::LLVMScalableVectorType::isValidElementType(), and verify().

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

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

Referenced by diag(), mlir::LLVM::detail::extractNDVectorTypeInfo(), getLLVMTypeBitWidth(), getPrimitiveTypeSizeInBits(), mlir::LLVMTypeConverter::getUnrankedMemRefDescriptorSize(), parseExtractElementOp(), parseInsertElementOp(), parseShuffleVectorOp(), mlir::LLVM::detail::TypeToLLVMIRTranslatorImpl::translateType(), and verify().

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

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

References kMemRefCopy, and lookupOrCreateFn().

◆ lookupOrCreatePrintCloseFn()

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

Definition at line 82 of file FunctionCallUtils.cpp.

References kPrintClose, and lookupOrCreateFn().

◆ lookupOrCreatePrintCommaFn()

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

Definition at line 87 of file FunctionCallUtils.cpp.

References kPrintComma, and lookupOrCreateFn().

◆ lookupOrCreatePrintF32Fn()

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

Definition at line 65 of file FunctionCallUtils.cpp.

References kPrintF32, and lookupOrCreateFn().

◆ lookupOrCreatePrintF64Fn()

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

Definition at line 71 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.

Such ops can then be invoked by creating a CallOp with the proper arguments via createLLVMCall. 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 53 of file FunctionCallUtils.cpp.

References kPrintI64, and lookupOrCreateFn().

◆ lookupOrCreatePrintNewlineFn()

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

Definition at line 92 of file FunctionCallUtils.cpp.

References kPrintNewline, and lookupOrCreateFn().

◆ lookupOrCreatePrintOpenFn()

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

Definition at line 77 of file FunctionCallUtils.cpp.

References kPrintOpen, and lookupOrCreateFn().

◆ lookupOrCreatePrintU64Fn()

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

Definition at line 59 of file FunctionCallUtils.cpp.

References kPrintU64, and lookupOrCreateFn().

◆ 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 2430 of file LLVMDialect.cpp.

References mlir::Operation::hasTrait().

Referenced by mlir::LLVM::detail::getLLVMConstant(), lookupSymbolInModule(), prepareLLVMModule(), and verify().