MLIR 22.0.0git
LLVMToLLVMIRTranslation.cpp File Reference
#include "mlir/Target/LLVMIR/Dialect/LLVMIR/LLVMToLLVMIRTranslation.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/Operation.h"
#include "mlir/Interfaces/CallInterfaces.h"
#include "mlir/Support/LLVM.h"
#include "mlir/Target/LLVMIR/ModuleTranslation.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/IR/DIBuilder.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/MDBuilder.h"
#include "llvm/IR/MatrixBuilder.h"
#include "llvm/IR/MemoryModelRelaxationAnnotations.h"
#include "llvm/Support/LogicalResult.h"
#include "mlir/Dialect/LLVMIR/LLVMConversionEnumsToLLVM.inc"
#include "mlir/Dialect/LLVMIR/LLVMConversions.inc"
#include "mlir/Dialect/LLVMIR/LLVMIntrinsicConversions.inc"

Go to the source code of this file.

Functions

static llvm::FastMathFlags getFastmathFlags (FastmathFlagsInterface &op)
static SmallVector< unsignedextractPosition (ArrayRef< int64_t > indices)
 Convert the value of a DenseI64ArrayAttr to a vector of unsigned indices.
static std::string diagStr (const llvm::Type *type)
 Convert an LLVM type to a string for printing in diagnostics.
static FailureOr< llvm::Function * > getOverloadedDeclaration (CallIntrinsicOp op, llvm::Intrinsic::ID id, llvm::Module *module, LLVM::ModuleTranslation &moduleTranslation)
 Get the declaration of an overloaded llvm intrinsic.
static llvm::OperandBundleDef convertOperandBundle (OperandRange bundleOperands, StringRef bundleTag, LLVM::ModuleTranslation &moduleTranslation)
static SmallVector< llvm::OperandBundleDef > convertOperandBundles (OperandRangeRange bundleOperands, ArrayAttr bundleTags, LLVM::ModuleTranslation &moduleTranslation)
static SmallVector< llvm::OperandBundleDef > convertOperandBundles (OperandRangeRange bundleOperands, std::optional< ArrayAttr > bundleTags, LLVM::ModuleTranslation &moduleTranslation)
static LogicalResult convertCallLLVMIntrinsicOp (CallIntrinsicOp op, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
 Builder for LLVM_CallIntrinsicOp.
static void convertLinkerOptionsOp (ArrayAttr options, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
static llvm::Metadata * convertModuleFlagValue (StringRef key, ArrayAttr arrayAttr, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
static llvm::Metadata * convertModuleFlagProfileSummaryAttr (StringRef key, ModuleFlagProfileSummaryAttr summaryAttr, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
static void convertModuleFlagsOp (ArrayAttr flags, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
static llvm::DILocalScope * getLocalScopeFromLoc (llvm::IRBuilderBase &builder, Location loc, LLVM::ModuleTranslation &moduleTranslation)
static LogicalResult convertOperationImpl (Operation &opInst, llvm::IRBuilderBase &builder, LLVM::ModuleTranslation &moduleTranslation)
static LogicalResult amendOperationImpl (Operation &op, ArrayRef< llvm::Instruction * > instructions, NamedAttribute attribute, LLVM::ModuleTranslation &moduleTranslation)
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.

Function Documentation

◆ amendOperationImpl()

LogicalResult amendOperationImpl ( Operation & op,
ArrayRef< llvm::Instruction * > instructions,
NamedAttribute attribute,
LLVM::ModuleTranslation & moduleTranslation )
static

◆ convertCallLLVMIntrinsicOp()

◆ convertLinkerOptionsOp()

void convertLinkerOptionsOp ( ArrayAttr options,
llvm::IRBuilderBase & builder,
LLVM::ModuleTranslation & moduleTranslation )
static

◆ convertModuleFlagProfileSummaryAttr()

llvm::Metadata * convertModuleFlagProfileSummaryAttr ( StringRef key,
ModuleFlagProfileSummaryAttr summaryAttr,
llvm::IRBuilderBase & builder,
LLVM::ModuleTranslation & moduleTranslation )
static

Definition at line 268 of file LLVMToLLVMIRTranslation.cpp.

Referenced by convertModuleFlagsOp().

◆ convertModuleFlagsOp()

void convertModuleFlagsOp ( ArrayAttr flags,
llvm::IRBuilderBase & builder,
LLVM::ModuleTranslation & moduleTranslation )
static

◆ convertModuleFlagValue()

llvm::Metadata * convertModuleFlagValue ( StringRef key,
ArrayAttr arrayAttr,
llvm::IRBuilderBase & builder,
LLVM::ModuleTranslation & moduleTranslation )
static

◆ convertOperandBundle()

llvm::OperandBundleDef convertOperandBundle ( OperandRange bundleOperands,
StringRef bundleTag,
LLVM::ModuleTranslation & moduleTranslation )
static

◆ convertOperandBundles() [1/2]

SmallVector< llvm::OperandBundleDef > convertOperandBundles ( OperandRangeRange bundleOperands,
ArrayAttr bundleTags,
LLVM::ModuleTranslation & moduleTranslation )
static

◆ convertOperandBundles() [2/2]

SmallVector< llvm::OperandBundleDef > convertOperandBundles ( OperandRangeRange bundleOperands,
std::optional< ArrayAttr > bundleTags,
LLVM::ModuleTranslation & moduleTranslation )
static

Definition at line 135 of file LLVMToLLVMIRTranslation.cpp.

References convertOperandBundles().

◆ convertOperationImpl()

LogicalResult convertOperationImpl ( Operation & opInst,
llvm::IRBuilderBase & builder,
LLVM::ModuleTranslation & moduleTranslation )
static

◆ diagStr()

std::string diagStr ( const llvm::Type * type)
static

Convert an LLVM type to a string for printing in diagnostics.

Definition at line 66 of file LLVMToLLVMIRTranslation.cpp.

Referenced by convertCallLLVMIntrinsicOp(), and getOverloadedDeclaration().

◆ extractPosition()

SmallVector< unsigned > extractPosition ( ArrayRef< int64_t > indices)
static

Convert the value of a DenseI64ArrayAttr to a vector of unsigned indices.

Definition at line 59 of file LLVMToLLVMIRTranslation.cpp.

References indices.

◆ getFastmathFlags()

llvm::FastMathFlags getFastmathFlags ( FastmathFlagsInterface & op)
static

Definition at line 36 of file LLVMToLLVMIRTranslation.cpp.

Referenced by convertCallLLVMIntrinsicOp(), and convertOperationImpl().

◆ 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 505 of file ModuleTranslation.cpp.

◆ getLocalScopeFromLoc()

llvm::DILocalScope * getLocalScopeFromLoc ( llvm::IRBuilderBase & builder,
Location loc,
LLVM::ModuleTranslation & moduleTranslation )
static

◆ getOverloadedDeclaration()

FailureOr< llvm::Function * > getOverloadedDeclaration ( CallIntrinsicOp op,
llvm::Intrinsic::ID id,
llvm::Module * module,
LLVM::ModuleTranslation & moduleTranslation )
static

Get the declaration of an overloaded llvm intrinsic.

First we get the overloaded argument types and/or result type from the CallIntrinsicOp, and then use those to get the correct declaration of the overloaded intrinsic.

Definition at line 77 of file LLVMToLLVMIRTranslation.cpp.

References mlir::LLVM::ModuleTranslation::convertType(), diagStr(), and mlir::emitError().

Referenced by convertCallLLVMIntrinsicOp().