MLIR 22.0.0git
mlir::LLVM::detail Namespace Reference

Classes

class  DataLayoutImporter
 Helper class that translates an LLVM data layout string to an MLIR data layout specification. More...
class  DebugImporter
class  DebugTranslation
struct  LLVMStructTypeStorage
 Type storage for LLVM structure types. More...
struct  LLVMTypeAndSizeStorage
 Common storage used for LLVM dialect types that need an element type and a number: arrays, fixed and scalable vectors. More...
class  LoopAnnotationImporter
 A helper class that converts llvm.loop metadata nodes into corresponding LoopAnnotationAttrs and llvm.access.group nodes into AccessGroupAttrs. More...
class  LoopAnnotationTranslation
 A helper class that converts LoopAnnotationAttrs and AccessGroupAttrs into corresponding llvm::MDNodes. More...
struct  NDVectorTypeInfo
class  TypeFromLLVMIRTranslatorImpl
 Support for translating LLVM IR types to MLIR LLVM dialect types. More...
class  TypeToLLVMIRTranslatorImpl
 Support for translating MLIR LLVM dialect types to LLVM IR. More...

Functions

LogicalResult oneToOneRewrite (Operation *op, StringRef targetOp, ValueRange operands, ArrayRef< NamedAttribute > targetAttrs, Attribute propertiesAttr, const LLVMTypeConverter &typeConverter, ConversionPatternRewriter &rewriter)
 Replaces the given operation "op" with a new operation of type "targetOp" and given operands.
LogicalResult intrinsicRewrite (Operation *op, StringRef intrinsic, ValueRange operands, const LLVMTypeConverter &typeConverter, RewriterBase &rewriter)
 Replaces the given operation "op" with a call to an LLVM intrinsic with the specified name "intrinsic" and operands.
NDVectorTypeInfo extractNDVectorTypeInfo (VectorType vectorType, const LLVMTypeConverter &converter)
SmallVector< int64_t, 4 > getCoordinates (ArrayRef< int64_t > basis, unsigned linearIndex)
void nDVectorIterate (const NDVectorTypeInfo &info, OpBuilder &builder, function_ref< void(ArrayRef< int64_t >)> fun)
LogicalResult handleMultidimensionalVectors (Operation *op, ValueRange operands, const LLVMTypeConverter &typeConverter, std::function< Value(Type, ValueRange)> createOperand, ConversionPatternRewriter &rewriter)
LogicalResult vectorOneToOneRewrite (Operation *op, StringRef targetOp, ValueRange operands, ArrayRef< NamedAttribute > targetAttrs, Attribute propertiesAttr, const LLVMTypeConverter &typeConverter, ConversionPatternRewriter &rewriter)
bool isValidLoadStoreImpl (Type type, ptr::AtomicOrdering ordering, std::optional< int64_t > alignment, const ::mlir::DataLayout *dataLayout, function_ref< InFlightDiagnostic()> emitError)
 Checks whether the given type is an LLVM type that can be loaded or stored.
LogicalResult verifyAccessGroupOpInterface (Operation *op)
 Verifies the access groups attribute of memory operations that implement the access group interface.
LogicalResult verifyAliasAnalysisOpInterface (Operation *op)
 Verifies the alias analysis attributes of memory operations that implement the alias analysis interface.
LogicalResult verifyDereferenceableOpInterface (Operation *op)
 Verifies that the operation implementing the dereferenceable interface has exactly one result of LLVM pointer type.
Type parseType (DialectAsmParser &parser)
 Parses an LLVM dialect type.
void printType (Type type, AsmPrinter &printer)
 Prints an LLVM Dialect type.
FloatType getFloatType (MLIRContext *context, unsigned width)
 Returns a supported MLIR floating point type of the given bit width or null if the bit width is not supported.
void connectPHINodes (Region &region, const ModuleTranslation &state)
 For all blocks in the region that were converted to LLVM IR using the given ModuleTranslation, connect the PHI nodes of the corresponding LLVM IR blocks to the results of preceding blocks.
llvm::Constant * getLLVMConstant (llvm::Type *llvmType, Attribute attr, Location loc, const ModuleTranslation &moduleTranslation)
 Create an LLVM IR constant of llvmType from the MLIR attribute attr.
