MLIR
17.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/FuncToLLVM/ConvertFuncToLLVM.h"
#include "mlir/Conversion/LLVMCommon/ConversionTarget.h"
#include "mlir/Conversion/LLVMCommon/Pattern.h"
#include "mlir/Conversion/LLVMCommon/VectorPattern.h"
#include "mlir/Dialect/Func/IR/FuncOps.h"
#include "mlir/Dialect/LLVMIR/FunctionCallUtils.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/Dialect/LLVMIR/LLVMTypes.h"
#include "mlir/Dialect/Utils/StaticValueUtils.h"
#include "mlir/IR/Attributes.h"
#include "mlir/IR/Builders.h"
#include "mlir/IR/BuiltinAttributeInterfaces.h"
#include "mlir/IR/BuiltinAttributes.h"
#include "mlir/IR/BuiltinOps.h"
#include "mlir/IR/IRMapping.h"
#include "mlir/IR/PatternMatch.h"
#include "mlir/IR/TypeUtilities.h"
#include "mlir/Support/LogicalResult.h"
#include "mlir/Support/MathExtras.h"
#include "mlir/Transforms/DialectConversion.h"
#include "mlir/Transforms/Passes.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/TypeSwitch.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Type.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FormatVariadic.h"
#include <algorithm>
#include <functional>
#include "mlir/Conversion/Passes.h.inc"
Go to the source code of this file.
Namespaces | |
mlir | |
This header declares functions that assit transformations in the MemRef dialect. | |
Macros | |
#define | GEN_PASS_DEF_CONVERTFUNCTOLLVMPASS |
#define | PASS_NAME "convert-func-to-llvm" |
Functions | |
static void | filterFuncAttributes (func::FuncOp func, bool filterArgAndResAttrs, SmallVectorImpl< NamedAttribute > &result) |
Only retain those attributes that are not constructed by LLVMFuncOp::build . More... | |
static void | prependEmptyArgAttr (OpBuilder &builder, SmallVectorImpl< NamedAttribute > &newFuncAttrs, func::FuncOp func) |
Adds a an empty set of argument attributes for the newly added argument in front of the existing ones. More... | |
static void | wrapForExternalCallers (OpBuilder &rewriter, Location loc, LLVMTypeConverter &typeConverter, func::FuncOp funcOp, LLVM::LLVMFuncOp newFuncOp) |
Creates an auxiliary function with pointer-to-memref-descriptor-struct arguments instead of unpacked arguments. More... | |
static void | wrapExternalFunction (OpBuilder &builder, Location loc, LLVMTypeConverter &typeConverter, func::FuncOp funcOp, LLVM::LLVMFuncOp newFuncOp) |
Creates an auxiliary function with pointer-to-memref-descriptor-struct arguments instead of unpacked arguments. More... | |
Variables | |
static constexpr StringRef | varargsAttrName = "func.varargs" |
static constexpr StringRef | linkageAttrName = "llvm.linkage" |
#define GEN_PASS_DEF_CONVERTFUNCTOLLVMPASS |
Definition at line 51 of file FuncToLLVM.cpp.
#define PASS_NAME "convert-func-to-llvm" |
Definition at line 57 of file FuncToLLVM.cpp.
|
static |
Only retain those attributes that are not constructed by LLVMFuncOp::build
.
If filterArgAttrs
is set, also filter out argument attributes.
Definition at line 65 of file FuncToLLVM.cpp.
References mlir::SymbolTable::getSymbolAttrName(), linkageAttrName, and varargsAttrName.
Referenced by wrapExternalFunction(), and wrapForExternalCallers().
|
static |
Adds a an empty set of argument attributes for the newly added argument in front of the existing ones.
Definition at line 83 of file FuncToLLVM.cpp.
References mlir::Builder::getArrayAttr(), mlir::Builder::getDictionaryAttr(), and mlir::Builder::getNamedAttr().
Referenced by wrapExternalFunction(), and wrapForExternalCallers().
|
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 175 of file FuncToLLVM.cpp.
References mlir::Type::cast(), mlir::LLVMTypeConverter::convertFunctionTypeCWrapper(), mlir::LLVMTypeConverter::convertType(), mlir::OpBuilder::create(), mlir::Value::dyn_cast(), filterFuncAttributes(), mlir::Builder::getIndexType(), mlir::Builder::getIntegerAttr(), mlir::UnrankedMemRefDescriptor::getNumUnpackedValues(), mlir::MemRefDescriptor::getNumUnpackedValues(), mlir::LLVMTypeConverter::getPointerType(), mlir::Value::getType(), mlir::MemRefDescriptor::pack(), mlir::UnrankedMemRefDescriptor::pack(), prependEmptyArgAttr(), and mlir::OpBuilder::setInsertionPointToStart().
|
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 111 of file FuncToLLVM.cpp.
References mlir::LLVMTypeConverter::convertFunctionTypeCWrapper(), mlir::LLVMTypeConverter::convertType(), mlir::OpBuilder::create(), mlir::detail::enumerate(), filterFuncAttributes(), prependEmptyArgAttr(), mlir::OpBuilder::setInsertionPointToStart(), mlir::MemRefDescriptor::unpack(), and mlir::UnrankedMemRefDescriptor::unpack().
|
staticconstexpr |
Definition at line 60 of file FuncToLLVM.cpp.
Referenced by filterFuncAttributes().
|
staticconstexpr |
Definition at line 59 of file FuncToLLVM.cpp.
Referenced by filterFuncAttributes().