MLIR  16.0.0git
Namespaces | Functions
ConvertFromLLVMIR.cpp File Reference
#include "DebugImporter.h"
#include "mlir/Target/LLVMIR/Import.h"
#include "mlir/Dialect/DLTI/DLTI.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/BuiltinTypes.h"
#include "mlir/IR/MLIRContext.h"
#include "mlir/IR/Matchers.h"
#include "mlir/Interfaces/DataLayoutInterfaces.h"
#include "mlir/Target/LLVMIR/TypeFromLLVM.h"
#include "mlir/Tools/mlir-translate/Translation.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/ScopeExit.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/IR/Attributes.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DebugInfoMetadata.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/InlineAsm.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Type.h"
#include "llvm/IRReader/IRReader.h"
#include "llvm/Support/Error.h"
#include "llvm/Support/SourceMgr.h"
#include "mlir/Dialect/LLVMIR/LLVMConversionEnumsFromLLVM.inc"
#include "mlir/Dialect/LLVMIR/LLVMConvertibleLLVMIRIntrinsics.inc"
#include "mlir/Dialect/LLVMIR/LLVMIntrinsicFromLLVMIRConversions.inc"
#include "mlir/Dialect/LLVMIR/LLVMOpFromLLVMIRConversions.inc"
+ Include dependency graph for ConvertFromLLVMIR.cpp:

Go to the source code of this file.

Namespaces

 mlir
 Include the generated interface declarations.
 

Functions

static bool isConvertibleIntrinsic (llvm::Intrinsic::ID id)
 Returns true if the LLVM IR intrinsic is convertible to an MLIR LLVM dialect intrinsic, or false if no counterpart exists. More...
 
static std::string diag (llvm::Value &value)
 
static DenseIntElementsAttr parseDataLayoutAlignment (MLIRContext &ctx, StringRef spec)
 Creates an attribute containing ABI and preferred alignment numbers parsed a string. More...
 
static FloatType getDLFloatType (MLIRContext &ctx, int32_t bitwidth)
 Returns a supported MLIR floating point type of the given bit width or null if the bit width is not supported. More...
 
static ICmpPredicate getICmpPredicate (llvm::CmpInst::Predicate pred)
 
static FCmpPredicate getFCmpPredicate (llvm::CmpInst::Predicate pred)
 
static AtomicOrdering getLLVMAtomicOrdering (llvm::AtomicOrdering ordering)
 
static AtomicBinOp getLLVMAtomicBinOp (llvm::AtomicRMWInst::BinOp binOp)
 
static StringRef getLLVMSyncScope (llvm::FenceInst *fenceInst)
 Converts the sync scope identifier of fenceInst to the string representation necessary to build the LLVM dialect fence operation. More...
 
static SmallVector< int64_t > getPositionFromIndices (ArrayRef< unsigned > indices)
 Converts an array of unsigned indices to a signed integer position array. More...
 
static SetVector< llvm::BasicBlock * > getTopologicallySortedBlocks (llvm::Function *func)
 Get a topologically sorted list of blocks for the given function. More...
 
static OwningOpRef< Operation * > translateLLVMIRToModule (llvm::SourceMgr &sourceMgr, MLIRContext *context)
 
void mlir::registerFromLLVMIRTranslation ()
 

Function Documentation

◆ diag()

static std::string diag ( llvm::Value &  value)
static

Definition at line 63 of file ConvertFromLLVMIR.cpp.

References value.