llvm::CallInst * createIntrinsicCall (llvm::IRBuilderBase &builder, llvm::Intrinsic::ID intrinsic, ArrayRef< llvm::Value * > args={}, ArrayRef< llvm::Type * > tys={})
 Creates a call to an LLVM IR intrinsic function with the given arguments.
llvm::CallInst * createIntrinsicCall (llvm::IRBuilderBase &builder, ModuleTranslation &moduleTranslation, Operation *intrOp, llvm::Intrinsic::ID intrinsic, unsigned numResults, ArrayRef< unsigned > overloadedResults, ArrayRef< unsigned > overloadedOperands, ArrayRef< unsigned > immArgPositions, ArrayRef< StringLiteral > immArgAttrNames)
 Creates a call to a LLVM IR intrinsic defined by LLVM_IntrOpBase.
void initializeBackendsOnce ()
 Idempotent helper to register/initialize all backends that LLVM has been configured to support.
FailureOr< std::unique_ptr< llvm::TargetMachine > > getTargetMachine (mlir::LLVM::TargetAttrInterface attr)
 Helper to obtain the TargetMachine specified by the properties of the TargetAttrInterface-implementing attribute.
FailureOr< llvm::DataLayout > getDataLayout (mlir::LLVM::TargetAttrInterface attr)
 Helper to obtain the DataLayout of the target specified by the properties of the TargetAttrInterface-implementing attribute.
void addBytecodeInterface (LLVMDialect *dialect)
 Add the interfaces necessary for encoding the LLVM dialect components in bytecode.
static llvm::ArrayRef< std::pair< llvm::Attribute::AttrKind, llvm::StringRef > > getAttrKindToNameMapping ()
 Returns a list of pairs that each hold a mapping from LLVM attribute kinds to their corresponding string name in LLVM IR dialect.
static llvm::DenseMap< llvm::StringRef, llvm::Attribute::AttrKind > getAttrNameToKindMapping ()
 Returns a dense map from LLVM attribute name to their kind in LLVM IR dialect.

Function Documentation

◆ addBytecodeInterface()

void mlir::LLVM::detail::addBytecodeInterface ( LLVMDialect * dialect)

Add the interfaces necessary for encoding the LLVM dialect components in bytecode.

Definition at line 152 of file LLVMDialectBytecode.cpp.

◆ connectPHINodes()

void mlir::LLVM::detail::connectPHINodes ( Region & region,
const ModuleTranslation & state )

For all blocks in the region that were converted to LLVM IR using the given ModuleTranslation, connect the PHI nodes of the corresponding LLVM IR blocks to the results of preceding blocks.

Connect the PHI nodes to the results of preceding blocks.

Definition at line 865 of file ModuleTranslation.cpp.

References getPHISourceValue(), mlir::LLVM::ModuleTranslation::lookupBlock(), mlir::LLVM::ModuleTranslation::lookupBranch(), and mlir::LLVM::ModuleTranslation::lookupValue().

Referenced by convertOmpOpRegions().

◆ createIntrinsicCall() [1/2]

llvm::CallInst * mlir::LLVM::detail::createIntrinsicCall ( llvm::IRBuilderBase & builder,
llvm::Intrinsic::ID intrinsic,
ArrayRef< llvm::Value * > args = {},
ArrayRef< llvm::Type * > tys = {} )

Creates a call to an LLVM IR intrinsic function with the given arguments.

Definition at line 892 of file ModuleTranslation.cpp.

◆ createIntrinsicCall() [2/2]

llvm::CallInst * mlir::LLVM::detail::createIntrinsicCall ( llvm::IRBuilderBase & builder,
ModuleTranslation & moduleTranslation,
Operation * intrOp,
llvm::Intrinsic::ID intrinsic,
unsigned numResults,
ArrayRef< unsigned > overloadedResults,
ArrayRef< unsigned > overloadedOperands,
ArrayRef< unsigned > immArgPositions,
ArrayRef< StringLiteral > immArgAttrNames )

Creates a call to a LLVM IR intrinsic defined by LLVM_IntrOpBase.

This resolves the overloads, and maps mixed MLIR value and attribute arguments to LLVM values.

Definition at line 901 of file ModuleTranslation.cpp.

References mlir::LLVM::ModuleTranslation::convertType(), mlir::Operation::getAttr(), getLLVMConstant(), mlir::Operation::getLoc(), mlir::Operation::getOperands(), mlir::Operation::getResult(), mlir::getType(), mlir::Value::getType(), and mlir::LLVM::ModuleTranslation::lookupValues().

