#include "mlir/Conversion/MemRefToLLVM/AllocLikeConversion.h"
#include "mlir/Analysis/DataLayoutAnalysis.h"
#include "mlir/Dialect/LLVMIR/FunctionCallUtils.h"
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
#include "mlir/IR/SymbolTable.h"
usingnamespacemlir;
namespace {
LLVM::LLVMFuncOp getNotalignedAllocFn(const LLVMTypeConverter *typeConverter,
Operation *module, Type indexType) { … }
LLVM::LLVMFuncOp getAlignedAllocFn(const LLVMTypeConverter *typeConverter,
Operation *module, Type indexType) { … }
}
Value AllocationOpLLVMLowering::createAligned(
ConversionPatternRewriter &rewriter, Location loc, Value input,
Value alignment) { … }
static Value castAllocFuncResult(ConversionPatternRewriter &rewriter,
Location loc, Value allocatedPtr,
MemRefType memRefType, Type elementPtrType,
const LLVMTypeConverter &typeConverter) { … }
std::tuple<Value, Value> AllocationOpLLVMLowering::allocateBufferManuallyAlign(
ConversionPatternRewriter &rewriter, Location loc, Value sizeBytes,
Operation *op, Value alignment) const { … }
unsigned AllocationOpLLVMLowering::getMemRefEltSizeInBytes(
MemRefType memRefType, Operation *op,
const DataLayout *defaultLayout) const { … }
bool AllocationOpLLVMLowering::isMemRefSizeMultipleOf(
MemRefType type, uint64_t factor, Operation *op,
const DataLayout *defaultLayout) const { … }
Value AllocationOpLLVMLowering::allocateBufferAutoAlign(
ConversionPatternRewriter &rewriter, Location loc, Value sizeBytes,
Operation *op, const DataLayout *defaultLayout, int64_t alignment) const { … }
void AllocLikeOpLLVMLowering::setRequiresNumElements() { … }
LogicalResult AllocLikeOpLLVMLowering::matchAndRewrite(
Operation *op, ArrayRef<Value> operands,
ConversionPatternRewriter &rewriter) const { … }