Referenced by alterGpuLaunch(), mlir::transform::TransformState::applyTransform(), mlir::transform::detail::applyTransformToEach(), checkDoubleConsume(), cloneAndFuseFirstUse(), mlir::lsp::MLIRServer::convertFromBytecode(), createGpuLaunch(), diagnoseInvalidOperandDominance(), mlir::DiagnosticEngine::emit(), mlir::detail::DiagnosticEngineImpl::emit(), emitDiag(), mlir::SourceMgrDiagnosticHandler::emitDiagnostic(), mlir::detail::ParallelDiagnosticHandlerImpl::emitDiagnostics(), mlir::Operation::emitError(), mlir::detail::Parser::emitError(), mlir::Operation::emitRemark(), mlir::Operation::emitWarning(), mlir::detail::PassCrashReproducerGenerator::finalize(), getLspDiagnoticFromDiag(), legalizeUnresolvedMaterialization(), mlir::pdll::Lexer::Lexer(), mlir::transform::gpu::mapNestedForeachToThreadsImpl(), TransferWriteToVectorStoreLowering::matchAndRewrite(), mlir::RewriterBase::notifyMatchFailure(), mlir::detail::ConversionPatternRewriterImpl::notifyMatchFailure(), mlir::operator<<(), mlir::detail::ParallelDiagnosticHandlerImpl::ParallelDiagnosticHandlerImpl(), mlir::detail::ParallelDiagnosticHandlerImpl::print(), mlir::DiagnosticEngine::registerHandler(), mlir::detail::ConversionPatternRewriterImpl::remapValues(), mlir::DiagnosedSilenceableFailure::silenceableFailure(), mlir::SourceMgrDiagnosticHandler::SourceMgrDiagnosticHandler(), mlir::SourceMgrDiagnosticVerifierHandler::SourceMgrDiagnosticVerifierHandler(), tileAndFuseFirstExtractUse(), tileAndFuseFirstExtractUseThroughContainingOpBlockArgument(), mlir::transform::tileToForeachThreadOpImpl(), mlir::lsp::toJSON(), unpackPDLOperations(), verifyAndGetTerminator(), mlir::impl::verifyCastInterfaceOp(), mlir::detail::verifyDataLayoutOp(), verifyOpAndAdjustFlags(), mlir::transform::detail::verifyPossibleTopLevelTransformOpTrait(), verifyTypeRangesMatch(), verifyTypesAlongAllEdges(), and mlir::detail::ParallelDiagnosticHandlerImpl::~ParallelDiagnosticHandlerImpl().

◆ getDLFloatType()

static FloatType getDLFloatType ( MLIRContext ctx,
int32_t  bitwidth 
)
static

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

Definition at line 93 of file ConvertFromLLVMIR.cpp.

References mlir::FloatType::getF128(), mlir::FloatType::getF16(), mlir::FloatType::getF32(), mlir::FloatType::getF64(), and mlir::FloatType::getF80().

◆ getFCmpPredicate()

static FCmpPredicate getFCmpPredicate ( llvm::CmpInst::Predicate  pred)
static

Definition at line 138 of file ConvertFromLLVMIR.cpp.

◆ getICmpPredicate()

static ICmpPredicate getICmpPredicate ( llvm::CmpInst::Predicate  pred)
static

Definition at line 110 of file ConvertFromLLVMIR.cpp.

◆ getLLVMAtomicBinOp()

static AtomicBinOp getLLVMAtomicBinOp ( llvm::AtomicRMWInst::BinOp  binOp)
static

Definition at line 198 of file ConvertFromLLVMIR.cpp.

References max(), and min().

◆ getLLVMAtomicOrdering()

static AtomicOrdering getLLVMAtomicOrdering ( llvm::AtomicOrdering  ordering)
static

Definition at line 178 of file ConvertFromLLVMIR.cpp.

◆ getLLVMSyncScope()

static StringRef getLLVMSyncScope ( llvm::FenceInst *  fenceInst)
static

Converts the sync scope identifier of fenceInst to the string representation necessary to build the LLVM dialect fence operation.

Definition at line 233 of file ConvertFromLLVMIR.cpp.

◆ getPositionFromIndices()

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

Converts an array of unsigned indices to a signed integer position array.

Definition at line 244 of file ConvertFromLLVMIR.cpp.

◆ getTopologicallySortedBlocks()

static SetVector<llvm::BasicBlock *> getTopologicallySortedBlocks ( llvm::Function *  func)
static

Get a topologically sorted list of blocks for the given function.

Definition at line 315 of file ConvertFromLLVMIR.cpp.

◆ isConvertibleIntrinsic()

static bool isConvertibleIntrinsic ( llvm::Intrinsic::ID  id)
static

Returns true if the LLVM IR intrinsic is convertible to an MLIR LLVM dialect intrinsic, or false if no counterpart exists.

Definition at line 53 of file ConvertFromLLVMIR.cpp.

◆ parseDataLayoutAlignment()

static DenseIntElementsAttr parseDataLayoutAlignment ( MLIRContext ctx,
StringRef  spec 
)
static

Creates an attribute containing ABI and preferred alignment numbers parsed a string.

The string may be either "abi:preferred" or just "abi". In the latter case, the prefrred alignment is considered equal to ABI alignment.

Definition at line 73 of file ConvertFromLLVMIR.cpp.

References mlir::DenseIntElementsAttr::get().

◆ translateLLVMIRToModule()

static OwningOpRef<Operation *> translateLLVMIRToModule ( llvm::SourceMgr &  sourceMgr,
MLIRContext context 
)
static