◆ extractNDVectorTypeInfo()

◆ getAttrKindToNameMapping()

llvm::ArrayRef< std::pair< llvm::Attribute::AttrKind, llvm::StringRef > > mlir::LLVM::detail::getAttrKindToNameMapping ( )
static

Returns a list of pairs that each hold a mapping from LLVM attribute kinds to their corresponding string name in LLVM IR dialect.

Definition at line 22 of file AttrKindDetail.h.

Referenced by getAttrNameToKindMapping().

◆ getAttrNameToKindMapping()

llvm::DenseMap< llvm::StringRef, llvm::Attribute::AttrKind > mlir::LLVM::detail::getAttrNameToKindMapping ( )
static

Returns a dense map from LLVM attribute name to their kind in LLVM IR dialect.

Definition at line 69 of file AttrKindDetail.h.

References getAttrKindToNameMapping().

◆ getCoordinates()

SmallVector< int64_t, 4 > mlir::LLVM::detail::getCoordinates ( ArrayRef< int64_t > basis,
unsigned linearIndex )

Definition at line 48 of file VectorPattern.cpp.

Referenced by nDVectorIterate().

◆ getDataLayout()

FailureOr< llvm::DataLayout > mlir::LLVM::detail::getDataLayout ( mlir::LLVM::TargetAttrInterface attr)

Helper to obtain the DataLayout of the target specified by the properties of the TargetAttrInterface-implementing attribute.

Definition at line 60 of file TargetUtils.cpp.

References getTargetMachine().

◆ getFloatType()

FloatType mlir::LLVM::detail::getFloatType ( MLIRContext * context,
unsigned width )

Returns a supported MLIR floating point type of the given bit width or null if the bit width is not supported.

Definition at line 28 of file DataLayoutImporter.cpp.

Referenced by getScalarConstantAsAttr().

◆ getLLVMConstant()

llvm::Constant * mlir::LLVM::detail::getLLVMConstant ( llvm::Type * llvmType,
Attribute attr,
Location loc,
const ModuleTranslation & moduleTranslation )

Create an LLVM IR constant of llvmType from the MLIR attribute attr.

This currently supports integer, floating point, splat and dense element attributes and combinations thereof. Also, an array attribute with two elements is supported to represent a complex constant. In case of error, report it to loc and return nullptr.

Definition at line 564 of file ModuleTranslation.cpp.

References buildSequentialConstant(), convertDenseElementsAttr(), convertDenseResourceElementsAttr(), mlir::emitError(), getInnermostElementType(), getLLVMConstant(), mlir::LLVM::ModuleTranslation::getLLVMContext(), mlir::LLVM::ModuleTranslation::lookupFunction(), and result.

Referenced by convertDenseElementsAttr(), createIntrinsicCall(), createVL(), and getLLVMConstant().

◆ getTargetMachine()

FailureOr< std::unique_ptr< llvm::TargetMachine > > mlir::LLVM::detail::getTargetMachine ( mlir::LLVM::TargetAttrInterface attr)

Helper to obtain the TargetMachine specified by the properties of the TargetAttrInterface-implementing attribute.

Definition at line 37 of file TargetUtils.cpp.

References target.

Referenced by getDataLayout(), and TargetToTargetFeaturesPass::runOnOperation().

◆ handleMultidimensionalVectors()

LogicalResult mlir::LLVM::detail::handleMultidimensionalVectors ( Operation * op,
ValueRange operands,
const LLVMTypeConverter & typeConverter,
std::function< Value(Type, ValueRange)> createOperand,
ConversionPatternRewriter & rewriter )

◆ initializeBackendsOnce()

void mlir::LLVM::detail::initializeBackendsOnce ( )

Idempotent helper to register/initialize all backends that LLVM has been configured to support.

Only runs the first time it is called.

Definition at line 25 of file TargetUtils.cpp.

Referenced by TargetToTargetFeaturesPass::runOnOperation().

◆ intrinsicRewrite()

LogicalResult mlir::LLVM::detail::intrinsicRewrite ( Operation * op,
StringRef intrinsic,
ValueRange operands,
const LLVMTypeConverter & typeConverter,
RewriterBase & rewriter )

Replaces the given operation "op" with a call to an LLVM intrinsic with the specified name "intrinsic" and operands.

