|
MLIR 24.0.0git
|
#include "mlir/Conversion/FuncToLLVM/ConvertFuncToLLVMPass.h"#include "mlir/Analysis/DataLayoutAnalysis.h"#include "mlir/Conversion/ArithToLLVM/ArithToLLVM.h"#include "mlir/Conversion/ControlFlowToLLVM/ControlFlowToLLVM.h"#include "mlir/Conversion/ConvertToLLVM/ToLLVMInterface.h"#include "mlir/Conversion/FuncToLLVM/ConvertFuncToLLVM.h"#include "mlir/Conversion/LLVMCommon/ConversionTarget.h"#include "mlir/Conversion/LLVMCommon/LowerFunctionDiscardablesToLLVM.h"#include "mlir/Conversion/LLVMCommon/Pattern.h"#include "mlir/Dialect/Func/IR/FuncOps.h"#include "mlir/Dialect/LLVMIR/FunctionCallUtils.h"#include "mlir/Dialect/LLVMIR/LLVMAggregateOps.h"#include "mlir/Dialect/LLVMIR/LLVMCallOps.h"#include "mlir/Dialect/LLVMIR/LLVMConstantOps.h"#include "mlir/Dialect/LLVMIR/LLVMMemoryOps.h"#include "mlir/Dialect/LLVMIR/LLVMModuleOps.h"#include "mlir/Dialect/LLVMIR/LLVMTerminatorOps.h"#include "mlir/Dialect/LLVMIR/LLVMTypes.h"#include "mlir/IR/Attributes.h"#include "mlir/IR/Builders.h"#include "mlir/IR/BuiltinAttributes.h"#include "mlir/IR/BuiltinOps.h"#include "mlir/IR/PatternMatch.h"#include "mlir/IR/SymbolTable.h"#include "mlir/IR/TypeUtilities.h"#include "mlir/Transforms/DialectConversion.h"#include "mlir/Transforms/Passes.h"#include "llvm/ADT/SmallVector.h"#include "llvm/IR/Type.h"#include "llvm/Support/DebugLog.h"#include "llvm/Support/FormatVariadic.h"#include <optional>#include "mlir/Conversion/Passes.h.inc"Go to the source code of this file.
Classes | |
| class | mlir::impl::ConvertFuncToLLVMPassBase< DerivedT > |
| class | mlir::impl::SetLLVMModuleDataLayoutPassBase< DerivedT > |
Namespaces | |
| namespace | mlir |
| Include the generated interface declarations. | |
| namespace | mlir::impl |
| Attribute collections provide a dictionary-like interface. | |
Macros | |
| #define | GEN_PASS_DEF_CONVERTFUNCTOLLVMPASS |
| #define | GEN_PASS_DEF_SETLLVMMODULEDATALAYOUTPASS |
| #define | PASS_NAME "convert-func-to-llvm" |
| #define | DEBUG_TYPE PASS_NAME |
Functions | |
| std::unique_ptr<::mlir::Pass > | mlir::impl::createConvertFuncToLLVMPass () |
| std::unique_ptr<::mlir::Pass > | mlir::impl::createConvertFuncToLLVMPass (ConvertFuncToLLVMPassOptions options) |
| std::unique_ptr<::mlir::Pass > | mlir::createConvertFuncToLLVMPass () |
| std::unique_ptr<::mlir::Pass > | mlir::createConvertFuncToLLVMPass (ConvertFuncToLLVMPassOptions options) |
| std::unique_ptr<::mlir::Pass > | mlir::impl::createSetLLVMModuleDataLayoutPass () |
| std::unique_ptr<::mlir::Pass > | mlir::impl::createSetLLVMModuleDataLayoutPass (SetLLVMModuleDataLayoutPassOptions options) |
| std::unique_ptr<::mlir::Pass > | mlir::createSetLLVMModuleDataLayoutPass () |
| std::unique_ptr<::mlir::Pass > | mlir::createSetLLVMModuleDataLayoutPass (SetLLVMModuleDataLayoutPassOptions options) |
| static bool | shouldUseBarePtrCallConv (Operation *op, const LLVMTypeConverter *typeConverter) |
| Return true if the op should use bare pointer calling convention. | |
| static bool | isDiscardableAttr (StringRef name) |
| static void | filterFuncAttributes (FunctionOpInterface func, SmallVectorImpl< NamedAttribute > &result) |
| Only retain those attributes that are not constructed by LLVMFuncOp::build. | |
| static void | propagateArgResAttrs (OpBuilder &builder, bool resultStructType, FunctionOpInterface funcOp, LLVM::LLVMFuncOp wrapperFuncOp) |
| Propagate argument/results attributes. | |
| static void | wrapForExternalCallers (OpBuilder &rewriter, Location loc, const LLVMTypeConverter &typeConverter, FunctionOpInterface funcOp, LLVM::LLVMFuncOp newFuncOp) |
| Creates an auxiliary function with pointer-to-memref-descriptor-struct arguments instead of unpacked arguments. | |
| static void | wrapExternalFunction (OpBuilder &builder, Location loc, const LLVMTypeConverter &typeConverter, FunctionOpInterface funcOp, LLVM::LLVMFuncOp newFuncOp) |
| Creates an auxiliary function with pointer-to-memref-descriptor-struct arguments instead of unpacked arguments. | |
| static void | restoreByValRefArgumentType (ConversionPatternRewriter &rewriter, const LLVMTypeConverter &typeConverter, ArrayRef< std::optional< NamedAttribute > > byValRefNonPtrAttrs, LLVM::LLVMFuncOp funcOp) |
| Inserts llvm.load ops in the function body to restore the expected pointee value from llvm.byval/llvm.byref function arguments that were converted to LLVM pointer types. | |
| static FailureOr< LLVM::LLVMFunctionType > | convertFuncSignature (FunctionOpInterface funcOp, const LLVMTypeConverter &converter, bool useBarePtrCallConv, TypeConverter::SignatureConversion &result, SmallVectorImpl< std::optional< NamedAttribute > > &byValRefNonPtrAttrs) |
| static LLVM::LLVMFuncOp | createLLVMFuncOp (FunctionOpInterface funcOp, ConversionPatternRewriter &rewriter, LLVM::LLVMFunctionType llvmType, LoweredLLVMFuncAttrs &loweredAttrs, SymbolTableCollection *symbolTables) |
| static SmallVector< NamedAttribute > | convertArgumentAttributes (DictionaryAttr attrsDict, ConversionPatternRewriter &rewriter, const LLVMTypeConverter &converter) |
| static void | propagateFunctionArgResAttrs (FunctionOpInterface funcOp, ConversionPatternRewriter &rewriter, const LLVMTypeConverter &converter, TypeConverter::SignatureConversion &sig, LLVM::LLVMFunctionType llvmType, LLVM::LLVMFuncOp newFuncOp) |
| static void | wrapWithCInterface (FunctionOpInterface funcOp, ConversionPatternRewriter &rewriter, const LLVMTypeConverter &converter, LLVM::LLVMFuncOp newFuncOp) |
Variables | |
| static constexpr StringRef | varargsAttrName = "func.varargs" |
| static constexpr StringRef | linkageAttrName = "llvm.linkage" |
| static constexpr StringRef | barePtrAttrName = "llvm.bareptr" |
| #define DEBUG_TYPE PASS_NAME |
Definition at line 57 of file FuncToLLVM.cpp.
| #define GEN_PASS_DEF_CONVERTFUNCTOLLVMPASS |
Definition at line 49 of file FuncToLLVM.cpp.
| #define GEN_PASS_DEF_SETLLVMMODULEDATALAYOUTPASS |
Definition at line 50 of file FuncToLLVM.cpp.
| #define PASS_NAME "convert-func-to-llvm" |
Definition at line 56 of file FuncToLLVM.cpp.
|
static |
Definition at line 359 of file FuncToLLVM.cpp.
Referenced by propagateFunctionArgResAttrs().
|
static |
Definition at line 303 of file FuncToLLVM.cpp.
References mlir::LLVMTypeConverter::convertFunctionSignature(), result, and varargsAttrName.
Referenced by mlir::convertFuncOpToLLVMFuncOp().
|
static |
Definition at line 318 of file FuncToLLVM.cpp.
References mlir::LoweredLLVMFuncAttrs::discardableAttrs, mlir::Operation::getParentWithTrait(), mlir::SymbolTableCollection::getSymbolTable(), mlir::SymbolTable::insert(), mlir::LoweredLLVMFuncAttrs::properties, and mlir::SymbolTable::remove().
Referenced by mlir::convertFuncOpToLLVMFuncOp().
|
static |
Only retain those attributes that are not constructed by LLVMFuncOp::build.
Definition at line 77 of file FuncToLLVM.cpp.
References isDiscardableAttr(), and result.
Referenced by wrapExternalFunction(), and wrapForExternalCallers().
|
static |
Definition at line 70 of file FuncToLLVM.cpp.
References linkageAttrName, and varargsAttrName.
Referenced by filterFuncAttributes().
|
static |
Propagate argument/results attributes.
Definition at line 88 of file FuncToLLVM.cpp.
References mlir::Builder::getDictionaryAttr().
Referenced by wrapExternalFunction(), and wrapForExternalCallers().
|
static |
Definition at line 391 of file FuncToLLVM.cpp.
References ArrayAttr(), and convertArgumentAttributes().
Referenced by mlir::convertFuncOpToLLVMFuncOp().
|
static |
Inserts llvm.load ops in the function body to restore the expected pointee value from llvm.byval/llvm.byref function arguments that were converted to LLVM pointer types.
Definition at line 274 of file FuncToLLVM.cpp.
Referenced by mlir::convertFuncOpToLLVMFuncOp().
|
static |
Return true if the op should use bare pointer calling convention.
Definition at line 64 of file FuncToLLVM.cpp.
References barePtrAttrName, mlir::LLVMTypeConverter::getOptions(), mlir::Operation::hasDiscardableAttr(), and mlir::LowerToLLVMOptions::useBarePtrCallConv.
Referenced by mlir::convertFuncOpToLLVMFuncOp().
|
static |
Creates an auxiliary function with pointer-to-memref-descriptor-struct arguments instead of unpacked arguments.
Creates a body for the (external) newFuncOp that allocates a memref descriptor on stack, packs the individual arguments into this descriptor and passes a pointer to it into the auxiliary function. If the result of the function cannot be directly returned, we write it to a special first argument that provides a pointer to a corresponding struct. This auxiliary external function is now compatible with functions defined in C using pointers to C structs corresponding to a memref descriptor.
Definition at line 179 of file FuncToLLVM.cpp.
References mlir::LLVMTypeConverter::convertFunctionTypeCWrapper(), filterFuncAttributes(), mlir::Builder::getContext(), mlir::Builder::getIndexType(), mlir::Builder::getIntegerAttr(), mlir::MemRefDescriptor::getNumUnpackedValues(), mlir::UnrankedMemRefDescriptor::getNumUnpackedValues(), mlir::Value::getType(), mlir::MemRefDescriptor::pack(), mlir::UnrankedMemRefDescriptor::pack(), propagateArgResAttrs(), result, and mlir::OpBuilder::setInsertionPointToStart().
Referenced by wrapWithCInterface().
|
static |
Creates an auxiliary function with pointer-to-memref-descriptor-struct arguments instead of unpacked arguments.
This function can be called from C by passing a pointer to a C struct corresponding to a memref descriptor. Similarly, returned memrefs are passed via pointers to a C struct that is passed as additional argument. Internally, the auxiliary function unpacks the descriptor into individual components and forwards them to newFuncOp and forwards the results to the extra arguments.
Definition at line 119 of file FuncToLLVM.cpp.
References mlir::LLVMTypeConverter::convertFunctionTypeCWrapper(), filterFuncAttributes(), propagateArgResAttrs(), mlir::OpBuilder::setInsertionPointToStart(), mlir::MemRefDescriptor::unpack(), and mlir::UnrankedMemRefDescriptor::unpack().
Referenced by wrapWithCInterface().
|
static |
Definition at line 432 of file FuncToLLVM.cpp.
References wrapExternalFunction(), and wrapForExternalCallers().
Referenced by mlir::convertFuncOpToLLVMFuncOp().
|
staticconstexpr |
Definition at line 61 of file FuncToLLVM.cpp.
Referenced by shouldUseBarePtrCallConv().
|
staticconstexpr |
Definition at line 60 of file FuncToLLVM.cpp.
Referenced by isDiscardableAttr().
|
staticconstexpr |
Definition at line 59 of file FuncToLLVM.cpp.
Referenced by convertFuncSignature(), and isDiscardableAttr().