#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/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/SymbolTable.h"
#include "mlir/IR/TypeUtilities.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/Casting.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/FormatVariadic.h"
#include <algorithm>
#include <functional>
#include <optional>
namespace mlir {
#define GEN_PASS_DEF_CONVERTFUNCTOLLVMPASS
#define GEN_PASS_DEF_SETLLVMMODULEDATALAYOUTPASS
#include "mlir/Conversion/Passes.h.inc"
}
usingnamespacemlir;
#define PASS_NAME …
static constexpr StringRef varargsAttrName = …;
static constexpr StringRef linkageAttrName = …;
static constexpr StringRef barePtrAttrName = …;
static bool shouldUseBarePtrCallConv(Operation *op,
const LLVMTypeConverter *typeConverter) { … }
static void filterFuncAttributes(FunctionOpInterface func,
SmallVectorImpl<NamedAttribute> &result) { … }
static void propagateArgResAttrs(OpBuilder &builder, bool resultStructType,
FunctionOpInterface funcOp,
LLVM::LLVMFuncOp wrapperFuncOp) { … }
static void wrapForExternalCallers(OpBuilder &rewriter, Location loc,
const LLVMTypeConverter &typeConverter,
FunctionOpInterface funcOp,
LLVM::LLVMFuncOp newFuncOp) { … }
static void wrapExternalFunction(OpBuilder &builder, Location loc,
const LLVMTypeConverter &typeConverter,
FunctionOpInterface funcOp,
LLVM::LLVMFuncOp newFuncOp) { … }
static void restoreByValRefArgumentType(
ConversionPatternRewriter &rewriter, const LLVMTypeConverter &typeConverter,
ArrayRef<std::optional<NamedAttribute>> byValRefNonPtrAttrs,
LLVM::LLVMFuncOp funcOp) { … }
FailureOr<LLVM::LLVMFuncOp>
mlir::convertFuncOpToLLVMFuncOp(FunctionOpInterface funcOp,
ConversionPatternRewriter &rewriter,
const LLVMTypeConverter &converter) { … }
namespace {
struct FuncOpConversion : public ConvertOpToLLVMPattern<func::FuncOp> { … };
struct ConstantOpLowering : public ConvertOpToLLVMPattern<func::ConstantOp> { … };
template <typename CallOpType>
struct CallOpInterfaceLowering : public ConvertOpToLLVMPattern<CallOpType> { … };
class CallOpLowering : public CallOpInterfaceLowering<func::CallOp> { … };
struct CallIndirectOpLowering
: public CallOpInterfaceLowering<func::CallIndirectOp> { … };
struct UnrealizedConversionCastOpLowering
: public ConvertOpToLLVMPattern<UnrealizedConversionCastOp> { … };
struct ReturnOpLowering : public ConvertOpToLLVMPattern<func::ReturnOp> { … };
}
void mlir::populateFuncToLLVMFuncOpConversionPattern(
const LLVMTypeConverter &converter, RewritePatternSet &patterns) { … }
void mlir::populateFuncToLLVMConversionPatterns(
const LLVMTypeConverter &converter, RewritePatternSet &patterns,
const SymbolTable *symbolTable) { … }
namespace {
struct ConvertFuncToLLVMPass
: public impl::ConvertFuncToLLVMPassBase<ConvertFuncToLLVMPass> { … };
struct SetLLVMModuleDataLayoutPass
: public impl::SetLLVMModuleDataLayoutPassBase<
SetLLVMModuleDataLayoutPass> { … };
}
namespace {
struct FuncToLLVMDialectInterface : public ConvertToLLVMPatternInterface { … };
}
void mlir::registerConvertFuncToLLVMInterface(DialectRegistry ®istry) { … }