The rewrite performs a simple one-to-one matching between the op and LLVM intrinsic. For example:

%res = intr.op %val : vector<16xf32>

can be converted to

%res = llvm.call_intrinsic "intrinsic"(%val)

The provided operands must be LLVM-compatible.

Upholds a convention that multi-result operations get converted into an operation returning the LLVM IR structure type, in which case individual values are first extracted before replacing the original results.

Definition at line 340 of file Pattern.cpp.

References mlir::Operation::getAttrDictionary(), mlir::Operation::getLoc(), mlir::Operation::getNumResults(), mlir::Operation::getResultTypes(), mlir::Builder::getStringAttr(), mlir::Value::getType(), mlir::LLVM::isCompatibleType(), mlir::LLVMTypeConverter::packOperationResults(), mlir::RewriterBase::replaceOp(), and success().

◆ isValidLoadStoreImpl()

bool mlir::LLVM::detail::isValidLoadStoreImpl ( Type type,
ptr::AtomicOrdering ordering,
std::optional< int64_t > alignment,
const ::mlir::DataLayout * dataLayout,
function_ref< InFlightDiagnostic()> emitError )

Checks whether the given type is an LLVM type that can be loaded or stored.

Definition at line 60 of file LLVMAttrs.cpp.

References mlir::emitError(), mlir::LLVM::isLoadableType(), and mlir::LLVM::isTypeCompatibleWithAtomicOp().

◆ nDVectorIterate()

void mlir::LLVM::detail::nDVectorIterate ( const NDVectorTypeInfo & info,
OpBuilder & builder,
function_ref< void(ArrayRef< int64_t >)> fun )

◆ oneToOneRewrite()

LogicalResult mlir::LLVM::detail::oneToOneRewrite ( Operation * op,
StringRef targetOp,
ValueRange operands,
ArrayRef< NamedAttribute > targetAttrs,
Attribute propertiesAttr,
const LLVMTypeConverter & typeConverter,
ConversionPatternRewriter & rewriter )

◆ parseType()

Type mlir::LLVM::detail::parseType ( DialectAsmParser & parser)

Parses an LLVM dialect type.

Parses one of the LLVM dialect types.

Definition at line 291 of file LLVMTypeSyntax.cpp.

References dispatchParse(), mlir::AsmParser::emitError(), mlir::AsmParser::getCurrentLocation(), and mlir::LLVM::isCompatibleOuterType().

◆ printType()

void mlir::LLVM::detail::printType ( Type type,
AsmPrinter & printer )

Prints an LLVM Dialect type.

Prints the given LLVM dialect type recursively.

This leverages closedness of the LLVM dialect type system to avoid printing the dialect prefix repeatedly. For recursive structures, only prints the name of the structure when printing a self-reference. Note that this does not apply to sibling references. For example, struct<"a", (ptr<struct<"a">>)> struct<"c", (ptr<struct<"b", (ptr<struct<"c">>)>>, ptr<struct<"b", (ptr<struct<"c">>)>>)> note that "b" is printed twice.

Definition at line 97 of file LLVMTypeSyntax.cpp.

References getTypeKeyword(), and mlir::Type::print().

Referenced by dispatchPrint().

◆ vectorOneToOneRewrite()

◆ verifyAccessGroupOpInterface()

LogicalResult mlir::LLVM::detail::verifyAccessGroupOpInterface ( Operation * op)

Verifies the access groups attribute of memory operations that implement the access group interface.

Definition at line 34 of file LLVMInterfaces.cpp.

References ArrayAttr(), isArrayOf(), and success().

◆ verifyAliasAnalysisOpInterface()

LogicalResult mlir::LLVM::detail::verifyAliasAnalysisOpInterface ( Operation * op)

Verifies the alias analysis attributes of memory operations that implement the alias analysis interface.

Definition at line 48 of file LLVMInterfaces.cpp.

References ArrayAttr(), isArrayOf(), and success().

◆ verifyDereferenceableOpInterface()

LogicalResult mlir::LLVM::detail::verifyDereferenceableOpInterface ( Operation * op)

Verifies that the operation implementing the dereferenceable interface has exactly one result of LLVM pointer type.

Definition at line 71 of file LLVMInterfaces.cpp.

References mlir::Operation::emitOpError(), mlir::Operation::getNumResults(), mlir::Operation::getResult(), mlir::Value::getType(), and success().